{"version":3,"file":"prompts-Dere4Q0Z.cjs","names":[],"sources":["../src/services/prompts/index.ts"],"sourcesContent":["export type PlanningFlavor = 'normal' | 'debug' | 'fable';\n\nexport interface DebugEvidencePacket {\n  issue: string;\n  expectedBehavior: string;\n  reproductionAttempt: string;\n  actualBehavior: string;\n  logs: string[];\n  correlatedTraceEvidence: string[];\n  processOutput: string[];\n  browserConsoleEvidence: string[];\n  correlationIds: string[];\n  timestamps: string[];\n  verifiedFacts: string[];\n  hypotheses: string[];\n  unavailableEvidence: string[];\n}\n\nconst EVIDENCE_FIELDS: readonly (keyof DebugEvidencePacket)[] = [\n  'issue',\n  'expectedBehavior',\n  'reproductionAttempt',\n  'actualBehavior',\n  'logs',\n  'correlatedTraceEvidence',\n  'processOutput',\n  'browserConsoleEvidence',\n  'correlationIds',\n  'timestamps',\n  'verifiedFacts',\n  'hypotheses',\n  'unavailableEvidence',\n];\n\nfunction evidenceLines(packet: DebugEvidencePacket): string {\n  return EVIDENCE_FIELDS.flatMap((field) => {\n    const value = packet[field];\n    if (Array.isArray(value) && value.length === 0) return [];\n    if (typeof value === 'string' && value.length === 0) return [];\n    return `${field}: ${Array.isArray(value) ? value.join(' | ') : value}`;\n  }).join('\\n');\n}\n\n/**\n * What a host's plan tooling can actually do, declared as capabilities rather than as a host\n * name. The prompt must instruct only what the host's tool surface accepts: the server's\n * complete_plan takes no parameters, so telling that model to pass a decision asks for an\n * argument its provider schema rejects. A `cli | server` flag would encode identity and invite\n * the next divergence to hide behind it.\n */\nexport interface PlanHostCapabilities {\n  /** The host's complete_plan accepts a `decision` argument. */\n  readonly completePlanTakesDecision: boolean;\n  /** The host can narrate the plan review under autonomous voice. */\n  readonly narratesReview: boolean;\n  /** The host has a Fable broker. */\n  readonly fableAvailable: boolean;\n}\n\n/** The review protocol sentences that exist only because a host's tools support them. */\nfunction reviewProtocolLines(capabilities: PlanHostCapabilities): string[] {\n  return [\n    ...(capabilities.completePlanTakesDecision\n      ? [\n          'In an interactive text session, call complete_plan without a decision and it opens the exit-or-continue selector.',\n        ]\n      : []),\n    ...(capabilities.narratesReview\n      ? [\n          'Under autonomous voice, complete_plan displays and narrates the choices without opening a blocking dialog, then ends the turn.',\n        ]\n      : []),\n    ...(capabilities.completePlanTakesDecision\n      ? ['Interpret the user\\'s next ordinary message and call complete_plan again with decision \"exit\" or \"continue\".']\n      : []),\n  ];\n}\n\n/**\n * The host-independent plan mode block, pushed ahead of the flavor block.\n *\n * Both the Pi extension and the server facet append this. It lives here so the cockpit and the\n * terminal cannot drift into giving the agent different instructions for the same mode. The two\n * facets may differ only through {@link PlanHostCapabilities}, so every other sentence is shared\n * by construction.\n */\nexport function buildPlanModeBasePrompt(plansDirectory: string, capabilities: PlanHostCapabilities): string {\n  const review = reviewProtocolLines(capabilities);\n  return `[PLAN MODE ACTIVE]\\nYou are in repository read-only plan mode. The dedicated write_plan tool may write one unique Markdown plan file under ${plansDirectory}.\\n\\nExplore the codebase and produce a concrete implementation plan. For every plan, first call subagent with action \"agents\", cluster the exploration by independent domain, subsystem, or integration boundary, and create a provisional task graph with the task tool. Select specialized agents by matching their names and descriptions to each cluster. Assign every unblocked delegated task through the task tool, and use a one-shot inlineAgent with a focused systemPrompt when no discovered specialist fits. Treat the initial graph as provisional, not as a fixed contract. After findings arrive, review the entire graph at least once and perform one to three review passes in total. In each pass, use the evidence to add, rewrite, delete, cancel, reassign, or change blockedBy relationships for tasks when warranted. Do not keep following tasks that new information has made stale. Stop revising early when the graph is stable, or after the third pass.\\n\\nEvery plan must end with a delegated planning-draft stage blocked by all exploration and decision tasks. A single-boundary plan gets one planning draft. A complex plan spanning multiple subsystems, domains, packages, apps, or integration boundaries gets two planning drafts concurrently. Use three concurrent drafts instead when the work is cross-layer, migration-sensitive, security-sensitive, or similarly high risk. Assign each draft through the task tool to the discovered \"planner\" agent with context \"fork\" so it receives the conversation and gathered evidence. If the planner agent is unavailable, assign the same draft task through the task tool with a focused inlineAgent. All children receive read, Bash, grep, find, ls, and configured MCP tools with artifacts disabled. Bash and MCP tools are for read-only inspection and must not modify files, external systems, or repository state. Doom Team runs asynchronously, so do not poll. After launch, continue non-overlapping exploration or end your turn; completion notifications wake the parent session.\\n\\nAfter all planning drafts complete, the main agent must compare the candidates, pick the strongest draft, cross-check it against the gathered evidence and the other drafts, resolve conflicts and gaps, and ask the user only for product decisions. A child produces the draft, but the main agent owns and synthesizes the final plan. The edit and write tools are withheld while plan mode is active; do not modify files or repository state except through write_plan. Start the final plan with a meaningful Markdown H1 because write_plan derives the filename from it. Present the complete plan as visible Markdown in chat, then call write_plan with no arguments. After write_plan succeeds, clear the completed durable task graph and call complete_plan so the user can review the plan and choose whether to begin implementation or continue planning. Do not exit plan mode without explicit approval.${review.length === 0 ? '' : `\\n\\n${review.join('\\n')}`}`;\n}\n\n/**\n * Normal planning adds only what the base block cannot say: that this flavor carries no debug\n * packet and no Fable draft. Everything else it used to repeat now lives in the base block once.\n */\nexport function buildNormalPlanningPrompt(): string {\n  return `[PLAN MODE ACTIVE: NORMAL]\\nStandard planning: no debug evidence packet and no Fable draft, so follow the plan mode brief above using the read-only tools directly.`;\n}\n\nexport function buildDebugPlanningPrompt(plansDirectory: string, evidence: DebugEvidencePacket | undefined): string {\n  const guidance = evidence\n    ? `A bounded debug evidence packet is recorded below. Cite its verified facts when making source findings. Keep verified facts and hypotheses distinct. Do not claim a verified root cause when reproduction or supporting evidence is unavailable.\\n\\n[DEBUG EVIDENCE]\\n${evidenceLines(evidence)}`\n    : 'No structured debug evidence packet is recorded yet. First understand the reported issue, then gather only the evidence relevant to it. Recording evidence is optional and must not block source exploration, delegation, writing a plan, or completing a plan.';\n  return `[PLAN MODE ACTIVE: DEBUG]\\nYou are in repository read-only adaptive debug planning. The dedicated write_plan tool may write one unique Markdown plan file under ${plansDirectory}.\\n\\n${guidance}\\n\\nUse the exact read-only tools available for the issue. Bash is available for repository inspection, but commands must not modify files or repository state. Treat unavailable evidence as unavailable, never invent its contents, and keep verified facts separate from hypotheses. ${evidence ? 'The final plan must separate verified facts from hypotheses and must not present an unsupported root cause as verified.' : 'You may call record_debug_evidence when structured notes would help, but continue investigating without it when it is not relevant.'}`;\n}\n\nexport function buildFablePlanningPrompt(\n  plansDirectory: string,\n  stage: string,\n  capabilities: PlanHostCapabilities,\n): string {\n  if (!capabilities.fableAvailable) {\n    return `[PLAN MODE ACTIVE: FABLE]\\nFable planning is unavailable in this host, so plan with the read-only tools directly.`;\n  }\n  return `[PLAN MODE ACTIVE: FABLE]\\nYou are in repository read-only Fable planning. Pi owns final verification and synthesis. The dedicated write_plan tool may write one unique Markdown plan file under ${plansDirectory}.\\n\\nUse Pi read-only exploration first. When the bounded packet is ready, call run_fable_plan. Fable runs one fresh draft with repository inspection access and returns untrusted text. Cross-check every Fable claim against repository evidence, keep verified findings separate from explicitly inferred findings, resolve conflicts yourself, and present the final visible plan before calling write_plan. Never treat Fable output as repository evidence and never expose credentials, transcripts, commands, tools, or session data in the packet.\\n\\nCurrent Fable stage: ${stage}. An interrupted stage is not relaunched automatically.`;\n}\n\nexport function buildFlavorPlanningPrompt(\n  flavor: PlanningFlavor,\n  plansDirectory: string,\n  evidence: DebugEvidencePacket | undefined,\n  fableStage: string,\n  capabilities: PlanHostCapabilities,\n): string {\n  if (flavor === 'debug') return buildDebugPlanningPrompt(plansDirectory, evidence);\n  if (flavor === 'fable') return buildFablePlanningPrompt(plansDirectory, fableStage, capabilities);\n  return buildNormalPlanningPrompt();\n}\n"],"mappings":";AAkBA,MAAM,kBAA0D;CAC9D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,cAAc,QAAqC;CAC1D,OAAO,gBAAgB,SAAS,UAAU;EACxC,MAAM,QAAQ,OAAO;EACrB,IAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,GAAG,OAAO,CAAC;EACxD,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG,OAAO,CAAC;EAC7D,OAAO,GAAG,MA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