@darkrymit/crunes-cli 0.8.5 → 0.9.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 (72) hide show
  1. package/dist/chunks/{add-CBHWFGCA.js → add-IT3IHBPO.js} +2 -2
  2. package/dist/chunks/{apply-J4YICV6H.js → apply-YY7MIM64.js} +9 -9
  3. package/dist/chunks/{benchmark-AKKV7G32.js → benchmark-BQNMULOO.js} +17 -14
  4. package/dist/chunks/{browse-JZFU52ET.js → browse-PHMBDREQ.js} +2 -2
  5. package/dist/chunks/{chunk-6MRZXASS.js → chunk-2Q3KLBE6.js} +16 -0
  6. package/dist/chunks/{chunk-KII6KW5Z.js → chunk-34F4ZURL.js} +40 -37
  7. package/dist/chunks/{chunk-ZJDKCC2Y.js → chunk-4GJMCFR6.js} +6 -3
  8. package/dist/chunks/chunk-CY6C6ADU.js +2787 -0
  9. package/dist/chunks/{chunk-J3GZ3DXD.js → chunk-GVMT55GH.js} +3 -2
  10. package/dist/chunks/{chunk-JOAL437H.js → chunk-I6MHDUCW.js} +16 -1
  11. package/dist/chunks/{chunk-6XLT25GS.js → chunk-MIKWIFYR.js} +47 -0
  12. package/dist/chunks/chunk-MRNZFUXZ.js +70 -0
  13. package/dist/chunks/{chunk-T53L5CJW.js → chunk-PBGUKXT6.js} +2887 -1874
  14. package/dist/chunks/chunk-QYRF3R35.js +154 -0
  15. package/dist/chunks/{chunk-BTIPUR5S.js → chunk-SNC7AOT7.js} +78 -12
  16. package/dist/chunks/{chunk-63H5VXZY.js → chunk-UEUUOAJY.js} +4 -1
  17. package/dist/chunks/{chunk-GTCPZ22N.js → chunk-VST6HAB6.js} +1 -1
  18. package/dist/chunks/{chunk-NDEYEYSU.js → chunk-WJII3LZK.js} +4 -3
  19. package/dist/chunks/chunk-X7PZN73N.js +44 -0
  20. package/dist/chunks/{chunk-NYLRTAAA.js → chunk-YVN3VDRE.js} +1 -1
  21. package/dist/chunks/{chunk-WJRZN7BR.js → chunk-YXCHIMLW.js} +843 -3027
  22. package/dist/chunks/{clear-YBDIPEEH.js → clear-AT7HNUV4.js} +2 -2
  23. package/dist/chunks/{create-GPDE2YKL.js → create-ET6DT5ZE.js} +22 -18
  24. package/dist/chunks/{create-VYZRWRGQ.js → create-LM7U3CJS.js} +22 -18
  25. package/dist/chunks/{create-L6DJN4ME.js → create-TLPM7HJE.js} +3 -3
  26. package/dist/chunks/{delete-LNOYM5KG.js → delete-5R3WBLVD.js} +5 -5
  27. package/dist/chunks/{delete-E4TEBRPX.js → delete-GKYA2W5Z.js} +4 -2
  28. package/dist/chunks/{delete-C4UJ7X5K.js → delete-U4STA2QZ.js} +5 -5
  29. package/dist/chunks/disable-TNTEIAKO.js +39 -0
  30. package/dist/chunks/doctor-VXAQYMTR.js +101 -0
  31. package/dist/chunks/enable-GUQCB4CU.js +31 -0
  32. package/dist/chunks/{globals-H2WF344Y.js → globals-SNQFCHMP.js} +1 -1
  33. package/dist/chunks/{init-HU5OMHEH.js → init-PJSCFOC6.js} +14 -8
  34. package/dist/chunks/{install-FIYRMVLR.js → install-4YP7FALO.js} +18 -16
  35. package/dist/chunks/{intro-36OLGNYN.js → intro-SA7MWV3Z.js} +50 -8
  36. package/dist/chunks/{kill-2UG7PHUV.js → kill-TX3PC73P.js} +2 -1
  37. package/dist/chunks/list-7R6NASFI.js +92 -0
  38. package/dist/chunks/{list-4X3JFQGS.js → list-EHREZR6M.js} +2 -1
  39. package/dist/chunks/{list-U7PAYNAH.js → list-LC6HB3H3.js} +2 -2
  40. package/dist/chunks/{list-AIYNOPNZ.js → list-OMMZAQ23.js} +2 -2
  41. package/dist/chunks/{list-7VHJIUDX.js → list-U4EMHQZT.js} +2 -2
  42. package/dist/chunks/{list-PTAWQYWG.js → list-V7VVD5AG.js} +2 -1
  43. package/dist/chunks/{list-A5WVDBWF.js → list-VA73WPK6.js} +2 -2
  44. package/dist/chunks/{list-2JYMBMZC.js → list-WKNPZZOV.js} +5 -4
  45. package/dist/chunks/{output-RJ6JSNY7.js → output-QN5CVJ62.js} +4 -1
  46. package/dist/chunks/{query-AW7WYILM.js → query-2US3CPYT.js} +2 -2
  47. package/dist/chunks/{registry-RG34DPD7.js → registry-K5DV5NAK.js} +2 -2
  48. package/dist/chunks/{remove-QUH2D3S5.js → remove-BCFTF23J.js} +2 -2
  49. package/dist/chunks/{repl-STBZC4P2.js → repl-2YWTHUWT.js} +4 -0
  50. package/dist/chunks/{repl-BPEWARN7.js → repl-ZB3DIJ4K.js} +84 -26
  51. package/dist/chunks/resolver-QIYYFIDX.js +34 -0
  52. package/dist/chunks/run-22B65ZWZ.js +29 -0
  53. package/dist/chunks/rune-SYK4N642.js +425 -0
  54. package/dist/chunks/{search-MSSDGJTF.js → search-B7IM7JRJ.js} +2 -2
  55. package/dist/chunks/shell-explain-QLITLHW7.js +74 -0
  56. package/dist/chunks/{uninstall-G56DZRFG.js → uninstall-4WR5IHLC.js} +15 -11
  57. package/dist/chunks/{unset-YASSMSE5.js → unset-P6IUF7SS.js} +2 -2
  58. package/dist/chunks/{update-KSC6VRMU.js → update-ACLDK6E6.js} +19 -18
  59. package/dist/chunks/{update-EWWDROKW.js → update-WXT7CHYA.js} +2 -2
  60. package/dist/chunks/{utils-3SJFSUSV.js → utils-B2QULX5J.js} +8 -4
  61. package/dist/chunks/{version-YG2M7HER.js → version-EULYWNXN.js} +2 -2
  62. package/dist/cli.js +92 -64
  63. package/package.json +1 -1
  64. package/dist/chunks/chunk-ASZKAC24.js +0 -103
  65. package/dist/chunks/chunk-GSA432UC.js +0 -90
  66. package/dist/chunks/disable-FGJ7VMPO.js +0 -47
  67. package/dist/chunks/doctor-7NWBJAH7.js +0 -53
  68. package/dist/chunks/enable-ZL6QOC2I.js +0 -47
  69. package/dist/chunks/list-NZ5DHXJF.js +0 -111
  70. package/dist/chunks/resolver-36V72VKR.js +0 -28
  71. package/dist/chunks/run-IVL23SMW.js +0 -26
  72. package/dist/chunks/rune-XRREUL56.js +0 -186
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  addMarketplace
3
- } from "./chunk-NYLRTAAA.js";
4
- import "./chunk-6MRZXASS.js";
3
+ } from "./chunk-YVN3VDRE.js";
4
+ import "./chunk-2Q3KLBE6.js";
5
5
  import {
6
6
  init_require_shim
7
7
  } from "./chunk-TPK5AGRA.js";
@@ -1,21 +1,21 @@
1
+ import {
2
+ loadConfig
3
+ } from "./chunk-QYRF3R35.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
- loadConfig
9
- } from "./chunk-GSA432UC.js";
10
- import {
11
- output
12
- } from "./chunk-6XLT25GS.js";
13
13
  import "./chunk-WCODTMDN.js";
14
14
  import {
15
15
  loadRegistry,
16
16
  resolvePluginKey
17
- } from "./chunk-GTCPZ22N.js";
18
- import "./chunk-6MRZXASS.js";
17
+ } from "./chunk-VST6HAB6.js";
18
+ import "./chunk-2Q3KLBE6.js";
19
19
  import {
20
20
  loadPluginJson
21
21
  } from "./chunk-G3U4V32O.js";
@@ -117,7 +117,7 @@ async function handler({
117
117
  let templateMeta = {};
118
118
  if (resolved.type === "local") {
119
119
  const localPath = typeof resolved.entry === "string" ? resolved.entry : resolved.entry.path;
120
- await fs.copyFile(path.join(projectRoot, localPath), runeAbsPath);
120
+ await fs.copyFile(path.resolve(projectRoot, localPath), runeAbsPath);
121
121
  templateMeta = typeof resolved.entry === "string" ? {} : resolved.entry;
122
122
  } else if (resolved.type === "shortcut") {
123
123
  const pluginRef = resolved.entry.plugin;
@@ -1,26 +1,28 @@
1
1
  import {
2
+ joinBracketTokens,
2
3
  parseBracketKey
3
- } from "./chunk-BTIPUR5S.js";
4
- import {
5
- loadConfig
6
- } from "./chunk-GSA432UC.js";
4
+ } from "./chunk-SNC7AOT7.js";
7
5
  import {
8
6
  runRune
9
- } from "./chunk-WJRZN7BR.js";
10
- import "./chunk-J3GZ3DXD.js";
11
- import "./chunk-ZJDKCC2Y.js";
12
- import "./chunk-NDEYEYSU.js";
7
+ } from "./chunk-YXCHIMLW.js";
8
+ import "./chunk-UEUUOAJY.js";
9
+ import "./chunk-4GJMCFR6.js";
10
+ import "./chunk-CY6C6ADU.js";
11
+ import "./chunk-GVMT55GH.js";
12
+ import "./chunk-WJII3LZK.js";
13
13
  import "./chunk-G4ZAUHHA.js";
14
- import "./chunk-63H5VXZY.js";
15
- import "./chunk-ASZKAC24.js";
14
+ import {
15
+ loadConfig
16
+ } from "./chunk-QYRF3R35.js";
16
17
  import {
17
18
  output
18
- } from "./chunk-6XLT25GS.js";
19
+ } from "./chunk-MIKWIFYR.js";
20
+ import "./chunk-CGZL5SSH.js";
19
21
  import {
20
22
  source_default
21
23
  } from "./chunk-WCODTMDN.js";
22
- import "./chunk-GTCPZ22N.js";
23
- import "./chunk-6MRZXASS.js";
24
+ import "./chunk-VST6HAB6.js";
25
+ import "./chunk-2Q3KLBE6.js";
24
26
  import "./chunk-G3U4V32O.js";
25
27
  import {
26
28
  init_require_shim
@@ -98,7 +100,8 @@ function parseBenchArgs(argv) {
98
100
  }
99
101
  }
100
102
  rawSegments.push(current);
101
- const segments = rawSegments.map((seg) => {
103
+ const segments = rawSegments.map((rawSeg) => {
104
+ const seg = joinBracketTokens(rawSeg);
102
105
  const { key, bracketArgs } = parseBracketKey(seg[0] ?? "");
103
106
  let runs = globalRuns;
104
107
  let warmup = globalWarmup;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  searchMarketplaces
3
- } from "./chunk-NYLRTAAA.js";
4
- import "./chunk-6MRZXASS.js";
3
+ } from "./chunk-YVN3VDRE.js";
4
+ import "./chunk-2Q3KLBE6.js";
5
5
  import {
6
6
  init_require_shim
7
7
  } from "./chunk-TPK5AGRA.js";
@@ -5,11 +5,25 @@ import {
5
5
  // src/store/index.js
6
6
  init_require_shim();
7
7
  import fs from "node:fs/promises";
8
+ import { existsSync } from "node:fs";
8
9
  import os from "node:os";
9
10
  import path from "node:path";
11
+ import { createHash } from "node:crypto";
10
12
  function getStorePath() {
11
13
  return process.env.CRUNES_STORE ?? path.join(os.homedir(), ".crunes");
12
14
  }
15
+ function shortHash(str) {
16
+ return createHash("sha1").update(str).digest("hex").slice(0, 8);
17
+ }
18
+ function isRootless(projectDir) {
19
+ return !existsSync(path.join(projectDir, ".crunes", "config.json"));
20
+ }
21
+ function getRootlessBase(projectDir) {
22
+ return path.join(getStorePath(), "rootless", shortHash(projectDir));
23
+ }
24
+ function getLocalBase(projectDir) {
25
+ return isRootless(projectDir) ? getRootlessBase(projectDir) : path.join(projectDir, ".crunes");
26
+ }
13
27
  function getProjectsJsonPath() {
14
28
  return path.join(getStorePath(), "projects.json");
15
29
  }
@@ -49,6 +63,8 @@ async function ensureStoreDirs() {
49
63
 
50
64
  export {
51
65
  getStorePath,
66
+ isRootless,
67
+ getLocalBase,
52
68
  getProjectsJsonPath,
53
69
  getPluginsJsonPath,
54
70
  getPluginCacheDir,
@@ -1,5 +1,16 @@
1
1
  import {
2
- Ce,
2
+ getConfigPath,
3
+ readRawConfig,
4
+ setPluginEnabled,
5
+ writeRawConfig
6
+ } from "./chunk-X7PZN73N.js";
7
+ import {
8
+ coercePlugins
9
+ } from "./chunk-QYRF3R35.js";
10
+ import {
11
+ output
12
+ } from "./chunk-MIKWIFYR.js";
13
+ import {
3
14
  R,
4
15
  le
5
16
  } from "./chunk-CGZL5SSH.js";
@@ -7,12 +18,12 @@ import {
7
18
  loadRegistry,
8
19
  registerPlugin,
9
20
  removePlugin
10
- } from "./chunk-GTCPZ22N.js";
21
+ } from "./chunk-VST6HAB6.js";
11
22
  import {
12
23
  ensureStoreDirs,
13
24
  getPluginCacheDir,
14
25
  getPnpmStorePath
15
- } from "./chunk-6MRZXASS.js";
26
+ } from "./chunk-2Q3KLBE6.js";
16
27
  import {
17
28
  loadPluginJson
18
29
  } from "./chunk-G3U4V32O.js";
@@ -143,7 +154,7 @@ function formatConsentScreen(pluginName, pluginJson) {
143
154
  async function promptConsent(pluginName, pluginJson, { yes = false } = {}) {
144
155
  const isYes = yes || !process.stdout.isTTY;
145
156
  if (isYes) return true;
146
- Ce(formatConsentScreen(pluginName, pluginJson), "Permissions requested");
157
+ output.note(formatConsentScreen(pluginName, pluginJson), "Permissions requested");
147
158
  const answer = await le({ message: "Allow these permissions?" });
148
159
  if (R(answer)) return false;
149
160
  return answer === true;
@@ -170,7 +181,7 @@ async function promptReConsent(pluginName, diff, { yes = false } = {}) {
170
181
  }
171
182
  lines.push("");
172
183
  }
173
- Ce(lines.join("\n"), "New permissions");
184
+ output.note(lines.join("\n"), "New permissions");
174
185
  const answer = await le({ message: "Allow these new permissions?" });
175
186
  if (R(answer)) return false;
176
187
  return answer === true;
@@ -228,7 +239,7 @@ async function downloadNpm(packageName, destDir) {
228
239
  }
229
240
  }
230
241
  async function installPlugin(source, projectDir, provenance = {}, options = {}) {
231
- const { yes = false } = options;
242
+ const { yes = false, global = false } = options;
232
243
  if (!provenance.marketplaceName) {
233
244
  throw new Error("Direct installs are not allowed. Use: crunes plugin install <marketplace>@<plugin>");
234
245
  }
@@ -255,7 +266,7 @@ async function installPlugin(source, projectDir, provenance = {}, options = {})
255
266
  const registry = await loadRegistry();
256
267
  const existing = registry.plugins?.[pluginKey];
257
268
  if (existing) {
258
- return await updatePlugin(pluginKey, stagingDir, pluginJson, projectDir, type === "local", provenance, { yes });
269
+ return await updatePlugin(pluginKey, stagingDir, pluginJson, projectDir, type === "local", provenance, { yes, global });
259
270
  }
260
271
  const isLocal = type === "local";
261
272
  const cacheDir = getPluginCacheDir(name, version, provenance.marketplaceName);
@@ -275,7 +286,7 @@ async function installPlugin(source, projectDir, provenance = {}, options = {})
275
286
  consentedPermissions[key] = collectAllowFromRune(rune);
276
287
  }
277
288
  await registerPlugin({ name, version, path: isLocal ? stagingDir : cacheDir, cacheDir, local: isLocal, consentedPermissions, ...provenance });
278
- await addPluginToProjectConfig(projectDir, pluginKey);
289
+ await setEnabled(projectDir, pluginKey, true, global);
279
290
  return { installed: true, name: pluginKey, version };
280
291
  } finally {
281
292
  if (type !== "local") {
@@ -285,7 +296,7 @@ async function installPlugin(source, projectDir, provenance = {}, options = {})
285
296
  }
286
297
  }
287
298
  async function updatePlugin(pluginKey, newPluginDir, newPluginJson, projectDir, isLocal, provenance = {}, options = {}) {
288
- const { yes = false } = options;
299
+ const { yes = false, global = false } = options;
289
300
  const registry = await loadRegistry();
290
301
  const existing = registry.plugins[pluginKey];
291
302
  if (!existing) throw new Error(`Plugin "${pluginKey}" is not installed.`);
@@ -311,26 +322,31 @@ async function updatePlugin(pluginKey, newPluginDir, newPluginJson, projectDir,
311
322
  consentedPermissions[key] = collectAllowFromRune(rune);
312
323
  }
313
324
  await registerPlugin({ name, version, path: isLocal ? newPluginDir : cacheDir, cacheDir, local: isLocal, consentedPermissions, ...provenance });
314
- await addPluginToProjectConfig(projectDir, pluginKey);
325
+ await setEnabled(projectDir, pluginKey, true, global);
315
326
  return { installed: true, name: pluginKey, version, updated: true };
316
327
  }
317
- async function addPluginToProjectConfig(projectDir, pluginName) {
318
- if (!projectDir) return;
319
- const configPath = path2.join(projectDir, ".crunes", "config.json");
328
+ async function setEnabled(projectDir, pluginKey, enabled, global) {
329
+ if (!projectDir && !global) return;
320
330
  try {
321
- const raw = await fs2.readFile(configPath, "utf8");
322
- const config = JSON.parse(raw);
323
- const plugins = config.plugins ?? [];
324
- if (!plugins.includes(pluginName)) {
325
- config.plugins = [...plugins, pluginName];
326
- const tmp = configPath + "." + Date.now() + Math.random().toString(36).slice(2) + ".tmp";
327
- await fs2.writeFile(tmp, JSON.stringify(config, null, 2), "utf8");
328
- await fs2.rename(tmp, configPath);
329
- }
331
+ await setPluginEnabled(getConfigPath({ configRoot: projectDir, global }), pluginKey, enabled);
332
+ } catch {
333
+ }
334
+ }
335
+ async function removeEnabled(projectDir, pluginKey, global) {
336
+ if (!projectDir && !global) return;
337
+ try {
338
+ const configPath = getConfigPath({ configRoot: projectDir, global });
339
+ const config = readRawConfig(configPath);
340
+ if (!config) return;
341
+ const plugins = coercePlugins(config.plugins);
342
+ if (!(pluginKey in plugins)) return;
343
+ delete plugins[pluginKey];
344
+ config.plugins = plugins;
345
+ await writeRawConfig(configPath, config);
330
346
  } catch {
331
347
  }
332
348
  }
333
- async function uninstallPlugin(pluginKey, projectDir) {
349
+ async function uninstallPlugin(pluginKey, projectDir, { global = false } = {}) {
334
350
  const registry = await loadRegistry();
335
351
  const entry = registry.plugins?.[pluginKey];
336
352
  if (!entry) throw new Error(`Plugin "${pluginKey}" is not installed.`);
@@ -347,20 +363,7 @@ async function uninstallPlugin(pluginKey, projectDir) {
347
363
  } catch {
348
364
  }
349
365
  await removePlugin(pluginKey);
350
- await removePluginFromProjectConfig(projectDir, pluginKey);
351
- }
352
- async function removePluginFromProjectConfig(projectDir, pluginName) {
353
- if (!projectDir) return;
354
- const configPath = path2.join(projectDir, ".crunes", "config.json");
355
- try {
356
- const raw = await fs2.readFile(configPath, "utf8");
357
- const config = JSON.parse(raw);
358
- config.plugins = (config.plugins ?? []).filter((p) => p !== pluginName);
359
- const tmp = configPath + "." + Date.now() + Math.random().toString(36).slice(2) + ".tmp";
360
- await fs2.writeFile(tmp, JSON.stringify(config, null, 2), "utf8");
361
- await fs2.rename(tmp, configPath);
362
- } catch {
363
- }
366
+ await removeEnabled(projectDir, pluginKey, global);
364
367
  }
365
368
 
366
369
  export {
@@ -1,3 +1,6 @@
1
+ import {
2
+ getLocalBase
3
+ } from "./chunk-2Q3KLBE6.js";
1
4
  import {
2
5
  init_require_shim
3
6
  } from "./chunk-TPK5AGRA.js";
@@ -8,7 +11,7 @@ import { readFile, writeFile, mkdir, readdir, rm } from "node:fs/promises";
8
11
  import { join } from "node:path";
9
12
  import { randomUUID } from "node:crypto";
10
13
  function jobDir(projectDir, id) {
11
- return join(projectDir, ".crunes", "jobs", id);
14
+ return join(getLocalBase(projectDir), "jobs", id);
12
15
  }
13
16
  function jobStdoutPath(projectDir, id) {
14
17
  return join(jobDir(projectDir, id), "stdout.log");
@@ -42,7 +45,7 @@ async function getJob(projectDir, id) {
42
45
  }
43
46
  }
44
47
  async function listJobs(projectDir) {
45
- const base = join(projectDir, ".crunes", "jobs");
48
+ const base = join(getLocalBase(projectDir), "jobs");
46
49
  let entries;
47
50
  try {
48
51
  entries = await readdir(base, { withFileTypes: true });
@@ -58,7 +61,7 @@ async function deleteJob(projectDir, id) {
58
61
  await rm(jobDir(projectDir, id), { recursive: true, force: true });
59
62
  }
60
63
  async function cleanJobs(projectDir) {
61
- const base = join(projectDir, ".crunes", "jobs");
64
+ const base = join(getLocalBase(projectDir), "jobs");
62
65
  let entries;
63
66
  try {
64
67
  entries = await readdir(base, { withFileTypes: true });