#!/usr/bin/env node import { existsSync } from 'node:fs'; import { readFile, writeFile } from 'node:fs/promises'; async function read(path: string): Promise { return await readFile(path, 'utf-8'); } function replaceBetween(text: string, startMarker: string, endMarker: string, replacement: string): string { const start = text.indexOf(startMarker); const end = text.indexOf(endMarker, start + startMarker.length); if (start === -1 || end === -1) throw new Error(`Markers not found: ${startMarker} .. ${endMarker}`); return text.slice(0, start + startMarker.length) + '\n' + replacement.trimEnd() + '\n' + text.slice(end); } async function main(): Promise { const op = (await read('docs/prompt-guidance-fragments/core-operating-principles.md')).trim(); const sr = (await read('docs/prompt-guidance-fragments/leader-specialist-routing.md')).trim(); const vs = (await read('docs/prompt-guidance-fragments/core-verification-and-sequencing.md')).trim(); const exC = (await read('docs/prompt-guidance-fragments/executor-constraints.md')).trim(); const exO = (await read('docs/prompt-guidance-fragments/executor-output.md')).trim(); const plC = (await read('docs/prompt-guidance-fragments/planner-constraints.md')).trim(); const plI = (await read('docs/prompt-guidance-fragments/planner-investigation.md')).trim(); const plO = (await read('docs/prompt-guidance-fragments/planner-output.md')).trim(); const vfC = (await read('docs/prompt-guidance-fragments/verifier-constraints.md')).trim(); const vfI = (await read('docs/prompt-guidance-fragments/verifier-investigation.md')).trim(); for (const file of ['AGENTS.md', 'templates/AGENTS.md']) { if (!existsSync(file)) continue; let text = await read(file); text = replaceBetween(text, '', '', op); text = replaceBetween(text, '', '', sr); text = replaceBetween(text, '', '', vs); await writeFile(file, text); } let text = await read('prompts/executor.md'); text = replaceBetween(text, '', '', exC); text = replaceBetween(text, '', '', exO); await writeFile('prompts/executor.md', text); text = await read('prompts/planner.md'); text = replaceBetween(text, '', '', plC); text = replaceBetween(text, '', '', plI); text = replaceBetween(text, '', '', plO); await writeFile('prompts/planner.md', text); text = await read('prompts/verifier.md'); text = replaceBetween(text, '', '', vfC); text = replaceBetween(text, '', '', vfI); await writeFile('prompts/verifier.md', text); } main().catch((err) => { console.error(err instanceof Error ? err.message : String(err)); process.exit(1); });