@darkrymit/crunes-cli 0.8.4 → 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-YC6JEPUN.js → apply-YY7MIM64.js} +13 -12
- package/dist/chunks/{benchmark-BJEAAFWG.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-2PBPDTRD.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-NAEVMRNA.js → chunk-PBGUKXT6.js} +2940 -1847
- package/dist/chunks/chunk-QYRF3R35.js +154 -0
- package/dist/chunks/{chunk-DZJRYFOP.js → chunk-SNC7AOT7.js} +78 -12
- package/dist/chunks/{chunk-63H5VXZY.js → chunk-UEUUOAJY.js} +4 -1
- package/dist/chunks/{chunk-65J65MAP.js → chunk-VST6HAB6.js} +16 -2
- 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-JU6FKUBY.js → chunk-YXCHIMLW.js} +995 -3097
- 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-OZACMPEU.js → create-LM7U3CJS.js} +28 -20
- package/dist/chunks/{create-ZFFV3Z2P.js → create-TLPM7HJE.js} +5 -5
- 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-RRLUOYFO.js → install-4YP7FALO.js} +18 -16
- package/dist/chunks/{intro-4CICBP2J.js → intro-SA7MWV3Z.js} +113 -43
- 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-FLAYJQKN.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-CK5X2YN3.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-3QIL5SVL.js → registry-K5DV5NAK.js} +4 -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-VGC5FUJG.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-55YTHZRH.js → uninstall-4WR5IHLC.js} +15 -11
- package/dist/chunks/{unset-YASSMSE5.js → unset-P6IUF7SS.js} +2 -2
- package/dist/chunks/{update-G6XO4RIM.js → update-ACLDK6E6.js} +19 -18
- package/dist/chunks/{update-EWWDROKW.js → update-WXT7CHYA.js} +2 -2
- package/dist/chunks/{utils-XOWJQWNR.js → utils-B2QULX5J.js} +8 -4
- package/dist/chunks/{version-PW7MHDFH.js → version-EULYWNXN.js} +3 -2
- package/dist/cli.js +93 -71
- package/package.json +2 -1
- package/dist/chunks/chunk-ASZKAC24.js +0 -103
- package/dist/chunks/chunk-H3BVJCIL.js +0 -105
- package/dist/chunks/disable-TMG2K3BF.js +0 -47
- package/dist/chunks/doctor-N43QEMAH.js +0 -53
- package/dist/chunks/enable-327OMBPC.js +0 -47
- package/dist/chunks/list-WH7KESMV.js +0 -111
- package/dist/chunks/resolver-QMIY33FM.js +0 -26
- package/dist/chunks/run-T33CMCFZ.js +0 -26
- package/dist/chunks/rune-UBRVWG5A.js +0 -139
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,32 +3424,29 @@ 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
|
|
3444
|
-
const { handler } = await import("./chunks/intro-
|
|
3445
|
-
await handler({
|
|
3446
|
-
global: !!opts.global,
|
|
3447
|
-
out: opts.out,
|
|
3448
|
-
format: opts.format,
|
|
3449
|
-
projectRoot: projectRoot(),
|
|
3450
|
-
configRoot: configRoot()
|
|
3451
|
-
});
|
|
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");
|
|
3449
|
+
await handler({ out: opts.out });
|
|
3452
3450
|
});
|
|
3453
3451
|
helpGroup.command("args").description("Show detailed documentation, conventions, and examples for the args(builder) export").action(async () => {
|
|
3454
3452
|
const { handler } = await import("./chunks/args-KBPMNKBI.js");
|
|
@@ -3459,7 +3457,7 @@ function buildProgram() {
|
|
|
3459
3457
|
await handler();
|
|
3460
3458
|
});
|
|
3461
3459
|
helpGroup.command("repl").description("Show detailed documentation, conventions, and examples for the repl(args) export").action(async () => {
|
|
3462
|
-
const { handler } = await import("./chunks/repl-
|
|
3460
|
+
const { handler } = await import("./chunks/repl-2YWTHUWT.js");
|
|
3463
3461
|
await handler();
|
|
3464
3462
|
});
|
|
3465
3463
|
helpGroup.command("args-repl").description("Show detailed documentation, conventions, and examples for the argsRepl(builder) export").action(async () => {
|
|
@@ -3483,154 +3481,159 @@ function buildProgram() {
|
|
|
3483
3481
|
await handler();
|
|
3484
3482
|
});
|
|
3485
3483
|
program3.command("version").description("Print the installed version and check for updates").option("--no-check", "skip the npm update check").action(async (opts) => {
|
|
3486
|
-
const { handler } = await import("./chunks/version-
|
|
3484
|
+
const { handler } = await import("./chunks/version-EULYWNXN.js");
|
|
3487
3485
|
await handler({ check: opts.check, plain: !!program3.opts().plain });
|
|
3488
3486
|
});
|
|
3489
3487
|
program3.command("doctor").description("Verify environment and project setup").action(async () => {
|
|
3490
|
-
const { handler } = await import("./chunks/doctor-
|
|
3488
|
+
const { handler } = await import("./chunks/doctor-VXAQYMTR.js");
|
|
3491
3489
|
await handler({ projectRoot: projectRoot() });
|
|
3492
3490
|
});
|
|
3493
3491
|
program3.command("bench [args...]").description("Time rune execution and report fast, ok, or slow.").addHelpText(
|
|
3494
3492
|
"after",
|
|
3495
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'
|
|
3496
3494
|
).allowUnknownOption().passThroughOptions().action(async (args, _opts, _command) => {
|
|
3497
|
-
const { handler, parseBenchArgs } = await import("./chunks/benchmark-
|
|
3495
|
+
const { handler, parseBenchArgs } = await import("./chunks/benchmark-BQNMULOO.js");
|
|
3498
3496
|
const parsed = parseBenchArgs(args);
|
|
3499
3497
|
if (!parsed.segments[0]?.key) {
|
|
3500
|
-
const { output } = await import("./chunks/output-
|
|
3498
|
+
const { output } = await import("./chunks/output-QN5CVJ62.js");
|
|
3501
3499
|
output.error("Missing required argument: <rune>");
|
|
3502
3500
|
process.exit(1);
|
|
3503
3501
|
}
|
|
3504
3502
|
await handler({ ...parsed, plain: !!program3.opts().plain, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3505
3503
|
});
|
|
3506
|
-
program3.command("list").description("List all registered runes").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (opts) => {
|
|
3507
|
-
const { handler } = await import("./chunks/list-
|
|
3508
|
-
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 });
|
|
3509
3507
|
});
|
|
3510
3508
|
const jobs = program3.command("job").description("Manage background jobs");
|
|
3511
3509
|
jobs.command("list").description("List background jobs for the current project").action(async () => {
|
|
3512
|
-
const { handler } = await import("./chunks/list-
|
|
3510
|
+
const { handler } = await import("./chunks/list-EHREZR6M.js");
|
|
3513
3511
|
await handler({ projectDir: projectRoot() });
|
|
3514
3512
|
});
|
|
3515
3513
|
jobs.command("kill <id>").description("Send SIGTERM to a background job and remove its record").action(async (id) => {
|
|
3516
|
-
const { handler } = await import("./chunks/kill-
|
|
3514
|
+
const { handler } = await import("./chunks/kill-TX3PC73P.js");
|
|
3517
3515
|
await handler({ id, projectDir: projectRoot() });
|
|
3518
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
|
+
});
|
|
3519
3522
|
const cache = program3.command("cache").description("Manage cache buckets");
|
|
3520
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) => {
|
|
3521
|
-
const { handler } = await import("./chunks/list-
|
|
3524
|
+
const { handler } = await import("./chunks/list-VA73WPK6.js");
|
|
3522
3525
|
await handler({ projectDir: projectRoot(), plugin: opts.plugin });
|
|
3523
3526
|
});
|
|
3524
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) => {
|
|
3525
|
-
const { handler } = await import("./chunks/clear-
|
|
3528
|
+
const { handler } = await import("./chunks/clear-AT7HNUV4.js");
|
|
3526
3529
|
await handler({ id, projectDir: projectRoot(), plugin: opts.plugin });
|
|
3527
3530
|
});
|
|
3528
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) => {
|
|
3529
|
-
const { handler } = await import("./chunks/delete-
|
|
3532
|
+
const { handler } = await import("./chunks/delete-5R3WBLVD.js");
|
|
3530
3533
|
await handler({ id, projectDir: projectRoot(), yes: !!program3.opts().yes, plugin: opts.plugin });
|
|
3531
3534
|
});
|
|
3532
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) => {
|
|
3533
|
-
const { handler } = await import("./chunks/unset-
|
|
3536
|
+
const { handler } = await import("./chunks/unset-P6IUF7SS.js");
|
|
3534
3537
|
await handler({ id, key, projectDir: projectRoot(), plugin: opts.plugin });
|
|
3535
3538
|
});
|
|
3536
3539
|
const schema = program3.command("schema").description("Manage schema cache");
|
|
3537
3540
|
schema.command("list").description("List cached schemas for the current project").action(async () => {
|
|
3538
|
-
const { handler } = await import("./chunks/list-
|
|
3541
|
+
const { handler } = await import("./chunks/list-V7VVD5AG.js");
|
|
3539
3542
|
await handler({ projectDir: projectRoot() });
|
|
3540
3543
|
});
|
|
3541
3544
|
schema.command("delete <rune-key>").description("Delete cached schema files for a rune key").action(async (runeKey) => {
|
|
3542
|
-
const { handler } = await import("./chunks/delete-
|
|
3545
|
+
const { handler } = await import("./chunks/delete-GKYA2W5Z.js");
|
|
3543
3546
|
await handler({ runeKey, projectDir: projectRoot() });
|
|
3544
3547
|
});
|
|
3545
3548
|
const sqlite = program3.command("sqlite").description("Manage SQLite databases");
|
|
3546
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) => {
|
|
3547
|
-
const { handler } = await import("./chunks/list-
|
|
3550
|
+
const { handler } = await import("./chunks/list-LC6HB3H3.js");
|
|
3548
3551
|
await handler({ projectDir: projectRoot(), plugin: opts.plugin });
|
|
3549
3552
|
});
|
|
3550
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) => {
|
|
3551
|
-
const { handler } = await import("./chunks/delete-
|
|
3554
|
+
const { handler } = await import("./chunks/delete-U4STA2QZ.js");
|
|
3552
3555
|
await handler({ id, yes: !!program3.opts().yes, projectDir: projectRoot(), plugin: opts.plugin });
|
|
3553
3556
|
});
|
|
3554
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) => {
|
|
3555
|
-
const { handler } = await import("./chunks/query-
|
|
3558
|
+
const { handler } = await import("./chunks/query-2US3CPYT.js");
|
|
3556
3559
|
await handler({ id, sql, projectDir: projectRoot(), plugin: opts.plugin });
|
|
3557
3560
|
});
|
|
3558
|
-
program3.command("init").description("Create .crunes/config.json in the current project").action(async () => {
|
|
3559
|
-
const { handler } = await import("./chunks/init-
|
|
3560
|
-
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 });
|
|
3561
3564
|
});
|
|
3562
|
-
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) => {
|
|
3563
|
-
const { handler } = await import("./chunks/create-
|
|
3564
|
-
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 });
|
|
3565
3568
|
});
|
|
3566
3569
|
const plugin = program3.command("plugin").description("Manage rune plugins");
|
|
3567
|
-
plugin.command("install <source>").description("Install a plugin from a configured marketplace in the format <marketplace>@<plugin>").action(async (source) => {
|
|
3568
|
-
const { handler } = await import("./chunks/install-
|
|
3569
|
-
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 });
|
|
3570
3573
|
});
|
|
3571
|
-
plugin.command("uninstall <plugin>").description("Uninstall an installed plugin").action(async (name) => {
|
|
3572
|
-
const { handler } = await import("./chunks/uninstall-
|
|
3573
|
-
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 });
|
|
3574
3577
|
});
|
|
3575
3578
|
plugin.command("list").description("List installed plugins").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (opts) => {
|
|
3576
|
-
const { handler } = await import("./chunks/list-
|
|
3579
|
+
const { handler } = await import("./chunks/list-OMMZAQ23.js");
|
|
3577
3580
|
await handler({ format: opts.format });
|
|
3578
3581
|
});
|
|
3579
3582
|
plugin.command("update [plugin]").description("Update one or all installed plugins").action(async (name) => {
|
|
3580
|
-
const { handler } = await import("./chunks/update-
|
|
3583
|
+
const { handler } = await import("./chunks/update-ACLDK6E6.js");
|
|
3581
3584
|
await handler({ name, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3582
3585
|
});
|
|
3583
|
-
plugin.command("enable <plugin>").description("Add a plugin to this project's enabled list").action(async (name) => {
|
|
3584
|
-
const { handler } = await import("./chunks/enable-
|
|
3585
|
-
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 });
|
|
3586
3589
|
});
|
|
3587
|
-
plugin.command("disable <plugin>").description("
|
|
3588
|
-
const { handler } = await import("./chunks/disable-
|
|
3589
|
-
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 });
|
|
3590
3593
|
});
|
|
3591
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) => {
|
|
3592
|
-
const { handler } = await import("./chunks/create-
|
|
3595
|
+
const { handler } = await import("./chunks/create-TLPM7HJE.js");
|
|
3593
3596
|
await handler({ name, description: opts.description, author: opts.author, license: opts.license, out: opts.out, yes: !!program3.opts().yes, projectRoot: projectRoot() });
|
|
3594
3597
|
});
|
|
3595
3598
|
const template = program3.command("template").description("Manage rune templates");
|
|
3596
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) => {
|
|
3597
|
-
const { handler } = await import("./chunks/list-
|
|
3600
|
+
const { handler } = await import("./chunks/list-WKNPZZOV.js");
|
|
3598
3601
|
await handler({ source, format: opts.format, plain: !!program3.opts().plain, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3599
3602
|
});
|
|
3600
3603
|
template.command("apply <template>").description("Copy a template into the project as a new rune and register it in config.").addHelpText(
|
|
3601
3604
|
"after",
|
|
3602
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"
|
|
3603
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) => {
|
|
3604
|
-
const { handler } = await import("./chunks/apply-
|
|
3607
|
+
const { handler } = await import("./chunks/apply-YY7MIM64.js");
|
|
3605
3608
|
await handler({ ref, key: opts.as, path: opts.path, name: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot() });
|
|
3606
3609
|
});
|
|
3607
|
-
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) => {
|
|
3608
|
-
const { handler } = await import("./chunks/create-
|
|
3609
|
-
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 });
|
|
3610
3613
|
});
|
|
3611
3614
|
const marketplace = program3.command("marketplace").description("Manage plugin marketplace sources");
|
|
3612
3615
|
marketplace.command("add <url>").description("Add a marketplace source URL").action(async (url) => {
|
|
3613
|
-
const { handler } = await import("./chunks/add-
|
|
3616
|
+
const { handler } = await import("./chunks/add-IT3IHBPO.js");
|
|
3614
3617
|
await handler({ url });
|
|
3615
3618
|
});
|
|
3616
3619
|
marketplace.command("remove <url>").description("Remove a marketplace source URL").action(async (url) => {
|
|
3617
|
-
const { handler } = await import("./chunks/remove-
|
|
3620
|
+
const { handler } = await import("./chunks/remove-BCFTF23J.js");
|
|
3618
3621
|
await handler({ url });
|
|
3619
3622
|
});
|
|
3620
3623
|
marketplace.command("list").description("List configured marketplace sources").action(async () => {
|
|
3621
|
-
const { handler } = await import("./chunks/list-
|
|
3624
|
+
const { handler } = await import("./chunks/list-U4EMHQZT.js");
|
|
3622
3625
|
await handler();
|
|
3623
3626
|
});
|
|
3624
3627
|
marketplace.command("search <query>").description("Search for plugins across configured marketplace sources").action(async (query) => {
|
|
3625
|
-
const { handler } = await import("./chunks/search-
|
|
3628
|
+
const { handler } = await import("./chunks/search-B7IM7JRJ.js");
|
|
3626
3629
|
await handler({ query });
|
|
3627
3630
|
});
|
|
3628
3631
|
marketplace.command("update [url]").description("Refresh cached marketplace data (all sources if no URL given)").action(async (url) => {
|
|
3629
|
-
const { handler } = await import("./chunks/update-
|
|
3632
|
+
const { handler } = await import("./chunks/update-WXT7CHYA.js");
|
|
3630
3633
|
await handler({ url });
|
|
3631
3634
|
});
|
|
3632
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) => {
|
|
3633
|
-
const { handler } = await import("./chunks/browse-
|
|
3636
|
+
const { handler } = await import("./chunks/browse-PHMBDREQ.js");
|
|
3634
3637
|
await handler({ format: opts.format });
|
|
3635
3638
|
});
|
|
3636
3639
|
const completions = program3.command("completions").description("Manage shell tab-completions");
|
|
@@ -3652,9 +3655,9 @@ function buildProgram() {
|
|
|
3652
3655
|
});
|
|
3653
3656
|
completions.command("install <shell>").description(
|
|
3654
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"
|
|
3655
|
-
).action(async (
|
|
3658
|
+
).action(async (shell2) => {
|
|
3656
3659
|
const { installHandler } = await import("./chunks/completions-2MSEWWTG.js");
|
|
3657
|
-
await installHandler(
|
|
3660
|
+
await installHandler(shell2);
|
|
3658
3661
|
});
|
|
3659
3662
|
return program3;
|
|
3660
3663
|
}
|
|
@@ -3680,6 +3683,25 @@ if (hasCommand) {
|
|
|
3680
3683
|
const vIndex = process.argv.indexOf("-v");
|
|
3681
3684
|
if (vIndex !== -1) process.argv[vIndex] = "--verbose";
|
|
3682
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
|
+
}
|
|
3683
3705
|
program2.parseAsync(process.argv).catch((err) => {
|
|
3684
3706
|
console.error("[crunes] FATAL CLI ERROR:", err);
|
|
3685
3707
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkrymit/crunes-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "CLI tool for querying crunes enrichers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@clack/prompts": "^1.5.0",
|
|
27
27
|
"archiver": "^8.0.0",
|
|
28
|
+
"buffer": "^6.0.3",
|
|
28
29
|
"chalk": "^5.6.2",
|
|
29
30
|
"chokidar": "^5.0.0",
|
|
30
31
|
"cli-table3": "^0.6.5",
|
|
@@ -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,105 +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 !== "vars" && key !== "permissions" && 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.vars) {
|
|
35
|
-
merged.vars = { ...shared.vars };
|
|
36
|
-
for (const [key, localVarsObj] of Object.entries(local.vars)) {
|
|
37
|
-
const sharedVarsObj = shared.vars?.[key];
|
|
38
|
-
if (sharedVarsObj && isObject(sharedVarsObj) && isObject(localVarsObj)) {
|
|
39
|
-
merged.vars[key] = { ...sharedVarsObj, ...localVarsObj };
|
|
40
|
-
} else {
|
|
41
|
-
merged.vars[key] = localVarsObj;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (local.permissions) {
|
|
46
|
-
merged.permissions = { ...shared.permissions, ...local.permissions };
|
|
47
|
-
}
|
|
48
|
-
if (local.plugins) {
|
|
49
|
-
const combined = [...shared.plugins ?? [], ...local.plugins ?? []];
|
|
50
|
-
merged.plugins = Array.from(new Set(combined));
|
|
51
|
-
}
|
|
52
|
-
return merged;
|
|
53
|
-
}
|
|
54
|
-
function validateConfig(config, fileName = "config.json") {
|
|
55
|
-
if (config.permissions && typeof config.permissions === "object") {
|
|
56
|
-
for (const [runeKey, perms] of Object.entries(config.permissions)) {
|
|
57
|
-
if (Array.isArray(perms)) {
|
|
58
|
-
throw new Error(`${fileName}: permissions for "${runeKey}" must be lifecycle-scoped (e.g. permissions["${runeKey}"].run.allow)`);
|
|
59
|
-
}
|
|
60
|
-
if (perms && typeof perms === "object") {
|
|
61
|
-
if (Array.isArray(perms.allow) || Array.isArray(perms.deny)) {
|
|
62
|
-
throw new Error(`${fileName}: permissions for "${runeKey}" must be lifecycle-scoped (e.g. permissions["${runeKey}"].run.allow)`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (config.runes && typeof config.runes === "object") {
|
|
68
|
-
for (const [runeKey, entry] of Object.entries(config.runes)) {
|
|
69
|
-
if (entry && typeof entry === "object" && entry.permissions) {
|
|
70
|
-
const perms = entry.permissions;
|
|
71
|
-
if (Array.isArray(perms)) {
|
|
72
|
-
throw new Error(`${fileName}: runes["${runeKey}"].permissions must be lifecycle-scoped (e.g. permissions.run.allow)`);
|
|
73
|
-
}
|
|
74
|
-
if (perms && typeof perms === "object") {
|
|
75
|
-
if (Array.isArray(perms.allow) || Array.isArray(perms.deny)) {
|
|
76
|
-
throw new Error(`${fileName}: runes["${runeKey}"].permissions must be lifecycle-scoped (e.g. permissions.run.allow)`);
|
|
77
|
-
}
|
|
78
|
-
if (perms.run && typeof perms.run === "object" && Object.keys(perms.run).length === 0) {
|
|
79
|
-
console.warn(`[crunes:warn] ${fileName}: runes["${runeKey}"].permissions.run is empty. No extra permissions will be granted.`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function loadConfig(dir) {
|
|
87
|
-
const configPath = join(dir, ".crunes", "config.json");
|
|
88
|
-
const localConfigPath = join(dir, ".crunes", "config.local.json");
|
|
89
|
-
const shared = JSON.parse(readFileSync(configPath, "utf8"));
|
|
90
|
-
validateConfig(shared, "config.json");
|
|
91
|
-
let local = {};
|
|
92
|
-
if (existsSync(localConfigPath)) {
|
|
93
|
-
try {
|
|
94
|
-
local = JSON.parse(readFileSync(localConfigPath, "utf8"));
|
|
95
|
-
} catch (err) {
|
|
96
|
-
throw new Error(`config.local.json is invalid JSON: ${err.message}`);
|
|
97
|
-
}
|
|
98
|
-
validateConfig(local, "config.local.json");
|
|
99
|
-
}
|
|
100
|
-
return mergeConfigs(shared, local);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export {
|
|
104
|
-
loadConfig
|
|
105
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadRegistry,
|
|
3
|
-
resolvePluginKey
|
|
4
|
-
} from "./chunk-65J65MAP.js";
|
|
5
|
-
import "./chunk-6MRZXASS.js";
|
|
6
|
-
import {
|
|
7
|
-
init_require_shim
|
|
8
|
-
} from "./chunk-TPK5AGRA.js";
|
|
9
|
-
|
|
10
|
-
// src/plugin/commands/disable.js
|
|
11
|
-
init_require_shim();
|
|
12
|
-
import fs from "node:fs/promises";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
async function handler({ name, projectRoot, configRoot }) {
|
|
15
|
-
try {
|
|
16
|
-
const registry = await loadRegistry();
|
|
17
|
-
const pluginKey = resolvePluginKey(name, registry);
|
|
18
|
-
if (!pluginKey) throw new Error(`Plugin "${name}" is not installed. Run: crunes plugin list`);
|
|
19
|
-
await setProjectPluginEnabled(configRoot ?? projectRoot, pluginKey, false);
|
|
20
|
-
console.log(`Plugin "${pluginKey}" disabled.`);
|
|
21
|
-
} catch (err) {
|
|
22
|
-
console.error(`Error: ${err.message}`);
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async function setProjectPluginEnabled(configRoot, pluginKey, enabled) {
|
|
27
|
-
const configPath = path.join(configRoot, ".crunes", "config.json");
|
|
28
|
-
let config;
|
|
29
|
-
try {
|
|
30
|
-
config = JSON.parse(await fs.readFile(configPath, "utf8"));
|
|
31
|
-
} catch (err) {
|
|
32
|
-
if (err.code === "ENOENT") throw new Error("No .crunes/config.json found. Run: crunes init");
|
|
33
|
-
throw err;
|
|
34
|
-
}
|
|
35
|
-
const plugins = config.plugins ?? [];
|
|
36
|
-
if (enabled && !plugins.includes(pluginKey)) {
|
|
37
|
-
config.plugins = [...plugins, pluginKey];
|
|
38
|
-
} else if (!enabled) {
|
|
39
|
-
config.plugins = plugins.filter((p) => p !== pluginKey);
|
|
40
|
-
}
|
|
41
|
-
const tmp = configPath + ".tmp";
|
|
42
|
-
await fs.writeFile(tmp, JSON.stringify(config, null, 2), "utf8");
|
|
43
|
-
await fs.rename(tmp, configPath);
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
handler
|
|
47
|
-
};
|