@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.0f07274d438b

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 (329) hide show
  1. package/README.md +183 -4
  2. package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
  3. package/dist/bridge/bridge-chat-giphy-look.js +55 -0
  4. package/dist/bridge/bridge-chat-provider-command.d.ts +40 -0
  5. package/dist/bridge/bridge-chat-provider-command.js +230 -0
  6. package/dist/bridge/bridge-chat.types.d.ts +20 -0
  7. package/dist/bridge/bridge-chat.types.js +28 -1
  8. package/dist/bridge/bridge-state-file.d.ts +161 -0
  9. package/dist/bridge/bridge-state-file.js +376 -0
  10. package/dist/bridge/bridge-state-io.d.ts +15 -0
  11. package/dist/bridge/bridge-state-io.js +68 -0
  12. package/dist/bridge/bridge-state-lock.d.ts +11 -0
  13. package/dist/bridge/bridge-state-lock.js +102 -0
  14. package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
  15. package/dist/bridge/bridge-state-unpublished.js +111 -0
  16. package/dist/bridge/bridge.base.d.ts +9 -0
  17. package/dist/bridge/bridge.service.d.ts +102 -14
  18. package/dist/bridge/bridge.service.js +499 -471
  19. package/dist/bridge/bridge.types.d.ts +37 -0
  20. package/dist/bridge/bridge.types.js +2 -1
  21. package/dist/bridge/default-session-service.d.ts +13 -0
  22. package/dist/bridge/default-session-service.js +22 -0
  23. package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
  24. package/dist/bridge/dispatch-offer-policy.js +58 -0
  25. package/dist/bridge/in-flight-registry.d.ts +62 -0
  26. package/dist/bridge/in-flight-registry.js +207 -0
  27. package/dist/bridge/local-yield-flag.d.ts +6 -0
  28. package/dist/bridge/local-yield-flag.js +34 -0
  29. package/dist/bridge/readiness-result-outbox.d.ts +5 -1
  30. package/dist/bridge/readiness-result-outbox.js +20 -0
  31. package/dist/bridge/runner-host-capabilities.d.ts +5 -0
  32. package/dist/bridge/runner-host-capabilities.js +31 -1
  33. package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
  34. package/dist/bridge/sandbox-resource-accounting.js +150 -0
  35. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  36. package/dist/bridge/test-postgres-capability.js +120 -0
  37. package/dist/bridge/windows-bash-resolution.d.ts +31 -0
  38. package/dist/bridge/windows-bash-resolution.js +153 -0
  39. package/dist/cleanup/cleanup-wip.d.ts +12 -0
  40. package/dist/cleanup/cleanup-wip.js +66 -0
  41. package/dist/cleanup/cleanup.service.d.ts +20 -1
  42. package/dist/cleanup/cleanup.service.js +150 -169
  43. package/dist/cleanup/cleanup.types.d.ts +6 -0
  44. package/dist/cleanup/forge-owned-paths.d.ts +11 -0
  45. package/dist/cleanup/forge-owned-paths.js +62 -0
  46. package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
  47. package/dist/cleanup/host-runtime-ledger.js +130 -0
  48. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  49. package/dist/cleanup/managed-branch-sweep.js +111 -0
  50. package/dist/cli/cli.help.js +75 -13
  51. package/dist/cli/cli.service.d.ts +19 -10
  52. package/dist/cli/cli.service.js +161 -228
  53. package/dist/cli/idle-status.d.ts +84 -0
  54. package/dist/cli/idle-status.js +181 -0
  55. package/dist/cli/local-config.d.ts +18 -1
  56. package/dist/cli/local-config.js +67 -5
  57. package/dist/cli/provider-cli-advertising.d.ts +24 -0
  58. package/dist/cli/provider-cli-advertising.js +88 -0
  59. package/dist/cli/provider-cli-detection.d.ts +10 -0
  60. package/dist/cli/provider-cli-detection.js +160 -0
  61. package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
  62. package/dist/runtime/aspnet-runtime-prebuild.js +184 -18
  63. package/dist/runtime/attempt-database-broker.d.ts +1 -1
  64. package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
  65. package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
  66. package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
  67. package/dist/runtime/attempt-process-supervisor.js +12 -6
  68. package/dist/runtime/docker-engine-probe.d.ts +5 -0
  69. package/dist/runtime/docker-engine-probe.js +7 -0
  70. package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
  71. package/dist/runtime/dotnet-build-outputs.js +402 -0
  72. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  73. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  74. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  75. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  76. package/dist/runtime/host-facts.d.ts +2 -1
  77. package/dist/runtime/host-listener-inspector.d.ts +26 -0
  78. package/dist/runtime/host-listener-inspector.js +84 -3
  79. package/dist/runtime/host-load-admission.d.ts +72 -0
  80. package/dist/runtime/host-load-admission.js +99 -0
  81. package/dist/runtime/host-load-capacity.d.ts +198 -0
  82. package/dist/runtime/host-load-capacity.js +353 -0
  83. package/dist/runtime/host-load-child-environment.d.ts +40 -0
  84. package/dist/runtime/host-load-child-environment.js +110 -0
  85. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  86. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  87. package/dist/runtime/host-load-governor-config.d.ts +82 -0
  88. package/dist/runtime/host-load-governor-config.js +104 -0
  89. package/dist/runtime/host-load-governor.d.ts +273 -0
  90. package/dist/runtime/host-load-governor.js +831 -0
  91. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  92. package/dist/runtime/host-load-ledger-lock.js +187 -0
  93. package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
  94. package/dist/runtime/host-load-live-test-slots.js +193 -0
  95. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  96. package/dist/runtime/host-load-runtime-settings.js +80 -0
  97. package/dist/runtime/host-load-sampler.d.ts +92 -2
  98. package/dist/runtime/host-load-sampler.js +166 -8
  99. package/dist/runtime/host-load-step-class.d.ts +70 -0
  100. package/dist/runtime/host-load-step-class.js +161 -0
  101. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  102. package/dist/runtime/host-load-step-reaper.js +95 -0
  103. package/dist/runtime/host-load-step-run.d.ts +107 -0
  104. package/dist/runtime/host-load-step-run.js +158 -0
  105. package/dist/runtime/host-load-test-slot.d.ts +46 -0
  106. package/dist/runtime/host-load-test-slot.js +100 -0
  107. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  108. package/dist/runtime/host-load-token-ledger.js +453 -0
  109. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  110. package/dist/runtime/host-load-windows-cpu.js +85 -0
  111. package/dist/runtime/host-pressure-stall.d.ts +21 -1
  112. package/dist/runtime/host-pressure-stall.js +48 -1
  113. package/dist/runtime/host-runtime-contract.d.ts +15 -0
  114. package/dist/runtime/host-runtime-contract.js +39 -6
  115. package/dist/runtime/host-runtime-lease.d.ts +101 -6
  116. package/dist/runtime/host-runtime-lease.js +408 -294
  117. package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
  118. package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
  119. package/dist/runtime/host-runtime-promotion.d.ts +101 -2
  120. package/dist/runtime/host-runtime-promotion.js +355 -14
  121. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  122. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  123. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  124. package/dist/runtime/host-runtime-requirements.js +117 -0
  125. package/dist/runtime/managed-command-teardown.js +5 -16
  126. package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
  127. package/dist/runtime/native-test-postgres-fallback.js +60 -8
  128. package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
  129. package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
  130. package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
  131. package/dist/runtime/prepared-runtime-identity.js +130 -9
  132. package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
  133. package/dist/runtime/prepared-runtime-readiness.js +89 -18
  134. package/dist/runtime/runner-settings.d.ts +104 -0
  135. package/dist/runtime/runner-settings.js +236 -0
  136. package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
  137. package/dist/runtime/supervised-runtime-build-guard.js +112 -0
  138. package/dist/sandbox/host-capacity-broker.d.ts +115 -0
  139. package/dist/sandbox/host-capacity-broker.js +336 -0
  140. package/dist/sandbox/managed-branch.d.ts +13 -0
  141. package/dist/sandbox/managed-branch.js +90 -0
  142. package/dist/sandbox/provider-auth/codex.js +11 -11
  143. package/dist/sandbox/runtime.d.ts +11 -3
  144. package/dist/sandbox/runtime.js +53 -20
  145. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  146. package/dist/sandbox/sandbox-cgroups.js +42 -0
  147. package/dist/sandbox/sandbox-input.d.ts +22 -0
  148. package/dist/sandbox/sandbox-input.js +49 -0
  149. package/dist/sandbox/workspace.service.js +15 -2
  150. package/dist/session/architect-waits.d.ts +2 -0
  151. package/dist/session/architect-waits.js +138 -0
  152. package/dist/session/managed-attempt-tools.d.ts +2 -7
  153. package/dist/session/managed-attempt-tools.js +204 -141
  154. package/dist/session/managed-build-coordinator.d.ts +16 -0
  155. package/dist/session/managed-build-coordinator.js +10 -0
  156. package/dist/session/managed-build-receipt.d.ts +7 -0
  157. package/dist/session/managed-build-receipt.js +11 -3
  158. package/dist/session/managed-command-environment.d.ts +8 -0
  159. package/dist/session/managed-command-environment.js +28 -0
  160. package/dist/session/managed-command-host-load.d.ts +52 -0
  161. package/dist/session/managed-command-host-load.js +87 -0
  162. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  163. package/dist/session/mcp-argument-coercion.js +121 -0
  164. package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
  165. package/dist/session/phase-completion.artifact-bundle.js +167 -0
  166. package/dist/session/phase-completion.artifacts.d.ts +9 -17
  167. package/dist/session/phase-completion.artifacts.js +158 -190
  168. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  169. package/dist/session/phase-completion.command-validation.js +77 -0
  170. package/dist/session/phase-completion.d.ts +31 -2
  171. package/dist/session/phase-completion.helpers.js +18 -65
  172. package/dist/session/phase-completion.js +19 -32
  173. package/dist/session/phase-completion.mcp-args.d.ts +9 -0
  174. package/dist/session/phase-completion.mcp-args.js +195 -0
  175. package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
  176. package/dist/session/phase-completion.phase-aliases.js +43 -0
  177. package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
  178. package/dist/session/phase-completion.pr-review-schema.js +75 -0
  179. package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
  180. package/dist/session/phase-completion.pr-review-validation.js +212 -0
  181. package/dist/session/phase-completion.pr-review.d.ts +36 -0
  182. package/dist/session/phase-completion.pr-review.js +294 -0
  183. package/dist/session/phase-completion.prompts.d.ts +1 -1
  184. package/dist/session/phase-completion.prompts.js +20 -1
  185. package/dist/session/phase-completion.runtime.d.ts +13 -12
  186. package/dist/session/phase-completion.runtime.js +113 -214
  187. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  188. package/dist/session/phase-completion.schema-parts.js +188 -0
  189. package/dist/session/phase-completion.schemas.d.ts +3 -3
  190. package/dist/session/phase-completion.schemas.js +219 -232
  191. package/dist/session/phase-completion.validation.d.ts +3 -3
  192. package/dist/session/phase-completion.validation.js +58 -94
  193. package/dist/session/pr-review-diff-base.d.ts +18 -0
  194. package/dist/session/pr-review-diff-base.js +44 -0
  195. package/dist/session/pr-review-placement.d.ts +50 -0
  196. package/dist/session/pr-review-placement.js +91 -0
  197. package/dist/session/pre-publication-change-set.d.ts +62 -0
  198. package/dist/session/pre-publication-change-set.js +166 -0
  199. package/dist/session/pre-publication-host-load.d.ts +27 -0
  200. package/dist/session/pre-publication-host-load.js +112 -0
  201. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  202. package/dist/session/pre-publication-native-postgres.js +111 -0
  203. package/dist/session/pre-publication-pass.d.ts +61 -0
  204. package/dist/session/pre-publication-pass.js +148 -0
  205. package/dist/session/pre-publication-process.d.ts +3 -0
  206. package/dist/session/pre-publication-process.js +32 -19
  207. package/dist/session/pre-publication-step-execution.d.ts +12 -0
  208. package/dist/session/pre-publication-step-execution.js +50 -0
  209. package/dist/session/pre-publication-validation.d.ts +39 -22
  210. package/dist/session/pre-publication-validation.js +241 -207
  211. package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
  212. package/dist/session/provider-cli/claude-background-work.js +181 -0
  213. package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
  214. package/dist/session/provider-cli/dispatch-target-branch.js +8 -0
  215. package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
  216. package/dist/session/provider-cli/host-build-lock.js +30 -0
  217. package/dist/session/provider-cli/pr-review-credential-isolation.d.ts +83 -0
  218. package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
  219. package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
  220. package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
  221. package/dist/session/provider-cli/pr-review-prompt.d.ts +2 -0
  222. package/dist/session/provider-cli/pr-review-prompt.js +119 -0
  223. package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
  224. package/dist/session/provider-cli/pre-publication-repair.js +281 -0
  225. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  226. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  227. package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
  228. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  229. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  230. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
  231. package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
  232. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
  233. package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
  234. package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
  235. package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
  236. package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
  237. package/dist/session/provider-cli/provider-cli.process.js +41 -432
  238. package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -3
  239. package/dist/session/provider-cli/provider-cli.prompts.js +183 -90
  240. package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
  241. package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
  242. package/dist/session/provider-cli/provider-cli.runtime.d.ts +15 -0
  243. package/dist/session/provider-cli/provider-cli.runtime.js +43 -1
  244. package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
  245. package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
  246. package/dist/session/provider-cli/provider-cli.service.d.ts +18 -18
  247. package/dist/session/provider-cli/provider-cli.service.js +127 -317
  248. package/dist/session/provider-cli/provider-cli.types.d.ts +35 -0
  249. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  250. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  251. package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
  252. package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
  253. package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
  254. package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
  255. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  256. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  257. package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
  258. package/dist/session/provider-cli/provider-output-state.js +6 -0
  259. package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
  260. package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
  261. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  262. package/dist/session/qa-sidecar-validation.js +28 -0
  263. package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
  264. package/dist/session/sandbox-host-capacity-gate.js +279 -0
  265. package/dist/session/session-host-project.d.ts +22 -0
  266. package/dist/session/session-host-project.js +98 -0
  267. package/dist/session/session-redaction.js +31 -181
  268. package/dist/session/session.base.d.ts +9 -1
  269. package/dist/session/session.parse-helpers.d.ts +10 -0
  270. package/dist/session/session.parse-helpers.js +84 -0
  271. package/dist/session/session.runtime-refresh.d.ts +46 -0
  272. package/dist/session/session.runtime-refresh.js +116 -0
  273. package/dist/session/session.service.d.ts +16 -2
  274. package/dist/session/session.service.js +208 -155
  275. package/dist/session/session.types.d.ts +8 -0
  276. package/dist/session/session.types.js +13 -83
  277. package/dist/session/session.types.pr-review.d.ts +48 -0
  278. package/dist/session/session.types.pr-review.js +51 -0
  279. package/dist/session/sidecar-json-shape.d.ts +31 -0
  280. package/dist/session/sidecar-json-shape.js +217 -0
  281. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  282. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  283. package/dist/shared/fs/file-identity.d.ts +10 -0
  284. package/dist/shared/fs/file-identity.js +15 -0
  285. package/dist/shared/fs/replace-file.d.ts +7 -0
  286. package/dist/shared/fs/replace-file.js +33 -0
  287. package/dist/shared/process/host-process-recovery.d.ts +14 -3
  288. package/dist/shared/process/host-process-recovery.js +23 -3
  289. package/dist/shared/process/host-process-supervisor.d.ts +14 -1
  290. package/dist/shared/process/host-process-supervisor.js +67 -15
  291. package/dist/shared/process/process-tree.d.ts +52 -0
  292. package/dist/shared/process/process-tree.js +144 -0
  293. package/dist/shared/process/process.d.ts +67 -0
  294. package/dist/shared/process/process.js +213 -11
  295. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  296. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  297. package/dist/shared/process/windows-launch.d.ts +18 -0
  298. package/dist/shared/process/windows-launch.js +68 -0
  299. package/dist/shared/provider-capabilities.d.ts +2 -0
  300. package/dist/shared/provider-capabilities.js +23 -7
  301. package/dist/version.d.ts +1 -1
  302. package/dist/version.js +1 -1
  303. package/dist/worktree/artifact-injector.js +24 -0
  304. package/dist/worktree/dependency-warmer.d.ts +25 -0
  305. package/dist/worktree/dependency-warmer.js +46 -10
  306. package/dist/worktree/orphan-relink.d.ts +19 -0
  307. package/dist/worktree/orphan-relink.js +106 -0
  308. package/dist/worktree/wip-git.d.ts +58 -0
  309. package/dist/worktree/wip-git.js +182 -0
  310. package/dist/worktree/wip-refs.d.ts +85 -0
  311. package/dist/worktree/wip-refs.js +169 -0
  312. package/dist/worktree/wip-restore.d.ts +51 -0
  313. package/dist/worktree/wip-restore.js +324 -0
  314. package/dist/worktree/wip-snapshot.d.ts +53 -0
  315. package/dist/worktree/wip-snapshot.js +270 -0
  316. package/dist/worktree/worktree-inputs.d.ts +8 -0
  317. package/dist/worktree/worktree-inputs.js +134 -0
  318. package/dist/worktree/worktree-origin-sync.d.ts +35 -0
  319. package/dist/worktree/worktree-origin-sync.js +128 -0
  320. package/dist/worktree/worktree-wip-events.d.ts +20 -0
  321. package/dist/worktree/worktree-wip-events.js +148 -0
  322. package/dist/worktree/worktree-wip.d.ts +57 -0
  323. package/dist/worktree/worktree-wip.js +200 -0
  324. package/dist/worktree/worktree.base.d.ts +7 -1
  325. package/dist/worktree/worktree.service.d.ts +58 -5
  326. package/dist/worktree/worktree.service.js +237 -161
  327. package/dist/worktree/worktree.types.d.ts +54 -0
  328. package/package.json +2 -2
  329. package/runtime/windows-listener-owner.ps1 +12 -1
@@ -3,6 +3,8 @@ import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { debugCompletionPhaseOrder, debugGateToolNames, decomposeCompletionGateOrder, decomposeGateToolNames, draftCompletionGateOrder, draftGateToolNames, qaCompletionGateOrder, qaGateToolNames, resolvedFindingStatuses } from "./phase-completion.js";
6
+ import { structuredTypeHint } from "./mcp-argument-coercion.js";
7
+ import { completionPhaseFromAlias, singleGatePhaseFromToolName } from "./phase-completion.phase-aliases.js";
6
8
  export function normalizeArtifactPayload(payload, defaults) {
7
9
  const normalized = stripUndefined({ ...payload });
8
10
  delete normalized.report_markdown;
@@ -60,38 +62,7 @@ ${summary}
60
62
  }
61
63
  export function parseStrictCompletionPhase(value) {
62
64
  const normalized = (value ?? "").trim().toLowerCase().replace(/-/g, "_");
63
- const debugPhase = normalizeDebugCompletionPhase(normalized);
64
- if (debugPhase) {
65
- return debugPhase;
66
- }
67
- if (normalized === "implementation" || normalized === "implement" || normalized === "develop") {
68
- return "implementation";
69
- }
70
- if (normalized === "self_review" || normalized === "selfreview" || normalized === "review") {
71
- return "self_review";
72
- }
73
- if (normalized === "validate" || normalized === "validation") {
74
- return "validation";
75
- }
76
- if (normalized === "qa" || normalized === "quality_assurance" || normalized === "qualityassurance") {
77
- return "qa";
78
- }
79
- if (normalized === "architect" || normalized === "architect_plan" || normalized === "planning" || normalized === "plan") {
80
- return "architect";
81
- }
82
- if (normalized === "draft" || normalized === "drafting" || normalized === "draft_work_order") {
83
- return "draft";
84
- }
85
- if (normalized === "decompose" || normalized === "decomposition" || normalized === "work_order_decomposition" || normalized === "feature_decomposition") {
86
- return "decompose";
87
- }
88
- if (normalized === "ci_repair" || normalized === "pr_checks" || normalized === "repair_pr_checks") {
89
- return "ci_repair";
90
- }
91
- if (normalized === "comment_repair" || normalized === "pr_comments" || normalized === "repair_pr_comments") {
92
- return "comment_repair";
93
- }
94
- return null;
65
+ return normalizeDebugCompletionPhase(normalized) ?? completionPhaseFromAlias(normalized);
95
66
  }
96
67
  export function normalizeDebugCompletionPhase(value) {
97
68
  const normalized = (value ?? "").trim().toLowerCase().replace(/-/g, "_");
@@ -146,27 +117,9 @@ export function parseCompletionRedactionSecrets(raw) {
146
117
  }
147
118
  }
148
119
  export function phaseFromToolName(toolName) {
149
- const normalized = toolName.trim().toLowerCase();
150
- if (normalized === "forge.complete_implementation" || normalized === "complete_implementation") {
151
- return "implementation";
152
- }
153
- if (normalized === "forge.complete_self_review" || normalized === "complete_self_review") {
154
- return "self_review";
155
- }
156
- if (normalized === "forge.complete_validation" || normalized === "complete_validation") {
157
- return "validation";
158
- }
159
- if (normalized === "forge.complete_qa" || normalized === "complete_qa") {
160
- return "qa";
161
- }
162
- if (normalized === "forge.complete_architect_plan" || normalized === "complete_architect_plan") {
163
- return "architect";
164
- }
165
- if (normalized === "forge.complete_ci_repair" || normalized === "complete_ci_repair") {
166
- return "ci_repair";
167
- }
168
- if (normalized === "forge.complete_comment_repair" || normalized === "complete_comment_repair") {
169
- return "comment_repair";
120
+ const singleGatePhase = singleGatePhaseFromToolName(toolName);
121
+ if (singleGatePhase) {
122
+ return singleGatePhase;
170
123
  }
171
124
  if (draftGateFromToolName(toolName)) {
172
125
  return "draft";
@@ -310,7 +263,7 @@ export function throwCompletionPayloadIssues(issues) {
310
263
  }
311
264
  export function requireArray(payload, key) {
312
265
  if (!Array.isArray(payload[key])) {
313
- throw new Error(`${key} must be an array.`);
266
+ throw new Error(`${key} must be an array${structuredTypeHint(payload[key], "array")}.`);
314
267
  }
315
268
  }
316
269
  export function requireNonEmptyArray(payload, key) {
@@ -332,7 +285,7 @@ export function requireAllowedStatus(payload, key, allowed) {
332
285
  export function requireObject(payload, key) {
333
286
  const value = payload[key];
334
287
  if (!value || typeof value !== "object" || Array.isArray(value)) {
335
- throw new Error(`${key} must be an object.`);
288
+ throw new Error(`${key} must be an object${structuredTypeHint(value, "object")}.`);
336
289
  }
337
290
  }
338
291
  export function requiredRecord(payload, key) {
@@ -372,12 +325,12 @@ export function validateResolvedFindings(payload) {
372
325
  return;
373
326
  }
374
327
  if (!Array.isArray(resolvedFindings)) {
375
- throw new Error("resolved_findings must be an array.");
328
+ throw new Error(`resolved_findings must be an array${structuredTypeHint(resolvedFindings, "array")}.`);
376
329
  }
377
330
  for (const [index, finding] of resolvedFindings.entries()) {
378
331
  const prefix = `resolved_findings[${index}].`;
379
332
  if (!finding || typeof finding !== "object" || Array.isArray(finding)) {
380
- throw new Error(`resolved_findings[${index}] must be an object.`);
333
+ throw new Error(`resolved_findings[${index}] must be an object${structuredTypeHint(finding, "object")}.`);
381
334
  }
382
335
  const record = finding;
383
336
  requireNonEmptyStringRecord(record, "qa_id", prefix);
@@ -409,14 +362,14 @@ export function qaArray(payload, key, fallback = {}) {
409
362
  return [];
410
363
  }
411
364
  if (!Array.isArray(value)) {
412
- throw new Error(`${key} must be an array.`);
365
+ throw new Error(`${key} must be an array${structuredTypeHint(value, "array")}.`);
413
366
  }
414
367
  return value;
415
368
  }
416
369
  export function qaObjectArray(payload, key) {
417
370
  return qaArray(payload, key).map((entry, index) => {
418
371
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
419
- throw new Error(`${key}[${index}] must be an object.`);
372
+ throw new Error(`${key}[${index}] must be an object${structuredTypeHint(entry, "object")}.`);
420
373
  }
421
374
  return entry;
422
375
  });
@@ -424,7 +377,7 @@ export function qaObjectArray(payload, key) {
424
377
  export function qaPolicyWarnings(payload) {
425
378
  return qaArray(payload, "policy_warnings").map((entry, index) => {
426
379
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
427
- throw new Error(`policy_warnings[${index}] must be an object.`);
380
+ throw new Error(`policy_warnings[${index}] must be an object${structuredTypeHint(entry, "object")}.`);
428
381
  }
429
382
  const warning = entry;
430
383
  const prefix = `policy_warnings[${index}].`;
@@ -448,7 +401,7 @@ export function qaStringArray(payload, key) {
448
401
  return [];
449
402
  }
450
403
  if (!Array.isArray(value)) {
451
- throw new Error(`${key} must be an array.`);
404
+ throw new Error(`${key} must be an array${structuredTypeHint(value, "array")}.`);
452
405
  }
453
406
  return value.map((entry, index) => {
454
407
  if (typeof entry !== "string" || entry.trim().length === 0) {
@@ -459,7 +412,7 @@ export function qaStringArray(payload, key) {
459
412
  }
460
413
  export function requireEvidenceRecord(value, label) {
461
414
  if (!value || typeof value !== "object" || Array.isArray(value)) {
462
- throw new Error(`${label} must be an object.`);
415
+ throw new Error(`${label} must be an object${structuredTypeHint(value, "object")}.`);
463
416
  }
464
417
  }
465
418
  export function requireNonEmptyStringRecord(source, key, prefix = "") {
@@ -469,7 +422,7 @@ export function requireNonEmptyStringRecord(source, key, prefix = "") {
469
422
  }
470
423
  export function requireArrayRecord(source, key, prefix = "") {
471
424
  if (!Array.isArray(source[key])) {
472
- throw new Error(`${prefix}${key} must be an array.`);
425
+ throw new Error(`${prefix}${key} must be an array${structuredTypeHint(source[key], "array")}.`);
473
426
  }
474
427
  }
475
428
  export function requireKnownStringRecord(source, key, allowed, prefix = "") {
@@ -497,7 +450,7 @@ export function requireSubstantiveValueRecord(source, key, prefix = "") {
497
450
  export function requireSubstantiveEvidenceRecord(source, prefix = "") {
498
451
  const evidence = source.evidence;
499
452
  if (!evidence || typeof evidence !== "object" || Array.isArray(evidence)) {
500
- throw new Error(`${prefix}evidence must be an object.`);
453
+ throw new Error(`${prefix}evidence must be an object${structuredTypeHint(evidence, "object")}, for example {"summary": "...", "screenshot": "..."}.`);
501
454
  }
502
455
  if (!Object.values(evidence).some(hasSubstantiveJsonValue)) {
503
456
  throw new Error(`${prefix}evidence must include at least one concrete evidence reference or summary.`);
@@ -587,7 +540,7 @@ export function parseOptionalJsonObject(content, label) {
587
540
  }
588
541
  export function asRecord(value, label) {
589
542
  if (!value || typeof value !== "object" || Array.isArray(value)) {
590
- throw new Error(`${label} must be an object.`);
543
+ throw new Error(`${label} must be an object${structuredTypeHint(value, "object")}.`);
591
544
  }
592
545
  return value;
593
546
  }
@@ -1,9 +1,12 @@
1
1
  import path from "node:path";
2
+ import { completionPhaseFromAlias } from "./phase-completion.phase-aliases.js";
2
3
  import { artifactOwnerDirectory, isDebugCompletionPhase, normalizeDebugCompletionPhase, safePathSegment } from "./phase-completion.validation.js";
3
4
  export { isDebugCompletionPhase } from "./phase-completion.validation.js";
4
5
  export { readCompletionArtifact, writeCompletionArtifact } from "./phase-completion.artifacts.js";
6
+ export { recordedPrReviewArtifactProblem } from "./phase-completion.pr-review.js";
5
7
  export * from "./phase-completion.prompts.js";
6
8
  export * from "./phase-completion.runtime.js";
9
+ export * from "./phase-completion.mcp-args.js";
7
10
  export const toolServerName = "forge";
8
11
  export const completionRedactionSecretsEnv = "FORGE_COMPLETION_REDACTION_SECRETS";
9
12
  export const completionPhaseOrder = ["implementation", "self_review", "validation"];
@@ -40,6 +43,10 @@ export const decomposeCompletionGateOrder = [
40
43
  "decompose_critic",
41
44
  "decompose_proposal"
42
45
  ];
46
+ // Statuses the Draft and Decompose gate tools advertise and accept. Decompose adds fail/failed;
47
+ // every status except pass records rework, never a pass.
48
+ export const draftStatuses = ["pass", "needs_revision", "needs_rework", "blocked"];
49
+ export const decomposeStatuses = ["pass", "needs_rework", "fail", "failed", "needs_revision", "blocked"];
43
50
  export const decomposeGateFileNames = {
44
51
  decompose_subject_intake: "decompose.subject-intake.json",
45
52
  decompose_context_review: "decompose.context-review.json",
@@ -205,42 +212,20 @@ export const phaseFiles = {
205
212
  comment_repair: {
206
213
  jsonFileName: "comment-repair.handoff.json",
207
214
  reportFileName: "comment-repair.report.md"
215
+ },
216
+ pr_review: {
217
+ jsonFileName: "pr-review.result.json",
218
+ reportFileName: "pr-review.report.md"
208
219
  }
209
220
  };
221
+ /** Statuses `forge.complete_pr_review` accepts; each one ends the review lane. */
222
+ export const prReviewStatuses = ["reviewed", "stale_head", "blocked"];
210
223
  export function completionPhaseFromDispatch(dispatch) {
211
224
  return normalizeCompletionPhase(dispatch.cycleRun.phase || dispatch.execution.lane || dispatch.execution.role);
212
225
  }
213
226
  export function normalizeCompletionPhase(value) {
214
227
  const normalized = (value ?? "").trim().toLowerCase().replace(/-/g, "_");
215
- const debugPhase = normalizeDebugCompletionPhase(normalized);
216
- if (debugPhase) {
217
- return debugPhase;
218
- }
219
- if (normalized === "self_review" || normalized === "selfreview" || normalized === "review") {
220
- return "self_review";
221
- }
222
- if (normalized === "validate" || normalized === "validation") {
223
- return "validation";
224
- }
225
- if (normalized === "qa" || normalized === "quality_assurance" || normalized === "qualityassurance") {
226
- return "qa";
227
- }
228
- if (normalized === "architect" || normalized === "architect_plan" || normalized === "planning" || normalized === "plan") {
229
- return "architect";
230
- }
231
- if (normalized === "draft" || normalized === "drafting" || normalized === "draft_work_order") {
232
- return "draft";
233
- }
234
- if (normalized === "decompose" || normalized === "decomposition" || normalized === "work_order_decomposition" || normalized === "feature_decomposition") {
235
- return "decompose";
236
- }
237
- if (normalized === "ci_repair" || normalized === "pr_checks" || normalized === "repair_pr_checks") {
238
- return "ci_repair";
239
- }
240
- if (normalized === "comment_repair" || normalized === "pr_comments" || normalized === "repair_pr_comments") {
241
- return "comment_repair";
242
- }
243
- return "implementation";
228
+ return normalizeDebugCompletionPhase(normalized) ?? completionPhaseFromAlias(normalized) ?? "implementation";
244
229
  }
245
230
  export function usesDevelopCycleCompletion(dispatch) {
246
231
  const kind = dispatch.cycleRun.kind.trim().toLowerCase();
@@ -295,9 +280,11 @@ export function completionToolNamesForPhase(phase) {
295
280
  ? "complete_ci_repair"
296
281
  : phase === "comment_repair"
297
282
  ? "complete_comment_repair"
298
- : phase === "architect"
299
- ? "complete_architect_plan"
300
- : "complete_qa";
283
+ : phase === "pr_review"
284
+ ? "complete_pr_review"
285
+ : phase === "architect"
286
+ ? "complete_architect_plan"
287
+ : "complete_qa";
301
288
  return [`forge.${base}`, base];
302
289
  }
303
290
  export function completionToolNamesForQaGate(gate) {
@@ -0,0 +1,9 @@
1
+ import { type CompletionToolServerConfig } from "./phase-completion.js";
2
+ export declare function buildCompletionToolServerArgs(config: CompletionToolServerConfig): readonly string[];
3
+ export declare function parseCompletionMcpArgs(argv: readonly string[]): {
4
+ readonly ok: true;
5
+ readonly config: CompletionToolServerConfig;
6
+ } | {
7
+ readonly ok: false;
8
+ readonly error: string;
9
+ };
@@ -0,0 +1,195 @@
1
+ import path from "node:path";
2
+ import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
3
+ import { completionRedactionSecretsEnv, } from "./phase-completion.js";
4
+ import { isDebugCompletionPhase, isDevelopCompletionPhase, normalizedOwnerType, parseCompletionRedactionSecrets, parseStrictCompletionPhase, } from "./phase-completion.validation.js";
5
+ // The `forge-bridge mcp` command line: the arguments the Bridge launches its completion-tool server
6
+ // with, and the parsing that server applies to them.
7
+ export function buildCompletionToolServerArgs(config) {
8
+ const args = [
9
+ "mcp",
10
+ "--worktree",
11
+ path.resolve(config.worktreePath),
12
+ "--work-item-id",
13
+ config.workItemId,
14
+ "--phase",
15
+ config.phase,
16
+ "--produced-by",
17
+ config.producedBy ?? "forge-completion-tool"
18
+ ];
19
+ if (config.ownerType || config.ownerId) {
20
+ args.push("--owner-type", normalizedOwnerType(config.ownerType) ?? "work_item");
21
+ args.push("--owner-id", config.ownerId ?? config.workItemId);
22
+ }
23
+ if (config.developCycle) {
24
+ args.push("--develop-cycle");
25
+ }
26
+ if (config.qaCycle) {
27
+ args.push("--qa-cycle");
28
+ }
29
+ if (config.debugCycle) {
30
+ args.push("--debug-cycle");
31
+ }
32
+ if (config.architectCycle) {
33
+ args.push("--architect-cycle");
34
+ }
35
+ if (config.draftCycle) {
36
+ args.push("--draft-cycle");
37
+ }
38
+ if (config.decomposeCycle) {
39
+ args.push("--decompose-cycle");
40
+ }
41
+ if (config.managedToolsOnly) {
42
+ args.push("--managed-tools-only");
43
+ }
44
+ if (config.prReview?.headSha) {
45
+ args.push("--pr-review-head", config.prReview.headSha);
46
+ }
47
+ if (config.prReview?.baseSha) {
48
+ args.push("--pr-review-base", config.prReview.baseSha);
49
+ }
50
+ for (const threadId of config.prReview?.threadIds ?? []) {
51
+ args.push("--pr-review-thread", threadId);
52
+ }
53
+ return args;
54
+ }
55
+ const completionMcpFlags = {
56
+ "--develop-cycle": "developCycle",
57
+ "--qa-cycle": "qaCycle",
58
+ "--debug-cycle": "debugCycle",
59
+ "--architect-cycle": "architectCycle",
60
+ "--draft-cycle": "draftCycle",
61
+ "--decompose-cycle": "decomposeCycle",
62
+ "--managed-tools-only": "managedToolsOnly",
63
+ };
64
+ const completionMcpValues = {
65
+ "--worktree": "worktreePath",
66
+ "--work-item-id": "workItemId",
67
+ "--owner-id": "ownerId",
68
+ "--produced-by": "producedBy",
69
+ };
70
+ export function parseCompletionMcpArgs(argv) {
71
+ let phase = "implementation";
72
+ let ownerType;
73
+ const values = {};
74
+ const prReview = { threadIds: [] };
75
+ const flags = {
76
+ developCycle: false,
77
+ qaCycle: false,
78
+ debugCycle: false,
79
+ architectCycle: false,
80
+ draftCycle: false,
81
+ decomposeCycle: false,
82
+ managedToolsOnly: false,
83
+ };
84
+ for (let index = 1; index < argv.length; index += 1) {
85
+ const arg = argv[index];
86
+ if (Object.hasOwn(completionMcpFlags, arg)) {
87
+ flags[completionMcpFlags[arg]] = true;
88
+ }
89
+ else if (Object.hasOwn(completionMcpValues, arg)) {
90
+ values[completionMcpValues[arg]] = argv[++index];
91
+ }
92
+ else if (applyPrReviewArg(prReview, arg, () => argv[++index])) {
93
+ continue;
94
+ }
95
+ else if (arg === "--owner-type") {
96
+ ownerType = normalizedOwnerType(argv[++index]);
97
+ if (!ownerType) {
98
+ return { ok: false, error: "mcp --owner-type must be work_item or story." };
99
+ }
100
+ }
101
+ else if (arg === "--phase") {
102
+ const rawPhase = argv[++index];
103
+ const parsedPhase = parseStrictCompletionPhase(rawPhase);
104
+ if (!parsedPhase) {
105
+ return { ok: false, error: "mcp --phase must be one of: implementation, self-review, validation, qa, architect, draft, decompose, ci-repair, comment-repair, pr-review, debug-repro, debug-root-cause, debug-fix, debug-regression." };
106
+ }
107
+ phase = parsedPhase;
108
+ }
109
+ else {
110
+ return { ok: false, error: `Unknown mcp argument: ${arg}` };
111
+ }
112
+ }
113
+ const { worktreePath, workItemId, ownerId, producedBy } = values;
114
+ if (!worktreePath?.trim() || !workItemId?.trim()) {
115
+ return { ok: false, error: "mcp requires --worktree and --work-item-id." };
116
+ }
117
+ const { managedToolsOnly, ...cycles } = flags;
118
+ const config = {
119
+ worktreePath: path.resolve(worktreePath),
120
+ workItemId,
121
+ ownerType,
122
+ ownerId,
123
+ phase,
124
+ producedBy,
125
+ redactionSecrets: redactionSecretsFromEnvironment(),
126
+ ...cycles,
127
+ ...(managedToolsOnly ? { managedToolsOnly } : {}),
128
+ ...prReviewConfig(prReview)
129
+ };
130
+ const modeError = completionMcpModeError(config);
131
+ return modeError ? { ok: false, error: modeError } : { ok: true, config };
132
+ }
133
+ /** Applies one pr_review dispatch-context flag; false when the flag is not one of them. */
134
+ function applyPrReviewArg(state, arg, next) {
135
+ switch (arg) {
136
+ case "--pr-review-head":
137
+ state.headSha = next()?.trim() || undefined;
138
+ return true;
139
+ case "--pr-review-base":
140
+ state.baseSha = next()?.trim() || undefined;
141
+ return true;
142
+ case "--pr-review-thread": {
143
+ const threadId = next()?.trim();
144
+ if (threadId)
145
+ state.threadIds.push(threadId);
146
+ return true;
147
+ }
148
+ default:
149
+ return false;
150
+ }
151
+ }
152
+ function prReviewConfig(state) {
153
+ const { headSha, baseSha, threadIds } = state;
154
+ return headSha || baseSha || threadIds.length > 0
155
+ ? { prReview: { headSha, baseSha, threadIds: threadIds.length > 0 ? threadIds : undefined } }
156
+ : {};
157
+ }
158
+ /** The secrets the server redacts from what it records: the Bridge's list and the attempt database capability. */
159
+ function redactionSecretsFromEnvironment() {
160
+ return [
161
+ ...parseCompletionRedactionSecrets(process.env[completionRedactionSecretsEnv]),
162
+ ...attemptDatabaseCapabilitySecrets(process.env[attemptDatabaseCapabilityEnvironment]),
163
+ ];
164
+ }
165
+ /** Why the parsed cycle mode, phase and tool scope cannot run together, or null when they can. */
166
+ function completionMcpModeError(config) {
167
+ const { phase } = config;
168
+ const cycleModes = [config.developCycle, config.qaCycle, config.debugCycle, config.architectCycle, config.draftCycle, config.decomposeCycle]
169
+ .filter(Boolean).length;
170
+ if (cycleModes > 1) {
171
+ return "mcp accepts only one cycle mode.";
172
+ }
173
+ if (config.managedToolsOnly && cycleModes > 0) {
174
+ return "mcp --managed-tools-only serves no completion tools, so it accepts no cycle mode.";
175
+ }
176
+ if (config.developCycle && !isDevelopCompletionPhase(phase)) {
177
+ return "mcp --develop-cycle requires --phase implementation, self-review, or validation.";
178
+ }
179
+ if (config.qaCycle && phase !== "qa") {
180
+ return "mcp --qa-cycle requires --phase qa.";
181
+ }
182
+ if (config.debugCycle && !isDebugCompletionPhase(phase)) {
183
+ return "mcp --debug-cycle requires --phase debug-repro, debug-root-cause, debug-fix, or debug-regression.";
184
+ }
185
+ if (config.architectCycle && phase !== "architect") {
186
+ return "mcp --architect-cycle requires --phase architect.";
187
+ }
188
+ if (config.draftCycle && phase !== "draft") {
189
+ return "mcp --draft-cycle requires --phase draft.";
190
+ }
191
+ if (config.decomposeCycle && phase !== "decompose") {
192
+ return "mcp --decompose-cycle requires --phase decompose.";
193
+ }
194
+ return null;
195
+ }
@@ -0,0 +1,5 @@
1
+ import type { CompletionPhase } from "./phase-completion.js";
2
+ /** Resolves an already-normalized (trimmed, lower-case, underscore) phase alias, or null. */
3
+ export declare function completionPhaseFromAlias(normalized: string): CompletionPhase | null;
4
+ /** Resolves a fixed single-gate completion tool name (with or without the forge. prefix), or null. */
5
+ export declare function singleGatePhaseFromToolName(toolName: string): CompletionPhase | null;
@@ -0,0 +1,43 @@
1
+ // Table-driven phase aliases and tool names. Debug phases are resolved separately because they
2
+ // have their own normalizer. Aliases are disjoint, so lookup order never changes a result.
3
+ const phaseAliases = [
4
+ ["implementation", ["implementation", "implement", "develop"]],
5
+ ["self_review", ["self_review", "selfreview", "review"]],
6
+ ["validation", ["validate", "validation"]],
7
+ ["qa", ["qa", "quality_assurance", "qualityassurance"]],
8
+ ["architect", ["architect", "architect_plan", "planning", "plan"]],
9
+ ["draft", ["draft", "drafting", "draft_work_order"]],
10
+ ["decompose", ["decompose", "decomposition", "work_order_decomposition", "feature_decomposition"]],
11
+ ["ci_repair", ["ci_repair", "pr_checks", "repair_pr_checks"]],
12
+ ["comment_repair", ["comment_repair", "pr_comments", "repair_pr_comments"]],
13
+ ["pr_review", ["pr_review", "prreview", "pull_request_review"]]
14
+ ];
15
+ /** Resolves an already-normalized (trimmed, lower-case, underscore) phase alias, or null. */
16
+ export function completionPhaseFromAlias(normalized) {
17
+ for (const [phase, aliases] of phaseAliases) {
18
+ if (aliases.includes(normalized)) {
19
+ return phase;
20
+ }
21
+ }
22
+ return null;
23
+ }
24
+ const phaseToolNames = [
25
+ ["implementation", "complete_implementation"],
26
+ ["self_review", "complete_self_review"],
27
+ ["validation", "complete_validation"],
28
+ ["qa", "complete_qa"],
29
+ ["architect", "complete_architect_plan"],
30
+ ["ci_repair", "complete_ci_repair"],
31
+ ["comment_repair", "complete_comment_repair"],
32
+ ["pr_review", "complete_pr_review"]
33
+ ];
34
+ /** Resolves a fixed single-gate completion tool name (with or without the forge. prefix), or null. */
35
+ export function singleGatePhaseFromToolName(toolName) {
36
+ const normalized = toolName.trim().toLowerCase();
37
+ for (const [phase, base] of phaseToolNames) {
38
+ if (normalized === `forge.${base}` || normalized === base) {
39
+ return phase;
40
+ }
41
+ }
42
+ return null;
43
+ }
@@ -0,0 +1 @@
1
+ export declare function prReviewToolInputSchema(): unknown;
@@ -0,0 +1,75 @@
1
+ import { evidenceObjectSchema, objectToolSchema } from "./phase-completion.schema-parts.js";
2
+ export function prReviewToolInputSchema() {
3
+ const stringArray = { type: "array", items: { type: "string" } };
4
+ return objectToolSchema({
5
+ status: {
6
+ type: "string",
7
+ enum: ["reviewed", "stale_head", "blocked"],
8
+ description: "reviewed for a completed review. stale_head when `git rev-parse HEAD` differs from the dispatched head_sha (set head_sha to what you found). blocked, with a reason, when the diff cannot be read."
9
+ },
10
+ head_sha: { type: "string", description: "Full sha of the head you reviewed: the output of `git rev-parse HEAD`. Must be the dispatched head for status reviewed." },
11
+ base_sha: { type: "string", description: "The dispatched base sha you diffed against." },
12
+ review_effort: { type: "string", enum: ["lite", "standard", "deep"] },
13
+ verdict: { type: "string", enum: ["changes_recommended", "needs_closer_look", "approval_recommended"], description: "changes_recommended exactly when there is an open issue: a finding in this payload or a prior thread that is still_open or reintroduced." },
14
+ verdict_reason: { type: "string", description: "One sentence naming the open issues, or why approval is or is not recommended." },
15
+ summary: { type: "string", description: "A paragraph on what the pull request does." },
16
+ reason: { type: "string", description: "Required for status blocked: why the review could not be done." },
17
+ changes: { ...stringArray, description: "The main changes, as short bullets." },
18
+ files: {
19
+ type: "array",
20
+ description: "The reviewed files with a short description each.",
21
+ items: evidenceObjectSchema(["path", "description"], { path: { type: "string" }, description: { type: "string" } })
22
+ },
23
+ findings: {
24
+ type: "array",
25
+ description: "New inline comments only; may be empty. Every line must be on the new side of the pull request diff.",
26
+ items: evidenceObjectSchema(["path", "line", "side", "severity", "category", "title", "body"], {
27
+ path: { type: "string" },
28
+ line: { type: "integer", minimum: 1, description: "A line on the new side of the PR diff (a changed or context line inside a hunk)." },
29
+ start_line: { type: ["integer", "null"], minimum: 1, description: "First line of a multi-line range inside the same hunk, or null." },
30
+ side: { type: "string", enum: ["RIGHT"] },
31
+ severity: { type: "string", enum: ["high", "medium", "low"] },
32
+ category: { type: "string", enum: ["correctness", "security", "contract", "tests", "data", "docs"] },
33
+ title: { type: "string", description: "At most about 70 characters naming the defect." },
34
+ body: { type: "string", description: "The inline comment: defect, concrete scenario, evidence as path:line, and what to change." },
35
+ also_at: {
36
+ type: "array",
37
+ items: evidenceObjectSchema(["path", "line"], { path: { type: "string" }, line: { type: "integer", minimum: 1 } })
38
+ },
39
+ suggestion: { type: ["string", "null"] }
40
+ })
41
+ },
42
+ prior_threads: {
43
+ type: "array",
44
+ description: "Prior review threads from the dispatch, by thread_id. Still-open threads belong here, not in findings.",
45
+ items: evidenceObjectSchema(["thread_id", "status"], {
46
+ thread_id: { type: "string" },
47
+ status: { type: "string", enum: ["resolved_since_last_review", "still_open", "reintroduced"] }
48
+ })
49
+ },
50
+ tests_checked: {
51
+ type: "array",
52
+ description: "New or changed test assertions you traced to production code. produced_at \"not produced\" needs a matching tests finding.",
53
+ items: evidenceObjectSchema(["test", "assertion", "produced_at"], { test: { type: "string" }, assertion: { type: "string" }, produced_at: { type: "string" } })
54
+ },
55
+ security_review: {
56
+ type: "object",
57
+ additionalProperties: true,
58
+ description: "Required on every reviewed payload, including reviews with no findings.",
59
+ properties: {
60
+ status: { type: "string", enum: ["findings", "no_findings"], description: "findings exactly when some finding has category security." },
61
+ checked: stringArray,
62
+ keys_checked: {
63
+ type: "array",
64
+ items: evidenceObjectSchema(["key", "per_user_data", "includes_user"], { key: { type: "string" }, per_user_data: { type: "boolean" }, includes_user: { type: "boolean" } })
65
+ },
66
+ notes: { type: "string" }
67
+ },
68
+ required: ["status", "checked", "keys_checked", "notes"]
69
+ },
70
+ skipped_files: {
71
+ type: "array",
72
+ items: evidenceObjectSchema(["path", "reason"], { path: { type: "string" }, reason: { type: "string" } })
73
+ }
74
+ }, ["status"], "For status reviewed, include head_sha, base_sha, review_effort, verdict, verdict_reason, summary, changes, files, findings, security_review. For stale_head include head_sha. For blocked include reason. Forge rejects a head_sha that is not the checked-out head, non-RIGHT sides, lines off the diff, a verdict that contradicts the open issues, and unknown prior thread ids; fix the fields it names and call again.");
75
+ }
@@ -0,0 +1,11 @@
1
+ import type { PrReviewCompletionContext, PrReviewStatus } from "./phase-completion.js";
2
+ /** Per-finding limits; Forge's API applies the same ones (PrReviewArtifactValidator.MaximumFindingTextCharacters). */
3
+ export declare const prReviewMaximumFindingTextCharacters: number;
4
+ /**
5
+ * Shape and consistency rules for `forge.complete_pr_review`. Anything that needs the
6
+ * repository (the worktree head, the diff lines) is checked separately, after this passes.
7
+ *
8
+ * `stale_head` and `blocked` are terminal outcomes, not reviews: they need only enough
9
+ * evidence to explain themselves. A `reviewed` payload is held to the skill's full contract.
10
+ */
11
+ export declare function validatePrReviewPayloadShape(payload: Record<string, unknown>, status: PrReviewStatus, context?: PrReviewCompletionContext | undefined): void;