gentle-pi 4.6.0 → 4.8.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 (536) hide show
  1. package/README.md +65 -55
  2. package/assets/agents/gentle-ai-explore.md +4 -3
  3. package/assets/agents/gentle-ai-verify.md +23 -6
  4. package/assets/agents/gentle-ai-worker.md +9 -6
  5. package/assets/agents/jd-fix-agent.md +1 -0
  6. package/assets/agents/jd-judge-a.md +2 -3
  7. package/assets/agents/jd-judge-b.md +2 -3
  8. package/assets/agents/review-readability.md +1 -5
  9. package/assets/agents/review-reliability.md +1 -5
  10. package/assets/agents/review-resilience.md +1 -5
  11. package/assets/agents/review-risk.md +1 -5
  12. package/assets/design-canvas/canvas-api.js +45 -0
  13. package/assets/design-canvas/canvas-boards.js +456 -0
  14. package/assets/design-canvas/canvas-boot.js +217 -0
  15. package/assets/design-canvas/canvas-checks.js +491 -0
  16. package/assets/design-canvas/canvas-comments.js +315 -0
  17. package/assets/design-canvas/canvas-compare.js +159 -0
  18. package/assets/design-canvas/canvas-events.js +75 -0
  19. package/assets/design-canvas/canvas-export.js +393 -0
  20. package/assets/design-canvas/canvas-focus.js +203 -0
  21. package/assets/design-canvas/canvas-handoffs.js +150 -0
  22. package/assets/design-canvas/canvas-i18n-es.js +392 -0
  23. package/assets/design-canvas/canvas-i18n.js +108 -0
  24. package/assets/design-canvas/canvas-layout.js +526 -0
  25. package/assets/design-canvas/canvas-menu.js +213 -0
  26. package/assets/design-canvas/canvas-messages.js +86 -0
  27. package/assets/design-canvas/canvas-minimap.js +163 -0
  28. package/assets/design-canvas/canvas-parts.js +401 -0
  29. package/assets/design-canvas/canvas-popover.js +234 -0
  30. package/assets/design-canvas/canvas-rail.js +348 -0
  31. package/assets/design-canvas/canvas-sizes.js +524 -0
  32. package/assets/design-canvas/canvas-store.js +164 -0
  33. package/assets/design-canvas/canvas-tokens.js +674 -0
  34. package/assets/design-canvas/canvas-ui.js +24 -0
  35. package/assets/design-canvas/canvas-view.js +184 -0
  36. package/assets/design-canvas/canvas.css +759 -16
  37. package/assets/design-canvas/canvas.js +2 -1497
  38. package/assets/design-canvas/index.html +117 -36
  39. package/assets/design-canvas/inspector.js +546 -16
  40. package/assets/install-wizard/wizard.js +6 -1
  41. package/assets/migrations/agent-body-history.json +40 -1
  42. package/assets/orchestrator-delegation-reference.md +10 -16
  43. package/assets/orchestrator-delegation.md +5 -5
  44. package/assets/orchestrator-full-delegation-card.md +64 -0
  45. package/assets/orchestrator-full-delegation.md +34 -0
  46. package/assets/orchestrator-memory.md +5 -5
  47. package/assets/orchestrator-prompts.md +2 -2
  48. package/assets/orchestrator-quota-recovery.md +5 -0
  49. package/assets/orchestrator-skills.md +14 -13
  50. package/assets/orchestrator-tracking.md +10 -14
  51. package/assets/orchestrator-verification.md +12 -8
  52. package/assets/orchestrator-writer.md +4 -4
  53. package/assets/orchestrator.md +21 -25
  54. package/bin/gentle-shell.mjs +292 -65
  55. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
  56. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
  57. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
  58. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
  59. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
  60. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
  61. package/docs/agent-status.md +61 -0
  62. package/docs/assets/brand/sponsor-banner.svg +60 -0
  63. package/docs/bundled-install.md +20 -10
  64. package/docs/delegated-verification.md +46 -8
  65. package/docs/desktop-rpc.md +1253 -0
  66. package/docs/gentle-agents-activity.md +40 -0
  67. package/docs/gentle-shell.md +91 -30
  68. package/docs/install-wizard.md +30 -21
  69. package/docs/odd-preparation-continuity.md +24 -0
  70. package/docs/permission-modes.md +17 -4
  71. package/docs/prompt-budget.md +12 -0
  72. package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
  73. package/docs/readme-reference.md +142 -45
  74. package/docs/render-cache-performance.md +11 -1
  75. package/docs/review-coordinator.md +53 -0
  76. package/docs/review-delivery-preflight.md +22 -0
  77. package/docs/review-request-context.md +19 -0
  78. package/docs/review-windows-acl.md +18 -0
  79. package/docs/voice.md +6 -3
  80. package/docs/work-continuity.md +11 -1
  81. package/docs/yolo-mode.md +5 -5
  82. package/extensions/ask-user-choice.ts +1 -0
  83. package/extensions/ask-user-question.ts +3 -2
  84. package/extensions/child-context.ts +21 -7
  85. package/extensions/child-safety.ts +3 -0
  86. package/extensions/gentle-agent-status.ts +99 -0
  87. package/extensions/gentle-agents.ts +559 -66
  88. package/extensions/gentle-ai.ts +2001 -518
  89. package/extensions/gentle-design.ts +69 -3
  90. package/extensions/gentle-desktop-rpc.ts +143 -0
  91. package/extensions/gentle-guide.ts +3 -0
  92. package/extensions/gentle-shell.ts +398 -115
  93. package/extensions/gentle-todo.ts +66 -27
  94. package/extensions/gentle-tps.ts +48 -0
  95. package/extensions/quiet-tools.ts +38 -8
  96. package/extensions/skill-registry.ts +349 -167
  97. package/extensions/startup-banner.ts +30 -3
  98. package/lib/agent-assets.ts +30 -6
  99. package/lib/agent-profile-pin.ts +3 -3
  100. package/lib/agent-profiles.ts +160 -2
  101. package/lib/agent-status.ts +105 -0
  102. package/lib/agent-tool-overlay.ts +117 -0
  103. package/lib/agents-config.ts +93 -6
  104. package/lib/agents-history.ts +24 -5
  105. package/lib/agents-message-delivery.ts +17 -0
  106. package/lib/agents-messaging.ts +55 -7
  107. package/lib/agents-protocol.ts +15 -0
  108. package/lib/agents-report-cap.ts +115 -0
  109. package/lib/agents-runner.ts +272 -16
  110. package/lib/agents-session-transport.ts +17 -1
  111. package/lib/auto-permission-runtime.ts +1 -1
  112. package/lib/background-jobs-tools.ts +9 -4
  113. package/lib/bounded-writer-admission.ts +197 -32
  114. package/lib/card-content-policy.ts +8 -6
  115. package/lib/child-context-files.ts +21 -6
  116. package/lib/codemode-renderer.ts +1 -0
  117. package/lib/command-palette.ts +133 -17
  118. package/lib/context-backstop.ts +14 -5
  119. package/lib/delivery-conflict-markers.ts +349 -0
  120. package/lib/design-canvas-assets.ts +36 -0
  121. package/lib/design-canvas-server.ts +241 -23
  122. package/lib/design-comments.ts +94 -4
  123. package/lib/design-handoffs.ts +2 -1
  124. package/lib/design-layout.ts +125 -0
  125. package/lib/design-parts.ts +281 -0
  126. package/lib/design-system-tokens.ts +111 -0
  127. package/lib/desktop-agents-service.ts +294 -0
  128. package/lib/desktop-design-service.ts +233 -0
  129. package/lib/desktop-jobs-service.ts +263 -0
  130. package/lib/desktop-rpc-agents.ts +294 -0
  131. package/lib/desktop-rpc-config.ts +731 -0
  132. package/lib/desktop-rpc-design.ts +138 -0
  133. package/lib/desktop-rpc-jobs.ts +181 -0
  134. package/lib/desktop-rpc-permissions.ts +177 -0
  135. package/lib/desktop-rpc-profiles.ts +196 -0
  136. package/lib/desktop-rpc-usage.ts +229 -0
  137. package/lib/desktop-rpc.ts +225 -0
  138. package/lib/desktop-usage-service.ts +310 -0
  139. package/lib/destructive-command-guard.ts +236 -17
  140. package/lib/execution-surface-guard.ts +20 -0
  141. package/lib/exploration-budget.ts +4 -2
  142. package/lib/gentle-ai-binary.ts +1 -1
  143. package/lib/gentle-ai-renderer.ts +13 -1
  144. package/lib/gentle-design.ts +204 -14
  145. package/lib/gentle-shell-bundled.ts +106 -28
  146. package/lib/gentle-shell-launcher.ts +43 -8
  147. package/lib/herdr-activity.ts +14 -2
  148. package/lib/herdr-busy.ts +45 -0
  149. package/lib/hidden-tools.ts +35 -0
  150. package/lib/image-attachments.ts +33 -0
  151. package/lib/image-disk-cache.ts +137 -0
  152. package/lib/inprocess-reviewer.ts +358 -144
  153. package/lib/jobs-view.ts +198 -11
  154. package/lib/model-fallback-policy.ts +9 -0
  155. package/lib/model-routing-authority.ts +31 -4
  156. package/lib/nan-provider.ts +42 -28
  157. package/lib/native-choice-list.ts +20 -2
  158. package/lib/native-review-cli.ts +172 -20
  159. package/lib/orchestrator-discovery.ts +39 -2
  160. package/lib/orchestrator-mode-policy.ts +105 -0
  161. package/lib/questionnaire/questionnaire-view.ts +105 -12
  162. package/lib/rdd-mode-control.ts +32 -0
  163. package/lib/reply-language-anchor.ts +129 -0
  164. package/lib/request-context-placement.ts +53 -0
  165. package/lib/review-blocker.ts +92 -0
  166. package/lib/review-candidate-symlink-scan.ts +136 -0
  167. package/lib/review-candidate-view-owner.ts +81 -44
  168. package/lib/review-candidate-view.ts +11 -1
  169. package/lib/review-continuation-registry.ts +116 -0
  170. package/lib/review-coordinator.ts +407 -0
  171. package/lib/review-delivery-preflight.ts +85 -0
  172. package/lib/review-failure-facts.ts +49 -0
  173. package/lib/review-host-relay.ts +51 -11
  174. package/lib/review-integration-v2.ts +63 -4
  175. package/lib/review-relay-phase-timing.ts +45 -0
  176. package/lib/review-start-context.ts +17 -0
  177. package/lib/reviewer-stream.ts +87 -0
  178. package/lib/session-profile-freeze.ts +4 -2
  179. package/lib/shell-bar.ts +140 -58
  180. package/lib/shell-changes.ts +2 -0
  181. package/lib/shell-panel.ts +17 -3
  182. package/lib/shell-prompt.ts +16 -3
  183. package/lib/shell-sidebar-layout.ts +112 -40
  184. package/lib/shell-sidebar.ts +7 -0
  185. package/lib/shell-todo.ts +10 -3
  186. package/lib/shell-usage.ts +10 -0
  187. package/lib/verifier-admission.ts +1 -1
  188. package/lib/vim-editor-adapter.ts +9 -2
  189. package/lib/visual-customization-policy.ts +36 -16
  190. package/lib/visual-customize-view.ts +216 -21
  191. package/lib/visual-layout-preview.ts +9 -5
  192. package/lib/visual-profiles.ts +2 -2
  193. package/lib/windows-session-transport.ts +53 -2
  194. package/lib/writer-batch-admission.ts +55 -0
  195. package/lib/yolo-session-policy.ts +46 -16
  196. package/package.json +3 -2
  197. package/prompts/skill-creation.md +1 -10
  198. package/runtime/design-canvas-assets.mjs +37 -0
  199. package/runtime/gentle-ai-binary.mjs +1 -1
  200. package/runtime/gentle-shell-bundled.mjs +106 -28
  201. package/runtime/gentle-shell-launcher.mjs +42 -7
  202. package/runtime/native-review-cli.mjs +169 -17
  203. package/runtime/review-integration-v2.mjs +63 -4
  204. package/scripts/bootstrap.cmd +2 -2
  205. package/scripts/bootstrap.sh +41 -4
  206. package/scripts/build-full-delegation-card.mjs +179 -0
  207. package/scripts/build-runtime-modules.mjs +1 -0
  208. package/scripts/bundled-install.mjs +38 -8
  209. package/scripts/download-progress.mjs +68 -0
  210. package/scripts/gentle-ai-installer.mjs +41 -18
  211. package/scripts/gentle-ai-proxy.mjs +294 -0
  212. package/scripts/install-gentle-ai.mjs +14 -1
  213. package/scripts/installer-downloads.mjs +34 -8
  214. package/scripts/installer-preflight.mjs +33 -22
  215. package/scripts/installer-probes.mjs +25 -5
  216. package/scripts/installer-runner.mjs +27 -12
  217. package/scripts/installer-server.mjs +46 -16
  218. package/scripts/installer-windows.mjs +2 -2
  219. package/scripts/pi-update.mjs +166 -27
  220. package/scripts/prepare-verifier.mjs +107 -0
  221. package/scripts/render-cache-host.mjs +72 -0
  222. package/scripts/render-cache-performance-worker.mjs +5 -4
  223. package/scripts/render-cache-performance.mjs +6 -1
  224. package/scripts/run-test-suite.mjs +40 -28
  225. package/scripts/update-agent-body-history.mjs +55 -8
  226. package/scripts/verify-package-files.mjs +50 -19
  227. package/scripts/voice-worker.cjs +32 -6
  228. package/skills/branch-pr/SKILL.md +16 -16
  229. package/skills/comment-writer/SKILL.md +1 -1
  230. package/skills/design/SKILL.md +16 -13
  231. package/skills/gentle-ai/SKILL.md +7 -7
  232. package/skills/gentle-ui-design/SKILL.md +46 -0
  233. package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
  234. package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
  235. package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
  236. package/skills/gentle-ui-design/references/task-and-content.md +60 -0
  237. package/skills/judgment-day/SKILL.md +2 -2
  238. package/skills/judgment-day/references/prompts-and-formats.md +1 -1
  239. package/skills/rdd-defect-workflow/SKILL.md +6 -6
  240. package/skills/skill-improver/SKILL.md +2 -2
  241. package/skills/skill-registry/SKILL.md +11 -11
  242. package/skills/tui-design/SKILL.md +1 -1
  243. package/skills/work-unit-commits/SKILL.md +10 -11
  244. package/tests/agent-home.test.ts +28 -9
  245. package/tests/agent-profiles-workflow.test.ts +163 -0
  246. package/tests/agent-prompt-diet-contract.test.ts +101 -0
  247. package/tests/agent-risk-escalation.test.ts +1 -1
  248. package/tests/agent-status.test.ts +143 -0
  249. package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
  250. package/tests/agent-tool-overlay.test.ts +89 -0
  251. package/tests/agents-config.test.ts +106 -1
  252. package/tests/agents-history.test.ts +31 -0
  253. package/tests/agents-jobs-frames.test.ts +93 -0
  254. package/tests/agents-message-delivery.test.ts +36 -0
  255. package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
  256. package/tests/agents-queries.test.ts +144 -4
  257. package/tests/agents-report-cap.test.ts +126 -0
  258. package/tests/agents-runner-drain.test.ts +193 -0
  259. package/tests/agents-runner.test.ts +215 -3
  260. package/tests/agents-session-transport.test.ts +34 -0
  261. package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
  262. package/tests/append-system-prompt-route.test.ts +12 -1
  263. package/tests/approved-text-leftovers-contract.test.ts +136 -0
  264. package/tests/artifact-language.test.ts +1 -1
  265. package/tests/ask-user-choice.test.ts +4 -3
  266. package/tests/ask-user-question.test.ts +99 -1
  267. package/tests/audit-leftovers-contract.test.ts +51 -0
  268. package/tests/auto-permission-runtime.test.ts +1 -1
  269. package/tests/autonomous-guard.test.ts +346 -10
  270. package/tests/bounded-stop-contract.test.ts +51 -3
  271. package/tests/branch-pr-skill.test.ts +10 -1
  272. package/tests/bridge-cost.test.ts +19 -4
  273. package/tests/bundled-install.test.ts +31 -6
  274. package/tests/card-content-policy.test.ts +3 -3
  275. package/tests/chained-pr-skill.test.ts +8 -6
  276. package/tests/child-context-files.test.ts +64 -8
  277. package/tests/child-safety.test.ts +11 -0
  278. package/tests/child-skills-catalog.test.ts +56 -0
  279. package/tests/codegraph-tools.test.ts +11 -5
  280. package/tests/codemode-rendering.test.ts +4 -1
  281. package/tests/command-palette.test.ts +284 -1
  282. package/tests/delegate-for-reason-contract.test.ts +32 -10
  283. package/tests/delivery-conflict-markers.test.ts +348 -0
  284. package/tests/design-canvas-all-sizes.test.ts +631 -0
  285. package/tests/design-canvas-allowlist.test.ts +32 -0
  286. package/tests/design-canvas-assets.test.ts +11 -695
  287. package/tests/design-canvas-boards.test.ts +77 -0
  288. package/tests/design-canvas-checks.test.ts +655 -0
  289. package/tests/design-canvas-compare.test.ts +79 -0
  290. package/tests/design-canvas-events.test.ts +59 -0
  291. package/tests/design-canvas-export.test.ts +1168 -0
  292. package/tests/design-canvas-focus.test.ts +113 -0
  293. package/tests/design-canvas-handoffs.test.ts +59 -0
  294. package/tests/design-canvas-i18n-review.test.ts +513 -0
  295. package/tests/design-canvas-i18n-views.test.ts +259 -0
  296. package/tests/design-canvas-i18n.test.ts +526 -0
  297. package/tests/design-canvas-inspector.test.ts +937 -0
  298. package/tests/design-canvas-layout.test.ts +1222 -0
  299. package/tests/design-canvas-minimap.test.ts +413 -0
  300. package/tests/design-canvas-modules.test.ts +90 -0
  301. package/tests/design-canvas-parts.test.ts +721 -0
  302. package/tests/design-canvas-rail.test.ts +799 -0
  303. package/tests/design-canvas-server.test.ts +855 -17
  304. package/tests/design-canvas-sizes.test.ts +548 -0
  305. package/tests/design-canvas-store.test.ts +180 -0
  306. package/tests/design-canvas-tokens.test.ts +965 -0
  307. package/tests/design-canvas-view.test.ts +299 -0
  308. package/tests/design-comments.test.ts +201 -1
  309. package/tests/design-handoffs.test.ts +20 -0
  310. package/tests/design-layout.test.ts +100 -0
  311. package/tests/design-parts.test.ts +260 -0
  312. package/tests/design-system-tokens.test.ts +215 -0
  313. package/tests/desktop-rpc-agents.test.ts +893 -0
  314. package/tests/desktop-rpc-config.test.ts +1452 -0
  315. package/tests/desktop-rpc-design.test.ts +662 -0
  316. package/tests/desktop-rpc-jobs.test.ts +796 -0
  317. package/tests/desktop-rpc-permissions.test.ts +311 -0
  318. package/tests/desktop-rpc-profiles.test.ts +140 -0
  319. package/tests/desktop-rpc-safety.test.ts +119 -0
  320. package/tests/desktop-rpc-usage.test.ts +697 -0
  321. package/tests/desktop-rpc.test.ts +252 -0
  322. package/tests/destructive-command-guard.test.ts +52 -0
  323. package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
  324. package/tests/devbinary/review-session-consent.devtest.ts +84 -0
  325. package/tests/download-progress.test.ts +71 -0
  326. package/tests/engram-safety.test.ts +111 -0
  327. package/tests/execution-surface-guard.test.ts +55 -0
  328. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
  329. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
  330. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -31
  331. package/tests/fixtures/proxy-tls/proxy.crt +19 -0
  332. package/tests/fixtures/proxy-tls/proxy.key +28 -0
  333. package/tests/fixtures/refusal-identity.probe.mjs +139 -0
  334. package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
  335. package/tests/fixtures/session-profile-v1/replay.ts +53 -6
  336. package/tests/full-delegation-closure.test.ts +160 -0
  337. package/tests/full-delegation-notices.test.ts +76 -0
  338. package/tests/generic-agent-tools.test.ts +3 -3
  339. package/tests/gentle-agent-status.test.ts +74 -0
  340. package/tests/gentle-agents-child-jobs.test.ts +237 -0
  341. package/tests/gentle-agents.test.ts +1403 -20
  342. package/tests/gentle-ai-binary.test.ts +3 -1
  343. package/tests/gentle-ai-child-guards.test.ts +1 -0
  344. package/tests/gentle-ai-elapsed-store.test.ts +19 -0
  345. package/tests/gentle-ai-exploration-budget.test.ts +18 -2
  346. package/tests/gentle-ai-installer.test.ts +135 -51
  347. package/tests/gentle-ai-proxy.test.ts +434 -0
  348. package/tests/gentle-ai-renderer.test.ts +36 -2
  349. package/tests/gentle-ai.test.ts +233 -43
  350. package/tests/gentle-design.test.ts +386 -1
  351. package/tests/gentle-herdr-activity.test.ts +9 -6
  352. package/tests/gentle-shell-bin.test.ts +123 -0
  353. package/tests/gentle-shell-bundled.test.ts +293 -31
  354. package/tests/gentle-shell-launcher.test.ts +78 -11
  355. package/tests/gentle-shell.test.ts +1017 -146
  356. package/tests/gentle-todo.test.ts +51 -11
  357. package/tests/gentle-tps.test.ts +123 -0
  358. package/tests/gentle-ui-design-skill.test.ts +59 -0
  359. package/tests/herdr-busy.test.ts +59 -0
  360. package/tests/herdr-task-summary-policy.test.ts +8 -4
  361. package/tests/hidden-tools.test.ts +188 -0
  362. package/tests/image-disk-cache.test.ts +163 -0
  363. package/tests/independent-recovery-delivery.test.ts +97 -0
  364. package/tests/inprocess-reviewer.test.ts +249 -4
  365. package/tests/install-wizard.test.ts +27 -1
  366. package/tests/installer-downloads.test.ts +30 -1
  367. package/tests/installer-posix-bootstrap.test.ts +115 -14
  368. package/tests/installer-preflight.test.ts +54 -5
  369. package/tests/installer-probes.test.ts +146 -0
  370. package/tests/installer-runner.test.ts +79 -44
  371. package/tests/installer-server.test.ts +215 -13
  372. package/tests/installer-windows-bootstrap.test.ts +19 -1
  373. package/tests/jobs-view.test.ts +260 -6
  374. package/tests/judgment-day-severity-admission.test.ts +46 -0
  375. package/tests/lazy-module-contradictions-contract.test.ts +158 -0
  376. package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
  377. package/tests/maintainer/pi-update-source.maintest.ts +48 -18
  378. package/tests/modal-mouse-boundaries.test.ts +136 -0
  379. package/tests/model-fallback-policy.test.ts +26 -7
  380. package/tests/model-routing-authority.test.ts +178 -2
  381. package/tests/nan-provider-runtime.test.ts +17 -3
  382. package/tests/nan-provider.test.ts +111 -56
  383. package/tests/native-choice-list.test.ts +77 -2
  384. package/tests/native-review-capability-contract.test.ts +17 -1
  385. package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
  386. package/tests/native-review-cli.test.ts +269 -1
  387. package/tests/native-review-parity.test.ts +24 -5
  388. package/tests/native-review-refusal-identity.test.ts +25 -0
  389. package/tests/no-self-pause-contract.test.ts +13 -2
  390. package/tests/odd-integration.test.ts +11 -3
  391. package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
  392. package/tests/odd-routing-contract.test.ts +80 -28
  393. package/tests/orchestrator-budget.test.ts +35 -5
  394. package/tests/orchestrator-consultation-sdk.test.ts +32 -6
  395. package/tests/orchestrator-delegation-mode.test.ts +154 -0
  396. package/tests/orchestrator-discovery.test.ts +28 -0
  397. package/tests/orchestrator-mode-policy.test.ts +175 -0
  398. package/tests/orchestrator-prompt-budget.test.ts +13 -2
  399. package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
  400. package/tests/orchestrator-rdd-ownership.test.ts +4 -3
  401. package/tests/orchestrator-work-search.test.ts +4 -2
  402. package/tests/package-files.test.ts +25 -1
  403. package/tests/package-manifest.test.ts +16 -13
  404. package/tests/parallel-reason-contract.test.ts +6 -3
  405. package/tests/permission-allowlist.test.ts +372 -0
  406. package/tests/persona-neutral-voseo.test.ts +4 -4
  407. package/tests/persona-reply-language.test.ts +1 -1
  408. package/tests/persona-single-channel.test.ts +13 -5
  409. package/tests/pi-update-launcher.test.ts +25 -7
  410. package/tests/pi-update-source.test.ts +113 -6
  411. package/tests/pi-update.test.ts +294 -19
  412. package/tests/pnpm-workspace-config.test.ts +58 -0
  413. package/tests/pnpm-workspace-policy.test.ts +47 -0
  414. package/tests/primary-context-files.test.ts +233 -0
  415. package/tests/primary-context-three-files.test.ts +174 -0
  416. package/tests/primary-session-prompt.test.ts +13 -0
  417. package/tests/profile-pin.test.ts +29 -2
  418. package/tests/profile-tier-footer.test.ts +5 -0
  419. package/tests/profiles-panel-delegation-mode.test.ts +422 -0
  420. package/tests/provider-defect-handoff.test.ts +9 -2
  421. package/tests/questionnaire-view.test.ts +115 -0
  422. package/tests/quiet-bash-runtime.test.ts +1 -1
  423. package/tests/quiet-tool-rendering.test.ts +48 -0
  424. package/tests/rdd-aware-verification-contract.test.ts +17 -12
  425. package/tests/rdd-customize.test.ts +287 -0
  426. package/tests/rdd-mode-cache.test.ts +450 -0
  427. package/tests/rdd-mode-control.test.ts +407 -0
  428. package/tests/rdd-mode-scope-regression.test.ts +137 -0
  429. package/tests/rdd-off-independent-regression.test.ts +69 -0
  430. package/tests/rdd-status-line.test.ts +112 -1
  431. package/tests/render-cache-performance.test.ts +171 -2
  432. package/tests/reply-language-anchor-placement.test.ts +184 -0
  433. package/tests/reply-language-anchor.test.ts +189 -0
  434. package/tests/request-context-append-only.test.ts +218 -0
  435. package/tests/request-context-placement.test.ts +148 -0
  436. package/tests/review-agent-end-preflight.test.ts +80 -2
  437. package/tests/review-blocker.test.ts +193 -0
  438. package/tests/review-candidate-owner-retry.test.ts +1 -1
  439. package/tests/review-candidate-symlink-scan.test.ts +157 -0
  440. package/tests/review-candidate-view.test.ts +66 -1
  441. package/tests/review-candidate-windows-boundary.test.ts +131 -0
  442. package/tests/review-candidate-windows-probe.test.ts +63 -0
  443. package/tests/review-committed-restart-ack.test.ts +129 -0
  444. package/tests/review-continuation-registry.test.ts +107 -0
  445. package/tests/review-contract-prompt.test.ts +1 -1
  446. package/tests/review-controller-native-routing.test.ts +261 -5
  447. package/tests/review-controller-workspace-root.test.ts +230 -3
  448. package/tests/review-controller.test.ts +98 -12
  449. package/tests/review-coordinator-correction-gate.test.ts +105 -0
  450. package/tests/review-coordinator-findings.test.ts +206 -0
  451. package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
  452. package/tests/review-coordinator-runtime.test.ts +117 -0
  453. package/tests/review-coordinator.test.ts +462 -0
  454. package/tests/review-delivery-preflight.test.ts +462 -0
  455. package/tests/review-due-compaction.test.ts +31 -0
  456. package/tests/review-due-public-boundary.test.ts +26 -0
  457. package/tests/review-failure-facts.test.ts +87 -0
  458. package/tests/review-host-relay-routing.test.ts +258 -4
  459. package/tests/review-host-relay.test.ts +39 -0
  460. package/tests/review-integration-nonblocking-findings.test.ts +108 -0
  461. package/tests/review-integration-v2.test.ts +46 -3
  462. package/tests/review-json-arguments.test.ts +105 -11
  463. package/tests/review-last-event-closure.test.ts +68 -0
  464. package/tests/review-ledger-contract.test.ts +19 -40
  465. package/tests/review-loadout-rdd-off-sdk.test.ts +95 -32
  466. package/tests/review-one-call-findings.test.ts +131 -0
  467. package/tests/review-one-call-followups.test.ts +308 -0
  468. package/tests/review-one-call-reviewer-requests.test.ts +207 -0
  469. package/tests/review-one-call.test.ts +452 -0
  470. package/tests/review-owner-identity.test.ts +60 -24
  471. package/tests/review-relay-phase-timing.test.ts +128 -0
  472. package/tests/review-relay-transport-agent.test.ts +39 -2
  473. package/tests/review-reviewer-evidence.test.ts +223 -0
  474. package/tests/review-risk-assessment.test.ts +126 -8
  475. package/tests/review-run-statement-guidance-independent.test.ts +54 -0
  476. package/tests/review-session-standing-permission-controller.test.ts +53 -3
  477. package/tests/review-start-context.test.ts +19 -0
  478. package/tests/review-tool-prose-budget.test.ts +122 -0
  479. package/tests/reviewer-stream.test.ts +149 -0
  480. package/tests/run-test-suite.test.ts +122 -1
  481. package/tests/runtime-harness.mjs +4 -1
  482. package/tests/sensitive-path-tools.test.ts +181 -5
  483. package/tests/session-profile-append-controller-pi.test.ts +60 -31
  484. package/tests/session-profile-binding.test.ts +19 -1
  485. package/tests/session-profile-disk-reader-pi.test.ts +58 -16
  486. package/tests/session-profile-extension.test.ts +2 -2
  487. package/tests/session-profile-v1-compat.test.ts +35 -1
  488. package/tests/shell-bar.test.ts +186 -42
  489. package/tests/shell-panel.test.ts +50 -22
  490. package/tests/shell-prompt.test.ts +17 -0
  491. package/tests/shell-sidebar-fullscreen.test.ts +5 -5
  492. package/tests/shell-sidebar-layout.test.ts +294 -23
  493. package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
  494. package/tests/shell-surface-transparent.test.ts +89 -0
  495. package/tests/shell-todo.test.ts +12 -0
  496. package/tests/shell-usage.test.ts +59 -10
  497. package/tests/skill-contradictions-contract.test.ts +122 -0
  498. package/tests/skill-registry-watcher.test.ts +216 -2
  499. package/tests/skill-registry.test.ts +1461 -5
  500. package/tests/startup-banner.test.ts +152 -1
  501. package/tests/startup-home-repo.test.ts +2 -0
  502. package/tests/support/design-canvas-dom.ts +369 -0
  503. package/tests/support/review-coordinator-runtime.ts +264 -0
  504. package/tests/task-size-routing-contract.test.ts +45 -12
  505. package/tests/test-strength-contract.test.ts +2 -1
  506. package/tests/todo-request-append-only.test.ts +214 -0
  507. package/tests/tool-batching-contract.test.ts +3 -1
  508. package/tests/update-agent-body-history.test.ts +138 -0
  509. package/tests/verification-tiers-contract.test.ts +229 -0
  510. package/tests/verifier-admission.test.ts +49 -0
  511. package/tests/verifier-preparation.test.ts +229 -0
  512. package/tests/verify-agent-contract.test.ts +20 -2
  513. package/tests/verify-first-launch-contract.test.ts +162 -11
  514. package/tests/vim-editor-adapter.test.ts +2 -2
  515. package/tests/visual-customization-policy.test.ts +39 -6
  516. package/tests/visual-customize-view.test.ts +573 -9
  517. package/tests/visual-layout-preview.test.ts +15 -1
  518. package/tests/visual-profiles.test.ts +11 -0
  519. package/tests/voice-worker.test.ts +73 -2
  520. package/tests/windows-session-transport.test.ts +126 -0
  521. package/tests/work-continuity-contract.test.ts +77 -6
  522. package/tests/writer-admission-messages.test.ts +232 -0
  523. package/tests/writer-batch-admission.test.ts +66 -0
  524. package/tests/writer-edit-surface-scope.test.ts +52 -20
  525. package/tests/writer-feature-document-admission.test.ts +276 -0
  526. package/tests/yolo-customize.test.ts +27 -4
  527. package/tests/yolo-mode.test.ts +62 -18
  528. package/tests/yolo-session-policy.test.ts +270 -1
  529. package/skills/_shared/review-ledger-contract.md +0 -106
  530. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
  531. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
  532. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
  533. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  534. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
  535. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
  536. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -266,8 +266,8 @@ export function bundledPi(install: BundledInstall, input: { platform: string; fs
266
266
  // given explicitly, and its npm through the home's npmCommand setting), plus
267
267
  // only no Pi override, subagents on the same node and Pi (the subagent runner
268
268
  // splits GENTLE_PI_AGENTS_PI on whitespace, so a spaced path is left to its
269
- // default, the running node and cli.js), and no Pi update check, since Pi only
270
- // updates with Gentle Shell (S5). S9: the prefix (GENTLE_SHELL_PREFIX, from
269
+ // default, the running node and cli.js), and no separate Pi update check, since
270
+ // Shell handles Pi updates. S9: the prefix (GENTLE_SHELL_PREFIX, from
271
271
  // which gentle-pi derives its config folder and gives its own gentle-ai runs
272
272
  // Gentle AI's variables, never set here because the agent's shell would pass
273
273
  // them to a gentle-ai the user runs), and the published Engram as
@@ -275,7 +275,7 @@ export function bundledPi(install: BundledInstall, input: { platform: string; fs
275
275
  // (S2, S6): the startup policy, and ENGRAM_BIN is the Shell-owned guard, so no
276
276
  // provider, whatever loaded it, runs an Engram binary against a store; allowed
277
277
  // memory reaches the shared server through ENGRAM_URL only.
278
- export const ENGRAM_COMPANION_SOURCE = "npm:gentle-engram@0.4.2";
278
+ export const ENGRAM_COMPANION_SOURCE = "npm:gentle-engram";
279
279
  export const ENGRAM_RECOVERY_NOTICE = "Engram memory disabled: Shell could not verify safe server reuse. Matching versions or updating alone do not prove compatibility. Reuse requires a server on 127.0.0.1:7437 with verified /compatibility evidence; Shell never stops or replaces a server already listening there. Back up existing Engram data before manual changes; do not delete it or bypass the safety check. Shell rechecks on every launch and remains usable without memory.";
280
280
  export const ENGRAM_START_FAILED_NOTICE = "Engram memory disabled for this launch: Shell could not start the shared Engram server, or it did not report ready in time. Restart Shell to retry; if another program holds 127.0.0.1:7437, stop it first. Shell remains usable without memory.";
281
281
  export const ENGRAM_NEWER_SCHEMA_NOTICE = "Engram memory disabled: ~/.engram was migrated by a newer Engram than Shell's bundled core, so Shell will not start a server on it. Start that newer Engram's server yourself (engram serve); Shell reuses a running server with verified /compatibility evidence. Back up the store; do not delete or downgrade it. Shell remains usable without memory.";
@@ -286,16 +286,50 @@ export const ENGRAM_COMPATIBILITY_MIN_VERSION = "3.4.0";
286
286
  export function engramOutdatedServerNotice(version: string): string {
287
287
  return `Engram memory disabled: the running Engram server reports version ${version}, which cannot prove store compatibility. Back up your Engram data, update that server to ${ENGRAM_COMPATIBILITY_MIN_VERSION} or later with the method you installed it with, and restart it; updating Shell alone does not replace a running server. Shell rechecks on every launch and remains usable without memory.`;
288
288
  }
289
+ // A canonical numeric x.y.z (optionally v-prefixed, no leading zeros), split
290
+ // into numeric parts; undefined otherwise. The version comes from the server,
291
+ // so anything else is never echoed to the user.
292
+ function canonicalVersion(version: string | undefined): number[] | undefined {
293
+ const match = /^v?(0|[1-9]\d{0,3})\.(0|[1-9]\d{0,3})\.(0|[1-9]\d{0,3})$/.exec(version ?? "");
294
+ return match === null ? undefined : match.slice(1).map(Number);
295
+ }
296
+
297
+ // "older" or "same-or-newer" over canonical numeric parts, or undefined when
298
+ // the version itself is not canonical.
299
+ function compareVersion(version: string | undefined, minimum: string): "older" | "same-or-newer" | undefined {
300
+ const parts = canonicalVersion(version);
301
+ if (parts === undefined) return undefined;
302
+ const base = canonicalVersion(minimum);
303
+ if (base === undefined) return undefined;
304
+ for (let i = 0; i < parts.length; i += 1) {
305
+ if (parts[i] !== base[i]) return parts[i] < base[i] ? "older" : "same-or-newer";
306
+ }
307
+ return "same-or-newer";
308
+ }
309
+
289
310
  // A canonical numeric x.y.z (optionally v-prefixed, no leading zeros) older than
290
311
  // the minimum. The version comes from the server, so anything else is never
291
312
  // echoed to the user.
292
313
  function outdatedServerVersion(version: string | undefined): string | undefined {
293
- const match = /^v?(0|[1-9]\d{0,3})\.(0|[1-9]\d{0,3})\.(0|[1-9]\d{0,3})$/.exec(version ?? "");
294
- if (match === null) return undefined;
295
- const parts = match.slice(1).map(Number);
296
- const minimum = ENGRAM_COMPATIBILITY_MIN_VERSION.split(".").map(Number);
297
- const index = parts.findIndex((part, i) => part !== minimum[i]);
298
- return index >= 0 && parts[index] < minimum[index] ? parts.join(".") : undefined;
314
+ const parts = canonicalVersion(version);
315
+ if (parts === undefined) return undefined;
316
+ return compareVersion(version, ENGRAM_COMPATIBILITY_MIN_VERSION) === "older" ? parts.join(".") : undefined;
317
+ }
318
+
319
+ // The first release whose CLI runs the shared server's whole lifecycle as a
320
+ // pidfile-tracked daemon (`engram run -d` plus the `ps`, `stop`, `logs`,
321
+ // `restart` verbs; engram issues #2228 and #2346): a core older than this
322
+ // knows only `serve`, which no daemon verb can adopt.
323
+ export const ENGRAM_DAEMON_LIFECYCLE_MIN_VERSION = "3.7.0";
324
+ export function engramSupportsDaemonLifecycle(version: string | undefined): boolean {
325
+ return compareVersion(version, ENGRAM_DAEMON_LIFECYCLE_MIN_VERSION) === "same-or-newer";
326
+ }
327
+
328
+ // The command line Shell starts the shared server with: daemon-lifecycle cores
329
+ // register with `run -d` so the standard verbs manage the server; older cores
330
+ // spawn only the legacy detached `serve`.
331
+ export function engramSpawnArgs(version: string | undefined): string[] {
332
+ return engramSupportsDaemonLifecycle(version) ? ["run", "-d"] : ["serve"];
299
333
  }
300
334
  // The default endpoint gentle-engram uses without ENGRAM_URL or ENGRAM_PORT.
301
335
  export const ENGRAM_DEFAULT_PORT = 7437;
@@ -410,14 +444,71 @@ export function parseEngramProvenance(text: string | undefined): EngramProvenanc
410
444
  }
411
445
 
412
446
  // The bundled core's own schema (SQLite user_version), verified from the
413
- // tagged sources v3.3.2, v3.4.0 and v3.5.2: internal/store/store.go `const schemaVersion = 1`.
414
- // A pin without a verified entry leaves the header check unavailable.
415
- const BUNDLED_ENGRAM_SCHEMA: Record<string, number> = { "3.3.2": 1, "3.4.0": 1, "3.5.2": 1 };
447
+ // tagged sources v3.3.2, v3.4.0, v3.5.2 and the v3.7.0 and v3.7.2 trees:
448
+ // internal/store/store.go `const schemaVersion = 1`, and the released 3.7.2
449
+ // linux/darwin binaries stamp user_version 1 in an isolated store. A pin
450
+ // without a verified entry leaves the header check unavailable.
451
+ const BUNDLED_ENGRAM_SCHEMA: Record<string, number> = { "3.3.2": 1, "3.4.0": 1, "3.5.2": 1, "3.7.0": 1, "3.7.2": 1 };
416
452
 
417
453
  export function bundledEngramSchema(coreVersion: string): number | undefined {
418
454
  return Object.hasOwn(BUNDLED_ENGRAM_SCHEMA, coreVersion) ? BUNDLED_ENGRAM_SCHEMA[coreVersion] : undefined;
419
455
  }
420
456
 
457
+ // Companion-vs-core contract gate (gentle-shell#3015): the runtime-contract
458
+ // digest each pinned core answers on GET /runtime-contract, read from the real
459
+ // release binaries during development; the 3.5.2 windows archive sha256 matched
460
+ // the retired 3.5.2 pin exactly. gentle-engram 0.8.0 requires the 3.7.2 digest:
461
+ // the released 3.7.2 binary and the published 0.8.0 companion both report
462
+ // contract_id engram.pi-http-runtime/v1, revision 1, with the same digest, and
463
+ // only that digest differs from 3.5.2. A pin without a verified entry leaves
464
+ // the gate unavailable, and the gate only ever warns (S3: "Instalar y avisar
465
+ // fuerte"), never blocks.
466
+ const BUNDLED_ENGRAM_CONTRACT: Record<string, string> = {
467
+ "3.5.2": "4bf32703e111162b24073d090bec1c15c9120708587000bf595a07264e768672",
468
+ "3.7.0": "0af9af176928e98562ab1396d3196efe582dd5d1c5d2c5f8f546ab4ed609810f",
469
+ "3.7.2": "0af9af176928e98562ab1396d3196efe582dd5d1c5d2c5f8f546ab4ed609810f",
470
+ };
471
+
472
+ export function bundledEngramContract(coreVersion: string): string | undefined {
473
+ return Object.hasOwn(BUNDLED_ENGRAM_CONTRACT, coreVersion) ? BUNDLED_ENGRAM_CONTRACT[coreVersion] : undefined;
474
+ }
475
+
476
+ // The runtime contract a gentle-engram companion ships (runtime-contract.json)
477
+ // and the running core answers on GET /runtime-contract. Only the exact
478
+ // contract id, an integer revision and a lowercase 64-hex digest count as
479
+ // evidence; anything else is no signal, never an error.
480
+ export type ParsedEngramRuntimeContract = { contract_id: "engram.pi-http-runtime/v1"; revision: number; digest: string };
481
+
482
+ export function parseEngramRuntimeContract(payload: unknown): ParsedEngramRuntimeContract | undefined {
483
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) return undefined;
484
+ const record = payload as Record<string, unknown>;
485
+ const revision = record.revision;
486
+ if (record.contract_id !== "engram.pi-http-runtime/v1" || typeof revision !== "number" || !Number.isInteger(revision)) return undefined;
487
+ if (typeof record.digest !== "string" || !/^[0-9a-f]{64}$/.test(record.digest)) return undefined;
488
+ return { contract_id: "engram.pi-http-runtime/v1", revision, digest: record.digest };
489
+ }
490
+
491
+ // The loud, warn-only mismatch notice (S3): Shell still installs and runs the
492
+ // pair, and the human decides whether to update the core or the companion.
493
+ // Silent when the digests are equal or either side is unknown — never a false
494
+ // alarm. `coreDigest` lets the launch path pass the digest the running server
495
+ // actually answered; the default is the pinned core's verified table entry.
496
+ // `coreLabel` names whoever answered, so a reused older server is never
497
+ // misattributed to the pinned version.
498
+ export function engramContractMismatchNotice(companionDigest: string | undefined, coreVersion: string, coreDigest: string | undefined = bundledEngramContract(coreVersion), coreLabel: string = `the Engram core ${coreVersion}`): string | undefined {
499
+ if (companionDigest === undefined || coreDigest === undefined || !/^[0-9a-f]{64}$/.test(companionDigest) || companionDigest === coreDigest) return undefined;
500
+ return `Engram contract mismatch: the gentle-engram companion declares runtime-contract digest ${companionDigest}, while ${coreLabel} answers ${coreDigest}; memory may be unavailable until the pair matches. Update the core with a new Gentle Shell release, or update the companion.`;
501
+ }
502
+
503
+ // One bounded read-only GET /runtime-contract on the shared server (the same
504
+ // loopback rules as probeEngramEndpoint): the parsed digest, or undefined when
505
+ // the server does not answer with a well-formed contract.
506
+ export async function probeEngramRuntimeContract(input: { port?: number; timeoutMs?: number } = {}): Promise<string | undefined> {
507
+ const answer = await localGet(input.port ?? ENGRAM_DEFAULT_PORT, "/runtime-contract", input.timeoutMs ?? 1000);
508
+ if (answer.kind !== "response" || answer.status !== 200) return undefined;
509
+ return parseEngramRuntimeContract(parseJson(answer.body))?.digest;
510
+ }
511
+
421
512
  // SQLite's user_version from the raw database header (bytes 60-63), or
422
513
  // undefined for anything that is not a well-formed rollback or WAL database.
423
514
  export function sqliteHeaderUserVersion(header: Uint8Array, size: number): number | undefined {
@@ -613,29 +704,16 @@ export function bundledUpdatePlan(passthrough: string[]): BundledUpdatePlan {
613
704
  return { self: true, ...marked };
614
705
  }
615
706
 
616
- // What `gentle-shell update` does after the redirected upgrade or the
617
- // `--latest` Pi update (`upgradeCode` is undefined when it did not run): with
618
- // nothing left for Pi it exits with that code; otherwise Pi still runs, so
619
- // `update --all` updates the extensions even when that step could not complete.
707
+ // Forward extension updates even when the latest Pi update failed; the caller
708
+ // retains that failure code while Pi handles the remaining arguments.
620
709
  export function bundledUpdateNext(plan: BundledUpdatePlan, upgradeCode: number | undefined): { exitCode: number } | { piArgs: string[]; note?: string } {
621
710
  if (plan.piArgs === undefined) return { exitCode: upgradeCode ?? 0 };
622
711
  if (plan.self && upgradeCode !== undefined && upgradeCode !== 0) {
623
- const step = plan.latest ? "latest Pi update" : "Gentle Shell upgrade";
624
- return { piArgs: plan.piArgs, note: `gentle-shell: the ${step} did not complete; updating the extensions anyway.` };
712
+ return { piArgs: plan.piArgs, note: "gentle-shell: the latest Pi update did not complete; updating the extensions anyway." };
625
713
  }
626
714
  return { piArgs: plan.piArgs };
627
715
  }
628
716
 
629
- export function bundledUpdateNotice(input: { piVersion: string; interactive: boolean }): string[] {
630
- return [
631
- `Pi ships pinned with Gentle Shell (Pi ${input.piVersion}): a newer Pi arrives with a Gentle Shell release.`,
632
- input.interactive
633
- ? "Running 'gentle-shell upgrade'..."
634
- : "Run 'gentle-shell upgrade' to install the latest Gentle Shell release and its Pi.",
635
- "Run 'gentle-shell update --latest' to install the newest published Pi now, without the release's verified lockfile.",
636
- ];
637
- }
638
-
639
717
  export type BundledUpgradeAction = { action: "upgrade" } | { action: "rollback" } | { error: string; usage: boolean };
640
718
 
641
719
  export const BUNDLED_UPGRADE_USAGE = "usage: gentle-shell upgrade [--channel release] | gentle-shell upgrade --rollback";
@@ -222,6 +222,32 @@ export function userPiHome(env: Record<string, string | undefined>, homedir: str
222
222
  return env[USER_PI_HOME_ENV] || linkDir(env, homedir);
223
223
  }
224
224
 
225
+ // Nobody can see or type into an editor git opens from Pi's bash tool, so
226
+ // `git rebase --continue` or a bare `git commit` would wait on it forever.
227
+ // `true` makes git keep the prepared message (or abort an empty one) instead.
228
+ // A value the user already set is kept; on Windows env names ignore case, so a
229
+ // user's `git_editor` counts too.
230
+ export const NON_INTERACTIVE_GIT_ENV = { GIT_EDITOR: "true", GIT_SEQUENCE_EDITOR: "true" } as const;
231
+
232
+ export function nonInteractiveGitEnv(env: Record<string, string | undefined>, platform: string = process.platform): Record<string, string> {
233
+ const isSet = (key: string) => platform === "win32"
234
+ ? Object.entries(env).some(([name, value]) => value !== undefined && name.toUpperCase() === key)
235
+ : env[key] !== undefined;
236
+ return Object.fromEntries(Object.entries(NON_INTERACTIVE_GIT_ENV).filter(([key]) => !isSet(key)));
237
+ }
238
+
239
+ // On Windows, Node keeps only the first of a set of case variants (in sorted
240
+ // order) and then skips it if it is undefined, so `{ GIT_EDITOR: undefined,
241
+ // git_editor: "vim" }` would reach the child with neither. Drop the undefined
242
+ // variants so the defined one is what gets spawned.
243
+ export function dropUndefinedCaseVariants(env: Record<string, string | undefined>, platform: string = process.platform): void {
244
+ if (platform !== "win32") return;
245
+ const defined = new Set(Object.entries(env).filter(([, value]) => value !== undefined).map(([name]) => name.toUpperCase()));
246
+ for (const [name, value] of Object.entries(env)) {
247
+ if (value === undefined && defined.has(name.toUpperCase())) delete env[name];
248
+ }
249
+ }
250
+
225
251
  export function isolatedDir(env: Record<string, string | undefined>, homedir: string): string {
226
252
  return env.GENTLE_SHELL_HOME || join(homedir, ".gentle-shell", "agent");
227
253
  }
@@ -454,11 +480,16 @@ export interface PiRuntime {
454
480
  kind: PiRuntimeKind;
455
481
  command: string;
456
482
  args: string[];
483
+ // Only ever set for kind "bundled": the adjacent peer's and the
484
+ // gentle-shell-managed install's version both come from a package.json
485
+ // already read into memory, so main() can run checkPiVersion(runtime.version)
486
+ // without spawning a process just to print it back (#2096).
487
+ version?: string;
457
488
  }
458
489
 
459
490
  export interface PiRuntimeDeps {
460
491
  env: Record<string, string | undefined>;
461
- resolveBundledCli: () => string | undefined;
492
+ resolveBundledCli: () => { path: string; version: string } | undefined;
462
493
  findOnPath: (name: string) => string | undefined;
463
494
  nodeExecPath: string;
464
495
  }
@@ -467,8 +498,8 @@ export function resolvePiRuntime(deps: PiRuntimeDeps): PiRuntime | undefined {
467
498
  const envOverride = deps.env.GENTLE_SHELL_PI;
468
499
  if (envOverride !== undefined && envOverride.length > 0) return { kind: "env", command: envOverride, args: [] };
469
500
 
470
- const bundledCliPath = deps.resolveBundledCli();
471
- if (bundledCliPath !== undefined) return { kind: "bundled", command: deps.nodeExecPath, args: [bundledCliPath] };
501
+ const bundledCli = deps.resolveBundledCli();
502
+ if (bundledCli !== undefined) return { kind: "bundled", command: deps.nodeExecPath, args: [bundledCli.path], version: bundledCli.version };
472
503
 
473
504
  const onPath = deps.findOnPath("pi");
474
505
  if (onPath !== undefined) return { kind: "path", command: onPath, args: [] };
@@ -988,6 +1019,8 @@ export interface BuildPiInvocationInput {
988
1019
  // gentle-pi extension injection below may precede it.
989
1020
  piSubcommand?: PiSubcommand;
990
1021
  baseEnv: Record<string, string | undefined>;
1022
+ // Defaults to process.platform; decides whether env names ignore case.
1023
+ platform?: string;
991
1024
  // A bundled launch: its gentle-pi keeps its config in the prefix, so Pi gets
992
1025
  // no standalone config marker (standaloneConfigHome).
993
1026
  bundled?: boolean;
@@ -1085,6 +1118,7 @@ export function buildPiInvocation(input: BuildPiInvocationInput): PiInvocation {
1085
1118
 
1086
1119
  const env: Record<string, string | undefined> = {
1087
1120
  ...input.baseEnv,
1121
+ ...nonInteractiveGitEnv(input.baseEnv, input.platform),
1088
1122
  PI_CODING_AGENT_DIR: input.home.dir,
1089
1123
  PI_PROGRAM_STATUS_APP: "gentle-shell",
1090
1124
  GENTLE_PI_AGENT_HOME: input.home.dir,
@@ -1098,6 +1132,7 @@ export function buildPiInvocation(input: BuildPiInvocationInput): PiInvocation {
1098
1132
  else env[GENTLE_SHELL_CONFIG_HOME_ENV] = configHome;
1099
1133
  if (childInjection === undefined) delete env[CHILD_PACKAGE_INJECTION_ENV];
1100
1134
  else env[CHILD_PACKAGE_INJECTION_ENV] = encodeChildPackageInjection(childInjection);
1135
+ dropUndefinedCaseVariants(env, input.platform);
1101
1136
 
1102
1137
  return { command: input.runtime.command, args, env };
1103
1138
  }
@@ -1352,11 +1387,11 @@ export function helpText(): string {
1352
1387
  " gentle-shell install npm:<pkg> Run pi's own 'install' against the resolved home.",
1353
1388
  " gentle-shell remove <source> Run pi's own 'remove' against the resolved home.",
1354
1389
  " gentle-shell list Run pi's own 'list' against the resolved home.",
1355
- " gentle-shell update [target] Run pi's own 'update' against the resolved home.",
1356
- " In a bundled install Pi ships pinned: 'update' without a package",
1357
- " runs 'gentle-shell upgrade' instead of updating Pi.",
1358
- " 'update --latest' installs the newest published Pi instead,",
1359
- " without the release's verified lockfile.",
1390
+ " gentle-shell update [target] Update Pi through its supported owner, or packages in the resolved home.",
1391
+ " In a bundled install 'update' installs the newest stable Pi",
1392
+ " without the release's verified lockfile; --latest is an alias.",
1393
+ " --all also updates extensions; explicit package pins remain pinned.",
1394
+ " --force is not supported for managed Pi self updates.",
1360
1395
  " gentle-shell config Run pi's own 'config' against the resolved home.",
1361
1396
  " gentle-shell auth <command> Run pi's own 'auth' against the resolved home.",
1362
1397
  " gentle-shell mcp <command> Run pi's own 'mcp' (add, list, login, logout) against the",
@@ -66,8 +66,7 @@ function fit(parts: string[], columns: number, bytes: number, characters: number
66
66
  return count;
67
67
  }
68
68
 
69
- /** Only the active Todo title is free text. LF is private framing, not a token. */
70
- export function activitySummary(tasks: unknown, columns = FALLBACK_COLUMNS): string | null {
69
+ function activeTodo(tasks: unknown): { parts: string[]; clipped: boolean } | null {
71
70
  if (!Array.isArray(tasks)) return null;
72
71
  const title: unknown = tasks.find((task) => task?.status === "in_progress")?.title;
73
72
  if (typeof title !== "string") return null;
@@ -82,6 +81,19 @@ export function activitySummary(tasks: unknown, columns = FALLBACK_COLUMNS): str
82
81
  const parts = Array.from(graphemes.segment(clean), ({ segment }) => segment);
83
82
  // The bounded sample may end inside a grapheme; never publish that fragment.
84
83
  if (clipped) parts.pop();
84
+ return { parts, clipped };
85
+ }
86
+
87
+ /** Sanitized active title, without Herdr icons, rows or ellipsis layout. */
88
+ export function activeTodoTitle(tasks: unknown): string | null {
89
+ return activeTodo(tasks)?.parts.join("") || null;
90
+ }
91
+
92
+ /** Only the active Todo title is free text. LF is private framing, not a token. */
93
+ export function activitySummary(tasks: unknown, columns = FALLBACK_COLUMNS): string | null {
94
+ const active = activeTodo(tasks);
95
+ if (!active) return null;
96
+ const { parts, clipped } = active;
85
97
  columns = Number.isFinite(columns) ? Math.max(1, Math.min(512, Math.floor(columns))) : FALLBACK_COLUMNS;
86
98
  if (columns <= 2) return columns === 1 ? "…" : "◐…";
87
99
  // Herdr caps each token at 80 scalars; count our icon/indent before its trim.
@@ -0,0 +1,45 @@
1
+ import { FINISHED_STATUSES } from "./agents-protocol.ts";
2
+
3
+ // gentle-shell#626: the herdr pane must stay busy while owned background
4
+ // subagents run, even after the parent itself settles. This module is the
5
+ // pure, edge-triggered projection the extension feeds on every summary
6
+ // notification; it mirrors pi-subagents' herdr producer exactly: raise once,
7
+ // dedup an unchanged label, relabel as lower-then-raise in one synchronous
8
+ // step, lower once. Labels are content-free and derived from counts only.
9
+
10
+ export const HERDR_BUSY_CHANNEL = "herdr:busy";
11
+
12
+ /** What the extension last emitted on the channel, or nothing yet. */
13
+ export type HerdrBusyEmitted = { active: true; label: string } | { active: false } | undefined;
14
+
15
+ export type HerdrBusyAction =
16
+ | { kind: "none" }
17
+ | { kind: "raise"; label: string }
18
+ | { kind: "lower-then-raise"; label: string }
19
+ | { kind: "lower" };
20
+
21
+ const finishedStatuses: ReadonlySet<string> = new Set<string>(FINISHED_STATUSES);
22
+
23
+ export function herdrBusyLabel(count: number): string {
24
+ return count === 1 ? "1 subagent running" : `${count} subagents running`;
25
+ }
26
+
27
+ // Fails closed: malformed task input is a no-op, and a malformed previously
28
+ // emitted state is simply "not busy". Never throws.
29
+ export function nextHerdrBusyAction(tasks: unknown, emitted: unknown): HerdrBusyAction {
30
+ if (!Array.isArray(tasks)) return { kind: "none" };
31
+ let running = 0;
32
+ for (const task of tasks) {
33
+ if (task === null || typeof task !== "object" || typeof (task as { status?: unknown }).status !== "string") return { kind: "none" };
34
+ if (!finishedStatuses.has((task as { status: string }).status)) running += 1;
35
+ }
36
+ const emittedLabel = typeof emitted === "object" && emitted !== null
37
+ && (emitted as { active?: unknown }).active === true
38
+ && typeof (emitted as { label?: unknown }).label === "string"
39
+ ? (emitted as { label: string }).label
40
+ : undefined;
41
+ if (running === 0) return emittedLabel === undefined ? { kind: "none" } : { kind: "lower" };
42
+ const label = herdrBusyLabel(running);
43
+ if (label === emittedLabel) return { kind: "none" };
44
+ return emittedLabel === undefined ? { kind: "raise", label } : { kind: "lower-then-raise", label };
45
+ }
@@ -0,0 +1,35 @@
1
+ import type { ToolLoadout, ToolLoadoutChanges } from "@earendil-works/pi-coding-agent";
2
+
3
+ // Rarely used or state-bound tools leave the per-turn declarations only while
4
+ // a route the model is told about still reaches them. The route is codemode:
5
+ // a hidden declaration stays registered and active (Pi's prepareLoadout
6
+ // `hiddenDeclarations`, the projection the RDD-off review loadout uses), so a
7
+ // script calls it as `tools.<name>(args)`. Without codemode in the loadout the
8
+ // tool stays a direct declaration. The decision depends only on the loadout and
9
+ // session state, so two requests of one session carry the same tool list until
10
+ // that state changes.
11
+
12
+ export const CODEMODE_TOOL_NAME = "codemode";
13
+
14
+ /** Whether codemode is among the given tool names, the route that reaches hidden declarations. */
15
+ export function codemodeReaches(names: readonly unknown[] | undefined): boolean {
16
+ return Array.isArray(names) && names.includes(CODEMODE_TOOL_NAME);
17
+ }
18
+
19
+ /**
20
+ * A prepareLoadout hook that hides `name`'s declaration while codemode is
21
+ * declared beside it and `when()` holds. The tool stays active and callable.
22
+ */
23
+ export function hideBehindCodemode(name: string, when: () => boolean = () => true): (loadout: ToolLoadout) => ToolLoadoutChanges | undefined {
24
+ return (loadout) => {
25
+ const declared = loadout.declared.map((tool) => tool.name);
26
+ return codemodeReaches(declared) && declared.includes(name) && when() ? { hiddenDeclarations: [name] } : undefined;
27
+ };
28
+ }
29
+
30
+ /** Appended to the system prompt while the coordination tools are hidden. */
31
+ export const COORDINATION_TOOLS_ROUTE = "Cross-session tools orchestrator_list, orchestrator_consult and orchestrator_send_message are not declared: call them from codemode as `tools.<name>(args)`; `describeTool(name)` shows their arguments.";
32
+ /** Appended while the design tools are hidden: no design/ directory when this run started. */
33
+ export const DESIGN_TOOLS_ROUTE = "gentle_design and gentle_design_comments are not declared in this run: call them from codemode, such as `tools.gentle_design({ action: \"list\" })`.";
34
+ /** Appended while the guide tool is hidden. */
35
+ export const GUIDE_TOOL_ROUTE = "gentle_guide is not declared: call it from codemode as `tools.gentle_guide({ action: \"start\" })`.";
@@ -1,6 +1,7 @@
1
1
  import type { ImageContent } from "@earendil-works/pi-ai";
2
2
  import { getImageDimensions, type ImageDimensions } from "@earendil-works/pi-tui";
3
3
  import type { ClipboardImage } from "./clipboard-image.ts";
4
+ import type { ImageDiskCache } from "./image-disk-cache.ts";
4
5
 
5
6
  // Pasted images live in the draft as atomic `[Image#N]` chips (gentle-shell#2464).
6
7
  // The bytes stay in memory: a chip deleted from the draft is never sent, and
@@ -20,6 +21,8 @@ export interface ImageAttachment {
20
21
  byteLength: number;
21
22
  base64: string;
22
23
  dimensions?: ImageDimensions;
24
+ /** Present only when a disk cache was supplied; never injected into the prompt. */
25
+ diskPath?: string;
23
26
  }
24
27
 
25
28
  export interface SubmittedImages {
@@ -42,6 +45,35 @@ export class ImageAttachments {
42
45
  // Never reset: Pi's prompt history keeps the raw submitted text, so a
43
46
  // reused id would let a recalled `[Image#1]` bind to a different image.
44
47
  private counter = 0;
48
+ private cache?: ImageDiskCache;
49
+
50
+ /** Attach or drop the disk cache at runtime (session start and shutdown). */
51
+ setCache(cache?: ImageDiskCache): void {
52
+ this.cache = cache;
53
+ }
54
+
55
+ /** Cached files for the chips still in the draft; empty when no cache is active. */
56
+ cachedPaths(draftText?: string): Array<{ token: string; path: string }> {
57
+ const inDraft = draftText === undefined ? undefined : new Set(this.referenced(draftText).map((entry) => entry.id));
58
+ return [...this.entries.values()].flatMap((entry) =>
59
+ entry.diskPath && (inDraft === undefined || inDraft.has(entry.id)) ? [{ token: entry.token, path: entry.diskPath }] : [],
60
+ );
61
+ }
62
+
63
+ /**
64
+ * An optional disk cache. Without one the class behaves exactly as before:
65
+ * bytes stay in memory and no path exists. With one, each added image also
66
+ * gets a private file the agent's tools can read; the path never enters the
67
+ * prompt, the base64 payload stays the source of truth for submission.
68
+ */
69
+ constructor(cache?: ImageDiskCache) {
70
+ this.cache = cache;
71
+ }
72
+
73
+ /** Drop the session's cached files. Safe to call when no cache was given. */
74
+ dispose(): void {
75
+ this.cache?.dispose();
76
+ }
45
77
 
46
78
  get size(): number { return this.entries.size; }
47
79
 
@@ -57,6 +89,7 @@ export class ImageAttachments {
57
89
  byteLength: image.bytes.length,
58
90
  base64,
59
91
  dimensions: getImageDimensions(base64, image.mimeType) ?? undefined,
92
+ diskPath: this.cache?.write(id, image.bytes, image.mimeType),
60
93
  };
61
94
  this.entries.set(id, attachment);
62
95
  return attachment;
@@ -0,0 +1,137 @@
1
+ import { mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { isAbsolute, basename, join } from "node:path";
4
+
5
+ // Pasted images normally live only in memory (see lib/image-attachments.ts).
6
+ // This module is the opt-in disk cache: it gives tools that need a filesystem
7
+ // path somewhere to look, without ever putting a path in the prompt.
8
+ //
9
+ // Privacy contract:
10
+ // - the directory is per session and private (0700), every file is 0600;
11
+ // - the whole session directory is removed on shutdown;
12
+ // - a startup sweep removes session directories left behind by a crash.
13
+ // Nothing here is on by default: the caller decides whether to build a cache.
14
+
15
+ const EXT_BY_MIME: Record<string, string> = {
16
+ "image/png": "png",
17
+ "image/jpeg": "jpg",
18
+ "image/webp": "webp",
19
+ "image/gif": "gif",
20
+ };
21
+
22
+ /** Files this cache owns. The sweep only ever touches directories holding them. */
23
+ const OWN_FILE = /^image-\d+\.(png|jpg|webp|gif)$/;
24
+
25
+ /** `${XDG_CACHE_HOME:-~/.cache}/gentle-shell/images`, where sessions are created. */
26
+ export function defaultCacheRoot(env: NodeJS.ProcessEnv = process.env, home = homedir()): string {
27
+ const xdg = env.XDG_CACHE_HOME;
28
+ // XDG says a relative value must be ignored: a cache path that depends on the
29
+ // working directory cannot be handed to a tool as an absolute file path.
30
+ const base = xdg && xdg.trim() && isAbsolute(xdg) ? xdg : join(home, ".cache");
31
+ return join(base, "gentle-shell", "images");
32
+ }
33
+
34
+ /**
35
+ * Reduce a session id to one path segment. Taking the last segment first means
36
+ * a crafted id such as `../../etc` lands inside the root instead of above it.
37
+ */
38
+ function safeSegment(id: string): string {
39
+ const last = id.split(/[\\/]/).filter((part) => part.length > 0 && part !== "." && part !== "..").pop();
40
+ const cleaned = (last ?? "").replace(/[^A-Za-z0-9._-]/g, "_").replace(/^\.+/, "");
41
+ return cleaned.length > 0 ? cleaned : "session";
42
+ }
43
+
44
+ export interface ImageDiskCacheOptions {
45
+ root?: string;
46
+ sessionId: string;
47
+ }
48
+
49
+ export class ImageDiskCache {
50
+ readonly directory: string;
51
+
52
+ constructor(options: ImageDiskCacheOptions) {
53
+ const root = options.root ?? defaultCacheRoot();
54
+ this.directory = join(root, safeSegment(options.sessionId));
55
+ try {
56
+ mkdirSync(this.directory, { recursive: true, mode: 0o700 });
57
+ } catch {
58
+ // A cache that cannot be created is a cache that does nothing.
59
+ }
60
+ }
61
+
62
+ /** Write one image, returning its path, or undefined when the disk refuses. */
63
+ write(id: number, bytes: Uint8Array, mimeType: string): string | undefined {
64
+ const extension = EXT_BY_MIME[mimeType];
65
+ if (!extension) return undefined;
66
+ try {
67
+ const path = join(this.directory, `image-${id}.${extension}`);
68
+ writeFileSync(path, bytes, { mode: 0o600 });
69
+ return path;
70
+ } catch {
71
+ return undefined;
72
+ }
73
+ }
74
+
75
+ /** Remove this session's directory; other sessions are never touched. */
76
+ dispose(): void {
77
+ try {
78
+ rmSync(this.directory, { recursive: true, force: true });
79
+ } catch {
80
+ // Nothing to do: the next sweep will try again.
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Remove session directories whose own files are all older than `maxAgeMs`.
86
+ * Directories without this cache's files are left alone, so a wrong root
87
+ * cannot delete somebody else's data. Returns how many were removed.
88
+ */
89
+ static sweepStale(root: string, maxAgeMs: number, now = Date.now()): number {
90
+ let entries: string[];
91
+ try {
92
+ entries = readdirSync(root);
93
+ } catch {
94
+ return 0;
95
+ }
96
+
97
+ let removed = 0;
98
+ for (const entry of entries) {
99
+ const directory = join(root, entry);
100
+ let all: string[];
101
+ try {
102
+ if (!statSync(directory).isDirectory()) continue;
103
+ all = readdirSync(directory);
104
+ } catch {
105
+ continue;
106
+ }
107
+ const files = all.filter((file) => OWN_FILE.test(file));
108
+ if (files.length === 0) continue; // not ours
109
+ // A directory holding anything this cache did not write is somebody
110
+ // else's too, so the sweep leaves it alone.
111
+ if (files.length !== all.length) continue;
112
+
113
+ let newest = 0;
114
+ for (const file of files) {
115
+ try {
116
+ newest = Math.max(newest, statSync(join(directory, file)).mtimeMs);
117
+ } catch {
118
+ // a file that vanished cannot keep the directory alive
119
+ }
120
+ }
121
+ if (now - newest <= maxAgeMs) continue;
122
+
123
+ try {
124
+ rmSync(directory, { recursive: true, force: true });
125
+ removed += 1;
126
+ } catch {
127
+ // leave it for the next sweep
128
+ }
129
+ }
130
+ return removed;
131
+ }
132
+ }
133
+
134
+ /** `image-<id>.<ext>`, exported for callers that need to recognise a cached file. */
135
+ export function isCachedImageFile(name: string): boolean {
136
+ return OWN_FILE.test(basename(name));
137
+ }