gentle-pi 4.5.1 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/README.md +17 -15
  2. package/assets/agents/gentle-ai-explore.md +1 -0
  3. package/assets/agents/gentle-ai-verify.md +8 -1
  4. package/assets/agents/gentle-ai-worker.md +4 -0
  5. package/assets/agents/jd-fix-agent.md +1 -0
  6. package/assets/agents/jd-judge-a.md +1 -0
  7. package/assets/agents/jd-judge-b.md +1 -0
  8. package/assets/design-canvas/canvas.css +13 -1
  9. package/assets/design-canvas/canvas.js +11 -2
  10. package/assets/install-wizard/wizard.js +1 -0
  11. package/assets/migrations/agent-body-history.json +162 -0
  12. package/assets/orchestrator-delegation-reference.md +7 -7
  13. package/assets/orchestrator-delegation.md +3 -3
  14. package/assets/orchestrator-full-delegation-card.md +65 -0
  15. package/assets/orchestrator-full-delegation.md +34 -0
  16. package/assets/orchestrator-memory.md +3 -3
  17. package/assets/orchestrator-prompts.md +1 -1
  18. package/assets/orchestrator-skills.md +1 -1
  19. package/assets/orchestrator-verification.md +14 -8
  20. package/assets/orchestrator.md +11 -11
  21. package/bin/gentle-shell.mjs +225 -82
  22. package/docs/agent-status.md +61 -0
  23. package/docs/bundled-install.md +7 -5
  24. package/docs/ci-performance.md +11 -0
  25. package/docs/delegated-verification.md +35 -7
  26. package/docs/fast-mode.md +15 -0
  27. package/docs/gentle-agents-activity.md +22 -0
  28. package/docs/gentle-shell.md +113 -25
  29. package/docs/install-wizard.md +2 -2
  30. package/docs/mcp-status.md +52 -0
  31. package/docs/permission-modes.md +9 -4
  32. package/docs/prompt-budget.md +28 -0
  33. package/docs/readme-reference.md +154 -50
  34. package/docs/render-cache-performance.md +11 -1
  35. package/docs/review-coordinator.md +33 -0
  36. package/docs/review-request-context.md +19 -0
  37. package/docs/review-windows-acl.md +18 -0
  38. package/docs/session-profile-format.md +20 -5
  39. package/docs/sound-notifications.md +1 -1
  40. package/docs/star-prompt.md +32 -0
  41. package/docs/voice.md +6 -3
  42. package/docs/work-continuity.md +46 -0
  43. package/docs/yolo-mode.md +5 -5
  44. package/extensions/ask-user-choice.ts +1 -0
  45. package/extensions/ask-user-question.ts +2 -0
  46. package/extensions/child-safety.ts +3 -0
  47. package/extensions/codegraph-tools.ts +38 -4
  48. package/extensions/gentle-agent-status.ts +99 -0
  49. package/extensions/gentle-agents.ts +803 -84
  50. package/extensions/gentle-ai.ts +2491 -596
  51. package/extensions/gentle-fast.ts +61 -0
  52. package/extensions/gentle-guide.ts +174 -0
  53. package/extensions/gentle-herdr-activity.ts +21 -1
  54. package/extensions/gentle-herdr-agent.ts +144 -0
  55. package/extensions/gentle-program-identity.ts +61 -0
  56. package/extensions/gentle-shell.ts +895 -120
  57. package/extensions/gentle-star-prompt.ts +334 -0
  58. package/extensions/gentle-stats.ts +5 -5
  59. package/extensions/gentle-todo.ts +59 -23
  60. package/extensions/gentle-tps.ts +48 -0
  61. package/extensions/history/store.ts +18 -12
  62. package/extensions/quiet-tools.ts +38 -8
  63. package/extensions/skill-registry.ts +210 -21
  64. package/extensions/startup-banner.ts +69 -10
  65. package/lib/agent-assets.ts +74 -17
  66. package/lib/agent-profile-pin.ts +3 -3
  67. package/lib/agent-profiles.ts +161 -3
  68. package/lib/agent-status.ts +105 -0
  69. package/lib/agents-config.ts +58 -3
  70. package/lib/agents-history.ts +24 -5
  71. package/lib/agents-keys.ts +8 -16
  72. package/lib/agents-messaging.ts +47 -5
  73. package/lib/agents-protocol.ts +80 -4
  74. package/lib/agents-runner.ts +287 -15
  75. package/lib/agents-view.ts +6 -1
  76. package/lib/agents-widget.ts +132 -9
  77. package/lib/auto-permission-runtime.ts +1 -1
  78. package/lib/bounded-writer-admission.ts +13 -1
  79. package/lib/bridge-cost.ts +28 -0
  80. package/lib/card-content-policy.ts +8 -6
  81. package/lib/codemode-renderer.ts +16 -0
  82. package/lib/command-palette-catalog.ts +1 -0
  83. package/lib/command-palette.ts +154 -25
  84. package/lib/context-backstop.ts +14 -5
  85. package/lib/destructive-command-guard.ts +48 -4
  86. package/lib/execution-surface-guard.ts +20 -0
  87. package/lib/exploration-budget.ts +64 -0
  88. package/lib/gentle-ai-binary.ts +1 -1
  89. package/lib/gentle-design.ts +3 -0
  90. package/lib/gentle-guide.ts +201 -0
  91. package/lib/gentle-shell-bundled.ts +6 -19
  92. package/lib/gentle-shell-launcher.ts +47 -8
  93. package/lib/herdr-activity.ts +23 -5
  94. package/lib/herdr-busy.ts +45 -0
  95. package/lib/herdr-task-summary-policy.ts +85 -0
  96. package/lib/image-attachments.ts +33 -0
  97. package/lib/image-disk-cache.ts +137 -0
  98. package/lib/inprocess-reviewer.ts +282 -132
  99. package/lib/jobs-sidebar-state.ts +5 -6
  100. package/lib/jobs-view.ts +198 -11
  101. package/lib/jobs-widget.ts +16 -52
  102. package/lib/keymaps-customize.ts +81 -0
  103. package/lib/keymaps.ts +291 -0
  104. package/lib/model-fallback-notice.ts +61 -0
  105. package/lib/model-fallback-policy.ts +141 -0
  106. package/lib/model-fallback-store.ts +143 -0
  107. package/lib/model-routing-authority.ts +32 -6
  108. package/lib/nan-provider.ts +3 -2
  109. package/lib/native-choice-list.ts +20 -2
  110. package/lib/native-review-cli.ts +103 -21
  111. package/lib/notification-customize.ts +48 -51
  112. package/lib/openai-fast-tier.ts +22 -0
  113. package/lib/orchestrator-discovery.ts +5 -1
  114. package/lib/orchestrator-fallback.ts +75 -0
  115. package/lib/orchestrator-mode-policy.ts +105 -0
  116. package/lib/pasted-image-paths.ts +113 -0
  117. package/lib/questionnaire/questionnaire-view.ts +225 -18
  118. package/lib/rdd-mode-control.ts +32 -0
  119. package/lib/reply-language-anchor.ts +104 -0
  120. package/lib/review-blocker.ts +92 -0
  121. package/lib/review-candidate-symlink-scan.ts +136 -0
  122. package/lib/review-candidate-view-owner.ts +85 -44
  123. package/lib/review-candidate-view.ts +10 -7
  124. package/lib/review-continuation-registry.ts +99 -0
  125. package/lib/review-coordinator.ts +163 -0
  126. package/lib/review-failure-facts.ts +49 -0
  127. package/lib/review-host-relay.ts +51 -11
  128. package/lib/review-integration-v2.ts +29 -8
  129. package/lib/review-relay-phase-timing.ts +45 -0
  130. package/lib/review-repository.ts +5 -0
  131. package/lib/review-start-context.ts +17 -0
  132. package/lib/session-profile-append-controller.ts +21 -6
  133. package/lib/session-profile-authority.ts +119 -0
  134. package/lib/session-profile-binding.ts +54 -5
  135. package/lib/session-profile-freeze.ts +107 -9
  136. package/lib/session-profile-integration.ts +313 -0
  137. package/lib/session-profile-persistence.ts +63 -9
  138. package/lib/shell-bar.ts +269 -72
  139. package/lib/shell-card.ts +26 -6
  140. package/lib/shell-changes.ts +2 -0
  141. package/lib/shell-page.ts +120 -0
  142. package/lib/shell-panel.ts +163 -0
  143. package/lib/shell-prompt.ts +53 -1
  144. package/lib/shell-sidebar-layout.ts +198 -53
  145. package/lib/shell-sidebar.ts +61 -1
  146. package/lib/shell-stats.ts +123 -0
  147. package/lib/shell-todo.ts +79 -1
  148. package/lib/shell-usage.ts +12 -2
  149. package/lib/star-prompt.ts +197 -0
  150. package/lib/verifier-admission.ts +18 -8
  151. package/lib/verifier-settle-reminder.ts +64 -0
  152. package/lib/vim-editor-adapter.ts +6 -1
  153. package/lib/visual-customization-policy.ts +67 -12
  154. package/lib/visual-customize-view.ts +373 -40
  155. package/lib/visual-layout-preview.ts +47 -0
  156. package/lib/visual-profiles.ts +2 -2
  157. package/lib/windows-session-transport.ts +53 -2
  158. package/lib/yolo-session-policy.ts +68 -16
  159. package/package.json +2 -1
  160. package/runtime/gentle-ai-binary.mjs +1 -1
  161. package/runtime/gentle-shell-bundled.mjs +6 -19
  162. package/runtime/gentle-shell-launcher.mjs +46 -7
  163. package/runtime/native-review-cli.mjs +100 -18
  164. package/runtime/review-integration-v2.mjs +29 -8
  165. package/runtime/windows-session-transport.ps1 +60 -3
  166. package/scripts/bootstrap.sh +4 -1
  167. package/scripts/build-full-delegation-card.mjs +175 -0
  168. package/scripts/bundled-install.mjs +38 -8
  169. package/scripts/download-progress.mjs +68 -0
  170. package/scripts/gentle-ai-installer.mjs +41 -18
  171. package/scripts/gentle-ai-proxy.mjs +294 -0
  172. package/scripts/install-gentle-ai.mjs +14 -1
  173. package/scripts/installer-preflight.mjs +6 -6
  174. package/scripts/installer-runner.mjs +27 -12
  175. package/scripts/installer-server.mjs +8 -7
  176. package/scripts/pi-update.mjs +113 -3
  177. package/scripts/render-cache-host.mjs +72 -0
  178. package/scripts/render-cache-performance-worker.mjs +5 -4
  179. package/scripts/render-cache-performance.mjs +6 -1
  180. package/scripts/run-test-suite.mjs +41 -13
  181. package/scripts/shell-snapshot.mjs +340 -0
  182. package/scripts/test-packed-runner.mjs +1 -1
  183. package/scripts/update-agent-body-history.mjs +41 -0
  184. package/scripts/verify-installer-tap.mjs +45 -0
  185. package/scripts/verify-package-files.mjs +14 -2
  186. package/scripts/voice-worker.cjs +32 -6
  187. package/skills/design/SKILL.md +11 -8
  188. package/skills/gentle-ai/SKILL.md +4 -4
  189. package/skills/gentle-ui-design/SKILL.md +46 -0
  190. package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
  191. package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
  192. package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
  193. package/skills/gentle-ui-design/references/task-and-content.md +60 -0
  194. package/skills/skill-registry/SKILL.md +4 -2
  195. package/skills/tui-design/NOTICE.md +5 -0
  196. package/skills/tui-design/SKILL.md +56 -0
  197. package/skills/tui-design/references/commands.md +75 -0
  198. package/skills/tui-design/references/critique.md +48 -0
  199. package/skills/tui-design/references/design-doc.md +44 -0
  200. package/skills/tui-design/references/terminal-craft.md +64 -0
  201. package/skills/tui-design/references/visual-loop.md +32 -0
  202. package/skills/work-unit-commits/SKILL.md +6 -7
  203. package/tests/agent-home.test.ts +28 -9
  204. package/tests/agent-profiles-workflow.test.ts +163 -0
  205. package/tests/agent-risk-escalation.test.ts +1 -1
  206. package/tests/agent-status.test.ts +143 -0
  207. package/tests/agents-config.test.ts +96 -0
  208. package/tests/agents-history.test.ts +31 -0
  209. package/tests/agents-jobs-frames.test.ts +93 -0
  210. package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
  211. package/tests/agents-protocol.test.ts +53 -1
  212. package/tests/agents-runner-drain.test.ts +193 -0
  213. package/tests/agents-runner.test.ts +345 -4
  214. package/tests/agents-view.test.ts +27 -0
  215. package/tests/agents-widget.test.ts +312 -10
  216. package/tests/append-system-prompt-route.test.ts +4 -1
  217. package/tests/ask-user-choice.test.ts +4 -3
  218. package/tests/ask-user-question.test.ts +97 -0
  219. package/tests/auto-permission-runtime.test.ts +1 -1
  220. package/tests/autonomous-guard.test.ts +346 -10
  221. package/tests/bounded-scan-contract.test.ts +39 -0
  222. package/tests/bounded-stop-contract.test.ts +43 -3
  223. package/tests/bridge-cost.test.ts +47 -0
  224. package/tests/bundled-install.test.ts +36 -9
  225. package/tests/card-content-policy.test.ts +3 -3
  226. package/tests/chained-pr-skill.test.ts +8 -6
  227. package/tests/child-safety.test.ts +11 -0
  228. package/tests/ci-concurrency.test.ts +11 -0
  229. package/tests/ci-merge-base-identity.test.ts +114 -0
  230. package/tests/codegraph-tools.test.ts +80 -5
  231. package/tests/codemode-rendering.test.ts +22 -2
  232. package/tests/command-palette.test.ts +300 -3
  233. package/tests/commit-slice-signal.test.ts +11 -9
  234. package/tests/delegate-for-reason-contract.test.ts +8 -7
  235. package/tests/design-canvas-assets.test.ts +185 -2
  236. package/tests/destructive-command-guard.test.ts +52 -0
  237. package/tests/download-progress.test.ts +71 -0
  238. package/tests/execution-surface-guard.test.ts +55 -0
  239. package/tests/exploration-budget.test.ts +128 -0
  240. package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
  241. package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
  242. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -14
  243. package/tests/fixtures/proxy-tls/proxy.crt +19 -0
  244. package/tests/fixtures/proxy-tls/proxy.key +28 -0
  245. package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
  246. package/tests/fixtures/session-profile-v1/replay.ts +172 -0
  247. package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
  248. package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
  249. package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
  250. package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
  251. package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
  252. package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
  253. package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
  254. package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
  255. package/tests/full-delegation-closure.test.ts +131 -0
  256. package/tests/full-delegation-notices.test.ts +76 -0
  257. package/tests/generic-agent-tools.test.ts +3 -3
  258. package/tests/gentle-agent-status.test.ts +74 -0
  259. package/tests/gentle-agents-child-jobs.test.ts +237 -0
  260. package/tests/gentle-agents.test.ts +1491 -38
  261. package/tests/gentle-ai-binary.test.ts +3 -1
  262. package/tests/gentle-ai-elapsed-store.test.ts +19 -0
  263. package/tests/gentle-ai-exploration-budget.test.ts +151 -0
  264. package/tests/gentle-ai-installer.test.ts +134 -51
  265. package/tests/gentle-ai-proxy.test.ts +434 -0
  266. package/tests/gentle-ai.test.ts +1101 -52
  267. package/tests/gentle-design.test.ts +21 -0
  268. package/tests/gentle-fast.test.ts +73 -0
  269. package/tests/gentle-guide.test.ts +208 -0
  270. package/tests/gentle-herdr-activity.test.ts +80 -3
  271. package/tests/gentle-herdr-agent.test.ts +111 -0
  272. package/tests/gentle-program-identity.test.ts +197 -0
  273. package/tests/gentle-shell-bin.test.ts +172 -26
  274. package/tests/gentle-shell-bundled.test.ts +207 -31
  275. package/tests/gentle-shell-launcher.test.ts +93 -10
  276. package/tests/gentle-shell.test.ts +1937 -66
  277. package/tests/gentle-stats.test.ts +15 -2
  278. package/tests/gentle-todo.test.ts +67 -4
  279. package/tests/gentle-tps.test.ts +123 -0
  280. package/tests/gentle-ui-design-skill.test.ts +59 -0
  281. package/tests/herdr-busy.test.ts +59 -0
  282. package/tests/herdr-task-summary-policy.test.ts +132 -0
  283. package/tests/history-store-private-mode.test.ts +40 -0
  284. package/tests/image-disk-cache.test.ts +163 -0
  285. package/tests/image-paste-chips.test.ts +42 -0
  286. package/tests/independent-recovery-delivery.test.ts +83 -0
  287. package/tests/inprocess-reviewer.test.ts +298 -4
  288. package/tests/installer-posix-bootstrap.test.ts +68 -6
  289. package/tests/installer-preflight.test.ts +5 -4
  290. package/tests/installer-runner.test.ts +79 -44
  291. package/tests/installer-server.test.ts +14 -11
  292. package/tests/installer-windows-diagnostics.test.ts +4 -5
  293. package/tests/isolated-config-home.ts +28 -0
  294. package/tests/jobs-view.test.ts +260 -6
  295. package/tests/jobs-widget.test.ts +25 -37
  296. package/tests/keymaps-customize.test.ts +114 -0
  297. package/tests/keymaps.test.ts +103 -0
  298. package/tests/maintainer/mcp-status.maintest.ts +88 -0
  299. package/tests/maintainer/pi-update-source.maintest.ts +116 -0
  300. package/tests/modal-mouse-boundaries.test.ts +136 -0
  301. package/tests/model-fallback-notice.test.ts +45 -0
  302. package/tests/model-fallback-policy.test.ts +83 -0
  303. package/tests/model-fallback-store.test.ts +111 -0
  304. package/tests/model-routing-authority.test.ts +178 -2
  305. package/tests/nan-provider.test.ts +4 -4
  306. package/tests/native-choice-list.test.ts +77 -2
  307. package/tests/native-review-capability-contract.test.ts +7 -1
  308. package/tests/native-review-cli.test.ts +269 -1
  309. package/tests/no-self-pause-contract.test.ts +22 -0
  310. package/tests/notification-customize.test.ts +58 -34
  311. package/tests/odd-routing-canonical-ratchet.test.ts +6 -6
  312. package/tests/odd-routing-contract.test.ts +1 -1
  313. package/tests/orchestrator-budget.test.ts +7 -2
  314. package/tests/orchestrator-delegation-mode.test.ts +153 -0
  315. package/tests/orchestrator-fallback.test.ts +82 -0
  316. package/tests/orchestrator-mode-policy.test.ts +175 -0
  317. package/tests/orchestrator-prompt-budget.test.ts +133 -0
  318. package/tests/orchestrator-rdd-ownership.test.ts +2 -2
  319. package/tests/package-manifest.test.ts +169 -14
  320. package/tests/pasted-image-paths.test.ts +118 -0
  321. package/tests/permission-allowlist.test.ts +202 -0
  322. package/tests/persona-reply-language.test.ts +20 -1
  323. package/tests/pi-update-launcher.test.ts +40 -8
  324. package/tests/pi-update-source.test.ts +162 -0
  325. package/tests/pnpm-workspace-config.test.ts +58 -0
  326. package/tests/primary-session-prompt.test.ts +13 -0
  327. package/tests/profile-fast-tier.test.ts +311 -0
  328. package/tests/profile-pin.test.ts +29 -2
  329. package/tests/profile-tier-footer.test.ts +84 -0
  330. package/tests/profiles-panel-delegation-mode.test.ts +422 -0
  331. package/tests/questionnaire-view.test.ts +265 -0
  332. package/tests/quiet-bash-runtime.test.ts +1 -1
  333. package/tests/quiet-tool-rendering.test.ts +48 -0
  334. package/tests/rdd-aware-verification-contract.test.ts +16 -11
  335. package/tests/rdd-customize.test.ts +287 -0
  336. package/tests/rdd-mode-cache.test.ts +450 -0
  337. package/tests/rdd-mode-control.test.ts +407 -0
  338. package/tests/rdd-mode-scope-regression.test.ts +137 -0
  339. package/tests/rdd-off-independent-regression.test.ts +69 -0
  340. package/tests/rdd-status-line.test.ts +18 -0
  341. package/tests/render-cache-performance.test.ts +171 -2
  342. package/tests/reply-language-anchor.test.ts +173 -0
  343. package/tests/review-agent-end-preflight.test.ts +1 -1
  344. package/tests/review-blocker.test.ts +193 -0
  345. package/tests/review-candidate-owner-retry.test.ts +1 -1
  346. package/tests/review-candidate-owner-sweep.test.ts +93 -0
  347. package/tests/review-candidate-symlink-scan.test.ts +157 -0
  348. package/tests/review-candidate-view.test.ts +52 -1
  349. package/tests/review-candidate-windows-boundary.test.ts +131 -0
  350. package/tests/review-candidate-windows-probe.test.ts +63 -0
  351. package/tests/review-committed-restart-ack.test.ts +129 -0
  352. package/tests/review-continuation-registry.test.ts +76 -0
  353. package/tests/review-controller-native-routing.test.ts +381 -11
  354. package/tests/review-controller-workspace-root.test.ts +230 -3
  355. package/tests/review-controller.test.ts +96 -11
  356. package/tests/review-coordinator-runtime.test.ts +117 -0
  357. package/tests/review-coordinator.test.ts +195 -0
  358. package/tests/review-failure-facts.test.ts +87 -0
  359. package/tests/review-gate.test.ts +24 -0
  360. package/tests/review-host-relay-routing.test.ts +258 -4
  361. package/tests/review-host-relay.test.ts +39 -0
  362. package/tests/review-inspect-preflight.test.ts +197 -0
  363. package/tests/review-integration-v2-forward.test.ts +59 -0
  364. package/tests/review-integration-v2.test.ts +46 -3
  365. package/tests/review-json-arguments.test.ts +65 -10
  366. package/tests/review-last-event-closure.test.ts +68 -0
  367. package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
  368. package/tests/review-owner-identity.test.ts +60 -24
  369. package/tests/review-relay-phase-timing.test.ts +128 -0
  370. package/tests/review-relay-transport-agent.test.ts +12 -2
  371. package/tests/review-repository.test.ts +52 -1
  372. package/tests/review-reviewer-evidence.test.ts +183 -0
  373. package/tests/review-risk-assessment.test.ts +74 -3
  374. package/tests/review-session-standing-permission-controller.test.ts +21 -1
  375. package/tests/review-sidebar-state.test.ts +5 -5
  376. package/tests/review-start-context.test.ts +19 -0
  377. package/tests/review-tool-prose-budget.test.ts +121 -0
  378. package/tests/run-test-suite.test.ts +183 -6
  379. package/tests/runtime-harness.mjs +4 -1
  380. package/tests/sensitive-path-tools.test.ts +250 -0
  381. package/tests/session-profile-append-controller-pi.test.ts +60 -31
  382. package/tests/session-profile-append-controller.test.ts +63 -0
  383. package/tests/session-profile-authority.test.ts +259 -0
  384. package/tests/session-profile-binding.test.ts +34 -1
  385. package/tests/session-profile-disk-reader-pi.test.ts +58 -16
  386. package/tests/session-profile-extension.test.ts +615 -0
  387. package/tests/session-profile-freeze.test.ts +110 -2
  388. package/tests/session-profile-integration.test.ts +857 -0
  389. package/tests/session-profile-persistence.test.ts +57 -0
  390. package/tests/session-profile-v1-compat.test.ts +255 -0
  391. package/tests/shell-bar.test.ts +274 -72
  392. package/tests/shell-card.test.ts +13 -1
  393. package/tests/shell-page.test.ts +108 -0
  394. package/tests/shell-panel.test.ts +360 -0
  395. package/tests/shell-prompt.test.ts +54 -0
  396. package/tests/shell-render-cache.test.ts +5 -0
  397. package/tests/shell-sidebar-fullscreen.test.ts +13 -1
  398. package/tests/shell-sidebar-layout.test.ts +447 -44
  399. package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
  400. package/tests/shell-stats.test.ts +90 -0
  401. package/tests/shell-surface-transparent.test.ts +89 -0
  402. package/tests/shell-todo.test.ts +12 -0
  403. package/tests/shell-usage.test.ts +14 -0
  404. package/tests/skill-registry.test.ts +902 -2
  405. package/tests/star-prompt.test.ts +470 -0
  406. package/tests/startup-banner.test.ts +209 -2
  407. package/tests/startup-home-repo.test.ts +2 -0
  408. package/tests/support/review-coordinator-runtime.ts +69 -0
  409. package/tests/task-size-routing-contract.test.ts +50 -4
  410. package/tests/verifier-admission.test.ts +49 -0
  411. package/tests/verifier-settle-reminder.test.ts +281 -0
  412. package/tests/verify-first-launch-contract.test.ts +134 -8
  413. package/tests/verify-installer-tap.test.ts +57 -0
  414. package/tests/vim-editor-adapter.test.ts +2 -2
  415. package/tests/visual-customization-policy.test.ts +95 -8
  416. package/tests/visual-customize-view.test.ts +818 -9
  417. package/tests/visual-layout-preview.test.ts +42 -0
  418. package/tests/visual-profiles.test.ts +11 -0
  419. package/tests/voice-worker.test.ts +73 -2
  420. package/tests/windows-session-bootstrap.test.ts +105 -2
  421. package/tests/windows-session-transport.test.ts +126 -0
  422. package/tests/work-continuity-contract.test.ts +114 -0
  423. package/tests/writer-feature-document-admission.test.ts +92 -0
  424. package/tests/writer-surfaces.test.ts +12 -10
  425. package/tests/yolo-customize.test.ts +57 -15
  426. package/tests/yolo-mode-runtime.test.ts +4 -2
  427. package/tests/yolo-mode.test.ts +39 -20
  428. package/tests/yolo-session-policy.test.ts +270 -1
@@ -4,12 +4,13 @@ import { chmod, mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
4
4
  import { tmpdir } from "node:os";
5
5
  import { dirname, isAbsolute, join, posix, win32 } from "node:path";
6
6
  import { promisify } from "node:util";
7
- import { gentleAiIsolationEnv, PackageLocalGentleAiBinaryMissingError, resolveGentleAiBinary } from "./gentle-ai-binary.mjs";
7
+ import { binaryDigest, gentleAiIsolationEnv, PackageLocalGentleAiBinaryMissingError, resolveGentleAiBinary } from "./gentle-ai-binary.mjs";
8
8
  import { GENTLE_PI_REVIEW_RELAY_CONTRACT, GENTLE_PI_REVIEW_RELAY_CONTRACT_ENV } from "./review-relay-contract.mjs";
9
9
  import { decodeReviewAssessmentV1, } from "./review-risk-assessment.mjs";
10
10
  import {
11
11
  REVIEW_INTEGRATION_CONTRACT,
12
12
  decodeReviewAcknowledgedV1,
13
+ decodeReviewCapabilitiesV2,
13
14
  decodeReviewConsentV2,
14
15
  decodeReviewConsentV3,
15
16
  decodeReviewFailureV2,
@@ -19,6 +20,7 @@ import {
19
20
  decodeReviewStartV3,
20
21
  decodeReviewStartV4,
21
22
  decodeReviewStatusV3,
23
+ intendedUntrackedSubmissionCarriesTarget,
22
24
 
23
25
 
24
26
 
@@ -165,6 +167,9 @@ export const NATIVE_REVIEW_MODE_SCOPE = {
165
167
 
166
168
 
167
169
 
170
+
171
+
172
+
168
173
  // Read-only risk assessment request (gentle-pi#662). `baseRef` requires
169
174
  // explicit `committedOnly` acknowledgement, exactly like Native START's
170
175
  // baseRef/committedOnly pairing, because both select a committed range
@@ -538,6 +543,19 @@ export const NATIVE_UNTRACKED_SCOPE = {
538
543
 
539
544
 
540
545
 
546
+ /** Explicit request file; native owns reading, freezing, sizing and identity. */
547
+
548
+
549
+
550
+
551
+ export const NATIVE_REQUEST_CONTEXT_UNSUPPORTED_MESSAGE = "provider does not support request context";
552
+
553
+ function nativeRequestContextArguments(request ) {
554
+ if (request.requestContextPath === undefined) return [];
555
+ if (!isCanonicalProcessString(request.requestContextPath)) throw new TypeError("Native requestContextPath must be a non-empty, trimmed, NUL-free string");
556
+ return ["--request-context", request.requestContextPath];
557
+ }
558
+
541
559
 
542
560
 
543
561
 
@@ -1098,6 +1116,13 @@ export const NATIVE_CLI_CONTRACTS = Object.freeze({
1098
1116
  // The v4.3.0 tag has no release and is never pinned.
1099
1117
  // No new negotiated capability identity is asserted.
1100
1118
  "4.3.1": Object.freeze({ start: true, finalize: true, validate: true, bindSdd: true, status: true, inventory: true, reclaim: true, recover: true, abandon: true, quarantineLegacy: true, reconcileAuthority: true, repairLegacyAlias: true, mode: true, riskEvidence: false, hint: false, delivery: true }),
1119
+ // v4.4.0 repeats 4.3.1: the published binary still advertises
1120
+ // capabilities/v2.6 under review-integration/v2 with the same capabilities
1121
+ // payload apart from build identity, and the provider contract stays at
1122
+ // 1.4.0, with published tarball SHA-256
1123
+ // 58450471280aeb357443d6a28c819132d8c8eb78dd25b12bac64296b2f8c27c2.
1124
+ // No new negotiated capability identity is asserted.
1125
+ "4.4.0": Object.freeze({ start: true, finalize: true, validate: true, bindSdd: true, status: true, inventory: true, reclaim: true, recover: true, abandon: true, quarantineLegacy: true, reconcileAuthority: true, repairLegacyAlias: true, mode: true, riskEvidence: false, hint: false, delivery: true }),
1101
1126
  });
1102
1127
 
1103
1128
 
@@ -1476,6 +1501,16 @@ function decodeNativeReviewStatus(value ) {
1476
1501
  raw: body,
1477
1502
  };
1478
1503
  }
1504
+ function nativeReviewModeScopeArguments(operation , scope ) {
1505
+ if (scope !== undefined && scope !== NATIVE_REVIEW_MODE_SCOPE.CLONE && scope !== NATIVE_REVIEW_MODE_SCOPE.GLOBAL) {
1506
+ throw new TypeError("Native review mode scope must be clone or global");
1507
+ }
1508
+ if (scope !== undefined && operation !== NATIVE_REVIEW_MODE_OPERATION.ENABLE && operation !== NATIVE_REVIEW_MODE_OPERATION.DISABLE) {
1509
+ throw new TypeError("Native review mode scope is only valid for enable or disable");
1510
+ }
1511
+ return operation === NATIVE_REVIEW_MODE_OPERATION.STATUS ? [] : ["--scope", scope ?? NATIVE_REVIEW_MODE_SCOPE.CLONE];
1512
+ }
1513
+
1479
1514
  function isWindowsRepositoryPath(value ) { return /^[A-Za-z]:[\\/]/.test(value) || /^\\\\/.test(value); }
1480
1515
  export function normalizeNativeReviewCwd(value , platform = process.platform) {
1481
1516
  if (platform !== "win32") return value;
@@ -1667,22 +1702,21 @@ class NativeReviewPlainCli {
1667
1702
  return status;
1668
1703
  }
1669
1704
 
1670
- // Dark until the negotiated version reports `mode: true` (Design Decision
1671
- // #7, organic-rdd-parity). `status` is read-only (no timeout suppression,
1672
- // exact fixed argv per the design's data flow); `enable`/`disable` mutate
1673
- // and always pass `--scope clone` so Pi's own kill-switch command surface
1674
- // never mutates the operator's global gentle-ai state across other clones.
1705
+ // Status stays read-only; mutation defaults to clone unless the caller
1706
+ // explicitly supplies global. Validate scope before cwd or process access.
1675
1707
  async reviewMode(request ) {
1708
+ const operation = request.operation;
1709
+ const scopeArguments = nativeReviewModeScopeArguments(operation, request.scope);
1676
1710
  const cwd = await canonicalNativeReviewCwd(request.cwd);
1677
- const mutating = request.operation !== NATIVE_REVIEW_MODE_OPERATION.STATUS;
1711
+ const mutating = operation !== NATIVE_REVIEW_MODE_OPERATION.STATUS;
1678
1712
  const { body } = await this.execute(
1679
1713
  NATIVE_REVIEW_OPERATION.MODE,
1680
1714
  cwd,
1681
- ["review", "mode", request.operation, "--cwd", cwd, ...(mutating ? ["--scope", "clone"] : []), "--json"],
1715
+ ["review", "mode", operation, "--cwd", cwd, ...scopeArguments, "--json"],
1682
1716
  mutating,
1683
1717
  request.signal,
1684
1718
  );
1685
- return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(body, request.operation));
1719
+ return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(body, operation));
1686
1720
  }
1687
1721
 
1688
1722
  async reclaim(request ) {
@@ -1928,12 +1962,14 @@ export class NativeReviewIntegrationError extends Error {
1928
1962
  // answer only through one of the exact invocations carried by the envelope.
1929
1963
  export class NativeReviewConsentRequiredError extends Error {
1930
1964
  consent ;
1965
+ requestContextPath ;
1931
1966
  launchAttempted = true;
1932
1967
  mutationOutcome = "none";
1933
- constructor(consent ) {
1968
+ constructor(consent , requestContextPath ) {
1934
1969
  super(consent.headline);
1935
1970
  this.name = "NativeReviewConsentRequiredError";
1936
1971
  this.consent = consent;
1972
+ this.requestContextPath = requestContextPath;
1937
1973
  }
1938
1974
  }
1939
1975
 
@@ -2064,6 +2100,10 @@ function consentInvocationArguments(request )
2064
2100
  const words = splitNativeConsentInvocation(choice.invocation);
2065
2101
  if (words[0] !== "gentle-ai" || words[1] !== "review" || words[2] !== "start") throw new NativeReviewConsentBindingError("consent-invocation-not-start", "Native consent invocation is not a provider review START");
2066
2102
  const arguments_ = words.slice(1);
2103
+ if (request.requestContextPath !== undefined) {
2104
+ const values = arguments_.flatMap((token, index) => token === "--request-context" ? [arguments_[index + 1]] : token.startsWith("--request-context=") ? [token.slice("--request-context=".length)] : []);
2105
+ if (values.length !== 1 || values[0] !== request.requestContextPath) throw new NativeReviewConsentBindingError("consent-invocation-request-context-changed", "Native consent invocation did not retain the requested context file");
2106
+ }
2067
2107
  if (exactConsentOption(arguments_, "--contract") !== REVIEW_INTEGRATION_CONTRACT) throw new NativeReviewConsentBindingError("consent-invocation-contract-changed", "Native consent invocation contract changed");
2068
2108
  const providerCwd = exactConsentOption(arguments_, "--cwd");
2069
2109
  const requestedCwd = normalizeNativeReviewCwd(request.cwd);
@@ -2165,6 +2205,8 @@ function decodeNativeUnachievableLensCaptureArtifact(value )
2165
2205
  }
2166
2206
 
2167
2207
  export class NativeReviewCliV216 {
2208
+ // Only executable capabilities are reusable. STATUS and authority remain fresh.
2209
+ contextCapabilities ;
2168
2210
  plain ;
2169
2211
  adapter ;
2170
2212
  executable ;
@@ -2267,6 +2309,7 @@ export class NativeReviewCliV216 {
2267
2309
  const selection = nativeUntrackedSelection(request);
2268
2310
  const statusRequest = {
2269
2311
  cwd: request.cwd,
2312
+ ...(request.requestContextPath === undefined ? {} : { requestContextPath: request.requestContextPath }),
2270
2313
  projection,
2271
2314
  ...(request.baseRef === undefined ? {} : { baseRef: request.baseRef, committedOnly: true }),
2272
2315
  ...(request.lineageId === undefined ? {} : { lineageId: request.lineageId }),
@@ -2300,6 +2343,10 @@ export class NativeReviewCliV216 {
2300
2343
  return argument.token;
2301
2344
  });
2302
2345
  const targetIdentity = status.targetIdentity;
2346
+ if (request.requestContextPath !== undefined) {
2347
+ const values = transitionTokens.flatMap((token, index) => token === "--request-context" ? [transitionTokens[index + 1]] : token.startsWith("--request-context=") ? [token.slice("--request-context=".length)] : []);
2348
+ if (values.length !== 1 || values[0] !== request.requestContextPath) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH, NATIVE_REVIEW_OPERATION.START, false, "native START transition did not retain the requested context file", undefined, false);
2349
+ }
2303
2350
  const execution = await this.negotiated(NATIVE_REVIEW_OPERATION.START, request.cwd, ["review", "start", ...transitionTokens], true, request.signal);
2304
2351
  // A negotiated v2 START may answer a consent question (action:
2305
2352
  // "consent_required") instead of `start/v3` when the provider needs an
@@ -2317,7 +2364,10 @@ export class NativeReviewCliV216 {
2317
2364
  return decoded;
2318
2365
  });
2319
2366
  if (consent.targetIdentity !== targetIdentity || consent.projection !== projection) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH, NATIVE_REVIEW_OPERATION.START, true, "native consent target binding mismatch");
2320
- throw new NativeReviewConsentRequiredError(consent);
2367
+ if (request.requestContextPath !== undefined) {
2368
+ for (const choice of consent.choices) consentInvocationArguments({ cwd: request.cwd, consent, answer: choice.answer, requestContextPath: request.requestContextPath });
2369
+ }
2370
+ throw new NativeReviewConsentRequiredError(consent, request.requestContextPath);
2321
2371
  }
2322
2372
  const result = decode(NATIVE_REVIEW_OPERATION.START, true, () => decodeReviewStartResponse(execution.body));
2323
2373
  if (request.lineageId !== undefined && result.lineageId !== request.lineageId) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH, NATIVE_REVIEW_OPERATION.START, true, "native start lineage mismatch");
@@ -2387,6 +2437,9 @@ export class NativeReviewCliV216 {
2387
2437
  }
2388
2438
 
2389
2439
  async observedTargetStatus(request ) {
2440
+ // Validate locally before discovery; never probe support by sending an
2441
+ // unknown flag or retrying the review without its requested intent.
2442
+ const requestContextArguments = nativeRequestContextArguments(request);
2390
2443
  if (request.baseRef !== undefined && !isCanonicalProcessString(request.baseRef)) throw new TypeError("Native STATUS baseRef must be a non-empty, trimmed, NUL-free string");
2391
2444
  if (request.baseRef !== undefined && request.committedOnly !== true) throw new TypeError("Native STATUS baseRef requires explicit committedOnly acknowledgement");
2392
2445
  if (request.baseRef === undefined && request.committedOnly !== undefined) throw new TypeError("Native STATUS committedOnly requires an explicit baseRef");
@@ -2400,7 +2453,11 @@ export class NativeReviewCliV216 {
2400
2453
  // value for the same flag. providerFlagValue also fails closed on a
2401
2454
  // dangling `--flag` (last token, no value) or an empty `--flag=`.
2402
2455
  const submittedBaseRefValue = submittedTokens === undefined ? undefined : providerFlagValue(submittedTokens, "base-ref");
2403
- if (request.baseRef !== undefined && submittedBaseRefValue !== undefined && submittedBaseRefValue !== request.baseRef) throw new TypeError("Native intended-untracked selection already carries a conflicting base-ref");
2456
+ // A provider-issued base-diff selector (base tree plus scope) already binds
2457
+ // the target the request named; the tree is not textually comparable to
2458
+ // the request's ref, so it runs as issued and nothing is re-forwarded.
2459
+ const providerOwnsTarget = submitted !== undefined && intendedUntrackedSubmissionCarriesTarget(submitted.argumentTokens);
2460
+ if (!providerOwnsTarget && request.baseRef !== undefined && submittedBaseRefValue !== undefined && submittedBaseRefValue !== request.baseRef) throw new TypeError("Native intended-untracked selection already carries a conflicting base-ref");
2404
2461
  const submittedLineageValue = submittedTokens === undefined ? undefined : providerFlagValue(submittedTokens, "lineage");
2405
2462
  if (request.lineageId !== undefined && submittedLineageValue !== undefined && submittedLineageValue !== request.lineageId) throw new TypeError("Native intended-untracked selection already carries a conflicting lineage");
2406
2463
  let submittedHasCommittedOnly = false;
@@ -2413,11 +2470,31 @@ export class NativeReviewCliV216 {
2413
2470
  // Append only the half of the base-ref/committed-only pair the provider
2414
2471
  // did not already carry (a present base-ref already equals
2415
2472
  // request.baseRef; the throw above ruled out the conflicting case).
2416
- const forwardedBaseRef = request.baseRef === undefined ? [] : [
2473
+ const forwardedBaseRef = request.baseRef === undefined || providerOwnsTarget ? [] : [
2417
2474
  ...(submittedBaseRefValue === undefined ? ["--base-ref", request.baseRef] : []),
2418
2475
  ...(submittedHasCommittedOnly ? [] : ["--committed-only"]),
2419
2476
  ];
2420
2477
  const forwardedLineage = request.lineageId === undefined || submittedLineageValue !== undefined ? [] : ["--lineage", request.lineageId];
2478
+ let contextExecutable ;
2479
+ if (requestContextArguments.length > 0) {
2480
+ contextExecutable = this.executablePath(NATIVE_REVIEW_OPERATION.STATUS, false);
2481
+ const digest = binaryDigest(contextExecutable);
2482
+ let capabilities = this.contextCapabilities?.executable === contextExecutable && this.contextCapabilities.digest === digest
2483
+ ? this.contextCapabilities.value : undefined;
2484
+ if (capabilities === undefined) {
2485
+ this.contextCapabilities = undefined;
2486
+ const discovery = await this.invoke(NATIVE_REVIEW_OPERATION.STATUS, request.cwd,
2487
+ ["review", "capabilities", "--contract", REVIEW_INTEGRATION_CONTRACT], false, request.signal, contextExecutable);
2488
+ capabilities = decode(NATIVE_REVIEW_OPERATION.STATUS, false, () => decodeReviewCapabilitiesV2(discovery.body, digest));
2489
+ if (binaryDigest(contextExecutable) !== digest) throw nativeError(NATIVE_REVIEW_ERROR_CODE.IDENTITY_MISMATCH,
2490
+ NATIVE_REVIEW_OPERATION.STATUS, false, "native executable changed during capability discovery", undefined, false);
2491
+ this.contextCapabilities = { executable: contextExecutable, digest, value: capabilities };
2492
+ }
2493
+ if (!["start_request_context", "start_options_preflight"].every(feature => capabilities.optionalFeatures.has(feature))) {
2494
+ throw nativeError(NATIVE_REVIEW_ERROR_CODE.VERSION_INCOMPATIBLE, NATIVE_REVIEW_OPERATION.STATUS, false,
2495
+ NATIVE_REQUEST_CONTEXT_UNSUPPORTED_MESSAGE, undefined, false);
2496
+ }
2497
+ }
2421
2498
  const statusArguments = submittedTokens === undefined ? [
2422
2499
  "review", "status", "--contract", REVIEW_INTEGRATION_CONTRACT, "--cwd", request.cwd,
2423
2500
  "--projection", request.projection ?? "workspace",
@@ -2426,9 +2503,12 @@ export class NativeReviewCliV216 {
2426
2503
  ...(request.lineageId === undefined ? [] : ["--lineage", request.lineageId]),
2427
2504
  ...(request.agent === undefined ? [] : ["--agent", request.agent]),
2428
2505
  ...nativeLensSelectionArguments(request),
2506
+ ...requestContextArguments,
2429
2507
  "--next-transition",
2430
- ] : ["review", "status", "--cwd", request.cwd, ...submittedTokens, ...forwardedBaseRef, ...forwardedLineage, ...nativeLensSelectionArguments(request)];
2431
- const execution = await this.negotiated(NATIVE_REVIEW_OPERATION.STATUS, request.cwd, statusArguments, false, request.signal);
2508
+ ] : ["review", "status", "--cwd", request.cwd, ...submittedTokens, ...forwardedBaseRef, ...forwardedLineage, ...nativeLensSelectionArguments(request), ...requestContextArguments];
2509
+ const execution = contextExecutable === undefined
2510
+ ? await this.negotiated(NATIVE_REVIEW_OPERATION.STATUS, request.cwd, statusArguments, false, request.signal)
2511
+ : await this.invoke(NATIVE_REVIEW_OPERATION.STATUS, request.cwd, statusArguments, false, request.signal, contextExecutable);
2432
2512
  measureStatusSync("decode", () => assertSupportedNextTransitionOperation(execution.body));
2433
2513
  return decode(NATIVE_REVIEW_OPERATION.STATUS, false, () => decodeReviewStatusV3(execution.body));
2434
2514
  }
@@ -2636,17 +2716,19 @@ export class NativeReviewCliV216 {
2636
2716
  }
2637
2717
 
2638
2718
  async reviewMode(request ) {
2719
+ const operation = request.operation;
2720
+ const scopeArguments = nativeReviewModeScopeArguments(operation, request.scope);
2639
2721
  const cwd = await canonicalNativeReviewCwd(request.cwd);
2640
- const mutating = request.operation !== NATIVE_REVIEW_MODE_OPERATION.STATUS;
2722
+ const mutating = operation !== NATIVE_REVIEW_MODE_OPERATION.STATUS;
2641
2723
  const execution = await this.invoke(
2642
2724
  NATIVE_REVIEW_OPERATION.MODE,
2643
2725
  cwd,
2644
- ["review", "mode", request.operation, "--cwd", cwd, ...(mutating ? ["--scope", "clone"] : []), "--json"],
2726
+ ["review", "mode", operation, "--cwd", cwd, ...scopeArguments, "--json"],
2645
2727
  mutating,
2646
2728
  request.signal,
2647
2729
  this.executablePath(NATIVE_REVIEW_OPERATION.MODE, mutating),
2648
2730
  );
2649
- return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(execution.body, request.operation));
2731
+ return decode(NATIVE_REVIEW_OPERATION.MODE, mutating, () => decodeNativeReviewMode(execution.body, operation));
2650
2732
  }
2651
2733
 
2652
2734
  // Read-only risk assessment (gentle-ai#4295, gentle-pi#662). Never mutates;
@@ -218,6 +218,8 @@ const CAPABILITIES_SCHEMA_IDENTITIES
218
218
  }),
219
219
  });
220
220
  const OPTIONAL_FEATURE_NAMES = Object.freeze([
221
+ "start_request_context",
222
+ "start_options_preflight",
221
223
  "base_ref_workspace_overlay",
222
224
  "bounded_process_waits",
223
225
  "classified_authority_repair",
@@ -237,6 +239,8 @@ const OPTIONAL_FEATURE_NAMES = Object.freeze([
237
239
  "validating_result_reopen",
238
240
  ] );
239
241
  const FEATURE_NAMES = Object.freeze([
242
+ "start_request_context",
243
+ "start_options_preflight",
240
244
  "base_ref_workspace_overlay",
241
245
  "bounded_process_waits",
242
246
  "classified_authority_repair",
@@ -1467,17 +1471,32 @@ function decodeTransitionArguments(value , label )
1467
1471
  });
1468
1472
  }
1469
1473
 
1474
+ // The intended-untracked submission re-enters STATUS for the same target: the
1475
+ // workspace projection, or a provider-issued base-diff selector (a base tree
1476
+ // plus --committed-only or --workspace-overlay). No other selector is accepted.
1477
+ const INTENDED_UNTRACKED_PREFIX = ["--contract=gentle-ai.review-integration/v2", "--next-transition=true", "--agent=pi"] ;
1478
+ const INTENDED_UNTRACKED_SELECTION_TOKEN = "--intended-untracked-selection={{value}}";
1479
+ const INTENDED_UNTRACKED_BASE_TREE = /^--base-ref=[0-9a-f]{40}(?:[0-9a-f]{24})?$/;
1480
+
1481
+ /** True when a validated submission already carries the provider-issued base-diff target selector. */
1482
+ export function intendedUntrackedSubmissionCarriesTarget(tokens ) {
1483
+ return isIntendedUntrackedSubmissionTokens(tokens) && tokens.length === INTENDED_UNTRACKED_PREFIX.length + 3;
1484
+ }
1485
+
1486
+ function isIntendedUntrackedSubmissionTokens(tokens ) {
1487
+ if (INTENDED_UNTRACKED_PREFIX.some((token, index) => tokens[index] !== token) || tokens[tokens.length - 1] !== INTENDED_UNTRACKED_SELECTION_TOKEN) return false;
1488
+ const selector = tokens.slice(INTENDED_UNTRACKED_PREFIX.length, -1);
1489
+ if (selector.length === 1) return selector[0] === "--projection=workspace";
1490
+ return selector.length === 2 && INTENDED_UNTRACKED_BASE_TREE.test(selector[0] ) && (selector[1] === "--committed-only=true" || selector[1] === "--workspace-overlay=true");
1491
+ }
1492
+
1470
1493
  function decodeCaptureSubmission(value , label , v5 , v6 , captureOperation ) {
1471
1494
  // status/v6 adds the provider-owned intended-untracked selection form.
1472
1495
  if (v6 && captureOperation === "external.select_intended_untracked" && typeof value === "object" && value !== null && (value ).operation_token === "status") {
1473
1496
  const submission = exactRecord(value, label, ["operation_token", "argument_tokens", "value"]);
1474
- const expectedTokens = [
1475
- "--contract=gentle-ai.review-integration/v2", "--next-transition=true", "--agent=pi",
1476
- "--projection=workspace", "--intended-untracked-selection={{value}}",
1477
- ] ;
1478
1497
  const operationToken = enumeration(submission.operation_token, ["status"] , `${label}.operation_token`);
1479
- const argumentTokens = stringArray(submission.argument_tokens, `${label}.argument_tokens`, { minimum: expectedTokens.length, maximum: expectedTokens.length });
1480
- if (argumentTokens.some((token, index) => token !== expectedTokens[index])) throw new TypeError(`${label}.argument_tokens substitution binding is invalid`);
1498
+ const argumentTokens = stringArray(submission.argument_tokens, `${label}.argument_tokens`, { minimum: 5, maximum: 6 });
1499
+ if (!isIntendedUntrackedSubmissionTokens(argumentTokens)) throw new TypeError(`${label}.argument_tokens substitution binding is invalid`);
1481
1500
  const row = exactRecord(submission.value, `${label}.value`, ["slot", "domain", "schema", "substitution_location"]);
1482
1501
  return {
1483
1502
  operationToken,
@@ -1486,7 +1505,7 @@ function decodeCaptureSubmission(value , label , v5 , v6
1486
1505
  slot: enumeration(row.slot, ["intended_untracked_selection"] , `${label}.value.slot`),
1487
1506
  domain: enumeration(row.domain, ["schema_bound_json"] , `${label}.value.domain`),
1488
1507
  schema: enumeration(row.schema, ["gentle-ai.review-intended-untracked-selection/v1"] , `${label}.value.schema`),
1489
- substitutionLocation: integer(row.substitution_location, `${label}.value.substitution_location`, 4, 4),
1508
+ substitutionLocation: integer(row.substitution_location, `${label}.value.substitution_location`, argumentTokens.length - 1, argumentTokens.length - 1),
1490
1509
  }],
1491
1510
  };
1492
1511
  }
@@ -1585,6 +1604,7 @@ function decodeCorrectionPlanRequestV1(value , label )
1585
1604
  };
1586
1605
  }
1587
1606
 
1607
+ /** Decode frozen validation evidence, preserving an explicit empty policy and rejecting absence. */
1588
1608
  export function decodeReviewTargetedValidationRequestV1(value , label = "targeted_validation_request") {
1589
1609
  const body = exactRecord(value, label, [
1590
1610
  "schema", "request_hash", "lineage_id", "expected_revision", "target_identity", "fix_finding_ids", "policy_content", "fix_findings", "fix_classifications",
@@ -1627,7 +1647,8 @@ export function decodeReviewTargetedValidationRequestV1(value , label =
1627
1647
  expectedRevision: sha256(body.expected_revision, `${label}.expected_revision`),
1628
1648
  targetIdentity: sha256(body.target_identity, `${label}.target_identity`),
1629
1649
  fixFindingIds,
1630
- policyContent: nonempty(body.policy_content, `${label}.policy_content`),
1650
+ // A frozen empty policy is valid; missing historical policy is not.
1651
+ policyContent: text(body.policy_content, `${label}.policy_content`),
1631
1652
  fixFindings,
1632
1653
  fixClassifications,
1633
1654
  projection: enumeration(body.projection, REQUIRED_PROJECTIONS, `${label}.projection`),
@@ -230,6 +230,7 @@ public static class WindowsSessionBootstrap {
230
230
  [DllImport("kernel32.dll", SetLastError=true)] static extern bool ReadFile(IntPtr handle, byte[] buffer, uint length, out uint read, IntPtr overlapped);
231
231
  [DllImport("kernel32.dll", SetLastError=true)] static extern bool WriteFile(IntPtr handle, byte[] buffer, uint length, out uint written, IntPtr overlapped);
232
232
  [DllImport("kernel32.dll", SetLastError=true)] static extern bool FlushFileBuffers(IntPtr handle);
233
+ [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool WaitNamedPipe(string name, uint timeout);
233
234
  [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern IntPtr CreateNamedPipe(string name, uint openMode, uint pipeMode, uint maxInstances, uint outBufferSize, uint inBufferSize, uint defaultTimeout, IntPtr securityAttributes);
234
235
  [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool GetVolumeNameForVolumeMountPoint(string rootPathName, System.Text.StringBuilder volumeName, uint cchBufferLength);
235
236
  [DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)] static extern bool GetVolumeInformation(string rootPathName, IntPtr volumeNameBuffer, uint volumeNameSize, out uint volumeSerialNumber, out uint maximumComponentLength, out uint fileSystemFlags, IntPtr fileSystemNameBuffer, uint fileSystemNameSize);
@@ -379,11 +380,14 @@ public static class WindowsSessionBootstrap {
379
380
  static string RecordName(string sessionId, string token) { return sessionId + "." + token + ".json"; }
380
381
  static string RecordText(string sessionId, string endpoint, long createdAt) { return "{\"version\":1,\"sessionId\":\"" + sessionId + "\",\"endpoint\":\"" + endpoint.Replace("\\", "\\\\") + "\",\"createdAt\":" + createdAt.ToString(System.Globalization.CultureInfo.InvariantCulture) + "}"; }
381
382
  static OpenResult OpenRecord(IntPtr root, string name, bool create, byte[] descriptor, bool allowDeleteSharing) {
383
+ return OpenRecord(root, name, create, descriptor, allowDeleteSharing, false);
384
+ }
385
+ static OpenResult OpenRecord(IntPtr root, string name, bool create, byte[] descriptor, bool allowDeleteSharing, bool protectIdentity) {
382
386
  IntPtr chars = IntPtr.Zero, unicode = IntPtr.Zero, security = IntPtr.Zero, handle = IntPtr.Zero;
383
387
  try {
384
388
  unicode = Unicode(name, out chars); var attributes = new OBJECT_ATTRIBUTES(); attributes.Length = (uint)Marshal.SizeOf(typeof(OBJECT_ATTRIBUTES)); attributes.RootDirectory = root; attributes.ObjectName = unicode; attributes.Attributes = OBJ_CASE_INSENSITIVE | OBJ_DONT_REPARSE;
385
389
  if (create) { if (descriptor == null || descriptor.Length == 0) Fail("unavailable"); security = Marshal.AllocHGlobal(descriptor.Length); Marshal.Copy(descriptor, 0, security, descriptor.Length); attributes.SecurityDescriptor = security; }
386
- IO_STATUS_BLOCK statusBlock; uint status = NtCreateFile(out handle, SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | READ_CONTROL | DELETE, ref attributes, out statusBlock, IntPtr.Zero, 0, FILE_SHARE_READ | FILE_SHARE_WRITE | (allowDeleteSharing ? FILE_SHARE_DELETE : 0), create ? FILE_CREATE : FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_REPARSE_POINT, IntPtr.Zero, 0);
390
+ IO_STATUS_BLOCK statusBlock; uint status = NtCreateFile(out handle, SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | READ_CONTROL | DELETE, ref attributes, out statusBlock, IntPtr.Zero, 0, protectIdentity ? FILE_SHARE_READ : FILE_SHARE_READ | FILE_SHARE_WRITE | (allowDeleteSharing ? FILE_SHARE_DELETE : 0), create ? FILE_CREATE : FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_REPARSE_POINT, IntPtr.Zero, 0);
387
391
  if (status != 0) { Close(handle); return new OpenResult(IntPtr.Zero, status); } return new OpenResult(handle, status);
388
392
  } finally { if (security != IntPtr.Zero) Marshal.FreeHGlobal(security); if (unicode != IntPtr.Zero) Marshal.FreeHGlobal(unicode); if (chars != IntPtr.Zero) Marshal.FreeHGlobal(chars); }
389
393
  }
@@ -437,8 +441,61 @@ public static class WindowsSessionBootstrap {
437
441
  }
438
442
  }
439
443
  public static void Publish(string sessionId, string endpoint, long createdAt, byte[] descriptor, string sid) { PublishOwned(sessionId, endpoint, createdAt, descriptor, sid); }
440
- public static PresenceRecord[] List(string sid) { return List(null, sid); }
441
- public static PresenceRecord[] List(string excluded, string sid) { lock (Gate) { RequirePresence(); if (excluded != null && !Regex.IsMatch(excluded, "^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$")) Fail("invalid"); var newest = new Dictionary<string, PresenceRecord>(StringComparer.Ordinal); foreach (string name in EnumeratePinned(Presence)) { IntPtr file = IntPtr.Zero; try { RecordIdentity ignoredIdentity; PresenceRecord record = ReadPinnedRecord(name, sid, out file, out ignoredIdentity); if (record.SessionId == excluded) continue; PresenceRecord prior; if (!newest.TryGetValue(record.SessionId, out prior) || record.CreatedAt > prior.CreatedAt || (record.CreatedAt == prior.CreatedAt && String.CompareOrdinal(record.Token, prior.Token) > 0)) newest[record.SessionId] = record; } catch (BootstrapFailure) { } finally { Close(file); } } var records = new List<PresenceRecord>(newest.Values); records.Sort(delegate(PresenceRecord left, PresenceRecord right) { return String.CompareOrdinal(left.SessionId, right.SessionId); }); return records.ToArray(); } }
444
+ // WaitNamedPipe does not connect, send traffic, or consume an accept slot.
445
+ // Only ERROR_FILE_NOT_FOUND proves absence; busy, timeout, access denied,
446
+ // and every other error leave discovery reachability inconclusive.
447
+ const uint PresenceProbeMilliseconds = 1;
448
+ const int ERROR_FILE_NOT_FOUND = 2;
449
+ static bool EndpointAbsent(string endpoint) {
450
+ if (WaitNamedPipe(endpoint, PresenceProbeMilliseconds)) return false;
451
+ return Marshal.GetLastWin32Error() == ERROR_FILE_NOT_FOUND;
452
+ }
453
+ static void TryRemoveAbsentRecord(string name, PresenceRecord expected, RecordIdentity expectedIdentity, string sid) {
454
+ IntPtr file = IntPtr.Zero;
455
+ try {
456
+ // Reopen relative to the pinned private directory. Denying write and
457
+ // delete sharing prevents content changes or replacement during this
458
+ // check; a conflicting handle means leave the record untouched.
459
+ OpenResult opened = OpenRecord(Presence, name, false, null, false, true);
460
+ if (opened.Handle == IntPtr.Zero) return;
461
+ file = opened.Handle;
462
+ RecordIdentity identity = AssertRecord(file, sid);
463
+ PresenceRecord current = ParseRecord(name, ReadRecordText(file));
464
+ if (!identity.Equals(expectedIdentity) || !SameRecord(current, expected.SessionId, expected.Endpoint, expected.CreatedAt)) return;
465
+ if (!EndpointAbsent(current.Endpoint)) return;
466
+ DeletePinnedHandle(file);
467
+ } catch (BootstrapFailure) { /* best effort, never delete an unverified identity */ }
468
+ finally { Close(file); }
469
+ }
470
+ public static PresenceRecord[] List(string sid) { return List(null, sid); }
471
+ public static PresenceRecord[] List(string excluded, string sid) {
472
+ lock (Gate) {
473
+ RequirePresence();
474
+ if (excluded != null && !Regex.IsMatch(excluded, "^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$")) Fail("invalid");
475
+ var newest = new Dictionary<string, PresenceRecord>(StringComparer.Ordinal);
476
+ // Enumeration is capped at MaxEntries (64); each entry needs at most
477
+ // two explicit 1ms pipe waits, with no retries or protocol handshake.
478
+ foreach (string name in EnumeratePinned(Presence)) {
479
+ IntPtr file = IntPtr.Zero;
480
+ try {
481
+ RecordIdentity identity;
482
+ PresenceRecord record = ReadPinnedRecord(name, sid, out file, out identity);
483
+ if (record.SessionId == excluded) continue;
484
+ if (EndpointAbsent(record.Endpoint)) {
485
+ Close(file); file = IntPtr.Zero;
486
+ TryRemoveAbsentRecord(name, record, identity, sid);
487
+ continue;
488
+ }
489
+ PresenceRecord prior;
490
+ if (!newest.TryGetValue(record.SessionId, out prior) || record.CreatedAt > prior.CreatedAt || (record.CreatedAt == prior.CreatedAt && String.CompareOrdinal(record.Token, prior.Token) > 0)) newest[record.SessionId] = record;
491
+ } catch (BootstrapFailure) { }
492
+ finally { Close(file); }
493
+ }
494
+ var records = new List<PresenceRecord>(newest.Values);
495
+ records.Sort(delegate(PresenceRecord left, PresenceRecord right) { return String.CompareOrdinal(left.SessionId, right.SessionId); });
496
+ return records.ToArray();
497
+ }
498
+ }
442
499
  public static PresenceRecord Resolve(string sessionId, string sid) { PresenceRecord[] records = List(null, sid); foreach (PresenceRecord record in records) if (record.SessionId == sessionId) return record; Fail("not_found"); return null; }
443
500
  static void RemoveOwnedPublication(OwnedPublication owned) {
444
501
  IntPtr current = IntPtr.Zero;
@@ -78,7 +78,10 @@ make_tools() {
78
78
  tools=$(mktemp -d "$HOME/.gentle-shell-bootstrap-tools.XXXXXXXX") || fail 'Cannot create private tooling directory'
79
79
  case "$tools" in "$HOME"/.gentle-shell-bootstrap-tools.*) ;; *) fail 'Conflicting tooling destination';; esac
80
80
  [ -d "$tools" ] && [ ! -L "$tools" ] || fail 'Unsafe tooling destination'
81
- ls -nd "$tools" | awk -v uid="$uid" '$3 == uid && $1 == "drwx------" {ok=1} END {exit !ok}' || fail 'Unsafe tooling ownership'
81
+ # ls may append @ (BSD: extended attributes, e.g. macOS com.apple.provenance
82
+ # on every new directory) or . (GNU: an SELinux security context), but
83
+ # never + (an ACL could grant others access).
84
+ ls -nd "$tools" | awk -v uid="$uid" '$3 == uid && $1 ~ /^drwx------[@.]?$/ {ok=1} END {exit !ok}' || fail 'Unsafe tooling ownership'
82
85
  # No existing destination is ever reused or replaced.
83
86
  mkdir "$tools/.claim" || fail 'Conflicting tooling destination'
84
87
  owned=1
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env node
2
+ // Builds assets/orchestrator-full-delegation-card.md, the lazy card a full
3
+ // delegation session reads instead of the organic delegation and writer cards.
4
+ //
5
+ // Full delegation mode must never put an organic routing rule ("small work stays
6
+ // inline", "a large task alone never delegates") in front of the orchestrator,
7
+ // but it still needs the rules both modes share: handoff language, launch
8
+ // checks, allowed edit surfaces, background policy, the closing block. Those rules
9
+ // keep exactly one source, the organic assets that contract tests already pin;
10
+ // this script projects the shared sections out of them, so the card can never
11
+ // drift into a second, diverging copy.
12
+ //
13
+ // Every selection and every pointer rewrite throws when its anchor is missing:
14
+ // a source edit that moves an anchor must fail the drift check loudly, never
15
+ // produce a silently incomplete card.
16
+ //
17
+ // Usage: node scripts/build-full-delegation-card.mjs --write | --check
18
+
19
+ import { readFileSync, writeFileSync } from "node:fs";
20
+ import { dirname, join } from "node:path";
21
+ import { fileURLToPath } from "node:url";
22
+
23
+ export const FULL_DELEGATION_CARD = "orchestrator-full-delegation-card.md";
24
+
25
+ const HEADING = /^#{1,6} /;
26
+
27
+ function requireIncludes(text, anchor, source) {
28
+ if (!text.includes(anchor)) throw new Error(`${source}: anchor not found: ${JSON.stringify(anchor)}`);
29
+ }
30
+
31
+ /** The lines of one section, from its heading to the next heading of any level, trimmed of blank edges. */
32
+ function section(text, heading, source) {
33
+ const lines = text.split("\n");
34
+ const start = lines.indexOf(heading);
35
+ if (start === -1) throw new Error(`${source}: heading not found: ${JSON.stringify(heading)}`);
36
+ const body = [];
37
+ for (const line of lines.slice(start + 1)) {
38
+ if (HEADING.test(line)) break;
39
+ body.push(line);
40
+ }
41
+ while (body.length > 0 && body[0] === "") body.shift();
42
+ while (body.length > 0 && body.at(-1) === "") body.pop();
43
+ return body.join("\n");
44
+ }
45
+
46
+ /** The first heading after the given heading's section starts. */
47
+ function headingAfter(text, heading, source) {
48
+ const lines = text.split("\n");
49
+ const start = lines.indexOf(heading);
50
+ if (start === -1) throw new Error(`${source}: heading not found: ${JSON.stringify(heading)}`);
51
+ const next = lines.slice(start + 1).find((line) => HEADING.test(line));
52
+ if (next === undefined) throw new Error(`${source}: no heading follows ${JSON.stringify(heading)}`);
53
+ return next;
54
+ }
55
+
56
+ /** One paragraph line, selected by its exact leading text. */
57
+ function paragraph(text, prefix, source) {
58
+ const line = text.split("\n").find((candidate) => candidate.startsWith(prefix));
59
+ if (line === undefined) throw new Error(`${source}: paragraph not found: ${JSON.stringify(prefix)}`);
60
+ return line;
61
+ }
62
+
63
+ /** The marked block, markers included, so its own consumers keep recognizing it. */
64
+ function marked(text, name, source) {
65
+ const open = `<!-- ${name} -->`;
66
+ const close = `<!-- /${name} -->`;
67
+ const start = text.indexOf(open);
68
+ const end = text.indexOf(close);
69
+ if (start === -1 || end <= start) throw new Error(`${source}: marked block not found: ${name}`);
70
+ return text.slice(start, end + close.length);
71
+ }
72
+
73
+ /** Apply exact rewrites, each of which must find its anchor. */
74
+ function rewrite(text, replacements, source) {
75
+ let result = text;
76
+ for (const [from, to] of replacements) {
77
+ requireIncludes(result, from, source);
78
+ result = result.replace(from, to);
79
+ }
80
+ return result;
81
+ }
82
+
83
+ export function renderFullDelegationCard(assetsDir) {
84
+ const delegationSource = "orchestrator-delegation.md";
85
+ const writerSource = "orchestrator-writer.md";
86
+ const referenceSource = "orchestrator-delegation-reference.md";
87
+ const delegation = readFileSync(join(assetsDir, delegationSource), "utf8");
88
+ const writer = readFileSync(join(assetsDir, writerSource), "utf8");
89
+ const reference = readFileSync(join(assetsDir, referenceSource), "utf8");
90
+
91
+ // The card is self-contained: pointers back to the organic cards would send a
92
+ // full delegation session straight into the rules this card exists to keep out.
93
+ const handoff = rewrite(section(delegation, "## Handoff", delegationSource), [
94
+ [" (language domain detail: reference)", ""],
95
+ ["via `orchestrator_session_id` (reference).", "via `orchestrator_session_id`."],
96
+ ], delegationSource);
97
+ const invariants = rewrite(paragraph(delegation, "**Invariants:**", delegationSource), [
98
+ ["whoever writes, inline or delegated, reuses", "the writer reuses"],
99
+ [" (`orchestrator-writer.md`)", ""],
100
+ ], delegationSource);
101
+ const differential = paragraph(delegation, "**Differential check (PRESERVE):**", delegationSource);
102
+ const launch = rewrite(section(delegation, "## Launch", delegationSource), [
103
+ [" before launching a writer (`orchestrator-writer.md`).", " before launching a writer (below)."],
104
+ ["Otherwise run in the foreground. Detail: reference.", "Otherwise run in the foreground. Detail: below."],
105
+ ["report the capability gap; a fired trigger is never replaced by inline work.", "report the capability gap; never do the work yourself instead."],
106
+ ], delegationSource);
107
+ const surfaces = section(writer, "#### Allowed edit surfaces (MANDATORY)", writerSource);
108
+ const background = marked(reference, "gentle-pi:background-subagents", referenceSource);
109
+ // The closing-block section is selected by position, as the heading that follows
110
+ // the launch section, and its heading text is copied from the source. Pi runtime
111
+ // code must never carry the block's name (tests/delegated-key-learnings-contract
112
+ // .test.ts): this script copies documentation, it never reads model output.
113
+ const closingHeading = headingAfter(delegation, "## Launch", delegationSource);
114
+ const closing = section(delegation, closingHeading, delegationSource);
115
+
116
+ return [
117
+ "# Orchestrator — Full Delegation Card (lazy-loaded)",
118
+ "",
119
+ // The comment names the script, never the organic source cards: anything this
120
+ // card names is something a full delegation session may go and read.
121
+ "<!-- Generated by scripts/build-full-delegation-card.mjs. Do not edit; run it with --write. -->",
122
+ "",
123
+ "Parent Pi session only, in full delegation mode: every authorized change goes to a bounded writer. These are the handoff, launch, edit-surface and background rules both workflow modes share.",
124
+ "",
125
+ "## Handoff",
126
+ "",
127
+ handoff,
128
+ "",
129
+ invariants,
130
+ "",
131
+ differential,
132
+ "",
133
+ "## Launch",
134
+ "",
135
+ launch,
136
+ "",
137
+ "#### Allowed edit surfaces (MANDATORY)",
138
+ "",
139
+ surfaces,
140
+ "",
141
+ background,
142
+ "",
143
+ closingHeading,
144
+ "",
145
+ closing,
146
+ "",
147
+ ].join("\n");
148
+ }
149
+
150
+ const isMain = process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1];
151
+ if (isMain) {
152
+ const assetsDir = join(dirname(fileURLToPath(import.meta.url)), "..", "assets");
153
+ const target = join(assetsDir, FULL_DELEGATION_CARD);
154
+ const rendered = renderFullDelegationCard(assetsDir);
155
+ const mode = process.argv[2];
156
+ if (mode === "--write") {
157
+ writeFileSync(target, rendered);
158
+ process.stdout.write(`wrote assets/${FULL_DELEGATION_CARD}\n`);
159
+ } else if (mode === "--check") {
160
+ let current = "";
161
+ try {
162
+ current = readFileSync(target, "utf8");
163
+ } catch {
164
+ current = "";
165
+ }
166
+ if (current !== rendered) {
167
+ process.stderr.write(`assets/${FULL_DELEGATION_CARD} is out of date with its sources; run node scripts/build-full-delegation-card.mjs --write\n`);
168
+ process.exit(1);
169
+ }
170
+ process.stdout.write(`assets/${FULL_DELEGATION_CARD} is up to date\n`);
171
+ } else {
172
+ process.stderr.write("usage: node scripts/build-full-delegation-card.mjs --write | --check\n");
173
+ process.exit(2);
174
+ }
175
+ }