@darkrymit/crunes-cli 0.5.10 → 0.7.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 (70) hide show
  1. package/README.md +5 -5
  2. package/dist/chunks/add-OWYVF3IE.js +22 -0
  3. package/dist/chunks/apply-OMEVXCHC.js +183 -0
  4. package/dist/chunks/args-32BVYW77.js +42 -0
  5. package/dist/chunks/benchmark-CLUBISCR.js +164 -0
  6. package/dist/chunks/browse-COH6IJEX.js +34 -0
  7. package/dist/chunks/check-BS6TZGRR.js +144 -0
  8. package/dist/chunks/chunk-2Q24YPGL.js +369 -0
  9. package/dist/chunks/chunk-3TM6B4E5.js +70 -0
  10. package/dist/chunks/chunk-67I2J474.js +153 -0
  11. package/dist/chunks/chunk-6XLT25GS.js +50 -0
  12. package/dist/chunks/chunk-BVY5LN7X.js +25091 -0
  13. package/dist/chunks/chunk-CGZL5SSH.js +926 -0
  14. package/dist/chunks/chunk-DMMC4X27.js +1836 -0
  15. package/dist/chunks/chunk-G3U4V32O.js +46 -0
  16. package/dist/chunks/chunk-GHQOK4L7.js +59 -0
  17. package/dist/chunks/chunk-H3BVJCIL.js +105 -0
  18. package/dist/chunks/chunk-HMU2J25D.js +63 -0
  19. package/dist/chunks/chunk-HOH7WZX4.js +95 -0
  20. package/dist/chunks/chunk-L72BG6DS.js +225 -0
  21. package/dist/chunks/chunk-NXSDVVTW.js +181 -0
  22. package/dist/chunks/chunk-QLDB3FO2.js +73059 -0
  23. package/dist/chunks/chunk-QMWGQXEZ.js +26 -0
  24. package/dist/chunks/chunk-TPK5AGRA.js +54 -0
  25. package/dist/chunks/chunk-UGN3FFEF.js +8379 -0
  26. package/dist/chunks/chunk-WCODTMDN.js +508 -0
  27. package/dist/chunks/chunk-XIXND2M4.js +296 -0
  28. package/dist/chunks/chunk-XXUNHQIB.js +129 -0
  29. package/dist/chunks/chunk-ZXIP4Z5V.js +281 -0
  30. package/dist/chunks/clear-Y5POLIMF.js +32 -0
  31. package/dist/chunks/completions-2MSEWWTG.js +232 -0
  32. package/dist/chunks/create-5FXQYCGM.js +165 -0
  33. package/dist/chunks/create-I6BNYZ5Q.js +247 -0
  34. package/dist/chunks/create-O3HMODSL.js +130 -0
  35. package/dist/chunks/delete-7CQFYIXS.js +40 -0
  36. package/dist/chunks/delete-UB5SXO5I.js +40 -0
  37. package/dist/chunks/disable-FCBW7WVG.js +47 -0
  38. package/dist/chunks/doctor-DS57HDLJ.js +53 -0
  39. package/dist/chunks/enable-IXRVUXJM.js +47 -0
  40. package/dist/chunks/esm-7MEWZCHY.js +5162 -0
  41. package/dist/chunks/globals-YCJ2DGWC.js +60 -0
  42. package/dist/chunks/init-WGKQVAZE.js +59 -0
  43. package/dist/chunks/install-BCTBOPBS.js +57 -0
  44. package/dist/chunks/intro-2UDWF6D4.js +1482 -0
  45. package/dist/chunks/kill-LWRXZVM5.js +37 -0
  46. package/dist/chunks/list-5DVVP7HX.js +50 -0
  47. package/dist/chunks/list-6WL5LGIZ.js +80 -0
  48. package/dist/chunks/list-NGOCMJXE.js +104 -0
  49. package/dist/chunks/list-TTKLNJKI.js +28 -0
  50. package/dist/chunks/list-WUAOSO3M.js +110 -0
  51. package/dist/chunks/list-YPI7YDKK.js +80 -0
  52. package/dist/chunks/list-ZBYPMUID.js +23 -0
  53. package/dist/chunks/manifest-7RVNKBOH.js +9 -0
  54. package/dist/chunks/output-RJ6JSNY7.js +12 -0
  55. package/dist/chunks/promise-DUSIQMA2.js +19400 -0
  56. package/dist/chunks/query-NY4SCO77.js +41 -0
  57. package/dist/chunks/registry-W5XFI5T6.js +16 -0
  58. package/dist/chunks/remove-WEAZFZCO.js +22 -0
  59. package/dist/chunks/run-I6TZX347.js +23 -0
  60. package/dist/chunks/run-MVIZQVJ6.js +36 -0
  61. package/dist/chunks/rune-TAX26NH2.js +76 -0
  62. package/dist/chunks/search-XENXL3GC.js +25 -0
  63. package/dist/chunks/uninstall-MX5PLGDI.js +49 -0
  64. package/dist/chunks/unset-KQOZYVTE.js +28 -0
  65. package/dist/chunks/update-7XDTVFZ3.js +39 -0
  66. package/dist/chunks/update-IEE54GPY.js +79 -0
  67. package/dist/chunks/utils-PO3ZK53L.js +50 -0
  68. package/dist/chunks/version-DIEA5FVV.js +145 -0
  69. package/dist/cli.js +3360 -125840
  70. package/package.json +23 -15
@@ -0,0 +1,130 @@
1
+ import {
2
+ Re,
3
+ fe,
4
+ ge,
5
+ ye
6
+ } from "./chunk-CGZL5SSH.js";
7
+ import {
8
+ output
9
+ } from "./chunk-6XLT25GS.js";
10
+ import "./chunk-WCODTMDN.js";
11
+ import {
12
+ init_require_shim
13
+ } from "./chunk-TPK5AGRA.js";
14
+
15
+ // src/template/commands/create.js
16
+ init_require_shim();
17
+ import { mkdir, writeFile, readFile, rename } from "node:fs/promises";
18
+ import { join, dirname } from "node:path";
19
+ function templateStub(name) {
20
+ return [
21
+ `// permissions:`,
22
+ `// run:`,
23
+ `// allow: [] \u2014 add patterns like fs.read:./** if you use utils.fs`,
24
+ `// deny: []`,
25
+ ``,
26
+ `import { md, section } from '@utils'`,
27
+ ``,
28
+ `// export async function args(b) {`,
29
+ `// return b`,
30
+ `// .option('-v, --verbose', 'Verbose output', false)`,
31
+ `// .build()`,
32
+ `// }`,
33
+ ``,
34
+ `export async function run(args) {`,
35
+ ` // args._ \u2014 data positionals (command tokens stripped)`,
36
+ ` // args.verbose \u2014 named flag (if args export is defined above)`,
37
+ ` // utils.fs.cwd() \u2014 absolute path to the project root`,
38
+ ``,
39
+ ` const content = [`,
40
+ ` md.h3('${name}'),`,
41
+ ` md.ul(['Replace with real output']),`,
42
+ ` ].join('\\n');`,
43
+ ` return section.create('example-md', { type: 'markdown', content });`,
44
+ `}`,
45
+ ``
46
+ ].join("\n");
47
+ }
48
+ async function handler({
49
+ name,
50
+ path: templateRelPath,
51
+ templateName,
52
+ description,
53
+ yes = false,
54
+ projectRoot = process.cwd(),
55
+ configRoot = projectRoot
56
+ } = {}) {
57
+ const isNonInteractive = yes || !process.stdout.isTTY;
58
+ if (isNonInteractive) {
59
+ if (!name) {
60
+ output.error("Missing required argument: <name>");
61
+ process.exit(1);
62
+ }
63
+ } else {
64
+ ye("crunes template create");
65
+ if (!name) {
66
+ const result = await Re({ message: "Template name?", validate: (v) => v ? void 0 : "Required" });
67
+ if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
68
+ ge("Cancelled.");
69
+ return;
70
+ }
71
+ name = result;
72
+ }
73
+ if (!templateRelPath) {
74
+ const defaultPath = `.crunes/templates/${name}.js`;
75
+ const result = await Re({ message: "File path?", initialValue: defaultPath });
76
+ if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
77
+ ge("Cancelled.");
78
+ return;
79
+ }
80
+ templateRelPath = result;
81
+ }
82
+ if (!templateName) {
83
+ const result = await Re({ message: "Display name? (optional)", placeholder: "Human-readable label for crunes template list" });
84
+ if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
85
+ ge("Cancelled.");
86
+ return;
87
+ }
88
+ templateName = result || void 0;
89
+ }
90
+ if (!description) {
91
+ const result = await Re({ message: "Description? (optional)", placeholder: "What kind of rune does this template produce?" });
92
+ if (result === /* @__PURE__ */ Symbol.for("clack:cancel")) {
93
+ ge("Cancelled.");
94
+ return;
95
+ }
96
+ description = result || void 0;
97
+ }
98
+ }
99
+ templateRelPath = templateRelPath ?? `.crunes/templates/${name}.js`;
100
+ const templateAbsPath = join(configRoot, templateRelPath);
101
+ await mkdir(dirname(templateAbsPath), { recursive: true });
102
+ await writeFile(templateAbsPath, templateStub(name));
103
+ const configPath = join(configRoot, ".crunes", "config.json");
104
+ await mkdir(dirname(configPath), { recursive: true });
105
+ let config = { runes: {} };
106
+ try {
107
+ config = JSON.parse(await readFile(configPath, "utf8"));
108
+ } catch {
109
+ }
110
+ const entry = {
111
+ path: templateRelPath,
112
+ ...templateName && { name: templateName },
113
+ ...description && { description }
114
+ };
115
+ config.templates = { ...config.templates ?? {}, [name]: entry };
116
+ const tmpPath = configPath + ".tmp";
117
+ await writeFile(tmpPath, JSON.stringify(config, null, 2) + "\n", "utf8");
118
+ await rename(tmpPath, configPath);
119
+ if (!isNonInteractive) {
120
+ fe(`Created ${templateRelPath}
121
+ Use it with: crunes template apply ${name}`);
122
+ } else {
123
+ output.success(`Created ${templateRelPath}`);
124
+ output.info(`Use it with: crunes template apply ${name}`);
125
+ }
126
+ }
127
+ export {
128
+ handler,
129
+ templateStub
130
+ };
@@ -0,0 +1,40 @@
1
+ import {
2
+ R,
3
+ ge,
4
+ le
5
+ } from "./chunk-CGZL5SSH.js";
6
+ import {
7
+ deleteCacheBucket
8
+ } from "./chunk-NXSDVVTW.js";
9
+ import "./chunk-QMWGQXEZ.js";
10
+ import {
11
+ ensureProjectIdentity
12
+ } from "./chunk-3TM6B4E5.js";
13
+ import "./chunk-HMU2J25D.js";
14
+ import {
15
+ init_require_shim
16
+ } from "./chunk-TPK5AGRA.js";
17
+
18
+ // src/cache/commands/delete.js
19
+ init_require_shim();
20
+ async function handler({ id, yes, projectDir, global: isGlobal }) {
21
+ if (!yes) {
22
+ const confirm = await le({ message: `Delete cache bucket matching "${id}"?` });
23
+ if (R(confirm) || !confirm) {
24
+ ge("Cancelled.");
25
+ process.exit(0);
26
+ }
27
+ }
28
+ const key = isGlobal ? void 0 : (await ensureProjectIdentity(projectDir)).id;
29
+ let result;
30
+ try {
31
+ result = await deleteCacheBucket(id, key);
32
+ } catch (err) {
33
+ console.error(`Error: ${err.message}`);
34
+ process.exit(1);
35
+ }
36
+ console.log(`Deleted cache bucket "${result.name}".`);
37
+ }
38
+ export {
39
+ handler
40
+ };
@@ -0,0 +1,40 @@
1
+ import {
2
+ R,
3
+ ge,
4
+ le
5
+ } from "./chunk-CGZL5SSH.js";
6
+ import {
7
+ deleteSqliteDb
8
+ } from "./chunk-67I2J474.js";
9
+ import "./chunk-QMWGQXEZ.js";
10
+ import {
11
+ ensureProjectIdentity
12
+ } from "./chunk-3TM6B4E5.js";
13
+ import "./chunk-HMU2J25D.js";
14
+ import {
15
+ init_require_shim
16
+ } from "./chunk-TPK5AGRA.js";
17
+
18
+ // src/sqlite/commands/delete.js
19
+ init_require_shim();
20
+ async function handler({ id, yes, projectDir, global: isGlobal }) {
21
+ if (!yes) {
22
+ const confirm = await le({ message: `Delete SQLite database matching "${id}"?` });
23
+ if (R(confirm) || !confirm) {
24
+ ge("Cancelled.");
25
+ process.exit(0);
26
+ }
27
+ }
28
+ const key = isGlobal ? void 0 : (await ensureProjectIdentity(projectDir)).id;
29
+ let result;
30
+ try {
31
+ result = await deleteSqliteDb(id, key);
32
+ } catch (err) {
33
+ console.error(`Error: ${err.message}`);
34
+ process.exit(1);
35
+ }
36
+ console.log(`Deleted SQLite database "${result.name}".`);
37
+ }
38
+ export {
39
+ handler
40
+ };
@@ -0,0 +1,47 @@
1
+ import {
2
+ loadRegistry,
3
+ resolvePluginKey
4
+ } from "./chunk-GHQOK4L7.js";
5
+ import "./chunk-HMU2J25D.js";
6
+ import {
7
+ init_require_shim
8
+ } from "./chunk-TPK5AGRA.js";
9
+
10
+ // src/plugin/commands/disable.js
11
+ init_require_shim();
12
+ import fs from "node:fs/promises";
13
+ import path from "node:path";
14
+ async function handler({ name, projectRoot }) {
15
+ try {
16
+ const registry = await loadRegistry();
17
+ const pluginKey = resolvePluginKey(name, registry);
18
+ if (!pluginKey) throw new Error(`Plugin "${name}" is not installed. Run: crunes plugin list`);
19
+ await setProjectPluginEnabled(projectRoot, pluginKey, false);
20
+ console.log(`Plugin "${pluginKey}" disabled.`);
21
+ } catch (err) {
22
+ console.error(`Error: ${err.message}`);
23
+ process.exit(1);
24
+ }
25
+ }
26
+ async function setProjectPluginEnabled(projectRoot, pluginKey, enabled) {
27
+ const configPath = path.join(projectRoot, ".crunes", "config.json");
28
+ let config;
29
+ try {
30
+ config = JSON.parse(await fs.readFile(configPath, "utf8"));
31
+ } catch (err) {
32
+ if (err.code === "ENOENT") throw new Error("No .crunes/config.json found. Run: crunes init");
33
+ throw err;
34
+ }
35
+ const plugins = config.plugins ?? [];
36
+ if (enabled && !plugins.includes(pluginKey)) {
37
+ config.plugins = [...plugins, pluginKey];
38
+ } else if (!enabled) {
39
+ config.plugins = plugins.filter((p) => p !== pluginKey);
40
+ }
41
+ const tmp = configPath + ".tmp";
42
+ await fs.writeFile(tmp, JSON.stringify(config, null, 2), "utf8");
43
+ await fs.rename(tmp, configPath);
44
+ }
45
+ export {
46
+ handler
47
+ };
@@ -0,0 +1,53 @@
1
+ import {
2
+ loadConfig
3
+ } from "./chunk-H3BVJCIL.js";
4
+ import {
5
+ output
6
+ } from "./chunk-6XLT25GS.js";
7
+ import "./chunk-WCODTMDN.js";
8
+ import {
9
+ init_require_shim
10
+ } from "./chunk-TPK5AGRA.js";
11
+
12
+ // src/cli/commands/doctor.js
13
+ init_require_shim();
14
+ import { spawnSync } from "node:child_process";
15
+ var KNOWN_FORMATS = /* @__PURE__ */ new Set(["1"]);
16
+ async function handler({ projectRoot = process.cwd() } = {}) {
17
+ let anyFailed = false;
18
+ const major = parseInt(process.versions.node.split(".")[0], 10);
19
+ if (major >= 20) {
20
+ output.success(`Node.js v${process.versions.node}`);
21
+ } else {
22
+ output.error(`Node.js v${process.versions.node} \u2014 requires >= 20`);
23
+ anyFailed = true;
24
+ }
25
+ const versionResult = spawnSync("crunes", ["--version"], { encoding: "utf8", shell: true });
26
+ if (versionResult.status === 0) {
27
+ output.success(`crunes ${versionResult.stdout.trim()} in PATH`);
28
+ } else {
29
+ output.warn("crunes not found globally in PATH (you can still run it locally or via npx)");
30
+ }
31
+ let config;
32
+ try {
33
+ config = loadConfig(projectRoot);
34
+ } catch (err) {
35
+ output.error(`Config: ${err.message}`);
36
+ anyFailed = true;
37
+ }
38
+ if (config) {
39
+ const runeCount = Object.keys(config.runes ?? {}).length;
40
+ if (config.format !== void 0 && !KNOWN_FORMATS.has(String(config.format))) {
41
+ output.error(`Config format "${config.format}" not recognised by this CLI version`);
42
+ anyFailed = true;
43
+ } else {
44
+ output.success(`Config valid \u2014 ${runeCount} rune${runeCount === 1 ? "" : "s"} registered`);
45
+ }
46
+ }
47
+ if (anyFailed) {
48
+ process.exit(1);
49
+ }
50
+ }
51
+ export {
52
+ handler
53
+ };
@@ -0,0 +1,47 @@
1
+ import {
2
+ loadRegistry,
3
+ resolvePluginKey
4
+ } from "./chunk-GHQOK4L7.js";
5
+ import "./chunk-HMU2J25D.js";
6
+ import {
7
+ init_require_shim
8
+ } from "./chunk-TPK5AGRA.js";
9
+
10
+ // src/plugin/commands/enable.js
11
+ init_require_shim();
12
+ import fs from "node:fs/promises";
13
+ import path from "node:path";
14
+ async function handler({ name, projectRoot }) {
15
+ try {
16
+ const registry = await loadRegistry();
17
+ const pluginKey = resolvePluginKey(name, registry);
18
+ if (!pluginKey) throw new Error(`Plugin "${name}" is not installed. Run: crunes plugin list`);
19
+ await setProjectPluginEnabled(projectRoot, pluginKey, true);
20
+ console.log(`Plugin "${pluginKey}" enabled.`);
21
+ } catch (err) {
22
+ console.error(`Error: ${err.message}`);
23
+ process.exit(1);
24
+ }
25
+ }
26
+ async function setProjectPluginEnabled(projectRoot, pluginKey, enabled) {
27
+ const configPath = path.join(projectRoot, ".crunes", "config.json");
28
+ let config;
29
+ try {
30
+ config = JSON.parse(await fs.readFile(configPath, "utf8"));
31
+ } catch (err) {
32
+ if (err.code === "ENOENT") throw new Error("No .crunes/config.json found. Run: crunes init");
33
+ throw err;
34
+ }
35
+ const plugins = config.plugins ?? [];
36
+ if (enabled && !plugins.includes(pluginKey)) {
37
+ config.plugins = [...plugins, pluginKey];
38
+ } else if (!enabled) {
39
+ config.plugins = plugins.filter((p) => p !== pluginKey);
40
+ }
41
+ const tmp = configPath + ".tmp";
42
+ await fs.writeFile(tmp, JSON.stringify(config, null, 2), "utf8");
43
+ await fs.rename(tmp, configPath);
44
+ }
45
+ export {
46
+ handler
47
+ };