gentle-pi 4.8.0 → 4.9.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 (370) hide show
  1. package/README.md +60 -0
  2. package/assets/agents/gentle-ai-explore.md +1 -1
  3. package/assets/agents/gentle-ai-verify.md +1 -1
  4. package/assets/agents/gentle-ai-worker.md +10 -9
  5. package/assets/design-canvas/canvas-boards.js +22 -2
  6. package/assets/design-canvas/canvas-boot.js +3 -1
  7. package/assets/design-canvas/canvas-i18n-es.js +5 -0
  8. package/assets/design-canvas/canvas-menu.js +13 -7
  9. package/assets/design-canvas/canvas-messages.js +1 -1
  10. package/assets/design-canvas/canvas-rail.js +5 -2
  11. package/assets/design-canvas/canvas-store.js +3 -0
  12. package/assets/design-canvas/canvas-theme.js +69 -0
  13. package/assets/design-canvas/canvas.css +27 -2
  14. package/assets/design-canvas/index.html +3 -0
  15. package/assets/design-canvas/inspector.js +28 -5
  16. package/assets/design-canvas/theme-early.js +10 -0
  17. package/assets/migrations/agent-body-history.json +6 -0
  18. package/assets/orchestrator-delegation.md +1 -5
  19. package/assets/orchestrator-full-delegation-card.md +9 -13
  20. package/assets/orchestrator-full-delegation.md +2 -2
  21. package/assets/orchestrator-memory.md +2 -2
  22. package/assets/orchestrator-prompts.md +3 -31
  23. package/assets/orchestrator-tracking.md +6 -6
  24. package/assets/orchestrator-verification.md +4 -4
  25. package/assets/orchestrator-writer.md +12 -12
  26. package/assets/orchestrator.md +2 -2
  27. package/bin/gentle-shell.mjs +77 -1
  28. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +7 -7
  29. package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/manifest.json +3 -3
  30. package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/orchestration/pi.md +1 -1
  31. package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/routing/pi.md +10 -10
  32. package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/generated/provider-capabilities.baseline.json +3 -3
  33. package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/generated/provider-roles.baseline.json +1 -1
  34. package/docs/assets/features/gentle-tower.png +0 -0
  35. package/docs/auto-permission-answers.md +1 -1
  36. package/docs/bundled-install.md +1 -1
  37. package/docs/delegated-verification.md +6 -4
  38. package/docs/desktop-feed.md +303 -0
  39. package/docs/desktop-rpc.md +703 -25
  40. package/docs/fast-mode.md +2 -2
  41. package/docs/gentle-shell-desktop.md +465 -0
  42. package/docs/gentle-shell.md +65 -3
  43. package/docs/images/desktop/chat.png +0 -0
  44. package/docs/images/desktop/palette.png +0 -0
  45. package/docs/images/desktop/todo.png +0 -0
  46. package/docs/install-wizard.md +1 -1
  47. package/docs/odd-preparation-continuity.md +1 -1
  48. package/docs/readme-reference.md +44 -15
  49. package/docs/work-continuity.md +10 -7
  50. package/extensions/ask-user-choice.ts +36 -18
  51. package/extensions/ask-user-question.ts +47 -8
  52. package/extensions/gentle-agents.ts +206 -37
  53. package/extensions/gentle-ai.ts +234 -24
  54. package/extensions/gentle-desktop-feed.ts +778 -0
  55. package/extensions/gentle-desktop-rpc.ts +145 -12
  56. package/extensions/gentle-herdr-desktop-status.ts +275 -0
  57. package/extensions/gentle-shell.ts +69 -7
  58. package/extensions/gentle-stats.ts +30 -1
  59. package/extensions/gentle-tower.ts +305 -0
  60. package/extensions/skill-registry.ts +13 -3
  61. package/herdr/RECIPE.md +157 -0
  62. package/herdr/keys.json +14 -0
  63. package/herdr/layouts/gentle-shell.json +202 -0
  64. package/herdr/mods/gentle-agents/icons/kind-herdr.svg +1 -0
  65. package/herdr/mods/gentle-agents/icons/kind-remote.svg +1 -0
  66. package/herdr/mods/gentle-agents/icons/kind-tui.svg +1 -0
  67. package/herdr/mods/gentle-agents/main.js +190 -0
  68. package/herdr/mods/gentle-agents/mod.json +1 -0
  69. package/herdr/mods/gentle-agents/snapshot.js +469 -0
  70. package/herdr/mods/gentle-agents/tokens.js +273 -0
  71. package/herdr/mods/gentle-chat/MINIMAL.md +69 -0
  72. package/herdr/mods/gentle-chat/actions.js +180 -0
  73. package/herdr/mods/gentle-chat/feed.js +321 -0
  74. package/herdr/mods/gentle-chat/icons/branch.svg +1 -0
  75. package/herdr/mods/gentle-chat/icons/chat.svg +1 -0
  76. package/herdr/mods/gentle-chat/icons/check.svg +1 -0
  77. package/herdr/mods/gentle-chat/icons/chev.svg +1 -0
  78. package/herdr/mods/gentle-chat/icons/clip.svg +1 -0
  79. package/herdr/mods/gentle-chat/icons/down.svg +1 -0
  80. package/herdr/mods/gentle-chat/icons/folder.svg +1 -0
  81. package/herdr/mods/gentle-chat/icons/kind-herdr.svg +1 -0
  82. package/herdr/mods/gentle-chat/icons/kind-remote.svg +1 -0
  83. package/herdr/mods/gentle-chat/icons/kind-tui.svg +1 -0
  84. package/herdr/mods/gentle-chat/icons/mark.svg +1 -0
  85. package/herdr/mods/gentle-chat/icons/send.svg +1 -0
  86. package/herdr/mods/gentle-chat/icons/shield.svg +1 -0
  87. package/herdr/mods/gentle-chat/icons/stop.svg +1 -0
  88. package/herdr/mods/gentle-chat/icons/term.svg +1 -0
  89. package/herdr/mods/gentle-chat/icons/user.svg +1 -0
  90. package/herdr/mods/gentle-chat/icons/x.svg +1 -0
  91. package/herdr/mods/gentle-chat/main.js +968 -0
  92. package/herdr/mods/gentle-chat/mod.json +1 -0
  93. package/herdr/mods/gentle-chat/session.js +212 -0
  94. package/herdr/mods/gentle-chat/snapshot.js +469 -0
  95. package/herdr/mods/gentle-chat/tokens.js +137 -0
  96. package/herdr/mods/gentle-chat/ui.js +883 -0
  97. package/herdr/mods/gentle-confirm/main.js +60 -0
  98. package/herdr/mods/gentle-confirm/mod.json +1 -0
  99. package/herdr/mods/gentle-inspector/actions.js +180 -0
  100. package/herdr/mods/gentle-inspector/icons/bolt.svg +1 -0
  101. package/herdr/mods/gentle-inspector/icons/bot.svg +1 -0
  102. package/herdr/mods/gentle-inspector/icons/check.svg +1 -0
  103. package/herdr/mods/gentle-inspector/icons/db.svg +1 -0
  104. package/herdr/mods/gentle-inspector/icons/diff.svg +1 -0
  105. package/herdr/mods/gentle-inspector/icons/jobs.svg +1 -0
  106. package/herdr/mods/gentle-inspector/icons/plug.svg +1 -0
  107. package/herdr/mods/gentle-inspector/icons/review.svg +1 -0
  108. package/herdr/mods/gentle-inspector/icons/stats.svg +1 -0
  109. package/herdr/mods/gentle-inspector/icons/stop.svg +1 -0
  110. package/herdr/mods/gentle-inspector/icons/todo.svg +1 -0
  111. package/herdr/mods/gentle-inspector/main.js +500 -0
  112. package/herdr/mods/gentle-inspector/mod.json +1 -0
  113. package/herdr/mods/gentle-inspector/snapshot.js +469 -0
  114. package/herdr/mods/gentle-inspector/tokens.js +273 -0
  115. package/herdr/mods/gentle-palette/actions.js +180 -0
  116. package/herdr/mods/gentle-palette/icons/bolt.svg +1 -0
  117. package/herdr/mods/gentle-palette/icons/bot.svg +1 -0
  118. package/herdr/mods/gentle-palette/icons/chat.svg +1 -0
  119. package/herdr/mods/gentle-palette/icons/check.svg +1 -0
  120. package/herdr/mods/gentle-palette/icons/cmd.svg +1 -0
  121. package/herdr/mods/gentle-palette/icons/diff.svg +1 -0
  122. package/herdr/mods/gentle-palette/icons/jobs.svg +1 -0
  123. package/herdr/mods/gentle-palette/icons/plus.svg +1 -0
  124. package/herdr/mods/gentle-palette/icons/review.svg +1 -0
  125. package/herdr/mods/gentle-palette/icons/search.svg +1 -0
  126. package/herdr/mods/gentle-palette/icons/shield.svg +1 -0
  127. package/herdr/mods/gentle-palette/icons/stats.svg +1 -0
  128. package/herdr/mods/gentle-palette/icons/stop.svg +1 -0
  129. package/herdr/mods/gentle-palette/icons/term.svg +1 -0
  130. package/herdr/mods/gentle-palette/icons/todo.svg +1 -0
  131. package/herdr/mods/gentle-palette/main.js +333 -0
  132. package/herdr/mods/gentle-palette/mod.json +1 -0
  133. package/herdr/mods/gentle-palette/snapshot.js +469 -0
  134. package/herdr/mods/gentle-palette/tokens.js +273 -0
  135. package/herdr/mods/gentle-pane/icons/chat.svg +1 -0
  136. package/herdr/mods/gentle-pane/icons/close.svg +1 -0
  137. package/herdr/mods/gentle-pane/icons/kind-herdr.svg +1 -0
  138. package/herdr/mods/gentle-pane/icons/kind-remote.svg +1 -0
  139. package/herdr/mods/gentle-pane/icons/kind-tui.svg +1 -0
  140. package/herdr/mods/gentle-pane/icons/split-down.svg +1 -0
  141. package/herdr/mods/gentle-pane/icons/split-right.svg +1 -0
  142. package/herdr/mods/gentle-pane/icons/term.svg +1 -0
  143. package/herdr/mods/gentle-pane/icons/unzoom.svg +1 -0
  144. package/herdr/mods/gentle-pane/icons/zoom.svg +1 -0
  145. package/herdr/mods/gentle-pane/main.js +91 -0
  146. package/herdr/mods/gentle-pane/mod.json +1 -0
  147. package/herdr/mods/gentle-pane/snapshot.js +469 -0
  148. package/herdr/mods/gentle-pane/tokens.js +273 -0
  149. package/herdr/mods/gentle-sidebar/actions.js +180 -0
  150. package/herdr/mods/gentle-sidebar/icons/gear.svg +1 -0
  151. package/herdr/mods/gentle-sidebar/icons/mark.svg +1 -0
  152. package/herdr/mods/gentle-sidebar/icons/refresh.svg +1 -0
  153. package/herdr/mods/gentle-sidebar/icons/server-plus.svg +1 -0
  154. package/herdr/mods/gentle-sidebar/main.js +171 -0
  155. package/herdr/mods/gentle-sidebar/mod.json +1 -0
  156. package/herdr/mods/gentle-sidebar/snapshot.js +469 -0
  157. package/herdr/mods/gentle-sidebar/tokens.js +273 -0
  158. package/herdr/mods/gentle-spaces/icons/kind-herdr.svg +1 -0
  159. package/herdr/mods/gentle-spaces/icons/kind-remote.svg +1 -0
  160. package/herdr/mods/gentle-spaces/icons/kind-tui.svg +1 -0
  161. package/herdr/mods/gentle-spaces/icons/monitor.svg +1 -0
  162. package/herdr/mods/gentle-spaces/icons/plus.svg +1 -0
  163. package/herdr/mods/gentle-spaces/icons/server.svg +1 -0
  164. package/herdr/mods/gentle-spaces/machines.js +31 -0
  165. package/herdr/mods/gentle-spaces/main.js +299 -0
  166. package/herdr/mods/gentle-spaces/mod.json +1 -0
  167. package/herdr/mods/gentle-spaces/snapshot.js +469 -0
  168. package/herdr/mods/gentle-spaces/tokens.js +273 -0
  169. package/herdr/mods/gentle-status/actions.js +180 -0
  170. package/herdr/mods/gentle-status/main.js +192 -0
  171. package/herdr/mods/gentle-status/mod.json +1 -0
  172. package/herdr/mods/gentle-status/snapshot.js +469 -0
  173. package/herdr/mods/gentle-status/tokens.js +273 -0
  174. package/herdr/mods/gentle-tabs/icons/close.svg +1 -0
  175. package/herdr/mods/gentle-tabs/icons/kind-herdr.svg +1 -0
  176. package/herdr/mods/gentle-tabs/icons/kind-remote.svg +1 -0
  177. package/herdr/mods/gentle-tabs/icons/kind-tui.svg +1 -0
  178. package/herdr/mods/gentle-tabs/icons/plus.svg +1 -0
  179. package/herdr/mods/gentle-tabs/icons/win-close.svg +1 -0
  180. package/herdr/mods/gentle-tabs/icons/win-max.svg +1 -0
  181. package/herdr/mods/gentle-tabs/icons/win-min.svg +1 -0
  182. package/herdr/mods/gentle-tabs/icons/win-restore.svg +1 -0
  183. package/herdr/mods/gentle-tabs/main.js +171 -0
  184. package/herdr/mods/gentle-tabs/mod.json +1 -0
  185. package/herdr/mods/gentle-tabs/snapshot.js +469 -0
  186. package/herdr/mods/gentle-tabs/tokens.js +273 -0
  187. package/herdr/mods/gentle-tokens/main.js +20 -0
  188. package/herdr/mods/gentle-tokens/mod.json +1 -0
  189. package/herdr/mods/gentle-tokens/snapshot.js +469 -0
  190. package/herdr/mods/gentle-tokens/tokens.js +273 -0
  191. package/herdr/preview.png +0 -0
  192. package/herdr/themes/gentle-shell-dark.json +33 -0
  193. package/herdr/themes/gentle-shell-light.json +34 -0
  194. package/lib/agents-protocol.ts +2 -0
  195. package/lib/agents-rpc-publisher.ts +39 -12
  196. package/lib/agents-runner.ts +1 -0
  197. package/lib/auto-permission-answers.ts +2 -1
  198. package/lib/background-jobs.ts +22 -2
  199. package/lib/bounded-writer-admission.ts +1 -1
  200. package/lib/change-diff.ts +104 -0
  201. package/lib/commit-slice-signal.ts +1 -1
  202. package/lib/design-canvas-assets.ts +2 -0
  203. package/lib/desktop-agents-service.ts +31 -10
  204. package/lib/desktop-changes-service.ts +171 -0
  205. package/lib/desktop-feed-actions.ts +804 -0
  206. package/lib/desktop-feed-answers.ts +129 -0
  207. package/lib/desktop-feed-sources.ts +184 -0
  208. package/lib/desktop-feed-stats.ts +98 -0
  209. package/lib/desktop-feed-store.ts +124 -0
  210. package/lib/desktop-feed.ts +788 -0
  211. package/lib/desktop-jobs-service.ts +34 -7
  212. package/lib/desktop-review-service.ts +187 -0
  213. package/lib/desktop-rpc-agents.ts +112 -3
  214. package/lib/desktop-rpc-changes.ts +223 -0
  215. package/lib/desktop-rpc-config-watch.ts +285 -0
  216. package/lib/desktop-rpc-config.ts +162 -8
  217. package/lib/desktop-rpc-jobs.ts +118 -9
  218. package/lib/desktop-rpc-permissions.ts +154 -3
  219. package/lib/desktop-rpc-review.ts +180 -0
  220. package/lib/desktop-rpc-session.ts +203 -0
  221. package/lib/desktop-rpc-sessions.ts +250 -0
  222. package/lib/desktop-rpc-stats.ts +187 -0
  223. package/lib/desktop-rpc-updates.ts +143 -0
  224. package/lib/desktop-rpc.ts +116 -5
  225. package/lib/desktop-session-service.ts +223 -0
  226. package/lib/desktop-sessions-service.ts +249 -0
  227. package/lib/desktop-stats-service.ts +142 -0
  228. package/lib/desktop-updates-service.ts +268 -0
  229. package/lib/gentle-shell-desktop.ts +1370 -0
  230. package/lib/gentle-shell-launcher.ts +45 -3
  231. package/lib/herdr-desktop-events.ts +40 -0
  232. package/lib/herdr-desktop-status.ts +229 -0
  233. package/lib/jobs-sidebar-state.ts +5 -0
  234. package/lib/native-review-cli.ts +7 -0
  235. package/lib/openai-fast-tier.ts +1 -0
  236. package/lib/session-profile-freeze.ts +13 -5
  237. package/lib/stats-collector.ts +56 -27
  238. package/lib/tower-actions.ts +100 -0
  239. package/lib/tower-hub.ts +73 -0
  240. package/lib/tower-launch.ts +111 -0
  241. package/lib/tower-open.ts +99 -0
  242. package/lib/tower-presence.ts +70 -0
  243. package/lib/tower-server.ts +234 -0
  244. package/lib/tower-snapshot.ts +298 -0
  245. package/lib/update-status.ts +238 -0
  246. package/lib/verifier-settle-reminder.ts +1 -1
  247. package/package.json +13 -4
  248. package/runtime/design-canvas-assets.mjs +2 -0
  249. package/runtime/gentle-shell-desktop.mjs +1371 -0
  250. package/runtime/gentle-shell-launcher.mjs +44 -2
  251. package/runtime/native-review-cli.mjs +7 -0
  252. package/runtime/tower-actions.mjs +101 -0
  253. package/runtime/tower-hub.mjs +74 -0
  254. package/runtime/tower-launch.mjs +112 -0
  255. package/runtime/tower-open.mjs +100 -0
  256. package/runtime/tower-presence.mjs +71 -0
  257. package/runtime/tower-server.mjs +234 -0
  258. package/runtime/tower-snapshot.mjs +299 -0
  259. package/scripts/build-full-delegation-card.mjs +1 -21
  260. package/scripts/build-runtime-modules.mjs +9 -0
  261. package/scripts/gentle-ai-installer.mjs +10 -10
  262. package/scripts/verify-package-files.mjs +35 -15
  263. package/skills/provider-defect-report/SKILL.md +61 -0
  264. package/skills/rdd-defect-workflow/SKILL.md +3 -3
  265. package/tests/agent-prompt-diet-contract.test.ts +2 -2
  266. package/tests/append-system-prompt-route.test.ts +16 -5
  267. package/tests/ask-user-choice.test.ts +78 -21
  268. package/tests/ask-user-question.test.ts +59 -5
  269. package/tests/auto-permission-answers.test.ts +12 -1
  270. package/tests/background-jobs.test.ts +12 -0
  271. package/tests/bounded-stop-contract.test.ts +139 -26
  272. package/tests/change-diff.test.ts +75 -0
  273. package/tests/commit-slice-signal.test.ts +3 -2
  274. package/tests/decision-routing-contract.test.ts +390 -0
  275. package/tests/delegated-key-learnings-contract.test.ts +21 -28
  276. package/tests/delivery-b-rendered-surfaces.test.ts +32 -0
  277. package/tests/design-canvas-i18n.test.ts +24 -22
  278. package/tests/design-canvas-inspector.test.ts +67 -0
  279. package/tests/design-canvas-modules.test.ts +3 -2
  280. package/tests/design-canvas-rail.test.ts +10 -10
  281. package/tests/design-canvas-store.test.ts +9 -0
  282. package/tests/design-canvas-theme.test.ts +198 -0
  283. package/tests/design-canvas-tokens.test.ts +1 -1
  284. package/tests/desktop-feed-actions-guards.test.ts +595 -0
  285. package/tests/desktop-feed-actions.test.ts +761 -0
  286. package/tests/desktop-feed-live-work.test.ts +209 -0
  287. package/tests/desktop-feed-performance.test.ts +369 -0
  288. package/tests/desktop-feed-plan-profiles.test.ts +509 -0
  289. package/tests/desktop-feed-send-prompt.test.ts +303 -0
  290. package/tests/desktop-feed-tool-summaries.test.ts +69 -0
  291. package/tests/desktop-feed.test.ts +615 -0
  292. package/tests/desktop-rpc-agents.test.ts +428 -2
  293. package/tests/desktop-rpc-changes.test.ts +608 -0
  294. package/tests/desktop-rpc-config-watch.test.ts +1159 -0
  295. package/tests/desktop-rpc-config.test.ts +11 -1
  296. package/tests/desktop-rpc-design.test.ts +11 -1
  297. package/tests/desktop-rpc-jobs.test.ts +402 -5
  298. package/tests/desktop-rpc-permissions.test.ts +11 -1
  299. package/tests/desktop-rpc-review.test.ts +678 -0
  300. package/tests/desktop-rpc-session.test.ts +642 -0
  301. package/tests/desktop-rpc-sessions.test.ts +647 -0
  302. package/tests/desktop-rpc-stats.test.ts +431 -0
  303. package/tests/desktop-rpc-updates.test.ts +525 -0
  304. package/tests/desktop-rpc-usage.test.ts +11 -1
  305. package/tests/desktop-rpc.test.ts +43 -2
  306. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +11 -13
  307. package/tests/fixtures/session-profile-v1/replay.ts +4 -1
  308. package/tests/full-delegation-closure.test.ts +20 -1
  309. package/tests/gentle-agents.test.ts +519 -4
  310. package/tests/gentle-ai-binary.test.ts +1 -1
  311. package/tests/gentle-ai-installer.test.ts +52 -52
  312. package/tests/gentle-ai.test.ts +75 -16
  313. package/tests/gentle-fast.test.ts +15 -0
  314. package/tests/gentle-herdr-desktop-status.test.ts +595 -0
  315. package/tests/gentle-shell-desktop-bin.test.ts +125 -0
  316. package/tests/gentle-shell-desktop.test.ts +927 -0
  317. package/tests/gentle-shell-launcher-tower.test.ts +104 -0
  318. package/tests/gentle-shell.test.ts +3 -0
  319. package/tests/gentle-tower.test.ts +578 -0
  320. package/tests/herdr-desktop-status.test.ts +285 -0
  321. package/tests/independent-recovery-delivery.test.ts +16 -4
  322. package/tests/installer-server.test.ts +2 -2
  323. package/tests/lazy-module-contradictions-contract.test.ts +27 -4
  324. package/tests/maintainer/desktop-rpc.maintest.ts +279 -4
  325. package/tests/native-review-capability-contract.test.ts +9 -1
  326. package/tests/no-self-pause-contract.test.ts +23 -13
  327. package/tests/odd-routing-canonical-ratchet.test.ts +10 -0
  328. package/tests/odd-routing-contract.test.ts +19 -3
  329. package/tests/orchestrator-budget.test.ts +3 -1
  330. package/tests/orchestrator-prompt-budget.test.ts +2 -1
  331. package/tests/orchestrator-prompt-diet-contract.test.ts +31 -3
  332. package/tests/package-manifest.test.ts +10 -10
  333. package/tests/pi-routing-measured-values.test.ts +24 -0
  334. package/tests/primary-session-prompt.test.ts +25 -0
  335. package/tests/profile-fast-tier.test.ts +66 -1
  336. package/tests/provider-defect-handoff.test.ts +118 -100
  337. package/tests/review-contract-prompt.test.ts +2 -1
  338. package/tests/review-due-public-boundary.test.ts +2 -1
  339. package/tests/sensitive-path-tools.test.ts +138 -4
  340. package/tests/session-profile-extension.test.ts +310 -16
  341. package/tests/session-profile-freeze.test.ts +26 -0
  342. package/tests/session-profile-v1-compat.test.ts +20 -0
  343. package/tests/skill-collision-prefixes.test.ts +1 -0
  344. package/tests/skill-contradictions-contract.test.ts +5 -3
  345. package/tests/skill-registry.test.ts +54 -0
  346. package/tests/stats-collector.test.ts +109 -2
  347. package/tests/support/design-canvas-dom.ts +17 -0
  348. package/tests/task-size-routing-contract.test.ts +7 -3
  349. package/tests/tower-actions.test.ts +247 -0
  350. package/tests/tower-artifacts.test.ts +114 -0
  351. package/tests/tower-open.test.ts +97 -0
  352. package/tests/tower-presence.test.ts +175 -0
  353. package/tests/tower-server.test.ts +122 -0
  354. package/tests/tower-snapshot.test.ts +236 -0
  355. package/tests/tower-web-echo.test.ts +125 -0
  356. package/tests/tower-web-hover.test.ts +251 -0
  357. package/tests/verification-scoped-stop-contract.test.ts +32 -0
  358. package/tests/verification-tiers-contract.test.ts +5 -5
  359. package/tests/verifier-settle-reminder.test.ts +2 -2
  360. package/tests/verify-first-launch-contract.test.ts +2 -2
  361. package/tests/work-continuity-contract.test.ts +83 -17
  362. package/tests/writer-rejection-next-step.test.ts +55 -0
  363. package/tests/writer-surface-authority-contract.test.ts +158 -0
  364. /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/README.md +0 -0
  365. /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/schemas/lens.schema.json +0 -0
  366. /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/schemas/refuter.schema.json +0 -0
  367. /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  368. /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/vectors/lens.json +0 -0
  369. /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/vectors/refuter.json +0 -0
  370. /package/contracts/review-provider-contract-mirror/{v1.5.0 → v1.6.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -63,7 +63,7 @@ import {
63
63
  } from "node:fs/promises";
64
64
  import { homedir } from "node:os";
65
65
  import { PROVIDER_REVIEW_ROLES, discoverAgents, loadAgentsConfig, unmatchedProfileKeys } from "../lib/agents-config.ts";
66
- import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
66
+ import { dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
67
67
  import { fileURLToPath } from "node:url";
68
68
  import type {
69
69
  ExtensionAPI,
@@ -152,7 +152,7 @@ import { createSessionProfileIntegration, hasPendingSessionProfileSelection, rea
152
152
  import { publishSessionProfileOutcome, readSessionProfileAuthority, requireSessionProfileAuthority } from "../lib/session-profile-authority.ts";
153
153
  import { isSessionProfileFamilyEntry, type SessionProfileStartupState } from "../lib/session-profile-persistence.ts";
154
154
  import type { SessionProfileAppendOutcome } from "../lib/session-profile-append-controller.ts";
155
- import { freezeSessionProfileAtOwnStart, profileFollowEnabled, readSessionProfileOwnStartup, resolveSessionProfile, sessionProfileLabel, sessionProfileModelProfiles, sessionProfileRoutingAt, setFrozenDefaultOrchestrator } from "../lib/session-profile-freeze.ts";
155
+ import { freezeSessionProfileAtOwnStart, profileFollowEnabled, readFrozenDefaultOrchestrator, readSessionProfileOwnStartup, resolveSessionProfile, sessionProfileLabel, sessionProfileModelProfiles, sessionProfileRoutingAt, setFrozenDefaultOrchestrator } from "../lib/session-profile-freeze.ts";
156
156
  import {
157
157
  applyOrchestratorSettings,
158
158
  readOrchestratorSettings,
@@ -172,6 +172,13 @@ import {
172
172
  type DesktopProfileNote,
173
173
  type DesktopProfilesService,
174
174
  } from "../lib/desktop-rpc-profiles.ts";
175
+ import {
176
+ DESKTOP_REVIEW_SERVICE_CHANNEL,
177
+ DESKTOP_REVIEW_SERVICE_SCHEMA,
178
+ type DesktopReviewOwnerRead,
179
+ type DesktopReviewOwnerWrite,
180
+ type DesktopReviewService,
181
+ } from "../lib/desktop-rpc-review.ts";
175
182
  import {
176
183
  REVIEW_HOST_RELAY_FAILURE,
177
184
  REVIEW_HOST_RELAY_PI_TIMEOUT_ENV,
@@ -1683,6 +1690,10 @@ function resolveSessionDelegationMode(
1683
1690
 
1684
1691
  const TEST_FIRST_PRINCIPLE = "- For behavior changes with applicable runnable deterministic tests and a clear expected outcome, use test-first by default: observe RED, GREEN, then refactor with focused checks. Write one RED test per requested rule. For every existing command or option the change touches, add one test proving its previous behavior still holds; add no other cases. An existing behavior counts as touched when it shares the code you changed (options, parsers, helpers, validation). Only when your diff changes shared code (options, parsers, helpers) that an existing command the request did not name also uses, run one differential check before finishing, as a single script: for each such command, run it with the new or changed input (for example a new option passed to a sibling subcommand) against the previous code (a copy of the base commit in a `mktemp -d` scratch directory, never committed as a test; committed tests never read git history or a fixed commit) and against your change, and compare stdout, stderr, and exit code; any difference nobody asked for is a regression to fix and pin with a test. Test presence alone does not establish applicability; no chat or TUI toggle activates it. For passive documentation, non-testable changes, an unavailable runner, or no meaningful RED, explain why and run proportionate ordinary functional or structural verification. Never invent lifecycle evidence or skip checks. Follow orchestrator-delegation.md for ODD forwarding and evidence.";
1685
1692
  const FULL_DELEGATION_TEST_FIRST_PRINCIPLE = "- Writers apply test-first (RED, GREEN, PRESERVE with its differential check) from their own contract; forward it in every writer handoff and require their observed RED/GREEN evidence or stated exception. Never invent lifecycle evidence or skip checks.";
1693
+ // orchestrator-owns-correction-exhaustion S2: after a worker exhausts its limit the parent decides the next step
1694
+ // from the diagnosed cause; only organic mode may fix it inline, full delegation launches a new bounded writer.
1695
+ const EXHAUSTION_ROUTE = "fix inline if small and understood, or relaunch with changed scope, hypothesis or handoff plus new evidence";
1696
+ const FULL_DELEGATION_EXHAUSTION_ROUTE = "never edit: launch a new bounded writer with the diagnosis, new evidence and changed scope or hypothesis";
1686
1697
 
1687
1698
  function buildGentlePrompt(
1688
1699
  persona: PersonaMode,
@@ -1699,6 +1710,7 @@ function buildGentlePrompt(
1699
1710
  // cost-speed-painpoints S5: writers apply the test-first procedure from their own
1700
1711
  // contract; a full delegation parent only forwards it and checks the evidence.
1701
1712
  const testFirstPrinciple = delegationMode === DEFAULT_ORCHESTRATOR_MODE ? TEST_FIRST_PRINCIPLE : FULL_DELEGATION_TEST_FIRST_PRINCIPLE;
1713
+ const exhaustionRoute = delegationMode === DEFAULT_ORCHESTRATOR_MODE ? EXHAUSTION_ROUTE : FULL_DELEGATION_EXHAUSTION_ROUTE;
1702
1714
  return `## el Gentleman Identity and Harness
1703
1715
 
1704
1716
  Current persona mode: ${persona}
@@ -1716,21 +1728,19 @@ ${personaPrompt}
1716
1728
 
1717
1729
  ## Authorized work continuity
1718
1730
 
1719
- An authorized outcome includes its necessary in-scope implementation, documentation and verification steps. Continue those steps without asking the human to approve each transition. Never end a turn merely announcing an immediately executable authorized next step; execute it instead. A progress update is not a request for permission.
1731
+ An authorized outcome includes its necessary in-scope implementation, documentation and verification steps. Continue those steps without asking the human to approve each transition. Never end a turn merely announcing an immediately executable authorized next step; execute it instead. A progress update is not a request for permission. An explicit user stop applies only to the work it names.
1720
1732
 
1721
1733
  Interpret short replies such as "yes", "go ahead", or "eso mismo" against the immediately preceding proposal. When the human unambiguously accepts a concrete implementation action they already understand, execute that action within its agreed scope without asking again. Confirming a preference alone does not authorize implementation; genuinely unclear change intent still requires one focused question. Contextual approval never substitutes for provider-owned consent, exact-token authorization, or separate publishing and destructive-action permission.
1722
1734
 
1723
- Resolving an incident or subdecision does not complete or cancel the original authorized objective; resume safe, necessary in-scope steps automatically, using judgment for proportionate recovery and respecting explicit user dispositions. Investigate pending technical uncertainty rather than treating it alone as a new human decision.
1724
-
1725
- Stop for an unresolved consequential scope/product decision, required explicit consent, a denied action, or the human's explicit stop. Unavailable required proof blocks completion and delivery; it does not alone prohibit specifically authorized in-scope implementation where actual native authority and other limits permit it. Do not infer permission for publishing, destructive actions, unrelated scope or native consent from this continuity rule. Report a concrete blocker and the exact decision needed rather than requesting a generic "continue".
1735
+ Resolving an incident or subdecision does not complete or cancel the original authorized objective; resume safe, necessary in-scope steps automatically, using judgment for proportionate recovery and respecting explicit user dispositions. Do not infer permission for publishing, destructive actions, unrelated scope or native consent from this continuity rule.
1726
1736
 
1727
- Before a terminal bounded-stop outcome, distinguish a recoverable technical or harness failure from genuinely inaccessible required proof. A failed test or harness check may be corrected and rerun without another authorization only within the authorized scope and existing correction budget, subject to every applicable limit. Honor explicit one run, no retries, or diagnostic-only limits; stop for permission denial, required new consent, or exhausted budget. Do not propose diagnostic-only or single-attempt authorization unless the human requested it. Respect terminal review and verification outcomes and existing bounded-stop rules: never reset budgets, add retry allowances, weaken checks, or override final outcomes.
1737
+ Honor explicit one-run, no-retry, or diagnostic-only limits. Correct a failing check only within the existing correction budget; never reset budgets, add retry allowances, weaken checks, or override final outcomes.
1728
1738
 
1729
- An exhausted worker-local correction limit ends that automatic cycle, not necessarily the feature. Partial worker execution is not by itself exhausted proof or a terminal native review outcome. Stop and report the remaining work, failed checks and missing proof, and offer an explicit human-controlled bounded continuation. Name its scope, executor, correction limit and checks, or let the human stop. Before any worker continuation, confirm no child is active or has an uncertain status. The Close stop ends the cycle; later explicit requests stay subject to native authority. Quota recovery: \`orchestrator-quota-recovery.md\`. A new session does not reset any limit. When specifically authorized and not prohibited by actual native authority, continue ordinary in-scope compilation or implementation; unavailable proof still blocks completion and delivery.
1739
+ An exhausted worker-local correction limit ends that worker's cycle, not the unit; within native authority you own the next step, unasked. Partial worker execution is not by itself exhausted proof or a terminal native review outcome. Name the loop's cause from the evidence; act on it: ${exhaustionRoute}; never repeat an attempt or swap executors to dodge limits. Same cause again or no new hypothesis: block the unit; continue independent work. Before any worker continuation, confirm no child is active or has an uncertain status. The Close stop ends the cycle; later explicit requests stay subject to native authority. Quota recovery: \`orchestrator-quota-recovery.md\`. A new session does not reset any limit.
1730
1740
 
1731
1741
  For worker-prohibited maintenance or rollback, worker prohibitions remain unchanged. The parent only may perform the operation when the human explicitly authorized the operation itself, exact scope, ownership, and preservation are established, and available permitted tools can perform it; fresh runtime/native consent and guards remain binding. A broad feature authorization is not destructive authority; never substitute another worker or tool to bypass a denial. For an upgrade require a validated backup, artifact and migration validation where applicable, and a recovery path. For rollback preserve unrelated edits even in the same file, remove only proven task-created helpers, and never blanket restore, reset, or clean. Stop when ambiguous ownership or denial stops the operation, or any prerequisite is missing. This route is guidance, not authorization.
1732
1742
 
1733
- For background work, launch the bounded action and end the turn when no independent in-scope work remains. Retain its identity and resume the already-authorized continuation automatically on its completion event; do not ask the human to say "continue", poll, or claim completion while checks remain pending.
1743
+ For background work, launch the bounded action and end the turn when no independent in-scope work remains. Retain its identity and resume the already-authorized continuation automatically on its completion event; do not ask the human to say "continue" or poll.
1734
1744
 
1735
1745
  Default workflow: Organic Driven Development (MANDATORY)
1736
1746
  Organic Driven Development (ODD) is the predefined workflow of this orchestrator. Every request enters it, without the user asking for a workflow, a plan, or task tracking. Never describe this workflow only when asked about it: run it. Run these steps in this order on every request:
@@ -2250,9 +2260,109 @@ function normalizePolicyPath(value: string): string {
2250
2260
  return value.trim().replace(/^~(?=[/\\]|$)/, homedir()).replace(/\\/g, "/").toLowerCase();
2251
2261
  }
2252
2262
 
2253
- function isSensitivePath(value: string): boolean {
2263
+ // Gentle Shell Desktop (odd/tasks/herdr-desktop.md T7): the inbox, outbox and
2264
+ // snapshots under `<agentDir>/desktop/` are the human's channel into a live
2265
+ // session; the agent never writes an action there. Only the real folders are
2266
+ // guarded, never a project folder that happens to be named `agent/desktop`:
2267
+ // `<home>/desktop` for the resolved Gentle Pi agent home (the one the desktop
2268
+ // feed writes under) and the two standard homes, compared as normalized
2269
+ // absolute paths. `~`, `$HOME` and `${HOME}` expand, `.` and `..` resolve
2270
+ // lexically, and a relative path resolves against the tool call's cwd (a
2271
+ // relative path with no cwd never matches), so a project folder that is named
2272
+ // `agent/desktop` stays outside the guard while `../../.gentle-shell/...` from
2273
+ // the project does not. Case folds like the patterns.
2274
+ //
2275
+ // On Windows the bash tool is Git for Windows (MSYS) bash, where `/c/Users/x`
2276
+ // and `/cygdrive/c/Users/x` are the same folder as `C:\Users\x`, and Win32
2277
+ // accepts `//?/C:/...`. On win32 only, those spellings read as the drive path
2278
+ // before the compare (separators normalized, case folded). Shell variables
2279
+ // such as `$USERPROFILE` are not expanded: that indirection stays the
2280
+ // documented fail-open limit of a word-level guard.
2281
+ interface PolicyPathHost {
2282
+ platform: NodeJS.Platform;
2283
+ home: string;
2284
+ }
2285
+
2286
+ function currentPolicyPathHost(): PolicyPathHost {
2287
+ return { platform: process.platform, home: homedir() };
2288
+ }
2289
+
2290
+ function windowsDrivePath(path: string): string {
2291
+ const msys = /^(?:\/cygdrive)?\/([a-zA-Z])(\/.*)?$/.exec(path);
2292
+ if (msys !== null) return `${msys[1]}:${msys[2] ?? "/"}`;
2293
+ const device = /^\/\/[?.]\/([a-zA-Z]:(?:\/.*)?)$/.exec(path);
2294
+ return device === null ? path : device[1].length === 2 ? `${device[1]}/` : device[1];
2295
+ }
2296
+
2297
+ function normalizeAbsolutePolicyPath(value: string, cwd?: string, host: PolicyPathHost = currentPolicyPathHost()): string | undefined {
2298
+ let expanded = value.trim()
2299
+ .replace(/^(?:~|\$HOME|\$\{HOME\})(?=[/\\]|$)/, host.home.replace(/\\/g, "/"))
2300
+ .replace(/\\/g, "/");
2301
+ if (expanded.length === 0) return undefined;
2302
+ if (host.platform === "win32") expanded = windowsDrivePath(expanded);
2303
+ if (!/^(?:\/|[a-zA-Z]:\/)/.test(expanded)) {
2304
+ const base = cwd === undefined ? undefined : normalizeAbsolutePolicyPath(cwd, undefined, host);
2305
+ return base === undefined ? undefined : posix.join(base, expanded).replace(/(.)\/+$/, "$1").toLowerCase();
2306
+ }
2307
+ return posix.normalize(expanded).replace(/(.)\/+$/, "$1").toLowerCase();
2308
+ }
2309
+
2310
+ function desktopActionRootsFor(homes: readonly string[], host: PolicyPathHost): string[] {
2311
+ const roots = new Set<string>();
2312
+ for (const home of homes) {
2313
+ const normalized = normalizeAbsolutePolicyPath(home, undefined, host);
2314
+ if (normalized !== undefined) roots.add(posix.join(normalized, "desktop"));
2315
+ }
2316
+ return [...roots];
2317
+ }
2318
+
2319
+ function desktopActionRoots(env: NodeJS.ProcessEnv): string[] {
2320
+ const homes = [
2321
+ resolveGentlePiAgentHome(env),
2322
+ resolveGentlePiAgentHome(process.env),
2323
+ join(homedir(), ".gentle-shell", "agent"),
2324
+ join(homedir(), ".pi", "agent"),
2325
+ ];
2326
+ const spellings: string[] = [];
2327
+ for (const home of homes) {
2328
+ spellings.push(home);
2329
+ try { spellings.push(realpathSync(home)); } catch { /* A missing home has only its own spelling. */ }
2330
+ }
2331
+ return desktopActionRootsFor(spellings, currentPolicyPathHost());
2332
+ }
2333
+
2334
+ function isUnderDesktopRoot(value: string, roots: readonly string[], cwd: string | undefined, host: PolicyPathHost): boolean {
2335
+ const normalized = normalizeAbsolutePolicyPath(value, cwd, host);
2336
+ if (normalized === undefined) return false;
2337
+ return roots.some((root) => normalized === root || normalized.startsWith(`${root}/`));
2338
+ }
2339
+
2340
+ /** Pure seam of the desktop-folder guard: `homes` are agent homes, `home` the user home that `~`/`$HOME` expand to. */
2341
+ export function isDesktopActionPathOn(value: string, options: PolicyPathHost & { homes: readonly string[]; cwd?: string }): boolean {
2342
+ const host = { platform: options.platform, home: options.home };
2343
+ return isUnderDesktopRoot(value, desktopActionRootsFor(options.homes, host), options.cwd, host);
2344
+ }
2345
+
2346
+ function isDesktopActionPath(value: string, env: NodeJS.ProcessEnv, cwd?: string): boolean {
2347
+ return isUnderDesktopRoot(value, desktopActionRoots(env), cwd, currentPolicyPathHost());
2348
+ }
2349
+
2350
+ function isSensitivePath(value: string, env: NodeJS.ProcessEnv = process.env, cwd?: string): boolean {
2254
2351
  const normalized = normalizePolicyPath(value);
2255
- return SENSITIVE_PATH_PATTERNS.some((pattern) => pattern.test(normalized));
2352
+ return SENSITIVE_PATH_PATTERNS.some((pattern) => pattern.test(normalized)) || isDesktopActionPath(value, env, cwd);
2353
+ }
2354
+
2355
+ // A shell word can carry a path after `=`: `--target-directory=$HOME/...` or
2356
+ // `VAR=~/...` (quotes are already stripped by shellCommandWords). Only the
2357
+ // desktop guard reads these values; the pattern list keeps its word-level reach.
2358
+ function isSensitiveCommandWord(word: string, env: NodeJS.ProcessEnv, cwd?: string): boolean {
2359
+ if (isSensitivePath(word, env, cwd)) return true;
2360
+ let index = word.indexOf("=");
2361
+ while (index >= 0) {
2362
+ if (isDesktopActionPath(word.slice(index + 1), env, cwd)) return true;
2363
+ index = word.indexOf("=", index + 1);
2364
+ }
2365
+ return false;
2256
2366
  }
2257
2367
 
2258
2368
  function isSensitiveRequestContextPath(path: string): boolean {
@@ -2370,8 +2480,8 @@ function shellCommandWords(command: string): string[] {
2370
2480
  return words;
2371
2481
  }
2372
2482
 
2373
- function findSensitiveCommandPath(command: string): string | undefined {
2374
- return shellCommandWords(command).find(isSensitivePath);
2483
+ function findSensitiveCommandPath(command: string, env: NodeJS.ProcessEnv = process.env, cwd?: string): string | undefined {
2484
+ return shellCommandWords(command).find((word) => isSensitiveCommandWord(word, env, cwd));
2375
2485
  }
2376
2486
 
2377
2487
  function sensitivePathBlock(sensitivePath: string): ToolCallEventResult {
@@ -2384,15 +2494,17 @@ function sensitivePathBlock(sensitivePath: string): ToolCallEventResult {
2384
2494
  function evaluateSensitivePathTool(
2385
2495
  toolName: string,
2386
2496
  input: unknown,
2497
+ env: NodeJS.ProcessEnv = process.env,
2498
+ cwd?: string,
2387
2499
  ): ToolCallEventResult | undefined {
2388
2500
  const sensitivePath = PATH_GUARDED_TOOL_NAMES.has(toolName)
2389
- ? collectPathInputs(input).find(isSensitivePath)
2501
+ ? collectPathInputs(input).find((path) => isSensitivePath(path, env, cwd))
2390
2502
  : undefined;
2391
2503
  if (sensitivePath !== undefined) return sensitivePathBlock(sensitivePath);
2392
2504
  if (!SHELL_COMMAND_TOOLS.has(toolName)) return undefined;
2393
2505
  const command = readStringPath(input, ["command"]);
2394
2506
  if (command === undefined) return undefined;
2395
- const commandPath = findSensitiveCommandPath(command);
2507
+ const commandPath = findSensitiveCommandPath(command, env, cwd);
2396
2508
  return commandPath === undefined ? undefined : sensitivePathBlock(commandPath);
2397
2509
  }
2398
2510
 
@@ -3258,13 +3370,16 @@ function readReviewerRouting(cwd: string, sessionId: string | undefined, session
3258
3370
  : resolution.kind === "inherited" && resolution.profile !== undefined ? "frozen session profile"
3259
3371
  : resolution.kind === "follow" ? "followed session profile"
3260
3372
  : "repository profile pin";
3261
- // Only a profile chosen with Use in this session, or recorded as the session's
3262
- // startup profile, carries its orchestrator to the provider review roles; an
3263
- // in-memory freeze, pinned and global routing leave them on Pi's persisted
3264
- // default (gentle-shell#2716 A1, gentle-shell#2742 section 8).
3373
+ // Provider review roles inherit the explicit binding's orchestrator, the
3374
+ // startup record's, or the in-memory frozen profile's, before Pi's persisted
3375
+ // default. Pins and global routing never supply this fallback; a session
3376
+ // frozen without a profile has no orchestrator to carry to a foreign target.
3265
3377
  if (resolution.kind !== "explicit") delete config.orchestrator;
3266
- const recorded = resolution.kind === "inherited" ? readSessionProfileBinding(sessionId)?.modelProfiles.orchestrator : undefined;
3267
- if (recorded !== undefined) config.orchestrator = { ...recorded };
3378
+ const orchestrator = resolution.kind === "inherited"
3379
+ ? readSessionProfileBinding(sessionId)?.modelProfiles.orchestrator
3380
+ ?? (resolution.profile === undefined ? undefined : readFrozenDefaultOrchestrator(sessionId))
3381
+ : undefined;
3382
+ if (orchestrator !== undefined) config.orchestrator = { ...orchestrator };
3268
3383
  return { config, source };
3269
3384
  }
3270
3385
 
@@ -9663,8 +9778,8 @@ function reviewHostRelayFailureReport(error: ReviewHostRelayError): Record<strin
9663
9778
  // gentle-pi#2271: review-refuter and review-validator are provider review
9664
9779
  // roles, not installable agents, so nothing seeds their entries and profiles
9665
9780
  // never carry them. For those two keys only, a snapshot with no model falls
9666
- // back to Pi's persisted default model and effort, the default the routing
9667
- // panel already labels them with. Lens keys keep the fail-closed rule.
9781
+ // back to the session profile's orchestrator, then Pi's persisted default model
9782
+ // and effort. Lens keys keep the fail-closed rule.
9668
9783
  //
9669
9784
  // gentle-shell#2163: a caller that knows where the snapshot came from passes
9670
9785
  // it, so the relay's refusal names the routing source and whether the entry
@@ -12786,10 +12901,40 @@ function createGentleAiExtensionForTesting(
12786
12901
  sessionProfiles.start(ctx.sessionManager, (type, data) => pi.appendEntry(type, data), event);
12787
12902
  // gentle-shell#2742: only a session's own start tells this process its
12788
12903
  // startup state; anything else leaves it unknown.
12904
+ let startupProfile: SessionProfileStartupState | undefined;
12789
12905
  try {
12790
- if (profileSessionId && isSessionOwnStart(event, ctx.sessionManager))
12906
+ if (profileSessionId && isSessionOwnStart(event, ctx.sessionManager)) {
12791
12907
  freezeSessionProfileAtOwnStart({ sessionId: profileSessionId, cwd: ctx.sessionManager.getCwd(), configHome: gentleAiConfigHome() });
12908
+ startupProfile = readSessionProfileOwnStartup(profileSessionId);
12909
+ }
12792
12910
  } catch { /* The startup state stays unknown. */ }
12911
+ // A3: only this session's own start applies its frozen full definition.
12912
+ // The workflow mode remains live; launches still receive role routing only.
12913
+ if (startupProfile && startupProfile !== "none" && permissionEnvironment.GENTLE_PI_AGENTS_CHILD !== "1" && !profileFollowEnabled(permissionEnvironment)) {
12914
+ const orchestrator = readProfileOrchestrator(startupProfile.modelProfiles);
12915
+ const current = () => startupEpoch === reminderEpoch && sessionProfiles.isCurrent(ctx.sessionManager);
12916
+ // The switch is best-effort and contained: a reload or session
12917
+ // replacement racing the awaited switch must neither abort the rest
12918
+ // of session_start (Pi's runner throws on any access to a stale ctx)
12919
+ // nor leave the outcome unreported. Checked before and after the await.
12920
+ try {
12921
+ if (!current()) return;
12922
+ const note = orchestrator?.model
12923
+ ? await switchLiveOrchestrator(ctx, pi, orchestrator, current)
12924
+ || "\nThe profile's orchestrator model is invalid; this session keeps its current model."
12925
+ : `\nprofile "${startupProfile.name}" has no orchestrator model; this session keeps its current model.`;
12926
+ if (!current()) return;
12927
+ // A headless session (pi -p) has no notify surface: the startup note
12928
+ // falls back to stderr, the same channel Pi's own startup notifications
12929
+ // use headlessly, so a failed switch is observable instead of silent.
12930
+ const startedWith = `el Gentleman started with profile "${startupProfile.name}".${note}`;
12931
+ if (ctx.hasUI) ctx.ui.notify(startedWith, "info");
12932
+ else console.error(startedWith);
12933
+ } catch {
12934
+ // The startup switch stays best-effort: a staled context or a
12935
+ // reporting failure never aborts the remaining startup work.
12936
+ }
12937
+ }
12793
12938
  readSessionProfileAuthority(ctx.sessionManager);
12794
12939
  if (ctx.hasUI) notifySessionProfileProblem(ctx);
12795
12940
  auto.reset();
@@ -13185,6 +13330,8 @@ function createGentleAiExtensionForTesting(
13185
13330
  const sensitivePathDenied = evaluateSensitivePathTool(
13186
13331
  event.toolName,
13187
13332
  event.input,
13333
+ permissionEnvironment,
13334
+ typeof ctx.cwd === "string" && ctx.cwd.length > 0 ? ctx.cwd : undefined,
13188
13335
  );
13189
13336
  if (sensitivePathDenied) return sensitivePathDenied;
13190
13337
  const surfaceDenied = evaluateExecutionSurfaceTool(event.toolName, event.input);
@@ -13633,6 +13780,69 @@ function createGentleAiExtensionForTesting(
13633
13780
  },
13634
13781
  });
13635
13782
 
13783
+ // Desktop's get_review_mode/set_review_mode (#3324) reach this same switch
13784
+ // through a versioned, adapter-shaped seam: every read and write goes
13785
+ // through executeReviewMode and the native adapter, exactly like
13786
+ // /gentle:review-mode. The Desktop bridge owns the confirmation step; this
13787
+ // owner only reads (bounded, fail closed) and writes then re-reads. Raw
13788
+ // native errors never leave: they are classified as unavailable (gentle-ai
13789
+ // missing or the command unsupported), unknown, or failed. Subagent
13790
+ // children never answer, and hosts without an event bus skip the seam.
13791
+ const DESKTOP_REVIEW_WRITE_TIMEOUT_MS = 10_000;
13792
+ const reviewModeUnavailable = (error: unknown): boolean => {
13793
+ const code = asNativeReviewCliError(error)?.code;
13794
+ return code === NATIVE_REVIEW_ERROR_CODE.UNAVAILABLE || code === NATIVE_REVIEW_ERROR_CODE.VERSION_INCOMPATIBLE ||
13795
+ code === NATIVE_REVIEW_ERROR_CODE.PACKAGE_BINARY_MISSING || code === NATIVE_REVIEW_ERROR_CODE.UNSUPPORTED_TRANSITION_OPERATION;
13796
+ };
13797
+ const boundedReviewMode = async (request: NativeReviewModeRequest, ctx: ExtensionContext, timeoutMs: number) => {
13798
+ const signal = AbortSignal.timeout(timeoutMs);
13799
+ return await Promise.race([executeReviewMode({ ...request, signal }, ctx), rddAbortRejection(signal)]);
13800
+ };
13801
+ if (typeof pi.events?.on === "function") pi.events.on(DESKTOP_REVIEW_SERVICE_CHANNEL, (payload: unknown) => {
13802
+ if (!payload || typeof payload !== "object") return;
13803
+ const request = payload as Partial<{ context: ExtensionContext; respond(service: DesktopReviewService): void }>;
13804
+ if (typeof request.respond !== "function" || !request.context) return;
13805
+ if (permissionEnvironment.GENTLE_PI_AGENTS_CHILD === "1") return;
13806
+ const ctx = request.context;
13807
+ let disposed = false;
13808
+ const read = async (): Promise<DesktopReviewOwnerRead> => {
13809
+ if (disposed || nativeReviewCli?.reviewMode === undefined) return { kind: "unavailable" };
13810
+ try {
13811
+ const result = await boundedReviewMode({ cwd: ctx.cwd, operation: NATIVE_REVIEW_MODE_OPERATION.STATUS }, ctx, resolveRddStatusTimeoutMs(permissionEnvironment));
13812
+ if (result.operation !== NATIVE_REVIEW_MODE_OPERATION.STATUS || !isValidRddModeStatus(result.status)) return { kind: "unknown" };
13813
+ const { global, cloneLocal, effective, source, revision } = result.status;
13814
+ return { kind: "status", status: { global, cloneLocal, effective, source, ...(revision === undefined ? {} : { revision }) } };
13815
+ } catch (error) {
13816
+ return reviewModeUnavailable(error) ? { kind: "unavailable" } : { kind: "unknown" };
13817
+ }
13818
+ };
13819
+ try {
13820
+ request.respond({
13821
+ schema: DESKTOP_REVIEW_SERVICE_SCHEMA,
13822
+ read,
13823
+ async write({ enabled, scope }): Promise<DesktopReviewOwnerWrite> {
13824
+ if (disposed || nativeReviewCli?.reviewMode === undefined) return { kind: "unavailable" };
13825
+ const operation = enabled ? NATIVE_REVIEW_MODE_OPERATION.ENABLE : NATIVE_REVIEW_MODE_OPERATION.DISABLE;
13826
+ try {
13827
+ const result = await boundedReviewMode({ cwd: ctx.cwd, operation, scope }, ctx, DESKTOP_REVIEW_WRITE_TIMEOUT_MS);
13828
+ if (result.operation !== operation) return { kind: "failed" };
13829
+ } catch (error) {
13830
+ // A write that could not start changed nothing; any other failure
13831
+ // has an unknown outcome and is never retried.
13832
+ return reviewModeUnavailable(error) ? { kind: "unavailable" } : { kind: "failed" };
13833
+ }
13834
+ // Report the owner's state re-read after the write, not the write's echo.
13835
+ return await read();
13836
+ },
13837
+ dispose: () => {
13838
+ disposed = true;
13839
+ },
13840
+ });
13841
+ } catch {
13842
+ /* obsolete trusted context: discovery expires closed */
13843
+ }
13844
+ });
13845
+
13636
13846
  // gentle-pi#677: gentle-ai owns telemetry end to end (status, the opt-out
13637
13847
  // switches, and rate limiting); this command only runs the corresponding
13638
13848
  // `gentle-ai telemetry <op> --json` in the foreground and relays its