@darkrymit/crunes-cli 0.8.5 → 0.9.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.
- package/dist/chunks/{add-CBHWFGCA.js → add-IT3IHBPO.js} +2 -2
- package/dist/chunks/{apply-J4YICV6H.js → apply-YY7MIM64.js} +9 -9
- package/dist/chunks/{benchmark-AKKV7G32.js → benchmark-BQNMULOO.js} +17 -14
- package/dist/chunks/{browse-JZFU52ET.js → browse-PHMBDREQ.js} +2 -2
- package/dist/chunks/{chunk-6MRZXASS.js → chunk-2Q3KLBE6.js} +16 -0
- package/dist/chunks/{chunk-KII6KW5Z.js → chunk-34F4ZURL.js} +40 -37
- package/dist/chunks/{chunk-ZJDKCC2Y.js → chunk-4GJMCFR6.js} +6 -3
- package/dist/chunks/chunk-CY6C6ADU.js +2787 -0
- package/dist/chunks/{chunk-J3GZ3DXD.js → chunk-GVMT55GH.js} +3 -2
- package/dist/chunks/{chunk-JOAL437H.js → chunk-I6MHDUCW.js} +16 -1
- package/dist/chunks/{chunk-6XLT25GS.js → chunk-MIKWIFYR.js} +47 -0
- package/dist/chunks/chunk-MRNZFUXZ.js +70 -0
- package/dist/chunks/{chunk-T53L5CJW.js → chunk-PBGUKXT6.js} +2887 -1874
- package/dist/chunks/chunk-QYRF3R35.js +154 -0
- package/dist/chunks/{chunk-BTIPUR5S.js → chunk-SNC7AOT7.js} +78 -12
- package/dist/chunks/{chunk-63H5VXZY.js → chunk-UEUUOAJY.js} +4 -1
- package/dist/chunks/{chunk-GTCPZ22N.js → chunk-VST6HAB6.js} +1 -1
- package/dist/chunks/{chunk-NDEYEYSU.js → chunk-WJII3LZK.js} +4 -3
- package/dist/chunks/chunk-X7PZN73N.js +44 -0
- package/dist/chunks/{chunk-NYLRTAAA.js → chunk-YVN3VDRE.js} +1 -1
- package/dist/chunks/{chunk-WJRZN7BR.js → chunk-YXCHIMLW.js} +843 -3027
- package/dist/chunks/{clear-YBDIPEEH.js → clear-AT7HNUV4.js} +2 -2
- package/dist/chunks/{create-GPDE2YKL.js → create-ET6DT5ZE.js} +22 -18
- package/dist/chunks/{create-VYZRWRGQ.js → create-LM7U3CJS.js} +22 -18
- package/dist/chunks/{create-L6DJN4ME.js → create-TLPM7HJE.js} +3 -3
- package/dist/chunks/{delete-LNOYM5KG.js → delete-5R3WBLVD.js} +5 -5
- package/dist/chunks/{delete-E4TEBRPX.js → delete-GKYA2W5Z.js} +4 -2
- package/dist/chunks/{delete-C4UJ7X5K.js → delete-U4STA2QZ.js} +5 -5
- package/dist/chunks/disable-TNTEIAKO.js +39 -0
- package/dist/chunks/doctor-VXAQYMTR.js +101 -0
- package/dist/chunks/enable-GUQCB4CU.js +31 -0
- package/dist/chunks/{globals-H2WF344Y.js → globals-SNQFCHMP.js} +1 -1
- package/dist/chunks/{init-HU5OMHEH.js → init-PJSCFOC6.js} +14 -8
- package/dist/chunks/{install-FIYRMVLR.js → install-4YP7FALO.js} +18 -16
- package/dist/chunks/{intro-36OLGNYN.js → intro-SA7MWV3Z.js} +50 -8
- package/dist/chunks/{kill-2UG7PHUV.js → kill-TX3PC73P.js} +2 -1
- package/dist/chunks/list-7R6NASFI.js +92 -0
- package/dist/chunks/{list-4X3JFQGS.js → list-EHREZR6M.js} +2 -1
- package/dist/chunks/{list-U7PAYNAH.js → list-LC6HB3H3.js} +2 -2
- package/dist/chunks/{list-AIYNOPNZ.js → list-OMMZAQ23.js} +2 -2
- package/dist/chunks/{list-7VHJIUDX.js → list-U4EMHQZT.js} +2 -2
- package/dist/chunks/{list-PTAWQYWG.js → list-V7VVD5AG.js} +2 -1
- package/dist/chunks/{list-A5WVDBWF.js → list-VA73WPK6.js} +2 -2
- package/dist/chunks/{list-2JYMBMZC.js → list-WKNPZZOV.js} +5 -4
- package/dist/chunks/{output-RJ6JSNY7.js → output-QN5CVJ62.js} +4 -1
- package/dist/chunks/{query-AW7WYILM.js → query-2US3CPYT.js} +2 -2
- package/dist/chunks/{registry-RG34DPD7.js → registry-K5DV5NAK.js} +2 -2
- package/dist/chunks/{remove-QUH2D3S5.js → remove-BCFTF23J.js} +2 -2
- package/dist/chunks/{repl-STBZC4P2.js → repl-2YWTHUWT.js} +4 -0
- package/dist/chunks/{repl-BPEWARN7.js → repl-ZB3DIJ4K.js} +84 -26
- package/dist/chunks/resolver-QIYYFIDX.js +34 -0
- package/dist/chunks/run-22B65ZWZ.js +29 -0
- package/dist/chunks/rune-SYK4N642.js +425 -0
- package/dist/chunks/{search-MSSDGJTF.js → search-B7IM7JRJ.js} +2 -2
- package/dist/chunks/shell-explain-QLITLHW7.js +74 -0
- package/dist/chunks/{uninstall-G56DZRFG.js → uninstall-4WR5IHLC.js} +15 -11
- package/dist/chunks/{unset-YASSMSE5.js → unset-P6IUF7SS.js} +2 -2
- package/dist/chunks/{update-KSC6VRMU.js → update-ACLDK6E6.js} +19 -18
- package/dist/chunks/{update-EWWDROKW.js → update-WXT7CHYA.js} +2 -2
- package/dist/chunks/{utils-3SJFSUSV.js → utils-B2QULX5J.js} +8 -4
- package/dist/chunks/{version-YG2M7HER.js → version-EULYWNXN.js} +2 -2
- package/dist/cli.js +92 -64
- package/package.json +1 -1
- package/dist/chunks/chunk-ASZKAC24.js +0 -103
- package/dist/chunks/chunk-GSA432UC.js +0 -90
- package/dist/chunks/disable-FGJ7VMPO.js +0 -47
- package/dist/chunks/doctor-7NWBJAH7.js +0 -53
- package/dist/chunks/enable-ZL6QOC2I.js +0 -47
- package/dist/chunks/list-NZ5DHXJF.js +0 -111
- package/dist/chunks/resolver-36V72VKR.js +0 -28
- package/dist/chunks/run-IVL23SMW.js +0 -26
- package/dist/chunks/rune-XRREUL56.js +0 -186
|
@@ -0,0 +1,425 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BUILTIN_ALLOWLIST,
|
|
3
|
+
ScanRefusal,
|
|
4
|
+
resolveShell,
|
|
5
|
+
scanCommand
|
|
6
|
+
} from "./chunk-CY6C6ADU.js";
|
|
7
|
+
import "./chunk-GVMT55GH.js";
|
|
8
|
+
import "./chunk-WJII3LZK.js";
|
|
9
|
+
import "./chunk-G4ZAUHHA.js";
|
|
10
|
+
import "./chunk-2Q3KLBE6.js";
|
|
11
|
+
import {
|
|
12
|
+
init_require_shim
|
|
13
|
+
} from "./chunk-TPK5AGRA.js";
|
|
14
|
+
|
|
15
|
+
// src/rune/commands/shell-explain.js
|
|
16
|
+
init_require_shim();
|
|
17
|
+
function explain({ cmd, shellMode }) {
|
|
18
|
+
const shell = resolveShell(shellMode).kind;
|
|
19
|
+
try {
|
|
20
|
+
const { commands, redirects } = scanCommand(cmd, shell);
|
|
21
|
+
return {
|
|
22
|
+
shell,
|
|
23
|
+
refusal: null,
|
|
24
|
+
commands: commands.map((c) => ({
|
|
25
|
+
program: c.program,
|
|
26
|
+
segment: c.segment,
|
|
27
|
+
offset: c.offset,
|
|
28
|
+
builtin: BUILTIN_ALLOWLIST.has(c.program)
|
|
29
|
+
})),
|
|
30
|
+
redirects: redirects.map((r) => ({
|
|
31
|
+
capability: r.mode === "write" ? "fs.write" : "fs.read",
|
|
32
|
+
target: r.target,
|
|
33
|
+
offset: r.offset
|
|
34
|
+
}))
|
|
35
|
+
};
|
|
36
|
+
} catch (e) {
|
|
37
|
+
if (!(e instanceof ScanRefusal)) throw e;
|
|
38
|
+
return { shell, refusal: { construct: e.construct, offset: e.offset }, commands: [], redirects: [] };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function handler({ cmd, shellMode }) {
|
|
42
|
+
const r = explain({ cmd, shellMode });
|
|
43
|
+
console.log(`shell: ${r.shell}`);
|
|
44
|
+
console.log();
|
|
45
|
+
if (r.refusal) {
|
|
46
|
+
console.log(`REFUSED: ${r.refusal.construct} at offset ${r.refusal.offset}`);
|
|
47
|
+
console.log();
|
|
48
|
+
console.log(cmd);
|
|
49
|
+
console.log(" ".repeat(r.refusal.offset) + "^");
|
|
50
|
+
console.log();
|
|
51
|
+
console.log("This construct cannot be classified, so it is denied. There is no");
|
|
52
|
+
console.log("grant that overrides this. Rewrite the command without it.");
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
console.log("command positions:");
|
|
57
|
+
for (const c of r.commands) {
|
|
58
|
+
const tag = c.builtin ? "builtin, no grant needed" : `needs shell.run:${c.segment}`;
|
|
59
|
+
console.log(` @${String(c.offset).padStart(4)} ${c.segment}`);
|
|
60
|
+
console.log(` ${tag}`);
|
|
61
|
+
}
|
|
62
|
+
if (r.redirects.length > 0) {
|
|
63
|
+
console.log();
|
|
64
|
+
console.log("redirects:");
|
|
65
|
+
for (const rd of r.redirects) {
|
|
66
|
+
console.log(` @${String(rd.offset).padStart(4)} ${rd.target}`);
|
|
67
|
+
console.log(` needs ${rd.capability}:${rd.target}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
explain,
|
|
73
|
+
handler
|
|
74
|
+
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
uninstallPlugin
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-34F4ZURL.js";
|
|
4
|
+
import "./chunk-X7PZN73N.js";
|
|
5
|
+
import "./chunk-QYRF3R35.js";
|
|
6
|
+
import {
|
|
7
|
+
output
|
|
8
|
+
} from "./chunk-MIKWIFYR.js";
|
|
4
9
|
import {
|
|
5
10
|
R,
|
|
6
|
-
fe,
|
|
7
|
-
ge,
|
|
8
11
|
le
|
|
9
12
|
} from "./chunk-CGZL5SSH.js";
|
|
13
|
+
import "./chunk-WCODTMDN.js";
|
|
10
14
|
import {
|
|
11
15
|
loadRegistry,
|
|
12
16
|
resolvePluginKey
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-VST6HAB6.js";
|
|
18
|
+
import "./chunk-2Q3KLBE6.js";
|
|
15
19
|
import "./chunk-G3U4V32O.js";
|
|
16
20
|
import {
|
|
17
21
|
init_require_shim
|
|
@@ -19,28 +23,28 @@ import {
|
|
|
19
23
|
|
|
20
24
|
// src/plugin/commands/uninstall.js
|
|
21
25
|
init_require_shim();
|
|
22
|
-
async function handler({ name, yes, projectRoot, configRoot }) {
|
|
26
|
+
async function handler({ name, yes, projectRoot, configRoot, global = false }) {
|
|
23
27
|
let pluginKey;
|
|
24
28
|
try {
|
|
25
29
|
const registry = await loadRegistry();
|
|
26
30
|
pluginKey = resolvePluginKey(name, registry);
|
|
27
31
|
if (!pluginKey) throw new Error(`Plugin "${name}" is not installed. Run: crunes plugin list`);
|
|
28
32
|
} catch (err) {
|
|
29
|
-
|
|
33
|
+
output.cancel(`Error: ${err.message}`);
|
|
30
34
|
process.exit(1);
|
|
31
35
|
}
|
|
32
36
|
if (!yes) {
|
|
33
37
|
const confirm = await le({ message: `Uninstall plugin "${pluginKey}"?` });
|
|
34
38
|
if (R(confirm) || !confirm) {
|
|
35
|
-
|
|
39
|
+
output.cancel("Cancelled.");
|
|
36
40
|
process.exit(0);
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
try {
|
|
40
|
-
await uninstallPlugin(pluginKey, configRoot ?? projectRoot);
|
|
41
|
-
|
|
44
|
+
await uninstallPlugin(pluginKey, configRoot ?? projectRoot, { global });
|
|
45
|
+
output.outro(`Uninstalled ${pluginKey}`);
|
|
42
46
|
} catch (err) {
|
|
43
|
-
|
|
47
|
+
output.cancel(`Failed: ${err.message}`);
|
|
44
48
|
process.exit(1);
|
|
45
49
|
}
|
|
46
50
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveFromMarketplace
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YVN3VDRE.js";
|
|
4
4
|
import {
|
|
5
5
|
installPlugin
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-34F4ZURL.js";
|
|
7
|
+
import "./chunk-X7PZN73N.js";
|
|
8
|
+
import "./chunk-QYRF3R35.js";
|
|
7
9
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "./chunk-CGZL5SSH.js";
|
|
10
|
+
output
|
|
11
|
+
} from "./chunk-MIKWIFYR.js";
|
|
12
|
+
import "./chunk-CGZL5SSH.js";
|
|
13
|
+
import "./chunk-WCODTMDN.js";
|
|
13
14
|
import {
|
|
14
15
|
loadRegistry,
|
|
15
16
|
resolvePluginKey
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-VST6HAB6.js";
|
|
18
|
+
import "./chunk-2Q3KLBE6.js";
|
|
18
19
|
import "./chunk-G3U4V32O.js";
|
|
19
20
|
import {
|
|
20
21
|
init_require_shim
|
|
@@ -28,7 +29,7 @@ async function handler({ name, projectRoot, configRoot }) {
|
|
|
28
29
|
if (name) {
|
|
29
30
|
const pluginKey = resolvePluginKey(name, registry);
|
|
30
31
|
if (!pluginKey) {
|
|
31
|
-
|
|
32
|
+
output.cancel(`Plugin "${name}" is not installed. Run: crunes plugin list`);
|
|
32
33
|
process.exit(1);
|
|
33
34
|
}
|
|
34
35
|
plugins = [pluginKey];
|
|
@@ -39,16 +40,16 @@ async function handler({ name, projectRoot, configRoot }) {
|
|
|
39
40
|
console.log("No plugins installed.");
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
output.intro(name ? `Updating ${name}\u2026` : "Updating all plugins\u2026");
|
|
43
44
|
for (const pluginName of plugins) {
|
|
44
45
|
const entry = registry.plugins[pluginName];
|
|
45
46
|
if (!entry) {
|
|
46
|
-
|
|
47
|
+
output.log.warn(`Plugin "${pluginName}" is not installed.`);
|
|
47
48
|
continue;
|
|
48
49
|
}
|
|
49
50
|
const atIdx = pluginName.indexOf("@");
|
|
50
51
|
if (atIdx === -1) {
|
|
51
|
-
|
|
52
|
+
output.log.warn(`Skipping ${pluginName}: no marketplace provenance (legacy entry).`);
|
|
52
53
|
continue;
|
|
53
54
|
}
|
|
54
55
|
const marketplaceName = pluginName.slice(0, atIdx);
|
|
@@ -58,21 +59,21 @@ async function handler({ name, projectRoot, configRoot }) {
|
|
|
58
59
|
;
|
|
59
60
|
({ resolvedSource, ...provenance } = await resolveFromMarketplace(marketplaceName, pluginNamePart));
|
|
60
61
|
} catch (err) {
|
|
61
|
-
|
|
62
|
+
output.log.error(`Failed to resolve ${pluginName} from marketplace: ${err.message}`);
|
|
62
63
|
continue;
|
|
63
64
|
}
|
|
64
65
|
try {
|
|
65
66
|
const result = await installPlugin(resolvedSource, configRoot ?? projectRoot, provenance);
|
|
66
67
|
if (result.installed) {
|
|
67
|
-
|
|
68
|
+
output.log.success(`Updated ${pluginName}@${result.version}`);
|
|
68
69
|
} else {
|
|
69
|
-
|
|
70
|
+
output.log.warn(`Update of ${pluginName} cancelled (permission consent declined).`);
|
|
70
71
|
}
|
|
71
72
|
} catch (err) {
|
|
72
|
-
|
|
73
|
+
output.log.error(`Failed to update ${pluginName}: ${err.message}`);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
output.outro("Done.");
|
|
76
77
|
}
|
|
77
78
|
export {
|
|
78
79
|
handler
|