@darkrymit/crunes-cli 0.11.3 → 0.12.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 (39) hide show
  1. package/README.md +3 -2
  2. package/dist/chunks/{add-J3E6GLVR.js → add-GDF3XEGN.js} +2 -2
  3. package/dist/chunks/{apply-OZTKRCFK.js → apply-GDTGTBPD.js} +76 -37
  4. package/dist/chunks/{benchmark-R4CZKOQY.js → benchmark-2TVN6HDF.js} +6 -6
  5. package/dist/chunks/{chunk-CST3HAZF.js → chunk-3VFNNPQI.js} +4 -4
  6. package/dist/chunks/{chunk-P5WTJJSV.js → chunk-4SZGKHSW.js} +1 -7
  7. package/dist/chunks/{chunk-X5SKOAGS.js → chunk-ATI5HNNC.js} +2 -2
  8. package/dist/chunks/{chunk-NXNUMGXV.js → chunk-GABVYS5O.js} +3 -3
  9. package/dist/chunks/{chunk-YYOMTVCG.js → chunk-HQUMVDQE.js} +11 -3
  10. package/dist/chunks/{chunk-64INAIPB.js → chunk-J33GQMPV.js} +1 -1
  11. package/dist/chunks/{chunk-JQHD5C7T.js → chunk-KP4EW2DS.js} +1 -1
  12. package/dist/chunks/{create-EG6XUWZU.js → chunk-PBQDFAR4.js} +13 -14
  13. package/dist/chunks/{chunk-KJDS6KLG.js → chunk-QAP63JIK.js} +8 -8
  14. package/dist/chunks/{chunk-JCZPJPKB.js → chunk-THGPCLJD.js} +4 -4
  15. package/dist/chunks/{chunk-OSHSGWZN.js → chunk-YUI5RTLD.js} +1 -1
  16. package/dist/chunks/{trust-QJWRA2UU.js → chunk-ZLIG4RAI.js} +22 -22
  17. package/dist/chunks/{create-LZPZZIVO.js → create-4DEH53O6.js} +29 -12
  18. package/dist/chunks/{create-ZXC6IVTR.js → create-YLXRZQXI.js} +18 -7
  19. package/dist/chunks/create-ZWBV7PPT.js +24 -0
  20. package/dist/chunks/{disable-D64RMPMM.js → disable-QLB4FZOF.js} +2 -2
  21. package/dist/chunks/{doctor-RPMWVIU2.js → doctor-SXKAEYUF.js} +5 -5
  22. package/dist/chunks/{enable-WQ67RBZM.js → enable-D5BM5VZ7.js} +2 -2
  23. package/dist/chunks/{init-WXAPVBVC.js → init-EY5R26HE.js} +4 -3
  24. package/dist/chunks/{install-RIB6WJAJ.js → install-FSJAC3CL.js} +5 -5
  25. package/dist/chunks/{intro-WRYGSVZA.js → intro-PN7LT6ZG.js} +10 -10
  26. package/dist/chunks/{list-2L47SUMZ.js → list-THRLETUN.js} +4 -4
  27. package/dist/chunks/{list-YPY6WXXM.js → list-U44ZZ3NZ.js} +2 -4
  28. package/dist/chunks/{list-4HIUYIH6.js → list-WFMSED5O.js} +3 -3
  29. package/dist/chunks/{repl-D74NDSU3.js → repl-PSADU3MJ.js} +7 -7
  30. package/dist/chunks/{resolver-7OOQKADV.js → resolver-YEUZSOS4.js} +5 -5
  31. package/dist/chunks/{run-NWDA34W2.js → run-CYGL3HTA.js} +6 -6
  32. package/dist/chunks/{rune-M6CDT6KM.js → rune-OQX5EYSQ.js} +32 -19
  33. package/dist/chunks/{runner-J2ILUQH5.js → runner-VUSHR2OR.js} +2 -2
  34. package/dist/chunks/trust-7GU7ODWL.js +20 -0
  35. package/dist/chunks/{uninstall-NCBA2KNM.js → uninstall-MSCIWDWV.js} +5 -5
  36. package/dist/chunks/{update-PMK4FT7F.js → update-IHCYA3JW.js} +5 -5
  37. package/dist/chunks/{version-BHXXTACZ.js → version-QBWEJ45I.js} +1 -1
  38. package/dist/cli.js +27 -27
  39. package/package.json +1 -1
@@ -8,8 +8,7 @@ import {
8
8
  recordTrust,
9
9
  trustDigest,
10
10
  trustState
11
- } from "./chunk-YYOMTVCG.js";
12
- import "./chunk-BK4WG54O.js";
11
+ } from "./chunk-HQUMVDQE.js";
13
12
  import {
14
13
  loadRegistry,
15
14
  resolvePluginKey
@@ -17,12 +16,9 @@ import {
17
16
  import {
18
17
  loadPluginJson
19
18
  } from "./chunk-CEQBF5LN.js";
20
- import "./chunk-ESXRY4PQ.js";
21
19
  import {
22
20
  blockOf
23
- } from "./chunk-P5WTJJSV.js";
24
- import "./chunk-7YY3GPPK.js";
25
- import "./chunk-DR6PVO72.js";
21
+ } from "./chunk-4SZGKHSW.js";
26
22
  import {
27
23
  init_require_shim
28
24
  } from "./chunk-FATG2PA7.js";
@@ -31,6 +27,23 @@ import {
31
27
  init_require_shim();
32
28
  import { readFileSync } from "node:fs";
33
29
  var SHOWN_LINES = 80;
30
+ function scriptLines(file) {
31
+ const lines = [` file: ${file}`, ""];
32
+ let content;
33
+ try {
34
+ content = readFileSync(file, "utf8");
35
+ } catch {
36
+ content = null;
37
+ }
38
+ if (content == null) {
39
+ lines.push(" (the file is missing)");
40
+ } else {
41
+ const all = content.replace(/\n$/, "").split("\n");
42
+ for (const line of all.slice(0, SHOWN_LINES)) lines.push(` \u2502 ${line}`);
43
+ if (all.length > SHOWN_LINES) lines.push(` \u2502 \u2026 ${all.length - SHOWN_LINES} more lines \u2014 read the whole file before trusting it`);
44
+ }
45
+ return lines;
46
+ }
34
47
  function describeForReview(pluginKey, runeKey, rune, pluginDir, state) {
35
48
  const run = blockOf(rune, "run");
36
49
  const file = nativeRuneFile(pluginDir, rune);
@@ -40,22 +53,7 @@ function describeForReview(pluginKey, runeKey, rune, pluginDir, state) {
40
53
  ` command: ${[run.command, ...run.argv ?? []].join(" ")}${file ? "" : " (a program on PATH)"}`
41
54
  ];
42
55
  if (rune.args != null) lines.push(` arguments: ${run.pass === "mapped" ? "mapped from its schema \u2014 nothing else reaches the program" : "passed through as given"}`);
43
- if (file) {
44
- let content;
45
- try {
46
- content = readFileSync(file, "utf8");
47
- } catch {
48
- content = null;
49
- }
50
- lines.push(` file: ${file}`, "");
51
- if (content == null) {
52
- lines.push(" (the file is missing)");
53
- } else {
54
- const all = content.replace(/\n$/, "").split("\n");
55
- for (const line of all.slice(0, SHOWN_LINES)) lines.push(` \u2502 ${line}`);
56
- if (all.length > SHOWN_LINES) lines.push(` \u2502 \u2026 ${all.length - SHOWN_LINES} more lines \u2014 read the whole file before trusting it`);
57
- }
58
- }
56
+ if (file) lines.push(...scriptLines(file));
59
57
  return lines.join("\n");
60
58
  }
61
59
  async function handler({ name, rune: onlyRune = null, yes = false }) {
@@ -103,7 +101,9 @@ async function handler({ name, rune: onlyRune = null, yes = false }) {
103
101
  process.exit(1);
104
102
  }
105
103
  }
104
+
106
105
  export {
106
+ scriptLines,
107
107
  describeForReview,
108
108
  handler
109
109
  };
@@ -1,19 +1,25 @@
1
+ import {
2
+ SCRIPT_LANGS,
3
+ VALID_LANGS,
4
+ runeTestTemplate
5
+ } from "./chunk-PBQDFAR4.js";
1
6
  import {
2
7
  getConfigPath,
3
8
  readRawConfig,
4
9
  writeRawConfig
5
- } from "./chunk-64INAIPB.js";
10
+ } from "./chunk-J33GQMPV.js";
6
11
  import {
7
12
  output
8
13
  } from "./chunk-RQ6KHY6W.js";
9
14
  import {
15
+ R,
10
16
  Re,
11
17
  fe,
12
18
  ge,
13
19
  ye
14
20
  } from "./chunk-PRCVJ727.js";
15
21
  import "./chunk-AFAVAB5Q.js";
16
- import "./chunk-OSHSGWZN.js";
22
+ import "./chunk-YUI5RTLD.js";
17
23
  import "./chunk-BK4WG54O.js";
18
24
  import "./chunk-ESXRY4PQ.js";
19
25
  import {
@@ -61,6 +67,7 @@ function templateStub(name) {
61
67
  async function handler({
62
68
  name,
63
69
  path: templateRelPath,
70
+ lang,
64
71
  templateName,
65
72
  description,
66
73
  yes = false,
@@ -69,6 +76,10 @@ async function handler({
69
76
  global = false
70
77
  } = {}) {
71
78
  const isNonInteractive = yes || !process.stdout.isTTY;
79
+ if (lang && !VALID_LANGS.includes(lang)) {
80
+ output.error(`Invalid --lang. Must be one of: ${VALID_LANGS.join(", ")}`);
81
+ process.exit(1);
82
+ }
72
83
  if (isNonInteractive) {
73
84
  if (!name) {
74
85
  output.error("Missing required argument: <name>");
@@ -78,16 +89,16 @@ async function handler({
78
89
  ye("crunes template create");
79
90
  if (!name) {
80
91
  const result = await Re({ message: "Template name?", validate: (v) => v ? void 0 : "Required" });
81
- if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
92
+ if (R(result)) {
82
93
  ge("Cancelled.");
83
94
  return;
84
95
  }
85
96
  name = result;
86
97
  }
87
98
  if (!templateRelPath) {
88
- const defaultPath = global ? `templates/${name}.js` : `.crunes/templates/${name}.js`;
89
- const result = await Re({ message: "File path?", initialValue: defaultPath });
90
- if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
99
+ const defaultPath = global ? `templates/${name}` : `.crunes/templates/${name}`;
100
+ const result = await Re({ message: "Folder?", initialValue: defaultPath });
101
+ if (R(result)) {
91
102
  ge("Cancelled.");
92
103
  return;
93
104
  }
@@ -95,7 +106,7 @@ async function handler({
95
106
  }
96
107
  if (!templateName) {
97
108
  const result = await Re({ message: "Display name? (optional)", placeholder: "Human-readable label for crunes template list" });
98
- if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
109
+ if (R(result)) {
99
110
  ge("Cancelled.");
100
111
  return;
101
112
  }
@@ -103,18 +114,24 @@ async function handler({
103
114
  }
104
115
  if (!description) {
105
116
  const result = await Re({ message: "Description? (optional)", placeholder: "What kind of rune does this template produce?" });
106
- if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
117
+ if (R(result)) {
107
118
  ge("Cancelled.");
108
119
  return;
109
120
  }
110
121
  description = result || void 0;
111
122
  }
112
123
  }
113
- templateRelPath = templateRelPath ?? (global ? `templates/${name}.js` : `.crunes/templates/${name}.js`);
124
+ templateRelPath = templateRelPath ?? (global ? `templates/${name}` : `.crunes/templates/${name}`);
114
125
  const baseRoot = global ? getStorePath() : configRoot;
115
- const templateAbsPath = join(baseRoot, templateRelPath);
116
- await mkdir(dirname(templateAbsPath), { recursive: true });
117
- await writeFile(templateAbsPath, templateStub(name));
126
+ const script = lang ? SCRIPT_LANGS[lang] : null;
127
+ const files = [
128
+ script ? [join(baseRoot, templateRelPath, "src", `index.${script.ext}`), script.body(name)] : [join(baseRoot, templateRelPath, "src", "index.rune.js"), templateStub(name)],
129
+ [join(baseRoot, templateRelPath, "test", `${name}.test.js`), runeTestTemplate(name)]
130
+ ];
131
+ for (const [filePath, content] of files) {
132
+ await mkdir(dirname(filePath), { recursive: true });
133
+ await writeFile(filePath, content);
134
+ }
118
135
  const configPath = getConfigPath({ configRoot, global });
119
136
  const config = readRawConfig(configPath) ?? { runes: {} };
120
137
  const entry = {
@@ -1,7 +1,12 @@
1
+ import {
2
+ runeTestTemplate
3
+ } from "./chunk-PBQDFAR4.js";
4
+ import "./chunk-J33GQMPV.js";
1
5
  import {
2
6
  output
3
7
  } from "./chunk-RQ6KHY6W.js";
4
8
  import {
9
+ R,
5
10
  Re,
6
11
  fe,
7
12
  ge,
@@ -9,6 +14,11 @@ import {
9
14
  ye
10
15
  } from "./chunk-PRCVJ727.js";
11
16
  import "./chunk-AFAVAB5Q.js";
17
+ import "./chunk-YUI5RTLD.js";
18
+ import "./chunk-BK4WG54O.js";
19
+ import "./chunk-ESXRY4PQ.js";
20
+ import "./chunk-7YY3GPPK.js";
21
+ import "./chunk-DR6PVO72.js";
12
22
  import {
13
23
  init_require_shim
14
24
  } from "./chunk-FATG2PA7.js";
@@ -90,7 +100,7 @@ export async function run(args) {
90
100
  }
91
101
  function exampleTemplate() {
92
102
  return `// Template rune \u2014 copied into the user's project by \`crunes template apply\`.
93
- // Edit this file to define what a new rune looks like when scaffolded from your plugin.
103
+ // Edit this folder to define what a new rune looks like when scaffolded from your plugin.
94
104
  //
95
105
  // permissions (plugin.json):
96
106
  // run:
@@ -176,7 +186,7 @@ async function handler({
176
186
  ye("crunes plugin create");
177
187
  if (!name) {
178
188
  const r = await Re({ message: "Plugin name?", validate: (v) => v ? void 0 : "Required" });
179
- if (r === /* @__PURE__ */ Symbol.for("clack:cancel")) {
189
+ if (R(r)) {
180
190
  ge("Cancelled.");
181
191
  return;
182
192
  }
@@ -184,7 +194,7 @@ async function handler({
184
194
  }
185
195
  if (!description) {
186
196
  const r = await Re({ message: "Description?", validate: (v) => v ? void 0 : "Required" });
187
- if (r === /* @__PURE__ */ Symbol.for("clack:cancel")) {
197
+ if (R(r)) {
188
198
  ge("Cancelled.");
189
199
  return;
190
200
  }
@@ -192,7 +202,7 @@ async function handler({
192
202
  }
193
203
  if (author === void 0) {
194
204
  const r = await Re({ message: "Author?", initialValue: getGitAuthor() });
195
- if (r === /* @__PURE__ */ Symbol.for("clack:cancel")) {
205
+ if (R(r)) {
196
206
  ge("Cancelled.");
197
207
  return;
198
208
  }
@@ -200,7 +210,7 @@ async function handler({
200
210
  }
201
211
  if (license === void 0) {
202
212
  const r = await Re({ message: "License?", initialValue: "MIT" });
203
- if (r === /* @__PURE__ */ Symbol.for("clack:cancel")) {
213
+ if (R(r)) {
204
214
  ge("Cancelled.");
205
215
  return;
206
216
  }
@@ -219,7 +229,7 @@ async function handler({
219
229
  process.exit(1);
220
230
  }
221
231
  const ok = await le({ message: `"${outDir}" already exists and is not empty. Overwrite?` });
222
- if (!ok || ok === /* @__PURE__ */ Symbol.for("clack:cancel")) {
232
+ if (!ok || R(ok)) {
223
233
  ge("Cancelled.");
224
234
  return;
225
235
  }
@@ -232,7 +242,8 @@ async function handler({
232
242
  [join(outDir, ".crunes-plugin", "marketplace.json"), marketplaceJson(opts)],
233
243
  [runeEntry, exampleRune()],
234
244
  [testEntry, exampleTest()],
235
- [join(outDir, "templates", "example-template.js"), exampleTemplate()],
245
+ [join(outDir, "templates", "example-template", "src", "index.rune.js"), exampleTemplate()],
246
+ [join(outDir, "templates", "example-template", "test", "example-template.test.js"), runeTestTemplate("example-template")],
236
247
  [join(outDir, "README.md"), readmeMd(opts)],
237
248
  [join(outDir, "CHANGELOG.md"), changelogMd()]
238
249
  ];
@@ -0,0 +1,24 @@
1
+ import {
2
+ SCRIPT_LANGS,
3
+ VALID_LANGS,
4
+ handler,
5
+ runeTestTemplate,
6
+ template
7
+ } from "./chunk-PBQDFAR4.js";
8
+ import "./chunk-J33GQMPV.js";
9
+ import "./chunk-RQ6KHY6W.js";
10
+ import "./chunk-PRCVJ727.js";
11
+ import "./chunk-AFAVAB5Q.js";
12
+ import "./chunk-YUI5RTLD.js";
13
+ import "./chunk-BK4WG54O.js";
14
+ import "./chunk-ESXRY4PQ.js";
15
+ import "./chunk-7YY3GPPK.js";
16
+ import "./chunk-DR6PVO72.js";
17
+ import "./chunk-FATG2PA7.js";
18
+ export {
19
+ SCRIPT_LANGS,
20
+ VALID_LANGS,
21
+ handler,
22
+ runeTestTemplate,
23
+ template
24
+ };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  getConfigPath,
3
3
  setPluginEnabled
4
- } from "./chunk-64INAIPB.js";
4
+ } from "./chunk-J33GQMPV.js";
5
5
  import {
6
6
  enabledPluginKeys,
7
7
  loadConfig
8
- } from "./chunk-OSHSGWZN.js";
8
+ } from "./chunk-YUI5RTLD.js";
9
9
  import "./chunk-BK4WG54O.js";
10
10
  import "./chunk-ESXRY4PQ.js";
11
11
  import "./chunk-7YY3GPPK.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getConfigPath,
3
3
  readRawConfig
4
- } from "./chunk-64INAIPB.js";
4
+ } from "./chunk-J33GQMPV.js";
5
5
  import {
6
6
  output
7
7
  } from "./chunk-RQ6KHY6W.js";
@@ -9,7 +9,7 @@ import "./chunk-PRCVJ727.js";
9
9
  import "./chunk-AFAVAB5Q.js";
10
10
  import {
11
11
  describeRunBlock
12
- } from "./chunk-X5SKOAGS.js";
12
+ } from "./chunk-ATI5HNNC.js";
13
13
  import {
14
14
  assertNotMissedRename,
15
15
  onPath,
@@ -19,11 +19,11 @@ import {
19
19
  isNativeRune,
20
20
  trustDigest,
21
21
  trustState
22
- } from "./chunk-YYOMTVCG.js";
22
+ } from "./chunk-HQUMVDQE.js";
23
23
  import {
24
24
  coercePlugins,
25
25
  loadConfig
26
- } from "./chunk-OSHSGWZN.js";
26
+ } from "./chunk-YUI5RTLD.js";
27
27
  import "./chunk-BK4WG54O.js";
28
28
  import {
29
29
  loadRegistry
@@ -34,7 +34,7 @@ import {
34
34
  import {
35
35
  loadJsonSchema
36
36
  } from "./chunk-ESXRY4PQ.js";
37
- import "./chunk-P5WTJJSV.js";
37
+ import "./chunk-4SZGKHSW.js";
38
38
  import "./chunk-C2JSNCGY.js";
39
39
  import "./chunk-Q6K5MEDF.js";
40
40
  import "./chunk-ZT4QFTQM.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getConfigPath,
3
3
  setPluginEnabled
4
- } from "./chunk-64INAIPB.js";
5
- import "./chunk-OSHSGWZN.js";
4
+ } from "./chunk-J33GQMPV.js";
5
+ import "./chunk-YUI5RTLD.js";
6
6
  import "./chunk-BK4WG54O.js";
7
7
  import {
8
8
  loadRegistry,
@@ -1,17 +1,18 @@
1
1
  import {
2
2
  getConfigPath
3
- } from "./chunk-64INAIPB.js";
3
+ } from "./chunk-J33GQMPV.js";
4
4
  import {
5
5
  output
6
6
  } from "./chunk-RQ6KHY6W.js";
7
7
  import {
8
+ R,
8
9
  fe,
9
10
  ge,
10
11
  le,
11
12
  ye
12
13
  } from "./chunk-PRCVJ727.js";
13
14
  import "./chunk-AFAVAB5Q.js";
14
- import "./chunk-OSHSGWZN.js";
15
+ import "./chunk-YUI5RTLD.js";
15
16
  import "./chunk-BK4WG54O.js";
16
17
  import "./chunk-ESXRY4PQ.js";
17
18
  import "./chunk-7YY3GPPK.js";
@@ -45,7 +46,7 @@ async function handler({
45
46
  message: "Config already exists. Overwrite?",
46
47
  initialValue: false
47
48
  });
48
- if (!overwrite || overwrite === /* @__PURE__ */ Symbol.for("clack:cancel")) {
49
+ if (!overwrite || R(overwrite)) {
49
50
  ge("Cancelled.");
50
51
  return;
51
52
  }
@@ -3,21 +3,21 @@ import {
3
3
  } from "./chunk-Z4W3ZDFC.js";
4
4
  import {
5
5
  installPlugin
6
- } from "./chunk-JCZPJPKB.js";
6
+ } from "./chunk-THGPCLJD.js";
7
7
  import "./chunk-GBUZOC3O.js";
8
- import "./chunk-64INAIPB.js";
8
+ import "./chunk-J33GQMPV.js";
9
9
  import {
10
10
  output
11
11
  } from "./chunk-RQ6KHY6W.js";
12
12
  import "./chunk-PRCVJ727.js";
13
13
  import "./chunk-AFAVAB5Q.js";
14
- import "./chunk-YYOMTVCG.js";
15
- import "./chunk-OSHSGWZN.js";
14
+ import "./chunk-HQUMVDQE.js";
15
+ import "./chunk-YUI5RTLD.js";
16
16
  import "./chunk-BK4WG54O.js";
17
17
  import "./chunk-V2VVG44B.js";
18
18
  import "./chunk-CEQBF5LN.js";
19
19
  import "./chunk-ESXRY4PQ.js";
20
- import "./chunk-P5WTJJSV.js";
20
+ import "./chunk-4SZGKHSW.js";
21
21
  import "./chunk-7YY3GPPK.js";
22
22
  import "./chunk-DR6PVO72.js";
23
23
  import {
@@ -2519,7 +2519,7 @@ 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>.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:");
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>/src/index.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
2524
  lines.push("crunes -y create my-rune --format markdown");
2525
2525
  lines.push("```");
@@ -2645,7 +2645,7 @@ async function compileIntro() {
2645
2645
  lines.push(' "description": "Does something useful",');
2646
2646
  lines.push(' "vars": { "api_url": "https://example.com" },');
2647
2647
  lines.push(' "run": {');
2648
- lines.push(' "command": ".crunes/runes/my-rune.rune.js",');
2648
+ lines.push(' "command": ".crunes/runes/my-rune/src/index.rune.js",');
2649
2649
  lines.push(' "permissions": { "allow": ["fs.read:src/**", "fs.write:dist/**", "shell.run:git *"] }');
2650
2650
  lines.push(" }");
2651
2651
  lines.push(" }");
@@ -2658,8 +2658,8 @@ async function compileIntro() {
2658
2658
  lines.push("{");
2659
2659
  lines.push(' "runes": {');
2660
2660
  lines.push(' "my-shell": {');
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"] } }');
2661
+ lines.push(' "run": { "command": ".crunes/runes/my-shell/src/index.rune.js", "permissions": { "allow": ["sqlite.read:./state::db"] } },');
2662
+ lines.push(' "repl": { "command": ".crunes/runes/my-shell/src/index.rune.js", "permissions": { "allow": ["sqlite.read:./state::db", "sqlite.write:./state::db"] } }');
2663
2663
  lines.push(" }");
2664
2664
  lines.push(" }");
2665
2665
  lines.push("}");
@@ -2701,7 +2701,7 @@ async function compileIntro() {
2701
2701
  lines.push(' "runes": {');
2702
2702
  lines.push(' "coverage": { "description": "Coverage per module", "run": "tools/coverage.py", "args": ".crunes/runes/coverage.args.rune.js" },');
2703
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/**"] } } }');
2704
+ lines.push(' "api": { "run": { "command": ".crunes/runes/api/src/index.rune.js", "permissions": { "allow": ["fs.read:src/**"] } } }');
2705
2705
  lines.push(" }");
2706
2706
  lines.push("}");
2707
2707
  lines.push("```");
@@ -2724,7 +2724,7 @@ async function compileIntro() {
2724
2724
  lines.push("### Config File Fields Reference");
2725
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
2726
  lines.push('- **`plugins`**: Map of plugin key to a boolean, e.g. `{"my-market@my-plugin": true}`. `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`.");
2727
+ lines.push("- **`templates`**: Definition of registered templates, keyed by template name, merged across layers exactly like `runes`. An entry's `path` names a folder with exactly one `src/index.*` entry, a `*.rune.js` module or a script; `crunes template apply` copies the folder whole. A script template is printed first and applied only once confirmed in a terminal or with `-y`. `crunes template create --lang python|bash|node` scaffolds one.");
2728
2728
  lines.push("");
2729
2729
  lines.push("### Config Layers");
2730
2730
  lines.push("Configuration merges across three layers, lowest to highest \u2014 later layers win per key:");
@@ -2733,10 +2733,10 @@ async function compileIntro() {
2733
2733
  lines.push("2. <project>/.crunes/config.json");
2734
2734
  lines.push("3. <project>/.crunes/config.local.json");
2735
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:");
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>/src/index.rune.js` and lives at `~/.crunes/runes/<key>/src/index.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
2737
  lines.push("```json");
2738
2738
  lines.push("// ~/.crunes/config.json");
2739
- lines.push('{ "runes": { "serve": { "run": "runes/serve.rune.js", "vars": { "port": 3000 } } } }');
2739
+ lines.push('{ "runes": { "serve": { "run": "runes/serve/src/index.rune.js", "vars": { "port": 3000 } } } }');
2740
2740
  lines.push("");
2741
2741
  lines.push("// <project>/.crunes/config.json \u2014 same rune, different port");
2742
2742
  lines.push('{ "runes": { "serve": { "vars": { "port": 4000 } } } }');
@@ -2756,12 +2756,12 @@ async function compileIntro() {
2756
2756
  lines.push("`-g` / `--global` targets the global config instead of the project:");
2757
2757
  lines.push("```bash");
2758
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");
2759
+ lines.push("crunes create -g serve # write ~/.crunes/runes/serve/src/index.rune.js and register it");
2760
2760
  lines.push("crunes plugin install -g mkt@plug # install and enable everywhere");
2761
2761
  lines.push("crunes plugin enable -g plug");
2762
2762
  lines.push("crunes plugin disable plug # opt this project out of a global enable");
2763
2763
  lines.push("crunes plugin disable -g plug # turn it off everywhere");
2764
- lines.push("crunes template create -g base # ~/.crunes/templates/base.js");
2764
+ lines.push("crunes template create -g base # ~/.crunes/templates/base/");
2765
2765
  lines.push("crunes list -g # global entries only; bare `list` shows the merged set with a Layer column");
2766
2766
  lines.push("```");
2767
2767
  lines.push("");
@@ -3,23 +3,23 @@ import {
3
3
  } from "./chunk-HIKE52GN.js";
4
4
  import {
5
5
  enumerateRunes
6
- } from "./chunk-NXNUMGXV.js";
6
+ } from "./chunk-GABVYS5O.js";
7
7
  import {
8
8
  output
9
9
  } from "./chunk-RQ6KHY6W.js";
10
10
  import "./chunk-PRCVJ727.js";
11
11
  import "./chunk-AFAVAB5Q.js";
12
12
  import "./chunk-UKAIACRQ.js";
13
- import "./chunk-YYOMTVCG.js";
13
+ import "./chunk-HQUMVDQE.js";
14
14
  import {
15
15
  LAYER,
16
16
  ROOTLESS,
17
17
  loadConfig
18
- } from "./chunk-OSHSGWZN.js";
18
+ } from "./chunk-YUI5RTLD.js";
19
19
  import "./chunk-BK4WG54O.js";
20
20
  import "./chunk-V2VVG44B.js";
21
21
  import "./chunk-ESXRY4PQ.js";
22
- import "./chunk-P5WTJJSV.js";
22
+ import "./chunk-4SZGKHSW.js";
23
23
  import "./chunk-ZT4QFTQM.js";
24
24
  import "./chunk-7YY3GPPK.js";
25
25
  import "./chunk-DR6PVO72.js";
@@ -8,7 +8,7 @@ import "./chunk-PRCVJ727.js";
8
8
  import "./chunk-AFAVAB5Q.js";
9
9
  import {
10
10
  loadConfig
11
- } from "./chunk-OSHSGWZN.js";
11
+ } from "./chunk-YUI5RTLD.js";
12
12
  import "./chunk-BK4WG54O.js";
13
13
  import {
14
14
  loadRegistry
@@ -43,9 +43,7 @@ async function handler({
43
43
  }
44
44
  const templates = config.templates ?? {};
45
45
  for (const [name, entry] of Object.entries(templates)) {
46
- if (typeof entry === "string") {
47
- results.push({ source: "project", template: name, name, description: "" });
48
- } else if (entry.path) {
46
+ if (entry.path) {
49
47
  results.push({ source: "project", template: name, name: entry.name ?? name, description: entry.description ?? "" });
50
48
  } else if (entry.plugin) {
51
49
  results.push({ source: "project", template: name, name: entry.name ?? name, description: entry.description ?? "", plugin: entry.plugin });
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  isNativeRune
3
- } from "./chunk-YYOMTVCG.js";
3
+ } from "./chunk-HQUMVDQE.js";
4
4
  import {
5
5
  loadConfig
6
- } from "./chunk-OSHSGWZN.js";
6
+ } from "./chunk-YUI5RTLD.js";
7
7
  import "./chunk-BK4WG54O.js";
8
8
  import {
9
9
  loadRegistry
@@ -12,7 +12,7 @@ import {
12
12
  loadPluginJson
13
13
  } from "./chunk-CEQBF5LN.js";
14
14
  import "./chunk-ESXRY4PQ.js";
15
- import "./chunk-P5WTJJSV.js";
15
+ import "./chunk-4SZGKHSW.js";
16
16
  import "./chunk-7YY3GPPK.js";
17
17
  import "./chunk-DR6PVO72.js";
18
18
  import {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  parseSegment,
3
3
  permissionHint
4
- } from "./chunk-CST3HAZF.js";
4
+ } from "./chunk-3VFNNPQI.js";
5
5
  import {
6
6
  tailStdin
7
7
  } from "./chunk-OV4WBJT3.js";
@@ -13,20 +13,20 @@ import "./chunk-PRCVJ727.js";
13
13
  import "./chunk-AFAVAB5Q.js";
14
14
  import {
15
15
  describeConfigLayers
16
- } from "./chunk-KJDS6KLG.js";
16
+ } from "./chunk-QAP63JIK.js";
17
17
  import {
18
18
  formatSection
19
- } from "./chunk-X5SKOAGS.js";
19
+ } from "./chunk-ATI5HNNC.js";
20
20
  import "./chunk-UKAIACRQ.js";
21
- import "./chunk-YYOMTVCG.js";
21
+ import "./chunk-HQUMVDQE.js";
22
22
  import {
23
23
  loadConfig
24
- } from "./chunk-OSHSGWZN.js";
24
+ } from "./chunk-YUI5RTLD.js";
25
25
  import "./chunk-BK4WG54O.js";
26
26
  import "./chunk-V2VVG44B.js";
27
27
  import "./chunk-CEQBF5LN.js";
28
28
  import "./chunk-ESXRY4PQ.js";
29
- import "./chunk-P5WTJJSV.js";
29
+ import "./chunk-4SZGKHSW.js";
30
30
  import {
31
31
  isGlobMatch
32
32
  } from "./chunk-C2JSNCGY.js";
@@ -157,7 +157,7 @@ async function handler({
157
157
  output.info("Run `crunes init` to create a config file.");
158
158
  process.exit(1);
159
159
  }
160
- const { resolveRuneEntry } = await import("./resolver-7OOQKADV.js");
160
+ const { resolveRuneEntry } = await import("./resolver-YEUZSOS4.js");
161
161
  let runeEntry;
162
162
  try {
163
163
  runeEntry = await resolveRuneEntry(projectRoot, config, key, configRoot);
@@ -4,19 +4,19 @@ import {
4
4
  resolveRuneEntry,
5
5
  resolveRuneFromPlugins,
6
6
  runRune
7
- } from "./chunk-KJDS6KLG.js";
8
- import "./chunk-X5SKOAGS.js";
7
+ } from "./chunk-QAP63JIK.js";
8
+ import "./chunk-ATI5HNNC.js";
9
9
  import "./chunk-UKAIACRQ.js";
10
- import "./chunk-YYOMTVCG.js";
10
+ import "./chunk-HQUMVDQE.js";
11
11
  import {
12
12
  getRune,
13
13
  normaliseRune
14
- } from "./chunk-OSHSGWZN.js";
14
+ } from "./chunk-YUI5RTLD.js";
15
15
  import "./chunk-BK4WG54O.js";
16
16
  import "./chunk-V2VVG44B.js";
17
17
  import "./chunk-CEQBF5LN.js";
18
18
  import "./chunk-ESXRY4PQ.js";
19
- import "./chunk-P5WTJJSV.js";
19
+ import "./chunk-4SZGKHSW.js";
20
20
  import "./chunk-C2JSNCGY.js";
21
21
  import "./chunk-Q6K5MEDF.js";
22
22
  import "./chunk-ZT4QFTQM.js";