tests/pipeline.test.js (1933 bytes)
1 import assert from 'node:assert/strict'; 2 import fs from 'node:fs'; 3 import { test } from 'node:test'; 4 import { buildPrompt, pipelinePrompt, progressInstructions } from '../src/claude.js'; 5 6 const idea = { id: 12, title: 'Sync subtitles', text: 'sync subtitles with the audiobook', triage: { brief: 'Align the text with the audio track.' } }; 7 8 test('the pipeline request names the idea, its project, and its id, so the pipeline can report on it', () => { 9 const prompt = pipelinePrompt(idea, { dir: '/work/app' }); 10 assert.equal(prompt, [ 11 '/pipeline Build idea #12 from my ideamine archive: Sync subtitles', 12 'Align the text with the audio track.', 13 'My original note: sync subtitles with the audiobook', 14 'Project: /work/app', 15 '', 16 ...progressInstructions(12), 17 ].join('\n')); 18 assert.match(prompt, /ideamine note 12 "pipeline: <phase>"/); 19 assert.match(prompt, /ideamine done 12 /); 20 assert.match(pipelinePrompt({ ...idea, triage: null }, { dir: '/x' }), /^\/pipeline Build idea #12[^]*\nMy original note: /); 21 assert.doesNotMatch(buildPrompt(idea), /^\/pipeline/); // /ideas-go keeps its one-agent prompt 22 }); 23 24 test('the pipeline ships with its seven agents, and the skill names each of them', () => { 25 const root = new URL('../', import.meta.url); 26 const files = fs.readdirSync(new URL('agents/', root)).filter((f) => f.endsWith('.md')).sort(); 27 assert.deepEqual(files, ['e2e-tester.md', 'engineer.md', 'integrator.md', 'project-manager.md', 'researcher.md', 'story-writer.md', 'validator.md']); 28 const skill = fs.readFileSync(new URL('skills/pipeline/SKILL.md', root), 'utf8'); 29 for (const file of files) { 30 const name = file.slice(0, -3); 31 const text = fs.readFileSync(new URL(`agents/${file}`, root), 'utf8'); 32 assert.match(text, new RegExp(`^name: ${name}$`, 'm'), `${file} names itself`); 33 assert.match(skill, new RegExp(`\\b${name}\\b`), `the pipeline skill names ${name}`); 34 } 35 });