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
@@ -16,6 +16,28 @@ const read = (relative: string): string => readFileSync(join(REPO_ROOT, relative
16
16
  const tracking = read("assets/orchestrator-tracking.md");
17
17
  const core = read("assets/orchestrator.md");
18
18
 
19
+ const contextualApproval = 'Interpret short replies such as "yes", "go ahead", or "eso mismo" against the immediately preceding proposal. When the human unambiguously accepts a concrete implementation action they already understand, execute that action within its agreed scope without asking again. Confirming a preference alone does not authorize implementation; genuinely unclear change intent still requires one focused question. Contextual approval never substitutes for provider-owned consent, exact-token authorization, or separate publishing and destructive-action permission.';
20
+ const informedClarification = 'Clarify scope, constraints, acceptance criteria, and non-goals when needed for the human to understand the action or to resolve consequential uncertainty. Reuse what is already established; after informed approval, proceed without repeating the clarification unless new consequential uncertainty appears.';
21
+
22
+ test("contextual approval continues the agreed action without weakening consent boundaries", () => {
23
+ assert.ok(__testing.buildGentlePrompt("gentleman").includes(contextualApproval));
24
+ });
25
+
26
+ test("clarification preserves understanding without reopening informed approval", () => {
27
+ assert.ok(__testing.buildGentlePrompt("gentleman").includes(informedClarification));
28
+ assert.ok(read("skills/gentle-ai/SKILL.md").includes(informedClarification));
29
+ });
30
+
31
+ test("resolved subdecisions retain the original authorized objective", () => {
32
+ const prompt = __testing.buildGentlePrompt("gentleman");
33
+ assert.ok(prompt.includes("Resolving an incident or subdecision does not complete or cancel the original authorized objective; resume safe, necessary in-scope steps automatically, using judgment for proportionate recovery and respecting explicit user dispositions. Investigate pending technical uncertainty rather than treating it alone as a new human decision."));
34
+ assert.ok(prompt.includes("Stop for an unresolved consequential scope/product decision, required explicit consent, a denied action, or the human's explicit stop."));
35
+ assert.ok(prompt.includes("Unavailable required proof blocks completion and delivery; it does not alone prohibit specifically authorized in-scope implementation where actual native authority and other limits permit it."));
36
+ assert.ok(prompt.includes("After a setup prerequisite is repaired, the human may explicitly request one new bounded verification attempt."));
37
+ assert.ok(prompt.includes("Never bypass consent, a denial, explicit one-run or no-retry limits, terminal native outcomes, or exhausted native budgets."));
38
+ assert.ok(prompt.includes("Do not infer permission for publishing, destructive actions, unrelated scope or native consent from this continuity rule."));
39
+ });
40
+
19
41
  function authorizationSection(): string {
20
42
  const start = tracking.indexOf("#### Authorization and progress");
21
43
  assert.ok(start !== -1, "tracking module must keep its Authorization and progress section");
@@ -60,8 +60,8 @@ function harness(options: { malformed?: boolean; failWrite?: boolean; events?: P
60
60
  rows: () => buildNotificationRows(ctx) };
61
61
  }
62
62
 
63
- function findRow(rows: CustomizeRow[], label: string | RegExp): CustomizeRow {
64
- const found = rows.find(row => { const text = typeof row.label === "function" ? row.label() : row.label; return typeof label === "string" ? text.startsWith(label) : label.test(text); });
63
+ function findRow(rows: CustomizeRow[], label: string | RegExp, value?: string): CustomizeRow {
64
+ const found = rows.find(row => { const text = typeof row.label === "function" ? row.label() : row.label; return (value === undefined || row.choice?.value === value) && (typeof label === "string" ? text.startsWith(label) : label.test(text)); });
65
65
  assert.ok(found, `missing row ${label}`);
66
66
  return found!;
67
67
  }
@@ -70,21 +70,23 @@ function findRow(rows: CustomizeRow[], label: string | RegExp): CustomizeRow {
70
70
  function isVisible(row: CustomizeRow): boolean {
71
71
  try { return (row as CustomizeRow & { visible?: () => boolean }).visible?.() !== false; } catch { return false; }
72
72
  }
73
- function visibleRows(rows: CustomizeRow[]): CustomizeRow[] { return rows.filter(isVisible); }
73
+ function visibleRows(rows: CustomizeRow[]): CustomizeRow[] {
74
+ return rows.filter(isVisible).filter((row, i, shown) => !row.choice || row.choice.setting !== shown[i - 1]?.choice?.setting);
75
+ }
74
76
  function keyhintOf(row: CustomizeRow): string { return (row as CustomizeRow & { keyhint?: string }).keyhint ?? ""; }
75
77
 
76
78
  function fakeInline(inputs: (string | undefined)[] = [], confirms: boolean[] = []): CustomizeInline {
77
- return { input: async () => inputs.shift(), confirm: async () => confirms.shift() ?? false, disposed: false };
79
+ return { input: async () => inputs.shift(), capture: async () => undefined, confirm: async () => confirms.shift() ?? false, disposed: false };
78
80
  }
79
81
  function label(row: CustomizeRow): string { return typeof row.label === "function" ? row.label() : row.label; }
80
82
 
81
83
  test("Notifications rows toggle and mute directly without any nested native dialog", async () => {
82
84
  const h = harness(); try {
83
85
  const rows = h.rows();
84
- await findRow(rows, "Audio notifications: off").action(fakeInline());
86
+ await findRow(rows, "Audio notifications: off", "on").action(fakeInline());
85
87
  assert.equal(getNotificationService()!.getState().settings.enabled, true);
86
88
  assert.equal(h.writes, 1);
87
- await findRow(rows, "Audio: unmuted").action(fakeInline());
89
+ await findRow(rows, "Audio: unmuted", "on").action(fakeInline());
88
90
  assert.equal(getNotificationService()!.getState().muted, true);
89
91
  assert.equal(h.writes, 1, "mute persists in-process without writing configuration");
90
92
  assert.deepEqual(h.nested, { select: 0, input: 0, confirm: 0 });
@@ -101,10 +103,10 @@ test("labels and previews never probe, play or write and the card exposes no ava
101
103
  } finally { h.owner.retire(); }
102
104
  });
103
105
 
104
- test("event rows cycle independently and p tests the selected sound without writing", async () => {
106
+ test("event rows apply explicit choices independently and p tests the selected sound without writing", async () => {
105
107
  const h = harness(); try {
106
108
  const rows = h.rows();
107
- const failed = findRow(rows, "agent.failed:");
109
+ const failed = findRow(rows, "agent.failed:", "attention tone");
108
110
  assert.match(label(failed), /builtin:error/);
109
111
  await failed.action(fakeInline());
110
112
  assert.equal(getNotificationService()!.getState().settings.audio.events["agent.failed"], "builtin:attention");
@@ -157,7 +159,7 @@ test("malformed configuration needs fresh strict consent per attempt; a failed w
157
159
  for (const failWrite of [false, true]) {
158
160
  const h = harness({ malformed: true, failWrite }); try {
159
161
  const rows = h.rows();
160
- const enable = findRow(rows, "Audio notifications:");
162
+ const enable = findRow(rows, "Audio notifications:", "on");
161
163
  await enable.action(fakeInline([], [false]));
162
164
  assert.equal(h.writes, 0, "cancel preserves the file and settings");
163
165
  assert.equal(getNotificationService()!.getState().malformed, true);
@@ -200,25 +202,45 @@ function customizeView(rows: CustomizeRow[], onClose: () => void = () => {}) {
200
202
  profiles: { list: () => [], save: () => {}, apply: () => {}, delete: () => {}, reset: () => {} } });
201
203
  }
202
204
 
203
- /** Navigates the controls pane until the given label prefix carries the selection marker. */
205
+ /** Focus a row's inline setting without applying its highlighted value. */
204
206
  function selectControl(view: VisualCustomizeView, prefix: string): void {
207
+ assert.ok(view.focus(prefix), `could not select a control labelled ${prefix}`);
205
208
  view.render(76);
206
- view.handleInput("\x1b[C");
207
- for (let i = 0; i < 60; i++) {
208
- if (view.render(76).join("\n").includes(`\u25b8 ${prefix}`)) return;
209
- view.handleInput("\x1b[B");
210
- }
211
- assert.fail(`could not select a control labelled ${prefix}`);
212
209
  }
213
210
 
214
211
  /** Detailed event rows are folded by default: expand Advanced inside the same card, then select. */
215
212
  async function expandAndSelect(view: VisualCustomizeView, prefix: string): Promise<void> {
216
213
  selectControl(view, "Advanced");
214
+ view.handleInput("\x1b[C");
217
215
  view.handleInput("\r");
218
216
  await tick();
219
217
  selectControl(view, prefix);
220
218
  }
221
219
 
220
+ test("browsing notification choices neither saves nor opens a file or recovery prompt", async () => {
221
+ const h = harness();
222
+ try {
223
+ const before = structuredClone(getNotificationService()!.getState().settings);
224
+ const view = customizeView(h.rows());
225
+ for (const prefix of ["Audio notifications:", "Audio:", "Success:", "Advanced:"]) {
226
+ selectControl(view, prefix);
227
+ for (let i = 0; i < 4; i++) { view.handleInput("\x1b[C"); view.render(160); }
228
+ assert.doesNotMatch(view.render(160).join("\n"), /Local audio path|Replace malformed/);
229
+ }
230
+ assert.equal(h.writes, 0); assert.equal(h.probes, 0); assert.equal(h.played, 0);
231
+ assert.deepEqual(getNotificationService()!.getState().settings, before);
232
+ assert.deepEqual(h.nested, { select: 0, input: 0, confirm: 0 });
233
+ selectControl(view, "Success:");
234
+ for (let i = 0; i < 4; i++) view.handleInput("\x1b[C");
235
+ view.handleInput("\r");
236
+ assert.match(view.render(160).join("\n"), /Local audio path/);
237
+ view.handleInput("\x1b"); await tick(); await tick();
238
+ assert.equal(h.writes, 0);
239
+ assert.deepEqual(getNotificationService()!.getState().settings, before, "cancel preserves preferences");
240
+ view.dispose();
241
+ } finally { h.owner.retire(); }
242
+ });
243
+
222
244
  test("an in-flight local sound validation keeps busy, blocking a second field and any write until it settles", async () => {
223
245
  const h = harness(); try {
224
246
  const rows = h.rows();
@@ -313,14 +335,14 @@ test("event rows cover supported events and never expose session.shutdown", () =
313
335
  test("p on every basic non-event notification control stays on the audio card, opens no profiles and never previews", () => {
314
336
  const h = harness(); try {
315
337
  const rows = h.rows();
316
- const targets = ["Audio notifications:", "Audio: unmuted", "Advanced"];
338
+ const targets = [["Audio notifications:", "Enabled"], ["Audio: unmuted", "Mute"], ["Advanced", "Advanced"]];
317
339
  const listed: number[] = [];
318
340
  const view = new VisualCustomizeView({ rows, theme: { fg: (_role: string, text: string) => text }, rowsAvailable: () => 24, requestRender: () => {}, onClose: () => {}, profiles: {
319
341
  list: () => { listed.push(1); return []; }, save: () => {}, apply: () => {}, delete: () => {}, reset: () => {},
320
342
  } });
321
- for (const [i, target] of targets.entries()) {
343
+ for (const [i, [target, setting]] of targets.entries()) {
322
344
  selectControl(view, target);
323
- assert.ok(view.render(76).join("\n").includes(`\u25b8 ${target}`), `non-event row ${i} (${target}) must be the selected control`);
345
+ assert.ok(view.render(76).join("\n").includes(`\u25b8 ${setting} `), `non-event row ${i} (${target}) must be the selected control`);
324
346
  view.handleInput("p");
325
347
  const frame = view.render(76).join("\n");
326
348
  assert.equal(view.title(), "Audio notifications", `non-event row ${i} must keep the audio header`);
@@ -351,15 +373,15 @@ test("the basic card exposes exactly six human controls and an Advanced toggle w
351
373
  } finally { h.owner.retire(); }
352
374
  });
353
375
 
354
- test("context.high is exposed as an advanced per-event row that cycles independently", async () => {
376
+ test("context.high is exposed as an advanced per-event row with independent choices", async () => {
355
377
  const h = harness(); try {
356
378
  const rows = h.rows();
357
379
  assert.equal(label(findRow(rows, "context.high:")), "context.high: builtin:attention", "the attention tone is the context default");
358
- await findRow(rows, /^Advanced/).action(fakeInline());
380
+ await findRow(rows, /^Advanced/, "shown").action(fakeInline());
359
381
  assert.equal(visibleRows(rows).some(row => label(row).startsWith("context.high:")), true);
360
382
  await findRow(rows, "context.high:").action(fakeInline());
361
383
  const events = getNotificationService()!.getState().settings.audio.events;
362
- assert.equal(events["context.high"], null, "Enter cycles the context tone to silence without touching other events");
384
+ assert.equal(events["context.high"], null, "Enter applies silence to the context tone without touching other events");
363
385
  assert.equal(events["agent.attention"], "builtin:attention");
364
386
  assert.equal(h.writes, 1);
365
387
  } finally { h.owner.retire(); }
@@ -379,10 +401,10 @@ test("Advanced folds the fourteen detailed event rows inside the same card witho
379
401
  const rows = h.rows();
380
402
  const detail = () => visibleRows(rows).map(label).filter(text => /^(?:agent|subagent|session|context)\./.test(text));
381
403
  assert.equal(detail().length, 0, "detailed event rows stay folded by default");
382
- const toggle = findRow(rows, /^Advanced/);
404
+ const toggle = findRow(rows, /^Advanced/, "shown");
383
405
  await toggle.action(fakeInline());
384
406
  assert.equal(detail().length, 14, "expanding reveals the fourteen detailed rows");
385
- await toggle.action(fakeInline());
407
+ await findRow(rows, /^Advanced/, "hidden").action(fakeInline());
386
408
  assert.equal(detail().length, 0, "collapsing folds them again");
387
409
  assert.equal(h.writes, 0); assert.equal(h.probes, 0); assert.equal(h.played, 0);
388
410
  } finally { h.owner.retire(); }
@@ -394,7 +416,7 @@ test("global controls and the fold toggle advertise no sound key while group and
394
416
  for (const prefix of ["Audio notifications:", "Audio: unmuted", "Advanced"])
395
417
  assert.doesNotMatch(keyhintOf(findRow(rows, prefix)), /f sound/, `${prefix} is not a per-type file target`);
396
418
  for (const { prefix } of GROUPS) assert.match(keyhintOf(findRow(rows, prefix)), /f sound/, `${prefix} assigns its own sound`);
397
- await findRow(rows, /^Advanced/).action(fakeInline());
419
+ await findRow(rows, /^Advanced/, "shown").action(fakeInline());
398
420
  for (const prefix of ["agent.failed:", "agent.completed:"]) assert.match(keyhintOf(findRow(rows, prefix)), /f sound/);
399
421
  } finally { h.owner.retire(); }
400
422
  });
@@ -402,7 +424,7 @@ test("global controls and the fold toggle advertise no sound key while group and
402
424
  test("a group edit writes exactly its target events and preserves every other override", async () => {
403
425
  const h = harness(); try {
404
426
  const rows = h.rows();
405
- await findRow(rows, "Success:").action(fakeInline());
427
+ await findRow(rows, "Success:", "error tone").action(fakeInline());
406
428
  const events = getNotificationService()!.getState().settings.audio.events;
407
429
  assert.equal(events["agent.completed"], "builtin:error");
408
430
  assert.equal(events["subagent.completed"], "builtin:error");
@@ -416,7 +438,7 @@ test("a group edit writes exactly its target events and preserves every other ov
416
438
  test("error and attention groups target verified events only and never add subagent.waiting", async () => {
417
439
  const h = harness({ events: { "agent.failed": "builtin:error", "subagent.failed": "builtin:error", "subagent.timed_out": "builtin:error", "agent.attention": "builtin:attention", "subagent.waiting": "builtin:error" } }); try {
418
440
  const rows = h.rows();
419
- await findRow(rows, "Error:").action(fakeInline());
441
+ await findRow(rows, "Error:", "attention tone").action(fakeInline());
420
442
  let events = getNotificationService()!.getState().settings.audio.events;
421
443
  assert.equal(events["agent.failed"], "builtin:attention");
422
444
  assert.equal(events["subagent.failed"], "builtin:attention");
@@ -428,10 +450,10 @@ test("error and attention groups target verified events only and never add subag
428
450
  } finally { h.owner.retire(); }
429
451
  });
430
452
 
431
- test("a group whose targets diverge reads Custom until an explicit Enter applies the recommended tone", async () => {
453
+ test("a group whose targets diverge reads Custom until an explicit choice applies the success tone", async () => {
432
454
  const h = harness({ events: { "agent.completed": "builtin:success", "subagent.completed": null } }); try {
433
455
  const rows = h.rows();
434
- const success = findRow(rows, "Success:");
456
+ const success = findRow(rows, "Success:", "success tone");
435
457
  assert.equal(label(success), "Success: Custom (varies)");
436
458
  assert.equal(h.writes, 0);
437
459
  await success.action(fakeInline());
@@ -445,7 +467,7 @@ test("a group whose targets diverge reads Custom until an explicit Enter applies
445
467
  test("an omitted group reads silence and its edit writes only its targets without merging the preset", async () => {
446
468
  const h = harness({ events: {} }); try {
447
469
  const rows = h.rows();
448
- const success = findRow(rows, "Success:");
470
+ const success = findRow(rows, "Success:", "success tone");
449
471
  assert.equal(label(success), "Success: silence");
450
472
  await success.action(fakeInline());
451
473
  const events = getNotificationService()!.getState().settings.audio.events;
@@ -480,7 +502,7 @@ test("group p previews an unambiguous tone and mixed groups only point at Advanc
480
502
  test("Advanced expansion is ephemeral: rebuilding the card starts folded", async () => {
481
503
  const h = harness(); try {
482
504
  const first = h.rows();
483
- await findRow(first, /^Advanced/).action(fakeInline());
505
+ await findRow(first, /^Advanced/, "shown").action(fakeInline());
484
506
  assert.equal(visibleRows(first).map(label).filter(text => /^(?:agent|subagent|session)\./.test(text)).length, 13);
485
507
  const second = h.rows();
486
508
  assert.equal(visibleRows(second).map(label).filter(text => /^(?:agent|subagent|session)\./.test(text)).length, 0, "reopening folds the detailed rows");
@@ -557,7 +579,7 @@ test("a uniform file group shows the basename, prefills its path and previews th
557
579
  assert.doesNotMatch(label(success), /builtin:|file:|agent\.|subagent\./, "the main label stays human and raw-reference free");
558
580
  getNotificationService()!.validateFile = async () => true;
559
581
  const requests: string[] = [];
560
- const inline: CustomizeInline = { input: async request => { requests.push(request.value); return WAV_FIXTURES.success; }, confirm: async () => false, disposed: false };
582
+ const inline: CustomizeInline = { input: async request => { requests.push(request.value); return WAV_FIXTURES.success; }, capture: async () => undefined, confirm: async () => false, disposed: false };
561
583
  await Promise.resolve(success.key!("f", inline));
562
584
  await tick(); await tick();
563
585
  assert.deepEqual(requests, [WAV_FIXTURES.success], "the field is prefilled with the current file path");
@@ -602,14 +624,15 @@ test("the rendered basic card shows three independent group choices and hides pe
602
624
  view.render(76);
603
625
  view.handleInput("\x1b[C");
604
626
  const frame = () => view.render(76).join("\n");
605
- for (const { prefix } of GROUPS) assert.match(frame(), new RegExp(prefix), `${prefix} must be visible on the basic card`);
627
+ for (const { prefix } of GROUPS) assert.match(frame(), new RegExp(`${prefix.slice(0, -1)}\\s+`), `${prefix} must be visible on the basic card`);
606
628
  assert.doesNotMatch(frame(), /agent\.failed:/, "no per-event technical row is visible before Advanced");
607
629
  selectControl(view, "Success:");
608
630
  assert.match(frame(), /f sound/, "the selected group advertises its own file key");
609
631
  selectControl(view, "Advanced:");
632
+ view.handleInput("\x1b[C");
610
633
  view.handleInput("\r");
611
634
  await tick();
612
- assert.match(frame(), /agent\.failed:/, "Advanced reveals the per-event exceptions");
635
+ assert.match(frame(), /agent\.failed\s+/, "Advanced reveals the per-event exceptions");
613
636
  } finally { h.owner.retire(); }
614
637
  });
615
638
 
@@ -658,6 +681,7 @@ test("the Advanced per-event rows intentionally keep raw ids and builtin refs",
658
681
  view.render(76);
659
682
  view.handleInput("\x1b[C");
660
683
  selectControl(view, "Advanced:");
684
+ view.handleInput("\x1b[C");
661
685
  view.handleInput("\r");
662
686
  await tick();
663
687
  selectControl(view, "agent.failed:");
@@ -64,7 +64,7 @@ const ANCHORS: readonly RoutingAnchor[] = [
64
64
  label: "triggers hold only when their condition truly holds",
65
65
  canonical: "Each trigger holds only when its condition truly holds, and only then is it mandatory, not advisory; no trigger holds by default, and when in doubt work inline.",
66
66
  mirrors: [
67
- { surface: DELEGATION, includes: "Each trigger holds only when its condition truly holds, and only then is it mandatory, not advisory; no trigger holds by default, and when in doubt work inline." },
67
+ { surface: DELEGATION, includes: "Each trigger holds only when its condition truly holds; none holds by default. Inline stays within the evidence budget." },
68
68
  { surface: EXTENSION, includes: "No trigger holds by default and, when in doubt, work inline" },
69
69
  ],
70
70
  },
@@ -98,8 +98,8 @@ const ANCHORS: readonly RoutingAnchor[] = [
98
98
  label: "never explore to read files an inline write reads anyway",
99
99
  canonical: "Never explore to read files you will read anyway before writing inline.",
100
100
  mirrors: [
101
- { surface: DELEGATION, includes: "Never explore to read files you will read anyway before writing inline." },
102
- { surface: CORE, includes: "never for reading before an inline write" },
101
+ { surface: DELEGATION, includes: "Preparation for an already understood inline write stays inline, not further discovery." },
102
+ { surface: CORE, includes: "Exempt only preparation for an understood inline write, not discovery" },
103
103
  ],
104
104
  },
105
105
  {
@@ -168,8 +168,8 @@ const ANCHORS: readonly RoutingAnchor[] = [
168
168
  canonical: "**Verification trigger:** only a change whose Risk line names a high-risk item gets an independent verifier",
169
169
  mirrors: [
170
170
  // Verification by named risk: the core row names the escalate-only verifier.
171
- { surface: CORE, includes: "**Verification rule** — only a named high-risk item (assess `escalate`) → independent `gentle-ai-verify`" },
172
- { surface: DELEGATION, includes: "only a change whose Risk line names a high-risk item (Task Size, assess `escalate`) gets an independent `gentle-ai-verify` run" },
171
+ { surface: CORE, includes: "**Verification rule** — only a named high-risk item (assess `escalate` when RDD is on or unknown) → independent `gentle-ai-verify`" },
172
+ { surface: DELEGATION, includes: "only a change whose Risk line names a high-risk item (Task Size, assess `escalate` when RDD is on or unknown) gets an independent `gentle-ai-verify` run" },
173
173
  ],
174
174
  },
175
175
  {
@@ -238,7 +238,7 @@ const ANCHORS: readonly RoutingAnchor[] = [
238
238
  // rows, so they are mirror-only and not anchors of the canonical routing block.
239
239
  const CORE_ONLY_TRIGGERS = [
240
240
  "**Incident rule** — diagnose wrong cwd/worktree/git/tooling incidents separately",
241
- "**Verification rule** — only a named high-risk item (assess `escalate`) → independent `gentle-ai-verify`",
241
+ "**Verification rule** — only a named high-risk item (assess `escalate` when RDD is on or unknown) → independent `gentle-ai-verify`",
242
242
  ] as const;
243
243
 
244
244
  // The verified mirrored routing/pi.md: the bundle tree must pass the strict
@@ -346,7 +346,7 @@ test("ODD defaults to applicable test-first without chat or TUI activation", ()
346
346
  // once its condition truly holds; none holds by default, inline when in doubt.
347
347
  test("delegation triggers are behavioral in the lazy canonical port and the always-on ODD step", () => {
348
348
  for (const clause of [
349
- "Each trigger holds only when its condition truly holds, and only then is it mandatory, not advisory; no trigger holds by default, and when in doubt work inline.",
349
+ "Each trigger holds only when its condition truly holds; none holds by default. Inline stays within the evidence budget.",
350
350
  "stop and delegate through the runtime's subagent mechanism before continuing",
351
351
  "executing past a fired trigger inline is a routing defect even if the work succeeds",
352
352
  "**Mapping trigger",
@@ -36,7 +36,10 @@ const FIXTURE_PATH = join(import.meta.dirname, "fixtures", "orchestrator.pre-die
36
36
  // Weak-model economy (small path reads one batch with no todo; item 1 excludes rebuildable dev/test data), measured in
37
37
  // gentle-shell-bench 1321c60 (DeepSeek -24-30% time on x2/x5, -70% on a dev-database rename; Sol unchanged), user decision
38
38
  // 2026-10-22: 9,100 -> 9,250 B.
39
- const BUDGET_BYTES = 9250;
39
+ // Issue #2935 (user decision 2026-11-06): 9,250 -> 9,350 B so the confinement clause keeps its full wording
40
+ // (registered same-clone worktrees, never-blanket grants) while adding the resolved-skill-read exception; the
41
+ // controlled 128-char assets root needs the headroom for platform-independent rendering.
42
+ const BUDGET_BYTES = 9350;
40
43
  const MIN_CONTROLLED_LONG_ASSETS_ROOT_CHARS = 93;
41
44
 
42
45
  const LAZY_ASSET_NAMES = [
@@ -129,7 +132,7 @@ function measureOrchestratorPromptBytes(assetsDir: string): number {
129
132
  // measuring a shorter render again.
130
133
  const RDD_WORST_CASE_LINE = "Receipt-driven development: unknown (native status unavailable)";
131
134
 
132
- test("getOrchestratorPrompt return value stays within the canonical 9,250 B budget at a short assets root", () => {
135
+ test("getOrchestratorPrompt return value stays within the canonical 9,350 B budget at a short assets root", () => {
133
136
  const rendered = __testing.renderOrchestratorPrompt(representativeProductionAssetsDir);
134
137
  assert.ok(
135
138
  rendered.includes(RDD_WORST_CASE_LINE),
@@ -332,6 +335,8 @@ for (const range of DISPOSITION_MAP) {
332
335
  if (raw === undefined || !isNormativeLine(raw)) continue;
333
336
  const trimmed = raw.trim();
334
337
  const expected =
338
+ // Preserve the synthesis rule while reserving core bytes for the RDD scope condition.
339
+ ln === 13 ? "Default to concise synthesis: decision, outcome, next action. Expand on request or when detail is needed." :
335
340
  ln === 36 ? "- Substantial authorized work: use ODD; track feature progress automatically." :
336
341
  trimmed;
337
342
  if (SUPERSEDED_LIFECYCLE_REVIEW_LINES.has(ln)) {
@@ -0,0 +1,153 @@
1
+ import assert from "node:assert/strict";
2
+ import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import test, { after } from "node:test";
6
+
7
+ // ---------------------------------------------------------------------------
8
+ // full-delegation-mode S1/S3/S4/S7: one workflow block per turn, chosen by the
9
+ // profile, never both at once.
10
+ //
11
+ // The organic path is the compatibility surface: a profile that did not opt in
12
+ // must render the asset byte for byte, because every existing session and every
13
+ // budget measurement was taken against exactly those bytes.
14
+ // ---------------------------------------------------------------------------
15
+
16
+ const REPO_ROOT = join(import.meta.dirname, "..");
17
+ const REAL_ASSETS_DIR = join(REPO_ROOT, "assets");
18
+ const VARIANT_FILE = "orchestrator-full-delegation.md";
19
+ const ORGANIC_START = "You are a COORDINATOR, not the default executor for substantial work.";
20
+ const ORGANIC_END = "{{GENTLE_PI_BACKGROUND_POLICY}}";
21
+
22
+ const { __testing } = await import("../extensions/gentle-ai.ts");
23
+
24
+ const scratch: string[] = [];
25
+ function assetsDirWith(transform: (files: Record<string, string>) => Record<string, string> = (files) => files): string {
26
+ const dir = mkdtempSync(join(tmpdir(), "gp-delegation-mode-"));
27
+ scratch.push(dir);
28
+ const files: Record<string, string> = {
29
+ "orchestrator.md": readFileSync(join(REAL_ASSETS_DIR, "orchestrator.md"), "utf8"),
30
+ [VARIANT_FILE]: readFileSync(join(REAL_ASSETS_DIR, VARIANT_FILE), "utf8"),
31
+ };
32
+ for (const [name, content] of Object.entries(transform(files))) {
33
+ mkdirSync(dir, { recursive: true });
34
+ writeFileSync(join(dir, name), content);
35
+ }
36
+ return dir;
37
+ }
38
+ after(() => {
39
+ for (const dir of scratch) rmSync(dir, { recursive: true, force: true });
40
+ });
41
+
42
+ const organic = (dir: string) => __testing.renderOrchestratorPrompt(dir);
43
+ const full = (dir: string) => __testing.renderOrchestratorPrompt(dir, undefined, undefined, "full-delegation");
44
+
45
+ test("a profile that did not opt in renders the organic workflow region byte for byte", () => {
46
+ const dir = assetsDirWith();
47
+ const raw = readFileSync(join(REAL_ASSETS_DIR, "orchestrator.md"), "utf8");
48
+ const region = raw.slice(raw.indexOf(ORGANIC_START), raw.indexOf(ORGANIC_END));
49
+ assert.ok(region.length > 1000, "the fixture must actually span the organic workflow rules");
50
+ const rendered = organic(dir);
51
+ assert.ok(rendered.includes(region), "the organic region must survive rendering unchanged");
52
+ assert.equal(rendered, __testing.renderOrchestratorPrompt(dir, undefined, undefined, "organic"));
53
+ assert.equal(rendered.includes("in full delegation mode: you never implement"), false);
54
+ });
55
+
56
+ test("full delegation mode replaces the organic rules instead of adding to them", () => {
57
+ const dir = assetsDirWith();
58
+ const rendered = full(dir);
59
+ const variant = readFileSync(join(REAL_ASSETS_DIR, VARIANT_FILE), "utf8").trim();
60
+ const [beforeRisk, afterRisk] = variant.split("{{GENTLE_PI_HIGH_RISK_ITEMS}}");
61
+ assert.ok(rendered.includes(beforeRisk!.trim()) && rendered.includes(afterRisk!.trim()), "the variant block must be injected around its high-risk items");
62
+ assert.equal(rendered.includes(ORGANIC_START), false, "the organic role text must be gone, not merely followed");
63
+ // Task Size survives as tracking and risk only; its inline route does not.
64
+ assert.match(rendered, /## Task Size\n\nTask size decides tracking and risk, never who writes\./);
65
+ assert.equal(rendered.includes("Small path: inline"), false);
66
+ assert.equal(rendered.split("in full delegation mode: you never implement").length - 1, 1, "exactly one mode block");
67
+ });
68
+
69
+ test("both modes keep the shared sections, the lazy pointers and the rendered tokens", () => {
70
+ for (const rendered of [organic(assetsDirWith()), full(assetsDirWith())]) {
71
+ for (const shared of ["## Memory Contract", "## Safety", "## Skill Registry Protocol"]) {
72
+ assert.ok(rendered.includes(shared), `missing shared section: ${shared}`);
73
+ }
74
+ assert.ok(rendered.includes("orchestrator-prompts.md"), "the shared lazy pointers stay reachable");
75
+ assert.equal(rendered.includes("{{"), false, "no unrendered token may leak into the prompt");
76
+ }
77
+ // Each mode names its own routing detail and never the other's.
78
+ assert.ok(organic(assetsDirWith()).includes("orchestrator-delegation-reference.md"));
79
+ assert.equal(full(assetsDirWith()).includes("orchestrator-delegation-reference.md"), false);
80
+ assert.ok(full(assetsDirWith()).includes("orchestrator-full-delegation-card.md"));
81
+ });
82
+
83
+ test("the high-risk items keep one definition, taken from the organic core", () => {
84
+ const dir = assetsDirWith();
85
+ const highRisk = readFileSync(join(REAL_ASSETS_DIR, "orchestrator.md"), "utf8").split("\n").find((line) => line.startsWith("**High risk**:"));
86
+ assert.ok(highRisk);
87
+ assert.ok(full(dir).includes(highRisk), "the variant carries the organic paragraph itself, not a copy");
88
+ });
89
+
90
+ test("a missing high-risk paragraph falls back to the organic rules instead of a variant with no risk list", () => {
91
+ const dir = assetsDirWith((files) => ({ ...files, "orchestrator.md": files["orchestrator.md"].replace("**High risk**:", "**Risk, reworded upstream**:") }));
92
+ const rendered = full(dir);
93
+ assert.ok(rendered.includes("Small path: inline"), "the organic rules stay whole when the variant cannot be completed");
94
+ assert.equal(rendered.includes("in full delegation mode: you never implement"), false);
95
+ });
96
+
97
+ test("full delegation mode is not more expensive in context than the rules it replaces", () => {
98
+ const dir = assetsDirWith();
99
+ const organicBytes = Buffer.byteLength(organic(dir), "utf8");
100
+ const fullBytes = Buffer.byteLength(full(dir), "utf8");
101
+ assert.ok(
102
+ fullBytes < organicBytes,
103
+ `full delegation must cost less context than organic (${fullBytes} B vs ${organicBytes} B)`,
104
+ );
105
+ });
106
+
107
+ test("a missing variant asset falls back to the organic rules instead of a broken splice", () => {
108
+ const dir = assetsDirWith((files) => {
109
+ const { [VARIANT_FILE]: _dropped, ...rest } = files;
110
+ return rest;
111
+ });
112
+ const rendered = full(dir);
113
+ assert.equal(rendered, organic(dir));
114
+ assert.ok(rendered.includes("## Task Size"));
115
+ });
116
+
117
+ test("a drifted organic anchor falls back to the organic rules instead of a broken splice", () => {
118
+ const dir = assetsDirWith((files) => ({
119
+ ...files,
120
+ "orchestrator.md": files["orchestrator.md"].replace(ORGANIC_START, "You are a COORDINATOR, reworded upstream."),
121
+ }));
122
+ const rendered = full(dir);
123
+ assert.ok(rendered.includes("## Task Size"), "the organic rules stay whole when the splice cannot be made");
124
+ assert.equal(rendered.includes("in full delegation mode: you never implement"), false);
125
+ });
126
+
127
+ test("an empty variant asset falls back to the organic rules", () => {
128
+ const dir = assetsDirWith((files) => ({ ...files, [VARIANT_FILE]: " \n\n" }));
129
+ assert.equal(full(dir), organic(dir));
130
+ });
131
+
132
+ test("the memoized core is keyed by the mode, so a switch cannot serve stale rules", () => {
133
+ const cwd = REPO_ROOT;
134
+ const organicPrompt = __testing.getOrchestratorPrompt(cwd);
135
+ const fullPrompt = __testing.getOrchestratorPrompt(cwd, undefined, undefined, undefined, "full-delegation");
136
+ assert.notEqual(organicPrompt, fullPrompt, "a stale cache entry would return the previous profile's rules");
137
+ assert.ok(organicPrompt.includes("Small path: inline"));
138
+ assert.equal(fullPrompt.includes("Small path: inline"), false);
139
+ // Repeating each call still hits its own cache entry and never mixes them.
140
+ assert.equal(__testing.getOrchestratorPrompt(cwd), organicPrompt);
141
+ assert.equal(__testing.getOrchestratorPrompt(cwd, undefined, undefined, undefined, "full-delegation"), fullPrompt);
142
+ });
143
+
144
+ // gentle-shell#379: delegation stays inside the current runtime. The open
145
+ // "another available delegation mechanism" fallback is gone from the routing
146
+ // detail and the reference docs, and each names the stop rule instead.
147
+ test("delegation fallback never leaves the current runtime", () => {
148
+ for (const path of [join(REAL_ASSETS_DIR, "orchestrator-delegation-reference.md"), join(REPO_ROOT, "docs", "readme-reference.md")]) {
149
+ const text = readFileSync(path, "utf8");
150
+ assert.equal(text.includes("another available delegation mechanism"), false, path);
151
+ assert.match(text, /never fall back to an external pane, terminal, session, window, or remote worker/, path);
152
+ }
153
+ });
@@ -0,0 +1,82 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { ModelCooldown } from "../lib/model-fallback-policy.ts";
4
+ import { createOrchestratorFallback } from "../lib/orchestrator-fallback.ts";
5
+
6
+ const failed = (errorMessage: string) => [{ role: "user", content: "hi" }, { role: "assistant", content: [], stopReason: "error", errorMessage }];
7
+ const ok = [{ role: "assistant", content: [{ type: "text", text: "done" }], stopReason: "stop" }];
8
+
9
+ function setup(options: { chain?: Array<{ model: string; thinking?: "low" | "high" }>; catalog?: string[]; refuse?: string[]; throwing?: string[] } = {}) {
10
+ let current = "orc/primary";
11
+ const log: string[] = [];
12
+ const fallback = createOrchestratorFallback({
13
+ chain: () => options.chain ?? [{ model: "orc/second", thinking: "high" }, { model: "orc/third" }],
14
+ current: () => current,
15
+ available: (model) => (options.catalog ?? ["orc/primary", "orc/second", "orc/third"]).includes(model),
16
+ setModel: async (model) => {
17
+ if (options.throwing?.includes(model)) throw new Error("OAuth token expired");
18
+ if (options.refuse?.includes(model)) return false;
19
+ current = model;
20
+ log.push(`model ${model}`);
21
+ return true;
22
+ },
23
+ setThinking: (level) => log.push(`thinking ${level}`),
24
+ announce: (change) => log.push(`notice ${change.from}->${change.to} ${change.category}`),
25
+ resume: (message) => log.push(`resume ${/continue/i.test(message)}`),
26
+ thinking: () => "medium",
27
+ cooldown: new ModelCooldown(),
28
+ now: () => 1000,
29
+ });
30
+ return { fallback, log, current: () => current };
31
+ }
32
+
33
+ test("an orchestrator turn that hits its usage limit switches the session model and resumes", async () => {
34
+ const { fallback, log, current } = setup();
35
+ assert.equal(await fallback.onSettled(failed("insufficient_quota: monthly usage limit")), true);
36
+ assert.equal(current(), "orc/second");
37
+ assert.deepEqual(log, ["model orc/second", "thinking high", "notice orc/primary->orc/second quota", "resume true"]);
38
+ });
39
+
40
+ test("the orchestrator never switches on errors another model would repeat, on success or without a chain", async () => {
41
+ const context = setup();
42
+ assert.equal(await context.fallback.onSettled(failed("prompt is too long: maximum context length")), false);
43
+ assert.equal(await context.fallback.onSettled(ok), false);
44
+ assert.equal(await context.fallback.onSettled([{ role: "assistant", content: [], stopReason: "aborted" }]), false);
45
+ assert.deepEqual(context.log, []);
46
+ const none = setup({ chain: [] });
47
+ assert.equal(await none.fallback.onSettled(failed("rate limit exceeded")), false);
48
+ });
49
+
50
+ test("models outside the catalog or refused by Pi are skipped, and a spent chain stops", async () => {
51
+ const skip = setup({ catalog: ["orc/primary", "orc/third"] });
52
+ assert.equal(await skip.fallback.onSettled(failed("overloaded")), true);
53
+ assert.equal(skip.current(), "orc/third", "a model Pi does not know is skipped");
54
+ const refused = setup({ refuse: ["orc/second"] });
55
+ assert.equal(await refused.fallback.onSettled(failed("overloaded")), true);
56
+ assert.equal(refused.current(), "orc/third");
57
+ assert.equal(await refused.fallback.onSettled(failed("overloaded")), false, "every model was tried once");
58
+ });
59
+
60
+ test("a successful turn ends the episode: a later failure may use the chain again", async () => {
61
+ const { fallback, current } = setup({ chain: [{ model: "orc/second" }] });
62
+ assert.equal(await fallback.onSettled(failed("network error")), true);
63
+ assert.equal(await fallback.onSettled(ok), false);
64
+ assert.equal(current(), "orc/second");
65
+ assert.equal(await fallback.onSettled(failed("network error")), false, "orc/primary cools down and orc/second just failed");
66
+ });
67
+
68
+ test("an aborted run never resumes on a fallback, and a model Pi throws on gives way to the next", async () => {
69
+ const aborted = setup();
70
+ assert.equal(await aborted.fallback.onSettled(failed("insufficient_quota"), { aborted: true }), false);
71
+ assert.deepEqual(aborted.log, [], "the user stopped it: no switch, no resume");
72
+ const throwing = setup({ throwing: ["orc/second"] });
73
+ assert.equal(await throwing.fallback.onSettled(failed("insufficient_quota")), true);
74
+ assert.equal(throwing.current(), "orc/third");
75
+ });
76
+
77
+ test("a fallback step without its own effort runs at the session's original effort, not the previous step's", async () => {
78
+ const { fallback, log } = setup({ chain: [{ model: "orc/second", thinking: "high" }, { model: "orc/third" }], refuse: [] });
79
+ await fallback.onSettled(failed("insufficient_quota"));
80
+ await fallback.onSettled(failed("insufficient_quota"));
81
+ assert.deepEqual(log.filter((line) => line.startsWith("thinking")), ["thinking high", "thinking medium"]);
82
+ });