@darkrymit/crunes-cli 0.8.5 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/chunks/{add-CBHWFGCA.js → add-IT3IHBPO.js} +2 -2
  2. package/dist/chunks/add-MSX6XSU3.js +68 -0
  3. package/dist/chunks/{apply-J4YICV6H.js → apply-LOIJIPLR.js} +21 -12
  4. package/dist/chunks/{benchmark-AKKV7G32.js → benchmark-3IHFP3V2.js} +27 -18
  5. package/dist/chunks/{browse-JZFU52ET.js → browse-PHMBDREQ.js} +2 -2
  6. package/dist/chunks/chunk-2DNYVKBF.js +109 -0
  7. package/dist/chunks/chunk-2FI6KN3C.js +283 -0
  8. package/dist/chunks/chunk-2HM5Q52B.js +131 -0
  9. package/dist/chunks/{chunk-6MRZXASS.js → chunk-2Q3KLBE6.js} +16 -0
  10. package/dist/chunks/{chunk-ZJDKCC2Y.js → chunk-4GJMCFR6.js} +6 -3
  11. package/dist/chunks/chunk-55GTJG5I.js +1154 -0
  12. package/dist/chunks/chunk-6IC6ZJ74.js +9525 -0
  13. package/dist/chunks/chunk-7KYCYDAS.js +325 -0
  14. package/dist/chunks/chunk-DTOYFY3Z.js +578 -0
  15. package/dist/chunks/chunk-EO3CSXWK.js +70 -0
  16. package/dist/chunks/chunk-FIAFVIAN.js +79 -0
  17. package/dist/chunks/{chunk-J3GZ3DXD.js → chunk-GVMT55GH.js} +3 -2
  18. package/dist/chunks/chunk-H2OT7D6N.js +303 -0
  19. package/dist/chunks/{chunk-JOAL437H.js → chunk-I6MHDUCW.js} +16 -1
  20. package/dist/chunks/chunk-KSQDFE5N.js +85 -0
  21. package/dist/chunks/{chunk-BTIPUR5S.js → chunk-KUEMDPNG.js} +108 -91
  22. package/dist/chunks/{chunk-6XLT25GS.js → chunk-MIKWIFYR.js} +47 -0
  23. package/dist/chunks/{chunk-GTCPZ22N.js → chunk-MTJ2KW3V.js} +3 -1
  24. package/dist/chunks/chunk-MVCBPI4J.js +2354 -0
  25. package/dist/chunks/{chunk-T53L5CJW.js → chunk-PBGUKXT6.js} +2887 -1874
  26. package/dist/chunks/{chunk-KII6KW5Z.js → chunk-RVBAAXRY.js} +64 -44
  27. package/dist/chunks/chunk-SUCYDYMU.js +44 -0
  28. package/dist/chunks/chunk-UBCAZGLE.js +15 -0
  29. package/dist/chunks/{chunk-63H5VXZY.js → chunk-UEUUOAJY.js} +4 -1
  30. package/dist/chunks/chunk-VP7YLCQP.js +244 -0
  31. package/dist/chunks/{chunk-NDEYEYSU.js → chunk-WJII3LZK.js} +4 -3
  32. package/dist/chunks/chunk-XDMMSZIL.js +71 -0
  33. package/dist/chunks/chunk-YKIKJHYO.js +94 -0
  34. package/dist/chunks/{chunk-NYLRTAAA.js → chunk-YVN3VDRE.js} +1 -1
  35. package/dist/chunks/{clear-YBDIPEEH.js → clear-AT7HNUV4.js} +2 -2
  36. package/dist/chunks/{create-L6DJN4ME.js → create-DXW4YYLJ.js} +8 -8
  37. package/dist/chunks/create-LPLNCOW4.js +268 -0
  38. package/dist/chunks/{create-GPDE2YKL.js → create-Y4LHLWGL.js} +26 -18
  39. package/dist/chunks/{delete-LNOYM5KG.js → delete-2EXPFBFC.js} +2 -2
  40. package/dist/chunks/{delete-E4TEBRPX.js → delete-GKYA2W5Z.js} +4 -2
  41. package/dist/chunks/{delete-C4UJ7X5K.js → delete-MJAECXXV.js} +2 -2
  42. package/dist/chunks/disable-TITOSMXB.js +43 -0
  43. package/dist/chunks/doctor-R2Y6UAY4.js +208 -0
  44. package/dist/chunks/enable-LGTPDWPV.js +35 -0
  45. package/dist/chunks/{globals-H2WF344Y.js → globals-SNQFCHMP.js} +1 -1
  46. package/dist/chunks/{init-HU5OMHEH.js → init-KO2HLED5.js} +18 -8
  47. package/dist/chunks/install-7IRUAGSF.js +64 -0
  48. package/dist/chunks/{intro-36OLGNYN.js → intro-JNJ6A75J.js} +89 -21
  49. package/dist/chunks/{kill-2UG7PHUV.js → kill-TX3PC73P.js} +2 -1
  50. package/dist/chunks/{list-2JYMBMZC.js → list-BCCM3TLP.js} +12 -7
  51. package/dist/chunks/{list-4X3JFQGS.js → list-EHREZR6M.js} +2 -1
  52. package/dist/chunks/{list-U7PAYNAH.js → list-LC6HB3H3.js} +2 -2
  53. package/dist/chunks/list-MLKZE36K.js +92 -0
  54. package/dist/chunks/list-QVZKR3IE.js +62 -0
  55. package/dist/chunks/{list-7VHJIUDX.js → list-U4EMHQZT.js} +2 -2
  56. package/dist/chunks/{list-PTAWQYWG.js → list-V7VVD5AG.js} +2 -1
  57. package/dist/chunks/{list-A5WVDBWF.js → list-VA73WPK6.js} +2 -2
  58. package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
  59. package/dist/chunks/migrate-Y3EKMVP5.js +87 -0
  60. package/dist/chunks/{output-RJ6JSNY7.js → output-QN5CVJ62.js} +4 -1
  61. package/dist/chunks/{query-AW7WYILM.js → query-2US3CPYT.js} +2 -2
  62. package/dist/chunks/{registry-RG34DPD7.js → registry-IWP7JMNI.js} +2 -2
  63. package/dist/chunks/{remove-QUH2D3S5.js → remove-BCFTF23J.js} +2 -2
  64. package/dist/chunks/{repl-STBZC4P2.js → repl-2YWTHUWT.js} +4 -0
  65. package/dist/chunks/{repl-BPEWARN7.js → repl-5GDN3RAO.js} +99 -31
  66. package/dist/chunks/resolver-CA2A32AC.js +36 -0
  67. package/dist/chunks/run-WL3IZBXF.js +35 -0
  68. package/dist/chunks/rune-YA4TFHTB.js +283 -0
  69. package/dist/chunks/runner-QNZMBHQY.js +34 -0
  70. package/dist/chunks/{search-MSSDGJTF.js → search-B7IM7JRJ.js} +2 -2
  71. package/dist/chunks/shell-explain-LKBBP2BG.js +77 -0
  72. package/dist/chunks/trust-BFIDANXD.js +109 -0
  73. package/dist/chunks/uninstall-3MWZIZVA.js +58 -0
  74. package/dist/chunks/{unset-YASSMSE5.js → unset-P6IUF7SS.js} +2 -2
  75. package/dist/chunks/{update-KSC6VRMU.js → update-W4MJUTTW.js} +25 -19
  76. package/dist/chunks/{update-EWWDROKW.js → update-WXT7CHYA.js} +2 -2
  77. package/dist/chunks/{utils-3SJFSUSV.js → utils-B2QULX5J.js} +8 -4
  78. package/dist/chunks/{version-YG2M7HER.js → version-FLHI5KFS.js} +3 -3
  79. package/dist/cli.js +115 -70
  80. package/package.json +2 -2
  81. package/dist/chunks/chunk-ASZKAC24.js +0 -103
  82. package/dist/chunks/chunk-G3U4V32O.js +0 -46
  83. package/dist/chunks/chunk-GSA432UC.js +0 -90
  84. package/dist/chunks/chunk-WJRZN7BR.js +0 -77492
  85. package/dist/chunks/create-VYZRWRGQ.js +0 -170
  86. package/dist/chunks/disable-FGJ7VMPO.js +0 -47
  87. package/dist/chunks/doctor-7NWBJAH7.js +0 -53
  88. package/dist/chunks/enable-ZL6QOC2I.js +0 -47
  89. package/dist/chunks/install-FIYRMVLR.js +0 -57
  90. package/dist/chunks/list-AIYNOPNZ.js +0 -28
  91. package/dist/chunks/list-NZ5DHXJF.js +0 -111
  92. package/dist/chunks/resolver-36V72VKR.js +0 -28
  93. package/dist/chunks/run-IVL23SMW.js +0 -26
  94. package/dist/chunks/rune-XRREUL56.js +0 -186
  95. package/dist/chunks/uninstall-G56DZRFG.js +0 -49
@@ -0,0 +1,208 @@
1
+ import {
2
+ getConfigPath,
3
+ readRawConfig
4
+ } from "./chunk-SUCYDYMU.js";
5
+ import {
6
+ output
7
+ } from "./chunk-MIKWIFYR.js";
8
+ import "./chunk-CGZL5SSH.js";
9
+ import "./chunk-WCODTMDN.js";
10
+ import {
11
+ describeRunBlock
12
+ } from "./chunk-DTOYFY3Z.js";
13
+ import {
14
+ assertNotMissedRename,
15
+ onPath,
16
+ resolveInterpreter
17
+ } from "./chunk-2DNYVKBF.js";
18
+ import {
19
+ isNativeRune,
20
+ trustDigest,
21
+ trustState
22
+ } from "./chunk-XDMMSZIL.js";
23
+ import {
24
+ coercePlugins,
25
+ loadConfig
26
+ } from "./chunk-2FI6KN3C.js";
27
+ import "./chunk-UBCAZGLE.js";
28
+ import {
29
+ loadRegistry
30
+ } from "./chunk-MTJ2KW3V.js";
31
+ import {
32
+ loadPluginJson
33
+ } from "./chunk-FIAFVIAN.js";
34
+ import {
35
+ loadJsonSchema
36
+ } from "./chunk-VP7YLCQP.js";
37
+ import "./chunk-YKIKJHYO.js";
38
+ import "./chunk-MVCBPI4J.js";
39
+ import "./chunk-GVMT55GH.js";
40
+ import "./chunk-2HM5Q52B.js";
41
+ import "./chunk-WJII3LZK.js";
42
+ import "./chunk-G4ZAUHHA.js";
43
+ import "./chunk-2Q3KLBE6.js";
44
+ import "./chunk-55GTJG5I.js";
45
+ import {
46
+ init_require_shim
47
+ } from "./chunk-TPK5AGRA.js";
48
+
49
+ // src/cli/commands/doctor.js
50
+ init_require_shim();
51
+ import { spawnSync } from "node:child_process";
52
+ import { existsSync } from "node:fs";
53
+ import { relative } from "node:path";
54
+ async function checkPluginNativeTrust(config) {
55
+ const results = [];
56
+ let registry;
57
+ try {
58
+ registry = await loadRegistry();
59
+ } catch {
60
+ return results;
61
+ }
62
+ const enabled = new Set(Object.entries(config?.plugins ?? {}).filter(([, v]) => v).map(([k]) => k));
63
+ for (const [pluginKey, regEntry] of Object.entries(registry.plugins ?? {})) {
64
+ if (!enabled.has(pluginKey) || !regEntry?.path) continue;
65
+ try {
66
+ const pj = await loadPluginJson(regEntry.path);
67
+ for (const [runeKey, runeDef] of Object.entries(pj.runes ?? {})) {
68
+ if (!isNativeRune(runeDef)) continue;
69
+ const digest = trustDigest(regEntry.path, runeDef);
70
+ const state = trustState(regEntry, runeKey, digest);
71
+ if (state === "trusted") {
72
+ results.push({ ok: true, message: `plugin ${pluginKey}:${runeKey} native script trusted` });
73
+ } else if (state === "changed") {
74
+ results.push({ ok: false, message: `plugin ${pluginKey}:${runeKey} changed since trusted (run: crunes plugin trust ${pluginKey} ${runeKey})` });
75
+ } else {
76
+ results.push({ ok: false, message: `plugin ${pluginKey}:${runeKey} runs natively outside sandbox and is not yet trusted (run: crunes plugin trust ${pluginKey} ${runeKey})` });
77
+ }
78
+ }
79
+ } catch {
80
+ }
81
+ }
82
+ return results;
83
+ }
84
+ function checkRunBlockRunes(config, projectRoot) {
85
+ const results = [];
86
+ for (const [key, entry] of Object.entries(config?.runes ?? {})) {
87
+ if (entry?.run == null) continue;
88
+ const run = typeof entry.run === "string" ? { command: entry.run } : entry.run;
89
+ if (!run?.command) continue;
90
+ const desc = describeRunBlock(entry, projectRoot);
91
+ if (desc.runtime === "isolate") {
92
+ results.push({ ok: true, message: `${key} \u2192 isolate` });
93
+ continue;
94
+ }
95
+ try {
96
+ if (desc.runtime === "program") {
97
+ if (!onPath(desc.command)) throw new Error(`"${desc.command}" is not on PATH`);
98
+ } else if (!existsSync(desc.command)) {
99
+ throw new Error(`${relative(projectRoot, desc.command).replace(/\\/g, "/")} does not exist`);
100
+ }
101
+ assertNotMissedRename(desc.command, desc.runtime, projectRoot);
102
+ if (desc.argsModule && /\.json$/i.test(desc.argsModule)) {
103
+ loadJsonSchema(desc.argsModule, relative(projectRoot, desc.argsModule).replace(/\\/g, "/"));
104
+ }
105
+ const found = resolveInterpreter(desc.runtime, projectRoot);
106
+ const how = found ? `${desc.runtime}: ${[found.command, ...found.args].join(" ")}` : desc.runtime === "program" ? `program: ${onPath(desc.command)}` : `${desc.runtime}: run directly`;
107
+ results.push({ ok: true, message: `${key} \u2192 ${how} (native)` });
108
+ } catch (err) {
109
+ results.push({ ok: false, message: `${key}: ${err.message}` });
110
+ }
111
+ }
112
+ return results;
113
+ }
114
+ var KNOWN_FORMATS = /* @__PURE__ */ new Set(["1"]);
115
+ function collectLayerWarnings({ global = {}, project = {} } = {}) {
116
+ const warnings = [];
117
+ for (const key of Object.keys(project.runes ?? {})) {
118
+ if (global.runes?.[key]) {
119
+ warnings.push(`rune "${key}" shadows the global rune of the same name`);
120
+ }
121
+ }
122
+ const globalPlugins = coercePlugins(global.plugins);
123
+ const projectPlugins = coercePlugins(project.plugins);
124
+ for (const [key, enabled] of Object.entries(projectPlugins)) {
125
+ if (globalPlugins[key] === true && enabled === false) {
126
+ warnings.push(`plugin "${key}" is enabled globally but disabled in this project`);
127
+ }
128
+ }
129
+ return warnings;
130
+ }
131
+ async function handler({ projectRoot = process.cwd() } = {}) {
132
+ let anyFailed = false;
133
+ const major = parseInt(process.versions.node.split(".")[0], 10);
134
+ if (major >= 22) {
135
+ output.success(`Node.js v${process.versions.node}`);
136
+ } else {
137
+ output.error(`Node.js v${process.versions.node} \u2014 requires >= 22`);
138
+ anyFailed = true;
139
+ }
140
+ const versionResult = spawnSync("crunes", ["--version"], { encoding: "utf8", shell: true });
141
+ if (versionResult.status === 0) {
142
+ output.success(`crunes ${versionResult.stdout.trim()} in PATH`);
143
+ } else {
144
+ output.warn("crunes not found globally in PATH (you can still run it locally or via npx)");
145
+ }
146
+ let config;
147
+ try {
148
+ config = loadConfig(projectRoot);
149
+ } catch (err) {
150
+ output.error(`Config: ${err.message}`);
151
+ anyFailed = true;
152
+ }
153
+ if (config) {
154
+ const runeCount = Object.keys(config.runes ?? {}).length;
155
+ if (config.format !== void 0 && !KNOWN_FORMATS.has(String(config.format))) {
156
+ output.error(`Config format "${config.format}" not recognised by this CLI version`);
157
+ anyFailed = true;
158
+ } else {
159
+ output.success(`Config valid \u2014 ${runeCount} rune${runeCount === 1 ? "" : "s"} registered`);
160
+ }
161
+ for (const { ok, message } of checkRunBlockRunes(config, projectRoot)) {
162
+ if (ok) output.success(message);
163
+ else {
164
+ output.error(message);
165
+ anyFailed = true;
166
+ }
167
+ }
168
+ for (const { ok, message } of await checkPluginNativeTrust(config)) {
169
+ if (ok) output.success(message);
170
+ else {
171
+ output.info(message);
172
+ }
173
+ }
174
+ }
175
+ const globalPath = getConfigPath({ global: true });
176
+ let globalRaw = null;
177
+ try {
178
+ globalRaw = readRawConfig(globalPath);
179
+ } catch {
180
+ }
181
+ if (process.env.CRUNES_NO_GLOBAL === "1") {
182
+ output.warn("Global config skipped (CRUNES_NO_GLOBAL=1)");
183
+ } else if (globalRaw) {
184
+ output.success(`Global config found at ${globalPath}`);
185
+ } else {
186
+ output.info(`No global config at ${globalPath}`);
187
+ }
188
+ let projectRaw = null;
189
+ try {
190
+ projectRaw = readRawConfig(getConfigPath({ configRoot: projectRoot }));
191
+ } catch {
192
+ }
193
+ if (!projectRaw) {
194
+ output.info("No project config \u2014 crunes runs rootless here, writing no local state");
195
+ }
196
+ for (const warning of collectLayerWarnings({ global: globalRaw ?? {}, project: projectRaw ?? {} })) {
197
+ output.warn(warning);
198
+ }
199
+ if (anyFailed) {
200
+ process.exit(1);
201
+ }
202
+ }
203
+ export {
204
+ checkPluginNativeTrust,
205
+ checkRunBlockRunes,
206
+ collectLayerWarnings,
207
+ handler
208
+ };
@@ -0,0 +1,35 @@
1
+ import {
2
+ getConfigPath,
3
+ setPluginEnabled
4
+ } from "./chunk-SUCYDYMU.js";
5
+ import "./chunk-2FI6KN3C.js";
6
+ import "./chunk-UBCAZGLE.js";
7
+ import {
8
+ loadRegistry,
9
+ resolvePluginKey
10
+ } from "./chunk-MTJ2KW3V.js";
11
+ import "./chunk-VP7YLCQP.js";
12
+ import "./chunk-YKIKJHYO.js";
13
+ import "./chunk-2Q3KLBE6.js";
14
+ import "./chunk-55GTJG5I.js";
15
+ import {
16
+ init_require_shim
17
+ } from "./chunk-TPK5AGRA.js";
18
+
19
+ // src/plugin/commands/enable.js
20
+ init_require_shim();
21
+ async function handler({ name, projectRoot, configRoot, global = false }) {
22
+ try {
23
+ const registry = await loadRegistry();
24
+ const pluginKey = resolvePluginKey(name, registry);
25
+ if (!pluginKey) throw new Error(`Plugin "${name}" is not installed. Run: crunes plugin list`);
26
+ await setPluginEnabled(getConfigPath({ configRoot: configRoot ?? projectRoot, global }), pluginKey, true);
27
+ console.log(`Plugin "${pluginKey}" enabled${global ? " globally" : ""}.`);
28
+ } catch (err) {
29
+ console.error(`Error: ${err.message}`);
30
+ process.exit(1);
31
+ }
32
+ }
33
+ export {
34
+ handler
35
+ };
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  formatMembers,
6
6
  walk
7
- } from "./chunk-JOAL437H.js";
7
+ } from "./chunk-I6MHDUCW.js";
8
8
  import {
9
9
  init_require_shim
10
10
  } from "./chunk-TPK5AGRA.js";
@@ -1,13 +1,22 @@
1
+ import {
2
+ getConfigPath
3
+ } from "./chunk-SUCYDYMU.js";
4
+ import {
5
+ output
6
+ } from "./chunk-MIKWIFYR.js";
1
7
  import {
2
8
  fe,
3
9
  ge,
4
10
  le,
5
11
  ye
6
12
  } from "./chunk-CGZL5SSH.js";
7
- import {
8
- output
9
- } from "./chunk-6XLT25GS.js";
10
13
  import "./chunk-WCODTMDN.js";
14
+ import "./chunk-2FI6KN3C.js";
15
+ import "./chunk-UBCAZGLE.js";
16
+ import "./chunk-VP7YLCQP.js";
17
+ import "./chunk-YKIKJHYO.js";
18
+ import "./chunk-2Q3KLBE6.js";
19
+ import "./chunk-55GTJG5I.js";
11
20
  import {
12
21
  init_require_shim
13
22
  } from "./chunk-TPK5AGRA.js";
@@ -15,15 +24,16 @@ import {
15
24
  // src/core/commands/init.js
16
25
  init_require_shim();
17
26
  import { mkdirSync, writeFileSync, existsSync } from "node:fs";
18
- import { join } from "node:path";
27
+ import { join, dirname } from "node:path";
19
28
  var EMPTY_CONFIG = JSON.stringify({ runes: {} }, null, 2) + "\n";
20
29
  var GITIGNORE_CONTENT = "# local overrides (machine-specific, never commit)\nconfig.local.json\nproject.local.json\n\n# run logs\nlogs/\n\n# local caches, databases, schema cache and job logs (gitignored by default)\ncaches/\nschemas/\nsqlite/\njobs/\n";
21
30
  async function handler({
22
31
  yes = false,
23
- projectRoot = process.cwd()
32
+ projectRoot = process.cwd(),
33
+ global = false
24
34
  } = {}) {
25
- const configDir = join(projectRoot, ".crunes");
26
- const configPath = join(configDir, "config.json");
35
+ const configPath = getConfigPath({ configRoot: projectRoot, global });
36
+ const configDir = dirname(configPath);
27
37
  const isNonInteractive = yes || !process.stdout.isTTY;
28
38
  if (existsSync(configPath)) {
29
39
  if (!yes) {
@@ -45,7 +55,7 @@ async function handler({
45
55
  mkdirSync(configDir, { recursive: true });
46
56
  writeFileSync(configPath, EMPTY_CONFIG);
47
57
  const gitignorePath = join(configDir, ".gitignore");
48
- if (!existsSync(gitignorePath)) {
58
+ if (!global && !existsSync(gitignorePath)) {
49
59
  writeFileSync(gitignorePath, GITIGNORE_CONTENT);
50
60
  }
51
61
  if (!isNonInteractive) {
@@ -0,0 +1,64 @@
1
+ import {
2
+ resolveFromMarketplace
3
+ } from "./chunk-YVN3VDRE.js";
4
+ import {
5
+ installPlugin
6
+ } from "./chunk-RVBAAXRY.js";
7
+ import "./chunk-SUCYDYMU.js";
8
+ import {
9
+ output
10
+ } from "./chunk-MIKWIFYR.js";
11
+ import "./chunk-CGZL5SSH.js";
12
+ import "./chunk-WCODTMDN.js";
13
+ import "./chunk-XDMMSZIL.js";
14
+ import "./chunk-2FI6KN3C.js";
15
+ import "./chunk-UBCAZGLE.js";
16
+ import "./chunk-MTJ2KW3V.js";
17
+ import "./chunk-FIAFVIAN.js";
18
+ import "./chunk-VP7YLCQP.js";
19
+ import "./chunk-YKIKJHYO.js";
20
+ import "./chunk-2Q3KLBE6.js";
21
+ import "./chunk-55GTJG5I.js";
22
+ import {
23
+ init_require_shim
24
+ } from "./chunk-TPK5AGRA.js";
25
+
26
+ // src/plugin/commands/install.js
27
+ init_require_shim();
28
+ function parseInstallArg(arg) {
29
+ const idx = arg.indexOf("@");
30
+ if (idx === -1) return null;
31
+ return [arg.slice(0, idx), arg.slice(idx + 1)];
32
+ }
33
+ async function handler({ source, projectRoot, configRoot, yes, global = false }) {
34
+ const parts = parseInstallArg(source);
35
+ if (!parts) {
36
+ output.cancel("Use <marketplace>@<plugin> format (e.g. hello-world@hello-world)");
37
+ process.exit(1);
38
+ }
39
+ const [marketplaceName, pluginName] = parts;
40
+ output.intro("Installing plugin\u2026");
41
+ let resolvedSource, provenance;
42
+ try {
43
+ ;
44
+ ({ resolvedSource, ...provenance } = await resolveFromMarketplace(marketplaceName, pluginName));
45
+ } catch (err) {
46
+ output.cancel(err.message);
47
+ process.exit(1);
48
+ }
49
+ let result;
50
+ try {
51
+ result = await installPlugin(resolvedSource, configRoot ?? projectRoot, provenance, { yes, global });
52
+ } catch (err) {
53
+ output.cancel(`Installation failed: ${err.message}`);
54
+ process.exit(1);
55
+ }
56
+ if (!result.installed) {
57
+ output.cancel("Installation cancelled.");
58
+ process.exit(0);
59
+ }
60
+ output.outro(`Installed ${result.name}@${result.version}`);
61
+ }
62
+ export {
63
+ handler
64
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  utils_api_default
3
- } from "./chunk-T53L5CJW.js";
3
+ } from "./chunk-PBGUKXT6.js";
4
4
  import {
5
5
  globals_api_default
6
6
  } from "./chunk-V35LVVNV.js";
@@ -8,11 +8,11 @@ import {
8
8
  formatMembers,
9
9
  formatNode,
10
10
  walk
11
- } from "./chunk-JOAL437H.js";
12
- import "./chunk-ASZKAC24.js";
11
+ } from "./chunk-I6MHDUCW.js";
13
12
  import {
14
13
  output
15
- } from "./chunk-6XLT25GS.js";
14
+ } from "./chunk-MIKWIFYR.js";
15
+ import "./chunk-CGZL5SSH.js";
16
16
  import "./chunk-WCODTMDN.js";
17
17
  import {
18
18
  init_require_shim
@@ -2519,11 +2519,13 @@ async function compileIntro() {
2519
2519
  lines.push("");
2520
2520
  lines.push("Crunes execute inside an isolated sandbox (`isolated-vm`). Runes are ESM modules with two primary execution modes: **run** (one-shot) and **repl** (interactive session).");
2521
2521
  lines.push("");
2522
- lines.push("Scaffold a new rune with `crunes create`. In non-interactive/agent sessions `--format` is required (no default); `--path` defaults to `.crunes/runes/<key>.js` if omitted:");
2522
+ lines.push("Scaffold a new rune with `crunes create`. In non-interactive/agent sessions `--format` is required (no default); `--path` defaults to `.crunes/runes/<key>.rune.js` if omitted \u2014 the `.rune.js` suffix is what runs a file in the isolate. `-y`/`--yes` is a global flag, so it goes **before** the subcommand:");
2523
2523
  lines.push("```bash");
2524
- lines.push("crunes create my-rune --format markdown --yes");
2524
+ lines.push("crunes -y create my-rune --format markdown");
2525
2525
  lines.push("```");
2526
2526
  lines.push("");
2527
+ lines.push("`crunes create` does not write a `permissions` block. Grants live in `.crunes/config.json` under `runes.<key>.run.permissions.allow` \u2014 not in the rune file \u2014 so add them there once you know what the rune touches (section 3).");
2528
+ lines.push("");
2527
2529
  lines.push('**Run mode** \u2014 export `args` to declare a schema and `run` to execute. `--help`/`-h` is NOT intercepted by `crunes run` \u2014 declare it yourself and check it at the top of `run(args)`, as shown below. This example also shows `args(builder)` reading `vars` at schema-build time to compute a dynamic option (`--profile`), a common pattern for anything with a "profile"/"environment" concept:');
2528
2530
  lines.push("");
2529
2531
  lines.push("```javascript");
@@ -2631,49 +2633,48 @@ async function compileIntro() {
2631
2633
  lines.push("");
2632
2634
  lines.push("Configuration properties in `.crunes/config.json` control permissions, default variables, mappings, and plugin registration.");
2633
2635
  lines.push("");
2634
- lines.push("`crunes init` also scaffolds a `.crunes/.gitignore` covering local-only files (`config.local.json`, `project.local.json`) and generated directories (`logs/`, `caches/`, `schemas/`, `sqlite/`, `jobs/`) \u2014 only `config.json` and your rune `.js` files need to be committed.");
2636
+ lines.push("`crunes init` also scaffolds a `.crunes/.gitignore` covering local-only files (`config.local.json`, `project.local.json`) and generated directories (`logs/`, `caches/`, `schemas/`, `sqlite/`, `jobs/`) \u2014 only `config.json` and your rune `.rune.js` files need to be committed.");
2635
2637
  lines.push("");
2636
2638
  lines.push("### Sandbox Security & Permissions");
2637
- lines.push("Runes do not have direct access to Node.js APIs. They declare specific lifecycle-scoped permission scopes nested inside their own entry in `.crunes/config.json`:");
2639
+ lines.push("Runes do not have direct access to Node.js APIs. A rune entry names its module in a `run` block, and the grants for it inside that block in `.crunes/config.json`. Nothing is found by convention: a rune runs only the module its entry names.");
2638
2640
  lines.push("```json");
2639
2641
  lines.push("{");
2640
2642
  lines.push(' "runes": {');
2641
2643
  lines.push(' "my-rune": {');
2642
2644
  lines.push(' "name": "My Rune",');
2643
2645
  lines.push(' "description": "Does something useful",');
2644
- lines.push(' "path": ".crunes/runes/my-rune.js",');
2645
2646
  lines.push(' "vars": { "api_url": "https://example.com" },');
2646
- lines.push(' "permissions": {');
2647
- lines.push(' "run": { "allow": ["fs.read:src/**", "fs.write:dist/**", "shell.run:git *"] }');
2647
+ lines.push(' "run": {');
2648
+ lines.push(' "command": ".crunes/runes/my-rune.rune.js",');
2649
+ lines.push(' "permissions": { "allow": ["fs.read:src/**", "fs.write:dist/**", "shell.run:git *"] }');
2648
2650
  lines.push(" }");
2649
2651
  lines.push(" }");
2650
2652
  lines.push(" }");
2651
2653
  lines.push("}");
2652
2654
  lines.push("```");
2653
2655
  lines.push("");
2654
- lines.push("For runes that use both `run` and `repl`, declare both permission namespaces separately \u2014 `repl` does not inherit from `run`:");
2656
+ lines.push("A rune has a REPL only when its entry declares a `repl` block, with its own grants \u2014 `repl` does not inherit from `run`:");
2655
2657
  lines.push("```json");
2656
2658
  lines.push("{");
2657
2659
  lines.push(' "runes": {');
2658
2660
  lines.push(' "my-shell": {');
2659
- lines.push(' "permissions": {');
2660
- lines.push(' "run": { "allow": ["sqlite.read:./state::db"] },');
2661
- lines.push(' "repl": { "allow": ["sqlite.read:./state::db", "sqlite.write:./state::db"] }');
2662
- lines.push(" }");
2661
+ lines.push(' "run": { "command": ".crunes/runes/my-shell.rune.js", "permissions": { "allow": ["sqlite.read:./state::db"] } },');
2662
+ lines.push(' "repl": { "command": ".crunes/runes/my-shell.rune.js", "permissions": { "allow": ["sqlite.read:./state::db", "sqlite.write:./state::db"] } }');
2663
2663
  lines.push(" }");
2664
2664
  lines.push(" }");
2665
2665
  lines.push("}");
2666
2666
  lines.push("```");
2667
+ lines.push('A block written as a string is shorthand for `{ "command": \u2026 }`. An entry in the old shape \u2014 `path`, `permissions.run`, or none at all relying on `.crunes/runes/<key>.js` \u2014 is refused; `crunes migrate` rewrites every entry and renames the modules.');
2667
2668
  lines.push("");
2668
2669
  lines.push('To grant a **plugin** rune extra permissions or vars from the project side (plugin runes have no `runes.<key>` entry of their own), add an entry keyed by the fully-qualified `"marketplace@plugin:runeKey"` string \u2014 **this must always be the full form, never the bare plugin name**, since two enabled plugins could share a bare name and a bare-form key can never resolve to anything (config loading rejects a bare-form key outright).');
2669
2670
  lines.push("```json");
2670
2671
  lines.push("{");
2671
- lines.push(' "plugins": ["my-market@my-plugin"],');
2672
+ lines.push(' "plugins": { "my-market@my-plugin": true },');
2672
2673
  lines.push(' "runes": {');
2673
2674
  lines.push(' "my-market@my-plugin:deploy": {');
2674
2675
  lines.push(' "vars": { "region": "us-east-1" },');
2675
- lines.push(' "permissions": {');
2676
- lines.push(' "run": { "allow": ["fs.read:src/**"] }');
2676
+ lines.push(' "run": {');
2677
+ lines.push(' "permissions": { "allow": ["fs.read:src/**"] }');
2677
2678
  lines.push(" }");
2678
2679
  lines.push(" }");
2679
2680
  lines.push(" }");
@@ -2693,9 +2694,76 @@ async function compileIntro() {
2693
2694
  lines.push("```");
2694
2695
  lines.push("Now `crunes run git` always resolves to that specific plugin rune, with no ambiguity, regardless of what else is enabled.");
2695
2696
  lines.push("");
2697
+ lines.push("### Script Runes");
2698
+ lines.push("A rune can also be a Node, Python or bash script, or a program on `PATH`. Its `run` block names the script instead of a `*.rune.js` module \u2014 `crunes add <key> <command>` writes one:");
2699
+ lines.push("```json");
2700
+ lines.push("{");
2701
+ lines.push(' "runes": {');
2702
+ lines.push(' "coverage": { "description": "Coverage per module", "run": "tools/coverage.py", "args": ".crunes/runes/coverage.args.rune.js" },');
2703
+ lines.push(' "log": { "description": "Recent commits", "run": { "command": "git", "argv": ["log", "--oneline", "-n", "20"] } },');
2704
+ lines.push(' "api": { "run": { "command": ".crunes/runes/api.rune.js", "permissions": { "allow": ["fs.read:src/**"] } } }');
2705
+ lines.push(" }");
2706
+ lines.push("}");
2707
+ lines.push("```");
2708
+ lines.push("- **`run.command`** is resolved like a shell resolves a command: a value with a path separator, a leading `.`, or an absolute path is a file relative to the config layer; a bare name is a program on `PATH`. A file name selects the runtime: `*.rune.js` runs in the isolate, `.js`/`.mjs`/`.cjs` with Node, `.py` with Python (`CRUNES_PYTHON`, the active virtualenv, a project `.venv/` or `venv/`, then `python3`/`python`), `.sh` with bash; anything else is executed directly. `run.argv` is placed before the caller's arguments.");
2709
+ lines.push("- **Script runes run natively, with full access** \u2014 `run.permissions` is only accepted for a `*.rune.js` module. `crunes list` marks them `native`; `crunes doctor` reports the interpreter each one resolves to.");
2710
+ lines.push("- **A plugin may ship script runes too**, with the same `run` and `args` blocks in its `plugin.json`. Installing the plugin does not make them runnable: each is refused until you review it with `crunes plugin trust <plugin> [rune]`, which shows the command and the script itself and records your trust against exactly that content. A plugin update that changes a script, its command or its schema needs trusting again. Every run of a plugin script says on standard error that it runs natively; the script receives `CRUNES_PLUGIN_ROOT` beside the usual variables.");
2711
+ lines.push("- **`args`** documents and parses a script's arguments: crunes answers `--help`, `crunes docs rune` shows the schema, and the script receives the parsed result as JSON in `CRUNES_ARGS` alongside the raw arguments. It is a JSON schema \u2014 written inline, or in a `.json` file \u2014 or a `*.rune.js` module whose `args(builder)` export builds one. In a JSON schema, an option takes `default`, `required` and `choices`, a positional takes `choices`, and either takes `type` (`string`, `number` or `integer`; values are strings unless declared otherwise); crunes refuses a call that is missing a required argument, uses a value outside its choices, or is not of the declared type, before the script starts. Without an `args` block, arguments pass through unchanged.");
2712
+ lines.push("- **`run.timeout`** \u2014 seconds a rune may run. A script still running is stopped (SIGTERM, then SIGKILL five seconds later, with the processes it started) and ends with status 124 when run on its own, or fails the rune when captured; an isolate module's timeout replaces the default 30 seconds. A script has no timeout unless its entry declares one.");
2713
+ lines.push('- **`run.pass: "mapped"`** makes the schema the rune\'s whole surface: a call with an option or argument the schema does not declare is refused, and the parsed call is rewritten into the program\'s own arguments instead of being passed raw. Each positional, option or command may declare `to` \u2014 the program tokens it becomes, with `{value}` for its value, e.g. `{ "flags": "--limit <n>", "type": "integer", "to": ["-n", "{value}"] }`; without `to`, an option is passed as its own flag. The order is `run.argv`, the matched command path, the options as declared, then the positionals.');
2714
+ lines.push("```json");
2715
+ lines.push('"args": {');
2716
+ lines.push(' "positionals": [{ "spec": "<module>", "description": "Module to report on", "choices": ["auth", "billing"] }],');
2717
+ lines.push(' "options": [{ "flags": "--min <percent>", "description": "Fail below this", "default": "0" }]');
2718
+ lines.push("}");
2719
+ lines.push("```");
2720
+ lines.push('- **`run.output: "sections"`** lets a script print named sections: each standard-output line shaped like a `--format jsonl` section event \u2014 `{"type":"section","section":{"name":"summary","data":{"type":"markdown","content":"\u2026"}}}` \u2014 becomes a section as soon as it is printed, filterable with `-s`; any other line is plain text. Run on its own, a script\'s sections print as markdown; in a batch or JSONL they are labelled like any rune\'s.');
2721
+ lines.push("- **`crunes create --lang python|bash|node <key>`** scaffolds a script rune; `crunes add <key> <command>` registers one that already exists.");
2722
+ lines.push("- **Run on its own, a script rune gets the caller's terminal and standard streams and returns its own exit code.** In a batch, `--format jsonl` or `rune.exec`, its standard output is captured as an `output` section and a non-zero exit fails it. Every script also receives `CRUNES_PROJECT_ROOT`, `CRUNES_RUNE_KEY`, `CRUNES_LIFECYCLE`, and `CRUNES_VARS` \u2014 the rune's configured `vars` as a JSON object.");
2723
+ lines.push("");
2696
2724
  lines.push("### Config File Fields Reference");
2697
- lines.push('- **`runes`**: Definition of project-registered runes, keyed by rune key (or the fully-qualified `"marketplace@plugin:runeKey"` string for a plugin-rune override \u2014 never a bare plugin name). Each entry may declare `path`, `name`, `description`, `vars` (key-value settings read via `utils.vars.read(key)`), `permissions` (lifecycle-scoped allow/deny lists), or `plugin` (an alias to a specific plugin rune, see above).');
2698
- lines.push("- **`plugins`**: List of enabled third-party marketplaces or plugins.");
2725
+ lines.push('- **`runes`**: Definition of project-registered runes, keyed by rune key (or the fully-qualified `"marketplace@plugin:runeKey"` string for a plugin-rune override \u2014 never a bare plugin name). Each entry declares a `run` block (and optionally `args` \u2014 see Script Runes \u2014 and `repl`), `name`, `description` and `vars` (key-value settings read via `utils.vars.read(key)`); or `plugin` (an alias to a specific plugin rune, see above). Grants live inside the `run` and `repl` blocks as `{ "allow": [...], "deny": [...] }`; a plugin alias or `marketplace@plugin:rune` override may carry blocks with only `permissions`.');
2726
+ lines.push('- **`plugins`**: Map of plugin key to a boolean, e.g. `{"my-market@my-plugin": true}`. A legacy array of keys is still read and is converted to map form on the next write. `false` is meaningful: it turns a plugin off in this layer even though a lower layer enabled it.');
2727
+ lines.push("- **`templates`**: Definition of registered templates, keyed by template name, merged across layers exactly like `runes`.");
2728
+ lines.push("");
2729
+ lines.push("### Config Layers");
2730
+ lines.push("Configuration merges across three layers, lowest to highest \u2014 later layers win per key:");
2731
+ lines.push("```");
2732
+ lines.push("1. ~/.crunes/config.json (global \u2014 personal, machine-wide)");
2733
+ lines.push("2. <project>/.crunes/config.json");
2734
+ lines.push("3. <project>/.crunes/config.local.json");
2735
+ lines.push("```");
2736
+ lines.push("`~/.crunes` **is** the global config directory, so global paths carry no `.crunes/` segment: a global rune's module is written `runes/<key>.rune.js` and lives at `~/.crunes/runes/<key>.rune.js`. Each layer resolves its own files before merging, so a project can override one field of a global rune and still load the global file:");
2737
+ lines.push("```json");
2738
+ lines.push("// ~/.crunes/config.json");
2739
+ lines.push('{ "runes": { "serve": { "run": "runes/serve.rune.js", "vars": { "port": 3000 } } } }');
2740
+ lines.push("");
2741
+ lines.push("// <project>/.crunes/config.json \u2014 same rune, different port");
2742
+ lines.push('{ "runes": { "serve": { "vars": { "port": 4000 } } } }');
2743
+ lines.push("```");
2744
+ lines.push('Because `plugins` is a boolean map, a project can also opt out of a globally-enabled plugin \u2014 `crunes plugin disable <name>` writes `{"my-market@my-plugin": false}` into the project config, leaving the global enable intact.');
2745
+ lines.push("");
2746
+ lines.push("`CRUNES_NO_GLOBAL=1` skips the global layer entirely. Set it in CI so a developer's personal config can never alter project behavior.");
2747
+ lines.push("");
2748
+ lines.push("### Rootless Mode");
2749
+ lines.push("In a directory with no `.crunes/config.json`, crunes runs **rootless**: the global layer alone applies, and every piece of local state \u2014 caches, SQLite databases, job logs, schema caches, `node_modules` \u2014 is redirected into the store under `~/.crunes/rootless/<hash-of-cwd>/`. **Nothing is written outside the store.** Running a global rune inside an Obsidian vault or any other directory leaves that directory byte-identical.");
2750
+ lines.push("");
2751
+ lines.push('`@project/` and permission paths still resolve against the current working directory, which is what makes a generic "serve this directory" rune work from anywhere. **This is also the security property to understand:** a permission granted once in the global config applies in every directory you invoke that rune from. Scope global-rune permissions deliberately.');
2752
+ lines.push("");
2753
+ lines.push("Running `crunes init` in such a directory turns it into a project \u2014 the layer simply appears.");
2754
+ lines.push("");
2755
+ lines.push("### Global Commands");
2756
+ lines.push("`-g` / `--global` targets the global config instead of the project:");
2757
+ lines.push("```bash");
2758
+ lines.push("crunes init -g # create ~/.crunes/config.json");
2759
+ lines.push("crunes create -g serve # write ~/.crunes/runes/serve.rune.js and register it");
2760
+ lines.push("crunes plugin install -g mkt@plug # install and enable everywhere");
2761
+ lines.push("crunes plugin enable -g plug");
2762
+ lines.push("crunes plugin disable plug # opt this project out of a global enable");
2763
+ lines.push("crunes plugin disable -g plug # turn it off everywhere");
2764
+ lines.push("crunes template create -g base # ~/.crunes/templates/base.js");
2765
+ lines.push("crunes list -g # global entries only; bare `list` shows the merged set with a Layer column");
2766
+ lines.push("```");
2699
2767
  lines.push("");
2700
2768
  lines.push("## 4. Rune Exports API Reference");
2701
2769
  lines.push("");
@@ -2,7 +2,8 @@ import {
2
2
  deleteJob,
3
3
  listJobs,
4
4
  resolveJobId
5
- } from "./chunk-ZJDKCC2Y.js";
5
+ } from "./chunk-4GJMCFR6.js";
6
+ import "./chunk-2Q3KLBE6.js";
6
7
  import {
7
8
  init_require_shim
8
9
  } from "./chunk-TPK5AGRA.js";
@@ -1,20 +1,25 @@
1
1
  import {
2
2
  require_cli_table3
3
3
  } from "./chunk-DMMC4X27.js";
4
- import {
5
- loadConfig
6
- } from "./chunk-GSA432UC.js";
7
4
  import {
8
5
  output
9
- } from "./chunk-6XLT25GS.js";
6
+ } from "./chunk-MIKWIFYR.js";
7
+ import "./chunk-CGZL5SSH.js";
10
8
  import "./chunk-WCODTMDN.js";
9
+ import {
10
+ loadConfig
11
+ } from "./chunk-2FI6KN3C.js";
12
+ import "./chunk-UBCAZGLE.js";
11
13
  import {
12
14
  loadRegistry
13
- } from "./chunk-GTCPZ22N.js";
14
- import "./chunk-6MRZXASS.js";
15
+ } from "./chunk-MTJ2KW3V.js";
15
16
  import {
16
17
  loadPluginJson
17
- } from "./chunk-G3U4V32O.js";
18
+ } from "./chunk-FIAFVIAN.js";
19
+ import "./chunk-VP7YLCQP.js";
20
+ import "./chunk-YKIKJHYO.js";
21
+ import "./chunk-2Q3KLBE6.js";
22
+ import "./chunk-55GTJG5I.js";
18
23
  import {
19
24
  __toESM,
20
25
  init_require_shim
@@ -2,7 +2,8 @@ import {
2
2
  cleanJobs,
3
3
  isAlive,
4
4
  listJobs
5
- } from "./chunk-ZJDKCC2Y.js";
5
+ } from "./chunk-4GJMCFR6.js";
6
+ import "./chunk-2Q3KLBE6.js";
6
7
  import {
7
8
  init_require_shim
8
9
  } from "./chunk-TPK5AGRA.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  listLocalSqliteDbs,
3
3
  listSqliteDbs
4
- } from "./chunk-J3GZ3DXD.js";
4
+ } from "./chunk-GVMT55GH.js";
5
5
  import "./chunk-G4ZAUHHA.js";
6
- import "./chunk-6MRZXASS.js";
6
+ import "./chunk-2Q3KLBE6.js";
7
7
  import {
8
8
  init_require_shim
9
9
  } from "./chunk-TPK5AGRA.js";