@cnc-tools/storm 0.17.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 (129) hide show
  1. package/dist/bin/storm.js +37 -39
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-4WAMTUWZ.js → chunk-24UYAK4R.js} +88 -67
  4. package/dist/chunks/{chunk-RNAS7JHE.js → chunk-2JMWUKH3.js} +710 -102
  5. package/dist/chunks/{chunk-YEPFSLQR.js → chunk-3VXZONGE.js} +2 -2
  6. package/dist/chunks/{chunk-D27KILIA.js → chunk-55O4FCN4.js} +1 -1
  7. package/dist/chunks/{chunk-JN3YY6ZH.js → chunk-AS37D43E.js} +27 -20
  8. package/dist/chunks/{chunk-2VP4GRJM.js → chunk-CQAY6GLP.js} +54 -13
  9. package/dist/chunks/{chunk-MR77L2GK.js → chunk-DZLU7BYK.js} +5 -5
  10. package/dist/chunks/{chunk-LKTZ5OXS.js → chunk-EI3XDCEI.js} +1 -1
  11. package/dist/chunks/{chunk-FNBB6V4R.js → chunk-FDUY3BNF.js} +1 -1
  12. package/dist/chunks/{chunk-RWIXDDCK.js → chunk-GUCCYCIO.js} +3 -3
  13. package/dist/chunks/{chunk-6UHIJXZG.js → chunk-HBI4LEMH.js} +2 -2
  14. package/dist/chunks/{chunk-CKGZA25H.js → chunk-K4MDQPLW.js} +1 -1
  15. package/dist/chunks/{chunk-F4MOYHRY.js → chunk-KK7PAWIZ.js} +1 -1
  16. package/dist/chunks/{chunk-GRT3UIBV.js → chunk-KQ5FXRUD.js} +1 -1
  17. package/dist/chunks/{chunk-WV3DP6NR.js → chunk-LKXHGGGX.js} +1 -1
  18. package/dist/chunks/{chunk-4O5C2XGJ.js → chunk-LOGHIUUB.js} +6 -6
  19. package/dist/chunks/{chunk-7DZE67QM.js → chunk-OEPFINFT.js} +2 -2
  20. package/dist/chunks/{chunk-HWIQ2S7K.js → chunk-OI4AP6Z7.js} +3 -3
  21. package/dist/chunks/{chunk-DADEYJDW.js → chunk-PMBQWVTW.js} +6 -6
  22. package/dist/chunks/{chunk-HP3CURSZ.js → chunk-SZMYIIG2.js} +2 -2
  23. package/dist/chunks/{chunk-2RNDPDTJ.js → chunk-TXCOFC7N.js} +2 -2
  24. package/dist/chunks/{chunk-BCBKYOHW.js → chunk-UXD3TVWM.js} +1 -1
  25. package/dist/chunks/{chunk-M7EKRGVD.js → chunk-WNW2QXQK.js} +1 -1
  26. package/dist/chunks/{live-app-R76JQXZL.js → live-app-UY7BEDUN.js} +9 -7
  27. package/dist/cli.d.ts +28 -0
  28. package/dist/cli.js +64 -0
  29. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
  30. package/dist/commands/exec/across-sandboxes-outcomes.js +1 -1
  31. package/dist/commands/exec/before-run.d.ts +1 -1
  32. package/dist/commands/exec/command.d.ts +36 -12
  33. package/dist/commands/exec/command.js +18 -18
  34. package/dist/commands/exec/execute-run.js +1 -1
  35. package/dist/commands/exec/outcomes.d.ts +71 -15
  36. package/dist/commands/exec/outcomes.js +46 -6
  37. package/dist/commands/exec/plan-run.d.ts +1 -1
  38. package/dist/commands/exec/plan-run.js +8 -3
  39. package/dist/commands/exec/run-metadata.js +1 -1
  40. package/dist/commands/exec/run-summary.js +1 -1
  41. package/dist/commands/runs/facts.d.ts +1 -1
  42. package/dist/commands/runs/facts.js +2 -2
  43. package/dist/commands/runs/list/command.d.ts +2 -2
  44. package/dist/commands/runs/list/command.js +9 -9
  45. package/dist/commands/runs/list/outcomes.d.ts +1 -1
  46. package/dist/commands/runs/logs/command.js +9 -9
  47. package/dist/commands/runs/show/command.d.ts +2 -2
  48. package/dist/commands/runs/show/command.js +16 -16
  49. package/dist/commands/runs/show/metadata.js +1 -1
  50. package/dist/commands/runs/show/outcomes.d.ts +1 -1
  51. package/dist/commands/runs/show/outcomes.js +1 -1
  52. package/dist/commands/snapshots/build/command.d.ts +22 -14
  53. package/dist/commands/snapshots/build/command.js +32 -30
  54. package/dist/commands/snapshots/build/metadata.js +1 -1
  55. package/dist/commands/snapshots/build/outcomes.d.ts +14 -10
  56. package/dist/commands/snapshots/build/outcomes.js +1 -1
  57. package/dist/commands/snapshots/list/command.d.ts +2 -2
  58. package/dist/commands/snapshots/list/command.js +19 -19
  59. package/dist/commands/snapshots/list/outcomes.d.ts +2 -2
  60. package/dist/commands/snapshots/list/outcomes.js +3 -3
  61. package/dist/commands/snapshots/prune/command.js +14 -14
  62. package/dist/commands/suites/list/command.js +10 -10
  63. package/dist/commands/test/command.d.ts +36 -12
  64. package/dist/commands/test/command.js +20 -20
  65. package/dist/commands/test/outcomes.d.ts +18 -6
  66. package/dist/config-file/define.d.ts +1 -1
  67. package/dist/config-file/toolchain.d.ts +13 -3
  68. package/dist/config-file/toolchain.js +41 -5
  69. package/dist/context.d.ts +3 -1
  70. package/dist/context.js +2 -1
  71. package/dist/core/outcomes.d.ts +1 -1
  72. package/dist/core/run.js +1 -1
  73. package/dist/extension-commands.d.ts +2 -7
  74. package/dist/extension-commands.js +3 -17
  75. package/dist/extensions/testserver/commands/pool/create/command.js +3 -3
  76. package/dist/extensions/testserver/commands/pool/list/command.js +2 -2
  77. package/dist/run-directory/recording.js +1 -1
  78. package/dist/run-directory/run-record.d.ts +5 -5
  79. package/dist/run-directory/run-record.js +5 -5
  80. package/dist/runner/build-snapshots.d.ts +5 -0
  81. package/dist/runner/build-snapshots.js +11 -5
  82. package/dist/runner/gateways.d.ts +37 -4
  83. package/dist/runner/gh.d.ts +42 -0
  84. package/dist/runner/gh.js +58 -0
  85. package/dist/runner/index.d.ts +5 -4
  86. package/dist/runner/index.js +3 -2
  87. package/dist/runner/live/checkout-gateway.js +7 -0
  88. package/dist/runner/live/gh-output.d.ts +17 -0
  89. package/dist/runner/live/gh-output.js +37 -0
  90. package/dist/runner/live/gh-token-gateway.d.ts +13 -0
  91. package/dist/runner/live/gh-token-gateway.js +51 -0
  92. package/dist/runner/live/sandbox-gateway.js +12 -2
  93. package/dist/runner/live/snapshot-records.js +10 -9
  94. package/dist/runner/local-snapshot-index.d.ts +11 -5
  95. package/dist/runner/local-snapshot-index.js +13 -14
  96. package/dist/runner/ready.d.ts +1 -1
  97. package/dist/runner/ready.js +1 -1
  98. package/dist/runner/scope.d.ts +5 -2
  99. package/dist/runner/scope.js +6 -2
  100. package/dist/runner/secrets.d.ts +37 -14
  101. package/dist/runner/secrets.js +218 -25
  102. package/dist/runner/session.js +3 -0
  103. package/dist/runner/shared-snapshot-entry.d.ts +3 -3
  104. package/dist/runner/shared-snapshot-entry.js +4 -4
  105. package/dist/runner/shared-snapshot-list.d.ts +1 -1
  106. package/dist/runner/shared-snapshot-list.js +1 -1
  107. package/dist/runner/shared-snapshot-lookup.d.ts +1 -1
  108. package/dist/runner/shared-snapshot-lookup.js +1 -1
  109. package/dist/runner/snapshot-build.js +54 -25
  110. package/dist/runner/snapshot-choice.js +1 -0
  111. package/dist/runner/snapshot-inspect.js +2 -5
  112. package/dist/runner/snapshot-key.d.ts +21 -7
  113. package/dist/runner/snapshot-key.js +31 -7
  114. package/dist/runner/snapshot-source.d.ts +31 -0
  115. package/dist/runner/snapshot-source.js +122 -0
  116. package/dist/runner/vercel-sandbox-check.d.ts +2 -0
  117. package/dist/runner/vercel-sandbox-check.js +6 -2
  118. package/dist/runner/vercel-sandbox-options.d.ts +36 -6
  119. package/dist/runner/vercel-sandbox-options.js +62 -19
  120. package/dist/runner/vercel-sandbox-secrets.d.ts +55 -6
  121. package/dist/runner/vercel-sandbox-secrets.js +142 -9
  122. package/dist/sdk/extension/commands.d.ts +3 -8
  123. package/dist/sdk/extension/commands.js +1 -3
  124. package/package.json +4 -3
  125. package/skills/overview.md +1 -1
  126. package/dist/application.d.ts +0 -30
  127. package/dist/application.js +0 -41
  128. package/dist/bin/run.d.ts +0 -18
  129. package/dist/bin/run.js +0 -31
package/dist/bin/storm.js CHANGED
@@ -1,24 +1,32 @@
1
1
  import {
2
2
  runNodeCli
3
- } from "../chunks/chunk-BCBKYOHW.js";
3
+ } from "../chunks/chunk-UXD3TVWM.js";
4
4
  import {
5
5
  testserverExtensionCommands
6
- } from "../chunks/chunk-D27KILIA.js";
7
- import "../chunks/chunk-2RNDPDTJ.js";
6
+ } from "../chunks/chunk-55O4FCN4.js";
7
+ import "../chunks/chunk-TXCOFC7N.js";
8
8
  import {
9
9
  stormCommands
10
- } from "../chunks/chunk-WV3DP6NR.js";
10
+ } from "../chunks/chunk-LKXHGGGX.js";
11
11
  import {
12
12
  createApplication
13
- } from "../chunks/chunk-4WAMTUWZ.js";
13
+ } from "../chunks/chunk-24UYAK4R.js";
14
14
 
15
15
  // src/bin/storm.ts
16
16
  import { readFileSync } from "node:fs";
17
17
  import { fileURLToPath } from "node:url";
18
18
 
19
- // src/application.ts
19
+ // src/cli.ts
20
20
  import { join } from "node:path";
21
21
 
22
+ // src/extension-commands.ts
23
+ var EXTENSION_COMMANDS = [
24
+ { commands: testserverExtensionCommands, path: ["ext", "testserver"] }
25
+ ];
26
+ function extensionMounts(root2) {
27
+ return EXTENSION_COMMANDS.map(({ commands, path }) => commands.mount({ path, root: root2 }));
28
+ }
29
+
22
30
  // src/help-logo.ts
23
31
  var CLOUD_TOP = [" .-~~~~~-. .-~~~~-.", " .-~( )~-..-~( )~-."];
24
32
  var CLOUD_WORDMARK = { indent: " ", left: "( ", wordmark: "storm", right: " )" };
@@ -63,15 +71,7 @@ function stormHelpLogo(terminal, options) {
63
71
  return lines.join("\n");
64
72
  }
65
73
 
66
- // src/extension-commands.ts
67
- var EXTENSION_COMMANDS = [
68
- { commands: testserverExtensionCommands, path: ["ext", "testserver"] }
69
- ];
70
- function extensionMounts(root2) {
71
- return EXTENSION_COMMANDS.map(({ commands, path }) => commands.mount({ path, root: root2 }));
72
- }
73
-
74
- // src/application.ts
74
+ // src/cli.ts
75
75
  var DESCRIPTION = [
76
76
  "Run a project's tests in a test environment that storm sets up.",
77
77
  "",
@@ -79,26 +79,21 @@ var DESCRIPTION = [
79
79
  "",
80
80
  "Docs: https://storm.playground-vercel.tools/"
81
81
  ].join("\n");
82
- function directoryStormSources(root2) {
82
+ function sources(root2) {
83
83
  return {
84
84
  commands: stormCommands.directory(join(root2, "commands")),
85
85
  mounts: extensionMounts(root2),
86
86
  skills: join(root2, "../skills")
87
87
  };
88
88
  }
89
- async function loadStormApplication(version2, options) {
90
- const { accessible, commands, mounts, skills } = options;
91
- return await createApplication("storm", {
92
- commands,
89
+ function application(cliSources, options) {
90
+ const accessible = options?.accessible ?? false;
91
+ return createApplication("storm", {
92
+ ...cliSources,
93
93
  description: DESCRIPTION,
94
- version: version2,
95
- helpLogo: (terminal) => stormHelpLogo(terminal, { accessible }),
96
- mounts,
97
- skills
94
+ helpLogo: (terminal) => stormHelpLogo(terminal, { accessible })
98
95
  });
99
96
  }
100
-
101
- // src/bin/run.ts
102
97
  function hasNoColorFlag(argv) {
103
98
  for (const token of argv) {
104
99
  if (token === "--") return false;
@@ -106,33 +101,36 @@ function hasNoColorFlag(argv) {
106
101
  }
107
102
  return false;
108
103
  }
109
- async function runStormCli(options) {
104
+ async function run(options) {
110
105
  const exit = { status: void 0 };
111
106
  const accessible = process.env["VERCEL_ACCESSIBLE"] === "1";
112
- const noColor = hasNoColorFlag(process.argv.slice(2));
113
- const status = await runNodeCli(await loadStormApplication(options.version, { accessible, ...options.sources }), {
107
+ const noColor = hasNoColorFlag(options.argv);
108
+ const status = await runNodeCli(await application(options.sources, { accessible }), {
109
+ argv: options.argv,
114
110
  app: async (host) => {
115
- const [{ liveStormApp }, buildInfo] = await Promise.all([import("../chunks/live-app-R76JQXZL.js"), options.buildInfo()]);
116
- return liveStormApp(host, buildInfo, exit, { noColor });
111
+ const commitPromise = typeof options.commit === "function" ? options.commit() : Promise.resolve(options.commit);
112
+ const [{ liveStormApp }, resolvedCommit] = await Promise.all([import("../chunks/live-app-UY7BEDUN.js"), commitPromise]);
113
+ return liveStormApp(host, { version: options.version, commit: resolvedCommit }, exit, { noColor });
117
114
  }
118
115
  });
119
- process.exitCode = exit.status ?? status;
116
+ return exit.status ?? status;
120
117
  }
121
118
 
122
119
  // src/bin/storm.ts
123
120
  var root = fileURLToPath(new URL("..", import.meta.url));
124
121
  var manifest = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
125
122
  var commitRead;
126
- function commit() {
123
+ function readCommit() {
127
124
  commitRead ??= import("../chunks/version-X7RMSKZI.js").then(({ buildCommit }) => buildCommit(import.meta.url));
128
125
  return commitRead;
129
126
  }
130
- async function version() {
131
- const [{ versionText }, built] = await Promise.all([import("../chunks/version-X7RMSKZI.js"), commit()]);
127
+ async function formatVersion() {
128
+ const [{ versionText }, built] = await Promise.all([import("../chunks/version-X7RMSKZI.js"), readCommit()]);
132
129
  return versionText(manifest.version, built);
133
130
  }
134
- await runStormCli({
135
- version,
136
- buildInfo: async () => ({ version: manifest.version, commit: await commit() }),
137
- sources: directoryStormSources(root)
131
+ process.exitCode = await run({
132
+ argv: process.argv.slice(2),
133
+ sources: { ...sources(root), version: formatVersion },
134
+ version: manifest.version,
135
+ commit: readCommit
138
136
  });
@@ -1,3 +1,3 @@
1
1
  // Written by scripts/write-build-info.js when the package was built.
2
- export const sha = "1768bcd51e0f";
2
+ export const sha = "b2c342aa63be";
3
3
  export const dirty = false;
@@ -1533,13 +1533,14 @@ function commandTree(tree) {
1533
1533
  throw new Error(`Command tree ${tag.id}: directory takes an absolute path`);
1534
1534
  return Object.freeze({ kind: "directory", tree: tag.id, directory });
1535
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 }) });
1540
- }
1536
+ manifest: (commands) => createManifestGroup(tag.id, commands)
1541
1537
  });
1542
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
+ }
1543
1544
  var GROUP_KEYS = ["commands", ...GROUP_NAVIGATION_KEYS];
1544
1545
  function groupNavigation(treeId, navigation) {
1545
1546
  const unknown = Object.keys(navigation).filter((key) => !GROUP_KEYS.includes(key));
@@ -1569,12 +1570,10 @@ function mount(group, options) {
1569
1570
  }
1570
1571
 
1571
1572
  // ../../../libs/clinkr/ts/dist/create-application.js
1572
- import { readdir as readdir3, stat as stat2 } from "node:fs/promises";
1573
- import { join as join4 } from "node:path";
1573
+ import { stat as stat2 } from "node:fs/promises";
1574
1574
 
1575
1575
  // ../../../libs/clinkr/ts/dist/discovery.js
1576
- import { readdir, stat } from "node:fs/promises";
1577
- import { basename, join } from "node:path";
1576
+ import { basename as basename2 } from "node:path";
1578
1577
  import { pathToFileURL } from "node:url";
1579
1578
 
1580
1579
  // ../../../libs/clinkr/ts/dist/is-listed.js
@@ -1591,6 +1590,67 @@ function defaultCommandOf(nodes) {
1591
1590
  return nodes.find((node) => isDefaultCommand(node) && isListed(node));
1592
1591
  }
1593
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
+
1594
1654
  // ../../../libs/clinkr/ts/dist/discovery.js
1595
1655
  function isGroup(node) {
1596
1656
  return node.description.kind === "group";
@@ -1601,9 +1661,6 @@ function sourceOf(group) {
1601
1661
  function matchesName(node, segment) {
1602
1662
  return node.description.name === segment || commandAliases(node.description).includes(segment);
1603
1663
  }
1604
- function compareCodeUnits(left, right) {
1605
- return left < right ? -1 : left > right ? 1 : 0;
1606
- }
1607
1664
  function undeclaredSection(section2, declared) {
1608
1665
  if (section2 === void 0 || declared === void 0 || declared.has(section2))
1609
1666
  return void 0;
@@ -1763,30 +1820,27 @@ function manifestNode(scope, name, entry, prefix) {
1763
1820
  }
1764
1821
  async function discoverChildren(scope, prefix, directory) {
1765
1822
  return checkedSiblings(scope, prefix, async () => {
1766
- const entries = await readdir(directory, { withFileTypes: true });
1767
- const directories = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).toSorted(compareCodeUnits);
1823
+ const directories = await listCommandDirectoryNames(directory);
1768
1824
  return Promise.all(directories.map((name) => discoverNode(scope, name, prefix, directory)));
1769
1825
  });
1770
1826
  }
1771
1827
  function discoverNode(scope, name, prefix, parentDirectory) {
1772
- const directory = join(parentDirectory, name);
1773
1828
  const location = [...prefix, name];
1774
1829
  return atLocation(scope.source, location, async () => {
1775
- const metadataPath = await findModule(directory, "metadata");
1776
- if (metadataPath === void 0)
1777
- throw new Error(`Missing metadata.ts or metadata.js for command node: ${directory}`);
1778
- const metadata = await loadMetadata(metadataPath);
1779
- const found = { name, metadata, metadataLabel: metadataPath, where: directory };
1780
- const entries = await readdir(directory, { withFileTypes: true });
1781
- const hasChildDirectories = entries.some((entry) => entry.isDirectory());
1782
- const commandModule = await findModule(directory, "command");
1783
- if (commandModule === void 0)
1784
- return groupNode(scope, found, () => discoverChildren(scope, location, directory));
1785
- if (hasChildDirectories)
1786
- 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
+ }
1787
1841
  const treeId = scope.source.id;
1788
- const root = scope.source.directory ?? directory;
1789
- 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));
1790
1844
  });
1791
1845
  }
1792
1846
  function checkAliasConflicts(nodes, prefix) {
@@ -1840,7 +1894,7 @@ function commandOfModule(module) {
1840
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})`}`);
1841
1895
  const own = typeof exported.navigation === "object" && exported.navigation !== null ? Object.keys(exported.navigation) : [];
1842
1896
  if (own.length > 0)
1843
- throw new Error(`Invalid command export in ${commandLabel}: navigation parts go in ${metadataName ?? basename(metadataLabel)}, not ${own.join(", ")}`);
1897
+ throw new Error(`Invalid command export in ${commandLabel}: navigation parts go in ${metadataName ?? basename2(metadataLabel)}, not ${own.join(", ")}`);
1844
1898
  let checked;
1845
1899
  try {
1846
1900
  checked = checkCommandDefinition(exported);
@@ -1852,27 +1906,6 @@ function commandOfModule(module) {
1852
1906
  throw new Error(`Command help is set in both ${metadataLabel} and ${commandLabel}; set it in one of them`);
1853
1907
  return Object.freeze({ ...checked, navigation: Object.freeze(navigation), ...help === void 0 ? {} : { help } });
1854
1908
  }
1855
- async function findModule(directory, stem) {
1856
- const typescript = join(directory, `${stem}.ts`);
1857
- if (await isFile(typescript))
1858
- return typescript;
1859
- const javascript = join(directory, `${stem}.js`);
1860
- if (await isFile(javascript))
1861
- return javascript;
1862
- return void 0;
1863
- }
1864
- async function isFile(path) {
1865
- try {
1866
- return (await stat(path)).isFile();
1867
- } catch (error) {
1868
- if (isMissing(error))
1869
- return false;
1870
- throw error;
1871
- }
1872
- }
1873
- function isMissing(error) {
1874
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
1875
- }
1876
1909
 
1877
1910
  // ../../../libs/clinkr/ts/dist/mounts.js
1878
1911
  import { join as join2, resolve } from "node:path";
@@ -1996,8 +2029,7 @@ function isResult(value) {
1996
2029
  }
1997
2030
 
1998
2031
  // ../../../libs/clinkr/ts/dist/skills/read-skills.js
1999
- import { readFile, readdir as readdir2 } from "node:fs/promises";
2000
- import { isAbsolute as isAbsolute2, join as join3 } from "node:path";
2032
+ import { readFile as readFile2 } from "node:fs/promises";
2001
2033
 
2002
2034
  // ../../../libs/clinkr/ts/dist/skills/skill-file.js
2003
2035
  var COMMANDS_SKILL_NAME = "commands";
@@ -2125,7 +2157,7 @@ function fileStem(path) {
2125
2157
  function parseSkillRecord(files) {
2126
2158
  if (typeof files !== "object" || files === null || Array.isArray(files))
2127
2159
  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);
2160
+ const names = Object.keys(files).toSorted(compareCodeUnits);
2129
2161
  return Object.freeze(names.map((name) => {
2130
2162
  if (!name.endsWith(".md") || name.startsWith(".") || name.includes("/") || name.includes("\\"))
2131
2163
  throw new Error(`Invalid skill file name ${JSON.stringify(name)}: expected a plain <name>.md file name`);
@@ -2136,19 +2168,8 @@ function parseSkillRecord(files) {
2136
2168
  }));
2137
2169
  }
2138
2170
  async function readSkillFiles(directory) {
2139
- if (typeof directory !== "string" || !isAbsolute2(directory))
2140
- throw new Error(`skills must be an absolute directory path; received ${JSON.stringify(directory)}`);
2141
- let entries;
2142
- try {
2143
- entries = await readdir2(directory, { withFileTypes: true });
2144
- } catch (cause) {
2145
- throw new Error(`Unable to read the skills directory ${directory}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
2146
- }
2147
- 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);
2148
- return Promise.all(names.map(async (name) => {
2149
- const path = join3(directory, name);
2150
- return parseSkillFile(path, await readFile(path, "utf8"));
2151
- }));
2171
+ const files = await listSkillFiles(directory);
2172
+ return Promise.all(files.map(async ({ path }) => parseSkillFile(path, await readFile2(path, "utf8"))));
2152
2173
  }
2153
2174
 
2154
2175
  // ../../../libs/clinkr/ts/dist/skills/skills-group.js