@noppu-labs/opencode-permission-reviewer 3.4.2 → 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/explain.js CHANGED
@@ -3,7 +3,7 @@ import { parseArgs } from "node:util";
3
3
  import { homedir } from "node:os";
4
4
  import { dirname, isAbsolute, join, normalize, resolve, sep } from "node:path";
5
5
  import { closeSync, constants, existsSync, fstatSync, fsyncSync, ftruncateSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, writeFileSync, writeSync } from "node:fs";
6
- import { lstat, mkdir, open, readlink, realpath } from "node:fs/promises";
6
+ import { lstat, mkdir, open as open$2, readlink, realpath } from "node:fs/promises";
7
7
  import { createHash } from "node:crypto";
8
8
  import { satisfies } from "semver";
9
9
  import { OpenCode } from "@opencode/client";
@@ -332,6 +332,9 @@ const OPENROUTER_DECISION_MODELS = {
332
332
  "cloudflare/clef": { benchmarked: false },
333
333
  "cloudflare/clef-flash": { benchmarked: false },
334
334
  "cloudflare/clef-omni": { benchmarked: false },
335
+ "google/gemini-decision-1": { benchmarked: false },
336
+ "heygen/heygen-decision-1": { benchmarked: false },
337
+ "heygen/heygen-decision-1-turbo": { benchmarked: false },
335
338
  "jaredpalmer/kev-4b": { benchmarked: false },
336
339
  "liquid/d1": { benchmarked: true },
337
340
  "liquid/d1-ultra": { benchmarked: true },
@@ -339,12 +342,15 @@ const OPENROUTER_DECISION_MODELS = {
339
342
  "microsoft/microsoft-decision-1": { benchmarked: false },
340
343
  "morph/reflex": { benchmarked: false },
341
344
  "nace-ai/drex-max": { benchmarked: false },
345
+ "nace-ai/drex-max-finance": { benchmarked: false },
342
346
  "nace-ai/drex-v1.5": { benchmarked: false },
343
347
  "nace-ai/drex-v2.0": { benchmarked: false },
344
348
  "openai/gpt-6-luna-decisions": { benchmarked: false },
345
- "parallel/decisions-fast:free": { benchmarked: false },
349
+ "parallel/decisions-fast": { benchmarked: false },
346
350
  "perplexity/pplx-decider-flash-v1.2": { benchmarked: false },
351
+ "perplexity/pplx-decider-flash-v1.3:free": { benchmarked: false },
347
352
  "perplexity/pplx-decider-v1.2": { benchmarked: false },
353
+ "perplexity/pplx-decider-v1.3:free": { benchmarked: false },
348
354
  "respan/span-02": { benchmarked: false },
349
355
  "togethercomputer/tev1-4b-experimental": { benchmarked: false },
350
356
  "typesafe/jev-1.13": { benchmarked: true },
@@ -1533,9 +1539,9 @@ function fmtCounts(map) {
1533
1539
  * validates to nothing. */
1534
1540
  function conditionMatches(cond, cap, actor, config) {
1535
1541
  if (cond === void 0 || cond.always === true) return true;
1536
- return listConditionHolds(cond.actionClass, cap, actionClassOf) && listConditionHolds(cond.actorProfile, actor, profileOf) && capabilityFlagsHold(cond, cap) && listConditionHolds(cond.repositoryTrust, config, repositoryTrustOf);
1542
+ return listConditionHolds(cond.actionClass, cap, actionClassOf$1) && listConditionHolds(cond.actorProfile, actor, profileOf) && capabilityFlagsHold(cond, cap) && listConditionHolds(cond.repositoryTrust, config, repositoryTrustOf);
1537
1543
  }
1538
- const actionClassOf = (cap) => cap.actionClass.value;
1544
+ const actionClassOf$1 = (cap) => cap.actionClass.value;
1539
1545
  const profileOf = (actor) => actor.profile.value;
1540
1546
  const repositoryTrustOf = (config) => config.repositoryTrust;
1541
1547
  /** An enum-list condition holds when it is absent or lists the observed value.
@@ -1978,12 +1984,127 @@ function addScript(into, placeholder, text) {
1978
1984
  function invariant(condition, message) {
1979
1985
  if (!condition) throw new Error(message);
1980
1986
  }
1987
+ // src/modules/analysis/capability/heredoc/ansi-c-numeric.ts
1988
+ const HEX_DIGITS = /* @__PURE__ */ new Map([
1989
+ ["x", /[0-9a-f]{1,2}/iy],
1990
+ ["u", /[0-9a-f]{1,4}/iy],
1991
+ ["U", /[0-9a-f]{1,8}/iy]
1992
+ ]);
1993
+ const OCTAL_DIGITS = /[0-7]{1,3}/y;
1994
+ /** The octal escape at `index`, whose first digit is at `index + 1`. */
1995
+ function decodeAnsiCOctal(inner, index) {
1996
+ const digits = digitsAt(inner, index + 1, OCTAL_DIGITS);
1997
+ return {
1998
+ text: String.fromCharCode(Number.parseInt(digits, 8) & 255),
1999
+ end: index + 1 + digits.length
2000
+ };
2001
+ }
2002
+ /** The `\x`, `\u` or `\U` escape at `index`; undefined for another letter or
2003
+ * without a hex digit. */
2004
+ function decodeAnsiCHex(inner, index, letter) {
2005
+ const pattern = HEX_DIGITS.get(letter);
2006
+ if (pattern === void 0) return void 0;
2007
+ const digits = digitsAt(inner, index + 2, pattern);
2008
+ if (digits === "") return void 0;
2009
+ const end = index + 2 + digits.length;
2010
+ const value = Number.parseInt(digits, 16);
2011
+ if (letter === "x") return {
2012
+ text: String.fromCharCode(value),
2013
+ end
2014
+ };
2015
+ return {
2016
+ text: codePointText(value),
2017
+ end
2018
+ };
2019
+ }
2020
+ /** The text bash gives a `\u` or `\U` code point. Values above 0x7fffffff
2021
+ * are dropped; surrogates and values past U+10FFFF are not JavaScript code
2022
+ * points and become U+FFFD. */
2023
+ function codePointText(value) {
2024
+ if (value > 2147483647) return "";
2025
+ if (value >= 55296 && value <= 57343 || value > 1114111) return "�";
2026
+ return String.fromCodePoint(value);
2027
+ }
2028
+ /** `\cX` is the control character of X. In bash 4.4 and later `\c?` is DEL and
2029
+ * `\c\\` takes both backslashes; bash 3.2 reads each like any other X. */
2030
+ function decodeAnsiCControl(inner, index, dialect) {
2031
+ const target = inner.charAt(index + 2);
2032
+ if (target === "") return {
2033
+ text: "\\c",
2034
+ end: index + 2
2035
+ };
2036
+ const modern = dialect === "bash";
2037
+ if (target === "\\" && modern) return {
2038
+ text: "",
2039
+ end: inner.charAt(index + 3) === "\\" ? index + 4 : index + 3
2040
+ };
2041
+ const code = target === "?" && modern ? 127 : target.charCodeAt(0) & 31;
2042
+ return {
2043
+ text: String.fromCharCode(code),
2044
+ end: index + 3
2045
+ };
2046
+ }
2047
+ /** The digits matched by the sticky `pattern` at `start`. */
2048
+ function digitsAt(text, start, pattern) {
2049
+ pattern.lastIndex = start;
2050
+ return pattern.exec(text)?.[0] ?? "";
2051
+ }
2052
+ // src/modules/analysis/capability/heredoc/ansi-c-zsh.ts
2053
+ /** `\C` clears bits 5 and 6 (`?` becomes DEL); `\M` sets bit 7. */
2054
+ const MODIFIERS = {
2055
+ C: (code) => code === 63 ? 127 : code & 159,
2056
+ M: (code) => code | 128
2057
+ };
2058
+ /** An escape zsh reads without a backslash: `\x`, `\u` and `\U` without a
2059
+ * hex digit are NUL, a run of `\C[-]` and `\M[-]` modifies the first
2060
+ * character of the escape or character after it (innermost first, nothing
2061
+ * at the end of the text), and anything else (`\cX` included) is the
2062
+ * character itself. `decodeEscape` decodes the escape at an index. */
2063
+ function decodeZshOther(inner, index, escaped, decodeEscape) {
2064
+ if (/^[xuU]$/.test(escaped)) return {
2065
+ text: "\0",
2066
+ end: index + 2
2067
+ };
2068
+ if (MODIFIERS[escaped] === void 0) return {
2069
+ text: escaped,
2070
+ end: index + 2
2071
+ };
2072
+ const modifiers = [];
2073
+ let position = index;
2074
+ let modify = MODIFIERS[inner.charAt(position + 1)];
2075
+ while (inner.charAt(position) === "\\" && modify !== void 0) {
2076
+ modifiers.push(modify);
2077
+ position += inner.charAt(position + 2) === "-" ? 3 : 2;
2078
+ modify = MODIFIERS[inner.charAt(position + 1)];
2079
+ }
2080
+ const operand = operandAt(inner, position, decodeEscape);
2081
+ if (operand.text === "") return operand;
2082
+ let code = operand.text.charCodeAt(0);
2083
+ for (const apply of modifiers.reverse()) code = apply(code);
2084
+ return {
2085
+ text: String.fromCharCode(code) + operand.text.slice(1),
2086
+ end: operand.end
2087
+ };
2088
+ }
2089
+ /** The escape or character a modifier run applies to. */
2090
+ function operandAt(inner, position, decodeEscape) {
2091
+ if (position >= inner.length) return {
2092
+ text: "",
2093
+ end: position
2094
+ };
2095
+ if (inner.charAt(position) === "\\" && position + 1 < inner.length) return decodeEscape(inner, position);
2096
+ return {
2097
+ text: inner.charAt(position),
2098
+ end: position + 1
2099
+ };
2100
+ }
1981
2101
  // src/modules/analysis/capability/heredoc/ansi-c-quoting.ts
1982
- /** Unescape an ANSI-C quoted region (`$'...'`), the subset bash defines for
1983
- * here-document delimiter words: standard escapes, `\xHH` hex, and up to
1984
- * three octal digits. Unknown escapes drop the backslash, like bash. A
1985
- * delimiter containing a newline can never match a body line; it stays
1986
- * resolved and the body scan reports the heredoc as unterminated. */
2102
+ /** Unescape the `$'...'` region of a here-document delimiter word. Unknown
2103
+ * escapes drop the backslash as zsh does, so the text is right for every
2104
+ * shell only when `ansiCShellDependent` accepts the part; `scanDollarQuoted`
2105
+ * marks the word unresolved otherwise. A delimiter containing a newline can
2106
+ * never match a body line; it stays resolved and the body scan reports the
2107
+ * heredoc as unterminated. */
1987
2108
  function unescapeAnsiC(command, start) {
1988
2109
  let text = "";
1989
2110
  let index = start;
@@ -2053,10 +2174,37 @@ function ansiCEscape(command, index, escaped) {
2053
2174
  end: index + 2
2054
2175
  };
2055
2176
  }
2056
- /** The value bash gives a `$'...'` word whose text between the quotes is
2057
- * `inner`, as written: escapes decoded, cut at the first NUL. Unknown
2058
- * escapes and a bare `\x`, `\u` or `\U` keep their backslash. */
2059
- function decodeAnsiCWord(inner) {
2177
+ /** Whether an escape in `inner` (the text between `$'` and the closing `'`, as
2178
+ * written) is read differently by bash, bash 3.2 and zsh: anything but a
2179
+ * simple escape, an octal escape, or `\x` with a hex digit. `\c`, `\u` and
2180
+ * `\U` always count, and so does a NUL with text after it, where bash ends
2181
+ * the word and zsh keeps the rest. A NUL that ends the word gives the same
2182
+ * argument in both; a heredoc delimiter checks for one itself. */
2183
+ function ansiCShellDependent(inner) {
2184
+ let index = 0;
2185
+ while (index < inner.length) {
2186
+ if (inner.charAt(index) !== "\\") {
2187
+ index += 1;
2188
+ continue;
2189
+ }
2190
+ const bash = decodeAnsiCEscape(inner, index, "bash");
2191
+ if (textAfterNul(bash.text, inner.slice(bash.end)) || bash.text !== decodeAnsiCEscape(inner, index, "zsh").text || bash.text !== decodeAnsiCEscape(inner, index, "bash32").text) return true;
2192
+ index = bash.end;
2193
+ }
2194
+ return false;
2195
+ }
2196
+ /** Whether an escape's `text` has a NUL with more text after it, in the
2197
+ * escape or in the `rest` of the word. */
2198
+ function textAfterNul(text, rest) {
2199
+ const nul = text.indexOf("\0");
2200
+ return nul !== -1 && (nul < text.length - 1 || rest !== "");
2201
+ }
2202
+ /** The value a `$'...'` word whose text between the quotes is `inner`, as
2203
+ * written, has in `dialect` as a command's argument: escapes decoded, cut
2204
+ * at the first NUL. In bash, unknown escapes and a bare `\x`, `\u` or `\U`
2205
+ * keep their backslash, and bash 3.2 also keeps it for every `\u` and
2206
+ * `\U`. */
2207
+ function decodeAnsiCWord(inner, dialect = "bash") {
2060
2208
  let value = "";
2061
2209
  let index = 0;
2062
2210
  while (index < inner.length) {
@@ -2065,101 +2213,51 @@ function decodeAnsiCWord(inner) {
2065
2213
  index += 1;
2066
2214
  continue;
2067
2215
  }
2068
- const decoded = decodeAnsiCEscape(inner, index);
2216
+ const decoded = decodeAnsiCEscape(inner, index, dialect);
2069
2217
  value += decoded.text;
2070
2218
  index = decoded.end;
2071
2219
  }
2072
- const nul = value.indexOf("\0");
2073
- return nul === -1 ? value : value.slice(0, nul);
2220
+ return value.split("\0", 1).join("");
2074
2221
  }
2075
- const HEX_DIGITS = /* @__PURE__ */ new Map([
2076
- ["x", /[0-9a-f]{1,2}/iy],
2077
- ["u", /[0-9a-f]{1,4}/iy],
2078
- ["U", /[0-9a-f]{1,8}/iy]
2079
- ]);
2080
- const OCTAL_DIGITS = /[0-7]{1,3}/y;
2081
2222
  /** The decoded escape whose backslash is at `index`, and the index just past it. */
2082
- function decodeAnsiCEscape(inner, index) {
2223
+ function decodeAnsiCEscape(inner, index, dialect) {
2083
2224
  const escaped = inner.charAt(index + 1);
2084
2225
  const simple = ANSI_C_SIMPLE_ESCAPES[escaped];
2085
2226
  if (simple !== void 0) return {
2086
2227
  text: simple,
2087
2228
  end: index + 2
2088
2229
  };
2089
- if (/^[0-7]$/.test(escaped)) {
2090
- const digits = digitsAt(inner, index + 1, OCTAL_DIGITS);
2091
- const value = Number.parseInt(digits, 8) & 255;
2092
- return {
2093
- text: String.fromCharCode(value),
2094
- end: index + 1 + digits.length
2095
- };
2096
- }
2097
- if (escaped === "c") return decodeAnsiCControl(inner, index);
2098
- const hex = HEX_DIGITS.get(escaped);
2099
- if (hex !== void 0) return decodeAnsiCHex(inner, index, escaped, hex);
2230
+ if (/^[0-7]$/.test(escaped)) return decodeAnsiCOctal(inner, index);
2231
+ if (escaped === "c" && dialect !== "zsh") return decodeAnsiCControl(inner, index, dialect);
2232
+ const decoded = (dialect !== "bash32" || escaped === "x") && decodeAnsiCHex(inner, index, escaped);
2233
+ if (decoded) return decoded;
2234
+ if (dialect === "zsh") return decodeZshOther(inner, index, escaped, (text, at) => decodeAnsiCEscape(text, at, "zsh"));
2100
2235
  return {
2101
2236
  text: `\\${escaped}`,
2102
2237
  end: index + 2
2103
2238
  };
2104
2239
  }
2105
- function decodeAnsiCHex(inner, index, letter, pattern) {
2106
- const digits = digitsAt(inner, index + 2, pattern);
2107
- if (digits === "") return {
2108
- text: `\\${letter}`,
2109
- end: index + 2
2110
- };
2111
- const end = index + 2 + digits.length;
2112
- const value = Number.parseInt(digits, 16);
2113
- if (letter === "x") return {
2114
- text: String.fromCharCode(value),
2115
- end
2116
- };
2117
- return {
2118
- text: codePointText(value),
2119
- end
2120
- };
2121
- }
2122
- /** The text bash gives a `\u` or `\U` code point. Values above 0x7fffffff
2123
- * are dropped; surrogates and values past U+10FFFF are not JavaScript code
2124
- * points and become U+FFFD. */
2125
- function codePointText(value) {
2126
- if (value > 2147483647) return "";
2127
- if (value >= 55296 && value <= 57343 || value > 1114111) return "�";
2128
- return String.fromCodePoint(value);
2129
- }
2130
- /** `\cX` is the control character of X, `\c?` is DEL, and `\c\\` is the
2131
- * control character of a backslash. */
2132
- function decodeAnsiCControl(inner, index) {
2133
- const target = inner.charAt(index + 2);
2134
- if (target === "") return {
2135
- text: "\\c",
2136
- end: index + 2
2137
- };
2138
- if (target === "\\") return {
2139
- text: "",
2140
- end: inner.charAt(index + 3) === "\\" ? index + 4 : index + 3
2141
- };
2142
- const code = target === "?" ? 127 : target.charCodeAt(0) & 31;
2143
- return {
2144
- text: String.fromCharCode(code),
2145
- end: index + 3
2146
- };
2240
+ // src/modules/analysis/shell/shell-lex-state.ts
2241
+ /** Whether the reading is `finder` with only a `$'…'` word's value changed. */
2242
+ function readsAsFinder(quoting = "bash") {
2243
+ return quoting === "finder" || quoting === "zsh" || quoting === "bash32";
2147
2244
  }
2148
- /** The digits matched by the sticky `pattern` at `start`. */
2149
- function digitsAt(text, start, pattern) {
2150
- pattern.lastIndex = start;
2151
- return pattern.exec(text)?.[0] ?? "";
2245
+ /** The dialect a reading decodes a `$'…'` word in. */
2246
+ function ansiCDialectOf(quoting = "bash") {
2247
+ return quoting === "zsh" || quoting === "bash32" ? quoting : "bash";
2152
2248
  }
2153
- // src/modules/analysis/shell/shell-lex-state.ts
2154
- /** Whether the reading decodes quotes the way bash does. */
2249
+ /** Whether the reading has bash's quote structure: `$'…'` strings and the
2250
+ * quote spans that follow from it. The readings that read as `finder` does
2251
+ * differ from `bash` only in how an escape decodes. */
2155
2252
  function readsBashQuotes(quoting = "bash") {
2156
- return quoting === "bash" || quoting === "rescan" || quoting === "finder";
2253
+ return quoting === "bash" || quoting === "rescan" || readsAsFinder(quoting);
2157
2254
  }
2158
- /** The substitution scan a reading uses. Only `bash` and `finder` end a body
2159
- * where the shell does, and their outer scan then jumps past the body; every
2160
- * other reading ends it where the previous release did and walks it again. */
2255
+ /** The substitution scan a reading uses. Only `bash` and the readings that
2256
+ * read as `finder` does end a body where the shell does, and their outer
2257
+ * scan then jumps past the body; every other reading ends it where the
2258
+ * previous release did and walks it again. */
2161
2259
  function substitutionScanOf(quoting = "bash") {
2162
- return quoting === "bash" || quoting === "finder" ? "bash" : "previous";
2260
+ return quoting === "bash" || readsAsFinder(quoting) ? "bash" : "previous";
2163
2261
  }
2164
2262
  /** Ceiling on the substitution text one scan re-lexes by default: nested
2165
2263
  * substitutions re-lex their body once per level. */
@@ -2211,7 +2309,7 @@ function lastValueChar(lex) {
2211
2309
  * joins the value as quoted text. Nothing was collected under the
2212
2310
  * `undecoded` reading, which appends the text as it scans. */
2213
2311
  function closeAnsiC(lex) {
2214
- appendValue(lex, decodeAnsiCWord(lex.ansiCText), true);
2312
+ appendValue(lex, decodeAnsiCWord(lex.ansiCText, ansiCDialectOf(lex.budget.quoting)), true);
2215
2313
  lex.ansiCText = "";
2216
2314
  lex.ansiC = false;
2217
2315
  }
@@ -2509,6 +2607,7 @@ function consumeBodies(scan, bodyStart, lineEnd) {
2509
2607
  const read = readBody(scan.command, position, start, bound);
2510
2608
  position = read.position;
2511
2609
  if (read.unterminated) scan.unterminated = true;
2610
+ noteDelimiter(scan, start);
2512
2611
  const record = bodyRecord(scan.command, start, read, lineEnd, targets);
2513
2612
  if (record.dynamic) scan.hasDynamicConstructs = true;
2514
2613
  keepBody(scan.bodies, start, read, record.sha256);
@@ -2520,6 +2619,10 @@ function consumeBodies(scan, bodyStart, lineEnd) {
2520
2619
  scan.pieces = [];
2521
2620
  return position;
2522
2621
  }
2622
+ function noteDelimiter(scan, start) {
2623
+ if (!start.resolved) scan.delimiterUnresolved = true;
2624
+ if (start.shellDependent) scan.delimiterShellDependent = true;
2625
+ }
2523
2626
  /** Keeps what one read body gives the collector: the commands its
2524
2627
  * substitutions run, when its delimiter is unquoted, and the text the command
2525
2628
  * that reads it gets, when it has its terminator line. */
@@ -2573,8 +2676,10 @@ function scanSingleQuoted(command, scan) {
2573
2676
  scan.index = end + 1;
2574
2677
  return true;
2575
2678
  }
2576
- /** `$'...'` is unescaped here; for `$"..."` only the `$` is consumed, and
2577
- * the double-quoted part follows. */
2679
+ /** `$'...'` is unescaped here. A part with an escape the shells read
2680
+ * differently, or with a NUL (bash ends the delimiter there, zsh keeps it),
2681
+ * leaves the word unresolved and shell-dependent. For `$"..."` only the `$`
2682
+ * is consumed, and the double-quoted part follows. */
2578
2683
  function scanDollarQuoted(command, scan) {
2579
2684
  scan.quoted = true;
2580
2685
  scan.sawAny = true;
@@ -2587,6 +2692,10 @@ function scanDollarQuoted(command, scan) {
2587
2692
  scan.resolved = false;
2588
2693
  return false;
2589
2694
  }
2695
+ if (ansiCShellDependent(command.slice(scan.index + 2, parsed.end - 1)) || parsed.text.includes("\0")) {
2696
+ scan.resolved = false;
2697
+ scan.shellDependent = true;
2698
+ }
2590
2699
  scan.delimiter += parsed.text;
2591
2700
  scan.index = parsed.end;
2592
2701
  return true;
@@ -2658,14 +2767,16 @@ const BARE_WORD_STOP = /* @__PURE__ */ new Set([
2658
2767
  * inside a backtick substitution, which the shell cuts out before it reads
2659
2768
  * the operator's word. A bare carriage return ends the word when
2660
2769
  * `stopAtCarriageReturn` is set, as the previous release read it.
2661
- * The word is `resolved: false` only when its quoting never terminates or
2662
- * the word is empty: then no line can be proven to be the terminator. */
2770
+ * The word is `resolved: false` when its quoting never terminates, the word
2771
+ * is empty, or a `$'...'` part is shell-dependent: then no line can be
2772
+ * proven to be the terminator. */
2663
2773
  function parseDelimiterWord(command, start, options = {}) {
2664
2774
  const scan = {
2665
2775
  index: start,
2666
2776
  delimiter: "",
2667
2777
  quoted: false,
2668
2778
  resolved: true,
2779
+ shellDependent: false,
2669
2780
  sawAny: false
2670
2781
  };
2671
2782
  while (scan.index < command.length) {
@@ -2678,13 +2789,15 @@ function parseDelimiterWord(command, start, options = {}) {
2678
2789
  wordEnd: start,
2679
2790
  delimiter: "",
2680
2791
  quoted: false,
2681
- resolved: false
2792
+ resolved: false,
2793
+ shellDependent: false
2682
2794
  };
2683
2795
  return {
2684
2796
  wordEnd: scan.index,
2685
2797
  delimiter: scan.delimiter,
2686
2798
  quoted: scan.quoted,
2687
- resolved: scan.resolved
2799
+ resolved: scan.resolved,
2800
+ shellDependent: scan.shellDependent
2688
2801
  };
2689
2802
  }
2690
2803
  /** Consume the word part at `scan.index`. Returns false when the word ends
@@ -3094,6 +3207,7 @@ function scanHeredocOperator(scan) {
3094
3207
  rawWord: command.slice(j, word.wordEnd),
3095
3208
  quoted: word.quoted,
3096
3209
  resolved: word.resolved,
3210
+ shellDependent: word.shellDependent,
3097
3211
  opStart: i,
3098
3212
  wordEnd: word.wordEnd,
3099
3213
  lineStart: scan.lineStart,
@@ -3114,6 +3228,8 @@ function legacySanitizedCommand(command) {
3114
3228
  hasDynamicConstructs: false,
3115
3229
  unterminated: false,
3116
3230
  framed: false,
3231
+ delimiterUnresolved: false,
3232
+ delimiterShellDependent: false,
3117
3233
  out: "",
3118
3234
  cursor: 0,
3119
3235
  i: 0,
@@ -3189,6 +3305,8 @@ function extractHeredocs(command, options = {}) {
3189
3305
  hasDynamicConstructs: false,
3190
3306
  unterminated: false,
3191
3307
  framed: false,
3308
+ delimiterUnresolved: false,
3309
+ delimiterShellDependent: false,
3192
3310
  out: "",
3193
3311
  cursor: 0,
3194
3312
  i: 0,
@@ -3211,6 +3329,8 @@ function extractHeredocs(command, options = {}) {
3211
3329
  return {
3212
3330
  unterminated: scan.unterminated,
3213
3331
  framed: scan.framed,
3332
+ delimiterUnresolved: scan.delimiterUnresolved,
3333
+ delimiterShellDependent: scan.delimiterShellDependent,
3214
3334
  sanitizedCommand: scan.out,
3215
3335
  heredocs: scan.heredocs,
3216
3336
  hasDynamicConstructs: scan.hasDynamicConstructs,
@@ -3223,6 +3343,8 @@ function unchanged(command) {
3223
3343
  return {
3224
3344
  unterminated: false,
3225
3345
  framed: false,
3346
+ delimiterUnresolved: false,
3347
+ delimiterShellDependent: false,
3226
3348
  sanitizedCommand: command,
3227
3349
  heredocs: [],
3228
3350
  hasDynamicConstructs: false,
@@ -3262,7 +3384,8 @@ function sanitizedText(text) {
3262
3384
  return {
3263
3385
  text: extraction.sanitizedCommand,
3264
3386
  bodyCommands: extraction.bodyCommands,
3265
- bodyUnresolved: extraction.bodyUnresolved,
3387
+ bodyUnresolved: extraction.bodyUnresolved || extraction.delimiterUnresolved,
3388
+ delimiterShellDependent: extraction.delimiterShellDependent,
3266
3389
  scripts: extraction.scripts
3267
3390
  };
3268
3391
  }
@@ -3613,7 +3736,7 @@ function advance(scan) {
3613
3736
  scan.index += 1;
3614
3737
  return false;
3615
3738
  }
3616
- function open$2(scan, frame, width) {
3739
+ function open$1(scan, frame, width) {
3617
3740
  scan.frames.push(frame);
3618
3741
  scan.starts.push(scan.index);
3619
3742
  scan.prefix = void 0;
@@ -3637,8 +3760,8 @@ function close$1(scan) {
3637
3760
  }
3638
3761
  function stepCommand(scan, c, insideCase) {
3639
3762
  if (c === ")" || c === "(") return stepParenthesis(scan, c, insideCase);
3640
- if (c === "\"") return open$2(scan, "double", 1);
3641
- if (c === "`") return open$2(scan, "backtick", 1);
3763
+ if (c === "\"") return open$1(scan, "double", 1);
3764
+ if (c === "`") return open$1(scan, "backtick", 1);
3642
3765
  if (c === "'" || c === "$" && scan.text[scan.index + 1] === "'") {
3643
3766
  skipSingleQuoted(scan, c === "$");
3644
3767
  return false;
@@ -3663,7 +3786,7 @@ function stepParenthesis(scan, c, insideCase) {
3663
3786
  /** A `(` opens a subshell, unless it is the `()` of a function header. */
3664
3787
  function openParenthesis(scan) {
3665
3788
  const end = scan.mode === "bash" ? functionHeaderEnd(scan) : -1;
3666
- if (end < 0) return open$2(scan, "command", 1);
3789
+ if (end < 0) return open$1(scan, "command", 1);
3667
3790
  scan.index = end;
3668
3791
  scan.headStart = -1;
3669
3792
  scan.commandPosition = true;
@@ -3672,7 +3795,7 @@ function openParenthesis(scan) {
3672
3795
  /** `${` opens an expansion that holds a `)` as text; `$$` is one parameter. */
3673
3796
  function stepDollar$2(scan) {
3674
3797
  const next = scan.text[scan.index + 1];
3675
- if (next === "{") return open$2(scan, "brace", 2);
3798
+ if (next === "{") return open$1(scan, "brace", 2);
3676
3799
  scan.commandPosition = false;
3677
3800
  scan.index += next === "$" ? 2 : 1;
3678
3801
  return false;
@@ -3697,8 +3820,8 @@ function stepBrace$1(scan, c) {
3697
3820
  /** It ends at `closer`; substitutions inside open frames of their own. */
3698
3821
  function stepQuoted$1(scan, c, closer, singleQuotes) {
3699
3822
  if (c === closer) return close$1(scan);
3700
- if (c === "\"") return open$2(scan, "double", 1);
3701
- if (c === "`") return open$2(scan, "backtick", 1);
3823
+ if (c === "\"") return open$1(scan, "double", 1);
3824
+ if (c === "`") return open$1(scan, "backtick", 1);
3702
3825
  if (c === "'" && singleQuotes) return skip(scan, false);
3703
3826
  return c === "$" ? stepDollar$1(scan, singleQuotes) : advance(scan);
3704
3827
  }
@@ -3707,11 +3830,11 @@ function stepQuoted$1(scan, c, closer, singleQuotes) {
3707
3830
  function stepDollar$1(scan, singleQuotes) {
3708
3831
  const next = scan.text[scan.index + 1];
3709
3832
  if (next !== "(") return stepParameter(scan, next, singleQuotes);
3710
- return open$2(scan, scan.mode === "bash" && scan.text[scan.index + 2] === "(" ? "arith" : "command", 2);
3833
+ return open$1(scan, scan.mode === "bash" && scan.text[scan.index + 2] === "(" ? "arith" : "command", 2);
3711
3834
  }
3712
3835
  function stepParameter(scan, next, singleQuotes) {
3713
3836
  if (scan.mode !== "bash") return advance(scan);
3714
- if (next === "{") return open$2(scan, "brace", 2);
3837
+ if (next === "{") return open$1(scan, "brace", 2);
3715
3838
  if (next === "$") scan.index += 1;
3716
3839
  else if (next === "'" && singleQuotes) return skip(scan, true);
3717
3840
  return advance(scan);
@@ -3991,14 +4114,14 @@ function openGroup(scan, c) {
3991
4114
  if (!scan.commandPosition && !dollar && scan.words !== "forName") return void 0;
3992
4115
  if (!dollar && !closesAsArithmetic(text, index, scan.probes)) return void 0;
3993
4116
  const forLoop = scan.words === "forName";
3994
- open$2(scan, "arith", 1);
3995
- open$2(scan, "arith", 1);
4117
+ open$1(scan, "arith", 1);
4118
+ open$1(scan, "arith", 1);
3996
4119
  scan.commandPosition = false;
3997
4120
  if (forLoop) scan.saved[scan.saved.length - 2] = ["forAfterName", void 0];
3998
4121
  return false;
3999
4122
  }
4000
4123
  function openArray(scan) {
4001
- open$2(scan, "array", 1);
4124
+ open$1(scan, "array", 1);
4002
4125
  scan.commandPosition = false;
4003
4126
  return false;
4004
4127
  }
@@ -4006,7 +4129,7 @@ function openTest(scan) {
4006
4129
  const { text, index } = scan;
4007
4130
  if (!scan.commandPosition || !text.startsWith("[[", index)) return void 0;
4008
4131
  if (!/\s/.test(text.charAt(index + 2))) return void 0;
4009
- open$2(scan, "test", 2);
4132
+ open$1(scan, "test", 2);
4010
4133
  scan.commandPosition = false;
4011
4134
  return false;
4012
4135
  }
@@ -4020,7 +4143,7 @@ function stepArith(scan, c) {
4020
4143
  const group = c === "(" ? openGroup(scan, c) : void 0;
4021
4144
  if (group !== void 0) return group;
4022
4145
  if (c === "(" && scan.text[scan.index - 1] !== "$") {
4023
- open$2(scan, "arith", 1);
4146
+ open$1(scan, "arith", 1);
4024
4147
  scan.commandPosition = false;
4025
4148
  return false;
4026
4149
  }
@@ -4093,12 +4216,12 @@ function substitutionBodyEnd(text, start, opener, reading = "default", mode = "b
4093
4216
  escapedEnd: -1,
4094
4217
  probes
4095
4218
  };
4096
- while (scan.index < text.length) if (step$1(scan)) return scan.index;
4219
+ while (scan.index < text.length) if (step$2(scan)) return scan.index;
4097
4220
  return text.length;
4098
4221
  }
4099
4222
  /** Advance past one character or construct; true once the opener's frame
4100
4223
  * closes at `scan.index`. */
4101
- function step$1(scan) {
4224
+ function step$2(scan) {
4102
4225
  const c = scan.text.charAt(scan.index);
4103
4226
  if (c === "\\") {
4104
4227
  const joins = scan.mode === "bash" && scan.text[scan.index + 1] === "\n";
@@ -4170,6 +4293,7 @@ function commandBody(text, end, reading, sanitize) {
4170
4293
  text: sanitize ? legacySanitizedCommand(text) : text,
4171
4294
  bodyCommands: [],
4172
4295
  bodyUnresolved: false,
4296
+ delimiterShellDependent: false,
4173
4297
  scripts: NO_SCRIPTS,
4174
4298
  end
4175
4299
  };
@@ -4179,6 +4303,7 @@ function commandBody(text, end, reading, sanitize) {
4179
4303
  text: read.text,
4180
4304
  bodyCommands: read.bodyCommands,
4181
4305
  bodyUnresolved: read.bodyUnresolved,
4306
+ delimiterShellDependent: read.delimiterShellDependent,
4182
4307
  scripts: read.scripts,
4183
4308
  end
4184
4309
  };
@@ -4269,10 +4394,10 @@ function stepFrame(scan, index) {
4269
4394
  * every other character plain. */
4270
4395
  function stepCount(scan, index) {
4271
4396
  const c = scan.text.charAt(index);
4272
- if (c === "(") return open$1(scan, "count", index + 1);
4397
+ if (c === "(") return open(scan, "count", index + 1);
4273
4398
  if (c === ")") return close(scan, index);
4274
4399
  if (c === "\\") return index + 2;
4275
- if (c === "\"") return open$1(scan, "double", index + 1);
4400
+ if (c === "\"") return open(scan, "double", index + 1);
4276
4401
  if (c !== "'") return index + 1;
4277
4402
  const end = scan.text.indexOf("'", index + 1);
4278
4403
  return end < 0 ? -1 : end + 1;
@@ -4290,7 +4415,7 @@ function stepParen(scan, index) {
4290
4415
  return index + 1;
4291
4416
  }
4292
4417
  if (c === "\\" || c === "") return index + 2;
4293
- if (c === "(" || c === "$" && text.charAt(index + 1) === "(") return open$1(scan, "paren", index + (c === "(" ? 1 : 2));
4418
+ if (c === "(" || c === "$" && text.charAt(index + 1) === "(") return open(scan, "paren", index + (c === "(" ? 1 : 2));
4294
4419
  if (c === ")") return close(scan, index);
4295
4420
  return stepQuoted(scan, index);
4296
4421
  }
@@ -4311,7 +4436,7 @@ function stepBrace(scan, index) {
4311
4436
  function stepQuoted(scan, index) {
4312
4437
  const c = scan.text.charAt(index);
4313
4438
  if (c === "`") return pastBacktick(scan.text, index);
4314
- if (c === "\"") return open$1(scan, "double", index + 1);
4439
+ if (c === "\"") return open(scan, "double", index + 1);
4315
4440
  if (c !== "'") return stepDollar(scan, index);
4316
4441
  const end = scan.text.indexOf("'", index + 1);
4317
4442
  return end < 0 ? -1 : end + 1;
@@ -4321,11 +4446,11 @@ function stepQuoted(scan, index) {
4321
4446
  function stepDollar(scan, index) {
4322
4447
  const next = scan.text.charAt(index + 1);
4323
4448
  if (scan.text.charAt(index) !== "$") return index + 1;
4324
- if (next === "(") return open$1(scan, "paren", index + 2);
4325
- if (next === "{" && scan.frames.at(-1) !== "paren") return open$1(scan, "brace", index + 2);
4449
+ if (next === "(") return open(scan, "paren", index + 2);
4450
+ if (next === "{" && scan.frames.at(-1) !== "paren") return open(scan, "brace", index + 2);
4326
4451
  return index + 1;
4327
4452
  }
4328
- function open$1(scan, frame, after) {
4453
+ function open(scan, frame, after) {
4329
4454
  scan.frames.push(frame);
4330
4455
  scan.starts.push(after);
4331
4456
  return after;
@@ -4553,7 +4678,7 @@ function scanBody(text) {
4553
4678
  ends: /* @__PURE__ */ new Map()
4554
4679
  };
4555
4680
  let index = 0;
4556
- while (index < text.length && !scan.unresolved) index = step(scan, index);
4681
+ while (index < text.length && !scan.unresolved) index = step$1(scan, index);
4557
4682
  if (scan.unresolved) return {
4558
4683
  commands: scan.commands,
4559
4684
  unresolved: true
@@ -4570,7 +4695,7 @@ function scanBody(text) {
4570
4695
  };
4571
4696
  }
4572
4697
  /** The index after the character or construct at `index`. */
4573
- function step(scan, index) {
4698
+ function step$1(scan, index) {
4574
4699
  const after = bodyTextStep(scan.text, index);
4575
4700
  return after < 0 ? substitute(scan, index) : after;
4576
4701
  }
@@ -4605,12 +4730,14 @@ function keepCommand(scan, found, backtick) {
4605
4730
  scan.unresolved ||= read.bodyUnresolved;
4606
4731
  }
4607
4732
  // src/modules/analysis/capability/heredoc/heredoc-body-collector.ts
4608
- /** Adds commands to `into`, with whether their bodies were unresolved. A
4609
- * collector that is not there is a reading that keeps none. */
4610
- function keepBodyCommands(into, commands, unresolved) {
4733
+ /** Adds commands to `into`, with whether their bodies were unresolved and
4734
+ * whether a delimiter of theirs was shell-dependent. A collector that is not
4735
+ * there is a reading that keeps none. */
4736
+ function keepBodyCommands(into, commands, unresolved, shellDependent = false) {
4611
4737
  if (into === void 0 || commands.length === 0 && !unresolved) return;
4612
4738
  for (const command of commands) into.commands.push(command);
4613
4739
  into.unresolved ||= unresolved;
4740
+ if (shellDependent) into.shellDependent = true;
4614
4741
  }
4615
4742
  /** Adds the commands of one unquoted body to `into`, with the scripts of the
4616
4743
  * heredocs in them. */
@@ -4658,7 +4785,7 @@ function uncertainRegion(lex, from, to) {
4658
4785
  if (pair < to && nextMark(marks, 2, pair, () => commentFrom(text, pair)) < to) return true;
4659
4786
  const open = nextMark(marks, 3, from, () => find(text, "$(", from));
4660
4787
  if (open < to && nextMark(marks, 4, open, () => closingComment(text, open)) < to) return true;
4661
- if (lex.budget.quoting === "finder") return false;
4788
+ if (readsAsFinder(lex.budget.quoting)) return false;
4662
4789
  if (nextMark(marks, 5, from, () => find(text, "<<", from)) >= to) return false;
4663
4790
  return nextMark(marks, 7, from, () => heredocGroupFrom(lex, from)) < to;
4664
4791
  }
@@ -4743,7 +4870,7 @@ function commentStart(text, at) {
4743
4870
  * the same budget, and keep the commands its heredocs run. */
4744
4871
  function lexBody(lex, budget, body) {
4745
4872
  const { text, end } = body;
4746
- keepBodyCommands(budget.bodies, body.bodyCommands, body.bodyUnresolved);
4873
+ keepBodyCommands(budget.bodies, body.bodyCommands, body.bodyUnresolved, body.delimiterShellDependent);
4747
4874
  keepBodyScripts(budget.bodies, body.scripts);
4748
4875
  lex.substitutionEnd = end;
4749
4876
  budget.substitutionCharsRemaining -= text.length;
@@ -4998,6 +5125,7 @@ function lexSegmentsBounded(command, reading = "default", quoting = "bash") {
4998
5125
  truncated: true,
4999
5126
  bodyCommands: [],
5000
5127
  bodyUnresolved: false,
5128
+ delimiterShellDependent: false,
5001
5129
  scripts: NO_SCRIPTS
5002
5130
  };
5003
5131
  const bodies = {
@@ -5017,6 +5145,7 @@ function lexSegmentsBounded(command, reading = "default", quoting = "bash") {
5017
5145
  truncated: state.tokensRemaining <= 0,
5018
5146
  bodyCommands: bodies.commands,
5019
5147
  bodyUnresolved: bodies.unresolved,
5148
+ delimiterShellDependent: bodies.shellDependent === true,
5020
5149
  scripts: bodies.scripts ?? NO_SCRIPTS
5021
5150
  };
5022
5151
  }
@@ -5647,14 +5776,15 @@ function analysisWarnings(parsed, heredocTruncated) {
5647
5776
  if (parsed.heredocs.some((h) => h.dynamic)) warnings.push("one or more heredoc bodies have unresolvable expansion");
5648
5777
  if (heredocTruncated) warnings.push("one or more heredoc bodies were truncated or never terminated");
5649
5778
  if (parsed.analysisTruncated) warnings.push("command structure exceeded the static analysis depth or expansion budget");
5779
+ if (parsed.shellDependentQuoting) warnings.push("command contains a $'…' escape whose value depends on the shell");
5650
5780
  return warnings;
5651
5781
  }
5652
5782
  function parserCompleteness(parsed, heredocTruncated) {
5653
5783
  if (parsed.hasDynamicConstructs) return hasCommandSubstitution(parsed.sanitizedCommand) || parsed.heredocs.some((h) => h.dynamic) ? "opaque" : "partial";
5654
- return parsed.analysisTruncated || heredocTruncated ? "partial" : "complete-for-supported-form";
5784
+ return parsed.analysisTruncated || heredocTruncated || parsed.shellDependentQuoting ? "partial" : "complete-for-supported-form";
5655
5785
  }
5656
- function summaryOf(facts) {
5657
- const summaryParts = [facts.dominantClass];
5786
+ function summaryOf(facts, actionClass) {
5787
+ const summaryParts = [actionClass];
5658
5788
  if (facts.createsAdHocCode) summaryParts.push("ad-hoc code");
5659
5789
  if (facts.executesRepositoryCode) summaryParts.push("repository code");
5660
5790
  if (facts.invokesPackageLifecycle) summaryParts.push("package lifecycle scripts");
@@ -5664,17 +5794,24 @@ function summaryOf(facts) {
5664
5794
  if (facts.privilegeEscalation) summaryParts.push("privilege escalation");
5665
5795
  return summaryParts.join(", ");
5666
5796
  }
5797
+ /** The class the facts give. A shell-dependent word can hide an effect the
5798
+ * facts missed, so it turns `read-only` into `unknown`; any other class
5799
+ * stays, so a rule that matches it still does. */
5800
+ function actionClassOf(parsed, facts) {
5801
+ return parsed.shellDependentQuoting && facts.dominantClass === "read-only" ? "unknown" : facts.dominantClass;
5802
+ }
5667
5803
  function assessmentFrom(parsed, facts) {
5804
+ const actionClass = actionClassOf(parsed, facts);
5668
5805
  const heredocTruncated = parsed.heredocs.some((h) => h.truncated);
5669
5806
  const warnings = analysisWarnings(parsed, heredocTruncated);
5670
5807
  const networkPossible = facts.networkObserved || facts.networkPossible;
5671
5808
  return {
5672
5809
  actionClass: {
5673
- value: facts.dominantClass,
5810
+ value: actionClass,
5674
5811
  source: "static-analysis",
5675
- confidence: facts.classConfidence
5812
+ confidence: parsed.shellDependentQuoting ? "low" : facts.classConfidence
5676
5813
  },
5677
- summary: summaryOf(facts),
5814
+ summary: summaryOf(facts, actionClass),
5678
5815
  executesCode: staticFlag(facts.executesCode),
5679
5816
  executesRepositoryCode: staticFlag(facts.executesRepositoryCode),
5680
5817
  createsAdHocCode: staticFlag(facts.createsAdHocCode),
@@ -7821,7 +7958,7 @@ const SCRIPT_READER = /\b(?:sh|bash|zsh|dash|ksh|ash|mksh|ssh|busybox)\b/;
7821
7958
  function keepStringBodies(bodies, text) {
7822
7959
  if (bodies === void 0 || !text.includes("<<")) return;
7823
7960
  const read = sanitizedText(text);
7824
- keepBodyCommands(bodies, read.bodyCommands, read.bodyUnresolved);
7961
+ keepBodyCommands(bodies, read.bodyCommands, read.bodyUnresolved, read.delimiterShellDependent);
7825
7962
  keepBodyScripts(bodies, read.scripts);
7826
7963
  if (read.scripts.size > 0 && SCRIPT_READER.test(read.text)) feedsOf(bodies).commands.push(text);
7827
7964
  }
@@ -8039,6 +8176,7 @@ function newWalked() {
8039
8176
  effective: [],
8040
8177
  redirections: [],
8041
8178
  truncated: false,
8179
+ delimiterShellDependent: false,
8042
8180
  parts: [],
8043
8181
  remote: [],
8044
8182
  stdinCode: false,
@@ -8582,6 +8720,7 @@ function addAll(into, scripts) {
8582
8720
  function walkBodyCommands(commands, unresolved, budget, into, feeds = [], scripts = []) {
8583
8721
  const strings = takeBodies(budget);
8584
8722
  into.truncated = into.truncated || unresolved || strings.unresolved;
8723
+ into.delimiterShellDependent ||= strings.shellDependent === true;
8585
8724
  const queue = [...[...commands, ...strings.commands].map((command) => ({
8586
8725
  command,
8587
8726
  level: 1,
@@ -8602,6 +8741,7 @@ function walkBodyCommands(commands, unresolved, budget, into, feeds = [], script
8602
8741
  if (next.remote) into.remote.push(...into.effective.slice(first.effective));
8603
8742
  const deeper = takeBodies(budget);
8604
8743
  into.truncated = into.truncated || lex.bodyUnresolved || deeper.unresolved;
8744
+ into.delimiterShellDependent ||= lex.delimiterShellDependent || deeper.shellDependent === true;
8605
8745
  if (lex.truncated || stopped) {
8606
8746
  into.truncated = true;
8607
8747
  return;
@@ -8619,9 +8759,11 @@ function takeBodies(budget) {
8619
8759
  };
8620
8760
  const taken = {
8621
8761
  commands: bodies.commands.splice(0),
8622
- unresolved: bodies.unresolved
8762
+ unresolved: bodies.unresolved,
8763
+ shellDependent: bodies.shellDependent === true
8623
8764
  };
8624
8765
  bodies.unresolved = false;
8766
+ bodies.shellDependent = false;
8625
8767
  return taken;
8626
8768
  }
8627
8769
  /** Queue the commands and feeds one level below `from`; true when that is
@@ -8642,6 +8784,46 @@ function queueDeeper(queue, commands, feeds, from) {
8642
8784
  });
8643
8785
  return false;
8644
8786
  }
8787
+ // src/modules/analysis/capability/heredoc/shell-dependent-word.ts
8788
+ /** Index of the first `close` at or after `from` that no backslash escapes,
8789
+ * or -1. */
8790
+ function closingIndex(raw, from, close) {
8791
+ for (let i = from; i < raw.length; i++) if (raw[i] === "\\") i++;
8792
+ else if (raw[i] === close) return i;
8793
+ return -1;
8794
+ }
8795
+ /** Index of the quote that ends a `'…'` or `"…"` region opened before `from`.
8796
+ * Inside single quotes a backslash is literal. */
8797
+ function quoteEnd(raw, from, quote) {
8798
+ return quote === "'" ? raw.indexOf("'", from) : closingIndex(raw, from, quote);
8799
+ }
8800
+ const FOUND = -1;
8801
+ const UNTERMINATED = -2;
8802
+ /** Index where the scan resumes after the part at `i`, FOUND for a
8803
+ * shell-dependent `$'…'`, or UNTERMINATED when a quote never closes. */
8804
+ function step(raw, i) {
8805
+ const ch = raw[i];
8806
+ if (ch === "\\") return i + 2;
8807
+ if (ch === "'" || ch === "\"") {
8808
+ const close = quoteEnd(raw, i + 1, ch);
8809
+ return close < 0 ? UNTERMINATED : close + 1;
8810
+ }
8811
+ if (ch === "$" && raw[i + 1] === "'") {
8812
+ const close = closingIndex(raw, i + 2, "'");
8813
+ if (close < 0) return UNTERMINATED;
8814
+ return ansiCShellDependent(raw.slice(i + 2, close)) ? FOUND : close + 1;
8815
+ }
8816
+ return i + 1;
8817
+ }
8818
+ /** Whether a word has an unquoted `$'…'` part whose escapes the shells
8819
+ * decode differently (`ansiCShellDependent`). One left-to-right pass: `'…'`,
8820
+ * `"…"` and backslash pairs are skipped, so `"$'\q'"` doesn't count. */
8821
+ function hasShellDependentWord(raw) {
8822
+ if (!raw.includes("\\")) return false;
8823
+ let i = 0;
8824
+ while (i >= 0 && i < raw.length) i = step(raw, i);
8825
+ return i === FOUND;
8826
+ }
8645
8827
  // src/modules/analysis/capability/command-parser.ts
8646
8828
  /** Parse a raw bash command into the reusable structure. */
8647
8829
  function parseCommand(rawCommand) {
@@ -8672,6 +8854,7 @@ function parse(rawCommand) {
8672
8854
  analysisTruncated: walked.truncated,
8673
8855
  heads: walked.heads,
8674
8856
  segmentRedirections: walked.parts.map((part) => part.segmentRedirections),
8857
+ shellDependentQuoting: extraction.delimiterShellDependent || lex.delimiterShellDependent || walked.delimiterShellDependent || [...walked.segments.flatMap((segment) => segment.tokens), ...walked.effective.flat()].some((token) => hasShellDependentWord(token.raw)),
8675
8858
  ...walked.remote.length > 0 && { remoteCommands: walked.remote },
8676
8859
  ...walked.stdinCode && { stdinCode: true }
8677
8860
  };
@@ -9012,7 +9195,7 @@ async function includeFileOnce(source, directory, rootDirectory, worktree, maxCh
9012
9195
  const actualBlock = resolvedPathBlock(actual, roots, "outside approved enrichment roots");
9013
9196
  if (actualBlock !== void 0) return blocked(resolved, actualBlock);
9014
9197
  const limit = Math.max(1, maxChars);
9015
- const handle = await open(actual, O_RDONLY | O_NOFOLLOW | O_NONBLOCK);
9198
+ const handle = await open$2(actual, O_RDONLY | O_NOFOLLOW | O_NONBLOCK);
9016
9199
  try {
9017
9200
  return await readOpenedFile(handle, resolved, roots, limit);
9018
9201
  } finally {
@@ -9214,7 +9397,7 @@ async function connectedStatus(endpoint, directory) {
9214
9397
  async function checkWritable(path) {
9215
9398
  try {
9216
9399
  await mkdir(dirname(path), { recursive: true });
9217
- await (await open(path, "a", 384)).close();
9400
+ await (await open$2(path, "a", 384)).close();
9218
9401
  return { ok: true };
9219
9402
  } catch (error) {
9220
9403
  return {