import type { MpcPhase } from "./utils.js"; export function phaseLabel(phase: MpcPhase): string { const labels: Record = { idle: "off", explore: "explore", dryrun: "dry-run", issues: "issues", backtrack: "backtrack", verified: "verified", execute: "execute", }; return labels[phase]; } export function buildPhasePrompt(phase: MpcPhase): string { switch (phase) { case "explore": return `[MPC MODE - PHASE 1: EXPLORATION] Goal: Understand the codebase relevant to this task. Do NOT make any changes. - Read files, grep for patterns, understand the structure - Identify all files that will need to change - Note dependencies, interfaces, test files - End your response with exactly: "EXPLORATION COMPLETE: [one-sentence summary of what you found]"`; case "dryrun": return `[MPC MODE - PHASE 2: DRY RUN] You have explored the codebase. Now mentally execute the task without actually doing it. - Describe each edit you would make, step by step - For each step, predict: what does the file look like after this change? - Trace through call sites, imports, type signatures - End your response with exactly: "DRY RUN COMPLETE: [numbered list of steps]"`; case "issues": return `[MPC MODE - PHASE 3: ISSUE DETECTION] Review your dry run. Actively look for problems: - Type errors that would result from your changes - Broken imports or missing exports - Tests that would fail - Edge cases or missing error handling - Incorrect assumptions about the codebase List each issue as: "ISSUE N: [description] → [impact]" If there are no problems, end with exactly: "NO ISSUES FOUND"`; case "backtrack": return `[MPC MODE - PHASE 4: BACKTRACK] Issues were found in Phase 3. Revise your plan: - Address each issue identified - Adjust the step sequence if needed - Re-verify your assumptions End your response with exactly: "REVISED PLAN: [updated numbered steps]"`; case "verified": return `[MPC MODE - PHASE 5: VERIFIED PLAN] Present the final verified plan in this format: ## Verified Plan ### Summary [One paragraph: what this does and why] ### Assumptions Verified - [assumption]: [how you verified it] ### Steps 1. **[File/Action]**: [what and why] 2. ... ### Potential Risks - [any remaining unknowns or caveats] ### Confidence [HIGH/MEDIUM/LOW]: [reason]`; case "execute": return `[MPC MODE - EXECUTING PLAN] Execute the verified plan exactly as described. Follow the steps in order.`; default: return ""; } }