@noppu-labs/opencode-permission-reviewer 3.4.3 → 3.5.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.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createHash, randomBytes, randomUUID } from "node:crypto";
2
- import { basename, dirname, isAbsolute, join, normalize, resolve, sep } from "node:path";
3
- import { lstat, mkdir, mkdtemp, open, readlink, realpath, rm, stat, writeFile } from "node:fs/promises";
2
+ import { basename as basename$1, dirname, isAbsolute, join, normalize, resolve, sep } from "node:path";
3
+ import { lstat, mkdir, mkdtemp, open as open$2, readlink, realpath, rm, stat, writeFile } from "node:fs/promises";
4
4
  import { execFile } from "node:child_process";
5
5
  import { promisify } from "node:util";
6
6
  import { closeSync, constants, fchmodSync, fstatSync, openSync, readSync, realpathSync, rmSync, writeSync } from "node:fs";
@@ -13,14 +13,14 @@ import { Buffer as Buffer$1 } from "node:buffer";
13
13
  import { OpenCode } from "@opencode/client";
14
14
  // \0rolldown/runtime.js
15
15
  var __defProp = Object.defineProperty;
16
- var __exportAll = (all, no_symbols) => {
17
- let target = {};
16
+ var __exportAll = (all, flags) => {
17
+ let target = Object.setPrototypeOf({}, null);
18
18
  for (var name in all) __defProp(target, name, {
19
19
  get: all[name],
20
20
  enumerable: true
21
21
  });
22
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
23
- return target;
22
+ if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
23
+ return flags & 2 ? target : Object.preventExtensions(target);
24
24
  };
25
25
  // src/utils/is-record.ts
26
26
  /** A non-null object that is not an array. */
@@ -108,7 +108,7 @@ function invariant(condition, message) {
108
108
  if (!condition) throw new Error(message);
109
109
  }
110
110
  // package.json
111
- var version = "3.4.3";
111
+ var version = "3.5.0";
112
112
  // src/utils/redact.ts
113
113
  const REDACT = (type) => `[REDACTED:${type}]`;
114
114
  const OPENCODE_SESSION_KEY = /^(?:session[_-]?id|session|sid)$/i;
@@ -917,6 +917,9 @@ const OPENROUTER_DECISION_MODELS = {
917
917
  "cloudflare/clef": { benchmarked: false },
918
918
  "cloudflare/clef-flash": { benchmarked: false },
919
919
  "cloudflare/clef-omni": { benchmarked: false },
920
+ "google/gemini-decision-1": { benchmarked: false },
921
+ "heygen/heygen-decision-1": { benchmarked: false },
922
+ "heygen/heygen-decision-1-turbo": { benchmarked: false },
920
923
  "jaredpalmer/kev-4b": { benchmarked: false },
921
924
  "liquid/d1": { benchmarked: true },
922
925
  "liquid/d1-ultra": { benchmarked: true },
@@ -924,12 +927,15 @@ const OPENROUTER_DECISION_MODELS = {
924
927
  "microsoft/microsoft-decision-1": { benchmarked: false },
925
928
  "morph/reflex": { benchmarked: false },
926
929
  "nace-ai/drex-max": { benchmarked: false },
930
+ "nace-ai/drex-max-finance": { benchmarked: false },
927
931
  "nace-ai/drex-v1.5": { benchmarked: false },
928
932
  "nace-ai/drex-v2.0": { benchmarked: false },
929
933
  "openai/gpt-6-luna-decisions": { benchmarked: false },
930
- "parallel/decisions-fast:free": { benchmarked: false },
934
+ "parallel/decisions-fast": { benchmarked: false },
931
935
  "perplexity/pplx-decider-flash-v1.2": { benchmarked: false },
936
+ "perplexity/pplx-decider-flash-v1.3:free": { benchmarked: false },
932
937
  "perplexity/pplx-decider-v1.2": { benchmarked: false },
938
+ "perplexity/pplx-decider-v1.3:free": { benchmarked: false },
933
939
  "respan/span-02": { benchmarked: false },
934
940
  "togethercomputer/tev1-4b-experimental": { benchmarked: false },
935
941
  "typesafe/jev-1.13": { benchmarked: true },
@@ -1627,12 +1633,127 @@ function splitTokens(tokens, split) {
1627
1633
  tokenIndex += 1;
1628
1634
  }
1629
1635
  }
1636
+ // src/modules/analysis/capability/heredoc/ansi-c-numeric.ts
1637
+ const HEX_DIGITS = /* @__PURE__ */ new Map([
1638
+ ["x", /[0-9a-f]{1,2}/iy],
1639
+ ["u", /[0-9a-f]{1,4}/iy],
1640
+ ["U", /[0-9a-f]{1,8}/iy]
1641
+ ]);
1642
+ const OCTAL_DIGITS = /[0-7]{1,3}/y;
1643
+ /** The octal escape at `index`, whose first digit is at `index + 1`. */
1644
+ function decodeAnsiCOctal(inner, index) {
1645
+ const digits = digitsAt(inner, index + 1, OCTAL_DIGITS);
1646
+ return {
1647
+ text: String.fromCharCode(Number.parseInt(digits, 8) & 255),
1648
+ end: index + 1 + digits.length
1649
+ };
1650
+ }
1651
+ /** The `\x`, `\u` or `\U` escape at `index`; undefined for another letter or
1652
+ * without a hex digit. */
1653
+ function decodeAnsiCHex(inner, index, letter) {
1654
+ const pattern = HEX_DIGITS.get(letter);
1655
+ if (pattern === void 0) return void 0;
1656
+ const digits = digitsAt(inner, index + 2, pattern);
1657
+ if (digits === "") return void 0;
1658
+ const end = index + 2 + digits.length;
1659
+ const value = Number.parseInt(digits, 16);
1660
+ if (letter === "x") return {
1661
+ text: String.fromCharCode(value),
1662
+ end
1663
+ };
1664
+ return {
1665
+ text: codePointText(value),
1666
+ end
1667
+ };
1668
+ }
1669
+ /** The text bash gives a `\u` or `\U` code point. Values above 0x7fffffff
1670
+ * are dropped; surrogates and values past U+10FFFF are not JavaScript code
1671
+ * points and become U+FFFD. */
1672
+ function codePointText(value) {
1673
+ if (value > 2147483647) return "";
1674
+ if (value >= 55296 && value <= 57343 || value > 1114111) return "�";
1675
+ return String.fromCodePoint(value);
1676
+ }
1677
+ /** `\cX` is the control character of X. In bash 4.4 and later `\c?` is DEL and
1678
+ * `\c\\` takes both backslashes; bash 3.2 reads each like any other X. */
1679
+ function decodeAnsiCControl(inner, index, dialect) {
1680
+ const target = inner.charAt(index + 2);
1681
+ if (target === "") return {
1682
+ text: "\\c",
1683
+ end: index + 2
1684
+ };
1685
+ const modern = dialect === "bash";
1686
+ if (target === "\\" && modern) return {
1687
+ text: "",
1688
+ end: inner.charAt(index + 3) === "\\" ? index + 4 : index + 3
1689
+ };
1690
+ const code = target === "?" && modern ? 127 : target.charCodeAt(0) & 31;
1691
+ return {
1692
+ text: String.fromCharCode(code),
1693
+ end: index + 3
1694
+ };
1695
+ }
1696
+ /** The digits matched by the sticky `pattern` at `start`. */
1697
+ function digitsAt(text, start, pattern) {
1698
+ pattern.lastIndex = start;
1699
+ return pattern.exec(text)?.[0] ?? "";
1700
+ }
1701
+ // src/modules/analysis/capability/heredoc/ansi-c-zsh.ts
1702
+ /** `\C` clears bits 5 and 6 (`?` becomes DEL); `\M` sets bit 7. */
1703
+ const MODIFIERS = {
1704
+ C: (code) => code === 63 ? 127 : code & 159,
1705
+ M: (code) => code | 128
1706
+ };
1707
+ /** An escape zsh reads without a backslash: `\x`, `\u` and `\U` without a
1708
+ * hex digit are NUL, a run of `\C[-]` and `\M[-]` modifies the first
1709
+ * character of the escape or character after it (innermost first, nothing
1710
+ * at the end of the text), and anything else (`\cX` included) is the
1711
+ * character itself. `decodeEscape` decodes the escape at an index. */
1712
+ function decodeZshOther(inner, index, escaped, decodeEscape) {
1713
+ if (/^[xuU]$/.test(escaped)) return {
1714
+ text: "\0",
1715
+ end: index + 2
1716
+ };
1717
+ if (MODIFIERS[escaped] === void 0) return {
1718
+ text: escaped,
1719
+ end: index + 2
1720
+ };
1721
+ const modifiers = [];
1722
+ let position = index;
1723
+ let modify = MODIFIERS[inner.charAt(position + 1)];
1724
+ while (inner.charAt(position) === "\\" && modify !== void 0) {
1725
+ modifiers.push(modify);
1726
+ position += inner.charAt(position + 2) === "-" ? 3 : 2;
1727
+ modify = MODIFIERS[inner.charAt(position + 1)];
1728
+ }
1729
+ const operand = operandAt(inner, position, decodeEscape);
1730
+ if (operand.text === "") return operand;
1731
+ let code = operand.text.charCodeAt(0);
1732
+ for (const apply of modifiers.reverse()) code = apply(code);
1733
+ return {
1734
+ text: String.fromCharCode(code) + operand.text.slice(1),
1735
+ end: operand.end
1736
+ };
1737
+ }
1738
+ /** The escape or character a modifier run applies to. */
1739
+ function operandAt(inner, position, decodeEscape) {
1740
+ if (position >= inner.length) return {
1741
+ text: "",
1742
+ end: position
1743
+ };
1744
+ if (inner.charAt(position) === "\\" && position + 1 < inner.length) return decodeEscape(inner, position);
1745
+ return {
1746
+ text: inner.charAt(position),
1747
+ end: position + 1
1748
+ };
1749
+ }
1630
1750
  // src/modules/analysis/capability/heredoc/ansi-c-quoting.ts
1631
- /** Unescape an ANSI-C quoted region (`$'...'`), the subset bash defines for
1632
- * here-document delimiter words: standard escapes, `\xHH` hex, and up to
1633
- * three octal digits. Unknown escapes drop the backslash, like bash. A
1634
- * delimiter containing a newline can never match a body line; it stays
1635
- * resolved and the body scan reports the heredoc as unterminated. */
1751
+ /** Unescape the `$'...'` region of a here-document delimiter word. Unknown
1752
+ * escapes drop the backslash as zsh does, so the text is right for every
1753
+ * shell only when `ansiCShellDependent` accepts the part; `scanDollarQuoted`
1754
+ * marks the word unresolved otherwise. A delimiter containing a newline can
1755
+ * never match a body line; it stays resolved and the body scan reports the
1756
+ * heredoc as unterminated. */
1636
1757
  function unescapeAnsiC(command, start) {
1637
1758
  let text = "";
1638
1759
  let index = start;
@@ -1702,10 +1823,37 @@ function ansiCEscape(command, index, escaped) {
1702
1823
  end: index + 2
1703
1824
  };
1704
1825
  }
1705
- /** The value bash gives a `$'...'` word whose text between the quotes is
1706
- * `inner`, as written: escapes decoded, cut at the first NUL. Unknown
1707
- * escapes and a bare `\x`, `\u` or `\U` keep their backslash. */
1708
- function decodeAnsiCWord(inner) {
1826
+ /** Whether an escape in `inner` (the text between `$'` and the closing `'`, as
1827
+ * written) is read differently by bash, bash 3.2 and zsh: anything but a
1828
+ * simple escape, an octal escape, or `\x` with a hex digit. `\c`, `\u` and
1829
+ * `\U` always count, and so does a NUL with text after it, where bash ends
1830
+ * the word and zsh keeps the rest. A NUL that ends the word gives the same
1831
+ * argument in both; a heredoc delimiter checks for one itself. */
1832
+ function ansiCShellDependent(inner) {
1833
+ let index = 0;
1834
+ while (index < inner.length) {
1835
+ if (inner.charAt(index) !== "\\") {
1836
+ index += 1;
1837
+ continue;
1838
+ }
1839
+ const bash = decodeAnsiCEscape(inner, index, "bash");
1840
+ if (textAfterNul(bash.text, inner.slice(bash.end)) || bash.text !== decodeAnsiCEscape(inner, index, "zsh").text || bash.text !== decodeAnsiCEscape(inner, index, "bash32").text) return true;
1841
+ index = bash.end;
1842
+ }
1843
+ return false;
1844
+ }
1845
+ /** Whether an escape's `text` has a NUL with more text after it, in the
1846
+ * escape or in the `rest` of the word. */
1847
+ function textAfterNul(text, rest) {
1848
+ const nul = text.indexOf("\0");
1849
+ return nul !== -1 && (nul < text.length - 1 || rest !== "");
1850
+ }
1851
+ /** The value a `$'...'` word whose text between the quotes is `inner`, as
1852
+ * written, has in `dialect` as a command's argument: escapes decoded, cut
1853
+ * at the first NUL. In bash, unknown escapes and a bare `\x`, `\u` or `\U`
1854
+ * keep their backslash, and bash 3.2 also keeps it for every `\u` and
1855
+ * `\U`. */
1856
+ function decodeAnsiCWord(inner, dialect = "bash") {
1709
1857
  let value = "";
1710
1858
  let index = 0;
1711
1859
  while (index < inner.length) {
@@ -1714,101 +1862,51 @@ function decodeAnsiCWord(inner) {
1714
1862
  index += 1;
1715
1863
  continue;
1716
1864
  }
1717
- const decoded = decodeAnsiCEscape(inner, index);
1865
+ const decoded = decodeAnsiCEscape(inner, index, dialect);
1718
1866
  value += decoded.text;
1719
1867
  index = decoded.end;
1720
1868
  }
1721
- const nul = value.indexOf("\0");
1722
- return nul === -1 ? value : value.slice(0, nul);
1869
+ return value.split("\0", 1).join("");
1723
1870
  }
1724
- const HEX_DIGITS = /* @__PURE__ */ new Map([
1725
- ["x", /[0-9a-f]{1,2}/iy],
1726
- ["u", /[0-9a-f]{1,4}/iy],
1727
- ["U", /[0-9a-f]{1,8}/iy]
1728
- ]);
1729
- const OCTAL_DIGITS = /[0-7]{1,3}/y;
1730
1871
  /** The decoded escape whose backslash is at `index`, and the index just past it. */
1731
- function decodeAnsiCEscape(inner, index) {
1872
+ function decodeAnsiCEscape(inner, index, dialect) {
1732
1873
  const escaped = inner.charAt(index + 1);
1733
1874
  const simple = ANSI_C_SIMPLE_ESCAPES[escaped];
1734
1875
  if (simple !== void 0) return {
1735
1876
  text: simple,
1736
1877
  end: index + 2
1737
1878
  };
1738
- if (/^[0-7]$/.test(escaped)) {
1739
- const digits = digitsAt(inner, index + 1, OCTAL_DIGITS);
1740
- const value = Number.parseInt(digits, 8) & 255;
1741
- return {
1742
- text: String.fromCharCode(value),
1743
- end: index + 1 + digits.length
1744
- };
1745
- }
1746
- if (escaped === "c") return decodeAnsiCControl(inner, index);
1747
- const hex = HEX_DIGITS.get(escaped);
1748
- if (hex !== void 0) return decodeAnsiCHex(inner, index, escaped, hex);
1879
+ if (/^[0-7]$/.test(escaped)) return decodeAnsiCOctal(inner, index);
1880
+ if (escaped === "c" && dialect !== "zsh") return decodeAnsiCControl(inner, index, dialect);
1881
+ const decoded = (dialect !== "bash32" || escaped === "x") && decodeAnsiCHex(inner, index, escaped);
1882
+ if (decoded) return decoded;
1883
+ if (dialect === "zsh") return decodeZshOther(inner, index, escaped, (text, at) => decodeAnsiCEscape(text, at, "zsh"));
1749
1884
  return {
1750
1885
  text: `\\${escaped}`,
1751
1886
  end: index + 2
1752
1887
  };
1753
1888
  }
1754
- function decodeAnsiCHex(inner, index, letter, pattern) {
1755
- const digits = digitsAt(inner, index + 2, pattern);
1756
- if (digits === "") return {
1757
- text: `\\${letter}`,
1758
- end: index + 2
1759
- };
1760
- const end = index + 2 + digits.length;
1761
- const value = Number.parseInt(digits, 16);
1762
- if (letter === "x") return {
1763
- text: String.fromCharCode(value),
1764
- end
1765
- };
1766
- return {
1767
- text: codePointText(value),
1768
- end
1769
- };
1770
- }
1771
- /** The text bash gives a `\u` or `\U` code point. Values above 0x7fffffff
1772
- * are dropped; surrogates and values past U+10FFFF are not JavaScript code
1773
- * points and become U+FFFD. */
1774
- function codePointText(value) {
1775
- if (value > 2147483647) return "";
1776
- if (value >= 55296 && value <= 57343 || value > 1114111) return "�";
1777
- return String.fromCodePoint(value);
1778
- }
1779
- /** `\cX` is the control character of X, `\c?` is DEL, and `\c\\` is the
1780
- * control character of a backslash. */
1781
- function decodeAnsiCControl(inner, index) {
1782
- const target = inner.charAt(index + 2);
1783
- if (target === "") return {
1784
- text: "\\c",
1785
- end: index + 2
1786
- };
1787
- if (target === "\\") return {
1788
- text: "",
1789
- end: inner.charAt(index + 3) === "\\" ? index + 4 : index + 3
1790
- };
1791
- const code = target === "?" ? 127 : target.charCodeAt(0) & 31;
1792
- return {
1793
- text: String.fromCharCode(code),
1794
- end: index + 3
1795
- };
1889
+ // src/modules/analysis/shell/shell-lex-state.ts
1890
+ /** Whether the reading is `finder` with only a `$'…'` word's value changed. */
1891
+ function readsAsFinder(quoting = "bash") {
1892
+ return quoting === "finder" || quoting === "zsh" || quoting === "bash32";
1796
1893
  }
1797
- /** The digits matched by the sticky `pattern` at `start`. */
1798
- function digitsAt(text, start, pattern) {
1799
- pattern.lastIndex = start;
1800
- return pattern.exec(text)?.[0] ?? "";
1894
+ /** The dialect a reading decodes a `$'…'` word in. */
1895
+ function ansiCDialectOf(quoting = "bash") {
1896
+ return quoting === "zsh" || quoting === "bash32" ? quoting : "bash";
1801
1897
  }
1802
- // src/modules/analysis/shell/shell-lex-state.ts
1803
- /** Whether the reading decodes quotes the way bash does. */
1898
+ /** Whether the reading has bash's quote structure: `$'…'` strings and the
1899
+ * quote spans that follow from it. The readings that read as `finder` does
1900
+ * differ from `bash` only in how an escape decodes. */
1804
1901
  function readsBashQuotes(quoting = "bash") {
1805
- return quoting === "bash" || quoting === "rescan" || quoting === "finder";
1902
+ return quoting === "bash" || quoting === "rescan" || readsAsFinder(quoting);
1806
1903
  }
1807
- /** The substitution scan a reading uses. Only `bash` and `finder` end a body
1808
- * where the shell does, and their outer scan then jumps past the body; every
1809
- * other reading ends it where the previous release did and walks it again. */
1904
+ /** The substitution scan a reading uses. Only `bash` and the readings that
1905
+ * read as `finder` does end a body where the shell does, and their outer
1906
+ * scan then jumps past the body; every other reading ends it where the
1907
+ * previous release did and walks it again. */
1810
1908
  function substitutionScanOf(quoting = "bash") {
1811
- return quoting === "bash" || quoting === "finder" ? "bash" : "previous";
1909
+ return quoting === "bash" || readsAsFinder(quoting) ? "bash" : "previous";
1812
1910
  }
1813
1911
  /** Ceiling on the substitution text one scan re-lexes by default: nested
1814
1912
  * substitutions re-lex their body once per level. */
@@ -1860,7 +1958,7 @@ function lastValueChar(lex) {
1860
1958
  * joins the value as quoted text. Nothing was collected under the
1861
1959
  * `undecoded` reading, which appends the text as it scans. */
1862
1960
  function closeAnsiC(lex) {
1863
- appendValue(lex, decodeAnsiCWord(lex.ansiCText), true);
1961
+ appendValue(lex, decodeAnsiCWord(lex.ansiCText, ansiCDialectOf(lex.budget.quoting)), true);
1864
1962
  lex.ansiCText = "";
1865
1963
  lex.ansiC = false;
1866
1964
  }
@@ -2273,6 +2371,7 @@ function consumeBodies(scan, bodyStart, lineEnd) {
2273
2371
  const read = readBody(scan.command, position, start, bound);
2274
2372
  position = read.position;
2275
2373
  if (read.unterminated) scan.unterminated = true;
2374
+ noteDelimiter(scan, start);
2276
2375
  const record = bodyRecord(scan.command, start, read, lineEnd, targets);
2277
2376
  if (record.dynamic) scan.hasDynamicConstructs = true;
2278
2377
  keepBody(scan.bodies, start, read, record.sha256);
@@ -2284,6 +2383,10 @@ function consumeBodies(scan, bodyStart, lineEnd) {
2284
2383
  scan.pieces = [];
2285
2384
  return position;
2286
2385
  }
2386
+ function noteDelimiter(scan, start) {
2387
+ if (!start.resolved) scan.delimiterUnresolved = true;
2388
+ if (start.shellDependent) scan.delimiterShellDependent = true;
2389
+ }
2287
2390
  /** Keeps what one read body gives the collector: the commands its
2288
2391
  * substitutions run, when its delimiter is unquoted, and the text the command
2289
2392
  * that reads it gets, when it has its terminator line. */
@@ -2337,8 +2440,10 @@ function scanSingleQuoted(command, scan) {
2337
2440
  scan.index = end + 1;
2338
2441
  return true;
2339
2442
  }
2340
- /** `$'...'` is unescaped here; for `$"..."` only the `$` is consumed, and
2341
- * the double-quoted part follows. */
2443
+ /** `$'...'` is unescaped here. A part with an escape the shells read
2444
+ * differently, or with a NUL (bash ends the delimiter there, zsh keeps it),
2445
+ * leaves the word unresolved and shell-dependent. For `$"..."` only the `$`
2446
+ * is consumed, and the double-quoted part follows. */
2342
2447
  function scanDollarQuoted(command, scan) {
2343
2448
  scan.quoted = true;
2344
2449
  scan.sawAny = true;
@@ -2351,6 +2456,10 @@ function scanDollarQuoted(command, scan) {
2351
2456
  scan.resolved = false;
2352
2457
  return false;
2353
2458
  }
2459
+ if (ansiCShellDependent(command.slice(scan.index + 2, parsed.end - 1)) || parsed.text.includes("\0")) {
2460
+ scan.resolved = false;
2461
+ scan.shellDependent = true;
2462
+ }
2354
2463
  scan.delimiter += parsed.text;
2355
2464
  scan.index = parsed.end;
2356
2465
  return true;
@@ -2422,14 +2531,16 @@ const BARE_WORD_STOP = /* @__PURE__ */ new Set([
2422
2531
  * inside a backtick substitution, which the shell cuts out before it reads
2423
2532
  * the operator's word. A bare carriage return ends the word when
2424
2533
  * `stopAtCarriageReturn` is set, as the previous release read it.
2425
- * The word is `resolved: false` only when its quoting never terminates or
2426
- * the word is empty: then no line can be proven to be the terminator. */
2534
+ * The word is `resolved: false` when its quoting never terminates, the word
2535
+ * is empty, or a `$'...'` part is shell-dependent: then no line can be
2536
+ * proven to be the terminator. */
2427
2537
  function parseDelimiterWord(command, start, options = {}) {
2428
2538
  const scan = {
2429
2539
  index: start,
2430
2540
  delimiter: "",
2431
2541
  quoted: false,
2432
2542
  resolved: true,
2543
+ shellDependent: false,
2433
2544
  sawAny: false
2434
2545
  };
2435
2546
  while (scan.index < command.length) {
@@ -2442,13 +2553,15 @@ function parseDelimiterWord(command, start, options = {}) {
2442
2553
  wordEnd: start,
2443
2554
  delimiter: "",
2444
2555
  quoted: false,
2445
- resolved: false
2556
+ resolved: false,
2557
+ shellDependent: false
2446
2558
  };
2447
2559
  return {
2448
2560
  wordEnd: scan.index,
2449
2561
  delimiter: scan.delimiter,
2450
2562
  quoted: scan.quoted,
2451
- resolved: scan.resolved
2563
+ resolved: scan.resolved,
2564
+ shellDependent: scan.shellDependent
2452
2565
  };
2453
2566
  }
2454
2567
  /** Consume the word part at `scan.index`. Returns false when the word ends
@@ -2858,6 +2971,7 @@ function scanHeredocOperator(scan) {
2858
2971
  rawWord: command.slice(j, word.wordEnd),
2859
2972
  quoted: word.quoted,
2860
2973
  resolved: word.resolved,
2974
+ shellDependent: word.shellDependent,
2861
2975
  opStart: i,
2862
2976
  wordEnd: word.wordEnd,
2863
2977
  lineStart: scan.lineStart,
@@ -2878,6 +2992,8 @@ function legacySanitizedCommand(command) {
2878
2992
  hasDynamicConstructs: false,
2879
2993
  unterminated: false,
2880
2994
  framed: false,
2995
+ delimiterUnresolved: false,
2996
+ delimiterShellDependent: false,
2881
2997
  out: "",
2882
2998
  cursor: 0,
2883
2999
  i: 0,
@@ -2953,6 +3069,8 @@ function extractHeredocs(command, options = {}) {
2953
3069
  hasDynamicConstructs: false,
2954
3070
  unterminated: false,
2955
3071
  framed: false,
3072
+ delimiterUnresolved: false,
3073
+ delimiterShellDependent: false,
2956
3074
  out: "",
2957
3075
  cursor: 0,
2958
3076
  i: 0,
@@ -2975,6 +3093,8 @@ function extractHeredocs(command, options = {}) {
2975
3093
  return {
2976
3094
  unterminated: scan.unterminated,
2977
3095
  framed: scan.framed,
3096
+ delimiterUnresolved: scan.delimiterUnresolved,
3097
+ delimiterShellDependent: scan.delimiterShellDependent,
2978
3098
  sanitizedCommand: scan.out,
2979
3099
  heredocs: scan.heredocs,
2980
3100
  hasDynamicConstructs: scan.hasDynamicConstructs,
@@ -2987,6 +3107,8 @@ function unchanged(command) {
2987
3107
  return {
2988
3108
  unterminated: false,
2989
3109
  framed: false,
3110
+ delimiterUnresolved: false,
3111
+ delimiterShellDependent: false,
2990
3112
  sanitizedCommand: command,
2991
3113
  heredocs: [],
2992
3114
  hasDynamicConstructs: false,
@@ -3026,7 +3148,8 @@ function sanitizedText(text) {
3026
3148
  return {
3027
3149
  text: extraction.sanitizedCommand,
3028
3150
  bodyCommands: extraction.bodyCommands,
3029
- bodyUnresolved: extraction.bodyUnresolved,
3151
+ bodyUnresolved: extraction.bodyUnresolved || extraction.delimiterUnresolved,
3152
+ delimiterShellDependent: extraction.delimiterShellDependent,
3030
3153
  scripts: extraction.scripts
3031
3154
  };
3032
3155
  }
@@ -3377,7 +3500,7 @@ function advance(scan) {
3377
3500
  scan.index += 1;
3378
3501
  return false;
3379
3502
  }
3380
- function open$2(scan, frame, width) {
3503
+ function open$1(scan, frame, width) {
3381
3504
  scan.frames.push(frame);
3382
3505
  scan.starts.push(scan.index);
3383
3506
  scan.prefix = void 0;
@@ -3401,8 +3524,8 @@ function close$1(scan) {
3401
3524
  }
3402
3525
  function stepCommand(scan, c, insideCase) {
3403
3526
  if (c === ")" || c === "(") return stepParenthesis(scan, c, insideCase);
3404
- if (c === "\"") return open$2(scan, "double", 1);
3405
- if (c === "`") return open$2(scan, "backtick", 1);
3527
+ if (c === "\"") return open$1(scan, "double", 1);
3528
+ if (c === "`") return open$1(scan, "backtick", 1);
3406
3529
  if (c === "'" || c === "$" && scan.text[scan.index + 1] === "'") {
3407
3530
  skipSingleQuoted(scan, c === "$");
3408
3531
  return false;
@@ -3427,7 +3550,7 @@ function stepParenthesis(scan, c, insideCase) {
3427
3550
  /** A `(` opens a subshell, unless it is the `()` of a function header. */
3428
3551
  function openParenthesis(scan) {
3429
3552
  const end = scan.mode === "bash" ? functionHeaderEnd(scan) : -1;
3430
- if (end < 0) return open$2(scan, "command", 1);
3553
+ if (end < 0) return open$1(scan, "command", 1);
3431
3554
  scan.index = end;
3432
3555
  scan.headStart = -1;
3433
3556
  scan.commandPosition = true;
@@ -3436,7 +3559,7 @@ function openParenthesis(scan) {
3436
3559
  /** `${` opens an expansion that holds a `)` as text; `$$` is one parameter. */
3437
3560
  function stepDollar$2(scan) {
3438
3561
  const next = scan.text[scan.index + 1];
3439
- if (next === "{") return open$2(scan, "brace", 2);
3562
+ if (next === "{") return open$1(scan, "brace", 2);
3440
3563
  scan.commandPosition = false;
3441
3564
  scan.index += next === "$" ? 2 : 1;
3442
3565
  return false;
@@ -3461,8 +3584,8 @@ function stepBrace$1(scan, c) {
3461
3584
  /** It ends at `closer`; substitutions inside open frames of their own. */
3462
3585
  function stepQuoted$1(scan, c, closer, singleQuotes) {
3463
3586
  if (c === closer) return close$1(scan);
3464
- if (c === "\"") return open$2(scan, "double", 1);
3465
- if (c === "`") return open$2(scan, "backtick", 1);
3587
+ if (c === "\"") return open$1(scan, "double", 1);
3588
+ if (c === "`") return open$1(scan, "backtick", 1);
3466
3589
  if (c === "'" && singleQuotes) return skip(scan, false);
3467
3590
  return c === "$" ? stepDollar$1(scan, singleQuotes) : advance(scan);
3468
3591
  }
@@ -3471,11 +3594,11 @@ function stepQuoted$1(scan, c, closer, singleQuotes) {
3471
3594
  function stepDollar$1(scan, singleQuotes) {
3472
3595
  const next = scan.text[scan.index + 1];
3473
3596
  if (next !== "(") return stepParameter(scan, next, singleQuotes);
3474
- return open$2(scan, scan.mode === "bash" && scan.text[scan.index + 2] === "(" ? "arith" : "command", 2);
3597
+ return open$1(scan, scan.mode === "bash" && scan.text[scan.index + 2] === "(" ? "arith" : "command", 2);
3475
3598
  }
3476
3599
  function stepParameter(scan, next, singleQuotes) {
3477
3600
  if (scan.mode !== "bash") return advance(scan);
3478
- if (next === "{") return open$2(scan, "brace", 2);
3601
+ if (next === "{") return open$1(scan, "brace", 2);
3479
3602
  if (next === "$") scan.index += 1;
3480
3603
  else if (next === "'" && singleQuotes) return skip(scan, true);
3481
3604
  return advance(scan);
@@ -3755,14 +3878,14 @@ function openGroup(scan, c) {
3755
3878
  if (!scan.commandPosition && !dollar && scan.words !== "forName") return void 0;
3756
3879
  if (!dollar && !closesAsArithmetic(text, index, scan.probes)) return void 0;
3757
3880
  const forLoop = scan.words === "forName";
3758
- open$2(scan, "arith", 1);
3759
- open$2(scan, "arith", 1);
3881
+ open$1(scan, "arith", 1);
3882
+ open$1(scan, "arith", 1);
3760
3883
  scan.commandPosition = false;
3761
3884
  if (forLoop) scan.saved[scan.saved.length - 2] = ["forAfterName", void 0];
3762
3885
  return false;
3763
3886
  }
3764
3887
  function openArray(scan) {
3765
- open$2(scan, "array", 1);
3888
+ open$1(scan, "array", 1);
3766
3889
  scan.commandPosition = false;
3767
3890
  return false;
3768
3891
  }
@@ -3770,7 +3893,7 @@ function openTest(scan) {
3770
3893
  const { text, index } = scan;
3771
3894
  if (!scan.commandPosition || !text.startsWith("[[", index)) return void 0;
3772
3895
  if (!/\s/.test(text.charAt(index + 2))) return void 0;
3773
- open$2(scan, "test", 2);
3896
+ open$1(scan, "test", 2);
3774
3897
  scan.commandPosition = false;
3775
3898
  return false;
3776
3899
  }
@@ -3784,7 +3907,7 @@ function stepArith(scan, c) {
3784
3907
  const group = c === "(" ? openGroup(scan, c) : void 0;
3785
3908
  if (group !== void 0) return group;
3786
3909
  if (c === "(" && scan.text[scan.index - 1] !== "$") {
3787
- open$2(scan, "arith", 1);
3910
+ open$1(scan, "arith", 1);
3788
3911
  scan.commandPosition = false;
3789
3912
  return false;
3790
3913
  }
@@ -3857,12 +3980,12 @@ function substitutionBodyEnd(text, start, opener, reading = "default", mode = "b
3857
3980
  escapedEnd: -1,
3858
3981
  probes
3859
3982
  };
3860
- while (scan.index < text.length) if (step$1(scan)) return scan.index;
3983
+ while (scan.index < text.length) if (step$2(scan)) return scan.index;
3861
3984
  return text.length;
3862
3985
  }
3863
3986
  /** Advance past one character or construct; true once the opener's frame
3864
3987
  * closes at `scan.index`. */
3865
- function step$1(scan) {
3988
+ function step$2(scan) {
3866
3989
  const c = scan.text.charAt(scan.index);
3867
3990
  if (c === "\\") {
3868
3991
  const joins = scan.mode === "bash" && scan.text[scan.index + 1] === "\n";
@@ -3934,6 +4057,7 @@ function commandBody(text, end, reading, sanitize) {
3934
4057
  text: sanitize ? legacySanitizedCommand(text) : text,
3935
4058
  bodyCommands: [],
3936
4059
  bodyUnresolved: false,
4060
+ delimiterShellDependent: false,
3937
4061
  scripts: NO_SCRIPTS,
3938
4062
  end
3939
4063
  };
@@ -3943,6 +4067,7 @@ function commandBody(text, end, reading, sanitize) {
3943
4067
  text: read.text,
3944
4068
  bodyCommands: read.bodyCommands,
3945
4069
  bodyUnresolved: read.bodyUnresolved,
4070
+ delimiterShellDependent: read.delimiterShellDependent,
3946
4071
  scripts: read.scripts,
3947
4072
  end
3948
4073
  };
@@ -4033,10 +4158,10 @@ function stepFrame(scan, index) {
4033
4158
  * every other character plain. */
4034
4159
  function stepCount(scan, index) {
4035
4160
  const c = scan.text.charAt(index);
4036
- if (c === "(") return open$1(scan, "count", index + 1);
4161
+ if (c === "(") return open(scan, "count", index + 1);
4037
4162
  if (c === ")") return close(scan, index);
4038
4163
  if (c === "\\") return index + 2;
4039
- if (c === "\"") return open$1(scan, "double", index + 1);
4164
+ if (c === "\"") return open(scan, "double", index + 1);
4040
4165
  if (c !== "'") return index + 1;
4041
4166
  const end = scan.text.indexOf("'", index + 1);
4042
4167
  return end < 0 ? -1 : end + 1;
@@ -4054,7 +4179,7 @@ function stepParen(scan, index) {
4054
4179
  return index + 1;
4055
4180
  }
4056
4181
  if (c === "\\" || c === "") return index + 2;
4057
- if (c === "(" || c === "$" && text.charAt(index + 1) === "(") return open$1(scan, "paren", index + (c === "(" ? 1 : 2));
4182
+ if (c === "(" || c === "$" && text.charAt(index + 1) === "(") return open(scan, "paren", index + (c === "(" ? 1 : 2));
4058
4183
  if (c === ")") return close(scan, index);
4059
4184
  return stepQuoted(scan, index);
4060
4185
  }
@@ -4075,7 +4200,7 @@ function stepBrace(scan, index) {
4075
4200
  function stepQuoted(scan, index) {
4076
4201
  const c = scan.text.charAt(index);
4077
4202
  if (c === "`") return pastBacktick(scan.text, index);
4078
- if (c === "\"") return open$1(scan, "double", index + 1);
4203
+ if (c === "\"") return open(scan, "double", index + 1);
4079
4204
  if (c !== "'") return stepDollar(scan, index);
4080
4205
  const end = scan.text.indexOf("'", index + 1);
4081
4206
  return end < 0 ? -1 : end + 1;
@@ -4085,11 +4210,11 @@ function stepQuoted(scan, index) {
4085
4210
  function stepDollar(scan, index) {
4086
4211
  const next = scan.text.charAt(index + 1);
4087
4212
  if (scan.text.charAt(index) !== "$") return index + 1;
4088
- if (next === "(") return open$1(scan, "paren", index + 2);
4089
- if (next === "{" && scan.frames.at(-1) !== "paren") return open$1(scan, "brace", index + 2);
4213
+ if (next === "(") return open(scan, "paren", index + 2);
4214
+ if (next === "{" && scan.frames.at(-1) !== "paren") return open(scan, "brace", index + 2);
4090
4215
  return index + 1;
4091
4216
  }
4092
- function open$1(scan, frame, after) {
4217
+ function open(scan, frame, after) {
4093
4218
  scan.frames.push(frame);
4094
4219
  scan.starts.push(after);
4095
4220
  return after;
@@ -4317,7 +4442,7 @@ function scanBody(text) {
4317
4442
  ends: /* @__PURE__ */ new Map()
4318
4443
  };
4319
4444
  let index = 0;
4320
- while (index < text.length && !scan.unresolved) index = step(scan, index);
4445
+ while (index < text.length && !scan.unresolved) index = step$1(scan, index);
4321
4446
  if (scan.unresolved) return {
4322
4447
  commands: scan.commands,
4323
4448
  unresolved: true
@@ -4334,7 +4459,7 @@ function scanBody(text) {
4334
4459
  };
4335
4460
  }
4336
4461
  /** The index after the character or construct at `index`. */
4337
- function step(scan, index) {
4462
+ function step$1(scan, index) {
4338
4463
  const after = bodyTextStep(scan.text, index);
4339
4464
  return after < 0 ? substitute(scan, index) : after;
4340
4465
  }
@@ -4369,12 +4494,14 @@ function keepCommand(scan, found, backtick) {
4369
4494
  scan.unresolved ||= read.bodyUnresolved;
4370
4495
  }
4371
4496
  // src/modules/analysis/capability/heredoc/heredoc-body-collector.ts
4372
- /** Adds commands to `into`, with whether their bodies were unresolved. A
4373
- * collector that is not there is a reading that keeps none. */
4374
- function keepBodyCommands(into, commands, unresolved) {
4497
+ /** Adds commands to `into`, with whether their bodies were unresolved and
4498
+ * whether a delimiter of theirs was shell-dependent. A collector that is not
4499
+ * there is a reading that keeps none. */
4500
+ function keepBodyCommands(into, commands, unresolved, shellDependent = false) {
4375
4501
  if (into === void 0 || commands.length === 0 && !unresolved) return;
4376
4502
  for (const command of commands) into.commands.push(command);
4377
4503
  into.unresolved ||= unresolved;
4504
+ if (shellDependent) into.shellDependent = true;
4378
4505
  }
4379
4506
  /** Adds the commands of one unquoted body to `into`, with the scripts of the
4380
4507
  * heredocs in them. */
@@ -4422,7 +4549,7 @@ function uncertainRegion(lex, from, to) {
4422
4549
  if (pair < to && nextMark(marks, 2, pair, () => commentFrom(text, pair)) < to) return true;
4423
4550
  const open = nextMark(marks, 3, from, () => find(text, "$(", from));
4424
4551
  if (open < to && nextMark(marks, 4, open, () => closingComment(text, open)) < to) return true;
4425
- if (lex.budget.quoting === "finder") return false;
4552
+ if (readsAsFinder(lex.budget.quoting)) return false;
4426
4553
  if (nextMark(marks, 5, from, () => find(text, "<<", from)) >= to) return false;
4427
4554
  return nextMark(marks, 7, from, () => heredocGroupFrom(lex, from)) < to;
4428
4555
  }
@@ -4507,7 +4634,7 @@ function commentStart(text, at) {
4507
4634
  * the same budget, and keep the commands its heredocs run. */
4508
4635
  function lexBody(lex, budget, body) {
4509
4636
  const { text, end } = body;
4510
- keepBodyCommands(budget.bodies, body.bodyCommands, body.bodyUnresolved);
4637
+ keepBodyCommands(budget.bodies, body.bodyCommands, body.bodyUnresolved, body.delimiterShellDependent);
4511
4638
  keepBodyScripts(budget.bodies, body.scripts);
4512
4639
  lex.substitutionEnd = end;
4513
4640
  budget.substitutionCharsRemaining -= text.length;
@@ -4829,7 +4956,7 @@ function shellCommandSegmentsWithDirectory(command, initialDirectory) {
4829
4956
  ...tracker.directory === void 0 ? { directoryReason: tracker.directoryReason ?? "working directory is unresolved" } : { directory: tracker.directory }
4830
4957
  });
4831
4958
  const [head] = segment.tokens;
4832
- if (head !== void 0 && basename(head) === "cd") recordCd(tracker, segment.tokens);
4959
+ if (head !== void 0 && basename$1(head) === "cd") recordCd(tracker, segment.tokens);
4833
4960
  applyGrouping(tracker, segment.endedBy);
4834
4961
  }
4835
4962
  return result;
@@ -4855,7 +4982,7 @@ function newAnalysisBudget(reading = "default", quoting = "bash", bodies) {
4855
4982
  if (bodies !== void 0) budget.bodies = bodies;
4856
4983
  return budget;
4857
4984
  }
4858
- function basename$1(exe) {
4985
+ function basename(exe) {
4859
4986
  const slash = exe.lastIndexOf("/");
4860
4987
  return slash >= 0 ? exe.slice(slash + 1) : exe;
4861
4988
  }
@@ -4865,6 +4992,7 @@ function lexSegmentsBounded(command, reading = "default", quoting = "bash") {
4865
4992
  truncated: true,
4866
4993
  bodyCommands: [],
4867
4994
  bodyUnresolved: false,
4995
+ delimiterShellDependent: false,
4868
4996
  scripts: NO_SCRIPTS
4869
4997
  };
4870
4998
  const bodies = {
@@ -4884,6 +5012,7 @@ function lexSegmentsBounded(command, reading = "default", quoting = "bash") {
4884
5012
  truncated: state.tokensRemaining <= 0,
4885
5013
  bodyCommands: bodies.commands,
4886
5014
  bodyUnresolved: bodies.unresolved,
5015
+ delimiterShellDependent: bodies.shellDependent === true,
4887
5016
  scripts: bodies.scripts ?? NO_SCRIPTS
4888
5017
  };
4889
5018
  }
@@ -4915,7 +5044,7 @@ function splitArguments(command) {
4915
5044
  * command. */
4916
5045
  function commandName(command) {
4917
5046
  const first = command[0];
4918
- return first === void 0 ? void 0 : basename$1(first.value);
5047
+ return first === void 0 ? void 0 : basename(first.value);
4919
5048
  }
4920
5049
  // src/modules/analysis/shell/shell-lexer-tables.ts
4921
5050
  const TRANSPARENT_WRAPPERS = /* @__PURE__ */ new Set([
@@ -5252,7 +5381,7 @@ const CAT_PLAIN_WORDS = /* @__PURE__ */ new Set([
5252
5381
  * Where shells disagree on a form, it counts. */
5253
5382
  function shellReadsStdin(words, from = 0) {
5254
5383
  const head = words[from]?.value ?? "";
5255
- if (!STDIN_SCRIPT_SHELLS.has(basename$1(head))) return false;
5384
+ if (!STDIN_SCRIPT_SHELLS.has(basename(head))) return false;
5256
5385
  const scan = scanOptions(words, from + 1);
5257
5386
  if (scan.noRun || scan.noExec) return false;
5258
5387
  return scan.stdinFlag || !scan.command && !scan.operand;
@@ -5260,7 +5389,7 @@ function shellReadsStdin(words, from = 0) {
5260
5389
  /** Whether `words` are a `cat` that passes its stdin on unchanged: no
5261
5390
  * options, or `-u`, with no file operand but `-`. */
5262
5391
  function catPassesStdin(words) {
5263
- if (basename$1(words[0]?.value ?? "") !== "cat") return false;
5392
+ if (basename(words[0]?.value ?? "") !== "cat") return false;
5264
5393
  return words.slice(1).every((word) => CAT_PLAIN_WORDS.has(word.value));
5265
5394
  }
5266
5395
  function scanOptions(words, from) {
@@ -6903,7 +7032,7 @@ const SCRIPT_READER = /\b(?:sh|bash|zsh|dash|ksh|ash|mksh|ssh|busybox)\b/;
6903
7032
  function keepStringBodies(bodies, text) {
6904
7033
  if (bodies === void 0 || !text.includes("<<")) return;
6905
7034
  const read = sanitizedText(text);
6906
- keepBodyCommands(bodies, read.bodyCommands, read.bodyUnresolved);
7035
+ keepBodyCommands(bodies, read.bodyCommands, read.bodyUnresolved, read.delimiterShellDependent);
6907
7036
  keepBodyScripts(bodies, read.scripts);
6908
7037
  if (read.scripts.size > 0 && SCRIPT_READER.test(read.text)) feedsOf(bodies).commands.push(text);
6909
7038
  }
@@ -7031,7 +7160,7 @@ function walk(tokens, sink, inheritedRedirections, depth, remote = false, readin
7031
7160
  function peel(words, i, level) {
7032
7161
  const word = elementAt(words, i, "tokens").value;
7033
7162
  if (word === "--") return void 0;
7034
- const base = basename$1(word);
7163
+ const base = basename(word);
7035
7164
  level.sink.heads?.push({
7036
7165
  head: base,
7037
7166
  tokens: words,
@@ -7153,7 +7282,7 @@ function localExecutableCommand(tokens) {
7153
7282
  if (offset < 0 || command.some((value, index) => normalized[offset + index]?.value !== value)) return;
7154
7283
  const prefix = normalized.slice(0, offset).map((token) => token.value);
7155
7284
  if (prefix.some((token) => ["--help", "--version"].includes(token))) return;
7156
- if (prefix.some((token) => basename(token) === "command") && prefix.some((token) => /^-[vV]+$/.test(token))) return;
7285
+ if (prefix.some((token) => basename$1(token) === "command") && prefix.some((token) => /^-[vV]+$/.test(token))) return;
7157
7286
  if (prefix.some((token) => [
7158
7287
  "ssh",
7159
7288
  "chroot",
@@ -7173,7 +7302,7 @@ function localExecutableCommand(tokens) {
7173
7302
  "ash",
7174
7303
  "mksh",
7175
7304
  "fish"
7176
- ].includes(basename(token)))) return;
7305
+ ].includes(basename$1(token)))) return;
7177
7306
  if (prefix.some((token) => /^-(?!-)[^-]*[CDR]/.test(token) || /^--(?:chdir|chroot|working-directory)(?:=|$)/.test(token))) return;
7178
7307
  return {
7179
7308
  tokens: command,
@@ -7225,7 +7354,7 @@ const PLANNED_SUBCOMMANDS = [
7225
7354
  * tokens and prefix, and its planned subcommand. */
7226
7355
  function plannedInvocation(segmentTokens) {
7227
7356
  const local = localExecutableCommand(segmentTokens);
7228
- if (!local || basename(local.tokens[0] ?? "") !== "git") return void 0;
7357
+ if (!local || basename$1(local.tokens[0] ?? "") !== "git") return void 0;
7229
7358
  const { command: subcommand, index } = gitSubcommand(local.tokens, 0);
7230
7359
  if (!subcommand || !PLANNED_SUBCOMMANDS.includes(subcommand)) return void 0;
7231
7360
  return {
@@ -8508,7 +8637,7 @@ async function includeFileOnce(source, directory, rootDirectory, worktree, maxCh
8508
8637
  const actualBlock = resolvedPathBlock(actual, roots, "outside approved enrichment roots");
8509
8638
  if (actualBlock !== void 0) return blocked(resolved, actualBlock);
8510
8639
  const limit = Math.max(1, maxChars);
8511
- const handle = await open(actual, O_RDONLY$1 | O_NOFOLLOW$1 | O_NONBLOCK$1);
8640
+ const handle = await open$2(actual, O_RDONLY$1 | O_NOFOLLOW$1 | O_NONBLOCK$1);
8512
8641
  try {
8513
8642
  return await readOpenedFile(handle, resolved, roots, limit);
8514
8643
  } finally {
@@ -8610,8 +8739,8 @@ const INTERPRETERS = /* @__PURE__ */ new Set([
8610
8739
  function interpreterScript(tokens) {
8611
8740
  const command = localExecutableCommand(tokens)?.tokens;
8612
8741
  const executable = command?.[0];
8613
- if (command === void 0 || executable === void 0 || !INTERPRETERS.has(basename(executable))) return;
8614
- const interpreter = basename(executable);
8742
+ if (command === void 0 || executable === void 0 || !INTERPRETERS.has(basename$1(executable))) return;
8743
+ const interpreter = basename$1(executable);
8615
8744
  const path = scriptPath(command, 0, interpreter);
8616
8745
  return path ? {
8617
8746
  interpreter,
@@ -8700,7 +8829,7 @@ function isScriptName(script) {
8700
8829
  return script !== void 0 && script !== "" && !script.startsWith("-") && !/[/$`*?{}<>]/.test(script) && !/\.[cm]?[jt]sx?$/.test(script);
8701
8830
  }
8702
8831
  function invocation(tokens) {
8703
- const manager = basename(tokens[0] ?? "");
8832
+ const manager = basename$1(tokens[0] ?? "");
8704
8833
  if (!MANAGERS.has(manager)) return;
8705
8834
  const scan = {
8706
8835
  cursor: 1,
@@ -8737,9 +8866,9 @@ const REMOTE_OR_PRIVILEGED = [
8737
8866
  "systemd-run"
8738
8867
  ];
8739
8868
  function scriptCalls(tokens) {
8740
- const managerIndex = tokens.findIndex((token) => MANAGERS.has(basename(token)));
8869
+ const managerIndex = tokens.findIndex((token) => MANAGERS.has(basename$1(token)));
8741
8870
  const prefix = managerIndex < 0 ? tokens : tokens.slice(0, managerIndex);
8742
- if (prefix.some((token) => REMOTE_OR_PRIVILEGED.includes(basename(token)))) return [];
8871
+ if (prefix.some((token) => REMOTE_OR_PRIVILEGED.includes(basename$1(token)))) return [];
8743
8872
  const redirected = prefix.some((token) => token === "-C" || token.startsWith("--chdir"));
8744
8873
  const commands = effectiveCommands({ tokens: tokens.map((value) => ({
8745
8874
  raw: value,
@@ -9103,7 +9232,7 @@ function sshLoginUser(words, start) {
9103
9232
  }
9104
9233
  // src/modules/evidence/ssh/ssh-command-segments.ts
9105
9234
  function findSshIndex(tokens) {
9106
- return tokens.findIndex((token) => basename(token) === "ssh");
9235
+ return tokens.findIndex((token) => basename$1(token) === "ssh");
9107
9236
  }
9108
9237
  function parseSsh(tokens, sshIndex) {
9109
9238
  const { destination, index, options } = scanSshArguments(tokens, sshIndex);
@@ -9149,7 +9278,7 @@ function remoteCommand(tokens) {
9149
9278
  }
9150
9279
  function catSource(tokens) {
9151
9280
  const [head] = tokens;
9152
- if (tokens.length < 2 || head === void 0 || basename(head) !== "cat") return;
9281
+ if (tokens.length < 2 || head === void 0 || basename$1(head) !== "cat") return;
9153
9282
  const positional = tokens.slice(1).filter((value) => value !== "--" && !value.startsWith("-"));
9154
9283
  const [source] = positional;
9155
9284
  if (positional.length !== 1 || source === void 0) return;
@@ -9965,7 +10094,7 @@ function hasInlineCodeOption(tokens) {
9965
10094
  interpreter: "",
9966
10095
  inline: false
9967
10096
  };
9968
- const base = basename$1(first.value);
10097
+ const base = basename(first.value);
9969
10098
  if (!INTERPRETERS$1.has(base)) return {
9970
10099
  interpreter: base,
9971
10100
  inline: false
@@ -9995,14 +10124,15 @@ function analysisWarnings(parsed, heredocTruncated) {
9995
10124
  if (parsed.heredocs.some((h) => h.dynamic)) warnings.push("one or more heredoc bodies have unresolvable expansion");
9996
10125
  if (heredocTruncated) warnings.push("one or more heredoc bodies were truncated or never terminated");
9997
10126
  if (parsed.analysisTruncated) warnings.push("command structure exceeded the static analysis depth or expansion budget");
10127
+ if (parsed.shellDependentQuoting) warnings.push("command contains a $'…' escape whose value depends on the shell");
9998
10128
  return warnings;
9999
10129
  }
10000
10130
  function parserCompleteness(parsed, heredocTruncated) {
10001
10131
  if (parsed.hasDynamicConstructs) return hasCommandSubstitution(parsed.sanitizedCommand) || parsed.heredocs.some((h) => h.dynamic) ? "opaque" : "partial";
10002
- return parsed.analysisTruncated || heredocTruncated ? "partial" : "complete-for-supported-form";
10132
+ return parsed.analysisTruncated || heredocTruncated || parsed.shellDependentQuoting ? "partial" : "complete-for-supported-form";
10003
10133
  }
10004
- function summaryOf(facts) {
10005
- const summaryParts = [facts.dominantClass];
10134
+ function summaryOf(facts, actionClass) {
10135
+ const summaryParts = [actionClass];
10006
10136
  if (facts.createsAdHocCode) summaryParts.push("ad-hoc code");
10007
10137
  if (facts.executesRepositoryCode) summaryParts.push("repository code");
10008
10138
  if (facts.invokesPackageLifecycle) summaryParts.push("package lifecycle scripts");
@@ -10012,17 +10142,24 @@ function summaryOf(facts) {
10012
10142
  if (facts.privilegeEscalation) summaryParts.push("privilege escalation");
10013
10143
  return summaryParts.join(", ");
10014
10144
  }
10145
+ /** The class the facts give. A shell-dependent word can hide an effect the
10146
+ * facts missed, so it turns `read-only` into `unknown`; any other class
10147
+ * stays, so a rule that matches it still does. */
10148
+ function actionClassOf$1(parsed, facts) {
10149
+ return parsed.shellDependentQuoting && facts.dominantClass === "read-only" ? "unknown" : facts.dominantClass;
10150
+ }
10015
10151
  function assessmentFrom(parsed, facts) {
10152
+ const actionClass = actionClassOf$1(parsed, facts);
10016
10153
  const heredocTruncated = parsed.heredocs.some((h) => h.truncated);
10017
10154
  const warnings = analysisWarnings(parsed, heredocTruncated);
10018
10155
  const networkPossible = facts.networkObserved || facts.networkPossible;
10019
10156
  return {
10020
10157
  actionClass: {
10021
- value: facts.dominantClass,
10158
+ value: actionClass,
10022
10159
  source: "static-analysis",
10023
- confidence: facts.classConfidence
10160
+ confidence: parsed.shellDependentQuoting ? "low" : facts.classConfidence
10024
10161
  },
10025
- summary: summaryOf(facts),
10162
+ summary: summaryOf(facts, actionClass),
10026
10163
  executesCode: staticFlag(facts.executesCode),
10027
10164
  executesRepositoryCode: staticFlag(facts.executesRepositoryCode),
10028
10165
  createsAdHocCode: staticFlag(facts.createsAdHocCode),
@@ -10491,7 +10628,7 @@ function classifyPersistenceTool(base, facts) {
10491
10628
  function classifyEffectiveCommand(cmd, facts, context) {
10492
10629
  const first = cmd[0];
10493
10630
  if (first === void 0) return;
10494
- const base = basename$1(first.value);
10631
+ const base = basename(first.value);
10495
10632
  classifyRecognition(base, classifyReadOnlyToolMutation(cmd, base, facts, context), facts);
10496
10633
  classifyInterpreter(cmd, base, facts, context);
10497
10634
  classifyTestRunner(base, facts);
@@ -10566,7 +10703,7 @@ function classifyCredentialReads(parsed, facts) {
10566
10703
  function classifyCredentialCommand(cmd, redirects, facts) {
10567
10704
  const first = cmd[0];
10568
10705
  if (first === void 0) return;
10569
- const base = basename$1(first.value);
10706
+ const base = basename(first.value);
10570
10707
  for (const r of redirects) if (inputRedirectReadsCredential(r)) facts.credentialRead = true;
10571
10708
  if (!CREDENTIAL_READERS.has(base)) return;
10572
10709
  for (let i = 1; i < cmd.length; i += 1) if (operandReadsCredential(elementAt(cmd, i - 1, "cmd"), elementAt(cmd, i, "cmd").value)) facts.credentialRead = true;
@@ -10594,7 +10731,7 @@ function classifyTruncatedSegmentHeads(segments, facts) {
10594
10731
  for (const { tokens } of segments) {
10595
10732
  let k = commandStart$1(tokens);
10596
10733
  while (k !== void 0 && k < tokens.length) {
10597
- const head = basename$1(valueAt(tokens, k));
10734
+ const head = basename(valueAt(tokens, k));
10598
10735
  classifyWrapperHead(head, facts);
10599
10736
  if (SSH_TOOLS.has(head) && tailMutates(tokens, k + 1)) facts.remoteMutation = true;
10600
10737
  k = wrappedCommandIndex(tokens, k, head);
@@ -10660,6 +10797,7 @@ function newWalked() {
10660
10797
  effective: [],
10661
10798
  redirections: [],
10662
10799
  truncated: false,
10800
+ delimiterShellDependent: false,
10663
10801
  parts: [],
10664
10802
  remote: [],
10665
10803
  stdinCode: false,
@@ -10927,7 +11065,7 @@ function isPipe(separator) {
10927
11065
  * operand, so an option whose grammar is not known leaves stdin as data.
10928
11066
  */
10929
11067
  function interpreterReadsStdin(words) {
10930
- const name = basename$1(words[0]?.value ?? "");
11068
+ const name = basename(words[0]?.value ?? "");
10931
11069
  const spec = INTERPRETER_SPECS[name];
10932
11070
  const valued = (option) => OPTIONS_WITH_VALUE.has(option) || spec?.valueOptions?.has(option) === true;
10933
11071
  for (let index = 1; index < words.length; index += 1) {
@@ -10966,7 +11104,7 @@ function analyzeFeeds(parts, scripts) {
10966
11104
  * file or command string for a shell, without a script operand for the
10967
11105
  * rest. */
10968
11106
  function runsStdinCode(words) {
10969
- const head = basename$1(words[0]?.value ?? "");
11107
+ const head = basename(words[0]?.value ?? "");
10970
11108
  if (!INTERPRETERS$1.has(head)) return false;
10971
11109
  return STDIN_SCRIPT_SHELLS.has(head) ? shellReadsStdin(words) : interpreterReadsStdin(words);
10972
11110
  }
@@ -11055,6 +11193,7 @@ function addAll(into, scripts) {
11055
11193
  function walkBodyCommands(commands, unresolved, budget, into, feeds = [], scripts = []) {
11056
11194
  const strings = takeBodies(budget);
11057
11195
  into.truncated = into.truncated || unresolved || strings.unresolved;
11196
+ into.delimiterShellDependent ||= strings.shellDependent === true;
11058
11197
  const queue = [...[...commands, ...strings.commands].map((command) => ({
11059
11198
  command,
11060
11199
  level: 1,
@@ -11075,6 +11214,7 @@ function walkBodyCommands(commands, unresolved, budget, into, feeds = [], script
11075
11214
  if (next.remote) into.remote.push(...into.effective.slice(first.effective));
11076
11215
  const deeper = takeBodies(budget);
11077
11216
  into.truncated = into.truncated || lex.bodyUnresolved || deeper.unresolved;
11217
+ into.delimiterShellDependent ||= lex.delimiterShellDependent || deeper.shellDependent === true;
11078
11218
  if (lex.truncated || stopped) {
11079
11219
  into.truncated = true;
11080
11220
  return;
@@ -11092,9 +11232,11 @@ function takeBodies(budget) {
11092
11232
  };
11093
11233
  const taken = {
11094
11234
  commands: bodies.commands.splice(0),
11095
- unresolved: bodies.unresolved
11235
+ unresolved: bodies.unresolved,
11236
+ shellDependent: bodies.shellDependent === true
11096
11237
  };
11097
11238
  bodies.unresolved = false;
11239
+ bodies.shellDependent = false;
11098
11240
  return taken;
11099
11241
  }
11100
11242
  /** Queue the commands and feeds one level below `from`; true when that is
@@ -11115,6 +11257,46 @@ function queueDeeper(queue, commands, feeds, from) {
11115
11257
  });
11116
11258
  return false;
11117
11259
  }
11260
+ // src/modules/analysis/capability/heredoc/shell-dependent-word.ts
11261
+ /** Index of the first `close` at or after `from` that no backslash escapes,
11262
+ * or -1. */
11263
+ function closingIndex(raw, from, close) {
11264
+ for (let i = from; i < raw.length; i++) if (raw[i] === "\\") i++;
11265
+ else if (raw[i] === close) return i;
11266
+ return -1;
11267
+ }
11268
+ /** Index of the quote that ends a `'…'` or `"…"` region opened before `from`.
11269
+ * Inside single quotes a backslash is literal. */
11270
+ function quoteEnd(raw, from, quote) {
11271
+ return quote === "'" ? raw.indexOf("'", from) : closingIndex(raw, from, quote);
11272
+ }
11273
+ const FOUND = -1;
11274
+ const UNTERMINATED = -2;
11275
+ /** Index where the scan resumes after the part at `i`, FOUND for a
11276
+ * shell-dependent `$'…'`, or UNTERMINATED when a quote never closes. */
11277
+ function step(raw, i) {
11278
+ const ch = raw[i];
11279
+ if (ch === "\\") return i + 2;
11280
+ if (ch === "'" || ch === "\"") {
11281
+ const close = quoteEnd(raw, i + 1, ch);
11282
+ return close < 0 ? UNTERMINATED : close + 1;
11283
+ }
11284
+ if (ch === "$" && raw[i + 1] === "'") {
11285
+ const close = closingIndex(raw, i + 2, "'");
11286
+ if (close < 0) return UNTERMINATED;
11287
+ return ansiCShellDependent(raw.slice(i + 2, close)) ? FOUND : close + 1;
11288
+ }
11289
+ return i + 1;
11290
+ }
11291
+ /** Whether a word has an unquoted `$'…'` part whose escapes the shells
11292
+ * decode differently (`ansiCShellDependent`). One left-to-right pass: `'…'`,
11293
+ * `"…"` and backslash pairs are skipped, so `"$'\q'"` doesn't count. */
11294
+ function hasShellDependentWord(raw) {
11295
+ if (!raw.includes("\\")) return false;
11296
+ let i = 0;
11297
+ while (i >= 0 && i < raw.length) i = step(raw, i);
11298
+ return i === FOUND;
11299
+ }
11118
11300
  // src/modules/analysis/capability/command-parser.ts
11119
11301
  /** Parse a raw bash command into the reusable structure. */
11120
11302
  function parseCommand(rawCommand) {
@@ -11145,6 +11327,7 @@ function parse(rawCommand) {
11145
11327
  analysisTruncated: walked.truncated,
11146
11328
  heads: walked.heads,
11147
11329
  segmentRedirections: walked.parts.map((part) => part.segmentRedirections),
11330
+ shellDependentQuoting: extraction.delimiterShellDependent || lex.delimiterShellDependent || walked.delimiterShellDependent || [...walked.segments.flatMap((segment) => segment.tokens), ...walked.effective.flat()].some((token) => hasShellDependentWord(token.raw)),
11148
11331
  ...walked.remote.length > 0 && { remoteCommands: walked.remote },
11149
11332
  ...walked.stdinCode && { stdinCode: true }
11150
11333
  };
@@ -14584,7 +14767,7 @@ function commandReason(command, depth, budget, scripts) {
14584
14767
  * least as strict as the release before the substitution step, and the
14585
14768
  * undecoded reading as strict as the previous release, on every input. */
14586
14769
  function readingsReason(command, bodies) {
14587
- return brakeReadingsReason(command, "finder", bodies) ?? brakeReadingsReason(command, "rescan", bodies) ?? brakeReadingsReason(command, "undecoded", bodies) ?? brakeReadingsReason(command, "previous", bodies);
14770
+ return brakeReadingsReason(command, "finder", bodies) ?? brakeReadingsReason(command, "rescan", bodies) ?? brakeReadingsReason(command, "undecoded", bodies) ?? brakeReadingsReason(command, "previous", bodies) ?? (command.includes("\\") ? brakeReadingsReason(command, "zsh", bodies) ?? brakeReadingsReason(command, "bash32", bodies) : void 0);
14588
14771
  }
14589
14772
  // src/modules/policy/policy-conditions.ts
14590
14773
  /** Whether every field of a condition matches the observed facts. A missing