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
@@ -1002,9 +1002,9 @@ function activateWithLauncher(layout, id, active, { module, next }) {
1002
1002
  * print exactly the release's gentle-pi and Pi before `current` switches; the
1003
1003
  * release's launcher is then written (a failure puts `current` back) and two
1004
1004
  * versions are kept (a pruning failure is only a warning). An already current
1005
- * release changes nothing, and so does a release of the active Gentle Shell
1006
- * whose Pi is older than the one `gentle-shell update --latest` installed (no
1007
- * downgrade); any failure leaves `current` as it was and removes a version this
1005
+ * release changes nothing. A newer active Pi is kept across Shell releases,
1006
+ * without applying a different Pi's verified lockfile; any failure leaves
1007
+ * `current` as it was and removes a version this
1008
1008
  * call installed. Returns { id, changed, previous?, removed?, warning? }.
1009
1009
  */
1010
1010
  export async function upgradeBundled({ layout, home, platform = layout.platform, arch = process.arch, env = {}, adapters, out = () => {} }) {
@@ -1018,10 +1018,26 @@ export async function upgradeBundled({ layout, home, platform = layout.platform,
1018
1018
  out(`Gentle Shell ${shell} with Pi ${pi} is already current.`);
1019
1019
  return { id, changed: false };
1020
1020
  }
1021
- const activePi = piOfVersion(active, shell);
1021
+ let activePi = null;
1022
+ if (active) {
1023
+ try {
1024
+ if (!installedVersion(layout, active)) throw new Error("not installed");
1025
+ const dependencies = JSON.parse(read(pathFor(process.platform).join(versionDirectory(layout, active), "package.json"))).dependencies;
1026
+ const current = versionsOf({ shell: dependencies?.["gentle-pi"], pi: dependencies?.[PI_PACKAGE] });
1027
+ if (current.id !== active) throw new Error("version mismatch");
1028
+ activePi = current.pi;
1029
+ } catch {
1030
+ throw new Error(`the active version ${active} could not be verified; current stays as it is`);
1031
+ }
1032
+ }
1022
1033
  if (activePi && newerVersion(activePi, pi)) {
1023
- out(`Gentle Shell ${shell} is current; Pi ${activePi} (installed with 'gentle-shell update --latest') is newer than this release's verified Pi ${pi}.`);
1024
- return { id: active, changed: false };
1034
+ if (piOfVersion(active, shell)) {
1035
+ out(`Gentle Shell ${shell} is current; Pi ${activePi} is newer than this release's verified Pi ${pi}.`);
1036
+ return { id: active, changed: false };
1037
+ }
1038
+ out(`warning: keeping Pi ${activePi}, newer than this release's verified Pi ${pi}; installing without the release's verified lockfile. Gentle Shell features that rely on audited Pi internals may turn off.`);
1039
+ return installAndActivate({ layout, home, platform, arch, env, adapters, out, manifest: { ...manifest, pi: activePi }, unverified: true, active,
1040
+ success: `Upgraded to Gentle Shell ${shell} with Pi ${activePi} (from ${active}). Run 'gentle-shell upgrade --rollback' to switch back.` });
1025
1041
  }
1026
1042
  return installAndActivate({ layout, home, platform, arch, env, adapters, out, manifest, lockfile, active,
1027
1043
  success: `Upgraded to Gentle Shell ${shell} with Pi ${pi} (from ${active ?? "no active version"}). Run 'gentle-shell upgrade --rollback' to switch back.` });
@@ -1032,11 +1048,25 @@ function piOfVersion(id, shell) {
1032
1048
  const pi = typeof id === "string" && id.startsWith(`${shell}-`) ? id.slice(shell.length + 1) : "";
1033
1049
  return SEMVER.test(pi) ? pi : null;
1034
1050
  }
1035
- /** Whether version `a` is newer than `b` by major, minor and patch. */
1051
+ /** Semver precedence, including prereleases; callers already validated both versions. */
1036
1052
  function newerVersion(a, b) {
1037
1053
  const [left, right] = [a, b].map((version) => SEMVER.exec(version).slice(1, 4).map(Number));
1038
1054
  const index = left.findIndex((part, at) => part !== right[at]);
1039
- return index !== -1 && left[index] > right[index];
1055
+ if (index !== -1) return left[index] > right[index];
1056
+ const [preA, preB] = [a, b].map((version) => version.split("-").slice(1).join("-"));
1057
+ if (!preA || !preB) return !preA && Boolean(preB);
1058
+ const [partsA, partsB] = [preA.split("."), preB.split(".")];
1059
+ for (let i = 0; i < Math.max(partsA.length, partsB.length); i += 1) {
1060
+ if (partsA[i] === undefined) return false;
1061
+ if (partsB[i] === undefined) return true;
1062
+ if (partsA[i] === partsB[i]) continue;
1063
+ const numericA = /^\d+$/.test(partsA[i]);
1064
+ const numericB = /^\d+$/.test(partsB[i]);
1065
+ if (numericA && numericB) return BigInt(partsA[i]) > BigInt(partsB[i]);
1066
+ if (numericA !== numericB) return !numericA;
1067
+ return partsA[i] > partsB[i];
1068
+ }
1069
+ return false;
1040
1070
  }
1041
1071
 
1042
1072
  /** Installs `manifest` beside the active version (with the release lockfile,
@@ -0,0 +1,68 @@
1
+ // One-line terminal progress for the package-local Gentle AI download. Pure
2
+ // formatting plus a throttled reporter over an injected writer; the caller
3
+ // decides whether a terminal is attached (install-gentle-ai.mjs).
4
+
5
+ const KB = 1024;
6
+ const MB = 1024 * 1024;
7
+
8
+ function size(bytes) {
9
+ return bytes >= MB ? `${(bytes / MB).toFixed(1)} MB` : `${Math.round(bytes / KB)} KB`;
10
+ }
11
+
12
+ function truncate(text, width) {
13
+ const chars = [...text];
14
+ return chars.length <= width ? text : chars.slice(0, Math.max(0, width)).join("");
15
+ }
16
+
17
+ export function formatDownloadProgress({ label, received, total, elapsedMs, width }) {
18
+ const rate = elapsedMs > 0 ? (received * 1000) / elapsedMs : 0;
19
+ const known = typeof total === "number" && total > 0;
20
+ const amount = known
21
+ ? total >= MB
22
+ ? `${(received / MB).toFixed(1)}/${(total / MB).toFixed(1)} MB`
23
+ : `${Math.round(received / KB)}/${Math.round(total / KB)} KB`
24
+ : size(received);
25
+ const parts = [amount];
26
+ if (known) parts.push(`${String(Math.min(100, Math.floor((received / total) * 100))).padStart(3)}%`);
27
+ // The rate is the first thing to go when even the bare numbers do not fit.
28
+ if (rate > 0 && [...parts.join(" ")].length + [...size(rate)].length + 3 <= width) parts.push(`${size(rate)}/s`);
29
+ const metrics = parts.join(" ");
30
+ // The moving numbers win over the label on a narrow terminal: the label is
31
+ // shortened, then dropped, before the amount and percent are ever cut.
32
+ const room = width - [...metrics].length - 1;
33
+ if (room < [...label].length) return room >= 1 ? `${truncate(label, room)} ${metrics}` : truncate(metrics, width);
34
+ const text = `${label} ${metrics}`;
35
+ if (!known) return text;
36
+ const barWidth = Math.min(30, width - [...text].length - 3);
37
+ if (barWidth < 5) return truncate(text, width);
38
+ const filled = Math.min(barWidth, Math.round((received / total) * barWidth));
39
+ return `${text} [${"#".repeat(filled)}${"-".repeat(barWidth - filled)}]`;
40
+ }
41
+
42
+ // Redraws at most every `intervalMs`, except the completed state, which is
43
+ // always drawn. `done` clears the line once, and only if something was drawn.
44
+ export function createDownloadProgress({ label, write: rawWrite, now = Date.now, width = () => 80, intervalMs = 100 }) {
45
+ // Display only: a failing terminal write (closed pipe, detached tty) must
46
+ // never change the install result, including during cleanup in `done`.
47
+ const write = (text) => { try { rawWrite(text); } catch { /* display only */ } };
48
+ const started = now();
49
+ let lastDraw;
50
+ let drawn = false;
51
+ let finished = false;
52
+ return {
53
+ update({ received, total }) {
54
+ if (finished) return;
55
+ const at = now();
56
+ const complete = typeof total === "number" && total > 0 && received >= total;
57
+ if (lastDraw !== undefined && at - lastDraw < intervalMs && !complete) return;
58
+ lastDraw = at;
59
+ drawn = true;
60
+ write(`\r${formatDownloadProgress({ label, received, total, elapsedMs: at - started, width: Math.max(10, width() - 1) })}\x1b[K`);
61
+ },
62
+ done() {
63
+ if (finished) return;
64
+ finished = true;
65
+ if (drawn) write("\r\x1b[K");
66
+ },
67
+ };
68
+ }
@@ -14,10 +14,11 @@ import {
14
14
  } from "node:fs/promises";
15
15
  import https from "node:https";
16
16
  import { tmpdir } from "node:os";
17
- import { dirname, isAbsolute, join, relative } from "node:path";
17
+ import { dirname, isAbsolute, join, relative, toNamespacedPath } from "node:path";
18
18
  import { fileURLToPath } from "node:url";
19
19
  import { execFile } from "node:child_process";
20
20
  import { promisify } from "node:util";
21
+ import { createProxyTunnelAgent, proxyTrustOptions, resolveProxyForTarget } from "./gentle-ai-proxy.mjs";
21
22
 
22
23
  const execFileAsync = promisify(execFile);
23
24
  const MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024;
@@ -37,7 +38,7 @@ const WINDOWS_SYSTEM_ROOT = "C:\\Windows";
37
38
  // version check below) derives from this constant instead of repeating the
38
39
  // literal, so a pin bump cannot leave a stale copy behind. See
39
40
  // scripts/install-gentle-ai.mjs for the incident that motivated this.
40
- export const INSTALLER_VERSION = "4.3.1";
41
+ export const INSTALLER_VERSION = "4.4.0";
41
42
  export const RELEASE_BASE_URL = `https://github.com/Gentleman-Programming/gentle-ai/releases/download/v${INSTALLER_VERSION}/`;
42
43
  export const GENTLE_AI_INSTALL_METHOD = Object.freeze({
43
44
  SIGNED_RELEASE_ASSET: "signed-release-asset",
@@ -46,11 +47,11 @@ export const GENTLE_AI_INSTALL_METHOD = Object.freeze({
46
47
  export const GENTLE_AI_WINDOWS_SOURCE_PACKAGE_PATH = "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai";
47
48
  export const GENTLE_AI_WINDOWS_SOURCE_MODULE = "github.com/gentleman-programming/gentle-ai/v4";
48
49
  export const GENTLE_AI_WINDOWS_SOURCE_TAG = `v${INSTALLER_VERSION}`;
49
- // `go mod download -json github.com/gentleman-programming/gentle-ai/v4@v4.3.1`
50
+ // `go mod download -json github.com/gentleman-programming/gentle-ai/v4@v4.4.0`
50
51
  // with GOSUMDB=sum.golang.org reports this exact module SumDB checksum, and the
51
- // tag resolves to commit 2dba7784114fff57864519c4c0d067e952a8c98b, the published v4.3.1 release head.
52
+ // tag resolves to commit 55240afb100ad6d2ef5fbe16f7be33a7693f77ad, the published v4.4.0 release head.
52
53
  // v4.0.0 moved the Go module path to the /v4 major-version suffix.
53
- export const GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM = "h1:00p8dnjJrhYFq1Qikk2oY6K/UXIty9A/IBUUOUiX9XA=";
54
+ export const GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM = "h1:cAQAzIsbocYcQfOzA1CmgGpGgiCivUNcPjdfJE8RJ6g=";
54
55
  export const GENTLE_AI_WINDOWS_SOURCE_PACKAGE = `${GENTLE_AI_WINDOWS_SOURCE_PACKAGE_PATH}@${GENTLE_AI_WINDOWS_SOURCE_TAG}`;
55
56
  export const GENTLE_AI_WINDOWS_MINIMUM_GO_VERSION = "1.25.10";
56
57
  export const GENTLE_AI_GO_TOOLCHAIN_UNAVAILABLE_CODE = "GENTLE_AI_GO_TOOLCHAIN_UNAVAILABLE";
@@ -69,7 +70,7 @@ export class GentleAiInstallerError extends Error {
69
70
  // Sentinel used while a re-pinned gentle-ai release is not yet published. A
70
71
  // sentinel digest can never match a real SHA-256, so installation fails closed,
71
72
  // and verify-package-files.mjs refuses to pack/publish while any digest below
72
- // still holds it. The v4.3.1 digests are pinned from the published release:
73
+ // still holds it. The v4.4.0 digests are pinned from the published release:
73
74
  // archive sha256 values verified against the minisign-signed checksums.txt and
74
75
  // freshly computed hashes; binary sha256 values computed from the extracted
75
76
  // executables.
@@ -94,12 +95,14 @@ function asset(name, sha256, binarySha256, executable) {
94
95
  // documented recovery instead of leaving a dead end until the next repin.
95
96
  async function downloadPinnedGentleAiAsset(asset, destination, options) {
96
97
  const download = options.download ?? downloadGentleAiAsset;
98
+ // Progress is display-only: it never changes what is downloaded or verified.
99
+ const progress = options.onProgress === undefined ? [] : [undefined, undefined, { onProgress: options.onProgress }];
97
100
  try {
98
- await download(asset.url, destination);
101
+ await download(asset.url, destination, ...progress);
99
102
  } catch (primaryError) {
100
103
  if (asset.mirrorUrl === undefined) throw primaryError;
101
104
  try {
102
- await download(asset.mirrorUrl, destination);
105
+ await download(asset.mirrorUrl, destination, ...progress);
103
106
  } catch (mirrorError) {
104
107
  throw new GentleAiInstallerError(
105
108
  GENTLE_AI_ASSET_UNAVAILABLE_CODE,
@@ -111,15 +114,15 @@ async function downloadPinnedGentleAiAsset(asset, destination, options) {
111
114
  }
112
115
 
113
116
  // Windows is absent from signed release archives on purpose. gentle-ai stopped
114
- // distributing unsigned Windows builds in c4b764d0, so v4.3.1 publishes signed
117
+ // distributing unsigned Windows builds in c4b764d0, so v4.4.0 publishes signed
115
118
  // Darwin/Linux archives only. Windows x64/arm64 uses the separately verified
116
119
  // exact-tag Go SumDB source-build path below; restore archive rows only when
117
120
  // upstream ships signed Windows assets.
118
121
  export const GENTLE_AI_RELEASE_ASSETS = Object.freeze({
119
- "darwin/amd64": asset("gentle-ai_4.3.1_darwin_amd64.tar.gz", "6cf57fee0574daef2abed07f54a355fec3b93ac8f01733dc6c4d3674f1746112", "ca44c3fce186b63a7e7ad455c338133ba1982f4a13485301ce4d66edb73d2928", "gentle-ai"),
120
- "darwin/arm64": asset("gentle-ai_4.3.1_darwin_arm64.tar.gz", "13e8828447f9081465ee0c35a61b24fb49296d51a310c6999227e2aed178956b", "749d08062b0dec13681678a1a1c018613d223ddcca47b5f27681b1d8ab5d14c2", "gentle-ai"),
121
- "linux/amd64": asset("gentle-ai_4.3.1_linux_amd64.tar.gz", "04ec685c56b42c29dff6db10fc7dc2c730217dc9c96736e53ad2acf3226dafb7", "86248792bde3fe5e9ca93b128c07e7caa6a5b31fac0f9fc84b5b3011b123cb90", "gentle-ai"),
122
- "linux/arm64": asset("gentle-ai_4.3.1_linux_arm64.tar.gz", "99e7d313a2ff85eaf23a6415e9b3aae67bf74c2fa169b21b93070ada7613f6a0", "df3580506bb5ea63cc4ef5ccebe8b68cfedf66b72f3b51f84ff393183d8cea2b", "gentle-ai"),
122
+ "darwin/amd64": asset("gentle-ai_4.4.0_darwin_amd64.tar.gz", "95686ea30615516aa29ebb6257227b1cdd4c67649dff63ec7adb576ca26a678d", "634189866db1db635aed6257716969e87e7cde6830c26627795becbd2969e104", "gentle-ai"),
123
+ "darwin/arm64": asset("gentle-ai_4.4.0_darwin_arm64.tar.gz", "b6e00957eb81115f18e33197ae2035f75812a624c6d53e72826ecf7b4a635539", "5bb53e7e32da585f08b668444209bde7a9b5c9c26489e2052bf180b05a2aab81", "gentle-ai"),
124
+ "linux/amd64": asset("gentle-ai_4.4.0_linux_amd64.tar.gz", "1f72ca13b32e87cb7f65b29e7fae6df4490b53d69d4763cdf23e944165880cd6", "9f39a94cef0b9882be4cd519fac3ef3602e602e3bf437df7db55c8cbd42f358d", "gentle-ai"),
125
+ "linux/arm64": asset("gentle-ai_4.4.0_linux_arm64.tar.gz", "2d8874464cbe54b66a77d7c9fe66ce577933de00936ed1a035c81de6406a95fc", "b9913af83cbeff2719e33d4b6c09e6ed568a000c4d6b885b4806ec5ce796f2b7", "gentle-ai"),
123
126
  });
124
127
 
125
128
  // A pinned asset is either a signed archive or, for a prerelease pin only,
@@ -171,17 +174,37 @@ async function sha256File(path) {
171
174
  function downloadTimeoutError(stage) { return Object.assign(new Error(`Gentle AI download ${stage} timed out`), { code: "GENTLE_AI_DOWNLOAD_TIMEOUT" }); }
172
175
  function isRetryableDownloadError(error) { return error && typeof error === "object" && ["GENTLE_AI_DOWNLOAD_TIMEOUT", "GENTLE_AI_DOWNLOAD_TRANSIENT_HTTP", "ECONNABORTED", "ECONNREFUSED", "ECONNRESET", "EAI_AGAIN", "EHOSTUNREACH", "ENETUNREACH", "ETIMEDOUT"].includes(error.code); }
173
176
  function downloadHttpError(status) { return Object.assign(new Error(`Gentle AI download failed with HTTP ${status}`), { code: [429, 500, 502, 503, 504].includes(status) ? "GENTLE_AI_DOWNLOAD_TRANSIENT_HTTP" : "GENTLE_AI_DOWNLOAD_HTTP" }); }
177
+ /**
178
+ * Downloads a release asset over HTTPS.
179
+ *
180
+ * The trust options in `options` reach both peers of the connection, the
181
+ * proxy and the origin. An explicit `ca` replaces Node's default certificate
182
+ * authority list rather than adding to it, so it has to include the
183
+ * authorities of both peers the download is expected to reach. The client
184
+ * credentials are used for the origin only and are never offered to the
185
+ * proxy.
186
+ */
174
187
  export async function downloadGentleAiAsset(url, destination, maxBytes = MAX_DOWNLOAD_BYTES, redirects = MAX_REDIRECTS, options = {}) {
175
- const { request = https.get, headerTimeoutMs = DOWNLOAD_TIMEOUTS.headers, bodyTimeoutMs = DOWNLOAD_TIMEOUTS.body, maxAttempts = DOWNLOAD_TIMEOUTS.attempts, retryDelayMs = DOWNLOAD_TIMEOUTS.retryDelay } = options;
188
+ const { request = https.get, env = process.env, headerTimeoutMs = DOWNLOAD_TIMEOUTS.headers, bodyTimeoutMs = DOWNLOAD_TIMEOUTS.body, maxAttempts = DOWNLOAD_TIMEOUTS.attempts, retryDelayMs = DOWNLOAD_TIMEOUTS.retryDelay, onProgress } = options;
189
+ // `onProgress({ received, total })` is display-only: `total` is undefined
190
+ // without a content-length. A reporter failure must never fail or alter the
191
+ // download itself, so it is swallowed here and reported per chunk below.
192
+ const report = (received, total) => { try { onProgress?.({ received, total }); } catch { /* display only */ } };
193
+ const trust = proxyTrustOptions(options);
176
194
  if (![headerTimeoutMs, bodyTimeoutMs, retryDelayMs, maxAttempts].every((value) => Number.isSafeInteger(value) && value >= 0) || maxAttempts < 1) throw new TypeError("Gentle AI download timeout and retry options must be safe non-negative integers");
177
195
  const responseFor = async (currentUrl, remainingRedirects) => {
178
196
  const parsed = new URL(currentUrl);
179
197
  if (parsed.protocol !== "https:") throw new Error("Gentle AI installer requires HTTPS downloads");
198
+ // The proxy is resolved per URL rather than once per download, because a
199
+ // redirect may land on a host that NO_PROXY exempts.
200
+ const proxy = resolveProxyForTarget(parsed, env);
201
+ const requestOptions = { headers: { "user-agent": "gentle-pi-installer" }, ...trust };
202
+ if (proxy !== undefined) requestOptions.agent = createProxyTunnelAgent(proxy, headerTimeoutMs, trust);
180
203
  return new Promise((resolve, reject) => {
181
204
  let pending;
182
205
  const timer = setTimeout(() => pending?.destroy(downloadTimeoutError("headers")), headerTimeoutMs);
183
206
  const fail = (error) => { clearTimeout(timer); reject(error); };
184
- pending = request(parsed, { headers: { "user-agent": "gentle-pi-installer" } }, (response) => {
207
+ pending = request(parsed, requestOptions, (response) => {
185
208
  clearTimeout(timer);
186
209
  const status = response.statusCode ?? 0, location = response.headers.location;
187
210
  if (status >= 300 && status < 400 && location) { response.resume(); return remainingRedirects <= 0 ? fail(new Error("Gentle AI download exceeded redirect limit")) : responseFor(new URL(location, parsed).toString(), remainingRedirects - 1).then(resolve, reject); }
@@ -210,7 +233,7 @@ export async function downloadGentleAiAsset(url, destination, maxBytes = MAX_DOW
210
233
  const finish = (callback, value) => { if (settled) return; settled = true; clearTimeout(timer); void closed().then(() => callback(value)); };
211
234
  const fail = (error) => { response.destroy(); output.destroy(); finish(reject, error); };
212
235
  const reset = () => { clearTimeout(timer); timer = setTimeout(() => response.destroy(downloadTimeoutError("body")), bodyTimeoutMs); };
213
- response.on("data", (chunk) => { reset(); received += chunk.length; if (received > maxBytes) response.destroy(new Error("Gentle AI download exceeds the maximum allowed size")); });
236
+ response.on("data", (chunk) => { reset(); received += chunk.length; if (received > maxBytes) response.destroy(new Error("Gentle AI download exceeds the maximum allowed size")); else report(received, contentLength > 0 ? contentLength : undefined); });
214
237
  response.on("error", fail); response.setTimeout?.(bodyTimeoutMs, () => response.destroy(downloadTimeoutError("body")));
215
238
  output.on("error", fail); output.on("finish", () => finish(resolve)); response.pipe(output);
216
239
  });
@@ -661,7 +684,7 @@ async function installWindowsGentleAiFromGoSumdb(options, packageRoot, architect
661
684
  const execute = options.execFile ?? execFileAsync;
662
685
  return withInstallLock(packageRoot, options, async (runtimeRoot) => {
663
686
  await cleanupStaleStagingBundles(runtimeRoot);
664
- const stagingDirectory = await mkdtemp(join(runtimeRoot, `.v${INSTALLER_VERSION}.staging-`));
687
+ const stagingDirectory = await mkdtemp(toNamespacedPath(join(runtimeRoot, `.v${INSTALLER_VERSION}.staging-`)));
665
688
  // Go builds in a short private directory under the system temp directory, never inside
666
689
  // the package: from a deep pnpm store path (179 characters, run 38063142924) the
667
690
  // working directories Go gives asm.exe inside GOMODCACHE exceed MAX_PATH and
@@ -704,7 +727,7 @@ async function installSignedRelease(options, packageRoot, platform, arch, asset)
704
727
  await cleanupStaleStagingBundles(runtimeRoot);
705
728
  const existing = versionBundlePath(runtimeRoot);
706
729
  if (await existingSignedBundleMatches(existing, asset, platform)) return { installed: false, binaryPath: join(existing, asset.executable), asset };
707
- const stagingDirectory = await mkdtemp(join(runtimeRoot, `.v${INSTALLER_VERSION}.staging-`));
730
+ const stagingDirectory = await mkdtemp(toNamespacedPath(join(runtimeRoot, `.v${INSTALLER_VERSION}.staging-`)));
708
731
  try {
709
732
  const form = gentleAiAssetForm(asset.name);
710
733
  const archive = join(stagingDirectory, asset.name);
@@ -0,0 +1,294 @@
1
+ // A corporate proxy is the only route to the internet for many operators, and
2
+ // npm already honours it, so the installer has to as well. The Gentle AI
3
+ // release asset is fetched with node:https, whose client ignores HTTPS_PROXY,
4
+ // HTTP_PROXY and NO_PROXY unless the process opts in, and Node only grew that
5
+ // opt-in in v24 (NODE_USE_ENV_PROXY / --use-env-proxy) while this package
6
+ // supports node >= 22.19.0. The tunnel below is the portable equivalent of
7
+ // that opt-in: it opens a CONNECT tunnel to the proxy and speaks TLS to the
8
+ // origin host through it, so the origin's own certificate still decides
9
+ // whether the connection is trusted and the proxy never sees the request.
10
+ import https from "node:https";
11
+ import net from "node:net";
12
+ import tls from "node:tls";
13
+
14
+ // Both spellings are read because shells and CI runners disagree about the
15
+ // convention, and the lowercase form is what most corporate setups export.
16
+ const PROXY_ENV_BY_PROTOCOL = Object.freeze({
17
+ "https:": Object.freeze(["HTTPS_PROXY", "https_proxy"]),
18
+ "http:": Object.freeze(["HTTP_PROXY", "http_proxy"]),
19
+ });
20
+
21
+ const TRANSIENT_PROXY_STATUSES = Object.freeze([429, 500, 502, 503, 504]);
22
+
23
+ function proxyPort(proxy) {
24
+ if (proxy.port !== "") return Number(proxy.port);
25
+ return proxy.protocol === "https:" ? 443 : 80;
26
+ }
27
+
28
+ // URL.hostname keeps the brackets of an IPv6 literal, but a socket address
29
+ // and a TLS server name need the bare address, so the brackets come off here.
30
+ // The bare address stays the server name because dropping it would turn off
31
+ // the certificate identity check.
32
+ function proxyHost(proxy) {
33
+ return proxy.hostname.replace(/^\[|\]$/g, "");
34
+ }
35
+
36
+ // A proxy value that is not a usable http(s) URL is ignored rather than
37
+ // allowed to break an install that would have reached the host directly.
38
+ function parseProxy(raw) {
39
+ try {
40
+ // A bare "host:port" is a proxy address, not a URL whose scheme is "host".
41
+ const proxy = new URL(raw.includes("://") ? raw : `http://${raw}`);
42
+ if (proxy.protocol !== "http:" && proxy.protocol !== "https:") return undefined;
43
+ if (proxy.hostname === "") return undefined;
44
+ // Credentials are percent-encoded in the URL and decoded when the
45
+ // Proxy-Authorization header is built. Decoding them here rejects a
46
+ // malformed value now, instead of failing later inside the tunnel.
47
+ decodeURIComponent(proxy.username);
48
+ decodeURIComponent(proxy.password);
49
+ return proxy;
50
+ } catch {
51
+ return undefined;
52
+ }
53
+ }
54
+
55
+ function splitHostPort(entry) {
56
+ if (entry.startsWith("[")) {
57
+ const end = entry.indexOf("]");
58
+ if (end === -1) return { host: entry, port: undefined };
59
+ const rest = entry.slice(end + 1);
60
+ return { host: entry.slice(0, end + 1), port: rest.startsWith(":") ? rest.slice(1) : undefined };
61
+ }
62
+ const separator = entry.lastIndexOf(":");
63
+ // More than one colon is a bare IPv6 address, which carries no port.
64
+ if (separator === -1 || entry.indexOf(":") !== separator) return { host: entry, port: undefined };
65
+ return { host: entry.slice(0, separator), port: entry.slice(separator + 1) };
66
+ }
67
+
68
+ function matchesNoProxy(target, entry) {
69
+ if (entry === "*") return true;
70
+ const { host: pattern, port } = splitHostPort(entry.toLowerCase());
71
+ const host = target.hostname.toLowerCase();
72
+ const targetPort = target.port !== "" ? target.port : target.protocol === "https:" ? "443" : "80";
73
+ if (port !== undefined && port !== targetPort) return false;
74
+ if (pattern.startsWith("*.")) {
75
+ const base = pattern.slice(2);
76
+ return host === base || host.endsWith(`.${base}`);
77
+ }
78
+ // A leading dot covers the domain and its subdomains; a bare domain is an
79
+ // exact match, so one entry never silently exempts a whole namespace.
80
+ if (pattern.startsWith(".")) {
81
+ const base = pattern.slice(1);
82
+ return host === base || host.endsWith(`.${base}`);
83
+ }
84
+ return host === pattern;
85
+ }
86
+
87
+ /**
88
+ * The proxy that applies to `target`, or undefined when the target is reached
89
+ * directly. HTTPS_PROXY answers for an https target and HTTP_PROXY is the
90
+ * fallback, exactly as every other HTTP client on the platform resolves them,
91
+ * and NO_PROXY always wins over both. A value that is not a usable proxy URL
92
+ * is ignored, so a stray variable cannot break an install that would otherwise
93
+ * reach the host directly.
94
+ */
95
+ export function resolveProxyForTarget(target, env = process.env) {
96
+ const url = target instanceof URL ? target : new URL(String(target));
97
+ const noProxy = String(env.NO_PROXY ?? env.no_proxy ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
98
+ if (noProxy.some((entry) => matchesNoProxy(url, entry))) return undefined;
99
+ const primary = PROXY_ENV_BY_PROTOCOL[url.protocol] ?? [];
100
+ const fallback = url.protocol === "https:" ? PROXY_ENV_BY_PROTOCOL["http:"] : [];
101
+ for (const key of [...primary, ...fallback]) {
102
+ const raw = env[key];
103
+ if (typeof raw !== "string" || raw.trim() === "") continue;
104
+ const proxy = parseProxy(raw.trim());
105
+ if (proxy !== undefined) return proxy;
106
+ }
107
+ return undefined;
108
+ }
109
+
110
+ function tunnelAuthority(host, port) {
111
+ return host.includes(":") ? `[${host}]:${port}` : `${host}:${port}`;
112
+ }
113
+
114
+ /**
115
+ * The TLS options for the connection to an https proxy.
116
+ *
117
+ * The proxy host is always the name the certificate is checked against,
118
+ * because Node leaves the socket host unset and would otherwise fall back
119
+ * to "localhost". An IP address cannot be a server name, and a modern Node
120
+ * refuses the handshake outright when it is given one, so the server name
121
+ * is only sent for a hostname.
122
+ */
123
+ export function proxyTlsOptions(proxy) {
124
+ return hostTlsOptions(proxyHost(proxy));
125
+ }
126
+
127
+ /**
128
+ * The TLS options for a host reached through the tunnel.
129
+ *
130
+ * The host is always the name the certificate is checked against, because
131
+ * Node leaves the socket host unset and would otherwise fall back to
132
+ * "localhost". An IP address cannot be a server name, and a modern Node
133
+ * refuses the handshake outright when it is given one, so the server name
134
+ * is only sent for a hostname.
135
+ */
136
+ export function hostTlsOptions(name) {
137
+ return net.isIP(name) ? { host: name } : { host: name, servername: name };
138
+ }
139
+
140
+ /**
141
+ * The trust options for a handshake, so a caller that trusts a private
142
+ * certificate authority reaches a peer that presents one.
143
+ *
144
+ * An explicit `ca` replaces Node's default certificate authority list
145
+ * rather than adding to it, so a caller that sets it has to include the
146
+ * authorities of both peers it expects to reach. The proxy and the origin
147
+ * are separate peers, so a private authority for one of them and a public
148
+ * certificate for the other need both authorities in the list.
149
+ */
150
+ export function proxyTrustOptions(options) {
151
+ return {
152
+ ...(options.rejectUnauthorized === undefined ? {} : { rejectUnauthorized: options.rejectUnauthorized }),
153
+ ...(options.ca === undefined ? {} : { ca: options.ca }),
154
+ ...(options.cert === undefined ? {} : { cert: options.cert }),
155
+ ...(options.key === undefined ? {} : { key: options.key }),
156
+ ...(options.passphrase === undefined ? {} : { passphrase: options.passphrase }),
157
+ };
158
+ }
159
+
160
+ /**
161
+ * The trust options for the proxy handshake.
162
+ *
163
+ * The client credentials belong to the origin, so they stay on the origin
164
+ * handshake: a proxy that asks for a client certificate would otherwise
165
+ * receive the identity of the origin. The certificate authority and the
166
+ * verification setting are shared, because the proxy is a peer of the
167
+ * client just like the origin is.
168
+ *
169
+ * The certificate authority is the same list the origin handshake uses, so
170
+ * it has to trust both peers, and an explicit list replaces Node's default
171
+ * authorities rather than adding to them.
172
+ */
173
+ export function proxyHandshakeTrustOptions(trust) {
174
+ return {
175
+ ...(trust.rejectUnauthorized === undefined ? {} : { rejectUnauthorized: trust.rejectUnauthorized }),
176
+ ...(trust.ca === undefined ? {} : { ca: trust.ca }),
177
+ };
178
+ }
179
+
180
+ /**
181
+ * An https.Agent whose sockets are CONNECT tunnels to `proxy`. The origin host
182
+ * is still verified by TLS over the tunnel, so the proxy cannot read the
183
+ * request and cannot impersonate the release host without the origin's own
184
+ * certificate chain failing the handshake.
185
+ */
186
+ export function createProxyTunnelAgent(proxy, headerTimeoutMs = 10_000, trust = {}) {
187
+ const agent = new https.Agent({ keepAlive: false });
188
+ agent.createConnection = (options, callback) => {
189
+ const host = options.host ?? options.hostname;
190
+ const port = Number(options.port ?? 443);
191
+ const authority = tunnelAuthority(host, port);
192
+ const raw = net.connect({ host: proxyHost(proxy), port: proxyPort(proxy) });
193
+ let channel = raw;
194
+ let head = Buffer.alloc(0);
195
+ let delivered = false;
196
+ let timer;
197
+ const closed = new Set();
198
+ // The listener identity of each socket is kept so every one of them can
199
+ // be detached again on completion, failure and teardown.
200
+ const listeners = new Map();
201
+ const onEnd = () => fail(Object.assign(new Error("Gentle AI download proxy closed before completing CONNECT headers"), { code: "ECONNRESET" }));
202
+ const deliver = (error, secure) => {
203
+ if (delivered) return;
204
+ delivered = true;
205
+ clearTimeout(timer);
206
+ raw.off("connect", onConnect);
207
+ for (const [socket, bound] of listeners) {
208
+ // TLS queues an error while handling EOF, so the error handler
209
+ // stays until teardown finishes and is removed with the close.
210
+ if (error && !closed.has(socket)) socket.once("close", () => socket.off("error", bound.error));
211
+ else socket.off("error", bound.error);
212
+ socket.off("end", bound.end);
213
+ socket.off("close", bound.close);
214
+ socket.off("data", onData);
215
+ }
216
+ callback(error, secure);
217
+ };
218
+ function fail(error) {
219
+ if (delivered) return;
220
+ channel.destroy();
221
+ raw.destroy();
222
+ deliver(error, undefined);
223
+ }
224
+ const watch = (socket) => {
225
+ const bound = {
226
+ error: fail,
227
+ end: onEnd,
228
+ close: () => {
229
+ closed.add(socket);
230
+ onEnd();
231
+ },
232
+ };
233
+ listeners.set(socket, bound);
234
+ socket.on("error", bound.error);
235
+ socket.on("end", bound.end);
236
+ socket.on("close", bound.close);
237
+ return bound;
238
+ };
239
+ // The request cannot enforce its deadline until this agent hands it a
240
+ // socket. Bound TCP, proxy TLS and the CONNECT headers here instead.
241
+ timer = setTimeout(() => fail(Object.assign(new Error("Gentle AI download proxy CONNECT timed out"), { code: "GENTLE_AI_DOWNLOAD_TIMEOUT" })), headerTimeoutMs);
242
+ watch(raw);
243
+ raw.once("connect", onConnect);
244
+ function onConnect() {
245
+ // A proxy reached over TLS speaks the same CONNECT protocol once its
246
+ // own handshake is done, so the tunnel is written to whichever
247
+ // channel is open.
248
+ if (proxy.protocol === "https:") {
249
+ channel = tls.connect({ socket: raw, ...proxyTlsOptions(proxy), ...proxyHandshakeTrustOptions(trust) });
250
+ watch(channel);
251
+ }
252
+ const lines = [`CONNECT ${authority} HTTP/1.1`, `Host: ${authority}`];
253
+ if (proxy.username !== "") {
254
+ const credentials = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
255
+ lines.push(`Proxy-Authorization: Basic ${Buffer.from(credentials).toString("base64")}`);
256
+ }
257
+ channel.write(`${lines.join("\r\n")}\r\n\r\n`);
258
+ channel.on("data", onData);
259
+ }
260
+ function onData(chunk) {
261
+ head = Buffer.concat([head, chunk]);
262
+ const boundary = head.indexOf("\r\n\r\n");
263
+ if (boundary === -1) return;
264
+ channel.off("data", onData);
265
+ const status = Number(head.subarray(0, head.indexOf("\r\n")).toString("latin1").split(" ")[1]);
266
+ if (status !== 200) {
267
+ // A proxy that is briefly overloaded answers like any other
268
+ // transient HTTP failure, and the downloader's own retry rule
269
+ // decides whether the attempt is worth repeating.
270
+ const error = new Error(`Gentle AI download proxy refused the tunnel with status ${status}`);
271
+ error.code = TRANSIENT_PROXY_STATUSES.includes(status) ? "GENTLE_AI_DOWNLOAD_TRANSIENT_HTTP" : "GENTLE_AI_DOWNLOAD_HTTP";
272
+ fail(error);
273
+ return;
274
+ }
275
+ // Bytes the proxy sent past the header block belong to the origin
276
+ // stream and have to reach the TLS layer rather than be dropped.
277
+ const remainder = head.subarray(boundary + 4);
278
+ if (remainder.length > 0) channel.unshift(remainder);
279
+ deliver(undefined, tls.connect({
280
+ socket: channel,
281
+ // A request for an address leaves the server name empty, and an
282
+ // empty server name would make the certificate be checked
283
+ // against "localhost" instead of the origin.
284
+ ...hostTlsOptions(options.servername || host),
285
+ ALPNProtocols: options.ALPNProtocols ?? ["http/1.1"],
286
+ // The origin handshake is the one that carries the client
287
+ // credentials, because they are the identity of the origin.
288
+ ...proxyTrustOptions(options),
289
+ ...trust,
290
+ }));
291
+ }
292
+ };
293
+ return agent;
294
+ }
@@ -57,10 +57,23 @@ function describeGentleAiInstallFailure(error) {
57
57
  if (process.env.GENTLE_PI_SKIP_GENTLE_AI_INSTALL === "1") {
58
58
  console.warn("GENTLE_PI_SKIP_GENTLE_AI_INSTALL=1: skipped package-local Gentle AI installation; native review operations will fail with package-local-binary-missing until gentle-pi is reinstalled.");
59
59
  } else {
60
+ // A live progress line only on a terminal: npm logs and CI output stay
61
+ // unchanged. Loaded lazily and optional, so it can never break the install.
62
+ let progress;
63
+ if (process.stderr.isTTY === true) {
64
+ try {
65
+ const { createDownloadProgress } = await import("./download-progress.mjs");
66
+ progress = createDownloadProgress({ label: `Downloading Gentle AI v${INSTALLER_VERSION}`, write: (text) => process.stderr.write(text), width: () => process.stderr.columns || 80 });
67
+ } catch {
68
+ progress = undefined;
69
+ }
70
+ }
60
71
  try {
61
- const result = await installGentleAi();
72
+ const result = await installGentleAi(progress === undefined ? {} : { onProgress: (state) => progress.update(state) });
73
+ progress?.done();
62
74
  console.log(`Gentle AI v${INSTALLER_VERSION} ${result.installed ? "installed" : "integrity-verified"} at ${result.binaryPath}`);
63
75
  } catch (error) {
76
+ progress?.done();
64
77
  // The whole cause chain: the failing command's own output is the diagnosis.
65
78
  console.error(`gentle-pi could not install its package-local Gentle AI v${INSTALLER_VERSION} binary: ${describeGentleAiInstallFailure(error)}`);
66
79
  process.exitCode = 1;
@@ -22,10 +22,10 @@ export const requirements = Object.freeze({
22
22
  go: GENTLE_AI_WINDOWS_MINIMUM_GO_VERSION,
23
23
  });
24
24
 
25
- /** Pi version the installer installs next to gentle-pi, and the version an older
26
- * Pi is updated to (never below requirements.pi; the runner asserts it).
25
+ /** Legacy Pi pin retained for verified distribution and compatibility checks.
26
+ * Global installs resolve the latest stable Pi after consent instead.
27
27
  */
28
- export const PI_INSTALL_VERSION = "1.4.0";
28
+ export const PI_INSTALL_VERSION = "1.5.0";
29
29
 
30
30
  /** Runtime persisted under PNPM_HOME. Bootstrap-only Node: `pnpm runtime set
31
31
  * node <node> -g`, then `pnpm add -g npm@<npm> pnpm@<pnpm>`, or only npm when
@@ -206,7 +206,7 @@ export function planPreflight(inventory, { channel = "release" } = {}) {
206
206
  }
207
207
  record("node", classify(inventory.node, requirements.node), requirements.node);
208
208
  // An older Pi whose owner (pnpm or npm) is known is updated with that package
209
- // manager to PI_INSTALL_VERSION instead of blocking; the plan records the
209
+ // manager to the latest stable version instead of blocking; the plan records the
210
210
  // found version and owner the update must still match. An older Pi neither
211
211
  // owns (mise, Homebrew, a binary) is left as it is: the installer's Pi is
212
212
  // installed alongside, exactly as when Pi is absent.
@@ -327,7 +327,7 @@ export function planPreflight(inventory, { channel = "release" } = {}) {
327
327
  if (update || npmCurrent) {
328
328
  // Only an update builds: main, or a Windows release postinstall.
329
329
  if (update) acquireGo();
330
- if (updatePi) action("update-pi", "upgrade", "pi", PI_INSTALL_VERSION);
330
+ if (updatePi) action("update-pi", "upgrade", "pi", "latest");
331
331
  // A current npm Shell next to an older Pi neither manager owns gets the installer's Pi.
332
332
  if (!update && tools.pi.status === "needs-install") action("install-pi", "install-global", "pi", requirements.pi);
333
333
  if (update) {
@@ -369,7 +369,7 @@ export function planPreflight(inventory, { channel = "release" } = {}) {
369
369
  else if (pnpm) action("persist-pnpm", "install-global", "pnpm", persistencePins.pnpm);
370
370
  }
371
371
  if (installPi) action("install-pi", "install-global", "pi", requirements.pi);
372
- if (updatePi) action("update-pi", "upgrade", "pi", PI_INSTALL_VERSION);
372
+ if (updatePi) action("update-pi", "upgrade", "pi", "latest");
373
373
  if (missingShell) action("install-shell", "install-global", "shell", requirements.shell);
374
374
  // Global gentle-pi postinstall owns native provisioning when Shell is missing.
375
375
  // Otherwise the later runner must reuse that existing installer, not duplicate it.