@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,92 @@
1
+ import {
2
+ require_cli_table3
3
+ } from "./chunk-DMMC4X27.js";
4
+ import {
5
+ enumerateRunes
6
+ } from "./chunk-KSQDFE5N.js";
7
+ import {
8
+ output
9
+ } from "./chunk-MIKWIFYR.js";
10
+ import "./chunk-CGZL5SSH.js";
11
+ import "./chunk-WCODTMDN.js";
12
+ import "./chunk-2DNYVKBF.js";
13
+ import "./chunk-XDMMSZIL.js";
14
+ import {
15
+ LAYER,
16
+ ROOTLESS,
17
+ loadConfig
18
+ } from "./chunk-2FI6KN3C.js";
19
+ import "./chunk-UBCAZGLE.js";
20
+ import "./chunk-MTJ2KW3V.js";
21
+ import "./chunk-VP7YLCQP.js";
22
+ import "./chunk-YKIKJHYO.js";
23
+ import "./chunk-2HM5Q52B.js";
24
+ import "./chunk-2Q3KLBE6.js";
25
+ import "./chunk-55GTJG5I.js";
26
+ import {
27
+ __toESM,
28
+ init_require_shim
29
+ } from "./chunk-TPK5AGRA.js";
30
+
31
+ // src/rune/commands/list.js
32
+ init_require_shim();
33
+ var import_cli_table3 = __toESM(require_cli_table3(), 1);
34
+ async function collectListRows({ projectRoot = process.cwd(), configRoot, global = false } = {}) {
35
+ const config = loadConfig(configRoot ?? projectRoot);
36
+ const entries = await enumerateRunes(config);
37
+ const rows = entries.map((entry) => ({
38
+ ...entry,
39
+ layer: config.runes?.[entry.key] ? config.runes[entry.key][LAYER] ?? "project" : "plugin"
40
+ }));
41
+ return {
42
+ rows: global ? rows.filter((r) => r.layer === "global") : rows,
43
+ rootless: config[ROOTLESS] === true
44
+ };
45
+ }
46
+ async function handler({
47
+ format = "md",
48
+ plain = false,
49
+ projectRoot = process.cwd(),
50
+ configRoot = projectRoot,
51
+ global = false
52
+ } = {}) {
53
+ let entries, rootless;
54
+ try {
55
+ ({ rows: entries, rootless } = await collectListRows({ projectRoot, configRoot, global }));
56
+ } catch (err) {
57
+ output.error(`Config unreadable: ${err.message}`);
58
+ output.info("Run `crunes init` to create a config file.");
59
+ process.exit(1);
60
+ }
61
+ if (entries.length === 0) {
62
+ process.stdout.write("No runes configured. Run `crunes create <key>` to add one.\n");
63
+ return;
64
+ }
65
+ if (format === "json") {
66
+ process.stdout.write(JSON.stringify(entries, null, 2) + "\n");
67
+ return;
68
+ }
69
+ const shownSource = ({ source, runtime }) => runtime ? `${source} (${runtime === "isolate" ? "isolate" : `${runtime}, native`})` : source;
70
+ if (plain) {
71
+ for (const { key, name, description, source, runtime, layer } of entries) {
72
+ process.stdout.write(`${key} ${name ?? ""} ${description ?? ""} ${shownSource({ source, runtime })} ${layer}
73
+ `);
74
+ }
75
+ return;
76
+ }
77
+ if (rootless) {
78
+ process.stdout.write("no project config \u2014 global only\n");
79
+ }
80
+ const table = new import_cli_table3.default({
81
+ head: ["Key", "Name", "Description", "Source", "Layer"],
82
+ style: { head: ["cyan"] }
83
+ });
84
+ for (const { key, name, description, source, runtime, layer } of entries) {
85
+ table.push([key, name ?? "", description ?? "", shownSource({ source, runtime }), layer]);
86
+ }
87
+ process.stdout.write(table.toString() + "\n");
88
+ }
89
+ export {
90
+ collectListRows,
91
+ handler
92
+ };
@@ -0,0 +1,62 @@
1
+ import {
2
+ isNativeRune
3
+ } from "./chunk-XDMMSZIL.js";
4
+ import {
5
+ loadConfig
6
+ } from "./chunk-2FI6KN3C.js";
7
+ import "./chunk-UBCAZGLE.js";
8
+ import {
9
+ loadRegistry
10
+ } from "./chunk-MTJ2KW3V.js";
11
+ import {
12
+ loadPluginJson
13
+ } from "./chunk-FIAFVIAN.js";
14
+ import "./chunk-VP7YLCQP.js";
15
+ import "./chunk-YKIKJHYO.js";
16
+ import "./chunk-2Q3KLBE6.js";
17
+ import "./chunk-55GTJG5I.js";
18
+ import {
19
+ init_require_shim
20
+ } from "./chunk-TPK5AGRA.js";
21
+
22
+ // src/plugin/commands/list.js
23
+ init_require_shim();
24
+ async function handler({ format = "md", projectRoot = process.cwd() } = {}) {
25
+ const registry = await loadRegistry();
26
+ const plugins = Object.entries(registry.plugins ?? {});
27
+ if (plugins.length === 0) {
28
+ console.log("No plugins installed.");
29
+ return;
30
+ }
31
+ if (format === "json") {
32
+ console.log(JSON.stringify(registry.plugins, null, 2));
33
+ return;
34
+ }
35
+ let enabledKeys = /* @__PURE__ */ new Set();
36
+ try {
37
+ const config = await loadConfig(projectRoot);
38
+ for (const [k, v] of Object.entries(config.plugins ?? {})) {
39
+ if (v) enabledKeys.add(k);
40
+ }
41
+ } catch {
42
+ }
43
+ for (const [key, entry] of plugins) {
44
+ const isEnabled = enabledKeys.has(key);
45
+ let hasNative = false;
46
+ try {
47
+ if (entry.path) {
48
+ const pj = await loadPluginJson(entry.path);
49
+ hasNative = Object.values(pj.runes ?? {}).some((r) => isNativeRune(r));
50
+ }
51
+ } catch {
52
+ }
53
+ const tags = [];
54
+ if (isEnabled) tags.push("[enabled]");
55
+ if (hasNative) tags.push("(native runes)");
56
+ const tagStr = tags.length ? ` ${tags.join(" ")}` : "";
57
+ console.log(`${key} v${entry.version}${tagStr}`);
58
+ }
59
+ }
60
+ export {
61
+ handler
62
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  listMarketplaces
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";
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  listSchemaCaches
3
- } from "./chunk-63H5VXZY.js";
3
+ } from "./chunk-UEUUOAJY.js";
4
+ import "./chunk-2Q3KLBE6.js";
4
5
  import {
5
6
  init_require_shim
6
7
  } from "./chunk-TPK5AGRA.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  listCacheBuckets,
3
3
  listLocalCacheBuckets
4
- } from "./chunk-NDEYEYSU.js";
4
+ } from "./chunk-WJII3LZK.js";
5
5
  import "./chunk-G4ZAUHHA.js";
6
- import "./chunk-6MRZXASS.js";
6
+ import "./chunk-2Q3KLBE6.js";
7
7
  import {
8
8
  init_require_shim
9
9
  } from "./chunk-TPK5AGRA.js";
@@ -1,7 +1,9 @@
1
1
  import {
2
2
  loadPluginJson,
3
3
  validatePluginJson
4
- } from "./chunk-G3U4V32O.js";
4
+ } from "./chunk-FIAFVIAN.js";
5
+ import "./chunk-VP7YLCQP.js";
6
+ import "./chunk-55GTJG5I.js";
5
7
  import "./chunk-TPK5AGRA.js";
6
8
  export {
7
9
  loadPluginJson,
@@ -0,0 +1,87 @@
1
+ import {
2
+ output
3
+ } from "./chunk-MIKWIFYR.js";
4
+ import "./chunk-CGZL5SSH.js";
5
+ import "./chunk-WCODTMDN.js";
6
+ import {
7
+ defaultRuneFile
8
+ } from "./chunk-2FI6KN3C.js";
9
+ import "./chunk-UBCAZGLE.js";
10
+ import "./chunk-VP7YLCQP.js";
11
+ import {
12
+ migrateEntry
13
+ } from "./chunk-YKIKJHYO.js";
14
+ import {
15
+ getStorePath
16
+ } from "./chunk-2Q3KLBE6.js";
17
+ import "./chunk-55GTJG5I.js";
18
+ import {
19
+ init_require_shim
20
+ } from "./chunk-TPK5AGRA.js";
21
+
22
+ // src/cli/commands/migrate.js
23
+ init_require_shim();
24
+ import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
25
+ import { join, isAbsolute, relative } from "node:path";
26
+ function migrateRunes(runes, base, defaultFileFor) {
27
+ const changed = [];
28
+ const renames = [];
29
+ for (const [key, entry] of Object.entries(runes ?? {})) {
30
+ const rewritten = migrateEntry(entry, { base, defaultFile: defaultFileFor(key) });
31
+ if (!rewritten) continue;
32
+ runes[key] = rewritten.entry;
33
+ changed.push(key);
34
+ renames.push(...rewritten.renames.map((r) => ({
35
+ from: isAbsolute(r.from) ? r.from : join(base, r.from),
36
+ to: isAbsolute(r.to) ? r.to : join(base, r.to)
37
+ })));
38
+ }
39
+ return { changed, renames };
40
+ }
41
+ function readJson(file) {
42
+ return JSON.parse(readFileSync(file, "utf8"));
43
+ }
44
+ function planMigration({ configRoot, global = false }) {
45
+ const files = [];
46
+ const layers = global ? [{ file: join(getStorePath(), "config.json"), base: getStorePath(), layer: "global" }] : [
47
+ { file: join(configRoot, ".crunes", "config.json"), base: configRoot, layer: "project" },
48
+ { file: join(configRoot, ".crunes", "config.local.json"), base: configRoot, layer: "local" }
49
+ ];
50
+ const declared = /* @__PURE__ */ new Set();
51
+ for (const { file, base, layer } of layers) {
52
+ if (!existsSync(file)) continue;
53
+ const json = readJson(file);
54
+ const { changed, renames } = migrateRunes(json.runes, base, (key) => declared.has(key) ? null : defaultRuneFile(key, layer));
55
+ for (const key of Object.keys(json.runes ?? {})) declared.add(key);
56
+ if (changed.length) files.push({ file, json, changed, renames });
57
+ }
58
+ return files;
59
+ }
60
+ async function handler({ configRoot, global = false, dryRun = false }) {
61
+ const plan = planMigration({ configRoot, global });
62
+ const shown = (file) => relative(process.cwd(), file).replace(/\\/g, "/") || file;
63
+ if (plan.length === 0) {
64
+ output.success("Nothing to migrate \u2014 every entry already uses run and repl blocks.");
65
+ return;
66
+ }
67
+ const renames = /* @__PURE__ */ new Map();
68
+ for (const { file, json, changed, renames: needed } of plan) {
69
+ output.info(`${shown(file)}: ${changed.length} entr${changed.length === 1 ? "y" : "ies"} rewritten (${changed.join(", ")})`);
70
+ if (dryRun) output.info(JSON.stringify({ runes: Object.fromEntries(changed.map((k) => [k, json.runes[k]])) }, null, 2));
71
+ for (const r of needed) renames.set(r.from, r.to);
72
+ }
73
+ for (const [from, to] of renames) {
74
+ const state = !existsSync(from) ? " (not found \u2014 skipped)" : existsSync(to) ? " (target exists \u2014 skipped)" : "";
75
+ output.info(`rename ${shown(from)} \u2192 ${shown(to)}${state}`);
76
+ }
77
+ if (dryRun) return;
78
+ for (const { file, json } of plan) writeFileSync(file, JSON.stringify(json, null, 2) + "\n");
79
+ for (const [from, to] of renames) {
80
+ if (existsSync(from) && !existsSync(to)) renameSync(from, to);
81
+ }
82
+ output.success("Migrated. Rename the modules in version control too if it does not track renames.");
83
+ }
84
+ export {
85
+ handler,
86
+ planMigration
87
+ };
@@ -1,12 +1,15 @@
1
1
  import {
2
2
  configure,
3
+ isPlain,
3
4
  isVerbose,
4
5
  output
5
- } from "./chunk-6XLT25GS.js";
6
+ } from "./chunk-MIKWIFYR.js";
7
+ import "./chunk-CGZL5SSH.js";
6
8
  import "./chunk-WCODTMDN.js";
7
9
  import "./chunk-TPK5AGRA.js";
8
10
  export {
9
11
  configure,
12
+ isPlain,
10
13
  isVerbose,
11
14
  output
12
15
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  querySqliteDb
3
- } from "./chunk-J3GZ3DXD.js";
3
+ } from "./chunk-GVMT55GH.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";
@@ -5,8 +5,8 @@ import {
5
5
  resolvePluginKey,
6
6
  resolvePluginKeyScoped,
7
7
  saveRegistry
8
- } from "./chunk-GTCPZ22N.js";
9
- import "./chunk-6MRZXASS.js";
8
+ } from "./chunk-MTJ2KW3V.js";
9
+ import "./chunk-2Q3KLBE6.js";
10
10
  import "./chunk-TPK5AGRA.js";
11
11
  export {
12
12
  loadRegistry,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  removeMarketplace
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";
@@ -167,12 +167,16 @@ When \`--format jsonl\` is active and stdin is not a TTY, each stdin line is par
167
167
  \`\`\`jsonl
168
168
  {"type":"line","text":"SELECT 1"}
169
169
  {"type":"line","text":"SELECT *\\nFROM books\\nWHERE genre = 'Sci-Fi'"}
170
+ {"type":"command","text":"/schema books"}
171
+ {"type":"command","args":{"$command":"schema","table":"books"}}
170
172
  {"type":"interrupt"}
171
173
  {"type":"eof"}
172
174
  \`\`\`
173
175
 
174
176
  Multi-line text is encoded as \`\\n\` in the JSON string \u2014 no Ctrl+Enter needed. Invalid JSON or unrecognised \`type\` values emit a \`{ type: "error" }\` JSONL output line and are skipped; the session continues.
175
177
 
178
+ Programmatic callers can use \`session.writeCommand('/schema books')\` or \`session.writeCommand('schema', { table: 'books' })\` to dispatch commands.
179
+
176
180
  `);
177
181
  }
178
182
  export {
@@ -1,29 +1,43 @@
1
1
  import {
2
- formatSection,
3
- parseSegment
4
- } from "./chunk-BTIPUR5S.js";
2
+ parseSegment,
3
+ permissionHint
4
+ } from "./chunk-KUEMDPNG.js";
5
5
  import {
6
- loadConfig
7
- } from "./chunk-GSA432UC.js";
8
- import {
9
- isGlobMatch,
10
- parseArgs,
11
6
  tailStdin
12
- } from "./chunk-WJRZN7BR.js";
13
- import "./chunk-J3GZ3DXD.js";
14
- import "./chunk-ZJDKCC2Y.js";
15
- import "./chunk-NDEYEYSU.js";
16
- import "./chunk-G4ZAUHHA.js";
17
- import "./chunk-63H5VXZY.js";
18
- import "./chunk-ASZKAC24.js";
7
+ } from "./chunk-EO3CSXWK.js";
19
8
  import {
20
9
  isVerbose,
21
10
  output
22
- } from "./chunk-6XLT25GS.js";
11
+ } from "./chunk-MIKWIFYR.js";
12
+ import "./chunk-CGZL5SSH.js";
23
13
  import "./chunk-WCODTMDN.js";
24
- import "./chunk-GTCPZ22N.js";
25
- import "./chunk-6MRZXASS.js";
26
- import "./chunk-G3U4V32O.js";
14
+ import {
15
+ describeConfigLayers
16
+ } from "./chunk-H2OT7D6N.js";
17
+ import {
18
+ formatSection
19
+ } from "./chunk-DTOYFY3Z.js";
20
+ import "./chunk-2DNYVKBF.js";
21
+ import "./chunk-XDMMSZIL.js";
22
+ import {
23
+ loadConfig
24
+ } from "./chunk-2FI6KN3C.js";
25
+ import "./chunk-UBCAZGLE.js";
26
+ import "./chunk-MTJ2KW3V.js";
27
+ import "./chunk-FIAFVIAN.js";
28
+ import "./chunk-VP7YLCQP.js";
29
+ import "./chunk-YKIKJHYO.js";
30
+ import {
31
+ isGlobMatch
32
+ } from "./chunk-MVCBPI4J.js";
33
+ import "./chunk-GVMT55GH.js";
34
+ import "./chunk-2HM5Q52B.js";
35
+ import "./chunk-WJII3LZK.js";
36
+ import "./chunk-G4ZAUHHA.js";
37
+ import "./chunk-2Q3KLBE6.js";
38
+ import {
39
+ parseArgs
40
+ } from "./chunk-55GTJG5I.js";
27
41
  import {
28
42
  init_require_shim
29
43
  } from "./chunk-TPK5AGRA.js";
@@ -57,15 +71,54 @@ function parseJsonlInputLine(text) {
57
71
  if (!parsed || !VALID_INPUT_TYPES.has(parsed.type)) return null;
58
72
  return parsed;
59
73
  }
60
- function parseSlashCommand(line) {
74
+ function parseSlashCommand(line, requireSlash = true) {
61
75
  const trimmed = line.trim();
62
- if (!trimmed.startsWith("/")) return null;
63
- const spaceIdx = trimmed.indexOf(" ");
64
- const name = spaceIdx === -1 ? trimmed.slice(1) : trimmed.slice(1, spaceIdx);
65
- const rest = spaceIdx === -1 ? "" : trimmed.slice(spaceIdx + 1).trim();
76
+ if (requireSlash && !trimmed.startsWith("/")) return null;
77
+ const raw = trimmed.startsWith("/") ? trimmed.slice(1) : trimmed;
78
+ const spaceIdx = raw.indexOf(" ");
79
+ const name = spaceIdx === -1 ? raw : raw.slice(0, spaceIdx);
80
+ const rest = spaceIdx === -1 ? "" : raw.slice(spaceIdx + 1).trim();
66
81
  if (!name) return null;
67
82
  return { name, rest };
68
83
  }
84
+ function resolveCommandEvent(event, commandsSchema) {
85
+ if (event.type !== "command") return event;
86
+ if (event.args && typeof event.args === "object") {
87
+ const args = { ...event.args };
88
+ if (event.name && !args.$command) args.$command = event.name;
89
+ if (!args.$command) args.$command = "";
90
+ if (!args.$commands) args.$commands = args.$command ? [args.$command] : [];
91
+ return { type: "command", args };
92
+ }
93
+ if (typeof event.text === "string") {
94
+ const slash = parseSlashCommand(event.text, false);
95
+ if (!slash) return { type: "command", args: { $command: "", $commands: [], _: [], $rest: [], $raw: [] } };
96
+ if (slash.name === "exit") return { type: "eof", text: "" };
97
+ if (commandsSchema?.commands?.some((c) => c.name === slash.name)) {
98
+ const cmdSchema = {
99
+ commands: commandsSchema.commands,
100
+ options: [],
101
+ positionals: [],
102
+ examples: []
103
+ };
104
+ const cmdTokens2 = slash.rest ? [slash.name, ...slash.rest.split(/\s+/)] : [slash.name];
105
+ const parsedCmdArgs2 = parseArgs(cmdTokens2, cmdSchema);
106
+ return { type: "command", args: parsedCmdArgs2 };
107
+ }
108
+ const cmdTokens = slash.rest ? [slash.name, ...slash.rest.split(/\s+/)] : [slash.name];
109
+ const parsedCmdArgs = parseArgs(cmdTokens, null);
110
+ parsedCmdArgs.$command = slash.name;
111
+ parsedCmdArgs.$commands = [slash.name];
112
+ return { type: "command", args: parsedCmdArgs };
113
+ }
114
+ if (typeof event.name === "string") {
115
+ return {
116
+ type: "command",
117
+ args: { $command: event.name, $commands: [event.name], _: [], $rest: [], $raw: [event.name] }
118
+ };
119
+ }
120
+ return event;
121
+ }
69
122
  function parseReplArgs(argv) {
70
123
  let format = "text";
71
124
  let i = 0;
@@ -104,12 +157,12 @@ async function handler({
104
157
  output.info("Run `crunes init` to create a config file.");
105
158
  process.exit(1);
106
159
  }
107
- const { resolveRuneEntry } = await import("./resolver-36V72VKR.js");
160
+ const { resolveRuneEntry } = await import("./resolver-CA2A32AC.js");
108
161
  let runeEntry;
109
162
  try {
110
163
  runeEntry = await resolveRuneEntry(projectRoot, config, key, configRoot);
111
164
  } catch (err) {
112
- output.error(`Rune "${key}" not found: ${err.message}`);
165
+ output.error(`Cannot start a REPL for "${key}": ${err.message}`);
113
166
  process.exit(1);
114
167
  }
115
168
  const instanceId = "1";
@@ -141,7 +194,12 @@ async function handler({
141
194
  session = await runeEntry.createReplSession(runeArgs, { onEvent, instanceId });
142
195
  } catch (err) {
143
196
  const msg = isVerbose ? err.stack || err.message : err.message;
144
- output.error(`Failed to start REPL for "${key}": ${msg}`);
197
+ const hint = permissionHint(err.message, {
198
+ key,
199
+ lifecycle: "repl",
200
+ configLayers: describeConfigLayers(configRoot)
201
+ });
202
+ output.error(`Failed to start REPL for "${key}": ${msg}${hint ?? ""}`);
145
203
  process.exit(1);
146
204
  }
147
205
  if (format === "jsonl") {
@@ -182,7 +240,12 @@ async function handler({
182
240
  if (format === "jsonl") {
183
241
  process.stdout.write(JSON.stringify({ type: "error", rune: key, instance: instanceId, message: msg }) + "\n");
184
242
  } else {
185
- process.stderr.write(`Error: ${msg}
243
+ const hint = permissionHint(err.message, {
244
+ key,
245
+ lifecycle: "repl",
246
+ configLayers: describeConfigLayers(configRoot)
247
+ });
248
+ process.stderr.write(`Error: ${msg}${hint ?? ""}
186
249
  `);
187
250
  }
188
251
  prompt();
@@ -216,7 +279,10 @@ async function handler({
216
279
  if (sessionEnded) return;
217
280
  if (jsonlInput) {
218
281
  const event = parseJsonlInputLine(line);
219
- if (event) await handleInputEvent(event);
282
+ if (event) {
283
+ const resolved = resolveCommandEvent(event, session.commandsSchema);
284
+ await handleInputEvent(resolved);
285
+ }
220
286
  } else {
221
287
  await handleInputEvent({ type: "line", text: line });
222
288
  }
@@ -321,7 +387,8 @@ async function handler({
321
387
  process.stdout.write(JSON.stringify({ type: "error", rune: key, instance: instanceId, message: `Invalid JSONL input: ${text}` }) + "\n");
322
388
  return;
323
389
  }
324
- await handleInputEvent(event);
390
+ const resolved = resolveCommandEvent(event, session.commandsSchema);
391
+ await handleInputEvent(resolved);
325
392
  return;
326
393
  }
327
394
  const slash = parseSlashCommand(text);
@@ -374,5 +441,6 @@ export {
374
441
  parseJsonlInputLine,
375
442
  parseReplArgs,
376
443
  parseReplReturn,
377
- parseSlashCommand
444
+ parseSlashCommand,
445
+ resolveCommandEvent
378
446
  };
@@ -0,0 +1,36 @@
1
+ import {
2
+ describeConfigLayers,
3
+ resolvePluginRune,
4
+ resolveRuneEntry,
5
+ resolveRuneFromPlugins,
6
+ runRune
7
+ } from "./chunk-H2OT7D6N.js";
8
+ import "./chunk-DTOYFY3Z.js";
9
+ import "./chunk-2DNYVKBF.js";
10
+ import "./chunk-XDMMSZIL.js";
11
+ import {
12
+ getRune,
13
+ normaliseRune
14
+ } from "./chunk-2FI6KN3C.js";
15
+ import "./chunk-UBCAZGLE.js";
16
+ import "./chunk-MTJ2KW3V.js";
17
+ import "./chunk-FIAFVIAN.js";
18
+ import "./chunk-VP7YLCQP.js";
19
+ import "./chunk-YKIKJHYO.js";
20
+ import "./chunk-MVCBPI4J.js";
21
+ import "./chunk-GVMT55GH.js";
22
+ import "./chunk-2HM5Q52B.js";
23
+ import "./chunk-WJII3LZK.js";
24
+ import "./chunk-G4ZAUHHA.js";
25
+ import "./chunk-2Q3KLBE6.js";
26
+ import "./chunk-55GTJG5I.js";
27
+ import "./chunk-TPK5AGRA.js";
28
+ export {
29
+ describeConfigLayers,
30
+ getRune,
31
+ normaliseRune,
32
+ resolvePluginRune,
33
+ resolveRuneEntry,
34
+ resolveRuneFromPlugins,
35
+ runRune
36
+ };
@@ -0,0 +1,35 @@
1
+ import {
2
+ handler,
3
+ joinBracketTokens,
4
+ parseBracketKey,
5
+ parseRunArgs,
6
+ parseSegment
7
+ } from "./chunk-KUEMDPNG.js";
8
+ import "./chunk-MIKWIFYR.js";
9
+ import "./chunk-CGZL5SSH.js";
10
+ import "./chunk-WCODTMDN.js";
11
+ import "./chunk-H2OT7D6N.js";
12
+ import "./chunk-DTOYFY3Z.js";
13
+ import "./chunk-2DNYVKBF.js";
14
+ import "./chunk-XDMMSZIL.js";
15
+ import "./chunk-2FI6KN3C.js";
16
+ import "./chunk-UBCAZGLE.js";
17
+ import "./chunk-MTJ2KW3V.js";
18
+ import "./chunk-FIAFVIAN.js";
19
+ import "./chunk-VP7YLCQP.js";
20
+ import "./chunk-YKIKJHYO.js";
21
+ import "./chunk-MVCBPI4J.js";
22
+ import "./chunk-GVMT55GH.js";
23
+ import "./chunk-2HM5Q52B.js";
24
+ import "./chunk-WJII3LZK.js";
25
+ import "./chunk-G4ZAUHHA.js";
26
+ import "./chunk-2Q3KLBE6.js";
27
+ import "./chunk-55GTJG5I.js";
28
+ import "./chunk-TPK5AGRA.js";
29
+ export {
30
+ handler,
31
+ joinBracketTokens,
32
+ parseBracketKey,
33
+ parseRunArgs,
34
+ parseSegment
35
+ };