@darkrymit/crunes-cli 0.8.5 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/chunks/{add-CBHWFGCA.js → add-IT3IHBPO.js} +2 -2
  2. package/dist/chunks/add-MSX6XSU3.js +68 -0
  3. package/dist/chunks/{apply-J4YICV6H.js → apply-LOIJIPLR.js} +21 -12
  4. package/dist/chunks/{benchmark-AKKV7G32.js → benchmark-3IHFP3V2.js} +27 -18
  5. package/dist/chunks/{browse-JZFU52ET.js → browse-PHMBDREQ.js} +2 -2
  6. package/dist/chunks/chunk-2DNYVKBF.js +109 -0
  7. package/dist/chunks/chunk-2FI6KN3C.js +283 -0
  8. package/dist/chunks/chunk-2HM5Q52B.js +131 -0
  9. package/dist/chunks/{chunk-6MRZXASS.js → chunk-2Q3KLBE6.js} +16 -0
  10. package/dist/chunks/{chunk-ZJDKCC2Y.js → chunk-4GJMCFR6.js} +6 -3
  11. package/dist/chunks/chunk-55GTJG5I.js +1154 -0
  12. package/dist/chunks/chunk-6IC6ZJ74.js +9525 -0
  13. package/dist/chunks/chunk-7KYCYDAS.js +325 -0
  14. package/dist/chunks/chunk-DTOYFY3Z.js +578 -0
  15. package/dist/chunks/chunk-EO3CSXWK.js +70 -0
  16. package/dist/chunks/chunk-FIAFVIAN.js +79 -0
  17. package/dist/chunks/{chunk-J3GZ3DXD.js → chunk-GVMT55GH.js} +3 -2
  18. package/dist/chunks/chunk-H2OT7D6N.js +303 -0
  19. package/dist/chunks/{chunk-JOAL437H.js → chunk-I6MHDUCW.js} +16 -1
  20. package/dist/chunks/chunk-KSQDFE5N.js +85 -0
  21. package/dist/chunks/{chunk-BTIPUR5S.js → chunk-KUEMDPNG.js} +108 -91
  22. package/dist/chunks/{chunk-6XLT25GS.js → chunk-MIKWIFYR.js} +47 -0
  23. package/dist/chunks/{chunk-GTCPZ22N.js → chunk-MTJ2KW3V.js} +3 -1
  24. package/dist/chunks/chunk-MVCBPI4J.js +2354 -0
  25. package/dist/chunks/{chunk-T53L5CJW.js → chunk-PBGUKXT6.js} +2887 -1874
  26. package/dist/chunks/{chunk-KII6KW5Z.js → chunk-RVBAAXRY.js} +64 -44
  27. package/dist/chunks/chunk-SUCYDYMU.js +44 -0
  28. package/dist/chunks/chunk-UBCAZGLE.js +15 -0
  29. package/dist/chunks/{chunk-63H5VXZY.js → chunk-UEUUOAJY.js} +4 -1
  30. package/dist/chunks/chunk-VP7YLCQP.js +244 -0
  31. package/dist/chunks/{chunk-NDEYEYSU.js → chunk-WJII3LZK.js} +4 -3
  32. package/dist/chunks/chunk-XDMMSZIL.js +71 -0
  33. package/dist/chunks/chunk-YKIKJHYO.js +94 -0
  34. package/dist/chunks/{chunk-NYLRTAAA.js → chunk-YVN3VDRE.js} +1 -1
  35. package/dist/chunks/{clear-YBDIPEEH.js → clear-AT7HNUV4.js} +2 -2
  36. package/dist/chunks/{create-L6DJN4ME.js → create-DXW4YYLJ.js} +8 -8
  37. package/dist/chunks/create-LPLNCOW4.js +268 -0
  38. package/dist/chunks/{create-GPDE2YKL.js → create-Y4LHLWGL.js} +26 -18
  39. package/dist/chunks/{delete-LNOYM5KG.js → delete-2EXPFBFC.js} +2 -2
  40. package/dist/chunks/{delete-E4TEBRPX.js → delete-GKYA2W5Z.js} +4 -2
  41. package/dist/chunks/{delete-C4UJ7X5K.js → delete-MJAECXXV.js} +2 -2
  42. package/dist/chunks/disable-TITOSMXB.js +43 -0
  43. package/dist/chunks/doctor-R2Y6UAY4.js +208 -0
  44. package/dist/chunks/enable-LGTPDWPV.js +35 -0
  45. package/dist/chunks/{globals-H2WF344Y.js → globals-SNQFCHMP.js} +1 -1
  46. package/dist/chunks/{init-HU5OMHEH.js → init-KO2HLED5.js} +18 -8
  47. package/dist/chunks/install-7IRUAGSF.js +64 -0
  48. package/dist/chunks/{intro-36OLGNYN.js → intro-JNJ6A75J.js} +89 -21
  49. package/dist/chunks/{kill-2UG7PHUV.js → kill-TX3PC73P.js} +2 -1
  50. package/dist/chunks/{list-2JYMBMZC.js → list-BCCM3TLP.js} +12 -7
  51. package/dist/chunks/{list-4X3JFQGS.js → list-EHREZR6M.js} +2 -1
  52. package/dist/chunks/{list-U7PAYNAH.js → list-LC6HB3H3.js} +2 -2
  53. package/dist/chunks/list-MLKZE36K.js +92 -0
  54. package/dist/chunks/list-QVZKR3IE.js +62 -0
  55. package/dist/chunks/{list-7VHJIUDX.js → list-U4EMHQZT.js} +2 -2
  56. package/dist/chunks/{list-PTAWQYWG.js → list-V7VVD5AG.js} +2 -1
  57. package/dist/chunks/{list-A5WVDBWF.js → list-VA73WPK6.js} +2 -2
  58. package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
  59. package/dist/chunks/migrate-Y3EKMVP5.js +87 -0
  60. package/dist/chunks/{output-RJ6JSNY7.js → output-QN5CVJ62.js} +4 -1
  61. package/dist/chunks/{query-AW7WYILM.js → query-2US3CPYT.js} +2 -2
  62. package/dist/chunks/{registry-RG34DPD7.js → registry-IWP7JMNI.js} +2 -2
  63. package/dist/chunks/{remove-QUH2D3S5.js → remove-BCFTF23J.js} +2 -2
  64. package/dist/chunks/{repl-STBZC4P2.js → repl-2YWTHUWT.js} +4 -0
  65. package/dist/chunks/{repl-BPEWARN7.js → repl-5GDN3RAO.js} +99 -31
  66. package/dist/chunks/resolver-CA2A32AC.js +36 -0
  67. package/dist/chunks/run-WL3IZBXF.js +35 -0
  68. package/dist/chunks/rune-YA4TFHTB.js +283 -0
  69. package/dist/chunks/runner-QNZMBHQY.js +34 -0
  70. package/dist/chunks/{search-MSSDGJTF.js → search-B7IM7JRJ.js} +2 -2
  71. package/dist/chunks/shell-explain-LKBBP2BG.js +77 -0
  72. package/dist/chunks/trust-BFIDANXD.js +109 -0
  73. package/dist/chunks/uninstall-3MWZIZVA.js +58 -0
  74. package/dist/chunks/{unset-YASSMSE5.js → unset-P6IUF7SS.js} +2 -2
  75. package/dist/chunks/{update-KSC6VRMU.js → update-W4MJUTTW.js} +25 -19
  76. package/dist/chunks/{update-EWWDROKW.js → update-WXT7CHYA.js} +2 -2
  77. package/dist/chunks/{utils-3SJFSUSV.js → utils-B2QULX5J.js} +8 -4
  78. package/dist/chunks/{version-YG2M7HER.js → version-FLHI5KFS.js} +3 -3
  79. package/dist/cli.js +115 -70
  80. package/package.json +2 -2
  81. package/dist/chunks/chunk-ASZKAC24.js +0 -103
  82. package/dist/chunks/chunk-G3U4V32O.js +0 -46
  83. package/dist/chunks/chunk-GSA432UC.js +0 -90
  84. package/dist/chunks/chunk-WJRZN7BR.js +0 -77492
  85. package/dist/chunks/create-VYZRWRGQ.js +0 -170
  86. package/dist/chunks/disable-FGJ7VMPO.js +0 -47
  87. package/dist/chunks/doctor-7NWBJAH7.js +0 -53
  88. package/dist/chunks/enable-ZL6QOC2I.js +0 -47
  89. package/dist/chunks/install-FIYRMVLR.js +0 -57
  90. package/dist/chunks/list-AIYNOPNZ.js +0 -28
  91. package/dist/chunks/list-NZ5DHXJF.js +0 -111
  92. package/dist/chunks/resolver-36V72VKR.js +0 -28
  93. package/dist/chunks/run-IVL23SMW.js +0 -26
  94. package/dist/chunks/rune-XRREUL56.js +0 -186
  95. package/dist/chunks/uninstall-G56DZRFG.js +0 -49
@@ -1,13 +1,14 @@
1
1
  import {
2
2
  utils_api_default
3
- } from "./chunk-T53L5CJW.js";
3
+ } from "./chunk-PBGUKXT6.js";
4
4
  import {
5
5
  formatNode,
6
6
  walk
7
- } from "./chunk-JOAL437H.js";
7
+ } from "./chunk-I6MHDUCW.js";
8
8
  import {
9
9
  output
10
- } from "./chunk-6XLT25GS.js";
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 ?? ""}`.trimEnd());
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-6MRZXASS.js";
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.8.5",
19
+ version: "0.10.0",
20
20
  description: "CLI tool for querying crunes enrichers",
21
21
  type: "module",
22
22
  bin: {
@@ -27,7 +27,7 @@ var package_default = {
27
27
  ],
28
28
  scripts: {
29
29
  build: "typedoc --options typedoc.json && typedoc --options typedoc-lifecycle.json && typedoc --options typedoc-globals.json && node build.mjs",
30
- prepack: "node build.mjs",
30
+ prepack: "npm run build",
31
31
  test: "vitest run"
32
32
  },
33
33
  dependencies: {
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-6XLT25GS.js";
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,10 +3397,11 @@ 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.8.5", "-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
+ program3.name("crunes").description("CLI tool for managing context runes").version("0.10.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
- configure({ plain: !!program3.opts().plain, verbose: !!program3.opts().verbose });
3402
- if (program3.opts().verbose) {
3402
+ const opts = { ...program3.opts(), ...actionCommand.opts() };
3403
+ configure({ plain: !!opts.plain, verbose: !!opts.verbose });
3404
+ if (opts.verbose) {
3403
3405
  console.error(`[crunes:debug] Executing command: ${actionCommand.name()}`);
3404
3406
  }
3405
3407
  });
@@ -3415,7 +3417,7 @@ function buildProgram() {
3415
3417
  "after",
3416
3418
  '\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
3419
  ).allowUnknownOption().passThroughOptions().action(async (args, _opts, _command) => {
3418
- const { handler, parseRunArgs } = await import("./chunks/run-IVL23SMW.js");
3420
+ const { handler, parseRunArgs } = await import("./chunks/run-WL3IZBXF.js");
3419
3421
  const { segments, format, failFast, isBatch } = parseRunArgs(args);
3420
3422
  await handler({ segments, format, failFast, isBatch, projectRoot: projectRoot(), configRoot: configRoot() });
3421
3423
  });
@@ -3423,25 +3425,28 @@ function buildProgram() {
3423
3425
  "after",
3424
3426
  '\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
3427
  ).allowUnknownOption().passThroughOptions().action(async (args, _opts, _command) => {
3426
- const { handler, parseReplArgs } = await import("./chunks/repl-BPEWARN7.js");
3428
+ const { handler, parseReplArgs } = await import("./chunks/repl-5GDN3RAO.js");
3427
3429
  const { key, runeArgs, sections, format } = parseReplArgs(args);
3428
3430
  await handler({ key, runeArgs, sections, format, projectRoot: projectRoot(), configRoot: configRoot() });
3429
3431
  });
3430
3432
  const helpGroup = program3.command("docs").description("Show documentation for runes and other resources");
3431
- helpGroup.command("rune <rune...>").description("Show usage, argument schema, and examples for one or more runes").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (keys, opts) => {
3432
- const { handler } = await import("./chunks/rune-XRREUL56.js");
3433
- await handler({ keys, format: opts.format, projectRoot: projectRoot(), configRoot: configRoot() });
3433
+ helpGroup.command("rune [key] [path...]").description("Show a rune command index, or drill into one command").addHelpText(
3434
+ "after",
3435
+ "\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"
3436
+ ).addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).action(async (key, path3, opts) => {
3437
+ const { handler } = await import("./chunks/rune-YA4TFHTB.js");
3438
+ await handler({ key, path: path3, format: opts.format, projectRoot: projectRoot(), configRoot: configRoot() });
3434
3439
  });
3435
3440
  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-3SJFSUSV.js");
3441
+ const { handler } = await import("./chunks/utils-B2QULX5J.js");
3437
3442
  await handler({ namespaces, format: opts.format });
3438
3443
  });
3439
3444
  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-H2WF344Y.js");
3445
+ const { handler } = await import("./chunks/globals-SNQFCHMP.js");
3441
3446
  await handler({ format: opts.format });
3442
3447
  });
3443
- helpGroup.command("intro").description("Generate a comprehensive introduction and context document for Crunes and the active project").option("--out <path>", "output file path (defaults to stdout)").action(async (opts) => {
3444
- const { handler } = await import("./chunks/intro-36OLGNYN.js");
3448
+ 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) => {
3449
+ const { handler } = await import("./chunks/intro-JNJ6A75J.js");
3445
3450
  await handler({ out: opts.out });
3446
3451
  });
3447
3452
  helpGroup.command("args").description("Show detailed documentation, conventions, and examples for the args(builder) export").action(async () => {
@@ -3453,7 +3458,7 @@ function buildProgram() {
3453
3458
  await handler();
3454
3459
  });
3455
3460
  helpGroup.command("repl").description("Show detailed documentation, conventions, and examples for the repl(args) export").action(async () => {
3456
- const { handler } = await import("./chunks/repl-STBZC4P2.js");
3461
+ const { handler } = await import("./chunks/repl-2YWTHUWT.js");
3457
3462
  await handler();
3458
3463
  });
3459
3464
  helpGroup.command("args-repl").description("Show detailed documentation, conventions, and examples for the argsRepl(builder) export").action(async () => {
@@ -3477,154 +3482,171 @@ function buildProgram() {
3477
3482
  await handler();
3478
3483
  });
3479
3484
  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-YG2M7HER.js");
3485
+ const { handler } = await import("./chunks/version-FLHI5KFS.js");
3481
3486
  await handler({ check: opts.check, plain: !!program3.opts().plain });
3482
3487
  });
3483
- program3.command("doctor").description("Verify environment and project setup").action(async () => {
3484
- const { handler } = await import("./chunks/doctor-7NWBJAH7.js");
3488
+ program3.command("doctor").description("Verify environment and project setup").option("-p, --plain", "plain output: no colors, no box-drawing, plain symbols \u2014 optimised for AI/pipe use").action(async () => {
3489
+ const { handler } = await import("./chunks/doctor-R2Y6UAY4.js");
3485
3490
  await handler({ projectRoot: projectRoot() });
3486
3491
  });
3492
+ program3.command("migrate").description("Rewrite rune entries from path/permissions to run and repl blocks, renaming isolate modules to *.rune.js").option("-g, --global", "migrate the global config (~/.crunes/config.json) instead of the project").option("--dry-run", "print the rewrite without writing or renaming anything").action(async (opts) => {
3493
+ const { handler } = await import("./chunks/migrate-Y3EKMVP5.js");
3494
+ await handler({ configRoot: configRoot(), global: !!opts.global, dryRun: !!opts.dryRun });
3495
+ });
3487
3496
  program3.command("bench [args...]").description("Time rune execution and report fast, ok, or slow.").addHelpText(
3488
3497
  "after",
3489
3498
  '\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
3499
  ).allowUnknownOption().passThroughOptions().action(async (args, _opts, _command) => {
3491
- const { handler, parseBenchArgs } = await import("./chunks/benchmark-AKKV7G32.js");
3500
+ const { handler, parseBenchArgs } = await import("./chunks/benchmark-3IHFP3V2.js");
3492
3501
  const parsed = parseBenchArgs(args);
3493
3502
  if (!parsed.segments[0]?.key) {
3494
- const { output } = await import("./chunks/output-RJ6JSNY7.js");
3503
+ const { output } = await import("./chunks/output-QN5CVJ62.js");
3495
3504
  output.error("Missing required argument: <rune>");
3496
3505
  process.exit(1);
3497
3506
  }
3498
3507
  await handler({ ...parsed, plain: !!program3.opts().plain, projectRoot: projectRoot(), configRoot: configRoot() });
3499
3508
  });
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-NZ5DHXJF.js");
3502
- await handler({ format: opts.format, plain: !!program3.opts().plain, projectRoot: projectRoot(), configRoot: configRoot() });
3509
+ program3.command("list").description("List all registered runes").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).option("-p, --plain", "plain output: no colors, no box-drawing, plain symbols \u2014 optimised for AI/pipe use").option("-g, --global", "list only runes from the global config (~/.crunes/config.json)").action(async (opts) => {
3510
+ const { handler } = await import("./chunks/list-MLKZE36K.js");
3511
+ await handler({ format: opts.format, plain: !!program3.opts().plain || !!opts.plain, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
3503
3512
  });
3504
3513
  const jobs = program3.command("job").description("Manage background jobs");
3505
3514
  jobs.command("list").description("List background jobs for the current project").action(async () => {
3506
- const { handler } = await import("./chunks/list-4X3JFQGS.js");
3515
+ const { handler } = await import("./chunks/list-EHREZR6M.js");
3507
3516
  await handler({ projectDir: projectRoot() });
3508
3517
  });
3509
3518
  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-2UG7PHUV.js");
3519
+ const { handler } = await import("./chunks/kill-TX3PC73P.js");
3511
3520
  await handler({ id, projectDir: projectRoot() });
3512
3521
  });
3522
+ const shell = program3.command("shell").description("Inspect how commands are parsed and permission-checked");
3523
+ 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) => {
3524
+ const { handler } = await import("./chunks/shell-explain-LKBBP2BG.js");
3525
+ await handler({ cmd, shellMode: opts.shell });
3526
+ });
3513
3527
  const cache = program3.command("cache").description("Manage cache buckets");
3514
3528
  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-A5WVDBWF.js");
3529
+ const { handler } = await import("./chunks/list-VA73WPK6.js");
3516
3530
  await handler({ projectDir: projectRoot(), plugin: opts.plugin });
3517
3531
  });
3518
3532
  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-YBDIPEEH.js");
3533
+ const { handler } = await import("./chunks/clear-AT7HNUV4.js");
3520
3534
  await handler({ id, projectDir: projectRoot(), plugin: opts.plugin });
3521
3535
  });
3522
3536
  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-LNOYM5KG.js");
3537
+ const { handler } = await import("./chunks/delete-2EXPFBFC.js");
3524
3538
  await handler({ id, projectDir: projectRoot(), yes: !!program3.opts().yes, plugin: opts.plugin });
3525
3539
  });
3526
3540
  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-YASSMSE5.js");
3541
+ const { handler } = await import("./chunks/unset-P6IUF7SS.js");
3528
3542
  await handler({ id, key, projectDir: projectRoot(), plugin: opts.plugin });
3529
3543
  });
3530
3544
  const schema = program3.command("schema").description("Manage schema cache");
3531
3545
  schema.command("list").description("List cached schemas for the current project").action(async () => {
3532
- const { handler } = await import("./chunks/list-PTAWQYWG.js");
3546
+ const { handler } = await import("./chunks/list-V7VVD5AG.js");
3533
3547
  await handler({ projectDir: projectRoot() });
3534
3548
  });
3535
3549
  schema.command("delete <rune-key>").description("Delete cached schema files for a rune key").action(async (runeKey) => {
3536
- const { handler } = await import("./chunks/delete-E4TEBRPX.js");
3550
+ const { handler } = await import("./chunks/delete-GKYA2W5Z.js");
3537
3551
  await handler({ runeKey, projectDir: projectRoot() });
3538
3552
  });
3539
3553
  const sqlite = program3.command("sqlite").description("Manage SQLite databases");
3540
3554
  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-U7PAYNAH.js");
3555
+ const { handler } = await import("./chunks/list-LC6HB3H3.js");
3542
3556
  await handler({ projectDir: projectRoot(), plugin: opts.plugin });
3543
3557
  });
3544
3558
  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-C4UJ7X5K.js");
3559
+ const { handler } = await import("./chunks/delete-MJAECXXV.js");
3546
3560
  await handler({ id, yes: !!program3.opts().yes, projectDir: projectRoot(), plugin: opts.plugin });
3547
3561
  });
3548
3562
  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-AW7WYILM.js");
3563
+ const { handler } = await import("./chunks/query-2US3CPYT.js");
3550
3564
  await handler({ id, sql, projectDir: projectRoot(), plugin: opts.plugin });
3551
3565
  });
3552
- program3.command("init").description("Create .crunes/config.json in the current project").action(async () => {
3553
- const { handler } = await import("./chunks/init-HU5OMHEH.js");
3554
- await handler({ yes: !!program3.opts().yes, projectRoot: projectRoot() });
3566
+ 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) => {
3567
+ const { handler } = await import("./chunks/init-KO2HLED5.js");
3568
+ await handler({ yes: !!program3.opts().yes, projectRoot: projectRoot(), global: !!opts.global });
3555
3569
  });
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-VYZRWRGQ.js");
3558
- await handler({ key, format: opts.format, path: opts.path, name: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot() });
3570
+ 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)").addOption(new Option("--lang <lang>", "scaffold a script rune instead of a sandboxed JS one").choices(["python", "bash", "node"])).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) => {
3571
+ const { handler } = await import("./chunks/create-LPLNCOW4.js");
3572
+ await handler({ key, format: opts.format, lang: opts.lang, path: opts.path, name: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
3573
+ });
3574
+ program3.command("add <key> <command> [argv...]").description("Register an existing script or program as a rune (fixed arguments go after --)").option("--name <name>", "human-readable label shown in crunes list").option("--description <description>", "short description of what the rune does").option("-g, --global", "operate on the global config (~/.crunes/config.json) instead of the project").addHelpText("after", '\nExamples:\n crunes add coverage tools/coverage.py --description "Test coverage per module"\n crunes add log git -- log --oneline -n 20').action(async (key, command, argv, opts) => {
3575
+ const { handler } = await import("./chunks/add-MSX6XSU3.js");
3576
+ await handler({ key, command, argv, name: opts.name, description: opts.description, configRoot: configRoot(), global: !!opts.global });
3559
3577
  });
3560
3578
  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-FIYRMVLR.js");
3563
- await handler({ source, projectRoot: projectRoot(), configRoot: configRoot(), yes: !!program3.opts().yes });
3579
+ 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) => {
3580
+ const { handler } = await import("./chunks/install-7IRUAGSF.js");
3581
+ await handler({ source, projectRoot: projectRoot(), configRoot: configRoot(), yes: !!program3.opts().yes, global: !!opts.global });
3564
3582
  });
3565
- plugin.command("uninstall <plugin>").description("Uninstall an installed plugin").action(async (name) => {
3566
- const { handler } = await import("./chunks/uninstall-G56DZRFG.js");
3567
- await handler({ name, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot() });
3583
+ 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) => {
3584
+ const { handler } = await import("./chunks/uninstall-3MWZIZVA.js");
3585
+ await handler({ name, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
3568
3586
  });
3569
- 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-AIYNOPNZ.js");
3571
- await handler({ format: opts.format });
3587
+ plugin.command("list").description("List installed plugins").addOption(new Option("--format <format>", "output format").choices(["text", "json"]).default("text")).option("-p, --plain", "plain output: no colors, no box-drawing, plain symbols \u2014 optimised for AI/pipe use").action(async (opts) => {
3588
+ const { handler } = await import("./chunks/list-QVZKR3IE.js");
3589
+ await handler({ format: opts.format, projectRoot: projectRoot() });
3572
3590
  });
3573
3591
  plugin.command("update [plugin]").description("Update one or all installed plugins").action(async (name) => {
3574
- const { handler } = await import("./chunks/update-KSC6VRMU.js");
3592
+ const { handler } = await import("./chunks/update-W4MJUTTW.js");
3575
3593
  await handler({ name, projectRoot: projectRoot(), configRoot: configRoot() });
3576
3594
  });
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-ZL6QOC2I.js");
3579
- await handler({ name, projectRoot: projectRoot(), configRoot: configRoot() });
3595
+ plugin.command("trust <plugin> [rune]").description("Review a plugin's native runes \u2014 scripts that run outside the sandbox \u2014 and trust them to run").action(async (name, rune) => {
3596
+ const { handler } = await import("./chunks/trust-BFIDANXD.js");
3597
+ await handler({ name, rune: rune ?? null, yes: !!program3.opts().yes });
3580
3598
  });
3581
- plugin.command("disable <plugin>").description("Remove a plugin from this project's enabled list").action(async (name) => {
3582
- const { handler } = await import("./chunks/disable-FGJ7VMPO.js");
3583
- await handler({ name, projectRoot: projectRoot(), configRoot: configRoot() });
3599
+ 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) => {
3600
+ const { handler } = await import("./chunks/enable-LGTPDWPV.js");
3601
+ await handler({ name, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
3602
+ });
3603
+ 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) => {
3604
+ const { handler } = await import("./chunks/disable-TITOSMXB.js");
3605
+ await handler({ name, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
3584
3606
  });
3585
3607
  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-L6DJN4ME.js");
3608
+ const { handler } = await import("./chunks/create-DXW4YYLJ.js");
3587
3609
  await handler({ name, description: opts.description, author: opts.author, license: opts.license, out: opts.out, yes: !!program3.opts().yes, projectRoot: projectRoot() });
3588
3610
  });
3589
3611
  const template = program3.command("template").description("Manage rune templates");
3590
3612
  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-2JYMBMZC.js");
3613
+ const { handler } = await import("./chunks/list-BCCM3TLP.js");
3592
3614
  await handler({ source, format: opts.format, plain: !!program3.opts().plain, projectRoot: projectRoot(), configRoot: configRoot() });
3593
3615
  });
3594
3616
  template.command("apply <template>").description("Copy a template into the project as a new rune and register it in config.").addHelpText(
3595
3617
  "after",
3596
3618
  "\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
3619
  ).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-J4YICV6H.js");
3620
+ const { handler } = await import("./chunks/apply-LOIJIPLR.js");
3599
3621
  await handler({ ref, key: opts.as, path: opts.path, name: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot() });
3600
3622
  });
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-GPDE2YKL.js");
3603
- await handler({ name, path: opts.path, templateName: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot() });
3623
+ 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) => {
3624
+ const { handler } = await import("./chunks/create-Y4LHLWGL.js");
3625
+ await handler({ name, path: opts.path, templateName: opts.name, description: opts.description, yes: !!program3.opts().yes, projectRoot: projectRoot(), configRoot: configRoot(), global: !!opts.global });
3604
3626
  });
3605
3627
  const marketplace = program3.command("marketplace").description("Manage plugin marketplace sources");
3606
3628
  marketplace.command("add <url>").description("Add a marketplace source URL").action(async (url) => {
3607
- const { handler } = await import("./chunks/add-CBHWFGCA.js");
3629
+ const { handler } = await import("./chunks/add-IT3IHBPO.js");
3608
3630
  await handler({ url });
3609
3631
  });
3610
3632
  marketplace.command("remove <url>").description("Remove a marketplace source URL").action(async (url) => {
3611
- const { handler } = await import("./chunks/remove-QUH2D3S5.js");
3633
+ const { handler } = await import("./chunks/remove-BCFTF23J.js");
3612
3634
  await handler({ url });
3613
3635
  });
3614
- marketplace.command("list").description("List configured marketplace sources").action(async () => {
3615
- const { handler } = await import("./chunks/list-7VHJIUDX.js");
3636
+ marketplace.command("list").description("List configured marketplace sources").option("-p, --plain", "plain output: no colors, no box-drawing, plain symbols \u2014 optimised for AI/pipe use").action(async () => {
3637
+ const { handler } = await import("./chunks/list-U4EMHQZT.js");
3616
3638
  await handler();
3617
3639
  });
3618
3640
  marketplace.command("search <query>").description("Search for plugins across configured marketplace sources").action(async (query) => {
3619
- const { handler } = await import("./chunks/search-MSSDGJTF.js");
3641
+ const { handler } = await import("./chunks/search-B7IM7JRJ.js");
3620
3642
  await handler({ query });
3621
3643
  });
3622
3644
  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-EWWDROKW.js");
3645
+ const { handler } = await import("./chunks/update-WXT7CHYA.js");
3624
3646
  await handler({ url });
3625
3647
  });
3626
3648
  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-JZFU52ET.js");
3649
+ const { handler } = await import("./chunks/browse-PHMBDREQ.js");
3628
3650
  await handler({ format: opts.format });
3629
3651
  });
3630
3652
  const completions = program3.command("completions").description("Manage shell tab-completions");
@@ -3646,9 +3668,9 @@ function buildProgram() {
3646
3668
  });
3647
3669
  completions.command("install <shell>").description(
3648
3670
  "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 (shell) => {
3671
+ ).action(async (shell2) => {
3650
3672
  const { installHandler } = await import("./chunks/completions-2MSEWWTG.js");
3651
- await installHandler(shell);
3673
+ await installHandler(shell2);
3652
3674
  });
3653
3675
  return program3;
3654
3676
  }
@@ -3661,6 +3683,10 @@ if (process.env.CRUNES_NO_TIMEOUT === "1") {
3661
3683
  }
3662
3684
  }
3663
3685
  var program2 = buildProgram();
3686
+ process.stdout.on("error", (err) => {
3687
+ if (err.code === "EPIPE") process.exit(0);
3688
+ throw err;
3689
+ });
3664
3690
  process.on("uncaughtException", (err) => {
3665
3691
  console.error("[crunes] FATAL UNCAUGHT EXCEPTION:", err);
3666
3692
  process.exit(1);
@@ -3674,6 +3700,25 @@ if (hasCommand) {
3674
3700
  const vIndex = process.argv.indexOf("-v");
3675
3701
  if (vIndex !== -1) process.argv[vIndex] = "--verbose";
3676
3702
  }
3703
+ var VALUED_GLOBALS = /* @__PURE__ */ new Set(["--cwd", "--ccd"]);
3704
+ var cmdIdx = 2;
3705
+ while (cmdIdx < process.argv.length && process.argv[cmdIdx].startsWith("-")) {
3706
+ const tok = process.argv[cmdIdx];
3707
+ cmdIdx += VALUED_GLOBALS.has(tok) ? 2 : 1;
3708
+ }
3709
+ if (cmdIdx < process.argv.length) {
3710
+ const name = process.argv[cmdIdx];
3711
+ const known = /* @__PURE__ */ new Set(["help"]);
3712
+ for (const c of program2.commands) {
3713
+ known.add(c.name());
3714
+ for (const a of c.aliases()) known.add(a);
3715
+ }
3716
+ if (!known.has(name)) {
3717
+ console.error(`error: unknown command '${name}'`);
3718
+ console.error(`Run 'crunes --help' for a list of commands.`);
3719
+ process.exit(1);
3720
+ }
3721
+ }
3677
3722
  program2.parseAsync(process.argv).catch((err) => {
3678
3723
  console.error("[crunes] FATAL CLI ERROR:", err);
3679
3724
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkrymit/crunes-cli",
3
- "version": "0.8.5",
3
+ "version": "0.10.0",
4
4
  "description": "CLI tool for querying crunes enrichers",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "build": "typedoc --options typedoc.json && typedoc --options typedoc-lifecycle.json && typedoc --options typedoc-globals.json && node build.mjs",
14
- "prepack": "node build.mjs",
14
+ "prepack": "npm run build",
15
15
  "test": "vitest run"
16
16
  },
17
17
  "dependencies": {
@@ -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,46 +0,0 @@
1
- import {
2
- init_require_shim
3
- } from "./chunk-TPK5AGRA.js";
4
-
5
- // src/plugin/manifest.js
6
- init_require_shim();
7
- import fs from "node:fs/promises";
8
- import path from "node:path";
9
- var PLUGIN_JSON_RELATIVE = ".crunes-plugin/plugin.json";
10
- async function loadPluginJson(pluginDir) {
11
- const jsonPath = path.join(pluginDir, PLUGIN_JSON_RELATIVE);
12
- const raw = await fs.readFile(jsonPath, "utf8");
13
- const json = JSON.parse(raw);
14
- validatePluginJson(json);
15
- return json;
16
- }
17
- function validatePluginJson(json) {
18
- if (json.format !== "1") throw new Error(`plugin.json: unsupported format "${json.format}" (expected "1")`);
19
- if (!json.runes || typeof json.runes !== "object") throw new Error('plugin.json: "runes" must be an object');
20
- for (const [key, rune] of Object.entries(json.runes)) {
21
- if (!rune.permissions || Object.keys(rune.permissions).length === 0) {
22
- continue;
23
- }
24
- const perms = rune.permissions;
25
- if (Array.isArray(perms)) {
26
- throw new Error(`plugin.json: rune "${key}" permissions must be lifecycle-scoped (e.g. permissions.run.allow)`);
27
- }
28
- if (perms.allow || perms.deny) {
29
- throw new Error(`plugin.json: rune "${key}" permissions must be lifecycle-scoped (e.g. permissions.run.allow)`);
30
- }
31
- const hasLifecycleScoped = Object.values(perms).some((v) => v && Array.isArray(v.allow));
32
- if (!hasLifecycleScoped) {
33
- const hasEmptyRun = perms.run && typeof perms.run === "object" && Object.keys(perms.run).length === 0;
34
- if (hasEmptyRun) {
35
- console.warn(`[crunes:warn] plugin.json: rune "${key}" permissions.run is empty.`);
36
- continue;
37
- }
38
- throw new Error(`plugin.json: rune "${key}" must have lifecycle-scoped permissions (e.g. permissions.run.allow)`);
39
- }
40
- }
41
- }
42
-
43
- export {
44
- loadPluginJson,
45
- validatePluginJson
46
- };