gentle-pi 4.6.0 → 4.8.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 (536) hide show
  1. package/README.md +65 -55
  2. package/assets/agents/gentle-ai-explore.md +4 -3
  3. package/assets/agents/gentle-ai-verify.md +23 -6
  4. package/assets/agents/gentle-ai-worker.md +9 -6
  5. package/assets/agents/jd-fix-agent.md +1 -0
  6. package/assets/agents/jd-judge-a.md +2 -3
  7. package/assets/agents/jd-judge-b.md +2 -3
  8. package/assets/agents/review-readability.md +1 -5
  9. package/assets/agents/review-reliability.md +1 -5
  10. package/assets/agents/review-resilience.md +1 -5
  11. package/assets/agents/review-risk.md +1 -5
  12. package/assets/design-canvas/canvas-api.js +45 -0
  13. package/assets/design-canvas/canvas-boards.js +456 -0
  14. package/assets/design-canvas/canvas-boot.js +217 -0
  15. package/assets/design-canvas/canvas-checks.js +491 -0
  16. package/assets/design-canvas/canvas-comments.js +315 -0
  17. package/assets/design-canvas/canvas-compare.js +159 -0
  18. package/assets/design-canvas/canvas-events.js +75 -0
  19. package/assets/design-canvas/canvas-export.js +393 -0
  20. package/assets/design-canvas/canvas-focus.js +203 -0
  21. package/assets/design-canvas/canvas-handoffs.js +150 -0
  22. package/assets/design-canvas/canvas-i18n-es.js +392 -0
  23. package/assets/design-canvas/canvas-i18n.js +108 -0
  24. package/assets/design-canvas/canvas-layout.js +526 -0
  25. package/assets/design-canvas/canvas-menu.js +213 -0
  26. package/assets/design-canvas/canvas-messages.js +86 -0
  27. package/assets/design-canvas/canvas-minimap.js +163 -0
  28. package/assets/design-canvas/canvas-parts.js +401 -0
  29. package/assets/design-canvas/canvas-popover.js +234 -0
  30. package/assets/design-canvas/canvas-rail.js +348 -0
  31. package/assets/design-canvas/canvas-sizes.js +524 -0
  32. package/assets/design-canvas/canvas-store.js +164 -0
  33. package/assets/design-canvas/canvas-tokens.js +674 -0
  34. package/assets/design-canvas/canvas-ui.js +24 -0
  35. package/assets/design-canvas/canvas-view.js +184 -0
  36. package/assets/design-canvas/canvas.css +759 -16
  37. package/assets/design-canvas/canvas.js +2 -1497
  38. package/assets/design-canvas/index.html +117 -36
  39. package/assets/design-canvas/inspector.js +546 -16
  40. package/assets/install-wizard/wizard.js +6 -1
  41. package/assets/migrations/agent-body-history.json +40 -1
  42. package/assets/orchestrator-delegation-reference.md +10 -16
  43. package/assets/orchestrator-delegation.md +5 -5
  44. package/assets/orchestrator-full-delegation-card.md +64 -0
  45. package/assets/orchestrator-full-delegation.md +34 -0
  46. package/assets/orchestrator-memory.md +5 -5
  47. package/assets/orchestrator-prompts.md +2 -2
  48. package/assets/orchestrator-quota-recovery.md +5 -0
  49. package/assets/orchestrator-skills.md +14 -13
  50. package/assets/orchestrator-tracking.md +10 -14
  51. package/assets/orchestrator-verification.md +12 -8
  52. package/assets/orchestrator-writer.md +4 -4
  53. package/assets/orchestrator.md +21 -25
  54. package/bin/gentle-shell.mjs +292 -65
  55. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
  56. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
  57. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
  58. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
  59. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
  60. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
  61. package/docs/agent-status.md +61 -0
  62. package/docs/assets/brand/sponsor-banner.svg +60 -0
  63. package/docs/bundled-install.md +20 -10
  64. package/docs/delegated-verification.md +46 -8
  65. package/docs/desktop-rpc.md +1253 -0
  66. package/docs/gentle-agents-activity.md +40 -0
  67. package/docs/gentle-shell.md +91 -30
  68. package/docs/install-wizard.md +30 -21
  69. package/docs/odd-preparation-continuity.md +24 -0
  70. package/docs/permission-modes.md +17 -4
  71. package/docs/prompt-budget.md +12 -0
  72. package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
  73. package/docs/readme-reference.md +142 -45
  74. package/docs/render-cache-performance.md +11 -1
  75. package/docs/review-coordinator.md +53 -0
  76. package/docs/review-delivery-preflight.md +22 -0
  77. package/docs/review-request-context.md +19 -0
  78. package/docs/review-windows-acl.md +18 -0
  79. package/docs/voice.md +6 -3
  80. package/docs/work-continuity.md +11 -1
  81. package/docs/yolo-mode.md +5 -5
  82. package/extensions/ask-user-choice.ts +1 -0
  83. package/extensions/ask-user-question.ts +3 -2
  84. package/extensions/child-context.ts +21 -7
  85. package/extensions/child-safety.ts +3 -0
  86. package/extensions/gentle-agent-status.ts +99 -0
  87. package/extensions/gentle-agents.ts +559 -66
  88. package/extensions/gentle-ai.ts +2001 -518
  89. package/extensions/gentle-design.ts +69 -3
  90. package/extensions/gentle-desktop-rpc.ts +143 -0
  91. package/extensions/gentle-guide.ts +3 -0
  92. package/extensions/gentle-shell.ts +398 -115
  93. package/extensions/gentle-todo.ts +66 -27
  94. package/extensions/gentle-tps.ts +48 -0
  95. package/extensions/quiet-tools.ts +38 -8
  96. package/extensions/skill-registry.ts +349 -167
  97. package/extensions/startup-banner.ts +30 -3
  98. package/lib/agent-assets.ts +30 -6
  99. package/lib/agent-profile-pin.ts +3 -3
  100. package/lib/agent-profiles.ts +160 -2
  101. package/lib/agent-status.ts +105 -0
  102. package/lib/agent-tool-overlay.ts +117 -0
  103. package/lib/agents-config.ts +93 -6
  104. package/lib/agents-history.ts +24 -5
  105. package/lib/agents-message-delivery.ts +17 -0
  106. package/lib/agents-messaging.ts +55 -7
  107. package/lib/agents-protocol.ts +15 -0
  108. package/lib/agents-report-cap.ts +115 -0
  109. package/lib/agents-runner.ts +272 -16
  110. package/lib/agents-session-transport.ts +17 -1
  111. package/lib/auto-permission-runtime.ts +1 -1
  112. package/lib/background-jobs-tools.ts +9 -4
  113. package/lib/bounded-writer-admission.ts +197 -32
  114. package/lib/card-content-policy.ts +8 -6
  115. package/lib/child-context-files.ts +21 -6
  116. package/lib/codemode-renderer.ts +1 -0
  117. package/lib/command-palette.ts +133 -17
  118. package/lib/context-backstop.ts +14 -5
  119. package/lib/delivery-conflict-markers.ts +349 -0
  120. package/lib/design-canvas-assets.ts +36 -0
  121. package/lib/design-canvas-server.ts +241 -23
  122. package/lib/design-comments.ts +94 -4
  123. package/lib/design-handoffs.ts +2 -1
  124. package/lib/design-layout.ts +125 -0
  125. package/lib/design-parts.ts +281 -0
  126. package/lib/design-system-tokens.ts +111 -0
  127. package/lib/desktop-agents-service.ts +294 -0
  128. package/lib/desktop-design-service.ts +233 -0
  129. package/lib/desktop-jobs-service.ts +263 -0
  130. package/lib/desktop-rpc-agents.ts +294 -0
  131. package/lib/desktop-rpc-config.ts +731 -0
  132. package/lib/desktop-rpc-design.ts +138 -0
  133. package/lib/desktop-rpc-jobs.ts +181 -0
  134. package/lib/desktop-rpc-permissions.ts +177 -0
  135. package/lib/desktop-rpc-profiles.ts +196 -0
  136. package/lib/desktop-rpc-usage.ts +229 -0
  137. package/lib/desktop-rpc.ts +225 -0
  138. package/lib/desktop-usage-service.ts +310 -0
  139. package/lib/destructive-command-guard.ts +236 -17
  140. package/lib/execution-surface-guard.ts +20 -0
  141. package/lib/exploration-budget.ts +4 -2
  142. package/lib/gentle-ai-binary.ts +1 -1
  143. package/lib/gentle-ai-renderer.ts +13 -1
  144. package/lib/gentle-design.ts +204 -14
  145. package/lib/gentle-shell-bundled.ts +106 -28
  146. package/lib/gentle-shell-launcher.ts +43 -8
  147. package/lib/herdr-activity.ts +14 -2
  148. package/lib/herdr-busy.ts +45 -0
  149. package/lib/hidden-tools.ts +35 -0
  150. package/lib/image-attachments.ts +33 -0
  151. package/lib/image-disk-cache.ts +137 -0
  152. package/lib/inprocess-reviewer.ts +358 -144
  153. package/lib/jobs-view.ts +198 -11
  154. package/lib/model-fallback-policy.ts +9 -0
  155. package/lib/model-routing-authority.ts +31 -4
  156. package/lib/nan-provider.ts +42 -28
  157. package/lib/native-choice-list.ts +20 -2
  158. package/lib/native-review-cli.ts +172 -20
  159. package/lib/orchestrator-discovery.ts +39 -2
  160. package/lib/orchestrator-mode-policy.ts +105 -0
  161. package/lib/questionnaire/questionnaire-view.ts +105 -12
  162. package/lib/rdd-mode-control.ts +32 -0
  163. package/lib/reply-language-anchor.ts +129 -0
  164. package/lib/request-context-placement.ts +53 -0
  165. package/lib/review-blocker.ts +92 -0
  166. package/lib/review-candidate-symlink-scan.ts +136 -0
  167. package/lib/review-candidate-view-owner.ts +81 -44
  168. package/lib/review-candidate-view.ts +11 -1
  169. package/lib/review-continuation-registry.ts +116 -0
  170. package/lib/review-coordinator.ts +407 -0
  171. package/lib/review-delivery-preflight.ts +85 -0
  172. package/lib/review-failure-facts.ts +49 -0
  173. package/lib/review-host-relay.ts +51 -11
  174. package/lib/review-integration-v2.ts +63 -4
  175. package/lib/review-relay-phase-timing.ts +45 -0
  176. package/lib/review-start-context.ts +17 -0
  177. package/lib/reviewer-stream.ts +87 -0
  178. package/lib/session-profile-freeze.ts +4 -2
  179. package/lib/shell-bar.ts +140 -58
  180. package/lib/shell-changes.ts +2 -0
  181. package/lib/shell-panel.ts +17 -3
  182. package/lib/shell-prompt.ts +16 -3
  183. package/lib/shell-sidebar-layout.ts +112 -40
  184. package/lib/shell-sidebar.ts +7 -0
  185. package/lib/shell-todo.ts +10 -3
  186. package/lib/shell-usage.ts +10 -0
  187. package/lib/verifier-admission.ts +1 -1
  188. package/lib/vim-editor-adapter.ts +9 -2
  189. package/lib/visual-customization-policy.ts +36 -16
  190. package/lib/visual-customize-view.ts +216 -21
  191. package/lib/visual-layout-preview.ts +9 -5
  192. package/lib/visual-profiles.ts +2 -2
  193. package/lib/windows-session-transport.ts +53 -2
  194. package/lib/writer-batch-admission.ts +55 -0
  195. package/lib/yolo-session-policy.ts +46 -16
  196. package/package.json +3 -2
  197. package/prompts/skill-creation.md +1 -10
  198. package/runtime/design-canvas-assets.mjs +37 -0
  199. package/runtime/gentle-ai-binary.mjs +1 -1
  200. package/runtime/gentle-shell-bundled.mjs +106 -28
  201. package/runtime/gentle-shell-launcher.mjs +42 -7
  202. package/runtime/native-review-cli.mjs +169 -17
  203. package/runtime/review-integration-v2.mjs +63 -4
  204. package/scripts/bootstrap.cmd +2 -2
  205. package/scripts/bootstrap.sh +41 -4
  206. package/scripts/build-full-delegation-card.mjs +179 -0
  207. package/scripts/build-runtime-modules.mjs +1 -0
  208. package/scripts/bundled-install.mjs +38 -8
  209. package/scripts/download-progress.mjs +68 -0
  210. package/scripts/gentle-ai-installer.mjs +41 -18
  211. package/scripts/gentle-ai-proxy.mjs +294 -0
  212. package/scripts/install-gentle-ai.mjs +14 -1
  213. package/scripts/installer-downloads.mjs +34 -8
  214. package/scripts/installer-preflight.mjs +33 -22
  215. package/scripts/installer-probes.mjs +25 -5
  216. package/scripts/installer-runner.mjs +27 -12
  217. package/scripts/installer-server.mjs +46 -16
  218. package/scripts/installer-windows.mjs +2 -2
  219. package/scripts/pi-update.mjs +166 -27
  220. package/scripts/prepare-verifier.mjs +107 -0
  221. package/scripts/render-cache-host.mjs +72 -0
  222. package/scripts/render-cache-performance-worker.mjs +5 -4
  223. package/scripts/render-cache-performance.mjs +6 -1
  224. package/scripts/run-test-suite.mjs +40 -28
  225. package/scripts/update-agent-body-history.mjs +55 -8
  226. package/scripts/verify-package-files.mjs +50 -19
  227. package/scripts/voice-worker.cjs +32 -6
  228. package/skills/branch-pr/SKILL.md +16 -16
  229. package/skills/comment-writer/SKILL.md +1 -1
  230. package/skills/design/SKILL.md +16 -13
  231. package/skills/gentle-ai/SKILL.md +7 -7
  232. package/skills/gentle-ui-design/SKILL.md +46 -0
  233. package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
  234. package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
  235. package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
  236. package/skills/gentle-ui-design/references/task-and-content.md +60 -0
  237. package/skills/judgment-day/SKILL.md +2 -2
  238. package/skills/judgment-day/references/prompts-and-formats.md +1 -1
  239. package/skills/rdd-defect-workflow/SKILL.md +6 -6
  240. package/skills/skill-improver/SKILL.md +2 -2
  241. package/skills/skill-registry/SKILL.md +11 -11
  242. package/skills/tui-design/SKILL.md +1 -1
  243. package/skills/work-unit-commits/SKILL.md +10 -11
  244. package/tests/agent-home.test.ts +28 -9
  245. package/tests/agent-profiles-workflow.test.ts +163 -0
  246. package/tests/agent-prompt-diet-contract.test.ts +101 -0
  247. package/tests/agent-risk-escalation.test.ts +1 -1
  248. package/tests/agent-status.test.ts +143 -0
  249. package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
  250. package/tests/agent-tool-overlay.test.ts +89 -0
  251. package/tests/agents-config.test.ts +106 -1
  252. package/tests/agents-history.test.ts +31 -0
  253. package/tests/agents-jobs-frames.test.ts +93 -0
  254. package/tests/agents-message-delivery.test.ts +36 -0
  255. package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
  256. package/tests/agents-queries.test.ts +144 -4
  257. package/tests/agents-report-cap.test.ts +126 -0
  258. package/tests/agents-runner-drain.test.ts +193 -0
  259. package/tests/agents-runner.test.ts +215 -3
  260. package/tests/agents-session-transport.test.ts +34 -0
  261. package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
  262. package/tests/append-system-prompt-route.test.ts +12 -1
  263. package/tests/approved-text-leftovers-contract.test.ts +136 -0
  264. package/tests/artifact-language.test.ts +1 -1
  265. package/tests/ask-user-choice.test.ts +4 -3
  266. package/tests/ask-user-question.test.ts +99 -1
  267. package/tests/audit-leftovers-contract.test.ts +51 -0
  268. package/tests/auto-permission-runtime.test.ts +1 -1
  269. package/tests/autonomous-guard.test.ts +346 -10
  270. package/tests/bounded-stop-contract.test.ts +51 -3
  271. package/tests/branch-pr-skill.test.ts +10 -1
  272. package/tests/bridge-cost.test.ts +19 -4
  273. package/tests/bundled-install.test.ts +31 -6
  274. package/tests/card-content-policy.test.ts +3 -3
  275. package/tests/chained-pr-skill.test.ts +8 -6
  276. package/tests/child-context-files.test.ts +64 -8
  277. package/tests/child-safety.test.ts +11 -0
  278. package/tests/child-skills-catalog.test.ts +56 -0
  279. package/tests/codegraph-tools.test.ts +11 -5
  280. package/tests/codemode-rendering.test.ts +4 -1
  281. package/tests/command-palette.test.ts +284 -1
  282. package/tests/delegate-for-reason-contract.test.ts +32 -10
  283. package/tests/delivery-conflict-markers.test.ts +348 -0
  284. package/tests/design-canvas-all-sizes.test.ts +631 -0
  285. package/tests/design-canvas-allowlist.test.ts +32 -0
  286. package/tests/design-canvas-assets.test.ts +11 -695
  287. package/tests/design-canvas-boards.test.ts +77 -0
  288. package/tests/design-canvas-checks.test.ts +655 -0
  289. package/tests/design-canvas-compare.test.ts +79 -0
  290. package/tests/design-canvas-events.test.ts +59 -0
  291. package/tests/design-canvas-export.test.ts +1168 -0
  292. package/tests/design-canvas-focus.test.ts +113 -0
  293. package/tests/design-canvas-handoffs.test.ts +59 -0
  294. package/tests/design-canvas-i18n-review.test.ts +513 -0
  295. package/tests/design-canvas-i18n-views.test.ts +259 -0
  296. package/tests/design-canvas-i18n.test.ts +526 -0
  297. package/tests/design-canvas-inspector.test.ts +937 -0
  298. package/tests/design-canvas-layout.test.ts +1222 -0
  299. package/tests/design-canvas-minimap.test.ts +413 -0
  300. package/tests/design-canvas-modules.test.ts +90 -0
  301. package/tests/design-canvas-parts.test.ts +721 -0
  302. package/tests/design-canvas-rail.test.ts +799 -0
  303. package/tests/design-canvas-server.test.ts +855 -17
  304. package/tests/design-canvas-sizes.test.ts +548 -0
  305. package/tests/design-canvas-store.test.ts +180 -0
  306. package/tests/design-canvas-tokens.test.ts +965 -0
  307. package/tests/design-canvas-view.test.ts +299 -0
  308. package/tests/design-comments.test.ts +201 -1
  309. package/tests/design-handoffs.test.ts +20 -0
  310. package/tests/design-layout.test.ts +100 -0
  311. package/tests/design-parts.test.ts +260 -0
  312. package/tests/design-system-tokens.test.ts +215 -0
  313. package/tests/desktop-rpc-agents.test.ts +893 -0
  314. package/tests/desktop-rpc-config.test.ts +1452 -0
  315. package/tests/desktop-rpc-design.test.ts +662 -0
  316. package/tests/desktop-rpc-jobs.test.ts +796 -0
  317. package/tests/desktop-rpc-permissions.test.ts +311 -0
  318. package/tests/desktop-rpc-profiles.test.ts +140 -0
  319. package/tests/desktop-rpc-safety.test.ts +119 -0
  320. package/tests/desktop-rpc-usage.test.ts +697 -0
  321. package/tests/desktop-rpc.test.ts +252 -0
  322. package/tests/destructive-command-guard.test.ts +52 -0
  323. package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
  324. package/tests/devbinary/review-session-consent.devtest.ts +84 -0
  325. package/tests/download-progress.test.ts +71 -0
  326. package/tests/engram-safety.test.ts +111 -0
  327. package/tests/execution-surface-guard.test.ts +55 -0
  328. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
  329. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
  330. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -31
  331. package/tests/fixtures/proxy-tls/proxy.crt +19 -0
  332. package/tests/fixtures/proxy-tls/proxy.key +28 -0
  333. package/tests/fixtures/refusal-identity.probe.mjs +139 -0
  334. package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
  335. package/tests/fixtures/session-profile-v1/replay.ts +53 -6
  336. package/tests/full-delegation-closure.test.ts +160 -0
  337. package/tests/full-delegation-notices.test.ts +76 -0
  338. package/tests/generic-agent-tools.test.ts +3 -3
  339. package/tests/gentle-agent-status.test.ts +74 -0
  340. package/tests/gentle-agents-child-jobs.test.ts +237 -0
  341. package/tests/gentle-agents.test.ts +1403 -20
  342. package/tests/gentle-ai-binary.test.ts +3 -1
  343. package/tests/gentle-ai-child-guards.test.ts +1 -0
  344. package/tests/gentle-ai-elapsed-store.test.ts +19 -0
  345. package/tests/gentle-ai-exploration-budget.test.ts +18 -2
  346. package/tests/gentle-ai-installer.test.ts +135 -51
  347. package/tests/gentle-ai-proxy.test.ts +434 -0
  348. package/tests/gentle-ai-renderer.test.ts +36 -2
  349. package/tests/gentle-ai.test.ts +233 -43
  350. package/tests/gentle-design.test.ts +386 -1
  351. package/tests/gentle-herdr-activity.test.ts +9 -6
  352. package/tests/gentle-shell-bin.test.ts +123 -0
  353. package/tests/gentle-shell-bundled.test.ts +293 -31
  354. package/tests/gentle-shell-launcher.test.ts +78 -11
  355. package/tests/gentle-shell.test.ts +1017 -146
  356. package/tests/gentle-todo.test.ts +51 -11
  357. package/tests/gentle-tps.test.ts +123 -0
  358. package/tests/gentle-ui-design-skill.test.ts +59 -0
  359. package/tests/herdr-busy.test.ts +59 -0
  360. package/tests/herdr-task-summary-policy.test.ts +8 -4
  361. package/tests/hidden-tools.test.ts +188 -0
  362. package/tests/image-disk-cache.test.ts +163 -0
  363. package/tests/independent-recovery-delivery.test.ts +97 -0
  364. package/tests/inprocess-reviewer.test.ts +249 -4
  365. package/tests/install-wizard.test.ts +27 -1
  366. package/tests/installer-downloads.test.ts +30 -1
  367. package/tests/installer-posix-bootstrap.test.ts +115 -14
  368. package/tests/installer-preflight.test.ts +54 -5
  369. package/tests/installer-probes.test.ts +146 -0
  370. package/tests/installer-runner.test.ts +79 -44
  371. package/tests/installer-server.test.ts +215 -13
  372. package/tests/installer-windows-bootstrap.test.ts +19 -1
  373. package/tests/jobs-view.test.ts +260 -6
  374. package/tests/judgment-day-severity-admission.test.ts +46 -0
  375. package/tests/lazy-module-contradictions-contract.test.ts +158 -0
  376. package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
  377. package/tests/maintainer/pi-update-source.maintest.ts +48 -18
  378. package/tests/modal-mouse-boundaries.test.ts +136 -0
  379. package/tests/model-fallback-policy.test.ts +26 -7
  380. package/tests/model-routing-authority.test.ts +178 -2
  381. package/tests/nan-provider-runtime.test.ts +17 -3
  382. package/tests/nan-provider.test.ts +111 -56
  383. package/tests/native-choice-list.test.ts +77 -2
  384. package/tests/native-review-capability-contract.test.ts +17 -1
  385. package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
  386. package/tests/native-review-cli.test.ts +269 -1
  387. package/tests/native-review-parity.test.ts +24 -5
  388. package/tests/native-review-refusal-identity.test.ts +25 -0
  389. package/tests/no-self-pause-contract.test.ts +13 -2
  390. package/tests/odd-integration.test.ts +11 -3
  391. package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
  392. package/tests/odd-routing-contract.test.ts +80 -28
  393. package/tests/orchestrator-budget.test.ts +35 -5
  394. package/tests/orchestrator-consultation-sdk.test.ts +32 -6
  395. package/tests/orchestrator-delegation-mode.test.ts +154 -0
  396. package/tests/orchestrator-discovery.test.ts +28 -0
  397. package/tests/orchestrator-mode-policy.test.ts +175 -0
  398. package/tests/orchestrator-prompt-budget.test.ts +13 -2
  399. package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
  400. package/tests/orchestrator-rdd-ownership.test.ts +4 -3
  401. package/tests/orchestrator-work-search.test.ts +4 -2
  402. package/tests/package-files.test.ts +25 -1
  403. package/tests/package-manifest.test.ts +16 -13
  404. package/tests/parallel-reason-contract.test.ts +6 -3
  405. package/tests/permission-allowlist.test.ts +372 -0
  406. package/tests/persona-neutral-voseo.test.ts +4 -4
  407. package/tests/persona-reply-language.test.ts +1 -1
  408. package/tests/persona-single-channel.test.ts +13 -5
  409. package/tests/pi-update-launcher.test.ts +25 -7
  410. package/tests/pi-update-source.test.ts +113 -6
  411. package/tests/pi-update.test.ts +294 -19
  412. package/tests/pnpm-workspace-config.test.ts +58 -0
  413. package/tests/pnpm-workspace-policy.test.ts +47 -0
  414. package/tests/primary-context-files.test.ts +233 -0
  415. package/tests/primary-context-three-files.test.ts +174 -0
  416. package/tests/primary-session-prompt.test.ts +13 -0
  417. package/tests/profile-pin.test.ts +29 -2
  418. package/tests/profile-tier-footer.test.ts +5 -0
  419. package/tests/profiles-panel-delegation-mode.test.ts +422 -0
  420. package/tests/provider-defect-handoff.test.ts +9 -2
  421. package/tests/questionnaire-view.test.ts +115 -0
  422. package/tests/quiet-bash-runtime.test.ts +1 -1
  423. package/tests/quiet-tool-rendering.test.ts +48 -0
  424. package/tests/rdd-aware-verification-contract.test.ts +17 -12
  425. package/tests/rdd-customize.test.ts +287 -0
  426. package/tests/rdd-mode-cache.test.ts +450 -0
  427. package/tests/rdd-mode-control.test.ts +407 -0
  428. package/tests/rdd-mode-scope-regression.test.ts +137 -0
  429. package/tests/rdd-off-independent-regression.test.ts +69 -0
  430. package/tests/rdd-status-line.test.ts +112 -1
  431. package/tests/render-cache-performance.test.ts +171 -2
  432. package/tests/reply-language-anchor-placement.test.ts +184 -0
  433. package/tests/reply-language-anchor.test.ts +189 -0
  434. package/tests/request-context-append-only.test.ts +218 -0
  435. package/tests/request-context-placement.test.ts +148 -0
  436. package/tests/review-agent-end-preflight.test.ts +80 -2
  437. package/tests/review-blocker.test.ts +193 -0
  438. package/tests/review-candidate-owner-retry.test.ts +1 -1
  439. package/tests/review-candidate-symlink-scan.test.ts +157 -0
  440. package/tests/review-candidate-view.test.ts +66 -1
  441. package/tests/review-candidate-windows-boundary.test.ts +131 -0
  442. package/tests/review-candidate-windows-probe.test.ts +63 -0
  443. package/tests/review-committed-restart-ack.test.ts +129 -0
  444. package/tests/review-continuation-registry.test.ts +107 -0
  445. package/tests/review-contract-prompt.test.ts +1 -1
  446. package/tests/review-controller-native-routing.test.ts +261 -5
  447. package/tests/review-controller-workspace-root.test.ts +230 -3
  448. package/tests/review-controller.test.ts +98 -12
  449. package/tests/review-coordinator-correction-gate.test.ts +105 -0
  450. package/tests/review-coordinator-findings.test.ts +206 -0
  451. package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
  452. package/tests/review-coordinator-runtime.test.ts +117 -0
  453. package/tests/review-coordinator.test.ts +462 -0
  454. package/tests/review-delivery-preflight.test.ts +462 -0
  455. package/tests/review-due-compaction.test.ts +31 -0
  456. package/tests/review-due-public-boundary.test.ts +26 -0
  457. package/tests/review-failure-facts.test.ts +87 -0
  458. package/tests/review-host-relay-routing.test.ts +258 -4
  459. package/tests/review-host-relay.test.ts +39 -0
  460. package/tests/review-integration-nonblocking-findings.test.ts +108 -0
  461. package/tests/review-integration-v2.test.ts +46 -3
  462. package/tests/review-json-arguments.test.ts +105 -11
  463. package/tests/review-last-event-closure.test.ts +68 -0
  464. package/tests/review-ledger-contract.test.ts +19 -40
  465. package/tests/review-loadout-rdd-off-sdk.test.ts +95 -32
  466. package/tests/review-one-call-findings.test.ts +131 -0
  467. package/tests/review-one-call-followups.test.ts +308 -0
  468. package/tests/review-one-call-reviewer-requests.test.ts +207 -0
  469. package/tests/review-one-call.test.ts +452 -0
  470. package/tests/review-owner-identity.test.ts +60 -24
  471. package/tests/review-relay-phase-timing.test.ts +128 -0
  472. package/tests/review-relay-transport-agent.test.ts +39 -2
  473. package/tests/review-reviewer-evidence.test.ts +223 -0
  474. package/tests/review-risk-assessment.test.ts +126 -8
  475. package/tests/review-run-statement-guidance-independent.test.ts +54 -0
  476. package/tests/review-session-standing-permission-controller.test.ts +53 -3
  477. package/tests/review-start-context.test.ts +19 -0
  478. package/tests/review-tool-prose-budget.test.ts +122 -0
  479. package/tests/reviewer-stream.test.ts +149 -0
  480. package/tests/run-test-suite.test.ts +122 -1
  481. package/tests/runtime-harness.mjs +4 -1
  482. package/tests/sensitive-path-tools.test.ts +181 -5
  483. package/tests/session-profile-append-controller-pi.test.ts +60 -31
  484. package/tests/session-profile-binding.test.ts +19 -1
  485. package/tests/session-profile-disk-reader-pi.test.ts +58 -16
  486. package/tests/session-profile-extension.test.ts +2 -2
  487. package/tests/session-profile-v1-compat.test.ts +35 -1
  488. package/tests/shell-bar.test.ts +186 -42
  489. package/tests/shell-panel.test.ts +50 -22
  490. package/tests/shell-prompt.test.ts +17 -0
  491. package/tests/shell-sidebar-fullscreen.test.ts +5 -5
  492. package/tests/shell-sidebar-layout.test.ts +294 -23
  493. package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
  494. package/tests/shell-surface-transparent.test.ts +89 -0
  495. package/tests/shell-todo.test.ts +12 -0
  496. package/tests/shell-usage.test.ts +59 -10
  497. package/tests/skill-contradictions-contract.test.ts +122 -0
  498. package/tests/skill-registry-watcher.test.ts +216 -2
  499. package/tests/skill-registry.test.ts +1461 -5
  500. package/tests/startup-banner.test.ts +152 -1
  501. package/tests/startup-home-repo.test.ts +2 -0
  502. package/tests/support/design-canvas-dom.ts +369 -0
  503. package/tests/support/review-coordinator-runtime.ts +264 -0
  504. package/tests/task-size-routing-contract.test.ts +45 -12
  505. package/tests/test-strength-contract.test.ts +2 -1
  506. package/tests/todo-request-append-only.test.ts +214 -0
  507. package/tests/tool-batching-contract.test.ts +3 -1
  508. package/tests/update-agent-body-history.test.ts +138 -0
  509. package/tests/verification-tiers-contract.test.ts +229 -0
  510. package/tests/verifier-admission.test.ts +49 -0
  511. package/tests/verifier-preparation.test.ts +229 -0
  512. package/tests/verify-agent-contract.test.ts +20 -2
  513. package/tests/verify-first-launch-contract.test.ts +162 -11
  514. package/tests/vim-editor-adapter.test.ts +2 -2
  515. package/tests/visual-customization-policy.test.ts +39 -6
  516. package/tests/visual-customize-view.test.ts +573 -9
  517. package/tests/visual-layout-preview.test.ts +15 -1
  518. package/tests/visual-profiles.test.ts +11 -0
  519. package/tests/voice-worker.test.ts +73 -2
  520. package/tests/windows-session-transport.test.ts +126 -0
  521. package/tests/work-continuity-contract.test.ts +77 -6
  522. package/tests/writer-admission-messages.test.ts +232 -0
  523. package/tests/writer-batch-admission.test.ts +66 -0
  524. package/tests/writer-edit-surface-scope.test.ts +52 -20
  525. package/tests/writer-feature-document-admission.test.ts +276 -0
  526. package/tests/yolo-customize.test.ts +27 -4
  527. package/tests/yolo-mode.test.ts +62 -18
  528. package/tests/yolo-session-policy.test.ts +270 -1
  529. package/skills/_shared/review-ledger-contract.md +0 -106
  530. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
  531. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
  532. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
  533. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  534. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
  535. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
  536. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -1,21 +1,25 @@
1
1
  import { execFile } from "node:child_process";
2
- import { createHash } from "node:crypto";
3
- import { existsSync, type FSWatcher, watch } from "node:fs";
2
+ import { createHash, randomUUID } from "node:crypto";
3
+ import { constants, existsSync, type FSWatcher, watch } from "node:fs";
4
4
  import {
5
5
  access,
6
6
  lstat,
7
7
  mkdir,
8
+ open,
8
9
  readFile,
9
10
  readdir,
11
+ realpath,
10
12
  rename,
11
13
  stat,
14
+ unlink,
12
15
  writeFile,
13
16
  } from "node:fs/promises";
14
17
  import { homedir } from "node:os";
15
- import { basename, delimiter, dirname, join, normalize, relative, resolve, sep } from "node:path";
18
+ import { basename, delimiter, dirname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
16
19
  import { fileURLToPath } from "node:url";
17
20
  import { promisify } from "node:util";
18
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
21
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
22
+ import { appendSystemPromptOnce, type AppendableSystemPromptOptions } from "../lib/append-system-prompt.ts";
19
23
  import { isHomeOrBroadUserDirectory } from "../lib/bounded-writer-admission.ts";
20
24
  import { resolveSessionWorktree } from "../lib/session-worktree-registry.ts";
21
25
 
@@ -24,13 +28,17 @@ const CACHE_REL_PATH = ".atl/.skill-registry.cache.json";
24
28
  const SECTION_MARKER = "## Skills";
25
29
  const EXCLUDE_NAMES = new Set(["_shared", "skill-registry"]);
26
30
  const EXCLUDE_PREFIXES = ["sdd-"];
31
+ // The registry skill's shipped name. Excluded from the session view only: the
32
+ // shared disk index keeps byte parity with the Gentle AI CLI writer.
33
+ const SESSION_EXCLUDE_NAMES = new Set(["gentle-ai-skill-registry"]);
27
34
  const WATCH_DEBOUNCE_MS = 500;
28
35
  // inotify budgets are finite (ENOSPC/EMFILE) and recursive watches degrade
29
36
  // silently on exhausted systems -- WSL2 hits this constantly -- so a slow
30
37
  // poll is the floor that keeps regeneration working when the OS cannot
31
- // deliver change events. The fingerprint gate makes a redundant poll cheap.
32
- const WATCH_FALLBACK_POLL_MS = 2_000;
33
- const REGISTRY_SCHEMA_VERSION = 7;
38
+ // deliver change events. Watcher events still use the 500ms debounce; the
39
+ // fallback scans at most twice per minute instead of rereading every skill
40
+ // 30 times per minute in an idle session. Each poll validates disk bytes.
41
+ const WATCH_FALLBACK_POLL_MS = 30_000;
34
42
  const NO_SKILL_REGISTRY_FLAG = "no-skill-registry";
35
43
  const NO_SKILL_REGISTRY_ENV = "GENTLE_PI_NO_SKILL_REGISTRY";
36
44
  const LEGACY_PROJECT_REGISTRY_REL_PATH = ".pi/extensions/skill-registry.ts";
@@ -60,30 +68,61 @@ interface SkillEntry {
60
68
  scope?: string;
61
69
  }
62
70
 
63
- function userSkillDirs(): string[] {
64
- const home = homedir();
71
+ // Structural mirror of pi's runtime-resolved skill record. Kept local on
72
+ // purpose: this seam must not import pi internals.
73
+ export interface ResolvedSkill {
74
+ name: string;
75
+ description: string;
76
+ filePath: string;
77
+ baseDir?: string;
78
+ disableModelInvocation?: boolean;
79
+ sourceInfo?: {
80
+ path?: string;
81
+ source?: string;
82
+ scope?: "user" | "project" | "temporary";
83
+ origin?: "package" | "top-level";
84
+ baseDir?: string;
85
+ };
86
+ }
87
+
88
+ async function userSkillDirs(): Promise<string[]> {
89
+ const home = resolve(homedir());
90
+ // Match CodexConfigDir: an invalid override stays at its resolved location,
91
+ // rather than silently falling back to ~/.codex.
92
+ let codex = process.env.CODEX_HOME ? resolve(process.env.CODEX_HOME) : join(home, ".codex");
93
+ if (process.env.CODEX_HOME) {
94
+ try {
95
+ if ((await stat(codex)).isDirectory()) codex = await realpath(codex);
96
+ } catch { /* Invalid overrides are not redirected. */ }
97
+ }
65
98
  return [
66
99
  join(home, ".pi/agent/skills"),
67
100
  join(home, ".config/agents/skills"),
68
101
  join(home, ".agents/skills"),
102
+ join(home, ".kimi-code/skills"),
69
103
  join(home, ".kimi/skills"),
70
104
  join(home, ".config/opencode/skills"),
71
105
  join(home, ".config/kilo/skills"),
72
106
  join(home, ".claude/skills"),
73
107
  join(home, ".gemini/skills"),
108
+ join(home, ".gemini/config/skills"),
74
109
  join(home, ".gemini/antigravity/skills"),
75
- join(home, ".trae/skills"),
110
+ join(home, ".gemini/antigravity-desktop/skills"),
111
+ join(home, ".gemini/antigravity-cli/skills"),
76
112
  join(home, ".cursor/skills"),
77
113
  join(home, ".copilot/skills"),
78
- join(home, ".codex/skills"),
114
+ join(codex, "skills"),
79
115
  join(home, ".codeium/windsurf/skills"),
80
116
  join(home, ".qwen/skills"),
81
117
  join(home, ".kiro/skills"),
82
118
  join(home, ".openclaw/skills"),
119
+ join(home, ".hermes/skills"),
120
+ join(home, ".trae/skills"),
83
121
  ];
84
122
  }
85
123
 
86
124
  function projectSkillDirs(cwd: string): string[] {
125
+ cwd = resolve(cwd);
87
126
  return [
88
127
  join(cwd, "skills"),
89
128
  join(cwd, ".opencode/skills"),
@@ -100,6 +139,7 @@ function projectSkillDirs(cwd: string): string[] {
100
139
  join(cwd, ".agent/skills"),
101
140
  join(cwd, ".agents/skills"),
102
141
  join(cwd, ".atl/skills"),
142
+ join(cwd, ".hermes/skills"),
103
143
  ];
104
144
  }
105
145
 
@@ -129,6 +169,8 @@ async function findSkillFiles(root: string): Promise<string[]> {
129
169
  const directSkills: string[] = [];
130
170
  const nestedSkills: string[] = [];
131
171
  for (const entry of entries) {
172
+ // Excluded directory names remain excluded even if frontmatter aliases them.
173
+ if (isExcluded(entry.name)) continue;
132
174
  const skillDir = join(root, entry.name);
133
175
  let dirInfo;
134
176
  try {
@@ -146,7 +188,7 @@ async function findSkillFiles(root: string): Promise<string[]> {
146
188
  } catch (error) {
147
189
  if (!isMissingSkillFileError(error)) continue;
148
190
  }
149
- if (entry.isSymbolicLink() || isExcluded(entry.name)) continue;
191
+ if (entry.isSymbolicLink()) continue;
150
192
 
151
193
  let nestedEntries;
152
194
  try {
@@ -155,7 +197,7 @@ async function findSkillFiles(root: string): Promise<string[]> {
155
197
  continue;
156
198
  }
157
199
  for (const nestedEntry of nestedEntries) {
158
- if (nestedEntry.isSymbolicLink()) continue;
200
+ if (nestedEntry.isSymbolicLink() || isExcluded(nestedEntry.name)) continue;
159
201
  const nestedSkillDir = join(skillDir, nestedEntry.name);
160
202
  let nestedDirInfo;
161
203
  try {
@@ -174,7 +216,7 @@ async function findSkillFiles(root: string): Promise<string[]> {
174
216
  }
175
217
  }
176
218
  }
177
- return [...directSkills.sort(), ...nestedSkills.sort()];
219
+ return [...directSkills.sort(compareUtf8), ...nestedSkills.sort(compareUtf8)];
178
220
  }
179
221
 
180
222
  function parseFrontmatter(source: string): { name?: string; description?: string; body: string } {
@@ -188,25 +230,25 @@ function parseFrontmatter(source: string): { name?: string; description?: string
188
230
  const lines = fm.split("\n");
189
231
  for (let i = 0; i < lines.length; i++) {
190
232
  const line = lines[i];
191
- const m = line.match(/^(\w+):\s*(.*)$/);
233
+ const m = line.match(/^(\w+):(.*)$/);
192
234
  if (!m) continue;
193
235
  const key = m[1];
194
- let value = m[2].trim();
236
+ let value = trimUnicodeWhitespace(m[2]);
195
237
  if (value === ">" || value === ">-" || value === "|" || value === "|-") {
196
238
  const block: string[] = [];
197
239
  while (i + 1 < lines.length) {
198
240
  const next = lines[i + 1];
199
- if (next.trim() === "") {
241
+ if (trimUnicodeWhitespace(next) === "") {
200
242
  block.push("");
201
243
  i++;
202
244
  continue;
203
245
  }
204
246
  if (!next.startsWith(" ") && !next.startsWith("\t")) break;
205
- block.push(next.trim());
247
+ block.push(trimUnicodeWhitespace(next));
206
248
  i++;
207
249
  }
208
- value = block.join(" ").trim();
209
- } else if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
250
+ value = trimUnicodeWhitespace(block.join(" "));
251
+ } else if (value.length >= 2 && ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'")))) {
210
252
  value = value.slice(1, -1);
211
253
  }
212
254
  if (key === "name") out.name = value;
@@ -234,8 +276,12 @@ async function uniqueExistingDirs(dirs: string[]): Promise<string[]> {
234
276
  const seen = new Set<string>();
235
277
  const out: string[] = [];
236
278
  for (const dir of dirs) {
237
- const clean = comparablePath(dir);
238
- if (seen.has(clean) || !(await pathExists(clean))) continue;
279
+ const clean = comparablePath(resolve(dir));
280
+ if (seen.has(clean)) continue;
281
+ try {
282
+ if (!(await stat(clean)).isDirectory()) continue;
283
+ await access(clean, constants.R_OK);
284
+ } catch { continue; }
239
285
  seen.add(clean);
240
286
  out.push(clean);
241
287
  }
@@ -259,8 +305,17 @@ async function loadSkill(file: string): Promise<SkillEntry | undefined> {
259
305
  };
260
306
  }
261
307
 
308
+ const UNICODE_WHITESPACE = "\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
309
+ const whitespaceRuns = new RegExp(`[${UNICODE_WHITESPACE}]+`, "g");
310
+ const whitespaceEdges = new RegExp(`^[${UNICODE_WHITESPACE}]+|[${UNICODE_WHITESPACE}]+$`, "g");
311
+ function trimUnicodeWhitespace(value: string): string {
312
+ return value.replace(whitespaceEdges, "");
313
+ }
262
314
  function normalizeSkillDescription(description: string): string {
263
- return description.replace(/\s+/g, " ").trim();
315
+ return trimUnicodeWhitespace(description.replace(whitespaceRuns, " "));
316
+ }
317
+ function compareUtf8(left: string, right: string): number {
318
+ return Buffer.compare(Buffer.from(left), Buffer.from(right));
264
319
  }
265
320
 
266
321
  function dedupeBySkillName(entries: SkillEntry[], cwd: string): SkillEntry[] {
@@ -274,10 +329,87 @@ function dedupeBySkillName(entries: SkillEntry[], cwd: string): SkillEntry[] {
274
329
  }
275
330
  const out: SkillEntry[] = [];
276
331
  for (const [, list] of buckets) {
277
- const projectScoped = list.find((e) => comparablePath(e.path).startsWith(projectPrefix));
332
+ const projectScoped = list.find((e) =>
333
+ e.scope?.startsWith("project") ||
334
+ (e.scope === undefined && comparablePath(e.path).startsWith(projectPrefix)),
335
+ );
278
336
  out.push(projectScoped ?? list[0]);
279
337
  }
280
- return out.sort((a, b) => a.name.localeCompare(b.name));
338
+ return out.sort((a, b) => compareUtf8(a.name, b.name));
339
+ }
340
+
341
+ function resolvedScopeLabel(skill: ResolvedSkill): string {
342
+ const scope = skill.sourceInfo?.scope === "project" ? "project" : "user";
343
+ return skill.sourceInfo?.origin === "package" ? `${scope} · package` : scope;
344
+ }
345
+
346
+ function trimResolvedSkill(skill: ResolvedSkill): ResolvedSkill {
347
+ const trimmed: ResolvedSkill = {
348
+ name: skill.name,
349
+ description: skill.description,
350
+ filePath: skill.filePath,
351
+ };
352
+ if (skill.disableModelInvocation === true) trimmed.disableModelInvocation = true;
353
+ if (skill.sourceInfo) {
354
+ trimmed.sourceInfo = {
355
+ scope: skill.sourceInfo.scope,
356
+ origin: skill.sourceInfo.origin,
357
+ };
358
+ }
359
+ return trimmed;
360
+ }
361
+
362
+ function isResolvedSourceInfo(value: unknown): value is NonNullable<ResolvedSkill["sourceInfo"]> {
363
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
364
+ const sourceInfo = value as NonNullable<ResolvedSkill["sourceInfo"]>;
365
+ return (
366
+ (sourceInfo.scope === undefined ||
367
+ sourceInfo.scope === "user" ||
368
+ sourceInfo.scope === "project" ||
369
+ sourceInfo.scope === "temporary") &&
370
+ (sourceInfo.origin === undefined || sourceInfo.origin === "package" || sourceInfo.origin === "top-level")
371
+ );
372
+ }
373
+
374
+ function isResolvedSkill(value: unknown): value is ResolvedSkill {
375
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
376
+ const skill = value as Partial<ResolvedSkill>;
377
+ return (
378
+ typeof skill.name === "string" &&
379
+ typeof skill.description === "string" &&
380
+ typeof skill.filePath === "string" &&
381
+ (skill.disableModelInvocation === undefined || typeof skill.disableModelInvocation === "boolean") &&
382
+ (skill.sourceInfo === undefined || isResolvedSourceInfo(skill.sourceInfo))
383
+ );
384
+ }
385
+
386
+ function toResolvedEntry(skill: ResolvedSkill, cwd: string): SkillEntry | undefined {
387
+ // cwd is reserved: pi-resolved paths are already absolute, but the seam stays
388
+ // symmetric with the loose scan for future scoping needs.
389
+ void cwd;
390
+ if (skill.disableModelInvocation === true) return undefined;
391
+ if (isExcluded(skill.name)) return undefined;
392
+ return {
393
+ name: skill.name,
394
+ path: skill.filePath,
395
+ description: normalizeSkillDescription(skill.description),
396
+ scope: resolvedScopeLabel(skill),
397
+ };
398
+ }
399
+
400
+ function mergeResolvedWithLoose(
401
+ resolved: SkillEntry[],
402
+ loose: SkillEntry[],
403
+ cwd: string,
404
+ suppressedPaths: readonly string[] = [],
405
+ ): SkillEntry[] {
406
+ const resolvedPaths = new Set(resolved.map((entry) => comparablePath(entry.path)));
407
+ // Every runtime-resolved path was filtered by Pi's own rules, so a skill Pi
408
+ // hides (disableModelInvocation or an excluded name) must never come back
409
+ // as an active row through a loose root that still holds its SKILL.md.
410
+ for (const path of suppressedPaths) resolvedPaths.add(comparablePath(path));
411
+ const filteredLoose = loose.filter((entry) => !resolvedPaths.has(comparablePath(entry.path)));
412
+ return dedupeBySkillName([...resolved, ...filteredLoose], cwd);
281
413
  }
282
414
 
283
415
  function scopeForPath(cwd: string, path: string): string {
@@ -287,77 +419,123 @@ function scopeForPath(cwd: string, path: string): string {
287
419
  }
288
420
 
289
421
  function markdownCell(value: string): string {
290
- const trimmed = value.replace(/\n/g, " ").replace(/\|/g, "\\|").trim();
422
+ const trimmed = trimUnicodeWhitespace(value.replace(/\n/g, " ").replace(/\|/g, "\\|"));
291
423
  return trimmed.length > 0 ? trimmed : "—";
292
424
  }
293
425
 
294
- function isCacheFile(value: unknown): value is { fingerprint: string } {
295
- return (
296
- typeof value === "object" &&
297
- value !== null &&
298
- "fingerprint" in value &&
299
- typeof value.fingerprint === "string"
300
- );
426
+ function renderRows(cwd: string, entries: SkillEntry[], withScope = true): string[] {
427
+ return entries.map((entry) => {
428
+ const scope = withScope ? ` ${markdownCell(entry.scope ?? scopeForPath(cwd, entry.path))} |` : "";
429
+ return `| \`${markdownCell(entry.name)}\` | ${markdownCell(entry.description)} |${scope} \`${markdownCell(entry.path)}\` |`;
430
+ });
301
431
  }
302
432
 
303
- async function fingerprint(files: string[]): Promise<string> {
304
- const lines: string[] = [`schema:${REGISTRY_SCHEMA_VERSION}`];
305
- for (const file of files) {
306
- try {
307
- const info = await stat(file);
308
- let contentHash: string;
309
- try {
310
- contentHash = createHash("sha1").update(await readFile(file)).digest("hex");
311
- } catch {
312
- lines.push(`${file}:unreadable`);
313
- continue;
314
- }
315
- lines.push(`${file}:${info.mtimeMs}:${info.size}:${contentHash}`);
316
- } catch {
317
- lines.push(`${file}:missing`);
433
+ function renderRegistry(cwd: string, sources: string[], entries: SkillEntry[]): string {
434
+ return [
435
+ `# Skill Registry — ${basename(cwd)}`, "",
436
+ "<!-- Shared disk skill registry; generated by Gentle Shell or Gentle AI. -->", "",
437
+ "## Sources scanned", "", ...sources.map((source) => `- ${source}`), "",
438
+ "## Contract", "",
439
+ "**Delegator use only.** This disk index is not a summary and excludes session-only runtime skills. Pi delegators use their effective session view; other delegators use these rows. Pass exact `SKILL.md` paths to subagents.", "",
440
+ "`SKILL.md` remains the source of truth. Do not inject generated summaries or compact rules by default; pass paths so subagents load the full runtime contract and preserve author intent.", "",
441
+ SECTION_MARKER, "", "| Skill | Trigger / description | Scope | Path |", "| --- | --- | --- | --- |",
442
+ ...renderRows(cwd, entries), "", "## Loading protocol", "",
443
+ "1. Match task context and target files against the effective view's `Trigger / description` column.",
444
+ "2. Pass only the matching `Path` values to the subagent under `## Skills to load before work`.",
445
+ "3. Instruct the subagent to read those exact `SKILL.md` files before reading, writing, reviewing, testing, or creating artifacts.",
446
+ "4. If no matching skill exists, proceed without project skill injection and report `skill_resolution: none`.", "",
447
+ ].join("\n");
448
+ }
449
+
450
+ async function scanDisk(cwd: string): Promise<{ sources: string[]; entries: SkillEntry[] }> {
451
+ const dirs = await uniqueExistingDirs([...projectSkillDirs(cwd), ...await userSkillDirs()]);
452
+ const entries: SkillEntry[] = [];
453
+ for (const dir of dirs) {
454
+ for (const file of await findSkillFiles(dir)) {
455
+ const entry = await loadSkill(file);
456
+ if (entry) entries.push(entry);
318
457
  }
319
458
  }
320
- lines.sort();
321
- return createHash("sha1").update(lines.join("\n")).digest("hex");
459
+ const sources = dirs.map((dir) => {
460
+ const rel = relative(cwd, dir);
461
+ return rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel) ? dir : rel || ".";
462
+ });
463
+ return { sources, entries };
464
+ }
465
+
466
+ const EFFECTIVE_BEGIN = "<!-- gentle-pi effective skills begin -->";
467
+ const EFFECTIVE_END = "<!-- gentle-pi effective skills end -->";
468
+ function clearEffectivePrompt(options: AppendableSystemPromptOptions | undefined): void {
469
+ if (!options) return;
470
+ const current = options.appendSystemPrompt ?? "";
471
+ const start = current.indexOf(EFFECTIVE_BEGIN);
472
+ if (start < 0) return;
473
+ const end = current.indexOf(EFFECTIVE_END, start);
474
+ if (end < 0) return;
475
+ const prefix = current.slice(0, start).replace(/\n\n$/, "");
476
+ options.appendSystemPrompt = prefix + current.slice(end + EFFECTIVE_END.length);
477
+ }
478
+
479
+ // Pi already lists every skill it loaded in `<available_skills>`, so only the
480
+ // effective winners Pi did not list are rendered; nothing is emitted when
481
+ // there are none. Rows keep dedupeBySkillName's name order across turns.
482
+ function unlistedEntries(effective: SkillEntry[], listed: SkillEntry[]): SkillEntry[] {
483
+ const listedPaths = new Set(listed.map((entry) => comparablePath(entry.path)));
484
+ return effective.filter((entry) => !listedPaths.has(comparablePath(entry.path)) && !SESSION_EXCLUDE_NAMES.has(entry.name));
485
+ }
486
+
487
+ // Mirrors Pi 1.5.2 buildSystemPromptSections (dist/core/system-prompt.js:101-108):
488
+ // `<available_skills>` renders only when `read` or `bash` is a selected tool,
489
+ // and an absent tool list defaults to read, bash, edit and write.
490
+ function piRendersAvailableSkills(options: { selectedTools?: unknown }): boolean {
491
+ const selected = Array.isArray(options.selectedTools) ? options.selectedTools : ["read", "bash", "edit", "write"];
492
+ return ["read", "bash"].some((tool) => selected.includes(tool));
493
+ }
494
+
495
+ function appendEffectivePrompt(options: AppendableSystemPromptOptions, cwd: string, entries: SkillEntry[], piListed: boolean): void {
496
+ if (entries.length === 0) return;
497
+ appendSystemPromptOnce(options, [
498
+ EFFECTIVE_BEGIN,
499
+ piListed
500
+ ? "## Effective session skills: on disk, not loaded by Pi; `<available_skills>` lists the rest"
501
+ : "## Effective session skills: all skills (Pi renders no `<available_skills>` without `read` or `bash`)",
502
+ "| Skill | Trigger / description | Path |",
503
+ "| --- | --- | --- |",
504
+ ...renderRows(cwd, entries, false), EFFECTIVE_END,
505
+ ].join("\n"));
506
+ }
507
+
508
+ async function readOptional(path: string): Promise<Buffer | undefined> {
509
+ try { return await readFile(path); }
510
+ catch (error) {
511
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return undefined;
512
+ throw error;
513
+ }
322
514
  }
323
515
 
324
- function renderRegistry(cwd: string, sources: string[], entries: SkillEntry[]): string {
325
- const projectName = basename(cwd);
326
- const today = new Date().toISOString().slice(0, 10);
327
- const lines: string[] = [];
328
- lines.push(`# Skill Registry — ${projectName}`);
329
- lines.push("");
330
- lines.push("<!-- Auto-generated by gentle-pi extensions/skill-registry.ts. Run /skill-registry:refresh to regenerate. -->");
331
- lines.push("");
332
- lines.push(`Last updated: ${today}`);
333
- lines.push("");
334
- lines.push("## Sources scanned");
335
- lines.push("");
336
- for (const src of sources) {
337
- lines.push(`- ${src}`);
338
- }
339
- lines.push("");
340
- lines.push("## Contract");
341
- lines.push("");
342
- lines.push("**Delegator use only.** This registry is an index, not a summary. Any agent that launches subagents reads it to select relevant skills, then passes exact `SKILL.md` paths for the subagent to read before work.");
343
- lines.push("");
344
- lines.push("`SKILL.md` remains the source of truth. Do not inject generated summaries or compact rules by default; pass paths so subagents load the full runtime contract and preserve author intent.");
345
- lines.push("");
346
- lines.push(SECTION_MARKER);
347
- lines.push("");
348
- lines.push("| Skill | Trigger / description | Scope | Path |");
349
- lines.push("| --- | --- | --- | --- |");
350
- for (const entry of entries) {
351
- lines.push(`| \`${markdownCell(entry.name)}\` | ${markdownCell(entry.description)} | ${markdownCell(entry.scope ?? scopeForPath(cwd, entry.path))} | \`${markdownCell(entry.path)}\` |`);
516
+ // Stage each complete file beside its target, then replace it atomically.
517
+ // Registry and cache are deliberately separate publications, not a transaction.
518
+ async function writeAtomic(path: string, content: string): Promise<void> {
519
+ let mode = 0o666 & ~process.umask();
520
+ try { mode = (await stat(path)).mode & 0o7777; }
521
+ catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; }
522
+ const temporary = join(dirname(path), `.${basename(path)}.${process.pid}.${randomUUID()}.tmp`);
523
+ let created = false;
524
+ try {
525
+ const file = await open(temporary, "wx", mode);
526
+ created = true;
527
+ try { await file.chmod(mode); await file.writeFile(content, "utf8"); }
528
+ finally { await file.close(); }
529
+ await rename(temporary, path);
530
+ created = false;
531
+ } catch (error) {
532
+ if (typeof error === "object" && error !== null && "path" in error && (error as NodeJS.ErrnoException).path === temporary) {
533
+ (error as NodeJS.ErrnoException).path = path;
534
+ }
535
+ throw error;
536
+ } finally {
537
+ if (created) await unlink(temporary).catch(() => undefined);
352
538
  }
353
- lines.push("");
354
- lines.push("## Loading protocol");
355
- lines.push("");
356
- lines.push("1. Match task context and target files against the `Trigger / description` column.");
357
- lines.push("2. Pass only the matching `Path` values to the subagent under `## Skills to load before work`.");
358
- lines.push("3. Instruct the subagent to read those exact `SKILL.md` files before reading, writing, reviewing, testing, or creating artifacts.");
359
- lines.push("4. If no matching skill exists, proceed without project skill injection and report `skill_resolution: none`.");
360
- return `${lines.join("\n").trimEnd()}\n`;
361
539
  }
362
540
 
363
541
  interface RegenResult {
@@ -409,7 +587,9 @@ export async function automaticWriteWarning(
409
587
  });
410
588
  tracked = stdout.split("\0").filter(Boolean);
411
589
  } catch (error) {
412
- const failure = error as { code?: number; stderr?: string };
590
+ const failure = error as { code?: number | string; stderr?: string };
591
+ // A missing cwd cannot hold tracked targets, but git cannot even spawn there.
592
+ if (failure.code === "ENOENT" && !(await pathExists(cwd))) return undefined;
413
593
  if (failure.code === 128 && failure.stderr?.startsWith("fatal: not a git repository") && await hasNoGitMetadata(cwd)) return undefined;
414
594
  throw new Error(`Cannot verify Git tracking for ${targets.join(", ")}; automatic writes skipped. Resolve Git detection, or deliberately run /skill-registry:refresh.`);
415
595
  }
@@ -491,59 +671,28 @@ async function quarantineLegacyProjectRegistry(cwd: string, notifyWarning: (mess
491
671
  }
492
672
  }
493
673
 
494
- async function regenerateRegistry(
495
- cwd: string,
496
- force: boolean,
497
- intentional = false,
498
- ): Promise<RegenResult> {
499
- const existingDirs = await uniqueExistingDirs([
500
- ...projectSkillDirs(cwd),
501
- ...userSkillDirs(),
502
- ]);
503
- const files: string[] = [];
504
- for (const dir of existingDirs) {
505
- files.push(...(await findSkillFiles(dir)));
506
- }
507
- const cachePath = join(cwd, CACHE_REL_PATH);
508
- const registryPath = join(cwd, REGISTRY_REL_PATH);
509
- const fp = await fingerprint(files);
510
- let cached: string | undefined;
511
- if (await pathExists(cachePath)) {
512
- try {
513
- const parsed: unknown = JSON.parse(await readFile(cachePath, "utf8"));
514
- cached = isCacheFile(parsed) ? parsed.fingerprint : undefined;
515
- } catch {
516
- cached = undefined;
517
- }
518
- }
519
- if (!force && cached === fp && (await pathExists(registryPath))) {
520
- return { regenerated: false, skillCount: 0, reason: "cache-hit" };
521
- }
522
- if (!intentional) {
523
- const warning = await automaticWriteWarning(cwd, [REGISTRY_REL_PATH, CACHE_REL_PATH]);
524
- if (warning) return { regenerated: false, skillCount: 0, reason: "tracked-target", warning };
525
- }
526
- const entries: SkillEntry[] = [];
527
- for (const file of files) {
528
- const entry = await loadSkill(file);
529
- if (entry) entries.push(entry);
530
- }
674
+ async function regenerateRegistry(cwd: string, force: boolean, intentional = false): Promise<RegenResult> {
675
+ cwd = resolve(cwd);
676
+ const { sources, entries } = await scanDisk(cwd);
531
677
  const deduped = dedupeBySkillName(entries, cwd);
532
- const sources = existingDirs.map((d) => {
533
- const rel = relative(cwd, d);
534
- return rel.startsWith("..") ? d : rel || ".";
535
- });
536
678
  const md = renderRegistry(cwd, sources, deduped);
679
+ const cache = `${JSON.stringify({ schema: 1, registry_sha256: createHash("sha256").update(md).digest("hex") })}\n`;
680
+ const registryPath = join(cwd, REGISTRY_REL_PATH);
681
+ const cachePath = join(cwd, CACHE_REL_PATH);
537
682
  try {
683
+ const registryChanged = !(await readOptional(registryPath))?.equals(Buffer.from(md));
684
+ const cacheChanged = !(await readOptional(cachePath))?.equals(Buffer.from(cache));
685
+ if (!registryChanged && !cacheChanged) return { regenerated: false, skillCount: deduped.length, reason: "cache-hit" };
686
+ if (!intentional) {
687
+ const warning = await automaticWriteWarning(cwd, [REGISTRY_REL_PATH, CACHE_REL_PATH]);
688
+ if (warning) return { regenerated: false, skillCount: 0, reason: "tracked-target", warning };
689
+ }
538
690
  await mkdir(join(cwd, ".atl"), { recursive: true });
539
- await writeFile(registryPath, md);
540
- await writeFile(cachePath, JSON.stringify({ fingerprint: fp }, null, 2));
691
+ if (registryChanged) await writeAtomic(registryPath, md);
692
+ if (cacheChanged) await writeAtomic(cachePath, cache);
693
+ return { regenerated: registryChanged, skillCount: deduped.length, reason: registryChanged ? (force ? "forced" : "fingerprint-changed") : "cache-hit" };
541
694
  } catch (error) {
542
695
  if (isStorageUnavailableError(error)) {
543
- // gentle-shell#373: an unwritable storage location must never
544
- // report a successful regeneration. The typed result names the
545
- // offending path and the safe next action; unexpected I/O keeps
546
- // its own diagnostic by rethrowing.
547
696
  const path = typeof (error as NodeJS.ErrnoException).path === "string" ? (error as NodeJS.ErrnoException).path as string : registryPath;
548
697
  const relativePath = relative(cwd, path).split(sep).join("/") || REGISTRY_REL_PATH;
549
698
  return {
@@ -555,15 +704,13 @@ async function regenerateRegistry(
555
704
  }
556
705
  throw error;
557
706
  }
558
- return {
559
- regenerated: true,
560
- skillCount: deduped.length,
561
- reason: force ? "forced" : "fingerprint-changed",
562
- };
563
707
  }
564
708
 
565
709
  const watchedCwds = new Set<string>();
566
710
  const watcherPolls = new Map<string, ReturnType<typeof setInterval>>();
711
+ // Debounced watcher refreshes, cleared on shutdown so none fires into a
712
+ // replaced or reloaded session.
713
+ const watcherTimers = new Map<string, ReturnType<typeof setTimeout>>();
567
714
  // Startup regeneration runs after session_start returns; watcher refreshes
568
715
  // wait for it so an older startup scan never overwrites a newer refresh.
569
716
  const pendingStartups = new Map<string, Promise<void>>();
@@ -644,30 +791,52 @@ function closeSkillRegistryWatchers(): void {
644
791
  activeWatchers.clear();
645
792
  for (const poll of watcherPolls.values()) clearInterval(poll);
646
793
  watcherPolls.clear();
794
+ for (const timer of watcherTimers.values()) clearTimeout(timer);
795
+ watcherTimers.clear();
647
796
  watchedCwds.clear();
648
797
  }
649
798
 
799
+ /**
800
+ * Pi's runner throws on any access to a ctx made stale by reload or session
801
+ * replacement (/reload, /resume, /new). Late async notices must neither reach
802
+ * that ctx nor let its throw escape as an uncaught exception.
803
+ */
804
+ function notifyIfLive(ctx: ExtensionContext, message: string, level: "info" | "warning"): void {
805
+ try {
806
+ void ctx.sessionManager;
807
+ if (ctx.hasUI) ctx.ui.notify(message, level);
808
+ } catch {
809
+ // The session ended; nobody is left to show this notice to.
810
+ }
811
+ }
812
+
650
813
  async function startSkillRegistryWatcher(
651
814
  cwd: string,
652
815
  notify: (message: string, level?: "info" | "warning") => void,
653
816
  ): Promise<void> {
654
817
  if (watchedCwds.has(cwd)) return;
655
818
  watchedCwds.add(cwd);
819
+ const generation = startupGeneration;
656
820
  const dirs = await uniqueExistingDirs([
657
821
  ...projectSkillDirs(cwd),
658
- ...userSkillDirs(),
822
+ ...await userSkillDirs(),
659
823
  ]);
660
- let timer: ReturnType<typeof setTimeout> | undefined;
824
+ if (generation !== startupGeneration) return;
661
825
  // The poll re-asks a state the watchers already answered: without this,
662
826
  // an unchanged tracked-target warning would repeat every poll interval.
663
827
  let lastWarning: string | undefined;
664
828
  const refresh = () => {
665
- if (timer) clearTimeout(timer);
666
- timer = setTimeout(() => {
829
+ if (generation !== startupGeneration) return;
830
+ const previous = watcherTimers.get(cwd);
831
+ if (previous) clearTimeout(previous);
832
+ watcherTimers.set(cwd, setTimeout(() => {
833
+ watcherTimers.delete(cwd);
667
834
  void (async () => {
668
835
  try {
669
836
  await pendingStartups.get(cwd);
837
+ if (generation !== startupGeneration) return;
670
838
  const result = await regenerateRegistry(cwd, false);
839
+ if (generation !== startupGeneration) return;
671
840
  if (result.warning) {
672
841
  if (result.warning !== lastWarning) notify(result.warning, "warning");
673
842
  lastWarning = result.warning;
@@ -678,10 +847,11 @@ async function startSkillRegistryWatcher(
678
847
  }
679
848
  }
680
849
  } catch (error) {
850
+ if (generation !== startupGeneration) return;
681
851
  notify(`Skill registry refresh failed: ${error instanceof Error ? error.message : String(error)}`, "warning");
682
852
  }
683
853
  })();
684
- }, WATCH_DEBOUNCE_MS);
854
+ }, WATCH_DEBOUNCE_MS));
685
855
  };
686
856
  for (const dir of dirs) {
687
857
  try {
@@ -711,6 +881,8 @@ export const __testing = {
711
881
  isStorageUnavailableError,
712
882
  uniqueExistingDirs,
713
883
  dedupeBySkillName,
884
+ toResolvedEntry,
885
+ mergeResolvedWithLoose,
714
886
  scopeForPath,
715
887
  normalizeSkillDescription,
716
888
  parseFrontmatter,
@@ -736,10 +908,13 @@ export const __testing = {
736
908
 
737
909
  export default function (pi: ExtensionAPI) {
738
910
  if (shouldSkipDuplicateExtensionLoad()) return;
911
+ // This capture belongs to this extension instance, never to the shared file.
912
+ let lastResolvedSkills: ResolvedSkill[] = [];
739
913
 
740
914
  pi.on("session_shutdown", () => {
741
915
  startupGeneration += 1;
742
916
  closeSkillRegistryWatchers();
917
+ lastResolvedSkills = [];
743
918
  });
744
919
 
745
920
  pi.registerFlag(NO_SKILL_REGISTRY_FLAG, {
@@ -753,9 +928,7 @@ export default function (pi: ExtensionAPI) {
753
928
  if (repositoryRootedAtHome(ctx.cwd)) return;
754
929
  const cwd = ctx.cwd;
755
930
  const generation = startupGeneration;
756
- const notifyWarning = (message: string) => {
757
- if (ctx.hasUI) ctx.ui.notify(message, "warning");
758
- };
931
+ const notifyWarning = (message: string) => notifyIfLive(ctx, message, "warning");
759
932
  const regenerate = async () => {
760
933
  if (generation !== startupGeneration) return;
761
934
  try {
@@ -764,17 +937,11 @@ export default function (pi: ExtensionAPI) {
764
937
  const quarantinedLegacy = await quarantineLegacyProjectRegistry(cwd, notifyWarning);
765
938
  const result = await regenerateRegistry(cwd, quarantinedLegacy);
766
939
  if (result.warning) notifyWarning(result.warning);
767
- if (result.regenerated && ctx.hasUI) {
768
- ctx.ui.notify(
769
- `Skill registry refreshed (${result.skillCount} skills)`,
770
- "info",
771
- );
940
+ if (result.regenerated) {
941
+ notifyIfLive(ctx, `Skill registry refreshed (${result.skillCount} skills)`, "info");
772
942
  }
773
- if (quarantinedLegacy && ctx.hasUI) {
774
- ctx.ui.notify(
775
- "Disabled stale project-local skill registry extension; using package registry with project skills first.",
776
- "warning",
777
- );
943
+ if (quarantinedLegacy) {
944
+ notifyWarning("Disabled stale project-local skill registry extension; using package registry with project skills first.");
778
945
  }
779
946
  if (quarantinedLegacy) {
780
947
  setTimeout(() => {
@@ -790,14 +957,7 @@ export default function (pi: ExtensionAPI) {
790
957
  }, WATCH_DEBOUNCE_MS);
791
958
  }
792
959
  } catch (error) {
793
- if (ctx.hasUI) {
794
- const message =
795
- error instanceof Error ? error.message : String(error);
796
- ctx.ui.notify(
797
- `Skill registry refresh failed: ${message}`,
798
- "warning",
799
- );
800
- }
960
+ notifyWarning(`Skill registry refresh failed: ${error instanceof Error ? error.message : String(error)}`);
801
961
  }
802
962
  };
803
963
  // Pi awaits session_start handlers one after another, so the Git tracking
@@ -810,7 +970,7 @@ export default function (pi: ExtensionAPI) {
810
970
  try {
811
971
  if (ctx.hasUI) {
812
972
  await startSkillRegistryWatcher(cwd, (message, level = "info") => {
813
- ctx.ui.notify(message, level);
973
+ notifyIfLive(ctx, message, level);
814
974
  });
815
975
  }
816
976
  } catch (error) {
@@ -818,6 +978,26 @@ export default function (pi: ExtensionAPI) {
818
978
  }
819
979
  });
820
980
 
981
+ pi.on("before_agent_start", async (event, ctx) => {
982
+ const options = event.systemPromptOptions;
983
+ clearEffectivePrompt(options);
984
+ if (shouldSkipSkillRegistryStartup(pi) || !options) return;
985
+ const skills = options.skills;
986
+ if (Array.isArray(skills) && skills.every(isResolvedSkill)) {
987
+ lastResolvedSkills = skills.map(trimResolvedSkill);
988
+ }
989
+ try {
990
+ const { entries } = await scanDisk(resolve(ctx.cwd));
991
+ const resolved = lastResolvedSkills.map((skill) => toResolvedEntry(skill, ctx.cwd))
992
+ .filter((entry): entry is SkillEntry => entry !== undefined);
993
+ const effective = mergeResolvedWithLoose(resolved, entries, ctx.cwd, lastResolvedSkills.map((skill) => skill.filePath));
994
+ const piListed = piRendersAvailableSkills(options as { selectedTools?: unknown });
995
+ appendEffectivePrompt(options, ctx.cwd, unlistedEntries(effective, piListed ? resolved : []), piListed);
996
+ } catch {
997
+ // Preserve best-effort behavior without advertising a stale or incomplete view.
998
+ }
999
+ });
1000
+
821
1001
  pi.registerCommand("skill-registry:refresh", {
822
1002
  description: "Regenerate .atl/skill-registry.md from local skill sources.",
823
1003
  handler: async (_args, ctx) => {
@@ -829,7 +1009,9 @@ export default function (pi: ExtensionAPI) {
829
1009
  return;
830
1010
  }
831
1011
  ctx.ui.notify(
832
- `Skill registry: ${result.skillCount} skill(s) written to ${REGISTRY_REL_PATH}`,
1012
+ result.regenerated
1013
+ ? `Skill registry: ${result.skillCount} skill(s) written to ${REGISTRY_REL_PATH}`
1014
+ : `Skill registry: ${result.skillCount} skill(s) unchanged in ${REGISTRY_REL_PATH}`,
833
1015
  "info",
834
1016
  );
835
1017
  } catch (error) {