chore: apply requested changes

This commit is contained in:
Ralph Khreish
2025-10-02 15:09:18 +02:00
parent 1d197fe9c2
commit f68330efb3
12 changed files with 148 additions and 61 deletions

View File

@@ -1,4 +1,6 @@
import { PromptManager } from '../../../scripts/modules/prompt-manager.js';
import { ExpandTaskResponseSchema } from '../../../src/schemas/expand-task.js';
import { SubtaskSchema } from '../../../src/schemas/base-schemas.js';
describe('expand-task prompt template', () => {
let promptManager;
@@ -77,29 +79,21 @@ describe('expand-task prompt template', () => {
expect(userPrompt).toContain(params.complexityReasoningContext);
});
test('all variants request structured subtasks with required fields', () => {
const variants = ['default', 'research', 'complexity-report'];
test('ExpandTaskResponseSchema defines required subtask fields', () => {
// Test the schema definition directly instead of weak substring matching
const schema = ExpandTaskResponseSchema;
const subtasksSchema = schema.shape.subtasks;
const subtaskSchema = subtasksSchema.element;
variants.forEach((variant) => {
const params =
variant === 'complexity-report'
? { ...baseParams, expansionPrompt: 'test' }
: baseParams;
const { systemPrompt, userPrompt } = promptManager.loadPrompt(
'expand-task',
params,
variant
);
const combined = systemPrompt + userPrompt;
// Verify prompts describe the structured output format
expect(combined.toLowerCase()).toContain('subtasks');
expect(combined).toContain('id');
expect(combined).toContain('title');
expect(combined).toContain('description');
expect(combined).toContain('dependencies');
});
// Verify the schema has the required fields
expect(subtaskSchema).toBe(SubtaskSchema);
expect(SubtaskSchema.shape).toHaveProperty('id');
expect(SubtaskSchema.shape).toHaveProperty('title');
expect(SubtaskSchema.shape).toHaveProperty('description');
expect(SubtaskSchema.shape).toHaveProperty('dependencies');
expect(SubtaskSchema.shape).toHaveProperty('details');
expect(SubtaskSchema.shape).toHaveProperty('status');
expect(SubtaskSchema.shape).toHaveProperty('testStrategy');
});
test('complexity-report variant fails without task context regression test', () => {

View File

@@ -15,9 +15,10 @@ describe('Prompt Migration Validation', () => {
'code block markers'
];
// Special cases where phrases are okay in different contexts
// Map banned phrases to contexts where they're allowed
const allowedContexts = {
'markdown formatting': ['Use markdown formatting for better readability']
'respond only with': ['Use markdown formatting for better readability'],
'return only the': ['Use markdown formatting for better readability']
};
test('prompts should not contain JSON formatting instructions', () => {
@@ -29,7 +30,6 @@ describe('Prompt Migration Validation', () => {
promptFiles.forEach((file) => {
const content = fs.readFileSync(path.join(promptsDir, file), 'utf8');
const promptData = JSON.parse(content);
bannedPhrases.forEach((phrase) => {
const lowerContent = content.toLowerCase();