Move src/ → apps/server/ and packages/web/ → apps/web/ to adopt standard monorepo conventions (apps/ for runnable apps, packages/ for reusable libraries). Update all config files, shared package imports, test fixtures, and documentation to reflect new paths. Key fixes: - Update workspace config to ["apps/*", "packages/*"] - Update tsconfig.json rootDir/include for apps/server/ - Add apps/web/** to vitest exclude list - Update drizzle.config.ts schema path - Fix ensure-schema.ts migration path detection (3 levels up in dev, 2 levels up in dist) - Fix tests/integration/cli-server.test.ts import paths - Update packages/shared imports to apps/server/ paths - Update all docs/ files with new paths
59 lines
2.4 KiB
TypeScript
59 lines
2.4 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { MISSING_SIGNAL_INSTRUCTION, addInstructionToPrompt } from './instructions.js';
|
|
|
|
describe('instructions', () => {
|
|
describe('MISSING_SIGNAL_INSTRUCTION', () => {
|
|
it('should contain key guidance about signal.json creation', () => {
|
|
expect(MISSING_SIGNAL_INSTRUCTION).toContain('signal.json');
|
|
expect(MISSING_SIGNAL_INSTRUCTION).toContain('.cw/output/signal.json');
|
|
expect(MISSING_SIGNAL_INSTRUCTION).toContain('"status": "done"');
|
|
expect(MISSING_SIGNAL_INSTRUCTION).toContain('"status": "questions"');
|
|
expect(MISSING_SIGNAL_INSTRUCTION).toContain('"status": "error"');
|
|
});
|
|
|
|
it('should be a clear instruction for missing signal recovery', () => {
|
|
expect(MISSING_SIGNAL_INSTRUCTION).toContain('IMPORTANT');
|
|
expect(MISSING_SIGNAL_INSTRUCTION).toContain('previous execution completed');
|
|
expect(MISSING_SIGNAL_INSTRUCTION).toContain('did not generate');
|
|
});
|
|
});
|
|
|
|
describe('addInstructionToPrompt', () => {
|
|
it('should add instruction to the beginning of the prompt', () => {
|
|
const originalPrompt = 'Please help me with this task';
|
|
const instruction = 'First, create a file called test.txt';
|
|
|
|
const result = addInstructionToPrompt(originalPrompt, instruction);
|
|
|
|
expect(result).toBe(`First, create a file called test.txt\n\nPlease help me with this task`);
|
|
});
|
|
|
|
it('should trim the instruction', () => {
|
|
const originalPrompt = 'Please help me';
|
|
const instruction = ' Important: Do this first ';
|
|
|
|
const result = addInstructionToPrompt(originalPrompt, instruction);
|
|
|
|
expect(result).toBe(`Important: Do this first\n\nPlease help me`);
|
|
});
|
|
|
|
it('should handle empty original prompt', () => {
|
|
const originalPrompt = '';
|
|
const instruction = 'Create a signal.json file';
|
|
|
|
const result = addInstructionToPrompt(originalPrompt, instruction);
|
|
|
|
expect(result).toBe(`Create a signal.json file\n\n`);
|
|
});
|
|
|
|
it('should handle missing signal instruction with real prompt', () => {
|
|
const originalPrompt = 'Fix the bug in the authentication system';
|
|
|
|
const result = addInstructionToPrompt(originalPrompt, MISSING_SIGNAL_INSTRUCTION);
|
|
|
|
expect(result).toContain('IMPORTANT: Your previous execution completed');
|
|
expect(result).toContain('Fix the bug in the authentication system');
|
|
expect(result.indexOf('IMPORTANT')).toBeLessThan(result.indexOf('Fix the bug'));
|
|
});
|
|
});
|
|
}); |