@loucompanion/forge-bridge 0.1.3-dev.b6be5e7f9668 → 0.1.3-dev.bf78fdcaa623

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +44 -0
  2. package/dist/bridge/bridge.base.d.ts +5 -1
  3. package/dist/bridge/bridge.service.d.ts +36 -2
  4. package/dist/bridge/bridge.service.js +588 -18
  5. package/dist/bridge/bridge.types.d.ts +114 -1
  6. package/dist/cli/cli.help.d.ts +2 -0
  7. package/dist/cli/cli.help.js +183 -0
  8. package/dist/cli/cli.service.d.ts +12 -0
  9. package/dist/cli/cli.service.js +176 -184
  10. package/dist/cli/local-config.d.ts +2 -0
  11. package/dist/cli/local-config.js +6 -2
  12. package/dist/sandbox/command-runner.d.ts +4 -0
  13. package/dist/sandbox/command-runner.js +47 -0
  14. package/dist/sandbox/contract.d.ts +5 -0
  15. package/dist/sandbox/contract.js +276 -0
  16. package/dist/sandbox/event-budget.d.ts +11 -0
  17. package/dist/sandbox/event-budget.js +27 -0
  18. package/dist/sandbox/image-policy.d.ts +33 -0
  19. package/dist/sandbox/image-policy.js +245 -0
  20. package/dist/sandbox/index.d.ts +5 -0
  21. package/dist/sandbox/index.js +5 -0
  22. package/dist/sandbox/lease-watchdog.d.ts +18 -0
  23. package/dist/sandbox/lease-watchdog.js +67 -0
  24. package/dist/sandbox/preflight.d.ts +36 -0
  25. package/dist/sandbox/preflight.js +239 -0
  26. package/dist/sandbox/process.d.ts +20 -0
  27. package/dist/sandbox/process.js +124 -0
  28. package/dist/sandbox/provider-auth/codex.d.ts +26 -0
  29. package/dist/sandbox/provider-auth/codex.js +212 -0
  30. package/dist/sandbox/repository-lock.d.ts +5 -0
  31. package/dist/sandbox/repository-lock.js +83 -0
  32. package/dist/sandbox/runtime.d.ts +216 -0
  33. package/dist/sandbox/runtime.js +1658 -0
  34. package/dist/sandbox/sandbox.types.d.ts +83 -0
  35. package/dist/sandbox/sandbox.types.js +1 -0
  36. package/dist/sandbox/worker-supervisor.d.ts +13 -0
  37. package/dist/sandbox/worker-supervisor.js +36 -0
  38. package/dist/sandbox/worker.d.ts +1 -0
  39. package/dist/sandbox/worker.js +228 -0
  40. package/dist/sandbox/workspace.service.d.ts +12 -0
  41. package/dist/sandbox/workspace.service.js +49 -0
  42. package/dist/session/phase-completion.artifacts.d.ts +10 -0
  43. package/dist/session/phase-completion.artifacts.js +620 -0
  44. package/dist/session/phase-completion.d.ts +32 -44
  45. package/dist/session/phase-completion.helpers.d.ts +112 -0
  46. package/dist/session/phase-completion.helpers.js +660 -0
  47. package/dist/session/phase-completion.js +28 -3485
  48. package/dist/session/phase-completion.prompts.d.ts +14 -0
  49. package/dist/session/phase-completion.prompts.js +220 -0
  50. package/dist/session/phase-completion.runtime.d.ts +36 -0
  51. package/dist/session/phase-completion.runtime.js +609 -0
  52. package/dist/session/phase-completion.schemas.d.ts +3 -0
  53. package/dist/session/phase-completion.schemas.js +707 -0
  54. package/dist/session/phase-completion.validation.d.ts +34 -0
  55. package/dist/session/phase-completion.validation.js +724 -0
  56. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +93 -0
  57. package/dist/session/provider-cli/provider-cli.artifacts.js +754 -0
  58. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  59. package/dist/session/provider-cli/provider-cli.deterministic-payloads.d.ts +12 -0
  60. package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
  61. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
  62. package/dist/session/provider-cli/provider-cli.deterministic.js +329 -0
  63. package/dist/session/provider-cli/provider-cli.process.d.ts +32 -0
  64. package/dist/session/provider-cli/provider-cli.process.js +287 -0
  65. package/dist/session/provider-cli/provider-cli.prompts.d.ts +44 -0
  66. package/dist/session/provider-cli/provider-cli.prompts.js +528 -0
  67. package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
  68. package/dist/session/provider-cli/provider-cli.qa-sidecars.js +65 -0
  69. package/dist/session/provider-cli/provider-cli.runtime.d.ts +9 -0
  70. package/dist/session/provider-cli/provider-cli.runtime.js +40 -0
  71. package/dist/session/provider-cli/provider-cli.service.d.ts +9 -53
  72. package/dist/session/provider-cli/provider-cli.service.js +161 -2527
  73. package/dist/session/provider-cli/provider-cli.types.d.ts +1 -0
  74. package/dist/session/provider-cli/provider-output-state.d.ts +20 -0
  75. package/dist/session/provider-cli/provider-output-state.js +445 -0
  76. package/dist/session/session.service.js +34 -24
  77. package/dist/session/session.types.d.ts +106 -1
  78. package/dist/session/session.types.js +248 -3
  79. package/dist/shared/process/windows-launch.d.ts +8 -0
  80. package/dist/shared/process/windows-launch.js +41 -0
  81. package/dist/shared/provider-capabilities.d.ts +1 -0
  82. package/dist/shared/provider-capabilities.js +3 -0
  83. package/dist/shared/redaction/redaction.js +4 -2
  84. package/dist/version.d.ts +1 -1
  85. package/dist/version.js +1 -1
  86. package/dist/worktree/artifact-injector.js +39 -6
  87. package/dist/worktree/dependency-warmer.d.ts +11 -0
  88. package/dist/worktree/dependency-warmer.js +45 -1
  89. package/dist/worktree/worktree.service.d.ts +2 -1
  90. package/dist/worktree/worktree.service.js +32 -12
  91. package/package.json +4 -2
@@ -0,0 +1,14 @@
1
+ import { type CompletionPhase, type DebugCompletionPhase, type DecomposeCompletionGate, type DevelopCompletionPhase, type DraftCompletionGate, type QaCompletionGate } from "./phase-completion.js";
2
+ export declare function completionPromptForPhase(phase: CompletionPhase): string;
3
+ export declare function completionPromptForDevelopCycle(phase: CompletionPhase): string;
4
+ export declare function completionPromptForQaCycle(currentGate?: QaCompletionGate): string;
5
+ export declare function completionPromptForDraftCycle(currentGate?: DraftCompletionGate): string;
6
+ export declare function completionPromptForDecomposeCycle(currentGate?: DecomposeCompletionGate): string;
7
+ export declare function completionPromptForDebugCycle(currentGate?: DebugCompletionPhase): string;
8
+ export declare function nextPhaseAfter(phase: CompletionPhase): DevelopCompletionPhase | null;
9
+ export declare function nextDebugPhaseAfter(phase: DebugCompletionPhase): DebugCompletionPhase | null;
10
+ export declare function completionToolNextInstruction(completedPhase: CompletionPhase, status: string, nextPhase: CompletionPhase | "dev_test_ready" | "qa_ready" | "sign_off_ready"): string;
11
+ export declare function completionToolNextInstructionForDraftGate(completedGate: DraftCompletionGate, status: string, nextGate: DraftCompletionGate | null): string;
12
+ export declare function completionToolNextInstructionForQaGate(completedGate: QaCompletionGate, status: string, nextGate: QaCompletionGate | null): string;
13
+ export declare function completionToolNextInstructionForDecomposeGate(completedGate: DecomposeCompletionGate, status: string, nextGate: DecomposeCompletionGate | null): string;
14
+ export declare function completionToolNextInstructionForDebugGate(completedGate: DebugCompletionPhase, status: string, nextGate: DebugCompletionPhase | null): string;
@@ -0,0 +1,220 @@
1
+ import { completionPhaseOrder, completionToolNamesForPhase, debugCompletionPhaseOrder, expectedCompletionToolName, expectedDebugCompletionToolName, expectedDecomposeCompletionToolName, phaseFiles, toolServerName } from "./phase-completion.js";
2
+ import { isDebugCompletionPhase, isDevelopCompletionPhase } from "./phase-completion.validation.js";
3
+ export function completionPromptForPhase(phase) {
4
+ const toolName = expectedCompletionToolName(phase);
5
+ const alias = completionToolNamesForPhase(phase).find((name) => name !== toolName);
6
+ const artifactName = phaseFiles[phase].jsonFileName;
7
+ if (phase === "qa") {
8
+ return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
9
+ Do not write QA artifacts by hand. When QA is complete, call \`${toolName}(...)\`${alias ? ` (or \`${alias}\` if your client shows unqualified MCP tool names)` : ""} with the required structured QA payload.
10
+ That tool writes the durable QA bundle under \`.forge/work-items/{workItemId}/artifacts/\`: \`qa.plan.json\`, \`qa.evidence.json\`, \`qa.findings.json\`, \`${artifactName}\`, and \`qa.report.md\`.
11
+ Use \`status: "pass"\` only when the validated changes satisfy acceptance criteria with concrete evidence. Use \`status: "needs_rework"\` with actionable in-scope findings, or \`status: "blocked"\` with a concrete blocker_reason.
12
+ Include \`policy_warnings\` for non-blocking Forge policy or scope mismatches that should remain visible after QA.
13
+ Forge will mirror only the tool-written QA artifacts; reporting QA completion in prose is not enough.`;
14
+ }
15
+ if (phase === "architect") {
16
+ return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
17
+ Do not write Architect artifacts by hand. When the plan is complete, call \`${toolName}(...)\`${alias ? ` (or \`${alias}\` if your client shows unqualified MCP tool names)` : ""} with the full structured Architect planning payload.
18
+ That tool writes \`.forge/work-items/{workItemId}/artifacts/implementation.plan.json\`, \`qa.plan.json\`, \`${artifactName}\`, and \`architect.report.md\`.
19
+ The payload must put \`phases\`, \`tasks\`, \`dependencies\`, and \`phase_gates\` as top-level fields inside \`implementation_plan\`, for example:
20
+ \`{ "status": "pass", "summary": "...", "implementation_plan": { "schema_version": 1, "plan_id": "plan-...", "phases": [{ "id": "phase-1", "tasks": ["task-1"], "gate": "gate-1" }], "tasks": [{ "id": "task-1", "verification_scope": { "schema_version": 1, "surface": ["domain_contract"], "required_evidence": ["unit_tests"], "not_applicable": ["browser_manual", "api_http"], "browser_required": false, "api_required": false, "rationale": "Backend-only child task." }, "tests": [{ "command": "npm test" }] }], "dependencies": [], "phase_gates": [{ "id": "gate-1", "phase": "phase-1" }] }, "qa_plan": { "schema_version": 1, "final_qa": [{ "id": "qa-1", "coverage": "..." }] }, "report_markdown": "# Architect Report" }\`.
21
+ \`implementation_plan.tasks\` are Develop child tasks only: each task should include \`verification_scope\` describing task-level QA evidence, and must require a focused repo/product implementation change. Put parent-story QA, sign-off, child-count/materialization inventory, parent plan artifact checks, and final integrated acceptance proof in \`qa_plan.final_qa\`, not as child Develop tasks.
22
+ Dependency entries use canonical \`before\` and \`after\` task ids, for example \`{ "before": "task-1", "after": "task-2" }\`. Forge accepts \`from\`/\`to\` only as aliases and normalizes them before writing artifacts.
23
+ Use \`status: "pass"\` for a valid pending-approval plan, \`needs_revision\` when story/design input must change, or \`blocked\` with a concrete blocker.
24
+ Forge will mirror only the tool-written Architect artifacts; reporting the plan in prose is not enough.`;
25
+ }
26
+ return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
27
+ Do not write phase artifacts by hand. When the phase is complete, call \`${toolName}(...)\`${alias ? ` (or \`${alias}\` if your client shows unqualified MCP tool names)` : ""} with the required evidence payload.
28
+ That tool writes \`.forge/work-items/{workItemId}/artifacts/${artifactName}\` and returns the artifact reference that Forge will mirror through the existing phase-artifact pipeline.
29
+ If the work cannot pass, call the same tool with a non-pass status and explicit blockers instead of reporting completion in prose only.`;
30
+ }
31
+ export function completionPromptForDevelopCycle(phase) {
32
+ return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
33
+ Do not write phase artifacts by hand. The tool server enforces phase order and starts this run in \`${phase}\`.
34
+ Complete the dev cycle in order inside this same provider session:
35
+ 1. Call \`forge.complete_implementation(...)\` when implementation evidence is ready.
36
+ 2. Follow the returned self-review instruction, then call \`forge.complete_self_review(...)\`.
37
+ 3. Follow the returned validation instruction, then call \`forge.complete_validation(...)\`.
38
+ Each tool writes the canonical artifact under \`.forge/work-items/{workItemId}/artifacts/\` and returns the next-phase instruction Forge expects you to follow.
39
+ If the current phase cannot pass, call the current phase tool with a non-pass status and explicit blockers instead of reporting completion in prose only.`;
40
+ }
41
+ export function completionPromptForQaCycle(currentGate = "qa_plan") {
42
+ return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
43
+ Do not write QA artifacts by hand. The tool server enforces QA gate order and starts this run at \`${currentGate}\`.
44
+ Complete the QA cycle in order inside this same provider session:
45
+ 1. Call \`forge.complete_qa_plan(...)\` after the QA test plan/checklist is ready.
46
+ 2. Follow the returned regression instruction, then call \`forge.complete_qa_regression(...)\`.
47
+ 3. Follow the returned API/backend instruction, then call \`forge.complete_qa_api(...)\`.
48
+ 4. Follow the returned manual web instruction, then call \`forge.complete_qa_manual_web(...)\`.
49
+ 5. Follow the returned bug reproduction instruction, then call \`forge.complete_qa_bug_repro(...)\`.
50
+ 6. Follow the returned findings instruction, then call \`forge.complete_qa_findings(...)\`.
51
+ 7. Follow the returned verdict instruction, then call \`forge.complete_qa_verdict(...)\`.
52
+ Use \`status: "skipped"\` with a reason for gates that are not applicable. If a gate is blocked, keep moving through later gates as skipped due to the blocker and finish with a blocked verdict.
53
+ The final verdict tool writes the canonical QA bundle under \`.forge/work-items/{workItemId}/artifacts/\`: \`qa.plan.json\`, \`qa.evidence.json\`, \`qa.findings.json\`, \`qa.verdict.json\`, and \`qa.report.md\`.
54
+ Include \`policy_warnings\` in the final verdict for non-blocking Forge policy or scope mismatches that should remain visible after QA.
55
+ The legacy \`forge.complete_qa\` one-shot tool is not available in normal QA-cycle mode. Reporting QA completion in prose is not enough.`;
56
+ }
57
+ export function completionPromptForDraftCycle(currentGate = "draft_intent") {
58
+ return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
59
+ Do not finish Draft by prose or raw JSON. The tool server enforces Draft gate order and starts at \`${currentGate}\`.
60
+ Complete the Draft cycle in order inside this same provider session:
61
+ 1. Call \`forge.complete_draft_intent(...)\` after interpreting user intent and non-goals.
62
+ 2. Follow the returned repo-context instruction, inspect selected project/repo assumptions, then call \`forge.complete_draft_repo_context(...)\`.
63
+ 3. Follow the returned graph-context instruction, account for DAG/dependency placement, then call \`forge.complete_draft_graph_context(...)\`.
64
+ 4. Follow the returned product-scope instruction, choose product scope for the selected project, then call \`forge.complete_draft_product_scope(...)\`.
65
+ 5. Follow the returned draft-plan instruction, draft the requested final JSON shape for the current Draft kind, then call \`forge.complete_draft_work_order_plan(...)\`.
66
+ 6. Follow the returned critic instruction, critique literalism, wrong-project scope, and decomposition quality, then call \`forge.complete_draft_critic(...)\`.
67
+ 7. Follow the returned proposal instruction, then call \`forge.complete_draft_proposal(...)\` with the final Draft JSON payload in \`draft_json\`.
68
+ The final proposal tool writes \`draft.proposal.json\` under \`.forge/work-items/{workItemId}/artifacts/\`. Reporting Draft completion in prose is not enough.`;
69
+ }
70
+ export function completionPromptForDecomposeCycle(currentGate = "decompose_subject_intake") {
71
+ return `# Forge Decompose completion cycle
72
+ You must complete the Decompose gates in order using the Forge MCP tools. Reporting progress in prose is not enough.
73
+
74
+ Current gate: ${currentGate}
75
+
76
+ Required order:
77
+ 1. Call \`forge.complete_decompose_subject_intake(...)\` after identifying the Work Order/Feature subject, scope, and non-goals.
78
+ 2. Follow the returned context-review instruction, inspect injected project/repo/dependency context, then call \`forge.complete_decompose_context_review(...)\`.
79
+ 3. Follow the returned breakdown-strategy instruction, choose safe Feature/Story boundaries, then call \`forge.complete_decompose_breakdown_strategy(...)\`.
80
+ 4. Follow the returned child-items instruction, draft candidate child items, then call \`forge.complete_decompose_child_items(...)\`.
81
+ 5. Follow the returned dependency-graph instruction, validate keys/dependencies/order, then call \`forge.complete_decompose_dependency_graph(...)\`.
82
+ 6. Follow the returned critic instruction, critique scope, DAG safety, manual reconciliation risk, and missing acceptance detail, then call \`forge.complete_decompose_critic(...)\`.
83
+ 7. Follow the returned proposal instruction, then call \`forge.complete_decompose_proposal(...)\` with final JSON in \`proposal_json\`.
84
+ The final proposal tool writes \`decompose.proposal.json\` under \`.forge/work-items/{workItemId}/artifacts/\`. The proposal_json object must contain summary, optional blockedReason, and candidates. Work Order-to-Feature candidates may include \`estimated_qa_scope\`; Feature-to-Story candidates should include \`qa_scope\` with schema_version 1 plus scheduleIndex, waveIndex, expectedOutput, handoffSummary, and dependencyReason for dependency handoff.`;
85
+ }
86
+ export function completionPromptForDebugCycle(currentGate = "debug_repro") {
87
+ return `Forge completion tools are available through the MCP server named \`${toolServerName}\`.
88
+ Do not write Debug artifacts by hand. The tool server enforces Debug gate order and starts this run at \`${currentGate}\`.
89
+ Complete the Debug cycle in order inside this same provider session:
90
+ 1. Reproduce or tightly characterize the bug, then call \`forge.complete_debug_repro(...)\`.
91
+ 2. Follow the returned root-cause instruction, isolate evidence, then call \`forge.complete_debug_root_cause(...)\`.
92
+ 3. Follow the returned fix instruction, apply the smallest safe fix with regression coverage when practical, then call \`forge.complete_debug_fix(...)\`.
93
+ 4. Follow the returned regression instruction, prove the original repro is negative and the fix is QA-ready, then call \`forge.complete_debug_regression(...)\`.
94
+ Each tool writes a canonical Debug artifact under \`.forge/work-items/{workItemId}/artifacts/\`: \`debug.repro.json\`, \`debug.root-cause.json\`, \`debug.fix.json\`, and \`debug.regression.json\` plus \`debug.report.md\` when report text is provided or generated.
95
+ Use a non-pass status with explicit blockers when the current Debug gate cannot pass. Reporting Debug completion in prose is not enough; the relevant MCP completion tool is the transition request.`;
96
+ }
97
+ export function nextPhaseAfter(phase) {
98
+ if (!isDevelopCompletionPhase(phase)) {
99
+ return null;
100
+ }
101
+ const index = completionPhaseOrder.indexOf(phase);
102
+ return index >= 0 ? completionPhaseOrder[index + 1] ?? null : null;
103
+ }
104
+ export function nextDebugPhaseAfter(phase) {
105
+ const index = debugCompletionPhaseOrder.indexOf(phase);
106
+ return index >= 0 ? debugCompletionPhaseOrder[index + 1] ?? null : null;
107
+ }
108
+ export function completionToolNextInstruction(completedPhase, status, nextPhase) {
109
+ if (completedPhase === "qa") {
110
+ if (status === "blocked") {
111
+ return "QA blocked. Forge recorded the blocker reason and will surface the run for human attention.";
112
+ }
113
+ if (status === "needs_rework") {
114
+ return "QA findings recorded. Forge has the structured evidence needed to route this work back for implementation rework.";
115
+ }
116
+ return "QA accepted. Forge has the structured evidence needed to move this work item to Sign-Off.";
117
+ }
118
+ if (status !== "pass") {
119
+ return `Stay in ${completedPhase}, address the recorded blockers, then call ${expectedCompletionToolName(completedPhase)} again.`;
120
+ }
121
+ if (isDebugCompletionPhase(completedPhase)) {
122
+ const debugNext = isDebugCompletionPhase(nextPhase) ? nextPhase : null;
123
+ return completionToolNextInstructionForDebugGate(completedPhase, status, debugNext);
124
+ }
125
+ if (nextPhase === "self_review") {
126
+ return "Implementation accepted. Begin self-review: inspect the diff, apply safe fixes, and call forge.complete_self_review with review evidence.";
127
+ }
128
+ if (nextPhase === "validation") {
129
+ return "Self-review accepted. Begin validation: run deterministic checks, prove acceptance criteria, and call forge.complete_validation with command evidence.";
130
+ }
131
+ return "Validation accepted. Forge has the structured evidence needed to move this work item to QA.";
132
+ }
133
+ export function completionToolNextInstructionForDraftGate(completedGate, status, nextGate) {
134
+ if (status === "blocked") {
135
+ return `Stay in ${completedGate}; record the blocker and retry the same Draft gate when unblocked.`;
136
+ }
137
+ if (!nextGate) {
138
+ return "Draft proposal accepted. Forge has the structured Work Order draft JSON needed to populate the form.";
139
+ }
140
+ const instructions = {
141
+ draft_intent: "Capture intent/non-goals, then call forge.complete_draft_intent.",
142
+ draft_repo_context: "Inspect selected repo/project assumptions, then call forge.complete_draft_repo_context.",
143
+ draft_graph_context: "Account for DAG dependencies and placement, then call forge.complete_draft_graph_context.",
144
+ draft_product_scope: "Choose product scope for the selected project, then call forge.complete_draft_product_scope.",
145
+ draft_work_order_plan: "Draft the current Draft kind's plan fields, then call forge.complete_draft_work_order_plan.",
146
+ draft_critic: "Critique literalism/wrong-project scope/decomposition risk, then call forge.complete_draft_critic.",
147
+ draft_proposal: "Submit final draft_json through forge.complete_draft_proposal."
148
+ };
149
+ return `${completedGate} accepted. Continue to ${nextGate}. ${instructions[nextGate]}`;
150
+ }
151
+ export function completionToolNextInstructionForQaGate(completedGate, status, nextGate) {
152
+ if (!nextGate) {
153
+ if (status === "blocked") {
154
+ return "QA blocked. Forge recorded the blocker reason and will surface the run for human attention.";
155
+ }
156
+ if (status === "needs_rework") {
157
+ return "QA findings recorded. Forge has the structured evidence needed to route this work back for implementation rework.";
158
+ }
159
+ return "QA accepted. Forge has the structured evidence needed to move this work item to Sign-Off.";
160
+ }
161
+ const skipped = status === "skipped";
162
+ const blocked = status === "blocked";
163
+ const prefix = blocked
164
+ ? `${completedGate} recorded a blocker. Continue through ${nextGate} and mark downstream gates skipped if the blocker prevents evidence collection.`
165
+ : skipped
166
+ ? `${completedGate} skipped. Continue to ${nextGate}.`
167
+ : `${completedGate} accepted. Continue to ${nextGate}.`;
168
+ return `${prefix} ${qaGateInstruction(nextGate)}`;
169
+ }
170
+ export function completionToolNextInstructionForDecomposeGate(completedGate, status, nextGate) {
171
+ if (status !== "pass") {
172
+ return `Stay in ${completedGate}, address the recorded blockers/rework, then call ${expectedDecomposeCompletionToolName(completedGate)} again.`;
173
+ }
174
+ if (!nextGate) {
175
+ return "Decompose proposal accepted. Forge has the structured child-item proposal JSON needed to populate the proposal row.";
176
+ }
177
+ const nextInstructions = {
178
+ decompose_subject_intake: "Capture subject/scope, then call forge.complete_decompose_subject_intake.",
179
+ decompose_context_review: "Review project/repo/dependency context, then call forge.complete_decompose_context_review.",
180
+ decompose_breakdown_strategy: "Choose safe child boundaries, then call forge.complete_decompose_breakdown_strategy.",
181
+ decompose_child_items: "Draft child candidates, then call forge.complete_decompose_child_items.",
182
+ decompose_dependency_graph: "Validate dependency DAG, then call forge.complete_decompose_dependency_graph.",
183
+ decompose_critic: "Critique the decomposition, then call forge.complete_decompose_critic.",
184
+ decompose_proposal: "Submit final proposal_json through forge.complete_decompose_proposal."
185
+ };
186
+ return `${completedGate} accepted. ${nextInstructions[nextGate]}`;
187
+ }
188
+ export function completionToolNextInstructionForDebugGate(completedGate, status, nextGate) {
189
+ if (status !== "pass") {
190
+ return `Stay in ${completedGate}, address the recorded blockers, then call ${expectedDebugCompletionToolName(completedGate)} again.`;
191
+ }
192
+ if (nextGate === "debug_root_cause") {
193
+ return "Debug repro accepted. Begin root-cause analysis: connect the observed failure to code evidence and call forge.complete_debug_root_cause.";
194
+ }
195
+ if (nextGate === "debug_fix") {
196
+ return "Debug root cause accepted. Apply the smallest safe fix with regression coverage where practical, then call forge.complete_debug_fix.";
197
+ }
198
+ if (nextGate === "debug_regression") {
199
+ return "Debug fix accepted. Prove the original repro is negative, run targeted regression checks, and call forge.complete_debug_regression.";
200
+ }
201
+ return "Debug regression accepted. Forge has the structured evidence needed to move this bug fix to QA.";
202
+ }
203
+ function qaGateInstruction(gate) {
204
+ switch (gate) {
205
+ case "qa_regression":
206
+ return "Run or explicitly skip applicable regression/build/lint/typecheck/e2e checks, then call forge.complete_qa_regression.";
207
+ case "qa_api":
208
+ return "Run or explicitly skip applicable API/backend contract checks, then call forge.complete_qa_api.";
209
+ case "qa_manual_web":
210
+ return "Run or explicitly skip applicable browser/manual web checks, then call forge.complete_qa_manual_web.";
211
+ case "qa_bug_repro":
212
+ return "Reproduce or explicitly skip relevant defects/candidate bugs, then call forge.complete_qa_bug_repro.";
213
+ case "qa_findings":
214
+ return "Normalize observations into findings and candidate bugs, then call forge.complete_qa_findings.";
215
+ case "qa_verdict":
216
+ return "Assemble the final QA verdict from all prior gate evidence, then call forge.complete_qa_verdict.";
217
+ case "qa_plan":
218
+ return "Prepare the QA checklist, then call forge.complete_qa_plan.";
219
+ }
220
+ }
@@ -0,0 +1,36 @@
1
+ import { type CompletionToolCallResult, type CompletionToolRuntime, type CompletionToolRuntimeOptions, type CompletionToolServerConfig } from "./phase-completion.js";
2
+ export declare function prepareCompletionToolRuntime(options: CompletionToolRuntimeOptions): Promise<CompletionToolRuntime>;
3
+ export declare function buildCompletionToolServerArgs(config: CompletionToolServerConfig): readonly string[];
4
+ export declare function codexMcpConfigArgs(runtime: CompletionToolRuntime): readonly string[];
5
+ export declare function cursorMcpServerConfig(runtime: CompletionToolRuntime): unknown;
6
+ export declare function completionToolNamesForServer(config: CompletionToolServerConfig): readonly string[];
7
+ export declare class CompletionToolServerSession {
8
+ private readonly config;
9
+ private currentPhase;
10
+ private currentQaGate;
11
+ private currentDraftGate;
12
+ private currentDecomposeGate;
13
+ private completed;
14
+ constructor(config: CompletionToolServerConfig);
15
+ get instructions(): string;
16
+ toolDefinitions(): readonly unknown[];
17
+ callTool(toolName: string, input: unknown): Promise<CompletionToolCallResult>;
18
+ private callDecomposeGateTool;
19
+ private callDraftGateTool;
20
+ private callDebugGateTool;
21
+ private callQaGateTool;
22
+ private advanceAfterPass;
23
+ private advanceAfterDecomposeGate;
24
+ private advanceAfterDraftGate;
25
+ private advanceAfterQaGate;
26
+ private advanceAfterDebugGate;
27
+ }
28
+ export declare function runCompletionMcpServer(config: CompletionToolServerConfig): Promise<void>;
29
+ export declare function parseCompletionMcpArgs(argv: readonly string[]): {
30
+ readonly ok: true;
31
+ readonly config: CompletionToolServerConfig;
32
+ } | {
33
+ readonly ok: false;
34
+ readonly error: string;
35
+ };
36
+ export declare function completionRedactionEnv(secrets: readonly string[]): Readonly<Record<string, string>>;