export interface ContinuationInput { objective: string; planPath: string; gaps: string[]; nextStep: string | null; strategyNote?: string; verifyRound?: number; } /** * Build a follow-up directive the harness injects after a NotAchieved verify. */ export function buildContinuationDirective(input: ContinuationInput): string { const lines: string[] = [ "# Goal continuation", "", `Continue pursuing the goal. Do not claim completion until the harness verifies.`, "", `**Objective:** ${input.objective.trim()}`, `**Plan:** \`${input.planPath}\``, ]; if (input.verifyRound !== undefined) { lines.push(`**Verify round:** ${input.verifyRound}`); } lines.push(""); lines.push("## Unmet gaps"); if (input.gaps.length === 0) { lines.push("- (no specific gaps recorded — re-check acceptance criteria and evidence)"); } else { for (const g of input.gaps) { lines.push(`- ${g}`); } } lines.push(""); lines.push("## Next step"); if (input.nextStep) { lines.push(`Focus on: ${input.nextStep}`); } else { lines.push( "No unchecked task-checklist item found — pick the highest-impact remaining criterion.", ); } if (input.strategyNote?.trim()) { lines.push(""); lines.push("## Strategy note"); lines.push(input.strategyNote.trim()); } lines.push(""); lines.push("## Standing orders"); lines.push("- Work from the frozen plan contract (acceptance criteria + verification plan)."); lines.push("- Update the evidence index when you produce proof artifacts."); lines.push("- Call `update_goal(message)` for progress at milestones (`researched` / `implementing` / `pre-complete`); `update_goal(completed: true)` only when done."); lines.push("- Do not weaken plan.baseline.md acceptance criteria."); lines.push(""); return lines.join("\n"); }