@darkrymit/crunes-cli 0.9.0 → 0.10.1

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 (58) hide show
  1. package/dist/chunks/add-2OM5KGN5.js +67 -0
  2. package/dist/chunks/{apply-YY7MIM64.js → apply-GBUQQ4XF.js} +21 -9
  3. package/dist/chunks/{benchmark-BQNMULOO.js → benchmark-QWGVX3BX.js} +21 -15
  4. package/dist/chunks/chunk-2DNYVKBF.js +109 -0
  5. package/dist/chunks/chunk-2HM5Q52B.js +131 -0
  6. package/dist/chunks/chunk-3KKRNQQU.js +275 -0
  7. package/dist/chunks/chunk-55GTJG5I.js +1154 -0
  8. package/dist/chunks/chunk-7KYCYDAS.js +325 -0
  9. package/dist/chunks/{chunk-SNC7AOT7.js → chunk-AL37NFWR.js} +45 -94
  10. package/dist/chunks/chunk-ARIFLX5E.js +9525 -0
  11. package/dist/chunks/{chunk-X7PZN73N.js → chunk-E7CZPAM2.js} +1 -1
  12. package/dist/chunks/chunk-EO3CSXWK.js +70 -0
  13. package/dist/chunks/chunk-FIAFVIAN.js +79 -0
  14. package/dist/chunks/{chunk-MRNZFUXZ.js → chunk-KQMTTEJV.js} +22 -7
  15. package/dist/chunks/chunk-KX6QEHM5.js +578 -0
  16. package/dist/chunks/{chunk-VST6HAB6.js → chunk-MTJ2KW3V.js} +2 -0
  17. package/dist/chunks/chunk-MUWDZJN2.js +71 -0
  18. package/dist/chunks/{chunk-CY6C6ADU.js → chunk-MVCBPI4J.js} +45 -478
  19. package/dist/chunks/{chunk-34F4ZURL.js → chunk-NJVPLN5D.js} +29 -12
  20. package/dist/chunks/chunk-UBCAZGLE.js +15 -0
  21. package/dist/chunks/chunk-VP7YLCQP.js +244 -0
  22. package/dist/chunks/chunk-VSMAZISQ.js +303 -0
  23. package/dist/chunks/chunk-WE4HDHFU.js +37 -0
  24. package/dist/chunks/{create-ET6DT5ZE.js → create-2CQZF53Z.js} +5 -2
  25. package/dist/chunks/{create-LM7U3CJS.js → create-36F6V4WP.js} +99 -6
  26. package/dist/chunks/{create-TLPM7HJE.js → create-DXW4YYLJ.js} +5 -5
  27. package/dist/chunks/{disable-TNTEIAKO.js → disable-FB64CSYV.js} +5 -2
  28. package/dist/chunks/doctor-PVO4JLYN.js +208 -0
  29. package/dist/chunks/{enable-GUQCB4CU.js → enable-UVXHTKCJ.js} +6 -3
  30. package/dist/chunks/{init-PJSCFOC6.js → init-GPNC7TR5.js} +5 -2
  31. package/dist/chunks/{install-4YP7FALO.js → install-3G7U5ZIO.js} +10 -5
  32. package/dist/chunks/{intro-SA7MWV3Z.js → intro-YI5HUZCF.js} +45 -19
  33. package/dist/chunks/{list-WKNPZZOV.js → list-J2UCBYAY.js} +9 -6
  34. package/dist/chunks/list-JB4447YK.js +62 -0
  35. package/dist/chunks/{list-7R6NASFI.js → list-W4JAYPAA.js} +19 -19
  36. package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
  37. package/dist/chunks/{registry-K5DV5NAK.js → registry-IWP7JMNI.js} +1 -1
  38. package/dist/chunks/{repl-ZB3DIJ4K.js → repl-MWFEZ65P.js} +30 -20
  39. package/dist/chunks/resolver-URPQMOIV.js +36 -0
  40. package/dist/chunks/{run-22B65ZWZ.js → run-3VKWSRLO.js} +17 -11
  41. package/dist/chunks/rune-L5EP645W.js +283 -0
  42. package/dist/chunks/runner-VPTLUQJE.js +34 -0
  43. package/dist/chunks/{shell-explain-QLITLHW7.js → shell-explain-LKBBP2BG.js} +5 -2
  44. package/dist/chunks/trust-LXXYSF6W.js +109 -0
  45. package/dist/chunks/{uninstall-4WR5IHLC.js → uninstall-J7JUYETA.js} +10 -5
  46. package/dist/chunks/{update-ACLDK6E6.js → update-ZJRLDCUT.js} +10 -5
  47. package/dist/chunks/{version-EULYWNXN.js → version-ZULO6CV3.js} +2 -2
  48. package/dist/cli.js +47 -34
  49. package/package.json +2 -2
  50. package/dist/chunks/chunk-G3U4V32O.js +0 -46
  51. package/dist/chunks/chunk-QYRF3R35.js +0 -154
  52. package/dist/chunks/chunk-YXCHIMLW.js +0 -75308
  53. package/dist/chunks/doctor-VXAQYMTR.js +0 -101
  54. package/dist/chunks/list-OMMZAQ23.js +0 -28
  55. package/dist/chunks/resolver-QIYYFIDX.js +0 -34
  56. package/dist/chunks/rune-SYK4N642.js +0 -425
  57. package/dist/chunks/{delete-5R3WBLVD.js → delete-2EXPFBFC.js} +4 -4
  58. package/dist/chunks/{delete-U4STA2QZ.js → delete-MJAECXXV.js} +4 -4
@@ -271,8 +271,8 @@ var require_utils = __commonJS({
271
271
  }
272
272
  return output;
273
273
  };
274
- exports.basename = (path4, { windows } = {}) => {
275
- const segs = path4.split(windows ? /[\\/]/ : "/");
274
+ exports.basename = (path3, { windows } = {}) => {
275
+ const segs = path3.split(windows ? /[\\/]/ : "/");
276
276
  const last = segs[segs.length - 1];
277
277
  if (last === "") {
278
278
  return segs[segs.length - 2];
@@ -1770,400 +1770,6 @@ var require_picomatch2 = __commonJS({
1770
1770
  }
1771
1771
  });
1772
1772
 
1773
- // src/rune/api/shell-resolve.js
1774
- init_require_shim();
1775
- import { existsSync } from "node:fs";
1776
- import path from "node:path";
1777
- var ShellResolutionError = class extends Error {
1778
- constructor(message, { mode, tried }) {
1779
- super(message);
1780
- this.name = "ShellResolutionError";
1781
- this.mode = mode;
1782
- this.tried = tried;
1783
- }
1784
- };
1785
- function isWslLauncher(candidate, env) {
1786
- const systemRoot = (env.SystemRoot ?? "C:\\Windows").replace(/\\/g, "/").toLowerCase();
1787
- const p = String(candidate).replace(/\\/g, "/").toLowerCase();
1788
- return p.startsWith(`${systemRoot}/system32/`);
1789
- }
1790
- function bashCandidates(deps) {
1791
- const { platform, env, pathDirs } = deps;
1792
- if (platform !== "win32") {
1793
- return ["/bin/bash", "/usr/bin/bash", ...pathDirs.map((d) => path.posix.join(d, "bash"))];
1794
- }
1795
- const out = [];
1796
- if (env.ProgramFiles) out.push(path.win32.join(env.ProgramFiles, "Git", "bin", "bash.exe"));
1797
- if (env["ProgramFiles(x86)"]) out.push(path.win32.join(env["ProgramFiles(x86)"], "Git", "bin", "bash.exe"));
1798
- if (env.LOCALAPPDATA) out.push(path.win32.join(env.LOCALAPPDATA, "Programs", "Git", "bin", "bash.exe"));
1799
- for (const dir of pathDirs) {
1800
- const candidate = path.win32.join(dir, "bash.exe");
1801
- if (isWslLauncher(candidate, env)) continue;
1802
- out.push(candidate);
1803
- }
1804
- return out;
1805
- }
1806
- function findBash(deps) {
1807
- const { env, exists } = deps;
1808
- const tried = bashCandidates(deps);
1809
- for (const candidate of tried) {
1810
- if (exists(candidate)) return { path: candidate, tried };
1811
- }
1812
- const override = env.CRUNES_BASH;
1813
- if (override && exists(override) && !isWslLauncher(override, env)) {
1814
- return { path: override, tried: [...tried, override] };
1815
- }
1816
- return { path: null, tried: override ? [...tried, override] : tried };
1817
- }
1818
- function findSh(deps) {
1819
- if (deps.platform === "win32") return null;
1820
- return deps.exists("/bin/sh") ? "/bin/sh" : null;
1821
- }
1822
- function findCmd(deps) {
1823
- if (deps.platform !== "win32") return null;
1824
- return deps.env.ComSpec ?? "C:\\Windows\\System32\\cmd.exe";
1825
- }
1826
- var cached = null;
1827
- function defaultDeps() {
1828
- const sep = process.platform === "win32" ? ";" : ":";
1829
- return {
1830
- platform: process.platform,
1831
- env: process.env,
1832
- exists: (p) => {
1833
- try {
1834
- return existsSync(p);
1835
- } catch {
1836
- return false;
1837
- }
1838
- },
1839
- pathDirs: (process.env.PATH ?? "").split(sep).filter(Boolean)
1840
- };
1841
- }
1842
- function resolveShell(mode, deps = null) {
1843
- const d = deps ?? defaultDeps();
1844
- const useCache = deps === null;
1845
- if (mode !== void 0 && mode !== "bash" && mode !== "cmd") {
1846
- throw new ShellResolutionError(`Unknown shell mode: '${mode}'. Expected 'bash', 'cmd', or undefined.`, { mode, tried: [] });
1847
- }
1848
- if (useCache && cached && cached[String(mode)]) return cached[String(mode)];
1849
- let result;
1850
- if (mode === "bash") {
1851
- const { path: bash, tried } = findBash(d);
1852
- if (!bash) {
1853
- throw new ShellResolutionError(
1854
- `shell: 'bash' was requested but no bash was found. Tried:
1855
- ${tried.join("\n ")}
1856
- Set CRUNES_BASH to an absolute bash path if it is installed elsewhere.`,
1857
- { mode, tried }
1858
- );
1859
- }
1860
- result = { kind: "bash", path: bash };
1861
- } else if (mode === "cmd") {
1862
- const cmd = findCmd(d);
1863
- if (!cmd) {
1864
- throw new ShellResolutionError(`shell: 'cmd' is only available on Windows (platform is '${d.platform}').`, { mode, tried: [] });
1865
- }
1866
- result = { kind: "cmd", path: cmd };
1867
- } else {
1868
- const { path: bash, tried } = findBash(d);
1869
- if (bash) {
1870
- result = { kind: "bash", path: bash };
1871
- } else {
1872
- const sh = findSh(d);
1873
- if (sh) {
1874
- result = { kind: "sh", path: sh };
1875
- } else {
1876
- const cmd = findCmd(d);
1877
- if (!cmd) {
1878
- throw new ShellResolutionError(
1879
- `No usable shell found. Tried bash:
1880
- ${tried.join("\n ")}
1881
- then /bin/sh.`,
1882
- { mode, tried: [...tried, "/bin/sh"] }
1883
- );
1884
- }
1885
- result = { kind: "cmd", path: cmd };
1886
- }
1887
- }
1888
- }
1889
- if (useCache) {
1890
- cached ??= {};
1891
- cached[String(mode)] = result;
1892
- }
1893
- return result;
1894
- }
1895
-
1896
- // src/rune/permissions/shell-scan.js
1897
- init_require_shim();
1898
- var ScanRefusal = class extends Error {
1899
- constructor(construct, offset) {
1900
- super(`Cannot scan command: ${construct} at offset ${offset} is not supported.`);
1901
- this.name = "ScanRefusal";
1902
- this.construct = construct;
1903
- this.offset = offset;
1904
- }
1905
- };
1906
- var ASSIGNMENT_RE = /^[A-Za-z_][A-Za-z0-9_]*=/;
1907
- var CONTROL_KEYWORDS = /* @__PURE__ */ new Set([
1908
- "if",
1909
- "then",
1910
- "else",
1911
- "elif",
1912
- "fi",
1913
- "while",
1914
- "until",
1915
- "do",
1916
- "done",
1917
- "for",
1918
- "select",
1919
- "case",
1920
- "esac",
1921
- "function"
1922
- ]);
1923
- var NESTED_INTERPRETERS = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash", "ksh"]);
1924
- var CMD_METACHARACTERS = /[&|<>^%()]/;
1925
- function guardCmdMode(cmd) {
1926
- const m = CMD_METACHARACTERS.exec(cmd);
1927
- if (m) throw new ScanRefusal("cmd metacharacter", m.index);
1928
- }
1929
- function matchDelimiter(src, from, open, close) {
1930
- let depth = 1;
1931
- let i = from;
1932
- while (i < src.length) {
1933
- const ch = src[i];
1934
- if (ch === "\\") {
1935
- i += 2;
1936
- continue;
1937
- }
1938
- if (ch === "'") {
1939
- const e = src.indexOf("'", i + 1);
1940
- if (e === -1) return -1;
1941
- i = e + 1;
1942
- continue;
1943
- }
1944
- if (ch === '"') {
1945
- const e = src.indexOf('"', i + 1);
1946
- if (e === -1) return -1;
1947
- i = e + 1;
1948
- continue;
1949
- }
1950
- if (ch === open) depth++;
1951
- else if (ch === close) {
1952
- depth--;
1953
- if (depth === 0) return i;
1954
- }
1955
- i++;
1956
- }
1957
- return -1;
1958
- }
1959
- function isOperatorStart(ch) {
1960
- return ch === "|" || ch === "&" || ch === ";" || ch === "\n";
1961
- }
1962
- function tokenize(src, baseOffset) {
1963
- const tokens = [];
1964
- let i = 0;
1965
- let buf = "";
1966
- let bufStart = -1;
1967
- let hadWord = false;
1968
- const flush = () => {
1969
- if (!hadWord) return;
1970
- tokens.push({ type: "word", value: buf, offset: baseOffset + bufStart });
1971
- buf = "";
1972
- bufStart = -1;
1973
- hadWord = false;
1974
- };
1975
- const begin = (at) => {
1976
- if (!hadWord) {
1977
- hadWord = true;
1978
- bufStart = at;
1979
- }
1980
- };
1981
- while (i < src.length) {
1982
- const ch = src[i];
1983
- if (ch === " " || ch === " ") {
1984
- flush();
1985
- i++;
1986
- continue;
1987
- }
1988
- if (ch === "'") {
1989
- const end = src.indexOf("'", i + 1);
1990
- if (end === -1) throw new ScanRefusal("unterminated single quote", baseOffset + i);
1991
- begin(i);
1992
- buf += src.slice(i + 1, end);
1993
- i = end + 1;
1994
- continue;
1995
- }
1996
- if (ch === '"') {
1997
- begin(i);
1998
- let j = i + 1;
1999
- let inner = "";
2000
- let closed = false;
2001
- while (j < src.length) {
2002
- if (src[j] === "\\" && j + 1 < src.length) {
2003
- inner += src[j + 1];
2004
- j += 2;
2005
- continue;
2006
- }
2007
- if (src[j] === '"') {
2008
- closed = true;
2009
- break;
2010
- }
2011
- inner += src[j];
2012
- j++;
2013
- }
2014
- if (!closed) throw new ScanRefusal("unterminated double quote", baseOffset + i);
2015
- if (inner.includes("$(") || inner.includes("`")) {
2016
- const nested = tokenize(inner, baseOffset + i + 1);
2017
- for (const t of nested) {
2018
- if (t.type === "subst") tokens.push({ ...t, inCommandPosition: false });
2019
- }
2020
- buf += inner.replace(/\$\([^)]*\)|`[^`]*`/g, "");
2021
- } else {
2022
- buf += inner;
2023
- }
2024
- i = j + 1;
2025
- continue;
2026
- }
2027
- if (ch === "\\" && i + 1 < src.length) {
2028
- begin(i);
2029
- buf += src[i + 1];
2030
- i += 2;
2031
- continue;
2032
- }
2033
- if (ch === "$" && src[i + 1] === "(" && src[i + 2] === "(") {
2034
- throw new ScanRefusal("arithmetic expansion", baseOffset + i);
2035
- }
2036
- if (ch === "<" && src[i + 1] === "<") {
2037
- throw new ScanRefusal("heredoc", baseOffset + i);
2038
- }
2039
- if ((ch === "<" || ch === ">") && src[i + 1] === "(") {
2040
- throw new ScanRefusal("process substitution", baseOffset + i);
2041
- }
2042
- if (ch === "$" && src[i + 1] === "(") {
2043
- const end = matchDelimiter(src, i + 2, "(", ")");
2044
- if (end === -1) throw new ScanRefusal("unterminated command substitution", baseOffset + i);
2045
- const wasInCommandPosition = !hadWord;
2046
- flush();
2047
- tokens.push({ type: "subst", src: src.slice(i + 2, end), offset: baseOffset + i + 2, inCommandPosition: wasInCommandPosition });
2048
- i = end + 1;
2049
- continue;
2050
- }
2051
- if (ch === "`") {
2052
- const end = src.indexOf("`", i + 1);
2053
- if (end === -1) throw new ScanRefusal("unterminated command substitution", baseOffset + i);
2054
- const wasInCommandPosition = !hadWord;
2055
- flush();
2056
- tokens.push({ type: "subst", src: src.slice(i + 1, end), offset: baseOffset + i + 1, inCommandPosition: wasInCommandPosition });
2057
- i = end + 1;
2058
- continue;
2059
- }
2060
- if (ch === "(" && !hadWord) {
2061
- const end = matchDelimiter(src, i + 1, "(", ")");
2062
- if (end === -1) throw new ScanRefusal("unterminated subshell", baseOffset + i);
2063
- flush();
2064
- tokens.push({ type: "group", src: src.slice(i + 1, end), offset: baseOffset + i + 1 });
2065
- i = end + 1;
2066
- continue;
2067
- }
2068
- if (ch === ">" || ch === "<" || ch === "&" && src[i + 1] === ">") {
2069
- let opLen = 1;
2070
- let mode = ch === "<" ? "read" : "write";
2071
- if (ch === "&") {
2072
- opLen = 2;
2073
- mode = "write";
2074
- } else if (src[i + 1] === ">" || src[i + 1] === "|") opLen = 2;
2075
- if (hadWord && /^\d+$/.test(buf) && (ch === ">" || ch === "<")) {
2076
- buf = "";
2077
- hadWord = false;
2078
- bufStart = -1;
2079
- } else {
2080
- flush();
2081
- }
2082
- tokens.push({ type: "redirect", mode, offset: baseOffset + i });
2083
- i += opLen;
2084
- continue;
2085
- }
2086
- if (isOperatorStart(ch)) {
2087
- flush();
2088
- let op = ch;
2089
- if (ch === "|" && src[i + 1] === "|" || ch === "&" && src[i + 1] === "&") op = ch + ch;
2090
- tokens.push({ type: "op", value: op, offset: baseOffset + i });
2091
- i += op.length;
2092
- continue;
2093
- }
2094
- begin(i);
2095
- buf += ch;
2096
- i++;
2097
- }
2098
- flush();
2099
- return tokens;
2100
- }
2101
- function splitSegments(tokens) {
2102
- const segments = [];
2103
- let current = [];
2104
- for (const t of tokens) {
2105
- if (t.type === "op") {
2106
- segments.push(current);
2107
- current = [];
2108
- continue;
2109
- }
2110
- current.push(t);
2111
- }
2112
- segments.push(current);
2113
- return segments.filter((s) => s.length > 0);
2114
- }
2115
- function stripAssignments(words) {
2116
- let k = 0;
2117
- while (k < words.length && ASSIGNMENT_RE.test(words[k].value)) k++;
2118
- return words.slice(k);
2119
- }
2120
- function scanCommand(cmd, shellKind = "bash") {
2121
- if (shellKind === "cmd") guardCmdMode(cmd);
2122
- const commands = [];
2123
- const redirects = [];
2124
- collect(tokenize(cmd, 0), commands, redirects);
2125
- return { commands, redirects };
2126
- }
2127
- function collect(tokens, commands, redirects) {
2128
- for (const segment of splitSegments(tokens)) {
2129
- const words = [];
2130
- for (let k = 0; k < segment.length; k++) {
2131
- const t = segment[k];
2132
- if (t.type === "subst" || t.type === "group") {
2133
- if (t.type === "subst" && t.inCommandPosition && words.length === 0) {
2134
- throw new ScanRefusal("substitution in command position", t.offset);
2135
- }
2136
- collect(tokenize(t.src, t.offset), commands, redirects);
2137
- continue;
2138
- }
2139
- if (t.type === "redirect") {
2140
- const target = segment[k + 1];
2141
- if (!target || target.type !== "word") throw new ScanRefusal("redirect without target", t.offset);
2142
- if (target.value.startsWith("$")) throw new ScanRefusal("variable redirect target", target.offset);
2143
- redirects.push({ mode: t.mode, target: target.value, offset: target.offset });
2144
- k++;
2145
- continue;
2146
- }
2147
- words.push(t);
2148
- }
2149
- const real = stripAssignments(words);
2150
- if (real.length === 0) continue;
2151
- const program = real[0].value;
2152
- const args = real.slice(1).map((w) => w.value);
2153
- if (program.startsWith("$")) throw new ScanRefusal("variable in command position", real[0].offset);
2154
- if (CONTROL_KEYWORDS.has(program)) throw new ScanRefusal("control structure", real[0].offset);
2155
- if (program === "eval") throw new ScanRefusal("eval", real[0].offset);
2156
- if (program === "xargs") throw new ScanRefusal("xargs", real[0].offset);
2157
- if (NESTED_INTERPRETERS.has(program) && args.includes("-c")) {
2158
- throw new ScanRefusal("nested interpreter", real[0].offset);
2159
- }
2160
- if (program === "find" && args.some((a) => a === "-exec" || a === "-execdir" || a === "-ok")) {
2161
- throw new ScanRefusal("find -exec", real[0].offset);
2162
- }
2163
- commands.push({ program, args, segment: [program, ...args].join(" "), offset: real[0].offset });
2164
- }
2165
- }
2166
-
2167
1773
  // src/shared/match.js
2168
1774
  init_require_shim();
2169
1775
  var import_picomatch = __toESM(require_picomatch2(), 1);
@@ -2177,40 +1783,31 @@ var isWildcardMatch = (value, patterns) => {
2177
1783
  return list.some((p) => wildcardToRegex(p).test(value));
2178
1784
  };
2179
1785
 
2180
- // src/rune/permissions/permissions.js
2181
- init_require_shim();
2182
- import os2 from "node:os";
2183
-
2184
- // src/rune/api/utils.js
2185
- init_require_shim();
2186
- import os from "node:os";
2187
- import path3 from "node:path";
2188
-
2189
1786
  // src/project/index.js
2190
1787
  init_require_shim();
2191
1788
  import { readFile, writeFile, mkdir } from "node:fs/promises";
2192
1789
  import { dirname } from "node:path";
2193
1790
  import { createHash } from "node:crypto";
2194
- import path2 from "node:path";
1791
+ import path from "node:path";
2195
1792
  function shortHash(str) {
2196
1793
  return createHash("sha1").update(str).digest("hex").slice(0, 8);
2197
1794
  }
2198
1795
  async function ensureProjectIdentity(dir) {
2199
- const localJsonPath = path2.join(dir, ".crunes", "project.local.json");
1796
+ const localJsonPath = path.join(dir, ".crunes", "project.local.json");
2200
1797
  try {
2201
1798
  const raw = await readFile(localJsonPath, "utf8");
2202
1799
  return JSON.parse(raw);
2203
1800
  } catch {
2204
1801
  }
2205
- let alias = path2.basename(dir);
1802
+ let alias = path.basename(dir);
2206
1803
  try {
2207
- const config = JSON.parse(await readFile(path2.join(dir, ".crunes", "config.json"), "utf8"));
1804
+ const config = JSON.parse(await readFile(path.join(dir, ".crunes", "config.json"), "utf8"));
2208
1805
  if (typeof config.name === "string" && config.name.length > 0) alias = config.name;
2209
1806
  } catch {
2210
1807
  }
2211
- const id = `${path2.basename(dir).slice(0, 15)}-${shortHash(dir + "-" + Math.random())}`;
1808
+ const id = `${path.basename(dir).slice(0, 15)}-${shortHash(dir + "-" + Math.random())}`;
2212
1809
  const identity = { id, alias };
2213
- await mkdir(path2.join(dir, ".crunes"), { recursive: true });
1810
+ await mkdir(path.join(dir, ".crunes"), { recursive: true });
2214
1811
  await writeFile(localJsonPath, JSON.stringify(identity, null, 2), "utf8");
2215
1812
  return identity;
2216
1813
  }
@@ -2224,9 +1821,9 @@ async function loadProjects() {
2224
1821
  }
2225
1822
  async function upsertProject(id, projectDir) {
2226
1823
  const data = await loadProjects();
2227
- let alias = path2.basename(projectDir);
1824
+ let alias = path.basename(projectDir);
2228
1825
  try {
2229
- const raw = await readFile(path2.join(projectDir, ".crunes", "project.local.json"), "utf8");
1826
+ const raw = await readFile(path.join(projectDir, ".crunes", "project.local.json"), "utf8");
2230
1827
  const parsed = JSON.parse(raw);
2231
1828
  if (typeof parsed.alias === "string" && parsed.alias.length > 0) alias = parsed.alias;
2232
1829
  } catch {
@@ -2244,6 +1841,9 @@ async function upsertProject(id, projectDir) {
2244
1841
  }
2245
1842
 
2246
1843
  // src/rune/api/utils.js
1844
+ init_require_shim();
1845
+ import os from "node:os";
1846
+ import path2 from "node:path";
2247
1847
  var VIRTUAL_STORE_PREFIXES = [
2248
1848
  "@global-plugin-cache",
2249
1849
  "@global-plugin-sqlite",
@@ -2257,7 +1857,7 @@ function parseVirtualStore(location) {
2257
1857
  if (location === prefix) return { prefix, subpath: "" };
2258
1858
  if (location.startsWith(prefix + "/")) {
2259
1859
  const raw = location.slice(prefix.length + 1);
2260
- const normalized = path3.normalize(raw).replace(/\\/g, "/");
1860
+ const normalized = path2.normalize(raw).replace(/\\/g, "/");
2261
1861
  if (normalized.startsWith("..")) throw new RangeError(`subpath escapes virtual root: ${location}`);
2262
1862
  return { prefix, subpath: normalized };
2263
1863
  }
@@ -2273,35 +1873,35 @@ function virtualStoreBase(prefix, { dir, pluginId }) {
2273
1873
  if (!pluginId) throw new Error("@global-plugin-sqlite requires a plugin context");
2274
1874
  return getSqlitePluginDir(pluginId);
2275
1875
  case "@local-cache":
2276
- return path3.join(getLocalBase(dir), "caches", "project");
1876
+ return path2.join(getLocalBase(dir), "caches", "project");
2277
1877
  case "@local-plugin-cache":
2278
1878
  if (!pluginId) throw new Error("@local-plugin-cache requires a plugin context");
2279
- return path3.join(getLocalBase(dir), "caches", "plugins", pluginId);
1879
+ return path2.join(getLocalBase(dir), "caches", "plugins", pluginId);
2280
1880
  case "@local-sqlite":
2281
- return path3.join(getLocalBase(dir), "sqlite", "project");
1881
+ return path2.join(getLocalBase(dir), "sqlite", "project");
2282
1882
  case "@local-plugin-sqlite":
2283
1883
  if (!pluginId) throw new Error("@local-plugin-sqlite requires a plugin context");
2284
- return path3.join(getLocalBase(dir), "sqlite", "plugins", pluginId);
1884
+ return path2.join(getLocalBase(dir), "sqlite", "plugins", pluginId);
2285
1885
  }
2286
1886
  }
2287
1887
  function resolvePath(location, { dir, pluginDir = null, pluginId = null, storeDir = null } = {}) {
2288
1888
  if (location.startsWith("@plugin/")) {
2289
1889
  if (!pluginDir) throw new Error("@plugin/ paths are only available in plugin runes");
2290
- return path3.join(pluginDir, location.slice("@plugin/".length));
1890
+ return path2.join(pluginDir, location.slice("@plugin/".length));
2291
1891
  }
2292
1892
  if (location.startsWith("@project/")) {
2293
- return path3.join(dir, location.slice("@project/".length));
1893
+ return path2.join(dir, location.slice("@project/".length));
2294
1894
  }
2295
1895
  const virtual = parseVirtualStore(location);
2296
1896
  if (virtual) {
2297
1897
  const base = virtualStoreBase(virtual.prefix, { dir, pluginId });
2298
- return virtual.subpath ? path3.join(base, virtual.subpath) : base;
1898
+ return virtual.subpath ? path2.join(base, virtual.subpath) : base;
2299
1899
  }
2300
1900
  if (location === "~" || location.startsWith("~/") || location.startsWith("~\\")) {
2301
- return path3.join(os.homedir(), location.slice(1));
1901
+ return path2.join(os.homedir(), location.slice(1));
2302
1902
  }
2303
- if (path3.isAbsolute(location)) return location;
2304
- return path3.resolve(dir, location);
1903
+ if (path2.isAbsolute(location)) return location;
1904
+ return path2.resolve(dir, location);
2305
1905
  }
2306
1906
  function getAutoPermits({ pluginId = null, pluginDir = null } = {}) {
2307
1907
  const permits = [];
@@ -2332,6 +1932,10 @@ function getAutoPermits({ pluginId = null, pluginDir = null } = {}) {
2332
1932
  return permits;
2333
1933
  }
2334
1934
 
1935
+ // src/rune/permissions/permissions.js
1936
+ init_require_shim();
1937
+ import os2 from "node:os";
1938
+
2335
1939
  // src/rune/permissions/permissions-http.js
2336
1940
  init_require_shim();
2337
1941
  function matchFetchPermission(value, patterns) {
@@ -2571,6 +2175,7 @@ function normalizeFsPath(raw) {
2571
2175
  return !v.startsWith("./") && !v.startsWith("../") && !v.startsWith("@") && !v.startsWith("~/") && !isAbsolute ? `./${v}` : v;
2572
2176
  }
2573
2177
  function normalizePattern(perm) {
2178
+ if (perm === "*" || perm === "*:*") return "*";
2574
2179
  if (perm.startsWith("fs.glob:")) {
2575
2180
  const rest = perm.slice("fs.glob:".length);
2576
2181
  const dColonIdx = rest.indexOf("::");
@@ -2613,6 +2218,8 @@ function computeEffectivePermissions(pluginPerms, projectPerms, lifecycle) {
2613
2218
  };
2614
2219
  }
2615
2220
  function makePermissionChecker(effective, ctx = null) {
2221
+ const hasWildcardAllow = (effective.allow ?? []).some((p) => p === "*" || p === "*:*");
2222
+ const hasWildcardDeny = (effective.deny ?? []).some((p) => p === "*" || p === "*:*");
2616
2223
  const buckets = /* @__PURE__ */ new Map();
2617
2224
  const getBucket = (cap) => {
2618
2225
  if (!buckets.has(cap)) buckets.set(cap, { allow: [], deny: [] });
@@ -2624,6 +2231,7 @@ function makePermissionChecker(effective, ctx = null) {
2624
2231
  };
2625
2232
  const globBucket = { allow: [], deny: [] };
2626
2233
  for (const p of effective.allow.map(normalizePattern)) {
2234
+ if (p === "*") continue;
2627
2235
  if (p.startsWith("fs.glob:")) {
2628
2236
  globBucket.allow.push(p.slice("fs.glob:".length));
2629
2237
  continue;
@@ -2631,6 +2239,7 @@ function makePermissionChecker(effective, ctx = null) {
2631
2239
  for (const expanded of expandPattern(p, ctx)) getBucket(capOf(expanded)).allow.push(expanded);
2632
2240
  }
2633
2241
  for (const p of effective.deny.map(normalizePattern)) {
2242
+ if (p === "*") continue;
2634
2243
  if (p.startsWith("fs.glob:")) {
2635
2244
  globBucket.deny.push(p.slice("fs.glob:".length));
2636
2245
  continue;
@@ -2646,8 +2255,8 @@ function makePermissionChecker(effective, ctx = null) {
2646
2255
  };
2647
2256
  const checkBatchAndThrow = (capability, value, matchFn) => {
2648
2257
  const b = buckets.get(capability) ?? { allow: [], deny: [] };
2649
- const allowed = b.allow.length > 0 && matchFn(pvs(b.allow, capability));
2650
- const denied = b.deny.length > 0 && matchFn(pvs(b.deny, capability));
2258
+ const allowed = hasWildcardAllow || b.allow.length > 0 && matchFn(pvs(b.allow, capability));
2259
+ const denied = hasWildcardDeny || b.deny.length > 0 && matchFn(pvs(b.deny, capability));
2651
2260
  if (!allowed || denied) throw new PermissionError(capability, value);
2652
2261
  };
2653
2262
  const absDir = ctx?.dir?.replace(/\\/g, "/") ?? "";
@@ -2664,8 +2273,8 @@ function makePermissionChecker(effective, ctx = null) {
2664
2273
  }
2665
2274
  case "fs.glob": {
2666
2275
  const resolvedCwd = (absCwd ?? absDir).replace(/\\/g, "/");
2667
- const allowed = globBucket.allow.length > 0 && matchGlobPermission(value, resolvedCwd, globBucket.allow, globCtx);
2668
- const denied = globBucket.deny.length > 0 && matchGlobPermission(value, resolvedCwd, globBucket.deny, globCtx);
2276
+ const allowed = hasWildcardAllow || globBucket.allow.length > 0 && matchGlobPermission(value, resolvedCwd, globBucket.allow, globCtx);
2277
+ const denied = hasWildcardDeny || globBucket.deny.length > 0 && matchGlobPermission(value, resolvedCwd, globBucket.deny, globCtx);
2669
2278
  if (!allowed || denied) throw new PermissionError(capability, value);
2670
2279
  return;
2671
2280
  }
@@ -2689,7 +2298,9 @@ function makePermissionChecker(effective, ctx = null) {
2689
2298
  case "shell.job.write":
2690
2299
  case "notify.send": {
2691
2300
  const b = buckets.get(capability);
2692
- if (!b?.allow.length || b.deny.length > 0) throw new PermissionError(capability, "");
2301
+ const allowed = hasWildcardAllow || b?.allow.length > 0;
2302
+ const denied = hasWildcardDeny || b?.deny.length > 0;
2303
+ if (!allowed || denied) throw new PermissionError(capability, "");
2693
2304
  return;
2694
2305
  }
2695
2306
  case "http.fetch":
@@ -2722,66 +2333,22 @@ function makePermissionChecker(effective, ctx = null) {
2722
2333
  return;
2723
2334
  }
2724
2335
  default:
2336
+ if (hasWildcardAllow && !hasWildcardDeny) return;
2725
2337
  throw new PermissionError(capability, value ?? "");
2726
2338
  }
2727
2339
  };
2728
2340
  }
2729
2341
 
2730
- // src/rune/permissions/shell-check.js
2731
- init_require_shim();
2732
- var BUILTIN_ALLOWLIST = /* @__PURE__ */ new Set([
2733
- "cd",
2734
- "echo",
2735
- "printf",
2736
- "test",
2737
- "[",
2738
- "pwd",
2739
- "true",
2740
- "false",
2741
- "export",
2742
- "set",
2743
- "unset",
2744
- "shift",
2745
- "read",
2746
- ":"
2747
- ]);
2748
- function checkShellCommand(cmd, shellKind, checkPermission) {
2749
- if (!checkPermission) return;
2750
- let scanned;
2751
- try {
2752
- scanned = scanCommand(cmd, shellKind);
2753
- } catch (e) {
2754
- if (e instanceof ScanRefusal) {
2755
- throw new PermissionError("shell.run", cmd, "unscannable", {
2756
- construct: e.construct,
2757
- offset: e.offset
2758
- });
2759
- }
2760
- throw e;
2761
- }
2762
- for (const command of scanned.commands) {
2763
- if (BUILTIN_ALLOWLIST.has(command.program)) continue;
2764
- checkPermission("shell.run", command.segment);
2765
- }
2766
- for (const redirect of scanned.redirects) {
2767
- checkPermission(redirect.mode === "write" ? "fs.write" : "fs.read", redirect.target);
2768
- }
2769
- }
2770
-
2771
2342
  export {
2772
2343
  require_picomatch2 as require_picomatch,
2344
+ isGlobMatch,
2345
+ isWildcardMatch,
2773
2346
  ensureProjectIdentity,
2774
2347
  upsertProject,
2775
2348
  resolvePath,
2776
2349
  getAutoPermits,
2777
- resolveShell,
2778
- ScanRefusal,
2779
- scanCommand,
2780
- isGlobMatch,
2781
- isWildcardMatch,
2782
2350
  parseEnvPattern,
2351
+ PermissionError,
2783
2352
  computeEffectivePermissions,
2784
- makePermissionChecker,
2785
- BUILTIN_ALLOWLIST,
2786
- checkShellCommand
2353
+ makePermissionChecker
2787
2354
  };