gentle-pi 4.0.0 → 4.1.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 (398) hide show
  1. package/README.md +122 -8
  2. package/assets/agents/gentle-ai-explore.md +11 -4
  3. package/assets/agents/gentle-ai-verify.md +23 -4
  4. package/assets/agents/gentle-ai-worker.md +6 -6
  5. package/assets/install-wizard/index.html +47 -0
  6. package/assets/install-wizard/wizard.css +1279 -0
  7. package/assets/install-wizard/wizard.js +951 -0
  8. package/assets/orchestrator-delegation.md +70 -163
  9. package/assets/orchestrator-memory.md +11 -4
  10. package/assets/orchestrator-prompts.md +48 -0
  11. package/assets/orchestrator-tracking.md +53 -0
  12. package/assets/orchestrator-verification.md +28 -0
  13. package/assets/orchestrator-writer.md +38 -0
  14. package/assets/orchestrator.md +29 -25
  15. package/assets/sounds/LICENSE.md +52 -0
  16. package/assets/sounds/attention.wav +0 -0
  17. package/assets/sounds/error.wav +0 -0
  18. package/assets/sounds/success.wav +0 -0
  19. package/bin/engram-guard +9 -0
  20. package/bin/gentle-shell-install.mjs +302 -0
  21. package/bin/gentle-shell.mjs +703 -22
  22. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +7 -7
  23. package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/bundle/manifest.json +2 -2
  24. package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/bundle/orchestration/pi.md +16 -4
  25. package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/generated/provider-capabilities.baseline.json +2 -2
  26. package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/generated/provider-roles.baseline.json +1 -1
  27. package/docs/bundled-install.md +397 -0
  28. package/docs/delegated-verification.md +3 -5
  29. package/docs/gentle-agents-activity.md +513 -0
  30. package/docs/gentle-shell-uninstall.md +136 -0
  31. package/docs/gentle-shell.md +81 -31
  32. package/docs/install-wizard.md +2040 -0
  33. package/docs/native-authority-architecture.md +1 -1
  34. package/docs/permission-modes.md +82 -0
  35. package/docs/prompt-history.md +1 -1
  36. package/docs/readme-reference.md +267 -40
  37. package/docs/render-cache-performance.md +28 -0
  38. package/docs/sound-notifications-proposal.md +191 -0
  39. package/docs/sound-notifications.md +114 -0
  40. package/docs/yolo-mode.md +9 -9
  41. package/extensions/child-context.ts +11 -2
  42. package/extensions/child-safety.ts +4 -2
  43. package/extensions/codegraph-tools.ts +18 -5
  44. package/extensions/gentle-agents.ts +688 -88
  45. package/extensions/gentle-ai.ts +886 -238
  46. package/extensions/gentle-herdr-activity.ts +81 -0
  47. package/extensions/gentle-notifications.ts +104 -0
  48. package/extensions/gentle-shell.ts +265 -69
  49. package/extensions/gentle-todo.ts +108 -13
  50. package/extensions/history/index.ts +11 -6
  51. package/extensions/pi-pretty.ts +39 -3
  52. package/extensions/quiet-tools.ts +91 -21
  53. package/extensions/skill-registry.ts +175 -46
  54. package/extensions/startup-banner.ts +11 -2
  55. package/lib/agent-home.ts +10 -1
  56. package/lib/agent-model-resolution.ts +80 -0
  57. package/lib/agent-profiles.ts +13 -3
  58. package/lib/agents-completion-delivery.ts +11 -3
  59. package/lib/agents-messaging.ts +1 -1
  60. package/lib/agents-protocol.ts +40 -1
  61. package/lib/agents-runner.ts +90 -15
  62. package/lib/auto-permission-classifier.ts +280 -0
  63. package/lib/auto-permission-runtime.ts +268 -0
  64. package/lib/background-jobs-tools.ts +202 -0
  65. package/lib/background-jobs.ts +253 -0
  66. package/lib/background-monitor.ts +154 -0
  67. package/lib/bounded-writer-admission.ts +83 -10
  68. package/lib/builtin-codemode-optout.ts +166 -0
  69. package/lib/card-content-policy.ts +85 -0
  70. package/lib/child-package-injection.ts +62 -0
  71. package/lib/codemode-renderer.ts +14 -4
  72. package/lib/command-palette-catalog.ts +3 -2
  73. package/lib/context-threshold.ts +26 -0
  74. package/lib/gentle-ai-binary.ts +109 -4
  75. package/lib/gentle-shell-bundled.ts +517 -0
  76. package/lib/gentle-shell-launcher.ts +74 -23
  77. package/lib/gentle-shell-startup-flow.ts +54 -0
  78. package/lib/gentle-shell-startup-update.ts +92 -0
  79. package/lib/gentle-shell-uninstall.ts +840 -0
  80. package/lib/gentle-shell-update-panel.ts +231 -0
  81. package/lib/herdr-activity.ts +183 -0
  82. package/lib/inprocess-reviewer.ts +3 -0
  83. package/lib/jobs-sidebar-state.ts +20 -0
  84. package/lib/jobs-view.ts +161 -0
  85. package/lib/model-price-ratio.ts +83 -0
  86. package/lib/nan-provider.ts +33 -11
  87. package/lib/native-review-cli.ts +194 -73
  88. package/lib/notification-audio-native.ts +162 -0
  89. package/lib/notification-audio-windows.ts +399 -0
  90. package/lib/notification-audio.ts +332 -0
  91. package/lib/notification-customize.ts +241 -0
  92. package/lib/notification-events.ts +113 -0
  93. package/lib/notification-policy.ts +148 -0
  94. package/lib/notification-pulse-client.ts +367 -0
  95. package/lib/notification-pulse-protocol.ts +305 -0
  96. package/lib/notification-pulse-stream.ts +213 -0
  97. package/lib/notification-pulse-worker.ts +66 -0
  98. package/lib/notification-scheduler.ts +173 -0
  99. package/lib/notification-service.ts +202 -0
  100. package/lib/notification-ui.ts +87 -0
  101. package/lib/odd-phase.ts +1 -1
  102. package/lib/orchestrator-alias.ts +20 -0
  103. package/lib/orchestrator-catalog.ts +79 -0
  104. package/lib/orchestrator-consultation.ts +61 -0
  105. package/lib/orchestrator-discovery.ts +49 -0
  106. package/lib/orchestrator-helper-consent.ts +122 -0
  107. package/lib/orchestrator-helper.ts +167 -0
  108. package/lib/orchestrator-message-card.ts +105 -0
  109. package/lib/orchestrator-presence.ts +115 -14
  110. package/lib/orchestrator-scope.ts +80 -0
  111. package/lib/orchestrator-state.ts +107 -0
  112. package/lib/orchestrator-tool-card.ts +280 -0
  113. package/lib/orchestrator-work-search.ts +218 -0
  114. package/lib/orchestrator-work.ts +79 -0
  115. package/lib/permission-mode-policy.ts +59 -0
  116. package/lib/review-candidate-view-owner.ts +8 -6
  117. package/lib/review-candidate-view.ts +3 -2
  118. package/lib/review-compact-contract.ts +2 -2
  119. package/lib/review-host-relay.ts +7 -2
  120. package/lib/review-integration-v2.ts +100 -22
  121. package/lib/review-publication-gate.ts +1 -1
  122. package/lib/review-risk-assessment.ts +77 -51
  123. package/lib/review-sidebar-state.ts +2 -1
  124. package/lib/review-transaction.ts +72 -3
  125. package/lib/runtime-metrics-children.ts +1 -1
  126. package/lib/runtime-metrics-native.ts +3 -2
  127. package/lib/selection-engine.ts +18 -6
  128. package/lib/session-change-capture.ts +5 -4
  129. package/lib/session-changes.ts +27 -22
  130. package/lib/session-profile-binding.ts +83 -0
  131. package/lib/session-profile-freeze.ts +266 -0
  132. package/lib/session-worktree-registry.ts +74 -8
  133. package/lib/shell-bar.ts +41 -11
  134. package/lib/shell-changes-view.ts +40 -13
  135. package/lib/shell-changes.ts +86 -71
  136. package/lib/shell-sidebar-layout.ts +5 -1
  137. package/lib/shell-todo.ts +62 -19
  138. package/lib/shell-usage.ts +4 -3
  139. package/lib/status-timing-diagnostics.ts +201 -0
  140. package/lib/telemetry-trigger.ts +3 -1
  141. package/lib/vim-editor-adapter.ts +7 -3
  142. package/lib/visual-customization-policy.ts +20 -9
  143. package/lib/visual-customize-view.ts +171 -20
  144. package/lib/writer-surfaces.ts +162 -0
  145. package/lib/yolo-session-policy.ts +198 -121
  146. package/package.json +1 -1
  147. package/runtime/child-package-injection.mjs +63 -0
  148. package/runtime/gentle-ai-binary.mjs +109 -4
  149. package/runtime/gentle-shell-bundled.mjs +518 -0
  150. package/runtime/gentle-shell-launcher.mjs +73 -22
  151. package/runtime/gentle-shell-startup-flow.mjs +55 -0
  152. package/runtime/gentle-shell-startup-update.mjs +93 -0
  153. package/runtime/gentle-shell-uninstall.mjs +841 -0
  154. package/runtime/gentle-shell-update-panel.mjs +232 -0
  155. package/runtime/native-review-cli.mjs +191 -70
  156. package/runtime/review-integration-v2.mjs +100 -22
  157. package/runtime/review-risk-assessment.mjs +77 -51
  158. package/runtime/status-timing-diagnostics.mjs +202 -0
  159. package/runtime/telemetry-trigger.mjs +3 -1
  160. package/scripts/bootstrap.cmd +255 -0
  161. package/scripts/bootstrap.sh +168 -0
  162. package/scripts/build-distribution.mjs +157 -0
  163. package/scripts/build-installer-bundles.mjs +136 -0
  164. package/scripts/build-runtime-modules.mjs +7 -0
  165. package/scripts/bundled-install.mjs +1308 -0
  166. package/scripts/bundled-wizard.mjs +399 -0
  167. package/scripts/check-types.mjs +4 -6
  168. package/scripts/gentle-ai-installer.mjs +79 -32
  169. package/scripts/install-gentle-ai.mjs +48 -1
  170. package/scripts/install-tui-mode-setting.mjs +10 -1
  171. package/scripts/install-wizard-preview.mjs +154 -0
  172. package/scripts/installer-downloads.mjs +648 -0
  173. package/scripts/installer-preflight.mjs +387 -0
  174. package/scripts/installer-probes.mjs +564 -0
  175. package/scripts/installer-runner.mjs +1102 -0
  176. package/scripts/installer-server.mjs +881 -0
  177. package/scripts/installer-windows-artifacts.json +15 -0
  178. package/scripts/installer-windows.mjs +752 -0
  179. package/scripts/main-channel.mjs +452 -0
  180. package/scripts/npm-pack-result.mjs +31 -0
  181. package/scripts/render-cache-performance-worker.mjs +205 -0
  182. package/scripts/render-cache-performance.mjs +115 -0
  183. package/scripts/run-test-suite.mjs +22 -8
  184. package/scripts/test-installer-acceptance.sh +161 -0
  185. package/scripts/test-packed-runner.mjs +23 -5
  186. package/scripts/types-baseline.json +2 -92
  187. package/scripts/verify-package-files.mjs +82 -18
  188. package/skills/gentle-ai/SKILL.md +12 -11
  189. package/tests/agent-home.test.ts +56 -3
  190. package/tests/agent-model-resolution.test.ts +113 -0
  191. package/tests/agent-profiles.test.ts +12 -0
  192. package/tests/agent-risk-escalation.test.ts +123 -0
  193. package/tests/agents-completion-delivery.test.ts +17 -0
  194. package/tests/agents-protocol.test.ts +57 -0
  195. package/tests/agents-queries.test.ts +9 -9
  196. package/tests/agents-runner-process.test.ts +31 -0
  197. package/tests/agents-runner.test.ts +89 -4
  198. package/tests/auto-mode-invariants.test.ts +258 -0
  199. package/tests/auto-mode-sdk.test.ts +57 -0
  200. package/tests/auto-mode.test.ts +49 -0
  201. package/tests/auto-permission-classifier.test.ts +283 -0
  202. package/tests/auto-permission-runtime.test.ts +196 -0
  203. package/tests/background-cache-warming.test.ts +2 -1
  204. package/tests/background-jobs.test.ts +227 -0
  205. package/tests/background-monitor.test.ts +195 -0
  206. package/tests/background-subagents-default-mode.test.ts +28 -5
  207. package/tests/bounded-stop-contract.test.ts +85 -0
  208. package/tests/bounded-writer-admission.test.ts +52 -1
  209. package/tests/bridge-wake-lifecycle.test.ts +129 -0
  210. package/tests/bridge-wake-rendering.test.ts +56 -0
  211. package/tests/build-distribution.test.ts +269 -0
  212. package/tests/builtin-codemode-optout.test.ts +242 -0
  213. package/tests/bundled-install.test.ts +1319 -0
  214. package/tests/bundled-wizard.test.ts +505 -0
  215. package/tests/card-content-policy.test.ts +68 -0
  216. package/tests/card-style-policy.test.ts +34 -2
  217. package/tests/child-codegraph-bootstrap.test.ts +74 -0
  218. package/tests/child-package-entrypoints.test.ts +65 -0
  219. package/tests/child-package-injection.test.ts +74 -0
  220. package/tests/child-safety.test.ts +12 -0
  221. package/tests/child-web-package.test.ts +224 -0
  222. package/tests/codegraph-tools.test.ts +35 -0
  223. package/tests/codemode-rendering.test.ts +107 -2
  224. package/tests/command-palette.test.ts +5 -5
  225. package/tests/context-threshold.test.ts +31 -0
  226. package/tests/delegate-for-reason-contract.test.ts +327 -0
  227. package/tests/delegated-key-learnings-contract.test.ts +3 -2
  228. package/tests/devbinary/native-review-parity.devtest.ts +1 -1
  229. package/tests/devbinary/pi-host-relay.devtest.ts +173 -3
  230. package/tests/engram-safety.test.ts +288 -0
  231. package/tests/generic-agent-tools.test.ts +16 -1
  232. package/tests/gentle-agents.test.ts +1722 -59
  233. package/tests/gentle-ai-binary-isolation.test.ts +135 -0
  234. package/tests/gentle-ai-binary.test.ts +19 -2
  235. package/tests/gentle-ai-child-guards.test.ts +202 -0
  236. package/tests/gentle-ai-dev-binary-surfacing.test.ts +125 -15
  237. package/tests/gentle-ai-installer.test.ts +548 -58
  238. package/tests/gentle-ai-prompt-model-routing.test.ts +123 -0
  239. package/tests/gentle-ai-renderer.test.ts +6 -6
  240. package/tests/gentle-ai.test.ts +999 -31
  241. package/tests/gentle-herdr-activity.test.ts +100 -0
  242. package/tests/gentle-notifications.test.ts +427 -0
  243. package/tests/gentle-shell-bin.test.ts +249 -5
  244. package/tests/gentle-shell-bundled.test.ts +1002 -0
  245. package/tests/gentle-shell-launcher.test.ts +234 -13
  246. package/tests/gentle-shell-startup-flow.test.ts +75 -0
  247. package/tests/gentle-shell-startup-update.test.ts +85 -0
  248. package/tests/gentle-shell-uninstall.test.ts +978 -0
  249. package/tests/gentle-shell-update-panel.test.ts +158 -0
  250. package/tests/gentle-shell.test.ts +541 -96
  251. package/tests/gentle-todo.test.ts +253 -2
  252. package/tests/herdr-activity.test.ts +243 -0
  253. package/tests/history-agent-home.test.ts +81 -0
  254. package/tests/history-child-guard.test.ts +70 -0
  255. package/tests/inprocess-reviewer.test.ts +20 -0
  256. package/tests/install-gentle-ai-failure.test.ts +69 -0
  257. package/tests/install-tui-mode-setting.test.ts +15 -0
  258. package/tests/install-wizard.test.ts +1223 -0
  259. package/tests/installer-bundles.test.ts +122 -0
  260. package/tests/installer-posix-bootstrap.test.ts +1201 -0
  261. package/tests/installer-preflight.test.ts +750 -0
  262. package/tests/installer-probes.test.ts +1106 -0
  263. package/tests/installer-runner.test.ts +2158 -0
  264. package/tests/installer-server.test.ts +1567 -0
  265. package/tests/installer-windows-bootstrap.test.ts +2410 -0
  266. package/tests/jobs-view.test.ts +160 -0
  267. package/tests/main-channel-upgrade.test.ts +389 -0
  268. package/tests/main-channel.test.ts +344 -0
  269. package/tests/maintainer/provider-relay.maintest.ts +13 -12
  270. package/tests/model-price-ratio.test.ts +116 -0
  271. package/tests/model-profiles-preservation.test.ts +153 -0
  272. package/tests/model-routing-package.test.ts +10 -0
  273. package/tests/nan-provider-runtime.test.ts +156 -0
  274. package/tests/nan-provider.test.ts +28 -18
  275. package/tests/native-binary-gate.test.ts +2 -0
  276. package/tests/native-review-capability-contract.test.ts +7 -1
  277. package/tests/native-review-cli.test.ts +236 -1
  278. package/tests/native-review-consent.test.ts +2 -2
  279. package/tests/native-review-parity-runtime.test.ts +1 -1
  280. package/tests/native-review-parity.test.ts +12 -48
  281. package/tests/native-risk-evidence-parity.test.ts +21 -0
  282. package/tests/no-self-pause-contract.test.ts +87 -0
  283. package/tests/notification-audio-native.test.ts +281 -0
  284. package/tests/notification-audio-windows.test.ts +581 -0
  285. package/tests/notification-audio.test.ts +548 -0
  286. package/tests/notification-customize.test.ts +655 -0
  287. package/tests/notification-events.test.ts +115 -0
  288. package/tests/notification-policy.test.ts +201 -0
  289. package/tests/notification-pulse-client.test.ts +356 -0
  290. package/tests/notification-pulse-protocol.test.ts +213 -0
  291. package/tests/notification-pulse-stream.test.ts +320 -0
  292. package/tests/notification-scheduler.test.ts +258 -0
  293. package/tests/notification-ui.test.ts +157 -0
  294. package/tests/npm-pack-result.test.ts +41 -0
  295. package/tests/odd-integration.test.ts +14 -5
  296. package/tests/odd-routing-canonical-ratchet.test.ts +53 -12
  297. package/tests/odd-routing-contract.test.ts +80 -23
  298. package/tests/orchestrator-budget.test.ts +29 -6
  299. package/tests/orchestrator-catalog.test.ts +146 -0
  300. package/tests/orchestrator-consultation-sdk.test.ts +614 -0
  301. package/tests/orchestrator-consultation.test.ts +111 -0
  302. package/tests/orchestrator-discovery.test.ts +241 -0
  303. package/tests/orchestrator-helper-consent.test.ts +171 -0
  304. package/tests/orchestrator-helper.test.ts +297 -0
  305. package/tests/orchestrator-message-card.test.ts +190 -0
  306. package/tests/orchestrator-presence.test.ts +23 -0
  307. package/tests/orchestrator-rdd-ownership.test.ts +6 -5
  308. package/tests/orchestrator-scope.test.ts +107 -0
  309. package/tests/orchestrator-state.test.ts +114 -0
  310. package/tests/orchestrator-status-publication-contract.test.ts +34 -0
  311. package/tests/orchestrator-tool-card.test.ts +398 -0
  312. package/tests/orchestrator-work-search.test.ts +318 -0
  313. package/tests/orchestrator-work.test.ts +147 -0
  314. package/tests/package-manifest.test.ts +101 -17
  315. package/tests/packed-runner-owned-path.test.ts +35 -1
  316. package/tests/parallel-reason-contract.test.ts +21 -0
  317. package/tests/parallel-writer-admission.test.ts +210 -0
  318. package/tests/permission-mode-policy.test.ts +194 -0
  319. package/tests/persona-single-channel.test.ts +4 -12
  320. package/tests/pi-pretty.test.ts +56 -0
  321. package/tests/provider-defect-handoff.test.ts +4 -3
  322. package/tests/quiet-tool-rendering.test.ts +160 -3
  323. package/tests/rdd-aware-verification-contract.test.ts +29 -41
  324. package/tests/render-cache-performance.test.ts +48 -0
  325. package/tests/review-agent-end-preflight.test.ts +62 -10
  326. package/tests/review-candidate-view.test.ts +101 -12
  327. package/tests/review-contract-prompt.test.ts +33 -4
  328. package/tests/review-controller-native-recovery.test.ts +327 -17
  329. package/tests/review-controller-native-routing.test.ts +255 -1
  330. package/tests/review-controller-workspace-root.test.ts +43 -2
  331. package/tests/review-controller.test.ts +2 -2
  332. package/tests/review-correction-lifecycle.test.ts +2 -1
  333. package/tests/review-gate.test.ts +7 -4
  334. package/tests/review-graph-schema.test.ts +2 -2
  335. package/tests/review-host-relay-routing.test.ts +5 -3
  336. package/tests/review-host-relay.test.ts +49 -2
  337. package/tests/review-integration-v2-forward.test.ts +21 -1
  338. package/tests/review-json-arguments.test.ts +167 -0
  339. package/tests/review-last-event-closure.test.ts +157 -8
  340. package/tests/review-ledger-contract.test.ts +5 -4
  341. package/tests/review-policy-judgment-day.test.ts +1 -1
  342. package/tests/review-policy-ordinary.test.ts +2 -2
  343. package/tests/review-relay-transport-agent.test.ts +66 -1
  344. package/tests/review-risk-assessment.test.ts +109 -33
  345. package/tests/review-session-standing-permission-controller.test.ts +16 -17
  346. package/tests/review-session-standing-permission-ipc.test.ts +6 -5
  347. package/tests/review-test-fixtures.ts +7 -1
  348. package/tests/review-transaction.test.ts +18 -1
  349. package/tests/run-test-suite.test.ts +83 -5
  350. package/tests/runtime-harness.mjs +42 -15
  351. package/tests/runtime-metrics-extension.test.ts +1 -1
  352. package/tests/runtime-metrics-native.test.ts +31 -1
  353. package/tests/selection-engine.test.ts +30 -0
  354. package/tests/session-change-capture.test.ts +10 -10
  355. package/tests/session-changes-shell.test.ts +242 -48
  356. package/tests/session-changes.test.ts +17 -24
  357. package/tests/session-profile-binding.test.ts +163 -0
  358. package/tests/session-profile-freeze.test.ts +381 -0
  359. package/tests/session-subject-routing-contract.test.ts +34 -0
  360. package/tests/session-worktree-registry.test.ts +57 -2
  361. package/tests/shell-bar.test.ts +40 -0
  362. package/tests/shell-changes-view.test.ts +85 -34
  363. package/tests/shell-changes.test.ts +61 -62
  364. package/tests/shell-render-cache-runtime.test.ts +69 -0
  365. package/tests/shell-render-cache.test.ts +129 -0
  366. package/tests/shell-sidebar-layout.test.ts +27 -2
  367. package/tests/shell-todo.test.ts +120 -2
  368. package/tests/shell-usage-view.test.ts +1 -1
  369. package/tests/shell-usage.test.ts +35 -0
  370. package/tests/short-check-routing-contract.test.ts +49 -0
  371. package/tests/skill-registry-watcher.test.ts +119 -0
  372. package/tests/skill-registry.test.ts +311 -5
  373. package/tests/startup-banner.test.ts +117 -3
  374. package/tests/startup-home-repo.test.ts +170 -0
  375. package/tests/status-timing-diagnostics.test.ts +283 -0
  376. package/tests/support/orchestrator-modules.ts +19 -0
  377. package/tests/task-size-routing-contract.test.ts +241 -0
  378. package/tests/telemetry-trigger.test.ts +27 -1
  379. package/tests/test-strength-contract.test.ts +124 -0
  380. package/tests/verify-agent-contract.test.ts +90 -0
  381. package/tests/verify-first-launch-contract.test.ts +139 -0
  382. package/tests/verify-package-files.test.ts +56 -0
  383. package/tests/vim-editor-adapter.test.ts +7 -7
  384. package/tests/visual-customization-policy.test.ts +32 -3
  385. package/tests/visual-customize-view.test.ts +288 -10
  386. package/tests/writer-edit-surface-scope.test.ts +59 -2
  387. package/tests/writer-surfaces.test.ts +199 -0
  388. package/tests/yolo-customize.test.ts +18 -3
  389. package/tests/yolo-mode-runtime.test.ts +37 -10
  390. package/tests/yolo-mode.test.ts +32 -4
  391. package/tests/yolo-session-policy.test.ts +1 -1
  392. /package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/bundle/README.md +0 -0
  393. /package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/bundle/schemas/lens.schema.json +0 -0
  394. /package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/bundle/schemas/refuter.schema.json +0 -0
  395. /package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  396. /package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/bundle/vectors/lens.json +0 -0
  397. /package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/bundle/vectors/refuter.json +0 -0
  398. /package/contracts/review-provider-contract-mirror/{v1.2.0 → v1.3.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -1,95 +1,5 @@
1
1
  {
2
2
  "note": "Recorded TypeScript diagnostics. Regenerate with `node scripts/check-types.mjs --update` after fixing or deliberately accepting diagnostics. This file may only shrink without a review decision.",
3
- "total": 200,
4
- "byFileAndCode": {
5
- "extensions/codegraph-tools.ts TS2339": 1,
6
- "extensions/codegraph-tools.ts TS2345": 1,
7
- "extensions/gentle-agents.ts TS2322": 3,
8
- "extensions/gentle-ai.ts TS2322": 5,
9
- "extensions/gentle-ai.ts TS2339": 11,
10
- "extensions/gentle-ai.ts TS2345": 15,
11
- "extensions/gentle-ai.ts TS2365": 1,
12
- "extensions/gentle-ai.ts TS2488": 2,
13
- "extensions/gentle-ai.ts TS2554": 1,
14
- "extensions/gentle-ai.ts TS2740": 1,
15
- "extensions/gentle-shell.ts TS2556": 1,
16
- "extensions/quiet-tools.ts TS2339": 1,
17
- "extensions/quiet-tools.ts TS2352": 2,
18
- "lib/agents-messaging.ts TS2322": 1,
19
- "lib/native-review-cli.ts TS2304": 6,
20
- "lib/native-review-cli.ts TS2339": 1,
21
- "lib/native-review-cli.ts TS2345": 1,
22
- "lib/review-candidate-view.ts TS2353": 2,
23
- "lib/review-compact-contract.ts TS2322": 2,
24
- "lib/review-compact-contract.ts TS2365": 1,
25
- "lib/review-integration-v2.ts TS2322": 2,
26
- "lib/review-integration-v2.ts TS2352": 2,
27
- "lib/review-publication-gate.ts TS2365": 2,
28
- "lib/review-transaction.ts TS2322": 1,
29
- "lib/review-transaction.ts TS2345": 1,
30
- "lib/runtime-metrics-children.ts TS2345": 2,
31
- "lib/sdd-preflight.ts TS2352": 1,
32
- "lib/sdd-preflight.ts TS2365": 1,
33
- "lib/shell-sidebar-layout.ts TS2341": 1,
34
- "tests/agents-queries.test.ts TS2322": 1,
35
- "tests/agents-queries.test.ts TS2345": 3,
36
- "tests/agents-runner-process.test.ts TS2322": 1,
37
- "tests/devbinary/native-review-parity.devtest.ts TS2339": 1,
38
- "tests/devbinary/pi-host-relay.devtest.ts TS2339": 3,
39
- "tests/gentle-ai-binary.test.ts TS2339": 2,
40
- "tests/gentle-ai-installer.test.ts TS2339": 7,
41
- "tests/gentle-ai-installer.test.ts TS2556": 1,
42
- "tests/gentle-ai-renderer.test.ts TS2345": 6,
43
- "tests/gentle-ai.test.ts TS2339": 1,
44
- "tests/gentle-ai.test.ts TS2352": 8,
45
- "tests/gentle-ai.test.ts TS2353": 1,
46
- "tests/gentle-shell.test.ts TS2352": 1,
47
- "tests/gentle-shell.test.ts TS2540": 1,
48
- "tests/gentle-shell.test.ts TS2554": 1,
49
- "tests/maintainer/provider-relay.maintest.ts TS2339": 17,
50
- "tests/maintainer/provider-relay.maintest.ts TS2345": 1,
51
- "tests/maintainer/provider-relay.maintest.ts TS2540": 2,
52
- "tests/native-binary-gate.test.ts TS2339": 2,
53
- "tests/native-review-consent.test.ts TS2554": 1,
54
- "tests/native-review-parity-runtime.test.ts TS2339": 1,
55
- "tests/quiet-tool-rendering.test.ts TS2339": 1,
56
- "tests/quiet-tool-rendering.test.ts TS2345": 1,
57
- "tests/review-agent-end-preflight.test.ts TS2339": 2,
58
- "tests/review-agent-end-preflight.test.ts TS2345": 1,
59
- "tests/review-candidate-view.test.ts TS2353": 4,
60
- "tests/review-candidate-view.test.ts TS2540": 2,
61
- "tests/review-candidate-view.test.ts TS2554": 2,
62
- "tests/review-controller-native-recovery.test.ts TS2345": 1,
63
- "tests/review-controller-native-routing.test.ts TS2339": 2,
64
- "tests/review-controller-workspace-root.test.ts TS2322": 2,
65
- "tests/review-correction-lifecycle.test.ts TS2339": 4,
66
- "tests/review-gate.test.ts TS2322": 5,
67
- "tests/review-gate.test.ts TS2345": 4,
68
- "tests/review-gate.test.ts TS2740": 1,
69
- "tests/review-graph-schema.test.ts TS2352": 2,
70
- "tests/review-host-relay-routing.test.ts TS2345": 1,
71
- "tests/review-host-relay-routing.test.ts TS2739": 1,
72
- "tests/review-integration-v2-forward.test.ts TS2322": 1,
73
- "tests/review-last-event-closure.test.ts TS2322": 1,
74
- "tests/review-policy-judgment-day.test.ts TS2345": 1,
75
- "tests/review-policy-ordinary.test.ts TS2345": 1,
76
- "tests/review-policy-ordinary.test.ts TS2554": 1,
77
- "tests/review-risk-assessment.test.ts TS2345": 1,
78
- "tests/review-risk-assessment.test.ts TS2352": 1,
79
- "tests/review-session-standing-permission-controller.test.ts TS2339": 1,
80
- "tests/review-session-standing-permission-controller.test.ts TS2345": 1,
81
- "tests/review-session-standing-permission-controller.test.ts TS2352": 1,
82
- "tests/review-session-standing-permission-ipc.test.ts TS2322": 4,
83
- "tests/review-test-fixtures.ts TS2739": 1,
84
- "tests/review-transaction.test.ts TS2339": 1,
85
- "tests/runtime-metrics-extension.test.ts TS2345": 1,
86
- "tests/sdd-preflight.test.ts TS2352": 1,
87
- "tests/sdd-preflight.test.ts TS2554": 2,
88
- "tests/sdd-research-live.test.ts TS2322": 1,
89
- "tests/shell-sidebar-layout.test.ts TS2339": 1,
90
- "tests/shell-sidebar-layout.test.ts TS2345": 1,
91
- "tests/shell-usage-view.test.ts TS2322": 1,
92
- "tests/skill-registry.test.ts TS2345": 5,
93
- "tests/writer-edit-surface-scope.test.ts TS2352": 1
94
- }
3
+ "total": 0,
4
+ "byFileAndCode": {}
95
5
  }
@@ -7,10 +7,56 @@ import { fileURLToPath, pathToFileURL } from "node:url";
7
7
 
8
8
  const root = join(fileURLToPath(new URL("..", import.meta.url)));
9
9
 
10
- const requiredPaths = [
10
+ // Browser installation wizard: bootstrap scripts, entry, host and static assets.
11
+ export const installerPaths = Object.freeze([
12
+ "bin/gentle-shell-install.mjs",
13
+ "scripts/installer-server.mjs",
14
+ "scripts/installer-runner.mjs",
15
+ "scripts/installer-preflight.mjs",
16
+ "scripts/installer-probes.mjs",
17
+ "scripts/installer-downloads.mjs",
18
+ "scripts/main-channel.mjs",
19
+ "scripts/installer-windows.mjs",
20
+ "scripts/installer-windows-artifacts.json",
21
+ "scripts/bundled-wizard.mjs",
22
+ "scripts/bundled-install.mjs",
23
+ "scripts/bootstrap.sh",
24
+ "scripts/bootstrap.cmd",
25
+ "assets/install-wizard/index.html",
26
+ "assets/install-wizard/wizard.js",
27
+ "assets/install-wizard/wizard.css",
28
+ ]);
29
+
30
+ export const requiredPaths = [
11
31
  "bin/gentle-shell.mjs",
32
+ ...installerPaths,
33
+ "extensions/gentle-notifications.ts",
34
+ "lib/notification-audio.ts",
35
+ "lib/notification-audio-native.ts",
36
+ "lib/notification-audio-windows.ts",
37
+ "lib/notification-pulse-protocol.ts",
38
+ "lib/notification-pulse-client.ts",
39
+ "lib/notification-pulse-stream.ts",
40
+ "lib/notification-pulse-worker.ts",
41
+ "lib/notification-customize.ts",
42
+ "lib/notification-events.ts",
43
+ "lib/notification-policy.ts",
44
+ "lib/notification-scheduler.ts",
45
+ "lib/notification-service.ts",
46
+ "lib/notification-ui.ts",
47
+ "assets/sounds/success.wav",
48
+ "assets/sounds/error.wav",
49
+ "assets/sounds/attention.wav",
50
+ "assets/sounds/LICENSE.md",
51
+ "docs/sound-notifications.md",
52
+ "docs/sound-notifications-proposal.md",
53
+ "scripts/npm-pack-result.mjs",
12
54
  "assets/orchestrator.md",
13
55
  "assets/orchestrator-delegation.md",
56
+ "assets/orchestrator-tracking.md",
57
+ "assets/orchestrator-verification.md",
58
+ "assets/orchestrator-writer.md",
59
+ "assets/orchestrator-prompts.md",
14
60
  "assets/orchestrator-memory.md",
15
61
  "assets/orchestrator-skills.md",
16
62
  "assets/agents/gentle-ai-explore.md",
@@ -36,20 +82,33 @@ const requiredPaths = [
36
82
  "extensions/gentle-ai.ts",
37
83
  "extensions/resume-hint.ts",
38
84
  "extensions/skill-registry.ts",
85
+ "lib/child-package-injection.ts",
39
86
  "lib/gentle-ai-binary.ts",
40
87
  "lib/gentle-shell-launcher.ts",
88
+ "lib/gentle-shell-bundled.ts",
89
+ "lib/gentle-shell-startup-update.ts",
90
+ "lib/gentle-shell-update-panel.ts",
91
+ "lib/gentle-shell-startup-flow.ts",
41
92
  "lib/gentle-shell-resume-hint.ts",
42
93
  "lib/native-review-cli.ts",
94
+ "lib/status-timing-diagnostics.ts",
43
95
  "lib/provider-contract-bundle.ts",
44
96
  "lib/review-host-relay.ts",
45
97
  "lib/review-integration-v2.ts",
46
98
  "lib/review-relay-contract.ts",
47
99
  "lib/agent-assets.ts",
48
100
  "lib/telemetry-trigger.ts",
101
+ "runtime/child-package-injection.mjs",
49
102
  "runtime/gentle-ai-binary.mjs",
50
103
  "runtime/gentle-shell-launcher.mjs",
104
+ "runtime/gentle-shell-bundled.mjs",
105
+ "runtime/gentle-shell-startup-update.mjs",
106
+ "runtime/gentle-shell-update-panel.mjs",
107
+ "runtime/gentle-shell-startup-flow.mjs",
51
108
  "runtime/gentle-shell-resume-hint.mjs",
109
+ "runtime/gentle-shell-uninstall.mjs",
52
110
  "runtime/native-review-cli.mjs",
111
+ "runtime/status-timing-diagnostics.mjs",
53
112
  "runtime/review-integration-v2.mjs",
54
113
  "runtime/review-risk-assessment.mjs",
55
114
  "runtime/review-relay-contract.mjs",
@@ -72,17 +131,17 @@ const requiredPaths = [
72
131
  // exact bytes are pinned by the lock-driven scripts/check-provider-contract.mjs
73
132
  // drift check, which runs in the same pnpm test flow.
74
133
  "contracts/review-provider-contract-mirror/provider-contract.lock.json",
75
- "contracts/review-provider-contract-mirror/v1.2.0/bundle/README.md",
76
- "contracts/review-provider-contract-mirror/v1.2.0/bundle/manifest.json",
77
- "contracts/review-provider-contract-mirror/v1.2.0/bundle/orchestration/pi.md",
78
- "contracts/review-provider-contract-mirror/v1.2.0/bundle/schemas/lens.schema.json",
79
- "contracts/review-provider-contract-mirror/v1.2.0/bundle/schemas/refuter.schema.json",
80
- "contracts/review-provider-contract-mirror/v1.2.0/bundle/schemas/targeted-validator.schema.json",
81
- "contracts/review-provider-contract-mirror/v1.2.0/bundle/vectors/lens.json",
82
- "contracts/review-provider-contract-mirror/v1.2.0/bundle/vectors/refuter.json",
83
- "contracts/review-provider-contract-mirror/v1.2.0/bundle/vectors/targeted-validator.json",
84
- "contracts/review-provider-contract-mirror/v1.2.0/generated/provider-capabilities.baseline.json",
85
- "contracts/review-provider-contract-mirror/v1.2.0/generated/provider-roles.baseline.json",
134
+ "contracts/review-provider-contract-mirror/v1.3.0/bundle/README.md",
135
+ "contracts/review-provider-contract-mirror/v1.3.0/bundle/manifest.json",
136
+ "contracts/review-provider-contract-mirror/v1.3.0/bundle/orchestration/pi.md",
137
+ "contracts/review-provider-contract-mirror/v1.3.0/bundle/schemas/lens.schema.json",
138
+ "contracts/review-provider-contract-mirror/v1.3.0/bundle/schemas/refuter.schema.json",
139
+ "contracts/review-provider-contract-mirror/v1.3.0/bundle/schemas/targeted-validator.schema.json",
140
+ "contracts/review-provider-contract-mirror/v1.3.0/bundle/vectors/lens.json",
141
+ "contracts/review-provider-contract-mirror/v1.3.0/bundle/vectors/refuter.json",
142
+ "contracts/review-provider-contract-mirror/v1.3.0/bundle/vectors/targeted-validator.json",
143
+ "contracts/review-provider-contract-mirror/v1.3.0/generated/provider-capabilities.baseline.json",
144
+ "contracts/review-provider-contract-mirror/v1.3.0/generated/provider-roles.baseline.json",
86
145
  "prompts/skill-creation.md",
87
146
  "skills/_shared/review-ledger-contract.md",
88
147
  "skills/branch-pr/SKILL.md",
@@ -173,6 +232,14 @@ const contractHashes = {
173
232
 
174
233
  requiredPaths.push(...Object.keys(contractHashes));
175
234
 
235
+ // Required package-relative paths that are missing or are not regular files.
236
+ export function missingRequiredPaths(packageRoot, paths) {
237
+ return paths.filter((relativePath) => {
238
+ const absolutePath = join(packageRoot, relativePath);
239
+ return !existsSync(absolutePath) || !statSync(absolutePath).isFile();
240
+ });
241
+ }
242
+
176
243
  function listFilesRecursively(directory) {
177
244
  return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
178
245
  const absolutePath = join(directory, entry.name);
@@ -287,10 +354,7 @@ async function main() {
287
354
  process.exit(1);
288
355
  }
289
356
 
290
- const missing = requiredPaths.filter((relativePath) => {
291
- const absolutePath = join(root, relativePath);
292
- return !existsSync(absolutePath) || !statSync(absolutePath).isFile();
293
- });
357
+ const missing = missingRequiredPaths(root, requiredPaths);
294
358
 
295
359
  if (missing.length > 0) {
296
360
  console.error("gentle-pi package is missing required Pi resources:");
@@ -331,7 +395,7 @@ async function main() {
331
395
  });
332
396
 
333
397
  if (driftedContracts.length > 0) {
334
- console.error("gentle-pi packaged review-integration/v1 and review-integration/v2 contract bytes drifted from the pinned v4.0.0 runtime's vendored Gentle AI contract artifacts:");
398
+ console.error("gentle-pi packaged review-integration/v1 and review-integration/v2 contract bytes drifted from the pinned v4.1.1 runtime's vendored Gentle AI contract artifacts:");
335
399
  for (const drift of driftedContracts) console.error(`- ${drift.relativePath}: expected ${drift.expected}, got ${drift.actual}`);
336
400
  process.exit(1);
337
401
  }
@@ -376,7 +440,7 @@ async function main() {
376
440
  process.exit(1);
377
441
  }
378
442
 
379
- console.log(`gentle-pi package resource check passed (${requiredPaths.length} files; ${Object.keys(contractHashes).length} exact byte-pinned contract artifacts for the v4.0.0 runtime).`);
443
+ console.log(`gentle-pi package resource check passed (${requiredPaths.length} files; ${Object.keys(contractHashes).length} exact byte-pinned contract artifacts for the v4.1.1 runtime).`);
380
444
  }
381
445
 
382
446
  const isMainModule = process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href;
@@ -14,11 +14,11 @@ When asked who or what you are, answer as el Gentleman: a Pi-specific coding-age
14
14
  ## Compact Rules
15
15
 
16
16
  - Clarify scope, constraints, acceptance criteria, and non-goals before implementation.
17
- - For substantial authorized ODD work, track the feature in its task document and mirror.
17
+ - Size every task by the orchestrator's Task Size section: understood, contained risk, and resumable from the original request plus `git diff`. Counts of files, commands, tests, or fixes never decide it. Track only large work in its task document and mirror.
18
18
  - For behavior changes with applicable runnable deterministic tests and a clear expected outcome, use test-first by default: observe RED, GREEN, relevant alternate cases, then REFACTOR and record evidence. Test presence alone does not establish applicability. For passive documentation, non-testable changes, an unavailable runner, or no meaningful RED, state why and run proportionate ordinary functional or structural verification. Never invent RED/GREEN, skip checks, or require a chat/TUI toggle.
19
19
  - Keep one parent session responsible for orchestration; child subagents should receive concrete phase work and must not spawn more subagents.
20
- - Parent-only delegation triggers apply after complexity appears: reading beyond the evidence budget, 2+ non-trivial files to write, tooling/worktree incidents, or a parent context past the context backstop.
21
- - Keep writes single-threaded unless the user explicitly approves isolated parallel worktrees.
20
+ - Parent-only delegation triggers fire one mechanism at a time: an open decision (ask), understanding beyond the evidence budget (explore), high risk (independent verifier), a large task (track), a writer reason (parallel units or context), tooling/worktree incidents, or a parent context past the context backstop.
21
+ - Parallel writers only with disjoint Allowed edit surfaces (runtime-enforced) or isolated worktrees.
22
22
  - Forecast review workload before large changes; ask before producing oversized or multi-area diffs.
23
23
  - Keep dangerous-command safety independent and authoritative.
24
24
  - Never claim persistent memory is available because of el Gentleman itself; memory is provided by separate packages/tools when active.
@@ -30,23 +30,24 @@ When asked who or what you are, answer as el Gentleman: a Pi-specific coding-age
30
30
  Use the smallest safe harness:
31
31
 
32
32
  ```text
33
- small + known context → inline direct
34
- unknown / context-heavy → simple delegation
35
- substantial authorized work → track ODD tasks and implement by work unit
33
+ small task → inline direct, focused test and suite inline
34
+ understanding is missing → explore, then re-evaluate
35
+ large authorized work → track ODD tasks and implement by work unit
36
36
  ```
37
37
 
38
- For bounded implementation with subagents:
38
+ For large implementation with subagents:
39
39
 
40
40
  ```text
41
- clarify → scout/context-builder when context-heavy → one worker → verify
41
+ clarify → scout/context-builder when context-heavy → inline, or a writer only for a reason → verify
42
42
  ```
43
43
 
44
44
  Hard delegation triggers:
45
45
 
46
- - **Evidence-budget rule**: read inline only when the evidence fits one parallel batch of at most 3 calls, ~10k tokens (grep and line ranges, never whole large files). Larger reading, more than ~5 sequential lookups, or a long session ahead means delegate one explorer that returns a handoff of at most ~2k tokens with `path:line` evidence. Never force delegation for a small targeted question; do not re-read what the handoff covered beyond one spot check.
47
- - **Multi-file write rule**: touching 2+ non-trivial files means use one worker.
46
+ - **Evidence-budget rule**: read inline only when the evidence fits one parallel batch of at most 3 calls, ~10k tokens (grep and line ranges, never whole large files). When understanding needs more reading or more than ~5 sequential lookups, delegate one explorer that returns a handoff of at most ~2k tokens with `path:line` evidence. Never force delegation for a small targeted question; do not re-read what the handoff covered beyond one spot check.
47
+ - **Writer rule**: a writer only for a reason (parallel units launched together, or context); size and file count never fire it.
48
+ - **Verification rule**: a high-risk change gets an independent verifier; otherwise the change's own focused test and suite run inline.
48
49
  - **Incident rule**: after wrong cwd, accidental worktree/repo mutation, merge recovery, confusing test command, or environment workaround, diagnose separately.
49
- - **Context backstop**: when the parent context passes ~150k tokens, pause and delegate the next bounded unit of work to a non-review subagent. Keep command output bounded (counts, `--stat`, `tail`) and send full suites and builds to a verifier.
50
+ - **Context backstop**: when the parent context passes ~150k tokens, pause and delegate the next bounded unit of work to a non-review subagent. Keep command output bounded (counts, `--stat`, `tail`).
50
51
 
51
52
  ## Review Lens Selection
52
53
 
@@ -1,9 +1,10 @@
1
1
  import assert from "node:assert/strict";
2
- import { mkdtempSync, rmSync } from "node:fs";
2
+ import { mkdtempSync, realpathSync, rmSync } from "node:fs";
3
3
  import { homedir, tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import test from "node:test";
6
- import { gentlePiConfigHome } from "../lib/agent-home.ts";
6
+ import { bundledGentlePiAgentHome, gentlePiConfigHome } from "../lib/agent-home.ts";
7
+ import { setBundledInstallForTesting } from "../lib/gentle-shell-bundled.ts";
7
8
 
8
9
  // The two Pi homes: `~/.pi/agent` holds Pi's own agent definitions and
9
10
  // `~/.pi/gentle-ai` holds everything the Gentle AI commands own. Both are resolved
@@ -15,7 +16,9 @@ function isolatedHome(t: test.TestContext): string {
15
16
  const home = mkdtempSync(join(tmpdir(), "gentle-pi-config-home-"));
16
17
  const previousHome = process.env.HOME;
17
18
  const previousUserProfile = process.env.USERPROFILE;
18
- // Isolation must cover POSIX and Windows, the way homedir() resolves each.
19
+ const previousConfigHome = process.env.GENTLE_PI_CONFIG_HOME;
20
+ // Clear the higher-priority config override as well as isolating both OS homes.
21
+ delete process.env.GENTLE_PI_CONFIG_HOME;
19
22
  process.env.HOME = home;
20
23
  process.env.USERPROFILE = home;
21
24
  t.after(() => {
@@ -23,6 +26,8 @@ function isolatedHome(t: test.TestContext): string {
23
26
  else process.env.HOME = previousHome;
24
27
  if (previousUserProfile === undefined) delete process.env.USERPROFILE;
25
28
  else process.env.USERPROFILE = previousUserProfile;
29
+ if (previousConfigHome === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
30
+ else process.env.GENTLE_PI_CONFIG_HOME = previousConfigHome;
26
31
  rmSync(home, { recursive: true, force: true });
27
32
  });
28
33
  return home;
@@ -41,6 +46,25 @@ test("gentlePiConfigHome honours GENTLE_PI_CONFIG_HOME and otherwise falls back
41
46
  );
42
47
  });
43
48
 
49
+ test("the isolated home restores defined and undefined config overrides", async (t) => {
50
+ const previousConfigHome = process.env.GENTLE_PI_CONFIG_HOME;
51
+ try {
52
+ for (const inherited of [undefined, "/synthetic-inherited-config"]) {
53
+ if (inherited === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
54
+ else process.env.GENTLE_PI_CONFIG_HOME = inherited;
55
+ await t.test(`inherited override: ${inherited === undefined ? "unset" : "set"}`, (child) => {
56
+ const home = isolatedHome(child);
57
+ assert.equal(process.env.GENTLE_PI_CONFIG_HOME, undefined);
58
+ assert.equal(gentlePiConfigHome(), join(home, ".pi", "gentle-ai"));
59
+ });
60
+ assert.equal(process.env.GENTLE_PI_CONFIG_HOME, inherited);
61
+ }
62
+ } finally {
63
+ if (previousConfigHome === undefined) delete process.env.GENTLE_PI_CONFIG_HOME;
64
+ else process.env.GENTLE_PI_CONFIG_HOME = previousConfigHome;
65
+ }
66
+ });
67
+
44
68
  test("the config home ignores the Pi agent-home overrides", (t) => {
45
69
  const home = isolatedHome(t);
46
70
  // PI_CODING_AGENT_DIR and GENTLE_PI_AGENT_HOME move Pi's agent directory only.
@@ -50,3 +74,32 @@ test("the config home ignores the Pi agent-home overrides", (t) => {
50
74
  join(home, ".pi", "gentle-ai"),
51
75
  );
52
76
  });
77
+
78
+ // S9: a bundled Gentle Shell keeps gentle-pi's config inside its prefix. It is
79
+ // derived from this package's bundled install and the launcher's
80
+ // GENTLE_SHELL_PREFIX, never exported (Gentle AI 4.0.0 reads
81
+ // GENTLE_PI_CONFIG_HOME as a parent folder). The testing overlay stands in for
82
+ // this package running from that install.
83
+ function bundledInstall(t: test.TestContext): string {
84
+ const prefix = realpathSync(mkdtempSync(join(tmpdir(), "gentle-pi-bundled-config-")));
85
+ setBundledInstallForTesting({ root: prefix });
86
+ t.after(() => {
87
+ setBundledInstallForTesting(undefined);
88
+ rmSync(prefix, { recursive: true, force: true });
89
+ });
90
+ return prefix;
91
+ }
92
+
93
+ test("a bundled install derives the config home inside its prefix and the agent home from Pi's", (t) => {
94
+ isolatedHome(t);
95
+ const prefix = bundledInstall(t);
96
+ const env = { GENTLE_SHELL_PREFIX: prefix, GENTLE_PI_CONFIG_HOME: "/home/ana/.pi/gentle-ai", PI_CODING_AGENT_DIR: "/agent" };
97
+ assert.equal(gentlePiConfigHome(env), join(prefix, "config", "gentle-ai"));
98
+ assert.equal(bundledGentlePiAgentHome(env), "/agent");
99
+ // Another prefix, or none, is not this install: everything stays as before.
100
+ for (const other of [{ GENTLE_PI_CONFIG_HOME: "/custom" }, { GENTLE_SHELL_PREFIX: join(prefix, "other"), GENTLE_PI_CONFIG_HOME: "/custom" }]) {
101
+ assert.equal(gentlePiConfigHome(other), "/custom");
102
+ assert.equal(bundledGentlePiAgentHome({ ...other, PI_CODING_AGENT_DIR: "/agent" }), undefined);
103
+ }
104
+ assert.equal(gentlePiConfigHome({ GENTLE_PI_CONFIG_HOME: "" }), join(homedir(), ".pi", "gentle-ai"));
105
+ });
@@ -0,0 +1,113 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join, resolve } from "node:path";
5
+ import test, { after } from "node:test";
6
+ import { resolveAgentHomeDirectory, resolveEffectiveAgentModel, resolvePinnedAgentProfile } from "../lib/agent-model-resolution.ts";
7
+ import type { AgentDefinition } from "../lib/agents-config.ts";
8
+
9
+ // gentle-shell#1731 S3/AC3: the subagent launch and the harness model-routing
10
+ // fact resolve the effective subagent model through one helper, so the fact
11
+ // can never disagree with the model a launch would actually use.
12
+
13
+ const root = mkdtempSync(join(tmpdir(), "gentle-pi-agent-model-resolution-"));
14
+ after(() => rmSync(root, { recursive: true, force: true }));
15
+
16
+ function fixture(name: string) {
17
+ const base = join(root, name);
18
+ const home = join(base, "home");
19
+ const agentHome = join(base, "agent-home");
20
+ const cwd = join(base, "project");
21
+ const commonDir = join(base, "git-common");
22
+ const configHome = join(base, "config");
23
+ for (const dir of [home, join(agentHome, "agents"), cwd, commonDir, configHome]) mkdirSync(dir, { recursive: true });
24
+ return {
25
+ roots: { cwd, home, agentHome },
26
+ cwd,
27
+ configHome,
28
+ resolveWorktree: () => ({ root: cwd, commonDir }),
29
+ writeAgent(agentName: string, model?: string) {
30
+ writeFileSync(join(agentHome, "agents", `${agentName}.md`), `---\nname: ${agentName}\ndescription: Test agent.\n${model === undefined ? "" : `model: ${model}\n`}---\nBody.\n`);
31
+ },
32
+ writeSubagents(config: Record<string, unknown>) {
33
+ writeFileSync(join(agentHome, "subagents.json"), JSON.stringify(config));
34
+ },
35
+ writePinnedProfile(profiles: Record<string, unknown>, pin: string) {
36
+ writeFileSync(join(configHome, "profiles.json"), JSON.stringify({ kind: "gentle-pi.agent_model_profiles", version: 1, profiles }));
37
+ mkdirSync(join(commonDir, "gentle-ai"), { recursive: true });
38
+ writeFileSync(join(commonDir, "gentle-ai", "profile-pin.json"), JSON.stringify({ kind: "gentle-pi.agent_model_profile_pin", version: 1, profile: pin }));
39
+ },
40
+ };
41
+ }
42
+
43
+ const orchestrator = { provider: "anthropic", id: "fable" };
44
+
45
+ test("the effective worker model comes from the global subagent profile", () => {
46
+ const f = fixture("global-profile");
47
+ f.writeAgent("gentle-ai-worker");
48
+ f.writeSubagents({ model_profiles: { "gentle-ai-worker": { model: "anthropic/opus" } } });
49
+ assert.deepEqual(
50
+ resolveEffectiveAgentModel("gentle-ai-worker", { roots: f.roots, pinCwd: f.cwd, configHome: f.configHome, resolveWorktree: f.resolveWorktree, fallback: orchestrator }),
51
+ { agent: "gentle-ai-worker", model: { provider: "anthropic", id: "opus" }, inherited: false },
52
+ );
53
+ });
54
+
55
+ test("a repository profile pin replaces global routing for the effective worker model", () => {
56
+ const f = fixture("pinned-profile");
57
+ f.writeAgent("gentle-ai-worker");
58
+ f.writeSubagents({ model_profiles: { "gentle-ai-worker": { model: "anthropic/opus" } } });
59
+ f.writePinnedProfile({ cheap: { "gentle-ai-worker": { model: "openai/mini" } } }, "cheap");
60
+ assert.deepEqual(
61
+ resolveEffectiveAgentModel("gentle-ai-worker", { roots: f.roots, pinCwd: f.cwd, configHome: f.configHome, resolveWorktree: f.resolveWorktree, fallback: orchestrator })?.model,
62
+ { provider: "openai", id: "mini" },
63
+ );
64
+ });
65
+
66
+ test("the agent definition model applies when no profile routes the agent", () => {
67
+ const f = fixture("definition-model");
68
+ f.writeAgent("gentle-ai-worker", "openai/defined");
69
+ assert.deepEqual(
70
+ resolveEffectiveAgentModel("gentle-ai-worker", { roots: f.roots, pinCwd: f.cwd, configHome: f.configHome, resolveWorktree: f.resolveWorktree, fallback: orchestrator })?.model,
71
+ { provider: "openai", id: "defined" },
72
+ );
73
+ });
74
+
75
+ test("an unrouted agent inherits the fallback session model", () => {
76
+ const f = fixture("inherit");
77
+ f.writeAgent("gentle-ai-worker");
78
+ assert.deepEqual(
79
+ resolveEffectiveAgentModel("gentle-ai-worker", { roots: f.roots, pinCwd: f.cwd, configHome: f.configHome, resolveWorktree: f.resolveWorktree, fallback: orchestrator }),
80
+ { agent: "gentle-ai-worker", model: orchestrator, inherited: true },
81
+ );
82
+ assert.deepEqual(
83
+ resolveEffectiveAgentModel("gentle-ai-worker", { roots: f.roots, pinCwd: f.cwd, configHome: f.configHome, resolveWorktree: f.resolveWorktree }),
84
+ { agent: "gentle-ai-worker", model: undefined, inherited: true },
85
+ );
86
+ });
87
+
88
+ test("an undiscovered agent resolves to undefined", () => {
89
+ const f = fixture("missing-agent");
90
+ assert.equal(
91
+ resolveEffectiveAgentModel("gentle-ai-worker", { roots: f.roots, pinCwd: f.cwd, configHome: f.configHome, resolveWorktree: f.resolveWorktree, fallback: orchestrator }),
92
+ undefined,
93
+ );
94
+ });
95
+
96
+ test("resolvePinnedAgentProfile returns the launch profile with its model and thinking", () => {
97
+ const f = fixture("launch-profile");
98
+ f.writePinnedProfile({ deep: { explore: { model: "openai/alpha", thinking: "minimal" } } }, "deep");
99
+ const agent: AgentDefinition = { name: "explore", description: "", filePath: "", scope: "global", instructions: "", model: undefined, thinking: undefined, mode: undefined, tools: [] };
100
+ const profile = resolvePinnedAgentProfile(agent, { roots: f.roots, pinCwd: f.cwd, configHome: f.configHome, resolveWorktree: f.resolveWorktree });
101
+ assert.deepEqual(profile.model, { provider: "openai", id: "alpha" });
102
+ assert.equal(profile.thinking, "minimal");
103
+ assert.equal(profile.source.model, "profile");
104
+ });
105
+
106
+ test("resolveAgentHomeDirectory follows the environment, expands tildes, and keeps explicit overrides literal", () => {
107
+ const home = "/home/tester";
108
+ assert.equal(resolveAgentHomeDirectory({ env: { GENTLE_PI_AGENT_HOME: "/opt/agents" }, home }), resolve("/opt/agents"));
109
+ assert.equal(resolveAgentHomeDirectory({ env: { PI_CODING_AGENT_DIR: "~/pi-agent" }, home }), resolve(join(home, "pi-agent")));
110
+ assert.equal(resolveAgentHomeDirectory({ env: { GENTLE_PI_AGENT_HOME: "~" }, home }), resolve(home));
111
+ assert.equal(resolveAgentHomeDirectory({ env: { GENTLE_PI_AGENT_HOME: "/ignored" }, home, homeOverridden: true }), resolve(join(home, ".pi", "agent")));
112
+ assert.equal(resolveAgentHomeDirectory({ env: {}, home, agentHome: "/explicit" }), resolve("/explicit"));
113
+ });
@@ -767,3 +767,15 @@ test("formatOrchestratorSelection separates set, inherit, and inherit-with-think
767
767
  "nan/glm5.3 · max",
768
768
  );
769
769
  });
770
+
771
+ test("buildProfileListItems marks the session-bound profile ahead of the pinned one", () => {
772
+ const file = createProfile(createProfile(emptyProfilesFile(), "work", { worker: { model: "zai/glm-4.7" } }), "personal", { solo: { model: "openai/o4-mini" } });
773
+ const items = buildProfileListItems(file, "work", "personal");
774
+ assert.equal(items.find((item) => item.id === "personal")?.label, "personal (session)");
775
+ assert.equal(items.find((item) => item.id === "work")?.label, "work (pinned)");
776
+ assert.equal(items.find((item) => item.id === "personal")?.description, "1 role");
777
+ const both = buildProfileListItems(file, "work", "work");
778
+ assert.equal(both.find((item) => item.id === "work")?.label, "work (session)", "the session marker outranks the pin marker on the same profile");
779
+ const unbound = buildProfileListItems(file, "work");
780
+ assert.equal(unbound.find((item) => item.id === "personal")?.label, "personal", "no session marker without a binding");
781
+ });