gentle-pi 4.9.0 → 5.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 (443) hide show
  1. package/README.md +2 -2
  2. package/assets/agents/gentle-ai-explore.md +3 -6
  3. package/assets/agents/gentle-ai-verify.md +2 -2
  4. package/assets/agents/gentle-ai-worker.md +9 -9
  5. package/assets/agents/jd-fix-agent.md +2 -2
  6. package/assets/agents/jd-judge-a.md +0 -1
  7. package/assets/agents/jd-judge-b.md +0 -1
  8. package/assets/migrations/agent-body-history.json +9 -0
  9. package/assets/orchestrator-delegation.md +1 -1
  10. package/assets/orchestrator-full-delegation.md +1 -1
  11. package/assets/orchestrator-maintenance.md +11 -0
  12. package/assets/orchestrator-quota-recovery.md +1 -1
  13. package/assets/orchestrator-skills.md +10 -0
  14. package/assets/orchestrator-tracking.md +2 -2
  15. package/assets/orchestrator-verification.md +10 -8
  16. package/assets/orchestrator.md +2 -2
  17. package/bin/gentle-shell.mjs +69 -17
  18. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +11 -10
  19. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/manifest.json +5 -5
  20. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/orchestration/pi.md +5 -3
  21. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/routing/pi.md +2 -2
  22. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/lens.schema.json +3 -3
  23. package/contracts/review-provider-contract-mirror/v1.7.0/bundle/vectors/lens.json +1 -0
  24. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/generated/provider-capabilities.baseline.json +3 -3
  25. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/generated/provider-roles.baseline.json +3 -3
  26. package/docs/bundled-install.md +2 -2
  27. package/docs/delegated-verification.md +10 -6
  28. package/docs/desktop-feed.md +15 -6
  29. package/docs/desktop-rpc.md +298 -30
  30. package/docs/gentle-shell-desktop.md +10 -3
  31. package/docs/gentle-shell.md +25 -19
  32. package/docs/install-wizard.md +7 -5
  33. package/docs/native-authority-architecture.md +3 -3
  34. package/docs/odd-preparation-continuity.md +2 -2
  35. package/docs/permission-modes.md +10 -2
  36. package/docs/readme-reference.md +53 -24
  37. package/docs/review-coordinator.md +4 -2
  38. package/docs/session-profile-format.md +33 -7
  39. package/docs/sound-notifications.md +1 -1
  40. package/docs/work-continuity.md +7 -7
  41. package/docs/yolo-mode.md +1 -1
  42. package/extensions/ask-user-choice.ts +2 -2
  43. package/extensions/ask-user-question.ts +1 -1
  44. package/extensions/child-context.ts +2 -11
  45. package/extensions/gentle-agents.ts +86 -30
  46. package/extensions/gentle-ai.ts +918 -632
  47. package/extensions/gentle-desktop-feed.ts +13 -3
  48. package/extensions/gentle-desktop-rpc.ts +51 -2
  49. package/extensions/gentle-fast.ts +9 -2
  50. package/extensions/gentle-music.ts +2 -0
  51. package/extensions/gentle-notifications.ts +12 -4
  52. package/extensions/gentle-shell.ts +157 -62
  53. package/extensions/gentle-star-prompt.ts +3 -0
  54. package/extensions/gentle-tps.ts +7 -0
  55. package/extensions/history/index.ts +1 -1
  56. package/extensions/quiet-tools.ts +13 -22
  57. package/extensions/skill-registry.ts +9 -1
  58. package/extensions/startup-banner.ts +8 -13
  59. package/herdr/mods/gentle-agents/snapshot.js +30 -23
  60. package/herdr/mods/gentle-chat/feed.js +6 -0
  61. package/herdr/mods/gentle-chat/main.js +76 -16
  62. package/herdr/mods/gentle-chat/session.js +13 -5
  63. package/herdr/mods/gentle-chat/snapshot.js +30 -23
  64. package/herdr/mods/gentle-chat/ui.js +7 -1
  65. package/herdr/mods/gentle-inspector/main.js +2 -0
  66. package/herdr/mods/gentle-inspector/snapshot.js +30 -23
  67. package/herdr/mods/gentle-palette/main.js +1 -1
  68. package/herdr/mods/gentle-palette/snapshot.js +30 -23
  69. package/herdr/mods/gentle-pane/snapshot.js +30 -23
  70. package/herdr/mods/gentle-sidebar/snapshot.js +30 -23
  71. package/herdr/mods/gentle-spaces/snapshot.js +30 -23
  72. package/herdr/mods/gentle-status/snapshot.js +30 -23
  73. package/herdr/mods/gentle-tabs/main.js +3 -2
  74. package/herdr/mods/gentle-tabs/new-tab.js +9 -0
  75. package/herdr/mods/gentle-tabs/snapshot.js +30 -23
  76. package/herdr/mods/gentle-tokens/snapshot.js +30 -23
  77. package/lib/agent-profiles.ts +50 -10
  78. package/lib/agents-config.ts +69 -5
  79. package/lib/agents-runner.ts +34 -1
  80. package/lib/auto-permission-runtime.ts +2 -1
  81. package/lib/background-jobs-tools.ts +24 -16
  82. package/lib/banner-config.ts +69 -0
  83. package/lib/child-session.ts +6 -0
  84. package/lib/claude-bridge-config.ts +41 -0
  85. package/lib/codex-turn-continuation.ts +40 -0
  86. package/lib/compaction-threshold.ts +46 -0
  87. package/lib/context-threshold.ts +5 -5
  88. package/lib/desktop-agent-definitions-service.ts +93 -0
  89. package/lib/desktop-auth-service.ts +102 -0
  90. package/lib/desktop-background-subagents-service.ts +155 -0
  91. package/lib/desktop-command-rpc.ts +71 -0
  92. package/lib/desktop-feed-sources.ts +44 -1
  93. package/lib/desktop-feed.ts +41 -29
  94. package/lib/desktop-rpc-agent-definitions.ts +119 -0
  95. package/lib/desktop-rpc-agents.ts +44 -3
  96. package/lib/desktop-rpc-auth.ts +103 -0
  97. package/lib/desktop-rpc-background-subagents.ts +126 -0
  98. package/lib/desktop-rpc-changes.ts +13 -4
  99. package/lib/desktop-rpc-config.ts +287 -13
  100. package/lib/desktop-rpc-profile-binding.ts +212 -0
  101. package/lib/desktop-rpc-profiles.ts +2 -0
  102. package/lib/desktop-rpc-stats.ts +16 -4
  103. package/lib/desktop-rpc-status.ts +103 -0
  104. package/lib/desktop-status-service.ts +86 -0
  105. package/lib/destructive-command-guard.ts +9 -185
  106. package/lib/exploration-budget.ts +3 -7
  107. package/lib/gentle-design.ts +23 -4
  108. package/lib/gentle-shell-desktop.ts +85 -0
  109. package/lib/gentle-shell-launcher.ts +120 -8
  110. package/lib/mcp-config.ts +214 -0
  111. package/lib/native-choice-list.ts +1 -1
  112. package/lib/native-fullscreen-interaction.ts +3 -0
  113. package/lib/native-pointer-region.ts +1 -1
  114. package/lib/native-review-cli.ts +213 -397
  115. package/lib/odd-phase-inference.ts +1 -1
  116. package/lib/orchestrator-mode-policy.ts +25 -12
  117. package/lib/path-consent-fence.ts +113 -0
  118. package/lib/persona-config.ts +77 -0
  119. package/lib/pi-settings.ts +157 -0
  120. package/lib/questionnaire/questionnaire-view.ts +1 -1
  121. package/lib/review-continuation-registry.ts +9 -26
  122. package/lib/review-coordinator.ts +13 -2
  123. package/lib/review-host-relay.ts +2 -35
  124. package/lib/review-integration-v2.ts +129 -180
  125. package/lib/review-object-store.ts +0 -57
  126. package/lib/review-repository.ts +0 -44
  127. package/lib/review-risk-assessment.ts +11 -36
  128. package/lib/review-start-context.ts +2 -1
  129. package/lib/review-transaction.ts +6 -6
  130. package/lib/sensitive-paths.ts +45 -0
  131. package/lib/session-profile-binding.ts +29 -0
  132. package/lib/session-profile-freeze.ts +11 -4
  133. package/lib/session-worktree-registry.ts +11 -5
  134. package/lib/shell-bar.ts +41 -18
  135. package/lib/shell-card.ts +27 -1
  136. package/lib/shell-changes-view.ts +6 -2
  137. package/lib/shell-changes.ts +94 -37
  138. package/lib/shell-git-worker.ts +158 -0
  139. package/lib/shell-idle-changes.ts +88 -0
  140. package/lib/shell-untracked-cache.ts +142 -0
  141. package/lib/shell-untracked-lines.ts +178 -0
  142. package/lib/stats-collector.ts +24 -0
  143. package/lib/tower-open.ts +8 -1
  144. package/lib/tps-policy.ts +85 -0
  145. package/lib/vim-editor-adapter.ts +9 -2
  146. package/lib/voice-artifacts.ts +8 -1
  147. package/lib/voice-install.ts +7 -3
  148. package/lib/yolo-session-policy.ts +2 -2
  149. package/package.json +1 -1
  150. package/runtime/gentle-shell-desktop.mjs +85 -0
  151. package/runtime/gentle-shell-launcher.mjs +120 -8
  152. package/runtime/native-review-cli.mjs +206 -390
  153. package/runtime/review-integration-v2.mjs +129 -180
  154. package/runtime/review-risk-assessment.mjs +11 -36
  155. package/runtime/sensitive-paths.mjs +46 -0
  156. package/runtime/tower-open.mjs +8 -1
  157. package/scripts/build-runtime-modules.mjs +2 -0
  158. package/scripts/gentle-ai-installer.mjs +13 -14
  159. package/scripts/installer-preflight.mjs +1 -1
  160. package/scripts/main-channel.mjs +47 -11
  161. package/scripts/pi-update.mjs +10 -4
  162. package/scripts/prepare-verifier.mjs +14 -4
  163. package/scripts/verify-package-files.mjs +45 -13
  164. package/skills/judgment-day/SKILL.md +1 -1
  165. package/skills/judgment-day/references/prompts-and-formats.md +1 -1
  166. package/skills/provider-defect-report/SKILL.md +1 -1
  167. package/skills/rdd-defect-workflow/SKILL.md +2 -2
  168. package/skills/skill-creator/SKILL.md +4 -4
  169. package/skills/skill-improver/SKILL.md +4 -4
  170. package/skills/skill-registry/SKILL.md +2 -2
  171. package/tests/agent-profiles-workflow.test.ts +102 -0
  172. package/tests/agent-risk-escalation.test.ts +15 -0
  173. package/tests/agents-config.test.ts +22 -2
  174. package/tests/agents-protocol.test.ts +1 -1
  175. package/tests/agents-runner.test.ts +94 -2
  176. package/tests/append-system-prompt-route.test.ts +16 -11
  177. package/tests/ask-user-choice.test.ts +19 -0
  178. package/tests/ask-user-question.test.ts +23 -4
  179. package/tests/auto-permission-runtime.test.ts +4 -4
  180. package/tests/bounded-stop-contract.test.ts +50 -62
  181. package/tests/built-web-guard.test.ts +32 -0
  182. package/tests/child-context-files.test.ts +6 -6
  183. package/tests/child-ui-extensions.test.ts +125 -0
  184. package/tests/child-web-package.test.ts +1 -1
  185. package/tests/codex-turn-continuation.test.ts +183 -0
  186. package/tests/committed-range-untracked-exclusion.test.ts +18 -0
  187. package/tests/controlled-engineering-editor.test.ts +192 -0
  188. package/tests/controlled-engineering-launch.test.ts +136 -0
  189. package/tests/controlled-engineering.test.ts +244 -0
  190. package/tests/delegate-for-reason-contract.test.ts +1 -1
  191. package/tests/delivery-b-rendered-surfaces.test.ts +1 -1
  192. package/tests/delivery-conflict-markers.test.ts +2 -3
  193. package/tests/desktop-feed-tool-summaries.test.ts +1 -1
  194. package/tests/desktop-feed-transcript.test.ts +17 -0
  195. package/tests/desktop-feed.test.ts +141 -7
  196. package/tests/desktop-liveness.test.ts +125 -0
  197. package/tests/desktop-persona.test.ts +17 -0
  198. package/tests/desktop-rpc-agent-definitions.test.ts +219 -0
  199. package/tests/desktop-rpc-agents.test.ts +113 -3
  200. package/tests/desktop-rpc-auth.test.ts +278 -0
  201. package/tests/desktop-rpc-background-subagents.test.ts +186 -0
  202. package/tests/desktop-rpc-changes.test.ts +81 -4
  203. package/tests/desktop-rpc-config-mcp-fidelity.test.ts +106 -0
  204. package/tests/desktop-rpc-config-readonly-stores.test.ts +458 -0
  205. package/tests/desktop-rpc-config-settings.test.ts +234 -0
  206. package/tests/desktop-rpc-config.test.ts +17 -3
  207. package/tests/desktop-rpc-design.test.ts +30 -1
  208. package/tests/desktop-rpc-jobs.test.ts +9 -1
  209. package/tests/desktop-rpc-permissions.test.ts +9 -1
  210. package/tests/desktop-rpc-profile-binding.test.ts +195 -0
  211. package/tests/desktop-rpc-review.test.ts +1 -1
  212. package/tests/desktop-rpc-session-snapshot-commands.test.ts +50 -0
  213. package/tests/desktop-rpc-session.test.ts +2 -2
  214. package/tests/desktop-rpc-stats.test.ts +42 -11
  215. package/tests/desktop-rpc-status.test.ts +195 -0
  216. package/tests/desktop-rpc-updates.test.ts +1 -1
  217. package/tests/desktop-rpc-usage.test.ts +9 -1
  218. package/tests/desktop-rpc.test.ts +2 -2
  219. package/tests/desktop-session-switch.test.ts +237 -0
  220. package/tests/desktop-target-session.test.ts +104 -0
  221. package/tests/destructive-command-guard.test.ts +187 -0
  222. package/tests/devbinary/pi-host-relay.devtest.ts +73 -9
  223. package/tests/exploration-budget.test.ts +2 -26
  224. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +15 -11
  225. package/tests/full-delegation-closure.test.ts +19 -9
  226. package/tests/generic-agent-tools.test.ts +3 -3
  227. package/tests/gentle-agents.test.ts +215 -10
  228. package/tests/gentle-ai-binary.test.ts +3 -3
  229. package/tests/gentle-ai-exploration-budget.test.ts +3 -2
  230. package/tests/gentle-ai-installer.test.ts +60 -59
  231. package/tests/gentle-ai.test.ts +30 -59
  232. package/tests/gentle-chat-read-failure.test.ts +74 -0
  233. package/tests/gentle-chat-session-read.test.ts +127 -0
  234. package/tests/gentle-design.test.ts +39 -0
  235. package/tests/gentle-notifications.test.ts +43 -5
  236. package/tests/gentle-shell-desktop.test.ts +108 -0
  237. package/tests/gentle-shell-launcher-auto-provision.test.ts +152 -0
  238. package/tests/gentle-shell-launcher-machine-output.test.ts +356 -0
  239. package/tests/gentle-shell-launcher-tower.test.ts +7 -1
  240. package/tests/gentle-shell.test.ts +163 -15
  241. package/tests/gentle-tps.test.ts +57 -0
  242. package/tests/independent-recovery-delivery.test.ts +15 -13
  243. package/tests/installer-preflight.test.ts +3 -2
  244. package/tests/installer-server.test.ts +3 -2
  245. package/tests/installer-windows-bootstrap.test.ts +6 -0
  246. package/tests/job-turn-end-texts.test.ts +57 -0
  247. package/tests/judgment-day-dispatch-diagnostics.test.ts +87 -0
  248. package/tests/lazy-module-contradictions-contract.test.ts +2 -3
  249. package/tests/main-channel-upgrade.test.ts +14 -7
  250. package/tests/main-channel.test.ts +78 -23
  251. package/tests/maintainer/desktop-rpc.maintest.ts +4 -4
  252. package/tests/native-fullscreen-interaction.test.ts +37 -1
  253. package/tests/native-review-capability-contract.test.ts +13 -1
  254. package/tests/native-review-cli-nonblocking-findings.test.ts +9 -84
  255. package/tests/native-review-cli.test.ts +199 -21
  256. package/tests/native-review-consent.test.ts +20 -3
  257. package/tests/native-review-start-escalation-real-binary.test.ts +42 -0
  258. package/tests/no-self-pause-contract.test.ts +8 -7
  259. package/tests/odd-phase-inference.test.ts +2 -2
  260. package/tests/odd-routing-canonical-ratchet.test.ts +1 -1
  261. package/tests/odd-routing-contract.test.ts +2 -2
  262. package/tests/orchestrator-budget.test.ts +7 -2
  263. package/tests/orchestrator-prompt-diet-contract.test.ts +5 -5
  264. package/tests/orchestrator-skills-inline-contract.test.ts +26 -0
  265. package/tests/package-manifest.test.ts +11 -16
  266. package/tests/packaged-agent-codemode.test.ts +79 -0
  267. package/tests/path-consent-fence.test.ts +326 -0
  268. package/tests/persona-config.test.ts +42 -0
  269. package/tests/pi-update-launcher.test.ts +1 -1
  270. package/tests/pi-update-source.test.ts +48 -2
  271. package/tests/primary-session-prompt.test.ts +9 -7
  272. package/tests/profile-fast-tier.test.ts +79 -4
  273. package/tests/progress-rule-contract.test.ts +54 -0
  274. package/tests/rdd-delivery-warning.test.ts +109 -0
  275. package/tests/review-actor-tool-deny.test.ts +1 -2
  276. package/tests/review-agent-end-preflight.test.ts +3 -1
  277. package/tests/review-assess-escalation-forwarding.test.ts +99 -0
  278. package/tests/review-authority-recovery-docs.test.ts +9 -12
  279. package/tests/review-continuation-registry.test.ts +24 -25
  280. package/tests/review-controller-native-recovery.test.ts +165 -178
  281. package/tests/review-controller-native-routing.test.ts +352 -27
  282. package/tests/review-coordinator-correction-gate.test.ts +5 -9
  283. package/tests/review-coordinator-runtime.test.ts +3 -2
  284. package/tests/review-coordinator.test.ts +14 -0
  285. package/tests/review-due-compaction.test.ts +1 -1
  286. package/tests/review-failure-facts.test.ts +2 -2
  287. package/tests/review-host-relay-restart-parity.test.ts +2 -52
  288. package/tests/review-host-relay-routing.test.ts +59 -298
  289. package/tests/review-host-relay.test.ts +0 -46
  290. package/tests/review-integration-nonblocking-findings.test.ts +3 -6
  291. package/tests/review-integration-v2-forward.test.ts +114 -234
  292. package/tests/review-integration-v2.test.ts +85 -39
  293. package/tests/review-json-arguments.test.ts +30 -9
  294. package/tests/review-legacy-check.test.ts +38 -0
  295. package/tests/review-object-store.test.ts +2 -57
  296. package/tests/review-one-call-findings.test.ts +1 -0
  297. package/tests/review-one-call.test.ts +56 -0
  298. package/tests/review-risk-assessment.test.ts +14 -43
  299. package/tests/review-run-escalate-forwarding.test.ts +59 -0
  300. package/tests/review-sidebar-state.test.ts +2 -1
  301. package/tests/review-untracked-inventory-replay.test.ts +181 -0
  302. package/tests/runtime-harness.mjs +30 -4
  303. package/tests/sensitive-path-tools.test.ts +210 -5
  304. package/tests/session-profile-binding-observers.test.ts +47 -0
  305. package/tests/session-profile-extension.test.ts +109 -11
  306. package/tests/session-profile-freeze.test.ts +49 -2
  307. package/tests/session-profile-v1-compat.test.ts +11 -3
  308. package/tests/session-worktree-registry.test.ts +23 -0
  309. package/tests/shell-bar.test.ts +21 -3
  310. package/tests/shell-changes-idle-start.test.ts +510 -0
  311. package/tests/shell-changes-untracked-bound.test.ts +230 -0
  312. package/tests/shell-changes-view.test.ts +8 -2
  313. package/tests/shell-changes.test.ts +134 -0
  314. package/tests/shell-git-runner-stall.test.ts +74 -0
  315. package/tests/shell-git-worker-fallback.test.ts +140 -0
  316. package/tests/shell-git-worker-lifetime.test.ts +91 -0
  317. package/tests/shell-render-cache-runtime.test.ts +256 -3
  318. package/tests/shell-sidebar-layout.test.ts +1 -1
  319. package/tests/shell-sidebar-scroll-benchmark.test.ts +14 -5
  320. package/tests/shell-untracked-cache.test.ts +213 -0
  321. package/tests/short-check-routing-contract.test.ts +11 -7
  322. package/tests/skill-references.test.ts +39 -0
  323. package/tests/skill-registry.test.ts +4 -4
  324. package/tests/startup-banner.test.ts +2 -1
  325. package/tests/status-timing-diagnostics.test.ts +2 -1
  326. package/tests/support/capabilities-v26.ts +22 -0
  327. package/tests/support/chat-ui.ts +39 -0
  328. package/tests/support/review-coordinator-runtime.ts +11 -2
  329. package/tests/support/status-v9.ts +8 -0
  330. package/tests/t7-recovery-preservation.test.ts +68 -0
  331. package/tests/tower-open.test.ts +24 -0
  332. package/tests/tower-pack.test.ts +48 -0
  333. package/tests/tps-policy.test.ts +96 -0
  334. package/tests/turn-end-rule-contract.test.ts +155 -0
  335. package/tests/turn-end-scope.test.ts +39 -0
  336. package/tests/verification-proportionality.test.ts +1 -1
  337. package/tests/verification-scoped-stop-contract.test.ts +1 -1
  338. package/tests/verification-tiers-contract.test.ts +4 -3
  339. package/tests/verifier-admission.test.ts +1 -1
  340. package/tests/verifier-preparation.test.ts +94 -1
  341. package/tests/verifier-settle-reminder.test.ts +1 -1
  342. package/tests/verify-first-launch-contract.test.ts +19 -7
  343. package/tests/vim-editor-adapter.test.ts +12 -2
  344. package/tests/voice-install.test.ts +97 -11
  345. package/tests/windows-hidden-processes.test.ts +11 -44
  346. package/tests/work-continuity-contract.test.ts +48 -55
  347. package/tests/yolo-session-policy.test.ts +2 -0
  348. package/web/tower/dist/assets/BatchableSprite-BJ_TQxjN.js +217 -0
  349. package/web/tower/dist/assets/BufferResource-DeJpHuO6.js +139 -0
  350. package/web/tower/dist/assets/CanvasPool-cwc03T_x.js +23 -0
  351. package/web/tower/dist/assets/CanvasRenderer-DO84oP5R.js +1 -0
  352. package/web/tower/dist/assets/Filter-BKhT9lO8.js +1 -0
  353. package/web/tower/dist/assets/GlUniformGroupSystem-DluI7cqd.js +130 -0
  354. package/web/tower/dist/assets/GpuUboSystem-CM4Dys0F.js +17 -0
  355. package/web/tower/dist/assets/Graphics-3OyUtCzC.js +1 -0
  356. package/web/tower/dist/assets/RenderTargetSystem-X-9GAQ1C.js +184 -0
  357. package/web/tower/dist/assets/WebGLRenderer-I0fqIX1w.js +20 -0
  358. package/web/tower/dist/assets/WebGPURenderer-BRWSXotK.js +79 -0
  359. package/web/tower/dist/assets/_commonjsHelpers-CqkleIqs.js +1 -0
  360. package/web/tower/dist/assets/abnfDiagram-VCTEODGH-C4iBBhTL.js +1 -0
  361. package/web/tower/dist/assets/architectureDiagram-5GKGNRK7-Ih-qvfTu.js +36 -0
  362. package/web/tower/dist/assets/blockDiagram-I7D4REHJ-I9z_u3wb.js +129 -0
  363. package/web/tower/dist/assets/browserAll-gmBFNIA4.js +14 -0
  364. package/web/tower/dist/assets/c4Diagram-7LVT6UL2-DOyk2rEJ.js +38 -0
  365. package/web/tower/dist/assets/canvasUtils-DTaMcbkN.js +1 -0
  366. package/web/tower/dist/assets/channel-wuxBkGGz.js +1 -0
  367. package/web/tower/dist/assets/chunk-2Q5K7J3B-BaJ-OrJ_.js +1 -0
  368. package/web/tower/dist/assets/chunk-5VM5RSS4-wICrhvyw.js +15 -0
  369. package/web/tower/dist/assets/chunk-F27PBJKO-DUQ_JqvZ.js +1 -0
  370. package/web/tower/dist/assets/chunk-IMKFNOWR-DKfgQrGM.js +231 -0
  371. package/web/tower/dist/assets/chunk-JWPE2WC7-1k1LW87d.js +1 -0
  372. package/web/tower/dist/assets/chunk-POPQ4Y6H-Df8cN2w9.js +1 -0
  373. package/web/tower/dist/assets/chunk-SVP7TREG-CxU5LDj8.js +88 -0
  374. package/web/tower/dist/assets/chunk-TICWLB2K-CEuHEBi0.js +206 -0
  375. package/web/tower/dist/assets/chunk-XXDRQBXY-CbSAjj9l.js +1 -0
  376. package/web/tower/dist/assets/classDiagram-ZZMXUADV-DbRmVQRX.js +1 -0
  377. package/web/tower/dist/assets/classDiagram-v2-VYDZK3BY-DbRmVQRX.js +1 -0
  378. package/web/tower/dist/assets/cose-bilkent-JH36ORCC-8xZLSHER.js +1 -0
  379. package/web/tower/dist/assets/cynefin-OW5HDTMX-Cw4XG9Zj.js +166 -0
  380. package/web/tower/dist/assets/cynefinDiagram-5FMLGOSQ-CcQdokUv.js +62 -0
  381. package/web/tower/dist/assets/cytoscape.esm-BHa1VTXv.js +321 -0
  382. package/web/tower/dist/assets/d3-scale-4DPf7zan.js +1 -0
  383. package/web/tower/dist/assets/dagre-GXQ25YYZ-D-Xv7L9X.js +4 -0
  384. package/web/tower/dist/assets/diagram-S7CK7UJ4-Bqy2eT2c.js +30 -0
  385. package/web/tower/dist/assets/diagram-UQ7AKVKN-B2wK2GHj.js +41 -0
  386. package/web/tower/dist/assets/diagram-VSXAHHWV-CIZqh7BH.js +3 -0
  387. package/web/tower/dist/assets/diagram-VX7I27RA-BGX4HBj2.js +24 -0
  388. package/web/tower/dist/assets/diagram-Z3DM3KII-DYpsfaJW.js +24 -0
  389. package/web/tower/dist/assets/ebnfDiagram-PWID7BFC-BNnwCZNv.js +1 -0
  390. package/web/tower/dist/assets/erDiagram-RLTQ6QDP-_MN9W-1E.js +99 -0
  391. package/web/tower/dist/assets/flowDiagram-HODETNUW-D_ndx1UC.js +168 -0
  392. package/web/tower/dist/assets/ganttDiagram-EL5Y4UJY-C8chdEiZ.js +292 -0
  393. package/web/tower/dist/assets/getPo2TextureFromSource-CqJsdi0J.js +1 -0
  394. package/web/tower/dist/assets/getTexelRangeRects-DN3N5aFp.js +57 -0
  395. package/web/tower/dist/assets/getTextureBatchBindGroup-RNSiAVH3.js +1 -0
  396. package/web/tower/dist/assets/gitGraphDiagram-WWUBYQGX-B5ijv7LI.js +106 -0
  397. package/web/tower/dist/assets/index-B1Ho-Igs.css +1 -0
  398. package/web/tower/dist/assets/index-CfNjH1Wr.js +45 -0
  399. package/web/tower/dist/assets/infoDiagram-27XIBGKW-AYbp5ElT.js +2 -0
  400. package/web/tower/dist/assets/ishikawaDiagram-5VMMS53U-DnmwARuR.js +70 -0
  401. package/web/tower/dist/assets/journeyDiagram-3NMN7TZE-CK737kko.js +139 -0
  402. package/web/tower/dist/assets/kanban-definition-UXKFOSKX-0AhM3axC.js +89 -0
  403. package/web/tower/dist/assets/katex-HP8lGamR.js +257 -0
  404. package/web/tower/dist/assets/layout-wOIeK9c_.js +1 -0
  405. package/web/tower/dist/assets/mermaid.core-CGYyw6G7.js +310 -0
  406. package/web/tower/dist/assets/mindmap-definition-YA3MSWOX-CkZ_JOdx.js +96 -0
  407. package/web/tower/dist/assets/pegDiagram-XKGWAZYB-CHAPspih.js +1 -0
  408. package/web/tower/dist/assets/pieDiagram-E7YTZNPT-LwCcZl5o.js +39 -0
  409. package/web/tower/dist/assets/preload-helper-PPVm8Dsz.js +1 -0
  410. package/web/tower/dist/assets/quadrantDiagram-AXDQQJYC-Cm4uijV2.js +7 -0
  411. package/web/tower/dist/assets/railroadDiagram-O6MQD6OU-BPQHZ2b5.js +1 -0
  412. package/web/tower/dist/assets/requirementDiagram-BXWQKSXE-JLtSUDfS.js +84 -0
  413. package/web/tower/dist/assets/sankeyDiagram-P5KCCOFB-DJsYv9ii.js +40 -0
  414. package/web/tower/dist/assets/sequenceDiagram-WJ2MYXX4-Ca8T8sT0.js +162 -0
  415. package/web/tower/dist/assets/sizeCapture-INFHLROL-Ch4i2dS-.js +1 -0
  416. package/web/tower/dist/assets/stateDiagram-D77RDMKH-DDSkncYm.js +1 -0
  417. package/web/tower/dist/assets/stateDiagram-v2-MP3YSRHH-BkO_9mIH.js +1 -0
  418. package/web/tower/dist/assets/swimlanes-42K2YHIH-Bns5iI3y.js +1 -0
  419. package/web/tower/dist/assets/swimlanesDiagram-VR7AAH4N--LEBb1ti.js +8 -0
  420. package/web/tower/dist/assets/timeline-definition-24CTP7MA-QJDuVTb3.js +120 -0
  421. package/web/tower/dist/assets/vennDiagram-4TSXK5OY-pBNxKxOV.js +34 -0
  422. package/web/tower/dist/assets/wardleyDiagram-VM6X3IG4-1PEarjN1.js +78 -0
  423. package/web/tower/dist/assets/webworkerAll-D_Np003p.js +83 -0
  424. package/web/tower/dist/assets/xychartDiagram-S5SC5T6Z-CLwsvOg7.js +7 -0
  425. package/web/tower/dist/index.html +41 -0
  426. package/contracts/review-provider-contract-mirror/v1.6.0/bundle/vectors/lens.json +0 -1
  427. package/docs/review-delivery-preflight.md +0 -22
  428. package/extensions/codegraph-tools.ts +0 -437
  429. package/lib/native-review-authority-quarantine.ts +0 -2
  430. package/lib/review-delivery-preflight.ts +0 -85
  431. package/lib/review-legacy-detector.ts +0 -81
  432. package/tests/child-codegraph-bootstrap.test.ts +0 -74
  433. package/tests/codegraph-tools.test.ts +0 -554
  434. package/tests/fixtures/devbinary/capabilities-v2.1.derived.json +0 -331
  435. package/tests/fixtures/refusal-identity.probe.mjs +0 -139
  436. package/tests/native-review-authority-quarantine.test.ts +0 -10
  437. package/tests/native-review-refusal-identity.test.ts +0 -25
  438. package/tests/review-delivery-preflight.test.ts +0 -462
  439. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/README.md +0 -0
  440. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/refuter.schema.json +0 -0
  441. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  442. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/vectors/refuter.json +0 -0
  443. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -0,0 +1,127 @@
1
+ // Gentle Chat reads a big session history (> 1 MiB) through `sh` (herdr/mods/gentle-chat/session.js).
2
+ // Native Windows has no `sh`: Herdr's `exec` rejects when the program cannot start, and the read
3
+ // must still return the new lines (issue #3352, Chat part) instead of `text: null`.
4
+ import assert from "node:assert/strict";
5
+ import { execFile } from "node:child_process";
6
+ import { mkdtempSync, rmSync, writeFileSync, appendFileSync } from "node:fs";
7
+ import { registerHooks } from "node:module";
8
+ import { tmpdir } from "node:os";
9
+ import { join } from "node:path";
10
+ import test from "node:test";
11
+
12
+ type ExecResult = { code: number; stdout: string; stderr: string };
13
+ type Exec = (command: string, args?: string[], options?: { cwd?: string; timeout?: number }) => Promise<ExecResult>;
14
+ const state = globalThis as unknown as { __gentleChatExec: Exec; __gentleChatExecCalls: string[] };
15
+ state.__gentleChatExecCalls = [];
16
+
17
+ // The Herdr runtime module, with `exec` routed to the test. Only `exec` is used by these reads.
18
+ const HERDR = `data:text/javascript,${encodeURIComponent(`
19
+ const noop = () => null;
20
+ export const exec = (command, args, options) => { globalThis.__gentleChatExecCalls.push(command); return globalThis.__gentleChatExec(command, args, options); };
21
+ export const agents = () => [], terminals = () => [], panes = () => [], focused = noop, home = () => "/nonexistent-home", layout = noop, watchFolder = () => new Promise(() => {}), run = noop, shared = noop, setShared = noop;
22
+ `)}`;
23
+ // Herdr's readFile, which refuses a file outside the home folder (here: under /outside/).
24
+ const FS = `data:text/javascript,${encodeURIComponent(`
25
+ import { readFile as nodeReadFile } from "node:fs/promises";
26
+ export * from "node:fs/promises";
27
+ export const readFile = async (path, ...rest) => {
28
+ if (String(path).startsWith("/outside/")) throw new Error("outside every granted read root");
29
+ return nodeReadFile(path, ...rest);
30
+ };
31
+ `)}`;
32
+ registerHooks({ resolve(specifier, context, next) {
33
+ if (specifier === "herdr") return { url: HERDR, shortCircuit: true };
34
+ if (specifier === "fs/promises" && context.parentURL?.includes("/herdr/mods/")) return { url: FS, shortCircuit: true };
35
+ return next(specifier, context);
36
+ } });
37
+
38
+ const { readAfter } = await import("../herdr/mods/gentle-chat/session.js");
39
+
40
+ // No `sh` (native Windows): Herdr's exec rejects because the program cannot start.
41
+ const noSh: Exec = async (command) => { throw new Error(`failed to start ${command}: program not found`); };
42
+ // A real `sh`, shaped like Herdr's exec result (stdout as text).
43
+ const realSh: Exec = (command, args = [], options = {}) => new Promise((resolve) => {
44
+ execFile(command, args, { encoding: "utf8", timeout: options.timeout, maxBuffer: 8 * 1024 * 1024 }, (error, stdout, stderr) => {
45
+ resolve({ code: error ? (typeof error.code === "number" ? error.code : 1) : 0, stdout, stderr });
46
+ });
47
+ });
48
+ const hasSh = process.platform !== "win32";
49
+
50
+ const line = (i: number) => `${JSON.stringify({ type: "message", i, text: `añ🚀 ${"x".repeat(180)}` })}\n`;
51
+ function bigSession(t: test.TestContext) {
52
+ const dir = mkdtempSync(join(tmpdir(), "gentle-chat-read-"));
53
+ t.after(() => rmSync(dir, { recursive: true, force: true }));
54
+ const file = join(dir, "session.jsonl");
55
+ let body = "";
56
+ for (let i = 0; body.length < 1.5 * 1024 * 1024; i++) body += line(i);
57
+ writeFileSync(file, body);
58
+ return { file, size: Buffer.byteLength(body) };
59
+ }
60
+
61
+ test("a history over 1 MiB still reads its new lines when exec cannot start sh", async (t) => {
62
+ const { file, size } = bigSession(t);
63
+ appendFileSync(file, `${line(100_000)}${line(100_001)}{"half":`);
64
+ state.__gentleChatExec = noSh;
65
+ state.__gentleChatExecCalls = [];
66
+ const r = await readAfter(file, size, undefined, true);
67
+ assert.deepEqual(state.__gentleChatExecCalls, ["sh"]);
68
+ assert.equal(r.text, `${line(100_000)}${line(100_001)}`);
69
+ assert.equal(r.end, size + Buffer.byteLength(r.text));
70
+ assert.equal(r.more, false);
71
+ assert.equal(r.size, size + Buffer.byteLength(`${line(100_000)}${line(100_001)}{"half":`));
72
+ // Nothing new: an empty read at the same position, not a reset.
73
+ const again = await readAfter(file, r.end, undefined, true);
74
+ assert.deepEqual({ text: again.text, end: again.end, more: again.more }, { text: "", end: r.end, more: false });
75
+ });
76
+
77
+ test("without sh, a shrunk or missing history still resets (text null)", async (t) => {
78
+ const { file, size } = bigSession(t);
79
+ state.__gentleChatExec = noSh;
80
+ assert.equal((await readAfter(file, size + 10, undefined, true)).text, null);
81
+ assert.equal((await readAfter(`${file}.gone`, 0, undefined, true)).text, null);
82
+ });
83
+
84
+ test("incremental reads give the same lines, ends and sizes through sh, without sh and read whole", { skip: !hasSh && "needs a POSIX sh" }, async (t) => {
85
+ const { file, size } = bigSession(t);
86
+ appendFileSync(file, `${line(200_000)}${line(200_001)}{"partial":`);
87
+ const read = async (exec: Exec | null, pos: number, max?: number) => {
88
+ if (exec) state.__gentleChatExec = exec;
89
+ const r = await readAfter(file, pos, max, exec !== null);
90
+ return { text: r.text, end: r.end, more: r.more, size: r.size };
91
+ };
92
+ // The appended lines and a mid-file position (a line start). A capped read slices differently
93
+ // through sh (`max * 3` bytes), so capped reads are compared by following `more` below.
94
+ const mid = Buffer.byteLength(Array.from({ length: 2000 }, (_, i) => line(i)).join(""));
95
+ for (const [pos, max] of [[size, undefined], [mid, undefined]] as const) {
96
+ const whole = await read(null, pos, max);
97
+ const viaSh = await read(realSh, pos, max);
98
+ const fallback = await read(noSh, pos, max);
99
+ assert.equal(viaSh.text, whole.text, `sh text at ${pos}`);
100
+ assert.equal(viaSh.end, whole.end, `sh end at ${pos}`);
101
+ assert.equal(viaSh.size, whole.size, `sh size at ${pos}`);
102
+ assert.deepEqual(fallback, whole, `no-sh read at ${pos}`);
103
+ }
104
+ assert.deepEqual(await read(noSh, 0, 64 * 1024), await read(null, 0, 64 * 1024), "a capped no-sh read");
105
+ // Following `more` from 0 reaches the same end either way.
106
+ for (const exec of [realSh, noSh]) {
107
+ let pos = 0;
108
+ let text = "";
109
+ for (let r = await read(exec, pos, 256 * 1024); ; r = await read(exec, pos, 256 * 1024)) {
110
+ text += r.text;
111
+ pos = r.end;
112
+ if (!r.more) break;
113
+ }
114
+ assert.equal(pos, Buffer.byteLength(text));
115
+ assert.equal(text, (await read(null, 0)).text);
116
+ }
117
+ });
118
+
119
+ test("a file outside the home folder is read through sh, and without sh it starts over", async () => {
120
+ state.__gentleChatExec = async () => ({ code: 0, stdout: "5\n", stderr: "" });
121
+ state.__gentleChatExecCalls = [];
122
+ assert.deepEqual(await readAfter("/outside/session.jsonl", 5), { text: "", end: 5, more: false, size: 5 });
123
+ assert.deepEqual(state.__gentleChatExecCalls, ["sh"]);
124
+ state.__gentleChatExec = noSh;
125
+ const r = await readAfter("/outside/session.jsonl", 5);
126
+ assert.deepEqual({ text: r.text, end: r.end, more: r.more }, { text: null, end: 0, more: false });
127
+ });
@@ -258,6 +258,33 @@ test("when the browser cannot open, the URL is still printed with a manual hint"
258
258
  assert.equal(notices[0].message, "Design canvas: http://127.0.0.1:4100/tok/d/login/\nThe browser could not be opened (spawn xdg-open ENOENT). Open the URL manually.");
259
259
  });
260
260
 
261
+ test("GENTLE_DESIGN_OPEN_BROWSER=0 shows the canvas without opening the system browser and still prints the URL", async () => {
262
+ const cwd = scratchCwd();
263
+ writeDesign(cwd, "login", "Login screen");
264
+ const { pi, command } = fakePi();
265
+ const canvas = fakeCanvas();
266
+ gentleDesign(pi, { ...canvas, env: { GENTLE_DESIGN_OPEN_BROWSER: "0" } });
267
+ const { ctx, notices } = fakeContext(cwd);
268
+ await command().handler("open login", ctx);
269
+ assert.equal(canvas.starts.length, 1, "the canvas server still starts");
270
+ assert.deepEqual(canvas.opens, [], "the system browser is not opened");
271
+ assert.equal(notices.length, 1);
272
+ assert.equal(notices[0].level, "info");
273
+ assert.equal(notices[0].message, "Design canvas: http://127.0.0.1:4100/tok/d/login/\nThe system browser was not opened (GENTLE_DESIGN_OPEN_BROWSER=0).");
274
+ });
275
+
276
+ test("any GENTLE_DESIGN_OPEN_BROWSER value other than 0 keeps opening the system browser", async () => {
277
+ const cwd = scratchCwd();
278
+ writeDesign(cwd, "login", "Login screen");
279
+ const { pi, command } = fakePi();
280
+ const canvas = fakeCanvas();
281
+ gentleDesign(pi, { ...canvas, env: { GENTLE_DESIGN_OPEN_BROWSER: "1" } });
282
+ const { ctx, notices } = fakeContext(cwd);
283
+ await command().handler("open login", ctx);
284
+ assert.deepEqual(canvas.opens, ["http://127.0.0.1:4100/tok/d/login/"]);
285
+ assert.equal(notices[0].message, "Design canvas: http://127.0.0.1:4100/tok/d/login/");
286
+ });
287
+
261
288
  test("an unknown or invalid slug warns with the available slugs and starts nothing", async () => {
262
289
  const cwd = scratchCwd();
263
290
  writeDesign(cwd, "pricing-page", "Pricing page", 2000);
@@ -1066,6 +1093,18 @@ test("gentle_design open starts the canvas once, returns its URL, and /gentle:de
1066
1093
  assert.equal(fake.sent.length, 0);
1067
1094
  });
1068
1095
 
1096
+ test("gentle_design open with GENTLE_DESIGN_OPEN_BROWSER=0 returns the URL with opened false and browserDisabled", async () => {
1097
+ const cwd = scratchCwd();
1098
+ writeDesign(cwd, "login", "Login screen");
1099
+ const fake = fakePi();
1100
+ const canvas = fakeCanvas();
1101
+ gentleDesign(fake.pi, { ...canvas, env: { GENTLE_DESIGN_OPEN_BROWSER: "0" } });
1102
+ const opened = await designTool(fake)({ action: "open", slug: "login" }, fakeContext(cwd).ctx);
1103
+ assert.equal(toolText(opened), "Design canvas: http://127.0.0.1:4100/tok/d/login/\nThe system browser was not opened (GENTLE_DESIGN_OPEN_BROWSER=0).");
1104
+ assert.deepEqual(opened.details, { url: "http://127.0.0.1:4100/tok/d/login/", opened: false, browserDisabled: true });
1105
+ assert.deepEqual(canvas.opens, []);
1106
+ });
1107
+
1069
1108
  test("gentle_design open refreshes a connected canvas page, and opens the browser once none is connected", async () => {
1070
1109
  const cwd = scratchCwd();
1071
1110
  writeDesign(cwd, "pricing-page", "Pricing page", 2000);
@@ -18,6 +18,7 @@ interface Options {
18
18
  deferred?: boolean; slowProbe?: boolean; holdPlayback?: boolean; noUnsubscribe?: boolean; unavailable?: boolean; fail?: boolean;
19
19
  capabilities?: Set<"wav" | "ogg" | "flac">;
20
20
  percent?: number | null; visualNotice?: boolean;
21
+ compaction?: ReturnType<ExtensionAPI["getSettings"]>["compaction"]; contextWindow?: number;
21
22
  }
22
23
  function harness(options: Options = {}) {
23
24
  const id = options.sessionId ?? `parent-${++nextSession}`;
@@ -27,8 +28,8 @@ function harness(options: Options = {}) {
27
28
  if (!map.has(key)) map.set(key, new Set()); map.get(key)!.add(fn);
28
29
  return () => { map.get(key)!.delete(fn); };
29
30
  };
30
- // SAFETY: only lifecycle hooks and the bus are used by this factory; a minimal fake traps that contract.
31
- const pi = { on: (key: string, fn: any) => {
31
+ // SAFETY: a minimal fake for lifecycle hooks, the bus, and effective settings.
32
+ const pi = { getSettings: () => options.compaction === undefined ? undefined : { compaction: options.compaction }, on: (key: string, fn: any) => {
32
33
  const off = listen(native, key, fn); return options.noUnsubscribe ? undefined : off;
33
34
  }, events: { on: (key: string, fn: any) => listen(bus, key, fn), emit: (key: string, data: unknown) => {
34
35
  for (const fn of [...bus.get(key) ?? []]) fn(data);
@@ -41,10 +42,12 @@ function harness(options: Options = {}) {
41
42
  settings.enabled = options.enabled ?? !options.absent; settings.audio.minimumIntervalMs = 0; settings.audio.coalesceWindowMs = 0;
42
43
  settings.audio.events = Object.fromEntries(NOTIFICATION_EVENTS.map(e => [e,
43
44
  e === "context.high" ? "builtin:attention" : e.endsWith("failed") ? "builtin:error" : e === "agent.cancelled" ? "builtin:attention" : "builtin:success"]));
44
- // SAFETY: this owner reads only mode, session identity, context usage and local notify, never session entries/model APIs.
45
- let percent: number | null = options.percent ?? null;
45
+ // SAFETY: provides the session identity, model, latest context usage and local notify.
46
+ let percent: number | null = options.percent ?? null, tokens: number | null = null;
47
+ const contextWindow = options.contextWindow ?? 100;
46
48
  const ctx = { mode: options.mode ?? "tui", hasUI: true, sessionManager: { getSessionId: () => id },
47
- getContextUsage: () => ({ tokens: null, contextWindow: 100, percent }),
49
+ model: { provider: "provider", id: "model", contextWindow },
50
+ getContextUsage: () => ({ tokens, contextWindow, percent }),
48
51
  ui: { notify: (s: string) => notes.push(s) } } as unknown as ExtensionContext;
49
52
  const deps = { now: () => time, env: { GENTLE_PI_AGENTS_CHILD: options.child ? "1" : "0", GENTLE_SHELL_INTERACTIVE_HOST: "1" },
50
53
  visualNotice: () => options.visualNotice ?? true,
@@ -79,6 +82,7 @@ function harness(options: Options = {}) {
79
82
  };
80
83
  return { id, pi, ctx, deps, retire, emit, start, source, played, signals, permits, releases, probeReleases, notes, native, bus, timers, advance,
81
84
  setPercent: (value: number | null) => { percent = value; },
85
+ setTokens: (value: number | null) => { tokens = value; percent = value === null ? null : value / contextWindow * 100; },
82
86
  get probes() { return probes; }, get writes() { return writes; }, get attempts() { return attempts; } };
83
87
  }
84
88
  const listeners = (map: Map<string, Set<any>>) => [...map.values()].reduce((n, set) => n + set.size, 0);
@@ -128,6 +132,40 @@ test("context.high warns once per high episode and rearms only below the thresho
128
132
  } finally { h.retire(); }
129
133
  });
130
134
 
135
+ test("context.high warns once at the active model's compaction threshold, not at a rounded window percentage", async () => {
136
+ const h = harness({ contextWindow: 1_048_576, compaction: {
137
+ reserveTokens: 209_715, modelOverrides: { "provider/model": { reserveTokens: 419_430 } },
138
+ } });
139
+ try {
140
+ await h.start();
141
+ h.setTokens(629_145); await h.emit("turn_end");
142
+ assert.deepEqual(h.played, []); assert.deepEqual(h.notes, []);
143
+ const note = "Context usage has reached the auto-compaction threshold; Pi compacts when usage exceeds it.";
144
+ h.setTokens(629_146); await h.emit("turn_end");
145
+ assert.deepEqual(h.played, ["builtin:attention"]); assert.deepEqual(h.notes, [note]);
146
+ h.setTokens(null); await h.emit("turn_end");
147
+ h.setTokens(629_147); await h.emit("turn_end");
148
+ assert.deepEqual(h.played, ["builtin:attention"]); assert.deepEqual(h.notes, [note]);
149
+ h.setTokens(629_145); await h.emit("turn_end");
150
+ h.setTokens(629_146); await h.emit("turn_end");
151
+ assert.deepEqual(h.played, ["builtin:attention", "builtin:attention"]); assert.deepEqual(h.notes, [note, note]);
152
+ } finally { h.retire(); }
153
+ });
154
+
155
+ test("context.high preserves the inclusive 90% warning when compaction is disabled or the threshold is unknown", async () => {
156
+ for (const compaction of [{ enabled: false, reserveTokens: 40_000 }, { reserveTokens: -1 }, undefined]) {
157
+ const h = harness({ contextWindow: 100_000, compaction });
158
+ try {
159
+ await h.start();
160
+ h.setTokens(89_999); await h.emit("turn_end");
161
+ assert.deepEqual(h.played, []); assert.deepEqual(h.notes, []);
162
+ h.setTokens(90_000); await h.emit("turn_end");
163
+ assert.deepEqual(h.played, ["builtin:attention"]);
164
+ assert.deepEqual(h.notes, ["Context usage is at 90% (≥ 90%); consider compacting before the next turn."]);
165
+ } finally { h.retire(); }
166
+ }
167
+ });
168
+
131
169
  test("same-session reload preserves the context episode until usage drops below 90%", async () => {
132
170
  const h = harness({ percent: 93 }); try {
133
171
  await h.start(); await h.emit("turn_end");
@@ -414,6 +414,7 @@ test("--status prints versions and what is installed", async (t) => {
414
414
  " Gentle Shell: 9.9.9",
415
415
  ` Herdr app: not installed (needs ${HERDR_APP_VERSION} or newer)`,
416
416
  ` Herdr home: ${f.herdrHome}`,
417
+ ` Feed: none at ${f.home}/.pi/agent/desktop/sessions; start a session with gentle-shell and the window will see it`,
417
418
  " Layout gentle-shell: not installed",
418
419
  " Mods: none installed (ships gentle-a, gentle-b)",
419
420
  " Window: not running",
@@ -428,6 +429,7 @@ test("--status prints versions and what is installed", async (t) => {
428
429
  " Gentle Shell: 9.9.9",
429
430
  ` Herdr app: ${HERDR_APP_VERSION} at ${join(f.bin, "herdr-app")} (needs ${HERDR_APP_VERSION} or newer)`,
430
431
  ` Herdr home: ${f.herdrHome}`,
432
+ ` Feed: none at ${f.home}/.pi/agent/desktop/sessions; start a session with gentle-shell and the window will see it`,
431
433
  ` Layout gentle-shell: installed at ${join(f.herdrHome, "layouts", "gentle-shell.json")}`,
432
434
  ` Mods: gentle-a, gentle-b installed in ${join(f.herdrHome, "mods")}`,
433
435
  " Window: running, layout main",
@@ -610,6 +612,15 @@ test("Projects group by machine like Herdr's spaces once a machine is not this c
610
612
  assert.deepEqual(machineGroups([{ id: "x/w9", machine: "x" }], [])?.map((g) => [g.name, g.state]), [[null, "ready"], ["x", "unavailable"]]);
611
613
  });
612
614
 
615
+ test("the + after the tabs starts the new session in the shown project's folder, else the space's (#3453)", async () => {
616
+ const { newTabArgs } = await import("../herdr/mods/gentle-tabs/new-tab.js");
617
+ const space = { id: "w1", folder: "/work/project-b" };
618
+ // The shown session's project wins over the folder stored on the space.
619
+ assert.deepEqual(newTabArgs(space, "/work/project-a"), { argv: ["gentle-shell"], space: "w1", folder: "/work/project-a" });
620
+ // No project known: the space's folder, as before.
621
+ assert.deepEqual(newTabArgs(space, null), { argv: ["gentle-shell"], space: "w1", folder: "/work/project-b" });
622
+ });
623
+
613
624
  test("a swap conflict rolls back: Herdr home, originals and a created mods/ folder are as before (B1)", async (t) => {
614
625
  const f = fixture(t);
615
626
  installFakeHerdr(join(f.bin, "herdr-app"), HERDR_APP_VERSION, f.state);
@@ -925,3 +936,100 @@ test("chat feed: hideThinkingBlock follows pi's settings merge (project over age
925
936
  assert.equal(hideThinkingFrom(null, null), false);
926
937
  assert.equal(hideThinkingFrom("{not json", '{"hideThinkingBlock":"yes"}'), false);
927
938
  });
939
+
940
+ test("--status reports an agent home the mods cannot read", async (t) => {
941
+ const f = fixture(t);
942
+ const agent = join(f.home, "elsewhere", "agent");
943
+ const base = context(f, { args: ["--status"] });
944
+ assert.equal(await runDesktop({ ...base, env: { ...base.env, PI_CODING_AGENT_DIR: agent } }), 0);
945
+ const line = f.out.find((entry) => entry.startsWith(" Roots: "));
946
+ assert.ok(line !== undefined, f.out.join("\n"));
947
+ assert.match(line ?? "", /is not read by the mods/);
948
+ assert.match(line ?? "", /add \["/);
949
+ });
950
+
951
+ test("--status accepts an agent home listed in the roots file", async (t) => {
952
+ const f = fixture(t);
953
+ const agent = join(f.home, "elsewhere", "agent");
954
+ mkdirSync(f.herdrHome, { recursive: true });
955
+ writeFileSync(join(f.herdrHome, "gentle-shell-roots.json"), `${JSON.stringify({ roots: [agent] }, null, 2)}\n`);
956
+ const base = context(f, { args: ["--status"] });
957
+ assert.equal(await runDesktop({ ...base, env: { ...base.env, PI_CODING_AGENT_DIR: agent } }), 0);
958
+ const line = f.out.find((entry) => entry.startsWith(" Roots: "));
959
+ assert.ok(line !== undefined, f.out.join("\n"));
960
+ assert.match(line ?? "", /listed in .*gentle-shell-roots\.json/);
961
+ assert.doesNotMatch(line ?? "", /is not listed/);
962
+ });
963
+
964
+ test("--status reports a feed it can read", async (t) => {
965
+ const f = fixture(t);
966
+ const agent = join(f.home, "agent");
967
+ const dir = join(agent, "desktop", "sessions");
968
+ mkdirSync(dir, { recursive: true });
969
+ writeFileSync(join(dir, "session-a.json"), "{}\n");
970
+ const base = context(f, { args: ["--status"] });
971
+ assert.equal(await runDesktop({ ...base, env: { ...base.env, PI_CODING_AGENT_DIR: agent } }), 0);
972
+ const line = f.out.find((entry) => entry.startsWith(" Feed: "));
973
+ assert.ok(line !== undefined, f.out.join("\n"));
974
+ assert.match(line ?? "", /1 session snapshot in .*desktop\/sessions \(newest \d+s old\)/);
975
+ });
976
+
977
+ test("--status reads the agent home a separate install recorded", async (t) => {
978
+ const f = fixture(t);
979
+ // packageRoot mirrors <root>/prefix/lib/node_modules/gentle-pi, and installation.json sits at <root>.
980
+ const root = join(f.home, "install");
981
+ const packageRoot = join(root, "prefix", "lib", "node_modules", "gentle-pi");
982
+ mkdirSync(packageRoot, { recursive: true });
983
+ const agent = join(root, "agent");
984
+ writeFileSync(join(root, "installation.json"), `${JSON.stringify({ Agent: agent })}\n`);
985
+ const base = context(f, { args: ["--status"], packageRoot });
986
+ assert.equal(await runDesktop({ ...base, env: { ...base.env, PI_CODING_AGENT_DIR: "" } }), 0);
987
+ const line = f.out.find((entry) => entry.startsWith(" Roots: "));
988
+ assert.ok(line !== undefined, f.out.join("\n"));
989
+ assert.match(line ?? "", new RegExp(`Roots: ${agent} is not read by the mods`));
990
+ });
991
+
992
+ test("--status treats a trailing separator as the same agent home", async (t) => {
993
+ const f = fixture(t);
994
+ const agent = join(f.home, ".pi", "agent");
995
+ const base = context(f, { args: ["--status"] });
996
+ assert.equal(await runDesktop({ ...base, env: { ...base.env, PI_CODING_AGENT_DIR: `${agent}/` } }), 0);
997
+ assert.equal(f.out.some((entry) => entry.startsWith(" Roots: ")), false, f.out.join("\n"));
998
+ });
999
+
1000
+ test("--status stops at the eight roots the mods read", async (t) => {
1001
+ const f = fixture(t);
1002
+ const agent = join(f.home, "agent");
1003
+ const custom = Array.from({ length: 7 }, (_, i) => join(f.home, `root-${i}`));
1004
+ mkdirSync(f.herdrHome, { recursive: true });
1005
+ writeFileSync(join(f.herdrHome, "gentle-shell-roots.json"), `${JSON.stringify({ roots: [...custom, agent] }, null, 2)}\n`);
1006
+ const base = context(f, { args: ["--status"] });
1007
+ assert.equal(await runDesktop({ ...base, env: { ...base.env, PI_CODING_AGENT_DIR: agent } }), 0);
1008
+ const line = f.out.find((entry) => entry.startsWith(" Roots: "));
1009
+ assert.ok(line !== undefined, f.out.join("\n"));
1010
+ // Two defaults plus six customs fill the eight slots: adding the ninth does not help.
1011
+ assert.match(line ?? "", /the first 8 roots are taken/);
1012
+ assert.match(line ?? "", /move it into the first 8|remove an earlier one/);
1013
+ });
1014
+
1015
+ test("--status ignores non-absolute entries when counting the limit", async (t) => {
1016
+ const f = fixture(t);
1017
+ const agent = join(f.home, "agent");
1018
+ mkdirSync(f.herdrHome, { recursive: true });
1019
+ writeFileSync(join(f.herdrHome, "gentle-shell-roots.json"), `${JSON.stringify({ roots: ["relative/one", " ", agent] })}\n`);
1020
+ const base = context(f, { args: ["--status"] });
1021
+ assert.equal(await runDesktop({ ...base, env: { ...base.env, PI_CODING_AGENT_DIR: agent } }), 0);
1022
+ const line = f.out.find((entry) => entry.startsWith(" Roots: "));
1023
+ assert.ok(line !== undefined, f.out.join("\n"));
1024
+ assert.match(line ?? "", /listed in .*gentle-shell-roots\.json/);
1025
+ });
1026
+
1027
+ test("--status escapes the suggested entry as JSON", async (t) => {
1028
+ const f = fixture(t);
1029
+ const agent = "C:\\\\Users\\\\Ada\\\\agent";
1030
+ const base = context(f, { args: ["--status"] });
1031
+ assert.equal(await runDesktop({ ...base, env: { ...base.env, PI_CODING_AGENT_DIR: agent } }), 0);
1032
+ const line = f.out.find((entry) => entry.startsWith(" Roots: "));
1033
+ assert.ok(line !== undefined, f.out.join("\n"));
1034
+ assert.ok((line ?? "").includes('["C:\\\\\\\\Users\\\\\\\\Ada\\\\\\\\agent"]'), line ?? "");
1035
+ });
@@ -0,0 +1,152 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawnSync } from "node:child_process";
3
+ import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { join } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import test, { after } from "node:test";
8
+ import { shellQuote } from "../lib/gentle-shell-launcher.ts";
9
+
10
+ // Automatic first-run setup through the real launcher, runnable on every
11
+ // platform (tests/gentle-shell-bin.test.ts covers more but cannot run on
12
+ // Windows). Gentle AI is missing and its self-install is skipped, so every
13
+ // attempt fails fast and the launch continues into a fake Pi that logs its
14
+ // arguments. These lines are pinned exactly as Gentle Shell 18b862532 printed
15
+ // them: maybeAutoProvisionHome now takes its reasons from setupCheck, the
16
+ // helper `setup --check` reports, and must keep saying the same thing.
17
+
18
+ const binPath = fileURLToPath(new URL("../bin/gentle-shell.mjs", import.meta.url));
19
+ const gentlePi = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version as string;
20
+ const roots: string[] = [];
21
+ after(() => roots.forEach((root) => rmSync(root, { recursive: true, force: true })));
22
+ function scratch(prefix: string): string {
23
+ const root = realpathSync(mkdtempSync(join(tmpdir(), prefix)));
24
+ roots.push(root);
25
+ return root;
26
+ }
27
+
28
+ function fakePi(dir: string): { path: string; log: string } {
29
+ const log = join(dir, "pi.log");
30
+ if (process.platform === "win32") {
31
+ const path = join(dir, "fake-pi.cmd");
32
+ writeFileSync(path, `@echo off\r\necho %*>> "${log}"\r\nif "%1"=="--version" (echo 1.6.0)\r\n`);
33
+ return { path, log };
34
+ }
35
+ const path = join(dir, "fake-pi.sh");
36
+ writeFileSync(path, `#!/bin/sh\necho "$*" >> '${log}'\nif [ "$1" = "--version" ]; then echo 1.6.0; fi\n`);
37
+ chmodSync(path, 0o755);
38
+ return { path, log };
39
+ }
40
+
41
+ interface Case {
42
+ name: string;
43
+ argv?: (root: string) => string[];
44
+ pin?: string;
45
+ // The isolated home's provisioning record, when it has one.
46
+ record?: Record<string, string>;
47
+ seed?: (root: string) => void;
48
+ env?: Record<string, string>;
49
+ // The exact leading stderr lines (paths built with the root).
50
+ expect: (root: string, home: string) => string[];
51
+ attempted: boolean;
52
+ }
53
+
54
+ const failedLine = "gentle-shell: automatic setup failed (exit 1); starting anyway and retrying next run. Run `gentle-shell setup` to see the full output.";
55
+ const firstRunHint = (home: string) => `gentle-shell: using a separate home at ${home}. Run 'gentle-shell --link' to reuse your pi sign-ins and chats.`;
56
+
57
+ const cases: Case[] = [
58
+ {
59
+ name: "never provisioned",
60
+ expect: (_root, home) => [firstRunHint(home), `gentle-shell: first run in ${home}: installing the Gentle AI companion packages (one time; set GENTLE_SHELL_NO_AUTO_SETUP=1 to skip)`, failedLine],
61
+ attempted: true,
62
+ },
63
+ {
64
+ name: "gentle-ai pin changed",
65
+ pin: "3.7.0",
66
+ record: { gentleAi: "3.6.0", gentlePi },
67
+ expect: (_root, home) => [`gentle-shell: gentle-ai pin changed (3.6.0 -> 3.7.0): updating ${home}`, failedLine],
68
+ attempted: true,
69
+ },
70
+ {
71
+ name: "gentle-pi changed",
72
+ record: { gentleAi: "3.6.0", gentlePi: "4.0.0" },
73
+ expect: (_root, home) => [`gentle-shell: gentle-pi changed (4.0.0 -> ${gentlePi}): updating ${home}`, failedLine],
74
+ attempted: true,
75
+ },
76
+ {
77
+ name: "both changed",
78
+ pin: "3.7.0",
79
+ record: { gentleAi: "3.6.0", gentlePi: "4.0.0" },
80
+ expect: (_root, home) => [`gentle-shell: gentle-ai pin changed (3.6.0 -> 3.7.0) and gentle-pi changed (4.0.0 -> ${gentlePi}): updating ${home}`, failedLine],
81
+ attempted: true,
82
+ },
83
+ {
84
+ name: "a record without gentlePi",
85
+ record: { gentleAi: "3.6.0" },
86
+ expect: (_root, home) => [`gentle-shell: gentle-pi changed (unknown -> ${gentlePi}): updating ${home}`, failedLine],
87
+ attempted: true,
88
+ },
89
+ {
90
+ name: "provisioned and current",
91
+ record: { gentleAi: "3.6.0", gentlePi },
92
+ expect: (_root, home) => [`gentle-shell: disabled Pi's builtin codemode in ${join(home, "settings.json")} (Gentle Shell ships its own codemode tool)`],
93
+ attempted: false,
94
+ },
95
+ {
96
+ name: "a foreign --home",
97
+ argv: (root) => ["--home", join(root, "foreign"), "-p", "x"],
98
+ seed: (root) => {
99
+ mkdirSync(join(root, "foreign"));
100
+ writeFileSync(join(root, "foreign", "notes.txt"), "mine\n");
101
+ },
102
+ expect: (root) => [`gentle-shell: ${join(root, "foreign")} already has content and was not set up by gentle-shell; run \`gentle-shell --home ${shellQuote(join(root, "foreign"))} setup\` to provision it`],
103
+ attempted: false,
104
+ },
105
+ {
106
+ name: "--link",
107
+ argv: () => ["--link", "-p", "x"],
108
+ expect: () => [],
109
+ attempted: false,
110
+ },
111
+ {
112
+ name: "automatic setup off",
113
+ env: { GENTLE_SHELL_NO_AUTO_SETUP: "1" },
114
+ expect: (_root, home) => [firstRunHint(home), `gentle-shell: disabled Pi's builtin codemode in ${join(home, "settings.json")} (Gentle Shell ships its own codemode tool)`],
115
+ attempted: false,
116
+ },
117
+ ];
118
+
119
+ for (const c of cases) {
120
+ test(`automatic setup, ${c.name}: prints its reason, then still launches Pi`, () => {
121
+ const root = scratch("gentle-shell-auto-provision-");
122
+ const tools = scratch("gentle-shell-auto-provision-pi-");
123
+ const home = join(root, ".gentle-shell", "agent");
124
+ if (c.record !== undefined) {
125
+ mkdirSync(home, { recursive: true });
126
+ writeFileSync(join(home, "settings.json"), "{}");
127
+ writeFileSync(join(root, ".gentle-shell", "config.json"), JSON.stringify({ provisioned: { [home]: { ...c.record, at: "2026-01-01T00:00:00.000Z" } } }, null, 2));
128
+ }
129
+ c.seed?.(root);
130
+ const pi = fakePi(tools);
131
+ const env: NodeJS.ProcessEnv = {
132
+ HOME: root, USERPROFILE: root, PATH: process.env.PATH, SystemRoot: process.env.SystemRoot, ComSpec: process.env.ComSpec,
133
+ GENTLE_SHELL_SKIP_STARTUP_UPDATE: "1", GENTLE_SHELL_PI: pi.path, ENGRAM_URL: "http://127.0.0.1:9",
134
+ GENTLE_SHELL_GENTLE_AI_PIN: c.pin ?? "3.6.0", GENTLE_SHELL_GENTLE_AI_BIN: join(root, "missing-gentle-ai"), GENTLE_PI_SKIP_GENTLE_AI_INSTALL: "1",
135
+ ...c.env,
136
+ };
137
+ const argv = c.argv?.(root) ?? ["-p", "x"];
138
+ const result = spawnSync(process.execPath, [binPath, ...argv], { env, encoding: "utf8", input: "", timeout: 60000 });
139
+
140
+ assert.equal(result.status, 0, result.stderr);
141
+ const lines = result.stderr.split("\n").filter((line) => line.length > 0);
142
+ const expected = c.expect(root, home);
143
+ assert.deepEqual(lines.slice(0, expected.length), expected);
144
+ // A failed attempt also prints Gentle AI's missing-binary detail; nothing else follows otherwise.
145
+ if (c.attempted) assert.ok(lines.some((line) => line.startsWith("package-local-binary-missing: ")), result.stderr);
146
+ else assert.equal(lines.length, expected.length, result.stderr);
147
+ assert.equal(result.stderr.includes("automatic setup failed"), c.attempted);
148
+ // Pi is still launched with the prompt after the attempt (or without one).
149
+ assert.ok(existsSync(pi.log));
150
+ assert.match(readFileSync(pi.log, "utf8"), /-p x/);
151
+ });
152
+ }