@cnc-tools/storm 0.16.0 → 0.18.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 (290) hide show
  1. package/dist/bin/storm.js +54 -40
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-24UYAK4R.js} +465 -365
  4. package/dist/chunks/{chunk-DC2CDHNK.js → chunk-2JMWUKH3.js} +2074 -473
  5. package/dist/chunks/{chunk-FOZWA52V.js → chunk-3VXZONGE.js} +481 -376
  6. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-55O4FCN4.js} +1 -1
  7. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  8. package/dist/chunks/chunk-AS37D43E.js +2173 -0
  9. package/dist/chunks/chunk-CQAY6GLP.js +1260 -0
  10. package/dist/chunks/chunk-DZLU7BYK.js +340 -0
  11. package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
  12. package/dist/chunks/{chunk-TJNFVNKR.js → chunk-EI3XDCEI.js} +1 -1
  13. package/dist/chunks/{chunk-HVNK3I45.js → chunk-FDUY3BNF.js} +1 -1
  14. package/dist/chunks/{chunk-FCQUJDA4.js → chunk-GUCCYCIO.js} +4 -189
  15. package/dist/chunks/{chunk-OIY3DMF2.js → chunk-HBI4LEMH.js} +3 -3
  16. package/dist/chunks/{chunk-2MAD5NKK.js → chunk-K4MDQPLW.js} +1 -18
  17. package/dist/chunks/chunk-KK7PAWIZ.js +198 -0
  18. package/dist/chunks/{chunk-G3PHMXH5.js → chunk-KQ5FXRUD.js} +18 -1
  19. package/dist/chunks/{chunk-5VXBKPW6.js → chunk-LKXHGGGX.js} +1 -1
  20. package/dist/chunks/{chunk-P357TZAY.js → chunk-LOGHIUUB.js} +21 -18
  21. package/dist/chunks/{chunk-CK2GZEPK.js → chunk-OEPFINFT.js} +2 -2
  22. package/dist/chunks/{chunk-DWEAHX4T.js → chunk-OI4AP6Z7.js} +5 -5
  23. package/dist/chunks/{chunk-V4IKA3WI.js → chunk-PMBQWVTW.js} +26 -19
  24. package/dist/chunks/chunk-SZMYIIG2.js +88 -0
  25. package/dist/chunks/{chunk-5CCP36QQ.js → chunk-TXCOFC7N.js} +1 -1
  26. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-UXD3TVWM.js} +1 -1
  27. package/dist/chunks/{chunk-3L52KNQA.js → chunk-WNW2QXQK.js} +8 -8
  28. package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
  29. package/dist/chunks/{live-app-WECQOQ4C.js → live-app-UY7BEDUN.js} +17 -13
  30. package/dist/cli.d.ts +28 -0
  31. package/dist/cli.js +64 -0
  32. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +2 -2
  33. package/dist/commands/exec/across-sandboxes-outcomes.js +3 -3
  34. package/dist/commands/exec/before-run.d.ts +123 -0
  35. package/dist/commands/exec/before-run.js +105 -0
  36. package/dist/commands/exec/command.d.ts +67 -14
  37. package/dist/commands/exec/command.js +31 -95
  38. package/dist/commands/exec/driver-plan.d.ts +9 -4
  39. package/dist/commands/exec/driver-plan.js +8 -8
  40. package/dist/commands/exec/exec-words.js +1 -1
  41. package/dist/commands/exec/execute-run.d.ts +39 -0
  42. package/dist/commands/exec/execute-run.js +325 -0
  43. package/dist/commands/exec/live-view.d.ts +3 -3
  44. package/dist/commands/exec/live-view.js +16 -15
  45. package/dist/commands/exec/metadata.js +1 -1
  46. package/dist/commands/exec/mint-failed.d.ts +38 -0
  47. package/dist/commands/exec/mint-failed.js +27 -4
  48. package/dist/commands/exec/outcomes.d.ts +104 -22
  49. package/dist/commands/exec/outcomes.js +73 -26
  50. package/dist/commands/exec/plan-run.d.ts +58 -150
  51. package/dist/commands/exec/plan-run.js +239 -90
  52. package/dist/commands/exec/progress.d.ts +10 -6
  53. package/dist/commands/exec/progress.js +38 -25
  54. package/dist/commands/exec/run-bin.d.ts +11 -11
  55. package/dist/commands/exec/run-bin.js +9 -9
  56. package/dist/commands/exec/run-flags.d.ts +69 -0
  57. package/dist/commands/exec/run-flags.js +58 -0
  58. package/dist/commands/exec/run-metadata.js +4 -4
  59. package/dist/commands/exec/run-summary.d.ts +58 -0
  60. package/dist/commands/exec/run-summary.js +205 -0
  61. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  62. package/dist/commands/exec/runner-refusals.js +71 -0
  63. package/dist/commands/exec/sandbox-progress.js +3 -0
  64. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  65. package/dist/commands/exec/stopped-outcome.js +77 -0
  66. package/dist/commands/exec/view.d.ts +20 -11
  67. package/dist/commands/exec/view.js +103 -47
  68. package/dist/commands/runs/facts.d.ts +8 -4
  69. package/dist/commands/runs/facts.js +19 -10
  70. package/dist/commands/runs/list/command.d.ts +16 -8
  71. package/dist/commands/runs/list/command.js +10 -10
  72. package/dist/commands/runs/list/outcomes.d.ts +8 -4
  73. package/dist/commands/runs/logs/command.js +10 -10
  74. package/dist/commands/runs/show/command.d.ts +16 -8
  75. package/dist/commands/runs/show/command.js +31 -29
  76. package/dist/commands/runs/show/metadata.js +1 -1
  77. package/dist/commands/runs/show/outcomes.d.ts +8 -4
  78. package/dist/commands/runs/show/outcomes.js +8 -6
  79. package/dist/commands/snapshots/access.d.ts +111 -0
  80. package/dist/commands/snapshots/access.js +96 -0
  81. package/dist/commands/snapshots/build/command.d.ts +376 -101
  82. package/dist/commands/snapshots/build/command.js +447 -149
  83. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  84. package/dist/commands/snapshots/build/metadata.js +31 -11
  85. package/dist/commands/snapshots/build/outcomes.d.ts +242 -47
  86. package/dist/commands/snapshots/build/outcomes.js +200 -36
  87. package/dist/commands/snapshots/list/command.d.ts +368 -27
  88. package/dist/commands/snapshots/list/command.js +298 -68
  89. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  90. package/dist/commands/snapshots/list/metadata.js +29 -6
  91. package/dist/commands/snapshots/list/outcomes.d.ts +247 -15
  92. package/dist/commands/snapshots/list/outcomes.js +223 -52
  93. package/dist/commands/snapshots/metadata.js +1 -1
  94. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  95. package/dist/commands/snapshots/prune/command.js +161 -0
  96. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  97. package/dist/commands/snapshots/prune/metadata.js +39 -0
  98. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  99. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  100. package/dist/commands/suites/list/command.js +17 -17
  101. package/dist/commands/suites/list/outcomes.js +2 -2
  102. package/dist/commands/test/command.d.ts +67 -14
  103. package/dist/commands/test/command.js +49 -252
  104. package/dist/commands/test/outcomes.d.ts +33 -7
  105. package/dist/config/check-runner.d.ts +3 -3
  106. package/dist/config/check-runner.js +8 -7
  107. package/dist/config/credential-resolver.d.ts +50 -5
  108. package/dist/config/credential-resolver.js +51 -19
  109. package/dist/config/credential-settle.d.ts +6 -2
  110. package/dist/config/credential-settle.js +11 -5
  111. package/dist/config/index.d.ts +2 -2
  112. package/dist/config/index.js +1 -1
  113. package/dist/config/runner.d.ts +5 -5
  114. package/dist/config/runner.js +1 -1
  115. package/dist/config/schema.d.ts +2 -2
  116. package/dist/config/schema.js +1 -1
  117. package/dist/config-file/define.d.ts +1 -1
  118. package/dist/config-file/define.js +1 -1
  119. package/dist/config-file/runner.d.ts +5 -5
  120. package/dist/config-file/toolchain.d.ts +14 -4
  121. package/dist/config-file/toolchain.js +43 -7
  122. package/dist/context.d.ts +10 -6
  123. package/dist/context.js +8 -6
  124. package/dist/core/across-sandboxes.d.ts +7 -6
  125. package/dist/core/across-sandboxes.js +123 -152
  126. package/dist/core/coordinator.d.ts +166 -0
  127. package/dist/core/coordinator.js +233 -0
  128. package/dist/core/events.d.ts +2 -2
  129. package/dist/core/index.d.ts +4 -2
  130. package/dist/core/index.js +1 -1
  131. package/dist/core/outcomes.d.ts +148 -0
  132. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  133. package/dist/core/resources.d.ts +31 -53
  134. package/dist/core/resources.js +32 -70
  135. package/dist/core/run-state.d.ts +7 -1
  136. package/dist/core/run-state.js +2 -0
  137. package/dist/core/run.d.ts +32 -236
  138. package/dist/core/run.js +107 -267
  139. package/dist/core/state-directory.d.ts +1 -1
  140. package/dist/core/state-directory.js +2 -2
  141. package/dist/credential/gateways.d.ts +15 -1
  142. package/dist/credential/index.d.ts +4 -3
  143. package/dist/credential/index.js +3 -2
  144. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  145. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  146. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  147. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  148. package/dist/credential/source.d.ts +73 -6
  149. package/dist/credential/source.js +55 -2
  150. package/dist/extension-commands.d.ts +1 -1
  151. package/dist/extension-commands.js +2 -2
  152. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  153. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  154. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  155. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  156. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  157. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  158. package/dist/extensions/testserver/credential-facts.js +29 -11
  159. package/dist/extensions/testserver/lifecycle.js +7 -1
  160. package/dist/extensions/testserver/limit.d.ts +3 -0
  161. package/dist/extensions/testserver/limit.js +3 -0
  162. package/dist/extensions/testserver/provision.d.ts +8 -1
  163. package/dist/extensions/testserver/provision.js +8 -3
  164. package/dist/extensions/testserver/refusals.d.ts +6 -1
  165. package/dist/extensions/testserver/refusals.js +16 -1
  166. package/dist/extensions/testserver/resource.d.ts +1 -1
  167. package/dist/extensions/testserver/resource.js +1 -1
  168. package/dist/extensions/testserver/result.d.ts +1 -1
  169. package/dist/extensions/testserver/result.js +9 -4
  170. package/dist/planning/driver-file-lists.d.ts +0 -15
  171. package/dist/planning/driver-file-lists.js +2 -21
  172. package/dist/planning/plan-only.d.ts +3 -14
  173. package/dist/planning/plan-only.js +11 -20
  174. package/dist/planning/run-kind-flags.js +2 -2
  175. package/dist/planning/run-plan.d.ts +45 -12
  176. package/dist/planning/run-plan.js +4 -3
  177. package/dist/planning/suites.d.ts +1 -1
  178. package/dist/planning/suites.js +2 -2
  179. package/dist/planning/test-plan.d.ts +9 -0
  180. package/dist/planning/test-plan.js +9 -0
  181. package/dist/run-directory/recording.js +3 -3
  182. package/dist/run-directory/run-record.d.ts +26 -11
  183. package/dist/run-directory/run-record.js +16 -13
  184. package/dist/runner/base.js +1 -1
  185. package/dist/runner/build-snapshots.d.ts +60 -29
  186. package/dist/runner/build-snapshots.js +136 -29
  187. package/dist/runner/context.d.ts +15 -7
  188. package/dist/runner/context.js +19 -6
  189. package/dist/runner/events.d.ts +16 -10
  190. package/dist/runner/gateways.d.ts +122 -23
  191. package/dist/runner/gateways.js +1 -1
  192. package/dist/runner/gh.d.ts +42 -0
  193. package/dist/runner/gh.js +58 -0
  194. package/dist/runner/index.d.ts +13 -8
  195. package/dist/runner/index.js +12 -6
  196. package/dist/runner/live/checkout-gateway.js +7 -0
  197. package/dist/runner/live/gh-output.d.ts +17 -0
  198. package/dist/runner/live/gh-output.js +37 -0
  199. package/dist/runner/live/gh-token-gateway.d.ts +13 -0
  200. package/dist/runner/live/gh-token-gateway.js +51 -0
  201. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  202. package/dist/runner/live/sandbox-errors.js +4 -0
  203. package/dist/runner/live/sandbox-gateway.js +140 -4
  204. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  205. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  206. package/dist/runner/live/snapshot-records.js +12 -12
  207. package/dist/runner/local-snapshot-index.d.ts +205 -0
  208. package/dist/runner/local-snapshot-index.js +210 -0
  209. package/dist/runner/network-policy.d.ts +6 -6
  210. package/dist/runner/network-policy.js +7 -7
  211. package/dist/runner/policy-writes.d.ts +1 -1
  212. package/dist/runner/policy-writes.js +1 -1
  213. package/dist/runner/prepare.d.ts +14 -14
  214. package/dist/runner/prepare.js +20 -11
  215. package/dist/runner/ready.d.ts +19 -11
  216. package/dist/runner/ready.js +104 -33
  217. package/dist/runner/sandboxed-command.d.ts +3 -3
  218. package/dist/runner/sandboxed-command.js +3 -3
  219. package/dist/runner/scope.d.ts +15 -8
  220. package/dist/runner/scope.js +16 -5
  221. package/dist/runner/secrets.d.ts +41 -18
  222. package/dist/runner/secrets.js +226 -30
  223. package/dist/runner/session.d.ts +8 -8
  224. package/dist/runner/session.js +6 -3
  225. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  226. package/dist/runner/shared-snapshot-entry.js +168 -0
  227. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  228. package/dist/runner/shared-snapshot-list.js +155 -0
  229. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  230. package/dist/runner/shared-snapshot-lookup.js +118 -0
  231. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  232. package/dist/runner/shared-snapshot-prune.js +133 -0
  233. package/dist/runner/snapshot-build.d.ts +42 -14
  234. package/dist/runner/snapshot-build.js +79 -47
  235. package/dist/runner/snapshot-choice.js +2 -1
  236. package/dist/runner/snapshot-inspect.d.ts +39 -40
  237. package/dist/runner/snapshot-inspect.js +52 -35
  238. package/dist/runner/snapshot-key.d.ts +32 -17
  239. package/dist/runner/snapshot-key.js +43 -18
  240. package/dist/runner/snapshot-source.d.ts +31 -0
  241. package/dist/runner/snapshot-source.js +122 -0
  242. package/dist/runner/steps.d.ts +1 -1
  243. package/dist/runner/steps.js +1 -1
  244. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +4 -2
  245. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +7 -2
  246. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +59 -28
  247. package/dist/runner/{recipe.js → vercel-sandbox-options.js} +128 -84
  248. package/dist/runner/vercel-sandbox-secrets.d.ts +116 -0
  249. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +159 -26
  250. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  251. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  252. package/dist/sdk/extension/credential-source.d.ts +20 -3
  253. package/dist/sdk/extension/credential-source.js +4 -4
  254. package/dist/sdk/extension/index.d.ts +3 -2
  255. package/dist/sdk/extension/index.js +2 -1
  256. package/dist/sdk/extension/resource-definition.d.ts +1 -1
  257. package/dist/sdk/extension/secret-source.d.ts +1 -1
  258. package/dist/sdk/extension/secret-source.js +1 -1
  259. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  260. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  261. package/dist/shared/cleanup.d.ts +3 -3
  262. package/dist/shared/cleanup.js +15 -5
  263. package/dist/shared/snapshot-text.d.ts +4 -4
  264. package/dist/shared/snapshot-text.js +11 -11
  265. package/dist/time/duration.js +1 -1
  266. package/package.json +5 -3
  267. package/skills/overview.md +4 -4
  268. package/skills/plan-runs.md +1 -1
  269. package/skills/read-run-output.md +6 -6
  270. package/dist/application.d.ts +0 -21
  271. package/dist/application.js +0 -30
  272. package/dist/chunks/chunk-7EENF73W.js +0 -782
  273. package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
  274. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  275. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  276. package/dist/commands/exec/plan-only.d.ts +0 -10
  277. package/dist/commands/exec/plan-only.js +0 -45
  278. package/dist/commands/exec/run-command.d.ts +0 -475
  279. package/dist/commands/exec/run-command.js +0 -603
  280. package/dist/commands/exec/run-planned.d.ts +0 -20
  281. package/dist/commands/exec/run-planned.js +0 -22
  282. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  283. package/dist/commands/exec/sandbox-view.js +0 -72
  284. package/dist/commands/test/plan.d.ts +0 -92
  285. package/dist/commands/test/plan.js +0 -125
  286. package/dist/core/sandbox-end.d.ts +0 -64
  287. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  288. package/dist/runner/recipe-secrets.d.ts +0 -67
  289. package/dist/runner/snapshot-cache.d.ts +0 -148
  290. package/dist/runner/snapshot-cache.js +0 -126
@@ -1,198 +1,3 @@
1
- // ../../../libs/clinkr/ts/dist/outcomes/steps.js
2
- import { z } from "zod";
3
- var stepDocumentSchema = z.discriminatedUnion("type", [
4
- z.object({
5
- type: z.enum(["command", "external"]),
6
- command: z.string(),
7
- argv: z.array(z.string()),
8
- when: z.string().optional()
9
- }),
10
- z.object({ type: z.literal("url"), url: z.string() }),
11
- z.object({ type: z.literal("text"), text: z.string() })
12
- ]);
13
- var SHELL_SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/u;
14
- function commandLine(argv) {
15
- return argv.map((argument) => SHELL_SAFE.test(argument) ? argument : `'${argument.replaceAll("'", `'"'"'`)}'`).join(" ");
16
- }
17
- function stepDocument(step) {
18
- switch (step.type) {
19
- case "command":
20
- case "external":
21
- return {
22
- type: step.type,
23
- command: commandLine(step.argv),
24
- argv: [...step.argv],
25
- ...step.when === void 0 ? {} : { when: step.when }
26
- };
27
- case "url":
28
- return { type: "url", url: step.url };
29
- case "text":
30
- return { type: "text", text: step.text };
31
- }
32
- }
33
-
34
- // ../../../libs/clinkr/ts/dist/outcomes/present.js
35
- var LABEL_WIDTH = 16;
36
- var MAXIMUM_LIST_ITEMS = 5;
37
- var MAXIMUM_RECOVERY_STEPS = 2;
38
- function presentContent(content, options) {
39
- const { done, rows = [], sections = [], table, text, message, warnings = [], next = [] } = content;
40
- const report = [];
41
- let stdout = "";
42
- if (text !== void 0) {
43
- stdout = text;
44
- } else if (done === void 0) {
45
- const answer = [
46
- formatRows(printable(rows)).join("\n"),
47
- ...sections.map((section2) => [` ${section2.heading}`, ...formatRows(printable(section2.rows))].join("\n")),
48
- table === void 0 ? "" : formatTable(table, {
49
- padded: options.stdoutTerminal,
50
- links: options.stdoutTerminal && options.stdoutLinks === true
51
- })
52
- ];
53
- stdout = answer.filter((part) => part !== "").join("\n\n");
54
- } else {
55
- if (options.doneOnStdout)
56
- stdout = typeof done[1] === "string" ? done[1] : done[1].join("\n");
57
- const [doneLine = "", ...rowLines] = formatRows([done, ...printable(rows)]);
58
- const lines = [`\u2713${doneLine.slice(1)}`, ...rowLines];
59
- if (table !== void 0)
60
- lines.push("", formatTable(table, { padded: true, links: options.stderrLinks === true }));
61
- report.push(lines.join("\n"));
62
- }
63
- if (message !== void 0)
64
- report.push(` ${indent(message, 2)}`);
65
- if (warnings.length > 0)
66
- report.push(warnings.map((warning) => `! ${indent(warning.message, 2)}`).join("\n"));
67
- if (next.length > 0)
68
- report.push(formatSteps(next).join("\n"));
69
- return { stdout, stderr: report.join("\n\n") };
70
- }
71
- function presentError({ message, rows, next, rowLimit }) {
72
- const shown = printable(rows);
73
- const more = rowLimit === void 0 ? 0 : shown.length - rowLimit;
74
- const lines = [`\u2717 ${indent(message, 2)}`, ...formatRows(more > 0 ? shown.slice(0, rowLimit) : shown)];
75
- if (more > 0)
76
- lines.push(` and ${more} more`);
77
- if (next.length > 0)
78
- lines.push("", ...formatSteps(next.slice(0, MAXIMUM_RECOVERY_STEPS)));
79
- return lines.join("\n");
80
- }
81
- function presentCanceled({ message, changed }) {
82
- const lines = [` ${indent(message, 2)}`];
83
- if (changed !== void 0)
84
- lines.push(` ${indent(changed, 2)}`);
85
- return lines.join("\n");
86
- }
87
- function documentFrom(outcome, content) {
88
- const { warnings = [], next = [] } = content;
89
- return {
90
- ...outcome.value,
91
- outcome: outcome.name,
92
- ...warnings.length === 0 ? {} : { warnings: warnings.map(({ reason, message }) => ({ reason, message })) },
93
- ...next.length === 0 ? {} : { next: next.map(stepDocument) }
94
- };
95
- }
96
- function errorDocument(error) {
97
- const { message, data, next = [], status = "error" } = error.content;
98
- return {
99
- status,
100
- reason: error.reason,
101
- message,
102
- ...next.length === 0 ? {} : { next: next.map(stepDocument) },
103
- ...data === void 0 ? {} : { data }
104
- };
105
- }
106
- function indent(text, column) {
107
- return text.split("\n").join(`
108
- ${" ".repeat(column)}`);
109
- }
110
- function listLines(items) {
111
- const more = items.length - MAXIMUM_LIST_ITEMS;
112
- return [...items.slice(0, MAXIMUM_LIST_ITEMS), ...more > 0 ? [`and ${more} more`] : []];
113
- }
114
- function printable(rows) {
115
- return rows.filter(([, value]) => value.length > 0);
116
- }
117
- function formatRows(rows) {
118
- const width = Math.max(LABEL_WIDTH, ...rows.map(([label]) => label.length + 2));
119
- return rows.map(([label, value]) => {
120
- const text = typeof value === "string" ? value : listLines(value).join("\n");
121
- return ` ${label.padEnd(width)}${indent(text, 2 + width)}`;
122
- });
123
- }
124
- function formatSteps(steps) {
125
- const lines = [];
126
- let previous;
127
- for (const step of steps) {
128
- if (step.type === "text") {
129
- lines.push(` ${indent(step.text, 2)}`);
130
- previous = void 0;
131
- continue;
132
- }
133
- if (step.label !== previous)
134
- lines.push(` ${step.label}:`);
135
- previous = step.label;
136
- lines.push(` ${step.type === "url" ? step.url : commandLine(step.argv)}`);
137
- }
138
- return lines;
139
- }
140
- function formatTable(table, options) {
141
- const lines = [table.columns, ...table.rows];
142
- if (!options.padded)
143
- return lines.map((row) => row.map(cellText).join(" ")).join("\n");
144
- const widths = table.columns.map((column, index) => Math.max(column.length, ...table.rows.map((row) => cellText(row[index] ?? "").length)));
145
- return lines.map((row) => {
146
- const cells = row.map((cell, index) => {
147
- const drawn = drawnCell(cell, options.links);
148
- return index === row.length - 1 ? drawn : drawn + " ".repeat(widths[index] + 2 - cellText(cell).length);
149
- });
150
- return ` ${cells.join("")}`;
151
- }).join("\n");
152
- }
153
- function cellText(cell) {
154
- return typeof cell === "string" ? cell : cell.text;
155
- }
156
- function hasControlCharacter(text) {
157
- for (const char of text) {
158
- const code2 = char.codePointAt(0) ?? 0;
159
- if (code2 < 32 || code2 >= 127 && code2 <= 159)
160
- return true;
161
- }
162
- return false;
163
- }
164
- function drawnCell(cell, links) {
165
- if (typeof cell === "string")
166
- return cell;
167
- if (!links || hasControlCharacter(cell.url))
168
- return cell.text;
169
- return `\x1B]8;;${cell.url}\x1B\\${cell.text}\x1B]8;;\x1B\\`;
170
- }
171
-
172
- // ../../../libs/clinkr/ts/dist/outcomes/rendered.js
173
- function createOutcomeRenderer() {
174
- return (content) => Object.freeze({
175
- content,
176
- draw: (terminal) => {
177
- const { stdout, stderr } = presentContent(content, {
178
- stdoutTerminal: terminal.stdout.tty,
179
- doneOnStdout: false,
180
- stdoutLinks: takesLinks(terminal.stdout),
181
- stderrLinks: takesLinks(terminal.stderr)
182
- });
183
- return stdout === "" ? { report: stderr } : { report: stderr, answer: stdout };
184
- }
185
- });
186
- }
187
- function takesLinks(stream) {
188
- return stream.tty && stream.color !== "none";
189
- }
190
- var renderOutcome = createOutcomeRenderer();
191
- var plainUi = Object.freeze({
192
- error: (view) => [presentError(view), view.usage, view.stack].filter((block) => block !== void 0).join("\n\n"),
193
- canceled: presentCanceled
194
- });
195
-
196
1
  // ../../../libs/clinkr/ts/dist/outcomes/names.js
197
2
  var CAMEL_CASE = /^[a-z][a-zA-Z0-9]*$/u;
198
3
  var SNAKE_CASE = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/u;
@@ -215,7 +20,7 @@ function checkKeys(subject, keys, reserved) {
215
20
  }
216
21
 
217
22
  // ../../../libs/clinkr/ts/dist/outcomes/schema-code.js
218
- import { z as z2 } from "zod";
23
+ import { z } from "zod";
219
24
  var RULE = [
220
25
  "Command schemas check only shape: types, built-in checks such as min(1) and formats such as z.email(), defaults,",
221
26
  "enums, positionals, and overwrite normalizers such as trim().",
@@ -263,7 +68,7 @@ function schemaCodeProblems(label, schema, ancestors = /* @__PURE__ */ new Set()
263
68
  return [];
264
69
  const def = schema._zod.def;
265
70
  const checks = schema._zod.def.checks ?? [];
266
- const customFormat = schema instanceof z2.ZodCustomStringFormat || checks.some((check) => check instanceof z2.ZodCustomStringFormat);
71
+ const customFormat = schema instanceof z.ZodCustomStringFormat || checks.some((check) => check instanceof z.ZodCustomStringFormat);
267
72
  const found = [
268
73
  ...checks.some((check) => check._zod.def.check === "custom") ? ["a refinement (.refine, .superRefine, or .check)"] : [],
269
74
  ...customFormat ? ["a custom string format (z.stringFormat)"] : [],
@@ -298,11 +103,11 @@ function assertNoSchemaCode(problems) {
298
103
  }
299
104
 
300
105
  // ../../../libs/clinkr/ts/dist/outcomes/values.js
301
- import { z as z3 } from "zod";
106
+ import { z as z2 } from "zod";
302
107
  var OutcomeValueError = class extends Error {
303
108
  constructor(name, cause) {
304
109
  super(`Outcome ${name} value does not match its schema:
305
- ${z3.prettifyError(cause)}`, { cause });
110
+ ${z2.prettifyError(cause)}`, { cause });
306
111
  this.name = "OutcomeValueError";
307
112
  }
308
113
  };
@@ -366,32 +171,227 @@ function buildError(reason, definition, facts) {
366
171
  };
367
172
  return { kind: "error", reason, exitCode: definition.exitCode, content };
368
173
  }
369
- function defineErrors(definitions) {
370
- const keys = Object.keys(definitions);
371
- checkKeys("Error", keys, []);
372
- const named = keys.map((key) => {
373
- const reason = snakeCase(key);
374
- const definition = declareError(reason, definitions[key]);
375
- const { schema } = definition;
376
- if (schema !== void 0)
377
- assertNoSchemaCode(schemaCodeProblems(`${reason} error data`, schema));
378
- const build = (...facts) => buildError(reason, definition, facts);
379
- return [key, Object.freeze(Object.assign(build, { reason, definition }))];
174
+ function defineErrors(definitions) {
175
+ const keys = Object.keys(definitions);
176
+ checkKeys("Error", keys, []);
177
+ const named = keys.map((key) => {
178
+ const reason = snakeCase(key);
179
+ const definition = declareError(reason, definitions[key]);
180
+ const { schema } = definition;
181
+ if (schema !== void 0)
182
+ assertNoSchemaCode(schemaCodeProblems(`${reason} error data`, schema));
183
+ const build = (...facts) => buildError(reason, definition, facts);
184
+ return [key, Object.freeze(Object.assign(build, { reason, definition }))];
185
+ });
186
+ return Object.freeze(Object.fromEntries(named));
187
+ }
188
+ function isSharedError(value) {
189
+ if (typeof value !== "function")
190
+ return false;
191
+ const { reason, definition } = value;
192
+ if (typeof reason !== "string" || typeof definition !== "object" || definition === null)
193
+ return false;
194
+ const { exitCode } = definition;
195
+ return exitCode === 1 || exitCode === 2;
196
+ }
197
+ function isCommandError(value) {
198
+ return typeof value === "object" && value !== null && value.kind === "error";
199
+ }
200
+
201
+ // ../../../libs/clinkr/ts/dist/outcomes/steps.js
202
+ import { z as z3 } from "zod";
203
+ var stepDocumentSchema = z3.discriminatedUnion("type", [
204
+ z3.object({
205
+ type: z3.enum(["command", "external"]),
206
+ command: z3.string(),
207
+ argv: z3.array(z3.string()),
208
+ when: z3.string().optional()
209
+ }),
210
+ z3.object({ type: z3.literal("url"), url: z3.string() }),
211
+ z3.object({ type: z3.literal("text"), text: z3.string() })
212
+ ]);
213
+ var SHELL_SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/u;
214
+ function commandLine(argv) {
215
+ return argv.map((argument) => SHELL_SAFE.test(argument) ? argument : `'${argument.replaceAll("'", `'"'"'`)}'`).join(" ");
216
+ }
217
+ function stepDocument(step) {
218
+ switch (step.type) {
219
+ case "command":
220
+ case "external":
221
+ return {
222
+ type: step.type,
223
+ command: commandLine(step.argv),
224
+ argv: [...step.argv],
225
+ ...step.when === void 0 ? {} : { when: step.when }
226
+ };
227
+ case "url":
228
+ return { type: "url", url: step.url };
229
+ case "text":
230
+ return { type: "text", text: step.text };
231
+ }
232
+ }
233
+
234
+ // ../../../libs/clinkr/ts/dist/outcomes/present.js
235
+ var LABEL_WIDTH = 16;
236
+ var MAXIMUM_LIST_ITEMS = 5;
237
+ var MAXIMUM_RECOVERY_STEPS = 2;
238
+ function presentContent(content, options) {
239
+ const { done, rows = [], sections = [], table, text, message, warnings = [], next = [] } = content;
240
+ const report = [];
241
+ let stdout = "";
242
+ if (text !== void 0) {
243
+ stdout = text;
244
+ } else if (done === void 0) {
245
+ const answer = [
246
+ formatRows(printable(rows)).join("\n"),
247
+ ...sections.map((section2) => [` ${section2.heading}`, ...formatRows(printable(section2.rows))].join("\n")),
248
+ table === void 0 ? "" : formatTable(table, {
249
+ padded: options.stdoutTerminal,
250
+ links: options.stdoutTerminal && options.stdoutLinks === true
251
+ })
252
+ ];
253
+ stdout = answer.filter((part) => part !== "").join("\n\n");
254
+ } else {
255
+ if (options.doneOnStdout)
256
+ stdout = typeof done[1] === "string" ? done[1] : done[1].join("\n");
257
+ const [doneLine = "", ...rowLines] = formatRows([done, ...printable(rows)]);
258
+ const lines = [`\u2713${doneLine.slice(1)}`, ...rowLines];
259
+ if (table !== void 0)
260
+ lines.push("", formatTable(table, { padded: true, links: options.stderrLinks === true }));
261
+ report.push(lines.join("\n"));
262
+ }
263
+ if (message !== void 0)
264
+ report.push(` ${indent(message, 2)}`);
265
+ if (warnings.length > 0)
266
+ report.push(warnings.map((warning) => `! ${indent(warning.message, 2)}`).join("\n"));
267
+ if (next.length > 0)
268
+ report.push(formatSteps(next).join("\n"));
269
+ return { stdout, stderr: report.join("\n\n") };
270
+ }
271
+ function presentError({ message, rows, next, rowLimit }) {
272
+ const shown = printable(rows);
273
+ const more = rowLimit === void 0 ? 0 : shown.length - rowLimit;
274
+ const lines = [`\u2717 ${indent(message, 2)}`, ...formatRows(more > 0 ? shown.slice(0, rowLimit) : shown)];
275
+ if (more > 0)
276
+ lines.push(` and ${more} more`);
277
+ if (next.length > 0)
278
+ lines.push("", ...formatSteps(next.slice(0, MAXIMUM_RECOVERY_STEPS)));
279
+ return lines.join("\n");
280
+ }
281
+ function presentCanceled({ message, changed }) {
282
+ const lines = [` ${indent(message, 2)}`];
283
+ if (changed !== void 0)
284
+ lines.push(` ${indent(changed, 2)}`);
285
+ return lines.join("\n");
286
+ }
287
+ function documentFrom(outcome, content) {
288
+ const { warnings = [], next = [] } = content;
289
+ return {
290
+ ...outcome.value,
291
+ outcome: outcome.name,
292
+ ...warnings.length === 0 ? {} : { warnings: warnings.map(({ reason, message }) => ({ reason, message })) },
293
+ ...next.length === 0 ? {} : { next: next.map(stepDocument) }
294
+ };
295
+ }
296
+ function errorDocument(error) {
297
+ const { message, data, next = [], status = "error" } = error.content;
298
+ return {
299
+ status,
300
+ reason: error.reason,
301
+ message,
302
+ ...next.length === 0 ? {} : { next: next.map(stepDocument) },
303
+ ...data === void 0 ? {} : { data }
304
+ };
305
+ }
306
+ function indent(text, column) {
307
+ return text.split("\n").join(`
308
+ ${" ".repeat(column)}`);
309
+ }
310
+ function listLines(items) {
311
+ const more = items.length - MAXIMUM_LIST_ITEMS;
312
+ return [...items.slice(0, MAXIMUM_LIST_ITEMS), ...more > 0 ? [`and ${more} more`] : []];
313
+ }
314
+ function printable(rows) {
315
+ return rows.filter(([, value]) => value.length > 0);
316
+ }
317
+ function formatRows(rows) {
318
+ const width = Math.max(LABEL_WIDTH, ...rows.map(([label]) => label.length + 2));
319
+ return rows.map(([label, value]) => {
320
+ const text = typeof value === "string" ? value : listLines(value).join("\n");
321
+ return ` ${label.padEnd(width)}${indent(text, 2 + width)}`;
322
+ });
323
+ }
324
+ function formatSteps(steps) {
325
+ const lines = [];
326
+ let previous;
327
+ for (const step of steps) {
328
+ if (step.type === "text") {
329
+ lines.push(` ${indent(step.text, 2)}`);
330
+ previous = void 0;
331
+ continue;
332
+ }
333
+ if (step.label !== previous)
334
+ lines.push(` ${step.label}:`);
335
+ previous = step.label;
336
+ lines.push(` ${step.type === "url" ? step.url : commandLine(step.argv)}`);
337
+ }
338
+ return lines;
339
+ }
340
+ function formatTable(table, options) {
341
+ const lines = [table.columns, ...table.rows];
342
+ if (!options.padded)
343
+ return lines.map((row) => row.map(cellText).join(" ")).join("\n");
344
+ const widths = table.columns.map((column, index) => Math.max(column.length, ...table.rows.map((row) => cellText(row[index] ?? "").length)));
345
+ return lines.map((row) => {
346
+ const cells = row.map((cell, index) => {
347
+ const drawn = drawnCell(cell, options.links);
348
+ return index === row.length - 1 ? drawn : drawn + " ".repeat(widths[index] + 2 - cellText(cell).length);
349
+ });
350
+ return ` ${cells.join("")}`;
351
+ }).join("\n");
352
+ }
353
+ function cellText(cell) {
354
+ return typeof cell === "string" ? cell : cell.text;
355
+ }
356
+ function hasControlCharacter(text) {
357
+ for (const char of text) {
358
+ const code2 = char.codePointAt(0) ?? 0;
359
+ if (code2 < 32 || code2 >= 127 && code2 <= 159)
360
+ return true;
361
+ }
362
+ return false;
363
+ }
364
+ function drawnCell(cell, links) {
365
+ if (typeof cell === "string")
366
+ return cell;
367
+ if (!links || hasControlCharacter(cell.url))
368
+ return cell.text;
369
+ return `\x1B]8;;${cell.url}\x1B\\${cell.text}\x1B]8;;\x1B\\`;
370
+ }
371
+
372
+ // ../../../libs/clinkr/ts/dist/outcomes/rendered.js
373
+ function createOutcomeRenderer() {
374
+ return (content) => Object.freeze({
375
+ content,
376
+ draw: (terminal) => {
377
+ const { stdout, stderr } = presentContent(content, {
378
+ stdoutTerminal: terminal.stdout.tty,
379
+ doneOnStdout: false,
380
+ stdoutLinks: takesLinks(terminal.stdout),
381
+ stderrLinks: takesLinks(terminal.stderr)
382
+ });
383
+ return stdout === "" ? { report: stderr } : { report: stderr, answer: stdout };
384
+ }
380
385
  });
381
- return Object.freeze(Object.fromEntries(named));
382
- }
383
- function isSharedError(value) {
384
- if (typeof value !== "function")
385
- return false;
386
- const { reason, definition } = value;
387
- if (typeof reason !== "string" || typeof definition !== "object" || definition === null)
388
- return false;
389
- const { exitCode } = definition;
390
- return exitCode === 1 || exitCode === 2;
391
386
  }
392
- function isCommandError(value) {
393
- return typeof value === "object" && value !== null && value.kind === "error";
387
+ function takesLinks(stream) {
388
+ return stream.tty && stream.color !== "none";
394
389
  }
390
+ var renderOutcome = createOutcomeRenderer();
391
+ var plainUi = Object.freeze({
392
+ error: (view) => [presentError(view), view.usage, view.stack].filter((block) => block !== void 0).join("\n\n"),
393
+ canceled: presentCanceled
394
+ });
395
395
 
396
396
  // ../../../libs/clinkr/ts/dist/outcomes/outcomes.js
397
397
  import { z as z5 } from "zod";
@@ -716,58 +716,6 @@ function checkContent(name, content) {
716
716
  return content;
717
717
  }
718
718
 
719
- // ../../../libs/clinkr/ts/dist/terminal.js
720
- var PIPE = Object.freeze({ tty: false, columns: void 0, color: "none" });
721
- function createTerminal(facts = {}) {
722
- return Object.freeze({
723
- interactive: facts.interactive ?? false,
724
- unicode: facts.unicode ?? true,
725
- stdout: Object.freeze({ ...PIPE, ...facts.stdout }),
726
- stderr: Object.freeze({ ...PIPE, ...facts.stderr })
727
- });
728
- }
729
- function withoutColor(terminal) {
730
- return Object.freeze({
731
- ...terminal,
732
- stdout: Object.freeze({ ...terminal.stdout, color: "none" }),
733
- stderr: Object.freeze({ ...terminal.stderr, color: "none" })
734
- });
735
- }
736
- function scriptReadsStdout(terminal) {
737
- return !terminal.stdout.tty || !terminal.interactive;
738
- }
739
- function resolveColorDepth(facts) {
740
- const { env } = facts;
741
- const noColor = env["NO_COLOR"];
742
- if (noColor !== void 0 && noColor !== "")
743
- return "none";
744
- const forced = env["FORCE_COLOR"];
745
- if (forced !== void 0 && forced !== "") {
746
- if (forced === "0" || forced === "false")
747
- return "none";
748
- if (forced === "2")
749
- return "ansi256";
750
- if (forced === "3")
751
- return "truecolor";
752
- return "ansi16";
753
- }
754
- const term = env["TERM"];
755
- if (!facts.tty || term === "dumb")
756
- return "none";
757
- const colorterm = env["COLORTERM"];
758
- if (colorterm === "truecolor" || colorterm === "24bit")
759
- return "truecolor";
760
- if (term !== void 0 && term.includes("256color"))
761
- return "ansi256";
762
- return "ansi16";
763
- }
764
- function resolveUnicode(env) {
765
- const locale = [env["LC_ALL"], env["LC_CTYPE"], env["LANG"]].find((value) => value !== void 0 && value !== "");
766
- if (locale === void 0)
767
- return true;
768
- return /utf-?8/iu.test(locale);
769
- }
770
-
771
719
  // ../../../libs/clinkr/ts/dist/command-tree.js
772
720
  import { isAbsolute } from "node:path";
773
721
 
@@ -1584,9 +1532,15 @@ function commandTree(tree) {
1584
1532
  if (typeof directory !== "string" || !isAbsolute(directory))
1585
1533
  throw new Error(`Command tree ${tag.id}: directory takes an absolute path`);
1586
1534
  return Object.freeze({ kind: "directory", tree: tag.id, directory });
1587
- }
1535
+ },
1536
+ manifest: (commands) => createManifestGroup(tag.id, commands)
1588
1537
  });
1589
1538
  }
1539
+ function createManifestGroup(treeId, commands) {
1540
+ if (typeof commands !== "object" || commands === null || Array.isArray(commands))
1541
+ throw new TypeError(`Command tree ${treeId}: manifest takes a record of names to manifest entries`);
1542
+ return Object.freeze({ kind: "manifest", tree: treeId, commands: Object.freeze({ ...commands }) });
1543
+ }
1590
1544
  var GROUP_KEYS = ["commands", ...GROUP_NAVIGATION_KEYS];
1591
1545
  function groupNavigation(treeId, navigation) {
1592
1546
  const unknown = Object.keys(navigation).filter((key) => !GROUP_KEYS.includes(key));
@@ -1607,21 +1561,19 @@ function isTreeGroup(value) {
1607
1561
  const { kind, tree, navigation } = value;
1608
1562
  if (typeof tree !== "string")
1609
1563
  return false;
1610
- return kind === "directory" || kind === "inline-group" && typeof navigation === "object" && navigation !== null;
1564
+ return kind === "directory" || kind === "manifest" || kind === "inline-group" && typeof navigation === "object" && navigation !== null;
1611
1565
  }
1612
1566
  function mount(group, options) {
1613
1567
  if (!isTreeGroup(group))
1614
- throw new TypeError("mount takes a group from a command tree's group or directory");
1568
+ throw new TypeError("mount takes a group from a command tree's group, directory, or manifest");
1615
1569
  return Object.freeze({ ...options, group });
1616
1570
  }
1617
1571
 
1618
1572
  // ../../../libs/clinkr/ts/dist/create-application.js
1619
- import { readdir as readdir3, stat as stat2 } from "node:fs/promises";
1620
- import { join as join4 } from "node:path";
1573
+ import { stat as stat2 } from "node:fs/promises";
1621
1574
 
1622
1575
  // ../../../libs/clinkr/ts/dist/discovery.js
1623
- import { readdir, stat } from "node:fs/promises";
1624
- import { basename, join } from "node:path";
1576
+ import { basename as basename2 } from "node:path";
1625
1577
  import { pathToFileURL } from "node:url";
1626
1578
 
1627
1579
  // ../../../libs/clinkr/ts/dist/is-listed.js
@@ -1638,6 +1590,67 @@ function defaultCommandOf(nodes) {
1638
1590
  return nodes.find((node) => isDefaultCommand(node) && isListed(node));
1639
1591
  }
1640
1592
 
1593
+ // ../../../libs/clinkr/ts/dist/layout.js
1594
+ import { readdir, readFile, stat } from "node:fs/promises";
1595
+ import { basename, isAbsolute as isAbsolute2, join } from "node:path";
1596
+ function compareCodeUnits(left, right) {
1597
+ return left < right ? -1 : left > right ? 1 : 0;
1598
+ }
1599
+ function isMissing(error) {
1600
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
1601
+ }
1602
+ async function findModule(directory, stem) {
1603
+ const typescript = join(directory, `${stem}.ts`);
1604
+ if (await isFile(typescript))
1605
+ return typescript;
1606
+ const javascript = join(directory, `${stem}.js`);
1607
+ if (await isFile(javascript))
1608
+ return javascript;
1609
+ return void 0;
1610
+ }
1611
+ async function isFile(path) {
1612
+ try {
1613
+ return (await stat(path)).isFile();
1614
+ } catch (error) {
1615
+ if (isMissing(error))
1616
+ return false;
1617
+ throw error;
1618
+ }
1619
+ }
1620
+ async function listCommandDirectoryNames(directory) {
1621
+ const entries = await readdir(directory, { withFileTypes: true });
1622
+ return Object.freeze(entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).toSorted(compareCodeUnits));
1623
+ }
1624
+ async function inspectCommandDirectoryNode(parentDirectory, name) {
1625
+ const directory = join(parentDirectory, name);
1626
+ const metadataPath = await findModule(directory, "metadata");
1627
+ if (metadataPath === void 0) {
1628
+ throw new Error(`Missing metadata.ts or metadata.js for command node: ${directory}`);
1629
+ }
1630
+ const commandPath = await findModule(directory, "command");
1631
+ if (commandPath === void 0) {
1632
+ return Object.freeze({ kind: "group", name, directory, metadataPath });
1633
+ }
1634
+ const entries = await readdir(directory, { withFileTypes: true });
1635
+ if (entries.some((entry) => entry.isDirectory())) {
1636
+ throw new Error(`Command node cannot contain ${basename(commandPath)} and child commands: ${directory}`);
1637
+ }
1638
+ return Object.freeze({ kind: "leaf", name, directory, metadataPath, commandPath });
1639
+ }
1640
+ async function listSkillFiles(directory) {
1641
+ if (typeof directory !== "string" || !isAbsolute2(directory)) {
1642
+ throw new Error(`skills must be an absolute directory path; received ${JSON.stringify(directory)}`);
1643
+ }
1644
+ let entries;
1645
+ try {
1646
+ entries = await readdir(directory, { withFileTypes: true });
1647
+ } catch (cause) {
1648
+ throw new Error(`Unable to read the skills directory ${directory}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
1649
+ }
1650
+ const names = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md") && !entry.name.startsWith(".")).map((entry) => entry.name).toSorted(compareCodeUnits);
1651
+ return Object.freeze(names.map((name) => Object.freeze({ name, path: join(directory, name) })));
1652
+ }
1653
+
1641
1654
  // ../../../libs/clinkr/ts/dist/discovery.js
1642
1655
  function isGroup(node) {
1643
1656
  return node.description.kind === "group";
@@ -1648,9 +1661,6 @@ function sourceOf(group) {
1648
1661
  function matchesName(node, segment) {
1649
1662
  return node.description.name === segment || commandAliases(node.description).includes(segment);
1650
1663
  }
1651
- function compareCodeUnits(left, right) {
1652
- return left < right ? -1 : left > right ? 1 : 0;
1653
- }
1654
1664
  function undeclaredSection(section2, declared) {
1655
1665
  if (section2 === void 0 || declared === void 0 || declared.has(section2))
1656
1666
  return void 0;
@@ -1668,7 +1678,11 @@ var SourceDiscoveryError = class extends Error {
1668
1678
  }
1669
1679
  };
1670
1680
  function discoverGroup(group, scope, prefix = []) {
1671
- return group.kind === "directory" ? discoverChildren(scope, prefix, group.directory) : inlineChildren(scope, group, prefix);
1681
+ if (group.kind === "directory")
1682
+ return discoverChildren(scope, prefix, group.directory);
1683
+ if (group.kind === "manifest")
1684
+ return manifestChildren(scope, group.commands, prefix);
1685
+ return inlineChildren(scope, group, prefix);
1672
1686
  }
1673
1687
  async function atLocation(source, location, read) {
1674
1688
  try {
@@ -1687,11 +1701,11 @@ function checkedSiblings(scope, prefix, read) {
1687
1701
  return Object.freeze(nodes);
1688
1702
  });
1689
1703
  }
1690
- function checkNode(scope, { name, metadata, metadataPath }, leaf) {
1704
+ function checkNode(scope, { name, metadata, metadataLabel }, leaf) {
1691
1705
  const undeclared2 = undeclaredSection(metadata.helpSection, scope.declaredSections);
1692
1706
  if (undeclared2 !== void 0)
1693
- throw new Error(`${undeclared2}${metadataPath === void 0 ? "" : ` in ${metadataPath}`}`);
1694
- const at = metadataPath === void 0 ? "" : ` (${metadataPath})`;
1707
+ throw new Error(`${undeclared2}${metadataLabel === void 0 ? "" : ` in ${metadataLabel}`}`);
1708
+ const at = metadataLabel === void 0 ? "" : ` (${metadataLabel})`;
1695
1709
  if (leaf) {
1696
1710
  if (metadata.default === true && metadata.hidden === true)
1697
1711
  throw new Error(`Command ${name} cannot be both default and hidden${at}`);
@@ -1727,14 +1741,23 @@ async function groupNode(scope, found, children2) {
1727
1741
  function inlineChildren(scope, group, prefix) {
1728
1742
  return checkedSiblings(scope, prefix, () => Promise.all(Object.keys(group.commands).toSorted(compareCodeUnits).map((name) => inlineNode(scope, name, group.commands[name], prefix))));
1729
1743
  }
1744
+ function checkCommandName(name) {
1745
+ if (!isCommandNameSegment(name))
1746
+ throw new Error(`Invalid command name ${JSON.stringify(name)}: names are nonempty, without whitespace, control characters, or separators, and are not . or .. or begin with -`);
1747
+ }
1748
+ function parseCommandMetadata(value, where) {
1749
+ const result = commandMetadataSchema.safeParse(value);
1750
+ if (!result.success)
1751
+ throw new Error(`Invalid metadata ${where}: ${navigationIssues(result.error, "metadata")}`);
1752
+ return Object.freeze(result.data);
1753
+ }
1730
1754
  function inlineNode(scope, name, member, prefix) {
1731
1755
  const location = [...prefix, name];
1732
1756
  return atLocation(scope.source, location, async () => {
1733
- if (!isCommandNameSegment(name))
1734
- throw new Error(`Invalid command name ${JSON.stringify(name)}: names are nonempty, without whitespace, control characters, or separators, and are not . or .. or begin with -`);
1757
+ checkCommandName(name);
1735
1758
  const value = member;
1736
- if (isTreeGroup(value) && value.kind === "directory")
1737
- throw new Error("A group's commands hold commands and inline groups; mount a directory group with mount");
1759
+ if (isTreeGroup(value) && (value.kind === "directory" || value.kind === "manifest"))
1760
+ throw new Error("A group's commands hold commands and inline groups; mount a directory or manifest group with mount");
1738
1761
  if (isTreeGroup(member)) {
1739
1762
  const group = member;
1740
1763
  return groupNode(scope, inlineFound(name, member.navigation, location), () => inlineChildren(scope, group, location));
@@ -1751,32 +1774,73 @@ function inlineFound(name, navigation, location) {
1751
1774
  throw new Error("A group's commands and nested groups each need a description in their definition");
1752
1775
  return { name, metadata: Object.freeze({ ...navigation, description }), where: location.join(" ") };
1753
1776
  }
1777
+ function manifestChildren(scope, commands, prefix) {
1778
+ return checkedSiblings(scope, prefix, () => Promise.all(Object.keys(commands).toSorted(compareCodeUnits).map((name) => manifestNode(scope, name, commands[name], prefix))));
1779
+ }
1780
+ function manifestNode(scope, name, entry, prefix) {
1781
+ const location = [...prefix, name];
1782
+ const label = location.join("/");
1783
+ return atLocation(scope.source, location, async () => {
1784
+ checkCommandName(name);
1785
+ if (typeof entry !== "object" || entry === null)
1786
+ throw new Error(`Invalid manifest entry for ${label}: expected { metadata, load } or { metadata, commands }`);
1787
+ const candidate = entry;
1788
+ const metadata = parseCommandMetadata(candidate.metadata, `for ${label}`);
1789
+ const hasLoad = candidate.load !== void 0;
1790
+ const hasCommands = candidate.commands !== void 0;
1791
+ if (hasLoad && hasCommands)
1792
+ throw new Error(`Manifest entry ${label} cannot declare both load and commands; set one of them`);
1793
+ if (!hasLoad && !hasCommands)
1794
+ throw new Error(`Manifest entry ${label} must declare either load (leaf) or commands (group)`);
1795
+ const metadataLabel = `manifest entry ${label} metadata`;
1796
+ const found = { name, metadata, metadataLabel, where: location.join(" ") };
1797
+ if (hasLoad) {
1798
+ if (typeof candidate.load !== "function")
1799
+ throw new Error(`Manifest entry ${label}: load must be a function returning the command module`);
1800
+ const load = candidate.load;
1801
+ const treeId = scope.source.id;
1802
+ const commandLabel = `manifest entry ${label} command`;
1803
+ return leafNode(scope, found, location, async () => {
1804
+ const module = await load();
1805
+ return commandOfModule({
1806
+ treeId,
1807
+ metadata,
1808
+ exported: module?.default,
1809
+ metadataLabel,
1810
+ metadataName: "metadata",
1811
+ commandLabel
1812
+ });
1813
+ });
1814
+ }
1815
+ if (typeof candidate.commands !== "object" || candidate.commands === null || Array.isArray(candidate.commands))
1816
+ throw new Error(`Manifest entry ${label}: commands must be a record of names to manifest entries`);
1817
+ const children2 = candidate.commands;
1818
+ return groupNode(scope, found, () => manifestChildren(scope, children2, location));
1819
+ });
1820
+ }
1754
1821
  async function discoverChildren(scope, prefix, directory) {
1755
1822
  return checkedSiblings(scope, prefix, async () => {
1756
- const entries = await readdir(directory, { withFileTypes: true });
1757
- const directories = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).toSorted(compareCodeUnits);
1823
+ const directories = await listCommandDirectoryNames(directory);
1758
1824
  return Promise.all(directories.map((name) => discoverNode(scope, name, prefix, directory)));
1759
1825
  });
1760
1826
  }
1761
1827
  function discoverNode(scope, name, prefix, parentDirectory) {
1762
- const directory = join(parentDirectory, name);
1763
1828
  const location = [...prefix, name];
1764
1829
  return atLocation(scope.source, location, async () => {
1765
- const metadataPath = await findModule(directory, "metadata");
1766
- if (metadataPath === void 0)
1767
- throw new Error(`Missing metadata.ts or metadata.js for command node: ${directory}`);
1768
- const metadata = await loadMetadata(metadataPath);
1769
- const found = { name, metadata, metadataPath, where: directory };
1770
- const entries = await readdir(directory, { withFileTypes: true });
1771
- const hasChildDirectories = entries.some((entry) => entry.isDirectory());
1772
- const commandModule = await findModule(directory, "command");
1773
- if (commandModule === void 0)
1774
- return groupNode(scope, found, () => discoverChildren(scope, location, directory));
1775
- if (hasChildDirectories)
1776
- throw new Error(`Command node cannot contain ${basename(commandModule)} and child commands: ${directory}`);
1830
+ const inspected = await inspectCommandDirectoryNode(parentDirectory, name);
1831
+ const metadata = await loadMetadata(inspected.metadataPath);
1832
+ const found = {
1833
+ name,
1834
+ metadata,
1835
+ metadataLabel: inspected.metadataPath,
1836
+ where: inspected.directory
1837
+ };
1838
+ if (inspected.kind === "group") {
1839
+ return groupNode(scope, found, () => discoverChildren(scope, location, inspected.directory));
1840
+ }
1777
1841
  const treeId = scope.source.id;
1778
- const root = scope.source.directory ?? directory;
1779
- return leafNode(scope, found, location, () => importCommand(treeId, root, metadata, metadataPath, commandModule));
1842
+ const root = scope.source.directory ?? inspected.directory;
1843
+ return leafNode(scope, found, location, () => importCommand(treeId, root, metadata, inspected.metadataPath, inspected.commandPath));
1780
1844
  });
1781
1845
  }
1782
1846
  function checkAliasConflicts(nodes, prefix) {
@@ -1806,59 +1870,42 @@ function checkDefaultConflicts(nodes, prefix) {
1806
1870
  }
1807
1871
  async function loadMetadata(path) {
1808
1872
  const module = await import(pathToFileURL(path).href);
1809
- const result = commandMetadataSchema.safeParse(module.metadata);
1810
- if (!result.success)
1811
- throw new Error(`Invalid metadata export in ${path}: ${navigationIssues(result.error, "metadata")}`);
1812
- return Object.freeze(result.data);
1873
+ return parseCommandMetadata(module.metadata, `export in ${path}`);
1813
1874
  }
1814
1875
  async function importCommand(treeId, directory, metadata, metadataPath, modulePath) {
1815
1876
  const module = await import(pathToFileURL(modulePath).href);
1816
- return commandOfModule({ treeId, directory, metadata, metadataPath, modulePath, exported: module.default });
1877
+ return commandOfModule({
1878
+ treeId,
1879
+ directory,
1880
+ metadata,
1881
+ metadataLabel: metadataPath,
1882
+ commandLabel: modulePath,
1883
+ exported: module.default
1884
+ });
1817
1885
  }
1818
1886
  function commandOfModule(module) {
1819
- const { treeId, metadata, exported, metadataPath, modulePath, directory } = module;
1887
+ const { treeId, metadata, exported, metadataLabel, metadataName, commandLabel, directory } = module;
1820
1888
  if (!isOutcomeCommandDefinition(exported))
1821
- throw new Error(`Invalid command export in ${modulePath}: export default ${treeId}.define({ \u2026 })`);
1889
+ throw new Error(`Invalid command export in ${commandLabel}: export default ${treeId}.define({ \u2026 })`);
1822
1890
  const tag = treeTagOf(exported);
1823
1891
  if (tag === void 0)
1824
- throw new Error(`Invalid command export in ${modulePath}: define it with command tree ${treeId}'s define`);
1892
+ throw new Error(`Invalid command export in ${commandLabel}: define it with command tree ${treeId}'s define`);
1825
1893
  if (tag.id !== treeId)
1826
- throw new Error(`Invalid command export in ${modulePath}: it belongs to command tree ${tag.id}, not to command tree ${treeId}${directory === void 0 ? "" : ` (${directory})`}`);
1894
+ throw new Error(`Invalid command export in ${commandLabel}: it belongs to command tree ${tag.id}, not to command tree ${treeId}${directory === void 0 ? "" : ` (${directory})`}`);
1827
1895
  const own = typeof exported.navigation === "object" && exported.navigation !== null ? Object.keys(exported.navigation) : [];
1828
1896
  if (own.length > 0)
1829
- throw new Error(`Invalid command export in ${modulePath}: navigation parts go in ${basename(metadataPath)}, not ${own.join(", ")}`);
1897
+ throw new Error(`Invalid command export in ${commandLabel}: navigation parts go in ${metadataName ?? basename2(metadataLabel)}, not ${own.join(", ")}`);
1830
1898
  let checked;
1831
1899
  try {
1832
1900
  checked = checkCommandDefinition(exported);
1833
1901
  } catch (error) {
1834
- throw new Error(`Invalid command definition exported by ${modulePath}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
1902
+ throw new Error(`Invalid command definition exported by ${commandLabel}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
1835
1903
  }
1836
1904
  const { help, ...navigation } = metadata;
1837
1905
  if (help !== void 0 && checked.help !== void 0)
1838
- throw new Error(`Command help is set in both ${metadataPath} and ${modulePath}; set it in one of them`);
1906
+ throw new Error(`Command help is set in both ${metadataLabel} and ${commandLabel}; set it in one of them`);
1839
1907
  return Object.freeze({ ...checked, navigation: Object.freeze(navigation), ...help === void 0 ? {} : { help } });
1840
1908
  }
1841
- async function findModule(directory, stem) {
1842
- const typescript = join(directory, `${stem}.ts`);
1843
- if (await isFile(typescript))
1844
- return typescript;
1845
- const javascript = join(directory, `${stem}.js`);
1846
- if (await isFile(javascript))
1847
- return javascript;
1848
- return void 0;
1849
- }
1850
- async function isFile(path) {
1851
- try {
1852
- return (await stat(path)).isFile();
1853
- } catch (error) {
1854
- if (isMissing(error))
1855
- return false;
1856
- throw error;
1857
- }
1858
- }
1859
- function isMissing(error) {
1860
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
1861
- }
1862
1909
 
1863
1910
  // ../../../libs/clinkr/ts/dist/mounts.js
1864
1911
  import { join as join2, resolve } from "node:path";
@@ -1982,8 +2029,7 @@ function isResult(value) {
1982
2029
  }
1983
2030
 
1984
2031
  // ../../../libs/clinkr/ts/dist/skills/read-skills.js
1985
- import { readFile, readdir as readdir2 } from "node:fs/promises";
1986
- import { isAbsolute as isAbsolute2, join as join3 } from "node:path";
2032
+ import { readFile as readFile2 } from "node:fs/promises";
1987
2033
 
1988
2034
  // ../../../libs/clinkr/ts/dist/skills/skill-file.js
1989
2035
  var COMMANDS_SKILL_NAME = "commands";
@@ -2108,21 +2154,23 @@ function fileStem(path) {
2108
2154
  }
2109
2155
 
2110
2156
  // ../../../libs/clinkr/ts/dist/skills/read-skills.js
2111
- async function readSkillFiles(directory) {
2112
- if (typeof directory !== "string" || !isAbsolute2(directory))
2113
- throw new Error(`skills must be an absolute directory path; received ${JSON.stringify(directory)}`);
2114
- let entries;
2115
- try {
2116
- entries = await readdir2(directory, { withFileTypes: true });
2117
- } catch (cause) {
2118
- throw new Error(`Unable to read the skills directory ${directory}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
2119
- }
2120
- const names = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md") && !entry.name.startsWith(".")).map((entry) => entry.name).toSorted((left, right) => left < right ? -1 : left > right ? 1 : 0);
2121
- return Promise.all(names.map(async (name) => {
2122
- const path = join3(directory, name);
2123
- return parseSkillFile(path, await readFile(path, "utf8"));
2157
+ function parseSkillRecord(files) {
2158
+ if (typeof files !== "object" || files === null || Array.isArray(files))
2159
+ throw new Error("skills must be an absolute directory path or a record of <name>.md to Markdown text");
2160
+ const names = Object.keys(files).toSorted(compareCodeUnits);
2161
+ return Object.freeze(names.map((name) => {
2162
+ if (!name.endsWith(".md") || name.startsWith(".") || name.includes("/") || name.includes("\\"))
2163
+ throw new Error(`Invalid skill file name ${JSON.stringify(name)}: expected a plain <name>.md file name`);
2164
+ const text = files[name];
2165
+ if (typeof text !== "string")
2166
+ throw new Error(`Invalid skill file ${name}: content must be a string`);
2167
+ return parseSkillFile(name, text);
2124
2168
  }));
2125
2169
  }
2170
+ async function readSkillFiles(directory) {
2171
+ const files = await listSkillFiles(directory);
2172
+ return Promise.all(files.map(async ({ path }) => parseSkillFile(path, await readFile2(path, "utf8"))));
2173
+ }
2126
2174
 
2127
2175
  // ../../../libs/clinkr/ts/dist/skills/skills-group.js
2128
2176
  import { z as z17 } from "zod";
@@ -2830,7 +2878,7 @@ async function createApplication(name, options) {
2830
2878
  const declaredSections = new Set(helpSections);
2831
2879
  const group = options.commands;
2832
2880
  if (!isTreeGroup(group))
2833
- throw new Error("createApplication requires commands, a group from a command tree's directory or group");
2881
+ throw new Error("createApplication requires commands, a group from a command tree's group, directory, or manifest");
2834
2882
  checkNoGroupNavigation(group, "createApplication's commands take no navigation parts; root help takes description");
2835
2883
  const builtIn = sourceOf(group);
2836
2884
  const commands = await discoverBuiltIn(group, declaredSections);
@@ -2861,7 +2909,7 @@ async function createApplication(name, options) {
2861
2909
  checkProjectedTreeIds(mounts);
2862
2910
  const root = await mountAll(commands, mounts, builtIn, declaredSections);
2863
2911
  await checkGroupsFilled(root, builtIn);
2864
- const skills = options.skills === void 0 ? [] : await readSkillFiles(options.skills);
2912
+ const skills = options.skills === void 0 ? [] : typeof options.skills === "string" ? await readSkillFiles(options.skills) : parseSkillRecord(options.skills);
2865
2913
  const application = Object.freeze({
2866
2914
  name,
2867
2915
  ...description === void 0 ? {} : { description },
@@ -2995,6 +3043,58 @@ function leafSelection(leaf, path, argv) {
2995
3043
  };
2996
3044
  }
2997
3045
 
3046
+ // ../../../libs/clinkr/ts/dist/terminal.js
3047
+ var PIPE = Object.freeze({ tty: false, columns: void 0, color: "none" });
3048
+ function createTerminal(facts = {}) {
3049
+ return Object.freeze({
3050
+ interactive: facts.interactive ?? false,
3051
+ unicode: facts.unicode ?? true,
3052
+ stdout: Object.freeze({ ...PIPE, ...facts.stdout }),
3053
+ stderr: Object.freeze({ ...PIPE, ...facts.stderr })
3054
+ });
3055
+ }
3056
+ function withoutColor(terminal) {
3057
+ return Object.freeze({
3058
+ ...terminal,
3059
+ stdout: Object.freeze({ ...terminal.stdout, color: "none" }),
3060
+ stderr: Object.freeze({ ...terminal.stderr, color: "none" })
3061
+ });
3062
+ }
3063
+ function scriptReadsStdout(terminal) {
3064
+ return !terminal.stdout.tty || !terminal.interactive;
3065
+ }
3066
+ function resolveColorDepth(facts) {
3067
+ const { env } = facts;
3068
+ const noColor = env["NO_COLOR"];
3069
+ if (noColor !== void 0 && noColor !== "")
3070
+ return "none";
3071
+ const forced = env["FORCE_COLOR"];
3072
+ if (forced !== void 0 && forced !== "") {
3073
+ if (forced === "0" || forced === "false")
3074
+ return "none";
3075
+ if (forced === "2")
3076
+ return "ansi256";
3077
+ if (forced === "3")
3078
+ return "truecolor";
3079
+ return "ansi16";
3080
+ }
3081
+ const term = env["TERM"];
3082
+ if (!facts.tty || term === "dumb")
3083
+ return "none";
3084
+ const colorterm = env["COLORTERM"];
3085
+ if (colorterm === "truecolor" || colorterm === "24bit")
3086
+ return "truecolor";
3087
+ if (term !== void 0 && term.includes("256color"))
3088
+ return "ansi256";
3089
+ return "ansi16";
3090
+ }
3091
+ function resolveUnicode(env) {
3092
+ const locale = [env["LC_ALL"], env["LC_CTYPE"], env["LANG"]].find((value) => value !== void 0 && value !== "");
3093
+ if (locale === void 0)
3094
+ return true;
3095
+ return /utf-?8/iu.test(locale);
3096
+ }
3097
+
2998
3098
  // ../../../libs/clinkr/ts/dist/outcomes/refusals.js
2999
3099
  function refused(error) {
3000
3100
  return { ok: false, refusal: error };
@@ -4379,20 +4479,20 @@ function groupListing(application, commands) {
4379
4479
  }
4380
4480
 
4381
4481
  export {
4382
- appSourceOf,
4383
- lazyAppSource,
4482
+ defineErrors,
4384
4483
  stepDocument,
4385
4484
  renderOutcome,
4386
- defineErrors,
4387
4485
  defineOutcomes,
4486
+ commandTree,
4487
+ mount,
4488
+ createApplication,
4489
+ appSourceOf,
4490
+ lazyAppSource,
4388
4491
  INVALID_VALUE,
4389
4492
  CLINKR_PARSE_PARAMS,
4390
4493
  createTerminal,
4391
4494
  resolveColorDepth,
4392
4495
  resolveUnicode,
4393
- commandTree,
4394
- mount,
4395
4496
  runCliWith,
4396
- createApplication,
4397
4497
  refused
4398
4498
  };