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
@@ -0,0 +1,123 @@
1
+ import { formatElapsed } from "./agents-widget.ts";
2
+ import { formatCost, formatTokens } from "./shell-bar.ts";
3
+ import { PANEL_ROW_INDENT, renderPanelRow } from "./shell-panel.ts";
4
+ import { sanitizeTerminalText } from "./terminal-theme.ts";
5
+ import { visibleWidth } from "@earendil-works/pi-tui";
6
+
7
+ // Session statistics for the Power user rail (compact density): what the
8
+ // session spent, per model, and how the harness is behaving (cache reuse,
9
+ // tool failures, pace). Everything comes from the session's own entries.
10
+
11
+ export interface ModelStats {
12
+ model: string;
13
+ turns: number;
14
+ tokens: number;
15
+ cost: number;
16
+ }
17
+ export interface SessionStats {
18
+ cost: number;
19
+ input: number;
20
+ output: number;
21
+ cacheRead: number;
22
+ cacheWrite: number;
23
+ /** Assistant responses. */
24
+ turns: number;
25
+ toolCalls: number;
26
+ toolErrors: number;
27
+ /** From the first to the last dated entry. */
28
+ spanMs: number;
29
+ /** Cache reads over every prompt token, or undefined before the first prompt. */
30
+ cacheHitRate: number | undefined;
31
+ /** Most expensive first; ties by tokens. */
32
+ models: ModelStats[];
33
+ /** What this session's subagents spent, when the Agents section reports it. */
34
+ subagents?: { runs: number; tokens: number; cost: number };
35
+ }
36
+
37
+ type StatsEntry = {
38
+ type?: string;
39
+ timestamp?: unknown;
40
+ message?: {
41
+ role?: string;
42
+ model?: unknown;
43
+ isError?: unknown;
44
+ usage?: { input?: number; output?: number; cacheRead?: number; cacheWrite?: number; cost?: { total?: number } };
45
+ };
46
+ };
47
+
48
+ const count = (value: unknown) => (typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0);
49
+
50
+ export function collectSessionStats(entries: readonly unknown[]): SessionStats {
51
+ const stats: SessionStats = { cost: 0, input: 0, output: 0, cacheRead: 0, cacheWrite: 0, turns: 0, toolCalls: 0, toolErrors: 0, spanMs: 0, cacheHitRate: undefined, models: [] };
52
+ const models = new Map<string, ModelStats>();
53
+ let first = Infinity;
54
+ let last = -Infinity;
55
+ for (const raw of entries) {
56
+ const entry = raw as StatsEntry;
57
+ const at = typeof entry.timestamp === "string" ? Date.parse(entry.timestamp) : count(entry.timestamp) || Number.NaN;
58
+ if (Number.isFinite(at)) {
59
+ first = Math.min(first, at);
60
+ last = Math.max(last, at);
61
+ }
62
+ if (entry.type !== "message") continue;
63
+ const message = entry.message;
64
+ if (message?.role === "toolResult") {
65
+ stats.toolCalls++;
66
+ if (message.isError === true) stats.toolErrors++;
67
+ continue;
68
+ }
69
+ if (message?.role !== "assistant") continue;
70
+ const usage = message.usage ?? {};
71
+ const input = count(usage.input);
72
+ const output = count(usage.output);
73
+ const cacheRead = count(usage.cacheRead);
74
+ const cacheWrite = count(usage.cacheWrite);
75
+ const cost = count(usage.cost?.total);
76
+ stats.turns++;
77
+ stats.input += input;
78
+ stats.output += output;
79
+ stats.cacheRead += cacheRead;
80
+ stats.cacheWrite += cacheWrite;
81
+ stats.cost += cost;
82
+ // The registry id may carry a provider prefix (`claude-bridge/…`) and comes from
83
+ // session files, so it is reduced to the model name and stripped of escapes.
84
+ const id = typeof message.model === "string" ? sanitizeTerminalText(message.model).replace(/[\x00-\x1f\x7f]/g, "").trim() : "";
85
+ const name = id.slice(id.lastIndexOf("/") + 1) || "unknown";
86
+ const model = models.get(name) ?? { model: name, turns: 0, tokens: 0, cost: 0 };
87
+ model.turns++;
88
+ model.tokens += input + output + cacheRead + cacheWrite;
89
+ model.cost += cost;
90
+ models.set(name, model);
91
+ }
92
+ const prompt = stats.input + stats.cacheRead + stats.cacheWrite;
93
+ stats.cacheHitRate = prompt > 0 ? stats.cacheRead / prompt : undefined;
94
+ stats.spanMs = last > first ? last - first : 0;
95
+ stats.models = [...models.values()].sort((a, b) => b.cost - a.cost || b.tokens - a.tokens);
96
+ return stats;
97
+ }
98
+
99
+ type StatsTheme = { fg(role: string, text: string): string };
100
+
101
+ const plural = (n: number, word: string) => `${n} ${word}${n === 1 ? "" : "s"}`;
102
+
103
+ /** The Stats section rows: totals first, then one row per model. */
104
+ export function renderStatsRows(stats: SessionStats, theme: StatsTheme, width: number, subscription = false): string[] {
105
+ const label = (text: string) => theme.fg("muted", text.padEnd(7));
106
+ const value = (text: string) => theme.fg("text", text);
107
+ const muted = (text: string) => theme.fg("muted", text);
108
+ const rows = [
109
+ renderPanelRow(width, `${label("spent")}${value(formatCost(stats.cost, subscription))}`, muted(`${plural(stats.turns, "turn")} · ${formatElapsed(stats.spanMs)}`)),
110
+ renderPanelRow(width, `${label("tokens")}${value(`in ${formatTokens(stats.input)} · out ${formatTokens(stats.output)}`)}`),
111
+ ];
112
+ if (stats.cacheHitRate !== undefined) rows.push(renderPanelRow(width, `${label("cache")}${value(`${Math.round(stats.cacheHitRate * 100)}% hit · ${formatTokens(stats.cacheRead)} read`)}`));
113
+ const failed = stats.toolErrors ? ` · ${theme.fg("warning", `${stats.toolErrors} failed`)}` : "";
114
+ rows.push(renderPanelRow(width, `${label("tools")}${value(plural(stats.toolCalls, "call"))}${failed}`));
115
+ if (stats.subagents) rows.push(renderPanelRow(width, `${label("agents")}${value(`${plural(stats.subagents.runs, "run")} · ${formatTokens(stats.subagents.tokens)} · ${formatCost(stats.subagents.cost, subscription)}`)}`));
116
+ for (const model of stats.models) {
117
+ const numbers = `${plural(model.turns, "turn")} · ${formatTokens(model.tokens)} · ${formatCost(model.cost, subscription)}`;
118
+ // A narrow rail keeps the name: the numbers move to their own row instead of clipping it away.
119
+ if (visibleWidth(model.model) + 2 + visibleWidth(numbers) <= width - PANEL_ROW_INDENT) rows.push(renderPanelRow(width, value(model.model), muted(numbers)));
120
+ else rows.push(renderPanelRow(width, value(model.model)), renderPanelRow(width, muted(numbers), "", PANEL_ROW_INDENT + 2));
121
+ }
122
+ return rows;
123
+ }
package/lib/shell-todo.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import { truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
2
+ import type { OrchestratorMode } from "./agent-profiles.ts";
2
3
  import { CARD_TONE, panelHeaderRow, panelInnerWidth, renderCard, type CardTheme, type CardTone } from "./shell-card.ts";
3
4
  import { sanitizeTerminalText } from "./terminal-theme.ts";
4
5
  import { paintHoverable } from "./shell-hover.ts";
6
+ import { PANEL_ROW_INDENT, renderPanelHeader, renderPanelRow, type PanelSummary } from "./shell-panel.ts";
7
+ import { effectiveKey, type KeymapBindings } from "./keymaps.ts";
5
8
 
6
9
  // Gentle Todo: the task list the model keeps while it works. Everything here
7
10
  // is pure. The state lives in the session branch (every tool result carries
@@ -123,6 +126,10 @@ const NOTE_ROLE = "muted";
123
126
  const STALE_AFTER_TURNS = 2;
124
127
  /** Above this many rows the finished tasks fold into one line and the rest is capped. */
125
128
  const ROW_CAP = 12;
129
+ /** The key that folds the Todos card and section; GENTLE_PI_TODO_KEY overrides it ("" or "off" disables it), then keymaps.json. */
130
+ export function todoCollapseKey(env: NodeJS.ProcessEnv = process.env, bindings: KeymapBindings = {}): string | undefined {
131
+ return effectiveKey("todo.collapse", env, bindings);
132
+ }
126
133
 
127
134
  export function emptyTodo(): TodoState {
128
135
  return { tasks: [], nextId: 1, updatedTurn: null };
@@ -279,6 +286,8 @@ export function replayTodo(entries: readonly unknown[]): TodoState {
279
286
  // hidden transcript message appended when it changes (todoStateMessage,
280
287
  // gentle-shell#2195), so requests stay append-only and a change costs only
281
288
  // the tail of the conversation, never the prefix.
289
+ const TODO_SMALL_TASK_ORGANIC = "A small task (Task Size) uses no todo list: do it and report.";
290
+ const TODO_SMALL_TASK_FULL_DELEGATION = "A small task (Task Size) uses no todo list: delegate it and report.";
282
291
  const TODO_PROMPT_BLOCK = [
283
292
  "## Todo list",
284
293
  "A small task (Task Size) uses no todo list: do it and report. For tracked or multi-step work, keep it current with the `todo` tool: mark a task in_progress before starting it, done right after finishing it, and rewrite the whole list with `write` whenever the plan changes. Update it before you end the turn.",
@@ -287,7 +296,9 @@ const TODO_PROMPT_BLOCK = [
287
296
  ].join("\n");
288
297
 
289
298
  /** The byte-stable rules block appended to every system prompt. */
290
- export function todoPromptBlock(): string {
299
+ export function todoPromptBlock(mode: OrchestratorMode = "organic"): string {
300
+ // Full delegation mode: a small task still skips the list, but it goes to a writer.
301
+ if (mode === "full-delegation") return TODO_PROMPT_BLOCK.replace(TODO_SMALL_TASK_ORGANIC, TODO_SMALL_TASK_FULL_DELEGATION);
291
302
  return TODO_PROMPT_BLOCK;
292
303
  }
293
304
 
@@ -385,3 +396,70 @@ export function renderTodoCard(state: TodoState, theme: TodoTheme, width: number
385
396
  { expanded: true, hint, panel: true },
386
397
  );
387
398
  }
399
+
400
+ export interface TodoSection {
401
+ /** The `▾ TODOS … done/planned` header row, the section's collapse control; "" without tasks. */
402
+ header: string;
403
+ /** One row per entry under the header, every row exactly `width` columns. */
404
+ body: string[];
405
+ }
406
+
407
+ // The fullscreen rail's panel section: finished and dropped work fold into one
408
+ // row each, every open task takes one clipped row, and the note of the task in
409
+ // progress (or blocked) hangs under it, e.g. the job it launched.
410
+ // The task in progress or blocked is the one you read in full: its title and
411
+ // note wrap, so nothing about the current work is lost to a clip; every other
412
+ // task is one clipped row.
413
+ function sectionTaskRows(task: TodoTask, theme: TodoTheme, width: number): string[] {
414
+ const glyph = theme.fg(GLYPH_ROLE[task.status], STATUS_GLYPH[task.status]);
415
+ const focus = task.status === TODO_STATUS.IN_PROGRESS || task.status === TODO_STATUS.BLOCKED;
416
+ if (!focus) return [renderPanelRow(width, `${glyph} ${theme.fg(STATUS_ROLE[task.status], task.title)}`)];
417
+ const titleWidth = Math.max(1, width - PANEL_ROW_INDENT - 2);
418
+ const rows = wrapTextWithAnsi(task.title, titleWidth).map((line, index) => renderPanelRow(width, `${index === 0 ? glyph : " "} ${theme.fg(STATUS_ROLE[task.status], line)}`));
419
+ if (!task.note) return rows;
420
+ const noteWidth = Math.max(1, width - PANEL_ROW_INDENT - 4);
421
+ return [...rows, ...wrapTextWithAnsi(task.note, noteWidth).map((line, index) => renderPanelRow(width, `${index === 0 ? theme.fg("dim", "└") : " "} ${theme.fg(NOTE_ROLE, line)}`, "", PANEL_ROW_INDENT + 2))];
422
+ }
423
+
424
+ export function renderTodoSection(state: TodoState, theme: TodoTheme, width: number, options: Pick<TodoRenderOptions, "collapsed" | "staleTurns" | "hovered" | "collapseKey">): TodoSection {
425
+ if (state.tasks.length === 0) return { header: "", body: [] };
426
+ const { done, total } = todoSummary(state);
427
+ const planned = total - countStatus(state, TODO_STATUS.DROPPED);
428
+ const stale = options.staleTurns >= STALE_AFTER_TURNS;
429
+ // The collapse key rides the header, small and dim, as the only rail key hint.
430
+ const keyHint = options.collapseKey ? `${theme.fg("dim", options.collapseKey)} ` : "";
431
+ const header = renderPanelHeader(theme, width, {
432
+ title: "Todos",
433
+ count: `${keyHint}${stale ? `stale · ${options.staleTurns} turns · ` : ""}${done}/${planned}`,
434
+ countRole: stale ? "warning" : "muted",
435
+ open: !options.collapsed,
436
+ hovered: options.hovered,
437
+ });
438
+ const open = state.tasks.filter((task) => task.status !== TODO_STATUS.DONE && task.status !== TODO_STATUS.DROPPED);
439
+ if (options.collapsed) {
440
+ const current = [TODO_STATUS.IN_PROGRESS, TODO_STATUS.PENDING, TODO_STATUS.BLOCKED].map((status) => open.find((task) => task.status === status)).find(Boolean);
441
+ const row = current
442
+ ? `${theme.fg(GLYPH_ROLE[current.status], STATUS_GLYPH[current.status])} ${theme.fg(STATUS_ROLE[current.status], current.title)}`
443
+ : `${theme.fg(GLYPH_ROLE[TODO_STATUS.DONE], STATUS_GLYPH[TODO_STATUS.DONE])} ${theme.fg(NOTE_ROLE, `${done} done`)}`;
444
+ return { header, body: [renderPanelRow(width, row)] };
445
+ }
446
+ const body: string[] = [];
447
+ for (const [status, label] of [[TODO_STATUS.DONE, "done"], [TODO_STATUS.DROPPED, "dropped"]] as const) {
448
+ const count = countStatus(state, status);
449
+ if (count > 0) body.push(renderPanelRow(width, `${theme.fg(GLYPH_ROLE[status], STATUS_GLYPH[status])} ${theme.fg(NOTE_ROLE, `${count} ${label}`)}`));
450
+ }
451
+ for (const task of open) body.push(...sectionTaskRows(task, theme, width));
452
+ return { header, body };
453
+ }
454
+
455
+ /** The mobile work row's digest of the list: the task in progress (or next), and `done/planned`. */
456
+ export function todoWorkSummary(state: TodoState, theme: TodoTheme): PanelSummary | undefined {
457
+ if (state.tasks.length === 0) return undefined;
458
+ const { done, total } = todoSummary(state);
459
+ const planned = total - countStatus(state, TODO_STATUS.DROPPED);
460
+ const current = [TODO_STATUS.IN_PROGRESS, TODO_STATUS.PENDING, TODO_STATUS.BLOCKED].map((status) => state.tasks.find((task) => task.status === status)).find(Boolean);
461
+ const left = current
462
+ ? `${theme.fg(GLYPH_ROLE[current.status], STATUS_GLYPH[current.status])} ${theme.fg(STATUS_ROLE[current.status], current.title)}`
463
+ : `${theme.fg(GLYPH_ROLE[TODO_STATUS.DONE], STATUS_GLYPH[TODO_STATUS.DONE])} ${theme.fg(NOTE_ROLE, `${done} done`)}`;
464
+ return { left, right: `${done}/${planned}`, rightLabel: "todos" };
465
+ }
@@ -23,6 +23,8 @@ export interface UsageLimit {
23
23
  name: string;
24
24
  windows: UsageWindow[];
25
25
  limitReached: boolean;
26
+ /** "provider" when the limit covers every model of the provider (Codex's main limit). */
27
+ scope?: "provider";
26
28
  }
27
29
 
28
30
  export interface ProviderUsage {
@@ -286,7 +288,7 @@ export function parseCodexUsage(payload: unknown, now: number): ProviderUsage {
286
288
  const raw = (payload ?? {}) as RawCodexUsage;
287
289
  const limits: UsageLimit[] = [];
288
290
  const main = parseRateLimit(CODEX_MAIN_LIMIT, raw.rate_limit, now);
289
- if (main) limits.push(main);
291
+ if (main) limits.push({ ...main, scope: "provider" });
290
292
  for (const extra of raw.additional_rate_limits ?? []) {
291
293
  const limit = parseRateLimit(extra.limit_name ?? "limit", extra.rate_limit, now);
292
294
  if (limit) limits.push(limit);
@@ -308,7 +310,7 @@ export function parseCodexHeaders(headers: Record<string, string>, now: number):
308
310
  const windows = [headerWindow(headers, "primary"), headerWindow(headers, "secondary")].filter((window): window is UsageWindow => window !== undefined);
309
311
  if (windows.length === 0) return undefined;
310
312
  const reached = headers[`${HEADER_PREFIX}rate-limit-reached-type`];
311
- return { provider: CODEX_PROVIDER, plan: undefined, limits: [{ name: CODEX_MAIN_LIMIT, windows, limitReached: Boolean(reached) }], fetchedAt: now };
313
+ return { provider: CODEX_PROVIDER, plan: undefined, limits: [{ name: CODEX_MAIN_LIMIT, windows, limitReached: Boolean(reached), scope: "provider" }], fetchedAt: now };
312
314
  }
313
315
 
314
316
  // Claude Pro/Max sends utilization as a 0..1 fraction per window and reset
@@ -619,8 +621,16 @@ export function renderUsagePanel(usages: ProviderUsage[], theme: UsageTheme, wid
619
621
  export class UsageStore {
620
622
  private readonly usages = new Map<string, ProviderUsage>();
621
623
 
624
+ private readonly onRecord: ((usage: ProviderUsage) => void) | undefined;
625
+
626
+ /** `onRecord` hears every reading, e.g. the model fallback cooldown. */
627
+ constructor(onRecord?: (usage: ProviderUsage) => void) {
628
+ this.onRecord = onRecord;
629
+ }
630
+
622
631
  record(usage: ProviderUsage): void {
623
632
  this.usages.set(usage.provider, usage);
633
+ try { this.onRecord?.(usage); } catch { /* A listener never breaks the usage panel. */ }
624
634
  }
625
635
 
626
636
  get(provider: string): ProviderUsage | undefined {
@@ -0,0 +1,197 @@
1
+ import { execFile as nodeExecFile } from "node:child_process";
2
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { join, win32 } from "node:path";
4
+ import { spawn as nodeSpawn } from "node:child_process";
5
+ import { gentlePiConfigHome } from "./agent-home.ts";
6
+
7
+ export const STAR_PROMPT_SCHEMA = "gentle-shell.star-prompt/v1";
8
+ export const STAR_PROMPT_FILE = "star-prompt.json";
9
+ /** Both Gentleman-Programming repos get the star: the one in use and its sibling. */
10
+ export const STAR_PROMPT_REPOSITORIES = ["Gentleman-Programming/gentle-shell", "Gentleman-Programming/gentle-ai"] as const;
11
+ export const STAR_PROMPT_REPOSITORY_URLS = STAR_PROMPT_REPOSITORIES.map((repository) => `https://github.com/${repository}`);
12
+ /** Prompts 1..N stay silent; the offer may appear from N+1 on (t3code parity). */
13
+ export const PROMPTS_BEFORE_ASKING = 5;
14
+ /** Idle wait before offering, so the nudge never interrupts active typing. */
15
+ export const STAR_PROMPT_IDLE_MS = 30_000;
16
+ /** How long the footer offer stays visible without an answer. */
17
+ export const STAR_PROMPT_VISIBLE_MS = 5 * 60_000;
18
+
19
+ /** Raw terminal byte for Ctrl+G (the star chord; no editor text collides with a control byte). */
20
+ export const STAR_CHORD = "\x07";
21
+ /** Raw terminal byte for Alt+D (the dismiss chord). */
22
+ export const DISMISS_CHORD = "\x1bd";
23
+
24
+ export interface StarPromptState {
25
+ schema: string;
26
+ /** Interactive prompts sent across all sessions. */
27
+ sent: number;
28
+ /** Set by any dismissal; once true the prompt never asks again. */
29
+ dismissed: boolean;
30
+ }
31
+
32
+ export const DEFAULT_STAR_PROMPT_STATE: StarPromptState = {
33
+ schema: STAR_PROMPT_SCHEMA,
34
+ sent: 0,
35
+ dismissed: false,
36
+ };
37
+
38
+ export interface StarPromptStateRead {
39
+ state: StarPromptState;
40
+ /** Unreadable or malformed state: fail closed and never ask (a dismissal could not have been saved). */
41
+ unusable: boolean;
42
+ malformed: boolean;
43
+ readError: boolean;
44
+ file: string;
45
+ }
46
+
47
+ function record(value: unknown): value is Record<string, unknown> {
48
+ return typeof value === "object" && value !== null && !Array.isArray(value);
49
+ }
50
+
51
+ export function isStarPromptState(value: unknown): value is StarPromptState {
52
+ if (!record(value) || value.schema !== STAR_PROMPT_SCHEMA) return false;
53
+ return (
54
+ typeof value.sent === "number" && Number.isInteger(value.sent) && value.sent >= 0 &&
55
+ typeof value.dismissed === "boolean"
56
+ );
57
+ }
58
+
59
+ export function starPromptStateFile(configHome: string): string {
60
+ return join(configHome, STAR_PROMPT_FILE);
61
+ }
62
+
63
+ export function readStarPromptState(configHome: string, readFile: typeof readFileSync = readFileSync): StarPromptStateRead {
64
+ const file = starPromptStateFile(configHome);
65
+ const result: StarPromptStateRead = { state: { ...DEFAULT_STAR_PROMPT_STATE }, unusable: false, malformed: false, readError: false, file };
66
+ let raw: string;
67
+ try {
68
+ raw = readFile(file, "utf8");
69
+ } catch (error) {
70
+ // A missing file is a fresh install, not an error; anything else unreadable is unusable.
71
+ const code = record(error) && "code" in error ? (error as { code?: unknown }).code : undefined;
72
+ if (code !== "ENOENT") {
73
+ result.readError = true;
74
+ result.unusable = true;
75
+ }
76
+ return result;
77
+ }
78
+ try {
79
+ const parsed: unknown = JSON.parse(raw);
80
+ if (!isStarPromptState(parsed)) {
81
+ result.malformed = true;
82
+ result.unusable = true;
83
+ return result;
84
+ }
85
+ result.state = parsed;
86
+ return result;
87
+ } catch {
88
+ result.malformed = true;
89
+ result.unusable = true;
90
+ return result;
91
+ }
92
+ }
93
+
94
+ /** Writes the state atomically enough for a single-user config dir; a failed write must disable asking. */
95
+ export function writeStarPromptState(configHome: string, state: StarPromptState, writeFile: typeof writeFileSync = writeFileSync, mkdir: typeof mkdirSync = mkdirSync): void {
96
+ mkdir(configHome, { recursive: true });
97
+ writeFileSync(starPromptStateFile(configHome), `${JSON.stringify(state, null, "\t")}\n`, "utf8");
98
+ }
99
+
100
+ /** Pure gate: the full set of reasons the offer may appear right now. */
101
+ export function shouldOfferStarPrompt(input: { sent: number; dismissed: boolean; unusable: boolean; offeredThisSession: boolean; agentRunning: boolean }): boolean {
102
+ if (input.unusable || input.dismissed || input.offeredThisSession || input.agentRunning) return false;
103
+ return input.sent > PROMPTS_BEFORE_ASKING;
104
+ }
105
+
106
+ export function matchesStarPromptChord(data: string, chord: string): boolean {
107
+ return data === chord;
108
+ }
109
+
110
+ export type GhOutcome = "yes" | "no" | "unknown";
111
+
112
+ export interface GhDeps {
113
+ exec?: typeof nodeExecFile;
114
+ ghPath?: string;
115
+ repositories?: readonly string[];
116
+ }
117
+
118
+ function execGh(deps: GhDeps, args: readonly string[]): Promise<{ code: number; stderr: string }> {
119
+ const exec = deps.exec ?? nodeExecFile;
120
+ return new Promise((resolve) => {
121
+ exec(deps.ghPath ?? "gh", [...args], { timeout: 15_000 }, (error, _stdout, stderr) => {
122
+ // execFile passes null (not undefined) on success; both mean exit 0.
123
+ const rawCode: unknown = error == null ? 0 : (error as NodeJS.ErrnoException).code;
124
+ const code = typeof rawCode === "number" ? rawCode : 1;
125
+ resolve({ code, stderr: typeof stderr === "string" ? stderr : "" });
126
+ });
127
+ });
128
+ }
129
+
130
+ /** Resolves whether the authenticated gh account has starred every repository;
131
+ * unknown on any ambiguity (the PUT is idempotent, so partial knowledge is fine). */
132
+ export async function ghStarred(deps: GhDeps = {}): Promise<GhOutcome> {
133
+ let sawUnknown = false;
134
+ for (const repository of deps.repositories ?? STAR_PROMPT_REPOSITORIES) {
135
+ const { code, stderr } = await execGh(deps, ["api", `user/starred/${repository}`]);
136
+ if (code === 0) continue;
137
+ if (stderr.includes("HTTP 404")) return "no";
138
+ sawUnknown = true;
139
+ }
140
+ return sawUnknown ? "unknown" : "yes";
141
+ }
142
+
143
+ /** Stars every repository with the authenticated gh account; each PUT is an
144
+ * idempotent no-op when already starred. Any failure, a 404 included (missing
145
+ * repository or a token that cannot star), is unknown so the caller never thanks. */
146
+ export async function ghStar(deps: GhDeps = {}): Promise<GhOutcome> {
147
+ for (const repository of deps.repositories ?? STAR_PROMPT_REPOSITORIES) {
148
+ const { code } = await execGh(deps, ["api", "--method", "PUT", `user/starred/${repository}`]);
149
+ if (code !== 0) return "unknown";
150
+ }
151
+ return "yes";
152
+ }
153
+
154
+ type SpawnedChild = {
155
+ once(event: "spawn", listener: () => void): unknown;
156
+ once(event: "error", listener: (error: Error) => void): unknown;
157
+ unref(): void;
158
+ };
159
+
160
+ export interface OpenRepositoryDeps {
161
+ platform?: NodeJS.Platform;
162
+ spawn?: (command: string, args: readonly string[], options: Record<string, unknown>) => SpawnedChild;
163
+ env?: NodeJS.ProcessEnv;
164
+ }
165
+
166
+ export type OpenRepositoryResult = { opened: boolean; error?: string };
167
+
168
+ /** Fixed per-platform opener, always spawned with shell:false and an absolute path where Windows needs one. */
169
+ function openerFor(platform: NodeJS.Platform, url: string, env: NodeJS.ProcessEnv): { command: string; args: string[] } | string {
170
+ if (platform === "darwin") return { command: "/usr/bin/open", args: [url] };
171
+ if (platform === "win32") {
172
+ // Absolute path: Windows would otherwise search the current directory first.
173
+ const systemRoot = env.SystemRoot ?? env.SYSTEMROOT;
174
+ if (typeof systemRoot !== "string" || !win32.isAbsolute(systemRoot)) return "SystemRoot is not set to an absolute path";
175
+ return { command: win32.join(systemRoot, "System32", "rundll32.exe"), args: ["url.dll,FileProtocolHandler", url] };
176
+ }
177
+ return { command: "xdg-open", args: [url] };
178
+ }
179
+
180
+ /** Opens the repository URL in the default browser; resolves instead of throwing when that is impossible. */
181
+ export function openRepositoryInBrowser(url: string, deps: OpenRepositoryDeps = {}): Promise<OpenRepositoryResult> {
182
+ const opener = openerFor(deps.platform ?? process.platform, url, deps.env ?? process.env);
183
+ if (typeof opener === "string") return Promise.resolve({ opened: false, error: opener });
184
+ const spawn = deps.spawn ?? (nodeSpawn as unknown as NonNullable<OpenRepositoryDeps["spawn"]>);
185
+ return new Promise((resolve) => {
186
+ let child: SpawnedChild;
187
+ try {
188
+ child = spawn(opener.command, opener.args, { detached: true, stdio: "ignore", windowsHide: true, shell: false });
189
+ } catch (error) {
190
+ resolve({ opened: false, error: error instanceof Error ? error.message : String(error) });
191
+ return;
192
+ }
193
+ child.once("error", (error) => resolve({ opened: false, error: error.message }));
194
+ child.once("spawn", () => resolve({ opened: true }));
195
+ child.unref();
196
+ });
197
+ }
@@ -6,23 +6,33 @@ import { contextBackstopReached, type MeasuredContext } from "./context-backstop
6
6
  // verifier launch is admitted only when its task or context declares a named high-risk item, carries a task of an
7
7
  // existing feature document (the same lines writer admission accepts), or the parent's measured context reaches the
8
8
  // context backstop. The agent catalog has no generic verifier alias, so only `gentle-ai-verify` is gated.
9
- const VERIFIER_NAMES = ["gentle-ai-verify"];
9
+ export const VERIFIER_NAMES = ["gentle-ai-verify"];
10
10
  // A declaration that starts a line (optionally as a list item) or a sentence (after `.`, `!` or `?` and a space) with
11
11
  // `Risk:` whose first entry is `item N` with N in 1-6, for example `Risk: item 3 (shared parser)`, `- Risk: item 2,
12
12
  // item 3 (reason)` or `... on top of ebf3f35. Risk: item 1 (migration)`. `Risk: none` and a mention inside a
13
- // sentence ("Do not write Risk: item 3") do not start one.
14
- const HIGH_RISK_ITEM_LINE = /(?:^[ \t]*(?:[-*+][ \t]+)?|[.!?][ \t]+)Risk:[ \t]*item[ \t]+[1-6](?!\d)/m;
13
+ // sentence ("Do not write Risk: item 3") do not start one. The capture is the first named item.
14
+ const HIGH_RISK_ITEM_LINE = /(?:^[ \t]*(?:[-*+][ \t]+)?|[.!?][ \t]+)Risk:[ \t]*item[ \t]+([1-6])(?!\d)/m;
15
15
  export const VERIFIER_RISK_REJECTION =
16
- "An independent verifier runs only for a change that declares a named high-risk item (`Risk: item N` from the Task Size list in the task). This change declares none: run its focused test and suite inline yourself now; do not retry the launch, and never add a Risk line or create a feature document only to get a verifier admitted.";
16
+ "An independent verifier runs only for a change that declares a named high-risk item (`Risk: item N` from the Task Size list in the task). A supported `Risk: item N` declaration starts a line (optionally after a list marker like `- `) or a sentence (after `.`, `!` or `?` and a space), for example `Risk: item 2 (authorization tokens)`; a declaration after another separator such as `; ` or `,` is not recognized. No supported `Risk: item N` declaration was recognized in the launch `task` or `context`: run its focused test and suite inline yourself now; do not retry the launch, and never add a Risk line or create a feature document only to get a verifier admitted.";
17
+
18
+ // The first high-risk item a text declares with the admission grammar, or undefined when it declares none.
19
+ export function declaredHighRiskItem(text: string): number | undefined {
20
+ const match = HIGH_RISK_ITEM_LINE.exec(text);
21
+ return match ? Number(match[1]) : undefined;
22
+ }
23
+
24
+ export function isVerifierLaunch(input: unknown): input is Record<string, unknown> {
25
+ if (!input || typeof input !== "object" || Array.isArray(input)) return false;
26
+ const agent = (input as Record<string, unknown>).agent;
27
+ return typeof agent === "string" && VERIFIER_NAMES.includes(agent);
28
+ }
17
29
 
18
30
  export function rejectUnriskedVerifierLaunch(
19
31
  input: unknown,
20
32
  options: { root: string; contextUsage: MeasuredContext | undefined; env?: Readonly<Record<string, string | undefined>> },
21
33
  ): { block: true; reason: string } | undefined {
22
- if (!input || typeof input !== "object" || Array.isArray(input)) return undefined;
23
- const record = input as Record<string, unknown>;
24
- if (typeof record.agent !== "string" || !VERIFIER_NAMES.includes(record.agent)) return undefined;
25
- const values = [record.task, record.context];
34
+ if (!isVerifierLaunch(input)) return undefined;
35
+ const values = [input.task, input.context];
26
36
  if (values.some(value => typeof value === "string" && HIGH_RISK_ITEM_LINE.test(value))) return undefined;
27
37
  if (namesExistingFeatureDocumentTask(values, options.root)) return undefined;
28
38
  if (contextBackstopReached(options.contextUsage, options.env)) return undefined;
@@ -0,0 +1,64 @@
1
+ import { declaredHighRiskItem, isVerifierLaunch } from "./verifier-admission.ts";
2
+
3
+ // odd/tasks/verifier-settle-reminder.md (#2652): verifier admission only gates a launch that happens, so a run could
4
+ // declare `Risk: item N` in its final message and settle without ever attempting the independent verifier. At settle,
5
+ // such a primary run gets one visible reminder and one continuation; the declaration uses the admission grammar and
6
+ // any `gentle-ai-verify` launch attempt in the same user prompt, admitted or rejected, counts as an attempt.
7
+ export const VERIFIER_SETTLE_REMINDER_TYPE = "gentle-pi.verifier-settle-reminder";
8
+
9
+ export function verifierSettleReminderText(item: number): string {
10
+ return `Verification reminder: your final message declares \`Risk: item ${item}\`, but no independent verifier was launched for this prompt. Now launch \`gentle-ai-verify\` with the \`Risk: item ${item}\` line in its \`task\`. A user's visual or manual approval does not replace technical verification. If verification is unavailable, close with **Needs your decision** naming the missing proof.`;
11
+ }
12
+
13
+ // The text of the last assistant message, or undefined when the run has none.
14
+ export function finalAssistantText(messages: readonly unknown[]): string | undefined {
15
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
16
+ const message = messages[index];
17
+ if (!message || typeof message !== "object" || (message as { role?: unknown }).role !== "assistant") continue;
18
+ const content = (message as { content?: unknown }).content;
19
+ if (typeof content === "string") return content;
20
+ if (!Array.isArray(content)) return undefined;
21
+ return content
22
+ .filter((part): part is { type: "text"; text: string } => !!part && typeof part === "object" && part.type === "text" && typeof part.text === "string")
23
+ .map(part => part.text)
24
+ .join("");
25
+ }
26
+ return undefined;
27
+ }
28
+
29
+ interface PromptState {
30
+ verifierAttempted: boolean;
31
+ reminded: boolean;
32
+ }
33
+
34
+ // Per session, the state of the current user prompt. A continuation starts a new agent run within the same prompt, so
35
+ // only a new user prompt resets it; that is what keeps the reminder to one per prompt.
36
+ export function createVerifierSettleReminders<K>() {
37
+ const prompts = new Map<K, PromptState>();
38
+ const state = (key: K): PromptState => {
39
+ let current = prompts.get(key);
40
+ if (!current) {
41
+ current = { verifierAttempted: false, reminded: false };
42
+ prompts.set(key, current);
43
+ }
44
+ return current;
45
+ };
46
+ return {
47
+ userPrompt(key: K): void {
48
+ prompts.set(key, { verifierAttempted: false, reminded: false });
49
+ },
50
+ // Record before admission runs, so a rejected launch still counts as attempted.
51
+ toolCall(key: K, toolName: string, input: unknown): void {
52
+ if (toolName === "subagent_run" && isVerifierLaunch(input)) state(key).verifierAttempted = true;
53
+ },
54
+ // The reminder to append at this settle, or undefined when none is due.
55
+ beforeSettle(key: K, finalText: string | undefined): string | undefined {
56
+ const current = state(key);
57
+ if (current.reminded || current.verifierAttempted || finalText === undefined) return undefined;
58
+ const item = declaredHighRiskItem(finalText);
59
+ if (item === undefined) return undefined;
60
+ current.reminded = true;
61
+ return verifierSettleReminderText(item);
62
+ },
63
+ };
64
+ }
@@ -18,6 +18,11 @@ import { createRequire } from "node:module";
18
18
  // Keep these markers intact and rearm selection after their reverse-off;
19
19
  // state, undo, paste, layout and autocomplete contracts remain unchanged.
20
20
  // 1.3.0 and 1.4.0 ship editor.js, undo-stack.js and keys.js byte-identical to 1.2.0.
21
+ // 1.5.0 keeps undo-stack.js and editor-component.js byte-identical; editor.js adds a
22
+ // read-only `capturesViewportInput` getter (true while autocomplete is open) and also
23
+ // matches tui.select.pageUp/pageDown in the autocomplete menu, and keys.js adds Kitty
24
+ // F1-F12 functional-key mappings plus the Kitty functional PUA range filter. State,
25
+ // undo, paste, layout and autocomplete contracts remain unchanged.
21
26
  // Never silently adapt another build: undo also owns the paste registry.
22
27
  interface Position { line: number; col: number }
23
28
  interface State { lines: string[]; cursorLine: number; cursorCol: number }
@@ -58,7 +63,7 @@ interface PrivateEditor {
58
63
 
59
64
  // The single audited-release source for the adapter and Gentle Shell's runtime
60
65
  // identity gates. Add a release only after re-auditing the files named above.
61
- export const AUDITED_PI_EDITOR_VERSIONS = Object.freeze(["0.99.1", "0.99.2", "1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0"] as const);
66
+ export const AUDITED_PI_EDITOR_VERSIONS = Object.freeze(["0.99.1", "0.99.2", "1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0", "1.5.0"] as const);
62
67
  export type AuditedPiEditorVersion = (typeof AUDITED_PI_EDITOR_VERSIONS)[number];
63
68
 
64
69
  export function isAuditedPiEditorVersion(version: unknown): version is AuditedPiEditorVersion {