feat: Centralize AI prompts into JSON templates (#882)
* centralize prompt management * add changeset * add variant key to determine prompt version * update tests and add prompt manager test * determine internal path, don't use projectRoot * add promptManager mock * detailed prompt docs * add schemas and validator packages * add validate prompts command * add schema validation * update tests * move schemas to src/prompts/schemas * use this.promptsDir for better semantics * add prompt schemas * version schema files & update links * remove validate command * expect dependencies * update docs * fix test * remove suggestmode to ensure clean keys * remove default variant from research and update schema * now handled by prompt manager * add manual test to verify prompts * remove incorrect batch variant * consolidate variants * consolidate analyze-complexity to just default variant * consolidate parse-prd variants * add eq handler for handlebars * consolidate research prompt variants * use brevity * consolidate variants for update subtask * add not handler * consolidate variants for update-task * consolidate update-tasks variants * add conditional content to prompt when research used * update prompt tests * show correct research variant * make variant names link to below * remove changset * restore gitignore * Merge branch 'next' of https://github.com/eyaltoledano/claude-task-master into joedanz/centralize-prompts # Conflicts: # package-lock.json # scripts/modules/task-manager/expand-task.js # scripts/modules/task-manager/parse-prd.js remove unused * add else * update tests * update biome optional dependencies * responsive html output for mobile
This commit is contained in:
@@ -2,12 +2,27 @@ import { jest } from '@jest/globals';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
// Mock the schema integration functions to avoid chalk issues
|
||||
const mockSetupSchemaIntegration = jest.fn();
|
||||
|
||||
import { vscodeProfile } from '../../../src/profiles/vscode.js';
|
||||
|
||||
// Mock external modules
|
||||
jest.mock('child_process', () => ({
|
||||
execSync: jest.fn()
|
||||
}));
|
||||
|
||||
// Mock fs/promises
|
||||
const mockFsPromises = {
|
||||
mkdir: jest.fn(),
|
||||
access: jest.fn(),
|
||||
copyFile: jest.fn(),
|
||||
readFile: jest.fn(),
|
||||
writeFile: jest.fn()
|
||||
};
|
||||
|
||||
jest.mock('fs/promises', () => mockFsPromises);
|
||||
|
||||
// Mock console methods
|
||||
jest.mock('console', () => ({
|
||||
log: jest.fn(),
|
||||
@@ -288,4 +303,41 @@ Task Master specific VS Code instruction.`;
|
||||
expect(content).toContain('alwaysApply:');
|
||||
expect(content).toContain('**/*.ts'); // File patterns in quotes
|
||||
});
|
||||
|
||||
describe('Schema Integration', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
// Replace the onAddRulesProfile function with our mock
|
||||
vscodeProfile.onAddRulesProfile = mockSetupSchemaIntegration;
|
||||
});
|
||||
|
||||
test('setupSchemaIntegration is called with project root', async () => {
|
||||
// Arrange
|
||||
mockSetupSchemaIntegration.mockResolvedValue();
|
||||
|
||||
// Act
|
||||
await vscodeProfile.onAddRulesProfile(tempDir);
|
||||
|
||||
// Assert
|
||||
expect(mockSetupSchemaIntegration).toHaveBeenCalledWith(tempDir);
|
||||
});
|
||||
|
||||
test('schema integration function exists and is callable', () => {
|
||||
// Assert that the VS Code profile has the schema integration function
|
||||
expect(vscodeProfile.onAddRulesProfile).toBeDefined();
|
||||
expect(typeof vscodeProfile.onAddRulesProfile).toBe('function');
|
||||
});
|
||||
|
||||
test('schema integration handles errors gracefully', async () => {
|
||||
// Arrange
|
||||
mockSetupSchemaIntegration.mockRejectedValue(
|
||||
new Error('Schema setup failed')
|
||||
);
|
||||
|
||||
// Act & Assert - Should propagate the error
|
||||
await expect(vscodeProfile.onAddRulesProfile(tempDir)).rejects.toThrow(
|
||||
'Schema setup failed'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user