@cnc-tools/storm 0.15.0 → 0.17.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 (305) hide show
  1. package/dist/application.d.ts +22 -13
  2. package/dist/application.js +21 -10
  3. package/dist/bin/run.d.ts +18 -0
  4. package/dist/bin/run.js +31 -0
  5. package/dist/bin/storm.js +42 -26
  6. package/dist/build-info.js +1 -1
  7. package/dist/chunks/{chunk-5CCP36QQ.js → chunk-2RNDPDTJ.js} +2 -2
  8. package/dist/chunks/chunk-2VP4GRJM.js +1219 -0
  9. package/dist/chunks/{chunk-SZEURWRS.js → chunk-4O5C2XGJ.js} +18 -15
  10. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
  11. package/dist/chunks/{chunk-QVS7HRU7.js → chunk-6UHIJXZG.js} +3 -3
  12. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  13. package/dist/chunks/{chunk-4U4DZ7VG.js → chunk-7DZE67QM.js} +2 -2
  14. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
  15. package/dist/chunks/{chunk-QUHY6FGN.js → chunk-CKGZA25H.js} +1 -18
  16. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
  17. package/dist/chunks/{chunk-KC4KDJ5K.js → chunk-DADEYJDW.js} +174 -153
  18. package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
  19. package/dist/chunks/chunk-F4MOYHRY.js +198 -0
  20. package/dist/chunks/{chunk-CXAT7ZKP.js → chunk-FNBB6V4R.js} +1 -1
  21. package/dist/chunks/{chunk-OX7X4B2L.js → chunk-GRT3UIBV.js} +18 -1
  22. package/dist/chunks/chunk-HP3CURSZ.js +88 -0
  23. package/dist/chunks/{chunk-PN5ULTTH.js → chunk-HWIQ2S7K.js} +5 -5
  24. package/dist/chunks/chunk-JN3YY6ZH.js +2166 -0
  25. package/dist/chunks/{chunk-TJNFVNKR.js → chunk-LKTZ5OXS.js} +1 -1
  26. package/dist/chunks/{chunk-XEVHP5ZW.js → chunk-M7EKRGVD.js} +8 -8
  27. package/dist/chunks/chunk-MR77L2GK.js +340 -0
  28. package/dist/chunks/{chunk-L36GBUBB.js → chunk-RNAS7JHE.js} +1755 -522
  29. package/dist/chunks/{chunk-5GBMR4HM.js → chunk-RWIXDDCK.js} +4 -192
  30. package/dist/chunks/{chunk-5VXBKPW6.js → chunk-WV3DP6NR.js} +1 -1
  31. package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
  32. package/dist/chunks/{chunk-YV7GE6EV.js → chunk-YEPFSLQR.js} +480 -375
  33. package/dist/chunks/{live-app-PI3BAN6Y.js → live-app-R76JQXZL.js} +15 -13
  34. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
  35. package/dist/commands/exec/across-sandboxes-outcomes.js +4 -3
  36. package/dist/commands/exec/before-run.d.ts +123 -0
  37. package/dist/commands/exec/before-run.js +105 -0
  38. package/dist/commands/exec/command.d.ts +39 -4
  39. package/dist/commands/exec/command.js +31 -95
  40. package/dist/commands/exec/driver-plan.d.ts +9 -4
  41. package/dist/commands/exec/driver-plan.js +8 -8
  42. package/dist/commands/exec/exec-words.js +1 -1
  43. package/dist/commands/exec/execute-run.d.ts +39 -0
  44. package/dist/commands/exec/execute-run.js +325 -0
  45. package/dist/commands/exec/live-view.d.ts +3 -3
  46. package/dist/commands/exec/live-view.js +16 -15
  47. package/dist/commands/exec/metadata.js +1 -1
  48. package/dist/commands/exec/mint-failed.d.ts +38 -0
  49. package/dist/commands/exec/mint-failed.js +27 -4
  50. package/dist/commands/exec/outcomes.d.ts +38 -9
  51. package/dist/commands/exec/outcomes.js +32 -25
  52. package/dist/commands/exec/plan-run.d.ts +58 -150
  53. package/dist/commands/exec/plan-run.js +232 -88
  54. package/dist/commands/exec/planned-outcome.js +8 -1
  55. package/dist/commands/exec/progress.d.ts +10 -6
  56. package/dist/commands/exec/progress.js +38 -25
  57. package/dist/commands/exec/run-bin.d.ts +11 -11
  58. package/dist/commands/exec/run-bin.js +9 -9
  59. package/dist/commands/exec/run-flags.d.ts +69 -0
  60. package/dist/commands/exec/run-flags.js +58 -0
  61. package/dist/commands/exec/run-metadata.js +5 -5
  62. package/dist/commands/exec/run-summary.d.ts +58 -0
  63. package/dist/commands/exec/run-summary.js +205 -0
  64. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  65. package/dist/commands/exec/runner-refusals.js +71 -0
  66. package/dist/commands/exec/sandbox-progress.js +3 -0
  67. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  68. package/dist/commands/exec/stopped-outcome.js +77 -0
  69. package/dist/commands/exec/view.d.ts +20 -11
  70. package/dist/commands/exec/view.js +103 -47
  71. package/dist/commands/runs/facts.d.ts +9 -4
  72. package/dist/commands/runs/facts.js +28 -11
  73. package/dist/commands/runs/list/command.d.ts +16 -6
  74. package/dist/commands/runs/list/command.js +10 -10
  75. package/dist/commands/runs/list/outcomes.d.ts +8 -3
  76. package/dist/commands/runs/logs/command.d.ts +6 -2
  77. package/dist/commands/runs/logs/command.js +10 -10
  78. package/dist/commands/runs/logs/outcomes.d.ts +3 -1
  79. package/dist/commands/runs/past-run.d.ts +14 -5
  80. package/dist/commands/runs/past-run.js +16 -5
  81. package/dist/commands/runs/show/command.d.ts +20 -8
  82. package/dist/commands/runs/show/command.js +30 -28
  83. package/dist/commands/runs/show/outcomes.d.ts +10 -4
  84. package/dist/commands/runs/show/outcomes.js +7 -5
  85. package/dist/commands/snapshots/access.d.ts +111 -0
  86. package/dist/commands/snapshots/access.js +96 -0
  87. package/dist/commands/snapshots/build/command.d.ts +360 -93
  88. package/dist/commands/snapshots/build/command.js +446 -150
  89. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  90. package/dist/commands/snapshots/build/metadata.js +31 -11
  91. package/dist/commands/snapshots/build/outcomes.d.ts +234 -43
  92. package/dist/commands/snapshots/build/outcomes.js +200 -36
  93. package/dist/commands/snapshots/list/command.d.ts +368 -27
  94. package/dist/commands/snapshots/list/command.js +296 -66
  95. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  96. package/dist/commands/snapshots/list/metadata.js +29 -6
  97. package/dist/commands/snapshots/list/outcomes.d.ts +245 -13
  98. package/dist/commands/snapshots/list/outcomes.js +221 -50
  99. package/dist/commands/snapshots/metadata.js +1 -1
  100. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  101. package/dist/commands/snapshots/prune/command.js +161 -0
  102. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  103. package/dist/commands/snapshots/prune/metadata.js +39 -0
  104. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  105. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  106. package/dist/commands/suites/list/command.js +19 -18
  107. package/dist/commands/suites/list/outcomes.js +4 -4
  108. package/dist/commands/test/command.d.ts +39 -4
  109. package/dist/commands/test/command.js +50 -255
  110. package/dist/commands/test/metadata.js +1 -1
  111. package/dist/commands/test/outcomes.d.ts +19 -2
  112. package/dist/commands/test/outcomes.js +2 -2
  113. package/dist/config/check-runner.d.ts +5 -3
  114. package/dist/config/check-runner.js +33 -7
  115. package/dist/config/check-suites.js +1 -0
  116. package/dist/config/credential-resolver.d.ts +50 -5
  117. package/dist/config/credential-resolver.js +51 -19
  118. package/dist/config/credential-settle.d.ts +6 -2
  119. package/dist/config/credential-settle.js +11 -5
  120. package/dist/config/gateways.d.ts +7 -3
  121. package/dist/config/index.d.ts +4 -5
  122. package/dist/config/index.js +3 -4
  123. package/dist/config/live/config-gateway.js +5 -2
  124. package/dist/config/load.d.ts +21 -4
  125. package/dist/config/load.js +129 -15
  126. package/dist/config/runner.d.ts +7 -8
  127. package/dist/config/runner.js +1 -1
  128. package/dist/config/schema.d.ts +17 -5
  129. package/dist/config/schema.js +11 -3
  130. package/dist/config/typed-options.d.ts +1 -6
  131. package/dist/config/typed-options.js +2 -10
  132. package/dist/config-file/define.d.ts +1 -11
  133. package/dist/config-file/define.js +3 -3
  134. package/dist/config-file/runner.d.ts +5 -6
  135. package/dist/config-file/toolchain.d.ts +13 -7
  136. package/dist/config-file/toolchain.js +53 -37
  137. package/dist/context.d.ts +8 -6
  138. package/dist/context.js +7 -6
  139. package/dist/core/across-sandboxes.d.ts +7 -6
  140. package/dist/core/across-sandboxes.js +123 -152
  141. package/dist/core/coordinator.d.ts +166 -0
  142. package/dist/core/coordinator.js +233 -0
  143. package/dist/core/events.d.ts +2 -2
  144. package/dist/core/index.d.ts +4 -2
  145. package/dist/core/index.js +1 -1
  146. package/dist/core/outcomes.d.ts +148 -0
  147. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  148. package/dist/core/resources.d.ts +31 -53
  149. package/dist/core/resources.js +32 -70
  150. package/dist/core/run-state.d.ts +7 -1
  151. package/dist/core/run-state.js +2 -0
  152. package/dist/core/run.d.ts +32 -236
  153. package/dist/core/run.js +106 -266
  154. package/dist/core/state-directory.d.ts +1 -1
  155. package/dist/core/state-directory.js +2 -2
  156. package/dist/credential/gateways.d.ts +15 -1
  157. package/dist/credential/index.d.ts +4 -3
  158. package/dist/credential/index.js +3 -2
  159. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  160. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  161. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  162. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  163. package/dist/credential/source.d.ts +73 -6
  164. package/dist/credential/source.js +55 -2
  165. package/dist/extension-commands.d.ts +6 -1
  166. package/dist/extension-commands.js +15 -1
  167. package/dist/extensions/github/resource.d.ts +1 -1
  168. package/dist/extensions/github/resource.js +1 -1
  169. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  170. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  171. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  172. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  173. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  174. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  175. package/dist/extensions/testserver/credential-facts.js +29 -11
  176. package/dist/extensions/testserver/lifecycle.js +7 -1
  177. package/dist/extensions/testserver/limit.d.ts +3 -0
  178. package/dist/extensions/testserver/limit.js +3 -0
  179. package/dist/extensions/testserver/provision.d.ts +8 -1
  180. package/dist/extensions/testserver/provision.js +8 -3
  181. package/dist/extensions/testserver/refusals.d.ts +6 -1
  182. package/dist/extensions/testserver/refusals.js +16 -1
  183. package/dist/extensions/testserver/resource.d.ts +2 -2
  184. package/dist/extensions/testserver/resource.js +2 -2
  185. package/dist/extensions/testserver/result.d.ts +1 -1
  186. package/dist/extensions/testserver/result.js +9 -4
  187. package/dist/planning/driver-file-lists.d.ts +0 -15
  188. package/dist/planning/driver-file-lists.js +2 -21
  189. package/dist/planning/plan-only.d.ts +7 -15
  190. package/dist/planning/plan-only.js +16 -22
  191. package/dist/planning/run-kind-flags.js +2 -2
  192. package/dist/planning/run-plan.d.ts +45 -13
  193. package/dist/planning/run-plan.js +4 -3
  194. package/dist/planning/suites.d.ts +1 -1
  195. package/dist/planning/suites.js +2 -2
  196. package/dist/planning/test-plan.d.ts +9 -0
  197. package/dist/planning/test-plan.js +10 -2
  198. package/dist/run-directory/recording.js +2 -2
  199. package/dist/run-directory/run-record.d.ts +21 -6
  200. package/dist/run-directory/run-record.js +12 -9
  201. package/dist/runner/base.d.ts +0 -6
  202. package/dist/runner/base.js +1 -16
  203. package/dist/runner/build-snapshots.d.ts +55 -29
  204. package/dist/runner/build-snapshots.js +135 -35
  205. package/dist/runner/context.d.ts +15 -7
  206. package/dist/runner/context.js +19 -6
  207. package/dist/runner/events.d.ts +16 -10
  208. package/dist/runner/gateways.d.ts +92 -21
  209. package/dist/runner/gateways.js +1 -1
  210. package/dist/runner/index.d.ts +11 -7
  211. package/dist/runner/index.js +9 -4
  212. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  213. package/dist/runner/live/sandbox-errors.js +4 -0
  214. package/dist/runner/live/sandbox-gateway.js +141 -3
  215. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  216. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  217. package/dist/runner/live/snapshot-records.js +6 -7
  218. package/dist/runner/local-snapshot-index.d.ts +199 -0
  219. package/dist/runner/local-snapshot-index.js +211 -0
  220. package/dist/runner/network-policy.d.ts +6 -6
  221. package/dist/runner/network-policy.js +7 -7
  222. package/dist/runner/policy-writes.d.ts +1 -1
  223. package/dist/runner/policy-writes.js +1 -1
  224. package/dist/runner/prepare.d.ts +25 -24
  225. package/dist/runner/prepare.js +28 -20
  226. package/dist/runner/ready.d.ts +18 -10
  227. package/dist/runner/ready.js +104 -33
  228. package/dist/runner/sandboxed-command.d.ts +3 -3
  229. package/dist/runner/sandboxed-command.js +3 -3
  230. package/dist/runner/scope.d.ts +10 -6
  231. package/dist/runner/scope.js +10 -3
  232. package/dist/runner/secrets.d.ts +13 -13
  233. package/dist/runner/secrets.js +18 -15
  234. package/dist/runner/session.d.ts +8 -8
  235. package/dist/runner/session.js +3 -3
  236. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  237. package/dist/runner/shared-snapshot-entry.js +168 -0
  238. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  239. package/dist/runner/shared-snapshot-list.js +155 -0
  240. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  241. package/dist/runner/shared-snapshot-lookup.js +118 -0
  242. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  243. package/dist/runner/shared-snapshot-prune.js +133 -0
  244. package/dist/runner/snapshot-build.d.ts +42 -14
  245. package/dist/runner/snapshot-build.js +38 -28
  246. package/dist/runner/snapshot-choice.js +1 -1
  247. package/dist/runner/snapshot-inspect.d.ts +39 -40
  248. package/dist/runner/snapshot-inspect.js +58 -38
  249. package/dist/runner/snapshot-key.d.ts +30 -21
  250. package/dist/runner/snapshot-key.js +49 -29
  251. package/dist/runner/steps.d.ts +1 -1
  252. package/dist/runner/steps.js +1 -1
  253. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +2 -2
  254. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
  255. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +82 -82
  256. package/dist/runner/vercel-sandbox-options.js +510 -0
  257. package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
  258. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
  259. package/dist/sdk/extension/commands.d.ts +8 -3
  260. package/dist/sdk/extension/commands.js +3 -1
  261. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  262. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  263. package/dist/sdk/extension/credential-source.d.ts +20 -3
  264. package/dist/sdk/extension/credential-source.js +4 -4
  265. package/dist/sdk/extension/index.d.ts +3 -2
  266. package/dist/sdk/extension/index.js +2 -1
  267. package/dist/sdk/extension/resource-definition.d.ts +4 -3
  268. package/dist/sdk/extension/resource-definition.js +3 -2
  269. package/dist/sdk/extension/resource-factory.js +3 -4
  270. package/dist/sdk/extension/secret-source.d.ts +1 -1
  271. package/dist/sdk/extension/secret-source.js +1 -1
  272. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  273. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  274. package/dist/sdk/run/present.d.ts +3 -3
  275. package/dist/sdk/run/present.js +1 -3
  276. package/dist/shared/cleanup.d.ts +3 -3
  277. package/dist/shared/cleanup.js +15 -5
  278. package/dist/shared/snapshot-text.d.ts +4 -4
  279. package/dist/shared/snapshot-text.js +11 -11
  280. package/dist/time/duration.js +1 -1
  281. package/package.json +3 -2
  282. package/skills/overview.md +6 -4
  283. package/skills/plan-runs.md +2 -2
  284. package/skills/read-run-output.md +6 -6
  285. package/dist/chunks/chunk-E4PJNZVG.js +0 -783
  286. package/dist/chunks/chunk-RAQEXKL6.js +0 -2591
  287. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  288. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  289. package/dist/commands/exec/plan-only.d.ts +0 -10
  290. package/dist/commands/exec/plan-only.js +0 -46
  291. package/dist/commands/exec/run-command.d.ts +0 -476
  292. package/dist/commands/exec/run-command.js +0 -604
  293. package/dist/commands/exec/run-planned.d.ts +0 -20
  294. package/dist/commands/exec/run-planned.js +0 -22
  295. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  296. package/dist/commands/exec/sandbox-view.js +0 -72
  297. package/dist/commands/test/plan.d.ts +0 -92
  298. package/dist/commands/test/plan.js +0 -128
  299. package/dist/config/recipe-run.d.ts +0 -33
  300. package/dist/config/recipe-run.js +0 -28
  301. package/dist/core/sandbox-end.d.ts +0 -64
  302. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  303. package/dist/runner/recipe.js +0 -425
  304. package/dist/runner/snapshot-cache.d.ts +0 -148
  305. package/dist/runner/snapshot-cache.js +0 -126
@@ -1,14 +1,214 @@
1
- // ../../../libs/clinkr/ts/dist/outcomes/steps.js
1
+ // ../../../libs/clinkr/ts/dist/outcomes/names.js
2
+ var CAMEL_CASE = /^[a-z][a-zA-Z0-9]*$/u;
3
+ var SNAKE_CASE = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/u;
4
+ function isSnakeCase(name) {
5
+ return typeof name === "string" && SNAKE_CASE.test(name);
6
+ }
7
+ function snakeCase(key) {
8
+ return key.replace(/[A-Z]/gu, (letter) => `_${letter.toLowerCase()}`);
9
+ }
10
+ var CLINKR_REASON_KEYS = ["invalidArguments", "internalError", "canceled", "confirmationRequired"];
11
+ function checkKeys(subject, keys, reserved) {
12
+ for (const key of keys) {
13
+ if (!CAMEL_CASE.test(key))
14
+ throw new TypeError(`${subject} key ${JSON.stringify(key)} is not camelCase`);
15
+ if (reserved.includes(key))
16
+ throw new TypeError(`${subject} key ${JSON.stringify(key)} is reserved`);
17
+ if (CLINKR_REASON_KEYS.includes(key))
18
+ throw new TypeError(`${subject} key ${JSON.stringify(key)} is reserved: ${snakeCase(key)} is Clinkr's own reason`);
19
+ }
20
+ }
21
+
22
+ // ../../../libs/clinkr/ts/dist/outcomes/schema-code.js
2
23
  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()
24
+ var RULE = [
25
+ "Command schemas check only shape: types, built-in checks such as min(1) and formats such as z.email(), defaults,",
26
+ "enums, positionals, and overwrite normalizers such as trim().",
27
+ "Move the logic out of the schema: refuse a request that makes no sense in the command's validate, and have the",
28
+ "handler build outcome values that already have their final shape."
29
+ ].join(" ");
30
+ function isSchema(value) {
31
+ if (typeof value !== "object" || value === null || !("_zod" in value))
32
+ return false;
33
+ const { def } = value._zod;
34
+ return typeof def === "object" && typeof def.type === "string";
35
+ }
36
+ function codeIn(def) {
37
+ if (def["type"] === "custom")
38
+ return "z.custom or z.instanceof";
39
+ if (def["type"] === "catch")
40
+ return "a catch (.catch)";
41
+ if (def["type"] === "transform")
42
+ return "a transform (.transform or z.preprocess)";
43
+ if (def["type"] !== "pipe")
44
+ return void 0;
45
+ if ("transform" in def)
46
+ return "a codec (z.codec or z.stringbool)";
47
+ const ends = [def["in"], def["out"]];
48
+ return ends.some((end) => isSchema(end) && end._zod.def.type === "transform") ? void 0 : "a pipe (.pipe)";
49
+ }
50
+ function children(schema) {
51
+ const def = schema._zod.def;
52
+ if (def["type"] === "lazy")
53
+ return [["", def["getter"]()]];
54
+ const keys = Object.keys(def).filter((key) => key !== "checks" && key !== "defaultValue");
55
+ return keys.flatMap((key) => {
56
+ const value = def[key];
57
+ if (isSchema(value))
58
+ return [[key === "element" ? "[]" : "", value]];
59
+ if (Array.isArray(value))
60
+ return value.filter(isSchema).map((item) => ["", item]);
61
+ if (typeof value === "object" && value !== null)
62
+ return Object.entries(value).flatMap(([field, item]) => isSchema(item) ? [[`.${field}`, item]] : []);
63
+ return [];
64
+ });
65
+ }
66
+ function schemaCodeProblems(label, schema, ancestors = /* @__PURE__ */ new Set()) {
67
+ if (ancestors.has(schema))
68
+ return [];
69
+ const def = schema._zod.def;
70
+ const checks = schema._zod.def.checks ?? [];
71
+ const customFormat = schema instanceof z.ZodCustomStringFormat || checks.some((check) => check instanceof z.ZodCustomStringFormat);
72
+ const found = [
73
+ ...checks.some((check) => check._zod.def.check === "custom") ? ["a refinement (.refine, .superRefine, or .check)"] : [],
74
+ ...customFormat ? ["a custom string format (z.stringFormat)"] : [],
75
+ ...[codeIn(def)].filter((what) => what !== void 0)
76
+ ].map((what) => `${label} uses ${what}`);
77
+ const inside = /* @__PURE__ */ new Set([...ancestors, schema]);
78
+ return [
79
+ ...found,
80
+ ...children(schema).flatMap(([segment, child]) => schemaCodeProblems(`${label}${segment}`, child, inside))
81
+ ];
82
+ }
83
+ function inputSchemaCoercion(schema, path = "", ancestors = /* @__PURE__ */ new Set()) {
84
+ if (ancestors.has(schema))
85
+ return void 0;
86
+ const def = schema._zod.def;
87
+ const type = def["type"];
88
+ if (def["coerce"] === true && (type === "string" || type === "number" || type === "boolean"))
89
+ return { path, type };
90
+ const inside = /* @__PURE__ */ new Set([...ancestors, schema]);
91
+ const inputChildren = type === "pipe" && isSchema(def["in"]) ? [["", def["in"]]] : children(schema);
92
+ for (const [segment, child] of inputChildren) {
93
+ const found = inputSchemaCoercion(child, `${path}${segment}`, inside);
94
+ if (found !== void 0)
95
+ return found;
96
+ }
97
+ return void 0;
98
+ }
99
+ function assertNoSchemaCode(problems) {
100
+ const found = [...new Set(problems)];
101
+ if (found.length > 0)
102
+ throw new TypeError(`${found.join("; ")}. ${RULE}`);
103
+ }
104
+
105
+ // ../../../libs/clinkr/ts/dist/outcomes/values.js
106
+ import { z as z2 } from "zod";
107
+ var OutcomeValueError = class extends Error {
108
+ constructor(name, cause) {
109
+ super(`Outcome ${name} value does not match its schema:
110
+ ${z2.prettifyError(cause)}`, { cause });
111
+ this.name = "OutcomeValueError";
112
+ }
113
+ };
114
+ function parseOutcomeValue(name, schema, value) {
115
+ const parsed = schema.safeParse(value);
116
+ if (!parsed.success)
117
+ throw new OutcomeValueError(name, parsed.error);
118
+ return parsed.data;
119
+ }
120
+
121
+ // ../../../libs/clinkr/ts/dist/outcomes/errors.js
122
+ function checkDescription(subject, description) {
123
+ if (description === void 0)
124
+ return;
125
+ if (typeof description !== "string" || description.trim() === "" || description.includes("\n"))
126
+ throw new TypeError(`${subject} description must be one non-empty line`);
127
+ }
128
+ function isObjectSchema(value) {
129
+ if (typeof value !== "object" || value === null || !("_zod" in value))
130
+ return false;
131
+ const { def } = value._zod;
132
+ return typeof def === "object" && def.type === "object";
133
+ }
134
+ function declareError(reason, value) {
135
+ if (typeof value !== "object" || value === null)
136
+ throw new TypeError(`Error ${reason} is not an error definition`);
137
+ const { exitCode, status, description, schema, render } = value;
138
+ if (exitCode !== 1 && exitCode !== 2)
139
+ throw new TypeError(`Error ${reason} exit code must be 1 or 2`);
140
+ if (status !== void 0 && status !== "action_required" && status !== "error")
141
+ throw new TypeError(`Error ${reason} status must be action_required or error`);
142
+ checkDescription(`Error ${reason}`, description);
143
+ if (schema !== void 0 && !isObjectSchema(schema))
144
+ throw new TypeError(`Error ${reason} schema must be an object schema`);
145
+ if (render === void 0) {
146
+ if (schema !== void 0)
147
+ throw new TypeError(`Error ${reason} has a schema, so it needs a render function`);
148
+ if (description === void 0)
149
+ throw new TypeError(`Error ${reason} needs a render function, or a description to show as its message`);
150
+ } else if (typeof render !== "function")
151
+ throw new TypeError(`Error ${reason} needs a render function`);
152
+ return Object.freeze({
153
+ exitCode,
154
+ ...status === void 0 ? {} : { status },
155
+ ...description === void 0 ? {} : { description },
156
+ ...schema === void 0 ? {} : { schema },
157
+ render: render === void 0 ? () => ({ message: description }) : render
158
+ });
159
+ }
160
+ function buildError(reason, definition, facts) {
161
+ const { schema, status } = definition;
162
+ const data = schema === void 0 ? void 0 : parseOutcomeValue(reason, schema, facts[0]);
163
+ const render = definition.render;
164
+ const { message, next, rows } = data === void 0 ? render(...facts) : render(data, ...facts.slice(1));
165
+ const content = {
166
+ message,
167
+ ...next === void 0 ? {} : { next },
168
+ ...status === void 0 ? {} : { status },
169
+ // Only an error with a schema shows rows, and they come from its data.
170
+ ...data === void 0 ? {} : { ...rows === void 0 ? {} : { rows }, data }
171
+ };
172
+ return { kind: "error", reason, exitCode: definition.exitCode, content };
173
+ }
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()
9
209
  }),
10
- z.object({ type: z.literal("url"), url: z.string() }),
11
- z.object({ type: z.literal("text"), text: z.string() })
210
+ z3.object({ type: z3.literal("url"), url: z3.string() }),
211
+ z3.object({ type: z3.literal("text"), text: z3.string() })
12
212
  ]);
13
213
  var SHELL_SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/u;
14
214
  function commandLine(argv) {
@@ -137,261 +337,61 @@ function formatSteps(steps) {
137
337
  }
138
338
  return lines;
139
339
  }
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
- // ../../../libs/clinkr/ts/dist/outcomes/names.js
197
- var CAMEL_CASE = /^[a-z][a-zA-Z0-9]*$/u;
198
- var SNAKE_CASE = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/u;
199
- function isSnakeCase(name) {
200
- return typeof name === "string" && SNAKE_CASE.test(name);
201
- }
202
- function snakeCase(key) {
203
- return key.replace(/[A-Z]/gu, (letter) => `_${letter.toLowerCase()}`);
204
- }
205
- var CLINKR_REASON_KEYS = ["invalidArguments", "internalError", "canceled", "confirmationRequired"];
206
- function checkKeys(subject, keys, reserved) {
207
- for (const key of keys) {
208
- if (!CAMEL_CASE.test(key))
209
- throw new TypeError(`${subject} key ${JSON.stringify(key)} is not camelCase`);
210
- if (reserved.includes(key))
211
- throw new TypeError(`${subject} key ${JSON.stringify(key)} is reserved`);
212
- if (CLINKR_REASON_KEYS.includes(key))
213
- throw new TypeError(`${subject} key ${JSON.stringify(key)} is reserved: ${snakeCase(key)} is Clinkr's own reason`);
214
- }
215
- }
216
-
217
- // ../../../libs/clinkr/ts/dist/outcomes/schema-code.js
218
- import { z as z2 } from "zod";
219
- var RULE = [
220
- "Command schemas check only shape: types, built-in checks such as min(1) and formats such as z.email(), defaults,",
221
- "enums, positionals, and overwrite normalizers such as trim().",
222
- "Move the logic out of the schema: refuse a request that makes no sense in the command's validate, and have the",
223
- "handler build outcome values that already have their final shape."
224
- ].join(" ");
225
- function isSchema(value) {
226
- if (typeof value !== "object" || value === null || !("_zod" in value))
227
- return false;
228
- const { def } = value._zod;
229
- return typeof def === "object" && typeof def.type === "string";
230
- }
231
- function codeIn(def) {
232
- if (def["type"] === "custom")
233
- return "z.custom or z.instanceof";
234
- if (def["type"] === "catch")
235
- return "a catch (.catch)";
236
- if (def["type"] === "transform")
237
- return "a transform (.transform or z.preprocess)";
238
- if (def["type"] !== "pipe")
239
- return void 0;
240
- if ("transform" in def)
241
- return "a codec (z.codec or z.stringbool)";
242
- const ends = [def["in"], def["out"]];
243
- return ends.some((end) => isSchema(end) && end._zod.def.type === "transform") ? void 0 : "a pipe (.pipe)";
244
- }
245
- function children(schema) {
246
- const def = schema._zod.def;
247
- if (def["type"] === "lazy")
248
- return [["", def["getter"]()]];
249
- const keys = Object.keys(def).filter((key) => key !== "checks" && key !== "defaultValue");
250
- return keys.flatMap((key) => {
251
- const value = def[key];
252
- if (isSchema(value))
253
- return [[key === "element" ? "[]" : "", value]];
254
- if (Array.isArray(value))
255
- return value.filter(isSchema).map((item) => ["", item]);
256
- if (typeof value === "object" && value !== null)
257
- return Object.entries(value).flatMap(([field, item]) => isSchema(item) ? [[`.${field}`, item]] : []);
258
- return [];
259
- });
260
- }
261
- function schemaCodeProblems(label, schema, ancestors = /* @__PURE__ */ new Set()) {
262
- if (ancestors.has(schema))
263
- return [];
264
- const def = schema._zod.def;
265
- const checks = schema._zod.def.checks ?? [];
266
- const customFormat = schema instanceof z2.ZodCustomStringFormat || checks.some((check) => check instanceof z2.ZodCustomStringFormat);
267
- const found = [
268
- ...checks.some((check) => check._zod.def.check === "custom") ? ["a refinement (.refine, .superRefine, or .check)"] : [],
269
- ...customFormat ? ["a custom string format (z.stringFormat)"] : [],
270
- ...[codeIn(def)].filter((what) => what !== void 0)
271
- ].map((what) => `${label} uses ${what}`);
272
- const inside = /* @__PURE__ */ new Set([...ancestors, schema]);
273
- return [
274
- ...found,
275
- ...children(schema).flatMap(([segment, child]) => schemaCodeProblems(`${label}${segment}`, child, inside))
276
- ];
277
- }
278
- function inputSchemaCoercion(schema, path = "", ancestors = /* @__PURE__ */ new Set()) {
279
- if (ancestors.has(schema))
280
- return void 0;
281
- const def = schema._zod.def;
282
- const type = def["type"];
283
- if (def["coerce"] === true && (type === "string" || type === "number" || type === "boolean"))
284
- return { path, type };
285
- const inside = /* @__PURE__ */ new Set([...ancestors, schema]);
286
- const inputChildren = type === "pipe" && isSchema(def["in"]) ? [["", def["in"]]] : children(schema);
287
- for (const [segment, child] of inputChildren) {
288
- const found = inputSchemaCoercion(child, `${path}${segment}`, inside);
289
- if (found !== void 0)
290
- return found;
291
- }
292
- return void 0;
293
- }
294
- function assertNoSchemaCode(problems) {
295
- const found = [...new Set(problems)];
296
- if (found.length > 0)
297
- throw new TypeError(`${found.join("; ")}. ${RULE}`);
298
- }
299
-
300
- // ../../../libs/clinkr/ts/dist/outcomes/values.js
301
- import { z as z3 } from "zod";
302
- var OutcomeValueError = class extends Error {
303
- constructor(name, cause) {
304
- super(`Outcome ${name} value does not match its schema:
305
- ${z3.prettifyError(cause)}`, { cause });
306
- this.name = "OutcomeValueError";
307
- }
308
- };
309
- function parseOutcomeValue(name, schema, value) {
310
- const parsed = schema.safeParse(value);
311
- if (!parsed.success)
312
- throw new OutcomeValueError(name, parsed.error);
313
- return parsed.data;
314
- }
315
-
316
- // ../../../libs/clinkr/ts/dist/outcomes/errors.js
317
- function checkDescription(subject, description) {
318
- if (description === void 0)
319
- return;
320
- if (typeof description !== "string" || description.trim() === "" || description.includes("\n"))
321
- throw new TypeError(`${subject} description must be one non-empty line`);
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");
322
352
  }
323
- function isObjectSchema(value) {
324
- if (typeof value !== "object" || value === null || !("_zod" in value))
325
- return false;
326
- const { def } = value._zod;
327
- return typeof def === "object" && def.type === "object";
353
+ function cellText(cell) {
354
+ return typeof cell === "string" ? cell : cell.text;
328
355
  }
329
- function declareError(reason, value) {
330
- if (typeof value !== "object" || value === null)
331
- throw new TypeError(`Error ${reason} is not an error definition`);
332
- const { exitCode, status, description, schema, render } = value;
333
- if (exitCode !== 1 && exitCode !== 2)
334
- throw new TypeError(`Error ${reason} exit code must be 1 or 2`);
335
- if (status !== void 0 && status !== "action_required" && status !== "error")
336
- throw new TypeError(`Error ${reason} status must be action_required or error`);
337
- checkDescription(`Error ${reason}`, description);
338
- if (schema !== void 0 && !isObjectSchema(schema))
339
- throw new TypeError(`Error ${reason} schema must be an object schema`);
340
- if (render === void 0) {
341
- if (schema !== void 0)
342
- throw new TypeError(`Error ${reason} has a schema, so it needs a render function`);
343
- if (description === void 0)
344
- throw new TypeError(`Error ${reason} needs a render function, or a description to show as its message`);
345
- } else if (typeof render !== "function")
346
- throw new TypeError(`Error ${reason} needs a render function`);
347
- return Object.freeze({
348
- exitCode,
349
- ...status === void 0 ? {} : { status },
350
- ...description === void 0 ? {} : { description },
351
- ...schema === void 0 ? {} : { schema },
352
- render: render === void 0 ? () => ({ message: description }) : render
353
- });
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;
354
363
  }
355
- function buildError(reason, definition, facts) {
356
- const { schema, status } = definition;
357
- const data = schema === void 0 ? void 0 : parseOutcomeValue(reason, schema, facts[0]);
358
- const render = definition.render;
359
- const { message, next, rows } = data === void 0 ? render(...facts) : render(data, ...facts.slice(1));
360
- const content = {
361
- message,
362
- ...next === void 0 ? {} : { next },
363
- ...status === void 0 ? {} : { status },
364
- // Only an error with a schema shows rows, and they come from its data.
365
- ...data === void 0 ? {} : { ...rows === void 0 ? {} : { rows }, data }
366
- };
367
- return { kind: "error", reason, exitCode: definition.exitCode, content };
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\\`;
368
370
  }
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 }))];
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,6 +1532,11 @@ 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 });
1535
+ },
1536
+ manifest: (commands) => {
1537
+ if (typeof commands !== "object" || commands === null || Array.isArray(commands))
1538
+ throw new TypeError(`Command tree ${tag.id}: manifest takes a record of names to manifest entries`);
1539
+ return Object.freeze({ kind: "manifest", tree: tag.id, commands: Object.freeze({ ...commands }) });
1587
1540
  }
1588
1541
  });
1589
1542
  }
@@ -1607,11 +1560,11 @@ function isTreeGroup(value) {
1607
1560
  const { kind, tree, navigation } = value;
1608
1561
  if (typeof tree !== "string")
1609
1562
  return false;
1610
- return kind === "directory" || kind === "inline-group" && typeof navigation === "object" && navigation !== null;
1563
+ return kind === "directory" || kind === "manifest" || kind === "inline-group" && typeof navigation === "object" && navigation !== null;
1611
1564
  }
1612
1565
  function mount(group, options) {
1613
1566
  if (!isTreeGroup(group))
1614
- throw new TypeError("mount takes a group from a command tree's group or directory");
1567
+ throw new TypeError("mount takes a group from a command tree's group, directory, or manifest");
1615
1568
  return Object.freeze({ ...options, group });
1616
1569
  }
1617
1570
 
@@ -1668,7 +1621,11 @@ var SourceDiscoveryError = class extends Error {
1668
1621
  }
1669
1622
  };
1670
1623
  function discoverGroup(group, scope, prefix = []) {
1671
- return group.kind === "directory" ? discoverChildren(scope, prefix, group.directory) : inlineChildren(scope, group, prefix);
1624
+ if (group.kind === "directory")
1625
+ return discoverChildren(scope, prefix, group.directory);
1626
+ if (group.kind === "manifest")
1627
+ return manifestChildren(scope, group.commands, prefix);
1628
+ return inlineChildren(scope, group, prefix);
1672
1629
  }
1673
1630
  async function atLocation(source, location, read) {
1674
1631
  try {
@@ -1687,11 +1644,11 @@ function checkedSiblings(scope, prefix, read) {
1687
1644
  return Object.freeze(nodes);
1688
1645
  });
1689
1646
  }
1690
- function checkNode(scope, { name, metadata, metadataPath }, leaf) {
1647
+ function checkNode(scope, { name, metadata, metadataLabel }, leaf) {
1691
1648
  const undeclared2 = undeclaredSection(metadata.helpSection, scope.declaredSections);
1692
1649
  if (undeclared2 !== void 0)
1693
- throw new Error(`${undeclared2}${metadataPath === void 0 ? "" : ` in ${metadataPath}`}`);
1694
- const at = metadataPath === void 0 ? "" : ` (${metadataPath})`;
1650
+ throw new Error(`${undeclared2}${metadataLabel === void 0 ? "" : ` in ${metadataLabel}`}`);
1651
+ const at = metadataLabel === void 0 ? "" : ` (${metadataLabel})`;
1695
1652
  if (leaf) {
1696
1653
  if (metadata.default === true && metadata.hidden === true)
1697
1654
  throw new Error(`Command ${name} cannot be both default and hidden${at}`);
@@ -1727,14 +1684,23 @@ async function groupNode(scope, found, children2) {
1727
1684
  function inlineChildren(scope, group, prefix) {
1728
1685
  return checkedSiblings(scope, prefix, () => Promise.all(Object.keys(group.commands).toSorted(compareCodeUnits).map((name) => inlineNode(scope, name, group.commands[name], prefix))));
1729
1686
  }
1687
+ function checkCommandName(name) {
1688
+ if (!isCommandNameSegment(name))
1689
+ 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 -`);
1690
+ }
1691
+ function parseCommandMetadata(value, where) {
1692
+ const result = commandMetadataSchema.safeParse(value);
1693
+ if (!result.success)
1694
+ throw new Error(`Invalid metadata ${where}: ${navigationIssues(result.error, "metadata")}`);
1695
+ return Object.freeze(result.data);
1696
+ }
1730
1697
  function inlineNode(scope, name, member, prefix) {
1731
1698
  const location = [...prefix, name];
1732
1699
  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 -`);
1700
+ checkCommandName(name);
1735
1701
  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");
1702
+ if (isTreeGroup(value) && (value.kind === "directory" || value.kind === "manifest"))
1703
+ throw new Error("A group's commands hold commands and inline groups; mount a directory or manifest group with mount");
1738
1704
  if (isTreeGroup(member)) {
1739
1705
  const group = member;
1740
1706
  return groupNode(scope, inlineFound(name, member.navigation, location), () => inlineChildren(scope, group, location));
@@ -1751,6 +1717,50 @@ function inlineFound(name, navigation, location) {
1751
1717
  throw new Error("A group's commands and nested groups each need a description in their definition");
1752
1718
  return { name, metadata: Object.freeze({ ...navigation, description }), where: location.join(" ") };
1753
1719
  }
1720
+ function manifestChildren(scope, commands, prefix) {
1721
+ return checkedSiblings(scope, prefix, () => Promise.all(Object.keys(commands).toSorted(compareCodeUnits).map((name) => manifestNode(scope, name, commands[name], prefix))));
1722
+ }
1723
+ function manifestNode(scope, name, entry, prefix) {
1724
+ const location = [...prefix, name];
1725
+ const label = location.join("/");
1726
+ return atLocation(scope.source, location, async () => {
1727
+ checkCommandName(name);
1728
+ if (typeof entry !== "object" || entry === null)
1729
+ throw new Error(`Invalid manifest entry for ${label}: expected { metadata, load } or { metadata, commands }`);
1730
+ const candidate = entry;
1731
+ const metadata = parseCommandMetadata(candidate.metadata, `for ${label}`);
1732
+ const hasLoad = candidate.load !== void 0;
1733
+ const hasCommands = candidate.commands !== void 0;
1734
+ if (hasLoad && hasCommands)
1735
+ throw new Error(`Manifest entry ${label} cannot declare both load and commands; set one of them`);
1736
+ if (!hasLoad && !hasCommands)
1737
+ throw new Error(`Manifest entry ${label} must declare either load (leaf) or commands (group)`);
1738
+ const metadataLabel = `manifest entry ${label} metadata`;
1739
+ const found = { name, metadata, metadataLabel, where: location.join(" ") };
1740
+ if (hasLoad) {
1741
+ if (typeof candidate.load !== "function")
1742
+ throw new Error(`Manifest entry ${label}: load must be a function returning the command module`);
1743
+ const load = candidate.load;
1744
+ const treeId = scope.source.id;
1745
+ const commandLabel = `manifest entry ${label} command`;
1746
+ return leafNode(scope, found, location, async () => {
1747
+ const module = await load();
1748
+ return commandOfModule({
1749
+ treeId,
1750
+ metadata,
1751
+ exported: module?.default,
1752
+ metadataLabel,
1753
+ metadataName: "metadata",
1754
+ commandLabel
1755
+ });
1756
+ });
1757
+ }
1758
+ if (typeof candidate.commands !== "object" || candidate.commands === null || Array.isArray(candidate.commands))
1759
+ throw new Error(`Manifest entry ${label}: commands must be a record of names to manifest entries`);
1760
+ const children2 = candidate.commands;
1761
+ return groupNode(scope, found, () => manifestChildren(scope, children2, location));
1762
+ });
1763
+ }
1754
1764
  async function discoverChildren(scope, prefix, directory) {
1755
1765
  return checkedSiblings(scope, prefix, async () => {
1756
1766
  const entries = await readdir(directory, { withFileTypes: true });
@@ -1766,7 +1776,7 @@ function discoverNode(scope, name, prefix, parentDirectory) {
1766
1776
  if (metadataPath === void 0)
1767
1777
  throw new Error(`Missing metadata.ts or metadata.js for command node: ${directory}`);
1768
1778
  const metadata = await loadMetadata(metadataPath);
1769
- const found = { name, metadata, metadataPath, where: directory };
1779
+ const found = { name, metadata, metadataLabel: metadataPath, where: directory };
1770
1780
  const entries = await readdir(directory, { withFileTypes: true });
1771
1781
  const hasChildDirectories = entries.some((entry) => entry.isDirectory());
1772
1782
  const commandModule = await findModule(directory, "command");
@@ -1806,36 +1816,40 @@ function checkDefaultConflicts(nodes, prefix) {
1806
1816
  }
1807
1817
  async function loadMetadata(path) {
1808
1818
  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);
1819
+ return parseCommandMetadata(module.metadata, `export in ${path}`);
1813
1820
  }
1814
1821
  async function importCommand(treeId, directory, metadata, metadataPath, modulePath) {
1815
1822
  const module = await import(pathToFileURL(modulePath).href);
1816
- return commandOfModule({ treeId, directory, metadata, metadataPath, modulePath, exported: module.default });
1823
+ return commandOfModule({
1824
+ treeId,
1825
+ directory,
1826
+ metadata,
1827
+ metadataLabel: metadataPath,
1828
+ commandLabel: modulePath,
1829
+ exported: module.default
1830
+ });
1817
1831
  }
1818
1832
  function commandOfModule(module) {
1819
- const { treeId, metadata, exported, metadataPath, modulePath, directory } = module;
1833
+ const { treeId, metadata, exported, metadataLabel, metadataName, commandLabel, directory } = module;
1820
1834
  if (!isOutcomeCommandDefinition(exported))
1821
- throw new Error(`Invalid command export in ${modulePath}: export default ${treeId}.define({ \u2026 })`);
1835
+ throw new Error(`Invalid command export in ${commandLabel}: export default ${treeId}.define({ \u2026 })`);
1822
1836
  const tag = treeTagOf(exported);
1823
1837
  if (tag === void 0)
1824
- throw new Error(`Invalid command export in ${modulePath}: define it with command tree ${treeId}'s define`);
1838
+ throw new Error(`Invalid command export in ${commandLabel}: define it with command tree ${treeId}'s define`);
1825
1839
  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})`}`);
1840
+ 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
1841
  const own = typeof exported.navigation === "object" && exported.navigation !== null ? Object.keys(exported.navigation) : [];
1828
1842
  if (own.length > 0)
1829
- throw new Error(`Invalid command export in ${modulePath}: navigation parts go in ${basename(metadataPath)}, not ${own.join(", ")}`);
1843
+ throw new Error(`Invalid command export in ${commandLabel}: navigation parts go in ${metadataName ?? basename(metadataLabel)}, not ${own.join(", ")}`);
1830
1844
  let checked;
1831
1845
  try {
1832
1846
  checked = checkCommandDefinition(exported);
1833
1847
  } catch (error) {
1834
- throw new Error(`Invalid command definition exported by ${modulePath}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
1848
+ throw new Error(`Invalid command definition exported by ${commandLabel}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
1835
1849
  }
1836
1850
  const { help, ...navigation } = metadata;
1837
1851
  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`);
1852
+ throw new Error(`Command help is set in both ${metadataLabel} and ${commandLabel}; set it in one of them`);
1839
1853
  return Object.freeze({ ...checked, navigation: Object.freeze(navigation), ...help === void 0 ? {} : { help } });
1840
1854
  }
1841
1855
  async function findModule(directory, stem) {
@@ -2108,6 +2122,19 @@ function fileStem(path) {
2108
2122
  }
2109
2123
 
2110
2124
  // ../../../libs/clinkr/ts/dist/skills/read-skills.js
2125
+ function parseSkillRecord(files) {
2126
+ if (typeof files !== "object" || files === null || Array.isArray(files))
2127
+ throw new Error("skills must be an absolute directory path or a record of <name>.md to Markdown text");
2128
+ const names = Object.keys(files).toSorted((left, right) => left < right ? -1 : left > right ? 1 : 0);
2129
+ return Object.freeze(names.map((name) => {
2130
+ if (!name.endsWith(".md") || name.startsWith(".") || name.includes("/") || name.includes("\\"))
2131
+ throw new Error(`Invalid skill file name ${JSON.stringify(name)}: expected a plain <name>.md file name`);
2132
+ const text = files[name];
2133
+ if (typeof text !== "string")
2134
+ throw new Error(`Invalid skill file ${name}: content must be a string`);
2135
+ return parseSkillFile(name, text);
2136
+ }));
2137
+ }
2111
2138
  async function readSkillFiles(directory) {
2112
2139
  if (typeof directory !== "string" || !isAbsolute2(directory))
2113
2140
  throw new Error(`skills must be an absolute directory path; received ${JSON.stringify(directory)}`);
@@ -2830,7 +2857,7 @@ async function createApplication(name, options) {
2830
2857
  const declaredSections = new Set(helpSections);
2831
2858
  const group = options.commands;
2832
2859
  if (!isTreeGroup(group))
2833
- throw new Error("createApplication requires commands, a group from a command tree's directory or group");
2860
+ throw new Error("createApplication requires commands, a group from a command tree's group, directory, or manifest");
2834
2861
  checkNoGroupNavigation(group, "createApplication's commands take no navigation parts; root help takes description");
2835
2862
  const builtIn = sourceOf(group);
2836
2863
  const commands = await discoverBuiltIn(group, declaredSections);
@@ -2861,7 +2888,7 @@ async function createApplication(name, options) {
2861
2888
  checkProjectedTreeIds(mounts);
2862
2889
  const root = await mountAll(commands, mounts, builtIn, declaredSections);
2863
2890
  await checkGroupsFilled(root, builtIn);
2864
- const skills = options.skills === void 0 ? [] : await readSkillFiles(options.skills);
2891
+ const skills = options.skills === void 0 ? [] : typeof options.skills === "string" ? await readSkillFiles(options.skills) : parseSkillRecord(options.skills);
2865
2892
  const application = Object.freeze({
2866
2893
  name,
2867
2894
  ...description === void 0 ? {} : { description },
@@ -2995,6 +3022,58 @@ function leafSelection(leaf, path, argv) {
2995
3022
  };
2996
3023
  }
2997
3024
 
3025
+ // ../../../libs/clinkr/ts/dist/terminal.js
3026
+ var PIPE = Object.freeze({ tty: false, columns: void 0, color: "none" });
3027
+ function createTerminal(facts = {}) {
3028
+ return Object.freeze({
3029
+ interactive: facts.interactive ?? false,
3030
+ unicode: facts.unicode ?? true,
3031
+ stdout: Object.freeze({ ...PIPE, ...facts.stdout }),
3032
+ stderr: Object.freeze({ ...PIPE, ...facts.stderr })
3033
+ });
3034
+ }
3035
+ function withoutColor(terminal) {
3036
+ return Object.freeze({
3037
+ ...terminal,
3038
+ stdout: Object.freeze({ ...terminal.stdout, color: "none" }),
3039
+ stderr: Object.freeze({ ...terminal.stderr, color: "none" })
3040
+ });
3041
+ }
3042
+ function scriptReadsStdout(terminal) {
3043
+ return !terminal.stdout.tty || !terminal.interactive;
3044
+ }
3045
+ function resolveColorDepth(facts) {
3046
+ const { env } = facts;
3047
+ const noColor = env["NO_COLOR"];
3048
+ if (noColor !== void 0 && noColor !== "")
3049
+ return "none";
3050
+ const forced = env["FORCE_COLOR"];
3051
+ if (forced !== void 0 && forced !== "") {
3052
+ if (forced === "0" || forced === "false")
3053
+ return "none";
3054
+ if (forced === "2")
3055
+ return "ansi256";
3056
+ if (forced === "3")
3057
+ return "truecolor";
3058
+ return "ansi16";
3059
+ }
3060
+ const term = env["TERM"];
3061
+ if (!facts.tty || term === "dumb")
3062
+ return "none";
3063
+ const colorterm = env["COLORTERM"];
3064
+ if (colorterm === "truecolor" || colorterm === "24bit")
3065
+ return "truecolor";
3066
+ if (term !== void 0 && term.includes("256color"))
3067
+ return "ansi256";
3068
+ return "ansi16";
3069
+ }
3070
+ function resolveUnicode(env) {
3071
+ const locale = [env["LC_ALL"], env["LC_CTYPE"], env["LANG"]].find((value) => value !== void 0 && value !== "");
3072
+ if (locale === void 0)
3073
+ return true;
3074
+ return /utf-?8/iu.test(locale);
3075
+ }
3076
+
2998
3077
  // ../../../libs/clinkr/ts/dist/outcomes/refusals.js
2999
3078
  function refused(error) {
3000
3079
  return { ok: false, refusal: error };
@@ -4379,20 +4458,20 @@ function groupListing(application, commands) {
4379
4458
  }
4380
4459
 
4381
4460
  export {
4382
- appSourceOf,
4383
- lazyAppSource,
4461
+ defineErrors,
4384
4462
  stepDocument,
4385
4463
  renderOutcome,
4386
- defineErrors,
4387
4464
  defineOutcomes,
4465
+ commandTree,
4466
+ mount,
4467
+ createApplication,
4468
+ appSourceOf,
4469
+ lazyAppSource,
4388
4470
  INVALID_VALUE,
4389
4471
  CLINKR_PARSE_PARAMS,
4390
4472
  createTerminal,
4391
4473
  resolveColorDepth,
4392
4474
  resolveUnicode,
4393
- commandTree,
4394
- mount,
4395
4475
  runCliWith,
4396
- createApplication,
4397
4476
  refused
4398
4477
  };