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
@@ -26,9 +26,9 @@ import {
26
26
  writeFileSync,
27
27
  } from "node:fs";
28
28
  import { constants as osConstants, homedir, tmpdir } from "node:os";
29
- import { delimiter, dirname, join, resolve as resolvePath } from "node:path";
29
+ import { delimiter, dirname, isAbsolute, join, relative, resolve as resolvePath } from "node:path";
30
30
  import { spawn, spawnSync } from "node:child_process";
31
- import { fileURLToPath } from "node:url";
31
+ import { fileURLToPath, pathToFileURL } from "node:url";
32
32
  import {
33
33
  buildPiInvocation,
34
34
  checkPiVersion,
@@ -62,6 +62,7 @@ import {
62
62
  shellQuote,
63
63
  standaloneConfigHome,
64
64
  userPiHome,
65
+ HERDR_REPORTER_ENV,
65
66
  } from "../runtime/gentle-shell-launcher.mjs";
66
67
  import { formatImportPiReport, importPi } from "../runtime/gentle-shell-import-pi.mjs";
67
68
  import {
@@ -82,7 +83,6 @@ import {
82
83
  bundledPi,
83
84
  bundledSetupEnv,
84
85
  bundledUpdateNext,
85
- bundledUpdateNotice,
86
86
  bundledUpdatePlan,
87
87
  nodeBundledFs,
88
88
  parseBundledUpgradeArgs,
@@ -137,14 +137,14 @@ function resolveBundledCli() {
137
137
  const expectedEntry = join(root, "dist", "index.js");
138
138
  const metadata = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
139
139
  if (entry !== expectedEntry || metadata.name !== "@earendil-works/pi-coding-agent" ||
140
- metadata.bin?.pi !== "dist/bundle/cli.js") {
140
+ metadata.bin?.pi !== "dist/bundle/cli.js" || typeof metadata.version !== "string") {
141
141
  throw new Error("Unsupported adjacent Pi package entry/name/bin metadata");
142
142
  }
143
143
  const cliPath = join(root, metadata.bin.pi);
144
144
  if (realpathSync(cliPath) !== cliPath || !statSync(cliPath).isFile()) {
145
145
  throw new Error("Unsupported adjacent Pi CLI path");
146
146
  }
147
- return cliPath;
147
+ return { path: cliPath, version: metadata.version };
148
148
  }
149
149
 
150
150
  function findOnPath(name) {
@@ -262,9 +262,71 @@ async function startSharedEngram() {
262
262
  return failed;
263
263
  }
264
264
 
265
- // Use Pi's supported configuration-only install command, never an alternate
266
- // extension loader. Verify advertised enforcement before trusting the policy.
267
- async function ensureEngramCompanion(home, runtime, stdio, timeoutMs) {
265
+ const LEGACY_ENGRAM_COMPANION_SOURCE = "npm:gentle-engram@0.4.2";
266
+ const companionSource = (entry) => typeof entry === "string" ? entry : entry?.source;
267
+
268
+ function ownsCompanionHome(home, homeHadContentBeforeBootstrap) {
269
+ if (home.mode === "link") return false;
270
+ const previous = provisionedEntry(readRawConfig(resolveConfigPath()), safeRealpath(home.dir));
271
+ return !homeIsForeign(home, previous, homeHadContentBeforeBootstrap);
272
+ }
273
+
274
+ // The old launcher itself registered this exact pin. In a Shell-owned home,
275
+ // migrate only that legacy selection, using the selected Pi's own package
276
+ // manager to keep source identity, filters, ordering and settings locking. This
277
+ // changes configuration only: Pi's normal startup notice and explicit update
278
+ // command remain responsible for discovering and installing newer packages.
279
+ async function migrateManagedEngramCompanion(home, homeHadContentBeforeBootstrap) {
280
+ if (!ownsCompanionHome(home, homeHadContentBeforeBootstrap)) return { ok: true };
281
+ try {
282
+ const settingsPath = join(home.dir, "settings.json");
283
+ const packages = JSON.parse(readJsonIfExists(settingsPath) ?? "{}").packages ?? [];
284
+ if (!Array.isArray(packages)) return { ok: true };
285
+ const npmSources = packages.map(companionSource).filter((source) => typeof source === "string" && /^npm:gentle-engram(?:@|$)/.test(source));
286
+ if (npmSources.length !== 1 || npmSources[0] !== LEGACY_ENGRAM_COMPANION_SOURCE) return { ok: true };
287
+ // Do not take over an explicitly selected local companion, or infer
288
+ // ownership from a missing/unverified npm installation.
289
+ if (packages.some((entry) => {
290
+ const source = companionSource(entry);
291
+ return typeof source === "string" && !source.startsWith("npm:") && readPackageName(resolvePath(home.dir, source)) === "gentle-engram";
292
+ })) return { ok: true };
293
+ const metadata = join(home.dir, "npm", "node_modules", "gentle-engram", "package.json");
294
+ const metadataText = readJsonIfExists(metadata);
295
+ if (!supportsEngramStartupPolicy(metadataText) || JSON.parse(metadataText).version !== "0.4.2") throw new Error("the legacy companion installation could not be verified");
296
+ const piRoot = dirname(dirname(dirname(bundledCli)));
297
+ const main = JSON.parse(readJsonIfExists(join(piRoot, "package.json")) ?? "{}").main;
298
+ if (typeof main !== "string" || !main) throw new Error("the selected Pi does not expose its package manager");
299
+ const sdkPath = resolvePath(piRoot, main);
300
+ const sdkRelative = relative(piRoot, sdkPath);
301
+ if (!sdkRelative || sdkRelative === ".." || sdkRelative.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute(sdkRelative)) throw new Error("the selected Pi package manager is outside its package");
302
+ const { DefaultPackageManager, SettingsManager } = await import(pathToFileURL(sdkPath).href);
303
+ const settings = SettingsManager.create(process.cwd(), home.dir, { projectTrusted: false });
304
+ const loadErrors = settings.drainErrors();
305
+ if (loadErrors.length) throw loadErrors[0].error;
306
+ const selected = settings.getGlobalSettings().packages ?? [];
307
+ const currentNpmSources = selected.map(companionSource).filter((source) => typeof source === "string" && /^npm:gentle-engram(?:@|$)/.test(source));
308
+ const localSelected = selected.some((entry) => {
309
+ const source = companionSource(entry);
310
+ return typeof source === "string" && !source.startsWith("npm:") && readPackageName(resolvePath(home.dir, source)) === "gentle-engram";
311
+ });
312
+ if (localSelected || currentNpmSources.length !== 1 || currentNpmSources[0] !== LEGACY_ENGRAM_COMPANION_SOURCE) throw new Error("companion selection changed");
313
+ const manager = new DefaultPackageManager({ cwd: process.cwd(), agentDir: home.dir, settingsManager: settings });
314
+ manager.addSourceToSettings(ENGRAM_COMPANION_SOURCE);
315
+ await settings.flush();
316
+ const errors = settings.drainErrors();
317
+ if (errors.length) throw errors[0].error;
318
+ const persisted = JSON.parse(readJsonIfExists(settingsPath) ?? "{}").packages;
319
+ if (!Array.isArray(persisted) || !persisted.some((entry) => companionSource(entry) === ENGRAM_COMPANION_SOURCE)) throw new Error("companion selection was not saved");
320
+ return { ok: true };
321
+ } catch (error) {
322
+ return { ok: false, exitCode: 1, message: `gentle-shell: could not prepare the managed gentle-engram package for updates (${error.message}); review its selection before retrying` };
323
+ }
324
+ }
325
+
326
+ // Use Pi's install command, never an alternate extension loader. A user's
327
+ // selected companion stays selected; missing or unverified capability is only
328
+ // warned about, while the guard continues to protect unverified stores.
329
+ async function ensureEngramCompanion(home, runtime, stdio, timeoutMs, homeHadContentBeforeBootstrap) {
268
330
  const metadata = join(home.dir, "npm", "node_modules", "gentle-engram", "package.json");
269
331
  let packages;
270
332
  try {
@@ -273,15 +335,12 @@ async function ensureEngramCompanion(home, runtime, stdio, timeoutMs) {
273
335
  return { ok: false, exitCode: 1, message: "gentle-shell: cannot verify Engram startupPolicy from malformed settings; repair settings and recheck" };
274
336
  }
275
337
  if (!Array.isArray(packages)) return { ok: false, exitCode: 1, message: "gentle-shell: cannot verify Engram startupPolicy from non-array packages" };
276
- let pinned = false;
277
338
  let local = false;
278
- let npmSelected = false;
339
+ const npmSelections = [];
279
340
  for (const entry of packages) {
280
- const source = typeof entry === "string" ? entry : entry?.source;
281
- if (source === ENGRAM_COMPANION_SOURCE) pinned = true;
282
- if (typeof source === "string" && /^npm:gentle-engram(?:@|$)/.test(source)) npmSelected = true;
341
+ const source = companionSource(entry);
342
+ if (typeof source === "string" && /^npm:gentle-engram(?:@|$)/.test(source)) npmSelections.push(source);
283
343
  if (typeof source !== "string" || source.startsWith("npm:")) continue;
284
- // Preserve an explicit local companion selection rather than overwrite it.
285
344
  const selected = resolvePath(home.dir, source);
286
345
  if (readPackageName(selected) !== "gentle-engram") continue;
287
346
  if (!supportsEngramStartupPolicy(readJsonIfExists(join(selected, "package.json")))) {
@@ -289,14 +348,25 @@ async function ensureEngramCompanion(home, runtime, stdio, timeoutMs) {
289
348
  }
290
349
  local = true;
291
350
  }
292
- if (local && !npmSelected) return { ok: true };
293
- if (pinned && supportsEngramStartupPolicy(readJsonIfExists(metadata))) return { ok: true };
351
+ if (npmSelections.length) {
352
+ const metadataText = readJsonIfExists(metadata);
353
+ if (supportsEngramStartupPolicy(metadataText)) {
354
+ const installedVersion = JSON.parse(metadataText).version;
355
+ const mismatch = npmSelections.some((source) => {
356
+ const exact = /^npm:gentle-engram@v?((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)$/.exec(source);
357
+ return exact && exact[1] !== installedVersion;
358
+ });
359
+ if (!mismatch) return { ok: true };
360
+ return { ok: false, exitCode: 1, message: "gentle-shell: selected gentle-engram does not match its installed version; recheck its startupPolicy (selection preserved)" };
361
+ }
362
+ return { ok: false, exitCode: 1, message: "gentle-shell: selected gentle-engram lacks engram.startupPolicy=1; update it and recheck (selection preserved)" };
363
+ }
364
+ if (local || !ownsCompanionHome(home, homeHadContentBeforeBootstrap)) return { ok: true };
294
365
  process.stderr.write(`gentle-shell: installing policy-capable companion ${ENGRAM_COMPANION_SOURCE} through Pi\n`);
295
366
  const result = await spawnAndWait(runtime.command, [...runtime.args, "install", ENGRAM_COMPANION_SOURCE], buildSetupEnv(home, runtime), stdio, timeoutMs);
296
367
  let declared = false;
297
368
  try {
298
- declared = JSON.parse(readJsonIfExists(join(home.dir, "settings.json")) ?? "{}").packages?.some((entry) =>
299
- (typeof entry === "string" ? entry : entry?.source) === ENGRAM_COMPANION_SOURCE) === true;
369
+ declared = JSON.parse(readJsonIfExists(join(home.dir, "settings.json")) ?? "{}").packages?.some((entry) => companionSource(entry) === ENGRAM_COMPANION_SOURCE) === true;
300
370
  } catch { /* Missing or malformed readback cannot establish enforcement. */ }
301
371
  if (!result.ok || result.timedOut || !declared || !supportsEngramStartupPolicy(readJsonIfExists(metadata))) {
302
372
  return { ok: false, exitCode: 1, message: "gentle-shell: companion installation did not establish engram.startupPolicy=1; the Engram guard still keeps unverified stores closed. Repair gentle-engram, then restart Shell." };
@@ -317,6 +387,22 @@ function ownPackageVersion() {
317
387
  return packageJson.version;
318
388
  }
319
389
 
390
+ // The real spawn, only ever needed for a runtime with no in-memory version
391
+ // (env override, PATH pi): kind "bundled" always has runtime.version set and
392
+ // skips this entirely (#2096).
393
+ function probePiVersion(runtime) {
394
+ const versionProbePlan = planSpawn({ command: runtime.command, args: [...runtime.args, "--version"], platform: process.platform });
395
+ const versionProbe = spawnSync(versionProbePlan.command, versionProbePlan.args, {
396
+ stdio: ["ignore", "pipe", "pipe"],
397
+ timeout: 15000,
398
+ encoding: "utf8",
399
+ shell: versionProbePlan.shell,
400
+ env: bundledEnv ?? process.env,
401
+ });
402
+ if (versionProbe.error) fail(`Could not run the pi runtime at "${runtime.command}": ${versionProbe.error.message}`, 1);
403
+ return checkPiVersion(versionProbe.stdout ?? "");
404
+ }
405
+
320
406
  function emptyArgs() {
321
407
  return {
322
408
  link: false,
@@ -367,37 +453,28 @@ function isDirectory(path) {
367
453
  }
368
454
  }
369
455
 
370
- // Reuse Herdr's managed bridge, never its transport. This process-boundary
371
- // lookup is deliberately best-effort and does not modify either agent home.
372
- function managedHerdrExtensionArgs(home, args) {
373
- const env = process.env;
374
- if (home.mode !== "isolated" || args.piSubcommand !== undefined || args.passthrough[0] === "mcp") return [];
375
- if (env.HERDR_ENV !== "1" || !env.HERDR_SOCKET_PATH?.trim() || !env.HERDR_PANE_ID?.trim()) return [];
376
- if (env.GENTLE_PI_AGENTS_CHILD === "1" || !process.stdin.isTTY || !process.stdout.isTTY) return [];
377
- // Only automatic interactive loading: a user opt-out must not become an
378
- // explicit -e (which Pi loads even under --no-extensions). Conservatively
379
- // skip ambiguous mode flags too; --mode text alone still allows a TUI.
380
- const forwarded = args.passthrough;
381
- if (forwarded.some((arg) => ["--no-extensions", "-ne", "--print", "-p", "--export", "--list-models", "-v"].includes(arg))) return [];
382
- if (forwarded.some((arg, i) => (arg === "--mode" && forwarded[i + 1] !== "text") || arg.startsWith("--mode="))) return [];
456
+ const HERDR_BRIDGE_FILE = "herdr-agent-state.ts";
457
+
458
+ // Canonical file name check; an unreadable path is simply not a bridge.
459
+ function isHerdrBridge(path) {
383
460
  try {
384
- if (!statSync(env.HERDR_SOCKET_PATH).isSocket()) return [];
461
+ return basenameOf(realpathSync(path)) === HERDR_BRIDGE_FILE;
385
462
  } catch {
386
- return [];
463
+ return false;
387
464
  }
388
- // Prefer a bridge in the selected home over adding a competing copy; keep
389
- // the incoming Pi home override before falling back to Herdr's usual home.
390
- const agentHomes = [home.dir, env.PI_CODING_AGENT_DIR, join(homedir(), ".pi", "agent")];
391
- for (const agentHome of agentHomes) {
465
+ }
466
+
467
+ // First readable managed bridge among `homes`, as an explicit -e of its
468
+ // canonical path. Pi's package-manager.toResolvedPaths and
469
+ // resource-loader.mergePaths dedupe canonical files across discovery,
470
+ // explicit -e and manifests, so declaring it is harmless.
471
+ function managedBridgeArgs(homes) {
472
+ for (const agentHome of homes) {
392
473
  if (!agentHome) continue;
393
- const bridge = join(agentHome, "extensions", "herdr-agent-state.ts");
474
+ const bridge = join(agentHome, "extensions", HERDR_BRIDGE_FILE);
394
475
  try {
395
476
  if (!statSync(bridge).isFile()) continue;
396
477
  accessSync(bridge, fsConstants.R_OK);
397
- // Pi's package-manager.toResolvedPaths and resource-loader.mergePaths
398
- // dedupe canonical files across discovery, explicit -e and manifests.
399
- // Existence alone is NOT proof of loading: declare the resource and
400
- // let that resolver dedupe it, including explicit aliases from argv.
401
478
  return ["-e", realpathSync(bridge)];
402
479
  } catch {
403
480
  // An absent/unreadable bridge never prevents the ordinary launch.
@@ -406,6 +483,42 @@ function managedHerdrExtensionArgs(home, args) {
406
483
  return [];
407
484
  }
408
485
 
486
+ // Herdr agent identity for an interactive isolated launch (#2705). Herdr's
487
+ // managed Pi bridge reports every pane as `pi`, so when this launcher loads
488
+ // its own package (`loadsOwnPackage`) Gentle Shell no longer loads the bridge
489
+ // and enables its own reporter (extensions/gentle-herdr-agent.ts) through
490
+ // HERDR_REPORTER_ENV. Exactly one reporter owns the pane: a bridge in the
491
+ // selected home is discovered by Pi anyway, and a bridge the user passes
492
+ // explicitly is theirs, so Gentle Shell does not compete with either. A home
493
+ // that loads its own declared gentle-pi may predate the reporter, so it keeps
494
+ // the managed bridge. Best-effort, and it never modifies either agent home.
495
+ function herdrLaunchPlan(home, args, loadsOwnPackage) {
496
+ const none = { extensionArgs: [], reporter: false };
497
+ const env = process.env;
498
+ if (home.mode !== "isolated" || args.piSubcommand !== undefined || args.passthrough[0] === "mcp") return none;
499
+ if (env.HERDR_ENV !== "1" || !env.HERDR_SOCKET_PATH?.trim() || !env.HERDR_PANE_ID?.trim()) return none;
500
+ if (env.GENTLE_PI_AGENTS_CHILD === "1" || !process.stdin.isTTY || !process.stdout.isTTY) return none;
501
+ // Only automatic interactive loading: a user opt-out must not become an
502
+ // explicit -e (which Pi loads even under --no-extensions). Conservatively
503
+ // skip ambiguous mode flags too; --mode text alone still allows a TUI.
504
+ const forwarded = args.passthrough;
505
+ if (forwarded.some((arg) => ["--no-extensions", "-ne", "--print", "-p", "--export", "--list-models", "-v"].includes(arg))) return none;
506
+ if (forwarded.some((arg, i) => (arg === "--mode" && forwarded[i + 1] !== "text") || arg.startsWith("--mode="))) return none;
507
+ try {
508
+ if (!statSync(env.HERDR_SOCKET_PATH).isSocket()) return none;
509
+ } catch {
510
+ return none;
511
+ }
512
+ if (forwarded.some((arg, i) => (arg === "-e" || arg === "--extension") && isHerdrBridge(forwarded[i + 1] ?? ""))) return none;
513
+ if (!loadsOwnPackage) {
514
+ // Prefer the selected home, keep the incoming Pi home override, then
515
+ // fall back to Herdr's usual home.
516
+ return { extensionArgs: managedBridgeArgs([home.dir, env.PI_CODING_AGENT_DIR, join(homedir(), ".pi", "agent")]), reporter: false };
517
+ }
518
+ const selected = managedBridgeArgs([home.dir]);
519
+ return selected.length > 0 ? { extensionArgs: selected, reporter: false } : { extensionArgs: [], reporter: true };
520
+ }
521
+
409
522
  // Real-fs adapter for discoverLooseExtensionEntries (lib/gentle-shell-launcher.ts):
410
523
  // statSync-based isFile/isDirectory (not readdirSync's Dirent, which uses
411
524
  // lstat and so would treat a symlinked file or directory as neither) so a
@@ -1105,7 +1218,7 @@ function ensureBuiltinCodemodeExcluded(settingsPath) {
1105
1218
  // rpc`/`-p` consumers. `timeoutMs` is threaded into every child this flow
1106
1219
  // spawns (see spawnAndWait's own doc comment) — manual `setup` never passes
1107
1220
  // it, so it never times out; the automatic flow does (S9).
1108
- async function runSetupFlow(home, runtime, { dryRun, stdio, timeoutMs }) {
1221
+ async function runSetupFlow(home, runtime, { dryRun, stdio, timeoutMs, homeHadContentBeforeBootstrap }) {
1109
1222
  const pinnedVersion = resolveSetupGentleAiPin();
1110
1223
  if (!isSetupCapablePin(pinnedVersion)) {
1111
1224
  return {
@@ -1175,19 +1288,43 @@ async function runSetupFlow(home, runtime, { dryRun, stdio, timeoutMs }) {
1175
1288
  process.stderr.write(`gentle-shell: kept your Pi theme unchanged (gentle-ai rewrote ${settingsPath}; tracked upstream)\n`);
1176
1289
  }
1177
1290
  }
1178
- if (installResult.timedOut) {
1179
- return { ok: false, exitCode: 1, message: `gentle-shell: gentle-ai install timed out after ${formatTimeoutCeiling(timeoutMs)}` };
1180
- }
1181
1291
  if (installResult.error) {
1182
1292
  return { ok: false, exitCode: 1, message: `Could not start the gentle-ai binary: ${installResult.error.message}` };
1183
1293
  }
1184
- if (!installResult.ok) return installResult;
1294
+ if (!installResult.ok || installResult.timedOut) {
1295
+ // Run post-install cleanup even on failure or timeout so a failed setup
1296
+ // does not leave npm:gentle-pi declared in settings.json, which would make
1297
+ // subsequent launches silently run the published npm package instead of
1298
+ // the launcher's own package (#1647).
1299
+ if (!dryRun && !installResult.interrupted) {
1300
+ // A cleanup that throws (e.g. an unreadable settings.json) must not
1301
+ // replace the install's own failure; it only adds a diagnostic.
1302
+ let cleanupResult;
1303
+ try {
1304
+ cleanupResult = await runPostInstallCleanup(home, runtime, false, stdio, timeoutMs);
1305
+ } catch (error) {
1306
+ cleanupResult = { ok: false, exitCode: 1, message: `gentle-shell: post-install cleanup failed: ${error.message}` };
1307
+ }
1308
+ if (cleanupResult.interrupted) return cleanupResult;
1309
+ if (!cleanupResult.ok && cleanupResult.message !== undefined) {
1310
+ const baseMessage = installResult.timedOut
1311
+ ? `gentle-shell: gentle-ai install timed out after ${formatTimeoutCeiling(timeoutMs)}`
1312
+ : installResult.message;
1313
+ const message = baseMessage ? `${baseMessage}\n${cleanupResult.message}` : cleanupResult.message;
1314
+ return { ok: false, exitCode: installResult.exitCode, message };
1315
+ }
1316
+ }
1317
+ if (installResult.timedOut) {
1318
+ return { ok: false, exitCode: 1, message: `gentle-shell: gentle-ai install timed out after ${formatTimeoutCeiling(timeoutMs)}` };
1319
+ }
1320
+ return installResult;
1321
+ }
1185
1322
 
1186
1323
  const cleanupResult = await runPostInstallCleanup(home, runtime, dryRun, stdio, timeoutMs);
1187
1324
  if (cleanupResult.ok && !dryRun) {
1188
1325
  warnDisabledMCP(home);
1189
1326
  // The guard and policy protect memory, so the companion check only warns.
1190
- const companion = bundledInstall ? await ensureEngramCompanion(home, runtime, stdio, timeoutMs) : { ok: true };
1327
+ const companion = bundledInstall ? await ensureEngramCompanion(home, runtime, stdio, timeoutMs, homeHadContentBeforeBootstrap) : { ok: true };
1191
1328
  if (!companion.ok) process.stderr.write(`${companion.message}\n`);
1192
1329
  }
1193
1330
  return cleanupResult;
@@ -1333,7 +1470,7 @@ async function handleSetupCommand(commandArgs, home, runtime, { homeHadContentBe
1333
1470
  fail(`Unrecognized argument for 'gentle-shell setup': ${arg}\nRun 'gentle-shell --help' for usage.`, 2);
1334
1471
  }
1335
1472
 
1336
- const result = await runSetupFlow(home, runtime, { dryRun, stdio: "inherit" });
1473
+ const result = await runSetupFlow(home, runtime, { dryRun, stdio: "inherit", homeHadContentBeforeBootstrap });
1337
1474
  if (!result.ok && result.message !== undefined) process.stderr.write(`${result.message}\n`);
1338
1475
  if (result.ok && !dryRun && (home.mode === "isolated" || home.mode === "path")) {
1339
1476
  const configPath = resolveConfigPath();
@@ -1571,7 +1708,7 @@ async function maybeAutoProvisionHome(home, runtime, { homeHadContentBeforeBoots
1571
1708
  }
1572
1709
  }
1573
1710
 
1574
- const result = await runSetupFlow(home, runtime, { dryRun: false, stdio: ["ignore", 2, 2], timeoutMs: resolveAutoSetupTimeoutMs() });
1711
+ const result = await runSetupFlow(home, runtime, { dryRun: false, stdio: ["ignore", 2, 2], timeoutMs: resolveAutoSetupTimeoutMs(), homeHadContentBeforeBootstrap });
1575
1712
  // Abort the whole launch only for a launcher-forwarded interrupt
1576
1713
  // (R3-002); a child that exited via signal on its own (crash, OOM kill,
1577
1714
  // external kill) falls through to the ordinary-failure branch below,
@@ -1684,7 +1821,7 @@ async function handleBundledUpgrade(bundled, commandArgs) {
1684
1821
  }
1685
1822
  }
1686
1823
 
1687
- // `gentle-shell update --latest` in a bundled install: the newest published
1824
+ // `gentle-shell update` in a bundled install: the newest published
1688
1825
  // Pi installed with this Gentle Shell beside the active version, without the
1689
1826
  // release's verified lockfile (after a warning), verified, then `current`
1690
1827
  // switched. Returns the exit code like handleBundledUpgrade; a failure leaves
@@ -1865,7 +2002,7 @@ async function main() {
1865
2002
  const args = parseLauncherArgs(process.argv.slice(2));
1866
2003
  if (args.error !== undefined) fail(`${args.error}\nRun 'gentle-shell --help' for usage.`, 2);
1867
2004
  if (args.help) {
1868
- process.stdout.write("Pi updates: update reinstalls the verified supplier of the Pi this launcher runs (a global Pi, or the\nShell package whose adjacent peer it is, at the same Shell version) and reads the resulting Pi version back.\nUnknown ownership refuses without installing; update --extensions-only stays Pi-only.\nPrefix-bundled Pi updates with gentle-shell upgrade.\n");
2005
+ process.stdout.write("Pi updates: update reinstalls the verified supplier of the Pi this launcher runs (a global Pi, or the\nShell package whose adjacent peer it is, at the same Shell version) and reads the resulting Pi version back.\nA linked source Shell updates its local Pi with its project manager and one matching lockfile;\npnpm may be newer than the declared minimum; npm must match its pin. No manager is downloaded;\nGit roots only, no lifecycle scripts or range changes. Root-only pnpm configuration is preserved;\nmulti-project/ancestor workspaces and conflicting lockfiles refuse before installation. Unknown ownership refuses; update --extensions-only stays Pi-only.\nPrefix-bundled Pi updates with gentle-shell upgrade.\n");
1869
2006
  process.stdout.write(`${helpText()}\nBundled Engram memory: Shell shares the global Engram server on 127.0.0.1:7437, like other agents' hooks.\nA running server is reused only with verified /compatibility evidence; when nothing listens, Shell starts the\nbundled core's engram serve (default ~/.engram) and waits for that evidence. Otherwise ENGRAM_BIN is Shell's\nguard and memory stays off for that launch. Matching versions or updating alone do not prove compatibility.\nBack up existing data before manual changes; do not delete it or bypass the safety check.\nShell rechecks on every launch and remains usable without memory.\nAn explicit ENGRAM_BIN or ENGRAM_URL is kept and bypasses the guard.\n`);
1870
2007
  process.exit(0);
1871
2008
  }
@@ -1920,7 +2057,7 @@ async function main() {
1920
2057
  // S8: only the version's own Pi, never GENTLE_SHELL_PI, an adjacent fallback or PATH.
1921
2058
  const pi = bundledPi(bundled, { platform: process.platform, fs: bundledFs });
1922
2059
  if (!pi.ok) fail(pi.message, 1);
1923
- runtime = { kind: "bundled", command: process.execPath, args: [pi.cli] };
2060
+ runtime = { kind: "bundled", command: process.execPath, args: [pi.cli], version: pi.version };
1924
2061
  bundledInstall = bundled;
1925
2062
  bundledCli = pi.cli;
1926
2063
  bundledMemory = engramQuiet ? { policy: "disabled", notice: ENGRAM_RECOVERY_NOTICE } : await classifyBundledMemory();
@@ -1936,16 +2073,11 @@ async function main() {
1936
2073
  if (runtime === undefined) fail(missingPiMessage(), 1);
1937
2074
  }
1938
2075
 
1939
- const versionProbePlan = planSpawn({ command: runtime.command, args: [...runtime.args, "--version"], platform: process.platform });
1940
- const versionProbe = spawnSync(versionProbePlan.command, versionProbePlan.args, {
1941
- stdio: ["ignore", "pipe", "pipe"],
1942
- timeout: 15000,
1943
- encoding: "utf8",
1944
- shell: versionProbePlan.shell,
1945
- env: bundledEnv ?? process.env,
1946
- });
1947
- if (versionProbe.error) fail(`Could not run the pi runtime at "${runtime.command}": ${versionProbe.error.message}`, 1);
1948
- const versionCheck = checkPiVersion(versionProbe.stdout ?? "");
2076
+ // Bundled runtimes already carry their version in memory (package.json /
2077
+ // the pinned dependency): spawning a whole process just to print it back
2078
+ // is the redundant cost issue #2096 reports, so only env/path runtimes
2079
+ // (which have no such in-memory source) still pay for a real probe.
2080
+ const versionCheck = runtime.version !== undefined ? checkPiVersion(runtime.version) : probePiVersion(runtime);
1949
2081
  // A managed self update is how an old Pi gets replaced, so the minimum-version
1950
2082
  // gate must not block it; everything else still requires the minimum.
1951
2083
  const managedSelfUpdate = !bundled && args.piSubcommand === "update" && versionCheck.version !== undefined
@@ -1957,24 +2089,16 @@ async function main() {
1957
2089
  process.exit(0);
1958
2090
  }
1959
2091
 
1960
- // S5: in a bundled install Pi updates only with Gentle Shell, so Pi's own
1961
- // update becomes `gentle-shell upgrade` (run when interactive, named
1962
- // otherwise), or with `--latest` the newest published Pi without the
1963
- // release's lockfile (run even when not interactive: it was asked for);
1964
- // package updates still reach Pi.
2092
+ // Self updates select the latest published Pi in a bundled prefix; package
2093
+ // updates still go to Pi. A self failure must survive a successful child.
1965
2094
  let passthrough = args.passthrough;
2095
+ let updateExitCode = 0;
1966
2096
  if (bundled && args.piSubcommand === "update") {
1967
2097
  const plan = bundledUpdatePlan(args.passthrough);
1968
2098
  if (plan.self) {
1969
- let code;
1970
- if (plan.latest) {
1971
- code = await handleBundledPiLatest(bundled);
1972
- } else {
1973
- const interactive = process.stdin.isTTY === true && process.stdout.isTTY === true;
1974
- for (const line of bundledUpdateNotice({ piVersion: versionCheck.version, interactive })) process.stdout.write(`${line}\n`);
1975
- code = interactive ? await handleBundledUpgrade(bundled, []) : undefined;
1976
- }
1977
- const next = bundledUpdateNext(plan, code);
2099
+ if (args.passthrough.includes("--force")) fail("gentle-shell update: --force is not supported for managed Pi updates.", 2);
2100
+ updateExitCode = await handleBundledPiLatest(bundled);
2101
+ const next = bundledUpdateNext(plan, updateExitCode);
1978
2102
  if ("exitCode" in next) process.exit(next.exitCode);
1979
2103
  if (next.note) process.stderr.write(`${next.note}\n`);
1980
2104
  }
@@ -1983,9 +2107,10 @@ async function main() {
1983
2107
  const { managedUpdatePlan, updateSelectedPi } = await import("../scripts/pi-update.mjs");
1984
2108
  const plan = managedUpdatePlan(args.passthrough);
1985
2109
  if (plan.self) {
1986
- process.exitCode = await updateSelectedPi({ runtime, packageRoot, platform: process.platform, currentVersion: versionCheck.version, cwd: tmpdir(), env: process.env, home: homedir(),
2110
+ if (args.passthrough.includes("--force")) fail("gentle-shell update: --force is not supported for managed Pi updates.", 2);
2111
+ updateExitCode = await updateSelectedPi({ runtime, packageRoot, platform: process.platform, currentVersion: versionCheck.version, cwd: tmpdir(), env: process.env, home: homedir(),
1987
2112
  adapters: await packageManagerAdapters(), out: (line) => process.stdout.write(`${line}\n`) });
1988
- if (plan.piArgs === undefined) return;
2113
+ if (plan.piArgs === undefined) { process.exitCode = updateExitCode; return; }
1989
2114
  }
1990
2115
  passthrough = plan.piArgs;
1991
2116
  }
@@ -2039,6 +2164,15 @@ async function main() {
2039
2164
  }
2040
2165
  }
2041
2166
 
2167
+ // Only a valid extension-only update gets the configuration migration. All
2168
+ // rejected forms must reach Pi without changing a package selection.
2169
+ const extensionUpdate = args.piSubcommand === "update" && passthrough?.[0] === "update" && passthrough.includes("--extensions")
2170
+ && passthrough.slice(1).every((arg) => ["--extensions", "--approve", "-a", "--no-approve", "-na", "--force"].includes(arg));
2171
+ if (bundled && extensionUpdate) {
2172
+ const migrated = await migrateManagedEngramCompanion(home, homeHadContentBeforeBootstrap);
2173
+ if (!migrated.ok) fail(migrated.message, migrated.exitCode);
2174
+ }
2175
+
2042
2176
  if (args.command === "setup") {
2043
2177
  await handleSetupCommand(args.commandArgs, home, runtime, { homeHadContentBeforeBootstrap });
2044
2178
  return;
@@ -2176,7 +2310,9 @@ async function main() {
2176
2310
  bundledEnv = bundledProcessEnv();
2177
2311
  // The guard protects memory whatever provider loads, so a companion that
2178
2312
  // could not be verified is reported, never a reason to stop Shell.
2179
- const companion = await ensureEngramCompanion(home, runtime, ["ignore", 2, 2], 10000);
2313
+ const migrated = await migrateManagedEngramCompanion(home, homeHadContentBeforeBootstrap);
2314
+ if (!migrated.ok) process.stderr.write(`${migrated.message}\n`);
2315
+ const companion = await ensureEngramCompanion(home, runtime, ["ignore", 2, 2], 10000, homeHadContentBeforeBootstrap);
2180
2316
  if (!companion.ok) process.stderr.write(`${companion.message}\n`);
2181
2317
  // Only this final decision starts the shared server, and Pi gets its
2182
2318
  // URL only once the server verified.
@@ -2185,6 +2321,9 @@ async function main() {
2185
2321
  }
2186
2322
  bundledEnv = bundledProcessEnv();
2187
2323
  }
2324
+ // buildPiInvocation injects this package unless the home's own declared
2325
+ // gentle-pi is used as-is.
2326
+ const herdr = herdrLaunchPlan(home, args, takeOver || declaration === undefined);
2188
2327
  const invocation = buildPiInvocation({
2189
2328
  runtime,
2190
2329
  home,
@@ -2193,7 +2332,7 @@ async function main() {
2193
2332
  takeOver,
2194
2333
  otherPackagePaths,
2195
2334
  looseExtensionEntries,
2196
- passthrough: [...managedHerdrExtensionArgs(home, args), ...passthrough],
2335
+ passthrough: [...herdr.extensionArgs, ...passthrough],
2197
2336
  piSubcommand: args.piSubcommand,
2198
2337
  baseEnv: bundledEnv ?? process.env,
2199
2338
  bundled: Boolean(bundled),
@@ -2204,6 +2343,10 @@ async function main() {
2204
2343
 
2205
2344
  // Only an interactive session ends with pi's exit resume hint, which
2206
2345
  // gentle-shell completes with its own line; a pi subcommand gets no handoff.
2346
+ // A nested launch must not inherit a stale reporter handoff.
2347
+ if (herdr.reporter) invocation.env[HERDR_REPORTER_ENV] = "1";
2348
+ else delete invocation.env[HERDR_REPORTER_ENV];
2349
+
2207
2350
  const resumeHandoff = args.piSubcommand === undefined ? createResumeHandoff() : undefined;
2208
2351
  const childEnv = resumeHandoff ? { ...invocation.env, [RESUME_HANDOFF_ENV]: resumeHandoff.path } : invocation.env;
2209
2352
 
@@ -2229,7 +2372,7 @@ async function main() {
2229
2372
  fail(`Could not start pi: ${error.message}`, 1);
2230
2373
  });
2231
2374
  child.on("exit", (code, signal) => {
2232
- const exitCode = signal ? signalExitCode(signal) : (code ?? 1);
2375
+ const exitCode = signal ? signalExitCode(signal) : ((code ?? 1) || updateExitCode);
2233
2376
  if (resumeHandoff) {
2234
2377
  const hint = planResumeHint({
2235
2378
  handoff: resumeHandoff.read(),
@@ -0,0 +1,61 @@
1
+ # Read per-session agent status
2
+
3
+ Any terminal tool can read Gentle Shell's status without Herdr or a socket.
4
+ Interactive top-level Pi sessions publish JSON under
5
+ `<gentlePiConfigHome()>/agent-status/<sha256-of-session-id>.json`.
6
+ Use the active Gentle Shell profile's config home; no `XDG_RUNTIME_DIR` is needed.
7
+ The packaged `gentle-agent-status` extension loads automatically.
8
+
9
+ ## Format: `gentle-shell.agent-status/v1`
10
+
11
+ ```json
12
+ {
13
+ "schema": "gentle-shell.agent-status/v1",
14
+ "agent": "gentle-shell",
15
+ "session": "session-123",
16
+ "pid": 12345,
17
+ "cwd": "/work/project",
18
+ "state": "working",
19
+ "task": { "title": "Implement status adapter" },
20
+ "updatedAt": "2026-07-17T12:34:56.000Z"
21
+ }
22
+ ```
23
+
24
+ - `schema`: version identifier; readers should ignore unsupported versions.
25
+ - `agent`: `gentle-shell` when the launcher owns agent reporting, otherwise `pi`.
26
+ - `session`: stable Pi session ID; `pid`: publisher process ID; `cwd`: session workspace.
27
+ - `state`: `working`, `blocked` (attention takes precedence), or `idle`.
28
+ - `task`: sanitized first `in_progress` Todo title, or `null` when absent, inactive,
29
+ invalid, or task summaries are disabled. Live preference changes apply immediately.
30
+ Titles are bounded to a 4096 UTF-16-unit sample, preserve whole graphemes,
31
+ and strip terminal/control/bidi sequences; no icon, row layout or added ellipsis.
32
+ - `updatedAt`: ISO 8601 UTC heartbeat, refreshed at least every 10 seconds.
33
+
34
+ ## Minimal adapter
35
+
36
+ Set `STATUS_DIR` to the active config home's `agent-status` directory. For example,
37
+ this `jq` reader prints fresh sessions and tolerates missing files during shutdown:
38
+
39
+ ```sh
40
+ jq -r 'select(.schema == "gentle-shell.agent-status/v1") |
41
+ select((now - (.updatedAt | sub("\\.[0-9]+Z$"; "Z") | fromdateiso8601)) <= 30) |
42
+ [.agent, .session, .state, (.task.title // "")] | @tsv' "$STATUS_DIR"/*.json 2>/dev/null
43
+ ```
44
+
45
+ Treat timestamps older than 30 seconds as stale, even if the PID exists. Files
46
+ are replaced atomically on coalesced status changes and heartbeats, then removed
47
+ on shutdown. Crashes may leave stale files. Failed writes/removals never interrupt
48
+ Pi. Children and noninteractive sessions do not publish. Herdr remains unchanged.
49
+
50
+ ## Privacy
51
+
52
+ A symlinked config home, status directory, or status file is refused (nothing is
53
+ written). Directories above the config home are trusted and may be symlinks.
54
+ On POSIX the status directory is created 0700 and files 0600; an existing status
55
+ directory with any group/other permissions, or a config home owned by another
56
+ account or writable by group or others, is refused. Windows has no extra ACL
57
+ check: the files inherit the config home's
58
+ permissions, which are private under the default user profile. The files contain workspace paths,
59
+ session IDs and Todo titles: do not put secrets in titles or expose this directory
60
+ through a public server. Prompts, tool arguments/results and Todo notes are not
61
+ published. Disabling task summaries hides titles, not the remaining status fields.