/** * Post-planning kickoff: plan is ready — implement (no full draft paste). */ import type { PlannerMode, PlannerReason } from "./run-planner.ts"; export function buildExecuteKickoffPrompt(input: { objective: string; planPath: string; evidencePath: string; plannerMode: PlannerMode; /** Why planning used this mode (B026 — never claim "unavailable" on timeout). */ plannerReason?: PlannerReason; }): string { const modeNote = describePlannerKickoffMode(input.plannerMode, input.plannerReason); return [ "# Goal — execute", "", `**Objective:** ${input.objective}`, `**Plan (source of truth):** \`${input.planPath}\``, `**Evidence index:** \`${input.evidencePath}\``, "", modeNote, "", "## Do this now", `1. Read \`${input.planPath}\` fully.`, "2. If the plan is still a weak skeleton, expand it in place (outcome-based criteria, verification plan, task checklist) using codebase research — then continue.", "3. Implement against the plan. Flip task-checklist `- [ ]` → `- [x]` as you go.", `4. Maintain \`${input.evidencePath}\` (criterion → artifact paths).`, "5. **Required progress milestones** — call `update_goal({ message })` at least for: `researched`, `implementing`, `pre-complete` (optional mid-checklist notes too). Use `update_goal({ completed: true })` only when verification observations hold.", "6. `update_goal({ blocked_reason })` only after genuine stuckness.", "", "Goal state lives under `.pi/goal/` (session cwd / `PI_GOAL_ROOT` / `PI_GOAL_CWD`);", "the objective may require edits **outside** that directory — edit scope follows the objective, not the goal store.", "Read and rewrite the plan file on disk; do not paste the full draft back into the transcript.", "No test theater. Do not wait for the user to restate the goal.", ].join("\n"); } /** Human-readable kickoff note; timeout never reaches kickoff (fail-CLOSED). */ export function describePlannerKickoffMode( mode: PlannerMode, reason?: PlannerReason, ): string { if (mode === "subagent") { return "A planner subagent researched the codebase and wrote the plan file."; } switch (reason) { case "ping_failed": return "A structural draft plan was written (pi-subagents ping failed). Review and tighten the plan before heavy implementation if needed."; case "no_bus": return "A structural draft plan was written (no event bus / pi.events). Review and tighten the plan before heavy implementation if needed."; case "agent_failed": return "A structural draft plan was written (planner subagent failed). Review and tighten the plan before heavy implementation if needed."; case "spawn_error": return "A structural draft plan was written (planner spawn error). Review and tighten the plan before heavy implementation if needed."; case "wait_timeout": // Should not appear on execute kickoff (planning fails closed); keep honest copy. return "Planning timed out waiting for the planner subagent. Resume after /goal resume only if a usable plan exists on disk; do not treat a skeleton as final criteria."; case "structural_fallback": case "ok": default: return "A structural draft plan was written (pi-subagents unavailable). Review and tighten the plan before heavy implementation if needed."; } }