@darkrymit/crunes-cli 0.9.0 → 0.10.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 (59) hide show
  1. package/dist/chunks/add-MSX6XSU3.js +68 -0
  2. package/dist/chunks/{apply-YY7MIM64.js → apply-LOIJIPLR.js} +18 -9
  3. package/dist/chunks/{benchmark-BQNMULOO.js → benchmark-3IHFP3V2.js} +21 -15
  4. package/dist/chunks/chunk-2DNYVKBF.js +109 -0
  5. package/dist/chunks/chunk-2FI6KN3C.js +283 -0
  6. package/dist/chunks/chunk-2HM5Q52B.js +131 -0
  7. package/dist/chunks/chunk-55GTJG5I.js +1154 -0
  8. package/dist/chunks/chunk-6IC6ZJ74.js +9525 -0
  9. package/dist/chunks/chunk-7KYCYDAS.js +325 -0
  10. package/dist/chunks/chunk-DTOYFY3Z.js +578 -0
  11. package/dist/chunks/chunk-EO3CSXWK.js +70 -0
  12. package/dist/chunks/chunk-FIAFVIAN.js +79 -0
  13. package/dist/chunks/chunk-H2OT7D6N.js +303 -0
  14. package/dist/chunks/{chunk-MRNZFUXZ.js → chunk-KSQDFE5N.js} +22 -7
  15. package/dist/chunks/{chunk-SNC7AOT7.js → chunk-KUEMDPNG.js} +45 -94
  16. package/dist/chunks/{chunk-VST6HAB6.js → chunk-MTJ2KW3V.js} +2 -0
  17. package/dist/chunks/{chunk-CY6C6ADU.js → chunk-MVCBPI4J.js} +45 -478
  18. package/dist/chunks/{chunk-34F4ZURL.js → chunk-RVBAAXRY.js} +29 -12
  19. package/dist/chunks/{chunk-X7PZN73N.js → chunk-SUCYDYMU.js} +1 -1
  20. package/dist/chunks/chunk-UBCAZGLE.js +15 -0
  21. package/dist/chunks/chunk-VP7YLCQP.js +244 -0
  22. package/dist/chunks/chunk-XDMMSZIL.js +71 -0
  23. package/dist/chunks/chunk-YKIKJHYO.js +94 -0
  24. package/dist/chunks/{create-TLPM7HJE.js → create-DXW4YYLJ.js} +5 -5
  25. package/dist/chunks/{create-LM7U3CJS.js → create-LPLNCOW4.js} +100 -6
  26. package/dist/chunks/{create-ET6DT5ZE.js → create-Y4LHLWGL.js} +6 -2
  27. package/dist/chunks/{disable-TNTEIAKO.js → disable-TITOSMXB.js} +6 -2
  28. package/dist/chunks/doctor-R2Y6UAY4.js +208 -0
  29. package/dist/chunks/{enable-GUQCB4CU.js → enable-LGTPDWPV.js} +7 -3
  30. package/dist/chunks/{init-PJSCFOC6.js → init-KO2HLED5.js} +6 -2
  31. package/dist/chunks/{install-4YP7FALO.js → install-7IRUAGSF.js} +10 -5
  32. package/dist/chunks/{intro-SA7MWV3Z.js → intro-JNJ6A75J.js} +44 -18
  33. package/dist/chunks/{list-WKNPZZOV.js → list-BCCM3TLP.js} +10 -6
  34. package/dist/chunks/{list-7R6NASFI.js → list-MLKZE36K.js} +19 -19
  35. package/dist/chunks/list-QVZKR3IE.js +62 -0
  36. package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
  37. package/dist/chunks/migrate-Y3EKMVP5.js +87 -0
  38. package/dist/chunks/{registry-K5DV5NAK.js → registry-IWP7JMNI.js} +1 -1
  39. package/dist/chunks/{repl-ZB3DIJ4K.js → repl-5GDN3RAO.js} +30 -20
  40. package/dist/chunks/resolver-CA2A32AC.js +36 -0
  41. package/dist/chunks/{run-22B65ZWZ.js → run-WL3IZBXF.js} +17 -11
  42. package/dist/chunks/rune-YA4TFHTB.js +283 -0
  43. package/dist/chunks/runner-QNZMBHQY.js +34 -0
  44. package/dist/chunks/{shell-explain-QLITLHW7.js → shell-explain-LKBBP2BG.js} +5 -2
  45. package/dist/chunks/trust-BFIDANXD.js +109 -0
  46. package/dist/chunks/{uninstall-4WR5IHLC.js → uninstall-3MWZIZVA.js} +10 -5
  47. package/dist/chunks/{update-ACLDK6E6.js → update-W4MJUTTW.js} +10 -5
  48. package/dist/chunks/{version-EULYWNXN.js → version-FLHI5KFS.js} +2 -2
  49. package/dist/cli.js +51 -34
  50. package/package.json +2 -2
  51. package/dist/chunks/chunk-G3U4V32O.js +0 -46
  52. package/dist/chunks/chunk-QYRF3R35.js +0 -154
  53. package/dist/chunks/chunk-YXCHIMLW.js +0 -75308
  54. package/dist/chunks/doctor-VXAQYMTR.js +0 -101
  55. package/dist/chunks/list-OMMZAQ23.js +0 -28
  56. package/dist/chunks/resolver-QIYYFIDX.js +0 -34
  57. package/dist/chunks/rune-SYK4N642.js +0 -425
  58. package/dist/chunks/{delete-5R3WBLVD.js → delete-2EXPFBFC.js} +4 -4
  59. package/dist/chunks/{delete-U4STA2QZ.js → delete-MJAECXXV.js} +4 -4
@@ -1,101 +0,0 @@
1
- import {
2
- getConfigPath,
3
- readRawConfig
4
- } from "./chunk-X7PZN73N.js";
5
- import {
6
- coercePlugins,
7
- loadConfig
8
- } from "./chunk-QYRF3R35.js";
9
- import {
10
- output
11
- } from "./chunk-MIKWIFYR.js";
12
- import "./chunk-CGZL5SSH.js";
13
- import "./chunk-WCODTMDN.js";
14
- import "./chunk-2Q3KLBE6.js";
15
- import {
16
- init_require_shim
17
- } from "./chunk-TPK5AGRA.js";
18
-
19
- // src/cli/commands/doctor.js
20
- init_require_shim();
21
- import { spawnSync } from "node:child_process";
22
- var KNOWN_FORMATS = /* @__PURE__ */ new Set(["1"]);
23
- function collectLayerWarnings({ global = {}, project = {} } = {}) {
24
- const warnings = [];
25
- for (const key of Object.keys(project.runes ?? {})) {
26
- if (global.runes?.[key]) {
27
- warnings.push(`rune "${key}" shadows the global rune of the same name`);
28
- }
29
- }
30
- const globalPlugins = coercePlugins(global.plugins);
31
- const projectPlugins = coercePlugins(project.plugins);
32
- for (const [key, enabled] of Object.entries(projectPlugins)) {
33
- if (globalPlugins[key] === true && enabled === false) {
34
- warnings.push(`plugin "${key}" is enabled globally but disabled in this project`);
35
- }
36
- }
37
- return warnings;
38
- }
39
- async function handler({ projectRoot = process.cwd() } = {}) {
40
- let anyFailed = false;
41
- const major = parseInt(process.versions.node.split(".")[0], 10);
42
- if (major >= 22) {
43
- output.success(`Node.js v${process.versions.node}`);
44
- } else {
45
- output.error(`Node.js v${process.versions.node} \u2014 requires >= 22`);
46
- anyFailed = true;
47
- }
48
- const versionResult = spawnSync("crunes", ["--version"], { encoding: "utf8", shell: true });
49
- if (versionResult.status === 0) {
50
- output.success(`crunes ${versionResult.stdout.trim()} in PATH`);
51
- } else {
52
- output.warn("crunes not found globally in PATH (you can still run it locally or via npx)");
53
- }
54
- let config;
55
- try {
56
- config = loadConfig(projectRoot);
57
- } catch (err) {
58
- output.error(`Config: ${err.message}`);
59
- anyFailed = true;
60
- }
61
- if (config) {
62
- const runeCount = Object.keys(config.runes ?? {}).length;
63
- if (config.format !== void 0 && !KNOWN_FORMATS.has(String(config.format))) {
64
- output.error(`Config format "${config.format}" not recognised by this CLI version`);
65
- anyFailed = true;
66
- } else {
67
- output.success(`Config valid \u2014 ${runeCount} rune${runeCount === 1 ? "" : "s"} registered`);
68
- }
69
- }
70
- const globalPath = getConfigPath({ global: true });
71
- let globalRaw = null;
72
- try {
73
- globalRaw = readRawConfig(globalPath);
74
- } catch {
75
- }
76
- if (process.env.CRUNES_NO_GLOBAL === "1") {
77
- output.warn("Global config skipped (CRUNES_NO_GLOBAL=1)");
78
- } else if (globalRaw) {
79
- output.success(`Global config found at ${globalPath}`);
80
- } else {
81
- output.info(`No global config at ${globalPath}`);
82
- }
83
- let projectRaw = null;
84
- try {
85
- projectRaw = readRawConfig(getConfigPath({ configRoot: projectRoot }));
86
- } catch {
87
- }
88
- if (!projectRaw) {
89
- output.info("No project config \u2014 crunes runs rootless here, writing no local state");
90
- }
91
- for (const warning of collectLayerWarnings({ global: globalRaw ?? {}, project: projectRaw ?? {} })) {
92
- output.warn(warning);
93
- }
94
- if (anyFailed) {
95
- process.exit(1);
96
- }
97
- }
98
- export {
99
- collectLayerWarnings,
100
- handler
101
- };
@@ -1,28 +0,0 @@
1
- import {
2
- loadRegistry
3
- } from "./chunk-VST6HAB6.js";
4
- import "./chunk-2Q3KLBE6.js";
5
- import {
6
- init_require_shim
7
- } from "./chunk-TPK5AGRA.js";
8
-
9
- // src/plugin/commands/list.js
10
- init_require_shim();
11
- async function handler({ format = "md" }) {
12
- const registry = await loadRegistry();
13
- const plugins = Object.entries(registry.plugins ?? {});
14
- if (plugins.length === 0) {
15
- console.log("No plugins installed.");
16
- return;
17
- }
18
- if (format === "json") {
19
- console.log(JSON.stringify(registry.plugins, null, 2));
20
- return;
21
- }
22
- for (const [key, entry] of plugins) {
23
- console.log(`${key} v${entry.version}`);
24
- }
25
- }
26
- export {
27
- handler
28
- };
@@ -1,34 +0,0 @@
1
- import {
2
- describeConfigLayers,
3
- getRune,
4
- normaliseRune,
5
- resolvePluginRune,
6
- resolveRuneEntry,
7
- resolveRuneFilePath,
8
- resolveRuneFromPlugins,
9
- runRune
10
- } from "./chunk-YXCHIMLW.js";
11
- import "./chunk-UEUUOAJY.js";
12
- import "./chunk-4GJMCFR6.js";
13
- import "./chunk-CY6C6ADU.js";
14
- import "./chunk-GVMT55GH.js";
15
- import "./chunk-WJII3LZK.js";
16
- import "./chunk-G4ZAUHHA.js";
17
- import "./chunk-QYRF3R35.js";
18
- import "./chunk-MIKWIFYR.js";
19
- import "./chunk-CGZL5SSH.js";
20
- import "./chunk-WCODTMDN.js";
21
- import "./chunk-VST6HAB6.js";
22
- import "./chunk-2Q3KLBE6.js";
23
- import "./chunk-G3U4V32O.js";
24
- import "./chunk-TPK5AGRA.js";
25
- export {
26
- describeConfigLayers,
27
- getRune,
28
- normaliseRune,
29
- resolvePluginRune,
30
- resolveRuneEntry,
31
- resolveRuneFilePath,
32
- resolveRuneFromPlugins,
33
- runRune
34
- };
@@ -1,425 +0,0 @@
1
- import {
2
- enumerateRunes
3
- } from "./chunk-MRNZFUXZ.js";
4
- import {
5
- getArgsSchema,
6
- getPluginRunePath,
7
- getReplSchema,
8
- getRune,
9
- resolvePluginRune,
10
- resolveRuneFilePath,
11
- resolveRuneFromPlugins
12
- } from "./chunk-YXCHIMLW.js";
13
- import "./chunk-UEUUOAJY.js";
14
- import "./chunk-4GJMCFR6.js";
15
- import {
16
- computeEffectivePermissions
17
- } from "./chunk-CY6C6ADU.js";
18
- import "./chunk-GVMT55GH.js";
19
- import "./chunk-WJII3LZK.js";
20
- import "./chunk-G4ZAUHHA.js";
21
- import {
22
- loadConfig
23
- } from "./chunk-QYRF3R35.js";
24
- import {
25
- output
26
- } from "./chunk-MIKWIFYR.js";
27
- import "./chunk-CGZL5SSH.js";
28
- import "./chunk-WCODTMDN.js";
29
- import "./chunk-VST6HAB6.js";
30
- import "./chunk-2Q3KLBE6.js";
31
- import {
32
- loadPluginJson
33
- } from "./chunk-G3U4V32O.js";
34
- import {
35
- init_require_shim
36
- } from "./chunk-TPK5AGRA.js";
37
-
38
- // src/docs/commands/rune.js
39
- init_require_shim();
40
- import { relative } from "node:path";
41
-
42
- // src/docs/help-render.js
43
- init_require_shim();
44
- var PAD = 24;
45
- function row(label, description, indent = " ") {
46
- const padded = label.length >= PAD ? label + " " : label.padEnd(PAD);
47
- return `${indent}${padded} ${description ?? ""}`.trimEnd();
48
- }
49
- function positionalSpecs(node) {
50
- return (node?.positionals ?? []).map((p) => p.spec).join(" ");
51
- }
52
- function flattenCommands(commands, prefix = "") {
53
- const rows = [];
54
- for (const cmd of commands ?? []) {
55
- const path = prefix ? `${prefix} ${cmd.name}` : cmd.name;
56
- const specs = positionalSpecs(cmd);
57
- rows.push({
58
- path,
59
- label: specs ? `${path} ${specs}` : path,
60
- description: cmd.description ?? "",
61
- node: cmd
62
- });
63
- rows.push(...flattenCommands(cmd.commands ?? [], path));
64
- }
65
- return rows;
66
- }
67
- function selectNode(schema, segments) {
68
- let node = schema;
69
- const matched = [];
70
- for (const seg of segments ?? []) {
71
- const children = node?.commands ?? [];
72
- const next = children.find((c) => c.name === seg);
73
- if (!next) {
74
- return {
75
- node: null,
76
- matchedPath: matched.join(" "),
77
- failedAt: seg,
78
- candidates: children.map((c) => c.name)
79
- };
80
- }
81
- node = next;
82
- matched.push(seg);
83
- }
84
- return {
85
- node,
86
- matchedPath: matched.join(" "),
87
- failedAt: null,
88
- candidates: (node?.commands ?? []).map((c) => c.name)
89
- };
90
- }
91
- function verb(lifecycle) {
92
- return lifecycle === "repl" ? "repl" : "run";
93
- }
94
- function optionRows(options, indent = " ") {
95
- return (options ?? []).map((opt) => {
96
- const def = opt.def !== void 0 ? ` [default: ${JSON.stringify(opt.def)}]` : "";
97
- return row(opt.flags, `${opt.description ?? ""}${def}`, indent);
98
- });
99
- }
100
- function exampleLines(examples, indent = " ") {
101
- const lines = [];
102
- for (const ex of examples ?? []) {
103
- lines.push(`${indent}${ex.usage}`);
104
- if (ex.description) lines.push(`${indent} ${ex.description}`);
105
- }
106
- return lines;
107
- }
108
- function formatCommandPage(node, meta) {
109
- const key = meta?.key ?? "rune";
110
- const path = meta?.path ?? "";
111
- const specs = positionalSpecs(node);
112
- const children = node?.commands ?? [];
113
- const usage = [`Usage: crunes ${verb(meta?.lifecycle)} ${key}`];
114
- if (path) usage.push(path);
115
- if (specs) usage.push(specs);
116
- else if (children.length > 0) usage.push("<command>");
117
- usage.push("[options]");
118
- const lines = [usage.join(" ")];
119
- if (node?.description) {
120
- lines.push("");
121
- lines.push(` ${node.description}`);
122
- }
123
- const positionals = node?.positionals ?? [];
124
- if (positionals.length > 0) {
125
- lines.push("");
126
- lines.push("Positionals:");
127
- for (const p of positionals) lines.push(row(p.spec ?? "", p.description));
128
- }
129
- const options = node?.options ?? [];
130
- if (options.length > 0) {
131
- lines.push("");
132
- lines.push("Options:");
133
- lines.push(...optionRows(options));
134
- }
135
- if (children.length > 0) {
136
- lines.push("");
137
- lines.push("Commands:");
138
- for (const child of children) {
139
- const childPath = path ? `${path} ${child.name}` : child.name;
140
- const childSpecs = positionalSpecs(child);
141
- lines.push(row(childSpecs ? `${childPath} ${childSpecs}` : childPath, child.description));
142
- }
143
- }
144
- const examples = node?.examples ?? [];
145
- if (examples.length > 0) {
146
- lines.push("");
147
- lines.push("Examples:");
148
- lines.push(...exampleLines(examples));
149
- }
150
- return lines.join("\n");
151
- }
152
- function formatRuneIndex(schema, meta) {
153
- const key = meta?.key ?? "rune";
154
- const label = meta?.description ?? meta?.name ?? null;
155
- const commands = schema?.commands ?? [];
156
- const specs = positionalSpecs(schema);
157
- const lines = [`Rune: ${key}${label ? ` \u2014 ${label}` : ""}`];
158
- if (meta?.relativePath) lines.push(`File (project-relative): ${meta.relativePath}`);
159
- const usage = [`Usage: crunes ${verb(meta?.lifecycle)} ${key}`];
160
- if (specs) usage.push(specs);
161
- else if (commands.length > 0) usage.push("<command>");
162
- usage.push("[options]");
163
- lines.push("");
164
- lines.push(usage.join(" "));
165
- const positionals = schema?.positionals ?? [];
166
- if (positionals.length > 0) {
167
- lines.push("");
168
- lines.push("Positionals:");
169
- for (const p of positionals) lines.push(row(p.spec ?? "", p.description));
170
- }
171
- const options = schema?.options ?? [];
172
- if (options.length > 0) {
173
- lines.push("");
174
- lines.push("Options:");
175
- lines.push(...optionRows(options));
176
- }
177
- if (commands.length > 0) {
178
- lines.push("");
179
- lines.push("Commands:");
180
- for (const r of flattenCommands(commands)) lines.push(row(r.label, r.description));
181
- }
182
- const rootExamples = schema?.examples ?? [];
183
- if (commands.length === 0 && rootExamples.length > 0) {
184
- lines.push("");
185
- lines.push("Examples:");
186
- lines.push(...exampleLines(rootExamples));
187
- }
188
- const replCommands = meta?.repl?.commands ?? [];
189
- if (replCommands.length > 0) {
190
- lines.push("");
191
- lines.push("REPL commands:");
192
- for (const c of replCommands) lines.push(row(`/${c.name}`, c.description));
193
- }
194
- if (meta?.includeBatch === true) {
195
- lines.push("");
196
- lines.push("Batch:");
197
- if (!meta.batch) {
198
- lines.push(" (no batch block declared \u2014 this rune cannot appear in a -b batch)");
199
- } else {
200
- const allow = meta.batch.allow ?? [];
201
- const deny = meta.batch.deny ?? [];
202
- lines.push(` allow: ${allow.length ? allow.join(", ") : "(none)"}`);
203
- if (deny.length) lines.push(` deny: ${deny.join(", ")}`);
204
- }
205
- }
206
- if (commands.length > 0) {
207
- lines.push("");
208
- lines.push(`Drill down: crunes docs rune ${key} <command>`);
209
- }
210
- return lines.join("\n");
211
- }
212
- var GLOBAL_PAD = 50;
213
- function formatGlobalIndex(entries) {
214
- if (!entries || entries.length === 0) {
215
- return "No runes configured. Run `crunes create <key>` to add one.";
216
- }
217
- const lines = ["Runes:", ""];
218
- for (const e of entries) {
219
- if (e.error) {
220
- lines.push(`\u26A0 ${e.key} \u2014 could not build args schema: ${e.error}`);
221
- lines.push("");
222
- continue;
223
- }
224
- const label = e.description ?? e.name ?? "";
225
- const head = `${e.key}${label ? ` \u2014 ${label}` : ""}`;
226
- const padded = head.length >= GLOBAL_PAD ? head + " " : head.padEnd(GLOBAL_PAD);
227
- lines.push(`${padded}${e.source ?? ""}`.trimEnd());
228
- for (const r of flattenCommands(e.schema?.commands ?? [])) {
229
- lines.push(row(r.label, r.description));
230
- }
231
- lines.push("");
232
- }
233
- lines.push("Drill down: crunes docs rune <key> [command path...]");
234
- return lines.join("\n");
235
- }
236
-
237
- // src/docs/commands/rune.js
238
- var SUGGESTIONS = {
239
- run: "crunes docs run",
240
- args: "crunes docs args",
241
- intro: "crunes docs intro",
242
- utils: "crunes docs utils",
243
- globals: "crunes docs globals"
244
- };
245
- async function resolveRuneDocs(config, key, projectRoot, configRoot) {
246
- const pluginMatch = await resolvePluginRune(config, key);
247
- const localEntry = pluginMatch ? null : getRune(config, key);
248
- let autoMatch = null;
249
- if (!pluginMatch && !localEntry) {
250
- autoMatch = await resolveRuneFromPlugins(config, key);
251
- }
252
- const resolved = pluginMatch ?? autoMatch;
253
- if (!localEntry && !resolved) return null;
254
- let runeFile, relativePath, basePerms, vars, displayName, displayDescription, batch;
255
- if (resolved) {
256
- const { runeKey, pluginDir } = resolved;
257
- const pluginJson = await loadPluginJson(pluginDir);
258
- const runeDef = pluginJson.runes[runeKey] ?? {};
259
- runeFile = getPluginRunePath(pluginDir, runeKey, pluginJson);
260
- relativePath = void 0;
261
- basePerms = runeDef.permissions ?? { allow: [], deny: [] };
262
- vars = runeDef.vars ?? {};
263
- displayName = runeDef.name ?? runeKey;
264
- displayDescription = runeDef.description ?? null;
265
- batch = runeDef.batch != null ? { allow: runeDef.batch.allow ?? [], deny: runeDef.batch.deny ?? [] } : null;
266
- } else {
267
- runeFile = resolveRuneFilePath(localEntry, key, configRoot);
268
- relativePath = relative(projectRoot, runeFile).replace(/\\/g, "/");
269
- basePerms = localEntry.permissions ?? { allow: [], deny: [] };
270
- vars = localEntry.vars ?? {};
271
- displayName = localEntry.name ?? key;
272
- displayDescription = localEntry.description ?? null;
273
- batch = localEntry.batch != null ? { allow: localEntry.batch.allow ?? [], deny: localEntry.batch.deny ?? [] } : null;
274
- }
275
- const runEffective = computeEffectivePermissions(basePerms, void 0, "run");
276
- const replEffective = computeEffectivePermissions(basePerms, void 0, "repl");
277
- let schema = null;
278
- let schemaError = null;
279
- try {
280
- schema = await getArgsSchema(runeFile, runEffective, projectRoot, { vars, runeKey: key });
281
- } catch (err) {
282
- schemaError = err.message;
283
- output.warn(`Could not load args schema for "${key}": ${err.message}`);
284
- }
285
- let repl = null;
286
- try {
287
- const { argsSchema, commandsSchema } = await getReplSchema(runeFile, replEffective, [], projectRoot, { vars, runeKey: key });
288
- if (argsSchema !== null || commandsSchema !== null) repl = { argsSchema, commandsSchema };
289
- } catch (err) {
290
- output.warn(`Could not load REPL schema for "${key}": ${err.message}`);
291
- }
292
- return { key, name: displayName, description: displayDescription, relativePath, schema, schemaError, repl, batch };
293
- }
294
- function commandRows(commands) {
295
- return flattenCommands(commands ?? []).map((r) => ({ path: r.path, description: r.description }));
296
- }
297
- function directChildRows(node, path) {
298
- return (node?.commands ?? []).map((c) => ({
299
- path: path ? `${path} ${c.name}` : c.name,
300
- description: c.description ?? ""
301
- }));
302
- }
303
- async function handler({ key, path = [], format = "text", projectRoot = process.cwd(), configRoot = projectRoot }) {
304
- let config;
305
- try {
306
- config = loadConfig(configRoot);
307
- } catch (err) {
308
- output.error(`Config unreadable: ${err.message}`);
309
- process.exit(1);
310
- return;
311
- }
312
- if (key == null) {
313
- const listed = await enumerateRunes(config);
314
- const entries = [];
315
- let anyFailed = false;
316
- for (const e of listed) {
317
- let docsEntry = null;
318
- let error = null;
319
- try {
320
- docsEntry = await resolveRuneDocs(config, e.key, projectRoot, configRoot);
321
- if (!docsEntry) error = "rune could not be resolved";
322
- else if (docsEntry.schemaError) error = docsEntry.schemaError;
323
- } catch (err) {
324
- error = err.message;
325
- }
326
- if (error) {
327
- anyFailed = true;
328
- entries.push({ ...e, error });
329
- } else {
330
- entries.push({ ...e, schema: docsEntry.schema });
331
- }
332
- }
333
- if (format === "json") {
334
- process.stdout.write(JSON.stringify(entries.map((e) => ({
335
- key: e.key,
336
- name: e.name,
337
- description: e.description,
338
- source: e.source,
339
- error: e.error ?? null,
340
- commands: e.error ? [] : commandRows(e.schema?.commands)
341
- })), null, 2) + "\n");
342
- } else {
343
- process.stdout.write(formatGlobalIndex(entries) + "\n");
344
- }
345
- if (anyFailed) process.exit(1);
346
- return;
347
- }
348
- let docs;
349
- try {
350
- docs = await resolveRuneDocs(config, key, projectRoot, configRoot);
351
- } catch (err) {
352
- output.warn(err.message);
353
- process.exit(1);
354
- return;
355
- }
356
- if (!docs) {
357
- if (SUGGESTIONS[key]) {
358
- output.warn(`Unknown rune: "${key}". (Tip: Did you mean "${SUGGESTIONS[key]}"?)`);
359
- } else {
360
- output.warn(`Unknown rune: "${key}"`);
361
- }
362
- process.exit(1);
363
- return;
364
- }
365
- const segments = path ?? [];
366
- if (segments.length === 0) {
367
- if (format === "json") {
368
- process.stdout.write(JSON.stringify({
369
- key: docs.key,
370
- name: docs.name,
371
- description: docs.description,
372
- relativePath: docs.relativePath,
373
- options: docs.schema?.options ?? [],
374
- positionals: docs.schema?.positionals ?? [],
375
- // Mirrors the text index: withheld while there are commands to drill into.
376
- examples: (docs.schema?.commands ?? []).length === 0 ? docs.schema?.examples ?? [] : [],
377
- commands: commandRows(docs.schema?.commands),
378
- repl: docs.repl ? { commands: docs.repl.commandsSchema?.commands ?? [] } : null,
379
- batch: docs.batch
380
- }, null, 2) + "\n");
381
- } else {
382
- process.stdout.write(formatRuneIndex(docs.schema, {
383
- key: docs.key,
384
- name: docs.name,
385
- description: docs.description,
386
- relativePath: docs.relativePath,
387
- repl: docs.repl ? { commands: docs.repl.commandsSchema?.commands ?? [] } : null,
388
- batch: docs.batch,
389
- includeBatch: true
390
- }) + "\n");
391
- }
392
- return;
393
- }
394
- const sel = selectNode(docs.schema, segments);
395
- if (!sel.node) {
396
- const lines = [`"${sel.failedAt}" is not a command of rune "${docs.key}"${sel.matchedPath ? ` at path "${sel.matchedPath}"` : ""}.`];
397
- lines.push("");
398
- lines.push(` Available commands: ${sel.candidates.length ? sel.candidates.join(", ") : "(none)"}`);
399
- const isKnownRune = await resolveRuneDocs(config, sel.failedAt, projectRoot, configRoot).catch(() => null);
400
- if (isKnownRune) {
401
- lines.push("");
402
- lines.push(` "${sel.failedAt}" is a known rune. Multi-rune lookup was removed \u2014 run`);
403
- lines.push(" `crunes docs rune` for an index of all runes, or `crunes docs rune " + sel.failedAt + "`.");
404
- }
405
- output.error(lines.join("\n"));
406
- process.exit(1);
407
- return;
408
- }
409
- if (format === "json") {
410
- process.stdout.write(JSON.stringify({
411
- path: sel.matchedPath,
412
- description: sel.node.description ?? null,
413
- positionals: sel.node.positionals ?? [],
414
- options: sel.node.options ?? [],
415
- examples: sel.node.examples ?? [],
416
- commands: directChildRows(sel.node, sel.matchedPath)
417
- }, null, 2) + "\n");
418
- } else {
419
- process.stdout.write(formatCommandPage(sel.node, { key: docs.key, path: sel.matchedPath }) + "\n");
420
- }
421
- }
422
- export {
423
- handler,
424
- resolveRuneDocs
425
- };
@@ -1,12 +1,12 @@
1
- import {
2
- deleteCacheBucket
3
- } from "./chunk-WJII3LZK.js";
4
- import "./chunk-G4ZAUHHA.js";
5
1
  import {
6
2
  R,
7
3
  ge,
8
4
  le
9
5
  } from "./chunk-CGZL5SSH.js";
6
+ import {
7
+ deleteCacheBucket
8
+ } from "./chunk-WJII3LZK.js";
9
+ import "./chunk-G4ZAUHHA.js";
10
10
  import "./chunk-2Q3KLBE6.js";
11
11
  import {
12
12
  init_require_shim
@@ -1,12 +1,12 @@
1
- import {
2
- deleteSqliteDb
3
- } from "./chunk-GVMT55GH.js";
4
- import "./chunk-G4ZAUHHA.js";
5
1
  import {
6
2
  R,
7
3
  ge,
8
4
  le
9
5
  } from "./chunk-CGZL5SSH.js";
6
+ import {
7
+ deleteSqliteDb
8
+ } from "./chunk-GVMT55GH.js";
9
+ import "./chunk-G4ZAUHHA.js";
10
10
  import "./chunk-2Q3KLBE6.js";
11
11
  import {
12
12
  init_require_shim