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,9 +1,12 @@
1
1
  import assert from "node:assert/strict";
2
2
  import test from "node:test";
3
+ import { spawnSync } from "node:child_process";
3
4
  import { closeSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
4
5
  import { tmpdir } from "node:os";
5
- import { join } from "node:path";
6
+ import { join, dirname } from "node:path";
7
+ import { fileURLToPath } from "node:url";
6
8
  import { compare, outputDescriptor, percentile, summarize } from "../scripts/render-cache-performance.mjs";
9
+ import { validatePiRoot } from "../scripts/render-cache-host.mjs";
7
10
 
8
11
  test("summaries preserve raw samples and interpolate percentiles", () => {
9
12
  const samples = [4, 1, 3, 2];
@@ -32,7 +35,28 @@ test("comparison requires identical cold and warm outputs and host identity", ()
32
35
  assert.throws(() => compare(before, after), "cannot compare different Pi versions");
33
36
  });
34
37
 
35
- test("report outputs cannot overwrite files or enter protected roots via symlinks", () => {
38
+ /**
39
+ * Windows without Developer Mode cannot create symlinks at all, so the protection below cannot be
40
+ * exercised there. Probing keeps the test honest instead of failing on an environment limitation.
41
+ */
42
+ function hostAllowsSymlinks(): boolean {
43
+ const probe = mkdtempSync(join(tmpdir(), "render-cache-symlink-probe-"));
44
+ try {
45
+ mkdirSync(join(probe, "target"));
46
+ symlinkSync(join(probe, "target"), join(probe, "link"), "dir");
47
+ return true;
48
+ } catch {
49
+ return false;
50
+ } finally {
51
+ rmSync(probe, { recursive: true, force: true });
52
+ }
53
+ }
54
+
55
+ test("report outputs cannot overwrite files or enter protected roots via symlinks", (t) => {
56
+ if (!hostAllowsSymlinks()) {
57
+ t.skip("host does not permit creating symlinks (Windows without Developer Mode); this protection is exercised on hosts that do");
58
+ return;
59
+ }
36
60
  const home = mkdtempSync(join(tmpdir(), "render-cache-output-"));
37
61
  try {
38
62
  const source = join(home, "source"); mkdirSync(source);
@@ -46,3 +70,148 @@ test("report outputs cannot overwrite files or enter protected roots via symlink
46
70
  closeSync(outputDescriptor(join(home, "new.json"), [source]));
47
71
  } finally { rmSync(home, { recursive: true, force: true }); }
48
72
  });
73
+
74
+ const workerScript = fileURLToPath(new URL("../scripts/render-cache-performance-worker.mjs", import.meta.url));
75
+
76
+ function runWorker(piRoot: string) {
77
+ return spawnSync(process.execPath, [workerScript, JSON.stringify({ piRoot })], { encoding: "utf8" });
78
+ }
79
+
80
+ /** Writes only the two manifests the worker validates first, so each test controls what is missing. */
81
+ function writeHost(options: { name?: string; version?: string; tuiName?: string; tuiVersion?: string } = {}): string {
82
+ const root = mkdtempSync(join(tmpdir(), "render-cache-host-"));
83
+ writeFileSync(join(root, "package.json"), JSON.stringify({
84
+ name: options.name ?? "@earendil-works/pi-coding-agent",
85
+ version: options.version ?? "1.2.0",
86
+ }));
87
+ const tui = join(root, "node_modules", "@earendil-works", "pi-tui");
88
+ mkdirSync(tui, { recursive: true });
89
+ writeFileSync(join(tui, "package.json"), JSON.stringify({
90
+ name: options.tuiName ?? "@earendil-works/pi-tui",
91
+ version: options.tuiVersion ?? "1.2.0",
92
+ }));
93
+ return root;
94
+ }
95
+
96
+ test("the worker names the host it refuses instead of reporting an unrelated version", () => {
97
+ const root = writeHost({ version: "9.9.9", tuiVersion: "9.9.9" });
98
+ try {
99
+ const result = runWorker(root);
100
+ assert.notEqual(result.status, 0, "a mismatched host must fail closed");
101
+ assert.match(result.stderr, /is @earendil-works\/pi-coding-agent@9\.9\.9/, "the error must name the package that was found");
102
+ assert.match(result.stderr, /audited only on 1\.2\.0/, "the error must name the audited version");
103
+ assert.match(result.stderr, /Point --pi-root at a Pi 1\.2\.0 install/, "the error must say how to satisfy it");
104
+ } finally { rmSync(root, { recursive: true, force: true }); }
105
+ });
106
+
107
+ test("a host whose manifests are not Pi's is refused before anything is imported", () => {
108
+ const root = writeHost({ name: "some-other-package" });
109
+ try {
110
+ const result = runWorker(root);
111
+ assert.notEqual(result.status, 0, "a foreign root must fail closed");
112
+ assert.match(result.stderr, /is not a Pi install root/);
113
+ assert.match(result.stderr, /expected @earendil-works\/pi-coding-agent/, "the error must name the expected package");
114
+ assert.doesNotMatch(result.stderr, /ERR_MODULE_NOT_FOUND/, "the layout must be reported, not a module resolution error");
115
+ } finally { rmSync(root, { recursive: true, force: true }); }
116
+ });
117
+
118
+ test("a host without the required dist layout is reported as a layout problem", () => {
119
+ const root = writeHost();
120
+ try {
121
+ const result = runWorker(root);
122
+ assert.notEqual(result.status, 0, "a root without dist must fail closed");
123
+ assert.match(result.stderr, /is not a Pi install root/);
124
+ assert.match(result.stderr, /dist is not a directory/, "the error must name the missing layout");
125
+ assert.doesNotMatch(result.stderr, /ERR_MODULE_NOT_FOUND/, "the layout must be reported, not a module resolution error");
126
+ } finally { rmSync(root, { recursive: true, force: true }); }
127
+ });
128
+
129
+ test("a manifest that is not an object is refused as a layout problem", () => {
130
+ const root = writeHost();
131
+ try {
132
+ writeFileSync(join(root, "package.json"), "null");
133
+ const result = runWorker(root);
134
+ assert.notEqual(result.status, 0, "a null manifest must fail closed");
135
+ assert.match(result.stderr, /declares no package name and version/);
136
+ assert.doesNotMatch(result.stderr, /TypeError/, "the root must be described, not dereferenced");
137
+ } finally { rmSync(root, { recursive: true, force: true }); }
138
+ });
139
+
140
+ test("a host missing a required dependency is refused as a layout problem", () => {
141
+ const root = writeHost();
142
+ try {
143
+ const entry = join(root, "dist", "core", "extensions", "jiti-loader.js");
144
+ mkdirSync(dirname(entry), { recursive: true });
145
+ writeFileSync(entry, "");
146
+ const result = runWorker(root);
147
+ assert.notEqual(result.status, 0, "an incomplete layout must fail closed");
148
+ assert.match(result.stderr, /pi-ai is missing/, "the error must name the dependency that is missing");
149
+ assert.doesNotMatch(result.stderr, /ERR_MODULE_NOT_FOUND/, "the layout must be reported, not a module resolution error");
150
+ } finally { rmSync(root, { recursive: true, force: true }); }
151
+ });
152
+
153
+ test("a required dependency that is not a directory is refused as a layout problem", () => {
154
+ const root = writeHost();
155
+ try {
156
+ const entry = join(root, "dist", "core", "extensions", "jiti-loader.js");
157
+ mkdirSync(dirname(entry), { recursive: true });
158
+ writeFileSync(entry, "");
159
+ for (const name of ["pi-ai", "pi-agent-core"]) {
160
+ mkdirSync(join(root, "node_modules", "@earendil-works", name), { recursive: true });
161
+ }
162
+ writeFileSync(join(root, "node_modules", "jiti"), "not a directory");
163
+ const result = runWorker(root);
164
+ assert.notEqual(result.status, 0, "a dependency that is not a directory must fail closed");
165
+ assert.match(result.stderr, /jiti is missing or not a directory/, "the error must name the dependency that is not a directory");
166
+ assert.doesNotMatch(result.stderr, /ERR_MODULE_NOT_FOUND/, "the layout must be reported, not a module resolution error");
167
+ } finally { rmSync(root, { recursive: true, force: true }); }
168
+ });
169
+
170
+ test("a mixed host names the audited version and the layout it needs", () => {
171
+ const root = writeHost({ tuiVersion: "1.2.1" });
172
+ try {
173
+ const result = runWorker(root);
174
+ assert.notEqual(result.status, 0, "a mixed host must fail closed");
175
+ assert.match(result.stderr, /mixes @earendil-works\/pi-coding-agent@1\.2\.0 with @earendil-works\/pi-tui@1\.2\.1/);
176
+ assert.match(result.stderr, /Point --pi-root at a Pi 1\.2\.0 install/, "the error must name the audited version");
177
+ assert.match(result.stderr, /node_modules\/@earendil-works\/\{pi-tui,pi-ai,pi-agent-core\}/, "the error must name the required layout");
178
+ } finally { rmSync(root, { recursive: true, force: true }); }
179
+ });
180
+
181
+ const driverScript = fileURLToPath(new URL("../scripts/render-cache-performance.mjs", import.meta.url));
182
+
183
+ /** Writes every path the host contract requires, so the positive case cannot drift from it. */
184
+ function writeCompleteHost(): string {
185
+ const root = writeHost();
186
+ const entry = join(root, "dist", "core", "extensions", "jiti-loader.js");
187
+ mkdirSync(dirname(entry), { recursive: true });
188
+ writeFileSync(entry, "");
189
+ for (const name of ["pi-ai", "pi-agent-core"]) mkdirSync(join(root, "node_modules", "@earendil-works", name), { recursive: true });
190
+ mkdirSync(join(root, "node_modules", "jiti"), { recursive: true });
191
+ return root;
192
+ }
193
+
194
+ test("a complete Pi root passes validation instead of being refused", () => {
195
+ const root = writeCompleteHost();
196
+ try {
197
+ const { host, hostTui } = validatePiRoot(root);
198
+ assert.equal(host.name, "@earendil-works/pi-coding-agent");
199
+ assert.equal(host.version, "1.2.0");
200
+ assert.equal(hostTui.version, "1.2.0");
201
+ const result = runWorker(root);
202
+ assert.doesNotMatch(result.stderr, /is not a Pi install root/, "a complete root must reach the host import, not the layout guard");
203
+ assert.ok(result.stderr.length > 0, "the worker must keep going until the host import fails");
204
+ } finally { rmSync(root, { recursive: true, force: true }); }
205
+ });
206
+
207
+ test("the documented command refuses a bad --pi-root before it fingerprints anything", () => {
208
+ const root = mkdtempSync(join(tmpdir(), "render-cache-empty-host-"));
209
+ try {
210
+ const result = spawnSync(process.execPath, [driverScript,
211
+ `--baseline-root=${dirname(workerScript)}`, `--candidate-root=${dirname(workerScript)}`,
212
+ `--pi-root=${root}`, `--output=${join(root, "report.json")}`], { encoding: "utf8" });
213
+ assert.notEqual(result.status, 0, "a bad host must fail closed");
214
+ assert.match(result.stderr, /is not a Pi install root/, "the driver must reuse the curated layout message");
215
+ assert.doesNotMatch(result.stderr, /ENOENT|ENOTDIR/, "the driver must not surface a bare read error");
216
+ } finally { rmSync(root, { recursive: true, force: true }); }
217
+ });
@@ -0,0 +1,173 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdtempSync, rmSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import test, { type TestContext } from "node:test";
6
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
7
+
8
+ import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
9
+ import {
10
+ REPLY_LANGUAGE_ANCHOR_TYPE,
11
+ humanLanguageExcerpt,
12
+ isHumanInput,
13
+ replyLanguageAnchor,
14
+ } from "../lib/reply-language-anchor.ts";
15
+
16
+ // ---------------------------------------------------------------------------
17
+ // full-delegation-mode-conflicts S9. User's words: "Hay veces que el orquestador
18
+ // está hablando en el idioma del usuario, pero cuando recibe un mensaje en inglés
19
+ // del subagente, lo toma como mensaje del usuario y sigue hablando en inglés."
20
+ //
21
+ // A prompt rule alone did not hold: the human's message can sit far up a long
22
+ // transcript or be compacted away. The harness records the human's own text and,
23
+ // when the model is about to answer right after an automated message, appends one
24
+ // persisted anchor that quotes the start of it. Mid tool-loop nothing is added, and
25
+ // once persisted the anchor is never re-added, so requests stay append-only.
26
+ // ---------------------------------------------------------------------------
27
+
28
+ const HUMAN = "Che, revisá por qué el writer no arranca y decime qué pasa con la admisión";
29
+ const user = (text: string) => ({ role: "user", content: [{ type: "text", text }], timestamp: 1 });
30
+ const custom = (customType: string, content = "Subagent gentle-ai-worker (task x) finished. All checks pass.") => ({ role: "custom", customType, content, display: true, timestamp: 2 });
31
+ const toolResult = () => ({ role: "toolResult", toolCallId: "t1", toolName: "read", content: [{ type: "text", text: "file text" }], isError: false, timestamp: 3 });
32
+ const assistant = () => ({ role: "assistant", content: [{ type: "text", text: "Voy a revisar." }], timestamp: 4 });
33
+ const WAKE = "[System-generated Gentle Agents notification, not written by the user] Subagent output was delivered to this session above. Review it and continue.";
34
+
35
+ test("S9: only human-typed input counts; extension-sent text, commands and empty input do not", () => {
36
+ assert.equal(isHumanInput("interactive", HUMAN), true);
37
+ assert.equal(isHumanInput("rpc", HUMAN), true);
38
+ assert.equal(isHumanInput("extension", HUMAN), false, "bridge wakes and resumes arrive with the extension source");
39
+ assert.equal(isHumanInput("interactive", "/gentle:profiles"), false);
40
+ assert.equal(isHumanInput("interactive", "!git status"), false);
41
+ assert.equal(isHumanInput("interactive", " "), false);
42
+ });
43
+
44
+ test("S9: the excerpt is the start of the human's own words, whitespace-collapsed and bounded", () => {
45
+ assert.equal(humanLanguageExcerpt(" hola\n\n qué tal "), "hola qué tal");
46
+ const long = humanLanguageExcerpt("palabra ".repeat(60));
47
+ assert.ok(long && long.length <= 101 && long.endsWith("…"));
48
+ assert.equal(humanLanguageExcerpt(" "), undefined);
49
+ });
50
+
51
+ test("S9: an automated message at the tail gets an anchor quoting the human", () => {
52
+ const anchor = replyLanguageAnchor([user(HUMAN), assistant(), custom("gentle-agents.result")] as never, undefined);
53
+ assert.ok(anchor);
54
+ assert.match(anchor, /not written by the human/);
55
+ assert.ok(anchor.includes(`«${humanLanguageExcerpt(HUMAN)}»`), "the anchor quotes the human's own words");
56
+ assert.match(anchor, /subagent results, notices, reminders and summaries never change it/);
57
+ });
58
+
59
+ test("S9: a bridge wake, sent with the user role, counts as automated, not as the human", () => {
60
+ const anchor = replyLanguageAnchor([user(HUMAN), assistant(), custom("gentle-agents.result"), user(WAKE)] as never, undefined);
61
+ assert.ok(anchor?.includes(`«${humanLanguageExcerpt(HUMAN)}»`), "the wake is never taken as the human's latest message");
62
+ });
63
+
64
+ test("S9: mid tool loop, or right after the human, nothing is anchored", () => {
65
+ assert.equal(replyLanguageAnchor([user(HUMAN), assistant(), toolResult()] as never, undefined), undefined);
66
+ assert.equal(replyLanguageAnchor([user(HUMAN)] as never, undefined), undefined);
67
+ });
68
+
69
+ test("S9: todo snapshots and reminders never trigger an anchor on their own", () => {
70
+ const messages = [user(HUMAN), assistant(), toolResult(), custom("gentle-todo-state", "Current todo list: ..."), custom("gentle-todo-reminder", "Update the list.")];
71
+ assert.equal(replyLanguageAnchor(messages as never, undefined), undefined);
72
+ // ...but they do not hide an automated message right before them either.
73
+ const behind = [user(HUMAN), assistant(), custom("gentle-agents.result"), custom("gentle-todo-state", "Current todo list: ...")];
74
+ assert.ok(replyLanguageAnchor(behind as never, undefined));
75
+ });
76
+
77
+ test("S9: an anchor already after the automated tail is not added again", () => {
78
+ const first = replyLanguageAnchor([user(HUMAN), assistant(), custom("gentle-agents.result")] as never, undefined)!;
79
+ const persisted = [user(HUMAN), assistant(), custom("gentle-agents.result"), { role: "custom", customType: REPLY_LANGUAGE_ANCHOR_TYPE, content: first, display: false, timestamp: 5 }];
80
+ assert.equal(replyLanguageAnchor(persisted as never, undefined), undefined);
81
+ });
82
+
83
+ test("S9: after compaction the recorded human text still anchors", () => {
84
+ const compacted = [{ role: "compactionSummary", summary: "The user asked about the writer admission.", tokensBefore: 1, timestamp: 1 }, custom("gentle-agents.result")];
85
+ assert.equal(replyLanguageAnchor(compacted as never, undefined), undefined, "with nothing recorded there is no human text to quote");
86
+ assert.ok(replyLanguageAnchor(compacted as never, HUMAN)?.includes(`«${humanLanguageExcerpt(HUMAN)}»`));
87
+ });
88
+
89
+ type Handler = (event: unknown, ctx: ExtensionContext) => unknown;
90
+ function hookFixture(t: TestContext, child = false) {
91
+ const cwd = mkdtempSync(join(tmpdir(), "reply-language-"));
92
+ t.after(() => rmSync(cwd, { recursive: true, force: true }));
93
+ const handlers = new Map<string, Handler>();
94
+ const sent: Array<{ message: { customType: string; content: string; display: boolean }; options: unknown }> = [];
95
+ const pi = {
96
+ on(name: string, handler: Handler) { handlers.set(name, handler); },
97
+ events: { on() {}, emit() {} }, registerCommand() {}, registerTool() {},
98
+ getActiveTools: () => ["read"], getFlag: () => undefined,
99
+ sendMessage(message: never, options: unknown) { sent.push({ message, options }); },
100
+ } as unknown as ExtensionAPI;
101
+ createGentleAiExtension({
102
+ nativeReviewCli: null,
103
+ processEnv: { GENTLE_PI_CONFIG_HOME: join(cwd, "config"), GENTLE_PI_AGENTS_CHILD: child ? "1" : "0" },
104
+ resolveTelemetryTriggerBinary: () => "/usr/bin/true", telemetryTriggerSpawn: (() => undefined) as never,
105
+ })(pi);
106
+ const ctx = { cwd, hasUI: false, mode: "interactive", ui: { notify() {} },
107
+ sessionManager: { getSessionId: () => "reply-language-test", getCwd: () => cwd },
108
+ getContextUsage: () => undefined, isIdle: () => true,
109
+ } as unknown as ExtensionContext;
110
+ return {
111
+ sent,
112
+ input: (text: string, source = "interactive") => handlers.get("input")!({ type: "input", text, source }, ctx),
113
+ context: (messages: unknown[]) => handlers.get("context")?.({ type: "context", messages }, ctx) as { messages?: unknown[] } | undefined,
114
+ };
115
+ }
116
+
117
+ test("S9: through the real hooks, a subagent result after the human gets one persisted anchor", async (t) => {
118
+ const f = hookFixture(t);
119
+ await f.input(HUMAN);
120
+ const messages = [user(HUMAN), assistant(), custom("gentle-agents.result"), user(WAKE)];
121
+ const result = await f.context(messages);
122
+ const trailing = result?.messages?.at(-1) as { customType?: string; content?: string } | undefined;
123
+ assert.equal(trailing?.customType, REPLY_LANGUAGE_ANCHOR_TYPE, "the anchor trails this request");
124
+ assert.equal(f.sent.length, 1, "and is persisted once, so the next request is append-only");
125
+ assert.equal(f.sent[0]!.message.customType, REPLY_LANGUAGE_ANCHOR_TYPE);
126
+ assert.equal(f.sent[0]!.message.display, false, "the anchor never shows in the transcript");
127
+ assert.deepEqual(f.sent[0]!.options, { triggerTurn: false }, "the anchor never starts a run");
128
+ // The next request carries the persisted anchor and adds nothing.
129
+ assert.equal(await f.context([...messages, result!.messages!.at(-1)]), undefined);
130
+ assert.equal(f.sent.length, 1);
131
+ });
132
+
133
+ test("S9: through the real hooks, extension-sourced input never replaces the human's text", async (t) => {
134
+ const f = hookFixture(t);
135
+ await f.input(HUMAN);
136
+ await f.input(WAKE, "extension");
137
+ const compacted = [{ role: "compactionSummary", summary: "Earlier work.", tokensBefore: 1, timestamp: 1 }, custom("gentle-agents.result")];
138
+ const result = await f.context(compacted);
139
+ assert.ok((result?.messages?.at(-1) as { content?: string })?.content?.includes(`«${humanLanguageExcerpt(HUMAN)}»`));
140
+ });
141
+
142
+ test("S9: child sessions are never anchored", async (t) => {
143
+ const f = hookFixture(t, true);
144
+ await f.input(HUMAN, "rpc");
145
+ assert.equal(await f.context([user(HUMAN), assistant(), custom("gentle-agents.result")]), undefined);
146
+ assert.equal(f.sent.length, 0);
147
+ });
148
+
149
+ // Independent verification advisory 1: keyed by the anchor text alone, a second automated result after the same
150
+ // human message got only a trailing copy, never persisted. One anchor is now persisted per automated tail.
151
+ test("S9: a second subagent result after the same human message gets its own persisted anchor", async (t) => {
152
+ const f = hookFixture(t);
153
+ await f.input(HUMAN);
154
+ const firstTail = [user(HUMAN), assistant(), custom("gentle-agents.result")];
155
+ const first = await f.context(firstTail);
156
+ assert.equal(f.sent.length, 1);
157
+ const persisted = first!.messages!.at(-1);
158
+ const second = [...firstTail, persisted, assistant(), toolResult(), { ...custom("gentle-agents.result"), timestamp: 9 }];
159
+ const result = await f.context(second);
160
+ assert.equal((result?.messages?.at(-1) as { customType?: string })?.customType, REPLY_LANGUAGE_ANCHOR_TYPE);
161
+ assert.equal(f.sent.length, 2, "the new automated tail is anchored and persisted too");
162
+ assert.equal(await f.context([...second, result!.messages!.at(-1)]), undefined, "and only once");
163
+ assert.equal(f.sent.length, 2);
164
+ });
165
+
166
+ // Independent verification probe: Pi flushes a persisted custom message at turn_end, after the turn's assistant
167
+ // message and tool results, so the anchor lands there rather than where the trailing copy sat.
168
+ test("S9: the anchor Pi flushes at turn_end, after the tool round, is not re-added", () => {
169
+ const first = replyLanguageAnchor([user(HUMAN), assistant(), custom("gentle-agents.result")] as never, HUMAN)!;
170
+ const flushed = [user(HUMAN), assistant(), custom("gentle-agents.result"), assistant(), toolResult(), { role: "custom", customType: REPLY_LANGUAGE_ANCHOR_TYPE, content: first, display: false, timestamp: 6 }];
171
+ assert.equal(replyLanguageAnchor(flushed as never, HUMAN), undefined);
172
+ });
173
+
@@ -598,7 +598,7 @@ for (const scenario of ["reload", "fork", "new", "off-branch"] as const) {
598
598
  }
599
599
 
600
600
  for (const scenario of ["concurrent-write", "shutdown"] as const) {
601
- test(`agent_end binds consumption to the captured mutation during async STATUS: ${scenario}`, async () => {
601
+ test(`agent_end binds consumption to the captured mutation during async STATUS: ${scenario}`, { timeout: 5_000 }, async () => {
602
602
  const session = ctx(`status-race-${scenario}`);
603
603
  let resolveStatus!: (status: ReviewStatusV3) => void;
604
604
  let entered!: () => void;
@@ -0,0 +1,193 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { __testing } from "../extensions/gentle-ai.ts";
4
+ import { NativeReviewCliError, NativeReviewIntegrationError, NATIVE_REVIEW_ERROR_CODE, type NativeReviewCli } from "../lib/native-review-cli.ts";
5
+ import { decodeReviewFailureV2 } from "../lib/review-integration-v2.ts";
6
+ import { withReviewBlocker } from "../lib/review-blocker.ts";
7
+
8
+ test("empty workspace requests the intended range without diagnosing a failed earlier review", () => {
9
+ const before = { operation: "status", status: "blocked", result: {
10
+ applicability: "unrelated", projection: { kind: "current-changes", paths: [] },
11
+ next_transition: { kind: "collect", reason_code: "empty_candidate_base_ref_required" },
12
+ }, collectBindings: [] };
13
+ const after = withReviewBlocker(before);
14
+ const { blocker, ...preserved } = after;
15
+ assert.deepEqual(preserved, before);
16
+ const diagnosis = blocker as Record<string, unknown>;
17
+ assert.equal(diagnosis.category, "input");
18
+ assert.equal(diagnosis.actor, "caller");
19
+ assert.equal(diagnosis.automatic_retry, false);
20
+ assert.match(String(diagnosis.next_step), /baseRef.*committedOnly/);
21
+ assert.match(String(diagnosis.next_step), /ASSESS.*original committed range/);
22
+ assert.match(String(diagnosis.next_step), /does not establish.*failed/);
23
+ assert.equal("nativeReviewOutcome" in after, false);
24
+ assert.equal("next_action" in after, false);
25
+ });
26
+
27
+ test("empty-candidate guidance preserves unknown mutations and explicit provider stops", () => {
28
+ const transition = { kind: "collect", reason_code: "empty_candidate_base_ref_required" };
29
+ for (const mutation_outcome of ["unknown", "partial_unknown"]) {
30
+ const result = withReviewBlocker({ status: "blocked", mutation_outcome, result: { next_transition: transition } });
31
+ assert.equal((result.blocker as Record<string, unknown>).category, "authority-unavailable");
32
+ }
33
+ const stopped = withReviewBlocker({ status: "blocked", result: { next_transition: { ...transition, kind: "stop" } } });
34
+ assert.equal((stopped.blocker as Record<string, unknown>).category, "provider-stop");
35
+ const failed = withReviewBlocker({ status: "blocked", outcome: "native-status-failed", result: { next_transition: transition } });
36
+ assert.equal((failed.blocker as Record<string, unknown>).category, "provider-unavailable");
37
+ });
38
+
39
+ test("native stops outrank capability remediation without changing provider evidence", () => {
40
+ for (const blocked of [{ outcome: "request-context-unsupported" }, { failure: { kind: "handshake-refused" } }]) {
41
+ for (const stop of [{ native_failure: { next_action: "stop" } }, { result: { next_transition: { kind: "stop" } } }]) {
42
+ const before = { status: "blocked", ...blocked, ...stop };
43
+ const { blocker, ...preserved } = withReviewBlocker(before);
44
+ assert.deepEqual(preserved, before);
45
+ assert.equal((blocker as Record<string, unknown>).category, "provider-stop");
46
+ assert.equal((blocker as Record<string, unknown>).automatic_retry, false);
47
+ assert.doesNotMatch(String((blocker as Record<string, unknown>).next_step), /reload/);
48
+ }
49
+ }
50
+ });
51
+
52
+ test("timed_out diagnostics use timeout guidance without granting a retry", () => {
53
+ const before = { status: "blocked", diagnostics: { timed_out: true } };
54
+ const { blocker, ...preserved } = withReviewBlocker(before);
55
+ assert.deepEqual(preserved, before);
56
+ assert.equal((blocker as Record<string, unknown>).category, "provider-unavailable");
57
+ assert.equal((blocker as Record<string, unknown>).automatic_retry, false);
58
+ assert.match(String((blocker as Record<string, unknown>).next_step), /timed out/);
59
+ });
60
+
61
+ test("a read-only inventory timeout says the read can be rerun without granting an automatic retry", () => {
62
+ const before = { status: "blocked", outcome: "native-status-timed-out", inventory_complete: false, diagnostics: { timed_out: true }, next_action: "rerun-native-status", remediation_command: "gentle-ai review status --cwd <repo> --contract gentle-ai.review-integration/v2 --agent pi --next-transition" };
63
+ const { blocker, ...preserved } = withReviewBlocker(before);
64
+ assert.deepEqual(preserved, before);
65
+ assert.deepEqual(blocker, {
66
+ category: "provider-unavailable", scope: "review-step", actor: "user", automatic_retry: false,
67
+ 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.",
68
+ });
69
+ const stopped = withReviewBlocker({ ...before, native_failure: { next_action: "stop" } });
70
+ assert.equal((stopped.blocker as Record<string, unknown>).category, "provider-stop");
71
+ });
72
+
73
+ test("unsupported STATUS suggests local capability diagnosis before upstream escalation", async () => {
74
+ const result = await __testing.executeReviewControllerOperation({ operation: "status" }, process.cwd(), {} as NativeReviewCli);
75
+ assert.equal(result.status, "blocked");
76
+ assert.equal(result.next_action, "check-native-provider-capabilities");
77
+ assert.equal((result.blocker as Record<string, unknown>)?.category, "provider-capability");
78
+ assert.equal((result.blocker as Record<string, unknown>)?.actor, "user");
79
+ assert.equal((result.blocker as Record<string, unknown>)?.automatic_retry, false);
80
+ });
81
+
82
+ for (const [kind, category, actor] of [
83
+ ["reviewer-config-invalid", "configuration", "user"],
84
+ ["reviewer-model-not-found", "configuration", "user"],
85
+ ["reviewer-thinking-invalid", "configuration", "user"],
86
+ ["reviewer-auth-unavailable", "configuration", "user"],
87
+ ["submission-refused", "admission-refused", "caller"],
88
+ ["reviewer-tool-call-attempted", "generation-invalid", "caller"],
89
+ ] as const) test(`${kind} has an actionable diagnosis without changing native or transport evidence`, () => {
90
+ const failure = { kind, stage: "pi", stderr: "opaque provider diagnostic" };
91
+ const before = { status: "blocked", outcome: "pi-host-relay-transport-failure", mutation_outcome: "none", mutation_performed: false, next_action: "original exact continuation", failure };
92
+ const after = withReviewBlocker(before), { blocker, ...preserved } = after;
93
+ assert.deepEqual(preserved, before);
94
+ assert.equal(after.failure, failure);
95
+ assert.deepEqual([ (blocker as Record<string, unknown>).category, (blocker as Record<string, unknown>).actor ], [category, actor]);
96
+ assert.equal((blocker as Record<string, unknown>).automatic_retry, false);
97
+ assert.equal("blocker" in before, false);
98
+ });
99
+
100
+ test("unknown submission and partial unknown group progress outrank configuration or admission advice", () => {
101
+ for (const mutation of ["unknown", "partial_unknown"]) {
102
+ const result = withReviewBlocker({ status: "blocked", mutation_outcome: mutation, failure: { kind: "submission-refused" } });
103
+ assert.equal(result.mutation_outcome, mutation);
104
+ assert.equal("mutation_performed" in result, false);
105
+ assert.equal((result.blocker as Record<string, unknown>).category, "authority-unavailable");
106
+ }
107
+ });
108
+
109
+ test("a native maintenance action names an authorized operator without assuming a remote maintainer", () => {
110
+ const native_failure = { next_action: "explicit-maintainer-action", code: "invalid_request" };
111
+ const result = withReviewBlocker({ status: "blocked", native_failure, next_action: "explicit-maintainer-action", mutation_outcome: "none" });
112
+ assert.equal(result.native_failure, native_failure);
113
+ assert.equal((result.blocker as Record<string, unknown>).actor, "authorized-operator");
114
+ assert.equal(result.next_action, "explicit-maintainer-action");
115
+ });
116
+
117
+ test("successful envelopes are returned unchanged and unknown prose is never treated as authority", () => {
118
+ const success = { status: "captured", result: "opaque" };
119
+ assert.equal(withReviewBlocker(success), success);
120
+ const result = withReviewBlocker({ status: "blocked", reason: "submission-refused reset locks retry now" });
121
+ assert.equal((result.blocker as Record<string, unknown>).category, "diagnosis-required");
122
+ assert.equal("next_action" in result, false);
123
+ });
124
+
125
+ test("stale consent remains scoped to the review step rather than delivery policy", () => {
126
+ const result = withReviewBlocker({ status: "blocked", outcome: "consent-binding-stale", next_action: "restart-for-fresh-consent" });
127
+ assert.equal((result.blocker as Record<string, unknown>).category, "stale-binding");
128
+ assert.equal((result.blocker as Record<string, unknown>).scope, "review-step");
129
+ assert.equal(result.next_action, "restart-for-fresh-consent");
130
+ });
131
+
132
+ test("negotiated transport refusal is a known capability problem rather than an unknown blocker", () => {
133
+ const relay_transport = { supported: false, code: "unsupported_transport", message: "opaque diagnostic" };
134
+ const result = withReviewBlocker({ status: "blocked", outcome: "pi-host-relay-transport-unavailable", relay_transport, next_action: "exact host continuation" });
135
+ assert.equal((result.blocker as Record<string, unknown>).category, "provider-capability");
136
+ assert.equal((result.blocker as Record<string, unknown>).actor, "user");
137
+ assert.equal(result.relay_transport, relay_transport);
138
+ assert.equal(result.next_action, "exact host continuation");
139
+ });
140
+
141
+ test("an offered acknowledgement is a normal continuation with no diagnostic investigation required", () => {
142
+ const raw = { next_transition: { kind: "execute", execute: { operation: "review.acknowledge-approved" } } };
143
+ const result = withReviewBlocker({ status: "blocked", result: raw, next_action: "exact host acknowledgement" });
144
+ assert.equal((result.blocker as Record<string, unknown>).category, "continuation");
145
+ assert.equal((result.blocker as Record<string, unknown>).actor, "caller");
146
+ assert.equal(result.result, raw);
147
+ assert.equal(result.next_action, "exact host acknowledgement");
148
+ });
149
+
150
+ test("normal collect offers remain continuations while contradictory failure evidence never becomes permission", () => {
151
+ const offer = { status: "blocked", collectBindings: [{ collectBinding: "opaque" }] };
152
+ assert.equal((withReviewBlocker(offer).blocker as Record<string, unknown>).category, "continuation");
153
+ const native_failure = { next_action: "stop" };
154
+ const failed = withReviewBlocker({ ...offer, native_failure });
155
+ assert.notEqual((failed.blocker as Record<string, unknown>).category, "continuation");
156
+ assert.equal((failed.blocker as Record<string, unknown>).native_next_action, "stop");
157
+ assert.equal((failed.blocker as Record<string, unknown>).automatic_retry, false);
158
+ });
159
+
160
+ test("unsupported execute operations are never labelled as supported continuations", () => {
161
+ const result = withReviewBlocker({ status: "blocked", result: { next_transition: { kind: "execute", execute: { operation: "arbitrary.command" } } } });
162
+ assert.equal((result.blocker as Record<string, unknown>).category, "diagnosis-required");
163
+ });
164
+
165
+ test("native stop remains authoritative even when an invalid request has a diagnostic category", async () => {
166
+ const failure = decodeReviewFailureV2({
167
+ schema: "gentle-ai.review-integration.failure/v2", contract: "gentle-ai.review-integration/v2",
168
+ operation: "review.status", phase: "preflight", code: "invalid_request", message: "Invalid request",
169
+ mutation_outcome: "not_started", authority_applicability: "not_evaluated", retry_safe: false,
170
+ replayability: "not_replayable", required_inputs: [], next_action: "stop",
171
+ });
172
+ const native = { targetStatus: async () => { throw new NativeReviewIntegrationError(failure); } } as unknown as NativeReviewCli;
173
+ const result = await __testing.executeReviewControllerOperation({ operation: "status" }, process.cwd(), native);
174
+ assert.equal(result.native_failure, failure.raw);
175
+ assert.equal(result.next_action, "stop");
176
+ assert.equal(result.replayability, "not_replayable");
177
+ assert.equal((result.blocker as Record<string, unknown>)?.automatic_retry, false);
178
+ assert.equal((result.blocker as Record<string, unknown>)?.native_next_action, "stop");
179
+ });
180
+
181
+ test("STATUS timeout is diagnosed without inventing lock contention or retry permission", async () => {
182
+ const diagnostics = { operation: "review/status" as const, error_code: NATIVE_REVIEW_ERROR_CODE.TIMEOUT, timed_out: true, output_limit_exceeded: false };
183
+ const native = { targetStatus: async () => { throw new NativeReviewCliError(NATIVE_REVIEW_ERROR_CODE.TIMEOUT, "review/status", true, false, "timed out", diagnostics); } } as unknown as NativeReviewCli;
184
+ const result = await __testing.executeReviewControllerOperation({ operation: "status" }, process.cwd(), native);
185
+ assert.equal((result.blocker as Record<string, unknown>)?.category, "provider-unavailable");
186
+ assert.equal((result.blocker as Record<string, unknown>)?.automatic_retry, false);
187
+ assert.equal(result.mutation_outcome, "none");
188
+ assert.deepEqual(result.diagnostics, diagnostics);
189
+ assert.equal(result.outcome, "native-status-timed-out");
190
+ assert.equal((result.blocker as Record<string, unknown>)?.actor, "user");
191
+ assert.doesNotMatch(String((result.blocker as Record<string, unknown>)?.next_step), /lock/);
192
+ assert.equal((result.blocker as Record<string, unknown>)?.scope, "review-step");
193
+ });
@@ -79,6 +79,6 @@ test("every windows system probe uses the configurable timeout", async () => {
79
79
  const { readFileSync } = await import("node:fs");
80
80
  const source = readFileSync(new URL("../lib/review-candidate-view-owner.ts", import.meta.url), "utf8");
81
81
  const probes = source.match(/windowsSystemExecutable\([^)]*\), \[[^\]]*\], \{[^}]*\}/g) ?? [];
82
- assert.equal(probes.length, 5);
82
+ assert.equal(probes.length, 4);
83
83
  for (const probe of probes) assert.match(probe, /timeout: resolveWindowsSystemProbeTimeoutMs\(\)/);
84
84
  });