@noppu-labs/opencode-permission-reviewer 3.5.0 → 3.7.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/CHANGELOG.md +63 -0
- package/README.md +2 -2
- package/dist/explain.js +270 -20
- package/dist/index.js +316 -47
- package/dist/tui/modules/config/models/openrouter-decision-models.ts +5 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,69 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.7.0] - 2026-11-27
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **Breaking:** the TUI runtime dependencies move from OpenTUI 0.8 to 0.9. `@opentui/core` and
|
|
15
|
+
`@opentui/solid` are pinned at 0.9.9. `solid-js` stays at 1.9.18, inside the `^1.9.12` that
|
|
16
|
+
`@opentui/solid` 0.9.9 peers. Installs that pin `@opentui/*` themselves, or that run the plugin
|
|
17
|
+
beside another that expects OpenTUI 0.8, must move with it to keep a single Solid runtime. The
|
|
18
|
+
supported host ranges and the minimum Bun (1.3.14) are unchanged.
|
|
19
|
+
- The real-host matrix adds OpenCode 1.19.6 and 2.4.2, the latest V1 and V2 releases. 1.19.6 is
|
|
20
|
+
the first verified host on the 1.19 line.
|
|
21
|
+
- The real-host matrix in CI now runs the minimum and the latest release of each line, plus V2
|
|
22
|
+
2.2.5 for OpenTUI 0.8. V1 1.18.30 through 1.18.32 and 1.18.35 leave the matrix. V2 2.0.26, 2.1.2
|
|
23
|
+
and 2.2.0 move to the on-demand window (`tests/compatibility/verify-v2-window.ts`). The verified
|
|
24
|
+
references are now 1.19.6 and 2.4.2. The supported ranges are unchanged.
|
|
25
|
+
- Bumped the runtime dependency `@opencode/client` and the dev dependency `@opencode/plugin` to
|
|
26
|
+
2.4.2, with `bun.lock` synchronized.
|
|
27
|
+
- The OpenRouter decision model list adds `baseten/bison-1`, `baseten/groundhog-1`, `liquid/d1.2`,
|
|
28
|
+
`liquid/d1.2-ultra` and `microsoft/microsoft-decision-1.1`, and drops `liquid/d1`. The new
|
|
29
|
+
models are unbenchmarked, so selecting one raises a config notice
|
|
30
|
+
([Reviewer models](docs/REVIEWER-MODELS.md#openrouter)).
|
|
31
|
+
|
|
32
|
+
### Security
|
|
33
|
+
|
|
34
|
+
- Consumer installs no longer carry `glob` 9.3.5 and `minimatch` 8.0.7, which had the moderate
|
|
35
|
+
GHSA-3g3m-2fjr-6pw4 and GHSA-g3hv-75wg-m249. They came in through `@opentui/solid`'s
|
|
36
|
+
`babel-plugin-module-resolver`, which `@opentui/solid` dropped in 0.9.8. `npm audit` over a
|
|
37
|
+
consumer install of the tarball reports no advisory. The root `overrides` stay for the dev
|
|
38
|
+
dependency `@opencode/plugin`
|
|
39
|
+
([Supply chain](docs/SUPPLY-CHAIN.md#known-residual-exposure),
|
|
40
|
+
[#128](https://github.com/noppu-labs/opencode-permission-reviewer/issues/128)).
|
|
41
|
+
- The audit no longer ignores GHSA-fc5q-39xc-vjpf (`picomatch`), which GitHub withdrew
|
|
42
|
+
([#154](https://github.com/noppu-labs/opencode-permission-reviewer/issues/154)).
|
|
43
|
+
|
|
44
|
+
## [3.6.0] - 2026-11-19
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
|
|
48
|
+
- Answers to agent ask dialogs reach the reviewer with a full UTC timestamp
|
|
49
|
+
(`[2026-09-01T12:01:03Z]`) instead of the time of day only, so answers given on different days of
|
|
50
|
+
a long session no longer look alike.
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- The V1 entrypoint refuses to load on a host that reports an OpenCode V2 version, and logs why
|
|
55
|
+
even without `debug`. Its reviewer isolation is a single-file plugin, which V2 does not load, so
|
|
56
|
+
every review used to fail closed with no visible cause. The message points at the V2 `"plugins"`
|
|
57
|
+
key.
|
|
58
|
+
|
|
59
|
+
### Security
|
|
60
|
+
|
|
61
|
+
- Tools that usually only read are no longer labeled read-only when the command writes a file or
|
|
62
|
+
runs a program. Before, a policy rule on workspace writes or code execution did not match these
|
|
63
|
+
forms, and the reviewer was told the command only read.
|
|
64
|
+
- `sort` reads `-o` inside a short-option cluster (`sort -uo FILE`, `-nruoFILE`) and as an
|
|
65
|
+
abbreviated long option (`--out=FILE`). `--compress-program` counts as code execution.
|
|
66
|
+
- `uniq` and `xxd` report their second operand as a write.
|
|
67
|
+
- `tree` reports `-o FILE`, including after an attached level (`-L2 -o FILE`), and `-R`, which
|
|
68
|
+
writes a listing into each directory it visits.
|
|
69
|
+
- `yq` reports `-i` inside a flag cluster (`-iP`) or with a value (`--inplace=true`), and
|
|
70
|
+
`-s`/`--split-exp`, which writes a file per result. With `--security-allow-write-any-path`,
|
|
71
|
+
the write can land outside the workspace.
|
|
72
|
+
|
|
10
73
|
## [3.5.0] - 2026-11-19
|
|
11
74
|
|
|
12
75
|
### Changed
|
package/README.md
CHANGED
|
@@ -44,8 +44,8 @@ on Noppu Labs' AI Toolkit site.
|
|
|
44
44
|
## Requirements
|
|
45
45
|
|
|
46
46
|
- [Bun](https://bun.sh) >= 1.3.14
|
|
47
|
-
- [OpenCode](https://opencode.ai) V1 `>=1.18.29 <2` (tested
|
|
48
|
-
(tested
|
|
47
|
+
- [OpenCode](https://opencode.ai) V1 `>=1.18.29 <2` (tested up to 1.19.6) or V2 `>=2.0.22 <3`
|
|
48
|
+
(tested up to 2.4.2)
|
|
49
49
|
- `git` on `PATH`, used only for read-only Git enrichment. Without it, the reviewer gets no Git
|
|
50
50
|
snapshot.
|
|
51
51
|
- A reviewer model: either a model configured in OpenCode that follows JSON schemas reliably, or
|
package/dist/explain.js
CHANGED
|
@@ -325,7 +325,9 @@ function resolveMinimumConfidence(value) {
|
|
|
325
325
|
// src/modules/config/models/openrouter-decision-models.ts
|
|
326
326
|
const OPENROUTER_DECISION_MODELS = {
|
|
327
327
|
models: {
|
|
328
|
+
"baseten/bison-1": { benchmarked: false },
|
|
328
329
|
"baseten/elephant-1": { benchmarked: false },
|
|
330
|
+
"baseten/groundhog-1": { benchmarked: false },
|
|
329
331
|
"baseten/joey-1": { benchmarked: false },
|
|
330
332
|
"baseten/mammoth-1": { benchmarked: false },
|
|
331
333
|
"cloudflare/clairic": { benchmarked: false },
|
|
@@ -336,10 +338,12 @@ const OPENROUTER_DECISION_MODELS = {
|
|
|
336
338
|
"heygen/heygen-decision-1": { benchmarked: false },
|
|
337
339
|
"heygen/heygen-decision-1-turbo": { benchmarked: false },
|
|
338
340
|
"jaredpalmer/kev-4b": { benchmarked: false },
|
|
339
|
-
"liquid/d1": { benchmarked: true },
|
|
340
341
|
"liquid/d1-ultra": { benchmarked: true },
|
|
341
342
|
"liquid/d1.1": { benchmarked: false },
|
|
343
|
+
"liquid/d1.2": { benchmarked: false },
|
|
344
|
+
"liquid/d1.2-ultra": { benchmarked: false },
|
|
342
345
|
"microsoft/microsoft-decision-1": { benchmarked: false },
|
|
346
|
+
"microsoft/microsoft-decision-1.1": { benchmarked: false },
|
|
343
347
|
"morph/reflex": { benchmarked: false },
|
|
344
348
|
"nace-ai/drex-max": { benchmarked: false },
|
|
345
349
|
"nace-ai/drex-max-finance": { benchmarked: false },
|
|
@@ -5850,13 +5854,275 @@ function assessmentFrom(parsed, facts) {
|
|
|
5850
5854
|
analysisWarnings: warnings
|
|
5851
5855
|
};
|
|
5852
5856
|
}
|
|
5857
|
+
// src/modules/analysis/capability/getopt-long-option.ts
|
|
5858
|
+
/** A getopt_long option word: `--name` or `--name=value`, where `name` may be
|
|
5859
|
+
* any unambiguous prefix of the full option name. `minimum` is the length of
|
|
5860
|
+
* the shortest such prefix, `--` included, so a shorter prefix that another
|
|
5861
|
+
* option of the same tool shares never matches. */
|
|
5862
|
+
function longOption$1(value, name, minimum) {
|
|
5863
|
+
if (!value.startsWith("--")) return void 0;
|
|
5864
|
+
const equals = value.indexOf("=");
|
|
5865
|
+
const word = equals === -1 ? value : value.slice(0, equals);
|
|
5866
|
+
if (word.length < minimum || !name.startsWith(word)) return void 0;
|
|
5867
|
+
return equals === -1 ? {} : { inline: value.slice(equals + 1) };
|
|
5868
|
+
}
|
|
5869
|
+
// src/modules/analysis/capability/output-operand-mutations.ts
|
|
5870
|
+
/** uniq's long options with a required value, with the length of each one's
|
|
5871
|
+
* shortest unambiguous prefix. */
|
|
5872
|
+
const UNIQ_VALUED_LONG = [
|
|
5873
|
+
["--skip-fields", 8],
|
|
5874
|
+
["--skip-chars", 8],
|
|
5875
|
+
["--check-chars", 4]
|
|
5876
|
+
];
|
|
5877
|
+
const UNIQ_OPTIONS = {
|
|
5878
|
+
takesNextWord(value) {
|
|
5879
|
+
if (value.startsWith("--")) return !value.includes("=") && UNIQ_VALUED_LONG.some(([name, minimum]) => longOption$1(value, name, minimum) !== void 0);
|
|
5880
|
+
const at = value.slice(1).search(/[fsw]/);
|
|
5881
|
+
return at !== -1 && at + 2 === value.length;
|
|
5882
|
+
},
|
|
5883
|
+
permute: true
|
|
5884
|
+
};
|
|
5885
|
+
/** xxd's options that take a value, by letter, with the tails of their long
|
|
5886
|
+
* spellings (`-c`, `-cols`). Such a word takes the next word as its value;
|
|
5887
|
+
* any other text after the letter is the value itself (`-c8`). */
|
|
5888
|
+
const XXD_VALUED = /* @__PURE__ */ new Map([
|
|
5889
|
+
["c", ["ols"]],
|
|
5890
|
+
["g", ["roup"]],
|
|
5891
|
+
["o", ["ffset"]],
|
|
5892
|
+
["s", ["kip", "eek"]],
|
|
5893
|
+
["l", ["en"]],
|
|
5894
|
+
["n", ["ame"]],
|
|
5895
|
+
["R", []]
|
|
5896
|
+
]);
|
|
5897
|
+
const XXD_OPTIONS = {
|
|
5898
|
+
takesNextWord(value) {
|
|
5899
|
+
const word = value.startsWith("--") && value.length > 2 ? value.slice(1) : value;
|
|
5900
|
+
const rest = word.slice(2);
|
|
5901
|
+
if (word.charAt(1) === "c" && rest.startsWith("apitalize")) return false;
|
|
5902
|
+
const tails = XXD_VALUED.get(word.charAt(1));
|
|
5903
|
+
if (tails === void 0) return false;
|
|
5904
|
+
return rest === "" || tails.some((tail) => rest.startsWith(tail));
|
|
5905
|
+
},
|
|
5906
|
+
permute: false
|
|
5907
|
+
};
|
|
5908
|
+
/** `TOOL [OPTION]... [INPUT [OUTPUT]]` (uniq, xxd): a second operand is a file
|
|
5909
|
+
* the command writes ("-" is standard output). */
|
|
5910
|
+
function outputOperandMutation(cmd, tool) {
|
|
5911
|
+
const output = operandsOf(cmd, tool)[1];
|
|
5912
|
+
return output !== void 0 && output !== "-" ? { writeTargets: [output] } : void 0;
|
|
5913
|
+
}
|
|
5914
|
+
function operandsOf(cmd, tool) {
|
|
5915
|
+
const operands = [];
|
|
5916
|
+
let options = true;
|
|
5917
|
+
for (let index = 1; index < cmd.length; index += 1) {
|
|
5918
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
5919
|
+
if (options && value === "--") options = false;
|
|
5920
|
+
else if (options && value.startsWith("-") && value !== "-") {
|
|
5921
|
+
if (tool.takesNextWord(value)) index += 1;
|
|
5922
|
+
} else {
|
|
5923
|
+
operands.push(value);
|
|
5924
|
+
options &&= tool.permute;
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
return operands;
|
|
5928
|
+
}
|
|
5929
|
+
// src/modules/analysis/capability/sort-mutation.ts
|
|
5930
|
+
/** GNU sort short options that take a value. The value is the rest of the
|
|
5931
|
+
* cluster, or the next word when the letter ends it. */
|
|
5932
|
+
const SORT_VALUED_LETTERS = "kotST";
|
|
5933
|
+
/** GNU sort: `-o FILE` writes FILE and `--compress-program=PROG` runs PROG.
|
|
5934
|
+
* Short options cluster getopt-style (`-uo FILE`, `-nruoFILE`), and long
|
|
5935
|
+
* options may be abbreviated (`--out=FILE`). */
|
|
5936
|
+
function sortMutation(cmd) {
|
|
5937
|
+
const result = { writeTargets: [] };
|
|
5938
|
+
let index = 1;
|
|
5939
|
+
while (index < cmd.length) {
|
|
5940
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
5941
|
+
if (value === "--") break;
|
|
5942
|
+
index += value.startsWith("--") ? sortLongOption(cmd, index, result) : sortShortOptions(cmd, index, result);
|
|
5943
|
+
}
|
|
5944
|
+
return result.writeTargets.length > 0 || result.executesCode === true ? result : void 0;
|
|
5945
|
+
}
|
|
5946
|
+
/** Record a long option's effect; returns the words it spans. */
|
|
5947
|
+
function sortLongOption(cmd, index, result) {
|
|
5948
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
5949
|
+
const output = longOption$1(value, "--output", 3);
|
|
5950
|
+
if (output !== void 0) {
|
|
5951
|
+
const target = output.inline ?? cmd[index + 1]?.value;
|
|
5952
|
+
if (target !== void 0) result.writeTargets.push(target);
|
|
5953
|
+
return output.inline === void 0 ? 2 : 1;
|
|
5954
|
+
}
|
|
5955
|
+
if (longOption$1(value, "--compress-program", 4) !== void 0) result.executesCode = true;
|
|
5956
|
+
return 1;
|
|
5957
|
+
}
|
|
5958
|
+
/** Record a short-option cluster's output file; returns the words it spans. */
|
|
5959
|
+
function sortShortOptions(cmd, index, result) {
|
|
5960
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
5961
|
+
if (!value.startsWith("-") || value === "-") return 1;
|
|
5962
|
+
for (let at = 1; at < value.length; at += 1) {
|
|
5963
|
+
const letter = value.charAt(at);
|
|
5964
|
+
if (!SORT_VALUED_LETTERS.includes(letter)) continue;
|
|
5965
|
+
const attached = value.slice(at + 1);
|
|
5966
|
+
const argument = attached === "" ? cmd[index + 1]?.value : attached;
|
|
5967
|
+
if (letter === "o" && argument !== void 0) result.writeTargets.push(argument);
|
|
5968
|
+
return attached === "" ? 2 : 1;
|
|
5969
|
+
}
|
|
5970
|
+
return 1;
|
|
5971
|
+
}
|
|
5972
|
+
// src/modules/analysis/capability/tree-mutation.ts
|
|
5973
|
+
/** tree's short options whose value is the next unused word. `-L` also takes
|
|
5974
|
+
* its value as digits attached inside the cluster (`-L2`). */
|
|
5975
|
+
const TREE_VALUED_LETTERS = /* @__PURE__ */ new Set([
|
|
5976
|
+
"L",
|
|
5977
|
+
"P",
|
|
5978
|
+
"I",
|
|
5979
|
+
"H",
|
|
5980
|
+
"T",
|
|
5981
|
+
"o"
|
|
5982
|
+
]);
|
|
5983
|
+
/** tree's long options with a value, which is inline (`--sort=name`) or the
|
|
5984
|
+
* next word. tree matches each by prefix. */
|
|
5985
|
+
const TREE_VALUED_LONG = [
|
|
5986
|
+
"--authority",
|
|
5987
|
+
"--charset",
|
|
5988
|
+
"--compress",
|
|
5989
|
+
"--filelimit",
|
|
5990
|
+
"--gitfile",
|
|
5991
|
+
"--hintro",
|
|
5992
|
+
"--houtro",
|
|
5993
|
+
"--infofile",
|
|
5994
|
+
"--scheme",
|
|
5995
|
+
"--sort",
|
|
5996
|
+
"--timefmt"
|
|
5997
|
+
];
|
|
5998
|
+
/** tree: `-o FILE` writes FILE, and `-R` writes an `00Tree.html` listing into
|
|
5999
|
+
* each directory it visits. Options may follow the roots. */
|
|
6000
|
+
function treeMutation(cmd) {
|
|
6001
|
+
const scan = {
|
|
6002
|
+
roots: [],
|
|
6003
|
+
outputs: [],
|
|
6004
|
+
recursive: false
|
|
6005
|
+
};
|
|
6006
|
+
let index = 1;
|
|
6007
|
+
while (index < cmd.length) {
|
|
6008
|
+
if (elementAt(cmd, index, "cmd").value === "--") {
|
|
6009
|
+
scan.roots.push(...cmd.slice(index + 1).map((token) => token.value));
|
|
6010
|
+
break;
|
|
6011
|
+
}
|
|
6012
|
+
index += treeWord(cmd, index, scan);
|
|
6013
|
+
}
|
|
6014
|
+
const writeTargets = [...scan.outputs];
|
|
6015
|
+
if (scan.recursive) writeTargets.push(...scan.roots.length > 0 ? scan.roots : ["."]);
|
|
6016
|
+
return writeTargets.length > 0 ? { writeTargets } : void 0;
|
|
6017
|
+
}
|
|
6018
|
+
/** Scan the word at `index`; returns the words it spans. */
|
|
6019
|
+
function treeWord(cmd, index, scan) {
|
|
6020
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
6021
|
+
if (value.startsWith("--")) return TREE_VALUED_LONG.some((name) => value.startsWith(name) && value.charAt(name.length) !== "=") ? 2 : 1;
|
|
6022
|
+
if (!value.startsWith("-") || value === "-") {
|
|
6023
|
+
scan.roots.push(value);
|
|
6024
|
+
return 1;
|
|
6025
|
+
}
|
|
6026
|
+
return 1 + treeShortOptions(cmd, index, scan);
|
|
6027
|
+
}
|
|
6028
|
+
/** Scan a short-option cluster. Each letter that takes a value consumes the
|
|
6029
|
+
* next unused word, in order (`-Lo 2 out.txt`). Returns how many it used. */
|
|
6030
|
+
function treeShortOptions(cmd, index, scan) {
|
|
6031
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
6032
|
+
let consumed = 0;
|
|
6033
|
+
let at = 1;
|
|
6034
|
+
while (at < value.length) {
|
|
6035
|
+
const letter = value.charAt(at);
|
|
6036
|
+
const digits = letter === "L" ? attachedDigits(value, at + 1) : 0;
|
|
6037
|
+
if (letter === "R") scan.recursive = true;
|
|
6038
|
+
else if (digits === 0 && TREE_VALUED_LETTERS.has(letter)) {
|
|
6039
|
+
consumed += 1;
|
|
6040
|
+
recordTreeValue(letter, cmd[index + consumed]?.value, scan);
|
|
6041
|
+
}
|
|
6042
|
+
at += 1 + digits;
|
|
6043
|
+
}
|
|
6044
|
+
return consumed;
|
|
6045
|
+
}
|
|
6046
|
+
/** How many digits start `value` at `from`. */
|
|
6047
|
+
function attachedDigits(value, from) {
|
|
6048
|
+
return value.slice(from).match(/^\d*/)?.[0].length ?? 0;
|
|
6049
|
+
}
|
|
6050
|
+
function recordTreeValue(letter, argument, scan) {
|
|
6051
|
+
if (letter === "o" && argument !== void 0) scan.outputs.push(argument);
|
|
6052
|
+
}
|
|
6053
|
+
// src/modules/analysis/capability/yq-mutation.ts
|
|
6054
|
+
/** yq's short flags that take a value. The value is the rest of the cluster,
|
|
6055
|
+
* so a later letter is not a flag (`-oi` is output format "i"). */
|
|
6056
|
+
const YQ_VALUED_LETTERS = "poIsf";
|
|
6057
|
+
/** The values a Go boolean flag parses as false. */
|
|
6058
|
+
const FALSE_VALUES = /* @__PURE__ */ new Set([
|
|
6059
|
+
"0",
|
|
6060
|
+
"f",
|
|
6061
|
+
"F",
|
|
6062
|
+
"false",
|
|
6063
|
+
"FALSE",
|
|
6064
|
+
"False"
|
|
6065
|
+
]);
|
|
6066
|
+
/** yq: `-i` rewrites its file operands, and `-s` writes a file per result.
|
|
6067
|
+
* For an in-place edit every non-option word, the expression included, is
|
|
6068
|
+
* recorded as a write target. */
|
|
6069
|
+
function yqMutation(cmd) {
|
|
6070
|
+
const writes = yqWrites(cmd);
|
|
6071
|
+
const writeTargets = [];
|
|
6072
|
+
if (writes.inPlace) writeTargets.push(...cmd.slice(1).map((token) => token.value).filter((value) => !value.startsWith("-")));
|
|
6073
|
+
if (writes.split) writeTargets.push(writes.anyPath ? "/" : ".");
|
|
6074
|
+
if (writes.inPlace && writeTargets.length === 0) writeTargets.push(".");
|
|
6075
|
+
return writeTargets.length > 0 ? { writeTargets } : void 0;
|
|
6076
|
+
}
|
|
6077
|
+
/** Scan yq's flags (pflag syntax: no abbreviations, booleans may carry
|
|
6078
|
+
* `=value`, short booleans cluster). */
|
|
6079
|
+
function yqWrites(cmd) {
|
|
6080
|
+
const writes = {
|
|
6081
|
+
inPlace: false,
|
|
6082
|
+
split: false,
|
|
6083
|
+
anyPath: false
|
|
6084
|
+
};
|
|
6085
|
+
for (const token of cmd.slice(1)) {
|
|
6086
|
+
const value = token.value;
|
|
6087
|
+
if (value === "--") break;
|
|
6088
|
+
if (value.startsWith("--")) yqLongFlag(value, writes);
|
|
6089
|
+
else if (value.startsWith("-")) yqShortFlags(value, writes);
|
|
6090
|
+
}
|
|
6091
|
+
return writes;
|
|
6092
|
+
}
|
|
6093
|
+
function yqLongFlag(value, writes) {
|
|
6094
|
+
const equals = value.indexOf("=");
|
|
6095
|
+
const name = equals === -1 ? value : value.slice(0, equals);
|
|
6096
|
+
const enabled = equals === -1 || !FALSE_VALUES.has(value.slice(equals + 1));
|
|
6097
|
+
if (name === "--inplace") writes.inPlace ||= enabled;
|
|
6098
|
+
else if (name === "--split-exp" || name === "--split-exp-file") writes.split = true;
|
|
6099
|
+
else if (name === "--security-allow-write-any-path") writes.anyPath ||= enabled;
|
|
6100
|
+
}
|
|
6101
|
+
function yqShortFlags(value, writes) {
|
|
6102
|
+
for (let at = 1; at < value.length; at += 1) {
|
|
6103
|
+
const letter = value.charAt(at);
|
|
6104
|
+
if (letter === "i") {
|
|
6105
|
+
if (yqInPlaceFlag(value, at, writes)) return;
|
|
6106
|
+
} else if (YQ_VALUED_LETTERS.includes(letter)) {
|
|
6107
|
+
writes.split ||= letter === "s";
|
|
6108
|
+
return;
|
|
6109
|
+
}
|
|
6110
|
+
}
|
|
6111
|
+
}
|
|
6112
|
+
/** Record the `-i` at `at`. pflag reads `-i=false` as the flag with a value,
|
|
6113
|
+
* which ends the cluster; returns whether it did. */
|
|
6114
|
+
function yqInPlaceFlag(value, at, writes) {
|
|
6115
|
+
const inline = value.charAt(at + 1) === "=" ? value.slice(at + 2) : void 0;
|
|
6116
|
+
writes.inPlace ||= inline === void 0 || !FALSE_VALUES.has(inline);
|
|
6117
|
+
return inline !== void 0;
|
|
6118
|
+
}
|
|
5853
6119
|
// src/modules/analysis/capability/read-only-tool-mutations.ts
|
|
5854
|
-
/** Placeholder target when a mutating form names no operand: conservatively
|
|
5855
|
-
* treated as a workspace write (the current directory). */
|
|
5856
|
-
const directoryFallback = ".";
|
|
5857
6120
|
function readOnlyToolMutation(cmd, base) {
|
|
5858
6121
|
if (base === "find") return findMutation(cmd);
|
|
5859
6122
|
if (base === "sort") return sortMutation(cmd);
|
|
6123
|
+
if (base === "uniq") return outputOperandMutation(cmd, UNIQ_OPTIONS);
|
|
6124
|
+
if (base === "xxd") return outputOperandMutation(cmd, XXD_OPTIONS);
|
|
6125
|
+
if (base === "tree") return treeMutation(cmd);
|
|
5860
6126
|
if (base === "yq") return yqMutation(cmd);
|
|
5861
6127
|
}
|
|
5862
6128
|
function findMutation(cmd) {
|
|
@@ -5916,22 +6182,6 @@ function pushOptionValue(cmd, index, targets) {
|
|
|
5916
6182
|
const target = cmd[index + 1]?.value;
|
|
5917
6183
|
if (target !== void 0 && !target.startsWith("-")) targets.push(target);
|
|
5918
6184
|
}
|
|
5919
|
-
function sortMutation(cmd) {
|
|
5920
|
-
const result = { writeTargets: [] };
|
|
5921
|
-
for (let index = 1; index < cmd.length; index += 1) {
|
|
5922
|
-
const value = elementAt(cmd, index, "cmd").value;
|
|
5923
|
-
if (value === "-o" || value === "--output") pushOptionValue(cmd, index, result.writeTargets);
|
|
5924
|
-
else if (value.startsWith("--output=")) result.writeTargets.push(value.slice(9));
|
|
5925
|
-
else if (value.startsWith("-o") && value.length > 2) result.writeTargets.push(value.slice(2));
|
|
5926
|
-
}
|
|
5927
|
-
return result.writeTargets.length > 0 ? result : void 0;
|
|
5928
|
-
}
|
|
5929
|
-
/** In-place edit: every non-option operand, the expression included, is recorded as a write target. */
|
|
5930
|
-
function yqMutation(cmd) {
|
|
5931
|
-
if (!cmd.some((token) => token.value === "-i" || token.value === "--inplace")) return void 0;
|
|
5932
|
-
const targets = cmd.slice(1).map((token) => token.value).filter((value) => !value.startsWith("-"));
|
|
5933
|
-
return targets.length > 0 ? { writeTargets: targets } : { writeTargets: [directoryFallback] };
|
|
5934
|
-
}
|
|
5935
6185
|
// src/modules/analysis/capability/executable-recognition.ts
|
|
5936
6186
|
/** Effect families that keep a read-only or no-effect executable from
|
|
5937
6187
|
* counting as read-only. */
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parse as parse$1, satisfies } from "semver";
|
|
1
2
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
2
3
|
import { basename as basename$1, dirname, isAbsolute, join, normalize, resolve, sep } from "node:path";
|
|
3
4
|
import { lstat, mkdir, mkdtemp, open as open$2, readlink, realpath, rm, stat, writeFile } from "node:fs/promises";
|
|
@@ -6,7 +7,6 @@ import { promisify } from "node:util";
|
|
|
6
7
|
import { closeSync, constants, fchmodSync, fstatSync, openSync, readSync, realpathSync, rmSync, writeSync } from "node:fs";
|
|
7
8
|
import { homedir, tmpdir } from "node:os";
|
|
8
9
|
import { TypeSafeClient } from "@typesafe-ai/sdk";
|
|
9
|
-
import { satisfies } from "semver";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
@@ -76,6 +76,37 @@ function extractPermissionRequest(event) {
|
|
|
76
76
|
...tool === void 0 ? {} : { tool }
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
+
// src/adapters/opencode/host-guard.ts
|
|
80
|
+
/**
|
|
81
|
+
* OpenCode V2 host versions accepted at setup. A host outside this range
|
|
82
|
+
* fails setup loudly instead of running against an unknown contract.
|
|
83
|
+
*/
|
|
84
|
+
const SUPPORTED_V2_RANGE = ">=2.0.22 <3";
|
|
85
|
+
/**
|
|
86
|
+
* Guard the legacy adapter against incompatible client shapes.
|
|
87
|
+
*
|
|
88
|
+
* A client exposing only permission.reply does not satisfy the legacy
|
|
89
|
+
* transport contract. Product V2 uses its own setup entrypoint and adapter.
|
|
90
|
+
*/
|
|
91
|
+
function assertV1Host(client) {
|
|
92
|
+
const record = client ?? {};
|
|
93
|
+
const permission = record.permission ?? {};
|
|
94
|
+
const raw = record._client ?? {};
|
|
95
|
+
if (typeof permission.reply === "function" && typeof raw.post !== "function") throw new Error("The V1 adapter requires the authenticated legacy transport. Use the setup entrypoint for OpenCode V2; refusing this incompatible client.");
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Why the V1 entrypoint must refuse a host that reports a V2 version, or
|
|
99
|
+
* undefined when the version is V1 or unknown.
|
|
100
|
+
*
|
|
101
|
+
* The V1 reviewer isolates its sessions with a single-file local plugin, and
|
|
102
|
+
* V2 skips plugin paths that name a file. Every review would then fail closed
|
|
103
|
+
* with no visible cause, so the plugin fails at load and says how to fix it.
|
|
104
|
+
*/
|
|
105
|
+
function v1HostVersionRefusal(version) {
|
|
106
|
+
const parsed = version === void 0 ? null : parse$1(version);
|
|
107
|
+
if (parsed === null || parsed.major < 2) return;
|
|
108
|
+
return `OpenCode ${parsed.version} loaded the V1 entrypoint of opencode-permission-reviewer, whose reviewer isolation V2 does not load. Register the plugin under the V2 "plugins" key (see "Configure" in the README) so the host uses its setup entrypoint.`;
|
|
109
|
+
}
|
|
79
110
|
// src/utils/with-timeout.ts
|
|
80
111
|
function withTimeout(promise, timeoutMs) {
|
|
81
112
|
let timer;
|
|
@@ -108,7 +139,7 @@ function invariant(condition, message) {
|
|
|
108
139
|
if (!condition) throw new Error(message);
|
|
109
140
|
}
|
|
110
141
|
// package.json
|
|
111
|
-
var version = "3.
|
|
142
|
+
var version = "3.7.0";
|
|
112
143
|
// src/utils/redact.ts
|
|
113
144
|
const REDACT = (type) => `[REDACTED:${type}]`;
|
|
114
145
|
const OPENCODE_SESSION_KEY = /^(?:session[_-]?id|session|sid)$/i;
|
|
@@ -910,7 +941,9 @@ function resolveMinimumConfidence(value) {
|
|
|
910
941
|
// src/modules/config/models/openrouter-decision-models.ts
|
|
911
942
|
const OPENROUTER_DECISION_MODELS = {
|
|
912
943
|
models: {
|
|
944
|
+
"baseten/bison-1": { benchmarked: false },
|
|
913
945
|
"baseten/elephant-1": { benchmarked: false },
|
|
946
|
+
"baseten/groundhog-1": { benchmarked: false },
|
|
914
947
|
"baseten/joey-1": { benchmarked: false },
|
|
915
948
|
"baseten/mammoth-1": { benchmarked: false },
|
|
916
949
|
"cloudflare/clairic": { benchmarked: false },
|
|
@@ -921,10 +954,12 @@ const OPENROUTER_DECISION_MODELS = {
|
|
|
921
954
|
"heygen/heygen-decision-1": { benchmarked: false },
|
|
922
955
|
"heygen/heygen-decision-1-turbo": { benchmarked: false },
|
|
923
956
|
"jaredpalmer/kev-4b": { benchmarked: false },
|
|
924
|
-
"liquid/d1": { benchmarked: true },
|
|
925
957
|
"liquid/d1-ultra": { benchmarked: true },
|
|
926
958
|
"liquid/d1.1": { benchmarked: false },
|
|
959
|
+
"liquid/d1.2": { benchmarked: false },
|
|
960
|
+
"liquid/d1.2-ultra": { benchmarked: false },
|
|
927
961
|
"microsoft/microsoft-decision-1": { benchmarked: false },
|
|
962
|
+
"microsoft/microsoft-decision-1.1": { benchmarked: false },
|
|
928
963
|
"morph/reflex": { benchmarked: false },
|
|
929
964
|
"nace-ai/drex-max": { benchmarked: false },
|
|
930
965
|
"nace-ai/drex-max-finance": { benchmarked: false },
|
|
@@ -5421,12 +5456,12 @@ function scanWord(words, index, scan) {
|
|
|
5421
5456
|
scan.operand = index + 1 < words.length;
|
|
5422
5457
|
return;
|
|
5423
5458
|
}
|
|
5424
|
-
if (word.startsWith("--")) return longOption(word, scan);
|
|
5459
|
+
if (word.startsWith("--")) return longOption$1(word, scan);
|
|
5425
5460
|
if (word.length > 1 && (word.startsWith("-") || word.startsWith("+"))) return optionCluster(words, index, scan);
|
|
5426
5461
|
scan.operand = true;
|
|
5427
5462
|
}
|
|
5428
5463
|
/** The words a long option takes after itself. */
|
|
5429
|
-
function longOption(word, scan) {
|
|
5464
|
+
function longOption$1(word, scan) {
|
|
5430
5465
|
if (SHELL_NO_RUN_LONG_OPTIONS.has(word)) scan.noRun = true;
|
|
5431
5466
|
return SHELL_LONG_VALUE_OPTIONS.has(word) ? 1 : 0;
|
|
5432
5467
|
}
|
|
@@ -10198,13 +10233,275 @@ function assessmentFrom(parsed, facts) {
|
|
|
10198
10233
|
analysisWarnings: warnings
|
|
10199
10234
|
};
|
|
10200
10235
|
}
|
|
10236
|
+
// src/modules/analysis/capability/getopt-long-option.ts
|
|
10237
|
+
/** A getopt_long option word: `--name` or `--name=value`, where `name` may be
|
|
10238
|
+
* any unambiguous prefix of the full option name. `minimum` is the length of
|
|
10239
|
+
* the shortest such prefix, `--` included, so a shorter prefix that another
|
|
10240
|
+
* option of the same tool shares never matches. */
|
|
10241
|
+
function longOption(value, name, minimum) {
|
|
10242
|
+
if (!value.startsWith("--")) return void 0;
|
|
10243
|
+
const equals = value.indexOf("=");
|
|
10244
|
+
const word = equals === -1 ? value : value.slice(0, equals);
|
|
10245
|
+
if (word.length < minimum || !name.startsWith(word)) return void 0;
|
|
10246
|
+
return equals === -1 ? {} : { inline: value.slice(equals + 1) };
|
|
10247
|
+
}
|
|
10248
|
+
// src/modules/analysis/capability/output-operand-mutations.ts
|
|
10249
|
+
/** uniq's long options with a required value, with the length of each one's
|
|
10250
|
+
* shortest unambiguous prefix. */
|
|
10251
|
+
const UNIQ_VALUED_LONG = [
|
|
10252
|
+
["--skip-fields", 8],
|
|
10253
|
+
["--skip-chars", 8],
|
|
10254
|
+
["--check-chars", 4]
|
|
10255
|
+
];
|
|
10256
|
+
const UNIQ_OPTIONS = {
|
|
10257
|
+
takesNextWord(value) {
|
|
10258
|
+
if (value.startsWith("--")) return !value.includes("=") && UNIQ_VALUED_LONG.some(([name, minimum]) => longOption(value, name, minimum) !== void 0);
|
|
10259
|
+
const at = value.slice(1).search(/[fsw]/);
|
|
10260
|
+
return at !== -1 && at + 2 === value.length;
|
|
10261
|
+
},
|
|
10262
|
+
permute: true
|
|
10263
|
+
};
|
|
10264
|
+
/** xxd's options that take a value, by letter, with the tails of their long
|
|
10265
|
+
* spellings (`-c`, `-cols`). Such a word takes the next word as its value;
|
|
10266
|
+
* any other text after the letter is the value itself (`-c8`). */
|
|
10267
|
+
const XXD_VALUED = /* @__PURE__ */ new Map([
|
|
10268
|
+
["c", ["ols"]],
|
|
10269
|
+
["g", ["roup"]],
|
|
10270
|
+
["o", ["ffset"]],
|
|
10271
|
+
["s", ["kip", "eek"]],
|
|
10272
|
+
["l", ["en"]],
|
|
10273
|
+
["n", ["ame"]],
|
|
10274
|
+
["R", []]
|
|
10275
|
+
]);
|
|
10276
|
+
const XXD_OPTIONS = {
|
|
10277
|
+
takesNextWord(value) {
|
|
10278
|
+
const word = value.startsWith("--") && value.length > 2 ? value.slice(1) : value;
|
|
10279
|
+
const rest = word.slice(2);
|
|
10280
|
+
if (word.charAt(1) === "c" && rest.startsWith("apitalize")) return false;
|
|
10281
|
+
const tails = XXD_VALUED.get(word.charAt(1));
|
|
10282
|
+
if (tails === void 0) return false;
|
|
10283
|
+
return rest === "" || tails.some((tail) => rest.startsWith(tail));
|
|
10284
|
+
},
|
|
10285
|
+
permute: false
|
|
10286
|
+
};
|
|
10287
|
+
/** `TOOL [OPTION]... [INPUT [OUTPUT]]` (uniq, xxd): a second operand is a file
|
|
10288
|
+
* the command writes ("-" is standard output). */
|
|
10289
|
+
function outputOperandMutation(cmd, tool) {
|
|
10290
|
+
const output = operandsOf(cmd, tool)[1];
|
|
10291
|
+
return output !== void 0 && output !== "-" ? { writeTargets: [output] } : void 0;
|
|
10292
|
+
}
|
|
10293
|
+
function operandsOf(cmd, tool) {
|
|
10294
|
+
const operands = [];
|
|
10295
|
+
let options = true;
|
|
10296
|
+
for (let index = 1; index < cmd.length; index += 1) {
|
|
10297
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
10298
|
+
if (options && value === "--") options = false;
|
|
10299
|
+
else if (options && value.startsWith("-") && value !== "-") {
|
|
10300
|
+
if (tool.takesNextWord(value)) index += 1;
|
|
10301
|
+
} else {
|
|
10302
|
+
operands.push(value);
|
|
10303
|
+
options &&= tool.permute;
|
|
10304
|
+
}
|
|
10305
|
+
}
|
|
10306
|
+
return operands;
|
|
10307
|
+
}
|
|
10308
|
+
// src/modules/analysis/capability/sort-mutation.ts
|
|
10309
|
+
/** GNU sort short options that take a value. The value is the rest of the
|
|
10310
|
+
* cluster, or the next word when the letter ends it. */
|
|
10311
|
+
const SORT_VALUED_LETTERS = "kotST";
|
|
10312
|
+
/** GNU sort: `-o FILE` writes FILE and `--compress-program=PROG` runs PROG.
|
|
10313
|
+
* Short options cluster getopt-style (`-uo FILE`, `-nruoFILE`), and long
|
|
10314
|
+
* options may be abbreviated (`--out=FILE`). */
|
|
10315
|
+
function sortMutation(cmd) {
|
|
10316
|
+
const result = { writeTargets: [] };
|
|
10317
|
+
let index = 1;
|
|
10318
|
+
while (index < cmd.length) {
|
|
10319
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
10320
|
+
if (value === "--") break;
|
|
10321
|
+
index += value.startsWith("--") ? sortLongOption(cmd, index, result) : sortShortOptions(cmd, index, result);
|
|
10322
|
+
}
|
|
10323
|
+
return result.writeTargets.length > 0 || result.executesCode === true ? result : void 0;
|
|
10324
|
+
}
|
|
10325
|
+
/** Record a long option's effect; returns the words it spans. */
|
|
10326
|
+
function sortLongOption(cmd, index, result) {
|
|
10327
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
10328
|
+
const output = longOption(value, "--output", 3);
|
|
10329
|
+
if (output !== void 0) {
|
|
10330
|
+
const target = output.inline ?? cmd[index + 1]?.value;
|
|
10331
|
+
if (target !== void 0) result.writeTargets.push(target);
|
|
10332
|
+
return output.inline === void 0 ? 2 : 1;
|
|
10333
|
+
}
|
|
10334
|
+
if (longOption(value, "--compress-program", 4) !== void 0) result.executesCode = true;
|
|
10335
|
+
return 1;
|
|
10336
|
+
}
|
|
10337
|
+
/** Record a short-option cluster's output file; returns the words it spans. */
|
|
10338
|
+
function sortShortOptions(cmd, index, result) {
|
|
10339
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
10340
|
+
if (!value.startsWith("-") || value === "-") return 1;
|
|
10341
|
+
for (let at = 1; at < value.length; at += 1) {
|
|
10342
|
+
const letter = value.charAt(at);
|
|
10343
|
+
if (!SORT_VALUED_LETTERS.includes(letter)) continue;
|
|
10344
|
+
const attached = value.slice(at + 1);
|
|
10345
|
+
const argument = attached === "" ? cmd[index + 1]?.value : attached;
|
|
10346
|
+
if (letter === "o" && argument !== void 0) result.writeTargets.push(argument);
|
|
10347
|
+
return attached === "" ? 2 : 1;
|
|
10348
|
+
}
|
|
10349
|
+
return 1;
|
|
10350
|
+
}
|
|
10351
|
+
// src/modules/analysis/capability/tree-mutation.ts
|
|
10352
|
+
/** tree's short options whose value is the next unused word. `-L` also takes
|
|
10353
|
+
* its value as digits attached inside the cluster (`-L2`). */
|
|
10354
|
+
const TREE_VALUED_LETTERS = /* @__PURE__ */ new Set([
|
|
10355
|
+
"L",
|
|
10356
|
+
"P",
|
|
10357
|
+
"I",
|
|
10358
|
+
"H",
|
|
10359
|
+
"T",
|
|
10360
|
+
"o"
|
|
10361
|
+
]);
|
|
10362
|
+
/** tree's long options with a value, which is inline (`--sort=name`) or the
|
|
10363
|
+
* next word. tree matches each by prefix. */
|
|
10364
|
+
const TREE_VALUED_LONG = [
|
|
10365
|
+
"--authority",
|
|
10366
|
+
"--charset",
|
|
10367
|
+
"--compress",
|
|
10368
|
+
"--filelimit",
|
|
10369
|
+
"--gitfile",
|
|
10370
|
+
"--hintro",
|
|
10371
|
+
"--houtro",
|
|
10372
|
+
"--infofile",
|
|
10373
|
+
"--scheme",
|
|
10374
|
+
"--sort",
|
|
10375
|
+
"--timefmt"
|
|
10376
|
+
];
|
|
10377
|
+
/** tree: `-o FILE` writes FILE, and `-R` writes an `00Tree.html` listing into
|
|
10378
|
+
* each directory it visits. Options may follow the roots. */
|
|
10379
|
+
function treeMutation(cmd) {
|
|
10380
|
+
const scan = {
|
|
10381
|
+
roots: [],
|
|
10382
|
+
outputs: [],
|
|
10383
|
+
recursive: false
|
|
10384
|
+
};
|
|
10385
|
+
let index = 1;
|
|
10386
|
+
while (index < cmd.length) {
|
|
10387
|
+
if (elementAt(cmd, index, "cmd").value === "--") {
|
|
10388
|
+
scan.roots.push(...cmd.slice(index + 1).map((token) => token.value));
|
|
10389
|
+
break;
|
|
10390
|
+
}
|
|
10391
|
+
index += treeWord(cmd, index, scan);
|
|
10392
|
+
}
|
|
10393
|
+
const writeTargets = [...scan.outputs];
|
|
10394
|
+
if (scan.recursive) writeTargets.push(...scan.roots.length > 0 ? scan.roots : ["."]);
|
|
10395
|
+
return writeTargets.length > 0 ? { writeTargets } : void 0;
|
|
10396
|
+
}
|
|
10397
|
+
/** Scan the word at `index`; returns the words it spans. */
|
|
10398
|
+
function treeWord(cmd, index, scan) {
|
|
10399
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
10400
|
+
if (value.startsWith("--")) return TREE_VALUED_LONG.some((name) => value.startsWith(name) && value.charAt(name.length) !== "=") ? 2 : 1;
|
|
10401
|
+
if (!value.startsWith("-") || value === "-") {
|
|
10402
|
+
scan.roots.push(value);
|
|
10403
|
+
return 1;
|
|
10404
|
+
}
|
|
10405
|
+
return 1 + treeShortOptions(cmd, index, scan);
|
|
10406
|
+
}
|
|
10407
|
+
/** Scan a short-option cluster. Each letter that takes a value consumes the
|
|
10408
|
+
* next unused word, in order (`-Lo 2 out.txt`). Returns how many it used. */
|
|
10409
|
+
function treeShortOptions(cmd, index, scan) {
|
|
10410
|
+
const value = elementAt(cmd, index, "cmd").value;
|
|
10411
|
+
let consumed = 0;
|
|
10412
|
+
let at = 1;
|
|
10413
|
+
while (at < value.length) {
|
|
10414
|
+
const letter = value.charAt(at);
|
|
10415
|
+
const digits = letter === "L" ? attachedDigits(value, at + 1) : 0;
|
|
10416
|
+
if (letter === "R") scan.recursive = true;
|
|
10417
|
+
else if (digits === 0 && TREE_VALUED_LETTERS.has(letter)) {
|
|
10418
|
+
consumed += 1;
|
|
10419
|
+
recordTreeValue(letter, cmd[index + consumed]?.value, scan);
|
|
10420
|
+
}
|
|
10421
|
+
at += 1 + digits;
|
|
10422
|
+
}
|
|
10423
|
+
return consumed;
|
|
10424
|
+
}
|
|
10425
|
+
/** How many digits start `value` at `from`. */
|
|
10426
|
+
function attachedDigits(value, from) {
|
|
10427
|
+
return value.slice(from).match(/^\d*/)?.[0].length ?? 0;
|
|
10428
|
+
}
|
|
10429
|
+
function recordTreeValue(letter, argument, scan) {
|
|
10430
|
+
if (letter === "o" && argument !== void 0) scan.outputs.push(argument);
|
|
10431
|
+
}
|
|
10432
|
+
// src/modules/analysis/capability/yq-mutation.ts
|
|
10433
|
+
/** yq's short flags that take a value. The value is the rest of the cluster,
|
|
10434
|
+
* so a later letter is not a flag (`-oi` is output format "i"). */
|
|
10435
|
+
const YQ_VALUED_LETTERS = "poIsf";
|
|
10436
|
+
/** The values a Go boolean flag parses as false. */
|
|
10437
|
+
const FALSE_VALUES = /* @__PURE__ */ new Set([
|
|
10438
|
+
"0",
|
|
10439
|
+
"f",
|
|
10440
|
+
"F",
|
|
10441
|
+
"false",
|
|
10442
|
+
"FALSE",
|
|
10443
|
+
"False"
|
|
10444
|
+
]);
|
|
10445
|
+
/** yq: `-i` rewrites its file operands, and `-s` writes a file per result.
|
|
10446
|
+
* For an in-place edit every non-option word, the expression included, is
|
|
10447
|
+
* recorded as a write target. */
|
|
10448
|
+
function yqMutation(cmd) {
|
|
10449
|
+
const writes = yqWrites(cmd);
|
|
10450
|
+
const writeTargets = [];
|
|
10451
|
+
if (writes.inPlace) writeTargets.push(...cmd.slice(1).map((token) => token.value).filter((value) => !value.startsWith("-")));
|
|
10452
|
+
if (writes.split) writeTargets.push(writes.anyPath ? "/" : ".");
|
|
10453
|
+
if (writes.inPlace && writeTargets.length === 0) writeTargets.push(".");
|
|
10454
|
+
return writeTargets.length > 0 ? { writeTargets } : void 0;
|
|
10455
|
+
}
|
|
10456
|
+
/** Scan yq's flags (pflag syntax: no abbreviations, booleans may carry
|
|
10457
|
+
* `=value`, short booleans cluster). */
|
|
10458
|
+
function yqWrites(cmd) {
|
|
10459
|
+
const writes = {
|
|
10460
|
+
inPlace: false,
|
|
10461
|
+
split: false,
|
|
10462
|
+
anyPath: false
|
|
10463
|
+
};
|
|
10464
|
+
for (const token of cmd.slice(1)) {
|
|
10465
|
+
const value = token.value;
|
|
10466
|
+
if (value === "--") break;
|
|
10467
|
+
if (value.startsWith("--")) yqLongFlag(value, writes);
|
|
10468
|
+
else if (value.startsWith("-")) yqShortFlags(value, writes);
|
|
10469
|
+
}
|
|
10470
|
+
return writes;
|
|
10471
|
+
}
|
|
10472
|
+
function yqLongFlag(value, writes) {
|
|
10473
|
+
const equals = value.indexOf("=");
|
|
10474
|
+
const name = equals === -1 ? value : value.slice(0, equals);
|
|
10475
|
+
const enabled = equals === -1 || !FALSE_VALUES.has(value.slice(equals + 1));
|
|
10476
|
+
if (name === "--inplace") writes.inPlace ||= enabled;
|
|
10477
|
+
else if (name === "--split-exp" || name === "--split-exp-file") writes.split = true;
|
|
10478
|
+
else if (name === "--security-allow-write-any-path") writes.anyPath ||= enabled;
|
|
10479
|
+
}
|
|
10480
|
+
function yqShortFlags(value, writes) {
|
|
10481
|
+
for (let at = 1; at < value.length; at += 1) {
|
|
10482
|
+
const letter = value.charAt(at);
|
|
10483
|
+
if (letter === "i") {
|
|
10484
|
+
if (yqInPlaceFlag(value, at, writes)) return;
|
|
10485
|
+
} else if (YQ_VALUED_LETTERS.includes(letter)) {
|
|
10486
|
+
writes.split ||= letter === "s";
|
|
10487
|
+
return;
|
|
10488
|
+
}
|
|
10489
|
+
}
|
|
10490
|
+
}
|
|
10491
|
+
/** Record the `-i` at `at`. pflag reads `-i=false` as the flag with a value,
|
|
10492
|
+
* which ends the cluster; returns whether it did. */
|
|
10493
|
+
function yqInPlaceFlag(value, at, writes) {
|
|
10494
|
+
const inline = value.charAt(at + 1) === "=" ? value.slice(at + 2) : void 0;
|
|
10495
|
+
writes.inPlace ||= inline === void 0 || !FALSE_VALUES.has(inline);
|
|
10496
|
+
return inline !== void 0;
|
|
10497
|
+
}
|
|
10201
10498
|
// src/modules/analysis/capability/read-only-tool-mutations.ts
|
|
10202
|
-
/** Placeholder target when a mutating form names no operand: conservatively
|
|
10203
|
-
* treated as a workspace write (the current directory). */
|
|
10204
|
-
const directoryFallback = ".";
|
|
10205
10499
|
function readOnlyToolMutation(cmd, base) {
|
|
10206
10500
|
if (base === "find") return findMutation(cmd);
|
|
10207
10501
|
if (base === "sort") return sortMutation(cmd);
|
|
10502
|
+
if (base === "uniq") return outputOperandMutation(cmd, UNIQ_OPTIONS);
|
|
10503
|
+
if (base === "xxd") return outputOperandMutation(cmd, XXD_OPTIONS);
|
|
10504
|
+
if (base === "tree") return treeMutation(cmd);
|
|
10208
10505
|
if (base === "yq") return yqMutation(cmd);
|
|
10209
10506
|
}
|
|
10210
10507
|
function findMutation(cmd) {
|
|
@@ -10264,22 +10561,6 @@ function pushOptionValue(cmd, index, targets) {
|
|
|
10264
10561
|
const target = cmd[index + 1]?.value;
|
|
10265
10562
|
if (target !== void 0 && !target.startsWith("-")) targets.push(target);
|
|
10266
10563
|
}
|
|
10267
|
-
function sortMutation(cmd) {
|
|
10268
|
-
const result = { writeTargets: [] };
|
|
10269
|
-
for (let index = 1; index < cmd.length; index += 1) {
|
|
10270
|
-
const value = elementAt(cmd, index, "cmd").value;
|
|
10271
|
-
if (value === "-o" || value === "--output") pushOptionValue(cmd, index, result.writeTargets);
|
|
10272
|
-
else if (value.startsWith("--output=")) result.writeTargets.push(value.slice(9));
|
|
10273
|
-
else if (value.startsWith("-o") && value.length > 2) result.writeTargets.push(value.slice(2));
|
|
10274
|
-
}
|
|
10275
|
-
return result.writeTargets.length > 0 ? result : void 0;
|
|
10276
|
-
}
|
|
10277
|
-
/** In-place edit: every non-option operand, the expression included, is recorded as a write target. */
|
|
10278
|
-
function yqMutation(cmd) {
|
|
10279
|
-
if (!cmd.some((token) => token.value === "-i" || token.value === "--inplace")) return void 0;
|
|
10280
|
-
const targets = cmd.slice(1).map((token) => token.value).filter((value) => !value.startsWith("-"));
|
|
10281
|
-
return targets.length > 0 ? { writeTargets: targets } : { writeTargets: [directoryFallback] };
|
|
10282
|
-
}
|
|
10283
10564
|
// src/modules/analysis/capability/executable-recognition.ts
|
|
10284
10565
|
/** Effect families that keep a read-only or no-effect executable from
|
|
10285
10566
|
* counting as read-only. */
|
|
@@ -11762,15 +12043,16 @@ function renderActionPurpose(purpose, max, intentReference = false) {
|
|
|
11762
12043
|
...purpose.text === void 0 ? {} : { text: intentReference && purpose.source === "intent-derived" ? "<see literal intent sections>" : purpose.text }
|
|
11763
12044
|
}, max)}`;
|
|
11764
12045
|
}
|
|
11765
|
-
/** Compact rendering of ask decisions, one line each (UTC
|
|
11766
|
-
* answer).
|
|
11767
|
-
*
|
|
12046
|
+
/** Compact rendering of ask decisions, one line each (full UTC timestamp,
|
|
12047
|
+
* question, answer). The date keeps answers apart in sessions that span
|
|
12048
|
+
* several days. `undefined` when there is nothing to show so the whole
|
|
12049
|
+
* section is omitted rather than padded with a placeholder. */
|
|
11768
12050
|
function renderAskDecisions(decisions) {
|
|
11769
12051
|
if (decisions === void 0 || decisions.length === 0) return;
|
|
11770
12052
|
const lines = [];
|
|
11771
12053
|
for (const decision of decisions) {
|
|
11772
|
-
const time = new Date(decision.at).toISOString().
|
|
11773
|
-
lines.push(`[${time}
|
|
12054
|
+
const time = new Date(decision.at).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
12055
|
+
lines.push(`[${time}] Q: ${decision.question} A: ${decision.answer}`);
|
|
11774
12056
|
}
|
|
11775
12057
|
const maxChars = 1500;
|
|
11776
12058
|
while (lines.length > 1 && lines.join("\n").length > maxChars) lines.shift();
|
|
@@ -16355,24 +16637,6 @@ function probeCapabilities(client) {
|
|
|
16355
16637
|
tuiPublish: typeof tui.publish === "function"
|
|
16356
16638
|
};
|
|
16357
16639
|
}
|
|
16358
|
-
// src/adapters/opencode/host-guard.ts
|
|
16359
|
-
/**
|
|
16360
|
-
* OpenCode V2 host versions accepted at setup. A host outside this range
|
|
16361
|
-
* fails setup loudly instead of running against an unknown contract.
|
|
16362
|
-
*/
|
|
16363
|
-
const SUPPORTED_V2_RANGE = ">=2.0.22 <3";
|
|
16364
|
-
/**
|
|
16365
|
-
* Guard the legacy adapter against incompatible client shapes.
|
|
16366
|
-
*
|
|
16367
|
-
* A client exposing only permission.reply does not satisfy the legacy
|
|
16368
|
-
* transport contract. Product V2 uses its own setup entrypoint and adapter.
|
|
16369
|
-
*/
|
|
16370
|
-
function assertV1Host(client) {
|
|
16371
|
-
const record = client ?? {};
|
|
16372
|
-
const permission = record.permission ?? {};
|
|
16373
|
-
const raw = record._client ?? {};
|
|
16374
|
-
if (typeof permission.reply === "function" && typeof raw.post !== "function") throw new Error("The V1 adapter requires the authenticated legacy transport. Use the setup entrypoint for OpenCode V2; refusing this incompatible client.");
|
|
16375
|
-
}
|
|
16376
16640
|
// src/adapters/opencode/reply-transport.ts
|
|
16377
16641
|
/**
|
|
16378
16642
|
* Resolve how a permission reply is sent. The priority is: a public SDK reply
|
|
@@ -18938,6 +19202,11 @@ const server = async (input, options) => {
|
|
|
18938
19202
|
const writeAudit = createAuditWriter(config, config.debug ? logger : debugLogger);
|
|
18939
19203
|
const probe = probeHostVersion(input.client);
|
|
18940
19204
|
const hostVersion = probe === void 0 ? void 0 : await probe;
|
|
19205
|
+
const refusal = v1HostVersionRefusal(hostVersion);
|
|
19206
|
+
if (refusal !== void 0) {
|
|
19207
|
+
debugLogger(refusal);
|
|
19208
|
+
throw new Error(refusal);
|
|
19209
|
+
}
|
|
18941
19210
|
const ctx = {
|
|
18942
19211
|
...hostVersion ? { hostVersion } : {},
|
|
18943
19212
|
...createV1Adapter({
|
|
@@ -7,7 +7,9 @@ export interface OpenRouterDecisionModels {
|
|
|
7
7
|
// biome-ignore lint/nursery/useExplicitType: `as const satisfies` keeps the literal ids; an annotation would widen them
|
|
8
8
|
export const OPENROUTER_DECISION_MODELS = {
|
|
9
9
|
models: {
|
|
10
|
+
"baseten/bison-1": { benchmarked: false },
|
|
10
11
|
"baseten/elephant-1": { benchmarked: false },
|
|
12
|
+
"baseten/groundhog-1": { benchmarked: false },
|
|
11
13
|
"baseten/joey-1": { benchmarked: false },
|
|
12
14
|
"baseten/mammoth-1": { benchmarked: false },
|
|
13
15
|
"cloudflare/clairic": { benchmarked: false },
|
|
@@ -18,10 +20,12 @@ export const OPENROUTER_DECISION_MODELS = {
|
|
|
18
20
|
"heygen/heygen-decision-1": { benchmarked: false },
|
|
19
21
|
"heygen/heygen-decision-1-turbo": { benchmarked: false },
|
|
20
22
|
"jaredpalmer/kev-4b": { benchmarked: false },
|
|
21
|
-
"liquid/d1": { benchmarked: true },
|
|
22
23
|
"liquid/d1-ultra": { benchmarked: true },
|
|
23
24
|
"liquid/d1.1": { benchmarked: false },
|
|
25
|
+
"liquid/d1.2": { benchmarked: false },
|
|
26
|
+
"liquid/d1.2-ultra": { benchmarked: false },
|
|
24
27
|
"microsoft/microsoft-decision-1": { benchmarked: false },
|
|
28
|
+
"microsoft/microsoft-decision-1.1": { benchmarked: false },
|
|
25
29
|
"morph/reflex": { benchmarked: false },
|
|
26
30
|
"nace-ai/drex-max": { benchmarked: false },
|
|
27
31
|
"nace-ai/drex-max-finance": { benchmarked: false },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noppu-labs/opencode-permission-reviewer",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Let OpenCode run unattended, securely: a System One or LLM reviewer answers permission prompts and asks you only when it should.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -101,15 +101,15 @@
|
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"@biomejs/biome": "2.6.
|
|
104
|
+
"@biomejs/biome": "2.6.8",
|
|
105
105
|
"@opencode-ai/plugin": "1.19.6",
|
|
106
106
|
"@opencode-ai/sdk": "1.19.6",
|
|
107
|
-
"@opencode/plugin": "2.
|
|
107
|
+
"@opencode/plugin": "2.4.2",
|
|
108
108
|
"@types/bun": "^1.3.0",
|
|
109
109
|
"@types/semver": "7.8.0",
|
|
110
110
|
"fta-cli": "3.1.0",
|
|
111
111
|
"get-east-asian-width": "1.7.0",
|
|
112
|
-
"knip": "6.
|
|
112
|
+
"knip": "6.46.1",
|
|
113
113
|
"string-width": "9.0.0",
|
|
114
114
|
"tsdown": "0.23.7",
|
|
115
115
|
"typescript": "7.0.2"
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"typecheck": "tsc --noEmit",
|
|
130
130
|
"fta": "fta .",
|
|
131
131
|
"knip": "knip",
|
|
132
|
-
"audit": "bun audit --ignore GHSA-chp3-j5qr-2vfr
|
|
132
|
+
"audit": "bun audit --ignore GHSA-chp3-j5qr-2vfr",
|
|
133
133
|
"build": "rm -rf dist && tsdown && bun scripts/copy-tui.ts",
|
|
134
134
|
"test": "bun test",
|
|
135
135
|
"test:stress": "bun test tests/stress.test.ts --timeout 30000",
|
|
@@ -140,11 +140,11 @@
|
|
|
140
140
|
},
|
|
141
141
|
"dependencies": {
|
|
142
142
|
"@typesafe-ai/sdk": "0.6.0",
|
|
143
|
-
"@opencode/client": "2.
|
|
143
|
+
"@opencode/client": "2.4.2",
|
|
144
144
|
"jsonc-parser": "3.3.1",
|
|
145
145
|
"semver": "7.8.6",
|
|
146
|
-
"@opentui/core": "0.
|
|
147
|
-
"@opentui/solid": "0.
|
|
146
|
+
"@opentui/core": "0.9.9",
|
|
147
|
+
"@opentui/solid": "0.9.9",
|
|
148
148
|
"solid-js": "1.9.18",
|
|
149
149
|
"zod": "4.6.7"
|
|
150
150
|
}
|