fix(sdk): pass phaseDir to executor prompt so SUMMARY.md lands in .planning/

The SDK's buildExecutorPrompt told executors to "Create a SUMMARY.md file"
with no directory path, causing them to write it in cwd (project root)
instead of .planning/phases/{phase}/. Thread phaseDir from PhaseRunner
through PromptFactory and into the completion instructions so the executor
gets an explicit path like `.planning/phases/01-auth/01-01-SUMMARY.md`.

Backward compatible — buildExecutorPrompt still accepts a plain string
(agentDef) for existing callers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson
2026-04-25 14:43:00 -06:00
parent 470c1a0bff
commit 2fafbd2753
6 changed files with 48 additions and 8 deletions

View File

@@ -156,11 +156,23 @@ describe('buildExecutorPrompt', () => {
expect(prompt).toContain('Refresh tokens rotate correctly');
});
it('includes SUMMARY.md creation instruction', () => {
it('includes SUMMARY.md creation instruction with derived filename', () => {
const plan = makePlan();
const prompt = buildExecutorPrompt(plan);
expect(prompt).toContain('01-01-SUMMARY.md');
});
it('includes phaseDir in SUMMARY path when provided', () => {
const plan = makePlan();
const prompt = buildExecutorPrompt(plan, { phaseDir: '.planning/phases/01-auth' });
expect(prompt).toContain('.planning/phases/01-auth/01-01-SUMMARY.md');
});
it('uses bare SUMMARY.md when phase/plan numbers missing', () => {
const plan = makePlan({ frontmatter: { phase: '', plan: '', type: 'execute', wave: 1, depends_on: [], files_modified: [], autonomous: true, requirements: [], must_haves: { truths: [], artifacts: [], key_links: [] } } });
const prompt = buildExecutorPrompt(plan);
expect(prompt).toContain('SUMMARY.md');
expect(prompt).toContain('Create a SUMMARY.md file');
expect(prompt).not.toContain('/SUMMARY.md');
});
it('includes sequential execution instruction', () => {