feat: Migrate Task Master to generateObject for structured AI responses (#1262)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Ben Vargas <ben@example.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { jest } from '@jest/globals';
|
||||
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;
|
||||
@@ -74,30 +75,25 @@ describe('expand-task prompt template', () => {
|
||||
expect(userPrompt).toContain(`Current details: ${testTask.details}`);
|
||||
|
||||
// Also includes the expansion prompt
|
||||
expect(userPrompt).toContain('Expansion Guidance:');
|
||||
expect(userPrompt).toContain(params.expansionPrompt);
|
||||
expect(userPrompt).toContain(params.complexityReasoningContext);
|
||||
});
|
||||
|
||||
test('all variants request JSON format with subtasks array', () => {
|
||||
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;
|
||||
|
||||
expect(combined.toLowerCase()).toContain('subtasks');
|
||||
expect(combined).toContain('JSON');
|
||||
});
|
||||
// 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', () => {
|
||||
|
||||
Reference in New Issue
Block a user