@dreamlake/dreamlake-cli 0.88.1 → 0.89.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 (535) hide show
  1. package/dist/api/access.d.ts +83 -0
  2. package/dist/api/access.js +77 -0
  3. package/dist/api/agent.d.ts +156 -0
  4. package/dist/api/agent.js +111 -0
  5. package/dist/api/browser.d.ts +90 -0
  6. package/dist/api/browser.js +102 -0
  7. package/dist/api/client.d.ts +53 -0
  8. package/dist/api/client.js +102 -0
  9. package/dist/api/common.d.ts +28 -0
  10. package/dist/api/common.js +16 -0
  11. package/dist/api/content.d.ts +195 -0
  12. package/dist/api/content.js +147 -0
  13. package/dist/api/execution.d.ts +84 -0
  14. package/dist/api/execution.js +73 -0
  15. package/dist/api/http.d.ts +19 -0
  16. package/dist/api/http.js +66 -0
  17. package/dist/api/index.d.ts +2330 -0
  18. package/dist/api/index.js +114 -0
  19. package/dist/api/infra.d.ts +2 -0
  20. package/dist/api/infra.js +2 -0
  21. package/dist/api/jobs.d.ts +2 -0
  22. package/dist/api/jobs.js +2 -0
  23. package/dist/api/layout.d.ts +2 -0
  24. package/dist/api/layout.js +2 -0
  25. package/dist/api/library-edit.d.ts +3 -0
  26. package/dist/api/library-edit.js +3 -0
  27. package/dist/api/library-manifest.d.ts +2 -0
  28. package/dist/api/library-manifest.js +2 -0
  29. package/dist/api/note-character-plan.d.ts +2 -0
  30. package/dist/api/note-character-plan.js +2 -0
  31. package/dist/api/note-editing.d.ts +2 -0
  32. package/dist/api/note-editing.js +2 -0
  33. package/dist/api/note-edits.d.ts +21 -0
  34. package/dist/api/note-edits.js +10 -0
  35. package/dist/api/note-events.d.ts +5 -0
  36. package/dist/api/note-events.js +11 -0
  37. package/dist/api/note-files.d.ts +75 -0
  38. package/dist/api/note-files.js +65 -0
  39. package/dist/api/note-html-read.d.ts +2 -0
  40. package/dist/api/note-html-read.js +2 -0
  41. package/dist/api/note-html.d.ts +2 -0
  42. package/dist/api/note-html.js +2 -0
  43. package/dist/api/note-toc.d.ts +2 -0
  44. package/dist/api/note-toc.js +2 -0
  45. package/dist/api/notes.d.ts +304 -0
  46. package/dist/api/notes.js +181 -0
  47. package/dist/api/open-resources.d.ts +27 -0
  48. package/dist/api/open-resources.js +102 -0
  49. package/dist/api/ownership.d.ts +12 -0
  50. package/dist/api/ownership.js +24 -0
  51. package/dist/api/platform.d.ts +83 -0
  52. package/dist/api/platform.js +56 -0
  53. package/dist/api/presigned-transfer.d.ts +2 -0
  54. package/dist/api/presigned-transfer.js +2 -0
  55. package/dist/api/registered-runs.d.ts +48 -0
  56. package/dist/api/registered-runs.js +33 -0
  57. package/dist/api/sessions.d.ts +299 -0
  58. package/dist/api/sessions.js +105 -0
  59. package/dist/api/storage.d.ts +46 -0
  60. package/dist/api/storage.js +34 -0
  61. package/dist/api/streams.d.ts +18 -0
  62. package/dist/api/streams.js +70 -0
  63. package/dist/api/vault.d.ts +93 -0
  64. package/dist/api/vault.js +79 -0
  65. package/dist/api/workspace.d.ts +180 -0
  66. package/dist/api/workspace.js +146 -0
  67. package/dist/cli/agent-identity.d.ts +4 -0
  68. package/dist/cli/agent-identity.js +21 -0
  69. package/dist/cli/agents/identity.d.ts +50 -0
  70. package/dist/cli/agents/identity.js +105 -0
  71. package/dist/cli/agents/index.d.ts +31 -0
  72. package/dist/cli/agents/index.js +580 -0
  73. package/dist/cli/agents/manage.d.ts +43 -0
  74. package/dist/cli/agents/manage.js +376 -0
  75. package/dist/cli/agents/spec.d.ts +104 -0
  76. package/dist/cli/agents/spec.js +280 -0
  77. package/dist/cli/agents/web.d.ts +7 -0
  78. package/dist/cli/agents/web.js +109 -0
  79. package/dist/cli/artifact/incremental.d.ts +21 -0
  80. package/dist/cli/artifact/incremental.js +80 -0
  81. package/dist/cli/artifact/index.d.ts +52 -0
  82. package/dist/cli/artifact/index.js +405 -0
  83. package/dist/cli/artifact/meta.d.ts +69 -0
  84. package/dist/cli/artifact/meta.js +189 -0
  85. package/dist/cli/auth/commands.d.ts +29 -0
  86. package/dist/cli/auth/commands.js +327 -0
  87. package/dist/cli/auth/constants.d.ts +13 -0
  88. package/dist/cli/auth/constants.js +18 -0
  89. package/dist/cli/auth/credentials.d.ts +37 -0
  90. package/dist/cli/auth/credentials.js +155 -0
  91. package/dist/cli/auth/device-flow.d.ts +32 -0
  92. package/dist/cli/auth/device-flow.js +154 -0
  93. package/dist/cli/auth/device-secret.d.ts +6 -0
  94. package/dist/cli/auth/device-secret.js +26 -0
  95. package/dist/cli/auth/machine.d.ts +15 -0
  96. package/dist/cli/auth/machine.js +126 -0
  97. package/dist/cli/auth/materialized.d.ts +32 -0
  98. package/dist/cli/auth/materialized.js +102 -0
  99. package/dist/cli/auth/migrate.d.ts +10 -0
  100. package/dist/cli/auth/migrate.js +75 -0
  101. package/dist/cli/client.d.ts +102 -0
  102. package/dist/cli/client.js +206 -0
  103. package/dist/cli/collection-list.d.ts +3 -0
  104. package/dist/cli/collection-list.js +25 -0
  105. package/dist/cli/compat/ctx.d.ts +26 -0
  106. package/dist/cli/compat/ctx.js +76 -0
  107. package/dist/cli/compat/dreamdb-wasm-embedded.d.ts +2 -0
  108. package/dist/cli/compat/dreamdb-wasm-embedded.js +8 -0
  109. package/dist/cli/compat/dreamdb-wasm.d.ts +1 -0
  110. package/dist/cli/compat/dreamdb-wasm.js +26 -0
  111. package/dist/cli/compat/dreamdb.d.ts +112 -0
  112. package/dist/cli/compat/dreamdb.js +219 -0
  113. package/dist/cli/compat/flags.d.ts +2 -0
  114. package/dist/cli/compat/flags.js +13 -0
  115. package/dist/cli/compat/http.d.ts +23 -0
  116. package/dist/cli/compat/http.js +137 -0
  117. package/dist/cli/compat/presignedTransfer.d.ts +139 -0
  118. package/dist/cli/compat/presignedTransfer.js +580 -0
  119. package/dist/cli/compat/s3-backend.d.ts +73 -0
  120. package/dist/cli/compat/s3-backend.js +132 -0
  121. package/dist/cli/config.d.ts +22 -0
  122. package/dist/cli/config.js +96 -0
  123. package/dist/cli/connection/dto.d.ts +159 -0
  124. package/dist/cli/connection/dto.js +497 -0
  125. package/dist/cli/connection/index.d.ts +50 -0
  126. package/dist/cli/connection/index.js +413 -0
  127. package/dist/cli/connection/oauth.d.ts +23 -0
  128. package/dist/cli/connection/oauth.js +290 -0
  129. package/dist/cli/connection/write.d.ts +47 -0
  130. package/dist/cli/connection/write.js +573 -0
  131. package/dist/cli/create/index.d.ts +19 -0
  132. package/dist/cli/create/index.js +209 -0
  133. package/dist/cli/declare/index.d.ts +29 -0
  134. package/dist/cli/declare/index.js +304 -0
  135. package/dist/cli/delete/index.d.ts +18 -0
  136. package/dist/cli/delete/index.js +232 -0
  137. package/dist/cli/download/index.d.ts +9 -0
  138. package/dist/cli/download/index.js +128 -0
  139. package/dist/cli/env/compose.d.ts +88 -0
  140. package/dist/cli/env/compose.js +402 -0
  141. package/dist/cli/env/index.d.ts +176 -0
  142. package/dist/cli/env/index.js +1011 -0
  143. package/dist/cli/experiments/index.d.ts +11 -0
  144. package/dist/cli/experiments/index.js +168 -0
  145. package/dist/cli/glob.d.ts +1 -0
  146. package/dist/cli/glob.js +45 -0
  147. package/dist/cli/graphql-helpers.d.ts +23 -0
  148. package/dist/cli/graphql-helpers.js +42 -0
  149. package/dist/cli/graphql.d.ts +10 -0
  150. package/dist/cli/graphql.js +47 -0
  151. package/dist/cli/help-examples.generated.d.ts +1 -0
  152. package/dist/cli/help-examples.generated.js +192 -0
  153. package/dist/cli/helpers.d.ts +8 -0
  154. package/dist/cli/helpers.js +106 -0
  155. package/dist/cli/hosts/api.d.ts +29 -0
  156. package/dist/cli/hosts/api.js +54 -0
  157. package/dist/cli/hosts/bootstrap-source.d.ts +1 -0
  158. package/dist/cli/hosts/bootstrap-source.js +2 -0
  159. package/dist/cli/hosts/catalog.d.ts +26 -0
  160. package/dist/cli/hosts/catalog.js +55 -0
  161. package/dist/cli/hosts/config.d.ts +45 -0
  162. package/dist/cli/hosts/config.js +179 -0
  163. package/dist/cli/hosts/credentials.d.ts +19 -0
  164. package/dist/cli/hosts/credentials.js +173 -0
  165. package/dist/cli/hosts/enroll.d.ts +17 -0
  166. package/dist/cli/hosts/enroll.js +109 -0
  167. package/dist/cli/hosts/enrollments.d.ts +25 -0
  168. package/dist/cli/hosts/enrollments.js +54 -0
  169. package/dist/cli/hosts/index.d.ts +6 -0
  170. package/dist/cli/hosts/index.js +279 -0
  171. package/dist/cli/hosts/inventory.d.ts +40 -0
  172. package/dist/cli/hosts/inventory.js +91 -0
  173. package/dist/cli/hosts/lifecycle.d.ts +15 -0
  174. package/dist/cli/hosts/lifecycle.js +108 -0
  175. package/dist/cli/hosts/metrics-source.d.ts +12 -0
  176. package/dist/cli/hosts/metrics-source.js +89 -0
  177. package/dist/cli/hosts/observations.d.ts +39 -0
  178. package/dist/cli/hosts/observations.js +102 -0
  179. package/dist/cli/hosts/remote.d.ts +5 -0
  180. package/dist/cli/hosts/remote.js +66 -0
  181. package/dist/cli/hosts/ssh.d.ts +63 -0
  182. package/dist/cli/hosts/ssh.js +276 -0
  183. package/dist/cli/index.d.ts +1 -0
  184. package/dist/cli/index.js +288 -0
  185. package/dist/cli/infra/api.d.ts +95 -0
  186. package/dist/cli/infra/api.js +291 -0
  187. package/dist/cli/infra/index.d.ts +5 -0
  188. package/dist/cli/infra/index.js +102 -0
  189. package/dist/cli/infra/move.d.ts +15 -0
  190. package/dist/cli/infra/move.js +123 -0
  191. package/dist/cli/infra/transfer.d.ts +15 -0
  192. package/dist/cli/infra/transfer.js +280 -0
  193. package/dist/cli/jobs/api.d.ts +69 -0
  194. package/dist/cli/jobs/api.js +121 -0
  195. package/dist/cli/jobs/index.d.ts +5 -0
  196. package/dist/cli/jobs/index.js +140 -0
  197. package/dist/cli/lakeshore/index.d.ts +98 -0
  198. package/dist/cli/lakeshore/index.js +502 -0
  199. package/dist/cli/launch/index.d.ts +43 -0
  200. package/dist/cli/launch/index.js +270 -0
  201. package/dist/cli/layout/index.d.ts +2 -0
  202. package/dist/cli/layout/index.js +44 -0
  203. package/dist/cli/layout/transport.d.ts +12 -0
  204. package/dist/cli/layout/transport.js +70 -0
  205. package/dist/cli/library/add.d.ts +60 -0
  206. package/dist/cli/library/add.js +348 -0
  207. package/dist/cli/library/cache.d.ts +26 -0
  208. package/dist/cli/library/cache.js +88 -0
  209. package/dist/cli/library/config.d.ts +75 -0
  210. package/dist/cli/library/config.js +198 -0
  211. package/dist/cli/library/digest.d.ts +5 -0
  212. package/dist/cli/library/digest.js +19 -0
  213. package/dist/cli/library/discover.d.ts +87 -0
  214. package/dist/cli/library/discover.js +534 -0
  215. package/dist/cli/library/freshness.d.ts +35 -0
  216. package/dist/cli/library/freshness.js +109 -0
  217. package/dist/cli/library/generation.d.ts +35 -0
  218. package/dist/cli/library/generation.js +211 -0
  219. package/dist/cli/library/index.d.ts +2 -0
  220. package/dist/cli/library/index.js +36 -0
  221. package/dist/cli/library/info.d.ts +69 -0
  222. package/dist/cli/library/info.js +311 -0
  223. package/dist/cli/library/list.d.ts +33 -0
  224. package/dist/cli/library/list.js +86 -0
  225. package/dist/cli/library/manifest.d.ts +81 -0
  226. package/dist/cli/library/manifest.js +200 -0
  227. package/dist/cli/library/manifestCache.d.ts +45 -0
  228. package/dist/cli/library/manifestCache.js +169 -0
  229. package/dist/cli/library/pull.d.ts +30 -0
  230. package/dist/cli/library/pull.js +438 -0
  231. package/dist/cli/library/push.d.ts +72 -0
  232. package/dist/cli/library/push.js +642 -0
  233. package/dist/cli/library/rm.d.ts +31 -0
  234. package/dist/cli/library/rm.js +200 -0
  235. package/dist/cli/library/search.d.ts +18 -0
  236. package/dist/cli/library/search.js +181 -0
  237. package/dist/cli/library/stat.d.ts +15 -0
  238. package/dist/cli/library/stat.js +127 -0
  239. package/dist/cli/library/tools.d.ts +104 -0
  240. package/dist/cli/library/tools.js +163 -0
  241. package/dist/cli/library/wire.d.ts +47 -0
  242. package/dist/cli/library/wire.js +120 -0
  243. package/dist/cli/list/index.d.ts +26 -0
  244. package/dist/cli/list/index.js +256 -0
  245. package/dist/cli/notes/character-plan.d.ts +22 -0
  246. package/dist/cli/notes/character-plan.js +232 -0
  247. package/dist/cli/notes/document.d.ts +73 -0
  248. package/dist/cli/notes/document.js +306 -0
  249. package/dist/cli/notes/edit-commands.d.ts +106 -0
  250. package/dist/cli/notes/edit-commands.js +623 -0
  251. package/dist/cli/notes/editing.d.ts +81 -0
  252. package/dist/cli/notes/editing.js +305 -0
  253. package/dist/cli/notes/events.d.ts +36 -0
  254. package/dist/cli/notes/events.js +54 -0
  255. package/dist/cli/notes/files-commands.d.ts +120 -0
  256. package/dist/cli/notes/files-commands.js +554 -0
  257. package/dist/cli/notes/html-read.d.ts +9 -0
  258. package/dist/cli/notes/html-read.js +90 -0
  259. package/dist/cli/notes/html.d.ts +73 -0
  260. package/dist/cli/notes/html.js +381 -0
  261. package/dist/cli/notes/index.d.ts +123 -0
  262. package/dist/cli/notes/index.js +1303 -0
  263. package/dist/cli/notes/linger.d.ts +59 -0
  264. package/dist/cli/notes/linger.js +339 -0
  265. package/dist/cli/notes/media-commands.d.ts +5 -0
  266. package/dist/cli/notes/media-commands.js +51 -0
  267. package/dist/cli/notes/move-command.d.ts +83 -0
  268. package/dist/cli/notes/move-command.js +259 -0
  269. package/dist/cli/notes/rm-command.d.ts +22 -0
  270. package/dist/cli/notes/rm-command.js +110 -0
  271. package/dist/cli/notes/select-command.d.ts +12 -0
  272. package/dist/cli/notes/select-command.js +84 -0
  273. package/dist/cli/notes/suggest-diff.d.ts +56 -0
  274. package/dist/cli/notes/suggest-diff.js +311 -0
  275. package/dist/cli/notes/toc.d.ts +38 -0
  276. package/dist/cli/notes/toc.js +144 -0
  277. package/dist/cli/notes/transfer-command.d.ts +6 -0
  278. package/dist/cli/notes/transfer-command.js +9 -0
  279. package/dist/cli/notes/version-commands.d.ts +19 -0
  280. package/dist/cli/notes/version-commands.js +178 -0
  281. package/dist/cli/nymph/index.d.ts +74 -0
  282. package/dist/cli/nymph/index.js +349 -0
  283. package/dist/cli/org/index.d.ts +34 -0
  284. package/dist/cli/org/index.js +341 -0
  285. package/dist/cli/ownership/index.d.ts +12 -0
  286. package/dist/cli/ownership/index.js +122 -0
  287. package/dist/cli/ownership/metadata-transfer.d.ts +20 -0
  288. package/dist/cli/ownership/metadata-transfer.js +159 -0
  289. package/dist/cli/page/index.d.ts +58 -0
  290. package/dist/cli/page/index.js +387 -0
  291. package/dist/cli/pipeline/index.d.ts +69 -0
  292. package/dist/cli/pipeline/index.js +604 -0
  293. package/dist/cli/progress.d.ts +60 -0
  294. package/dist/cli/progress.js +276 -0
  295. package/dist/cli/project/attachments.d.ts +10 -0
  296. package/dist/cli/project/attachments.js +39 -0
  297. package/dist/cli/project/grants.d.ts +10 -0
  298. package/dist/cli/project/grants.js +39 -0
  299. package/dist/cli/project/index.d.ts +8 -0
  300. package/dist/cli/project/index.js +92 -0
  301. package/dist/cli/project/move.d.ts +57 -0
  302. package/dist/cli/project/move.js +242 -0
  303. package/dist/cli/project/output.d.ts +2 -0
  304. package/dist/cli/project/output.js +29 -0
  305. package/dist/cli/project/stream.d.ts +55 -0
  306. package/dist/cli/project/stream.js +207 -0
  307. package/dist/cli/project/transfer-preview.d.ts +8 -0
  308. package/dist/cli/project/transfer-preview.js +10 -0
  309. package/dist/cli/prompt.d.ts +1 -0
  310. package/dist/cli/prompt.js +17 -0
  311. package/dist/cli/provider/dreamdir.d.ts +52 -0
  312. package/dist/cli/provider/dreamdir.js +138 -0
  313. package/dist/cli/provider/index.d.ts +4 -0
  314. package/dist/cli/provider/index.js +419 -0
  315. package/dist/cli/provider/jump-worker.d.ts +9 -0
  316. package/dist/cli/provider/jump-worker.js +141 -0
  317. package/dist/cli/provider/lifecycle.d.ts +149 -0
  318. package/dist/cli/provider/lifecycle.js +1390 -0
  319. package/dist/cli/provider/machine.d.ts +17 -0
  320. package/dist/cli/provider/machine.js +116 -0
  321. package/dist/cli/provider/ssh.d.ts +105 -0
  322. package/dist/cli/provider/ssh.js +305 -0
  323. package/dist/cli/provider/terraform.d.ts +140 -0
  324. package/dist/cli/provider/terraform.js +288 -0
  325. package/dist/cli/providers/index.d.ts +18 -0
  326. package/dist/cli/providers/index.js +422 -0
  327. package/dist/cli/python.d.ts +61 -0
  328. package/dist/cli/python.js +255 -0
  329. package/dist/cli/queues/index.d.ts +33 -0
  330. package/dist/cli/queues/index.js +248 -0
  331. package/dist/cli/queues/slurm.d.ts +10 -0
  332. package/dist/cli/queues/slurm.js +134 -0
  333. package/dist/cli/resources.d.ts +72 -0
  334. package/dist/cli/resources.js +137 -0
  335. package/dist/cli/run/index.d.ts +15 -0
  336. package/dist/cli/run/index.js +163 -0
  337. package/dist/cli/run/input.d.ts +34 -0
  338. package/dist/cli/run/input.js +135 -0
  339. package/dist/cli/run/recovery.d.ts +2 -0
  340. package/dist/cli/run/recovery.js +18 -0
  341. package/dist/cli/run/setup.d.ts +3 -0
  342. package/dist/cli/run/setup.js +62 -0
  343. package/dist/cli/runconfig/index.d.ts +12 -0
  344. package/dist/cli/runconfig/index.js +130 -0
  345. package/dist/cli/runnable/index.d.ts +35 -0
  346. package/dist/cli/runnable/index.js +575 -0
  347. package/dist/cli/runnable/path.d.ts +115 -0
  348. package/dist/cli/runnable/path.js +288 -0
  349. package/dist/cli/runnable/run.d.ts +91 -0
  350. package/dist/cli/runnable/run.js +239 -0
  351. package/dist/cli/runnable/upload.d.ts +43 -0
  352. package/dist/cli/runnable/upload.js +342 -0
  353. package/dist/cli/runnable/worker.d.ts +1 -0
  354. package/dist/cli/runnable/worker.js +44 -0
  355. package/dist/cli/schemas/workflow-spec.schema.json +335 -0
  356. package/dist/cli/self-update/index.d.ts +5 -0
  357. package/dist/cli/self-update/index.js +107 -0
  358. package/dist/cli/self-update/install.d.ts +60 -0
  359. package/dist/cli/self-update/install.js +428 -0
  360. package/dist/cli/self-update/paths.d.ts +40 -0
  361. package/dist/cli/self-update/paths.js +87 -0
  362. package/dist/cli/self-update/releases.d.ts +41 -0
  363. package/dist/cli/self-update/releases.js +153 -0
  364. package/dist/cli/self-update/settings.d.ts +16 -0
  365. package/dist/cli/self-update/settings.js +68 -0
  366. package/dist/cli/self-update/update.d.ts +18 -0
  367. package/dist/cli/self-update/update.js +241 -0
  368. package/dist/cli/service-accounts/index.d.ts +3 -0
  369. package/dist/cli/service-accounts/index.js +149 -0
  370. package/dist/cli/session-affiliation.d.ts +26 -0
  371. package/dist/cli/session-affiliation.js +135 -0
  372. package/dist/cli/sessions/affiliation.d.ts +8 -0
  373. package/dist/cli/sessions/affiliation.js +66 -0
  374. package/dist/cli/sessions/api.d.ts +55 -0
  375. package/dist/cli/sessions/api.js +88 -0
  376. package/dist/cli/sessions/control.d.ts +6 -0
  377. package/dist/cli/sessions/control.js +159 -0
  378. package/dist/cli/sessions/conversation.d.ts +15 -0
  379. package/dist/cli/sessions/conversation.js +118 -0
  380. package/dist/cli/sessions/index.d.ts +2 -0
  381. package/dist/cli/sessions/index.js +209 -0
  382. package/dist/cli/sessions/managed.d.ts +39 -0
  383. package/dist/cli/sessions/managed.js +63 -0
  384. package/dist/cli/sessions/redaction.d.ts +2 -0
  385. package/dist/cli/sessions/redaction.js +11 -0
  386. package/dist/cli/sessions/runner/exec.d.ts +108 -0
  387. package/dist/cli/sessions/runner/exec.js +335 -0
  388. package/dist/cli/sessions/runner/journal.d.ts +26 -0
  389. package/dist/cli/sessions/runner/journal.js +49 -0
  390. package/dist/cli/sessions/runner/native.d.ts +48 -0
  391. package/dist/cli/sessions/runner/native.js +170 -0
  392. package/dist/cli/sessions/runner/pod.d.ts +30 -0
  393. package/dist/cli/sessions/runner/pod.js +129 -0
  394. package/dist/cli/sessions/runner/serve.d.ts +85 -0
  395. package/dist/cli/sessions/runner/serve.js +558 -0
  396. package/dist/cli/sessions/sync.d.ts +47 -0
  397. package/dist/cli/sessions/sync.js +80 -0
  398. package/dist/cli/sessions/transport.d.ts +14 -0
  399. package/dist/cli/sessions/transport.js +116 -0
  400. package/dist/cli/share.d.ts +15 -0
  401. package/dist/cli/share.js +139 -0
  402. package/dist/cli/skill/catalog.d.ts +141 -0
  403. package/dist/cli/skill/catalog.js +442 -0
  404. package/dist/cli/skill/files.d.ts +89 -0
  405. package/dist/cli/skill/files.js +264 -0
  406. package/dist/cli/skill/index.d.ts +268 -0
  407. package/dist/cli/skill/index.js +1216 -0
  408. package/dist/cli/skill/manifest.d.ts +30 -0
  409. package/dist/cli/skill/manifest.js +101 -0
  410. package/dist/cli/skill/prefs.d.ts +9 -0
  411. package/dist/cli/skill/prefs.js +32 -0
  412. package/dist/cli/skill/reminders.d.ts +15 -0
  413. package/dist/cli/skill/reminders.js +105 -0
  414. package/dist/cli/skill/tar.d.ts +17 -0
  415. package/dist/cli/skill/tar.js +195 -0
  416. package/dist/cli/snapshot/index.d.ts +24 -0
  417. package/dist/cli/snapshot/index.js +146 -0
  418. package/dist/cli/source/access.d.ts +45 -0
  419. package/dist/cli/source/access.js +563 -0
  420. package/dist/cli/source/control.d.ts +103 -0
  421. package/dist/cli/source/control.js +546 -0
  422. package/dist/cli/source/delete.d.ts +89 -0
  423. package/dist/cli/source/delete.js +463 -0
  424. package/dist/cli/source/index.d.ts +288 -0
  425. package/dist/cli/source/index.js +1348 -0
  426. package/dist/cli/source/share.d.ts +65 -0
  427. package/dist/cli/source/share.js +530 -0
  428. package/dist/cli/source/upload.d.ts +62 -0
  429. package/dist/cli/source/upload.js +258 -0
  430. package/dist/cli/source/write.d.ts +77 -0
  431. package/dist/cli/source/write.js +335 -0
  432. package/dist/cli/spawn.d.ts +28 -0
  433. package/dist/cli/spawn.js +81 -0
  434. package/dist/cli/target.d.ts +22 -0
  435. package/dist/cli/target.js +85 -0
  436. package/dist/cli/tasks/index.d.ts +38 -0
  437. package/dist/cli/tasks/index.js +365 -0
  438. package/dist/cli/team/index.d.ts +37 -0
  439. package/dist/cli/team/index.js +407 -0
  440. package/dist/cli/telemetry.d.ts +23 -0
  441. package/dist/cli/telemetry.js +262 -0
  442. package/dist/cli/telemetryJournal.d.ts +26 -0
  443. package/dist/cli/telemetryJournal.js +104 -0
  444. package/dist/cli/update/index.d.ts +21 -0
  445. package/dist/cli/update/index.js +284 -0
  446. package/dist/cli/upload/index.d.ts +11 -0
  447. package/dist/cli/upload/index.js +261 -0
  448. package/dist/cli/upload/kinds.d.ts +10 -0
  449. package/dist/cli/upload/kinds.js +85 -0
  450. package/dist/cli/upload/multipart.d.ts +21 -0
  451. package/dist/cli/upload/multipart.js +248 -0
  452. package/dist/cli/vault/affected-preview.d.ts +15 -0
  453. package/dist/cli/vault/affected-preview.js +38 -0
  454. package/dist/cli/vault/cloud.d.ts +55 -0
  455. package/dist/cli/vault/cloud.js +287 -0
  456. package/dist/cli/vault/format.d.ts +18 -0
  457. package/dist/cli/vault/format.js +104 -0
  458. package/dist/cli/vault/hostCredentials.d.ts +21 -0
  459. package/dist/cli/vault/hostCredentials.js +71 -0
  460. package/dist/cli/vault/hostSupersessions.d.ts +18 -0
  461. package/dist/cli/vault/hostSupersessions.js +68 -0
  462. package/dist/cli/vault/import.d.ts +3 -0
  463. package/dist/cli/vault/import.js +79 -0
  464. package/dist/cli/vault/index.d.ts +14 -0
  465. package/dist/cli/vault/index.js +225 -0
  466. package/dist/cli/vault/keys.d.ts +5 -0
  467. package/dist/cli/vault/keys.js +165 -0
  468. package/dist/cli/vault/kms.d.ts +6 -0
  469. package/dist/cli/vault/kms.js +169 -0
  470. package/dist/cli/vault/list.d.ts +13 -0
  471. package/dist/cli/vault/list.js +60 -0
  472. package/dist/cli/vault/listView.d.ts +21 -0
  473. package/dist/cli/vault/listView.js +123 -0
  474. package/dist/cli/vault/managementMetadata.d.ts +2 -0
  475. package/dist/cli/vault/managementMetadata.js +23 -0
  476. package/dist/cli/vault/mutations.d.ts +8 -0
  477. package/dist/cli/vault/mutations.js +151 -0
  478. package/dist/cli/vault/otp.d.ts +6 -0
  479. package/dist/cli/vault/otp.js +62 -0
  480. package/dist/cli/vault/otpIntent.d.ts +23 -0
  481. package/dist/cli/vault/otpIntent.js +76 -0
  482. package/dist/cli/vault/passImport.d.ts +25 -0
  483. package/dist/cli/vault/passImport.js +129 -0
  484. package/dist/cli/vault/passOtp.d.ts +51 -0
  485. package/dist/cli/vault/passOtp.js +101 -0
  486. package/dist/cli/vault/passStore.d.ts +26 -0
  487. package/dist/cli/vault/passStore.js +134 -0
  488. package/dist/cli/vault/passwordCommand.d.ts +39 -0
  489. package/dist/cli/vault/passwordCommand.js +101 -0
  490. package/dist/cli/vault/passwordProbe.d.ts +27 -0
  491. package/dist/cli/vault/passwordProbe.js +282 -0
  492. package/dist/cli/vault/passwordRotation.d.ts +9 -0
  493. package/dist/cli/vault/passwordRotation.js +273 -0
  494. package/dist/cli/vault/rotationApi.d.ts +13 -0
  495. package/dist/cli/vault/rotationApi.js +58 -0
  496. package/dist/cli/vault/rotationCommand.d.ts +2 -0
  497. package/dist/cli/vault/rotationCommand.js +75 -0
  498. package/dist/cli/vault/rotationEngine.d.ts +19 -0
  499. package/dist/cli/vault/rotationEngine.js +65 -0
  500. package/dist/cli/vault/rotationHelperSource.d.ts +2 -0
  501. package/dist/cli/vault/rotationHelperSource.js +3 -0
  502. package/dist/cli/vault/rotationInput.d.ts +11 -0
  503. package/dist/cli/vault/rotationInput.js +48 -0
  504. package/dist/cli/vault/rotationJournal.d.ts +16 -0
  505. package/dist/cli/vault/rotationJournal.js +183 -0
  506. package/dist/cli/vault/rotationKeys.d.ts +4 -0
  507. package/dist/cli/vault/rotationKeys.js +48 -0
  508. package/dist/cli/vault/rotationPrepare.d.ts +17 -0
  509. package/dist/cli/vault/rotationPrepare.js +108 -0
  510. package/dist/cli/vault/rotationRemote.d.ts +33 -0
  511. package/dist/cli/vault/rotationRemote.js +156 -0
  512. package/dist/cli/vault/rotationState.d.ts +42 -0
  513. package/dist/cli/vault/rotationState.js +115 -0
  514. package/dist/cli/vault/rotationTransport.d.ts +18 -0
  515. package/dist/cli/vault/rotationTransport.js +71 -0
  516. package/dist/cli/vault/sshSource.d.ts +18 -0
  517. package/dist/cli/vault/sshSource.js +196 -0
  518. package/dist/cli/vault/sshSync.d.ts +17 -0
  519. package/dist/cli/vault/sshSync.js +224 -0
  520. package/dist/cli/vault/sshTransfer.d.ts +22 -0
  521. package/dist/cli/vault/sshTransfer.js +140 -0
  522. package/dist/cli/vault/terraformState.d.ts +66 -0
  523. package/dist/cli/vault/terraformState.js +252 -0
  524. package/dist/cli/vault/terraformStateCommand.d.ts +2 -0
  525. package/dist/cli/vault/terraformStateCommand.js +61 -0
  526. package/dist/cli/vault/tree.d.ts +43 -0
  527. package/dist/cli/vault/tree.js +292 -0
  528. package/dist/cli/version.d.ts +1 -0
  529. package/dist/cli/version.js +9 -0
  530. package/dist/cli/workflow/index.d.ts +76 -0
  531. package/dist/cli/workflow/index.js +826 -0
  532. package/dist/cli/workflow/validate.d.ts +19 -0
  533. package/dist/cli/workflow/validate.js +353 -0
  534. package/dist/package.json +1 -0
  535. package/package.json +28 -10
@@ -0,0 +1,1216 @@
1
+ import { collectionList } from "../collection-list.js";
2
+ // `dreamlake init` / `dreamlake skill install|update|remove|list` — put agent
3
+ // skills from the public dreamlake-skills release where Claude Code
4
+ // (`.claude/skills/<name>/SKILL.md`) and Codex (`.agents/skills/<name>/`)
5
+ // will find them, and keep them current.
6
+ //
7
+ // WHY THIS EXISTS. Skills are written once, in the dreamlake-skills
8
+ // repository, and published as a release (`catalog.json` + `skills.tar.gz`).
9
+ // The CLI is the installer: it carries one skill (`dreamlake-cli`) embedded
10
+ // for offline use, downloads the rest, and records what it installed in
11
+ // `<skill>/.dreamlake-skill.json` so `update` and `remove` never have to
12
+ // guess which files are theirs. Manual install is unpacking the same tarball.
13
+ //
14
+ // THREE THINGS THIS MUST NEVER DO, each from a real hazard in this tree:
15
+ //
16
+ // 0. Every write, unlink, mkdir and rmdir goes through the owned-path
17
+ // wrappers in files.ts, which prove containment on every call. A plan
18
+ // is advice; the primitive is the guard.
19
+ // 1. Never `rm -rf` the target directory. `.claude/skills/` is shared —
20
+ // `dreamlake-workspace/.claude/skills/` already holds hand-written
21
+ // `dreamlake-py`, `pipeline-cli`, `run-dreamlake` and five more. We
22
+ // delete only files the install manifest lists AND whose hash still
23
+ // matches what we wrote, and only on `update` (retired files) or
24
+ // `remove`. Everything else — edited files, files we never wrote — is
25
+ // reported and left in place; `remove` has no flag that changes that.
26
+ // Overwrites touch only manifest-owned or payload-owned files, and user
27
+ // edits need `--force`.
28
+ // 2. Never touch `.claude/settings.json` or `settings.local.json`. They sit
29
+ // beside `skills/`, they carry permissions, and nothing about installing
30
+ // a skill justifies editing them. Every write here is under
31
+ // `<scope>/<agent dir>/skills/<name>/`.
32
+ // 3. Never assume every entry under `~/.claude/skills/` is a directory.
33
+ // There are loose `.md` files there in real homes. Anything that
34
+ // readdirs that path filters on `isDirectory()`, and a target that
35
+ // exists but is a file is a conflict with a sentence, not a crash.
36
+ // Symlinks are never followed: a symlink where a file belongs is a
37
+ // conflict `--force` does not override.
38
+ //
39
+ // The output contract is `snapshot` / `launch`'s, unchanged: prose by
40
+ // default, one JSON object under `--json` with a discriminated `status` and a
41
+ // required-but-nullable `nextAction`, and on failure stdout still carries
42
+ // exactly one object while stderr stays empty.
43
+ import { select } from "@inquirer/prompts";
44
+ import { readdirSync } from "node:fs";
45
+ import os from "node:os";
46
+ import path from "node:path";
47
+ import { emitJson, fail, ok, warn } from "../helpers.js";
48
+ import { EMBEDDED_SKILL, ReleaseError, SKILLS_ENV, catalogFileCount, catalogUrl, compareVersions, embeddedCatalog, embeddedPayload, embeddedVersion, extractSkills, fetchLatestCatalog, fetchSkillsTarball, fmtVersion, listBundledSkills, manualDownloadUrl, resolveBundleDir, bundledFiles, versionsEqual, } from "./catalog.js";
49
+ import { hashFile, hasSymlinkAncestor, isDirectChild, kindOf, listDir, pinOwnedDir, pruneEmptyDirs, resolveExisting, sha256, unlinkOwnedFile, writeOwnedFile, } from "./files.js";
50
+ import { MANIFEST_FILE, isAgent, readManifest, writeManifest, } from "./manifest.js";
51
+ import { readSkillPreferences, writeSkillPreferences } from "./prefs.js";
52
+ export { listBundledSkills, resolveBundleDir } from "./catalog.js";
53
+ // ─── names ───────────────────────────────────────────────────────────────────
54
+ //
55
+ // A skill name is a directory name under a shared skills directory, so it is
56
+ // validated before anything is resolved on disk: lower-case letters, digits
57
+ // and dashes, starting with a letter. Catalog names pass the same rule; a
58
+ // catalog that names anything else is refused rather than trusted.
59
+ const SKILL_NAME = /^[a-z][a-z0-9-]*$/;
60
+ export function isSkillName(name) {
61
+ return typeof name === "string" && SKILL_NAME.test(name);
62
+ }
63
+ /** The first invalid name, or null when all are valid. */
64
+ function invalidName(names) {
65
+ for (const name of names)
66
+ if (!isSkillName(name))
67
+ return name;
68
+ return null;
69
+ }
70
+ function invalidNameMessage(name) {
71
+ return `${JSON.stringify(name)} is not a valid skill name — lower-case letters, digits and dashes, starting with a letter`;
72
+ }
73
+ /**
74
+ * The scope's skills directory for an agent, symlinks resolved. A symlinked
75
+ * `.claude/skills` or `.agents/skills` (a dotfiles setup) is legitimate and
76
+ * is followed; the resolution happens once per command and every target,
77
+ * reported path and write is derived from the resolved directory.
78
+ */
79
+ export function skillsDir(scopeRoot, agent = "claude") {
80
+ return resolveExisting(path.join(scopeRoot, agent === "codex" ? ".agents" : ".claude", "skills"));
81
+ }
82
+ /**
83
+ * Where a skill lives inside a resolved skills directory: exactly
84
+ * `<dir>/<name>`. The name is validated before the path is built and the
85
+ * built path is checked to be a direct child — a second line behind the
86
+ * regex, so no caller can ever address a path outside the directory.
87
+ */
88
+ export function targetIn(dir, name) {
89
+ if (!isSkillName(name))
90
+ throw new Error(invalidNameMessage(name));
91
+ const target = path.join(dir, name);
92
+ if (!isDirectChild(dir, target) || path.basename(target) !== name) {
93
+ throw new Error(`refusing a skill target outside ${dir}: ${JSON.stringify(name)}`);
94
+ }
95
+ return target;
96
+ }
97
+ export function skillTarget(scopeRoot, name, agent = "claude") {
98
+ return targetIn(skillsDir(scopeRoot, agent), name);
99
+ }
100
+ /**
101
+ * The skill directory as a pinned descriptor: its path under the resolved
102
+ * scope directory and what that resolved to right now. Taken once per skill
103
+ * per command, before planning; every write or delete that follows is
104
+ * checked against it, never against a fresh resolution.
105
+ */
106
+ export function ownedTarget(dir, name) {
107
+ return pinOwnedDir(targetIn(dir, name));
108
+ }
109
+ function selectTarget(opts) {
110
+ if (opts.agent !== undefined && !isAgent(opts.agent))
111
+ return { error: "--agent must be claude or codex" };
112
+ const prefs = readSkillPreferences();
113
+ const agent = isAgent(opts.agent) ? opts.agent : prefs?.agent ?? "claude";
114
+ const o = opts;
115
+ let scope;
116
+ let root;
117
+ if (o.dir) {
118
+ scope = "dir";
119
+ root = path.resolve(o.dir);
120
+ }
121
+ else if (o.project) {
122
+ scope = "project";
123
+ root = process.cwd();
124
+ }
125
+ else if (o.global || (prefs?.scope === "global" && !o.project)) {
126
+ scope = "global";
127
+ root = os.homedir();
128
+ }
129
+ else {
130
+ scope = "project";
131
+ root = process.cwd();
132
+ }
133
+ return {
134
+ agent, scope, root, dir: skillsDir(root, agent),
135
+ saved: prefs !== null && opts.agent === undefined,
136
+ hint: prefs === null && opts.agent === undefined,
137
+ };
138
+ }
139
+ function printHint(sel, opts) {
140
+ if (!sel.hint || opts.json)
141
+ return;
142
+ process.stderr.write(` hint: no saved agent — using ${sel.agent}, ${sel.scope}; run 'dreamlake init' once to remember your choice\n`);
143
+ }
144
+ // ─── prose ───────────────────────────────────────────────────────────────────
145
+ //
146
+ // The house column: bare verb line, ` key:` padded to column 14, then the
147
+ // ✓ / ⚠ result lines, then indented copy-pasteable next commands.
148
+ function header(rows) {
149
+ for (const [k, v] of rows) {
150
+ process.stdout.write(` ${`${k}:`.padEnd(12)}${v}\n`);
151
+ }
152
+ }
153
+ function catalogLine(info) {
154
+ if (info.origin === "release")
155
+ return `${fmtVersion(info.version)} (release)`;
156
+ const base = info.origin === "embedded" ? `${fmtVersion(info.version)} (embedded snapshot)` : "none";
157
+ return info.unreachable ? `${base} — release unreachable: ${info.unreachable}` : base;
158
+ }
159
+ /** The command that would resolve the current invocation, `--force` and `--allow-downgrade` optional. */
160
+ export function skillCommand(verb, names, opts, force, allowDowngrade = false) {
161
+ const parts = ["dreamlake", "skill", verb, ...(Array.isArray(names) ? names : [names])];
162
+ if (opts.agent)
163
+ parts.push("--agent", opts.agent);
164
+ if (opts.dir)
165
+ parts.push("--dir", "'" + opts.dir.replace(/'/g, "'\"'\"'") + "'");
166
+ else if (opts.global)
167
+ parts.push("--global");
168
+ else if (opts.project)
169
+ parts.push("--project");
170
+ if (force || opts.force)
171
+ parts.push("--force");
172
+ if (allowDowngrade || opts.allowDowngrade)
173
+ parts.push("--allow-downgrade");
174
+ return parts.join(" ");
175
+ }
176
+ export function installCommand(skill, opts, force) {
177
+ return skillCommand("install", skill, opts, force);
178
+ }
179
+ /** The one error exit: prose to stderr, or folded into --json. */
180
+ function reject(opts, message, kind, nextAction = null, base) {
181
+ if (opts.json) {
182
+ emitJson({ ...(base ?? {}), status: "error", error: message, kind, nextAction });
183
+ }
184
+ else {
185
+ fail(message);
186
+ if (nextAction?.kind === "run")
187
+ process.stderr.write(`\n next: ${nextAction.command}\n`);
188
+ if (nextAction?.kind === "download")
189
+ process.stderr.write(`\n download by hand: ${nextAction.url}\n`);
190
+ }
191
+ return 1;
192
+ }
193
+ function snapshotCatalog(bundleDir) {
194
+ try {
195
+ return embeddedCatalog(bundleDir);
196
+ }
197
+ catch {
198
+ return null;
199
+ }
200
+ }
201
+ async function loadCatalog(bundleDir, offline) {
202
+ const snapshot = snapshotCatalog(bundleDir);
203
+ const fallback = (unreachable) => ({ catalog: snapshot, origin: snapshot ? "embedded" : "none", unreachable });
204
+ if (offline)
205
+ return fallback(null);
206
+ try {
207
+ return { catalog: await fetchLatestCatalog(), origin: "release", unreachable: null };
208
+ }
209
+ catch (err) {
210
+ return fallback(err.message);
211
+ }
212
+ }
213
+ function info(ctx) {
214
+ return {
215
+ version: ctx.catalog?.version ?? null,
216
+ origin: ctx.origin,
217
+ ...(ctx.unreachable ? { unreachable: ctx.unreachable } : {}),
218
+ };
219
+ }
220
+ function isRejection(v) {
221
+ return "message" in v;
222
+ }
223
+ async function resolvePayloads(requested, ctx, bundleDir) {
224
+ const bundled = bundleDir ? listBundledSkills(bundleDir) : [];
225
+ const catalog = ctx.catalog;
226
+ const known = (name) => Boolean(catalog?.skills[name]) || bundled.includes(name);
227
+ const available = catalog ? Object.keys(catalog.skills).sort() : bundled;
228
+ const order = [];
229
+ const requiredBy = new Map();
230
+ for (const name of requested) {
231
+ const renamed = catalog?.renamed[name];
232
+ if (renamed && !known(name)) {
233
+ return {
234
+ message: `'${name}' was renamed to '${renamed}' — install that instead`,
235
+ kind: "renamed",
236
+ nextAction: { kind: "run", command: `dreamlake skill install ${renamed}` },
237
+ };
238
+ }
239
+ if (!known(name)) {
240
+ return {
241
+ message: `no skill named '${name}' — ${catalog ? "the catalog" : "this build"} has: ${available.join(", ")}`,
242
+ kind: "unknown-skill",
243
+ nextAction: { kind: "run", command: "dreamlake skill list" },
244
+ };
245
+ }
246
+ if (!order.includes(name))
247
+ order.push(name);
248
+ }
249
+ // `requires` closure, breadth-first, after everything explicitly requested.
250
+ for (let i = 0; i < order.length; i += 1) {
251
+ const name = order[i];
252
+ for (const dep of catalog?.skills[name]?.requires ?? []) {
253
+ if (order.includes(dep))
254
+ continue;
255
+ if (!isSkillName(dep)) {
256
+ return { message: `${name} requires ${JSON.stringify(dep)}, which is not a valid skill name — the catalog is not usable`, kind: "bad-catalog", nextAction: null };
257
+ }
258
+ if (!known(dep)) {
259
+ return {
260
+ message: `${name} requires '${dep}', which is not in the catalog`,
261
+ kind: "unknown-skill",
262
+ nextAction: { kind: "run", command: "dreamlake skill list" },
263
+ };
264
+ }
265
+ order.push(dep);
266
+ requiredBy.set(dep, name);
267
+ }
268
+ }
269
+ const payloads = new Map();
270
+ const fromRelease = [];
271
+ const embeddedVer = bundleDir ? embeddedVersion(bundleDir) : null;
272
+ for (const name of order) {
273
+ const canEmbed = bundled.includes(name);
274
+ const current = ctx.origin !== "release" || versionsEqual(embeddedVer, catalog?.version);
275
+ if (canEmbed && current)
276
+ payloads.set(name, embeddedPayload(bundleDir, name));
277
+ else
278
+ fromRelease.push(name);
279
+ }
280
+ if (fromRelease.length > 0) {
281
+ if (ctx.origin !== "release") {
282
+ const why = ctx.unreachable ? `cannot reach the skills release (${ctx.unreachable})` : "this build has no catalog and the release was not consulted";
283
+ return {
284
+ message: `${why} — ${fromRelease.join(", ")} must come from the release. Download skills.tar.gz by hand and unpack the needed directories into your skills directory.`,
285
+ kind: "catalog-unreachable",
286
+ nextAction: { kind: "download", url: manualDownloadUrl() },
287
+ };
288
+ }
289
+ let tarball;
290
+ try {
291
+ tarball = await fetchSkillsTarball(catalog);
292
+ }
293
+ catch (err) {
294
+ if (err instanceof ReleaseError && err.kind === "integrity") {
295
+ // No checksum, or bytes that do not hash to it. Nothing is written;
296
+ // there is no manual-download way around an unverifiable asset.
297
+ return {
298
+ message: `the skills release failed its integrity check: ${err.message}. Nothing was written.`,
299
+ kind: "integrity",
300
+ nextAction: null,
301
+ };
302
+ }
303
+ return {
304
+ message: `cannot download the skills release: ${err.message}`,
305
+ kind: "catalog-unreachable",
306
+ nextAction: { kind: "download", url: err instanceof ReleaseError ? err.url : manualDownloadUrl() },
307
+ };
308
+ }
309
+ let extracted;
310
+ try {
311
+ extracted = extractSkills(tarball, fromRelease, catalog.version);
312
+ }
313
+ catch (err) {
314
+ return { message: `the skills release tarball is not usable: ${err.message}`, kind: "bad-release", nextAction: null };
315
+ }
316
+ for (const name of fromRelease) {
317
+ const payload = extracted.get(name);
318
+ if (!payload) {
319
+ return { message: `release ${fmtVersion(catalog.version)} has no '${name}' directory in skills.tar.gz`, kind: "missing-in-release", nextAction: null };
320
+ }
321
+ payloads.set(name, payload);
322
+ }
323
+ }
324
+ return { payloads: order.map((name) => payloads.get(name)), requiredBy };
325
+ }
326
+ function emptyPlan(status) {
327
+ return { status, writes: [], deletes: [], conflicts: [], hard: [], extra: [], previous: null };
328
+ }
329
+ function blockedPlan(target, kind) {
330
+ if (kind === "absent" || kind === "dir")
331
+ return null;
332
+ return {
333
+ ...emptyPlan("error"),
334
+ error: `${target} exists and is not a directory — move it aside, then re-run`,
335
+ kind: "not-a-directory",
336
+ };
337
+ }
338
+ /**
339
+ * No implicit downgrade. With a manifest in place the candidate's version is
340
+ * ordered against the installed one before any file is compared: an older
341
+ * candidate is a guarded `exists` (nothing changes, the manifest keeps its
342
+ * version), a version that cannot be ordered — a commit pin against a tag,
343
+ * an unknown format — is an error, because replacing files without knowing
344
+ * which copy is newer is exactly the mistake this guard exists to prevent.
345
+ * `--allow-downgrade` is the explicit way through both; `--force` keeps its
346
+ * one meaning (overwrite files the user edited) and does not bypass this.
347
+ */
348
+ function versionGuard(candidate, installed, allowDowngrade) {
349
+ if (allowDowngrade)
350
+ return null;
351
+ const order = compareVersions(candidate, installed);
352
+ if (order === -1) {
353
+ return { ...emptyPlan("exists"), noWrite: true, message: `installed ${fmtVersion(installed)} is newer than available ${fmtVersion(candidate)}; nothing changed` };
354
+ }
355
+ if (order === null) {
356
+ return {
357
+ ...emptyPlan("error"),
358
+ error: `installed ${fmtVersion(installed)} and available ${fmtVersion(candidate)} cannot be ordered; nothing changed — re-run with --allow-downgrade to replace the installed copy`,
359
+ kind: "version-unknown",
360
+ };
361
+ }
362
+ return null;
363
+ }
364
+ function localExtras(target, owned) {
365
+ const listing = listDir(target);
366
+ return [...listing.files, ...listing.others]
367
+ .filter((rel) => rel !== MANIFEST_FILE && !owned.has(rel))
368
+ .sort();
369
+ }
370
+ function planInstall(payload, target, force, allowDowngrade = false) {
371
+ const kind = kindOf(target);
372
+ const blocked = blockedPlan(target, kind);
373
+ if (blocked)
374
+ return blocked;
375
+ const plan = emptyPlan("installed");
376
+ if (kind === "absent") {
377
+ plan.writes = [...payload.files.keys()];
378
+ return plan;
379
+ }
380
+ try {
381
+ plan.previous = readManifest(target);
382
+ }
383
+ catch {
384
+ // Install rewrites the manifest regardless; an unreadable one is not used.
385
+ }
386
+ if (plan.previous) {
387
+ const guard = versionGuard(payload.version, plan.previous.version, allowDowngrade);
388
+ if (guard)
389
+ return { ...guard, previous: plan.previous };
390
+ }
391
+ for (const [rel, bytes] of payload.files) {
392
+ if (hasSymlinkAncestor(target, rel)) {
393
+ plan.hard.push(rel);
394
+ continue;
395
+ }
396
+ const local = path.join(target, rel);
397
+ const k = kindOf(local);
398
+ if (k === "absent")
399
+ plan.writes.push(rel);
400
+ else if (k !== "file")
401
+ plan.hard.push(rel);
402
+ else if (hashFile(local) !== sha256(bytes))
403
+ (force ? plan.writes : plan.conflicts).push(rel);
404
+ }
405
+ plan.extra = localExtras(target, new Set(payload.files.keys()));
406
+ if (!plan.previous && !force) {
407
+ // No manifest: nothing was ever accepted into one, so nothing is adopted
408
+ // on its own. Byte-identical and nothing else present is an `exists`
409
+ // that writes no manifest and says how to adopt; anything else — a
410
+ // missing or differing file, a file of the user's — is a conflict.
411
+ // --force adopts: the skill's files are written, a manifest listing only
412
+ // them is written, and the user's other files are reported, never listed.
413
+ plan.unmanaged = true;
414
+ const copy = `${payload.source} ${fmtVersion(payload.version)}`;
415
+ const pending = [...plan.writes, ...plan.conflicts];
416
+ if (plan.hard.length === 0 && pending.length === 0 && plan.extra.length === 0) {
417
+ plan.status = "exists";
418
+ plan.noWrite = true;
419
+ plan.message = `present without a manifest and identical to the ${copy} copy — not adopted`;
420
+ return plan;
421
+ }
422
+ plan.conflicts = pending.sort();
423
+ plan.writes = [];
424
+ plan.status = "conflict";
425
+ plan.kind = "unmanaged";
426
+ const counts = [
427
+ pending.length > 0 ? `${pending.length} file(s) differ or are missing` : "",
428
+ plan.extra.length > 0 ? `${plan.extra.length} file(s) are not part of it` : "",
429
+ ].filter(Boolean).join(", ");
430
+ plan.error = `${payload.name} at ${target} has no install manifest and is not the ${copy} copy as is (${counts}) — re-run with --force to adopt it`;
431
+ return plan;
432
+ }
433
+ plan.status = plan.hard.length > 0 || plan.conflicts.length > 0 ? "conflict"
434
+ : plan.writes.length > 0 ? "installed" : "exists";
435
+ return plan;
436
+ }
437
+ /** Exported for tests that need to act between planning and applying. */
438
+ export function planUpdate(payload, target, force, allowDowngrade = false) {
439
+ const kind = kindOf(target);
440
+ const blocked = blockedPlan(target, kind);
441
+ if (blocked)
442
+ return blocked;
443
+ if (kind === "absent") {
444
+ return {
445
+ ...emptyPlan("error"),
446
+ error: `${payload.name} is not installed at ${target}`,
447
+ kind: "not-installed",
448
+ nextAction: { kind: "run", command: `dreamlake skill install ${payload.name}` },
449
+ };
450
+ }
451
+ const plan = emptyPlan("installed");
452
+ try {
453
+ plan.previous = readManifest(target);
454
+ }
455
+ catch (err) {
456
+ return { ...emptyPlan("error"), error: `${err.file}: ${err.message}`, kind: "invalid-manifest" };
457
+ }
458
+ if (plan.previous) {
459
+ const guard = versionGuard(payload.version, plan.previous.version, allowDowngrade);
460
+ if (guard)
461
+ return { ...guard, previous: plan.previous };
462
+ }
463
+ const old = plan.previous?.files ?? null;
464
+ for (const [rel, bytes] of payload.files) {
465
+ if (hasSymlinkAncestor(target, rel)) {
466
+ plan.hard.push(rel);
467
+ continue;
468
+ }
469
+ const local = path.join(target, rel);
470
+ const k = kindOf(local);
471
+ if (k === "absent") {
472
+ plan.writes.push(rel);
473
+ continue;
474
+ }
475
+ if (k !== "file") {
476
+ plan.hard.push(rel);
477
+ continue;
478
+ }
479
+ const localHash = hashFile(local);
480
+ const newHash = sha256(bytes);
481
+ if (old === null) {
482
+ // No manifest: every existing file counts as the user's. Adopting the
483
+ // directory needs --force, after which a manifest is written.
484
+ if (!force)
485
+ plan.conflicts.push(rel);
486
+ else if (localHash !== newHash)
487
+ plan.writes.push(rel);
488
+ continue;
489
+ }
490
+ if (!(rel in old)) {
491
+ // A path the new release adds that already exists here is the user's
492
+ // file — even when the bytes happen to be identical, because the
493
+ // manifest never vouched for it. --force adopts it into the manifest.
494
+ // (`install` without a manifest is the opposite case: identical files
495
+ // are adopted silently, see planInstall.)
496
+ if (!force)
497
+ plan.conflicts.push(rel);
498
+ else if (localHash !== newHash)
499
+ plan.writes.push(rel);
500
+ continue;
501
+ }
502
+ if (localHash === newHash)
503
+ continue;
504
+ if (localHash === old[rel]) {
505
+ plan.writes.push(rel);
506
+ continue;
507
+ }
508
+ (force ? plan.writes : plan.conflicts).push(rel);
509
+ }
510
+ if (old) {
511
+ for (const [rel, hash] of Object.entries(old)) {
512
+ if (payload.files.has(rel))
513
+ continue;
514
+ const local = path.join(target, rel);
515
+ if (hasSymlinkAncestor(target, rel))
516
+ continue;
517
+ const k = kindOf(local);
518
+ if (k === "absent")
519
+ continue;
520
+ if (k === "file" && hashFile(local) === hash)
521
+ plan.deletes.push(rel);
522
+ }
523
+ }
524
+ const owned = new Set([...payload.files.keys(), ...plan.deletes]);
525
+ plan.extra = localExtras(target, owned);
526
+ if (plan.hard.length > 0 || plan.conflicts.length > 0) {
527
+ plan.status = "conflict";
528
+ if (old === null)
529
+ plan.kind = "unmanaged";
530
+ }
531
+ else {
532
+ plan.status = plan.writes.length > 0 || plan.deletes.length > 0 ? "installed" : "exists";
533
+ }
534
+ return plan;
535
+ }
536
+ export function applyPlan(payload, owned, plan, ctx) {
537
+ const target = owned.skillDir;
538
+ const base = {
539
+ status: plan.status,
540
+ skill: payload.name,
541
+ version: payload.version,
542
+ source: payload.source,
543
+ ...(ctx.verb === "update" ? { previous: plan.previous?.version ?? null } : {}),
544
+ scope: ctx.scope,
545
+ target,
546
+ files: [],
547
+ ...(ctx.verb === "update" ? { deleted: [] } : {}),
548
+ ...(plan.extra.length > 0 ? { extra: plan.extra } : {}),
549
+ ...(ctx.requiredBy ? { requiredBy: ctx.requiredBy } : {}),
550
+ ...(plan.message ? { message: plan.message } : {}),
551
+ ...(plan.unmanaged ? { unmanaged: true } : {}),
552
+ nextAction: plan.nextAction ?? null,
553
+ };
554
+ if (plan.status === "error") {
555
+ return {
556
+ ...base,
557
+ error: plan.error,
558
+ kind: plan.kind,
559
+ ...(plan.kind === "version-unknown" ? { nextAction: { kind: "run", command: skillCommand(ctx.verb, payload.name, ctx.opts, false, true) } } : {}),
560
+ };
561
+ }
562
+ // A guarded no-op — the installed copy is newer, or the target has no
563
+ // manifest and is not adopted. Nothing is written, the manifest included.
564
+ if (plan.status === "exists" && plan.noWrite) {
565
+ return plan.unmanaged
566
+ ? { ...base, nextAction: { kind: "run", command: skillCommand("update", payload.name, ctx.opts, true) } }
567
+ : base;
568
+ }
569
+ if (plan.status === "conflict") {
570
+ const conflicts = [...plan.hard, ...plan.conflicts].sort();
571
+ const hardOnly = plan.hard.length > 0 && plan.conflicts.length === 0 && plan.kind !== "unmanaged";
572
+ const copy = `${payload.source} ${fmtVersion(payload.version)}`;
573
+ return {
574
+ ...base,
575
+ conflicts,
576
+ error: hardOnly
577
+ ? `${payload.name}: ${plan.hard.map((rel) => path.join(target, rel)).join(", ")} is not a regular file — move it aside, then re-run`
578
+ : plan.error ?? (plan.kind === "unmanaged"
579
+ ? `${payload.name} at ${target} has no install manifest; its files count as yours — re-run with --force to adopt it`
580
+ : `${payload.name} is already installed at ${target} and differs from the ${copy} copy`),
581
+ kind: plan.kind ?? "conflict",
582
+ nextAction: hardOnly ? null : { kind: "run", command: skillCommand(ctx.verb, payload.name, ctx.opts, true) },
583
+ };
584
+ }
585
+ const written = [];
586
+ const deleted = [];
587
+ try {
588
+ for (const rel of plan.writes)
589
+ written.push(writeOwnedFile(owned, rel, payload.files.get(rel)));
590
+ for (const rel of plan.deletes) {
591
+ deleted.push(unlinkOwnedFile(owned, rel));
592
+ pruneEmptyDirs(owned, rel);
593
+ }
594
+ }
595
+ catch (err) {
596
+ return {
597
+ ...base,
598
+ status: "error",
599
+ files: written,
600
+ ...(ctx.verb === "update" ? { deleted } : {}),
601
+ error: `cannot write to ${target}: ${err.message}`,
602
+ kind: "write-failed",
603
+ nextAction: null,
604
+ };
605
+ }
606
+ const manifest = manifestFor(payload, ctx);
607
+ const result = { ...base, files: written, ...(ctx.verb === "update" ? { deleted } : {}) };
608
+ if (!sameManifest(plan.previous, manifest)) {
609
+ try {
610
+ result.manifest = writeManifest(owned, manifest);
611
+ }
612
+ catch (err) {
613
+ return { ...result, status: "error", error: `cannot write ${MANIFEST_FILE} under ${target}: ${err.message}`, kind: "write-failed", nextAction: null };
614
+ }
615
+ }
616
+ return result;
617
+ }
618
+ function manifestFor(payload, ctx) {
619
+ return {
620
+ name: payload.name,
621
+ version: payload.version,
622
+ source: payload.source,
623
+ agent: ctx.agent,
624
+ scope: ctx.scope,
625
+ files: Object.fromEntries([...payload.files].map(([rel, bytes]) => [rel, sha256(bytes)])),
626
+ };
627
+ }
628
+ function sameManifest(a, b) {
629
+ if (!a)
630
+ return false;
631
+ return JSON.stringify({ ...a, files: sortedFiles(a.files) }) === JSON.stringify({ ...b, files: sortedFiles(b.files) });
632
+ }
633
+ function sortedFiles(files) {
634
+ return Object.fromEntries(Object.keys(files).sort().map((k) => [k, files[k]]));
635
+ }
636
+ // ─── reporting an install/update run ─────────────────────────────────────────
637
+ function aggregate(results) {
638
+ if (results.some((r) => r.status === "error"))
639
+ return "error";
640
+ if (results.some((r) => r.status === "conflict"))
641
+ return "conflict";
642
+ if (results.some((r) => r.status === "installed"))
643
+ return "installed";
644
+ return "exists";
645
+ }
646
+ function printSkillResult(r, width, verb) {
647
+ const label = `${r.skill.padEnd(width)} ${r.source ?? "?"} ${fmtVersion(r.version)}`;
648
+ const via = r.requiredBy ? ` (required by ${r.requiredBy})` : "";
649
+ switch (r.status) {
650
+ case "installed": {
651
+ const parts = [`${verb === "update" ? "updated" : "installed"} ${r.files.length} file(s)`];
652
+ if (r.deleted && r.deleted.length > 0)
653
+ parts.push(`deleted ${r.deleted.length} retired file(s)`);
654
+ const from = verb === "update" && r.previous !== undefined && !versionsEqual(r.previous, r.version)
655
+ ? ` ${fmtVersion(r.previous)} → ${fmtVersion(r.version)}` : "";
656
+ ok(`${label} ${parts.join(", ")}${from}${via}`);
657
+ process.stdout.write(` target: ${r.target}\n`);
658
+ if (verb === "update" || r.files.length < 6)
659
+ for (const f of r.files)
660
+ process.stdout.write(` · ${path.relative(r.target, f)}\n`);
661
+ for (const f of r.deleted ?? [])
662
+ process.stdout.write(` − ${path.relative(r.target, f)}\n`);
663
+ break;
664
+ }
665
+ case "exists":
666
+ warn(`${label} ${r.message ?? "already installed — unchanged"}${via}`);
667
+ process.stdout.write(` target: ${r.target}\n`);
668
+ if (r.unmanaged && r.nextAction?.kind === "run")
669
+ process.stdout.write(` adopt it with: ${r.nextAction.command}\n`);
670
+ break;
671
+ case "conflict":
672
+ fail(r.error ?? `${r.skill} conflicts`);
673
+ for (const rel of r.conflicts ?? [])
674
+ process.stderr.write(` · ${rel}\n`);
675
+ break;
676
+ case "error":
677
+ fail(r.error ?? `${r.skill} failed`);
678
+ break;
679
+ }
680
+ if (r.extra && r.extra.length > 0 && r.status !== "error") {
681
+ process.stdout.write(` ${r.extra.length} file(s) under the target are not part of this skill — left alone\n`);
682
+ }
683
+ }
684
+ function printRun(verb, requested, sel, ctx, results, opts) {
685
+ process.stdout.write(`${verb === "init" ? "init" : `skill ${verb}`} ${requested.join(" ")}\n`);
686
+ header([
687
+ ["agent", `${sel.agent}${sel.saved ? " (saved)" : ""}`],
688
+ ["scope", sel.scope === "dir" ? `dir ${sel.root}` : sel.scope],
689
+ ["catalog", catalogLine(info(ctx))],
690
+ ]);
691
+ const width = Math.max(...results.map((r) => r.skill.length), 1);
692
+ for (const r of results)
693
+ printSkillResult(r, width, verb === "update" ? "update" : "install");
694
+ const conflicts = results.filter((r) => r.status === "conflict" && r.nextAction?.kind === "run");
695
+ if (conflicts.length > 0) {
696
+ const cmd = skillCommand(verb === "update" ? "update" : "install", conflicts.map((r) => r.skill), opts, true);
697
+ process.stderr.write(`\n overwrite ${conflicts.length > 1 ? "them" : "it"} with:\n ${cmd}\n`);
698
+ }
699
+ for (const r of results) {
700
+ if (r.status === "error" && r.nextAction?.kind === "run")
701
+ process.stderr.write(`\n next: ${r.nextAction.command}\n`);
702
+ }
703
+ }
704
+ function runNextAction(verb, results, opts) {
705
+ const conflicts = results.filter((r) => r.status === "conflict" && r.nextAction?.kind === "run");
706
+ if (conflicts.length > 0)
707
+ return { kind: "run", command: skillCommand(verb, conflicts.map((r) => r.skill), opts, true) };
708
+ const errored = results.find((r) => r.status === "error" && r.nextAction);
709
+ if (errored)
710
+ return errored.nextAction;
711
+ // Nothing to fix; an unmanaged copy that was not adopted still names how to.
712
+ return results.find((r) => r.unmanaged && r.nextAction)?.nextAction ?? null;
713
+ }
714
+ export async function runSkillInstall(names, opts, internal = {}) {
715
+ const sel = selectTarget(opts);
716
+ if ("error" in sel)
717
+ return reject(opts, sel.error, "invalid-agent");
718
+ let requested = typeof names === "string" ? [names] : names ?? [];
719
+ const bad = invalidName(requested);
720
+ if (bad !== null)
721
+ return reject(opts, invalidNameMessage(bad), "invalid-name");
722
+ const bundleDir = resolveBundleDir();
723
+ if (process.env[SKILLS_ENV] && !bundleDir) {
724
+ return reject(opts, `${SKILLS_ENV}=${process.env[SKILLS_ENV]} is not a directory`, "no-bundle");
725
+ }
726
+ const bundled = bundleDir ? listBundledSkills(bundleDir) : [];
727
+ const ctx = await loadCatalog(bundleDir, Boolean(internal.offline));
728
+ if (requested.length === 0) {
729
+ if (bundled.length === 1 && isSkillName(bundled[0]))
730
+ requested = [bundled[0]];
731
+ else if (bundled.length === 0 && !ctx.catalog) {
732
+ return reject(opts, `no bundled skills found and no catalog — this build ships none. Point ${SKILLS_ENV} at a skills/ directory to install from a checkout.`, "no-bundle");
733
+ }
734
+ else {
735
+ const choices = bundled.length > 1 ? bundled : Object.keys(ctx.catalog.skills).sort();
736
+ return reject(opts, `name a skill: ${choices.join(", ")}`, "ambiguous", { kind: "run", command: "dreamlake skill list" });
737
+ }
738
+ }
739
+ printHint(sel, opts);
740
+ const resolved = await resolvePayloads(requested, ctx, bundleDir);
741
+ const common = { agent: sel.agent, scope: sel.scope, catalog: info(ctx) };
742
+ if (isRejection(resolved))
743
+ return reject(opts, resolved.message, resolved.kind, resolved.nextAction, common);
744
+ const results = resolved.payloads.map((payload) => {
745
+ const owned = ownedTarget(sel.dir, payload.name);
746
+ const plan = planInstall(payload, owned.skillDir, Boolean(opts.force), Boolean(opts.allowDowngrade));
747
+ return applyPlan(payload, owned, plan, {
748
+ agent: sel.agent, scope: sel.scope, dir: sel.dir, verb: "install", opts, requiredBy: resolved.requiredBy.get(payload.name),
749
+ });
750
+ });
751
+ const status = aggregate(results);
752
+ const result = {
753
+ status,
754
+ ...common,
755
+ skills: results,
756
+ nextAction: runNextAction("install", results, opts),
757
+ ...(status === "error" ? { error: results.find((r) => r.status === "error").error, kind: results.find((r) => r.status === "error").kind } : {}),
758
+ ...(internal.init ? {
759
+ preferences: { ...internal.init.preferences, path: internal.init.path },
760
+ available: catalogOthers(ctx.catalog, results.map((r) => r.skill)),
761
+ } : {}),
762
+ };
763
+ const rc = status === "installed" || status === "exists" ? 0 : 1;
764
+ if (opts.json) {
765
+ emitJson(result);
766
+ return rc;
767
+ }
768
+ printRun(internal.init ? "init" : "install", requested, sel, ctx, results, opts);
769
+ if (internal.init)
770
+ printInitFooter(result);
771
+ return rc;
772
+ }
773
+ function catalogOthers(catalog, exclude) {
774
+ if (!catalog)
775
+ return [];
776
+ return Object.entries(catalog.skills)
777
+ .filter(([name]) => !exclude.includes(name))
778
+ .map(([name, entry]) => ({ name, description: entry.description }))
779
+ .sort((a, b) => a.name.localeCompare(b.name));
780
+ }
781
+ function printInitFooter(result) {
782
+ const prefs = result.preferences;
783
+ process.stdout.write(` saved ${prefs.agent}, ${prefs.scope} as the default for 'dreamlake skill' → ${prefs.path}\n`);
784
+ const others = result.available ?? [];
785
+ if (others.length === 0)
786
+ return;
787
+ const width = Math.max(...others.map((o) => o.name.length));
788
+ process.stdout.write(`\n more skills in the catalog${result.catalog?.version ? ` (${fmtVersion(result.catalog.version)})` : ""}:\n`);
789
+ for (const o of others)
790
+ process.stdout.write(` ${o.name.padEnd(width)} ${o.description}\n`);
791
+ process.stdout.write(`\n Install more with: dreamlake skill install <name>\n`);
792
+ }
793
+ // ─── update ──────────────────────────────────────────────────────────────────
794
+ /** Names of every manifest-bearing skill directory under one resolved skills directory. */
795
+ function managedSkills(dir) {
796
+ if (kindOf(dir) !== "dir")
797
+ return [];
798
+ const out = [];
799
+ for (const name of listDirNames(dir)) {
800
+ if (!isSkillName(name))
801
+ continue; // Not something this installer could have written.
802
+ try {
803
+ if (readManifest(path.join(dir, name)))
804
+ out.push(name);
805
+ }
806
+ catch {
807
+ out.push(name); // An invalid manifest still names a skill; update reports it.
808
+ }
809
+ }
810
+ return out.sort();
811
+ }
812
+ function listDirNames(dir) {
813
+ return readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
814
+ }
815
+ export async function runSkillUpdate(names, opts) {
816
+ const sel = selectTarget(opts);
817
+ if ("error" in sel)
818
+ return reject(opts, sel.error, "invalid-agent");
819
+ const bad = invalidName(names);
820
+ if (bad !== null)
821
+ return reject(opts, invalidNameMessage(bad), "invalid-name");
822
+ printHint(sel, opts);
823
+ const requested = names.length > 0 ? names : managedSkills(sel.dir);
824
+ const bundleDir = resolveBundleDir();
825
+ const ctx = await loadCatalog(bundleDir, false);
826
+ const common = { agent: sel.agent, scope: sel.scope, catalog: info(ctx) };
827
+ if (requested.length === 0) {
828
+ const result = { status: "exists", ...common, skills: [], nextAction: { kind: "run", command: "dreamlake skill list" } };
829
+ if (opts.json) {
830
+ emitJson(result);
831
+ return 0;
832
+ }
833
+ process.stdout.write(`skill update\n`);
834
+ header([["agent", sel.agent], ["scope", sel.scope === "dir" ? `dir ${sel.root}` : sel.scope]]);
835
+ warn(`no installed skills with a manifest under ${sel.dir}`);
836
+ process.stdout.write(`\n next: dreamlake skill list\n`);
837
+ return 0;
838
+ }
839
+ // Offline, the embedded copy may only stand in for a skill that was itself
840
+ // installed from the embedded copy (and then only if it is not older —
841
+ // planUpdate's guard). A skill installed from the release is updated from
842
+ // the release or not at all.
843
+ if (ctx.origin !== "release") {
844
+ const fromRelease = requested.filter((name) => {
845
+ try {
846
+ return readManifest(targetIn(sel.dir, name))?.source === "catalog";
847
+ }
848
+ catch {
849
+ return false; // An invalid manifest is reported by planUpdate.
850
+ }
851
+ });
852
+ if (fromRelease.length > 0) {
853
+ const why = ctx.unreachable ? `cannot reach the skills release (${ctx.unreachable})` : "this build has no catalog and the release was not consulted";
854
+ return reject(opts, `${why} — ${fromRelease.join(", ")} ${fromRelease.length > 1 ? "were" : "was"} installed from the release and can only be updated from it`, "catalog-unreachable", { kind: "download", url: manualDownloadUrl() }, common);
855
+ }
856
+ }
857
+ const resolved = await resolvePayloads(requested, ctx, bundleDir);
858
+ if (isRejection(resolved))
859
+ return reject(opts, resolved.message, resolved.kind, resolved.nextAction, common);
860
+ // `update` touches what was named (or installed); `requires` are not pulled in.
861
+ const payloads = resolved.payloads.filter((p) => requested.includes(p.name));
862
+ const results = payloads.map((payload) => {
863
+ const owned = ownedTarget(sel.dir, payload.name);
864
+ const plan = planUpdate(payload, owned.skillDir, Boolean(opts.force), Boolean(opts.allowDowngrade));
865
+ return applyPlan(payload, owned, plan, { agent: sel.agent, scope: sel.scope, dir: sel.dir, verb: "update", opts });
866
+ });
867
+ const status = aggregate(results);
868
+ const result = {
869
+ status,
870
+ ...common,
871
+ skills: results,
872
+ nextAction: runNextAction("update", results, opts),
873
+ ...(status === "error" ? { error: results.find((r) => r.status === "error").error, kind: results.find((r) => r.status === "error").kind } : {}),
874
+ };
875
+ const rc = status === "installed" || status === "exists" ? 0 : 1;
876
+ if (opts.json) {
877
+ emitJson(result);
878
+ return rc;
879
+ }
880
+ printRun("update", requested, sel, ctx, results, opts);
881
+ return rc;
882
+ }
883
+ // ─── remove ──────────────────────────────────────────────────────────────────
884
+ export async function runSkillRemove(name, opts) {
885
+ const sel = selectTarget(opts);
886
+ if ("error" in sel)
887
+ return reject(opts, sel.error, "invalid-agent");
888
+ if (!isSkillName(name))
889
+ return reject(opts, invalidNameMessage(name), "invalid-name");
890
+ printHint(sel, opts);
891
+ const owned = ownedTarget(sel.dir, name);
892
+ const target = owned.skillDir;
893
+ const base = { status: "removed", agent: sel.agent, scope: sel.scope, skill: name, target, nextAction: null };
894
+ const rejectRemove = (message, kind, nextAction = null) => {
895
+ if (opts.json) {
896
+ emitJson({ ...base, status: "error", error: message, kind, nextAction });
897
+ }
898
+ else {
899
+ fail(message);
900
+ if (nextAction?.kind === "run")
901
+ process.stderr.write(`\n next: ${nextAction.command}\n`);
902
+ }
903
+ return 1;
904
+ };
905
+ const kind = kindOf(target);
906
+ if (kind === "absent")
907
+ return rejectRemove(`${name} is not installed at ${target}`, "not-installed", { kind: "run", command: "dreamlake skill list" });
908
+ if (kind !== "dir")
909
+ return rejectRemove(`${target} exists and is not a directory — nothing to remove safely`, "not-a-directory");
910
+ let manifest;
911
+ try {
912
+ manifest = readManifest(target);
913
+ }
914
+ catch (err) {
915
+ return rejectRemove(`${err.file}: ${err.message}`, "invalid-manifest");
916
+ }
917
+ if (!manifest) {
918
+ return rejectRemove(`${target} has no ${MANIFEST_FILE} — it was not installed by dreamlake, so delete it yourself if you want it gone`, "unmanaged");
919
+ }
920
+ // Only a manifest-listed regular file whose hash still matches is deleted.
921
+ // Everything else — an edited file, a file the manifest never listed, a
922
+ // non-regular entry — is kept, and reported, because a user's edit is not
923
+ // ours to destroy and there is no flag that makes it so.
924
+ const deletable = [];
925
+ for (const [rel, hash] of Object.entries(manifest.files)) {
926
+ if (hasSymlinkAncestor(target, rel))
927
+ continue;
928
+ const local = path.join(target, rel);
929
+ if (kindOf(local) === "file" && hashFile(local) === hash)
930
+ deletable.push(rel);
931
+ }
932
+ const deleted = [];
933
+ try {
934
+ for (const rel of deletable) {
935
+ deleted.push(unlinkOwnedFile(owned, rel));
936
+ pruneEmptyDirs(owned, rel);
937
+ }
938
+ unlinkOwnedFile(owned, MANIFEST_FILE);
939
+ pruneEmptyDirs(owned, "x", true);
940
+ }
941
+ catch (err) {
942
+ const result = { ...base, status: "error", version: manifest.version, deleted, error: `cannot remove from ${target}: ${err.message}`, kind: "remove-failed", nextAction: null };
943
+ if (opts.json)
944
+ emitJson(result);
945
+ else
946
+ fail(result.error);
947
+ return 1;
948
+ }
949
+ const kept = kindOf(target) === "dir" ? localExtras(target, new Set()) : [];
950
+ const result = { ...base, status: "removed", version: manifest.version, deleted, kept, nextAction: null };
951
+ if (opts.json) {
952
+ emitJson(result);
953
+ return 0;
954
+ }
955
+ process.stdout.write(`skill remove ${name}\n`);
956
+ header([
957
+ ["agent", `${sel.agent}${sel.saved ? " (saved)" : ""}`],
958
+ ["scope", sel.scope === "dir" ? `dir ${sel.root}` : sel.scope],
959
+ ["target", target],
960
+ ]);
961
+ ok(`removed ${deleted.length} file(s) of ${manifest.source} ${fmtVersion(manifest.version)}`);
962
+ if (kept.length > 0) {
963
+ warn(`${kept.length} file(s) kept — edited, or not part of this skill:`);
964
+ for (const rel of kept)
965
+ process.stdout.write(` · ${rel}\n`);
966
+ if (kept.includes("SKILL.md")) {
967
+ warn(`SKILL.md was kept, so the agent still discovers this skill — delete ${target} yourself to remove it fully`);
968
+ }
969
+ }
970
+ return 0;
971
+ }
972
+ // ─── list ────────────────────────────────────────────────────────────────────
973
+ function scopeState(target, verify) {
974
+ const kind = kindOf(target);
975
+ if (kind === "absent")
976
+ return { path: target, state: "absent", version: null };
977
+ if (kind !== "dir")
978
+ return { path: target, state: "blocked", version: null };
979
+ let manifest;
980
+ try {
981
+ manifest = readManifest(target);
982
+ }
983
+ catch (err) {
984
+ return { path: target, state: "unmanaged", version: null, error: err.message };
985
+ }
986
+ if (!manifest)
987
+ return { path: target, state: "unmanaged", version: null };
988
+ if (!verify)
989
+ return { path: target, state: "installed", version: manifest.version };
990
+ for (const [rel, hash] of Object.entries(manifest.files)) {
991
+ const local = path.join(target, rel);
992
+ if (hasSymlinkAncestor(target, rel) || kindOf(local) !== "file" || hashFile(local) !== hash) {
993
+ return { path: target, state: "modified", version: manifest.version };
994
+ }
995
+ }
996
+ return { path: target, state: "installed", version: manifest.version };
997
+ }
998
+ /** Catalog rows with installed state at both scopes for one agent. */
999
+ export function installedSkillEntries(agent, options = {}) {
1000
+ const bundleDir = resolveBundleDir();
1001
+ const snapshot = snapshotCatalog(bundleDir);
1002
+ const bundled = bundleDir ? listBundledSkills(bundleDir) : [];
1003
+ const embeddedVer = bundleDir ? embeddedVersion(bundleDir) : null;
1004
+ const latest = options.latest ?? null;
1005
+ const verify = options.verify ?? true;
1006
+ const projectDir = skillsDir(options.cwd ?? process.cwd(), agent);
1007
+ const globalDir = skillsDir(os.homedir(), agent);
1008
+ const names = [...new Set([
1009
+ ...Object.keys(snapshot?.skills ?? {}),
1010
+ ...bundled,
1011
+ ...Object.keys(latest?.skills ?? {}),
1012
+ ])].filter(isSkillName).sort();
1013
+ return names.map((name) => {
1014
+ const entry = latest?.skills[name] ?? snapshot?.skills[name];
1015
+ const embedded = bundled.includes(name);
1016
+ const latestVersion = latest?.skills[name] ? latest.version
1017
+ : embedded && embeddedVer ? embeddedVer
1018
+ : snapshot?.skills[name] ? snapshot.version : null;
1019
+ return {
1020
+ name,
1021
+ description: entry?.description ?? "",
1022
+ requires: entry?.requires ?? [],
1023
+ files: embedded ? bundledFiles(bundleDir, name).length : catalogFileCount(entry),
1024
+ embedded,
1025
+ latest: latestVersion,
1026
+ project: scopeState(targetIn(projectDir, name), verify),
1027
+ global: scopeState(targetIn(globalDir, name), verify),
1028
+ };
1029
+ });
1030
+ }
1031
+ export async function runSkillList(opts) {
1032
+ const sel = selectTarget(opts);
1033
+ if ("error" in sel)
1034
+ return reject(opts, sel.error, "invalid-agent");
1035
+ const bundleDir = resolveBundleDir();
1036
+ if (process.env[SKILLS_ENV] && !bundleDir) {
1037
+ return reject(opts, `${SKILLS_ENV}=${process.env[SKILLS_ENV]} is not a directory`, "no-bundle");
1038
+ }
1039
+ const snapshot = snapshotCatalog(bundleDir);
1040
+ if (!bundleDir && !snapshot) {
1041
+ return reject(opts, `no bundled skills found — this build ships none. Point ${SKILLS_ENV} at a skills/ directory to install from a checkout.`, "no-bundle");
1042
+ }
1043
+ printHint(sel, opts);
1044
+ let latest;
1045
+ let refreshed = null;
1046
+ if (opts.refresh) {
1047
+ try {
1048
+ refreshed = await fetchLatestCatalog();
1049
+ latest = { version: refreshed.version, origin: "release" };
1050
+ }
1051
+ catch (err) {
1052
+ latest = { error: err.message, url: catalogUrl() };
1053
+ }
1054
+ }
1055
+ const entries = installedSkillEntries(sel.agent, { latest: refreshed });
1056
+ // One next action, and only when there is something to do. A skill with a
1057
+ // manifest at either scope is present, even if edited; `update` handles it.
1058
+ const present = (s) => s.state === "installed" || s.state === "modified";
1059
+ const pending = entries.find((e) => !present(e.project) && !present(e.global));
1060
+ const nextAction = pending
1061
+ ? { kind: "run", command: installCommand(pending.name, opts, false) }
1062
+ : null;
1063
+ const result = {
1064
+ status: "ok",
1065
+ source: bundleDir,
1066
+ agent: sel.agent,
1067
+ catalog: { version: snapshot?.version ?? null, origin: snapshot ? "embedded" : "none" },
1068
+ ...(latest ? { latest } : {}),
1069
+ skills: entries,
1070
+ nextAction,
1071
+ };
1072
+ if (opts.json) {
1073
+ emitJson(result);
1074
+ return 0;
1075
+ }
1076
+ process.stdout.write(`skill list\n`);
1077
+ header([
1078
+ ["agent", `${sel.agent}${sel.saved ? " (saved)" : ""}`],
1079
+ ["source", bundleDir ?? "none"],
1080
+ ["catalog", snapshot ? `${fmtVersion(snapshot.version)} (embedded snapshot)` : "none"],
1081
+ ...(latest ? [["latest", "version" in latest ? `${fmtVersion(latest.version)} (release)` : `unreachable — ${latest.error}`]] : []),
1082
+ ]);
1083
+ if (latest && "error" in latest)
1084
+ warn(`could not refresh the catalog; showing the embedded snapshot`);
1085
+ if (entries.length === 0) {
1086
+ warn("this build bundles no skills");
1087
+ return 0;
1088
+ }
1089
+ const label = (s) => ({
1090
+ absent: "not installed",
1091
+ installed: `installed ${fmtVersion(s.version)}`,
1092
+ modified: `modified ${fmtVersion(s.version)}`,
1093
+ blocked: "blocked (not a directory)",
1094
+ unmanaged: "unmanaged (no manifest)",
1095
+ })[s.state];
1096
+ const width = Math.max(...entries.map((e) => e.name.length));
1097
+ const stateWidth = Math.max(...entries.flatMap((e) => [label(e.project).length, label(e.global).length]));
1098
+ for (const e of entries) {
1099
+ const meta = [e.latest ? fmtVersion(e.latest) : "", e.files !== null ? `${e.files} files` : "", e.embedded ? "embedded" : ""]
1100
+ .filter(Boolean).join(" ");
1101
+ process.stdout.write(`\n ${e.name.padEnd(width)} ${meta}\n`);
1102
+ if (e.description)
1103
+ process.stdout.write(` ${e.description}\n`);
1104
+ process.stdout.write(` project ${label(e.project).padEnd(stateWidth)} ${e.project.path}\n`);
1105
+ process.stdout.write(` global ${label(e.global).padEnd(stateWidth)} ${e.global.path}\n`);
1106
+ }
1107
+ if (nextAction)
1108
+ process.stdout.write(`\n next: ${nextAction.command}\n`);
1109
+ return 0;
1110
+ }
1111
+ export async function runSkillInit(opts, io = {
1112
+ interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
1113
+ agent: () => select({ message: "Which agent?", choices: [
1114
+ { name: "Codex", value: "codex" }, { name: "Claude Code", value: "claude" },
1115
+ ] }),
1116
+ global: () => select({ message: "Where should skills be installed?", choices: [
1117
+ { name: "This project", value: false }, { name: "All projects (global)", value: true },
1118
+ ] }),
1119
+ }) {
1120
+ if (opts.agent !== undefined) {
1121
+ if (!isAgent(opts.agent))
1122
+ return reject(opts, "--agent must be claude or codex", "invalid-agent");
1123
+ return initInstall(opts, { agent: opts.agent, scope: opts.global && !opts.dir && !opts.project ? "global" : "project" });
1124
+ }
1125
+ if (!io.interactive || Object.values(opts).some((v) => v !== undefined && v !== false)) {
1126
+ return reject(opts, "specify --agent codex or --agent claude for non-interactive setup", "agent-required", { kind: "run", command: "dreamlake init --agent codex" });
1127
+ }
1128
+ let agent;
1129
+ let global;
1130
+ try {
1131
+ agent = await io.agent();
1132
+ global = await io.global();
1133
+ }
1134
+ catch {
1135
+ return reject(opts, "setup canceled; no skill files were written", "canceled");
1136
+ }
1137
+ return initInstall({ ...opts, agent, global }, { agent, scope: global ? "global" : "project" });
1138
+ }
1139
+ function initInstall(opts, preferences) {
1140
+ let saved;
1141
+ try {
1142
+ saved = writeSkillPreferences(preferences);
1143
+ }
1144
+ catch (err) {
1145
+ return Promise.resolve(reject(opts, `cannot save skill preferences: ${err.message}`, "preferences-unwritable"));
1146
+ }
1147
+ return runSkillInstall(EMBEDDED_SKILL, opts, { offline: true, init: { preferences, path: saved } });
1148
+ }
1149
+ // ─── registration ────────────────────────────────────────────────────────────
1150
+ //
1151
+ // NO `--version` OPTION HERE, EVER. `program.version(VERSION, "-v, --version")`
1152
+ // (src/cli/index.ts:61) is resolved from any descendant command, so declaring
1153
+ // one would make `dreamlake skill install --version` print 0.6.0 and exit 0
1154
+ // having installed nothing — the exact failure the docs' `runnable import
1155
+ // --version` drift produced.
1156
+ function scopeOptions(command) {
1157
+ return command
1158
+ .option("--agent <agent>", "target agent: claude or codex (default: what dreamlake init saved, else claude)")
1159
+ .option("--global", "use your home directory instead of the current project")
1160
+ .option("--project", "use the current project even if dreamlake init chose global")
1161
+ .option("--dir <path>", "use this project root; overrides --global and --project");
1162
+ }
1163
+ function installationOptions(command) {
1164
+ return scopeOptions(command)
1165
+ .option("--force", "overwrite files that differ; files the skill does not own are kept")
1166
+ .option("--allow-downgrade", "replace an installed skill with an older version, or one whose version cannot be ordered against it")
1167
+ .option("--json", "emit one result object without interactive prompts");
1168
+ }
1169
+ export function registerSkillCommand(program) {
1170
+ program.command("init")
1171
+ .description("set up agent skills: choose an agent and scope, install the embedded dreamlake-cli skill offline")
1172
+ .option("--agent <agent>", "claude or codex; saved as the default for 'dreamlake skill' and skips the prompts")
1173
+ .option("--global", "install under your home directory and save global scope")
1174
+ .option("--dir <path>", "install under this project root; overrides --global")
1175
+ .option("--force", "overwrite files that differ; files the skill does not own are kept")
1176
+ .option("--json", "emit one result object without interactive prompts")
1177
+ .action(async (opts) => {
1178
+ process.exitCode = await runSkillInit(opts);
1179
+ });
1180
+ const skill = program.command("skill")
1181
+ .description("install, update, remove and list agent skills from the dreamlake-skills release")
1182
+ .addHelpText("after", `
1183
+ Claude Code uses .claude/skills/; Codex uses .agents/skills/.
1184
+ 'dreamlake init' saves the default agent and scope; --agent, --global, --project and --dir override it.
1185
+ install and update download from the public release; dreamlake-cli is embedded and installs offline.
1186
+ Every install writes <skill>/.dreamlake-skill.json; update and remove touch only files it lists.
1187
+ remove never deletes a file you edited: it is kept and reported.
1188
+ `);
1189
+ installationOptions(skill.command("install")
1190
+ .description("install skills (and what they require) from the release; embedded dreamlake-cli when current")
1191
+ .argument("[names...]", "skill names; omit to install the embedded dreamlake-cli"))
1192
+ .action(async (names, opts) => {
1193
+ process.exitCode = await runSkillInstall(names, opts);
1194
+ });
1195
+ installationOptions(skill.command("update")
1196
+ .description("update installed skills: overwrite unchanged files, delete retired ones, report edited ones")
1197
+ .argument("[names...]", "skill names; omit to update every skill with a manifest in the selected scope"))
1198
+ .action(async (names, opts) => {
1199
+ process.exitCode = await runSkillUpdate(names, opts);
1200
+ });
1201
+ scopeOptions(skill.command("remove")
1202
+ .description("remove an installed skill: delete the manifest-listed files you did not edit; keep and report the rest")
1203
+ .argument("<name>", "skill name"))
1204
+ .option("--json", "emit one result object")
1205
+ .action(async (name, opts) => {
1206
+ process.exitCode = await runSkillRemove(name, opts);
1207
+ });
1208
+ collectionList(skill, "list")
1209
+ .description("show the catalog with project/global installation status")
1210
+ .option("--agent <agent>", "target agent: claude or codex (default: what dreamlake init saved, else claude)")
1211
+ .option("--refresh", "fetch the latest catalog from the release and show it next to the installed versions")
1212
+ .option("--json", "emit one result object")
1213
+ .action(async (opts) => {
1214
+ process.exitCode = await runSkillList(opts);
1215
+ });
1216
+ }