gentle-pi 4.5.1 → 4.7.0

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 (428) hide show
  1. package/README.md +17 -15
  2. package/assets/agents/gentle-ai-explore.md +1 -0
  3. package/assets/agents/gentle-ai-verify.md +8 -1
  4. package/assets/agents/gentle-ai-worker.md +4 -0
  5. package/assets/agents/jd-fix-agent.md +1 -0
  6. package/assets/agents/jd-judge-a.md +1 -0
  7. package/assets/agents/jd-judge-b.md +1 -0
  8. package/assets/design-canvas/canvas.css +13 -1
  9. package/assets/design-canvas/canvas.js +11 -2
  10. package/assets/install-wizard/wizard.js +1 -0
  11. package/assets/migrations/agent-body-history.json +162 -0
  12. package/assets/orchestrator-delegation-reference.md +7 -7
  13. package/assets/orchestrator-delegation.md +3 -3
  14. package/assets/orchestrator-full-delegation-card.md +65 -0
  15. package/assets/orchestrator-full-delegation.md +34 -0
  16. package/assets/orchestrator-memory.md +3 -3
  17. package/assets/orchestrator-prompts.md +1 -1
  18. package/assets/orchestrator-skills.md +1 -1
  19. package/assets/orchestrator-verification.md +14 -8
  20. package/assets/orchestrator.md +11 -11
  21. package/bin/gentle-shell.mjs +225 -82
  22. package/docs/agent-status.md +61 -0
  23. package/docs/bundled-install.md +7 -5
  24. package/docs/ci-performance.md +11 -0
  25. package/docs/delegated-verification.md +35 -7
  26. package/docs/fast-mode.md +15 -0
  27. package/docs/gentle-agents-activity.md +22 -0
  28. package/docs/gentle-shell.md +113 -25
  29. package/docs/install-wizard.md +2 -2
  30. package/docs/mcp-status.md +52 -0
  31. package/docs/permission-modes.md +9 -4
  32. package/docs/prompt-budget.md +28 -0
  33. package/docs/readme-reference.md +154 -50
  34. package/docs/render-cache-performance.md +11 -1
  35. package/docs/review-coordinator.md +33 -0
  36. package/docs/review-request-context.md +19 -0
  37. package/docs/review-windows-acl.md +18 -0
  38. package/docs/session-profile-format.md +20 -5
  39. package/docs/sound-notifications.md +1 -1
  40. package/docs/star-prompt.md +32 -0
  41. package/docs/voice.md +6 -3
  42. package/docs/work-continuity.md +46 -0
  43. package/docs/yolo-mode.md +5 -5
  44. package/extensions/ask-user-choice.ts +1 -0
  45. package/extensions/ask-user-question.ts +2 -0
  46. package/extensions/child-safety.ts +3 -0
  47. package/extensions/codegraph-tools.ts +38 -4
  48. package/extensions/gentle-agent-status.ts +99 -0
  49. package/extensions/gentle-agents.ts +803 -84
  50. package/extensions/gentle-ai.ts +2491 -596
  51. package/extensions/gentle-fast.ts +61 -0
  52. package/extensions/gentle-guide.ts +174 -0
  53. package/extensions/gentle-herdr-activity.ts +21 -1
  54. package/extensions/gentle-herdr-agent.ts +144 -0
  55. package/extensions/gentle-program-identity.ts +61 -0
  56. package/extensions/gentle-shell.ts +895 -120
  57. package/extensions/gentle-star-prompt.ts +334 -0
  58. package/extensions/gentle-stats.ts +5 -5
  59. package/extensions/gentle-todo.ts +59 -23
  60. package/extensions/gentle-tps.ts +48 -0
  61. package/extensions/history/store.ts +18 -12
  62. package/extensions/quiet-tools.ts +38 -8
  63. package/extensions/skill-registry.ts +210 -21
  64. package/extensions/startup-banner.ts +69 -10
  65. package/lib/agent-assets.ts +74 -17
  66. package/lib/agent-profile-pin.ts +3 -3
  67. package/lib/agent-profiles.ts +161 -3
  68. package/lib/agent-status.ts +105 -0
  69. package/lib/agents-config.ts +58 -3
  70. package/lib/agents-history.ts +24 -5
  71. package/lib/agents-keys.ts +8 -16
  72. package/lib/agents-messaging.ts +47 -5
  73. package/lib/agents-protocol.ts +80 -4
  74. package/lib/agents-runner.ts +287 -15
  75. package/lib/agents-view.ts +6 -1
  76. package/lib/agents-widget.ts +132 -9
  77. package/lib/auto-permission-runtime.ts +1 -1
  78. package/lib/bounded-writer-admission.ts +13 -1
  79. package/lib/bridge-cost.ts +28 -0
  80. package/lib/card-content-policy.ts +8 -6
  81. package/lib/codemode-renderer.ts +16 -0
  82. package/lib/command-palette-catalog.ts +1 -0
  83. package/lib/command-palette.ts +154 -25
  84. package/lib/context-backstop.ts +14 -5
  85. package/lib/destructive-command-guard.ts +48 -4
  86. package/lib/execution-surface-guard.ts +20 -0
  87. package/lib/exploration-budget.ts +64 -0
  88. package/lib/gentle-ai-binary.ts +1 -1
  89. package/lib/gentle-design.ts +3 -0
  90. package/lib/gentle-guide.ts +201 -0
  91. package/lib/gentle-shell-bundled.ts +6 -19
  92. package/lib/gentle-shell-launcher.ts +47 -8
  93. package/lib/herdr-activity.ts +23 -5
  94. package/lib/herdr-busy.ts +45 -0
  95. package/lib/herdr-task-summary-policy.ts +85 -0
  96. package/lib/image-attachments.ts +33 -0
  97. package/lib/image-disk-cache.ts +137 -0
  98. package/lib/inprocess-reviewer.ts +282 -132
  99. package/lib/jobs-sidebar-state.ts +5 -6
  100. package/lib/jobs-view.ts +198 -11
  101. package/lib/jobs-widget.ts +16 -52
  102. package/lib/keymaps-customize.ts +81 -0
  103. package/lib/keymaps.ts +291 -0
  104. package/lib/model-fallback-notice.ts +61 -0
  105. package/lib/model-fallback-policy.ts +141 -0
  106. package/lib/model-fallback-store.ts +143 -0
  107. package/lib/model-routing-authority.ts +32 -6
  108. package/lib/nan-provider.ts +3 -2
  109. package/lib/native-choice-list.ts +20 -2
  110. package/lib/native-review-cli.ts +103 -21
  111. package/lib/notification-customize.ts +48 -51
  112. package/lib/openai-fast-tier.ts +22 -0
  113. package/lib/orchestrator-discovery.ts +5 -1
  114. package/lib/orchestrator-fallback.ts +75 -0
  115. package/lib/orchestrator-mode-policy.ts +105 -0
  116. package/lib/pasted-image-paths.ts +113 -0
  117. package/lib/questionnaire/questionnaire-view.ts +225 -18
  118. package/lib/rdd-mode-control.ts +32 -0
  119. package/lib/reply-language-anchor.ts +104 -0
  120. package/lib/review-blocker.ts +92 -0
  121. package/lib/review-candidate-symlink-scan.ts +136 -0
  122. package/lib/review-candidate-view-owner.ts +85 -44
  123. package/lib/review-candidate-view.ts +10 -7
  124. package/lib/review-continuation-registry.ts +99 -0
  125. package/lib/review-coordinator.ts +163 -0
  126. package/lib/review-failure-facts.ts +49 -0
  127. package/lib/review-host-relay.ts +51 -11
  128. package/lib/review-integration-v2.ts +29 -8
  129. package/lib/review-relay-phase-timing.ts +45 -0
  130. package/lib/review-repository.ts +5 -0
  131. package/lib/review-start-context.ts +17 -0
  132. package/lib/session-profile-append-controller.ts +21 -6
  133. package/lib/session-profile-authority.ts +119 -0
  134. package/lib/session-profile-binding.ts +54 -5
  135. package/lib/session-profile-freeze.ts +107 -9
  136. package/lib/session-profile-integration.ts +313 -0
  137. package/lib/session-profile-persistence.ts +63 -9
  138. package/lib/shell-bar.ts +269 -72
  139. package/lib/shell-card.ts +26 -6
  140. package/lib/shell-changes.ts +2 -0
  141. package/lib/shell-page.ts +120 -0
  142. package/lib/shell-panel.ts +163 -0
  143. package/lib/shell-prompt.ts +53 -1
  144. package/lib/shell-sidebar-layout.ts +198 -53
  145. package/lib/shell-sidebar.ts +61 -1
  146. package/lib/shell-stats.ts +123 -0
  147. package/lib/shell-todo.ts +79 -1
  148. package/lib/shell-usage.ts +12 -2
  149. package/lib/star-prompt.ts +197 -0
  150. package/lib/verifier-admission.ts +18 -8
  151. package/lib/verifier-settle-reminder.ts +64 -0
  152. package/lib/vim-editor-adapter.ts +6 -1
  153. package/lib/visual-customization-policy.ts +67 -12
  154. package/lib/visual-customize-view.ts +373 -40
  155. package/lib/visual-layout-preview.ts +47 -0
  156. package/lib/visual-profiles.ts +2 -2
  157. package/lib/windows-session-transport.ts +53 -2
  158. package/lib/yolo-session-policy.ts +68 -16
  159. package/package.json +2 -1
  160. package/runtime/gentle-ai-binary.mjs +1 -1
  161. package/runtime/gentle-shell-bundled.mjs +6 -19
  162. package/runtime/gentle-shell-launcher.mjs +46 -7
  163. package/runtime/native-review-cli.mjs +100 -18
  164. package/runtime/review-integration-v2.mjs +29 -8
  165. package/runtime/windows-session-transport.ps1 +60 -3
  166. package/scripts/bootstrap.sh +4 -1
  167. package/scripts/build-full-delegation-card.mjs +175 -0
  168. package/scripts/bundled-install.mjs +38 -8
  169. package/scripts/download-progress.mjs +68 -0
  170. package/scripts/gentle-ai-installer.mjs +41 -18
  171. package/scripts/gentle-ai-proxy.mjs +294 -0
  172. package/scripts/install-gentle-ai.mjs +14 -1
  173. package/scripts/installer-preflight.mjs +6 -6
  174. package/scripts/installer-runner.mjs +27 -12
  175. package/scripts/installer-server.mjs +8 -7
  176. package/scripts/pi-update.mjs +113 -3
  177. package/scripts/render-cache-host.mjs +72 -0
  178. package/scripts/render-cache-performance-worker.mjs +5 -4
  179. package/scripts/render-cache-performance.mjs +6 -1
  180. package/scripts/run-test-suite.mjs +41 -13
  181. package/scripts/shell-snapshot.mjs +340 -0
  182. package/scripts/test-packed-runner.mjs +1 -1
  183. package/scripts/update-agent-body-history.mjs +41 -0
  184. package/scripts/verify-installer-tap.mjs +45 -0
  185. package/scripts/verify-package-files.mjs +14 -2
  186. package/scripts/voice-worker.cjs +32 -6
  187. package/skills/design/SKILL.md +11 -8
  188. package/skills/gentle-ai/SKILL.md +4 -4
  189. package/skills/gentle-ui-design/SKILL.md +46 -0
  190. package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
  191. package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
  192. package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
  193. package/skills/gentle-ui-design/references/task-and-content.md +60 -0
  194. package/skills/skill-registry/SKILL.md +4 -2
  195. package/skills/tui-design/NOTICE.md +5 -0
  196. package/skills/tui-design/SKILL.md +56 -0
  197. package/skills/tui-design/references/commands.md +75 -0
  198. package/skills/tui-design/references/critique.md +48 -0
  199. package/skills/tui-design/references/design-doc.md +44 -0
  200. package/skills/tui-design/references/terminal-craft.md +64 -0
  201. package/skills/tui-design/references/visual-loop.md +32 -0
  202. package/skills/work-unit-commits/SKILL.md +6 -7
  203. package/tests/agent-home.test.ts +28 -9
  204. package/tests/agent-profiles-workflow.test.ts +163 -0
  205. package/tests/agent-risk-escalation.test.ts +1 -1
  206. package/tests/agent-status.test.ts +143 -0
  207. package/tests/agents-config.test.ts +96 -0
  208. package/tests/agents-history.test.ts +31 -0
  209. package/tests/agents-jobs-frames.test.ts +93 -0
  210. package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
  211. package/tests/agents-protocol.test.ts +53 -1
  212. package/tests/agents-runner-drain.test.ts +193 -0
  213. package/tests/agents-runner.test.ts +345 -4
  214. package/tests/agents-view.test.ts +27 -0
  215. package/tests/agents-widget.test.ts +312 -10
  216. package/tests/append-system-prompt-route.test.ts +4 -1
  217. package/tests/ask-user-choice.test.ts +4 -3
  218. package/tests/ask-user-question.test.ts +97 -0
  219. package/tests/auto-permission-runtime.test.ts +1 -1
  220. package/tests/autonomous-guard.test.ts +346 -10
  221. package/tests/bounded-scan-contract.test.ts +39 -0
  222. package/tests/bounded-stop-contract.test.ts +43 -3
  223. package/tests/bridge-cost.test.ts +47 -0
  224. package/tests/bundled-install.test.ts +36 -9
  225. package/tests/card-content-policy.test.ts +3 -3
  226. package/tests/chained-pr-skill.test.ts +8 -6
  227. package/tests/child-safety.test.ts +11 -0
  228. package/tests/ci-concurrency.test.ts +11 -0
  229. package/tests/ci-merge-base-identity.test.ts +114 -0
  230. package/tests/codegraph-tools.test.ts +80 -5
  231. package/tests/codemode-rendering.test.ts +22 -2
  232. package/tests/command-palette.test.ts +300 -3
  233. package/tests/commit-slice-signal.test.ts +11 -9
  234. package/tests/delegate-for-reason-contract.test.ts +8 -7
  235. package/tests/design-canvas-assets.test.ts +185 -2
  236. package/tests/destructive-command-guard.test.ts +52 -0
  237. package/tests/download-progress.test.ts +71 -0
  238. package/tests/execution-surface-guard.test.ts +55 -0
  239. package/tests/exploration-budget.test.ts +128 -0
  240. package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
  241. package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
  242. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -14
  243. package/tests/fixtures/proxy-tls/proxy.crt +19 -0
  244. package/tests/fixtures/proxy-tls/proxy.key +28 -0
  245. package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
  246. package/tests/fixtures/session-profile-v1/replay.ts +172 -0
  247. package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
  248. package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
  249. package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
  250. package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
  251. package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
  252. package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
  253. package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
  254. package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
  255. package/tests/full-delegation-closure.test.ts +131 -0
  256. package/tests/full-delegation-notices.test.ts +76 -0
  257. package/tests/generic-agent-tools.test.ts +3 -3
  258. package/tests/gentle-agent-status.test.ts +74 -0
  259. package/tests/gentle-agents-child-jobs.test.ts +237 -0
  260. package/tests/gentle-agents.test.ts +1491 -38
  261. package/tests/gentle-ai-binary.test.ts +3 -1
  262. package/tests/gentle-ai-elapsed-store.test.ts +19 -0
  263. package/tests/gentle-ai-exploration-budget.test.ts +151 -0
  264. package/tests/gentle-ai-installer.test.ts +134 -51
  265. package/tests/gentle-ai-proxy.test.ts +434 -0
  266. package/tests/gentle-ai.test.ts +1101 -52
  267. package/tests/gentle-design.test.ts +21 -0
  268. package/tests/gentle-fast.test.ts +73 -0
  269. package/tests/gentle-guide.test.ts +208 -0
  270. package/tests/gentle-herdr-activity.test.ts +80 -3
  271. package/tests/gentle-herdr-agent.test.ts +111 -0
  272. package/tests/gentle-program-identity.test.ts +197 -0
  273. package/tests/gentle-shell-bin.test.ts +172 -26
  274. package/tests/gentle-shell-bundled.test.ts +207 -31
  275. package/tests/gentle-shell-launcher.test.ts +93 -10
  276. package/tests/gentle-shell.test.ts +1937 -66
  277. package/tests/gentle-stats.test.ts +15 -2
  278. package/tests/gentle-todo.test.ts +67 -4
  279. package/tests/gentle-tps.test.ts +123 -0
  280. package/tests/gentle-ui-design-skill.test.ts +59 -0
  281. package/tests/herdr-busy.test.ts +59 -0
  282. package/tests/herdr-task-summary-policy.test.ts +132 -0
  283. package/tests/history-store-private-mode.test.ts +40 -0
  284. package/tests/image-disk-cache.test.ts +163 -0
  285. package/tests/image-paste-chips.test.ts +42 -0
  286. package/tests/independent-recovery-delivery.test.ts +83 -0
  287. package/tests/inprocess-reviewer.test.ts +298 -4
  288. package/tests/installer-posix-bootstrap.test.ts +68 -6
  289. package/tests/installer-preflight.test.ts +5 -4
  290. package/tests/installer-runner.test.ts +79 -44
  291. package/tests/installer-server.test.ts +14 -11
  292. package/tests/installer-windows-diagnostics.test.ts +4 -5
  293. package/tests/isolated-config-home.ts +28 -0
  294. package/tests/jobs-view.test.ts +260 -6
  295. package/tests/jobs-widget.test.ts +25 -37
  296. package/tests/keymaps-customize.test.ts +114 -0
  297. package/tests/keymaps.test.ts +103 -0
  298. package/tests/maintainer/mcp-status.maintest.ts +88 -0
  299. package/tests/maintainer/pi-update-source.maintest.ts +116 -0
  300. package/tests/modal-mouse-boundaries.test.ts +136 -0
  301. package/tests/model-fallback-notice.test.ts +45 -0
  302. package/tests/model-fallback-policy.test.ts +83 -0
  303. package/tests/model-fallback-store.test.ts +111 -0
  304. package/tests/model-routing-authority.test.ts +178 -2
  305. package/tests/nan-provider.test.ts +4 -4
  306. package/tests/native-choice-list.test.ts +77 -2
  307. package/tests/native-review-capability-contract.test.ts +7 -1
  308. package/tests/native-review-cli.test.ts +269 -1
  309. package/tests/no-self-pause-contract.test.ts +22 -0
  310. package/tests/notification-customize.test.ts +58 -34
  311. package/tests/odd-routing-canonical-ratchet.test.ts +6 -6
  312. package/tests/odd-routing-contract.test.ts +1 -1
  313. package/tests/orchestrator-budget.test.ts +7 -2
  314. package/tests/orchestrator-delegation-mode.test.ts +153 -0
  315. package/tests/orchestrator-fallback.test.ts +82 -0
  316. package/tests/orchestrator-mode-policy.test.ts +175 -0
  317. package/tests/orchestrator-prompt-budget.test.ts +133 -0
  318. package/tests/orchestrator-rdd-ownership.test.ts +2 -2
  319. package/tests/package-manifest.test.ts +169 -14
  320. package/tests/pasted-image-paths.test.ts +118 -0
  321. package/tests/permission-allowlist.test.ts +202 -0
  322. package/tests/persona-reply-language.test.ts +20 -1
  323. package/tests/pi-update-launcher.test.ts +40 -8
  324. package/tests/pi-update-source.test.ts +162 -0
  325. package/tests/pnpm-workspace-config.test.ts +58 -0
  326. package/tests/primary-session-prompt.test.ts +13 -0
  327. package/tests/profile-fast-tier.test.ts +311 -0
  328. package/tests/profile-pin.test.ts +29 -2
  329. package/tests/profile-tier-footer.test.ts +84 -0
  330. package/tests/profiles-panel-delegation-mode.test.ts +422 -0
  331. package/tests/questionnaire-view.test.ts +265 -0
  332. package/tests/quiet-bash-runtime.test.ts +1 -1
  333. package/tests/quiet-tool-rendering.test.ts +48 -0
  334. package/tests/rdd-aware-verification-contract.test.ts +16 -11
  335. package/tests/rdd-customize.test.ts +287 -0
  336. package/tests/rdd-mode-cache.test.ts +450 -0
  337. package/tests/rdd-mode-control.test.ts +407 -0
  338. package/tests/rdd-mode-scope-regression.test.ts +137 -0
  339. package/tests/rdd-off-independent-regression.test.ts +69 -0
  340. package/tests/rdd-status-line.test.ts +18 -0
  341. package/tests/render-cache-performance.test.ts +171 -2
  342. package/tests/reply-language-anchor.test.ts +173 -0
  343. package/tests/review-agent-end-preflight.test.ts +1 -1
  344. package/tests/review-blocker.test.ts +193 -0
  345. package/tests/review-candidate-owner-retry.test.ts +1 -1
  346. package/tests/review-candidate-owner-sweep.test.ts +93 -0
  347. package/tests/review-candidate-symlink-scan.test.ts +157 -0
  348. package/tests/review-candidate-view.test.ts +52 -1
  349. package/tests/review-candidate-windows-boundary.test.ts +131 -0
  350. package/tests/review-candidate-windows-probe.test.ts +63 -0
  351. package/tests/review-committed-restart-ack.test.ts +129 -0
  352. package/tests/review-continuation-registry.test.ts +76 -0
  353. package/tests/review-controller-native-routing.test.ts +381 -11
  354. package/tests/review-controller-workspace-root.test.ts +230 -3
  355. package/tests/review-controller.test.ts +96 -11
  356. package/tests/review-coordinator-runtime.test.ts +117 -0
  357. package/tests/review-coordinator.test.ts +195 -0
  358. package/tests/review-failure-facts.test.ts +87 -0
  359. package/tests/review-gate.test.ts +24 -0
  360. package/tests/review-host-relay-routing.test.ts +258 -4
  361. package/tests/review-host-relay.test.ts +39 -0
  362. package/tests/review-inspect-preflight.test.ts +197 -0
  363. package/tests/review-integration-v2-forward.test.ts +59 -0
  364. package/tests/review-integration-v2.test.ts +46 -3
  365. package/tests/review-json-arguments.test.ts +65 -10
  366. package/tests/review-last-event-closure.test.ts +68 -0
  367. package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
  368. package/tests/review-owner-identity.test.ts +60 -24
  369. package/tests/review-relay-phase-timing.test.ts +128 -0
  370. package/tests/review-relay-transport-agent.test.ts +12 -2
  371. package/tests/review-repository.test.ts +52 -1
  372. package/tests/review-reviewer-evidence.test.ts +183 -0
  373. package/tests/review-risk-assessment.test.ts +74 -3
  374. package/tests/review-session-standing-permission-controller.test.ts +21 -1
  375. package/tests/review-sidebar-state.test.ts +5 -5
  376. package/tests/review-start-context.test.ts +19 -0
  377. package/tests/review-tool-prose-budget.test.ts +121 -0
  378. package/tests/run-test-suite.test.ts +183 -6
  379. package/tests/runtime-harness.mjs +4 -1
  380. package/tests/sensitive-path-tools.test.ts +250 -0
  381. package/tests/session-profile-append-controller-pi.test.ts +60 -31
  382. package/tests/session-profile-append-controller.test.ts +63 -0
  383. package/tests/session-profile-authority.test.ts +259 -0
  384. package/tests/session-profile-binding.test.ts +34 -1
  385. package/tests/session-profile-disk-reader-pi.test.ts +58 -16
  386. package/tests/session-profile-extension.test.ts +615 -0
  387. package/tests/session-profile-freeze.test.ts +110 -2
  388. package/tests/session-profile-integration.test.ts +857 -0
  389. package/tests/session-profile-persistence.test.ts +57 -0
  390. package/tests/session-profile-v1-compat.test.ts +255 -0
  391. package/tests/shell-bar.test.ts +274 -72
  392. package/tests/shell-card.test.ts +13 -1
  393. package/tests/shell-page.test.ts +108 -0
  394. package/tests/shell-panel.test.ts +360 -0
  395. package/tests/shell-prompt.test.ts +54 -0
  396. package/tests/shell-render-cache.test.ts +5 -0
  397. package/tests/shell-sidebar-fullscreen.test.ts +13 -1
  398. package/tests/shell-sidebar-layout.test.ts +447 -44
  399. package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
  400. package/tests/shell-stats.test.ts +90 -0
  401. package/tests/shell-surface-transparent.test.ts +89 -0
  402. package/tests/shell-todo.test.ts +12 -0
  403. package/tests/shell-usage.test.ts +14 -0
  404. package/tests/skill-registry.test.ts +902 -2
  405. package/tests/star-prompt.test.ts +470 -0
  406. package/tests/startup-banner.test.ts +209 -2
  407. package/tests/startup-home-repo.test.ts +2 -0
  408. package/tests/support/review-coordinator-runtime.ts +69 -0
  409. package/tests/task-size-routing-contract.test.ts +50 -4
  410. package/tests/verifier-admission.test.ts +49 -0
  411. package/tests/verifier-settle-reminder.test.ts +281 -0
  412. package/tests/verify-first-launch-contract.test.ts +134 -8
  413. package/tests/verify-installer-tap.test.ts +57 -0
  414. package/tests/vim-editor-adapter.test.ts +2 -2
  415. package/tests/visual-customization-policy.test.ts +95 -8
  416. package/tests/visual-customize-view.test.ts +818 -9
  417. package/tests/visual-layout-preview.test.ts +42 -0
  418. package/tests/visual-profiles.test.ts +11 -0
  419. package/tests/voice-worker.test.ts +73 -2
  420. package/tests/windows-session-bootstrap.test.ts +105 -2
  421. package/tests/windows-session-transport.test.ts +126 -0
  422. package/tests/work-continuity-contract.test.ts +114 -0
  423. package/tests/writer-feature-document-admission.test.ts +92 -0
  424. package/tests/writer-surfaces.test.ts +12 -10
  425. package/tests/yolo-customize.test.ts +57 -15
  426. package/tests/yolo-mode-runtime.test.ts +4 -2
  427. package/tests/yolo-mode.test.ts +39 -20
  428. package/tests/yolo-session-policy.test.ts +270 -1
@@ -1,13 +1,15 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { execFileSync } from "node:child_process";
3
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
4
- import { tmpdir } from "node:os";
3
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
4
+ import { homedir, tmpdir } from "node:os";
5
5
  import { join } from "node:path";
6
6
  import test from "node:test";
7
7
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
8
8
  import { __testing, createGentleAiExtension } from "../extensions/gentle-ai.ts";
9
- import { NativeReviewIntegrationError, type NativeReviewCli } from "../lib/native-review-cli.ts";
9
+ import { NativeReviewIntegrationError, NativeReviewCliError, NATIVE_REVIEW_ERROR_CODE, NATIVE_REVIEW_OPERATION, NATIVE_REQUEST_CONTEXT_UNSUPPORTED_MESSAGE, type NativeReviewCli } from "../lib/native-review-cli.ts";
10
10
  import { CandidateViewRegistry } from "../lib/review-candidate-view.ts";
11
+ import { ReviewContinuationRegistry } from "../lib/review-continuation-registry.ts";
12
+ import { prepareBoundSessionRepository } from "../lib/bounded-writer-admission.ts";
11
13
  import { decodeReviewFailureV2, type AuthorityRepairAssessmentV1, type ReviewStatusV3 } from "../lib/review-integration-v2.ts";
12
14
 
13
15
  interface RegisteredTool {
@@ -57,6 +59,56 @@ function context(cwd: string): ExtensionContext {
57
59
  return { cwd, hasUI: false, ui: { confirm: async () => true } } as unknown as ExtensionContext;
58
60
  }
59
61
 
62
+ test("repository preparation retains capture routes in the session registry used by later STATUS", async t => {
63
+ const fixture = realpathSync(mkdtempSync(join(tmpdir(), "gentle-pi-preparation-registry-")));
64
+ const cwd = join(fixture, "project");
65
+ mkdirSync(cwd);
66
+ const homes = { HOME: join(fixture, "home"), USERPROFILE: join(fixture, "home"), GENTLE_PI_AGENT_HOME: join(fixture, "agents"), PI_CODING_AGENT_DIR: join(fixture, "agents"), GENTLE_PI_CONFIG_HOME: join(fixture, "config"), GENTLE_PI_GENTLE_AI_DEV_BINARY: "" };
67
+ for (const path of new Set(Object.values(homes).filter(Boolean))) mkdirSync(path, { recursive: true });
68
+ const previous = Object.fromEntries(Object.keys(homes).map(key => [key, process.env[key]]));
69
+ Object.assign(process.env, homes);
70
+ t.after(() => {
71
+ for (const [key, value] of Object.entries(previous)) { if (value === undefined) delete process.env[key]; else process.env[key] = value; }
72
+ rmSync(fixture, { recursive: true, force: true });
73
+ });
74
+ const reads: Array<{ owner: ReviewContinuationRegistry; found: boolean }> = [];
75
+ const read = ReviewContinuationRegistry.prototype.readCapture;
76
+ t.mock.method(ReviewContinuationRegistry.prototype, "readCapture", function(this: ReviewContinuationRegistry, binding: string) {
77
+ const value = read.call(this, binding);
78
+ reads.push({ owner: this, found: value !== undefined });
79
+ return value;
80
+ });
81
+ const status = targetStatusFixture({ authorityState: "correction_required" });
82
+ const input = { name: "correction_plan", schema: "https://gentle-ai.dev/schema/review/correction-plan/v1", captureOperation: "review.capture-correction-plan", arguments: [{ name: "lineage", value: "native-lineage", token: "--lineage=native-lineage" }, { name: "target", value: status.targetIdentity, token: `--target=${status.targetIdentity}` }] };
83
+ status.nextTransition = { kind: "collect", reasonCode: "correction_plan_required", collect: { inputs: [input] } };
84
+ status.raw = { ...status.raw, next_transition: { kind: "collect", reason_code: "correction_plan_required" } };
85
+ const emptyConfig = join(fixture, "empty.gitconfig");
86
+ writeFileSync(emptyConfig, "");
87
+ const gitEnv = { ...Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.toUpperCase().startsWith("GIT_"))), GIT_CONFIG_GLOBAL: emptyConfig, GIT_CONFIG_NOSYSTEM: "1" };
88
+ const native = fakeNative({
89
+ reviewMode: async () => ({ operation: "status", scope: "global", status: { global: "on", cloneLocal: "", effective: "on", source: "global" } }),
90
+ targetStatus: async () => {
91
+ if (!existsSync(join(cwd, ".git"))) execFileSync("git", ["init", "--quiet", cwd], { env: gitEnv, windowsHide: true });
92
+ return status;
93
+ },
94
+ });
95
+ const h = runtime(native);
96
+ const manager = { getSessionId: () => "preparation-registry", getCwd: () => cwd, getEntries: () => [], getBranch: () => [] };
97
+ const session = { ...context(cwd), sessionManager: manager } as unknown as ExtensionContext;
98
+ try {
99
+ await h.lifecycle("session_start", { reason: "startup" }, session);
100
+ assert.equal(reads.length, 0);
101
+ assert.equal(await prepareBoundSessionRepository(manager, cwd), true);
102
+ assert.ok(reads.length > 0, "native preparation must actually retain capture routing");
103
+ const prepared = reads[0].owner;
104
+ const beforeStatus = reads.length;
105
+ await h.controller.execute("after-preparation", { operation: "status", lineageId: "native-lineage" }, undefined, undefined, session);
106
+ assert.ok(reads.length > beforeStatus);
107
+ assert.equal(reads[beforeStatus].owner, prepared, "later STATUS must reuse the preparation registry");
108
+ assert.equal(reads[beforeStatus].found, true, "preparation routing must still exist before STATUS refreshes it");
109
+ } finally { await h.lifecycle("session_shutdown", { reason: "quit" }, session); }
110
+ });
111
+
60
112
  function repository(t: test.TestContext, prefix = "gentle-pi-workspace-root-"): string {
61
113
  const cwd = realpathSync(mkdtempSync(join(tmpdir(), prefix)));
62
114
  t.after(() => {
@@ -233,6 +285,64 @@ test("START forwards the agent lens selection in canonical order and rejects mal
233
285
  assert.equal(statusCalls, 0);
234
286
  });
235
287
 
288
+ test("START resolves an explicit request file against the selected workspace", async (t) => {
289
+ const cwd = repository(t);
290
+ writeFileSync(join(cwd, "app.ts"), "export const value = 2;\n");
291
+ writeFileSync(join(cwd, "spec with spaces.md"), "Requested behavior");
292
+ const starts: Parameters<NativeReviewCli["start"]>[0][] = [];
293
+ const { controller } = runtime(fakeNative({ start: async request => {
294
+ starts.push(request);
295
+ return { lineageId: "intent-lineage", state: "reviewing", riskLevel: "medium", selectedLenses: ["review-risk"], changedFiles: 1, changedLines: 1, correctionBudget: 1, action: "created", lensesRequired: true };
296
+ } }));
297
+ await controller.execute("request-start", { operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath: "spec with spaces.md" }) }, undefined, undefined, context(cwd));
298
+ assert.equal(starts.length, 1);
299
+ assert.equal(starts[0].requestContextPath, join(cwd, "spec with spaces.md"));
300
+ for (const requestContextPath of [42, "", " spaced ", "nul\0path"]) {
301
+ const result = await __testing.executeReviewControllerOperation({ operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath }) }, cwd, fakeNative());
302
+ assert.equal(result.reason, "request-context-invalid");
303
+ }
304
+ });
305
+
306
+ test("START with explicit intent never silently adopts existing authority", async (t) => {
307
+ const cwd = repository(t);
308
+ writeFileSync(join(cwd, "new-spec.md"), "Requested behavior");
309
+ const result = await __testing.executeReviewControllerOperation({ operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath: "new-spec.md" }) }, cwd, fakeNative({
310
+ targetStatus: async () => targetStatusFixture(),
311
+ start: async () => { throw new Error("existing intent must not be replaced"); },
312
+ }));
313
+ assert.equal(result.reason, "request-context-requires-fresh-review");
314
+ assert.equal(result.mutation_performed, false);
315
+ });
316
+
317
+ test("request context rejects missing paths and dangling directory aliases before native lookup", async t => {
318
+ const cwd = repository(t);
319
+ symlinkSync(join(cwd, "missing"), join(cwd, "alias"), process.platform === "win32" ? "junction" : "dir");
320
+ let calls = 0;
321
+ const native = fakeNative({ targetStatus: async () => { calls++; throw new Error("unresolved path reached native"); } });
322
+ for (const requestContextPath of ["missing.md", "alias/request.md"]) {
323
+ const result = await __testing.executeReviewControllerOperation({ operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath }) }, cwd, native);
324
+ assert.equal(result.reason, "request-context-unresolved-path");
325
+ assert.equal(result.next_action, "supply-an-existing-resolvable-requestContextPath");
326
+ }
327
+ assert.equal(calls, 0);
328
+ });
329
+
330
+ test("request context expands home paths and forwards the canonical external file", async t => {
331
+ const cwd = repository(t);
332
+ const external = mkdtempSync(join(homedir(), "request-context-test-"));
333
+ t.after(() => rmSync(external, { recursive: true, force: true }));
334
+ const path = join(external, "spec.md"); writeFileSync(path, "Requested behavior");
335
+ symlinkSync(external, join(cwd, "alias"), process.platform === "win32" ? "junction" : "dir");
336
+ const starts: string[] = [];
337
+ const native = fakeNative({ targetStatus: async request => { starts.push(request.requestContextPath!); throw new Error("canonical path observed; stop before START"); } });
338
+ const relativeHomePath = path.slice(homedir().length + 1).replaceAll("\\", "/");
339
+ for (const requestContextPath of ["alias/spec.md", "~/" + relativeHomePath, ...(process.platform === "win32" ? ["~\\" + relativeHomePath.replaceAll("/", "\\")] : [])]) {
340
+ await __testing.executeReviewControllerOperation({ operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath }) }, cwd, native);
341
+ }
342
+ assert.equal(starts.length, process.platform === "win32" ? 3 : 2);
343
+ assert.ok(starts.every(value => value === realpathSync(path)));
344
+ });
345
+
236
346
  test("repository discovery ignores ambient Git root overrides", async (t) => {
237
347
  const sessionRoot = repository(t);
238
348
  const targetRoot = repository(t, "gentle-pi-isolated-target-");
@@ -476,6 +586,90 @@ test("inspect without workspaceRoot preserves the native invalid_request cause f
476
586
  assert.equal(details.next_action, "correct_request");
477
587
  });
478
588
 
589
+ // gentle-shell#213: the host-side 30 s budget on a read-only STATUS/inspect
590
+ // read used to dead-end in the corrupt-authority outcome with no runnable
591
+ // step. A read-only inventory timeout names the read-only command to rerun.
592
+ function hostStatusTimeout(): NativeReviewCliError {
593
+ return new NativeReviewCliError(NATIVE_REVIEW_ERROR_CODE.TIMEOUT, NATIVE_REVIEW_OPERATION.STATUS, true, false, "native process timed out", {
594
+ operation: NATIVE_REVIEW_OPERATION.STATUS, error_code: NATIVE_REVIEW_ERROR_CODE.TIMEOUT, timed_out: true, output_limit_exceeded: false,
595
+ });
596
+ }
597
+
598
+ for (const operation of ["status", "inspect"] as const) test(`a host timeout on read-only ${operation} returns a rerunnable status command`, async (t) => {
599
+ const sessionCwd = repository(t);
600
+ let calls = 0;
601
+ const { controller } = runtime(fakeNative({ targetStatus: async () => { calls++; throw hostStatusTimeout(); } }));
602
+ const result = await controller.execute(`timeout-${operation}`, { operation }, undefined, undefined, context(sessionCwd));
603
+ const details = result.details as Record<string, unknown>;
604
+ assert.equal(calls, 1);
605
+ assert.equal(details.status, "blocked");
606
+ assert.equal(details.outcome, "native-status-timed-out");
607
+ assert.equal(details.inventory_complete, false);
608
+ assert.equal(details.mutation_performed, false);
609
+ assert.equal(details.mutation_outcome, "none");
610
+ assert.equal(details.next_action, "rerun-native-status");
611
+ assert.equal(details.remediation_command, "gentle-ai review status --cwd <repo> --contract gentle-ai.review-integration/v2 --agent pi --next-transition");
612
+ assert.equal((details.diagnostics as Record<string, unknown>)?.timed_out, true);
613
+ const blocker = details.blocker as Record<string, unknown>;
614
+ assert.equal(blocker.category, "provider-unavailable");
615
+ assert.equal(blocker.actor, "user");
616
+ assert.equal(blocker.automatic_retry, false);
617
+ assert.equal(blocker.next_step, "The read-only review inventory read timed out before it completed. Nothing was mutated; rerun the returned remediation_command when ready. Pi does not retry automatically.");
618
+ });
619
+
620
+ test("a host timeout on the STATUS read behind a recovery authorization keeps the inventory-unavailable outcome", () => {
621
+ for (const operation of ["recover", "repair", "start"] as const) {
622
+ const result = __testing.nativeStatusFailed(operation, hostStatusTimeout());
623
+ assert.equal(result.outcome, "native-status-unavailable");
624
+ assert.equal(result.next_action, "require-complete-native-authority-inventory");
625
+ assert.equal("remediation_command" in result, false);
626
+ }
627
+ assert.deepEqual(__testing.nativeStatusFailed("recover", hostStatusTimeout()), {
628
+ operation: "recover", status: "blocked", outcome: "native-status-unavailable",
629
+ lineage_created: false, mutation_performed: false, mutation_outcome: "none",
630
+ diagnostics: { operation: NATIVE_REVIEW_OPERATION.STATUS, error_code: NATIVE_REVIEW_ERROR_CODE.TIMEOUT, timed_out: true, output_limit_exceeded: false },
631
+ inventory_complete: false, next_action: "require-complete-native-authority-inventory",
632
+ });
633
+ });
634
+
635
+ test("corrupt-authority STATUS failures keep the inventory-unavailable outcome", () => {
636
+ for (const code of [NATIVE_REVIEW_ERROR_CODE.SCHEMA_INCOMPATIBLE, NATIVE_REVIEW_ERROR_CODE.NON_ZERO]) {
637
+ const result = __testing.nativeStatusFailed("status", new NativeReviewCliError(code, NATIVE_REVIEW_OPERATION.STATUS, true, false, "corrupt"));
638
+ assert.equal(result.outcome, "native-status-unavailable");
639
+ assert.equal(result.next_action, "require-complete-native-authority-inventory");
640
+ assert.equal("remediation_command" in result, false);
641
+ }
642
+ assert.deepEqual(__testing.nativeStatusFailed("status", new Error("opaque")), {
643
+ operation: "status", status: "blocked", outcome: "native-status-unavailable",
644
+ lineage_created: false, mutation_performed: false, mutation_outcome: "none",
645
+ inventory_complete: false, next_action: "require-complete-native-authority-inventory",
646
+ });
647
+ });
648
+
649
+ for (const operation of ["status", "inspect"] as const) test(`a native ${operation} timeout envelope is forwarded as-is and read once`, async (t) => {
650
+ const sessionCwd = repository(t);
651
+ let calls = 0;
652
+ const { controller } = runtime(fakeNative({
653
+ targetStatus: async () => {
654
+ calls++;
655
+ throw new NativeReviewIntegrationError(decodeReviewFailureV2({
656
+ schema: "gentle-ai.review-integration.failure/v2", contract: "gentle-ai.review-integration/v2",
657
+ operation: "review.status", phase: "native_running", code: "timeout", message: "The review status read timed out.",
658
+ mutation_outcome: "not_started", authority_applicability: "not_evaluated", retry_safe: true,
659
+ replayability: "not_replayable", required_inputs: [], next_action: "retry",
660
+ }));
661
+ },
662
+ }));
663
+ const result = await controller.execute(`native-timeout-${operation}`, { operation }, undefined, undefined, context(sessionCwd));
664
+ const details = result.details as Record<string, unknown>;
665
+ assert.equal(calls, 1);
666
+ assert.equal(details.outcome, operation === "inspect" ? "native-status-unavailable" : undefined);
667
+ assert.equal(details.next_action, "retry");
668
+ assert.equal((details.native_failure as Record<string, unknown>)?.retry_safe, true);
669
+ assert.equal((details.native_failure as Record<string, unknown>)?.code, "timeout");
670
+ assert.equal("remediation_command" in details, false);
671
+ });
672
+
479
673
  test("START freezes the candidate from the explicit workspace root and returns the actor binding envelope", async (t) => {
480
674
  const sessionCwd = repository(t);
481
675
  writeFileSync(join(sessionCwd, "unrelated.ts"), "export const unrelated = true;\n");
@@ -768,3 +962,36 @@ test("an explicit linked-worktree root owns STATUS collect capture over the sess
768
962
  assert.equal(result.outcome, "native-last-event-closure");
769
963
  assert.deepEqual(observedRoots, [realpathSync(worktree)]);
770
964
  });
965
+
966
+ test("request-context capability refusal remains clear in the public facade", async (t) => {
967
+ const cwd = repository(t);
968
+ writeFileSync(join(cwd, "spec.md"), "Requested behavior");
969
+ const error = new NativeReviewCliError(NATIVE_REVIEW_ERROR_CODE.VERSION_INCOMPATIBLE, NATIVE_REVIEW_OPERATION.STATUS, false, false, NATIVE_REQUEST_CONTEXT_UNSUPPORTED_MESSAGE);
970
+ const native = fakeNative({ targetStatus: async () => { throw error; } });
971
+ for (const operation of ["inspect", "start"] as const) {
972
+ const result = await __testing.executeReviewControllerOperation({ operation, ...(operation === "start" ? { input: JSON.stringify({ mode: "ordinary", requestContextPath: "spec.md" }) } : {}) }, cwd, native);
973
+ assert.equal(result.status, "blocked");
974
+ assert.equal(result.reason, NATIVE_REQUEST_CONTEXT_UNSUPPORTED_MESSAGE);
975
+ assert.equal(result.mutation_performed, false);
976
+ }
977
+ });
978
+
979
+ test("request context applies sensitive-path policy before any native lookup", async () => {
980
+ let calls = 0;
981
+ const native = fakeNative({ targetStatus: async () => { calls++; throw new Error("must not read sensitive paths"); } });
982
+ for (const path of [".envrc", ".netrc", "~\\.netrc", ".env", ".env.local", ".ssh/id_rsa", "secrets/request.md", "C:/private/KEY.PEM", "docs/../.env", "secrets\\request.md"]) {
983
+ const result = await __testing.executeReviewControllerOperation({ operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath: path }) }, process.cwd(), native);
984
+ assert.equal(result.reason, "request-context-sensitive-path", path);
985
+ assert.equal(result.mutation_performed, false);
986
+ }
987
+ assert.equal(calls, 0);
988
+ });
989
+
990
+ test("request context rejects a harmless alias resolving into a sensitive directory", async (t) => {
991
+ const cwd = repository(t); mkdirSync(join(cwd, "secrets")); writeFileSync(join(cwd, "secrets", "request.md"), "private fixture");
992
+ symlinkSync(join(cwd, "secrets"), join(cwd, "alias"), process.platform === "win32" ? "junction" : "dir");
993
+ let calls = 0;
994
+ const native = fakeNative({ targetStatus: async () => { calls++; throw new Error("must not read aliased secrets"); } });
995
+ const result = await __testing.executeReviewControllerOperation({ operation: "start", input: JSON.stringify({ mode: "ordinary", requestContextPath: "alias/request.md" }) }, cwd, native);
996
+ assert.equal(result.reason, "request-context-sensitive-path"); assert.equal(calls, 0);
997
+ });
@@ -77,7 +77,7 @@ function budget(): ReviewBudgetV1 {
77
77
  };
78
78
  }
79
79
 
80
- function registerRuntime(): RuntimeRegistration {
80
+ function registerRuntime(nativeReviewCli: NativeReviewCli | null = null): RuntimeRegistration {
81
81
  const handlers = new Map<string, ToolCallHandler>();
82
82
  const tools = new Map<string, RegisteredReviewTool>();
83
83
  const pi = {
@@ -89,7 +89,7 @@ function registerRuntime(): RuntimeRegistration {
89
89
  },
90
90
  registerCommand() {},
91
91
  } as unknown as ExtensionAPI;
92
- createGentleAiExtension({ nativeReviewCli: null })(pi);
92
+ createGentleAiExtension({ nativeReviewCli })(pi);
93
93
  const controller = tools.get("gentle_review");
94
94
  const toolCall = handlers.get("tool_call");
95
95
  assert.ok(controller, "the supported review controller tool must be registered");
@@ -300,14 +300,54 @@ test("controller rejects graph-style ADVANCE without graph-v1 authority", async
300
300
  test("controller successfully starts the explicitly supported judgment-day mode", async (t) => {
301
301
  const fixture = createRepository(t);
302
302
  const { controller } = registerRuntime();
303
- const started = await controllerCall(controller, extensionContext(fixture.repository), {
303
+ const ctx = extensionContext(fixture.repository);
304
+ const params = {
304
305
  operation: "start",
305
306
  lineageId: "judgment-day-start",
306
307
  idempotencyKey: "judgment-day-start-key",
307
308
  input: JSON.stringify({ mode: "judgment-day", projection: { kind: "complete" }, policyHash: "a".repeat(64), evidenceHash: "b".repeat(64), budget: budget() }),
308
- });
309
+ };
310
+ const started = await controllerCall(controller, ctx, params);
309
311
  assert.equal(started.operation, "start");
310
312
  assert.equal((started.state as Record<string, unknown>).mode, "judgment-day");
313
+ const replayed = await controllerCall(controller, ctx, params);
314
+ assert.deepEqual(replayed.result, started.result);
315
+ assert.equal((replayed.state as Record<string, unknown>).mode, "judgment-day");
316
+ });
317
+
318
+ test("ordinary START without legacy credentials does not demand Judgment Day prerequisites", async (t) => {
319
+ const fixture = createRepository(t);
320
+ const { controller } = registerRuntime();
321
+ const started = await controllerCall(controller, extensionContext(fixture.repository), {
322
+ operation: "start",
323
+ input: JSON.stringify({ mode: REVIEW_MODE.ORDINARY }),
324
+ });
325
+ assert.equal(started.operation, "start");
326
+ assert.equal(started.outcome, "native-status-unsupported");
327
+ assert.equal(started.mutation_performed, false);
328
+ assert.equal(existsSync(join(fixture.repository, ".git", "gentle-ai", "reviews", "graph-v1")), false);
329
+ });
330
+
331
+ test("judgment-day START reports missing credentials after a supported mode is accepted", async (t) => {
332
+ const fixture = createRepository(t);
333
+ const { controller } = registerRuntime();
334
+ const ctx = extensionContext(fixture.repository);
335
+ const input = JSON.stringify({
336
+ mode: "judgment-day",
337
+ projection: { kind: "complete" },
338
+ policyHash: "a".repeat(64),
339
+ evidenceHash: "b".repeat(64),
340
+ budget: budget(),
341
+ });
342
+ await assert.rejects(
343
+ controller.execute("judgment-day-missing-idempotency", { operation: "start", input }, undefined, undefined, ctx),
344
+ /requires idempotencyKey/,
345
+ );
346
+ await assert.rejects(
347
+ controller.execute("judgment-day-missing-lineage", { operation: "start", idempotencyKey: "judgment-day-start-key", input }, undefined, undefined, ctx),
348
+ /Judgment Day graph-v1 START requires lineageId/,
349
+ );
350
+ assert.equal(existsSync(join(fixture.repository, ".git", "gentle-ai", "reviews", "graph-v1")), false);
311
351
  });
312
352
 
313
353
  test("general STATUS returns the typed native-status-unsupported boundary without authority selection", () => {
@@ -318,10 +358,10 @@ test("general STATUS returns the typed native-status-unsupported boundary withou
318
358
  outcome: "native-status-unsupported",
319
359
  mutation_performed: false,
320
360
  inventory_complete: false,
321
- next_action: "require-upstream-read-only-native-status-inventory",
361
+ next_action: "check-native-provider-capabilities",
322
362
  remediation_command: "gentle-ai review status --cwd <repo> --contract gentle-ai.review-integration/v2 --agent pi --next-transition",
323
363
  evidence: {
324
- native_contract: "gentle-ai/2.1.4",
364
+ expected_contract: "gentle-ai.review-integration/v2",
325
365
  general_status: "unsupported",
326
366
  claimant_inventory: "unsupported",
327
367
  },
@@ -354,18 +394,61 @@ test("gentle-pi#185: general STATUS on a non-negotiated native CLI names the exa
354
394
 
355
395
  test("failed START gives exact mode and serialization guidance and creates no lineage", async (t) => {
356
396
  const fixture = createRepository(t);
357
- const { controller } = registerRuntime();
397
+ let targetStatusCalls = 0;
398
+ let startCalls = 0;
399
+ const native = {
400
+ targetStatus: async () => {
401
+ targetStatusCalls += 1;
402
+ throw new Error("rejected START mode must not call native targetStatus");
403
+ },
404
+ start: async () => {
405
+ startCalls += 1;
406
+ throw new Error("rejected START mode must not call native start");
407
+ },
408
+ } as unknown as NativeReviewCli;
409
+ const { controller } = registerRuntime(native);
358
410
  const ctx = extensionContext(fixture.repository);
411
+ const modeGuidance = /only "ordinary" or "judgment-day".*JSON string.*no lineage was created.*do not call STATUS or ADVANCE/is;
412
+ const graphPath = join(fixture.repository, ".git", "gentle-ai", "reviews", "graph-v1");
413
+ const committedRange = { baseRef: fixture.baseCommit, committedOnly: true };
359
414
 
360
415
  await assert.rejects(
361
- controller.execute("unsupported-start", {
416
+ controller.execute("issue-992-omitted-mode-idempotency", {
417
+ operation: "start",
418
+ idempotencyKey: "unsupported-start-key",
419
+ input: JSON.stringify(committedRange),
420
+ }, undefined, undefined, ctx),
421
+ modeGuidance,
422
+ );
423
+ await assert.rejects(
424
+ controller.execute("issue-992-omitted-mode-lineage", {
362
425
  operation: "start",
363
426
  lineageId: "unsupported-start",
364
427
  idempotencyKey: "unsupported-start-key",
365
- input: JSON.stringify({ mode: "standard" }),
428
+ input: JSON.stringify(committedRange),
366
429
  }, undefined, undefined, ctx),
367
- /only "ordinary" or "judgment-day".*JSON string.*no lineage was created.*do not call STATUS or ADVANCE/is,
430
+ modeGuidance,
368
431
  );
432
+
433
+ const credentials = [
434
+ {},
435
+ { idempotencyKey: "unsupported-start-key" },
436
+ { lineageId: "unsupported-start" },
437
+ { lineageId: "unsupported-start", idempotencyKey: "unsupported-start-key" },
438
+ ] as const;
439
+ for (const mode of [undefined, null, 1, "standard"] as const) {
440
+ for (const credential of credentials) {
441
+ const payload = mode === undefined ? {} : { mode };
442
+ await assert.rejects(
443
+ controller.execute("unsupported-start", {
444
+ operation: "start",
445
+ ...credential,
446
+ input: JSON.stringify(payload),
447
+ }, undefined, undefined, ctx),
448
+ modeGuidance,
449
+ );
450
+ }
451
+ }
369
452
  await assert.rejects(
370
453
  controller.execute("nested-start-input", {
371
454
  operation: "start",
@@ -384,7 +467,9 @@ test("failed START gives exact mode and serialization guidance and creates no li
384
467
  }, undefined, undefined, ctx),
385
468
  /START input must be a JSON string encoding an object.*no lineage was created.*do not call STATUS or ADVANCE/is,
386
469
  );
387
- assert.equal(existsSync(join(fixture.repository, ".git", "gentle-ai", "reviews", "graph-v1")), false);
470
+ assert.equal(existsSync(graphPath), false);
471
+ assert.equal(targetStatusCalls, 0);
472
+ assert.equal(startCalls, 0);
388
473
  });
389
474
 
390
475
 
@@ -0,0 +1,117 @@
1
+ import assert from "node:assert/strict";
2
+ import { execFileSync } from "node:child_process";
3
+ import { mkdtempSync, rmSync, writeFileSync, mkdirSync, realpathSync, symlinkSync } from "node:fs";
4
+ import { readFileSync } from "node:fs";
5
+ import { tmpdir } from "node:os";
6
+ import { join } from "node:path";
7
+ import test from "node:test";
8
+ import { createCoordinatorRuntime } from "./support/review-coordinator-runtime.ts";
9
+ import { createGentleAiExtension, __testing } from "../extensions/gentle-ai.ts";
10
+ import { decodeReviewStatusV3 } from "../lib/review-integration-v2.ts";
11
+ import type { NativeReviewCli } from "../lib/native-review-cli.ts";
12
+
13
+ test("registered coordinator executes existing facade and preserves the baseline native trace", async (t) => {
14
+ const cwd = realpathSync(mkdtempSync(join(realpathSync(tmpdir()), "rdd-coordinator-runtime-")));
15
+ t.after(() => { assert.ok(cwd.startsWith(join(realpathSync(tmpdir()), "rdd-coordinator-runtime-"))); rmSync(cwd, { recursive: true, force: true }); });
16
+ execFileSync("git", ["init", "-q"], { cwd });
17
+ writeFileSync(join(cwd, "candidate.ts"), "export const value = 1;\n");
18
+ const baseline = createCoordinatorRuntime(cwd, "baseline");
19
+ let baselineTrace: string[];
20
+ try {
21
+ const status = await baseline.invoke("gentle_review", { operation: "status", lineageId: baseline.lineage });
22
+ const collectBinding = status.collectBindings[0].collectBinding;
23
+ const capture = { lineageId: baseline.lineage, collectBinding };
24
+ assert.equal((await baseline.invoke("gentle_review_capture", capture)).outcome, "reviewer-model-run-forecast");
25
+ assert.equal((await baseline.invoke("gentle_review_capture", { ...capture, reviewerRunAcknowledged: true })).outcome, "native-last-event-closure");
26
+ await baseline.invoke("gentle_review", { operation: "status", lineageId: baseline.lineage });
27
+ assert.equal((await baseline.invoke("gentle_review", { operation: "acknowledge-approved", lineageId: baseline.lineage })).authority, "burned");
28
+ assert.ok(baseline.closed());
29
+ baselineTrace = [...baseline.nativeCalls];
30
+ } finally { baseline.close(); }
31
+ const coordinated = createCoordinatorRuntime(cwd, "coordinator");
32
+ try {
33
+ assert.equal(coordinated.tools.get("gentle_review_run").exposure, "model-only");
34
+ const result = await coordinated.invoke("gentle_review_run", { lineageId: coordinated.lineage });
35
+ assert.equal(result.outcome, "closed", JSON.stringify({ result, calls: coordinated.nativeCalls }));
36
+ assert.ok(coordinated.closed());
37
+ assert.deepEqual(coordinated.nativeCalls, baselineTrace!);
38
+ assert.equal(coordinated.forecasts.length, 1);
39
+ assert.equal(coordinated.forecasts[0]!.outcome, "reviewer-model-run-forecast");
40
+ assert.deepEqual(result.forecasts, coordinated.forecasts, "the final tool result relays every forecast to the primary");
41
+ assert.equal(result.metrics.facade_calls, 5);
42
+ assert.equal(result.current_candidate, undefined);
43
+ assert.equal(coordinated.candidateReads(), 0, "ACK requires no post-burn query");
44
+ } finally { coordinated.close(); }
45
+ });
46
+
47
+ test("experimental coordinator respects RDD off and a switch disabled during its forecast", async (t) => {
48
+ const cwd = realpathSync(mkdtempSync(join(realpathSync(tmpdir()), "rdd-coordinator-mode-")));
49
+ t.after(() => { assert.ok(cwd.startsWith(join(realpathSync(tmpdir()), "rdd-coordinator-mode-"))); rmSync(cwd, { recursive: true, force: true }); });
50
+ execFileSync("git", ["init", "-q"], { cwd });
51
+ const raw = JSON.parse(readFileSync(new URL("./fixtures/devbinary/status-v5-capture-result-submission.captured.json", import.meta.url), "utf8"));
52
+ raw.action = "stop";
53
+ const status = decodeReviewStatusV3(raw);
54
+ for (const initiallyOff of [true, false]) {
55
+ let effective = initiallyOff ? "off" : "on";
56
+ let captures = 0;
57
+ __testing.setReviewHostRelayRunnerForTesting(async () => { captures++; throw new Error("No reviewer should run with RDD off"); });
58
+ try {
59
+ const native = {
60
+ targetStatus: async () => status,
61
+ reviewMode: async () => ({ operation: "status", scope: "clone", status: { global: effective, cloneLocal: "", effective, source: "global" } }),
62
+ } as unknown as NativeReviewCli;
63
+ const tools = new Map<string, any>();
64
+ createGentleAiExtension({ nativeReviewCli: native, candidateViews: null, processEnv: { GENTLE_PI_EXPERIMENTAL_REVIEW_COORDINATOR: "1" } })({ on() {}, registerCommand() {}, registerTool: (tool: any) => tools.set(tool.name, tool) } as never);
65
+ const result = await tools.get("gentle_review_run").execute("mode-test", { lineageId: status.authority!.lineageId }, undefined,
66
+ () => { effective = "off"; }, { cwd, hasUI: true, sessionManager: { getSessionId: () => "mode-test" } });
67
+ assert.equal(captures, 0, "mode off must stop before reviewer execution");
68
+ assert.equal(result.details.outcome, "blocked");
69
+ assert.equal(result.details.result.status, "skipped");
70
+ } finally { __testing.setReviewHostRelayRunnerForTesting(); }
71
+ }
72
+ });
73
+
74
+ test("capture forecast retains fresh mode and session checks before model execution", async (t) => {
75
+ const cwd = realpathSync(mkdtempSync(join(realpathSync(tmpdir()), "rdd-projected-guards-")));
76
+ t.after(() => { assert.ok(cwd.startsWith(join(realpathSync(tmpdir()), "rdd-projected-guards-"))); rmSync(cwd, { recursive: true, force: true }); });
77
+ execFileSync("git", ["init", "-q"], { cwd });
78
+ const raw = JSON.parse(readFileSync(new URL("./fixtures/devbinary/status-v5-capture-result-submission.captured.json", import.meta.url), "utf8"));
79
+ raw.action = "stop";
80
+ const base = decodeReviewStatusV3(raw);
81
+ const template = base.nextTransition!.collect!.inputs[0];
82
+ const input = { ...template, name: "provider_targeted_validator", captureOperation: "review.capture-validation",
83
+ submission: { ...template.submission!, operationToken: "capture-validation" } };
84
+ const validation = { ...base, authority: { ...base.authority!, state: "correction_required" },
85
+ nextTransition: { kind: "collect", reasonCode: "targeted_validation_required", collect: { inputs: [input] } },
86
+ raw: { ...raw, authority: { ...raw.authority, state: "correction_required" }, next_transition: { kind: "collect", reason_code: "targeted_validation_required" } } };
87
+ for (const change of ["mode", "session"]) {
88
+ let effective = "on"; let session = "original"; let runs = 0; let statusCalls = 0; let displayed = 0;
89
+ __testing.setReviewHostRelayRunnerForTesting(async () => { runs++; throw new Error("changed mode/session cannot launch reviewer"); });
90
+ try {
91
+ const native = { targetStatus: async () => { statusCalls++; return validation; },
92
+ reviewMode: async () => ({ operation: "status", scope: "clone", status: { global: effective, cloneLocal: "", effective, source: "global" } }),
93
+ } as unknown as NativeReviewCli;
94
+ const tools = new Map<string, any>();
95
+ createGentleAiExtension({ nativeReviewCli: native, candidateViews: null, processEnv: { GENTLE_PI_EXPERIMENTAL_REVIEW_COORDINATOR: "1" } })({ on() {}, registerCommand() {}, registerTool: (tool: any) => tools.set(tool.name, tool) } as never);
96
+ const call = () => tools.get("gentle_review_run").execute("projected-guard", { lineageId: base.authority!.lineageId }, undefined,
97
+ (update: any) => { assert.equal(update.details.outcome, "reviewer-model-run-forecast"); displayed++; if (change === "mode") effective = "off"; else session = "changed"; },
98
+ { cwd, hasUI: true, sessionManager: { getSessionId: () => session } });
99
+ if (change === "session") await assert.rejects(call, { name: "AbortError" });
100
+ else assert.equal((await call()).details.outcome, "blocked");
101
+ assert.equal(displayed, 1);
102
+ assert.equal(statusCalls, 2, "one offered STATUS and the existing capture forecast preflight");
103
+ assert.equal(runs, 0);
104
+ } finally { __testing.setReviewHostRelayRunnerForTesting(); }
105
+ }
106
+ });
107
+
108
+ test("coordinator fixture closes through an unresolved temporary-directory alias", async (t) => {
109
+ const root = realpathSync(mkdtempSync(join(tmpdir(), "rdd-canonical-fixture-")));
110
+ t.after(() => { assert.ok(root.startsWith(join(realpathSync(tmpdir()), "rdd-canonical-fixture-"))); rmSync(root, { recursive: true, force: true }); });
111
+ const cwd = join(root, "repo"), alias = join(root, "alias"); mkdirSync(cwd);
112
+ execFileSync("git", ["init", "-q"], { cwd }); writeFileSync(join(cwd, "candidate.ts"), "export const value = 1;\n");
113
+ symlinkSync(cwd, alias, process.platform === "win32" ? "junction" : "dir");
114
+ const runtime = createCoordinatorRuntime(alias, "coordinator");
115
+ try { const result = await runtime.invoke("gentle_review_run", { lineageId: runtime.lineage }); assert.equal(result.outcome, "closed", JSON.stringify(result)); }
116
+ finally { runtime.close(); }
117
+ });