@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.
Files changed (58) hide show
  1. package/dist/chunks/add-2OM5KGN5.js +67 -0
  2. package/dist/chunks/{apply-YY7MIM64.js → apply-GBUQQ4XF.js} +21 -9
  3. package/dist/chunks/{benchmark-BQNMULOO.js → benchmark-QWGVX3BX.js} +21 -15
  4. package/dist/chunks/chunk-2DNYVKBF.js +109 -0
  5. package/dist/chunks/chunk-2HM5Q52B.js +131 -0
  6. package/dist/chunks/chunk-3KKRNQQU.js +275 -0
  7. package/dist/chunks/chunk-55GTJG5I.js +1154 -0
  8. package/dist/chunks/chunk-7KYCYDAS.js +325 -0
  9. package/dist/chunks/{chunk-SNC7AOT7.js → chunk-AL37NFWR.js} +45 -94
  10. package/dist/chunks/chunk-ARIFLX5E.js +9525 -0
  11. package/dist/chunks/{chunk-X7PZN73N.js → chunk-E7CZPAM2.js} +1 -1
  12. package/dist/chunks/chunk-EO3CSXWK.js +70 -0
  13. package/dist/chunks/chunk-FIAFVIAN.js +79 -0
  14. package/dist/chunks/{chunk-MRNZFUXZ.js → chunk-KQMTTEJV.js} +22 -7
  15. package/dist/chunks/chunk-KX6QEHM5.js +578 -0
  16. package/dist/chunks/{chunk-VST6HAB6.js → chunk-MTJ2KW3V.js} +2 -0
  17. package/dist/chunks/chunk-MUWDZJN2.js +71 -0
  18. package/dist/chunks/{chunk-CY6C6ADU.js → chunk-MVCBPI4J.js} +45 -478
  19. package/dist/chunks/{chunk-34F4ZURL.js → chunk-NJVPLN5D.js} +29 -12
  20. package/dist/chunks/chunk-UBCAZGLE.js +15 -0
  21. package/dist/chunks/chunk-VP7YLCQP.js +244 -0
  22. package/dist/chunks/chunk-VSMAZISQ.js +303 -0
  23. package/dist/chunks/chunk-WE4HDHFU.js +37 -0
  24. package/dist/chunks/{create-ET6DT5ZE.js → create-2CQZF53Z.js} +5 -2
  25. package/dist/chunks/{create-LM7U3CJS.js → create-36F6V4WP.js} +99 -6
  26. package/dist/chunks/{create-TLPM7HJE.js → create-DXW4YYLJ.js} +5 -5
  27. package/dist/chunks/{disable-TNTEIAKO.js → disable-FB64CSYV.js} +5 -2
  28. package/dist/chunks/doctor-PVO4JLYN.js +208 -0
  29. package/dist/chunks/{enable-GUQCB4CU.js → enable-UVXHTKCJ.js} +6 -3
  30. package/dist/chunks/{init-PJSCFOC6.js → init-GPNC7TR5.js} +5 -2
  31. package/dist/chunks/{install-4YP7FALO.js → install-3G7U5ZIO.js} +10 -5
  32. package/dist/chunks/{intro-SA7MWV3Z.js → intro-YI5HUZCF.js} +45 -19
  33. package/dist/chunks/{list-WKNPZZOV.js → list-J2UCBYAY.js} +9 -6
  34. package/dist/chunks/list-JB4447YK.js +62 -0
  35. package/dist/chunks/{list-7R6NASFI.js → list-W4JAYPAA.js} +19 -19
  36. package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
  37. package/dist/chunks/{registry-K5DV5NAK.js → registry-IWP7JMNI.js} +1 -1
  38. package/dist/chunks/{repl-ZB3DIJ4K.js → repl-MWFEZ65P.js} +30 -20
  39. package/dist/chunks/resolver-URPQMOIV.js +36 -0
  40. package/dist/chunks/{run-22B65ZWZ.js → run-3VKWSRLO.js} +17 -11
  41. package/dist/chunks/rune-L5EP645W.js +283 -0
  42. package/dist/chunks/runner-VPTLUQJE.js +34 -0
  43. package/dist/chunks/{shell-explain-QLITLHW7.js → shell-explain-LKBBP2BG.js} +5 -2
  44. package/dist/chunks/trust-LXXYSF6W.js +109 -0
  45. package/dist/chunks/{uninstall-4WR5IHLC.js → uninstall-J7JUYETA.js} +10 -5
  46. package/dist/chunks/{update-ACLDK6E6.js → update-ZJRLDCUT.js} +10 -5
  47. package/dist/chunks/{version-EULYWNXN.js → version-ZULO6CV3.js} +2 -2
  48. package/dist/cli.js +47 -34
  49. package/package.json +2 -2
  50. package/dist/chunks/chunk-G3U4V32O.js +0 -46
  51. package/dist/chunks/chunk-QYRF3R35.js +0 -154
  52. package/dist/chunks/chunk-YXCHIMLW.js +0 -75308
  53. package/dist/chunks/doctor-VXAQYMTR.js +0 -101
  54. package/dist/chunks/list-OMMZAQ23.js +0 -28
  55. package/dist/chunks/resolver-QIYYFIDX.js +0 -34
  56. package/dist/chunks/rune-SYK4N642.js +0 -425
  57. package/dist/chunks/{delete-5R3WBLVD.js → delete-2EXPFBFC.js} +4 -4
  58. package/dist/chunks/{delete-U4STA2QZ.js → delete-MJAECXXV.js} +4 -4
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  coercePlugins
3
- } from "./chunk-QYRF3R35.js";
3
+ } from "./chunk-3KKRNQQU.js";
4
4
  import {
5
5
  getStorePath
6
6
  } from "./chunk-2Q3KLBE6.js";
@@ -0,0 +1,70 @@
1
+ import {
2
+ init_require_shim
3
+ } from "./chunk-TPK5AGRA.js";
4
+
5
+ // src/job/stdin-tail.js
6
+ init_require_shim();
7
+ import { readSync, openSync, closeSync, statSync } from "node:fs";
8
+ var EOF_SENTINEL = "__CRUNES_STDIN_EOF__";
9
+ function tailStdin(logPath, { onLine, onEof = () => {
10
+ }, pollMs = 50 } = {}) {
11
+ let offset = 0;
12
+ let stopped = false;
13
+ let timer = null;
14
+ let remainder = "";
15
+ function read() {
16
+ if (stopped) return;
17
+ let fd;
18
+ try {
19
+ fd = openSync(logPath, "r");
20
+ const size = statSync(logPath).size;
21
+ if (size <= offset) {
22
+ schedule();
23
+ return;
24
+ }
25
+ const buf = Buffer.allocUnsafe(size - offset);
26
+ const bytesRead = readSync(fd, buf, 0, buf.length, offset);
27
+ offset += bytesRead;
28
+ remainder += buf.slice(0, bytesRead).toString("utf8");
29
+ } catch {
30
+ schedule();
31
+ return;
32
+ } finally {
33
+ try {
34
+ if (fd !== void 0) closeSync(fd);
35
+ } catch {
36
+ }
37
+ }
38
+ const lines = remainder.split("\n");
39
+ remainder = lines.pop();
40
+ for (const line of lines) {
41
+ if (line === EOF_SENTINEL) {
42
+ stopped = true;
43
+ onEof();
44
+ return;
45
+ }
46
+ if (line.length > 0) onLine(line);
47
+ }
48
+ schedule();
49
+ }
50
+ function schedule() {
51
+ if (!stopped) {
52
+ timer = setTimeout(read, pollMs);
53
+ timer.unref();
54
+ }
55
+ }
56
+ function stop() {
57
+ stopped = true;
58
+ if (timer) {
59
+ clearTimeout(timer);
60
+ timer = null;
61
+ }
62
+ }
63
+ schedule();
64
+ return { stop };
65
+ }
66
+
67
+ export {
68
+ EOF_SENTINEL,
69
+ tailStdin
70
+ };
@@ -0,0 +1,79 @@
1
+ import {
2
+ isInlineSchema,
3
+ normaliseJsonSchema
4
+ } from "./chunk-VP7YLCQP.js";
5
+ import {
6
+ init_require_shim
7
+ } from "./chunk-TPK5AGRA.js";
8
+
9
+ // src/plugin/manifest.js
10
+ init_require_shim();
11
+ import fs from "node:fs/promises";
12
+ import path from "node:path";
13
+ var PLUGIN_JSON_RELATIVE = ".crunes-plugin/plugin.json";
14
+ async function loadPluginJson(pluginDir) {
15
+ const jsonPath = path.join(pluginDir, PLUGIN_JSON_RELATIVE);
16
+ const raw = await fs.readFile(jsonPath, "utf8");
17
+ const json = JSON.parse(raw);
18
+ validatePluginJson(json, pluginDir);
19
+ return json;
20
+ }
21
+ var ISOLATE_MODULE = /\.rune\.m?js$/i;
22
+ var ARGS_FILE = /\.(rune\.m?js|json)$/i;
23
+ var RUNE_BLOCK_KEYS = {
24
+ run: ["command", "argv", "permissions", "output", "pass", "timeout"],
25
+ repl: ["command", "permissions"]
26
+ };
27
+ function validatePluginJson(json, pluginDir = null) {
28
+ if (json.format !== "1") throw new Error(`plugin.json: unsupported format "${json.format}" (expected "1")`);
29
+ if (!json.runes || typeof json.runes !== "object") throw new Error('plugin.json: "runes" must be an object');
30
+ for (const [key, rune] of Object.entries(json.runes)) {
31
+ const at = `plugin.json: rune "${key}"`;
32
+ if (!rune || typeof rune !== "object" || Array.isArray(rune)) throw new Error(`${at} must be an object`);
33
+ for (const old of ["path", "permissions"]) {
34
+ if (rune[old] !== void 0) throw new Error(`${at} has "${old}" \u2014 a plugin manifest names the module and its grants in the run and repl blocks`);
35
+ }
36
+ if (rune.run == null) throw new Error(`${at} has no run block`);
37
+ for (const mode of ["run", "repl"]) {
38
+ if (rune[mode] == null) continue;
39
+ const block = typeof rune[mode] === "string" ? { command: rune[mode] } : rune[mode];
40
+ if (typeof block !== "object" || Array.isArray(block)) throw new Error(`${at}: ${mode} must be a module path or { "command", "permissions" }`);
41
+ const unknown = Object.keys(block).filter((k) => !RUNE_BLOCK_KEYS[mode].includes(k));
42
+ if (unknown.length) throw new Error(`${at}: ${mode} has unknown field ${unknown.map((k) => `"${k}"`).join(", ")}`);
43
+ if (typeof block.command !== "string" || block.command === "") throw new Error(`${at}: ${mode}.command must be a non-empty string`);
44
+ const isolate = ISOLATE_MODULE.test(block.command);
45
+ if (mode === "repl" && !isolate) throw new Error(`${at}: repl.command must be a *.rune.js module in the plugin`);
46
+ const perms = block.permissions;
47
+ if (perms != null && !isolate) {
48
+ throw new Error(`${at}: ${mode}.permissions \u2014 "${block.command}" runs natively with full access, so grants would not apply to it`);
49
+ }
50
+ if (perms != null && (typeof perms !== "object" || Array.isArray(perms) || Object.keys(perms).some((k) => k !== "allow" && k !== "deny"))) {
51
+ throw new Error(`${at}: ${mode}.permissions must be { "allow": [...], "deny": [...] }`);
52
+ }
53
+ if (isolate && ["argv", "output", "pass"].some((k) => block[k] !== void 0)) {
54
+ throw new Error(`${at}: ${mode} \u2014 argv, output and pass apply to a native handler, not an isolate module`);
55
+ }
56
+ }
57
+ if (rune.args != null) {
58
+ const run = typeof rune.run === "string" ? { command: rune.run } : rune.run;
59
+ if (ISOLATE_MODULE.test(run.command)) throw new Error(`${at}: args \u2014 an isolate module declares its schema with its own args export`);
60
+ if (isInlineSchema(rune.args)) {
61
+ try {
62
+ normaliseJsonSchema(rune.args, `rune "${key}" args`);
63
+ } catch (err) {
64
+ throw new Error(`plugin.json: ${err.message}`);
65
+ }
66
+ } else {
67
+ const args = typeof rune.args === "string" ? { command: rune.args } : rune.args;
68
+ if (typeof args.command !== "string" || !ARGS_FILE.test(args.command)) {
69
+ throw new Error(`${at}: args.command must be a *.rune.js module exporting args(builder), or a .json schema`);
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ export {
77
+ loadPluginJson,
78
+ validatePluginJson
79
+ };
@@ -1,9 +1,16 @@
1
1
  import {
2
+ runtimeOf
3
+ } from "./chunk-2DNYVKBF.js";
4
+ import {
5
+ isNativeRune
6
+ } from "./chunk-MUWDZJN2.js";
7
+ import {
8
+ enabledPluginKeys,
2
9
  getRune
3
- } from "./chunk-YXCHIMLW.js";
10
+ } from "./chunk-3KKRNQQU.js";
4
11
  import {
5
- enabledPluginKeys
6
- } from "./chunk-QYRF3R35.js";
12
+ blockOf
13
+ } from "./chunk-WE4HDHFU.js";
7
14
  import {
8
15
  init_require_shim
9
16
  } from "./chunk-TPK5AGRA.js";
@@ -20,14 +27,21 @@ async function enumerateRunes(config) {
20
27
  continue;
21
28
  }
22
29
  const entry = getRune(config, key);
23
- const source = entry.plugin ? `\u2192 ${entry.plugin}` : entry.path ?? "";
30
+ if (entry.run != null) {
31
+ const run = typeof entry.run === "string" ? { command: entry.run } : entry.run;
32
+ const runtime = runtimeOf(run.command);
33
+ const source2 = [run.command, ...run.argv ?? []].join(" ");
34
+ entries.push({ key, source: source2, runtime, name: entry.name ?? null, description: entry.description ?? null });
35
+ continue;
36
+ }
37
+ const source = entry.plugin ? `\u2192 ${entry.plugin}` : "";
24
38
  entries.push({ key, source, name: entry.name ?? null, description: entry.description ?? null });
25
39
  }
26
40
  const enabledPlugins = enabledPluginKeys(config);
27
41
  if (enabledPlugins.length > 0) {
28
42
  try {
29
- const { loadRegistry } = await import("./registry-K5DV5NAK.js");
30
- const { loadPluginJson } = await import("./manifest-7RVNKBOH.js");
43
+ const { loadRegistry } = await import("./registry-IWP7JMNI.js");
44
+ const { loadPluginJson } = await import("./manifest-76MIEL2F.js");
31
45
  const registry = await loadRegistry();
32
46
  for (const pluginKey of enabledPlugins) {
33
47
  const entry = registry.plugins?.[pluginKey];
@@ -46,6 +60,7 @@ async function enumerateRunes(config) {
46
60
  entries.push({
47
61
  key: displayKey,
48
62
  source: `plugin: ${pluginKey}`,
63
+ ...isNativeRune(runeEntry) && { runtime: runtimeOf(blockOf(runeEntry, "run").command) },
49
64
  name: runeEntry.name ?? null,
50
65
  description: runeEntry.description ?? null
51
66
  });
@@ -60,7 +75,7 @@ async function enumerateRunes(config) {
60
75
  const shortName = key.slice(key.indexOf("@") + 1, key.lastIndexOf(":"));
61
76
  if (entries.some((e) => e.key === `${shortName}:${runeKey}`)) continue;
62
77
  const entry = getRune(config, key);
63
- entries.push({ key, source: entry.path ?? "", name: entry.name ?? null, description: entry.description ?? null });
78
+ entries.push({ key, source: "", name: entry.name ?? null, description: entry.description ?? null });
64
79
  }
65
80
  return entries;
66
81
  }