@darkrymit/crunes-cli 0.8.5 → 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 (95) hide show
  1. package/dist/chunks/{add-CBHWFGCA.js → add-IT3IHBPO.js} +2 -2
  2. package/dist/chunks/add-MSX6XSU3.js +68 -0
  3. package/dist/chunks/{apply-J4YICV6H.js → apply-LOIJIPLR.js} +21 -12
  4. package/dist/chunks/{benchmark-AKKV7G32.js → benchmark-3IHFP3V2.js} +27 -18
  5. package/dist/chunks/{browse-JZFU52ET.js → browse-PHMBDREQ.js} +2 -2
  6. package/dist/chunks/chunk-2DNYVKBF.js +109 -0
  7. package/dist/chunks/chunk-2FI6KN3C.js +283 -0
  8. package/dist/chunks/chunk-2HM5Q52B.js +131 -0
  9. package/dist/chunks/{chunk-6MRZXASS.js → chunk-2Q3KLBE6.js} +16 -0
  10. package/dist/chunks/{chunk-ZJDKCC2Y.js → chunk-4GJMCFR6.js} +6 -3
  11. package/dist/chunks/chunk-55GTJG5I.js +1154 -0
  12. package/dist/chunks/chunk-6IC6ZJ74.js +9525 -0
  13. package/dist/chunks/chunk-7KYCYDAS.js +325 -0
  14. package/dist/chunks/chunk-DTOYFY3Z.js +578 -0
  15. package/dist/chunks/chunk-EO3CSXWK.js +70 -0
  16. package/dist/chunks/chunk-FIAFVIAN.js +79 -0
  17. package/dist/chunks/{chunk-J3GZ3DXD.js → chunk-GVMT55GH.js} +3 -2
  18. package/dist/chunks/chunk-H2OT7D6N.js +303 -0
  19. package/dist/chunks/{chunk-JOAL437H.js → chunk-I6MHDUCW.js} +16 -1
  20. package/dist/chunks/chunk-KSQDFE5N.js +85 -0
  21. package/dist/chunks/{chunk-BTIPUR5S.js → chunk-KUEMDPNG.js} +108 -91
  22. package/dist/chunks/{chunk-6XLT25GS.js → chunk-MIKWIFYR.js} +47 -0
  23. package/dist/chunks/{chunk-GTCPZ22N.js → chunk-MTJ2KW3V.js} +3 -1
  24. package/dist/chunks/chunk-MVCBPI4J.js +2354 -0
  25. package/dist/chunks/{chunk-T53L5CJW.js → chunk-PBGUKXT6.js} +2887 -1874
  26. package/dist/chunks/{chunk-KII6KW5Z.js → chunk-RVBAAXRY.js} +64 -44
  27. package/dist/chunks/chunk-SUCYDYMU.js +44 -0
  28. package/dist/chunks/chunk-UBCAZGLE.js +15 -0
  29. package/dist/chunks/{chunk-63H5VXZY.js → chunk-UEUUOAJY.js} +4 -1
  30. package/dist/chunks/chunk-VP7YLCQP.js +244 -0
  31. package/dist/chunks/{chunk-NDEYEYSU.js → chunk-WJII3LZK.js} +4 -3
  32. package/dist/chunks/chunk-XDMMSZIL.js +71 -0
  33. package/dist/chunks/chunk-YKIKJHYO.js +94 -0
  34. package/dist/chunks/{chunk-NYLRTAAA.js → chunk-YVN3VDRE.js} +1 -1
  35. package/dist/chunks/{clear-YBDIPEEH.js → clear-AT7HNUV4.js} +2 -2
  36. package/dist/chunks/{create-L6DJN4ME.js → create-DXW4YYLJ.js} +8 -8
  37. package/dist/chunks/create-LPLNCOW4.js +268 -0
  38. package/dist/chunks/{create-GPDE2YKL.js → create-Y4LHLWGL.js} +26 -18
  39. package/dist/chunks/{delete-LNOYM5KG.js → delete-2EXPFBFC.js} +2 -2
  40. package/dist/chunks/{delete-E4TEBRPX.js → delete-GKYA2W5Z.js} +4 -2
  41. package/dist/chunks/{delete-C4UJ7X5K.js → delete-MJAECXXV.js} +2 -2
  42. package/dist/chunks/disable-TITOSMXB.js +43 -0
  43. package/dist/chunks/doctor-R2Y6UAY4.js +208 -0
  44. package/dist/chunks/enable-LGTPDWPV.js +35 -0
  45. package/dist/chunks/{globals-H2WF344Y.js → globals-SNQFCHMP.js} +1 -1
  46. package/dist/chunks/{init-HU5OMHEH.js → init-KO2HLED5.js} +18 -8
  47. package/dist/chunks/install-7IRUAGSF.js +64 -0
  48. package/dist/chunks/{intro-36OLGNYN.js → intro-JNJ6A75J.js} +89 -21
  49. package/dist/chunks/{kill-2UG7PHUV.js → kill-TX3PC73P.js} +2 -1
  50. package/dist/chunks/{list-2JYMBMZC.js → list-BCCM3TLP.js} +12 -7
  51. package/dist/chunks/{list-4X3JFQGS.js → list-EHREZR6M.js} +2 -1
  52. package/dist/chunks/{list-U7PAYNAH.js → list-LC6HB3H3.js} +2 -2
  53. package/dist/chunks/list-MLKZE36K.js +92 -0
  54. package/dist/chunks/list-QVZKR3IE.js +62 -0
  55. package/dist/chunks/{list-7VHJIUDX.js → list-U4EMHQZT.js} +2 -2
  56. package/dist/chunks/{list-PTAWQYWG.js → list-V7VVD5AG.js} +2 -1
  57. package/dist/chunks/{list-A5WVDBWF.js → list-VA73WPK6.js} +2 -2
  58. package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
  59. package/dist/chunks/migrate-Y3EKMVP5.js +87 -0
  60. package/dist/chunks/{output-RJ6JSNY7.js → output-QN5CVJ62.js} +4 -1
  61. package/dist/chunks/{query-AW7WYILM.js → query-2US3CPYT.js} +2 -2
  62. package/dist/chunks/{registry-RG34DPD7.js → registry-IWP7JMNI.js} +2 -2
  63. package/dist/chunks/{remove-QUH2D3S5.js → remove-BCFTF23J.js} +2 -2
  64. package/dist/chunks/{repl-STBZC4P2.js → repl-2YWTHUWT.js} +4 -0
  65. package/dist/chunks/{repl-BPEWARN7.js → repl-5GDN3RAO.js} +99 -31
  66. package/dist/chunks/resolver-CA2A32AC.js +36 -0
  67. package/dist/chunks/run-WL3IZBXF.js +35 -0
  68. package/dist/chunks/rune-YA4TFHTB.js +283 -0
  69. package/dist/chunks/runner-QNZMBHQY.js +34 -0
  70. package/dist/chunks/{search-MSSDGJTF.js → search-B7IM7JRJ.js} +2 -2
  71. package/dist/chunks/shell-explain-LKBBP2BG.js +77 -0
  72. package/dist/chunks/trust-BFIDANXD.js +109 -0
  73. package/dist/chunks/uninstall-3MWZIZVA.js +58 -0
  74. package/dist/chunks/{unset-YASSMSE5.js → unset-P6IUF7SS.js} +2 -2
  75. package/dist/chunks/{update-KSC6VRMU.js → update-W4MJUTTW.js} +25 -19
  76. package/dist/chunks/{update-EWWDROKW.js → update-WXT7CHYA.js} +2 -2
  77. package/dist/chunks/{utils-3SJFSUSV.js → utils-B2QULX5J.js} +8 -4
  78. package/dist/chunks/{version-YG2M7HER.js → version-FLHI5KFS.js} +3 -3
  79. package/dist/cli.js +115 -70
  80. package/package.json +2 -2
  81. package/dist/chunks/chunk-ASZKAC24.js +0 -103
  82. package/dist/chunks/chunk-G3U4V32O.js +0 -46
  83. package/dist/chunks/chunk-GSA432UC.js +0 -90
  84. package/dist/chunks/chunk-WJRZN7BR.js +0 -77492
  85. package/dist/chunks/create-VYZRWRGQ.js +0 -170
  86. package/dist/chunks/disable-FGJ7VMPO.js +0 -47
  87. package/dist/chunks/doctor-7NWBJAH7.js +0 -53
  88. package/dist/chunks/enable-ZL6QOC2I.js +0 -47
  89. package/dist/chunks/install-FIYRMVLR.js +0 -57
  90. package/dist/chunks/list-AIYNOPNZ.js +0 -28
  91. package/dist/chunks/list-NZ5DHXJF.js +0 -111
  92. package/dist/chunks/resolver-36V72VKR.js +0 -28
  93. package/dist/chunks/run-IVL23SMW.js +0 -26
  94. package/dist/chunks/rune-XRREUL56.js +0 -186
  95. package/dist/chunks/uninstall-G56DZRFG.js +0 -49
@@ -0,0 +1,283 @@
1
+ import {
2
+ enumerateRunes
3
+ } from "./chunk-KSQDFE5N.js";
4
+ import {
5
+ getArgsSchema,
6
+ getPluginRunePath,
7
+ getReplSchema
8
+ } from "./chunk-6IC6ZJ74.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-H2OT7D6N.js";
22
+ import {
23
+ describeRunBlock,
24
+ flattenCommands,
25
+ formatCommandPage,
26
+ formatGlobalIndex,
27
+ formatRuneIndex,
28
+ getRunBlockSchema,
29
+ selectNode
30
+ } from "./chunk-DTOYFY3Z.js";
31
+ import {
32
+ resolveInterpreter
33
+ } from "./chunk-2DNYVKBF.js";
34
+ import {
35
+ isNativeRune
36
+ } from "./chunk-XDMMSZIL.js";
37
+ import {
38
+ getRune,
39
+ loadConfig
40
+ } from "./chunk-2FI6KN3C.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-YKIKJHYO.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-6IC6ZJ74.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-YKIKJHYO.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,7 +1,7 @@
1
1
  import {
2
2
  searchMarketplaces
3
- } from "./chunk-NYLRTAAA.js";
4
- import "./chunk-6MRZXASS.js";
3
+ } from "./chunk-YVN3VDRE.js";
4
+ import "./chunk-2Q3KLBE6.js";
5
5
  import {
6
6
  init_require_shim
7
7
  } from "./chunk-TPK5AGRA.js";
@@ -0,0 +1,77 @@
1
+ import {
2
+ BUILTIN_ALLOWLIST,
3
+ ScanRefusal,
4
+ scanCommand
5
+ } from "./chunk-7KYCYDAS.js";
6
+ import "./chunk-MVCBPI4J.js";
7
+ import "./chunk-GVMT55GH.js";
8
+ import {
9
+ resolveShell
10
+ } from "./chunk-2HM5Q52B.js";
11
+ import "./chunk-WJII3LZK.js";
12
+ import "./chunk-G4ZAUHHA.js";
13
+ import "./chunk-2Q3KLBE6.js";
14
+ import {
15
+ init_require_shim
16
+ } from "./chunk-TPK5AGRA.js";
17
+
18
+ // src/rune/commands/shell-explain.js
19
+ init_require_shim();
20
+ function explain({ cmd, shellMode }) {
21
+ const shell = resolveShell(shellMode).kind;
22
+ try {
23
+ const { commands, redirects } = scanCommand(cmd, shell);
24
+ return {
25
+ shell,
26
+ refusal: null,
27
+ commands: commands.map((c) => ({
28
+ program: c.program,
29
+ segment: c.segment,
30
+ offset: c.offset,
31
+ builtin: BUILTIN_ALLOWLIST.has(c.program)
32
+ })),
33
+ redirects: redirects.map((r) => ({
34
+ capability: r.mode === "write" ? "fs.write" : "fs.read",
35
+ target: r.target,
36
+ offset: r.offset
37
+ }))
38
+ };
39
+ } catch (e) {
40
+ if (!(e instanceof ScanRefusal)) throw e;
41
+ return { shell, refusal: { construct: e.construct, offset: e.offset }, commands: [], redirects: [] };
42
+ }
43
+ }
44
+ async function handler({ cmd, shellMode }) {
45
+ const r = explain({ cmd, shellMode });
46
+ console.log(`shell: ${r.shell}`);
47
+ console.log();
48
+ if (r.refusal) {
49
+ console.log(`REFUSED: ${r.refusal.construct} at offset ${r.refusal.offset}`);
50
+ console.log();
51
+ console.log(cmd);
52
+ console.log(" ".repeat(r.refusal.offset) + "^");
53
+ console.log();
54
+ console.log("This construct cannot be classified, so it is denied. There is no");
55
+ console.log("grant that overrides this. Rewrite the command without it.");
56
+ process.exitCode = 1;
57
+ return;
58
+ }
59
+ console.log("command positions:");
60
+ for (const c of r.commands) {
61
+ const tag = c.builtin ? "builtin, no grant needed" : `needs shell.run:${c.segment}`;
62
+ console.log(` @${String(c.offset).padStart(4)} ${c.segment}`);
63
+ console.log(` ${tag}`);
64
+ }
65
+ if (r.redirects.length > 0) {
66
+ console.log();
67
+ console.log("redirects:");
68
+ for (const rd of r.redirects) {
69
+ console.log(` @${String(rd.offset).padStart(4)} ${rd.target}`);
70
+ console.log(` needs ${rd.capability}:${rd.target}`);
71
+ }
72
+ }
73
+ }
74
+ export {
75
+ explain,
76
+ handler
77
+ };
@@ -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-XDMMSZIL.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-YKIKJHYO.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
+ };
@@ -0,0 +1,58 @@
1
+ import {
2
+ uninstallPlugin
3
+ } from "./chunk-RVBAAXRY.js";
4
+ import "./chunk-SUCYDYMU.js";
5
+ import {
6
+ output
7
+ } from "./chunk-MIKWIFYR.js";
8
+ import {
9
+ R,
10
+ le
11
+ } from "./chunk-CGZL5SSH.js";
12
+ import "./chunk-WCODTMDN.js";
13
+ import "./chunk-XDMMSZIL.js";
14
+ import "./chunk-2FI6KN3C.js";
15
+ import "./chunk-UBCAZGLE.js";
16
+ import {
17
+ loadRegistry,
18
+ resolvePluginKey
19
+ } from "./chunk-MTJ2KW3V.js";
20
+ import "./chunk-FIAFVIAN.js";
21
+ import "./chunk-VP7YLCQP.js";
22
+ import "./chunk-YKIKJHYO.js";
23
+ import "./chunk-2Q3KLBE6.js";
24
+ import "./chunk-55GTJG5I.js";
25
+ import {
26
+ init_require_shim
27
+ } from "./chunk-TPK5AGRA.js";
28
+
29
+ // src/plugin/commands/uninstall.js
30
+ init_require_shim();
31
+ async function handler({ name, yes, projectRoot, configRoot, global = false }) {
32
+ let pluginKey;
33
+ try {
34
+ const registry = await loadRegistry();
35
+ pluginKey = resolvePluginKey(name, registry);
36
+ if (!pluginKey) throw new Error(`Plugin "${name}" is not installed. Run: crunes plugin list`);
37
+ } catch (err) {
38
+ output.cancel(`Error: ${err.message}`);
39
+ process.exit(1);
40
+ }
41
+ if (!yes) {
42
+ const confirm = await le({ message: `Uninstall plugin "${pluginKey}"?` });
43
+ if (R(confirm) || !confirm) {
44
+ output.cancel("Cancelled.");
45
+ process.exit(0);
46
+ }
47
+ }
48
+ try {
49
+ await uninstallPlugin(pluginKey, configRoot ?? projectRoot, { global });
50
+ output.outro(`Uninstalled ${pluginKey}`);
51
+ } catch (err) {
52
+ output.cancel(`Failed: ${err.message}`);
53
+ process.exit(1);
54
+ }
55
+ }
56
+ export {
57
+ handler
58
+ };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  deleteCacheKey
3
- } from "./chunk-NDEYEYSU.js";
3
+ } from "./chunk-WJII3LZK.js";
4
4
  import "./chunk-G4ZAUHHA.js";
5
- import "./chunk-6MRZXASS.js";
5
+ import "./chunk-2Q3KLBE6.js";
6
6
  import {
7
7
  init_require_shim
8
8
  } from "./chunk-TPK5AGRA.js";
@@ -1,21 +1,27 @@
1
1
  import {
2
2
  resolveFromMarketplace
3
- } from "./chunk-NYLRTAAA.js";
3
+ } from "./chunk-YVN3VDRE.js";
4
4
  import {
5
5
  installPlugin
6
- } from "./chunk-KII6KW5Z.js";
6
+ } from "./chunk-RVBAAXRY.js";
7
+ import "./chunk-SUCYDYMU.js";
7
8
  import {
8
- R2 as R,
9
- fe,
10
- ge,
11
- ye
12
- } from "./chunk-CGZL5SSH.js";
9
+ output
10
+ } from "./chunk-MIKWIFYR.js";
11
+ import "./chunk-CGZL5SSH.js";
12
+ import "./chunk-WCODTMDN.js";
13
+ import "./chunk-XDMMSZIL.js";
14
+ import "./chunk-2FI6KN3C.js";
15
+ import "./chunk-UBCAZGLE.js";
13
16
  import {
14
17
  loadRegistry,
15
18
  resolvePluginKey
16
- } from "./chunk-GTCPZ22N.js";
17
- import "./chunk-6MRZXASS.js";
18
- import "./chunk-G3U4V32O.js";
19
+ } from "./chunk-MTJ2KW3V.js";
20
+ import "./chunk-FIAFVIAN.js";
21
+ import "./chunk-VP7YLCQP.js";
22
+ import "./chunk-YKIKJHYO.js";
23
+ import "./chunk-2Q3KLBE6.js";
24
+ import "./chunk-55GTJG5I.js";
19
25
  import {
20
26
  init_require_shim
21
27
  } from "./chunk-TPK5AGRA.js";
@@ -28,7 +34,7 @@ async function handler({ name, projectRoot, configRoot }) {
28
34
  if (name) {
29
35
  const pluginKey = resolvePluginKey(name, registry);
30
36
  if (!pluginKey) {
31
- ge(`Plugin "${name}" is not installed. Run: crunes plugin list`);
37
+ output.cancel(`Plugin "${name}" is not installed. Run: crunes plugin list`);
32
38
  process.exit(1);
33
39
  }
34
40
  plugins = [pluginKey];
@@ -39,16 +45,16 @@ async function handler({ name, projectRoot, configRoot }) {
39
45
  console.log("No plugins installed.");
40
46
  return;
41
47
  }
42
- ye(name ? `Updating ${name}\u2026` : "Updating all plugins\u2026");
48
+ output.intro(name ? `Updating ${name}\u2026` : "Updating all plugins\u2026");
43
49
  for (const pluginName of plugins) {
44
50
  const entry = registry.plugins[pluginName];
45
51
  if (!entry) {
46
- R.warn(`Plugin "${pluginName}" is not installed.`);
52
+ output.log.warn(`Plugin "${pluginName}" is not installed.`);
47
53
  continue;
48
54
  }
49
55
  const atIdx = pluginName.indexOf("@");
50
56
  if (atIdx === -1) {
51
- R.warn(`Skipping ${pluginName}: no marketplace provenance (legacy entry).`);
57
+ output.log.warn(`Skipping ${pluginName}: no marketplace provenance (legacy entry).`);
52
58
  continue;
53
59
  }
54
60
  const marketplaceName = pluginName.slice(0, atIdx);
@@ -58,21 +64,21 @@ async function handler({ name, projectRoot, configRoot }) {
58
64
  ;
59
65
  ({ resolvedSource, ...provenance } = await resolveFromMarketplace(marketplaceName, pluginNamePart));
60
66
  } catch (err) {
61
- R.error(`Failed to resolve ${pluginName} from marketplace: ${err.message}`);
67
+ output.log.error(`Failed to resolve ${pluginName} from marketplace: ${err.message}`);
62
68
  continue;
63
69
  }
64
70
  try {
65
71
  const result = await installPlugin(resolvedSource, configRoot ?? projectRoot, provenance);
66
72
  if (result.installed) {
67
- R.success(`Updated ${pluginName}@${result.version}`);
73
+ output.log.success(`Updated ${pluginName}@${result.version}`);
68
74
  } else {
69
- R.warn(`Update of ${pluginName} cancelled (permission consent declined).`);
75
+ output.log.warn(`Update of ${pluginName} cancelled (permission consent declined).`);
70
76
  }
71
77
  } catch (err) {
72
- R.error(`Failed to update ${pluginName}: ${err.message}`);
78
+ output.log.error(`Failed to update ${pluginName}: ${err.message}`);
73
79
  }
74
80
  }
75
- fe("Done.");
81
+ output.outro("Done.");
76
82
  }
77
83
  export {
78
84
  handler
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  listMarketplaces,
3
3
  updateMarketplace
4
- } from "./chunk-NYLRTAAA.js";
5
- import "./chunk-6MRZXASS.js";
4
+ } from "./chunk-YVN3VDRE.js";
5
+ import "./chunk-2Q3KLBE6.js";
6
6
  import {
7
7
  init_require_shim
8
8
  } from "./chunk-TPK5AGRA.js";