@darkrymit/crunes-cli 0.9.0 → 0.10.1
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-2OM5KGN5.js +67 -0
- package/dist/chunks/{apply-YY7MIM64.js → apply-GBUQQ4XF.js} +21 -9
- package/dist/chunks/{benchmark-BQNMULOO.js → benchmark-QWGVX3BX.js} +21 -15
- package/dist/chunks/chunk-2DNYVKBF.js +109 -0
- package/dist/chunks/chunk-2HM5Q52B.js +131 -0
- package/dist/chunks/chunk-3KKRNQQU.js +275 -0
- package/dist/chunks/chunk-55GTJG5I.js +1154 -0
- package/dist/chunks/chunk-7KYCYDAS.js +325 -0
- package/dist/chunks/{chunk-SNC7AOT7.js → chunk-AL37NFWR.js} +45 -94
- package/dist/chunks/chunk-ARIFLX5E.js +9525 -0
- package/dist/chunks/{chunk-X7PZN73N.js → chunk-E7CZPAM2.js} +1 -1
- package/dist/chunks/chunk-EO3CSXWK.js +70 -0
- package/dist/chunks/chunk-FIAFVIAN.js +79 -0
- package/dist/chunks/{chunk-MRNZFUXZ.js → chunk-KQMTTEJV.js} +22 -7
- package/dist/chunks/chunk-KX6QEHM5.js +578 -0
- package/dist/chunks/{chunk-VST6HAB6.js → chunk-MTJ2KW3V.js} +2 -0
- package/dist/chunks/chunk-MUWDZJN2.js +71 -0
- package/dist/chunks/{chunk-CY6C6ADU.js → chunk-MVCBPI4J.js} +45 -478
- package/dist/chunks/{chunk-34F4ZURL.js → chunk-NJVPLN5D.js} +29 -12
- package/dist/chunks/chunk-UBCAZGLE.js +15 -0
- package/dist/chunks/chunk-VP7YLCQP.js +244 -0
- package/dist/chunks/chunk-VSMAZISQ.js +303 -0
- package/dist/chunks/chunk-WE4HDHFU.js +37 -0
- package/dist/chunks/{create-ET6DT5ZE.js → create-2CQZF53Z.js} +5 -2
- package/dist/chunks/{create-LM7U3CJS.js → create-36F6V4WP.js} +99 -6
- package/dist/chunks/{create-TLPM7HJE.js → create-DXW4YYLJ.js} +5 -5
- package/dist/chunks/{disable-TNTEIAKO.js → disable-FB64CSYV.js} +5 -2
- package/dist/chunks/doctor-PVO4JLYN.js +208 -0
- package/dist/chunks/{enable-GUQCB4CU.js → enable-UVXHTKCJ.js} +6 -3
- package/dist/chunks/{init-PJSCFOC6.js → init-GPNC7TR5.js} +5 -2
- package/dist/chunks/{install-4YP7FALO.js → install-3G7U5ZIO.js} +10 -5
- package/dist/chunks/{intro-SA7MWV3Z.js → intro-YI5HUZCF.js} +45 -19
- package/dist/chunks/{list-WKNPZZOV.js → list-J2UCBYAY.js} +9 -6
- package/dist/chunks/list-JB4447YK.js +62 -0
- package/dist/chunks/{list-7R6NASFI.js → list-W4JAYPAA.js} +19 -19
- package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
- package/dist/chunks/{registry-K5DV5NAK.js → registry-IWP7JMNI.js} +1 -1
- package/dist/chunks/{repl-ZB3DIJ4K.js → repl-MWFEZ65P.js} +30 -20
- package/dist/chunks/resolver-URPQMOIV.js +36 -0
- package/dist/chunks/{run-22B65ZWZ.js → run-3VKWSRLO.js} +17 -11
- package/dist/chunks/rune-L5EP645W.js +283 -0
- package/dist/chunks/runner-VPTLUQJE.js +34 -0
- package/dist/chunks/{shell-explain-QLITLHW7.js → shell-explain-LKBBP2BG.js} +5 -2
- package/dist/chunks/trust-LXXYSF6W.js +109 -0
- package/dist/chunks/{uninstall-4WR5IHLC.js → uninstall-J7JUYETA.js} +10 -5
- package/dist/chunks/{update-ACLDK6E6.js → update-ZJRLDCUT.js} +10 -5
- package/dist/chunks/{version-EULYWNXN.js → version-ZULO6CV3.js} +2 -2
- package/dist/cli.js +47 -34
- package/package.json +2 -2
- package/dist/chunks/chunk-G3U4V32O.js +0 -46
- package/dist/chunks/chunk-QYRF3R35.js +0 -154
- package/dist/chunks/chunk-YXCHIMLW.js +0 -75308
- package/dist/chunks/doctor-VXAQYMTR.js +0 -101
- package/dist/chunks/list-OMMZAQ23.js +0 -28
- package/dist/chunks/resolver-QIYYFIDX.js +0 -34
- package/dist/chunks/rune-SYK4N642.js +0 -425
- package/dist/chunks/{delete-5R3WBLVD.js → delete-2EXPFBFC.js} +4 -4
- package/dist/chunks/{delete-U4STA2QZ.js → delete-MJAECXXV.js} +4 -4
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import {
|
|
2
|
+
enumerateRunes
|
|
3
|
+
} from "./chunk-KQMTTEJV.js";
|
|
4
|
+
import {
|
|
5
|
+
getArgsSchema,
|
|
6
|
+
getPluginRunePath,
|
|
7
|
+
getReplSchema
|
|
8
|
+
} from "./chunk-ARIFLX5E.js";
|
|
9
|
+
import "./chunk-UEUUOAJY.js";
|
|
10
|
+
import "./chunk-4GJMCFR6.js";
|
|
11
|
+
import "./chunk-7KYCYDAS.js";
|
|
12
|
+
import "./chunk-EO3CSXWK.js";
|
|
13
|
+
import {
|
|
14
|
+
output
|
|
15
|
+
} from "./chunk-MIKWIFYR.js";
|
|
16
|
+
import "./chunk-CGZL5SSH.js";
|
|
17
|
+
import "./chunk-WCODTMDN.js";
|
|
18
|
+
import {
|
|
19
|
+
resolvePluginRune,
|
|
20
|
+
resolveRuneFromPlugins
|
|
21
|
+
} from "./chunk-VSMAZISQ.js";
|
|
22
|
+
import {
|
|
23
|
+
describeRunBlock,
|
|
24
|
+
flattenCommands,
|
|
25
|
+
formatCommandPage,
|
|
26
|
+
formatGlobalIndex,
|
|
27
|
+
formatRuneIndex,
|
|
28
|
+
getRunBlockSchema,
|
|
29
|
+
selectNode
|
|
30
|
+
} from "./chunk-KX6QEHM5.js";
|
|
31
|
+
import {
|
|
32
|
+
resolveInterpreter
|
|
33
|
+
} from "./chunk-2DNYVKBF.js";
|
|
34
|
+
import {
|
|
35
|
+
isNativeRune
|
|
36
|
+
} from "./chunk-MUWDZJN2.js";
|
|
37
|
+
import {
|
|
38
|
+
getRune,
|
|
39
|
+
loadConfig
|
|
40
|
+
} from "./chunk-3KKRNQQU.js";
|
|
41
|
+
import {
|
|
42
|
+
isPathCommand
|
|
43
|
+
} from "./chunk-UBCAZGLE.js";
|
|
44
|
+
import "./chunk-MTJ2KW3V.js";
|
|
45
|
+
import {
|
|
46
|
+
loadPluginJson
|
|
47
|
+
} from "./chunk-FIAFVIAN.js";
|
|
48
|
+
import "./chunk-VP7YLCQP.js";
|
|
49
|
+
import {
|
|
50
|
+
blockModule,
|
|
51
|
+
scopedPermissions
|
|
52
|
+
} from "./chunk-WE4HDHFU.js";
|
|
53
|
+
import {
|
|
54
|
+
computeEffectivePermissions
|
|
55
|
+
} from "./chunk-MVCBPI4J.js";
|
|
56
|
+
import "./chunk-GVMT55GH.js";
|
|
57
|
+
import "./chunk-2HM5Q52B.js";
|
|
58
|
+
import "./chunk-WJII3LZK.js";
|
|
59
|
+
import "./chunk-G4ZAUHHA.js";
|
|
60
|
+
import "./chunk-2Q3KLBE6.js";
|
|
61
|
+
import "./chunk-55GTJG5I.js";
|
|
62
|
+
import {
|
|
63
|
+
init_require_shim
|
|
64
|
+
} from "./chunk-TPK5AGRA.js";
|
|
65
|
+
|
|
66
|
+
// src/docs/commands/rune.js
|
|
67
|
+
init_require_shim();
|
|
68
|
+
import { relative } from "node:path";
|
|
69
|
+
var SUGGESTIONS = {
|
|
70
|
+
run: "crunes docs run",
|
|
71
|
+
args: "crunes docs args",
|
|
72
|
+
intro: "crunes docs intro",
|
|
73
|
+
utils: "crunes docs utils",
|
|
74
|
+
globals: "crunes docs globals"
|
|
75
|
+
};
|
|
76
|
+
async function resolveRuneDocs(config, key, projectRoot, configRoot) {
|
|
77
|
+
const pluginMatch = await resolvePluginRune(config, key);
|
|
78
|
+
const localEntry = pluginMatch ? null : getRune(config, key);
|
|
79
|
+
let autoMatch = null;
|
|
80
|
+
if (!pluginMatch && !localEntry) {
|
|
81
|
+
autoMatch = await resolveRuneFromPlugins(config, key);
|
|
82
|
+
}
|
|
83
|
+
const resolved = pluginMatch ?? autoMatch;
|
|
84
|
+
if (!localEntry && !resolved) return null;
|
|
85
|
+
let runeFile, replFile = null, relativePath, basePerms, vars, displayName, displayDescription, batch;
|
|
86
|
+
let native = null, runs = null;
|
|
87
|
+
if (resolved) {
|
|
88
|
+
const { runeKey, pluginDir } = resolved;
|
|
89
|
+
const pluginJson = await loadPluginJson(pluginDir);
|
|
90
|
+
const runeDef = pluginJson.runes[runeKey] ?? {};
|
|
91
|
+
if (isNativeRune(runeDef)) {
|
|
92
|
+
native = describeRunBlock({ run: runeDef.run, args: runeDef.args }, pluginDir);
|
|
93
|
+
runs = `${[runeDef.run.command ?? runeDef.run, ...native.argv].join(" ")} \xB7 ${native.runtime} \xB7 plugin script, native, full access \u2014 runs only once trusted (crunes plugin trust)`;
|
|
94
|
+
} else {
|
|
95
|
+
runeFile = getPluginRunePath(pluginDir, runeKey, pluginJson);
|
|
96
|
+
}
|
|
97
|
+
if (runeDef.repl != null) replFile = getPluginRunePath(pluginDir, runeKey, pluginJson, "repl");
|
|
98
|
+
relativePath = void 0;
|
|
99
|
+
basePerms = scopedPermissions(runeDef) ?? {};
|
|
100
|
+
vars = runeDef.vars ?? {};
|
|
101
|
+
displayName = runeDef.name ?? runeKey;
|
|
102
|
+
displayDescription = runeDef.description ?? null;
|
|
103
|
+
batch = runeDef.batch != null ? { allow: runeDef.batch.allow ?? [], deny: runeDef.batch.deny ?? [] } : null;
|
|
104
|
+
} else {
|
|
105
|
+
const desc = describeRunBlock(localEntry, configRoot);
|
|
106
|
+
replFile = blockModule(localEntry, "repl", configRoot);
|
|
107
|
+
const shown = isPathCommand(desc.command) ? relative(projectRoot, desc.command).replace(/\\/g, "/") : desc.command;
|
|
108
|
+
if (desc.runtime === "isolate") {
|
|
109
|
+
runeFile = desc.command;
|
|
110
|
+
relativePath = shown;
|
|
111
|
+
basePerms = scopedPermissions(localEntry) ?? {};
|
|
112
|
+
} else {
|
|
113
|
+
native = desc;
|
|
114
|
+
let interpreter = "";
|
|
115
|
+
try {
|
|
116
|
+
const found = resolveInterpreter(desc.runtime, projectRoot);
|
|
117
|
+
if (found) interpreter = ` (${[found.command, ...found.args].join(" ")})`;
|
|
118
|
+
} catch (err) {
|
|
119
|
+
interpreter = ` (not found: ${err.message.split("\n")[0]})`;
|
|
120
|
+
}
|
|
121
|
+
runs = `${[shown, ...desc.argv].join(" ")} \xB7 ${desc.runtime}${interpreter} \xB7 native, full access`;
|
|
122
|
+
basePerms = scopedPermissions(localEntry) ?? {};
|
|
123
|
+
}
|
|
124
|
+
vars = localEntry.vars ?? {};
|
|
125
|
+
displayName = localEntry.name ?? key;
|
|
126
|
+
displayDescription = localEntry.description ?? null;
|
|
127
|
+
batch = localEntry.batch != null ? { allow: localEntry.batch.allow ?? [], deny: localEntry.batch.deny ?? [] } : null;
|
|
128
|
+
}
|
|
129
|
+
const runEffective = computeEffectivePermissions(basePerms, void 0, "run");
|
|
130
|
+
const replEffective = computeEffectivePermissions(basePerms, void 0, "repl");
|
|
131
|
+
let schema = null;
|
|
132
|
+
let schemaError = null;
|
|
133
|
+
try {
|
|
134
|
+
schema = native ? await getRunBlockSchema(native, projectRoot, { vars, runeKey: key }) : await getArgsSchema(runeFile, runEffective, projectRoot, { vars, runeKey: key });
|
|
135
|
+
} catch (err) {
|
|
136
|
+
schemaError = err.message;
|
|
137
|
+
output.warn(`Could not load args schema for "${key}": ${err.message}`);
|
|
138
|
+
}
|
|
139
|
+
let repl = null;
|
|
140
|
+
if (replFile) try {
|
|
141
|
+
const { argsSchema, commandsSchema } = await getReplSchema(replFile, replEffective, [], projectRoot, { vars, runeKey: key });
|
|
142
|
+
if (argsSchema !== null || commandsSchema !== null) repl = { argsSchema, commandsSchema };
|
|
143
|
+
} catch (err) {
|
|
144
|
+
output.warn(`Could not load REPL schema for "${key}": ${err.message}`);
|
|
145
|
+
}
|
|
146
|
+
const passThrough = native != null && schema == null && schemaError == null;
|
|
147
|
+
return { key, name: displayName, description: displayDescription, relativePath, runs, passThrough, schema, schemaError, repl, batch };
|
|
148
|
+
}
|
|
149
|
+
function commandRows(commands) {
|
|
150
|
+
return flattenCommands(commands ?? []).map((r) => ({ path: r.path, description: r.description }));
|
|
151
|
+
}
|
|
152
|
+
function directChildRows(node, path) {
|
|
153
|
+
return (node?.commands ?? []).map((c) => ({
|
|
154
|
+
path: path ? `${path} ${c.name}` : c.name,
|
|
155
|
+
description: c.description ?? ""
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
async function handler({ key, path = [], format = "text", projectRoot = process.cwd(), configRoot = projectRoot }) {
|
|
159
|
+
let config;
|
|
160
|
+
try {
|
|
161
|
+
config = loadConfig(configRoot);
|
|
162
|
+
} catch (err) {
|
|
163
|
+
output.error(`Config unreadable: ${err.message}`);
|
|
164
|
+
process.exit(1);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (key == null) {
|
|
168
|
+
const listed = await enumerateRunes(config);
|
|
169
|
+
const entries = [];
|
|
170
|
+
let anyFailed = false;
|
|
171
|
+
for (const e of listed) {
|
|
172
|
+
let docsEntry = null;
|
|
173
|
+
let error = null;
|
|
174
|
+
try {
|
|
175
|
+
docsEntry = await resolveRuneDocs(config, e.key, projectRoot, configRoot);
|
|
176
|
+
if (!docsEntry) error = "rune could not be resolved";
|
|
177
|
+
else if (docsEntry.schemaError) error = docsEntry.schemaError;
|
|
178
|
+
} catch (err) {
|
|
179
|
+
error = err.message;
|
|
180
|
+
}
|
|
181
|
+
if (error) {
|
|
182
|
+
anyFailed = true;
|
|
183
|
+
entries.push({ ...e, error });
|
|
184
|
+
} else {
|
|
185
|
+
entries.push({ ...e, schema: docsEntry.schema });
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (format === "json") {
|
|
189
|
+
process.stdout.write(JSON.stringify(entries.map((e) => ({
|
|
190
|
+
key: e.key,
|
|
191
|
+
name: e.name,
|
|
192
|
+
description: e.description,
|
|
193
|
+
source: e.source,
|
|
194
|
+
error: e.error ?? null,
|
|
195
|
+
commands: e.error ? [] : commandRows(e.schema?.commands)
|
|
196
|
+
})), null, 2) + "\n");
|
|
197
|
+
} else {
|
|
198
|
+
process.stdout.write(formatGlobalIndex(entries) + "\n");
|
|
199
|
+
}
|
|
200
|
+
if (anyFailed) process.exit(1);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
let docs;
|
|
204
|
+
try {
|
|
205
|
+
docs = await resolveRuneDocs(config, key, projectRoot, configRoot);
|
|
206
|
+
} catch (err) {
|
|
207
|
+
output.warn(err.message);
|
|
208
|
+
process.exit(1);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (!docs) {
|
|
212
|
+
if (SUGGESTIONS[key]) {
|
|
213
|
+
output.warn(`Unknown rune: "${key}". (Tip: Did you mean "${SUGGESTIONS[key]}"?)`);
|
|
214
|
+
} else {
|
|
215
|
+
output.warn(`Unknown rune: "${key}"`);
|
|
216
|
+
}
|
|
217
|
+
process.exit(1);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const segments = path ?? [];
|
|
221
|
+
if (segments.length === 0) {
|
|
222
|
+
if (format === "json") {
|
|
223
|
+
process.stdout.write(JSON.stringify({
|
|
224
|
+
key: docs.key,
|
|
225
|
+
name: docs.name,
|
|
226
|
+
description: docs.description,
|
|
227
|
+
relativePath: docs.relativePath,
|
|
228
|
+
...docs.runs ? { runs: docs.runs } : {},
|
|
229
|
+
options: docs.schema?.options ?? [],
|
|
230
|
+
positionals: docs.schema?.positionals ?? [],
|
|
231
|
+
// Mirrors the text index: withheld while there are commands to drill into.
|
|
232
|
+
examples: (docs.schema?.commands ?? []).length === 0 ? docs.schema?.examples ?? [] : [],
|
|
233
|
+
commands: commandRows(docs.schema?.commands),
|
|
234
|
+
repl: docs.repl ? { commands: docs.repl.commandsSchema?.commands ?? [] } : null,
|
|
235
|
+
batch: docs.batch
|
|
236
|
+
}, null, 2) + "\n");
|
|
237
|
+
} else {
|
|
238
|
+
process.stdout.write(formatRuneIndex(docs.schema, {
|
|
239
|
+
key: docs.key,
|
|
240
|
+
name: docs.name,
|
|
241
|
+
description: docs.description,
|
|
242
|
+
relativePath: docs.relativePath,
|
|
243
|
+
runs: docs.runs,
|
|
244
|
+
passThrough: docs.passThrough,
|
|
245
|
+
repl: docs.repl ? { commands: docs.repl.commandsSchema?.commands ?? [] } : null,
|
|
246
|
+
batch: docs.batch,
|
|
247
|
+
includeBatch: true
|
|
248
|
+
}) + "\n");
|
|
249
|
+
}
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const sel = selectNode(docs.schema, segments);
|
|
253
|
+
if (!sel.node) {
|
|
254
|
+
const lines = [`"${sel.failedAt}" is not a command of rune "${docs.key}"${sel.matchedPath ? ` at path "${sel.matchedPath}"` : ""}.`];
|
|
255
|
+
lines.push("");
|
|
256
|
+
lines.push(` Available commands: ${sel.candidates.length ? sel.candidates.join(", ") : "(none)"}`);
|
|
257
|
+
const isKnownRune = await resolveRuneDocs(config, sel.failedAt, projectRoot, configRoot).catch(() => null);
|
|
258
|
+
if (isKnownRune) {
|
|
259
|
+
lines.push("");
|
|
260
|
+
lines.push(` "${sel.failedAt}" is a known rune. Multi-rune lookup was removed \u2014 run`);
|
|
261
|
+
lines.push(" `crunes docs rune` for an index of all runes, or `crunes docs rune " + sel.failedAt + "`.");
|
|
262
|
+
}
|
|
263
|
+
output.error(lines.join("\n"));
|
|
264
|
+
process.exit(1);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (format === "json") {
|
|
268
|
+
process.stdout.write(JSON.stringify({
|
|
269
|
+
path: sel.matchedPath,
|
|
270
|
+
description: sel.node.description ?? null,
|
|
271
|
+
positionals: sel.node.positionals ?? [],
|
|
272
|
+
options: sel.node.options ?? [],
|
|
273
|
+
examples: sel.node.examples ?? [],
|
|
274
|
+
commands: directChildRows(sel.node, sel.matchedPath)
|
|
275
|
+
}, null, 2) + "\n");
|
|
276
|
+
} else {
|
|
277
|
+
process.stdout.write(formatCommandPage(sel.node, { key: docs.key, path: sel.matchedPath }) + "\n");
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
export {
|
|
281
|
+
handler,
|
|
282
|
+
resolveRuneDocs
|
|
283
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executePluginRune,
|
|
3
|
+
getArgsSchema,
|
|
4
|
+
getPluginRunePath,
|
|
5
|
+
getReplSchema,
|
|
6
|
+
runPluginRune,
|
|
7
|
+
runRuneInIsolate,
|
|
8
|
+
runRuneInRepl
|
|
9
|
+
} from "./chunk-ARIFLX5E.js";
|
|
10
|
+
import "./chunk-UEUUOAJY.js";
|
|
11
|
+
import "./chunk-4GJMCFR6.js";
|
|
12
|
+
import "./chunk-7KYCYDAS.js";
|
|
13
|
+
import "./chunk-EO3CSXWK.js";
|
|
14
|
+
import "./chunk-MIKWIFYR.js";
|
|
15
|
+
import "./chunk-CGZL5SSH.js";
|
|
16
|
+
import "./chunk-WCODTMDN.js";
|
|
17
|
+
import "./chunk-WE4HDHFU.js";
|
|
18
|
+
import "./chunk-MVCBPI4J.js";
|
|
19
|
+
import "./chunk-GVMT55GH.js";
|
|
20
|
+
import "./chunk-2HM5Q52B.js";
|
|
21
|
+
import "./chunk-WJII3LZK.js";
|
|
22
|
+
import "./chunk-G4ZAUHHA.js";
|
|
23
|
+
import "./chunk-2Q3KLBE6.js";
|
|
24
|
+
import "./chunk-55GTJG5I.js";
|
|
25
|
+
import "./chunk-TPK5AGRA.js";
|
|
26
|
+
export {
|
|
27
|
+
executePluginRune,
|
|
28
|
+
getArgsSchema,
|
|
29
|
+
getPluginRunePath,
|
|
30
|
+
getReplSchema,
|
|
31
|
+
runPluginRune,
|
|
32
|
+
runRuneInIsolate,
|
|
33
|
+
runRuneInRepl
|
|
34
|
+
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BUILTIN_ALLOWLIST,
|
|
3
3
|
ScanRefusal,
|
|
4
|
-
resolveShell,
|
|
5
4
|
scanCommand
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-7KYCYDAS.js";
|
|
6
|
+
import "./chunk-MVCBPI4J.js";
|
|
7
7
|
import "./chunk-GVMT55GH.js";
|
|
8
|
+
import {
|
|
9
|
+
resolveShell
|
|
10
|
+
} from "./chunk-2HM5Q52B.js";
|
|
8
11
|
import "./chunk-WJII3LZK.js";
|
|
9
12
|
import "./chunk-G4ZAUHHA.js";
|
|
10
13
|
import "./chunk-2Q3KLBE6.js";
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
R,
|
|
3
|
+
le
|
|
4
|
+
} from "./chunk-CGZL5SSH.js";
|
|
5
|
+
import {
|
|
6
|
+
isNativeRune,
|
|
7
|
+
nativeRuneFile,
|
|
8
|
+
recordTrust,
|
|
9
|
+
trustDigest,
|
|
10
|
+
trustState
|
|
11
|
+
} from "./chunk-MUWDZJN2.js";
|
|
12
|
+
import "./chunk-UBCAZGLE.js";
|
|
13
|
+
import {
|
|
14
|
+
loadRegistry,
|
|
15
|
+
resolvePluginKey
|
|
16
|
+
} from "./chunk-MTJ2KW3V.js";
|
|
17
|
+
import {
|
|
18
|
+
loadPluginJson
|
|
19
|
+
} from "./chunk-FIAFVIAN.js";
|
|
20
|
+
import "./chunk-VP7YLCQP.js";
|
|
21
|
+
import {
|
|
22
|
+
blockOf
|
|
23
|
+
} from "./chunk-WE4HDHFU.js";
|
|
24
|
+
import "./chunk-2Q3KLBE6.js";
|
|
25
|
+
import "./chunk-55GTJG5I.js";
|
|
26
|
+
import {
|
|
27
|
+
init_require_shim
|
|
28
|
+
} from "./chunk-TPK5AGRA.js";
|
|
29
|
+
|
|
30
|
+
// src/plugin/commands/trust.js
|
|
31
|
+
init_require_shim();
|
|
32
|
+
import { readFileSync } from "node:fs";
|
|
33
|
+
var SHOWN_LINES = 80;
|
|
34
|
+
function describeForReview(pluginKey, runeKey, rune, pluginDir, state) {
|
|
35
|
+
const run = blockOf(rune, "run");
|
|
36
|
+
const file = nativeRuneFile(pluginDir, rune);
|
|
37
|
+
const lines = [
|
|
38
|
+
`${pluginKey}:${runeKey} \u2014 ${state === "changed" ? "CHANGED since it was trusted" : state}`,
|
|
39
|
+
` runs natively, outside the sandbox, with your full access`,
|
|
40
|
+
` command: ${[run.command, ...run.argv ?? []].join(" ")}${file ? "" : " (a program on PATH)"}`
|
|
41
|
+
];
|
|
42
|
+
if (rune.args != null) lines.push(` arguments: ${run.pass === "mapped" ? "mapped from its schema \u2014 nothing else reaches the program" : "passed through as given"}`);
|
|
43
|
+
if (file) {
|
|
44
|
+
let content;
|
|
45
|
+
try {
|
|
46
|
+
content = readFileSync(file, "utf8");
|
|
47
|
+
} catch {
|
|
48
|
+
content = null;
|
|
49
|
+
}
|
|
50
|
+
lines.push(` file: ${file}`, "");
|
|
51
|
+
if (content == null) {
|
|
52
|
+
lines.push(" (the file is missing)");
|
|
53
|
+
} else {
|
|
54
|
+
const all = content.replace(/\n$/, "").split("\n");
|
|
55
|
+
for (const line of all.slice(0, SHOWN_LINES)) lines.push(` \u2502 ${line}`);
|
|
56
|
+
if (all.length > SHOWN_LINES) lines.push(` \u2502 \u2026 ${all.length - SHOWN_LINES} more lines \u2014 read the whole file before trusting it`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return lines.join("\n");
|
|
60
|
+
}
|
|
61
|
+
async function handler({ name, rune: onlyRune = null, yes = false }) {
|
|
62
|
+
try {
|
|
63
|
+
const registry = await loadRegistry();
|
|
64
|
+
const pluginKey = resolvePluginKey(name, registry);
|
|
65
|
+
const entry = pluginKey && registry.plugins[pluginKey];
|
|
66
|
+
if (!entry) throw new Error(`Plugin "${name}" is not installed. Run: crunes plugin list`);
|
|
67
|
+
const pluginJson = await loadPluginJson(entry.path);
|
|
68
|
+
let natives = Object.entries(pluginJson.runes).filter(([, rune]) => isNativeRune(rune));
|
|
69
|
+
if (onlyRune) {
|
|
70
|
+
if (!pluginJson.runes[onlyRune]) throw new Error(`Plugin "${pluginKey}" has no rune "${onlyRune}"`);
|
|
71
|
+
natives = natives.filter(([key]) => key === onlyRune);
|
|
72
|
+
if (!natives.length) throw new Error(`"${pluginKey}:${onlyRune}" runs in the sandbox under its declared permissions \u2014 there is nothing to trust`);
|
|
73
|
+
}
|
|
74
|
+
if (!natives.length) {
|
|
75
|
+
console.log(`Plugin "${pluginKey}" has no native runes \u2014 every rune runs in the sandbox.`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const pending = [];
|
|
79
|
+
for (const [runeKey, rune] of natives) {
|
|
80
|
+
const digest = trustDigest(entry.path, rune);
|
|
81
|
+
const state = trustState(entry, runeKey, digest);
|
|
82
|
+
console.log(describeForReview(pluginKey, runeKey, rune, entry.path, state) + "\n");
|
|
83
|
+
if (state !== "trusted") pending.push({ runeKey, digest });
|
|
84
|
+
}
|
|
85
|
+
if (!pending.length) {
|
|
86
|
+
console.log("Every native rune is already trusted in its current form.");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (!yes) {
|
|
90
|
+
if (!process.stdout.isTTY) {
|
|
91
|
+
throw new Error("Trusting a native rune is a decision to make after reading it. Run this in a terminal, or pass -y (crunes -y plugin trust \u2026) once you have reviewed it.");
|
|
92
|
+
}
|
|
93
|
+
const answer = await le({ message: `Trust ${pending.length === 1 ? "this rune" : `these ${pending.length} runes`} to run with your full access?` });
|
|
94
|
+
if (R(answer) || answer !== true) {
|
|
95
|
+
console.log("Not trusted.");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const { runeKey, digest } of pending) await recordTrust(pluginKey, runeKey, digest);
|
|
100
|
+
console.log(`Trusted ${pending.map((t) => `${pluginKey}:${t.runeKey}`).join(", ")}. A change to what ${pending.length === 1 ? "it runs" : "they run"} needs trusting again.`);
|
|
101
|
+
} catch (err) {
|
|
102
|
+
console.error(`Error: ${err.message}`);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
describeForReview,
|
|
108
|
+
handler
|
|
109
|
+
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
uninstallPlugin
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-QYRF3R35.js";
|
|
3
|
+
} from "./chunk-NJVPLN5D.js";
|
|
4
|
+
import "./chunk-E7CZPAM2.js";
|
|
6
5
|
import {
|
|
7
6
|
output
|
|
8
7
|
} from "./chunk-MIKWIFYR.js";
|
|
@@ -11,12 +10,18 @@ import {
|
|
|
11
10
|
le
|
|
12
11
|
} from "./chunk-CGZL5SSH.js";
|
|
13
12
|
import "./chunk-WCODTMDN.js";
|
|
13
|
+
import "./chunk-MUWDZJN2.js";
|
|
14
|
+
import "./chunk-3KKRNQQU.js";
|
|
15
|
+
import "./chunk-UBCAZGLE.js";
|
|
14
16
|
import {
|
|
15
17
|
loadRegistry,
|
|
16
18
|
resolvePluginKey
|
|
17
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-MTJ2KW3V.js";
|
|
20
|
+
import "./chunk-FIAFVIAN.js";
|
|
21
|
+
import "./chunk-VP7YLCQP.js";
|
|
22
|
+
import "./chunk-WE4HDHFU.js";
|
|
18
23
|
import "./chunk-2Q3KLBE6.js";
|
|
19
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-55GTJG5I.js";
|
|
20
25
|
import {
|
|
21
26
|
init_require_shim
|
|
22
27
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -3,20 +3,25 @@ import {
|
|
|
3
3
|
} from "./chunk-YVN3VDRE.js";
|
|
4
4
|
import {
|
|
5
5
|
installPlugin
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-QYRF3R35.js";
|
|
6
|
+
} from "./chunk-NJVPLN5D.js";
|
|
7
|
+
import "./chunk-E7CZPAM2.js";
|
|
9
8
|
import {
|
|
10
9
|
output
|
|
11
10
|
} from "./chunk-MIKWIFYR.js";
|
|
12
11
|
import "./chunk-CGZL5SSH.js";
|
|
13
12
|
import "./chunk-WCODTMDN.js";
|
|
13
|
+
import "./chunk-MUWDZJN2.js";
|
|
14
|
+
import "./chunk-3KKRNQQU.js";
|
|
15
|
+
import "./chunk-UBCAZGLE.js";
|
|
14
16
|
import {
|
|
15
17
|
loadRegistry,
|
|
16
18
|
resolvePluginKey
|
|
17
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-MTJ2KW3V.js";
|
|
20
|
+
import "./chunk-FIAFVIAN.js";
|
|
21
|
+
import "./chunk-VP7YLCQP.js";
|
|
22
|
+
import "./chunk-WE4HDHFU.js";
|
|
18
23
|
import "./chunk-2Q3KLBE6.js";
|
|
19
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-55GTJG5I.js";
|
|
20
25
|
import {
|
|
21
26
|
init_require_shim
|
|
22
27
|
} from "./chunk-TPK5AGRA.js";
|
|
@@ -16,7 +16,7 @@ import path from "node:path";
|
|
|
16
16
|
// package.json
|
|
17
17
|
var package_default = {
|
|
18
18
|
name: "@darkrymit/crunes-cli",
|
|
19
|
-
version: "0.
|
|
19
|
+
version: "0.10.1",
|
|
20
20
|
description: "CLI tool for querying crunes enrichers",
|
|
21
21
|
type: "module",
|
|
22
22
|
bin: {
|
|
@@ -27,7 +27,7 @@ var package_default = {
|
|
|
27
27
|
],
|
|
28
28
|
scripts: {
|
|
29
29
|
build: "typedoc --options typedoc.json && typedoc --options typedoc-lifecycle.json && typedoc --options typedoc-globals.json && node build.mjs",
|
|
30
|
-
prepack: "
|
|
30
|
+
prepack: "npm run build",
|
|
31
31
|
test: "vitest run"
|
|
32
32
|
},
|
|
33
33
|
dependencies: {
|