@darkrymit/crunes-cli 0.8.5 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{add-CBHWFGCA.js → add-IT3IHBPO.js} +2 -2
- package/dist/chunks/{apply-J4YICV6H.js → apply-YY7MIM64.js} +9 -9
- package/dist/chunks/{benchmark-AKKV7G32.js → benchmark-BQNMULOO.js} +17 -14
- package/dist/chunks/{browse-JZFU52ET.js → browse-PHMBDREQ.js} +2 -2
- package/dist/chunks/{chunk-6MRZXASS.js → chunk-2Q3KLBE6.js} +16 -0
- package/dist/chunks/{chunk-KII6KW5Z.js → chunk-34F4ZURL.js} +40 -37
- package/dist/chunks/{chunk-ZJDKCC2Y.js → chunk-4GJMCFR6.js} +6 -3
- package/dist/chunks/chunk-CY6C6ADU.js +2787 -0
- package/dist/chunks/{chunk-J3GZ3DXD.js → chunk-GVMT55GH.js} +3 -2
- package/dist/chunks/{chunk-JOAL437H.js → chunk-I6MHDUCW.js} +16 -1
- package/dist/chunks/{chunk-6XLT25GS.js → chunk-MIKWIFYR.js} +47 -0
- package/dist/chunks/chunk-MRNZFUXZ.js +70 -0
- package/dist/chunks/{chunk-T53L5CJW.js → chunk-PBGUKXT6.js} +2887 -1874
- package/dist/chunks/chunk-QYRF3R35.js +154 -0
- package/dist/chunks/{chunk-BTIPUR5S.js → chunk-SNC7AOT7.js} +78 -12
- package/dist/chunks/{chunk-63H5VXZY.js → chunk-UEUUOAJY.js} +4 -1
- package/dist/chunks/{chunk-GTCPZ22N.js → chunk-VST6HAB6.js} +1 -1
- package/dist/chunks/{chunk-NDEYEYSU.js → chunk-WJII3LZK.js} +4 -3
- package/dist/chunks/chunk-X7PZN73N.js +44 -0
- package/dist/chunks/{chunk-NYLRTAAA.js → chunk-YVN3VDRE.js} +1 -1
- package/dist/chunks/{chunk-WJRZN7BR.js → chunk-YXCHIMLW.js} +843 -3027
- package/dist/chunks/{clear-YBDIPEEH.js → clear-AT7HNUV4.js} +2 -2
- package/dist/chunks/{create-GPDE2YKL.js → create-ET6DT5ZE.js} +22 -18
- package/dist/chunks/{create-VYZRWRGQ.js → create-LM7U3CJS.js} +22 -18
- package/dist/chunks/{create-L6DJN4ME.js → create-TLPM7HJE.js} +3 -3
- package/dist/chunks/{delete-LNOYM5KG.js → delete-5R3WBLVD.js} +5 -5
- package/dist/chunks/{delete-E4TEBRPX.js → delete-GKYA2W5Z.js} +4 -2
- package/dist/chunks/{delete-C4UJ7X5K.js → delete-U4STA2QZ.js} +5 -5
- package/dist/chunks/disable-TNTEIAKO.js +39 -0
- package/dist/chunks/doctor-VXAQYMTR.js +101 -0
- package/dist/chunks/enable-GUQCB4CU.js +31 -0
- package/dist/chunks/{globals-H2WF344Y.js → globals-SNQFCHMP.js} +1 -1
- package/dist/chunks/{init-HU5OMHEH.js → init-PJSCFOC6.js} +14 -8
- package/dist/chunks/{install-FIYRMVLR.js → install-4YP7FALO.js} +18 -16
- package/dist/chunks/{intro-36OLGNYN.js → intro-SA7MWV3Z.js} +50 -8
- package/dist/chunks/{kill-2UG7PHUV.js → kill-TX3PC73P.js} +2 -1
- package/dist/chunks/list-7R6NASFI.js +92 -0
- package/dist/chunks/{list-4X3JFQGS.js → list-EHREZR6M.js} +2 -1
- package/dist/chunks/{list-U7PAYNAH.js → list-LC6HB3H3.js} +2 -2
- package/dist/chunks/{list-AIYNOPNZ.js → list-OMMZAQ23.js} +2 -2
- package/dist/chunks/{list-7VHJIUDX.js → list-U4EMHQZT.js} +2 -2
- package/dist/chunks/{list-PTAWQYWG.js → list-V7VVD5AG.js} +2 -1
- package/dist/chunks/{list-A5WVDBWF.js → list-VA73WPK6.js} +2 -2
- package/dist/chunks/{list-2JYMBMZC.js → list-WKNPZZOV.js} +5 -4
- package/dist/chunks/{output-RJ6JSNY7.js → output-QN5CVJ62.js} +4 -1
- package/dist/chunks/{query-AW7WYILM.js → query-2US3CPYT.js} +2 -2
- package/dist/chunks/{registry-RG34DPD7.js → registry-K5DV5NAK.js} +2 -2
- package/dist/chunks/{remove-QUH2D3S5.js → remove-BCFTF23J.js} +2 -2
- package/dist/chunks/{repl-STBZC4P2.js → repl-2YWTHUWT.js} +4 -0
- package/dist/chunks/{repl-BPEWARN7.js → repl-ZB3DIJ4K.js} +84 -26
- package/dist/chunks/resolver-QIYYFIDX.js +34 -0
- package/dist/chunks/run-22B65ZWZ.js +29 -0
- package/dist/chunks/rune-SYK4N642.js +425 -0
- package/dist/chunks/{search-MSSDGJTF.js → search-B7IM7JRJ.js} +2 -2
- package/dist/chunks/shell-explain-QLITLHW7.js +74 -0
- package/dist/chunks/{uninstall-G56DZRFG.js → uninstall-4WR5IHLC.js} +15 -11
- package/dist/chunks/{unset-YASSMSE5.js → unset-P6IUF7SS.js} +2 -2
- package/dist/chunks/{update-KSC6VRMU.js → update-ACLDK6E6.js} +19 -18
- package/dist/chunks/{update-EWWDROKW.js → update-WXT7CHYA.js} +2 -2
- package/dist/chunks/{utils-3SJFSUSV.js → utils-B2QULX5J.js} +8 -4
- package/dist/chunks/{version-YG2M7HER.js → version-EULYWNXN.js} +2 -2
- package/dist/cli.js +92 -64
- package/package.json +1 -1
- package/dist/chunks/chunk-ASZKAC24.js +0 -103
- package/dist/chunks/chunk-GSA432UC.js +0 -90
- package/dist/chunks/disable-FGJ7VMPO.js +0 -47
- package/dist/chunks/doctor-7NWBJAH7.js +0 -53
- package/dist/chunks/enable-ZL6QOC2I.js +0 -47
- package/dist/chunks/list-NZ5DHXJF.js +0 -111
- package/dist/chunks/resolver-36V72VKR.js +0 -28
- package/dist/chunks/run-IVL23SMW.js +0 -26
- package/dist/chunks/rune-XRREUL56.js +0 -186
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
utils_api_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PBGUKXT6.js";
|
|
4
4
|
import {
|
|
5
5
|
formatNode,
|
|
6
6
|
walk
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-I6MHDUCW.js";
|
|
8
8
|
import {
|
|
9
9
|
output
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-MIKWIFYR.js";
|
|
11
|
+
import "./chunk-CGZL5SSH.js";
|
|
11
12
|
import "./chunk-WCODTMDN.js";
|
|
12
13
|
import {
|
|
13
14
|
init_require_shim
|
|
@@ -16,10 +17,13 @@ import {
|
|
|
16
17
|
// src/docs/commands/utils.js
|
|
17
18
|
init_require_shim();
|
|
18
19
|
var ALL_NAMESPACES = walk(utils_api_default);
|
|
20
|
+
function summarize(description) {
|
|
21
|
+
return (description ?? "").split(/\n\s*\n/)[0].replace(/\s+/g, " ").trim();
|
|
22
|
+
}
|
|
19
23
|
function formatIndex(namespaces) {
|
|
20
24
|
const lines = ["Available utils namespaces:", ""];
|
|
21
25
|
for (const ns of namespaces) {
|
|
22
|
-
lines.push(` ${ns.name} ${ns.description
|
|
26
|
+
lines.push(` ${ns.name} ${summarize(ns.description)}`.trimEnd());
|
|
23
27
|
}
|
|
24
28
|
return lines.join("\n");
|
|
25
29
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-WCODTMDN.js";
|
|
4
4
|
import {
|
|
5
5
|
getStorePath
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2Q3KLBE6.js";
|
|
7
7
|
import {
|
|
8
8
|
init_require_shim
|
|
9
9
|
} 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.9.0",
|
|
20
20
|
description: "CLI tool for querying crunes enrichers",
|
|
21
21
|
type: "module",
|
|
22
22
|
bin: {
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
configure
|
|
4
|
-
} from "./chunks/chunk-
|
|
4
|
+
} from "./chunks/chunk-MIKWIFYR.js";
|
|
5
|
+
import "./chunks/chunk-CGZL5SSH.js";
|
|
5
6
|
import "./chunks/chunk-WCODTMDN.js";
|
|
6
7
|
import {
|
|
7
8
|
init_require_shim
|
|
@@ -3396,7 +3397,7 @@ var program = new Command();
|
|
|
3396
3397
|
// src/cli/program.js
|
|
3397
3398
|
function buildProgram() {
|
|
3398
3399
|
const program3 = new Command();
|
|
3399
|
-
program3.name("crunes").description("CLI tool for managing context runes").version("0.
|
|
3400
|
+
program3.name("crunes").description("CLI tool for managing context runes").version("0.9.0", "-v, --version").enablePositionalOptions().option("-y, --yes", "assume yes to all prompts and skip interactive mode (also auto-detected in non-TTY environments)").option("-p, --plain", "plain output: no colors, no box-drawing, plain symbols \u2014 optimised for AI/pipe use").option("--cwd <path>", "project root to use instead of the current working directory").option("--ccd <path>", "config directory \u2014 where .crunes/config.json and local rune files live (default: --cwd)").option("--verbose", "print full error stack traces and other verbose output");
|
|
3400
3401
|
program3.hook("preAction", (_thisCommand, actionCommand) => {
|
|
3401
3402
|
configure({ plain: !!program3.opts().plain, verbose: !!program3.opts().verbose });
|
|
3402
3403
|
if (program3.opts().verbose) {
|
|
@@ -3415,7 +3416,7 @@ function buildProgram() {
|
|
|
3415
3416
|
"after",
|
|
3416
3417
|
'\nImportant: Global flags (e.g. --cwd) MUST appear before the "run" command.\n\nSyntax:\n [run-flags] <key>[-s s1,s2] [rune-args...]\n -b [run-flags] <key1>[-s s1] [rune-args1] + <key2>[-s s2] [rune-args2]\n\nCommand flags:\n -b, --batch enable batching multiple runes with +\n --format text|jsonl output format (default: text)\n --fail-fast stop on first error\n\nPer-rune bracket flags (inside key[...]):\n -s, --section s1,s2 filter output sections for this rune\n\nKey prefixes:\n project:name resolve from project config only\n plugin:name resolve directly from an enabled plugin\n name auto-resolve: project config first, then plugins\n\nFor rune argument documentation: crunes docs rune <key>'
|
|
3417
3418
|
).allowUnknownOption().passThroughOptions().action(async (args, _opts, _command) => {
|
|
3418
|
-
const { handler, parseRunArgs } = await import("./chunks/run-
|
|
3419
|
+
const { handler, parseRunArgs } = await import("./chunks/run-22B65ZWZ.js");
|
|
3419
3420
|
const { segments, format, failFast, isBatch } = parseRunArgs(args);
|
|
3420
3421
|
await handler({ segments, format, failFast, isBatch, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3421
3422
|
});
|
|
@@ -3423,25 +3424,28 @@ function buildProgram() {
|
|
|
3423
3424
|
"after",
|
|
3424
3425
|
'\nImportant: Global flags (e.g. --cwd) MUST appear before the "repl" command.\n\nSyntax:\n [--format text|jsonl] <key>[-s s1,s2] [rune-args...]\n\nPer-rune bracket flags (inside key[...]):\n -s, --section s1,s2 filter output sections for this rune\n\nThe rune must export repl(args) and/or inputRepl(input).\nFor rune argument documentation: crunes docs rune <key>'
|
|
3425
3426
|
).allowUnknownOption().passThroughOptions().action(async (args, _opts, _command) => {
|
|
3426
|
-
const { handler, parseReplArgs } = await import("./chunks/repl-
|
|
3427
|
+
const { handler, parseReplArgs } = await import("./chunks/repl-ZB3DIJ4K.js");
|
|
3427
3428
|
const { key, runeArgs, sections, format } = parseReplArgs(args);
|
|
3428
3429
|
await handler({ key, runeArgs, sections, format, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3429
3430
|
});
|
|
3430
3431
|
const helpGroup = program3.command("docs").description("Show documentation for runes and other resources");
|
|
3431
|
-
helpGroup.command("rune
|
|
3432
|
-
|
|
3433
|
-
|
|
3432
|
+
helpGroup.command("rune [key] [path...]").description("Show a rune command index, or drill into one command").addHelpText(
|
|
3433
|
+
"after",
|
|
3434
|
+
"\n crunes docs rune index of every rune and its commands\n crunes docs rune <key> command index for one rune\n crunes docs rune <key> <cmd>... detail for one command path\n"
|
|
3435
|
+
).addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (key, path3, opts) => {
|
|
3436
|
+
const { handler } = await import("./chunks/rune-SYK4N642.js");
|
|
3437
|
+
await handler({ key, path: path3, format: opts.format, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3434
3438
|
});
|
|
3435
3439
|
helpGroup.command("utils [namespaces...]").description("Show function signatures and parameter docs for utils.* namespaces").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (namespaces, opts) => {
|
|
3436
|
-
const { handler } = await import("./chunks/utils-
|
|
3440
|
+
const { handler } = await import("./chunks/utils-B2QULX5J.js");
|
|
3437
3441
|
await handler({ namespaces, format: opts.format });
|
|
3438
3442
|
});
|
|
3439
3443
|
helpGroup.command("globals").description("Show injected sandbox globals and ES2020 builtins available in rune scripts").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (opts) => {
|
|
3440
|
-
const { handler } = await import("./chunks/globals-
|
|
3444
|
+
const { handler } = await import("./chunks/globals-SNQFCHMP.js");
|
|
3441
3445
|
await handler({ format: opts.format });
|
|
3442
3446
|
});
|
|
3443
|
-
helpGroup.command("intro").description("Generate a comprehensive introduction and
|
|
3444
|
-
const { handler } = await import("./chunks/intro-
|
|
3447
|
+
helpGroup.command("intro").description("Generate a comprehensive introduction to Crunes: rune anatomy, calling conventions, config, permissions and the full @utils API. Generic \u2014 for this project's own runes use `crunes list` and `crunes docs rune`").option("--out <path>", "output file path (defaults to stdout)").action(async (opts) => {
|
|
3448
|
+
const { handler } = await import("./chunks/intro-SA7MWV3Z.js");
|
|
3445
3449
|
await handler({ out: opts.out });
|
|
3446
3450
|
});
|
|
3447
3451
|
helpGroup.command("args").description("Show detailed documentation, conventions, and examples for the args(builder) export").action(async () => {
|
|
@@ -3453,7 +3457,7 @@ function buildProgram() {
|
|
|
3453
3457
|
await handler();
|
|
3454
3458
|
});
|
|
3455
3459
|
helpGroup.command("repl").description("Show detailed documentation, conventions, and examples for the repl(args) export").action(async () => {
|
|
3456
|
-
const { handler } = await import("./chunks/repl-
|
|
3460
|
+
const { handler } = await import("./chunks/repl-2YWTHUWT.js");
|
|
3457
3461
|
await handler();
|
|
3458
3462
|
});
|
|
3459
3463
|
helpGroup.command("args-repl").description("Show detailed documentation, conventions, and examples for the argsRepl(builder) export").action(async () => {
|
|
@@ -3477,154 +3481,159 @@ function buildProgram() {
|
|
|
3477
3481
|
await handler();
|
|
3478
3482
|
});
|
|
3479
3483
|
program3.command("version").description("Print the installed version and check for updates").option("--no-check", "skip the npm update check").action(async (opts) => {
|
|
3480
|
-
const { handler } = await import("./chunks/version-
|
|
3484
|
+
const { handler } = await import("./chunks/version-EULYWNXN.js");
|
|
3481
3485
|
await handler({ check: opts.check, plain: !!program3.opts().plain });
|
|
3482
3486
|
});
|
|
3483
3487
|
program3.command("doctor").description("Verify environment and project setup").action(async () => {
|
|
3484
|
-
const { handler } = await import("./chunks/doctor-
|
|
3488
|
+
const { handler } = await import("./chunks/doctor-VXAQYMTR.js");
|
|
3485
3489
|
await handler({ projectRoot: projectRoot() });
|
|
3486
3490
|
});
|
|
3487
3491
|
program3.command("bench [args...]").description("Time rune execution and report fast, ok, or slow.").addHelpText(
|
|
3488
3492
|
"after",
|
|
3489
3493
|
'\nImportant: Global flags (e.g. --cwd) MUST appear before the "bench" command.\n\nSyntax:\n [--runs <n>] [--warmup] <key>[--runs <n>] [--warmup] [-s s1,s2] [rune-args...]\n\nCommand flags:\n -b, --batch enable batching multiple runes with +\n --format text|jsonl output format (default: text)\n --fail-fast stop on first error\n --runs <n> default number of runs for all runes (default: 1)\n --warmup default warmup run for all runes\n\nPer-rune bracket flags (inside key[...]):\n --runs <n> override run count for this rune\n --warmup override warmup for this rune\n -s, --section s1,s2 filter output sections for this rune'
|
|
3490
3494
|
).allowUnknownOption().passThroughOptions().action(async (args, _opts, _command) => {
|
|
3491
|
-
const { handler, parseBenchArgs } = await import("./chunks/benchmark-
|
|
3495
|
+
const { handler, parseBenchArgs } = await import("./chunks/benchmark-BQNMULOO.js");
|
|
3492
3496
|
const parsed = parseBenchArgs(args);
|
|
3493
3497
|
if (!parsed.segments[0]?.key) {
|
|
3494
|
-
const { output } = await import("./chunks/output-
|
|
3498
|
+
const { output } = await import("./chunks/output-QN5CVJ62.js");
|
|
3495
3499
|
output.error("Missing required argument: <rune>");
|
|
3496
3500
|
process.exit(1);
|
|
3497
3501
|
}
|
|
3498
3502
|
await handler({ ...parsed, plain: !!program3.opts().plain, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3499
3503
|
});
|
|
3500
|
-
program3.command("list").description("List all registered runes").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (opts) => {
|
|
3501
|
-
const { handler } = await import("./chunks/list-
|
|
3502
|
-
await handler({ format: opts.format, plain: !!program3.opts().plain, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3504
|
+
program3.command("list").description("List all registered runes").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).option("-g, --global", "list only runes from the global config (~/.crunes/config.json)").action(async (opts) => {
|
|
3505
|
+
const { handler } = await import("./chunks/list-7R6NASFI.js");
|
|
3506
|
+
await handler({ format: opts.format, plain: !!program3.opts().plain, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
|
|
3503
3507
|
});
|
|
3504
3508
|
const jobs = program3.command("job").description("Manage background jobs");
|
|
3505
3509
|
jobs.command("list").description("List background jobs for the current project").action(async () => {
|
|
3506
|
-
const { handler } = await import("./chunks/list-
|
|
3510
|
+
const { handler } = await import("./chunks/list-EHREZR6M.js");
|
|
3507
3511
|
await handler({ projectDir: projectRoot() });
|
|
3508
3512
|
});
|
|
3509
3513
|
jobs.command("kill <id>").description("Send SIGTERM to a background job and remove its record").action(async (id) => {
|
|
3510
|
-
const { handler } = await import("./chunks/kill-
|
|
3514
|
+
const { handler } = await import("./chunks/kill-TX3PC73P.js");
|
|
3511
3515
|
await handler({ id, projectDir: projectRoot() });
|
|
3512
3516
|
});
|
|
3517
|
+
const shell = program3.command("shell").description("Inspect how commands are parsed and permission-checked");
|
|
3518
|
+
shell.command("explain <cmd>").description("Show the command positions and redirect targets a command resolves to").option("-s, --shell <mode>", "force a shell mode: 'bash' or 'cmd'").action(async (cmd, opts) => {
|
|
3519
|
+
const { handler } = await import("./chunks/shell-explain-QLITLHW7.js");
|
|
3520
|
+
await handler({ cmd, shellMode: opts.shell });
|
|
3521
|
+
});
|
|
3513
3522
|
const cache = program3.command("cache").description("Manage cache buckets");
|
|
3514
3523
|
cache.command("list").description("List cache buckets for the current project").option("-p, --plugin [pluginId]", "filter to plugin-related buckets; pass a value to match a specific plugin").action(async (opts) => {
|
|
3515
|
-
const { handler } = await import("./chunks/list-
|
|
3524
|
+
const { handler } = await import("./chunks/list-VA73WPK6.js");
|
|
3516
3525
|
await handler({ projectDir: projectRoot(), plugin: opts.plugin });
|
|
3517
3526
|
});
|
|
3518
3527
|
cache.command("clear <id>").description("Remove expired keys from a cache bucket").option("-p, --plugin [pluginId]", "filter to plugin-related buckets").action(async (id, opts) => {
|
|
3519
|
-
const { handler } = await import("./chunks/clear-
|
|
3528
|
+
const { handler } = await import("./chunks/clear-AT7HNUV4.js");
|
|
3520
3529
|
await handler({ id, projectDir: projectRoot(), plugin: opts.plugin });
|
|
3521
3530
|
});
|
|
3522
3531
|
cache.command("delete <id>").description("Delete a cache bucket directory and deregister it").option("-p, --plugin [pluginId]", "filter to plugin-related buckets").action(async (id, opts) => {
|
|
3523
|
-
const { handler } = await import("./chunks/delete-
|
|
3532
|
+
const { handler } = await import("./chunks/delete-5R3WBLVD.js");
|
|
3524
3533
|
await handler({ id, projectDir: projectRoot(), yes: !!program3.opts().yes, plugin: opts.plugin });
|
|
3525
3534
|
});
|
|
3526
3535
|
cache.command("unset <id> <key>").description("Remove a single key from a cache bucket").option("-p, --plugin [pluginId]", "filter to plugin-related buckets").action(async (id, key, opts) => {
|
|
3527
|
-
const { handler } = await import("./chunks/unset-
|
|
3536
|
+
const { handler } = await import("./chunks/unset-P6IUF7SS.js");
|
|
3528
3537
|
await handler({ id, key, projectDir: projectRoot(), plugin: opts.plugin });
|
|
3529
3538
|
});
|
|
3530
3539
|
const schema = program3.command("schema").description("Manage schema cache");
|
|
3531
3540
|
schema.command("list").description("List cached schemas for the current project").action(async () => {
|
|
3532
|
-
const { handler } = await import("./chunks/list-
|
|
3541
|
+
const { handler } = await import("./chunks/list-V7VVD5AG.js");
|
|
3533
3542
|
await handler({ projectDir: projectRoot() });
|
|
3534
3543
|
});
|
|
3535
3544
|
schema.command("delete <rune-key>").description("Delete cached schema files for a rune key").action(async (runeKey) => {
|
|
3536
|
-
const { handler } = await import("./chunks/delete-
|
|
3545
|
+
const { handler } = await import("./chunks/delete-GKYA2W5Z.js");
|
|
3537
3546
|
await handler({ runeKey, projectDir: projectRoot() });
|
|
3538
3547
|
});
|
|
3539
3548
|
const sqlite = program3.command("sqlite").description("Manage SQLite databases");
|
|
3540
3549
|
sqlite.command("list").description("List all registered SQLite databases").option("-p, --plugin [pluginId]", "filter to plugin-related databases; pass a value to match a specific plugin").action(async (opts) => {
|
|
3541
|
-
const { handler } = await import("./chunks/list-
|
|
3550
|
+
const { handler } = await import("./chunks/list-LC6HB3H3.js");
|
|
3542
3551
|
await handler({ projectDir: projectRoot(), plugin: opts.plugin });
|
|
3543
3552
|
});
|
|
3544
3553
|
sqlite.command("delete <id>").description("Delete a SQLite database file and deregister it").option("-p, --plugin [pluginId]", "filter to plugin-related databases").action(async (id, opts) => {
|
|
3545
|
-
const { handler } = await import("./chunks/delete-
|
|
3554
|
+
const { handler } = await import("./chunks/delete-U4STA2QZ.js");
|
|
3546
3555
|
await handler({ id, yes: !!program3.opts().yes, projectDir: projectRoot(), plugin: opts.plugin });
|
|
3547
3556
|
});
|
|
3548
3557
|
sqlite.command("query <id> <sql>").description("Run a SQL query against a registered SQLite database (readonly)").option("-p, --plugin [pluginId]", "filter to plugin-related databases").action(async (id, sql, opts) => {
|
|
3549
|
-
const { handler } = await import("./chunks/query-
|
|
3558
|
+
const { handler } = await import("./chunks/query-2US3CPYT.js");
|
|
3550
3559
|
await handler({ id, sql, projectDir: projectRoot(), plugin: opts.plugin });
|
|
3551
3560
|
});
|
|
3552
|
-
program3.command("init").description("Create .crunes/config.json in the current project").action(async () => {
|
|
3553
|
-
const { handler } = await import("./chunks/init-
|
|
3554
|
-
await handler({ yes: !!program3.opts().yes, projectRoot: projectRoot() });
|
|
3561
|
+
program3.command("init").description("Create .crunes/config.json in the current project").option("-g, --global", "operate on the global config (~/.crunes/config.json) instead of the project").action(async (opts) => {
|
|
3562
|
+
const { handler } = await import("./chunks/init-PJSCFOC6.js");
|
|
3563
|
+
await handler({ yes: !!program3.opts().yes, projectRoot: projectRoot(), global: !!opts.global });
|
|
3555
3564
|
});
|
|
3556
|
-
program3.command("create [new-rune]").description("Scaffold a new rune and register it in config").addOption(new Option("--format <format>", "rune output format").choices(["tree", "markdown"])).option("--path <path>", "file path for the rune (default: .crunes/runes/<key>.js)").option("--name <name>", "human-readable label shown in crunes list").option("--description <description>", "short description of what context this rune provides").action(async (key, opts) => {
|
|
3557
|
-
const { handler } = await import("./chunks/create-
|
|
3558
|
-
await handler({ key, format: opts.format, path: opts.path, name: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3565
|
+
program3.command("create [new-rune]").description("Scaffold a new rune and register it in config").addOption(new Option("--format <format>", "rune output format").choices(["tree", "markdown"])).option("--path <path>", "file path for the rune (default: .crunes/runes/<key>.js)").option("--name <name>", "human-readable label shown in crunes list").option("--description <description>", "short description of what context this rune provides").option("-g, --global", "operate on the global config (~/.crunes/config.json) instead of the project").action(async (key, opts) => {
|
|
3566
|
+
const { handler } = await import("./chunks/create-LM7U3CJS.js");
|
|
3567
|
+
await handler({ key, format: opts.format, path: opts.path, name: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
|
|
3559
3568
|
});
|
|
3560
3569
|
const plugin = program3.command("plugin").description("Manage rune plugins");
|
|
3561
|
-
plugin.command("install <source>").description("Install a plugin from a configured marketplace in the format <marketplace>@<plugin>").action(async (source) => {
|
|
3562
|
-
const { handler } = await import("./chunks/install-
|
|
3563
|
-
await handler({ source, projectRoot: projectRoot(), configRoot: configRoot(), yes: !!program3.opts().yes });
|
|
3570
|
+
plugin.command("install <source>").description("Install a plugin from a configured marketplace in the format <marketplace>@<plugin>").option("-g, --global", "enable in the global config (~/.crunes/config.json) instead of the project").action(async (source, opts) => {
|
|
3571
|
+
const { handler } = await import("./chunks/install-4YP7FALO.js");
|
|
3572
|
+
await handler({ source, projectRoot: projectRoot(), configRoot: configRoot(), yes: !!program3.opts().yes, global: !!opts.global });
|
|
3564
3573
|
});
|
|
3565
|
-
plugin.command("uninstall <plugin>").description("Uninstall an installed plugin").action(async (name) => {
|
|
3566
|
-
const { handler } = await import("./chunks/uninstall-
|
|
3567
|
-
await handler({ name, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3574
|
+
plugin.command("uninstall <plugin>").description("Uninstall an installed plugin").option("-g, --global", "also drop the plugin from the global config (~/.crunes/config.json)").action(async (name, opts) => {
|
|
3575
|
+
const { handler } = await import("./chunks/uninstall-4WR5IHLC.js");
|
|
3576
|
+
await handler({ name, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
|
|
3568
3577
|
});
|
|
3569
3578
|
plugin.command("list").description("List installed plugins").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (opts) => {
|
|
3570
|
-
const { handler } = await import("./chunks/list-
|
|
3579
|
+
const { handler } = await import("./chunks/list-OMMZAQ23.js");
|
|
3571
3580
|
await handler({ format: opts.format });
|
|
3572
3581
|
});
|
|
3573
3582
|
plugin.command("update [plugin]").description("Update one or all installed plugins").action(async (name) => {
|
|
3574
|
-
const { handler } = await import("./chunks/update-
|
|
3583
|
+
const { handler } = await import("./chunks/update-ACLDK6E6.js");
|
|
3575
3584
|
await handler({ name, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3576
3585
|
});
|
|
3577
|
-
plugin.command("enable <plugin>").description("Add a plugin to this project's enabled list").action(async (name) => {
|
|
3578
|
-
const { handler } = await import("./chunks/enable-
|
|
3579
|
-
await handler({ name, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3586
|
+
plugin.command("enable <plugin>").description("Add a plugin to this project's enabled list").option("-g, --global", "enable in the global config (~/.crunes/config.json), for every directory").action(async (name, opts) => {
|
|
3587
|
+
const { handler } = await import("./chunks/enable-GUQCB4CU.js");
|
|
3588
|
+
await handler({ name, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
|
|
3580
3589
|
});
|
|
3581
|
-
plugin.command("disable <plugin>").description("
|
|
3582
|
-
const { handler } = await import("./chunks/disable-
|
|
3583
|
-
await handler({ name, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3590
|
+
plugin.command("disable <plugin>").description("Turn a plugin off for this project, including one enabled globally").option("-g, --global", "disable in the global config (~/.crunes/config.json) instead of the project").action(async (name, opts) => {
|
|
3591
|
+
const { handler } = await import("./chunks/disable-TNTEIAKO.js");
|
|
3592
|
+
await handler({ name, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
|
|
3584
3593
|
});
|
|
3585
3594
|
plugin.command("create [new-plugin]").description("Scaffold a new plugin directory with all required files").option("--description <text>", "short description for plugin.json and marketplace.json").option("--author <name>", "author name (default: git config user.name)").option("--license <spdx>", "SPDX license identifier (default: MIT)").option("--out <path>", "output directory (default: ./<name>)").action(async (name, opts) => {
|
|
3586
|
-
const { handler } = await import("./chunks/create-
|
|
3595
|
+
const { handler } = await import("./chunks/create-TLPM7HJE.js");
|
|
3587
3596
|
await handler({ name, description: opts.description, author: opts.author, license: opts.license, out: opts.out, yes: !!program3.opts().yes, projectRoot: projectRoot() });
|
|
3588
3597
|
});
|
|
3589
3598
|
const template = program3.command("template").description("Manage rune templates");
|
|
3590
3599
|
template.command("list [template-source]").description('List available templates. [template-source] can be "project" (project config only) or a plugin name; omit to list all.').addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (source, opts) => {
|
|
3591
|
-
const { handler } = await import("./chunks/list-
|
|
3600
|
+
const { handler } = await import("./chunks/list-WKNPZZOV.js");
|
|
3592
3601
|
await handler({ source, format: opts.format, plain: !!program3.opts().plain, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3593
3602
|
});
|
|
3594
3603
|
template.command("apply <template>").description("Copy a template into the project as a new rune and register it in config.").addHelpText(
|
|
3595
3604
|
"after",
|
|
3596
3605
|
"\nKey prefixes:\n project:name \u2014 use a template defined in this project's config\n plugin:name \u2014 use a template from a specific installed plugin\n name \u2014 auto-resolve: project config first, then installed plugins"
|
|
3597
3606
|
).option("--as <new-rune>", "register the rune under a different key (default: template name)").option("--path <path>", "file path for the rune (default: .crunes/runes/<key>.js)").option("--name <name>", "human-readable label shown in crunes list").option("--description <description>", "short description of what context this rune provides").action(async (ref, opts) => {
|
|
3598
|
-
const { handler } = await import("./chunks/apply-
|
|
3607
|
+
const { handler } = await import("./chunks/apply-YY7MIM64.js");
|
|
3599
3608
|
await handler({ ref, key: opts.as, path: opts.path, name: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3600
3609
|
});
|
|
3601
|
-
template.command("create [new-template]").description("Scaffold a new template file and register it in config").option("--path <path>", "file path for the template (default: .crunes/templates/<name>.js)").option("--name <name>", "display label shown in crunes template list (separate from the template key)").option("--description <description>", "short description of what kind of rune this template produces").action(async (name, opts) => {
|
|
3602
|
-
const { handler } = await import("./chunks/create-
|
|
3603
|
-
await handler({ name, path: opts.path, templateName: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3610
|
+
template.command("create [new-template]").description("Scaffold a new template file and register it in config").option("--path <path>", "file path for the template (default: .crunes/templates/<name>.js)").option("--name <name>", "display label shown in crunes template list (separate from the template key)").option("--description <description>", "short description of what kind of rune this template produces").option("-g, --global", "operate on the global config (~/.crunes/config.json) instead of the project").action(async (name, opts) => {
|
|
3611
|
+
const { handler } = await import("./chunks/create-ET6DT5ZE.js");
|
|
3612
|
+
await handler({ name, path: opts.path, templateName: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
|
|
3604
3613
|
});
|
|
3605
3614
|
const marketplace = program3.command("marketplace").description("Manage plugin marketplace sources");
|
|
3606
3615
|
marketplace.command("add <url>").description("Add a marketplace source URL").action(async (url) => {
|
|
3607
|
-
const { handler } = await import("./chunks/add-
|
|
3616
|
+
const { handler } = await import("./chunks/add-IT3IHBPO.js");
|
|
3608
3617
|
await handler({ url });
|
|
3609
3618
|
});
|
|
3610
3619
|
marketplace.command("remove <url>").description("Remove a marketplace source URL").action(async (url) => {
|
|
3611
|
-
const { handler } = await import("./chunks/remove-
|
|
3620
|
+
const { handler } = await import("./chunks/remove-BCFTF23J.js");
|
|
3612
3621
|
await handler({ url });
|
|
3613
3622
|
});
|
|
3614
3623
|
marketplace.command("list").description("List configured marketplace sources").action(async () => {
|
|
3615
|
-
const { handler } = await import("./chunks/list-
|
|
3624
|
+
const { handler } = await import("./chunks/list-U4EMHQZT.js");
|
|
3616
3625
|
await handler();
|
|
3617
3626
|
});
|
|
3618
3627
|
marketplace.command("search <query>").description("Search for plugins across configured marketplace sources").action(async (query) => {
|
|
3619
|
-
const { handler } = await import("./chunks/search-
|
|
3628
|
+
const { handler } = await import("./chunks/search-B7IM7JRJ.js");
|
|
3620
3629
|
await handler({ query });
|
|
3621
3630
|
});
|
|
3622
3631
|
marketplace.command("update [url]").description("Refresh cached marketplace data (all sources if no URL given)").action(async (url) => {
|
|
3623
|
-
const { handler } = await import("./chunks/update-
|
|
3632
|
+
const { handler } = await import("./chunks/update-WXT7CHYA.js");
|
|
3624
3633
|
await handler({ url });
|
|
3625
3634
|
});
|
|
3626
3635
|
marketplace.command("browse").description("List all plugins from all configured marketplace sources").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (opts) => {
|
|
3627
|
-
const { handler } = await import("./chunks/browse-
|
|
3636
|
+
const { handler } = await import("./chunks/browse-PHMBDREQ.js");
|
|
3628
3637
|
await handler({ format: opts.format });
|
|
3629
3638
|
});
|
|
3630
3639
|
const completions = program3.command("completions").description("Manage shell tab-completions");
|
|
@@ -3646,9 +3655,9 @@ function buildProgram() {
|
|
|
3646
3655
|
});
|
|
3647
3656
|
completions.command("install <shell>").description(
|
|
3648
3657
|
"Append the completion hook for <shell> to your shell profile (idempotent).\n Supported: bash, zsh, fish, powershell\n Examples:\n crunes completions install bash # appends to ~/.bashrc\n crunes completions install zsh # appends to ~/.zshrc\n crunes completions install fish # appends to ~/.config/fish/config.fish\n crunes completions install powershell # appends to PowerShell $PROFILE"
|
|
3649
|
-
).action(async (
|
|
3658
|
+
).action(async (shell2) => {
|
|
3650
3659
|
const { installHandler } = await import("./chunks/completions-2MSEWWTG.js");
|
|
3651
|
-
await installHandler(
|
|
3660
|
+
await installHandler(shell2);
|
|
3652
3661
|
});
|
|
3653
3662
|
return program3;
|
|
3654
3663
|
}
|
|
@@ -3674,6 +3683,25 @@ if (hasCommand) {
|
|
|
3674
3683
|
const vIndex = process.argv.indexOf("-v");
|
|
3675
3684
|
if (vIndex !== -1) process.argv[vIndex] = "--verbose";
|
|
3676
3685
|
}
|
|
3686
|
+
var VALUED_GLOBALS = /* @__PURE__ */ new Set(["--cwd", "--ccd"]);
|
|
3687
|
+
var cmdIdx = 2;
|
|
3688
|
+
while (cmdIdx < process.argv.length && process.argv[cmdIdx].startsWith("-")) {
|
|
3689
|
+
const tok = process.argv[cmdIdx];
|
|
3690
|
+
cmdIdx += VALUED_GLOBALS.has(tok) ? 2 : 1;
|
|
3691
|
+
}
|
|
3692
|
+
if (cmdIdx < process.argv.length) {
|
|
3693
|
+
const name = process.argv[cmdIdx];
|
|
3694
|
+
const known = /* @__PURE__ */ new Set(["help"]);
|
|
3695
|
+
for (const c of program2.commands) {
|
|
3696
|
+
known.add(c.name());
|
|
3697
|
+
for (const a of c.aliases()) known.add(a);
|
|
3698
|
+
}
|
|
3699
|
+
if (!known.has(name)) {
|
|
3700
|
+
console.error(`error: unknown command '${name}'`);
|
|
3701
|
+
console.error(`Run 'crunes --help' for a list of commands.`);
|
|
3702
|
+
process.exit(1);
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3677
3705
|
program2.parseAsync(process.argv).catch((err) => {
|
|
3678
3706
|
console.error("[crunes] FATAL CLI ERROR:", err);
|
|
3679
3707
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_require_shim
|
|
3
|
-
} from "./chunk-TPK5AGRA.js";
|
|
4
|
-
|
|
5
|
-
// src/docs/formatter.js
|
|
6
|
-
init_require_shim();
|
|
7
|
-
function formatCommands(commands, depth = 0) {
|
|
8
|
-
const lines = [];
|
|
9
|
-
const indent = " ".repeat(depth + 1);
|
|
10
|
-
const childIndent = " ".repeat(depth + 2);
|
|
11
|
-
const detailIndent = " ".repeat(depth + 3);
|
|
12
|
-
for (const cmd of commands) {
|
|
13
|
-
const posSpecs = (cmd.positionals ?? []).map((p) => p.spec).join(" ");
|
|
14
|
-
const cmdStr = `${cmd.name}${posSpecs ? " " + posSpecs : ""}`;
|
|
15
|
-
lines.push(`${indent}${cmdStr.padEnd(30 - depth * 2)} ${cmd.description ?? ""}`.trimEnd());
|
|
16
|
-
const cmdPos = cmd.positionals ?? [];
|
|
17
|
-
if (cmdPos.length > 0) {
|
|
18
|
-
lines.push(`${childIndent}Positionals:`);
|
|
19
|
-
for (const p of cmdPos) {
|
|
20
|
-
lines.push(`${detailIndent}${p.spec.padEnd(26)} ${p.description ?? ""}`.trimEnd());
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const cmdOpts = cmd.options ?? [];
|
|
24
|
-
if (cmdOpts.length > 0) {
|
|
25
|
-
lines.push(`${childIndent}Options:`);
|
|
26
|
-
for (const opt of cmdOpts) {
|
|
27
|
-
const defStr = opt.def !== void 0 ? ` [default: ${JSON.stringify(opt.def)}]` : "";
|
|
28
|
-
lines.push(`${detailIndent}${opt.flags.padEnd(26)} ${opt.description ?? ""}${defStr}`.trimEnd());
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const cmdExs = cmd.examples ?? [];
|
|
32
|
-
if (cmdExs.length > 0) {
|
|
33
|
-
lines.push(`${childIndent}Examples:`);
|
|
34
|
-
for (const ex of cmdExs) {
|
|
35
|
-
lines.push(`${detailIndent}${ex.usage}`);
|
|
36
|
-
if (ex.description) lines.push(`${detailIndent} ${ex.description}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const nestedCmds = cmd.commands ?? [];
|
|
40
|
-
if (nestedCmds.length > 0) {
|
|
41
|
-
lines.push(`${childIndent}Commands:`);
|
|
42
|
-
lines.push(...formatCommands(nestedCmds, depth + 2));
|
|
43
|
-
}
|
|
44
|
-
lines.push("");
|
|
45
|
-
}
|
|
46
|
-
return lines;
|
|
47
|
-
}
|
|
48
|
-
function formatHelp(schema, runeMeta) {
|
|
49
|
-
const lines = [];
|
|
50
|
-
const key = runeMeta?.key ?? "rune";
|
|
51
|
-
const desc = runeMeta?.description ?? runeMeta?.name;
|
|
52
|
-
if (runeMeta?.relativePath) {
|
|
53
|
-
lines.push(`File (project-relative): ${runeMeta.relativePath}`);
|
|
54
|
-
lines.push("");
|
|
55
|
-
}
|
|
56
|
-
const hasCommands = (schema?.commands ?? []).length > 0;
|
|
57
|
-
const cmd = runeMeta?.lifecycle === "repl" ? "repl" : "run";
|
|
58
|
-
lines.push(`Usage: crunes ${cmd} ${key} ${hasCommands ? "<command> " : ""}[options]`);
|
|
59
|
-
if (desc) {
|
|
60
|
-
lines.push("");
|
|
61
|
-
lines.push(` ${desc}`);
|
|
62
|
-
}
|
|
63
|
-
const positionals = schema?.positionals ?? [];
|
|
64
|
-
if (positionals.length > 0) {
|
|
65
|
-
lines.push("");
|
|
66
|
-
for (const p of positionals) {
|
|
67
|
-
lines.push(` ${(p.spec ?? "").padEnd(20)} ${p.description ?? ""}`.trimEnd());
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const options = schema?.options ?? [];
|
|
71
|
-
if (options.length > 0) {
|
|
72
|
-
lines.push("");
|
|
73
|
-
lines.push("Options:");
|
|
74
|
-
for (const opt of options) {
|
|
75
|
-
const defStr = opt.def !== void 0 ? ` [default: ${JSON.stringify(opt.def)}]` : "";
|
|
76
|
-
lines.push(` ${opt.flags.padEnd(30)} ${opt.description ?? ""}${defStr}`.trimEnd());
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const commands = schema?.commands ?? [];
|
|
80
|
-
if (commands.length > 0) {
|
|
81
|
-
lines.push("");
|
|
82
|
-
lines.push("Commands:");
|
|
83
|
-
const cmdLines = formatCommands(commands, 0);
|
|
84
|
-
lines.push(...cmdLines);
|
|
85
|
-
if (lines[lines.length - 1] === "") {
|
|
86
|
-
lines.pop();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const examples = schema?.examples ?? [];
|
|
90
|
-
if (examples.length > 0) {
|
|
91
|
-
lines.push("");
|
|
92
|
-
lines.push("Examples:");
|
|
93
|
-
for (const ex of examples) {
|
|
94
|
-
lines.push(` ${ex.usage}`);
|
|
95
|
-
if (ex.description) lines.push(` ${ex.description}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return lines.join("\n");
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export {
|
|
102
|
-
formatHelp
|
|
103
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_require_shim
|
|
3
|
-
} from "./chunk-TPK5AGRA.js";
|
|
4
|
-
|
|
5
|
-
// src/core/config.js
|
|
6
|
-
init_require_shim();
|
|
7
|
-
import { readFileSync, existsSync } from "node:fs";
|
|
8
|
-
import { join } from "node:path";
|
|
9
|
-
function isObject(item) {
|
|
10
|
-
return item && typeof item === "object" && !Array.isArray(item);
|
|
11
|
-
}
|
|
12
|
-
function mergeConfigs(shared, local) {
|
|
13
|
-
const merged = { ...shared };
|
|
14
|
-
for (const [key, value] of Object.entries(local)) {
|
|
15
|
-
if (key !== "runes" && key !== "plugins") {
|
|
16
|
-
merged[key] = value;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (local.runes) {
|
|
20
|
-
merged.runes = { ...shared.runes };
|
|
21
|
-
for (const [key, localEntry] of Object.entries(local.runes)) {
|
|
22
|
-
const sharedEntry = shared.runes?.[key];
|
|
23
|
-
if (sharedEntry && isObject(sharedEntry) && isObject(localEntry)) {
|
|
24
|
-
merged.runes[key] = {
|
|
25
|
-
...sharedEntry,
|
|
26
|
-
...localEntry,
|
|
27
|
-
vars: { ...sharedEntry.vars, ...localEntry.vars }
|
|
28
|
-
};
|
|
29
|
-
} else {
|
|
30
|
-
merged.runes[key] = localEntry;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (local.plugins) {
|
|
35
|
-
const combined = [...shared.plugins ?? [], ...local.plugins ?? []];
|
|
36
|
-
merged.plugins = Array.from(new Set(combined));
|
|
37
|
-
}
|
|
38
|
-
return merged;
|
|
39
|
-
}
|
|
40
|
-
function validateConfig(config, fileName = "config.json") {
|
|
41
|
-
if (config.runes && typeof config.runes === "object") {
|
|
42
|
-
for (const [runeKey, entry] of Object.entries(config.runes)) {
|
|
43
|
-
if (entry && typeof entry === "object" && entry.permissions) {
|
|
44
|
-
const perms = entry.permissions;
|
|
45
|
-
if (Array.isArray(perms)) {
|
|
46
|
-
throw new Error(`${fileName}: runes["${runeKey}"].permissions must be lifecycle-scoped (e.g. permissions.run.allow)`);
|
|
47
|
-
}
|
|
48
|
-
if (perms && typeof perms === "object") {
|
|
49
|
-
if (Array.isArray(perms.allow) || Array.isArray(perms.deny)) {
|
|
50
|
-
throw new Error(`${fileName}: runes["${runeKey}"].permissions must be lifecycle-scoped (e.g. permissions.run.allow)`);
|
|
51
|
-
}
|
|
52
|
-
if (perms.run && typeof perms.run === "object" && Object.keys(perms.run).length === 0) {
|
|
53
|
-
console.warn(`[crunes:warn] ${fileName}: runes["${runeKey}"].permissions.run is empty. No extra permissions will be granted.`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (entry && typeof entry === "object" && !entry.path && !entry.plugin) {
|
|
58
|
-
const colonIdx = runeKey.indexOf(":");
|
|
59
|
-
if (colonIdx !== -1) {
|
|
60
|
-
const pluginPart = runeKey.slice(0, colonIdx);
|
|
61
|
-
if (!pluginPart.includes("@")) {
|
|
62
|
-
throw new Error(
|
|
63
|
-
`${fileName}: runes["${runeKey}"] has no path or plugin, so it can only be a plugin-rune override \u2014 but "${pluginPart}" is missing the marketplace prefix. Use the full "marketplace@plugin:${runeKey.slice(colonIdx + 1)}" form.`
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function loadConfig(dir) {
|
|
72
|
-
const configPath = join(dir, ".crunes", "config.json");
|
|
73
|
-
const localConfigPath = join(dir, ".crunes", "config.local.json");
|
|
74
|
-
const shared = JSON.parse(readFileSync(configPath, "utf8"));
|
|
75
|
-
validateConfig(shared, "config.json");
|
|
76
|
-
let local = {};
|
|
77
|
-
if (existsSync(localConfigPath)) {
|
|
78
|
-
try {
|
|
79
|
-
local = JSON.parse(readFileSync(localConfigPath, "utf8"));
|
|
80
|
-
} catch (err) {
|
|
81
|
-
throw new Error(`config.local.json is invalid JSON: ${err.message}`);
|
|
82
|
-
}
|
|
83
|
-
validateConfig(local, "config.local.json");
|
|
84
|
-
}
|
|
85
|
-
return mergeConfigs(shared, local);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export {
|
|
89
|
-
loadConfig
|
|
90
|
-
};
|