@darkrymit/crunes-cli 0.11.3 → 0.13.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 (42) 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/{chunk-KJDS6KLG.js → chunk-QAP63JIK.js} +8 -8
  13. package/dist/chunks/{create-EG6XUWZU.js → chunk-QFW2V36K.js} +29 -16
  14. package/dist/chunks/chunk-SMFHRQH4.js +83 -0
  15. package/dist/chunks/{chunk-JCZPJPKB.js → chunk-THGPCLJD.js} +4 -4
  16. package/dist/chunks/{chunk-OSHSGWZN.js → chunk-YUI5RTLD.js} +1 -1
  17. package/dist/chunks/{trust-QJWRA2UU.js → chunk-ZLIG4RAI.js} +22 -22
  18. package/dist/chunks/{create-ZXC6IVTR.js → create-676JD63L.js} +19 -16
  19. package/dist/chunks/create-UUYJ76JB.js +24 -0
  20. package/dist/chunks/{create-LZPZZIVO.js → create-WHYUMBIP.js} +29 -12
  21. package/dist/chunks/{disable-D64RMPMM.js → disable-QLB4FZOF.js} +2 -2
  22. package/dist/chunks/{doctor-RPMWVIU2.js → doctor-SXKAEYUF.js} +5 -5
  23. package/dist/chunks/{enable-WQ67RBZM.js → enable-D5BM5VZ7.js} +2 -2
  24. package/dist/chunks/{init-WXAPVBVC.js → init-EY5R26HE.js} +4 -3
  25. package/dist/chunks/{install-RIB6WJAJ.js → install-FSJAC3CL.js} +5 -5
  26. package/dist/chunks/{intro-WRYGSVZA.js → intro-PN7LT6ZG.js} +10 -10
  27. package/dist/chunks/{list-2L47SUMZ.js → list-THRLETUN.js} +4 -4
  28. package/dist/chunks/{list-YPY6WXXM.js → list-U44ZZ3NZ.js} +2 -4
  29. package/dist/chunks/{list-4HIUYIH6.js → list-WFMSED5O.js} +3 -3
  30. package/dist/chunks/{repl-D74NDSU3.js → repl-PSADU3MJ.js} +7 -7
  31. package/dist/chunks/{resolver-7OOQKADV.js → resolver-YEUZSOS4.js} +5 -5
  32. package/dist/chunks/{run-NWDA34W2.js → run-CYGL3HTA.js} +6 -6
  33. package/dist/chunks/{rune-M6CDT6KM.js → rune-OQX5EYSQ.js} +32 -19
  34. package/dist/chunks/{runner-J2ILUQH5.js → runner-VUSHR2OR.js} +2 -2
  35. package/dist/chunks/trust-7GU7ODWL.js +20 -0
  36. package/dist/chunks/{uninstall-NCBA2KNM.js → uninstall-MSCIWDWV.js} +5 -5
  37. package/dist/chunks/{update-PMK4FT7F.js → update-IHCYA3JW.js} +5 -5
  38. package/dist/chunks/{version-BHXXTACZ.js → version-SBE7LQ5C.js} +6 -1
  39. package/dist/cli.js +27 -27
  40. package/dist/test/index.js +75924 -0
  41. package/dist/test/register.js +9 -0
  42. package/package.json +6 -1
@@ -0,0 +1,83 @@
1
+ import {
2
+ init_require_shim
3
+ } from "./chunk-FATG2PA7.js";
4
+
5
+ // src/test/register.js
6
+ init_require_shim();
7
+ import { registerHooks } from "node:module";
8
+ import path from "node:path";
9
+ import { pathToFileURL } from "node:url";
10
+ var installed = false;
11
+ var roots = { projectRoot: null, pluginRoot: null };
12
+ function setCrunesTestRoots({ projectRoot, pluginRoot } = {}) {
13
+ if (projectRoot !== void 0) roots.projectRoot = projectRoot ? path.resolve(projectRoot) : null;
14
+ if (pluginRoot !== void 0) roots.pluginRoot = pluginRoot ? path.resolve(pluginRoot) : null;
15
+ }
16
+ function installCrunesTestHooks({ projectRoot, pluginRoot } = {}) {
17
+ setCrunesTestRoots({ projectRoot, pluginRoot });
18
+ if (installed) return;
19
+ installed = true;
20
+ registerHooks({
21
+ resolve(specifier, context, nextResolve) {
22
+ if (specifier === "@utils") {
23
+ return { shortCircuit: true, url: "crunes-test:@utils" };
24
+ }
25
+ if (roots.pluginRoot && specifier.startsWith("@plugin/")) {
26
+ const target = path.resolve(roots.pluginRoot, specifier.slice("@plugin/".length));
27
+ return { shortCircuit: true, url: pathToFileURL(target).href };
28
+ }
29
+ if (roots.projectRoot && specifier.startsWith("@project/")) {
30
+ const target = path.resolve(roots.projectRoot, specifier.slice("@project/".length));
31
+ return { shortCircuit: true, url: pathToFileURL(target).href };
32
+ }
33
+ return nextResolve(specifier, context);
34
+ },
35
+ load(url, context, nextLoad) {
36
+ if (url === "crunes-test:@utils") {
37
+ return {
38
+ shortCircuit: true,
39
+ format: "module",
40
+ source: [
41
+ `const get = ns => {`,
42
+ ` const u = globalThis.__CRUNES_TEST_UTILS__`,
43
+ ` if (!u) throw new Error('Call setupCrunesTest() before invoking @utils')`,
44
+ ` return u[ns]`,
45
+ `}`,
46
+ `const proxy = ns => new Proxy({}, { get: (_, k) => get(ns)[k] })`,
47
+ `export const fs = proxy('fs')`,
48
+ `export const shell = proxy('shell')`,
49
+ `export const section = proxy('section')`,
50
+ `export const rune = proxy('rune')`,
51
+ `export const json = proxy('json')`,
52
+ `export const yaml = proxy('yaml')`,
53
+ `export const xml = proxy('xml')`,
54
+ `export const csv = proxy('csv')`,
55
+ `export const http = proxy('http')`,
56
+ `export const env = proxy('env')`,
57
+ `export const vars = proxy('vars')`,
58
+ `export const os = proxy('os')`,
59
+ `export const stdin = proxy('stdin')`,
60
+ `export const archive = proxy('archive')`,
61
+ `export const cache = proxy('cache')`,
62
+ `export const sqlite = proxy('sqlite')`,
63
+ `export const db = proxy('db')`,
64
+ `export const crypt = proxy('crypt')`,
65
+ `export const codec = proxy('codec')`,
66
+ `export const ws = proxy('ws')`,
67
+ `export const time = proxy('time')`,
68
+ `export const notify = proxy('notify')`,
69
+ `export const md = proxy('md')`,
70
+ `export const tree = proxy('tree')`
71
+ ].join("\n")
72
+ };
73
+ }
74
+ return nextLoad(url, context);
75
+ }
76
+ });
77
+ }
78
+ installCrunesTestHooks();
79
+
80
+ export {
81
+ setCrunesTestRoots,
82
+ installCrunesTestHooks
83
+ };
@@ -6,7 +6,7 @@ import {
6
6
  readRawConfig,
7
7
  setPluginEnabled,
8
8
  writeRawConfig
9
- } from "./chunk-64INAIPB.js";
9
+ } from "./chunk-J33GQMPV.js";
10
10
  import {
11
11
  output
12
12
  } from "./chunk-RQ6KHY6W.js";
@@ -16,10 +16,10 @@ import {
16
16
  } from "./chunk-PRCVJ727.js";
17
17
  import {
18
18
  isNativeRune
19
- } from "./chunk-YYOMTVCG.js";
19
+ } from "./chunk-HQUMVDQE.js";
20
20
  import {
21
21
  coercePlugins
22
- } from "./chunk-OSHSGWZN.js";
22
+ } from "./chunk-YUI5RTLD.js";
23
23
  import {
24
24
  loadRegistry,
25
25
  registerPlugin,
@@ -31,7 +31,7 @@ import {
31
31
  import {
32
32
  blockOf,
33
33
  scopedPermissions
34
- } from "./chunk-P5WTJJSV.js";
34
+ } from "./chunk-4SZGKHSW.js";
35
35
  import {
36
36
  ensureStoreDirs,
37
37
  getPluginCacheDir,
@@ -32,7 +32,7 @@ function absolutizeSection(section, kind, baseDir, layer) {
32
32
  if (kind === "templates") {
33
33
  const isPluginRef = Boolean(entry.plugin) || key.includes(":");
34
34
  if (entry.path) copy.path = resolve(baseDir, entry.path);
35
- else if (layer === "global" && !isPluginRef) copy.path = resolve(baseDir, `templates/${key}.js`);
35
+ else if (layer === "global" && !isPluginRef) copy.path = resolve(baseDir, `templates/${key}`);
36
36
  out[key] = copy;
37
37
  continue;
38
38
  }
@@ -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,7 +1,12 @@
1
+ import {
2
+ runeTestTemplate
3
+ } from "./chunk-QFW2V36K.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:
@@ -136,15 +146,7 @@ function changelogMd() {
136
146
  `;
137
147
  }
138
148
  function exampleTest() {
139
- return `import { describe, it } from 'node:test'
140
- import assert from 'node:assert/strict'
141
-
142
- describe('example rune', () => {
143
- it('placeholder', () => {
144
- assert.ok(true)
145
- })
146
- })
147
- `;
149
+ return runeTestTemplate("example");
148
150
  }
149
151
  function getGitAuthor() {
150
152
  const result = spawnSync("git", ["config", "user.name"], { encoding: "utf8" });
@@ -176,7 +178,7 @@ async function handler({
176
178
  ye("crunes plugin create");
177
179
  if (!name) {
178
180
  const r = await Re({ message: "Plugin name?", validate: (v) => v ? void 0 : "Required" });
179
- if (r === /* @__PURE__ */ Symbol.for("clack:cancel")) {
181
+ if (R(r)) {
180
182
  ge("Cancelled.");
181
183
  return;
182
184
  }
@@ -184,7 +186,7 @@ async function handler({
184
186
  }
185
187
  if (!description) {
186
188
  const r = await Re({ message: "Description?", validate: (v) => v ? void 0 : "Required" });
187
- if (r === /* @__PURE__ */ Symbol.for("clack:cancel")) {
189
+ if (R(r)) {
188
190
  ge("Cancelled.");
189
191
  return;
190
192
  }
@@ -192,7 +194,7 @@ async function handler({
192
194
  }
193
195
  if (author === void 0) {
194
196
  const r = await Re({ message: "Author?", initialValue: getGitAuthor() });
195
- if (r === /* @__PURE__ */ Symbol.for("clack:cancel")) {
197
+ if (R(r)) {
196
198
  ge("Cancelled.");
197
199
  return;
198
200
  }
@@ -200,7 +202,7 @@ async function handler({
200
202
  }
201
203
  if (license === void 0) {
202
204
  const r = await Re({ message: "License?", initialValue: "MIT" });
203
- if (r === /* @__PURE__ */ Symbol.for("clack:cancel")) {
205
+ if (R(r)) {
204
206
  ge("Cancelled.");
205
207
  return;
206
208
  }
@@ -219,7 +221,7 @@ async function handler({
219
221
  process.exit(1);
220
222
  }
221
223
  const ok = await le({ message: `"${outDir}" already exists and is not empty. Overwrite?` });
222
- if (!ok || ok === /* @__PURE__ */ Symbol.for("clack:cancel")) {
224
+ if (!ok || R(ok)) {
223
225
  ge("Cancelled.");
224
226
  return;
225
227
  }
@@ -232,7 +234,8 @@ async function handler({
232
234
  [join(outDir, ".crunes-plugin", "marketplace.json"), marketplaceJson(opts)],
233
235
  [runeEntry, exampleRune()],
234
236
  [testEntry, exampleTest()],
235
- [join(outDir, "templates", "example-template.js"), exampleTemplate()],
237
+ [join(outDir, "templates", "example-template", "src", "index.rune.js"), exampleTemplate()],
238
+ [join(outDir, "templates", "example-template", "test", "example-template.test.js"), runeTestTemplate("example-template")],
236
239
  [join(outDir, "README.md"), readmeMd(opts)],
237
240
  [join(outDir, "CHANGELOG.md"), changelogMd()]
238
241
  ];
@@ -0,0 +1,24 @@
1
+ import {
2
+ SCRIPT_LANGS,
3
+ VALID_LANGS,
4
+ handler,
5
+ runeTestTemplate,
6
+ template
7
+ } from "./chunk-QFW2V36K.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,19 +1,25 @@
1
+ import {
2
+ SCRIPT_LANGS,
3
+ VALID_LANGS,
4
+ runeTestTemplate
5
+ } from "./chunk-QFW2V36K.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,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("");