@monoes/monomindcli 2.15.7 → 2.16.1

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 (460) hide show
  1. package/.claude/helpers/build-skill-registry.cjs +23 -2
  2. package/.claude/helpers/handlers/route-handler.cjs +102 -3
  3. package/.claude/helpers/handlers/session-restore-handler.cjs +1 -1
  4. package/.claude/helpers/hook-handler.cjs +17 -2
  5. package/.claude/helpers/jev-picker.cjs +499 -0
  6. package/.claude/helpers/redact-secrets.cjs +69 -0
  7. package/.claude/skills/mastermind-agent-select/SKILL.md +28 -0
  8. package/.claude/skills/monodesign/SKILL.md +257 -0
  9. package/.claude/skills/monodesign/adapt.md +53 -0
  10. package/.claude/skills/monodesign/agents/monodesign-asset-producer.md +100 -0
  11. package/.claude/skills/monodesign/agents/monodesign-manual-edit-applier.md +103 -0
  12. package/.claude/skills/monodesign/animate.md +65 -0
  13. package/.claude/skills/monodesign/audit.md +89 -0
  14. package/.claude/skills/monodesign/bolder.md +50 -0
  15. package/.claude/skills/monodesign/clarify.md +64 -0
  16. package/.claude/skills/monodesign/colorize.md +68 -0
  17. package/.claude/skills/monodesign/craft.md +51 -0
  18. package/.claude/skills/monodesign/critique.md +66 -0
  19. package/.claude/skills/monodesign/delight.md +47 -0
  20. package/.claude/skills/monodesign/distill.md +56 -0
  21. package/.claude/skills/monodesign/document.md +83 -0
  22. package/.claude/skills/monodesign/extract.md +74 -0
  23. package/.claude/skills/monodesign/harden.md +65 -0
  24. package/.claude/skills/monodesign/init.md +30 -0
  25. package/.claude/skills/monodesign/layout.md +36 -0
  26. package/.claude/skills/monodesign/live.md +34 -0
  27. package/.claude/skills/monodesign/onboard.md +50 -0
  28. package/.claude/skills/monodesign/optimize.md +64 -0
  29. package/.claude/skills/monodesign/overdrive.md +56 -0
  30. package/.claude/skills/monodesign/polish.md +68 -0
  31. package/.claude/skills/monodesign/quieter.md +57 -0
  32. package/.claude/skills/monodesign/reference/adapt.md +312 -0
  33. package/.claude/skills/monodesign/reference/adapt.native.md +58 -0
  34. package/.claude/skills/monodesign/reference/android.md +40 -0
  35. package/.claude/skills/monodesign/reference/animate.md +203 -0
  36. package/.claude/skills/monodesign/reference/antipatterns-catalog.md +410 -0
  37. package/.claude/skills/monodesign/reference/audit.md +135 -0
  38. package/.claude/skills/monodesign/reference/audit.native.md +139 -0
  39. package/.claude/skills/monodesign/reference/bolder.md +120 -0
  40. package/.claude/skills/monodesign/reference/brand-workflow.md +180 -0
  41. package/.claude/skills/monodesign/reference/brand.md +108 -0
  42. package/.claude/skills/monodesign/reference/clarify.md +288 -0
  43. package/.claude/skills/monodesign/reference/codex.md +105 -0
  44. package/.claude/skills/monodesign/reference/cognitive-load.md +106 -0
  45. package/.claude/skills/monodesign/reference/color-and-contrast.md +105 -0
  46. package/.claude/skills/monodesign/reference/colorize.md +257 -0
  47. package/.claude/skills/monodesign/reference/component-specs.md +260 -0
  48. package/.claude/skills/monodesign/reference/component-states.md +274 -0
  49. package/.claude/skills/monodesign/reference/component-system.md +358 -0
  50. package/.claude/skills/monodesign/reference/copy-formulas.md +160 -0
  51. package/.claude/skills/monodesign/reference/craft.md +123 -0
  52. package/.claude/skills/monodesign/reference/critique.md +780 -0
  53. package/.claude/skills/monodesign/reference/delight.md +302 -0
  54. package/.claude/skills/monodesign/reference/design-principles.md +246 -0
  55. package/.claude/skills/monodesign/reference/distill.md +111 -0
  56. package/.claude/skills/monodesign/reference/document.md +429 -0
  57. package/.claude/skills/monodesign/reference/extract.md +69 -0
  58. package/.claude/skills/monodesign/reference/harden.md +347 -0
  59. package/.claude/skills/monodesign/reference/heuristics-scoring.md +234 -0
  60. package/.claude/skills/monodesign/reference/hooks.md +92 -0
  61. package/.claude/skills/monodesign/reference/image-prompts.md +130 -0
  62. package/.claude/skills/monodesign/reference/init.md +221 -0
  63. package/.claude/skills/monodesign/reference/interaction-design.md +189 -0
  64. package/.claude/skills/monodesign/reference/ios.md +45 -0
  65. package/.claude/skills/monodesign/reference/layout.md +185 -0
  66. package/.claude/skills/monodesign/reference/live.md +710 -0
  67. package/.claude/skills/monodesign/reference/motion-design.md +109 -0
  68. package/.claude/skills/monodesign/reference/onboard.md +234 -0
  69. package/.claude/skills/monodesign/reference/optimize.md +258 -0
  70. package/.claude/skills/monodesign/reference/overdrive.md +130 -0
  71. package/.claude/skills/monodesign/reference/personas.md +179 -0
  72. package/.claude/skills/monodesign/reference/polish.md +241 -0
  73. package/.claude/skills/monodesign/reference/pre-delivery-checklist.md +108 -0
  74. package/.claude/skills/monodesign/reference/product.md +60 -0
  75. package/.claude/skills/monodesign/reference/quieter.md +99 -0
  76. package/.claude/skills/monodesign/reference/responsive-design.md +114 -0
  77. package/.claude/skills/monodesign/reference/shape.md +165 -0
  78. package/.claude/skills/monodesign/reference/spatial-design.md +100 -0
  79. package/.claude/skills/monodesign/reference/teach.md +10 -0
  80. package/.claude/skills/monodesign/reference/token-architecture.md +222 -0
  81. package/.claude/skills/monodesign/reference/typeset.md +301 -0
  82. package/.claude/skills/monodesign/reference/typography.md +159 -0
  83. package/.claude/skills/monodesign/reference/ux-research.md +143 -0
  84. package/.claude/skills/monodesign/reference/ux-rules.md +211 -0
  85. package/.claude/skills/monodesign/reference/ux-writing.md +107 -0
  86. package/.claude/skills/monodesign/scripts/command-metadata.json +94 -0
  87. package/.claude/skills/monodesign/scripts/context-signals.mjs +260 -0
  88. package/.claude/skills/monodesign/scripts/context.mjs +1065 -0
  89. package/.claude/skills/monodesign/scripts/critique-storage.mjs +416 -0
  90. package/.claude/skills/monodesign/scripts/detect-csp.mjs +193 -0
  91. package/.claude/skills/monodesign/scripts/detect.mjs +33 -0
  92. package/.claude/skills/monodesign/scripts/detector/browser/injected/index.mjs +1960 -0
  93. package/.claude/skills/monodesign/scripts/detector/cli/main.mjs +321 -0
  94. package/.claude/skills/monodesign/scripts/detector/design-system.mjs +814 -0
  95. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns-browser.js +5628 -0
  96. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns.mjs +50 -0
  97. package/.claude/skills/monodesign/scripts/detector/engines/browser/detect-url.mjs +259 -0
  98. package/.claude/skills/monodesign/scripts/detector/engines/browser/drivers.mjs +339 -0
  99. package/.claude/skills/monodesign/scripts/detector/engines/regex/detect-text.mjs +636 -0
  100. package/.claude/skills/monodesign/scripts/detector/engines/static-html/css-cascade.mjs +1016 -0
  101. package/.claude/skills/monodesign/scripts/detector/engines/static-html/detect-html.mjs +253 -0
  102. package/.claude/skills/monodesign/scripts/detector/engines/visual/screenshot-contrast.mjs +198 -0
  103. package/.claude/skills/monodesign/scripts/detector/findings.mjs +12 -0
  104. package/.claude/skills/monodesign/scripts/detector/fix/css-regions.mjs +181 -0
  105. package/.claude/skills/monodesign/scripts/detector/fix/fixers.mjs +373 -0
  106. package/.claude/skills/monodesign/scripts/detector/fix/index.mjs +426 -0
  107. package/.claude/skills/monodesign/scripts/detector/node/file-system.mjs +198 -0
  108. package/.claude/skills/monodesign/scripts/detector/profile/profiler.mjs +166 -0
  109. package/.claude/skills/monodesign/scripts/detector/registry/antipatterns.mjs +563 -0
  110. package/.claude/skills/monodesign/scripts/detector/rules/checks.mjs +3024 -0
  111. package/.claude/skills/monodesign/scripts/detector/shared/color.mjs +124 -0
  112. package/.claude/skills/monodesign/scripts/detector/shared/constants.mjs +101 -0
  113. package/.claude/skills/monodesign/scripts/detector/shared/fonts.mjs +30 -0
  114. package/.claude/skills/monodesign/scripts/detector/shared/inline-ignores.mjs +148 -0
  115. package/.claude/skills/monodesign/scripts/detector/shared/page.mjs +7 -0
  116. package/.claude/skills/monodesign/scripts/hook-admin.mjs +694 -0
  117. package/.claude/skills/monodesign/scripts/hook-before-edit.mjs +516 -0
  118. package/.claude/skills/monodesign/scripts/hook-lib.mjs +1785 -0
  119. package/.claude/skills/monodesign/scripts/hook.mjs +61 -0
  120. package/.claude/skills/monodesign/scripts/lib/design-parser.mjs +809 -0
  121. package/.claude/skills/monodesign/scripts/lib/is-generated.mjs +69 -0
  122. package/.claude/skills/monodesign/scripts/lib/monodesign-config.mjs +640 -0
  123. package/.claude/skills/monodesign/scripts/lib/monodesign-paths.mjs +129 -0
  124. package/.claude/skills/monodesign/scripts/lib/provider.mjs +4 -0
  125. package/.claude/skills/monodesign/scripts/lib/target-args.mjs +42 -0
  126. package/.claude/skills/monodesign/scripts/live/browser-script-parts.mjs +50 -0
  127. package/.claude/skills/monodesign/scripts/live/completion.mjs +19 -0
  128. package/.claude/skills/monodesign/scripts/live/event-validation.mjs +137 -0
  129. package/.claude/skills/monodesign/scripts/live/insert-ui.mjs +458 -0
  130. package/.claude/skills/monodesign/scripts/live/manual-apply.mjs +939 -0
  131. package/.claude/skills/monodesign/scripts/live/manual-edit-routes.mjs +357 -0
  132. package/.claude/skills/monodesign/scripts/live/manual-edits-buffer.mjs +152 -0
  133. package/.claude/skills/monodesign/scripts/live/session-store.mjs +293 -0
  134. package/.claude/skills/monodesign/scripts/live/svelte-component.mjs +826 -0
  135. package/.claude/skills/monodesign/scripts/live/sveltekit-adapter.mjs +279 -0
  136. package/.claude/skills/monodesign/scripts/live/ui-core.mjs +180 -0
  137. package/.claude/skills/monodesign/scripts/live/vocabulary.mjs +36 -0
  138. package/.claude/skills/monodesign/scripts/live-accept.mjs +812 -0
  139. package/.claude/skills/monodesign/scripts/live-browser-dom.js +147 -0
  140. package/.claude/skills/monodesign/scripts/live-browser-session.js +124 -0
  141. package/.claude/skills/monodesign/scripts/live-browser.js +11213 -0
  142. package/.claude/skills/monodesign/scripts/live-commit-manual-edits.mjs +1241 -0
  143. package/.claude/skills/monodesign/scripts/live-complete.mjs +75 -0
  144. package/.claude/skills/monodesign/scripts/live-copy-edit-agent.mjs +683 -0
  145. package/.claude/skills/monodesign/scripts/live-discard-manual-edits.mjs +51 -0
  146. package/.claude/skills/monodesign/scripts/live-inject.mjs +596 -0
  147. package/.claude/skills/monodesign/scripts/live-insert.mjs +272 -0
  148. package/.claude/skills/monodesign/scripts/live-manual-edit-evidence.mjs +363 -0
  149. package/.claude/skills/monodesign/scripts/live-poll.mjs +384 -0
  150. package/.claude/skills/monodesign/scripts/live-resume.mjs +94 -0
  151. package/.claude/skills/monodesign/scripts/live-server.mjs +1210 -0
  152. package/.claude/skills/monodesign/scripts/live-status.mjs +61 -0
  153. package/.claude/skills/monodesign/scripts/live-target.mjs +30 -0
  154. package/.claude/skills/monodesign/scripts/live-wrap.mjs +884 -0
  155. package/.claude/skills/monodesign/scripts/live.mjs +297 -0
  156. package/.claude/skills/monodesign/scripts/modern-screenshot.umd.js +14 -0
  157. package/.claude/skills/monodesign/scripts/palette.mjs +635 -0
  158. package/.claude/skills/monodesign/scripts/pin.mjs +221 -0
  159. package/.claude/skills/monodesign/shape.md +71 -0
  160. package/.claude/skills/monodesign/teach.md +18 -0
  161. package/.claude/skills/monodesign/typeset.md +59 -0
  162. package/README.md +1 -1
  163. package/dist/src/capabilities/cap-code.d.ts.map +1 -1
  164. package/dist/src/capabilities/cap-code.js +10 -5
  165. package/dist/src/capabilities/cap-code.js.map +1 -1
  166. package/dist/src/capabilities/manager.d.ts +2 -1
  167. package/dist/src/capabilities/manager.d.ts.map +1 -1
  168. package/dist/src/capabilities/manager.js +4 -1
  169. package/dist/src/capabilities/manager.js.map +1 -1
  170. package/dist/src/catalog/blueprints.d.ts +39 -0
  171. package/dist/src/catalog/blueprints.d.ts.map +1 -0
  172. package/dist/src/catalog/blueprints.js +78 -0
  173. package/dist/src/catalog/blueprints.js.map +1 -0
  174. package/dist/src/catalog/digest.d.ts +16 -0
  175. package/dist/src/catalog/digest.d.ts.map +1 -0
  176. package/dist/src/catalog/digest.js +62 -0
  177. package/dist/src/catalog/digest.js.map +1 -0
  178. package/dist/src/catalog/frontmatter.d.ts +23 -0
  179. package/dist/src/catalog/frontmatter.d.ts.map +1 -0
  180. package/dist/src/catalog/frontmatter.js +80 -0
  181. package/dist/src/catalog/frontmatter.js.map +1 -0
  182. package/dist/src/catalog/lifecycle.d.ts +31 -0
  183. package/dist/src/catalog/lifecycle.d.ts.map +1 -0
  184. package/dist/src/catalog/lifecycle.js +78 -0
  185. package/dist/src/catalog/lifecycle.js.map +1 -0
  186. package/dist/src/catalog/projection.d.ts +57 -0
  187. package/dist/src/catalog/projection.d.ts.map +1 -0
  188. package/dist/src/catalog/projection.js +272 -0
  189. package/dist/src/catalog/projection.js.map +1 -0
  190. package/dist/src/catalog/scan.d.ts +37 -0
  191. package/dist/src/catalog/scan.d.ts.map +1 -0
  192. package/dist/src/catalog/scan.js +214 -0
  193. package/dist/src/catalog/scan.js.map +1 -0
  194. package/dist/src/catalog/snapshot.d.ts +62 -0
  195. package/dist/src/catalog/snapshot.d.ts.map +1 -0
  196. package/dist/src/catalog/snapshot.js +183 -0
  197. package/dist/src/catalog/snapshot.js.map +1 -0
  198. package/dist/src/catalog/stage.d.ts +26 -0
  199. package/dist/src/catalog/stage.d.ts.map +1 -0
  200. package/dist/src/catalog/stage.js +316 -0
  201. package/dist/src/catalog/stage.js.map +1 -0
  202. package/dist/src/catalog/state.d.ts +23 -0
  203. package/dist/src/catalog/state.d.ts.map +1 -0
  204. package/dist/src/catalog/state.js +102 -0
  205. package/dist/src/catalog/state.js.map +1 -0
  206. package/dist/src/catalog/types.d.ts +289 -0
  207. package/dist/src/catalog/types.d.ts.map +1 -0
  208. package/dist/src/catalog/types.js +118 -0
  209. package/dist/src/catalog/types.js.map +1 -0
  210. package/dist/src/commands/catalog.d.ts +14 -0
  211. package/dist/src/commands/catalog.d.ts.map +1 -0
  212. package/dist/src/commands/catalog.js +392 -0
  213. package/dist/src/commands/catalog.js.map +1 -0
  214. package/dist/src/commands/doctor-catalog-checks.d.ts +3 -0
  215. package/dist/src/commands/doctor-catalog-checks.d.ts.map +1 -0
  216. package/dist/src/commands/doctor-catalog-checks.js +69 -0
  217. package/dist/src/commands/doctor-catalog-checks.js.map +1 -0
  218. package/dist/src/commands/doctor-decision-checks.d.ts +10 -0
  219. package/dist/src/commands/doctor-decision-checks.d.ts.map +1 -0
  220. package/dist/src/commands/doctor-decision-checks.js +82 -0
  221. package/dist/src/commands/doctor-decision-checks.js.map +1 -0
  222. package/dist/src/commands/doctor-project-checks.js +1 -1
  223. package/dist/src/commands/doctor-project-checks.js.map +1 -1
  224. package/dist/src/commands/doctor.d.ts.map +1 -1
  225. package/dist/src/commands/doctor.js +9 -1
  226. package/dist/src/commands/doctor.js.map +1 -1
  227. package/dist/src/commands/index.d.ts +2 -2
  228. package/dist/src/commands/index.d.ts.map +1 -1
  229. package/dist/src/commands/index.js +4 -1
  230. package/dist/src/commands/index.js.map +1 -1
  231. package/dist/src/commands/init-wizard.d.ts.map +1 -1
  232. package/dist/src/commands/init-wizard.js +2 -0
  233. package/dist/src/commands/init-wizard.js.map +1 -1
  234. package/dist/src/commands/init.d.ts.map +1 -1
  235. package/dist/src/commands/init.js +25 -26
  236. package/dist/src/commands/init.js.map +1 -1
  237. package/dist/src/commands/org-observe.d.ts.map +1 -1
  238. package/dist/src/commands/org-observe.js +12 -10
  239. package/dist/src/commands/org-observe.js.map +1 -1
  240. package/dist/src/commands/org-run-end.d.ts +26 -0
  241. package/dist/src/commands/org-run-end.d.ts.map +1 -0
  242. package/dist/src/commands/org-run-end.js +40 -0
  243. package/dist/src/commands/org-run-end.js.map +1 -0
  244. package/dist/src/commands/org-skills.d.ts.map +1 -1
  245. package/dist/src/commands/org-skills.js +14 -4
  246. package/dist/src/commands/org-skills.js.map +1 -1
  247. package/dist/src/commands/org.d.ts +2 -1
  248. package/dist/src/commands/org.d.ts.map +1 -1
  249. package/dist/src/commands/org.js +44 -16
  250. package/dist/src/commands/org.js.map +1 -1
  251. package/dist/src/commands/pick.d.ts +4 -0
  252. package/dist/src/commands/pick.d.ts.map +1 -0
  253. package/dist/src/commands/pick.js +77 -0
  254. package/dist/src/commands/pick.js.map +1 -0
  255. package/dist/src/commands/route.js +1 -1
  256. package/dist/src/commands/route.js.map +1 -1
  257. package/dist/src/commands/search-universal.d.ts.map +1 -1
  258. package/dist/src/commands/search-universal.js +1 -2
  259. package/dist/src/commands/search-universal.js.map +1 -1
  260. package/dist/src/decision/catalogs.d.ts +20 -0
  261. package/dist/src/decision/catalogs.d.ts.map +1 -0
  262. package/dist/src/decision/catalogs.js +64 -0
  263. package/dist/src/decision/catalogs.js.map +1 -0
  264. package/dist/src/decision/jev.d.ts +85 -0
  265. package/dist/src/decision/jev.d.ts.map +1 -0
  266. package/dist/src/decision/jev.js +72 -0
  267. package/dist/src/decision/jev.js.map +1 -0
  268. package/dist/src/decision/picks.d.ts +50 -0
  269. package/dist/src/decision/picks.d.ts.map +1 -0
  270. package/dist/src/decision/picks.js +100 -0
  271. package/dist/src/decision/picks.js.map +1 -0
  272. package/dist/src/init/executor.d.ts.map +1 -1
  273. package/dist/src/init/executor.js +7 -0
  274. package/dist/src/init/executor.js.map +1 -1
  275. package/dist/src/init/helpers-generator.d.ts.map +1 -1
  276. package/dist/src/init/helpers-generator.js +7 -0
  277. package/dist/src/init/helpers-generator.js.map +1 -1
  278. package/dist/src/init/init-memory.d.ts +14 -0
  279. package/dist/src/init/init-memory.d.ts.map +1 -0
  280. package/dist/src/init/init-memory.js +44 -0
  281. package/dist/src/init/init-memory.js.map +1 -0
  282. package/dist/src/init/types.d.ts +13 -0
  283. package/dist/src/init/types.d.ts.map +1 -1
  284. package/dist/src/init/types.js.map +1 -1
  285. package/dist/src/init/upgrade.d.ts.map +1 -1
  286. package/dist/src/init/upgrade.js +9 -0
  287. package/dist/src/init/upgrade.js.map +1 -1
  288. package/dist/src/orgrt/agent-runner.d.ts +7 -0
  289. package/dist/src/orgrt/agent-runner.d.ts.map +1 -1
  290. package/dist/src/orgrt/agent-runner.js +5 -1
  291. package/dist/src/orgrt/agent-runner.js.map +1 -1
  292. package/dist/src/orgrt/antigravity-runner.d.ts.map +1 -1
  293. package/dist/src/orgrt/antigravity-runner.js +8 -14
  294. package/dist/src/orgrt/antigravity-runner.js.map +1 -1
  295. package/dist/src/orgrt/checkpoint-ops.d.ts.map +1 -1
  296. package/dist/src/orgrt/checkpoint-ops.js +7 -1
  297. package/dist/src/orgrt/checkpoint-ops.js.map +1 -1
  298. package/dist/src/orgrt/checkpoint.d.ts +10 -2
  299. package/dist/src/orgrt/checkpoint.d.ts.map +1 -1
  300. package/dist/src/orgrt/checkpoint.js +8 -2
  301. package/dist/src/orgrt/checkpoint.js.map +1 -1
  302. package/dist/src/orgrt/codex-runner.d.ts.map +1 -1
  303. package/dist/src/orgrt/codex-runner.js +8 -14
  304. package/dist/src/orgrt/codex-runner.js.map +1 -1
  305. package/dist/src/orgrt/completion-gate.d.ts +6 -0
  306. package/dist/src/orgrt/completion-gate.d.ts.map +1 -1
  307. package/dist/src/orgrt/completion-gate.js +18 -0
  308. package/dist/src/orgrt/completion-gate.js.map +1 -1
  309. package/dist/src/orgrt/copilot-runner.d.ts.map +1 -1
  310. package/dist/src/orgrt/copilot-runner.js +7 -10
  311. package/dist/src/orgrt/copilot-runner.js.map +1 -1
  312. package/dist/src/orgrt/crush-runner.d.ts.map +1 -1
  313. package/dist/src/orgrt/crush-runner.js +7 -10
  314. package/dist/src/orgrt/crush-runner.js.map +1 -1
  315. package/dist/src/orgrt/cumulative-meter.d.ts +26 -0
  316. package/dist/src/orgrt/cumulative-meter.d.ts.map +1 -0
  317. package/dist/src/orgrt/cumulative-meter.js +46 -0
  318. package/dist/src/orgrt/cumulative-meter.js.map +1 -0
  319. package/dist/src/orgrt/daemon.d.ts +20 -3
  320. package/dist/src/orgrt/daemon.d.ts.map +1 -1
  321. package/dist/src/orgrt/daemon.js +55 -28
  322. package/dist/src/orgrt/daemon.js.map +1 -1
  323. package/dist/src/orgrt/dashboard-health.d.ts +54 -0
  324. package/dist/src/orgrt/dashboard-health.d.ts.map +1 -0
  325. package/dist/src/orgrt/dashboard-health.js +143 -0
  326. package/dist/src/orgrt/dashboard-health.js.map +1 -0
  327. package/dist/src/orgrt/decisions.d.ts +13 -1
  328. package/dist/src/orgrt/decisions.d.ts.map +1 -1
  329. package/dist/src/orgrt/decisions.js +92 -18
  330. package/dist/src/orgrt/decisions.js.map +1 -1
  331. package/dist/src/orgrt/forwarder.d.ts +2 -1
  332. package/dist/src/orgrt/forwarder.d.ts.map +1 -1
  333. package/dist/src/orgrt/forwarder.js +87 -27
  334. package/dist/src/orgrt/forwarder.js.map +1 -1
  335. package/dist/src/orgrt/grok-runner.d.ts.map +1 -1
  336. package/dist/src/orgrt/grok-runner.js +7 -12
  337. package/dist/src/orgrt/grok-runner.js.map +1 -1
  338. package/dist/src/orgrt/hermes-runner.d.ts.map +1 -1
  339. package/dist/src/orgrt/hermes-runner.js +9 -15
  340. package/dist/src/orgrt/hermes-runner.js.map +1 -1
  341. package/dist/src/orgrt/kimicode-runner.d.ts +1 -1
  342. package/dist/src/orgrt/kimicode-runner.d.ts.map +1 -1
  343. package/dist/src/orgrt/kimicode-runner.js +9 -15
  344. package/dist/src/orgrt/kimicode-runner.js.map +1 -1
  345. package/dist/src/orgrt/opencode-runner.d.ts.map +1 -1
  346. package/dist/src/orgrt/opencode-runner.js +7 -13
  347. package/dist/src/orgrt/opencode-runner.js.map +1 -1
  348. package/dist/src/orgrt/org-harness-tools.d.ts +8 -0
  349. package/dist/src/orgrt/org-harness-tools.d.ts.map +1 -0
  350. package/dist/src/orgrt/org-harness-tools.js +21 -0
  351. package/dist/src/orgrt/org-harness-tools.js.map +1 -0
  352. package/dist/src/orgrt/pi-rpc-runner.d.ts.map +1 -1
  353. package/dist/src/orgrt/pi-rpc-runner.js +9 -13
  354. package/dist/src/orgrt/pi-rpc-runner.js.map +1 -1
  355. package/dist/src/orgrt/pi-runner.d.ts.map +1 -1
  356. package/dist/src/orgrt/pi-runner.js +7 -11
  357. package/dist/src/orgrt/pi-runner.js.map +1 -1
  358. package/dist/src/orgrt/policy-git.d.ts +5 -1
  359. package/dist/src/orgrt/policy-git.d.ts.map +1 -1
  360. package/dist/src/orgrt/policy-git.js +56 -29
  361. package/dist/src/orgrt/policy-git.js.map +1 -1
  362. package/dist/src/orgrt/policy.d.ts +7 -0
  363. package/dist/src/orgrt/policy.d.ts.map +1 -1
  364. package/dist/src/orgrt/policy.js +10 -1
  365. package/dist/src/orgrt/policy.js.map +1 -1
  366. package/dist/src/orgrt/prompt-vars.d.ts +8 -1
  367. package/dist/src/orgrt/prompt-vars.d.ts.map +1 -1
  368. package/dist/src/orgrt/prompt-vars.js +60 -11
  369. package/dist/src/orgrt/prompt-vars.js.map +1 -1
  370. package/dist/src/orgrt/qwen-rpc-runner.d.ts.map +1 -1
  371. package/dist/src/orgrt/qwen-rpc-runner.js +9 -14
  372. package/dist/src/orgrt/qwen-rpc-runner.js.map +1 -1
  373. package/dist/src/orgrt/qwen-runner.d.ts.map +1 -1
  374. package/dist/src/orgrt/qwen-runner.js +7 -12
  375. package/dist/src/orgrt/qwen-runner.js.map +1 -1
  376. package/dist/src/orgrt/report-budget.d.ts +4 -0
  377. package/dist/src/orgrt/report-budget.d.ts.map +1 -0
  378. package/dist/src/orgrt/report-budget.js +12 -0
  379. package/dist/src/orgrt/report-budget.js.map +1 -0
  380. package/dist/src/orgrt/reporting.d.ts +4 -0
  381. package/dist/src/orgrt/reporting.d.ts.map +1 -1
  382. package/dist/src/orgrt/reporting.js +8 -2
  383. package/dist/src/orgrt/reporting.js.map +1 -1
  384. package/dist/src/orgrt/role-sandbox.d.ts +4 -1
  385. package/dist/src/orgrt/role-sandbox.d.ts.map +1 -1
  386. package/dist/src/orgrt/role-sandbox.js +24 -10
  387. package/dist/src/orgrt/role-sandbox.js.map +1 -1
  388. package/dist/src/orgrt/role-trace.d.ts +27 -0
  389. package/dist/src/orgrt/role-trace.d.ts.map +1 -0
  390. package/dist/src/orgrt/role-trace.js +28 -0
  391. package/dist/src/orgrt/role-trace.js.map +1 -0
  392. package/dist/src/orgrt/sandbox-deny-write.d.ts +52 -0
  393. package/dist/src/orgrt/sandbox-deny-write.d.ts.map +1 -0
  394. package/dist/src/orgrt/sandbox-deny-write.js +89 -0
  395. package/dist/src/orgrt/sandbox-deny-write.js.map +1 -0
  396. package/dist/src/orgrt/sandbox-fault.d.ts +40 -0
  397. package/dist/src/orgrt/sandbox-fault.d.ts.map +1 -0
  398. package/dist/src/orgrt/sandbox-fault.js +94 -0
  399. package/dist/src/orgrt/sandbox-fault.js.map +1 -0
  400. package/dist/src/orgrt/session.d.ts +10 -3
  401. package/dist/src/orgrt/session.d.ts.map +1 -1
  402. package/dist/src/orgrt/session.js +124 -64
  403. package/dist/src/orgrt/session.js.map +1 -1
  404. package/dist/src/orgrt/skill-library.d.ts +10 -1
  405. package/dist/src/orgrt/skill-library.d.ts.map +1 -1
  406. package/dist/src/orgrt/skill-library.js +53 -4
  407. package/dist/src/orgrt/skill-library.js.map +1 -1
  408. package/dist/src/orgrt/task-dag.d.ts +9 -1
  409. package/dist/src/orgrt/task-dag.d.ts.map +1 -1
  410. package/dist/src/orgrt/task-dag.js +6 -1
  411. package/dist/src/orgrt/task-dag.js.map +1 -1
  412. package/dist/src/orgrt/tool-fence.d.ts +21 -3
  413. package/dist/src/orgrt/tool-fence.d.ts.map +1 -1
  414. package/dist/src/orgrt/tool-fence.js +45 -7
  415. package/dist/src/orgrt/tool-fence.js.map +1 -1
  416. package/dist/src/orgrt/tool-providers.d.ts +4 -0
  417. package/dist/src/orgrt/tool-providers.d.ts.map +1 -1
  418. package/dist/src/orgrt/tool-providers.js +10 -0
  419. package/dist/src/orgrt/tool-providers.js.map +1 -1
  420. package/dist/src/orgrt/types.d.ts +10 -0
  421. package/dist/src/orgrt/types.d.ts.map +1 -1
  422. package/dist/src/orgrt/types.js +15 -0
  423. package/dist/src/orgrt/types.js.map +1 -1
  424. package/dist/src/orgrt/vercel-runner.d.ts +23 -0
  425. package/dist/src/orgrt/vercel-runner.d.ts.map +1 -1
  426. package/dist/src/orgrt/vercel-runner.js +2 -26
  427. package/dist/src/orgrt/vercel-runner.js.map +1 -1
  428. package/dist/src/platform-adapters/merge.d.ts +11 -0
  429. package/dist/src/platform-adapters/merge.d.ts.map +1 -1
  430. package/dist/src/platform-adapters/merge.js +28 -0
  431. package/dist/src/platform-adapters/merge.js.map +1 -1
  432. package/dist/src/platform-adapters/mutation.d.ts +37 -0
  433. package/dist/src/platform-adapters/mutation.d.ts.map +1 -0
  434. package/dist/src/platform-adapters/mutation.js +231 -0
  435. package/dist/src/platform-adapters/mutation.js.map +1 -0
  436. package/dist/src/platform-adapters/operations.d.ts +8 -1
  437. package/dist/src/platform-adapters/operations.d.ts.map +1 -1
  438. package/dist/src/platform-adapters/operations.js +41 -83
  439. package/dist/src/platform-adapters/operations.js.map +1 -1
  440. package/dist/src/platform-adapters/renderers/skills.d.ts.map +1 -1
  441. package/dist/src/platform-adapters/renderers/skills.js +11 -2
  442. package/dist/src/platform-adapters/renderers/skills.js.map +1 -1
  443. package/dist/src/platform-adapters/shared-surface.d.ts +34 -0
  444. package/dist/src/platform-adapters/shared-surface.d.ts.map +1 -0
  445. package/dist/src/platform-adapters/shared-surface.js +89 -0
  446. package/dist/src/platform-adapters/shared-surface.js.map +1 -0
  447. package/dist/src/platform-adapters/types.d.ts +7 -0
  448. package/dist/src/platform-adapters/types.d.ts.map +1 -1
  449. package/dist/src/routing/jev-step.d.ts +17 -0
  450. package/dist/src/routing/jev-step.d.ts.map +1 -0
  451. package/dist/src/routing/jev-step.js +27 -0
  452. package/dist/src/routing/jev-step.js.map +1 -0
  453. package/dist/src/routing/route-layer-factory.d.ts.map +1 -1
  454. package/dist/src/routing/route-layer-factory.js +16 -1
  455. package/dist/src/routing/route-layer-factory.js.map +1 -1
  456. package/dist/src/utils/redaction.d.ts.map +1 -1
  457. package/dist/src/utils/redaction.js +19 -4
  458. package/dist/src/utils/redaction.js.map +1 -1
  459. package/dist/tsconfig.tsbuildinfo +1 -1
  460. package/package.json +7 -7
@@ -0,0 +1,62 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { lstatSync, readdirSync, readFileSync, realpathSync } from 'node:fs';
3
+ import { join, relative, sep } from 'node:path';
4
+ export const catalogDir = (root) => join(root, '.monomind', 'catalog');
5
+ export const packagesDir = (root) => join(catalogDir(root), 'packages');
6
+ function files(dir, prefix = '') {
7
+ const out = [];
8
+ for (const e of readdirSync(join(dir, prefix), { withFileTypes: true })) {
9
+ const rel = prefix ? `${prefix}/${e.name}` : e.name;
10
+ if (e.isSymbolicLink())
11
+ throw new Error(`symlink in package: ${rel}`);
12
+ if (e.isDirectory())
13
+ out.push(...files(dir, rel));
14
+ else if (e.isFile())
15
+ out.push(rel);
16
+ }
17
+ return out;
18
+ }
19
+ /** sha256 over (u32 pathLen, path, u64 byteLen, bytes) for every file, paths sorted by code unit. */
20
+ export function packageDigest(dir) {
21
+ const h = createHash('sha256');
22
+ for (const rel of files(dir).sort()) {
23
+ const bytes = readFileSync(join(dir, rel));
24
+ const p = Buffer.from(rel, 'utf8');
25
+ const lens = Buffer.alloc(12);
26
+ lens.writeUInt32BE(p.length, 0);
27
+ lens.writeBigUInt64BE(BigInt(bytes.length), 4);
28
+ h.update(lens.subarray(0, 4)).update(p).update(lens.subarray(4)).update(bytes);
29
+ }
30
+ return h.digest('hex');
31
+ }
32
+ /** `<packages>/<name>/<sha12>`, proven to stay inside the store after realpath. */
33
+ export function resolvePackageDir(root, entry) {
34
+ const store = realpathSync(packagesDir(root));
35
+ const name = entry.id.split(':')[1] ?? '';
36
+ const dir = realpathSync(join(store, name, entry.sha256.slice(0, 12)));
37
+ const rel = relative(store, dir);
38
+ if (rel.startsWith('..') || rel.includes(`..${sep}`) || lstatSync(dir).isSymbolicLink())
39
+ throw new Error(`package path escapes the store: ${entry.id}`);
40
+ return dir;
41
+ }
42
+ export function verifyEntry(root, entry) {
43
+ let dir;
44
+ try {
45
+ dir = resolvePackageDir(root, entry);
46
+ }
47
+ catch (e) {
48
+ return {
49
+ ok: false,
50
+ reason: String(e).includes('escapes') ? 'escaping-path' : 'missing-package',
51
+ };
52
+ }
53
+ try {
54
+ return packageDigest(dir) === entry.sha256
55
+ ? { ok: true, dir }
56
+ : { ok: false, reason: 'digest-mismatch' };
57
+ }
58
+ catch {
59
+ return { ok: false, reason: 'digest-mismatch' };
60
+ }
61
+ }
62
+ //# sourceMappingURL=digest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digest.js","sourceRoot":"","sources":["../../../src/catalog/digest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGhD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;AACvF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC;AAExF,SAAS,KAAK,CAAC,GAAW,EAAE,MAAM,GAAG,EAAE;IACrC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACxE,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACpD,IAAI,CAAC,CAAC,cAAc,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,EAAE,CAAC,CAAC;QACtE,IAAI,CAAC,CAAC,WAAW,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAA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@ -0,0 +1,23 @@
1
+ /** The only top-level frontmatter keys a catalog SKILL.md may carry. */
2
+ export declare const ALLOWED_FRONTMATTER_KEYS: readonly ['name', 'description', 'tags', 'tools', 'license'];
3
+ /**
4
+ * Problems that keep `text` from being a canonical catalog SKILL.md: no
5
+ * frontmatter, a key outside the allow-list, any line that is not a
6
+ * single-line `key: value` (indented, flow-mapping, anchor, alias, tag or
7
+ * block-scalar forms, or a value holding a U+2028/U+2029), or a `---`
8
+ * anywhere in a line — Claude Code ends the frontmatter at the first `---`,
9
+ * even mid-value, and would read the rest as body. Staging refuses what
10
+ * `sanitizeFrontmatter` produces unless this is empty.
11
+ */
12
+ export declare function frontmatterViolations(text: string): string[];
13
+ /**
14
+ * Rewrites the frontmatter of `text` to the allow-listed keys, one line each
15
+ * (strings JSON-quoted, lists as JSON arrays of plain tokens), keeping the
16
+ * body byte-for-byte. `removed` names the dropped keys. Text without
17
+ * frontmatter is returned unchanged (inspection then refuses it).
18
+ */
19
+ export declare function sanitizeFrontmatter(text: string): {
20
+ text: string;
21
+ removed: string[];
22
+ };
23
+ //# sourceMappingURL=frontmatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../../src/catalog/frontmatter.ts"],"names":[],"mappings":"AAQA,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,YACnC,MAAM,EACN,aAAa,EACb,MAAM,EACN,OAAO,EACP,SAAS,CACD,CAAC;AAOX;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAc5D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAqBrF"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * SKILL.md frontmatter allow-list. Platforms read execution config from the
3
+ * frontmatter (`hooks`, `allowed-tools`, `model`, `context`, `agent`, …), so
4
+ * staging rewrites it to the keys below before the package is hashed, and
5
+ * projection re-checks the stored bytes with `frontmatterViolations`.
6
+ */
7
+ import { parseFrontmatter } from '../orgrt/skill-library.js';
8
+ /** The only top-level frontmatter keys a catalog SKILL.md may carry. */
9
+ export const ALLOWED_FRONTMATTER_KEYS = [
10
+ 'name',
11
+ 'description',
12
+ 'tags',
13
+ 'tools',
14
+ 'license',
15
+ ];
16
+ const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
17
+ const LIST_ITEM_RE = /^[A-Za-z0-9_.:/-]+$/;
18
+ const PLAIN_NAME_RE = /^[a-z0-9][a-z0-9-]*$/;
19
+ const ALLOWED = ALLOWED_FRONTMATTER_KEYS;
20
+ /**
21
+ * Problems that keep `text` from being a canonical catalog SKILL.md: no
22
+ * frontmatter, a key outside the allow-list, any line that is not a
23
+ * single-line `key: value` (indented, flow-mapping, anchor, alias, tag or
24
+ * block-scalar forms, or a value holding a U+2028/U+2029), or a `---`
25
+ * anywhere in a line — Claude Code ends the frontmatter at the first `---`,
26
+ * even mid-value, and would read the rest as body. Staging refuses what
27
+ * `sanitizeFrontmatter` produces unless this is empty.
28
+ */
29
+ export function frontmatterViolations(text) {
30
+ const m = FRONTMATTER_RE.exec(text);
31
+ if (!m)
32
+ return ['SKILL.md has no frontmatter'];
33
+ const out = [];
34
+ m[1].split(/\r?\n/).forEach((line, i) => {
35
+ if (line.trim() === '')
36
+ return;
37
+ if (line.includes('---'))
38
+ return void out.push(`frontmatter line ${i + 1} contains "---"`);
39
+ const kv = /^([A-Za-z_][\w-]*):(?: (.*))?$/.exec(line);
40
+ if (!kv)
41
+ out.push(`frontmatter line ${i + 1} is not a single-line key: value`);
42
+ else if (!ALLOWED.includes(kv[1]))
43
+ out.push(`frontmatter key "${kv[1]}" is not allowed`);
44
+ else if (/^[{&*!|>]/.test(kv[2] ?? ''))
45
+ out.push(`frontmatter key "${kv[1]}" has a non-scalar value`);
46
+ });
47
+ return out;
48
+ }
49
+ /**
50
+ * Rewrites the frontmatter of `text` to the allow-listed keys, one line each
51
+ * (strings JSON-quoted, lists as JSON arrays of plain tokens), keeping the
52
+ * body byte-for-byte. `removed` names the dropped keys. Text without
53
+ * frontmatter is returned unchanged (inspection then refuses it).
54
+ */
55
+ export function sanitizeFrontmatter(text) {
56
+ const m = FRONTMATTER_RE.exec(text);
57
+ if (!m)
58
+ return { text, removed: [] };
59
+ const { data, body } = parseFrontmatter(text);
60
+ const topLevel = m[1].split(/\r?\n/).filter((l) => /^[^\s#]/.test(l));
61
+ const keys = topLevel.map((l) => l.split(':')[0].trim().slice(0, 40));
62
+ const removed = [...new Set(keys.filter((k) => !ALLOWED.includes(k)))];
63
+ const q = JSON.stringify;
64
+ const str = (v) => (Array.isArray(v) ? v.join(' ') : v);
65
+ const list = (v) => (Array.isArray(v) ? v : v.split(/[,\s]+/)).filter((s) => LIST_ITEM_RE.test(s));
66
+ const lines = [];
67
+ for (const key of ALLOWED_FRONTMATTER_KEYS) {
68
+ const v = data[key];
69
+ if (v === undefined)
70
+ continue;
71
+ if (key === 'tags' || key === 'tools')
72
+ lines.push(`${key}: ${q(list(v))}`);
73
+ else if (key === 'name' && typeof v === 'string' && PLAIN_NAME_RE.test(v))
74
+ lines.push(`name: ${v}`);
75
+ else
76
+ lines.push(`${key}: ${q(str(v))}`);
77
+ }
78
+ return { text: ['---', ...lines, '---', ''].join('\n') + body, removed };
79
+ }
80
+ //# sourceMappingURL=frontmatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../../src/catalog/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,wEAAwE;AACxE,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,MAAM;IACN,aAAa;IACb,MAAM;IACN,OAAO;IACP,SAAS;CACD,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,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACjF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,wBAAwB,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,KAAK,SAAS;YAAE,SAAS;QAC9B,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;aACtE,IAAI,GAAG,KAAK,MAAM,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YACvE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;;YACtB,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { type CatalogEntry, type CatalogStatus } from './types.js';
2
+ export interface LifecycleOptions {
3
+ /** Self-asserted provenance, recorded in history. */
4
+ actor: string;
5
+ reason?: string;
6
+ now?: string;
7
+ }
8
+ export interface ApproveOptions extends LifecycleOptions {
9
+ targets: string[];
10
+ /** Tools to grant; must be requested by the skill and in CATALOG_GRANTABLE_TOOLS. */
11
+ grant?: string[];
12
+ replacesLegacy?: boolean;
13
+ }
14
+ export interface LifecycleResult {
15
+ id: string;
16
+ before: CatalogStatus;
17
+ after: CatalogStatus;
18
+ entry: CatalogEntry;
19
+ }
20
+ /** staged → approved, recording targets, grants and legacy replacement. */
21
+ export declare function approve(root: string, id: string, opts: ApproveOptions): LifecycleResult;
22
+ /** approved or disabled → active; the package digest must verify. */
23
+ export declare const activate: (root: string, id: string, opts: LifecycleOptions) => LifecycleResult;
24
+ export declare const disable: (root: string, id: string, opts: LifecycleOptions) => LifecycleResult;
25
+ /** staged, active or disabled → quarantined; needs a reason. */
26
+ export declare const quarantine: (root: string, id: string, opts: LifecycleOptions) => LifecycleResult;
27
+ /** quarantined → staged; needs a reason and records `inspection.override`. */
28
+ export declare const release: (root: string, id: string, opts: LifecycleOptions) => LifecycleResult;
29
+ /** Any status but revoked → revoked (terminal); needs a reason. */
30
+ export declare const revoke: (root: string, id: string, opts: LifecycleOptions) => LifecycleResult;
31
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/catalog/lifecycle.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,aAAa,EAGnB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,YAAY,CAAC;CACrB;AA4DD,2EAA2E;AAC3E,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,eAAe,CAcvF;AAED,qEAAqE;AACrE,eAAO,MAAM,QAAQ,SAAU,MAAM,MAAM,MAAM,QAAQ,gBAAgB,KAAG,eAC5C,CAAC;AAEjC,eAAO,MAAM,OAAO,SAAU,MAAM,MAAM,MAAM,QAAQ,gBAAgB,KAAG,eACzC,CAAC;AAEnC,gEAAgE;AAChE,eAAO,MAAM,UAAU,SAAU,MAAM,MAAM,MAAM,QAAQ,gBAAgB,KAAG,eACzC,CAAC;AAEtC,8EAA8E;AAC9E,eAAO,MAAM,OAAO,SAAU,MAAM,MAAM,MAAM,QAAQ,gBAAgB,KAAG,eAC3C,CAAC;AAEjC,mEAAmE;AACnE,eAAO,MAAM,MAAM,SAAU,MAAM,MAAM,MAAM,QAAQ,gBAAgB,KAAG,eACzC,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The mutating lifecycle verbs behind `monomind catalog approve|activate|
3
+ * disable|quarantine|release|revoke`. Each runs one `transition` under the
4
+ * catalog lock; `approve` also records targets and tool grants.
5
+ */
6
+ import { CatalogStateError, mutateCatalogState, transition } from './state.js';
7
+ import { CATALOG_GRANTABLE_TOOLS, CatalogTargetSchema, } from './types.js';
8
+ const GRANTABLE = CATALOG_GRANTABLE_TOOLS;
9
+ function move(root, id, to, opts, prepare) {
10
+ let before;
11
+ let entry;
12
+ const now = opts.now ?? new Date().toISOString();
13
+ mutateCatalogState(root, (state) => {
14
+ const cur = state.entries.find((e) => e.id === id);
15
+ if (!cur)
16
+ throw new CatalogStateError(`no catalog entry ${id}`);
17
+ before = cur.status;
18
+ const prepared = prepare ? prepare(cur) : cur;
19
+ const staged = { ...state, entries: state.entries.map((e) => (e.id === id ? prepared : e)) };
20
+ const next = transition(staged, id, to, { actor: opts.actor, now, reason: opts.reason, root });
21
+ entry = next.entries.find((e) => e.id === id);
22
+ return next;
23
+ });
24
+ return { id, before: before, after: to, entry: entry };
25
+ }
26
+ function checkTargets(raw, kind) {
27
+ if (raw.length === 0)
28
+ throw new CatalogStateError('approve needs at least one --target');
29
+ const targets = raw.map((t) => {
30
+ const p = CatalogTargetSchema.safeParse(t);
31
+ if (!p.success)
32
+ throw new CatalogStateError(`unknown target "${t}" — use ${CatalogTargetSchema.options.join(', ')}`);
33
+ return p.data;
34
+ });
35
+ if (new Set(targets).size !== targets.length)
36
+ throw new CatalogStateError('duplicate --target');
37
+ if (targets.includes('jev') && !targets.includes('org'))
38
+ throw new CatalogStateError('the jev target requires the org target');
39
+ const platform = targets.find((t) => t.startsWith('platform:'));
40
+ if (platform && kind !== 'skill')
41
+ throw new CatalogStateError(`only skills can be projected; ${kind} cannot target ${platform}`);
42
+ return targets;
43
+ }
44
+ function checkGrants(e, grant) {
45
+ if (grant.length && e.kind !== 'skill')
46
+ throw new CatalogStateError('only skills take tool grants');
47
+ for (const t of grant) {
48
+ if (!GRANTABLE.includes(t))
49
+ throw new CatalogStateError(`"${t}" is not grantable — grantable tools: ${CATALOG_GRANTABLE_TOOLS.join(', ')}`);
50
+ if (!e.inspection.requestedTools.includes(t))
51
+ throw new CatalogStateError(`"${t}" is not requested by ${e.id}`);
52
+ }
53
+ return [...new Set(grant)].sort();
54
+ }
55
+ /** staged → approved, recording targets, grants and legacy replacement. */
56
+ export function approve(root, id, opts) {
57
+ return move(root, id, 'approved', opts, (e) => {
58
+ const targets = checkTargets(opts.targets, e.kind);
59
+ if (e.inspection.verdict === 'quarantine' && !e.inspection.override)
60
+ throw new CatalogStateError(`${id} has a quarantine inspection verdict; release it first (catalog release)`);
61
+ return {
62
+ ...e,
63
+ targets,
64
+ grantedTools: checkGrants(e, opts.grant ?? []),
65
+ replacesLegacy: opts.replacesLegacy === true,
66
+ };
67
+ });
68
+ }
69
+ /** approved or disabled → active; the package digest must verify. */
70
+ export const activate = (root, id, opts) => move(root, id, 'active', opts);
71
+ export const disable = (root, id, opts) => move(root, id, 'disabled', opts);
72
+ /** staged, active or disabled → quarantined; needs a reason. */
73
+ export const quarantine = (root, id, opts) => move(root, id, 'quarantined', opts);
74
+ /** quarantined → staged; needs a reason and records `inspection.override`. */
75
+ export const release = (root, id, opts) => move(root, id, 'staged', opts);
76
+ /** Any status but revoked → revoked (terminal); needs a reason. */
77
+ export const revoke = (root, id, opts) => move(root, id, 'revoked', opts);
78
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/catalog/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EACL,uBAAuB,EAIvB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAuBpB,MAAM,SAAS,GAAsB,uBAAuB,CAAC;AAE7D,SAAS,IAAI,CACX,IAAY,EACZ,EAAU,EACV,EAAiB,EACjB,IAAsB,EACtB,OAA2C;IAE3C,IAAI,MAAiC,CAAC;IACtC,IAAI,KAA+B,CAAC;IACpC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACjD,kBAAkB,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;QACjC,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,iBAAiB,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;QAChE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QACpB,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,C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Y,EAAE,EAAU,EAAE,IAAsB,EAAmB,EAAE,CAC3F,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AAEjC,mEAAmE;AACnE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAU,EAAE,IAAsB,EAAmB,EAAE,CAC1F,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC"}
@@ -0,0 +1,57 @@
1
+ import type { ArtifactIntent } from '../platform-adapters/types.js';
2
+ import { type CatalogAsset } from './snapshot.js';
3
+ export type ProjectionSurface = 'platform:claude' | 'platform:agents';
4
+ export declare const PROJECTION_SURFACES: readonly ProjectionSurface[];
5
+ export interface ProjectedPackage {
6
+ id: string;
7
+ sha256: string;
8
+ paths: string[];
9
+ }
10
+ export interface ProjectionRemoval {
11
+ id: string;
12
+ /** Package directory relative to the surface's skill root. */
13
+ dir: string;
14
+ marker: string;
15
+ /** Files of a re-projected package to leave alone; only the rest are removed. */
16
+ keep?: string[];
17
+ }
18
+ export interface ProjectionPlan {
19
+ surface: ProjectionSurface;
20
+ intents: ArtifactIntent[];
21
+ packages: ProjectedPackage[];
22
+ removals: ProjectionRemoval[];
23
+ diagnostics: string[];
24
+ }
25
+ export interface ProjectionResult extends ProjectionPlan {
26
+ dryRun: boolean;
27
+ changed: string[];
28
+ skipped: string[];
29
+ /** Where each changed file's previous content was backed up. */
30
+ backupDir: string;
31
+ /** The skill registry rebuilt after the apply, when there was one to rebuild. */
32
+ registry?: string;
33
+ }
34
+ export interface ProjectionOptions {
35
+ /** Plan only the removal of this id's package; project nothing. */
36
+ unproject?: string;
37
+ }
38
+ export declare const catalogMarker: (name: string) => string;
39
+ /** The first body line of a projected SKILL.md; `jev:` is read by build-skill-registry.cjs. */
40
+ export declare const catalogMarkerLine: (a: Pick<CatalogAsset, 'id' | 'sha256' | 'targets'>) => string;
41
+ /**
42
+ * Surfaces that still hold a projected copy of catalog skill `id` (a marked
43
+ * package dir reached without following a link). Read-only; disable/revoke use
44
+ * it to point at the `project --apply` that removes the copy.
45
+ */
46
+ export declare function projectedSurfaces(root: string, id: string): ProjectionSurface[];
47
+ /** Read-only plan: what `applyProjection` would write and remove. */
48
+ export declare function planProjection(root: string, surface: ProjectionSurface, opts?: ProjectionOptions): Promise<ProjectionPlan>;
49
+ /**
50
+ * Plans and applies in one transaction under the platform mutation lock. A dry
51
+ * run takes the same path with `dryRun` set (no lock, no writes), so its
52
+ * `changed` list is the prediction.
53
+ */
54
+ export declare function applyProjection(root: string, surface: ProjectionSurface, opts: ProjectionOptions & {
55
+ dryRun: boolean;
56
+ }): Promise<ProjectionResult>;
57
+ //# sourceMappingURL=projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../src/catalog/projection.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAA8B,MAAM,+BAA+B,CAAC;AAIhG,OAAO,EAAiB,KAAK,YAAY,EAAY,MAAM,eAAe,CAAC;AAG3E,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AACtE,eAAO,MAAM,mBAAmB,EAAE,SAAS,iBAAiB,EAG3D,CAAC;AAQF,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,SAAU,MAAM,KAAG,MAAiC,CAAC;AAE/E,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,MAAO,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC,KAAG,MACQ,CAAC;AA4KhG;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAU/E;AAED,qEAAqE;AACrE,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,EAC1B,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,cAAc,CAAC,CAEzB;AA0BD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,iBAAiB,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAC5C,OAAO,CAAC,gBAAgB,CAAC,CA4B3B"}
@@ -0,0 +1,272 @@
1
+ /**
2
+ * Explicit, reversible projection of active catalog skills into the two real
3
+ * platform surfaces: `.claude/skills` (platform:claude) and the shared
4
+ * `.agents/skills` (platform:agents). Every projected file carries the stable
5
+ * managed marker `catalog:skill:<name>`; a destination without it is foreign
6
+ * and never written, and no write or removal passes through a symbolic link.
7
+ */
8
+ import { existsSync, lstatSync, readdirSync, readFileSync } from 'node:fs';
9
+ import { createRequire } from 'node:module';
10
+ import { dirname, join, relative } from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+ import { atomicWrite, removeManagedSkillPackage, symlinkedComponent, withMutationLock, } from '../platform-adapters/mutation.js';
13
+ import { applyIntents, resolveArtifactLocation } from '../platform-adapters/operations.js';
14
+ import { PLATFORM_REGISTRY } from '../platform-adapters/registry.js';
15
+ import { verifyEntry } from './digest.js';
16
+ import { frontmatterViolations } from './frontmatter.js';
17
+ import { shellExecSyntax } from './scan.js';
18
+ import { buildSnapshot, eligible } from './snapshot.js';
19
+ import { CatalogIdSchema } from './types.js';
20
+ export const PROJECTION_SURFACES = [
21
+ 'platform:claude',
22
+ 'platform:agents',
23
+ ];
24
+ /** Any `.agents` adapter resolves the same `.agents/skills` directory. */
25
+ const ADAPTER = {
26
+ 'platform:claude': 'claude',
27
+ 'platform:agents': 'codex',
28
+ };
29
+ export const catalogMarker = (name) => `catalog:skill:${name}`;
30
+ /** The first body line of a projected SKILL.md; `jev:` is read by build-skill-registry.cjs. */
31
+ export const catalogMarkerLine = (a) => `<!-- catalog ${a.id} sha256:${a.sha256} jev:${a.targets.includes('jev') ? 'yes' : 'no'} -->`;
32
+ /** Refusals of the package content itself (not drift or digest problems). */
33
+ const SECURITY_REFUSAL = /^(?:frontmatter-not-allowed|body-exec):/;
34
+ const FRONTMATTER = /^---\r?\n[\s\S]*?\r?\n---\r?\n/;
35
+ const isOurs = (content, name) => content.includes(`monomind:start ${catalogMarker(name)}`);
36
+ function requestFor(root, surface, dryRun) {
37
+ return { platform: ADAPTER[surface], scope: 'project', path: root, dryRun };
38
+ }
39
+ function listFiles(dir, prefix = '') {
40
+ const out = [];
41
+ for (const e of readdirSync(join(dir, prefix), { withFileTypes: true })) {
42
+ const rel = prefix ? `${prefix}/${e.name}` : e.name;
43
+ if (e.isDirectory())
44
+ out.push(...listFiles(dir, rel));
45
+ else if (e.isFile())
46
+ out.push(rel);
47
+ }
48
+ return out.sort();
49
+ }
50
+ function withMarkerLine(skillMd, line) {
51
+ const header = FRONTMATTER.exec(skillMd)?.[0];
52
+ if (!header)
53
+ return skillMd;
54
+ return `${header}\n${line}\n${skillMd.slice(header.length).replace(/^\r?\n/, '')}`;
55
+ }
56
+ /** Intents for one verified package, or the reason it is refused. */
57
+ function packageIntents(root, skillRoot, asset) {
58
+ const check = verifyEntry(root, asset);
59
+ if (!check.ok)
60
+ return { refused: check.reason };
61
+ const intents = [];
62
+ const paths = [];
63
+ const files = listFiles(check.dir);
64
+ // The same checks staging applies: stored bytes may predate them.
65
+ for (const file of files.filter((f) => f.endsWith('.md'))) {
66
+ const text = readFileSync(join(check.dir, file), 'utf8');
67
+ const nested = file !== 'SKILL.md' && file.endsWith('/SKILL.md');
68
+ if (file === 'SKILL.md' || (nested && FRONTMATTER.test(text))) {
69
+ const bad = frontmatterViolations(text);
70
+ if (bad.length)
71
+ return { refused: `frontmatter-not-allowed: ${file}: ${bad.join(', ')}` };
72
+ }
73
+ if (shellExecSyntax(text))
74
+ return { refused: `body-exec: ${file} carries shell execution syntax` };
75
+ }
76
+ for (const file of files) {
77
+ const dest = join(skillRoot, asset.name, file);
78
+ const display = relative(root, dest);
79
+ const link = symlinkedComponent(root, dest);
80
+ if (link)
81
+ return { refused: `symlinked-destination: ${relative(root, link) || link}` };
82
+ let content = readFileSync(join(check.dir, file), 'utf8');
83
+ if (file === 'SKILL.md')
84
+ content = withMarkerLine(content, catalogMarkerLine(asset));
85
+ const st = lstatSync(dest, { throwIfNoEntry: false });
86
+ if (st) {
87
+ const existing = st.isFile() ? readFileSync(dest, 'utf8') : '';
88
+ if (!isOurs(existing, asset.name))
89
+ return { refused: `not catalog-managed: ${display}` };
90
+ if (file === 'SKILL.md' && FRONTMATTER.exec(existing)?.[0] !== FRONTMATTER.exec(content)?.[0])
91
+ return {
92
+ refused: `frontmatter-drift: run catalog unproject ${asset.id} then catalog project`,
93
+ };
94
+ }
95
+ paths.push(display);
96
+ intents.push({
97
+ kind: 'skill',
98
+ locationKey: 'skill',
99
+ scope: 'project',
100
+ replace: 'managed_block',
101
+ format: 'md',
102
+ marker: catalogMarker(asset.name),
103
+ relativePath: `${asset.name}/${file}`,
104
+ content,
105
+ });
106
+ }
107
+ return { intents, paths, files };
108
+ }
109
+ /** Files below `dir` (not following links) that carry `name`'s marker. */
110
+ function markedFiles(dir, name) {
111
+ try {
112
+ return listFiles(dir).filter((f) => isOurs(readFileSync(join(dir, f), 'utf8'), name));
113
+ }
114
+ catch {
115
+ return [];
116
+ }
117
+ }
118
+ function buildPlan(root, surface, opts) {
119
+ const plan = {
120
+ surface,
121
+ intents: [],
122
+ packages: [],
123
+ removals: [],
124
+ diagnostics: [],
125
+ };
126
+ const adapter = PLATFORM_REGISTRY[ADAPTER[surface]];
127
+ const location = resolveArtifactLocation(adapter, 'skill', 'project', { root });
128
+ if (!location)
129
+ throw new Error(`no project skill location for ${surface}`);
130
+ const skillRoot = location.path;
131
+ const unprojectName = opts.unproject ? parseId(opts.unproject) : undefined;
132
+ const snapshot = buildSnapshot(root);
133
+ const wanted = unprojectName ? [] : eligible(snapshot, surface);
134
+ if (!unprojectName)
135
+ for (const d of snapshot.diagnostics) {
136
+ const a = snapshot.assets.find((x) => x.id === d.id);
137
+ if (!a || (a.status === 'active' && a.targets.includes(surface)))
138
+ plan.diagnostics.push(`${d.id}: ${d.reason}`);
139
+ }
140
+ const rootLink = symlinkedComponent(root, skillRoot);
141
+ if (rootLink) {
142
+ if (wanted.length || unprojectName || existsSync(skillRoot))
143
+ plan.diagnostics.push(`symlinked-destination: ${relative(root, rootLink)}`);
144
+ return plan;
145
+ }
146
+ const unsafe = new Set();
147
+ for (const asset of wanted) {
148
+ if (asset.kind !== 'skill') {
149
+ plan.diagnostics.push(`${asset.id}: only skills are projected`);
150
+ continue;
151
+ }
152
+ const r = packageIntents(root, skillRoot, asset);
153
+ if ('refused' in r) {
154
+ plan.diagnostics.push(`${asset.id}: ${r.refused}`);
155
+ if (SECURITY_REFUSAL.test(r.refused))
156
+ unsafe.add(asset.name);
157
+ }
158
+ else {
159
+ plan.intents.push(...r.intents);
160
+ plan.packages.push({ id: asset.id, sha256: asset.sha256, paths: r.paths });
161
+ const stale = markedFiles(join(skillRoot, asset.name), asset.name).filter((f) => !r.files.includes(f));
162
+ if (stale.length)
163
+ plan.removals.push({
164
+ id: asset.id,
165
+ dir: asset.name,
166
+ marker: catalogMarker(asset.name),
167
+ keep: r.files,
168
+ });
169
+ }
170
+ }
171
+ // Only skills own a projection. A refused skill keeps its earlier copy, unless
172
+ // the refusal is a security one: that copy may carry what is now refused.
173
+ const keep = new Set(wanted.filter((a) => a.kind === 'skill' && !unsafe.has(a.name)).map((a) => a.name));
174
+ const entries = existsSync(skillRoot) ? readdirSync(skillRoot, { withFileTypes: true }) : [];
175
+ for (const e of entries.sort((a, b) => (a.name < b.name ? -1 : 1))) {
176
+ if (unprojectName ? e.name !== unprojectName : keep.has(e.name))
177
+ continue;
178
+ if (e.isSymbolicLink()) {
179
+ if (unprojectName)
180
+ plan.diagnostics.push(`symlinked-destination: ${relative(root, join(skillRoot, e.name))}`);
181
+ continue;
182
+ }
183
+ if (e.isDirectory() && markedFiles(join(skillRoot, e.name), e.name).length)
184
+ plan.removals.push({ id: `skill:${e.name}`, dir: e.name, marker: catalogMarker(e.name) });
185
+ }
186
+ return plan;
187
+ }
188
+ function parseId(id) {
189
+ const parsed = CatalogIdSchema.safeParse(id);
190
+ if (!parsed.success || !parsed.data.startsWith('skill:'))
191
+ throw new Error(`not a skill catalog id: ${id}`);
192
+ return parsed.data.slice('skill:'.length);
193
+ }
194
+ /**
195
+ * Surfaces that still hold a projected copy of catalog skill `id` (a marked
196
+ * package dir reached without following a link). Read-only; disable/revoke use
197
+ * it to point at the `project --apply` that removes the copy.
198
+ */
199
+ export function projectedSurfaces(root, id) {
200
+ if (!id.startsWith('skill:'))
201
+ return [];
202
+ const name = id.slice('skill:'.length);
203
+ return PROJECTION_SURFACES.filter((surface) => {
204
+ const adapter = PLATFORM_REGISTRY[ADAPTER[surface]];
205
+ const location = resolveArtifactLocation(adapter, 'skill', 'project', { root });
206
+ if (!location)
207
+ return false;
208
+ const dir = join(location.path, name);
209
+ return !symlinkedComponent(root, dir) && markedFiles(dir, name).length > 0;
210
+ });
211
+ }
212
+ /** Read-only plan: what `applyProjection` would write and remove. */
213
+ export async function planProjection(root, surface, opts = {}) {
214
+ return buildPlan(root, surface, opts);
215
+ }
216
+ const HERE = dirname(fileURLToPath(import.meta.url));
217
+ /** src/catalog → ../.. is the package root; dist/src/catalog → ../../.. */
218
+ const BUILDER_CANDIDATES = [
219
+ join(HERE, '..', '..', '.claude', 'helpers', 'build-skill-registry.cjs'),
220
+ join(HERE, '..', '..', '..', '.claude', 'helpers', 'build-skill-registry.cjs'),
221
+ ];
222
+ /**
223
+ * Regenerates `<root>/.claude/helpers/skill-registry.json` with the bundled
224
+ * builder (which knows the catalog `jev:` flag) — only when the project
225
+ * already has one, so a project without the per-prompt router gains nothing.
226
+ */
227
+ function rebuildSkillRegistry(root) {
228
+ const file = join(root, '.claude', 'helpers', 'skill-registry.json');
229
+ if (!existsSync(file) || symlinkedComponent(root, file))
230
+ return undefined;
231
+ const builder = BUILDER_CANDIDATES.find((p) => existsSync(p));
232
+ if (!builder)
233
+ return undefined;
234
+ const { build } = createRequire(import.meta.url)(builder);
235
+ atomicWrite(file, `${JSON.stringify(build(root), null, 2)}\n`);
236
+ return relative(root, file);
237
+ }
238
+ /**
239
+ * Plans and applies in one transaction under the platform mutation lock. A dry
240
+ * run takes the same path with `dryRun` set (no lock, no writes), so its
241
+ * `changed` list is the prediction.
242
+ */
243
+ export async function applyProjection(root, surface, opts) {
244
+ const request = requestFor(root, surface, opts.dryRun);
245
+ const adapter = PLATFORM_REGISTRY[request.platform];
246
+ const run = (plan) => {
247
+ const applied = applyIntents(adapter, plan.intents, request);
248
+ const result = {
249
+ ...plan,
250
+ dryRun: opts.dryRun,
251
+ changed: applied.changed,
252
+ skipped: applied.skipped,
253
+ diagnostics: [...plan.diagnostics, ...applied.diagnostics],
254
+ backupDir: '.monomind/backups/',
255
+ };
256
+ for (const r of plan.removals) {
257
+ const removed = removeManagedSkillPackage(adapter, request, r.dir, r.marker, r.keep);
258
+ result.changed.push(...removed.changed);
259
+ result.skipped.push(...removed.skipped);
260
+ result.diagnostics.push(...removed.diagnostics.map((d) => `${r.id}: ${d}`));
261
+ }
262
+ if (!opts.dryRun && surface === 'platform:claude' && result.changed.length)
263
+ result.registry = rebuildSkillRegistry(root);
264
+ return result;
265
+ };
266
+ const preview = buildPlan(root, surface, opts);
267
+ // Nothing to do: return without taking the lock, so an empty apply creates nothing.
268
+ if (opts.dryRun || (preview.intents.length === 0 && preview.removals.length === 0))
269
+ return run(preview);
270
+ return withMutationLock(request, () => run(buildPlan(root, surface, opts)));
271
+ }
272
+ //# sourceMappingURL=projection.js.map