@skaile/workspaces 5.1.3 → 5.2.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 (338) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/app-sdk/index.js +1 -1
  3. package/dist/{asset-feeds-C4X4RTZV.js → asset-feeds-WDIB3E6H.js} +11 -11
  4. package/dist/{asset-feeds-C4X4RTZV.js.map → asset-feeds-WDIB3E6H.js.map} +1 -1
  5. package/dist/asset-manager/catalog-deployer.js +8 -8
  6. package/dist/asset-manager/index.js +12 -12
  7. package/dist/asset-manager/installer.js +8 -8
  8. package/dist/asset-manager/src/index.d.ts +27 -1
  9. package/dist/asset-manager/src/index.d.ts.map +1 -1
  10. package/dist/bridge/drivers/claude-sdk.js +14 -13
  11. package/dist/bridge/drivers/claude-sdk.js.map +1 -1
  12. package/dist/bridge/drivers/codex.js +11 -10
  13. package/dist/bridge/drivers/codex.js.map +1 -1
  14. package/dist/bridge/drivers/continue.js +10 -10
  15. package/dist/bridge/drivers/echo.js +3 -3
  16. package/dist/bridge/drivers/gemini.js +5 -5
  17. package/dist/bridge/drivers/goose.js +10 -10
  18. package/dist/bridge/drivers/omp.js +6 -5
  19. package/dist/bridge/drivers/omp.js.map +1 -1
  20. package/dist/bridge/drivers/opencode.js +10 -10
  21. package/dist/bridge/drivers/qwen.js +5 -5
  22. package/dist/bridge/index.js +13 -13
  23. package/dist/bridge/src/driver-capabilities.d.ts +66 -0
  24. package/dist/bridge/src/driver-capabilities.d.ts.map +1 -0
  25. package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
  26. package/dist/bridge/src/drivers/codex.d.ts.map +1 -1
  27. package/dist/bridge/src/drivers/omp.d.ts.map +1 -1
  28. package/dist/bridge/src/index.d.ts +1 -0
  29. package/dist/bridge/src/index.d.ts.map +1 -1
  30. package/dist/bridge/src/registry.d.ts.map +1 -1
  31. package/dist/{chunk-WPWJRDR3.js → chunk-2MEMXBLC.js} +8 -7
  32. package/dist/chunk-2MEMXBLC.js.map +1 -0
  33. package/dist/{chunk-TVOODIZE.js → chunk-2QZG5VJQ.js} +3 -3
  34. package/dist/{chunk-TVOODIZE.js.map → chunk-2QZG5VJQ.js.map} +1 -1
  35. package/dist/{chunk-7SAWDPUT.js → chunk-37GBJLF5.js} +5 -55
  36. package/dist/chunk-37GBJLF5.js.map +1 -0
  37. package/dist/{chunk-ZD7CX25M.js → chunk-3E2TIPBZ.js} +56 -7
  38. package/dist/chunk-3E2TIPBZ.js.map +1 -0
  39. package/dist/{chunk-H4EGUQ7M.js → chunk-4YE7OYTB.js} +5 -5
  40. package/dist/chunk-4YE7OYTB.js.map +1 -0
  41. package/dist/{chunk-K5GBV4SA.js → chunk-5BEFNLOR.js} +6 -5
  42. package/dist/chunk-5BEFNLOR.js.map +1 -0
  43. package/dist/{chunk-BJZHNSQO.js → chunk-6OWIEFZ2.js} +5 -5
  44. package/dist/{chunk-BJZHNSQO.js.map → chunk-6OWIEFZ2.js.map} +1 -1
  45. package/dist/{chunk-O4U7OL6D.js → chunk-6ZCVROWW.js} +6 -6
  46. package/dist/{chunk-O4U7OL6D.js.map → chunk-6ZCVROWW.js.map} +1 -1
  47. package/dist/{chunk-RO4Z2CBP.js → chunk-77GKEZ2R.js} +21 -4
  48. package/dist/chunk-77GKEZ2R.js.map +1 -0
  49. package/dist/{chunk-TYUJB336.js → chunk-7Y43UXKA.js} +3 -3
  50. package/dist/{chunk-TYUJB336.js.map → chunk-7Y43UXKA.js.map} +1 -1
  51. package/dist/{chunk-YV4J7V53.js → chunk-ANWHAGM7.js} +3 -3
  52. package/dist/{chunk-YV4J7V53.js.map → chunk-ANWHAGM7.js.map} +1 -1
  53. package/dist/{chunk-SP47UJKE.js → chunk-B4J4RGNY.js} +231 -114
  54. package/dist/chunk-B4J4RGNY.js.map +1 -0
  55. package/dist/{chunk-IWCCZL7C.js → chunk-BIMEKYOE.js} +91 -25
  56. package/dist/chunk-BIMEKYOE.js.map +1 -0
  57. package/dist/{chunk-WCQMXBO5.js → chunk-BJQUSAGB.js} +4 -4
  58. package/dist/{chunk-WCQMXBO5.js.map → chunk-BJQUSAGB.js.map} +1 -1
  59. package/dist/{chunk-RDYI4MML.js → chunk-BNUZEYC3.js} +3 -3
  60. package/dist/{chunk-RDYI4MML.js.map → chunk-BNUZEYC3.js.map} +1 -1
  61. package/dist/{chunk-KVAI5DGL.js → chunk-BUNBKRJZ.js} +3 -3
  62. package/dist/{chunk-KVAI5DGL.js.map → chunk-BUNBKRJZ.js.map} +1 -1
  63. package/dist/{chunk-AZYIEK3F.js → chunk-BWOLP6KQ.js} +3 -3
  64. package/dist/{chunk-AZYIEK3F.js.map → chunk-BWOLP6KQ.js.map} +1 -1
  65. package/dist/chunk-BZXR6SW5.js +15 -0
  66. package/dist/{chunk-XUQBVK4R.js.map → chunk-BZXR6SW5.js.map} +1 -1
  67. package/dist/{chunk-Y6V6NUEV.js → chunk-DD3OZLRD.js} +3 -3
  68. package/dist/{chunk-Y6V6NUEV.js.map → chunk-DD3OZLRD.js.map} +1 -1
  69. package/dist/{chunk-2HR3RPWD.js → chunk-EOGNW74K.js} +9 -8
  70. package/dist/chunk-EOGNW74K.js.map +1 -0
  71. package/dist/{chunk-RNNUYFFD.js → chunk-FJTC5YFO.js} +3 -3
  72. package/dist/{chunk-RNNUYFFD.js.map → chunk-FJTC5YFO.js.map} +1 -1
  73. package/dist/{chunk-ZVKJNNME.js → chunk-IOUIC2ZD.js} +8 -8
  74. package/dist/{chunk-ZVKJNNME.js.map → chunk-IOUIC2ZD.js.map} +1 -1
  75. package/dist/{chunk-YMOZC2D3.js → chunk-JPR7EPIM.js} +4 -4
  76. package/dist/{chunk-YMOZC2D3.js.map → chunk-JPR7EPIM.js.map} +1 -1
  77. package/dist/{chunk-IDEA6CYI.js → chunk-K2K7OF4P.js} +95 -3
  78. package/dist/chunk-K2K7OF4P.js.map +1 -0
  79. package/dist/{chunk-AGWYBS2E.js → chunk-KGGT6MUM.js} +4 -4
  80. package/dist/{chunk-AGWYBS2E.js.map → chunk-KGGT6MUM.js.map} +1 -1
  81. package/dist/{chunk-BEOKEK3B.js → chunk-L257BENF.js} +73 -54
  82. package/dist/chunk-L257BENF.js.map +1 -0
  83. package/dist/{chunk-UVOJSWD2.js → chunk-LZ5RH6LD.js} +24 -13
  84. package/dist/chunk-LZ5RH6LD.js.map +1 -0
  85. package/dist/{chunk-M4ISBWXR.js → chunk-MGHUSFYQ.js} +2472 -2265
  86. package/dist/chunk-MGHUSFYQ.js.map +1 -0
  87. package/dist/{chunk-43ZBF3WH.js → chunk-OABIGSUY.js} +16 -3
  88. package/dist/chunk-OABIGSUY.js.map +1 -0
  89. package/dist/{chunk-QU4J5YSJ.js → chunk-OFNXRI4L.js} +4 -4
  90. package/dist/{chunk-QU4J5YSJ.js.map → chunk-OFNXRI4L.js.map} +1 -1
  91. package/dist/{chunk-MXXKTQXJ.js → chunk-P2EM6FNQ.js} +5 -5
  92. package/dist/{chunk-MXXKTQXJ.js.map → chunk-P2EM6FNQ.js.map} +1 -1
  93. package/dist/{chunk-DLLM4U6C.js → chunk-PHKFFJ4I.js} +3 -3
  94. package/dist/{chunk-DLLM4U6C.js.map → chunk-PHKFFJ4I.js.map} +1 -1
  95. package/dist/{chunk-YDJZRLGN.js → chunk-PU5VY7KF.js} +4 -4
  96. package/dist/{chunk-YDJZRLGN.js.map → chunk-PU5VY7KF.js.map} +1 -1
  97. package/dist/{chunk-KC3OF6B2.js → chunk-QMWMSZQ4.js} +3 -3
  98. package/dist/{chunk-KC3OF6B2.js.map → chunk-QMWMSZQ4.js.map} +1 -1
  99. package/dist/{chunk-RNOIDD3Y.js → chunk-R3QW7CA5.js} +5 -5
  100. package/dist/{chunk-RNOIDD3Y.js.map → chunk-R3QW7CA5.js.map} +1 -1
  101. package/dist/{chunk-UMSWQKCY.js → chunk-RXPC4KBW.js} +3 -3
  102. package/dist/{chunk-UMSWQKCY.js.map → chunk-RXPC4KBW.js.map} +1 -1
  103. package/dist/{chunk-IAGCOAIW.js → chunk-S6KNDUAU.js} +4 -4
  104. package/dist/{chunk-IAGCOAIW.js.map → chunk-S6KNDUAU.js.map} +1 -1
  105. package/dist/{chunk-I75CM2QF.js → chunk-TVJBJLXR.js} +14 -15
  106. package/dist/chunk-TVJBJLXR.js.map +1 -0
  107. package/dist/{chunk-WKIOWDLQ.js → chunk-UDBN3LZU.js} +4 -4
  108. package/dist/{chunk-WKIOWDLQ.js.map → chunk-UDBN3LZU.js.map} +1 -1
  109. package/dist/{chunk-5S4ZK75K.js → chunk-WMEPS6S4.js} +3 -3
  110. package/dist/{chunk-5S4ZK75K.js.map → chunk-WMEPS6S4.js.map} +1 -1
  111. package/dist/{chunk-KNC55536.js → chunk-XIYXBHLN.js} +5 -4
  112. package/dist/chunk-XIYXBHLN.js.map +1 -0
  113. package/dist/{chunk-VDJKWKH2.js → chunk-XOTJVCJB.js} +3 -3
  114. package/dist/{chunk-VDJKWKH2.js.map → chunk-XOTJVCJB.js.map} +1 -1
  115. package/dist/{chunk-DXUQCMVT.js → chunk-YANDJSMN.js} +3 -3
  116. package/dist/{chunk-DXUQCMVT.js.map → chunk-YANDJSMN.js.map} +1 -1
  117. package/dist/{chunk-AG44ZJ7W.js → chunk-YRF5CYHR.js} +5 -14
  118. package/dist/chunk-YRF5CYHR.js.map +1 -0
  119. package/dist/{chunk-KWP4RVTJ.js → chunk-ZSFTCMZL.js} +760 -642
  120. package/dist/chunk-ZSFTCMZL.js.map +1 -0
  121. package/dist/cli/index.js +506 -434
  122. package/dist/cli/index.js.map +1 -1
  123. package/dist/cli/src/commands/asset-cmd.d.ts.map +1 -1
  124. package/dist/cli/src/commands/catalog.d.ts.map +1 -1
  125. package/dist/cli/src/commands/config.d.ts.map +1 -1
  126. package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
  127. package/dist/cli/src/commands/library-publish.d.ts.map +1 -1
  128. package/dist/cli/src/commands/project.d.ts.map +1 -1
  129. package/dist/cli/src/commands/run.d.ts.map +1 -1
  130. package/dist/cli/src/commands/skailify-lib.d.ts +0 -45
  131. package/dist/cli/src/commands/skailify-lib.d.ts.map +1 -1
  132. package/dist/cli/src/commands/source.d.ts.map +1 -1
  133. package/dist/cli/src/commands/validate.d.ts.map +1 -1
  134. package/dist/cli/src/flow-discovery.d.ts +9 -0
  135. package/dist/cli/src/flow-discovery.d.ts.map +1 -1
  136. package/dist/cli/src/helpers.d.ts +13 -0
  137. package/dist/cli/src/helpers.d.ts.map +1 -1
  138. package/dist/cli/src/setup.d.ts.map +1 -1
  139. package/dist/connectors/config.js +5 -5
  140. package/dist/connectors/index.js +17 -17
  141. package/dist/connectors/src/connector-manager.d.ts +8 -27
  142. package/dist/connectors/src/connector-manager.d.ts.map +1 -1
  143. package/dist/connectors/src/index.d.ts +1 -1
  144. package/dist/connectors/src/index.d.ts.map +1 -1
  145. package/dist/connectors/src/mount-ledger.d.ts +61 -0
  146. package/dist/connectors/src/mount-ledger.d.ts.map +1 -0
  147. package/dist/{connectors-BQXFKISC.js → connectors-GUN4MRWR.js} +20 -20
  148. package/dist/{connectors-BQXFKISC.js.map → connectors-GUN4MRWR.js.map} +1 -1
  149. package/dist/connectors-shared/index.js +2 -2
  150. package/dist/core/framework.js +1 -1
  151. package/dist/core/index.js +7 -7
  152. package/dist/core/manifest.js +2 -2
  153. package/dist/core/models.js +1 -1
  154. package/dist/core/publish-manifest.js +2 -2
  155. package/dist/core/ref.js +1 -1
  156. package/dist/core/runtime-assets.js +5 -5
  157. package/dist/core/src/framework.d.ts +7 -0
  158. package/dist/core/src/framework.d.ts.map +1 -1
  159. package/dist/core/src/index.d.ts +4 -4
  160. package/dist/core/src/index.d.ts.map +1 -1
  161. package/dist/core/src/lock.d.ts +12 -0
  162. package/dist/core/src/lock.d.ts.map +1 -1
  163. package/dist/core/src/manifest-yaml-editor.d.ts +14 -6
  164. package/dist/core/src/manifest-yaml-editor.d.ts.map +1 -1
  165. package/dist/core/src/models.d.ts +15 -0
  166. package/dist/core/src/models.d.ts.map +1 -1
  167. package/dist/core/src/publish-manifest.d.ts +4 -6
  168. package/dist/core/src/publish-manifest.d.ts.map +1 -1
  169. package/dist/core/src/settings.d.ts.map +1 -1
  170. package/dist/core/workspace-config.js +4 -4
  171. package/dist/deploy/index.js +7 -7
  172. package/dist/discovery/index.js +4 -4
  173. package/dist/discovery/src/discover-manifest.d.ts +5 -0
  174. package/dist/discovery/src/discover-manifest.d.ts.map +1 -1
  175. package/dist/discovery/src/index.d.ts +1 -1
  176. package/dist/discovery/src/index.d.ts.map +1 -1
  177. package/dist/{ensure-sources-CMHOTYFS.js → ensure-sources-VCPA762L.js} +15 -15
  178. package/dist/{ensure-sources-CMHOTYFS.js.map → ensure-sources-VCPA762L.js.map} +1 -1
  179. package/dist/factory-assets/connectors/box.js +17 -17
  180. package/dist/factory-assets/connectors/deploy.js +17 -17
  181. package/dist/factory-assets/connectors/devserver.js +17 -17
  182. package/dist/factory-assets/connectors/flow/adapter.d.ts +28 -4
  183. package/dist/factory-assets/connectors/flow/adapter.d.ts.map +1 -1
  184. package/dist/factory-assets/connectors/flow/adapter.js +17 -17
  185. package/dist/factory-assets/connectors/flow/engine.js +8 -8
  186. package/dist/factory-assets/connectors/flow/index.d.ts +1 -1
  187. package/dist/factory-assets/connectors/flow/index.d.ts.map +1 -1
  188. package/dist/factory-assets/connectors/flow/run-flow.js +19 -19
  189. package/dist/factory-assets/connectors/flow.js +17 -17
  190. package/dist/factory-assets/connectors/git/checkout.d.ts +161 -0
  191. package/dist/factory-assets/connectors/git/checkout.d.ts.map +1 -0
  192. package/dist/factory-assets/connectors/git/config.d.ts +78 -0
  193. package/dist/factory-assets/connectors/git/config.d.ts.map +1 -0
  194. package/dist/factory-assets/connectors/git/credentials.d.ts +93 -0
  195. package/dist/factory-assets/connectors/git/credentials.d.ts.map +1 -0
  196. package/dist/factory-assets/connectors/git/driver.d.ts +39 -598
  197. package/dist/factory-assets/connectors/git/driver.d.ts.map +1 -1
  198. package/dist/factory-assets/connectors/git/exec.d.ts +177 -0
  199. package/dist/factory-assets/connectors/git/exec.d.ts.map +1 -0
  200. package/dist/factory-assets/connectors/git/inspect.d.ts +120 -0
  201. package/dist/factory-assets/connectors/git/inspect.d.ts.map +1 -0
  202. package/dist/factory-assets/connectors/git/lifecycle.d.ts +107 -0
  203. package/dist/factory-assets/connectors/git/lifecycle.d.ts.map +1 -0
  204. package/dist/factory-assets/connectors/git/repo.d.ts +496 -0
  205. package/dist/factory-assets/connectors/git/repo.d.ts.map +1 -0
  206. package/dist/factory-assets/connectors/git.js +17 -17
  207. package/dist/factory-assets/connectors/gmail.js +17 -17
  208. package/dist/factory-assets/connectors/googledrive.js +17 -17
  209. package/dist/factory-assets/connectors/local.js +17 -17
  210. package/dist/factory-assets/connectors/mattermost.js +17 -17
  211. package/dist/factory-assets/connectors/memory.js +17 -17
  212. package/dist/factory-assets/connectors/minio.js +17 -17
  213. package/dist/factory-assets/connectors/postgres.js +17 -17
  214. package/dist/factory-assets/connectors/s3.js +17 -17
  215. package/dist/factory-assets/connectors/sharepoint.js +17 -17
  216. package/dist/factory-assets/connectors/sqlite.js +17 -17
  217. package/dist/factory-assets/connectors/static-server.js +17 -17
  218. package/dist/factory-assets/connectors/tunnel.js +17 -17
  219. package/dist/factory-assets/connectors/webdav.js +17 -17
  220. package/dist/factory-assets/connectors/xstate-store.js +17 -17
  221. package/dist/factory-assets/connectors/xstate.js +17 -17
  222. package/dist/{flows-SVCCADGE.js → flows-BOB5YA5R.js} +12 -12
  223. package/dist/{flows-SVCCADGE.js.map → flows-BOB5YA5R.js.map} +1 -1
  224. package/dist/{helpers-R3GLTAER.js → helpers-ZGK4R5MZ.js} +15 -15
  225. package/dist/{helpers-R3GLTAER.js.map → helpers-ZGK4R5MZ.js.map} +1 -1
  226. package/dist/library/index.js +10 -10
  227. package/dist/library/install.js +2 -2
  228. package/dist/library/src/index.d.ts +6 -3
  229. package/dist/library/src/index.d.ts.map +1 -1
  230. package/dist/library/src/install/install-from-manifest.d.ts +21 -0
  231. package/dist/library/src/install/install-from-manifest.d.ts.map +1 -1
  232. package/dist/library/src/local/install-library-asset.d.ts +64 -0
  233. package/dist/library/src/local/install-library-asset.d.ts.map +1 -0
  234. package/dist/library/src/local/local-catalog-source.d.ts +30 -0
  235. package/dist/library/src/local/local-catalog-source.d.ts.map +1 -1
  236. package/dist/library/src/local/store-paths.d.ts +6 -0
  237. package/dist/library/src/local/store-paths.d.ts.map +1 -1
  238. package/dist/library/src/manifest-writer.d.ts +73 -0
  239. package/dist/library/src/manifest-writer.d.ts.map +1 -0
  240. package/dist/library/src/sync/manifest-writeback.d.ts +2 -17
  241. package/dist/library/src/sync/manifest-writeback.d.ts.map +1 -1
  242. package/dist/{library-publish-EL7VYICU.js → library-publish-RIP6NBYA.js} +20 -21
  243. package/dist/library-publish-RIP6NBYA.js.map +1 -0
  244. package/dist/{open-library-MTD34YX3.js → open-library-4IJTBVTR.js} +18 -18
  245. package/dist/{open-library-MTD34YX3.js.map → open-library-4IJTBVTR.js.map} +1 -1
  246. package/dist/{open-registry-CHCWKV5W.js → open-registry-G5DI4RPU.js} +14 -14
  247. package/dist/{open-registry-CHCWKV5W.js.map → open-registry-G5DI4RPU.js.map} +1 -1
  248. package/dist/paths-L5XLUC3D.js +22 -0
  249. package/dist/{paths-MKSI52PF.js.map → paths-L5XLUC3D.js.map} +1 -1
  250. package/dist/plugin-registry/src/targets.d.ts +3 -1
  251. package/dist/plugin-registry/src/targets.d.ts.map +1 -1
  252. package/dist/{plugin-store-SVYV7L4C.js → plugin-store-QENDYZ63.js} +9 -9
  253. package/dist/{plugin-store-SVYV7L4C.js.map → plugin-store-QENDYZ63.js.map} +1 -1
  254. package/dist/{project-HCNWJP7J.js → project-4INCIIZI.js} +16 -16
  255. package/dist/{project-HCNWJP7J.js.map → project-4INCIIZI.js.map} +1 -1
  256. package/dist/resolver/index.js +8 -8
  257. package/dist/runner/index.js +27 -27
  258. package/dist/runner/src/agent.d.ts +1 -1
  259. package/dist/runner/src/agent.d.ts.map +1 -1
  260. package/dist/runner/src/codex-init.d.ts.map +1 -1
  261. package/dist/runner/src/compaction-gate.d.ts +9 -33
  262. package/dist/runner/src/compaction-gate.d.ts.map +1 -1
  263. package/dist/runner/src/managed-codex-bootstrap.d.ts.map +1 -1
  264. package/dist/runner/src/pending-turns.d.ts +7 -2
  265. package/dist/runner/src/pending-turns.d.ts.map +1 -1
  266. package/dist/runner/src/resources.d.ts +2 -2
  267. package/dist/runner/src/resources.d.ts.map +1 -1
  268. package/dist/runner/src/serve-credentials.d.ts +2 -1
  269. package/dist/runner/src/serve-credentials.d.ts.map +1 -1
  270. package/dist/runner/src/serve.d.ts +19 -35
  271. package/dist/runner/src/serve.d.ts.map +1 -1
  272. package/dist/runner/src/session-builder.d.ts.map +1 -1
  273. package/dist/runner/src/turn-scheduler.d.ts +158 -0
  274. package/dist/runner/src/turn-scheduler.d.ts.map +1 -0
  275. package/dist/sdk/asset-manager.js +12 -12
  276. package/dist/sdk/bridge.js +13 -13
  277. package/dist/sdk/core.js +7 -7
  278. package/dist/sdk/flow.js +8 -8
  279. package/dist/sdk/index.js +27 -27
  280. package/dist/sdk/resolver.js +8 -8
  281. package/dist/sdk/runner.js +27 -27
  282. package/dist/sdk/session.js +2 -2
  283. package/dist/sdk/types.js +1 -1
  284. package/dist/session/index.js +2 -2
  285. package/dist/session/src/dispatcher.d.ts.map +1 -1
  286. package/dist/{setup-HTXNR2CZ.js → setup-RG4PJJUW.js} +23 -23
  287. package/dist/setup-RG4PJJUW.js.map +1 -0
  288. package/dist/{skills-7K2YO3KN.js → skills-CL45F7AG.js} +13 -13
  289. package/dist/{skills-7K2YO3KN.js.map → skills-CL45F7AG.js.map} +1 -1
  290. package/dist/{source-UIFC2PFC.js → source-LJOI5AXU.js} +19 -19
  291. package/dist/{source-UIFC2PFC.js.map → source-LJOI5AXU.js.map} +1 -1
  292. package/dist/{source-manifest-publish-QKAKXDVH.js → source-manifest-publish-QEJML4VS.js} +21 -21
  293. package/dist/{source-manifest-publish-QKAKXDVH.js.map → source-manifest-publish-QEJML4VS.js.map} +1 -1
  294. package/dist/tui/index.js +28 -28
  295. package/dist/tui/index.js.map +1 -1
  296. package/dist/types/index.js +1 -1
  297. package/dist/types/src/delivery.d.ts +26 -0
  298. package/dist/types/src/delivery.d.ts.map +1 -0
  299. package/dist/types/src/index.d.ts +3 -1
  300. package/dist/types/src/index.d.ts.map +1 -1
  301. package/dist/types/src/runtime.d.ts +51 -0
  302. package/dist/types/src/runtime.d.ts.map +1 -1
  303. package/dist/workspace-plugin/adapters/mcp.js +24 -24
  304. package/dist/workspace-plugin/adapters/omp.js +18 -17
  305. package/dist/workspace-plugin/adapters/omp.js.map +1 -1
  306. package/dist/workspace-plugin/index.js +2 -1
  307. package/dist/workspace-plugin/src/adapters/mcp.d.ts.map +1 -1
  308. package/dist/workspace-plugin/src/adapters/omp.d.ts.map +1 -1
  309. package/dist/workspace-plugin/src/plugin.d.ts.map +1 -1
  310. package/package.json +1 -1
  311. package/dist/chunk-2HR3RPWD.js.map +0 -1
  312. package/dist/chunk-43ZBF3WH.js.map +0 -1
  313. package/dist/chunk-7SAWDPUT.js.map +0 -1
  314. package/dist/chunk-AG44ZJ7W.js.map +0 -1
  315. package/dist/chunk-BEOKEK3B.js.map +0 -1
  316. package/dist/chunk-F7JHP7JV.js +0 -122
  317. package/dist/chunk-F7JHP7JV.js.map +0 -1
  318. package/dist/chunk-H4EGUQ7M.js.map +0 -1
  319. package/dist/chunk-I75CM2QF.js.map +0 -1
  320. package/dist/chunk-IDEA6CYI.js.map +0 -1
  321. package/dist/chunk-IWCCZL7C.js.map +0 -1
  322. package/dist/chunk-K5GBV4SA.js.map +0 -1
  323. package/dist/chunk-KNC55536.js.map +0 -1
  324. package/dist/chunk-KWP4RVTJ.js.map +0 -1
  325. package/dist/chunk-M4ISBWXR.js.map +0 -1
  326. package/dist/chunk-RO4Z2CBP.js.map +0 -1
  327. package/dist/chunk-SP47UJKE.js.map +0 -1
  328. package/dist/chunk-UVOJSWD2.js.map +0 -1
  329. package/dist/chunk-WPWJRDR3.js.map +0 -1
  330. package/dist/chunk-XUQBVK4R.js +0 -15
  331. package/dist/chunk-ZD7CX25M.js.map +0 -1
  332. package/dist/library-publish-EL7VYICU.js.map +0 -1
  333. package/dist/paths-MKSI52PF.js +0 -22
  334. package/dist/runner/src/flow-turn-dispatch.d.ts +0 -41
  335. package/dist/runner/src/flow-turn-dispatch.d.ts.map +0 -1
  336. package/dist/runner/src/reply-routing.d.ts +0 -54
  337. package/dist/runner/src/reply-routing.d.ts.map +0 -1
  338. package/dist/setup-HTXNR2CZ.js.map +0 -1
@@ -1,122 +0,0 @@
1
- import { loadSkPublishManifest, saveSkPublishManifest } from './chunk-AG44ZJ7W.js';
2
- import { parseFrontmatter } from './chunk-DXUQCMVT.js';
3
- import { isValidAssetName, slugifyAssetName } from './chunk-43ZBF3WH.js';
4
- import * as fs from 'fs';
5
- import * as os from 'os';
6
- import * as path from 'path';
7
- import { stringify } from 'yaml';
8
-
9
- var DEFAULT_IMPORT_VERSION = "0.1.0";
10
- var DEFAULT_IMPORT_STAGE = "alpha";
11
- function claudeSkillRoots() {
12
- const roots = [];
13
- const override = process.env.SKAILE_CLAUDE_SKILLS_DIR;
14
- if (override) roots.push(override);
15
- roots.push(path.join(os.homedir(), ".claude", "skills"));
16
- return roots;
17
- }
18
- function resolveImportSource(nameOrPath) {
19
- const asPath = path.resolve(nameOrPath);
20
- if (fs.existsSync(asPath)) {
21
- const dir = fs.statSync(asPath).isDirectory() ? asPath : path.dirname(asPath);
22
- const skillFile = path.join(dir, "SKILL.md");
23
- if (fs.existsSync(skillFile)) return { dir, skillFile, via: "path" };
24
- }
25
- if (!nameOrPath.includes(path.sep) && !nameOrPath.startsWith(".")) {
26
- for (const root of claudeSkillRoots()) {
27
- const dir = path.join(root, nameOrPath);
28
- const skillFile = path.join(dir, "SKILL.md");
29
- if (fs.existsSync(skillFile)) return { dir, skillFile, via: "claude-skills" };
30
- }
31
- }
32
- return null;
33
- }
34
- function normalizeSkillContent(raw, opts = {}) {
35
- const notes = [];
36
- const { data, body } = parseFrontmatter(raw);
37
- const rawName = typeof data.name === "string" && data.name.trim() ? data.name.trim() : void 0;
38
- const sourceName = rawName ?? opts.fallbackName ?? "";
39
- let name = sourceName;
40
- let originalName;
41
- if (!sourceName) {
42
- throw new Error("skill has no `name` in frontmatter and no fallback was provided");
43
- }
44
- if (!isValidAssetName(sourceName)) {
45
- name = slugifyAssetName(sourceName);
46
- originalName = sourceName;
47
- notes.push(`renamed "${sourceName}" \u2192 "${name}" (canonical kebab-case)`);
48
- }
49
- const existingMeta = data.metadata && typeof data.metadata === "object" && !Array.isArray(data.metadata) ? { ...data.metadata } : {};
50
- if (existingMeta.version == null) {
51
- existingMeta.version = opts.version ?? DEFAULT_IMPORT_VERSION;
52
- notes.push(`stamped metadata.version: ${existingMeta.version}`);
53
- }
54
- if (existingMeta.stage == null) {
55
- existingMeta.stage = opts.stage ?? DEFAULT_IMPORT_STAGE;
56
- notes.push(`stamped metadata.stage: ${existingMeta.stage}`);
57
- }
58
- if (existingMeta.tags == null) {
59
- const keywords = Array.isArray(data.keywords) ? data.keywords : [];
60
- existingMeta.tags = keywords.filter((k) => typeof k === "string");
61
- if (existingMeta.tags.length > 0) {
62
- notes.push("promoted top-level keywords \u2192 metadata.tags");
63
- }
64
- }
65
- const ordered = { name };
66
- if (data.description != null) ordered.description = data.description;
67
- ordered.metadata = existingMeta;
68
- for (const [k, v] of Object.entries(data)) {
69
- if (k === "name" || k === "description" || k === "metadata" || k === "keywords") continue;
70
- ordered[k] = v;
71
- }
72
- const fm = stringify(ordered).trimEnd();
73
- const content = `---
74
- ${fm}
75
- ---
76
-
77
- ${body}
78
- `;
79
- const changed = notes.length > 0;
80
- return { content, name, originalName, changed, notes };
81
- }
82
- function upsertManifestAsset(libraryPath, input) {
83
- const manifest = loadSkPublishManifest(libraryPath) ?? { assets: [] };
84
- const assets = Array.isArray(manifest.assets) ? [...manifest.assets] : [];
85
- const overridesTopLevel = !!input.publisher && input.publisher !== manifest.publisher;
86
- const entry = { kind: input.kind, name: input.name, root: input.root };
87
- if (input.version) entry.version = input.version;
88
- if (overridesTopLevel) entry.publisher = input.publisher;
89
- if (input.description) entry.description = input.description;
90
- if (input.keywords && input.keywords.length > 0) entry.keywords = input.keywords;
91
- const idx = assets.findIndex((a) => a.kind === input.kind && a.name === input.name);
92
- const added = idx < 0;
93
- if (added) {
94
- assets.push(entry);
95
- } else {
96
- const merged = { ...assets[idx], ...entry };
97
- if (input.publisher && !overridesTopLevel) delete merged.publisher;
98
- assets[idx] = merged;
99
- }
100
- const manifestPath = saveSkPublishManifest(libraryPath, { ...manifest, assets });
101
- return { manifestPath, added };
102
- }
103
- function missingRootAssets(libraryPath, manifest) {
104
- return (manifest.assets ?? []).filter((a) => {
105
- if (a.source || !a.root) return false;
106
- const dir = path.resolve(libraryPath, a.root);
107
- return !(fs.existsSync(dir) && fs.statSync(dir).isDirectory());
108
- });
109
- }
110
- function pruneMissingRootAssets(libraryPath) {
111
- const manifest = loadSkPublishManifest(libraryPath);
112
- if (!manifest) return [];
113
- const removed = missingRootAssets(libraryPath, manifest);
114
- if (removed.length === 0) return [];
115
- const assets = (manifest.assets ?? []).filter((a) => !removed.includes(a));
116
- saveSkPublishManifest(libraryPath, { ...manifest, assets });
117
- return removed;
118
- }
119
-
120
- export { missingRootAssets, normalizeSkillContent, pruneMissingRootAssets, resolveImportSource, upsertManifestAsset };
121
- //# sourceMappingURL=chunk-F7JHP7JV.js.map
122
- //# sourceMappingURL=chunk-F7JHP7JV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../cli/src/commands/skailify-lib.ts"],"names":["stringifyYaml"],"mappings":";;;;;;;;AAuBO,IAAM,sBAAA,GAAyB,OAAA;AAE/B,IAAM,oBAAA,GAAuB,OAAA;AAO7B,SAAS,gBAAA,GAA6B;AAC3C,EAAA,MAAM,QAAkB,EAAC;AACzB,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,CAAC,CAAA;AACzE,EAAA,qBAAA,CAAsB,WAAA,EAAa,EAAE,GAAG,QAAA,EAAU,QAAQ,CAAA;AAC1D,EAAA,OAAO,OAAA;AACT","file":"chunk-F7JHP7JV.js","sourcesContent":["/**\n * skailify — pure, individually-testable helpers for importing an existing\n * coding-agent skill (e.g. a Claude Code skill from `~/.claude/skills/`) into a\n * skaile library. Composed by the `asset import` command and the `skailify`\n * factory skill. See each export's TSDoc for specifics.\n *\n * @docLink cli/commands/asset#import\n */\n\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport {\n isValidAssetName,\n loadSkPublishManifest,\n parseFrontmatter,\n saveSkPublishManifest,\n slugifyAssetName,\n} from \"@skaile/workspaces/core\";\nimport type { AssetEntry, SkPublishManifest } from \"@skaile/workspaces/core\";\nimport { stringify as stringifyYaml } from \"yaml\";\n\n/** Default authoring version stamped on a skill that ships none. */\nexport const DEFAULT_IMPORT_VERSION = \"0.1.0\";\n/** Default lifecycle stage stamped on an imported skill. */\nexport const DEFAULT_IMPORT_STAGE = \"alpha\";\n\n/**\n * Where coding-agent skills live on disk, highest precedence first. The\n * `SKAILE_CLAUDE_SKILLS_DIR` override exists so tests (and non-default setups)\n * can point the resolver at a fixture tree without touching `$HOME`.\n */\nexport function claudeSkillRoots(): string[] {\n const roots: string[] = [];\n const override = process.env.SKAILE_CLAUDE_SKILLS_DIR;\n if (override) roots.push(override);\n roots.push(path.join(os.homedir(), \".claude\", \"skills\"));\n return roots;\n}\n\nexport interface ResolvedImportSource {\n /** Absolute path to the skill directory. */\n dir: string;\n /** Absolute path to the skill's SKILL.md. */\n skillFile: string;\n /** How the source was located — for human-facing messages. */\n via: \"path\" | \"claude-skills\";\n}\n\n/**\n * Resolve an `import` argument to a concrete skill directory. A value that\n * exists on disk (file or dir) is used verbatim; otherwise it is treated as a\n * bare skill name and looked up under {@link claudeSkillRoots}.\n *\n * Returns `null` when nothing matches so the caller can print a tailored error.\n */\nexport function resolveImportSource(nameOrPath: string): ResolvedImportSource | null {\n // Explicit path (relative or absolute) wins.\n const asPath = path.resolve(nameOrPath);\n if (fs.existsSync(asPath)) {\n const dir = fs.statSync(asPath).isDirectory() ? asPath : path.dirname(asPath);\n const skillFile = path.join(dir, \"SKILL.md\");\n if (fs.existsSync(skillFile)) return { dir, skillFile, via: \"path\" };\n }\n // Bare name → coding-agent skill roots.\n if (!nameOrPath.includes(path.sep) && !nameOrPath.startsWith(\".\")) {\n for (const root of claudeSkillRoots()) {\n const dir = path.join(root, nameOrPath);\n const skillFile = path.join(dir, \"SKILL.md\");\n if (fs.existsSync(skillFile)) return { dir, skillFile, via: \"claude-skills\" };\n }\n }\n return null;\n}\n\nexport interface NormalizeOptions {\n /** Fallback name when frontmatter has none (usually the source dir name). */\n fallbackName?: string;\n /** Version to stamp when the skill ships none. */\n version?: string;\n /** Stage to stamp when the skill ships none. */\n stage?: string;\n}\n\nexport interface NormalizeResult {\n /** Rewritten SKILL.md content (frontmatter + body). */\n content: string;\n /** Canonical asset name (slugified if the source was non-compliant). */\n name: string;\n /** The name as it appeared in the source, when it differed from `name`. */\n originalName?: string;\n /** True when `content` differs from the input (metadata added, name slugified, …). */\n changed: boolean;\n /** Human-facing notes about what was normalized. */\n notes: string[];\n}\n\n/**\n * Bring a coding-agent `SKILL.md` into the skaile schema without touching the\n * body: ensure a canonical lowercase-kebab `name`, and a `metadata:` block\n * carrying at least `version`, `stage`, and `tags`. Idempotent — a SKILL.md\n * that already conforms comes back unchanged (`changed: false`).\n *\n * A Claude Code skill only requires `name` + `description`; skaile additionally\n * expects the `metadata:` block, so this is the transform `asset migrate`'s raw\n * byte-copy skips.\n */\nexport function normalizeSkillContent(raw: string, opts: NormalizeOptions = {}): NormalizeResult {\n const notes: string[] = [];\n const { data, body } = parseFrontmatter(raw);\n\n // ── name ─────────────────────────────────────────────────────────────────\n const rawName = typeof data.name === \"string\" && data.name.trim() ? data.name.trim() : undefined;\n const sourceName = rawName ?? opts.fallbackName ?? \"\";\n let name = sourceName;\n let originalName: string | undefined;\n if (!sourceName) {\n throw new Error(\"skill has no `name` in frontmatter and no fallback was provided\");\n }\n if (!isValidAssetName(sourceName)) {\n name = slugifyAssetName(sourceName);\n originalName = sourceName;\n notes.push(`renamed \"${sourceName}\" → \"${name}\" (canonical kebab-case)`);\n }\n\n // ── metadata block ─────────────────────────────────────────────────────────\n const existingMeta =\n data.metadata && typeof data.metadata === \"object\" && !Array.isArray(data.metadata)\n ? { ...(data.metadata as Record<string, unknown>) }\n : {};\n\n if (existingMeta.version == null) {\n existingMeta.version = opts.version ?? DEFAULT_IMPORT_VERSION;\n notes.push(`stamped metadata.version: ${existingMeta.version}`);\n }\n if (existingMeta.stage == null) {\n existingMeta.stage = opts.stage ?? DEFAULT_IMPORT_STAGE;\n notes.push(`stamped metadata.stage: ${existingMeta.stage}`);\n }\n if (existingMeta.tags == null) {\n // Promote top-level `keywords` (the agentskills.io convention) into tags.\n const keywords = Array.isArray(data.keywords) ? (data.keywords as unknown[]) : [];\n existingMeta.tags = keywords.filter((k): k is string => typeof k === \"string\");\n if ((existingMeta.tags as string[]).length > 0) {\n notes.push(\"promoted top-level keywords → metadata.tags\");\n }\n }\n\n // ── re-serialize, key order: name, description, metadata, then the rest ────\n const ordered: Record<string, unknown> = { name };\n if (data.description != null) ordered.description = data.description;\n ordered.metadata = existingMeta;\n for (const [k, v] of Object.entries(data)) {\n if (k === \"name\" || k === \"description\" || k === \"metadata\" || k === \"keywords\") continue;\n ordered[k] = v;\n }\n\n const fm = stringifyYaml(ordered).trimEnd();\n const content = `---\\n${fm}\\n---\\n\\n${body}\\n`;\n // `changed` tracks semantic mutation, not formatting — every real change adds\n // a note, so a conformant skill stays `false` despite YAML re-quoting.\n const changed = notes.length > 0;\n return { content, name, originalName, changed, notes };\n}\n\nexport interface UpsertAssetInput {\n kind: string;\n name: string;\n /** Repo-relative path to the asset directory (the AssetEntry `root`). */\n root: string;\n version?: string;\n /**\n * The asset's resolved publisher. Written to the entry's `publisher` only when\n * it differs from the manifest's top-level `publisher` (the entry otherwise\n * inherits it); when it equals the top-level one, any stale per-asset override\n * on an existing entry is dropped. Omit to leave an existing override untouched.\n */\n publisher?: string;\n description?: string;\n keywords?: string[];\n}\n\nexport interface UpsertAssetResult {\n manifestPath: string;\n /** True when a new entry was appended, false when an existing one was updated. */\n added: boolean;\n}\n\n/**\n * Auto-wire an asset into a library's `skaile.manifest.yaml` (creating the\n * manifest when absent). Matches an existing entry by `(kind, name)` and\n * updates it in place; otherwise appends. This is the manifest half of import\n * that a plain byte-copy (`asset migrate`) leaves stale.\n */\nexport function upsertManifestAsset(\n libraryPath: string,\n input: UpsertAssetInput,\n): UpsertAssetResult {\n const manifest: SkPublishManifest = loadSkPublishManifest(libraryPath) ?? { assets: [] };\n const assets: AssetEntry[] = Array.isArray(manifest.assets) ? [...manifest.assets] : [];\n\n const overridesTopLevel = !!input.publisher && input.publisher !== manifest.publisher;\n const entry: AssetEntry = { kind: input.kind, name: input.name, root: input.root };\n if (input.version) entry.version = input.version;\n if (overridesTopLevel) entry.publisher = input.publisher;\n if (input.description) entry.description = input.description;\n if (input.keywords && input.keywords.length > 0) entry.keywords = input.keywords;\n\n const idx = assets.findIndex((a) => a.kind === input.kind && a.name === input.name);\n const added = idx < 0;\n if (added) {\n assets.push(entry);\n } else {\n const merged = { ...assets[idx], ...entry };\n if (input.publisher && !overridesTopLevel) delete merged.publisher;\n assets[idx] = merged;\n }\n\n const manifestPath = saveSkPublishManifest(libraryPath, { ...manifest, assets });\n return { manifestPath, added };\n}\n\n/**\n * The manifest entries that point at a directory which no longer exists in the\n * library — an asset whose directory was deleted (or renamed) without the\n * manifest following. Only first-party `root:` entries are checked: curated\n * entries (`source:`) and `files:`-only entries carry no library directory.\n * A root that exists but is malformed is NOT reported — that is the indexer's\n * `ManifestFileMissing` warning, not a removed asset.\n */\nexport function missingRootAssets(libraryPath: string, manifest: SkPublishManifest): AssetEntry[] {\n return (manifest.assets ?? []).filter((a) => {\n if (a.source || !a.root) return false;\n const dir = path.resolve(libraryPath, a.root);\n return !(fs.existsSync(dir) && fs.statSync(dir).isDirectory());\n });\n}\n\n/**\n * Drop every entry {@link missingRootAssets} reports from the library's\n * `skaile.manifest.yaml` and write it back (same writer as\n * {@link upsertManifestAsset}). Returns the removed entries; the manifest is\n * left untouched when nothing is stale.\n */\nexport function pruneMissingRootAssets(libraryPath: string): AssetEntry[] {\n const manifest = loadSkPublishManifest(libraryPath);\n if (!manifest) return [];\n const removed = missingRootAssets(libraryPath, manifest);\n if (removed.length === 0) return [];\n const assets = (manifest.assets ?? []).filter((a) => !removed.includes(a));\n saveSkPublishManifest(libraryPath, { ...manifest, assets });\n return removed;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../library/src/install/install-from-manifest.ts"],"names":[],"mappings":";;;;;AA+CA,SAAS,sBAAA,CAAuB,aAAqB,CAAA,EAAiB;AACpE,EAAA,MAAM,MAAM,MAAa;AACvB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,yBAAA,EAA4B,CAAC,CAAA,CAAE,CAAA;AAAA,EACjD,CAAA;AACA,EAAA,IAAI,CAAC,CAAA,IAAK,CAAA,CAAE,MAAA,KAAW,GAAG,GAAA,EAAI;AAC9B,EAAA,IAAI,UAAA,CAAW,CAAC,CAAA,IAAK,CAAA,CAAE,UAAA,CAAW,GAAG,CAAA,IAAK,CAAA,CAAE,UAAA,CAAW,IAAI,CAAA,EAAG,GAAA,EAAI;AAClE,EAAA,MAAM,QAAA,GAAW,CAAA,CAAE,KAAA,CAAM,OAAO,CAAA;AAChC,EAAA,IAAI,SAAS,IAAA,CAAK,CAAC,MAAM,CAAA,KAAM,IAAI,GAAG,GAAA,EAAI;AAC1C,EAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,WAAA,EAAa,CAAC,CAAA;AACvC,EAAA,IAAI,QAAA,KAAa,eAAe,CAAC,QAAA,CAAS,WAAW,WAAA,GAAc,GAAG,GAAG,GAA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AA,CAAE,IAAA,CAAK,MAAM,SAAA,CAAU,MAAA,GAAS,CAAC,CAAA,GAAI,CAAA,CAAE,IAAA;AAEnE,IAAA,sBAAA,CAAuB,QAAQ,OAAO,CAAA;AACtC,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,MAAA,EAAQ,OAAO,CAAA;AACjC,IAAA,MAAM,MAAM,OAAA,CAAQ,IAAI,GAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AAC9C,IAAA,MAAM,SAAA,CAAU,MAAM,GAAG,CAAA;AAAA,EAC3B;AAEA,EAAA,OAAO,EAAE,aAAa,MAAA,EAAO;AAC/B","file":"chunk-H4EGUQ7M.js","sourcesContent":["/**\n * Pointer-only install path.\n *\n * Given an {@link InstallManifest} (the Pointer Triple the Catalog hands\n * clients), this:\n *\n * 1. fetches the asset bytes directly from the upstream repo at the pinned\n * commit (via an injectable fetcher, default {@link fetchAssetFilesFromGitHub});\n * 2. verifies EVERY per-file SHA256 against `manifest.files[].sha256`;\n * 3. verifies the composite SHA256 rollup over the sorted\n * `<path>:<sha256>\\n` lines against `manifest.sha256`;\n * 4. writes the verified bytes under `<libraryRoot>/@<publisher>/<name>/<version>`.\n *\n * Any hash mismatch is a hard failure — bytes are not written if per-file\n * verification fails, and the composite check is the second gate.\n *\n * @docLink packages/library/concepts#install\n */\n\nimport { createHash } from \"node:crypto\";\nimport { mkdir, rm, writeFile } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, resolve, sep } from \"node:path\";\nimport type { InstallManifest } from \"@skaile/workspaces/types\";\n// Narrow module, not the `core` barrel: the barrel's chunks carry `import.meta`,\n// which breaks consumers that transpile this entry to CommonJS.\nimport { parseAssetRef } from \"../../../core/src/models.js\";\n\n/**\n * Validate a single manifest-supplied file path against path traversal.\n *\n * `manifest.files[].path` comes off the network — the attacker controls the\n * entire manifest (and therefore every hash in it), so hash verification can\n * NEVER mitigate a malicious *destination*. A path like\n * `../../../../home/user/.bashrc` or an absolute path would escape\n * `installPath` and yield an arbitrary file write. Every path is checked\n * BEFORE any fetch or write happens; the first bad path aborts the entire\n * install with a hard throw.\n *\n * A path is rejected if ANY of:\n * - it is empty;\n * - it is absolute (`path.isAbsolute`) or has a leading slash;\n * - it contains a `..` segment;\n * - `path.resolve(installPath, p)` is not `installPath` itself and does not\n * start with `installPath + path.sep` (escapes the install dir).\n *\n * @throws An error matching `/unsafe path in manifest/` on the first bad path.\n */\nfunction assertSafeManifestPath(installPath: string, p: string): void {\n const bad = (): never => {\n throw new Error(`unsafe path in manifest: ${p}`);\n };\n if (!p || p.length === 0) bad();\n if (isAbsolute(p) || p.startsWith(\"/\") || p.startsWith(\"\\\\\")) bad();\n const segments = p.split(/[/\\\\]/);\n if (segments.some((s) => s === \"..\")) bad();\n const resolved = resolve(installPath, p);\n if (resolved !== installPath && !resolved.startsWith(installPath + sep)) bad();\n}\n\n/**\n * Validate one component (publisher / name / version) of the attacker-controlled\n * `manifest.ref`.\n *\n * `installPath` is built by joining these components onto `libraryRoot`. A\n * component containing a path separator or a `..` / leading-dot segment would\n * let `installPath` itself escape `libraryRoot` — yielding an arbitrary file\n * write AND, via the pre-write `rm(installPath, { recursive })`, an arbitrary\n * recursive delete. The per-file `assertSafeManifestPath` guard cannot catch\n * this: it only validates each `f.path` *relative to* `installPath`, never\n * `installPath` itself. Components must be plain identifier-like strings.\n *\n * @throws An error matching `/unsafe ref/` on a bad component.\n */\nfunction assertSafeRefComponent(kind: string, value: string): void {\n // Reject empty, leading-dot (covers `.` and `..`), path separators, and\n // ASCII control characters (NUL et al.) — fails a malformed segment fast\n // with a domain-specific error rather than a raw EINVAL deeper in.\n const hasControlChar = [...value].some((c) => c.charCodeAt(0) < 0x20);\n if (!value || value.startsWith(\".\") || /[/\\\\]/.test(value) || hasControlChar) {\n throw new Error(`unsafe ref ${kind} component in manifest: '${value}'`);\n }\n}\n\n/**\n * Longest common **directory** prefix across manifest paths, compared by whole\n * slash-delimited segments (never raw-string — so `app/` and `app-data/` never\n * collide). Each path's basename is excluded, so the result is always a\n * directory prefix and every path keeps a non-empty remainder after stripping.\n *\n * Used by flat mode to reproduce the platform pointer-installer's asset-rooting:\n * the store persists repo-root-relative paths (e.g. `skaile-platform/mcpo/xls/MCP.md`)\n * but the runner scans `.skaile/assets/<kind>/<name>/` for immediate-child files,\n * so this prefix is stripped from the WRITE path while the fetch keeps the full\n * repo path. Returns `''` when there is no common directory (a no-op strip).\n */\nexport function longestCommonDirPrefix(paths: readonly string[]): string {\n if (paths.length === 0) return \"\";\n const dirSegments = paths.map((p) => p.split(\"/\").slice(0, -1));\n let common = dirSegments[0]!;\n for (let i = 1; i < dirSegments.length && common.length > 0; i++) {\n const segs = dirSegments[i]!;\n let n = 0;\n while (n < common.length && n < segs.length && common[n] === segs[n]) n++;\n common = common.slice(0, n);\n }\n return common.join(\"/\");\n}\n\n/**\n * Fetcher signature — fetches `{ path → Buffer }` for the requested paths at\n * a pinned upstream commit. {@link fetchAssetFilesFromGitHub} is the default\n * production implementation; tests inject a mock.\n */\nexport type AssetFetcher = (opts: {\n url: string;\n commitSha: string;\n paths: string[];\n}) => Promise<Record<string, Buffer>>;\n\n/**\n * Options for {@link installFromManifest}.\n */\nexport interface InstallOpts {\n /** The pointer-only install manifest from the Catalog. */\n manifest: InstallManifest;\n /** Filesystem root the asset is installed under (ref-derived mode). */\n libraryRoot: string;\n /**\n * Pluggable fetcher so tests can inject mock data. Defaults to\n * {@link fetchAssetFilesFromGitHub} in production.\n */\n fetcher?: AssetFetcher;\n /**\n * Flat-layout mode. When set, install-core reproduces the platform\n * pointer-installer's behavior: it ignores `libraryRoot`/ref-derivation, does\n * NOT parse `manifest.ref` and does NOT verify the composite sha256, strips\n * the longest-common-dir prefix from each path, per-file sha256-verifies, and\n * writes the stripped paths as immediate children of `targetDir` (what the\n * runner's `.skaile/assets/<kind>/<name>/` scan requires). `installPath` is\n * `targetDir`. Absent → unchanged ref-derived `@<pub>/name/version/<path>`\n * layout with composite verify.\n */\n targetDir?: string;\n}\n\n/**\n * Result of a successful {@link installFromManifest} call.\n */\nexport interface InstallResult {\n /** Absolute path the asset files were written to. */\n installPath: string;\n}\n\n/**\n * Fetch, verify, and write an asset's files per its {@link InstallManifest}.\n *\n * @throws An error matching `/hash mismatch/i` if any per-file SHA256 differs.\n * @throws An error matching `/composite hash mismatch/i` if the rollup differs.\n * @throws An error if the ref is malformed or the fetcher omits a file.\n */\nexport async function installFromManifest(opts: InstallOpts): Promise<InstallResult> {\n const { manifest, libraryRoot } = opts;\n const fetcher =\n opts.fetcher ?? (await import(\"./source-fetch-github.js\")).fetchAssetFilesFromGitHub;\n\n // Flat mode: reproduce the platform pointer-installer's asset-rooted layout.\n // No ref parse, no composite verify — the platform store may not satisfy a\n // ref-grammar or composite, and the runner only needs immediate-child files.\n if (opts.targetDir !== undefined) {\n return installFlat(manifest, opts.targetDir, fetcher);\n }\n\n // 1. Parse ref into install path: `skill:@x/git#1.0.0` → `<root>/@x/git/1.0.0`.\n // Done first so the C1 path-traversal guard can resolve against installPath\n // BEFORE any network fetch happens. The ref is attacker-controlled, so each\n // segment is further validated as a safe path component (H1) after parsing.\n // `parseAssetRef` is the single canonical grammar (`kind:@publisher/name#version`);\n // the legacy trailing-`@version` shape was removed in core and is rejected here.\n let parsed: ReturnType<typeof parseAssetRef>;\n try {\n parsed = parseAssetRef(manifest.ref);\n } catch (e) {\n throw new Error(`invalid ref: ${manifest.ref}: ${e instanceof Error ? e.message : String(e)}`);\n }\n const publisher = parsed.publisher;\n const name = parsed.name;\n const version = parsed.pin;\n if (!publisher) throw new Error(`invalid ref: ${manifest.ref} (missing publisher)`);\n if (!version) throw new Error(`invalid ref: ${manifest.ref} (missing version pin)`);\n assertSafeRefComponent(\"publisher\", publisher);\n assertSafeRefComponent(\"name\", name);\n assertSafeRefComponent(\"version\", version);\n const root = resolve(libraryRoot);\n const installPath = resolve(join(root, `@${publisher}`, name, version));\n // Defense in depth: even with the segment guards above, assert the built\n // installPath stays strictly inside libraryRoot before any write or `rm`.\n if (installPath !== root && !installPath.startsWith(root + sep)) {\n throw new Error(`unsafe install path: ref '${manifest.ref}' resolves outside the library root`);\n }\n\n // 2. [C1] Validate EVERY manifest path against traversal BEFORE fetching.\n // The attacker controls the manifest (and thus all hashes) — hashes verify\n // content, never destination. Reject the whole install on the first bad path.\n for (const f of manifest.files) {\n assertSafeManifestPath(installPath, f.path);\n }\n\n // 3. Fetch all files at the pinned commit.\n const paths = manifest.files.map((f) => f.path);\n const bytes = await fetcher({\n url: manifest.source.url,\n commitSha: manifest.source.commitSha,\n paths,\n });\n\n // 4. Verify per-file SHA256 — hard fail before writing anything. The path\n // key used to read from the fetcher result is re-guarded as defense in depth.\n for (const f of manifest.files) {\n assertSafeManifestPath(installPath, f.path);\n const buf = bytes[f.path];\n if (!buf) throw new Error(`fetcher returned no bytes for ${f.path}`);\n const actual = createHash(\"sha256\").update(buf).digest(\"hex\");\n if (actual !== f.sha256) {\n throw new Error(`hash mismatch for ${f.path}: expected ${f.sha256}, got ${actual}`);\n }\n }\n\n // 5. Verify composite SHA256 over the sorted `<path>:<sha256>\\n` lines.\n const sortedLines = manifest.files\n .slice()\n .sort((a, b) => a.path.localeCompare(b.path))\n .map((e) => `${e.path}:${e.sha256}\\n`)\n .join(\"\");\n const actualComposite = createHash(\"sha256\").update(sortedLines, \"utf-8\").digest(\"hex\");\n if (actualComposite !== manifest.sha256) {\n throw new Error(`composite hash mismatch: expected ${manifest.sha256}, got ${actualComposite}`);\n }\n\n // 6. [M1] Write all verified files. A failed install must leave NO partial\n // directory: any prior `installPath` is removed first (clean overwrite), and\n // a mid-loop write failure removes the partially-written tree before\n // rethrowing.\n await rm(installPath, { recursive: true, force: true });\n try {\n for (const f of manifest.files) {\n const target = join(installPath, f.path);\n await mkdir(dirname(target), { recursive: true });\n await writeFile(target, bytes[f.path]!);\n }\n } catch (e) {\n await rm(installPath, { recursive: true, force: true }).catch(() => {});\n throw e;\n }\n\n return { installPath };\n}\n\n/**\n * Flat-layout install — the platform pointer-installer's behavior, made canonical\n * in install-core. Validates every path, fetches with the FULL repo paths, per-file\n * sha256-verifies, then strips the longest-common-dir prefix and writes each file\n * as `join(targetDir, path.slice(assetRoot.length + 1))` — immediate children of\n * `targetDir`. No ref parse, no composite check.\n */\nasync function installFlat(\n manifest: InstallManifest,\n targetDir: string,\n fetcher: AssetFetcher,\n): Promise<InstallResult> {\n const target = resolve(targetDir);\n\n // Gate every path before any fetch — the attacker controls the whole manifest.\n for (const f of manifest.files) {\n assertSafeManifestPath(target, f.path);\n }\n\n // Fetch keys off the FULL repo path (matches the upstream tree).\n const paths = manifest.files.map((f) => f.path);\n const bytes = await fetcher({\n url: manifest.source.url,\n commitSha: manifest.source.commitSha,\n paths,\n });\n\n // Strip the asset-root dir prefix from the WRITE path only — the fetch above\n // still keyed off the full repo path. Stripping removes leading whole segments\n // (never the basename), so a non-empty remainder always survives.\n const assetRoot = longestCommonDirPrefix(paths);\n\n for (const f of manifest.files) {\n const buf = bytes[f.path];\n if (!buf) throw new Error(`fetcher returned no bytes for ${f.path}`);\n const actual = createHash(\"sha256\").update(buf).digest(\"hex\");\n if (actual !== f.sha256) {\n throw new Error(`hash mismatch for ${f.path}: expected ${f.sha256}, got ${actual}`);\n }\n const relPath = assetRoot ? f.path.slice(assetRoot.length + 1) : f.path;\n // Re-guard the post-strip destination — it is what we actually write.\n assertSafeManifestPath(target, relPath);\n const dest = join(target, relPath);\n await mkdir(dirname(dest), { recursive: true });\n await writeFile(dest, buf);\n }\n\n return { installPath: target };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../cli/src/commands/source-manifest.ts","../cli/src/commands/source.ts"],"names":["path2","existsSync","spawnSync"],"mappings":";;;;;;;;;;;;;;;AA+CA,IAAM,aAAA,GACJ,2IAAA;AAGF,SAAS,SAAS,IAAA,EAAqB;AACrC,EAAA,MAAA,CAAO,CAAA,EAAG,aAAa,CAAA,wBAAA,EAA2B,IAAI,CAAA,CAAA,CAAG,CAAA;AACzD,EA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MAClB;AACA,MAAA,KAAA,MAAW,GAAA,IAAO,OAAO,MAAA,EAAQ,OAAA,CAAQ,GAAG,IAAI,CAAA,EAAA,EAAK,GAAG,CAAA,CAAE,CAAA;AAC1D,MAAA,KAAA,MAAW,QAAA,IAAY,OAAO,UAAA,EAAY,OAAA,CAAQ,GAAG,IAAI,CAAA,EAAA,EAAK,QAAQ,CAAA,CAAE,CAAA;AACxE,MAAA,MAAM,UAAA,GAAa,uBAAuB,IAAI,CAAA;AAC9C,MAAA,IAAI,YAAY,OAAA,CAAQ,CAAA,EAAG,IAAI,CAAA,EAAA,EAAK,UAAU,CAAA,CAAE,CAAA;AAAA,IAClD;AAAA,EACF,CAAC,CAAA;AAGH,EAAA,GAAA,CACG,OAAA,CAAQ,aAAa,CAAA,CACrB,WAAA,CAAY,iDAAiD,CAAA,CAC7D,MAAA,CAAO,CAAC,IAAA,KAAiB;AACxB,IAAA,MAAA;AAAA,MACE;AAAA,KAEF;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB,CAAC,CAAA;AAEH,EAAA,GAAA,CACG,OAAA,CAAQ,eAAe,CAAA,CACvB,WAAA,CAAY,sDAAsD,CAAA,CAClE,MAAA,CAAO,CAAC,IAAA,KAAiB;AACxB,IAAA,MAAA;AAAA,MACE;AAAA,KAEF;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB,CAAC,CAAA;AAGH,EAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,EAAA,OAAO,GAAA;AACT","file":"chunk-I75CM2QF.js","sourcesContent":["/**\n * `skaile source manifest …` — curated `skaile.manifest.yaml` lifecycle for a\n * source you do NOT own. `init` generates a curated manifest from a discovery\n * run and stores it OUTSIDE the source, under the local store catalog\n * (`~/.skaile/store/manifests/<slug>.yaml`); `edit` opens it in `$EDITOR` and\n * re-validates on save. `source add`/`sync` then apply it as a read overlay\n * (see `source.ts` `refreshManifestCache`).\n *\n * `rebuild` refreshes a curated manifest after an upstream change (merge by\n * default — curation is sacred; `--overwrite` re-scans). `verify` is a\n * read-only integrity check (paths, declared hashes, schema, dep refs).\n * `publish`/`propose`/`yank` remain stubs — they need the store publish\n * endpoint (`POST /sources/<id>/manifest`), which lands in a follow-up.\n *\n * @docLink cli/commands/source#manifest\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n type AssetEntry,\n decodeSkaileManifest,\n encodeSkaileManifest,\n findWorkspaceRoot,\n parseAssetRef,\n resolveSourcePublisher,\n type SkPublishManifest,\n type SourceEntry,\n sourceCacheKey,\n sourceShortName,\n storeManifestSlug,\n workspaceConfigFilename,\n} from \"@skaile/workspaces/core\";\nimport { computeDeterministicHash, discoverAssetsInTree } from \"@skaile/workspaces/discovery\";\nimport { getStoreManifestsDir, writeCuratedManifest } from \"@skaile/workspaces/library\";\nimport type { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport { createFullRegistry } from \"../open-registry.ts\";\nimport {\n ensureClone,\n normalizeSourceUrl,\n readProjectSources,\n sourceClonePath,\n sourceMatchesKey,\n} from \"./source.ts\";\n\nconst NOT_WIRED_MSG =\n \"`skaile source manifest *` is scaffolded but not yet wired. \" +\n \"Server-side endpoint (`POST /sources/<id>/manifest`) lands in a follow-up PR.\";\n\nfunction notWired(verb: string): never {\n logErr(`${NOT_WIRED_MSG} (verb: source manifest ${verb})`);\n process.exit(2);\n}\n\n/**\n * Resolve a `source manifest` argument into a `{ url, slug, dest }` triple.\n *\n * Resolution order:\n * 1. A key matching an already-registered project source (stored URL, cache\n * key, or short slug).\n * 2. A collision-free **store slug** (`<host>__<owner>__<repo>`) whose\n * manifest already exists at `~/.skaile/store/manifests/<arg>.yaml`. This\n * MUST be tried before bare-name expansion: a bare name like `cli` would\n * otherwise expand (via `normalizeSourceUrl`) to the skaile-ai org and a\n * DIFFERENT slug than the one `init` wrote (e.g. `larksuite`). The slug is\n * the exact identifier `init`'s next-step hint prints back.\n * 3. Otherwise a git URL / `owner/repo` / bare name via `normalizeSourceUrl`.\n *\n * The clone dir is the same URL-keyed cache `source add` uses.\n */\nexport function resolveSourceArg(\n arg: string,\n projectDir: string,\n): { url: string; slug: string; dest: string; manifestFile: string } {\n const root = findWorkspaceRoot(projectDir);\n const registered: SourceEntry[] = root\n ? readProjectSources(path.join(root, workspaceConfigFilename()))\n : [];\n const match = registered.find((e) => sourceMatchesKey(e, arg));\n const bySlug = !match ? resolveByStoreSlug(arg) : undefined;\n const url = match ? match.url : (bySlug?.url ?? normalizeSourceUrl(arg));\n const slug = sourceShortName(url); // human-facing label\n const dest = sourceClonePath(sourceCacheKey(url));\n return { url, slug, dest, manifestFile: bySlug?.manifestFile ?? storeManifestPath(url) };\n}\n\n/**\n * When `arg` is a bare store slug (`<host>__<owner>__<repo>`) whose curated\n * manifest already exists on disk, recover the source URL from the slug and\n * point at that manifest file directly. Returns `undefined` when the arg isn't\n * a slug or has no manifest yet (fall back to URL normalization).\n */\nfunction resolveByStoreSlug(arg: string): { url: string; manifestFile: string } | undefined {\n // A slug is our own encoding — no path/URL sigils, at least the `<host>__…`\n // separator. Anything URL/owner-repo shaped is not a slug.\n if (!/^[\\w.-]+__[\\w.-]+/.test(arg) || /[/:\\\\]/.test(arg)) return undefined;\n const manifestFile = path.join(getStoreManifestsDir(), `${arg}.yaml`);\n if (!existsSync(manifestFile)) return undefined;\n // `<host>__<owner>__<repo>` → `https://<host>/<owner>/<repo>` — good enough to\n // key the clone dir + re-derive the same slug; the manifest file is what edit\n // actually opens.\n const [host, owner, repo] = arg.split(\"__\");\n const url = host && owner && repo ? `https://${host}/${owner}/${repo}` : arg;\n return { url, manifestFile };\n}\n\n/**\n * Absolute path to a source's curated store manifest. Keyed by the\n * collision-free {@link storeManifestSlug} (`<host>__<owner>__<repo>`) so\n * `orgA/cli` and `orgB/cli` don't share `cli.yaml`.\n */\nfunction storeManifestPath(url: string): string {\n return path.join(getStoreManifestsDir(), `${storeManifestSlug(url)}.yaml`);\n}\n\n/**\n * Directory-name segments that mark a test-fixture tree. `init`/`rebuild` drop\n * any asset whose repo-relative root contains one of these as an exact path\n * SEGMENT. Repos routinely ship fixture \"skills\" under such dirs (e.g.\n * `scripts/skill-format-check/tests`, `internal/qualitygate/skillscan/testdata/skills/lark-demo`)\n * that are not real, publishable assets.\n */\nconst TEST_FIXTURE_SEGMENTS = new Set([\n \"tests\",\n \"test\",\n \"__tests__\",\n \"testdata\",\n \"fixtures\",\n \"__fixtures__\",\n]);\n\n/**\n * True when an asset's repo-relative `root` sits under a test-fixture directory\n * (see {@link TEST_FIXTURE_SEGMENTS}). Conservative, not repo-specific — finer\n * curation (keeping a genuine fixture asset) stays the user's job via `edit`.\n * `init`/`rebuild`-path only; the general discovery walk (`source add`) is\n * untouched.\n */\nfunction isTestFixtureAsset(relativePath: string): boolean {\n const segments = relativePath.replace(/\\\\/g, \"/\").split(\"/\");\n return segments.some((s) => TEST_FIXTURE_SEGMENTS.has(s));\n}\n\n/**\n * `source manifest init <src>` — clone (if needed), run discovery, and write a\n * curated `skaile.manifest.yaml` to `~/.skaile/store/manifests/<slug>.yaml`.\n */\nasync function runInit(\n arg: string,\n opts: { projectDir: string; publisher?: string; dev?: boolean; force?: boolean },\n): Promise<void> {\n const projectDir = path.resolve(opts.projectDir);\n const { url, dest, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (existsSync(target) && !opts.force) {\n logWarn(\n `A curated manifest already exists at ${S.dim(target)}. ` +\n \"Edit it with `skaile source manifest edit`, refresh it after an upstream \" +\n \"change with `skaile source manifest rebuild`, or pass --force to regenerate.\",\n );\n return;\n }\n\n const entry: SourceEntry = { url };\n ensureClone(entry);\n\n const { assets, errors } = discoverCuratableAssets(dest, opts.dev ?? false);\n\n const publisher = opts.publisher ?? resolveSourcePublisher(dest) ?? sourceShortName(url);\n\n const written = writeCuratedManifest({\n manifestFile: target,\n publisher,\n assets,\n force: opts.force,\n // Init: every asset inherits the top-level repo `publisher`. Do NOT stamp a\n // per-asset publisher — glob discovery here runs without the resolved\n // publisher, so each DiscoveredAsset.publisher is only the clone directory\n // name, which would clobber the intended org/`--publisher` default with\n // junk per-asset overrides.\n inheritPublisher: true,\n });\n\n if (!written.wrote) {\n logWarn(\n `Curated manifest already exists at ${S.dim(target)} — not overwritten. ` +\n \"Pass --force to regenerate.\",\n );\n return;\n }\n\n logOk(`Wrote curated manifest with ${written.assetCount} assets to ${S.dim(target)}.`);\n // Echo the EXACT <src> the user passed so the printed commands actually run.\n // A bare short name would mis-resolve through `normalizeSourceUrl` (→ the\n // skaile-ai org, wrong slug); the original arg is what `resolveSourceArg`\n // maps back to this same manifest.\n logInfo(\n `Edit it with \\`skaile source manifest edit ${arg}\\`, then ` +\n `\\`skaile source add ${arg}\\` to consume it.`,\n );\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the manifest before consuming.`);\n }\n}\n\n/**\n * Run discovery over a clone and drop the test-fixture assets (see\n * {@link isTestFixtureAsset}). Shared by `init` and `rebuild` so both paths\n * produce an identical inventory from the same tree.\n */\nfunction discoverCuratableAssets(\n dest: string,\n includeDev: boolean,\n): { assets: ReturnType<typeof discoverAssetsInTree>[\"assets\"]; errors: string[] } {\n const result = discoverAssetsInTree(dest, {\n registry: createFullRegistry(),\n includeDev,\n });\n const assets = result.assets.filter((a) => !isTestFixtureAsset(a.relativePath));\n return { assets, errors: result.errors.map((e) => `${e.path}: ${e.error}`) };\n}\n\n/**\n * Best-effort `git pull --ff-only` on an existing clone. Never throws: a pull\n * failure (offline, diverged, detached) is warned and the caller continues with\n * the clone as-is.\n */\nfunction pullCloneFfOnly(dest: string): void {\n const res = spawnSync(\"git\", [\"-C\", dest, \"pull\", \"--ff-only\"], { stdio: \"pipe\" });\n if (res.status !== 0) {\n logWarn(\n \"git pull --ff-only failed — continuing with the existing clone \" +\n \"(it may be behind upstream).\",\n );\n }\n}\n\n/**\n * Repo-relative `root` path for a manifest asset entry — the merge match key\n * between an existing curated entry and a freshly-discovered asset. `root:`\n * entries use their declared path; a `files:`-only entry (rare for a curated\n * sidecar) falls back to the entry's dirname of the first file, else the name.\n */\nfunction entryRootKey(entry: AssetEntry): string {\n if (entry.root) return entry.root.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\");\n const files = entry.files;\n if (files && files.length > 0) {\n const first = typeof files[0] === \"string\" ? files[0] : files[0].path;\n const dir = path.posix.dirname(first.replace(/\\\\/g, \"/\"));\n return dir === \".\" ? entry.name : dir;\n }\n return entry.name;\n}\n\n/** Repo-relative `root` path a discovered asset maps to (matches init's writer). */\nfunction discoveredRootKey(relativePath: string): string {\n const dir = path.posix.dirname(relativePath.replace(/\\\\/g, \"/\"));\n return dir === \".\" ? path.posix.basename(relativePath.replace(/\\\\/g, \"/\")) : dir;\n}\n\n/** Human ref for reporting: `kind:name`. */\nfunction entryRef(entry: AssetEntry): string {\n return `${entry.kind}:${entry.name}`;\n}\n\n/**\n * `source manifest rebuild <src>` — refresh a curated manifest after the\n * upstream repo changed. MERGE is the default (curation is sacred); `--overwrite`\n * re-scans from scratch with `init --force` semantics.\n *\n * Merge algorithm (match by repo-relative `root` path):\n * - Existing entries whose root is STILL discovered → KEPT verbatim (all\n * hand-edits preserved).\n * - Existing entries whose root is GONE upstream → DROPPED (reported).\n * - Freshly-discovered assets not already in the manifest → NOT auto-added,\n * only REPORTED (a curated foreign sidecar must not silently absorb new\n * upstream skills). An asset the curator deliberately dropped stays dropped\n * because it is neither in the existing manifest nor re-added here.\n */\nasync function runRebuild(\n arg: string,\n opts: { projectDir: string; publisher?: string; dev?: boolean; overwrite?: boolean },\n): Promise<void> {\n const projectDir = path.resolve(opts.projectDir);\n const { url, dest, slug, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (!existsSync(target)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${S.dim(target)} — ` +\n \"run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n // Update the clone: clone if absent, else pull --ff-only (best-effort).\n const entry: SourceEntry = { url };\n const cloned = ensureClone(entry);\n if (!cloned) pullCloneFfOnly(dest);\n\n const { assets: freshAssets, errors } = discoverCuratableAssets(dest, opts.dev ?? false);\n\n if (opts.overwrite) {\n logWarn(\n \"--overwrite: replacing the curated manifest with a full fresh inventory. \" +\n \"All hand-curation (dropped assets, per-asset edits) is discarded.\",\n );\n const publisher = opts.publisher ?? resolveSourcePublisher(dest) ?? sourceShortName(url);\n const written = writeCuratedManifest({\n manifestFile: target,\n publisher,\n assets: freshAssets,\n force: true,\n inheritPublisher: true,\n });\n logOk(\n `Rebuilt curated manifest with ${written.assetCount} assets to ${S.dim(target)} (overwrite).`,\n );\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the manifest before consuming.`);\n }\n return;\n }\n\n // MERGE (default). `--publisher` only applies to the full re-derive path.\n if (opts.publisher) {\n logWarn(\n \"--publisher is ignored in merge mode (the curated publisher is preserved). \" +\n \"Use --overwrite to re-derive the publisher from a full re-scan.\",\n );\n }\n\n // Read the existing curated manifest and keep it as the base.\n const { manifest: existing } = decodeSkaileManifest(readFileSync(target, \"utf-8\"));\n const existingEntries = existing.assets ?? [];\n\n // Index fresh discovery by repo-relative root path.\n const freshByRoot = new Map<string, (typeof freshAssets)[number]>();\n for (const a of freshAssets) freshByRoot.set(discoveredRootKey(a.relativePath), a);\n\n const kept: AssetEntry[] = [];\n const dropped: string[] = [];\n for (const e of existingEntries) {\n if (freshByRoot.has(entryRootKey(e))) kept.push(e);\n else dropped.push(entryRef(e));\n }\n\n // Fresh assets not already curated → report as available, do NOT add.\n const existingRoots = new Set(existingEntries.map(entryRootKey));\n const newlyAvailable: string[] = [];\n for (const a of freshAssets) {\n if (!existingRoots.has(discoveredRootKey(a.relativePath))) {\n newlyAvailable.push(`${a.kind}:${a.name}`);\n }\n }\n\n const changed = dropped.length > 0;\n if (dropped.length > 0) {\n logWarn(`removed (gone upstream): ${dropped.sort().join(\", \")}`);\n }\n if (newlyAvailable.length > 0) {\n logInfo(\n `${newlyAvailable.length} new upstream asset(s) available (not added): ` +\n `${newlyAvailable.sort().join(\", \")} — add with \\`skaile source manifest edit ${arg}\\` if wanted`,\n );\n }\n\n if (!changed) {\n logOk(\"already up to date\");\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the source before re-consuming.`);\n }\n return;\n }\n\n const merged: SkPublishManifest = { ...existing, assets: kept };\n writeFileSync(target, encodeSkaileManifest(merged), \"utf-8\");\n logOk(\n `Rebuilt curated manifest: kept ${kept.length}, dropped ${dropped.length} → ${S.dim(target)}.`,\n );\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the source before re-consuming.`);\n }\n}\n\n/**\n * `source manifest verify <src>` — READ-ONLY integrity check of a curated\n * manifest against its clone. Writes nothing. Exit 0 when no errors; with\n * `--strict`, any warning also forces a nonzero exit.\n *\n * Per-asset checks:\n * - `root`/`files` paths still exist upstream (missing → error).\n * - A declared `sha256` recomputes to the same deterministic hash (mismatch → error).\n * - Schema decode diagnostics map to errors/warnings.\n * - Dependency refs parse via `parseAssetRef` (malformed → warning).\n */\nasync function runVerify(\n arg: string,\n opts: { projectDir: string; strict?: boolean },\n): Promise<void> {\n const projectDir = path.resolve(opts.projectDir);\n const { url, dest, slug, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (!existsSync(target)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${S.dim(target)} — ` +\n \"run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n // Ensure a clone exists to verify paths/hashes against (best-effort; no pull).\n ensureClone({ url });\n\n const text = readFileSync(target, \"utf-8\");\n const { manifest, diagnostics } = decodeSkaileManifest(text);\n\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // Schema diagnostics from the decoder.\n for (const d of diagnostics) {\n const line = `${d.code}: ${d.message}`;\n if (d.severity === \"error\") errors.push(line);\n else warnings.push(line);\n }\n\n const assets = manifest.assets ?? [];\n for (const entry of assets) {\n const ref = entryRef(entry);\n\n // Path existence: `root` dir and/or each `files[]` path.\n const relPaths: string[] = [];\n if (entry.root) relPaths.push(entry.root);\n if (entry.files) {\n for (const f of entry.files) relPaths.push(typeof f === \"string\" ? f : f.path);\n }\n if (relPaths.length === 0) relPaths.push(entry.name);\n for (const rel of relPaths) {\n if (!existsSync(path.join(dest, rel))) {\n errors.push(`${ref}: path not found upstream: ${rel}`);\n }\n }\n\n // Declared sha256 → recompute + compare, but ONLY for granular `files:`\n // entries. Discovery (`discover-manifest.ts`) anchors a `files:`-only entry\n // at the REPO ROOT and hashes the files VERBATIM as repo-relative strings\n // (the path is folded into the digest), so verify must hash the same way:\n // `assetRoot = dest`, files kept repo-relative — NOT rebased onto the root.\n // A `root:` entry cannot be verified this way (discovery hashes only the\n // per-kind filtered set, not the whole-dir walk), and the writer never emits\n // sha256 for `root:` entries, so skip the hash check for them.\n if (entry.sha256) {\n if (entry.files && entry.files.length > 0) {\n const hashFiles = entry.files.map((f) =>\n (typeof f === \"string\" ? f : f.path).replace(/\\\\/g, \"/\"),\n );\n const actual = computeDeterministicHash(dest, hashFiles);\n if (actual !== entry.sha256) {\n errors.push(\n `${ref}: sha256 mismatch (declared ${entry.sha256.slice(0, 12)}…, got ${actual.slice(0, 12)}…)`,\n );\n }\n } else {\n warnings.push(\n `${ref}: declared sha256 on a root:-mode entry is not verifiable (discovery hashes only the per-kind filtered set) — skipped`,\n );\n }\n }\n\n // Dependency refs parse.\n for (const dep of entry.dependencies ?? []) {\n try {\n parseAssetRef(dep);\n } catch (err) {\n warnings.push(\n `${ref}: malformed dependency \"${dep}\": ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n }\n\n for (const w of warnings) logWarn(w);\n for (const e of errors) logErr(e);\n\n if (errors.length === 0) {\n logOk(`verified ${assets.length} asset(s).`);\n } else {\n logErr(`${errors.length} issue(s).`);\n }\n\n const failStrict = opts.strict && warnings.length > 0;\n if (errors.length > 0 || failStrict) process.exit(1);\n}\n\n/**\n * Split a `$VISUAL`/`$EDITOR` value into `{ command, args }` and append the file\n * as the final arg. The env value is a full command line, not a bare binary —\n * `EDITOR=\"code --wait\"` must spawn `code` with `[\"--wait\", <file>]`, and\n * `EDITOR=code` (which returns before save) is the user's problem, not ours.\n * A whitespace split covers the common editors (`code --wait`, `code -w`,\n * `subl -w`, `vi`); paths with embedded spaces are not supported (rare for an\n * editor binary and out of scope). Falls back to `vi` when unset/empty.\n *\n * @docLink cli/commands/source#manifest-edit\n */\nexport function resolveEditorCommand(\n editorEnv: string | undefined,\n target: string,\n): { command: string; args: string[] } {\n const parts = (editorEnv ?? \"\").trim().split(/\\s+/).filter(Boolean);\n const [command, ...rest] = parts.length > 0 ? parts : [\"vi\"];\n return { command: command as string, args: [...rest, target] };\n}\n\n/** Minimal spawn contract runEdit needs — lets tests inject a fake. */\ntype SpawnLike = (\n command: string,\n args: string[],\n opts: { stdio: \"inherit\" },\n) => { status: number | null };\n\n/**\n * `source manifest edit <src>` — open the curated store manifest in `$EDITOR`\n * and re-validate on save. Warnings are surfaced but never hard-fail.\n *\n * `spawn` is injectable so tests can assert the argv without launching a real\n * editor; production passes the default `spawnSync`.\n */\nexport function runEdit(\n arg: string,\n opts: { projectDir: string },\n spawn: SpawnLike = spawnSync as unknown as SpawnLike,\n): void {\n const projectDir = path.resolve(opts.projectDir);\n const { slug, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (!existsSync(target)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${target}. ` +\n \"Run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n const { command, args } = resolveEditorCommand(process.env.VISUAL || process.env.EDITOR, target);\n const res = spawn(command, args, { stdio: \"inherit\" });\n if (res.status !== 0 && res.status !== null) {\n logErr(`Editor exited with status ${res.status}.`);\n process.exit(1);\n }\n\n // Re-validate the saved file; surface diagnostics as warnings, don't hard-fail.\n const { diagnostics } = decodeSkaileManifest(readFileSync(target, \"utf-8\"));\n const errors = diagnostics.filter((d) => d.severity === \"error\");\n const warnings = diagnostics.filter((d) => d.severity !== \"error\");\n if (errors.length > 0) {\n for (const d of errors) logErr(`${d.code}: ${d.message}`);\n logWarn(\"Manifest has errors — fix them before `skaile source add` will consume it.\");\n } else if (warnings.length > 0) {\n for (const d of warnings) logWarn(`${d.code}: ${d.message}`);\n logOk(\"Saved (with warnings).\");\n } else {\n logOk(\"Saved.\");\n }\n}\n\n/**\n * Append the `manifest` sub-tree to a `source` command.\n *\n * Called from `makeSourceCommand()` in `source.ts`.\n */\nexport function addSourceManifestCommands(src: Command): void {\n // enablePositionalOptions so options on the leaf verb (`source manifest init\n // --publisher …`) route to that verb instead of being rejected by `manifest`.\n const manifest = src\n .command(\"manifest\")\n .description(\"Curated manifest lifecycle for a source\")\n .enablePositionalOptions();\n\n manifest\n .command(\"init <src>\")\n .description(\"Generate a curated manifest for a source (stored in the local store catalog)\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--publisher <name>\", \"Override the publisher (default: source's GitHub org)\")\n .option(\"--dev\", \"Include assets under the source's dev_paths\", false)\n .option(\"--force\", \"Overwrite an existing curated manifest\", false)\n .action((arg, opts) => runInit(arg, opts));\n\n manifest\n .command(\"edit <src>\")\n .description(\"Open the curated manifest in $EDITOR and re-validate on save\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .action((arg, opts) => runEdit(arg, opts));\n\n manifest\n .command(\"rebuild <src>\")\n .description(\n \"Refresh a curated manifest after an upstream change (merge by default: \" +\n \"keeps curation, drops assets gone upstream, reports new ones without adding)\",\n )\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--publisher <name>\", \"Override the publisher (--overwrite only)\")\n .option(\"--dev\", \"Include assets under the source's dev_paths\", false)\n .option(\"--overwrite\", \"Discard curation and re-scan the full inventory\", false)\n .action((arg, opts) => runRebuild(arg, opts));\n\n manifest\n .command(\"verify <src>\")\n .description(\"Verify hashes, deps, and schema (read-only)\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--strict\", \"Fail on advisory checks (warnings force a nonzero exit)\", false)\n .action((arg, opts) => runVerify(arg, opts));\n\n manifest\n .command(\"publish <src>\")\n .description(\"Push the curated sidecar manifest and publish it to the store\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--as <namespace>\", \"Publisher namespace (default: your store username)\")\n .option(\"--sidecar-repo <url>\", \"Public GitHub repo you own to hold the curated manifest\")\n .option(\"--ref <gitref>\", \"Foreign source ref to ingest (branch/sha; default: main)\")\n .option(\"--dry-run\", \"Print the publish plan without pushing or calling the store\", false)\n .action(async (arg, opts) => {\n const { runPublish } = await import(\"./source-manifest-publish.ts\");\n await runPublish(arg, opts);\n });\n\n manifest\n .command(\"propose <src>\")\n .description(\"Open a PR to upstream with the sidecar manifest\")\n .action(() => notWired(\"propose\"));\n\n manifest\n .command(\"yank <src>\")\n .description(\"Retract the source's published assets from the store\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--asset <ref>\", \"Yank only the asset matching this ref/name\")\n .action(async (arg, opts) => {\n const { runYank } = await import(\"./source-manifest-publish.ts\");\n await runYank(arg, opts);\n });\n}\n","/**\n * `skaile source …` — manage github sources for the current project.\n *\n * A *source* is a third-party github repo of AI assets. The project's\n * `skaile.yaml` `sources:` array is the source of truth for which sources\n * this project uses. The clone itself lives at\n * `~/.skaile/cache/sources/<host>/<owner>/<repo>/` (machine-global cache, shared\n * across projects, URL-keyed so cross-org repos never collide), and the manifest is\n * mirrored into `~/.skaile/index.db` (machine-global manifest cache).\n *\n * @docLink cli/commands/source\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, renameSync, rmSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n findWorkspaceRoot,\n getGlobalCacheDir,\n type SourceEntry,\n sourceCacheKey,\n sourceShortName,\n storeManifestSlug,\n WorkspaceYamlEditor,\n workspaceConfigFilename,\n} from \"@skaile/workspaces/core\";\nimport { getStoreManifestsDir, LocalCatalogSource } from \"@skaile/workspaces/library\";\nimport * as p from \"@clack/prompts\";\nimport { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport { openLibraryManager } from \"../open-library.ts\";\nimport { createFullRegistry } from \"../open-registry.ts\";\nimport { addSourceManifestCommands } from \"./source-manifest.ts\";\n\n/**\n * Clone dir for one source cache key (`<host>/<owner>/<repo>`). Exported for the\n * cache-path regression test. Callers pass `sourceCacheKey(url)`.\n */\nexport function sourceClonePath(key: string): string {\n return path.join(getGlobalCacheDir(), key);\n}\n\nconst SKAILE_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\nconst LEGACY_SOURCE_CONFIG_FILENAME = \".skaile-source.yaml\";\n\n/**\n * Whether a manifest-cache refresh actually failed to index something. Keyed on\n * `errors`, NOT on `assetsUpdated < assetsFound`: the discovery walk counts\n * presets (and other intentionally-not-cataloged kinds) toward `assetsFound` but\n * never upserts them, so a source shipping a `.preset.yaml` would otherwise read\n * as a partial failure — false `! N asset(s) failed to index` + exit 1 — with\n * zero real errors.\n */\nexport function indexingHadFailures(result: { errors: string[] }): boolean {\n return result.errors.length > 0;\n}\n\n/**\n * A clone that ships only the legacy `.skaile-source.yaml` (no\n * `skaile.manifest.yaml`) has its declared `publisher_default` silently ignored\n * — discovery only reads `skaile.manifest.yaml`, so publisher resolution falls\n * back to the first path segment. Surface a hint so the author can fix it.\n */\nexport function legacySourceConfigHint(dest: string): string | undefined {\n const hasLegacy = existsSync(path.join(dest, LEGACY_SOURCE_CONFIG_FILENAME));\n const hasManifest = existsSync(path.join(dest, SKAILE_MANIFEST_FILENAME));\n if (hasLegacy && !hasManifest) {\n return (\n `This source ships a legacy ${LEGACY_SOURCE_CONFIG_FILENAME} but no ` +\n `${SKAILE_MANIFEST_FILENAME}; its declared publisher is ignored and assets ` +\n `are published under their first path segment. Add a ${SKAILE_MANIFEST_FILENAME} ` +\n `(\\`skaile source manifest init\\`) to set the publisher and asset inventory.`\n );\n }\n return undefined;\n}\n\n/**\n * Normalize a `source add` argument into a clonable git URL. Full URLs and\n * scp-style (`git@host:…`) specs pass through unchanged; an `owner/repo`\n * shorthand and a bare repo name expand to GitHub over SSH — a bare name\n * defaults to the `skaile-ai` org (`git@github.com:skaile-ai/<name>.git`).\n */\nexport function normalizeSourceUrl(input: string): string {\n const s = input.trim();\n if (/^(?:https?|git|ssh|file):\\/\\//.test(s) || /^git@/.test(s)) return s;\n const repo = s.replace(/\\.git$/, \"\");\n if (/^[\\w.-]+\\/[\\w.-]+$/.test(repo)) return `git@github.com:${repo}.git`;\n if (/^[\\w.-]+$/.test(repo)) return `git@github.com:skaile-ai/${repo}.git`;\n return s;\n}\n\n/**\n * Match a stored source against a user-supplied key. Mirrors the shortcut\n * expansion `source add` applies (`normalizeSourceUrl`) so any form that `add`\n * accepted — bare name, `owner/repo`, `.git`-suffixed, full URL — also resolves\n * at `sync`/`show`/`remove` time, not just the raw stored URL or derived slug.\n */\nexport function sourceMatchesKey(entry: SourceEntry, key: string): boolean {\n if (entry.url === key) return true;\n if (sourceCacheKey(entry.url) === key || sourceShortName(entry.url) === key) return true;\n return entry.url === normalizeSourceUrl(key);\n}\n\n/**\n * Find an already-registered source that maps to the same cache key as `url`\n * but is stored under a *different* URL string (e.g. the `.git`-suffixed or\n * scp form of the same remote). Two such entries would fight over one clone\n * dir, so `source add` rejects the ambiguity. Returns the colliding entry, or\n * `undefined` when the URL is unique or only matches an exact-string duplicate\n * (which `setSource` updates in place).\n */\nexport function findCacheKeyCollision(\n sources: SourceEntry[],\n url: string,\n): SourceEntry | undefined {\n const key = sourceCacheKey(url);\n return sources.find((s) => s.url !== url && sourceCacheKey(s.url) === key);\n}\n\nfunction requireProjectYamlPath(): string {\n const root = findWorkspaceRoot(process.cwd());\n if (!root) {\n logErr(\n \"No skaile.yaml found in the current directory or any parent. \" + \"Run `skaile init` first.\",\n );\n process.exit(1);\n }\n return path.join(root, workspaceConfigFilename());\n}\n\nexport function readProjectSources(yamlPath: string): SourceEntry[] {\n if (!existsSync(yamlPath)) return [];\n try {\n return WorkspaceYamlEditor.load(yamlPath).getSources();\n } catch (err) {\n logErr(`Could not read ${yamlPath}: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n}\n\n/**\n * Clone the source if its clone directory does not yet exist. When `force` is\n * set, the existing clone is replaced by a fresh checkout. Returns true when a\n * clone happened. The cache slug is derived from the URL.\n *\n * A `--force` re-clone moves the old clone aside first and only deletes it once\n * the fresh clone succeeds — so a failed re-clone restores the previous clone\n * rather than leaving the source registered with no cache behind it.\n */\nexport function ensureClone(entry: SourceEntry, opts: { force?: boolean } = {}): boolean {\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n let backup: string | undefined;\n if (existsSync(dest)) {\n if (!opts.force) return false;\n backup = `${dest}.bak`;\n rmSync(backup, { recursive: true, force: true });\n renameSync(dest, backup);\n }\n mkdirSync(path.dirname(dest), { recursive: true });\n const args = [\"clone\", entry.url, dest];\n // `pin` may be a branch/tag; pass it as the clone branch when present.\n if (entry.pin) args.splice(1, 0, \"--branch\", entry.pin);\n const clone = spawnSync(\"git\", args, { stdio: \"inherit\" });\n if (clone.status !== 0) {\n if (backup) {\n rmSync(dest, { recursive: true, force: true });\n renameSync(backup, dest);\n }\n logErr(`git clone failed for ${entry.url}`);\n process.exit(1);\n }\n if (backup) rmSync(backup, { recursive: true, force: true });\n return true;\n}\n\n/**\n * Refresh the machine-global manifest cache for `entry` by running discovery\n * and upserting AssetDefinitions into `~/.skaile/index.db`. Creates the\n * libraries-table cache row if missing (ownership: reader = cache state).\n */\nasync function refreshManifestCache(\n entry: SourceEntry,\n includeDev = false,\n): Promise<{\n assetsFound: number;\n assetsUpdated: number;\n errors: string[];\n advisories: string[];\n}> {\n const { manager, library, close } = await openLibraryManager();\n try {\n const name = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n const existing = (await manager.listLibraries()).find((l) => l.name === name);\n const lib =\n existing ??\n (await manager.addLibrary({\n name,\n path: dest,\n backend: \"git\",\n backendConfig: { url: entry.url, branch: entry.pin ?? \"main\", authHint: \"ssh\" },\n ownership: \"reader\",\n }));\n // Curated overlay: a `skaile source manifest init` writes a curated\n // manifest to the local store at `~/.skaile/store/manifests/<slug>.yaml`.\n // When present, route discovery through it so the curated publisher +\n // asset inventory win over the upstream repo's raw glob discovery. Keyed by\n // the collision-free `storeManifestSlug` (matches the init writer + resolver).\n const overlayFile = path.join(getStoreManifestsDir(), `${storeManifestSlug(entry.url)}.yaml`);\n const catalog = new LocalCatalogSource(library, lib.id, dest, createFullRegistry(), {\n sidecarManifestFile: existsSync(overlayFile) ? overlayFile : undefined,\n });\n const result = await catalog.sync({ includeDev });\n await library.syncSource(lib.id);\n return result;\n } finally {\n close();\n }\n}\n\n/**\n * Auto-sync hook for `skaile search` on an unsynced workspace. Clones/pulls and\n * re-indexes every source declared in the project's `skaile.yaml`, then returns\n * whether the manifest cache may have changed (caller re-queries on `true`).\n *\n * Unlike `source sync`, this degrades gracefully — a clone/pull/index failure is\n * logged and skipped (never `process.exit`) so a failed auto-sync falls back to\n * the \"run sync first\" hint rather than killing the search. Returns `false`\n * (silently, no announce) when no sources are declared. Callers must guard\n * air-gapped mode themselves — this always touches the network.\n */\nexport async function autoSyncForSearch(projectDir: string): Promise<boolean> {\n const root = findWorkspaceRoot(projectDir);\n if (!root) return false;\n if (readProjectSources(path.join(root, workspaceConfigFilename())).length === 0) return false;\n\n logInfo(\"sources not synced — syncing now…\");\n const { synced } = await syncProjectSources(projectDir);\n return synced > 0;\n}\n\n/**\n * Clone-or-pull every source declared in the project's `skaile.yaml`, then\n * refresh its manifest cache. Shared by `autoSyncForSearch` and `skaile update`\n * (the latter offers it behind a confirm) so a re-deploy can see upstream\n * commits — `update` re-deploys against the local source cache, which is\n * otherwise frozen at the commit captured when the source was first cloned.\n *\n * Graceful by design: a clone/pull/index failure for one source is logged and\n * skipped (never `process.exit`), so a single bad remote can't abort the run.\n * Existing clones are advanced with `git pull --ff-only` (no `--depth=1`, unlike\n * the installer's `pullRepo`, so it fast-forwards instead of tripping the\n * shallow-divergence path). Returns a count summary for the caller to report.\n */\nexport async function syncProjectSources(\n projectDir: string,\n opts: { dev?: boolean } = {},\n): Promise<{ total: number; synced: number; failed: number }> {\n const root = findWorkspaceRoot(projectDir) ?? projectDir;\n const sources = readProjectSources(path.join(root, workspaceConfigFilename()));\n let synced = 0;\n let failed = 0;\n for (const entry of sources) {\n const slug = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n try {\n // Quiet git — the sync is a preparatory step; keep progress bars out of\n // the foreground output (spinner / install result).\n if (!existsSync(dest)) {\n mkdirSync(path.dirname(dest), { recursive: true });\n const args = [\"clone\", entry.url, dest];\n if (entry.pin) args.splice(1, 0, \"--branch\", entry.pin);\n const clone = spawnSync(\"git\", args, { stdio: \"ignore\" });\n if (clone.status !== 0) {\n logWarn(`${slug}: git clone failed, skipping.`);\n failed++;\n continue;\n }\n } else {\n const pull = spawnSync(\"git\", [\"pull\", \"--ff-only\"], { cwd: dest, stdio: \"ignore\" });\n if (pull.status !== 0) {\n logWarn(`${slug}: git pull failed, skipping manifest refresh.`);\n failed++;\n continue;\n }\n }\n const result = await refreshManifestCache(entry, opts.dev);\n for (const err of result.errors) logWarn(`${slug}: ${err}`);\n for (const advisory of result.advisories) logInfo(`${slug}: ${advisory}`);\n synced++;\n } catch (err) {\n logWarn(`${slug}: sync failed — ${err instanceof Error ? err.message : String(err)}`);\n failed++;\n }\n }\n return { total: sources.length, synced, failed };\n}\n\n/** Remove the libraries-table cache row and (optionally) the clone bytes. */\nasync function dropManifestCache(url: string, purgeClone: boolean): Promise<void> {\n const name = sourceShortName(url);\n const { manager, close } = await openLibraryManager();\n try {\n const existing = (await manager.listLibraries()).find((l) => l.name === name);\n if (existing) {\n await manager.removeLibrary(name, { purge: false });\n }\n } finally {\n close();\n }\n if (purgeClone) {\n const dest = sourceClonePath(sourceCacheKey(url));\n if (existsSync(dest)) rmSync(dest, { recursive: true, force: true });\n }\n}\n\nexport function makeSourceCommand(): Command {\n const cmd = new Command(\"source\").description(\n \"Manage github sources for the current project (recorded in skaile.yaml)\",\n );\n\n // ── source add ──────────────────────────────────────────────────────────\n cmd\n .command(\"add <source>\")\n .description(\n \"Clone a github repo and register it in this project's skaile.yaml. \" +\n \"<source> may be a full git URL, an owner/repo shorthand, or a bare \" +\n \"name (→ git@github.com:skaile-ai/<name>.git).\",\n )\n .option(\"--name <slug>\", \"[deprecated] no-op — the source entry stores only the URL\")\n .option(\"--pin <ref>\", \"Pin a branch, tag, or 40-char SHA\")\n .option(\"--branch <branch>\", \"[deprecated] alias for --pin\")\n .option(\"--force\", \"Remove an existing clone and re-clone\", false)\n .option(\"--dev\", \"Also index dev-only assets under the source's dev_paths\", false)\n .action(\n async (\n source: string,\n opts: {\n name?: string;\n pin?: string;\n branch?: string;\n force?: boolean;\n dev?: boolean;\n },\n ) => {\n const url = normalizeSourceUrl(source);\n const yamlPath = requireProjectYamlPath();\n\n // A different URL string that maps to the same cache key (e.g. the\n // `.git`-suffixed or scp form of an already-registered remote) would\n // fight over one clone dir. setSource only dedupes exact strings, so\n // reject the ambiguous collision here instead of silently shadowing.\n const collision = findCacheKeyCollision(readProjectSources(yamlPath), url);\n if (collision) {\n logErr(\n `\"${url}\" maps to the same cache key (${sourceCacheKey(url)}) as ` +\n `already-registered \"${collision.url}\". Remove that source first ` +\n `(skaile source remove) or re-use its exact URL to update it.`,\n );\n process.exitCode = 1;\n return;\n }\n\n if (opts.name) {\n logWarn(\n \"the --name flag is deprecated; the source entry now stores only the URL \" +\n \"(the cache slug is derived from it).\",\n );\n }\n const pin = opts.pin ?? opts.branch;\n const slug = sourceShortName(url);\n const entry: SourceEntry = { url };\n if (pin) entry.pin = pin;\n\n const dest = sourceClonePath(sourceCacheKey(url));\n const preexisting = existsSync(dest);\n // Clone/validate the repo BEFORE touching skaile.yaml — a failed clone\n // (repo not found, bad URL, network error) hard-exits in ensureClone, so\n // the entry is only ever recorded once the source is known-good.\n const cloned = ensureClone(entry, { force: opts.force });\n if (!cloned) {\n logOk(`Reusing cached clone at ${dest}`);\n } else if (preexisting) {\n logOk(`Re-cloned ${url} → ${dest}`);\n } else {\n logOk(`Cloned ${url} → ${dest}`);\n }\n\n const editor = WorkspaceYamlEditor.load(yamlPath);\n editor.setSource(entry);\n editor.save();\n\n const result = await refreshManifestCache(entry, opts.dev);\n const failed = indexingHadFailures(result);\n const indexedMsg = `Indexed ${result.assetsUpdated} of ${result.assetsFound} asset(s) from \"${slug}\".`;\n if (failed) {\n logWarn(indexedMsg);\n } else {\n logOk(indexedMsg);\n }\n for (const err of result.errors) logWarn(err);\n for (const advisory of result.advisories) logInfo(advisory);\n\n const legacyHint = legacySourceConfigHint(dest);\n if (legacyHint) logWarn(legacyHint);\n\n const where = path.relative(process.cwd(), yamlPath);\n if (failed) {\n // The entry IS recorded in skaile.yaml, but indexing did not fully\n // succeed — don't present it as a clean success.\n logWarn(\n `Source \"${slug}\" registered in ${where}, but ${result.errors.length} ` +\n `asset(s) failed to index (see above). Fix the cause, then re-run ` +\n `\\`skaile source sync ${slug}\\`.`,\n );\n process.exitCode = 1;\n } else {\n logOk(`Source \"${slug}\" registered in ${where}.`);\n }\n },\n );\n\n // ── source list ─────────────────────────────────────────────────────────\n cmd\n .command(\"list\")\n .description(\"List sources registered in this project's skaile.yaml\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts: { json?: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const sources = readProjectSources(yamlPath);\n if (opts.json) return console.log(JSON.stringify(sources, null, 2));\n if (sources.length === 0) {\n logInfo(\"No sources in skaile.yaml. Run `skaile source add <git-url>` to register one.\");\n return;\n }\n console.log();\n console.log(S.heading(\" Sources\"));\n for (const s of sources) {\n const slug = sourceShortName(s.url);\n const cached = existsSync(sourceClonePath(sourceCacheKey(s.url)))\n ? \"\"\n : S.warn(\" (not cached)\");\n console.log(` ${S.cmd(slug.padEnd(24))} ${S.dim(s.url)}${cached}`);\n }\n console.log(`\\n ${S.dim(`${sources.length} source(s)`)}\\n`);\n });\n\n // ── source show ─────────────────────────────────────────────────────────\n cmd\n .command(\"show <name-or-url>\")\n .description(\"Show details for a source (matched by URL or derived slug)\")\n .action(async (key: string) => {\n const yamlPath = requireProjectYamlPath();\n const entry = readProjectSources(yamlPath).find((s) => sourceMatchesKey(s, key));\n if (!entry) {\n logErr(`No source matching \"${key}\" in ${yamlPath}.`);\n process.exit(1);\n }\n const slug = sourceShortName(entry.url);\n const clonePath = sourceClonePath(sourceCacheKey(entry.url));\n console.log(\n JSON.stringify(\n {\n ...entry,\n slug,\n clonePath,\n cached: existsSync(clonePath),\n },\n null,\n 2,\n ),\n );\n });\n\n // ── source remove ───────────────────────────────────────────────────────\n cmd\n .command(\"remove <name-or-url>\")\n .description(\"Remove a source from this project's skaile.yaml (matched by URL or slug)\")\n .option(\"--purge\", \"Also delete the cached clone from ~/.skaile/cache/sources/\", false)\n .action(async (key: string, opts: { purge: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const editor = WorkspaceYamlEditor.load(yamlPath);\n // Resolve to the stored URL (entries are keyed by url in the editor).\n const match = editor.getSources().find((s) => sourceMatchesKey(s, key));\n if (!match) {\n logErr(`No source matching \"${key}\" in ${yamlPath}.`);\n process.exit(1);\n }\n const slug = sourceShortName(match.url);\n editor.removeSource(match.url);\n editor.save();\n await dropManifestCache(match.url, opts.purge);\n logOk(\n opts.purge\n ? `Removed source \"${slug}\" and purged its clone.`\n : `Removed source \"${slug}\" from skaile.yaml (clone left in ~/.skaile/cache/sources/ — pass --purge to remove it, or run \\`skaile cache clean\\`).`,\n );\n });\n\n // ── source sync ─────────────────────────────────────────────────────────\n cmd\n .command(\"sync [name]\")\n .description(\"Pull upstream changes and refresh the manifest cache\")\n .option(\"--dev\", \"Also index dev-only assets under each source's dev_paths\", false)\n .option(\"--all\", \"Sync every source without prompting\", false)\n .action(async (key: string | undefined, opts: { dev?: boolean; all?: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const sources = readProjectSources(yamlPath);\n if (sources.length === 0) {\n logInfo(\"No sources in skaile.yaml.\");\n return;\n }\n\n let targets: SourceEntry[];\n if (key) {\n targets = sources.filter((s) => sourceMatchesKey(s, key));\n if (targets.length === 0) {\n logInfo(`No source matching \"${key}\".`);\n return;\n }\n } else if (opts.all || sources.length === 1 || !process.stdin.isTTY) {\n // --all, a single source, or a non-interactive shell: sync everything.\n targets = sources;\n } else {\n const selected = await p.multiselect({\n message: \"Select sources to sync\",\n options: sources.map((s) => ({\n value: s.url,\n label: sourceShortName(s.url),\n hint: s.url,\n })),\n required: true,\n });\n if (p.isCancel(selected)) {\n p.cancel(\"Cancelled.\");\n return;\n }\n const picked = new Set(selected as string[]);\n targets = sources.filter((s) => picked.has(s.url));\n }\n for (const entry of targets) {\n const slug = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n if (!existsSync(dest)) {\n ensureClone(entry);\n logOk(`${slug}: cloned to ${dest}.`);\n } else {\n const pull = spawnSync(\"git\", [\"pull\", \"--ff-only\"], { cwd: dest, stdio: \"inherit\" });\n if (pull.status !== 0) {\n logWarn(`${slug}: git pull failed, skipping manifest refresh.`);\n continue;\n }\n }\n const result = await refreshManifestCache(entry, opts.dev);\n const failed = indexingHadFailures(result);\n const indexedMsg = `${slug}: indexed ${result.assetsUpdated} of ${result.assetsFound} asset(s).`;\n if (failed) {\n logWarn(indexedMsg);\n process.exitCode = 1;\n } else {\n logOk(indexedMsg);\n }\n for (const err of result.errors) logWarn(`${slug}: ${err}`);\n for (const advisory of result.advisories) logInfo(`${slug}: ${advisory}`);\n const legacyHint = legacySourceConfigHint(dest);\n if (legacyHint) logWarn(`${slug}: ${legacyHint}`);\n }\n });\n\n // ── source patch / propose (stubs) ──────────────────────────────────────\n cmd\n .command(\"patch <ref>\")\n .description(\"Extract an asset for editing against the source\")\n .action((_ref: string) => {\n logErr(\n \"`skaile source patch` is scaffolded but not yet wired. \" +\n \"The patch flow lands in a follow-up PR.\",\n );\n process.exit(2);\n });\n\n cmd\n .command(\"propose <ref>\")\n .description(\"Open a PR with the patch against the source upstream\")\n .action((_ref: string) => {\n logErr(\n \"`skaile source propose` is scaffolded but not yet wired. \" +\n \"The propose flow lands in a follow-up PR.\",\n );\n process.exit(2);\n });\n\n // ── source manifest * ───────────────────────────────────────────────────\n addSourceManifestCommands(cmd);\n\n return cmd;\n}\n"]}