@noppu-labs/opencode-permission-reviewer 3.2.2 → 3.3.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
@@ -9,7 +9,7 @@ import { satisfies } from "semver";
9
9
  import { OpenCode } from "@opencode/client";
10
10
  import { fileURLToPath } from "node:url";
11
11
  import { applyEdits, modify } from "jsonc-parser";
12
- //#region src/modules/policy/config-rule-condition.ts
12
+ // src/modules/policy/config-rule-condition.ts
13
13
  const ACTOR_PROFILES = /* @__PURE__ */ new Set([
14
14
  "read-only",
15
15
  "validation",
@@ -104,8 +104,7 @@ function copyFlagConditions(value, out) {
104
104
  function isClosedSetMemberArray(value, valid) {
105
105
  return Array.isArray(value) && value.length > 0 && value.every((v) => typeof v === "string" && valid.has(v));
106
106
  }
107
- //#endregion
108
- //#region src/modules/config/models/config-policy-rules.ts
107
+ // src/modules/config/models/config-policy-rules.ts
109
108
  const VALID_EFFECTS = /* @__PURE__ */ new Set([
110
109
  "review",
111
110
  "manual",
@@ -168,8 +167,7 @@ function countInvalidPolicyRules(value) {
168
167
  if (!Array.isArray(value)) return 1;
169
168
  return value.filter((raw) => parsePolicyRule(raw) === null).length;
170
169
  }
171
- //#endregion
172
- //#region src/modules/config/models/config-fields.ts
170
+ // src/modules/config/models/config-fields.ts
173
171
  /** Parse a trusted name→profile mapping. Invalid entries are dropped. */
174
172
  function resolveActorProfiles(value) {
175
173
  if (typeof value !== "object" || value === null) return {};
@@ -209,8 +207,7 @@ function isStringArray(value) {
209
207
  function optional$1(key, value) {
210
208
  return value === void 0 ? {} : { [key]: value };
211
209
  }
212
- //#endregion
213
- //#region src/modules/config/models/config-knobs.ts
210
+ // src/modules/config/models/config-knobs.ts
214
211
  function boundedInteger(value, fallback, min, max) {
215
212
  if (typeof value !== "number" || !Number.isInteger(value)) return fallback;
216
213
  return Math.min(max, Math.max(min, value));
@@ -261,8 +258,7 @@ function integerKnobs(source, bounds, defaults) {
261
258
  function numberKnobs(source, bounds, defaults) {
262
259
  return clampKnobs(source, bounds, defaults, boundedNumber);
263
260
  }
264
- //#endregion
265
- //#region src/modules/config/models/config-risk-policy.ts
261
+ // src/modules/config/models/config-risk-policy.ts
266
262
  /** Default risk×authorization matrix. `critical` stays empty: critical risk
267
263
  * never auto-allows. */
268
264
  const DEFAULT_RISK_POLICY = {
@@ -326,8 +322,126 @@ function resolveMinimumConfidence(value) {
326
322
  if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_RISK_POLICY.minimumConfidence;
327
323
  return Math.min(1, Math.max(.5, value));
328
324
  }
329
- //#endregion
330
- //#region src/modules/config/services/reviewer-model.ts
325
+ // src/modules/config/models/openrouter-decision-models.ts
326
+ const OPENROUTER_DECISION_MODELS = {
327
+ models: {
328
+ "cloudflare/clef": { benchmarked: false },
329
+ "cloudflare/clef-flash": { benchmarked: false },
330
+ "cloudflare/clef-omni": { benchmarked: false },
331
+ "inception/mercury-decide": { benchmarked: false },
332
+ "jaredpalmer/kev-4b": { benchmarked: false },
333
+ "liquid/d1": { benchmarked: true },
334
+ "liquid/d1-ultra": { benchmarked: true },
335
+ "liquid/d1.1": { benchmarked: false },
336
+ "microsoft/microsoft-decision-1": { benchmarked: false },
337
+ "nace-ai/drex-max": { benchmarked: false },
338
+ "nace-ai/drex-v1.5": { benchmarked: false },
339
+ "nace-ai/drex-v2.0": { benchmarked: false },
340
+ "openai/gpt-6-luna-decisions": { benchmarked: false },
341
+ "perplexity/pplx-decider-flash-v1.2": { benchmarked: false },
342
+ "perplexity/pplx-decider-v1.2": { benchmarked: false },
343
+ "respan/span-02": { benchmarked: false },
344
+ "togethercomputer/tev1-4b-experimental": { benchmarked: false },
345
+ "typesafe/jev-1.13": { benchmarked: true },
346
+ "typesafe/jev-1.14": { benchmarked: true },
347
+ "upstage/solar-decide": { benchmarked: false },
348
+ "upstage/solar-decide-flash": { benchmarked: false },
349
+ "~liquid/d1-latest": { benchmarked: false },
350
+ "~liquid/d1-ultra-latest": { benchmarked: false },
351
+ "~perplexity/pplx-decider-flash-latest": { benchmarked: false },
352
+ "~perplexity/pplx-decider-latest": { benchmarked: false },
353
+ "~typesafe/jev-latest": { benchmarked: false }
354
+ },
355
+ incompatible: {
356
+ "respan/span-01": "requires a different state shape",
357
+ "respan/span-01-lite": "requires a different state shape",
358
+ "respan/span-01-lite:free": "requires a different state shape",
359
+ "scaledown/classify-1": "accepts only plain-string instructions and criteria"
360
+ }
361
+ };
362
+ // src/modules/config/models/system-one-providers.ts
363
+ const JEV_MODEL = /^jev(?:-|$)/;
364
+ const COMMANDCODE_JEV = "typesafe/jev";
365
+ const LIQUID_DECISION_MODELS = /* @__PURE__ */ new Set(["d1", "d1-ultra"]);
366
+ const BASETEN_DECISION_MODELS = /* @__PURE__ */ new Set(["decision-models/baseten-elephant-9b-latest", "decision-models/baseten-mammoth-27b-latest"]);
367
+ const isJev = (modelID) => JEV_MODEL.test(modelID);
368
+ const returnsJev = (_modelID, returned) => isJev(returned);
369
+ const sameModel = (modelID, returned) => returned === modelID;
370
+ const OPENROUTER_FAMILIES = [/^(?:typesafe\/jev-\d[a-z0-9.-]*(?<!-latest)|~typesafe\/jev-latest)$/, /^(?:liquid\/d1(?:[-.][a-z0-9.-]*)?(?<!-latest)|~liquid\/d1(?:[-.][a-z0-9.-]*)?-latest)$/];
371
+ const OPENROUTER_ROUTING_SUFFIX = /:[a-z0-9-]+$/;
372
+ const OPENROUTER_ALIAS = /^~(.+)-latest$/;
373
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
374
+ const OPENROUTER_MODELS = OPENROUTER_DECISION_MODELS.models;
375
+ const OPENROUTER_INCOMPATIBLE = OPENROUTER_DECISION_MODELS.incompatible;
376
+ const withoutRoutingSuffix = (modelID) => {
377
+ const stripped = modelID.replace(OPENROUTER_ROUTING_SUFFIX, "");
378
+ return stripped === modelID ? [modelID] : [modelID, stripped];
379
+ };
380
+ const openRouterIncompatibleReason = (modelID) => {
381
+ for (const id of withoutRoutingSuffix(modelID)) if (Object.hasOwn(OPENROUTER_INCOMPATIBLE, id)) return OPENROUTER_INCOMPATIBLE[id];
382
+ };
383
+ const openRouterConfigWarning = (modelID) => {
384
+ const reason = openRouterIncompatibleReason(modelID);
385
+ if (reason !== void 0) return `openrouter/${modelID} is known to reject the reviewer's request (${reason}); every review will fail`;
386
+ const listed = withoutRoutingSuffix(modelID).find((id) => Object.hasOwn(OPENROUTER_MODELS, id));
387
+ if (listed !== void 0 && OPENROUTER_MODELS[listed]?.benchmarked === true) return;
388
+ return `openrouter/${modelID} has not been benchmarked as a reviewer; see REVIEWER-MODELS.md`;
389
+ };
390
+ const openRouterAccepts = (modelID) => openRouterIncompatibleReason(modelID) !== void 0 || withoutRoutingSuffix(modelID).some((id) => Object.hasOwn(OPENROUTER_DECISION_MODELS.models, id) || OPENROUTER_FAMILIES.some((family) => family.test(id)));
391
+ const openRouterAcceptsResponse = (modelID, returned) => {
392
+ const base = modelID.replace(OPENROUTER_ROUTING_SUFFIX, "");
393
+ const alias = OPENROUTER_ALIAS.exec(base)?.[1];
394
+ if (alias !== void 0) return new RegExp(`^${escapeRegExp(alias)}(?:$|[-.])`).test(returned);
395
+ return returned === base || new RegExp(`^${escapeRegExp(base)}-\\d{8}$`).test(returned);
396
+ };
397
+ const SYSTEM_ONE_PROVIDERS = {
398
+ opencode: {
399
+ keyEnv: "OPENCODE_API_KEY",
400
+ baseURL: "https://opencode.ai/zen",
401
+ accepts: isJev,
402
+ acceptsResponse: returnsJev
403
+ },
404
+ "typesafe-ai": {
405
+ keyEnv: "TYPESAFE_API_KEY",
406
+ accepts: isJev,
407
+ acceptsResponse: returnsJev
408
+ },
409
+ commandcode: {
410
+ keyEnv: "CMD_API_KEY",
411
+ baseURL: "https://api.commandcode.ai/provider",
412
+ accepts: (modelID) => modelID === COMMANDCODE_JEV,
413
+ acceptsResponse: (_modelID, returned) => returned === COMMANDCODE_JEV
414
+ },
415
+ "liquid-ai": {
416
+ keyEnv: "LIQUID_API_KEY",
417
+ baseURL: "https://api.liquid.ai/decisions",
418
+ keyShape: {
419
+ pattern: /^liquid_[A-Za-z0-9]{32,}$/,
420
+ message: "LIQUID_API_KEY is not a Liquid AI key (expected the \"liquid_\" prefix)"
421
+ },
422
+ accepts: (modelID) => LIQUID_DECISION_MODELS.has(modelID),
423
+ acceptsResponse: sameModel
424
+ },
425
+ baseten: {
426
+ keyEnv: "BASETEN_API_KEY",
427
+ baseURL: "https://inference.baseten.co",
428
+ accepts: (modelID) => BASETEN_DECISION_MODELS.has(modelID),
429
+ acceptsResponse: sameModel
430
+ },
431
+ openrouter: {
432
+ keyEnv: "OPENROUTER_API_KEY",
433
+ baseURL: "https://openrouter.ai/api",
434
+ keyShape: {
435
+ pattern: /^sk-or-v1-[0-9a-f]{64}$/,
436
+ message: "OPENROUTER_API_KEY is not an OpenRouter key (expected the \"sk-or-v1-\" prefix)"
437
+ },
438
+ accepts: openRouterAccepts,
439
+ acceptsResponse: openRouterAcceptsResponse,
440
+ incompatibleReason: openRouterIncompatibleReason,
441
+ configWarning: openRouterConfigWarning
442
+ }
443
+ };
444
+ // src/modules/config/services/reviewer-model.ts
331
445
  function splitModel(model) {
332
446
  const slash = model.indexOf("/");
333
447
  if (slash <= 0 || slash === model.length - 1) throw new Error(`Invalid reviewer model "${model}"; expected provider/model`);
@@ -336,14 +450,23 @@ function splitModel(model) {
336
450
  modelID: model.slice(slash + 1)
337
451
  };
338
452
  }
339
- function isSystemOneReviewerModel(model) {
453
+ function systemOneProviderFor(model) {
340
454
  let parsed;
341
455
  try {
342
456
  parsed = splitModel(model);
343
457
  } catch {
344
- return false;
458
+ return;
345
459
  }
346
- return (parsed.providerID === "opencode" || parsed.providerID === "typesafe-ai") && /^jev(?:-|$)/.test(parsed.modelID) || parsed.providerID === "commandcode" && parsed.modelID === "typesafe/jev";
460
+ if (!Object.hasOwn(SYSTEM_ONE_PROVIDERS, parsed.providerID)) return;
461
+ const provider = SYSTEM_ONE_PROVIDERS[parsed.providerID];
462
+ if (!provider?.accepts(parsed.modelID)) return;
463
+ return {
464
+ provider,
465
+ ...parsed
466
+ };
467
+ }
468
+ function isSystemOneReviewerModel(model) {
469
+ return systemOneProviderFor(model) !== void 0;
347
470
  }
348
471
  function isProviderModelId(value) {
349
472
  return typeof value === "string" && value.includes("/");
@@ -371,8 +494,7 @@ function isValidEscalationReviewer(value) {
371
494
  if (source === void 0) return false;
372
495
  return (source.variant === void 0 || typeof source.variant === "string" && source.variant !== "") && (source.outputFormat === void 0 || source.outputFormat === "text" || source.outputFormat === "json_schema") && (source.timeoutMs === void 0 || Number.isInteger(source.timeoutMs));
373
496
  }
374
- //#endregion
375
- //#region src/modules/config/services/system-one-routing.ts
497
+ // src/modules/config/services/system-one-routing.ts
376
498
  /** The least review time a hand-off needs; with less the request escalates. */
377
499
  const HANDOFF_BUDGET_FLOOR_MS = 15e3;
378
500
  /** A non-Jev model is reported first: no escalationReviewer fixes that. */
@@ -385,8 +507,8 @@ function systemOneRoutingWarnings(config) {
385
507
  const cause = inertCause(config);
386
508
  if (cause === void 0) return [];
387
509
  const warnings = [];
388
- if (config.systemOneEscalation === "reasoning-first") warnings.push(cause === "not-jev" ? "systemOneEscalation \"reasoning-first\" is inactive: the reviewer model is not Jev" : "systemOneEscalation \"reasoning-first\" is inactive: no escalationReviewer is configured; Jev escalations still go to you");
389
- if (config.systemOneDenialReview) warnings.push(cause === "not-jev" ? "systemOneDenialReview is inactive: the reviewer model is not Jev" : "systemOneDenialReview is inactive: no escalationReviewer is configured; Jev denials stay final");
510
+ if (config.systemOneEscalation === "reasoning-first") warnings.push(cause === "not-jev" ? "systemOneEscalation \"reasoning-first\" is inactive: the reviewer model is not a System One model" : "systemOneEscalation \"reasoning-first\" is inactive: no escalationReviewer is configured; System One escalations still go to you");
511
+ if (config.systemOneDenialReview) warnings.push(cause === "not-jev" ? "systemOneDenialReview is inactive: the reviewer model is not a System One model" : "systemOneDenialReview is inactive: no escalationReviewer is configured; System One denials stay final");
390
512
  return warnings;
391
513
  }
392
514
  /** Standard routing hands off too, so neither routing key gates this. The
@@ -397,6 +519,12 @@ function budgetFloorWarnings(config) {
397
519
  if (budget - config.timeoutMs >= 15e3) return [];
398
520
  return [`reviewBudgetMs ${budget} leaves less than ${HANDOFF_BUDGET_FLOOR_MS} ms after timeoutMs; hand-offs to the reasoning reviewer will escalate to you instead`];
399
521
  }
522
+ /** System One is never the escalation reviewer, so only `model` is checked. */
523
+ function systemOneModelWarnings(config) {
524
+ const target = systemOneProviderFor(config.model);
525
+ const warning = target?.provider.configWarning?.(target.modelID);
526
+ return warning === void 0 ? [] : [warning];
527
+ }
400
528
  const PREVIEW_CHARS = 80;
401
529
  /** A warning names the value; it does not reproduce it. */
402
530
  function preview(value) {
@@ -416,6 +544,7 @@ function withSystemOneRoutingWarnings(config, source) {
416
544
  const warnings = [
417
545
  ...invalidValueWarnings(config, source),
418
546
  ...systemOneRoutingWarnings(config),
547
+ ...systemOneModelWarnings(config),
419
548
  ...budgetFloorWarnings(config)
420
549
  ];
421
550
  return warnings.length === 0 ? config : {
@@ -423,8 +552,7 @@ function withSystemOneRoutingWarnings(config, source) {
423
552
  configWarnings: warnings
424
553
  };
425
554
  }
426
- //#endregion
427
- //#region src/modules/config/services/config.ts
555
+ // src/modules/config/services/config.ts
428
556
  const DEFAULT_CONFIG = {
429
557
  model: "openai/gpt-6-luna",
430
558
  variant: "medium",
@@ -487,8 +615,7 @@ function resolveConfig(options) {
487
615
  ...isStringArray(source.configDegraded) && source.configDegraded.length > 0 ? { configDegraded: source.configDegraded } : {}
488
616
  }, source);
489
617
  }
490
- //#endregion
491
- //#region src/utils/descriptor-io.ts
618
+ // src/utils/descriptor-io.ts
492
619
  const O_RDONLY$1 = typeof constants.O_RDONLY === "number" ? constants.O_RDONLY : 0;
493
620
  typeof constants.O_WRONLY === "number" && constants.O_WRONLY;
494
621
  typeof constants.O_CREAT === "number" && constants.O_CREAT;
@@ -512,8 +639,7 @@ function closeQuietly(fd) {
512
639
  closeSync(fd);
513
640
  } catch {}
514
641
  }
515
- //#endregion
516
- //#region src/modules/config/services/jsonc.ts
642
+ // src/modules/config/services/jsonc.ts
517
643
  /** Strict variant used by the config loader: throws on a syntax error or on a
518
644
  * top-level non-object so callers can distinguish a malformed config file
519
645
  * (worth warning about) from a missing one (the common case). */
@@ -584,8 +710,7 @@ function dropTrailingComma(state) {
584
710
  if (j >= 0) state.out = state.out.slice(0, j);
585
711
  state.lastReal = "";
586
712
  }
587
- //#endregion
588
- //#region src/modules/config/services/layer-read.ts
713
+ // src/modules/config/services/layer-read.ts
589
714
  /** Cap on a single config file read: the project layer is repository-controlled
590
715
  * and read at startup, so an unbounded read lets a committed symlink to an
591
716
  * endless source exhaust memory. A file over the cap is treated like any
@@ -670,8 +795,7 @@ function readBytes(fd, length) {
670
795
  const read = readFully(fd, buffer, length, 0);
671
796
  return (read < length ? buffer.subarray(0, read) : buffer).toString("utf8");
672
797
  }
673
- //#endregion
674
- //#region src/utils/is-record.ts
798
+ // src/utils/is-record.ts
675
799
  /** A non-null object that is not an array. */
676
800
  function isRecord(value) {
677
801
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -680,8 +804,7 @@ function isRecord(value) {
680
804
  function asObjectLike(value) {
681
805
  return typeof value === "object" && value !== null ? value : void 0;
682
806
  }
683
- //#endregion
684
- //#region src/modules/config/services/risk-policy-clamp.ts
807
+ // src/modules/config/services/risk-policy-clamp.ts
685
808
  /** Ensure project riskPolicy can only tighten the trusted baseline. */
686
809
  function clampRiskPolicy(project, trusted) {
687
810
  const out = {
@@ -727,8 +850,7 @@ function raisedMinimumConfidence(projectValue, trustedValue) {
727
850
  if (typeof projectValue === "number" && Number.isFinite(projectValue)) return Math.max(trustedMin, projectValue);
728
851
  return trustedMin;
729
852
  }
730
- //#endregion
731
- //#region src/modules/config/services/trust-boundary-keys.ts
853
+ // src/modules/config/services/trust-boundary-keys.ts
732
854
  /** Fields managed by the trust boundary. For these, the boundary's output is
733
855
  * final: the project layer may only tighten them against the trusted
734
856
  * baseline (which already includes inline), and a later inline value must not
@@ -829,8 +951,7 @@ const CONFIDENCE_FLOOR_KEYS = [
829
951
  "systemOneConfidenceThreshold",
830
952
  "systemOneReasoningThreshold"
831
953
  ];
832
- //#endregion
833
- //#region src/modules/config/services/trust-boundary.ts
954
+ // src/modules/config/services/trust-boundary.ts
834
955
  /** Whether the key is present in the layer (a `null`/wrong-type value must be
835
956
  * handled as a present-but-invalid override, never silently forwarded). */
836
957
  function hasKey(object, key) {
@@ -922,8 +1043,7 @@ function combinePolicyRules(clamped, trusted) {
922
1043
  clamped.policyRules = [...Array.isArray(trusted.policyRules) ? trusted.policyRules : [], ...projectRules];
923
1044
  } else if (Array.isArray(trusted.policyRules)) clamped.policyRules = trusted.policyRules;
924
1045
  }
925
- //#endregion
926
- //#region src/modules/config/services/trusted-degradation.ts
1046
+ // src/modules/config/services/trusted-degradation.ts
927
1047
  /** Trusted mode fields and the values resolveConfig honors. A mistyped mode
928
1048
  * silently falls back to the less restrictive default in resolveConfig, so it
929
1049
  * gets the same fail-closed treatment as a dropped rule: visible degradation
@@ -1024,8 +1144,7 @@ function mergeLayers(globalRaw, projectRaw, inline, inlineTrust) {
1024
1144
  function boundaryFields(options) {
1025
1145
  return Object.fromEntries(Object.entries(options).filter(([key]) => TRUST_BOUNDARY_KEYS.has(key)));
1026
1146
  }
1027
- //#endregion
1028
- //#region src/modules/audit/repositories/audit-files.ts
1147
+ // src/modules/audit/repositories/audit-files.ts
1029
1148
  /** Cap on how much of an audit file the summary reader will pull into memory:
1030
1149
  * the file is append-only and grows without bound, and the report only needs
1031
1150
  * the most recent records. When the cap is hit the reader summarizes the tail
@@ -1074,9 +1193,10 @@ function startsAtLineBoundary(fd, offset) {
1074
1193
  return false;
1075
1194
  }
1076
1195
  }
1077
- //#endregion
1078
- //#region src/utils/redact.ts
1196
+ // src/utils/redact.ts
1079
1197
  const REDACT = (type) => `[REDACTED:${type}]`;
1198
+ const OPENCODE_SESSION_KEY = /^(?:session[_-]?id|session|sid)$/i;
1199
+ const OPENCODE_SESSION_ID = /^ses_[0-9a-f]{12}[A-Za-z0-9]{14}(?:[A-Za-z0-9]{6})?$/;
1080
1200
  const RULES = [
1081
1201
  {
1082
1202
  re: /-----BEGIN (?:[A-Z ]*PRIVATE KEY(?: BLOCK)?)-----[\s\S]{0,8192}?-----END (?:[A-Z ]*PRIVATE KEY(?: BLOCK)?)-----/g,
@@ -1098,6 +1218,10 @@ const RULES = [
1098
1218
  re: /\bgithub_pat_[A-Za-z0-9_]{22,251}\b/g,
1099
1219
  replace: () => REDACT("github")
1100
1220
  },
1221
+ {
1222
+ re: /\bsk-or-v1-[0-9a-f]{64}\b/g,
1223
+ replace: () => REDACT("openrouter")
1224
+ },
1101
1225
  {
1102
1226
  re: /\bsk-proj-[A-Za-z0-9_-]{20,}\b/g,
1103
1227
  replace: () => REDACT("openai")
@@ -1134,6 +1258,10 @@ const RULES = [
1134
1258
  re: /\b\d{8,12}:AA[A-Za-z0-9_-]{30,}\b/g,
1135
1259
  replace: () => REDACT("telegram")
1136
1260
  },
1261
+ {
1262
+ re: /\bliquid_[A-Za-z0-9]{32,}\b/g,
1263
+ replace: () => REDACT("liquid")
1264
+ },
1137
1265
  {
1138
1266
  re: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,
1139
1267
  replace: () => REDACT("jwt")
@@ -1163,7 +1291,7 @@ const RULES = [
1163
1291
  },
1164
1292
  {
1165
1293
  re: /(^|_|[^A-Za-z0-9_])(api[_-]?key|access[_-]?token|secret[_-]?key|client[_-]?secret|secret|password|passwd|token|cookie|csrf[_-]?token|session[_-]?id|sessionid|session|sid|private[_-]?key|passphrase|credentials?)(["']?\s*[:=]\s*["']?)(?!\[REDACTED)([^$`{}()\s"'#[\]]{8,})/gi,
1166
- replace: (_m, g) => `${g[0] ?? ""}${g[1] ?? ""}${g[2] ?? ""}${REDACT("credential")}`
1294
+ replace: (m, g) => OPENCODE_SESSION_KEY.test(g[1] ?? "") && OPENCODE_SESSION_ID.test(g[3] ?? "") ? m : `${g[0] ?? ""}${g[1] ?? ""}${g[2] ?? ""}${REDACT("credential")}`
1167
1295
  }
1168
1296
  ];
1169
1297
  function redactSecrets(input) {
@@ -1177,8 +1305,7 @@ function redactSecrets(input) {
1177
1305
  }
1178
1306
  return result;
1179
1307
  }
1180
- //#endregion
1181
- //#region src/modules/audit/services/audit-tally.ts
1308
+ // src/modules/audit/services/audit-tally.ts
1182
1309
  /** The required identity/decision fields every audit record must carry. Used
1183
1310
  * by the report reader to flag truncated or malformed lines. */
1184
1311
  const REQUIRED_AUDIT_FIELDS = [
@@ -1237,8 +1364,7 @@ function tallyRecord(tally, record, lineNo) {
1237
1364
  missing
1238
1365
  });
1239
1366
  }
1240
- //#endregion
1241
- //#region src/modules/audit/services/audit-summary.ts
1367
+ // src/modules/audit/services/audit-summary.ts
1242
1368
  /** The line as a record, or undefined for bad JSON and for a bare primitive,
1243
1369
  * null or array, which are not audit records. */
1244
1370
  function parseAuditLine(line) {
@@ -1324,8 +1450,7 @@ function resolveAuditPath(config) {
1324
1450
  function readAuditSummary(path) {
1325
1451
  return summarizeAuditTail(path, readTail(path));
1326
1452
  }
1327
- //#endregion
1328
- //#region src/modules/audit/controllers/audit-command.ts
1453
+ // src/modules/audit/controllers/audit-command.ts
1329
1454
  async function runAudit(argv) {
1330
1455
  const { values, positionals } = parseArgs({
1331
1456
  args: argv,
@@ -1396,8 +1521,7 @@ function fmtCounts(map) {
1396
1521
  if (entries.length === 0) return "(none)";
1397
1522
  return entries.sort((a, b) => b[1] - a[1]).map(([k, v]) => `${k} ${v}`).join(" | ");
1398
1523
  }
1399
- //#endregion
1400
- //#region src/modules/policy/policy-conditions.ts
1524
+ // src/modules/policy/policy-conditions.ts
1401
1525
  /** Whether every field of a condition matches the observed facts. A missing
1402
1526
  * condition (or `{ always: true }`) is a universal rule: it matches any
1403
1527
  * request, which is why `validateCondition` rejects a condition that
@@ -1438,8 +1562,7 @@ const CAPABILITY_FLAG_FACTS = {
1438
1562
  function capabilityFlagsHold(cond, cap) {
1439
1563
  return CONDITION_FLAG_KEYS.every((flag) => cond[flag] !== true || CAPABILITY_FLAG_FACTS[flag](cap) === true);
1440
1564
  }
1441
- //#endregion
1442
- //#region src/modules/policy/policy-engine.ts
1565
+ // src/modules/policy/policy-engine.ts
1443
1566
  const EFFECT_SEVERITY = {
1444
1567
  deny: 3,
1445
1568
  manual: 2,
@@ -1509,8 +1632,7 @@ function hashEffectivePolicy(rules, config) {
1509
1632
  });
1510
1633
  return createHash("sha256").update(`${rulesCanonical}#${decisionConfig}`).digest("hex").slice(0, 16);
1511
1634
  }
1512
- //#endregion
1513
- //#region src/modules/config/controllers/config-sources.ts
1635
+ // src/modules/config/controllers/config-sources.ts
1514
1636
  function inspectConfigSources(directory) {
1515
1637
  return {
1516
1638
  global: inspectFile(globalConfigPath()),
@@ -1535,8 +1657,7 @@ function inspectFile(path) {
1535
1657
  function sha256hex(value) {
1536
1658
  return createHash("sha256").update(value).digest("hex");
1537
1659
  }
1538
- //#endregion
1539
- //#region src/modules/config/controllers/config-command.ts
1660
+ // src/modules/config/controllers/config-command.ts
1540
1661
  async function runConfig(argv) {
1541
1662
  const { values, positionals } = parseArgs({
1542
1663
  args: argv,
@@ -1574,8 +1695,7 @@ async function runConfig(argv) {
1574
1695
  function redactConfig(config) {
1575
1696
  return config;
1576
1697
  }
1577
- //#endregion
1578
- //#region src/modules/analysis/capability/action-class.ts
1698
+ // src/modules/analysis/capability/action-class.ts
1579
1699
  /** Pick the class when no classifier claimed one, preferring the most
1580
1700
  * specific observed surface. */
1581
1701
  function resolveActionClass(facts) {
@@ -1609,8 +1729,7 @@ function claimClass(facts, actionClass) {
1609
1729
  function claimUnsetClass(facts, actionClass) {
1610
1730
  if (facts.dominantClass === "unknown") claimClass(facts, actionClass);
1611
1731
  }
1612
- //#endregion
1613
- //#region src/modules/analysis/capability/bash-mutation.ts
1732
+ // src/modules/analysis/capability/bash-mutation.ts
1614
1733
  function hasWriteRedirect(redirections) {
1615
1734
  return redirections.some(redirectionWritesPath);
1616
1735
  }
@@ -1684,8 +1803,7 @@ function isLiteralPathValue(value) {
1684
1803
  if (/[$`*?[\]{}]/.test(value)) return false;
1685
1804
  return true;
1686
1805
  }
1687
- //#endregion
1688
- //#region src/modules/analysis/capability/capability-facts.ts
1806
+ // src/modules/analysis/capability/capability-facts.ts
1689
1807
  function newCapabilityFacts() {
1690
1808
  return {
1691
1809
  executesCode: false,
@@ -1721,8 +1839,7 @@ function recordWrite(facts, target, roots) {
1721
1839
  if (cls.workspace) facts.workspaceWrite = true;
1722
1840
  if (cls.external) facts.externalWrite = true;
1723
1841
  }
1724
- //#endregion
1725
- //#region src/modules/analysis/capability/heredoc/heredoc-body-reading.ts
1842
+ // src/modules/analysis/capability/heredoc/heredoc-body-reading.ts
1726
1843
  /** The body as its expansion reads it. Its backslash-newline pairs go
1727
1844
  * first; then, for a `<<-` body (`tabStripped`), every line loses its
1728
1845
  * leading tabs, so a line that continues another keeps its own. */
@@ -1764,8 +1881,7 @@ function bodyTextStep(text, index) {
1764
1881
  if (c === "`" || c === "$" && next === "(") return -1;
1765
1882
  return index + 1;
1766
1883
  }
1767
- //#endregion
1768
- //#region src/modules/analysis/capability/heredoc/heredoc-scripts.ts
1884
+ // src/modules/analysis/capability/heredoc/heredoc-scripts.ts
1769
1885
  /** What a reading that found no heredoc holds. It is shared, never written
1770
1886
  * to. */
1771
1887
  const NO_SCRIPTS = /* @__PURE__ */ new Map();
@@ -1848,8 +1964,7 @@ function addScript(into, placeholder, text) {
1848
1964
  if (held === void 0) into.scripts.set(placeholder, [text]);
1849
1965
  else if (!held.includes(text)) held.push(text);
1850
1966
  }
1851
- //#endregion
1852
- //#region src/utils/invariant.ts
1967
+ // src/utils/invariant.ts
1853
1968
  /** Assert a fact the surrounding code guarantees but the compiler cannot
1854
1969
  * see, such as an index the loop bound keeps in range. A broken guarantee is
1855
1970
  * a bug, so it throws.
@@ -1858,8 +1973,7 @@ function addScript(into, placeholder, text) {
1858
1973
  function invariant(condition, message) {
1859
1974
  if (!condition) throw new Error(message);
1860
1975
  }
1861
- //#endregion
1862
- //#region src/modules/analysis/capability/heredoc/ansi-c-quoting.ts
1976
+ // src/modules/analysis/capability/heredoc/ansi-c-quoting.ts
1863
1977
  /** Unescape an ANSI-C quoted region (`$'...'`), the subset bash defines for
1864
1978
  * here-document delimiter words: standard escapes, `\xHH` hex, and up to
1865
1979
  * three octal digits. Unknown escapes drop the backslash, like bash. A
@@ -2031,8 +2145,7 @@ function digitsAt(text, start, pattern) {
2031
2145
  pattern.lastIndex = start;
2032
2146
  return pattern.exec(text)?.[0] ?? "";
2033
2147
  }
2034
- //#endregion
2035
- //#region src/modules/analysis/shell/shell-lex-state.ts
2148
+ // src/modules/analysis/shell/shell-lex-state.ts
2036
2149
  /** Whether the reading decodes quotes the way bash does. */
2037
2150
  function readsBashQuotes(quoting = "bash") {
2038
2151
  return quoting === "bash" || quoting === "rescan" || quoting === "finder";
@@ -2125,8 +2238,7 @@ function flushSegment(lex, endedBy) {
2125
2238
  for (const segment of lex.substitutions) lex.segments.push(segment);
2126
2239
  lex.substitutions = [];
2127
2240
  }
2128
- //#endregion
2129
- //#region src/modules/analysis/shell/shell-quote-scan.ts
2241
+ // src/modules/analysis/shell/shell-quote-scan.ts
2130
2242
  /** Adds text of the open single quote to the value; an ANSI-C string keeps
2131
2243
  * its text as written until it closes, unless the scan reads it undecoded. */
2132
2244
  function appendQuoted(lex, text) {
@@ -2221,8 +2333,7 @@ function openQuote(lex, c) {
2221
2333
  lex.hasToken = true;
2222
2334
  lex.index += 1;
2223
2335
  }
2224
- //#endregion
2225
- //#region src/utils/element-at.ts
2336
+ // src/utils/element-at.ts
2226
2337
  /** `items[index]` for an index the caller's loop bound keeps in range, in an
2227
2338
  * array that holds no `undefined` elements. A miss is a broken guarantee, so
2228
2339
  * it throws naming the array and the index. The message is built only on
@@ -2232,8 +2343,7 @@ function elementAt(items, index, name) {
2232
2343
  if (item === void 0) invariant(false, `${name}[${index}] is out of bounds (length ${items.length})`);
2233
2344
  return item;
2234
2345
  }
2235
- //#endregion
2236
- //#region src/modules/analysis/capability/heredoc/heredoc-body-text.ts
2346
+ // src/modules/analysis/capability/heredoc/heredoc-body-text.ts
2237
2347
  /** Maximum body bytes retained (bounded + redacted for prompt/audit safety). */
2238
2348
  const MAX_BODY_BYTES = 4096;
2239
2349
  /** Scan the text before a heredoc operator for a trailing `> path` target. */
@@ -2314,8 +2424,7 @@ function containsDynamic(body, expansionDisabled) {
2314
2424
  if (expansionDisabled) return false;
2315
2425
  return /\$\(?|`/.test(body);
2316
2426
  }
2317
- //#endregion
2318
- //#region src/modules/analysis/capability/heredoc/heredoc-body-records.ts
2427
+ // src/modules/analysis/capability/heredoc/heredoc-body-records.ts
2319
2428
  /** Read one pending heredoc's body from `position`, bounded by `limit` when
2320
2429
  * given. Returns it with the index the next text is read from: just past its
2321
2430
  * terminator line, or the bound itself when the body is cut there. */
@@ -2375,8 +2484,7 @@ function bodyRecord(command, start, read, lineEnd, targets) {
2375
2484
  ...outputTarget === void 0 ? {} : { outputTarget }
2376
2485
  };
2377
2486
  }
2378
- //#endregion
2379
- //#region src/modules/analysis/capability/heredoc/heredoc-bodies.ts
2487
+ // src/modules/analysis/capability/heredoc/heredoc-bodies.ts
2380
2488
  function appendText(scan, text) {
2381
2489
  if (text.length === 0) return;
2382
2490
  const last = scan.pieces.at(-1);
@@ -2447,8 +2555,7 @@ function heredocRecord(start, record) {
2447
2555
  dynamic: record.dynamic
2448
2556
  };
2449
2557
  }
2450
- //#endregion
2451
- //#region src/modules/analysis/capability/heredoc/heredoc-word-quotes.ts
2558
+ // src/modules/analysis/capability/heredoc/heredoc-word-quotes.ts
2452
2559
  function scanSingleQuoted(command, scan) {
2453
2560
  const end = command.indexOf("'", scan.index + 1);
2454
2561
  if (end === -1) {
@@ -2511,8 +2618,7 @@ function scanDoubleQuoted(command, scan) {
2511
2618
  function doubleQuotedEscape(escaped) {
2512
2619
  return "$`\"\\".includes(escaped) ? escaped : `\\${escaped}`;
2513
2620
  }
2514
- //#endregion
2515
- //#region src/modules/analysis/capability/heredoc/heredoc-delimiter.ts
2621
+ // src/modules/analysis/capability/heredoc/heredoc-delimiter.ts
2516
2622
  /** Characters that cannot appear unquoted inside a heredoc delimiter word.
2517
2623
  * `$` and backticks are NOT stops: the delimiter word undergoes no
2518
2624
  * expansion, so they are literal terminator characters. */
@@ -2596,8 +2702,7 @@ function scanDelimiterPart(command, scan) {
2596
2702
  scan.index += 1;
2597
2703
  return true;
2598
2704
  }
2599
- //#endregion
2600
- //#region src/modules/analysis/capability/heredoc/heredoc-frame-bounds.ts
2705
+ // src/modules/analysis/capability/heredoc/heredoc-frame-bounds.ts
2601
2706
  /** For each index `p`, the index of the `)` that closes a `(` placed just
2602
2707
  * before `p`: scanning from `p`, the first `)` that leaves no `(` open,
2603
2708
  * skipping quotes and backslash escapes; `-1` when the text ends first.
@@ -2689,8 +2794,7 @@ function innermostLimit(frames) {
2689
2794
  function insideSubstitution(frames) {
2690
2795
  return (frames.at(-1)?.subst ?? -1) >= 0;
2691
2796
  }
2692
- //#endregion
2693
- //#region src/modules/analysis/capability/heredoc/heredoc-frame-links.ts
2797
+ // src/modules/analysis/capability/heredoc/heredoc-frame-links.ts
2694
2798
  /** The frame `spec` makes at stack `index`, with its links taken from the frame
2695
2799
  * below it (already linked). */
2696
2800
  function linkFrame(frames, index, spec) {
@@ -2706,8 +2810,7 @@ function linkFrame(frames, index, spec) {
2706
2810
  function pushFrame(scan, spec) {
2707
2811
  scan.frames.push(linkFrame(scan.frames, scan.frames.length, spec));
2708
2812
  }
2709
- //#endregion
2710
- //#region src/modules/analysis/capability/heredoc/heredoc-scan-context.ts
2813
+ // src/modules/analysis/capability/heredoc/heredoc-scan-context.ts
2711
2814
  /** The constructs that may open, most specific first: `$((` is decided by
2712
2815
  * `openDollarParen` (arithmetic, or a substitution ending at its matched
2713
2816
  * `)`); `((` is arithmetic, where `<<` is a shift, and falls back to two
@@ -2876,8 +2979,7 @@ function openBacktick(scan) {
2876
2979
  });
2877
2980
  scan.i += 1;
2878
2981
  }
2879
- //#endregion
2880
- //#region src/modules/analysis/capability/heredoc/heredoc-frame-starts.ts
2982
+ // src/modules/analysis/capability/heredoc/heredoc-frame-starts.ts
2881
2983
  /** Whether the shell reads no heredoc body at this `<<`. The nearest
2882
2984
  * expansion, substitution or backtick open at the operator decides: an
2883
2985
  * expansion reads `<<` as literal or shift text, while a substitution or
@@ -2945,8 +3047,7 @@ function closeFrame(scan) {
2945
3047
  if (!scan.readAllOperators && (frame.kind === "substitution" || frame.kind === "backtick")) dropSubstitutedStarts(scan, frame);
2946
3048
  return true;
2947
3049
  }
2948
- //#endregion
2949
- //#region src/modules/analysis/capability/heredoc/heredoc-operator-scan.ts
3050
+ // src/modules/analysis/capability/heredoc/heredoc-operator-scan.ts
2950
3051
  function scanNewline(scan) {
2951
3052
  if (scan.pending.length === 0) {
2952
3053
  scan.lineStart = scan.i + 1;
@@ -2998,8 +3099,7 @@ function scanHeredocOperator(scan) {
2998
3099
  scan.cursor = word.wordEnd;
2999
3100
  scan.i = word.wordEnd;
3000
3101
  }
3001
- //#endregion
3002
- //#region src/modules/analysis/capability/heredoc/heredoc-legacy.ts
3102
+ // src/modules/analysis/capability/heredoc/heredoc-legacy.ts
3003
3103
  /** The command with each heredoc body collapsed, as the previous release
3004
3104
  * collapsed it. */
3005
3105
  function legacySanitizedCommand(command) {
@@ -3062,8 +3162,7 @@ function scanArithmetic(scan, c) {
3062
3162
  scan.i += c === "$" ? 3 : 2;
3063
3163
  return true;
3064
3164
  }
3065
- //#endregion
3066
- //#region src/modules/analysis/capability/heredoc/heredoc-extractor.ts
3165
+ // src/modules/analysis/capability/heredoc/heredoc-extractor.ts
3067
3166
  /**
3068
3167
  * Extract every heredoc in `command`, replacing each body with a placeholder
3069
3168
  * `<HEREDOC:sha256:xxxxxxxx>` so the downstream lexer never sees the content.
@@ -3151,8 +3250,7 @@ function scanCharacter(scan) {
3151
3250
  }
3152
3251
  scan.i += 1;
3153
3252
  }
3154
- //#endregion
3155
- //#region src/modules/analysis/capability/heredoc/heredoc-sanitized.ts
3253
+ // src/modules/analysis/capability/heredoc/heredoc-sanitized.ts
3156
3254
  /** `text` with its heredoc bodies collapsed by the current extractor. */
3157
3255
  function sanitizedText(text) {
3158
3256
  const extraction = extractHeredocs(text);
@@ -3163,8 +3261,7 @@ function sanitizedText(text) {
3163
3261
  scripts: extraction.scripts
3164
3262
  };
3165
3263
  }
3166
- //#endregion
3167
- //#region src/modules/analysis/shell/shell-substitution-prefix.ts
3264
+ // src/modules/analysis/shell/shell-substitution-prefix.ts
3168
3265
  /** After a `coproc` name, the start of the compound command it runs. */
3169
3266
  const COMPOUND_START = /(?:(?:case|if|while|until|for|select)(?!\w)|\{|\(|\[\[)/y;
3170
3267
  const TIME_OPTION = /(?:-p|--)(?=[ \t\n]|$)/y;
@@ -3250,8 +3347,7 @@ function skipJoins(text, from) {
3250
3347
  while (text[at] === "\\" && text[at + 1] === "\n") at += 2;
3251
3348
  return at;
3252
3349
  }
3253
- //#endregion
3254
- //#region src/modules/analysis/shell/shell-substitution-heredoc.ts
3350
+ // src/modules/analysis/shell/shell-substitution-heredoc.ts
3255
3351
  /** The `<<` operator at `index`: the heredoc it opens (none for a `<<<`
3256
3352
  * here-string) and the index just past its delimiter word. */
3257
3353
  function heredocOperatorAt(text, index, reading = "default") {
@@ -3325,8 +3421,7 @@ function parenAfter(text, from) {
3325
3421
  while (text[at] === " " || text[at] === " ") at += 1;
3326
3422
  return text[at] === ")" ? at : -1;
3327
3423
  }
3328
- //#endregion
3329
- //#region src/modules/analysis/shell/shell-substitution-words.ts
3424
+ // src/modules/analysis/shell/shell-substitution-words.ts
3330
3425
  /** Words after which a command can still start. */
3331
3426
  const COMMAND_PREFIX_WORDS = /* @__PURE__ */ new Set([
3332
3427
  "then",
@@ -3437,8 +3532,7 @@ function endHeader(scan) {
3437
3532
  function startsSubject(scan, c) {
3438
3533
  if (scan.words === "caseSubject" && !/[\s\w]/.test(c)) scan.words = "caseIn";
3439
3534
  }
3440
- //#endregion
3441
- //#region src/modules/analysis/shell/shell-substitution-text.ts
3535
+ // src/modules/analysis/shell/shell-substitution-text.ts
3442
3536
  function stepCommandText(scan, c) {
3443
3537
  if (c === "\n") {
3444
3538
  skipNewline(scan);
@@ -3509,8 +3603,7 @@ function readHeredocOperator(scan) {
3509
3603
  scan.index = operator.end;
3510
3604
  scan.commandPosition = false;
3511
3605
  }
3512
- //#endregion
3513
- //#region src/modules/analysis/shell/shell-substitution-frames.ts
3606
+ // src/modules/analysis/shell/shell-substitution-frames.ts
3514
3607
  function advance(scan) {
3515
3608
  scan.index += 1;
3516
3609
  return false;
@@ -3587,8 +3680,7 @@ function skipSingleQuoted(scan, ansiC) {
3587
3680
  scan.index = i + 1;
3588
3681
  scan.commandPosition = false;
3589
3682
  }
3590
- //#endregion
3591
- //#region src/modules/analysis/shell/shell-substitution-brace.ts
3683
+ // src/modules/analysis/shell/shell-substitution-brace.ts
3592
3684
  function stepDouble$1(scan, c) {
3593
3685
  return stepQuoted$1(scan, c, "\"", false);
3594
3686
  }
@@ -3623,8 +3715,7 @@ function skip(scan, ansiC) {
3623
3715
  skipSingleQuoted(scan, ansiC);
3624
3716
  return false;
3625
3717
  }
3626
- //#endregion
3627
- //#region src/modules/analysis/shell/shell-pair-text.ts
3718
+ // src/modules/analysis/shell/shell-pair-text.ts
3628
3719
  function lineIndex(text) {
3629
3720
  const index = {
3630
3721
  starts: /* @__PURE__ */ new Map(),
@@ -3730,8 +3821,7 @@ function keywordAt(text, i, word) {
3730
3821
  }
3731
3822
  /** Keywords that a command follows. */
3732
3823
  const LEADS = /(?:^|[\s;&|(])(?:then|do|else|elif|\{|!|time)$/;
3733
- //#endregion
3734
- //#region src/modules/analysis/shell/shell-substitution-pairs.ts
3824
+ // src/modules/analysis/shell/shell-substitution-pairs.ts
3735
3825
  /** What the pair reading is inside: an arithmetic group `(…)`, a `$(…)`
3736
3826
  * body, `"…"`, a backtick body, `'…'`, `$'…'`, `${…}`, `$[…]`, and a
3737
3827
  * `case … esac` in a `$(…)` body, whose patterns end with a `)`. */
@@ -3880,8 +3970,7 @@ function commandClose(read, start) {
3880
3970
  if (c === "#") return at(read, Kind.Command, read.newline);
3881
3971
  return at(read, Kind.Command, start);
3882
3972
  }
3883
- //#endregion
3884
- //#region src/modules/analysis/shell/shell-substitution-groups.ts
3973
+ // src/modules/analysis/shell/shell-substitution-groups.ts
3885
3974
  /**
3886
3975
  * Opens the group that the `(` or `[` at the scan starts, if it starts one:
3887
3976
  * `x=(`, a `[[` at a command position, a `((` the shell pairs as arithmetic,
@@ -3966,8 +4055,7 @@ function endsTest(scan) {
3966
4055
  const { text, index } = scan;
3967
4056
  return text.startsWith("]]", index) && /\s/.test(text.charAt(index - 1)) && (index + 2 >= text.length || /[\s;&|)<>]/.test(text.charAt(index + 2)));
3968
4057
  }
3969
- //#endregion
3970
- //#region src/modules/analysis/shell/shell-substitution-end.ts
4058
+ // src/modules/analysis/shell/shell-substitution-end.ts
3971
4059
  /**
3972
4060
  * Index of the character that closes the substitution whose body starts at
3973
4061
  * `start`: the matching `)` for a `$(` body, the next unescaped backtick for
@@ -4030,8 +4118,7 @@ function stepFrame$1(scan, c, frame) {
4030
4118
  function openGroupAt(scan, c, insideCase) {
4031
4119
  return insideCase && scan.pattern ? void 0 : openGroup(scan, c);
4032
4120
  }
4033
- //#endregion
4034
- //#region src/modules/analysis/shell/shell-substitution-expansion.ts
4121
+ // src/modules/analysis/shell/shell-substitution-expansion.ts
4035
4122
  /** A `${…}` in double quotes holds quoted text and substitutions of its own,
4036
4123
  * so a `}` or `"` inside it does not end the word. Only the shell's reading
4037
4124
  * scans it. A `$` right after another `$` is no start: versions of the shell
@@ -4054,8 +4141,7 @@ function endsDollarPair(command, index) {
4054
4141
  while (command[index - 1 - dollars - slashes] === "\\") slashes += 1;
4055
4142
  return (dollars - slashes % 2) % 2 === 1;
4056
4143
  }
4057
- //#endregion
4058
- //#region src/modules/analysis/shell/shell-substitution.ts
4144
+ // src/modules/analysis/shell/shell-substitution.ts
4059
4145
  /**
4060
4146
  * An unquoted `$(` is not a substitution here: the scanner already splits at
4061
4147
  * its parentheses. `$((…))` is arithmetic, not a command. Heredoc bodies
@@ -4112,8 +4198,7 @@ function dollarParenBody(command, start, reading, scan, probes) {
4112
4198
  const end = opener === "arith" ? substitutionBodyEnd(command, start, "pair", reading, scan, void 0, probes) : close;
4113
4199
  return commandBody(command.slice(start, end), end + 1, reading, true);
4114
4200
  }
4115
- //#endregion
4116
- //#region src/modules/analysis/shell/shell-substitution-arithmetic.ts
4201
+ // src/modules/analysis/shell/shell-substitution-arithmetic.ts
4117
4202
  /** Whether the `$((` at `index` is arithmetic, by the frames the end-finder
4118
4203
  * already closed: its subshell frame closes right before its own. */
4119
4204
  function knownArithmetic(closes, index) {
@@ -4121,8 +4206,7 @@ function knownArithmetic(closes, index) {
4121
4206
  const inner = closes.get(index + 2);
4122
4207
  return outer !== void 0 && inner !== void 0 && outer === inner + 1;
4123
4208
  }
4124
- //#endregion
4125
- //#region src/modules/analysis/capability/heredoc/delimited-substitution-end.ts
4209
+ // src/modules/analysis/capability/heredoc/delimited-substitution-end.ts
4126
4210
  /**
4127
4211
  * The index of the `)` that ends the `$(` whose text starts at `start`, as
4128
4212
  * bash 3.2 finds it when it expands a heredoc body, or -1 when the text
@@ -4258,8 +4342,7 @@ function pastBacktick(text, index) {
4258
4342
  function doubleQuoteEnd(text, start) {
4259
4343
  return delimitedEnd(text, start, "double");
4260
4344
  }
4261
- //#endregion
4262
- //#region src/modules/analysis/capability/heredoc/delimited-arithmetic.ts
4345
+ // src/modules/analysis/capability/heredoc/delimited-arithmetic.ts
4263
4346
  /**
4264
4347
  * Whether bash 3.2 reads the `$((` at `index`, whose `$(` ends at the `)` at
4265
4348
  * `close`, as arithmetic: its text must end with `)` and balance its
@@ -4309,8 +4392,7 @@ function pastArithmeticChar(text, index, c) {
4309
4392
  const end = doubleQuoteEnd(text, index + 1);
4310
4393
  return end < 0 ? text.length : end;
4311
4394
  }
4312
- //#endregion
4313
- //#region src/modules/analysis/capability/heredoc/heredoc-scan-budget.ts
4395
+ // src/modules/analysis/capability/heredoc/heredoc-scan-budget.ts
4314
4396
  /** Text the scans may read, per character of the input they serve, and on
4315
4397
  * top of that. Past it every body still to scan is unresolved. */
4316
4398
  const SCAN_CHARS_PER_CHAR = 32;
@@ -4343,8 +4425,7 @@ function chargeScan(chars) {
4343
4425
  remaining -= chars;
4344
4426
  return remaining >= 0;
4345
4427
  }
4346
- //#endregion
4347
- //#region src/modules/analysis/capability/heredoc/heredoc-body-early-ends.ts
4428
+ // src/modules/analysis/capability/heredoc/heredoc-body-early-ends.ts
4348
4429
  /**
4349
4430
  * The commands an expanded body `text` runs under bash 3.2 that the scan of
4350
4431
  * later releases did not list. That scan listed a substitution for each
@@ -4518,8 +4599,7 @@ function keepCommand(scan, found, backtick) {
4518
4599
  keepBodyScripts(scan, read.scripts);
4519
4600
  scan.unresolved ||= read.bodyUnresolved;
4520
4601
  }
4521
- //#endregion
4522
- //#region src/modules/analysis/capability/heredoc/heredoc-body-collector.ts
4602
+ // src/modules/analysis/capability/heredoc/heredoc-body-collector.ts
4523
4603
  /** Adds commands to `into`, with whether their bodies were unresolved. A
4524
4604
  * collector that is not there is a reading that keeps none. */
4525
4605
  function keepBodyCommands(into, commands, unresolved) {
@@ -4534,8 +4614,7 @@ function addBodyCommands(into, body, tabStripped) {
4534
4614
  keepBodyCommands(into, found.commands, found.unresolved);
4535
4615
  keepBodyScripts(into, found.scripts ?? NO_SCRIPTS);
4536
4616
  }
4537
- //#endregion
4538
- //#region src/modules/analysis/shell/shell-substitution-trust.ts
4617
+ // src/modules/analysis/shell/shell-substitution-trust.ts
4539
4618
  /** The text the heredoc extractor puts in place of a body. A user may type
4540
4619
  * the same text, so it is never taken as proof that a body is gone. */
4541
4620
  const PLACEHOLDER = "<HEREDOC:sha256:";
@@ -4654,8 +4733,7 @@ function commentStart(text, at) {
4654
4733
  if (WORD_END.test(before) || before === "<" || before === ">") return true;
4655
4734
  return text.charAt(at - 2) === "\\" && afterContinuation(text, at);
4656
4735
  }
4657
- //#endregion
4658
- //#region src/modules/analysis/shell/shell-substitution-lex.ts
4736
+ // src/modules/analysis/shell/shell-substitution-lex.ts
4659
4737
  /** Lex the body of a command substitution into segments of its own, under
4660
4738
  * the same budget, and keep the commands its heredocs run. */
4661
4739
  function lexBody(lex, budget, body) {
@@ -4763,8 +4841,7 @@ function jumpPast(lex, budget, body) {
4763
4841
  function lexSubstitution(lex, budget) {
4764
4842
  while (lexOne(lex, budget) && !lex.outOfTokens);
4765
4843
  }
4766
- //#endregion
4767
- //#region src/modules/analysis/shell/shell-scanner.ts
4844
+ // src/modules/analysis/shell/shell-scanner.ts
4768
4845
  const SEPARATORS = /* @__PURE__ */ new Set([
4769
4846
  ";",
4770
4847
  "|",
@@ -4888,8 +4965,7 @@ function lexSegments(command, state = {
4888
4965
  if (!lex.outOfTokens) flushSegment(lex);
4889
4966
  return lex.segments;
4890
4967
  }
4891
- //#endregion
4892
- //#region src/modules/analysis/shell/shell-lexer.ts
4968
+ // src/modules/analysis/shell/shell-lexer.ts
4893
4969
  /** Ceiling on collected effective commands. Command strings can expand
4894
4970
  * combinatorially (a level duplicating its script doubles the output), so
4895
4971
  * past this bound collection stops instead of exhausting time or memory on
@@ -4939,8 +5015,7 @@ function lexSegmentsBounded(command, reading = "default", quoting = "bash") {
4939
5015
  scripts: bodies.scripts ?? NO_SCRIPTS
4940
5016
  };
4941
5017
  }
4942
- //#endregion
4943
- //#region src/modules/analysis/capability/bash-command-tables.ts
5018
+ // src/modules/analysis/capability/bash-command-tables.ts
4944
5019
  const INTERPRETERS = /* @__PURE__ */ new Set([
4945
5020
  "sh",
4946
5021
  "bash",
@@ -5510,8 +5585,7 @@ const CREDENTIAL_READERS = /* @__PURE__ */ new Set([
5510
5585
  "source",
5511
5586
  "."
5512
5587
  ]);
5513
- //#endregion
5514
- //#region src/modules/analysis/capability/bash-facts.ts
5588
+ // src/modules/analysis/capability/bash-facts.ts
5515
5589
  /** Command substitution (`$(...)` or backticks) makes analysis opaque. */
5516
5590
  function hasCommandSubstitution(command) {
5517
5591
  return /\$\(|`/.test(command);
@@ -5555,8 +5629,7 @@ function hasInlineCodeOption(tokens) {
5555
5629
  inline: false
5556
5630
  };
5557
5631
  }
5558
- //#endregion
5559
- //#region src/modules/analysis/capability/capability-report.ts
5632
+ // src/modules/analysis/capability/capability-report.ts
5560
5633
  function staticFlag(flag) {
5561
5634
  return staticFact(flag ? true : "unknown");
5562
5635
  }
@@ -5635,8 +5708,7 @@ function assessmentFrom(parsed, facts) {
5635
5708
  analysisWarnings: warnings
5636
5709
  };
5637
5710
  }
5638
- //#endregion
5639
- //#region src/modules/analysis/capability/read-only-tool-mutations.ts
5711
+ // src/modules/analysis/capability/read-only-tool-mutations.ts
5640
5712
  /** Placeholder target when a mutating form names no operand: conservatively
5641
5713
  * treated as a workspace write (the current directory). */
5642
5714
  const directoryFallback = ".";
@@ -5718,8 +5790,7 @@ function yqMutation(cmd) {
5718
5790
  const targets = cmd.slice(1).map((token) => token.value).filter((value) => !value.startsWith("-"));
5719
5791
  return targets.length > 0 ? { writeTargets: targets } : { writeTargets: [directoryFallback] };
5720
5792
  }
5721
- //#endregion
5722
- //#region src/modules/analysis/capability/executable-recognition.ts
5793
+ // src/modules/analysis/capability/executable-recognition.ts
5723
5794
  /** Effect families that keep a read-only or no-effect executable from
5724
5795
  * counting as read-only. */
5725
5796
  const READ_ONLY_DISQUALIFIERS = [
@@ -5770,8 +5841,7 @@ function classifyRecognition(base, mutatesReadOnlyTool, facts) {
5770
5841
  if ((READ_ONLY_TOOLS.has(base) || NO_EFFECT_BUILTINS.has(base)) && !mutatesReadOnlyTool && !READ_ONLY_DISQUALIFIERS.some((family) => family.has(base))) facts.sawReadOnlyExecutable = true;
5771
5842
  else if (base !== "git" && !RECOGNIZED_FAMILIES.some((family) => family.has(base))) facts.sawUnknownExecutable = true;
5772
5843
  }
5773
- //#endregion
5774
- //#region src/modules/analysis/capability/execution-classifiers.ts
5844
+ // src/modules/analysis/capability/execution-classifiers.ts
5775
5845
  const CHILD_PROCESS_INTERPRETERS = [
5776
5846
  "bun",
5777
5847
  "node",
@@ -5823,8 +5893,7 @@ function classifyPackageManager(cmd, base, facts) {
5823
5893
  if (sub === "run") facts.executesRepositoryCode = true;
5824
5894
  } else facts.networkObserved = true;
5825
5895
  }
5826
- //#endregion
5827
- //#region src/modules/analysis/walk/gnu-long-option-tables.ts
5896
+ // src/modules/analysis/walk/gnu-long-option-tables.ts
5828
5897
  const none = (name) => ({
5829
5898
  name,
5830
5899
  argument: "none"
@@ -5883,8 +5952,7 @@ const ENV_LONG_OPTIONS = [
5883
5952
  none("help"),
5884
5953
  none("version")
5885
5954
  ];
5886
- //#endregion
5887
- //#region src/modules/analysis/walk/gnu-long-options.ts
5955
+ // src/modules/analysis/walk/gnu-long-options.ts
5888
5956
  /** Resolves `--name[=value]` as glibc's getopt_long does; `undefined` means
5889
5957
  * the real tool rejects the token and runs nothing. */
5890
5958
  function resolveGnuLongOption(token, table) {
@@ -5909,8 +5977,7 @@ function uniquePrefix(name, table) {
5909
5977
  const id = first.id ?? first.name;
5910
5978
  return candidates.some((option) => (option.id ?? option.name) !== id || option.argument !== first.argument) ? void 0 : first;
5911
5979
  }
5912
- //#endregion
5913
- //#region src/modules/analysis/shell/shell-lexer-tables.ts
5980
+ // src/modules/analysis/shell/shell-lexer-tables.ts
5914
5981
  const TRANSPARENT_WRAPPERS = /* @__PURE__ */ new Set([
5915
5982
  "sudo",
5916
5983
  "doas",
@@ -6155,8 +6222,7 @@ const SHELL_KEYWORDS = /* @__PURE__ */ new Set([
6155
6222
  "elif",
6156
6223
  "!"
6157
6224
  ]);
6158
- //#endregion
6159
- //#region src/modules/analysis/shell/shell-wrapper-options.ts
6225
+ // src/modules/analysis/shell/shell-wrapper-options.ts
6160
6226
  const ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/;
6161
6227
  const NO_VALUE_OPTIONS = /* @__PURE__ */ new Set();
6162
6228
  /** Skip leading keywords, then leading VAR=value assignments (env-style,
@@ -6244,8 +6310,7 @@ function skipWrapperOption(opt, index, valueOpts) {
6244
6310
  for (let position = 0; position < letters.length; position += 1) if (valueOpts.has(`-${letters.charAt(position)}`)) return position === letters.length - 1 ? index + 2 : index + 1;
6245
6311
  return index + 1;
6246
6312
  }
6247
- //#endregion
6248
- //#region src/modules/analysis/capability/mutation-operands.ts
6313
+ // src/modules/analysis/capability/mutation-operands.ts
6249
6314
  /** A remote operand for rsync-style tools: a URL scheme, or an `host:path`
6250
6315
  * / `user@host:path` shape whose part before the colon is a bare host (no
6251
6316
  * slash), which is exactly how rsync decides local-with-colon vs remote. */
@@ -6325,8 +6390,7 @@ function scanShortOptions(cmd, i, v, valueOpts, scan) {
6325
6390
  }
6326
6391
  return i;
6327
6392
  }
6328
- //#endregion
6329
- //#region src/modules/analysis/capability/file-effect-classifiers.ts
6393
+ // src/modules/analysis/capability/file-effect-classifiers.ts
6330
6394
  function classifyFileWrite(cmd, base, facts, roots) {
6331
6395
  if (!FILE_WRITE_TOOLS.has(base)) return;
6332
6396
  for (const output of fileWriteOutputs(cmd, base)) recordWrite(facts, output, roots);
@@ -6371,8 +6435,7 @@ function classifyDeletion(cmd, base, facts, roots) {
6371
6435
  }
6372
6436
  if (!anyTarget) facts.workspaceWrite = true;
6373
6437
  }
6374
- //#endregion
6375
- //#region src/modules/analysis/git/git-global-options.ts
6438
+ // src/modules/analysis/git/git-global-options.ts
6376
6439
  /** Global options git reads with a separate value (`git.c` `handle_options`).
6377
6440
  * `--super-prefix` is accepted by older Git releases.
6378
6441
  * `--exec-path` takes a value only as `--exec-path=…`. */
@@ -6401,8 +6464,7 @@ function gitSubcommandIndex(values, gitIndex) {
6401
6464
  }
6402
6465
  return values.length;
6403
6466
  }
6404
- //#endregion
6405
- //#region src/modules/analysis/capability/git-subcommand-forms.ts
6467
+ // src/modules/analysis/capability/git-subcommand-forms.ts
6406
6468
  /** Resolve a git subcommand from the token stream, skipping global git
6407
6469
  * options and their separate values (see `src/modules/analysis/git/git-global-options.ts`), so
6408
6470
  * `git -C /repo push` still detects the `push` mutation. */
@@ -6464,8 +6526,7 @@ const GIT_SUBCOMMAND_FORMS = /* @__PURE__ */ new Map([
6464
6526
  ["submodule", submoduleMutates],
6465
6527
  ["symbolic-ref", symbolicRefMutates]
6466
6528
  ]);
6467
- //#endregion
6468
- //#region src/modules/analysis/capability/network-classifiers.ts
6529
+ // src/modules/analysis/capability/network-classifiers.ts
6469
6530
  function classifyNetworkClient(cmd, base, facts) {
6470
6531
  if (!NETWORK_CLIENTS.has(base)) return;
6471
6532
  facts.networkObserved = true;
@@ -6503,8 +6564,7 @@ function classifyGit(cmd, base, facts) {
6503
6564
  else facts.workspaceWrite = true;
6504
6565
  } else if (network) claimClass(facts, "network");
6505
6566
  }
6506
- //#endregion
6507
- //#region src/modules/analysis/capability/process-classifiers.ts
6567
+ // src/modules/analysis/capability/process-classifiers.ts
6508
6568
  function classifyServiceManager(base, facts) {
6509
6569
  if (!SERVICE_MANAGERS.has(base)) return;
6510
6570
  facts.persistence = true;
@@ -6517,8 +6577,7 @@ function classifyPersistenceTool(base, facts) {
6517
6577
  facts.persistence = true;
6518
6578
  facts.childProcesses = true;
6519
6579
  }
6520
- //#endregion
6521
- //#region src/modules/analysis/capability/effective-command-classifiers.ts
6580
+ // src/modules/analysis/capability/effective-command-classifiers.ts
6522
6581
  /** Every classifier runs on every command, in this order: a command can
6523
6582
  * match several (bun is an interpreter and a package manager, rsync a
6524
6583
  * network client and a mutation tool, shred a writer and a deleter). */
@@ -6540,8 +6599,7 @@ function classifyEffectiveCommand(cmd, facts, context) {
6540
6599
  classifyServiceManager(base, facts);
6541
6600
  classifyPersistenceTool(base, facts);
6542
6601
  }
6543
- //#endregion
6544
- //#region src/modules/analysis/capability/segment-heads.ts
6602
+ // src/modules/analysis/capability/segment-heads.ts
6545
6603
  /** Wrappers the walk peels (sudo, nohup, ssh, …) must be detected on the
6546
6604
  * commands it resolves, because `effective` starts at the real executable
6547
6605
  * after peeling. The walk reports each one at every level it re-enters, so
@@ -6574,8 +6632,7 @@ function classifyWrapperHead(head, facts) {
6574
6632
  claimUnsetClass(facts, "remote-operation");
6575
6633
  }
6576
6634
  }
6577
- //#endregion
6578
- //#region src/modules/analysis/shell/shell-token.ts
6635
+ // src/modules/analysis/shell/shell-token.ts
6579
6636
  /** Whether the character at `index` of `token.value` lies in a quoted or
6580
6637
  * escaped span, where it cannot act as a shell operator. Tokens without
6581
6638
  * span information fall back to whole-token conservatism. */
@@ -6685,8 +6742,7 @@ function operatorChars(token) {
6685
6742
  function hasQuotedChar(token) {
6686
6743
  return quotedChars(token).includes(true);
6687
6744
  }
6688
- //#endregion
6689
- //#region src/modules/analysis/capability/sensitive-paths.ts
6745
+ // src/modules/analysis/capability/sensitive-paths.ts
6690
6746
  /** Credential locations as literal path fragments (case-insensitive). */
6691
6747
  const SENSITIVE_PATH$1 = /(?:^|\/)(?:\.env(?:\.|$)|\.ssh(?:\/|$)|\.aws(?:\/|$)|\.config\/gcloud(?:\/|$)|\.config\/gh\/hosts\.yml$|id_(?:rsa|dsa|ecdsa|ed25519)(?:\.pub)?$|credentials(?:\.json)?$|authorized_keys$|known_hosts$|\.npmrc$|\.pypirc$|\.netrc$)/i;
6692
6748
  /** Suffixes that mark a path as a non-secret example or public artifact. */
@@ -6700,8 +6756,7 @@ function isSensitivePathToken(path) {
6700
6756
  if (NON_SECRET_SUFFIX.test(path)) return false;
6701
6757
  return SENSITIVE_PATH$1.test(path);
6702
6758
  }
6703
- //#endregion
6704
- //#region src/modules/analysis/capability/sensitive-path-reads.ts
6759
+ // src/modules/analysis/capability/sensitive-path-reads.ts
6705
6760
  /** A known file reader with a literal credential path operand, or any
6706
6761
  * command with a literal credential path as an input (`<`) redirect target.
6707
6762
  * Wrappers are already peeled in `effective`, so `sudo cat ...` arrives here
@@ -6733,8 +6788,7 @@ function operandReadsCredential(previous, value) {
6733
6788
  if (value.startsWith("<") || value.startsWith(">")) return false;
6734
6789
  return isLiteralPathValue(value) && isSensitivePathToken(value);
6735
6790
  }
6736
- //#endregion
6737
- //#region src/modules/analysis/capability/truncated-segment-heads.ts
6791
+ // src/modules/analysis/capability/truncated-segment-heads.ts
6738
6792
  /** The walk reports no command past its depth or command limits. When one
6739
6793
  * stopped it, each segment's own words are still read for the wrappers
6740
6794
  * they start with, without descending into command strings, so a wrapper
@@ -6766,8 +6820,7 @@ function wrappedCommandIndex(tokens, k, head) {
6766
6820
  function valueAt(tokens, k) {
6767
6821
  return elementAt(tokens, k, "tokens").value;
6768
6822
  }
6769
- //#endregion
6770
- //#region src/modules/analysis/capability/bash-analyzer.ts
6823
+ // src/modules/analysis/capability/bash-analyzer.ts
6771
6824
  /** Analyze a parsed bash command and produce capability facts. */
6772
6825
  function analyzeCapability(parsed, directory, worktree) {
6773
6826
  const facts = newCapabilityFacts();
@@ -6803,8 +6856,7 @@ function recordRedirectionWrites(redirections, facts, roots) {
6803
6856
  function recordHeredocWrites(heredocs, facts, roots) {
6804
6857
  for (const h of heredocs) if (h.outputTarget !== void 0) recordWrite(facts, h.outputTarget, roots);
6805
6858
  }
6806
- //#endregion
6807
- //#region src/modules/analysis/brake/brake-arguments.ts
6859
+ // src/modules/analysis/brake/brake-arguments.ts
6808
6860
  /** A word that reads as an option: a leading `-` with more after it. A lone
6809
6861
  * `-` is an operand. */
6810
6862
  function isOptionWord(value) {
@@ -6814,8 +6866,7 @@ function isOptionWord(value) {
6814
6866
  function isShortCluster(value) {
6815
6867
  return isOptionWord(value) && !value.startsWith("--");
6816
6868
  }
6817
- //#endregion
6818
- //#region src/modules/analysis/shell/shell-command-strings.ts
6869
+ // src/modules/analysis/shell/shell-command-strings.ts
6819
6870
  /** The command string that `script`, a shell or su at `i` runs, or `null`
6820
6871
  * when `base` is none of them or carries none. `script -c/--command '…'`
6821
6872
  * runs a command string through a shell; without it, script just starts an
@@ -6893,8 +6944,7 @@ function shellOptionWidth(t) {
6893
6944
  if (t === "-o" || t === "-O") return 2;
6894
6945
  return (t.startsWith("-") || t.startsWith("+")) && t.length > 1 ? 1 : 0;
6895
6946
  }
6896
- //#endregion
6897
- //#region src/modules/analysis/shell/shell-redirection-operators.ts
6947
+ // src/modules/analysis/shell/shell-redirection-operators.ts
6898
6948
  /** Multi-character operators in match order: the three-character forms
6899
6949
  * first, so `&>>` is never read as `&>`. */
6900
6950
  const REDIRECTION_OPERATORS = [
@@ -6944,8 +6994,7 @@ function redirectionsIn(token) {
6944
6994
  }
6945
6995
  return found;
6946
6996
  }
6947
- //#endregion
6948
- //#region src/modules/analysis/shell/shell-redirections.ts
6997
+ // src/modules/analysis/shell/shell-redirections.ts
6949
6998
  /** The heredoc extractor inserts this inert marker after removing the body.
6950
6999
  * It is evidence metadata, not another input redirection. */
6951
7000
  const HEREDOC_MARKER = /^<HEREDOC:sha256:[a-f0-9]+>$/;
@@ -7070,8 +7119,7 @@ function splitTokens(tokens, split) {
7070
7119
  tokenIndex += 1;
7071
7120
  }
7072
7121
  }
7073
- //#endregion
7074
- //#region src/modules/analysis/shell/shell-script-readers.ts
7122
+ // src/modules/analysis/shell/shell-script-readers.ts
7075
7123
  /** The words `cat` may have and still pass its stdin on as it is. */
7076
7124
  const CAT_PLAIN_WORDS = /* @__PURE__ */ new Set([
7077
7125
  "-u",
@@ -7153,8 +7201,7 @@ function noteLetter(letter, sets, scan) {
7153
7201
  else if (letter === "s") scan.stdinFlag = true;
7154
7202
  else if (letter === "c") scan.command = true;
7155
7203
  }
7156
- //#endregion
7157
- //#region src/modules/analysis/ssh/ssh-value-options.ts
7204
+ // src/modules/analysis/ssh/ssh-value-options.ts
7158
7205
  /** The options of OpenSSH's getopt string (`ssh.c`) that take a value. */
7159
7206
  const SSH_VALUE_LETTERS = new Set("B D E F I J L O P Q R S W b c e i l m o p w".split(" "));
7160
7207
  const SSH_READING = {
@@ -7224,8 +7271,7 @@ function readSshArguments(words, start, reading = SSH_READING) {
7224
7271
  terminated: remote.optionsEnded
7225
7272
  };
7226
7273
  }
7227
- //#endregion
7228
- //#region src/modules/analysis/ssh/ssh-arguments.ts
7274
+ // src/modules/analysis/ssh/ssh-arguments.ts
7229
7275
  /** The options of autossh's getopt string (`autossh.c` OPTION_STRING) that
7230
7276
  * take a value. */
7231
7277
  const AUTOSSH_VALUE_LETTERS = new Set("M b c e i l m o p w D E F I L O Q R S W".split(" "));
@@ -7362,8 +7408,7 @@ function readMoshArguments(words, start) {
7362
7408
  terminated
7363
7409
  };
7364
7410
  }
7365
- //#endregion
7366
- //#region src/modules/analysis/ssh/autossh-permutation.ts
7411
+ // src/modules/analysis/ssh/autossh-permutation.ts
7367
7412
  /** Whether the option word ends in a letter that takes a value, so that
7368
7413
  * its value is the next word. */
7369
7414
  function takesNextWord(word) {
@@ -7402,8 +7447,7 @@ function permuteAutosshWords(words, start) {
7402
7447
  ...words.slice(index)
7403
7448
  ];
7404
7449
  }
7405
- //#endregion
7406
- //#region src/modules/analysis/ssh/ssh-remote-command.ts
7450
+ // src/modules/analysis/ssh/ssh-remote-command.ts
7407
7451
  /** The remote command of the call as one string, or `null` when nothing
7408
7452
  * follows the options and host. */
7409
7453
  function remoteText(values, call) {
@@ -7436,8 +7480,7 @@ function remoteCommandTexts(words, i, base, previous) {
7436
7480
  const old = remoteText(values, readSshArguments(values, i + 1, PREVIOUS_SSH_READING));
7437
7481
  return old === text ? [text] : [text, old];
7438
7482
  }
7439
- //#endregion
7440
- //#region src/modules/analysis/walk/env-long-options.ts
7483
+ // src/modules/analysis/walk/env-long-options.ts
7441
7484
  /** The abbreviated long options of the `env` at `i`, each with its index
7442
7485
  * and the token written in full, so `--arg x` reads as `--argv0 x` and
7443
7486
  * `--split=s` as `--split-string=s`. Option values, ambiguous prefixes and
@@ -7477,8 +7520,7 @@ function fullSpelling(value) {
7477
7520
  if (!long.inlineValue) return `--${long.name}`;
7478
7521
  return `--${long.name}${value.slice(value.indexOf("="))}`;
7479
7522
  }
7480
- //#endregion
7481
- //#region src/modules/analysis/walk/env-split-words.ts
7523
+ // src/modules/analysis/walk/env-split-words.ts
7482
7524
  const ESCAPES = {
7483
7525
  "\"": "\"",
7484
7526
  "#": "#",
@@ -7589,8 +7631,7 @@ function finish(state) {
7589
7631
  function shellQuote(text) {
7590
7632
  return `'${text.replaceAll("'", "'\\''")}'`;
7591
7633
  }
7592
- //#endregion
7593
- //#region src/modules/analysis/walk/env-split-readings.ts
7634
+ // src/modules/analysis/walk/env-split-readings.ts
7594
7635
  /** A first word that, with its quotes and escapes removed, starts with `-`. */
7595
7636
  const OPTION_FIRST = /^\s*['"\\]*-/;
7596
7637
  /** A string and operands the shell and env split into the same words. */
@@ -7619,8 +7660,7 @@ function envSplitReadings(script, operands) {
7619
7660
  }
7620
7661
  return texts;
7621
7662
  }
7622
- //#endregion
7623
- //#region src/modules/analysis/walk/env-split-string.ts
7663
+ // src/modules/analysis/walk/env-split-string.ts
7624
7664
  /** `env -S 'command string'` (or unquoted: `env -S cmd args…`) carries a
7625
7665
  * parsed command line, and any operands after the string are appended to
7626
7666
  * it. The texts `envSplitReadings` makes of the two are what gets
@@ -7685,8 +7725,7 @@ function splitStringOperand(tokens, index) {
7685
7725
  tailIndex: index + 1
7686
7726
  };
7687
7727
  }
7688
- //#endregion
7689
- //#region src/modules/analysis/walk/env-readings.ts
7728
+ // src/modules/analysis/walk/env-readings.ts
7690
7729
  const TABLES = [
7691
7730
  "previous",
7692
7731
  "exact",
@@ -7748,16 +7787,14 @@ function follow(env, words, level, walk, side = false) {
7748
7787
  if (side) walk.walkTail(words, env.resume, level);
7749
7788
  return side ? void 0 : env.resume;
7750
7789
  }
7751
- //#endregion
7752
- //#region src/modules/analysis/walk/operand-tail-index.ts
7790
+ // src/modules/analysis/walk/operand-tail-index.ts
7753
7791
  /** The index where the operand tail of `busybox` or `chroot` at `i` starts,
7754
7792
  * or `undefined` for any other command. */
7755
7793
  function operandTailIndex(words, i, base) {
7756
7794
  if (base === "busybox") return i + 1;
7757
7795
  if (base === "chroot") return chrootCommandIndex(words, i);
7758
7796
  }
7759
- //#endregion
7760
- //#region src/modules/analysis/walk/walk-limits.ts
7797
+ // src/modules/analysis/walk/walk-limits.ts
7761
7798
  /** Ceiling on command-string re-entry (`sh -c`, `env -S`, watch, ssh,
7762
7799
  * busybox, chroot). Deeper nesting than this is not a legitimate review
7763
7800
  * shape; the walk stops descending and the unanalyzed remainder stays the
@@ -7769,8 +7806,7 @@ const MAX_WALK_DEPTH = 32;
7769
7806
  function walkLimitReached(sink, depth) {
7770
7807
  return depth > MAX_WALK_DEPTH || sink.commands.length >= 4096 || sink.budget.remainingCommands <= 0;
7771
7808
  }
7772
- //#endregion
7773
- //#region src/modules/analysis/capability/heredoc/heredoc-string-bodies.ts
7809
+ // src/modules/analysis/capability/heredoc/heredoc-string-bodies.ts
7774
7810
  /** A shell or ssh word in a string: without one, no command in it reads a
7775
7811
  * script from a heredoc. */
7776
7812
  const SCRIPT_READER = /\b(?:sh|bash|zsh|dash|ksh|ash|mksh|ssh|busybox)\b/;
@@ -7784,8 +7820,7 @@ function keepStringBodies(bodies, text) {
7784
7820
  keepBodyScripts(bodies, read.scripts);
7785
7821
  if (read.scripts.size > 0 && SCRIPT_READER.test(read.text)) feedsOf(bodies).commands.push(text);
7786
7822
  }
7787
- //#endregion
7788
- //#region src/modules/analysis/walk/walk-reanalysis.ts
7823
+ // src/modules/analysis/walk/walk-reanalysis.ts
7789
7824
  /** Re-lex a command string for the walk to descend into. Its length is
7790
7825
  * charged to the re-analysis budget first, then each substitution body as it
7791
7826
  * is lexed. The commands its heredoc bodies run go to the budget's `bodies`,
@@ -7811,8 +7846,7 @@ function reanalysisSegments(text, sink) {
7811
7846
  if (lexBudget.tokensRemaining <= 0) sink.truncated = true;
7812
7847
  return segments;
7813
7848
  }
7814
- //#endregion
7815
- //#region src/modules/analysis/walk/watch-command.ts
7849
+ // src/modules/analysis/walk/watch-command.ts
7816
7850
  /** The letters of watch's optstring `+bCcefd::ghq:n:prs:twvx` that take a
7817
7851
  * value: a required one in the rest of the cluster or the next token, and
7818
7852
  * an optional one only in the rest of the cluster. */
@@ -7886,8 +7920,7 @@ function shortStep(opt) {
7886
7920
  exec
7887
7921
  };
7888
7922
  }
7889
- //#endregion
7890
- //#region src/modules/analysis/walk/effective-command-walk.ts
7923
+ // src/modules/analysis/walk/effective-command-walk.ts
7891
7924
  function walk(tokens, sink, inheritedRedirections, depth, remote = false, reading = "both") {
7892
7925
  if (walkLimitReached(sink, depth)) {
7893
7926
  sink.truncated = true;
@@ -7972,8 +8005,7 @@ function walkDeeper(tokens, level) {
7972
8005
  const { sink, redirections, depth, remote, reading } = level;
7973
8006
  walk(tokens, sink, redirections, depth + 1, remote, reading);
7974
8007
  }
7975
- //#endregion
7976
- //#region src/modules/analysis/shell/shell-effective-commands.ts
8008
+ // src/modules/analysis/shell/shell-effective-commands.ts
7977
8009
  function analyzeSegmentRedirections(segment, budget, heads) {
7978
8010
  const sink = {
7979
8011
  ...heads !== void 0 && { heads },
@@ -7995,8 +8027,7 @@ function analyzeSegmentRedirections(segment, budget, heads) {
7995
8027
  stdinShells: sink.stdinShells
7996
8028
  };
7997
8029
  }
7998
- //#endregion
7999
- //#region src/modules/analysis/capability/command-walk.ts
8030
+ // src/modules/analysis/capability/command-walk.ts
8000
8031
  function newWalked() {
8001
8032
  return {
8002
8033
  segments: [],
@@ -8032,8 +8063,7 @@ function walkSegments(segments, budget, into) {
8032
8063
  }
8033
8064
  return stopped;
8034
8065
  }
8035
- //#endregion
8036
- //#region src/modules/analysis/shell/shell-stdin-source.ts
8066
+ // src/modules/analysis/shell/shell-stdin-source.ts
8037
8067
  const PIPE = { kind: "pipe" };
8038
8068
  const OTHER$1 = { kind: "other" };
8039
8069
  const UNRECORDED = { kind: "unrecorded" };
@@ -8100,8 +8130,7 @@ function isDigits(text) {
8100
8130
  function isDigitCode(code) {
8101
8131
  return code >= 48 && code <= 57;
8102
8132
  }
8103
- //#endregion
8104
- //#region src/modules/analysis/shell/shell-script-feeds.ts
8133
+ // src/modules/analysis/shell/shell-script-feeds.ts
8105
8134
  /** The script readings a command's stdin carries. */
8106
8135
  const OTHER = { kind: "other" };
8107
8136
  /** The scripts that run, one feed per distinct reading. */
@@ -8200,8 +8229,7 @@ function readings(source, scripts) {
8200
8229
  fed: true
8201
8230
  };
8202
8231
  }
8203
- //#endregion
8204
- //#region src/modules/analysis/shell/shell-script-feed-input.ts
8232
+ // src/modules/analysis/shell/shell-script-feed-input.ts
8205
8233
  function buildFeedInput(parts, scripts) {
8206
8234
  const producers = segmentProducers(parts.map(({ segment }) => segment), parts.map(({ effective }) => effective.length));
8207
8235
  const effective = [];
@@ -8263,8 +8291,7 @@ function segmentProducers(segments, counts) {
8263
8291
  function isPipe(separator) {
8264
8292
  return separator === "|" || separator === "|&";
8265
8293
  }
8266
- //#endregion
8267
- //#region src/modules/analysis/walk/interpreter-options.ts
8294
+ // src/modules/analysis/walk/interpreter-options.ts
8268
8295
  const INLINE_CODE_OPTIONS = /* @__PURE__ */ new Set([
8269
8296
  "-c",
8270
8297
  "-e",
@@ -8304,8 +8331,7 @@ function runsInlineCode(token, spec) {
8304
8331
  function stopsBeforeTarget(token, interpreter, spec) {
8305
8332
  return isInformationFlag(token, interpreter) || token === "-" || runsInlineCode(token, spec) || token.startsWith("-m") || spec?.bailOptions !== void 0 && matchesOption(token, spec.bailOptions);
8306
8333
  }
8307
- //#endregion
8308
- //#region src/modules/analysis/walk/interpreter-specs.ts
8334
+ // src/modules/analysis/walk/interpreter-specs.ts
8309
8335
  const BUN_SUBCOMMANDS = /* @__PURE__ */ new Set([
8310
8336
  "add",
8311
8337
  "build",
@@ -8413,8 +8439,7 @@ const INTERPRETER_SPECS = {
8413
8439
  ])
8414
8440
  }
8415
8441
  };
8416
- //#endregion
8417
- //#region src/modules/analysis/walk/interpreter-stdin.ts
8442
+ // src/modules/analysis/walk/interpreter-stdin.ts
8418
8443
  /**
8419
8444
  * Whether the interpreter that `words` start with takes its code from stdin:
8420
8445
  * a lone `-` says so, and so does the absence of any operand, with options
@@ -8436,8 +8461,7 @@ function interpreterReadsStdin(words) {
8436
8461
  }
8437
8462
  return true;
8438
8463
  }
8439
- //#endregion
8440
- //#region src/modules/analysis/capability/script-feed-analysis.ts
8464
+ // src/modules/analysis/capability/script-feed-analysis.ts
8441
8465
  const NO_FEEDS$1 = {
8442
8466
  feeds: [],
8443
8467
  unresolved: false,
@@ -8468,8 +8492,7 @@ function runsStdinCode(words) {
8468
8492
  if (!INTERPRETERS.has(head)) return false;
8469
8493
  return STDIN_SCRIPT_SHELLS.has(head) ? shellReadsStdin(words) : interpreterReadsStdin(words);
8470
8494
  }
8471
- //#endregion
8472
- //#region src/modules/analysis/capability/walk-feeds.ts
8495
+ // src/modules/analysis/capability/walk-feeds.ts
8473
8496
  const NO_FEEDS = [];
8474
8497
  /** The scripts the commands of the segments of `text`, walked from part
8475
8498
  * `from` on, read: none without a `<<` in `text`. Their heredocs are read in
@@ -8537,8 +8560,7 @@ function addAll(into, scripts) {
8537
8560
  into.set(placeholder, known);
8538
8561
  }
8539
8562
  }
8540
- //#endregion
8541
- //#region src/modules/analysis/capability/body-command-walk.ts
8563
+ // src/modules/analysis/capability/body-command-walk.ts
8542
8564
  /**
8543
8565
  * Walk the commands that heredoc bodies run, each lexed as a command line of
8544
8566
  * its own, after the command's own. The budget's `bodies` holds those of the
@@ -8615,8 +8637,7 @@ function queueDeeper(queue, commands, feeds, from) {
8615
8637
  });
8616
8638
  return false;
8617
8639
  }
8618
- //#endregion
8619
- //#region src/modules/analysis/capability/command-parser.ts
8640
+ // src/modules/analysis/capability/command-parser.ts
8620
8641
  /** Parse a raw bash command into the reusable structure. */
8621
8642
  function parseCommand(rawCommand) {
8622
8643
  return withScanBudget(rawCommand.length, () => parse(rawCommand));
@@ -8669,8 +8690,7 @@ const ALL_LITERAL = /^(?:'[^']*'|\$'(?:[^'\\]|\\[\s\S])*')+$/;
8669
8690
  function isAllLiteral(raw) {
8670
8691
  return ALL_LITERAL.test(raw);
8671
8692
  }
8672
- //#endregion
8673
- //#region src/modules/analysis/reviewed-command.ts
8693
+ // src/modules/analysis/reviewed-command.ts
8674
8694
  function commandText(request, separator) {
8675
8695
  const { command } = request.metadata;
8676
8696
  if (typeof command === "string" && command.trim() !== "") return command;
@@ -8679,8 +8699,7 @@ function commandText(request, separator) {
8679
8699
  function reviewedCommand(request) {
8680
8700
  return commandText(request, "\n");
8681
8701
  }
8682
- //#endregion
8683
- //#region src/adapters/opencode/v2/permission-codec.ts
8702
+ // src/adapters/opencode/v2/permission-codec.ts
8684
8703
  /** Host action names the reviewer's permission vocabulary spells differently. */
8685
8704
  const REVIEW_PERMISSIONS = /* @__PURE__ */ new Map([["shell", "bash"], ["subagent", "task"]]);
8686
8705
  function exactActionInput(actionInput) {
@@ -8730,8 +8749,7 @@ function normalizeV2Permission(input, scope, actionInput) {
8730
8749
  }
8731
8750
  };
8732
8751
  }
8733
- //#endregion
8734
- //#region src/modules/review/controllers/explain-request.ts
8752
+ // src/modules/review/controllers/explain-request.ts
8735
8753
  function normalizeRequest(value) {
8736
8754
  if (typeof value !== "object" || value === null) return;
8737
8755
  const v = value;
@@ -8775,8 +8793,7 @@ function sessionOf(v) {
8775
8793
  function metadataOf(v) {
8776
8794
  return asObjectLike(v.metadata) ?? {};
8777
8795
  }
8778
- //#endregion
8779
- //#region src/modules/review/controllers/explain-command.ts
8796
+ // src/modules/review/controllers/explain-command.ts
8780
8797
  async function runExplain(argv) {
8781
8798
  const { values } = parseArgs({
8782
8799
  args: argv,
@@ -8859,16 +8876,14 @@ function readStdin$1() {
8859
8876
  process.stdin.on("end", () => resolve(data));
8860
8877
  });
8861
8878
  }
8862
- //#endregion
8863
- //#region src/modules/evidence/files/file-evidence.ts
8879
+ // src/modules/evidence/files/file-evidence.ts
8864
8880
  function sha256(value) {
8865
8881
  return createHash("sha256").update(value).digest("hex");
8866
8882
  }
8867
8883
  function isMissingFile(result) {
8868
8884
  return result.status === "unavailable" && /\bENOENT\b|no such file or directory/i.test(result.reason ?? "");
8869
8885
  }
8870
- //#endregion
8871
- //#region src/modules/evidence/files/evidence-content.ts
8886
+ // src/modules/evidence/files/evidence-content.ts
8872
8887
  const SENSITIVE_CONTENT = /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:sk|nvapi)-[A-Za-z0-9_-]{16,}|\b(?:ghp|gho|ghs|ghr|ghu)_[A-Za-z0-9_-]{16,}|\bgithub_pat_[A-Za-z0-9_-]{16,}|\b(?:api[_-]?key|access[_-]?token|password)\s*[:=]\s*["'][^"'\n]{8,}["']/i;
8873
8888
  async function fillBuffer(handle, buffer) {
8874
8889
  let bytesRead = 0;
@@ -8909,8 +8924,7 @@ function contentEvidence(path, buffer, bytesRead, size, limit) {
8909
8924
  content
8910
8925
  };
8911
8926
  }
8912
- //#endregion
8913
- //#region src/modules/evidence/files/evidence-path-policy.ts
8927
+ // src/modules/evidence/files/evidence-path-policy.ts
8914
8928
  const SENSITIVE_PATH = /(?:^|\/)(?:\.env(?:\.|$)|\.ssh(?:\/|$)|\.aws(?:\/|$)|\.config\/(?:gh|gcloud)(?:\/|$)|id_(?:rsa|dsa|ecdsa|ed25519)(?:\.pub)?$|credentials(?:\.json)?$|authorized_keys$|known_hosts$|\.npmrc$|\.pypirc$|\.netrc$)/i;
8915
8929
  /** Whether `path` equals `root` or lives somewhere below it. */
8916
8930
  function isWithinRoot(path, root) {
@@ -8960,8 +8974,7 @@ function resolvedPathBlock(path, roots, outsideReason) {
8960
8974
  if (!roots.some((root) => isWithinRoot(path, root))) return outsideReason;
8961
8975
  if (SENSITIVE_PATH.test(path)) return "sensitive resolved path";
8962
8976
  }
8963
- //#endregion
8964
- //#region src/modules/evidence/files/evidence-file-reader.ts
8977
+ // src/modules/evidence/files/evidence-file-reader.ts
8965
8978
  const O_RDONLY = typeof constants.O_RDONLY === "number" ? constants.O_RDONLY : 0;
8966
8979
  const O_NOFOLLOW = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
8967
8980
  const O_NONBLOCK = typeof constants.O_NONBLOCK === "number" ? constants.O_NONBLOCK : 0;
@@ -9031,8 +9044,7 @@ async function includeEvidenceFile(source, directory, rootDirectory, worktree, m
9031
9044
  await new Promise((resolveDelay) => setTimeout(resolveDelay, 100));
9032
9045
  return includeFileOnce(source, directory, rootDirectory, worktree, maxChars);
9033
9046
  }
9034
- //#endregion
9035
- //#region src/modules/evidence/ssh/verified-ssh-command.ts
9047
+ // src/modules/evidence/ssh/verified-ssh-command.ts
9036
9048
  /** This exact shell form binds the locally reviewed bytes to the remote ones.
9037
9049
  * The remote hash check runs before the interpreter, even if the file changes
9038
9050
  * between permission review and execution. */
@@ -9040,11 +9052,9 @@ function renderVerifiedSshScriptCommand(input) {
9040
9052
  const remote = `set -eu; f=\$(mktemp /tmp/reviewer-script.XXXXXXXX); cleanup(){ rm -f -- \$f; }; trap cleanup EXIT; cat >\$f; sum=$(sha256sum $f); test \${sum%% *} = ${input.sha256}; ${input.shell} $f`;
9041
9053
  return `cat -- ${input.path} | ssh -T -o BatchMode=yes -o StrictHostKeyChecking=yes -o ConnectTimeout=5${input.port === void 0 ? "" : ` -p ${input.port}`} ${input.destination} '${remote}'`;
9042
9054
  }
9043
- //#endregion
9044
- //#region src/modules/evidence/ssh/verified-ssh-script.ts
9055
+ // src/modules/evidence/ssh/verified-ssh-script.ts
9045
9056
  const VERIFIED_SCRIPT_LIMIT = 65536;
9046
- //#endregion
9047
- //#region src/modules/review/controllers/script-command.ts
9057
+ // src/modules/review/controllers/script-command.ts
9048
9058
  async function runScript(argv) {
9049
9059
  const { values, positionals } = parseArgs({
9050
9060
  args: argv,
@@ -9080,8 +9090,7 @@ async function runScript(argv) {
9080
9090
  }));
9081
9091
  return 0;
9082
9092
  }
9083
- //#endregion
9084
- //#region src/utils/package-json.ts
9093
+ // src/utils/package-json.ts
9085
9094
  /** The CLI runs from `<root>/src/cli` (source) or `<root>/dist` (bundle), so
9086
9095
  * the package root is a different number of levels up in each; walking up
9087
9096
  * works for both. */
@@ -9101,8 +9110,7 @@ function findPackageJson(start) {
9101
9110
  dir = parent;
9102
9111
  }
9103
9112
  }
9104
- //#endregion
9105
- //#region src/cli/init/init-host-version.ts
9113
+ // src/cli/init/init-host-version.ts
9106
9114
  async function runVersionChecks(pkg, binary) {
9107
9115
  const checks = [];
9108
9116
  const bunVer = process.versions.bun ?? process.versions.node ?? "0.0.0";
@@ -9144,8 +9152,7 @@ async function probeOpencodeVersion(binary = "opencode") {
9144
9152
  return;
9145
9153
  }
9146
9154
  }
9147
- //#endregion
9148
- //#region src/modules/status/models/rpc.ts
9155
+ // src/modules/status/models/rpc.ts
9149
9156
  /** Portable, read-only protocol. No UI message can approve a permission. */
9150
9157
  const ReviewerRpc = {
9151
9158
  id: "opencode-permission-reviewer",
@@ -9174,8 +9181,7 @@ const ReviewerRpc = {
9174
9181
  },
9175
9182
  events: { "review.updated": { schema: { type: "object" } } }
9176
9183
  };
9177
- //#endregion
9178
- //#region src/adapters/opencode/v2/connection.ts
9184
+ // src/adapters/opencode/v2/connection.ts
9179
9185
  const LOOPBACK_HOSTS = /* @__PURE__ */ new Set([
9180
9186
  "localhost",
9181
9187
  "127.0.0.1",
@@ -9187,8 +9193,7 @@ function validateHostEndpoint(url) {
9187
9193
  if (endpoint.protocol === "http:" && !LOOPBACK_HOSTS.has(endpoint.hostname)) throw new Error("Reviewer host connections outside loopback require HTTPS");
9188
9194
  return endpoint;
9189
9195
  }
9190
- //#endregion
9191
- //#region src/cli/doctor/doctor-probes.ts
9196
+ // src/cli/doctor/doctor-probes.ts
9192
9197
  /** The reviewer status a running host reports over its RPC route. */
9193
9198
  async function connectedStatus(endpoint, directory) {
9194
9199
  const password = process.env.OPENCODE_PASSWORD ?? process.env.OPENCODE_SERVER_PASSWORD;
@@ -9213,8 +9218,7 @@ async function checkWritable(path) {
9213
9218
  };
9214
9219
  }
9215
9220
  }
9216
- //#endregion
9217
- //#region src/cli/doctor/doctor-report.ts
9221
+ // src/cli/doctor/doctor-report.ts
9218
9222
  function printDoctorHuman(report) {
9219
9223
  const { config, audit } = report;
9220
9224
  console.error(`opencode-permission-reviewer doctor ${report.version.package}`);
@@ -9244,8 +9248,7 @@ function printEntries(label, entries) {
9244
9248
  function fmtSource(s) {
9245
9249
  return `${s.path} exists=${s.exists ? "yes" : "no"} sha256=${s.sha256 ?? "-"}`;
9246
9250
  }
9247
- //#endregion
9248
- //#region src/cli/doctor/doctor-command.ts
9251
+ // src/cli/doctor/doctor-command.ts
9249
9252
  async function runDoctor(argv) {
9250
9253
  const { values } = parseArgs({
9251
9254
  args: argv,
@@ -9319,8 +9322,7 @@ function readPackageJson() {
9319
9322
  engines: found.manifest.engines ?? {}
9320
9323
  };
9321
9324
  }
9322
- //#endregion
9323
- //#region src/cli/init/init-config-read.ts
9325
+ // src/cli/init/init-config-read.ts
9324
9326
  function readConfigFile(path) {
9325
9327
  let fd;
9326
9328
  try {
@@ -9353,8 +9355,7 @@ function parseConfigText(raw) {
9353
9355
  function fingerprintOf(raw) {
9354
9356
  return createHash("sha256").update(raw).digest("hex");
9355
9357
  }
9356
- //#endregion
9357
- //#region src/cli/init/init-entry-match.ts
9358
+ // src/cli/init/init-entry-match.ts
9358
9359
  function isOurEntry(entry, pkg, directory) {
9359
9360
  const head = entryHead(entry);
9360
9361
  if (head === void 0) return false;
@@ -9371,13 +9372,11 @@ function entryHead(entry) {
9371
9372
  if (Array.isArray(entry) && typeof entry[0] === "string") return entry[0];
9372
9373
  if (typeof entry === "object" && entry !== null && "package" in entry && typeof entry.package === "string") return entry.package;
9373
9374
  }
9374
- //#endregion
9375
- //#region src/cli/init/init-types.ts
9375
+ // src/cli/init/init-types.ts
9376
9376
  function pluginKey(host) {
9377
9377
  return host === "v2" ? "plugins" : "plugin";
9378
9378
  }
9379
- //#endregion
9380
- //#region src/cli/init/init-config-files.ts
9379
+ // src/cli/init/init-config-files.ts
9381
9380
  function planFileChange(path, pkg, host = "v1") {
9382
9381
  const snapshot = readConfigFile(path);
9383
9382
  if (snapshot.status === "missing") return {
@@ -9434,8 +9433,7 @@ function backupPath(path) {
9434
9433
  for (let i = 2; existsSync(bak); i++) bak = `${path}.bak-${stamp}-${i}`;
9435
9434
  return bak;
9436
9435
  }
9437
- //#endregion
9438
- //#region src/cli/init/init-config-write.ts
9436
+ // src/cli/init/init-config-write.ts
9439
9437
  /** Copy the current file to a backup name, claiming the destination
9440
9438
  * atomically: when the planned name was taken concurrently, the next free
9441
9439
  * rotation name is used instead of overwriting the collision. Returns the
@@ -9509,8 +9507,7 @@ function overwrite(fd, data) {
9509
9507
  while (written < data.length) written += writeSync(fd, data, written, data.length - written, written);
9510
9508
  fsyncSync(fd);
9511
9509
  }
9512
- //#endregion
9513
- //#region src/cli/init/init-apply.ts
9510
+ // src/cli/init/init-apply.ts
9514
9511
  /** Each plan is re-resolved against the current file before its write, so a
9515
9512
  * file edited or created since planning refuses its write instead of acting
9516
9513
  * on stale assumptions. Returns the process exit code. */
@@ -9547,8 +9544,7 @@ function refusalOf(plan, fresh) {
9547
9544
  if (fresh.action !== plan.action || plan.fingerprint !== void 0 && fresh.fingerprint !== plan.fingerprint) return `init: ${plan.path} changed since planning (was ${plan.action}, now ${fresh.action}); refusing to write`;
9548
9545
  if (fresh.action === "error") return `init: ${plan.path} is malformed or has a non-array "plugin" key; refusing to write`;
9549
9546
  }
9550
- //#endregion
9551
- //#region src/cli/init/init-targets.ts
9547
+ // src/cli/init/init-targets.ts
9552
9548
  function buildEntry(pkg, npm, host) {
9553
9549
  const fromNodeModules = pkg.root.includes(join("node_modules", ""));
9554
9550
  if (npm || fromNodeModules) {
@@ -9587,8 +9583,7 @@ function resolveTargets(directory, forceGlobal, wantTui, host) {
9587
9583
  function pickExisting(candidates) {
9588
9584
  return candidates.find((p) => existsSync(p));
9589
9585
  }
9590
- //#endregion
9591
- //#region src/cli/init/init-plan.ts
9586
+ // src/cli/init/init-plan.ts
9592
9587
  /** Resolves the host, entry and per-file plans, or prints why it cannot and
9593
9588
  * returns the exit code. */
9594
9589
  async function planInit(values, pkg, directory) {
@@ -9636,8 +9631,7 @@ function formatDisagrees(path, host) {
9636
9631
  if (existing.status !== "read") return false;
9637
9632
  return host === "v1" && "plugins" in existing.config || host === "v2" && "plugin" in existing.config;
9638
9633
  }
9639
- //#endregion
9640
- //#region src/cli/init/init-report.ts
9634
+ // src/cli/init/init-report.ts
9641
9635
  function usage$1() {
9642
9636
  return `Usage:
9643
9637
  opencode-permission-reviewer init [--project <dir>] [--global] [--tui]
@@ -9691,8 +9685,7 @@ function printInitHuman(plan, pkg) {
9691
9685
  console.error(` entry: ${JSON.stringify(plan.entry)}`);
9692
9686
  for (const p of plan.plans) console.error(` ${p.path}: ${p.action}`);
9693
9687
  }
9694
- //#endregion
9695
- //#region src/cli/init/init.ts
9688
+ // src/cli/init/init.ts
9696
9689
  /** `init` subcommand: register the plugin in an OpenCode config file.
9697
9690
  *
9698
9691
  * Detects the active OpenCode config (global or project), generates the plugin
@@ -9787,8 +9780,7 @@ function readPackageInfo() {
9787
9780
  async function readStdin() {
9788
9781
  return new Response(await Bun.stdin.text()).text();
9789
9782
  }
9790
- //#endregion
9791
- //#region src/cli/explain.ts
9783
+ // src/cli/explain.ts
9792
9784
  if (import.meta.main) {
9793
9785
  const code = await runCli(process.argv.slice(2));
9794
9786
  process.exit(code);
@@ -9828,5 +9820,4 @@ function usage() {
9828
9820
  opencode-permission-reviewer audit report [--path <file>] [--project <dir>] [--json]
9829
9821
  opencode-permission-reviewer script command --file <path> --host <host> [--port <port>] [--shell bash|sh]`;
9830
9822
  }
9831
- //#endregion
9832
9823
  export { runCli };