opencode-azure-devops-pr-review 0.3.2 → 0.3.4

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
@@ -1,5 +1,56 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.4 — 2026-11-01
4
+
5
+ - Reviewers file concrete gaps as findings, usually low: a changed or added
6
+ behavior that no test would catch where the project already tests comparable
7
+ code, a test that cannot fail or checks the wrong thing, a comment, document,
8
+ example, schema or configuration that now contradicts the code, and
9
+ duplicated, dead, misleading or inconsistent code the change introduces.
10
+ Design trade-offs and general advice without a specific defect or location
11
+ stay in the report and the summary's improvement suggestions. Low findings
12
+ stay in the summary index, as before.
13
+ - A mistake repeated in places that each need their own correction, such as
14
+ parallel routes or handlers that make the same wrong call, is one finding per
15
+ place, each at its own lines with the sibling places in its evidence, and
16
+ reviewers check their other assigned files for the same mistake. Identical
17
+ copies of one file among one reviewer's assigned files count as one place;
18
+ copies that a large PR's shards give to different reviewers can each produce
19
+ a finding. One wrong piece of shared code stays one finding at that code.
20
+ `/pr-quick` follows the same rule.
21
+ - In a self-judged before-and-after comparison on the public ReviewBench test
22
+ set, `/pr-deep` with gpt-6.1-sol matched more of the high- and
23
+ medium-severity reference issues, including high ones, with more findings,
24
+ mostly low, and somewhat longer reviews; the share of findings judged valid
25
+ stayed about the same. `/pr-review` with gpt-6-luna matched slightly more,
26
+ within the variation between runs. The
27
+ [validation record](docs/VALIDATION.md) describes the method and its limits.
28
+
29
+ ## 0.3.3 — 2026-10-31
30
+
31
+ - AZPR is tested with OpenCode 2.2.4 instead of 2.1.4. The runtime needed no
32
+ change: on both hosts the same review sends byte-identical model requests.
33
+ Upgrading OpenCode migrates its database irreversibly; stop the service and
34
+ back up `opencode.db` first.
35
+ - `/pr-check` names the OpenCode version in a row of its own and warns when it
36
+ is not the tested one; reviews still run. Receipts no longer end with a
37
+ host notice.
38
+ - A used-up usage or spend limit stops the stage at once: AZPR refuses
39
+ OpenCode's retries and starts no new session, and the receipt names the
40
+ limit. This covers OpenCode 2.2.3's ChatGPT and OpenCode Go usage limits and
41
+ OpenCode's spend limits besides the provider quota and the free-model limit;
42
+ before, a used-up ChatGPT limit was retried as a rate limit.
43
+ - AZPR subscribes only to the session events that show a review progressing;
44
+ OpenCode 2.2.0 and later deliver no others.
45
+ - On OpenCode 2.2.4, `NO_PROXY` always lists `127.0.0.1`, `localhost` and
46
+ `::1`, and Bun honours `NO_PROXY` even for `azure.proxy`. Azure DevOps is
47
+ unaffected; the company-network guide now says to keep `dev.azure.com` out of
48
+ `NO_PROXY` when it must use the proxy. Test-only Azure DevOps base URLs may
49
+ use any 127.0.0.0/8 address, so the proxy scenario can still be tested.
50
+ - The host smoke test adds a foreign MCP server behind CodeMode and an image
51
+ model, and checks that private reviewers see neither those tools nor image
52
+ generation while ordinary sessions keep them.
53
+
3
54
  ## 0.3.2 — 2026-10-30
4
55
 
5
56
  - The README starts with actual Azure DevOps output: an inline comment with its
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![CI](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/actions/workflows/ci.yml?query=branch%3Amain)
4
4
  [![npm](https://img.shields.io/npm/v/opencode-azure-devops-pr-review)](https://www.npmjs.com/package/opencode-azure-devops-pr-review)
5
5
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
6
- [![Tested with OpenCode 2.1.4](https://img.shields.io/badge/OpenCode-2.1.4%20tested-blue)](docs/VALIDATION.md)
6
+ [![Tested with OpenCode 2.2.4](https://img.shields.io/badge/OpenCode-2.2.4%20tested-blue)](docs/VALIDATION.md)
7
7
 
8
8
  **Review Azure DevOps pull requests from a URL. No checkout required.**
9
9
 
@@ -47,7 +47,7 @@ is an actual capture excerpt with identifying UI removed and its text unchanged.
47
47
  [company networks](docs/ENTERPRISE.md#company-networks) first):
48
48
 
49
49
  ```sh
50
- opencode plugin add opencode-azure-devops-pr-review@0.3.2
50
+ opencode plugin add opencode-azure-devops-pr-review@0.3.4
51
51
  ```
52
52
 
53
53
  2. Follow the [quickstart](docs/QUICKSTART.md) to save your PAT in a private
@@ -171,7 +171,7 @@ general review-accuracy score.
171
171
 
172
172
  | Component | Tested target |
173
173
  | --- | --- |
174
- | OpenCode | **OpenCode CLI 2.1.4** (`@opencode/cli`; V2 plugin API). OpenCode 1.x is not supported. |
174
+ | OpenCode | **OpenCode CLI 2.2.4** (`@opencode/cli`; V2 plugin API). On another OpenCode 2.x, `/pr-check` shows an OpenCode WARNING row and reviews still run. OpenCode 1.x is not supported. |
175
175
  | Operating system | **Ubuntu 22.04** (validation environment: WSL2). Other operating systems are not yet validated. |
176
176
  | Azure | **Azure DevOps Services**, REST API **7.1**. Azure DevOps Server is not supported by the current URL handling. |
177
177
  | Installation | OpenCode's plugin manager with the npm package or the versioned Git package, or the source installer with POSIX `sh` and Python 3; no plugin build step or npm dependencies. |
@@ -263,17 +263,17 @@ Azure DevOps REST API with the runtime's built-in `fetch`.
263
263
  Install the npm package with OpenCode's plugin manager:
264
264
 
265
265
  ```sh
266
- opencode plugin add opencode-azure-devops-pr-review@0.3.2
266
+ opencode plugin add opencode-azure-devops-pr-review@0.3.4
267
267
  ```
268
268
 
269
269
  The same release is also a versioned Git package, which needs Git but not the
270
270
  npm registry:
271
271
 
272
272
  ```sh
273
- opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.2'
273
+ opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.4'
274
274
  ```
275
275
 
276
- Add only one of them. OpenCode 2.1.4 loads the plugin into a running OpenCode
276
+ Add only one of them. OpenCode 2.2.4 loads the plugin into a running OpenCode
277
277
  service within a few seconds; if `/pr-setup` does not appear in a new
278
278
  conversation, run `opencode service restart`. Then run `/pr-setup` for setup
279
279
  instructions. Native packages
@@ -284,7 +284,7 @@ To select another configuration file, use an absolute path in the host config:
284
284
  ```json
285
285
  {
286
286
  "plugins": [{
287
- "package": "opencode-azure-devops-pr-review@0.3.2",
287
+ "package": "opencode-azure-devops-pr-review@0.3.4",
288
288
  "options": { "settingsFile": "/absolute/path/to/azpr/settings.json" }
289
289
  }]
290
290
  }
@@ -303,13 +303,13 @@ with a new version adds a second entry**: OpenCode keeps running the version
303
303
  listed first and reports the new one as `Duplicate plugin ID: azpr` (from
304
304
  0.3.1, `/pr-check` also warns about it). Upgrade when no AZPR command is
305
305
  running, since
306
- OpenCode 2.1.4 replaces the running plugin as soon as its entry changes.
306
+ OpenCode 2.2.4 replaces the running plugin as soon as its entry changes.
307
307
 
308
308
  For an entry that `opencode plugin add` created, add the new version and,
309
309
  only when that succeeds, remove the previous one:
310
310
 
311
311
  ```sh
312
- opencode plugin add opencode-azure-devops-pr-review@0.3.2 &&
312
+ opencode plugin add opencode-azure-devops-pr-review@0.3.4 &&
313
313
  opencode plugin remove opencode-azure-devops-pr-review@PREVIOUS_VERSION
314
314
  ```
315
315
 
@@ -332,7 +332,7 @@ configuration needs no new `/pr-setup`. `opencode plugin list` should then
332
332
  show a single `azpr` row with the new version (from 0.3.1, `/pr-check` names
333
333
  it too); if it still shows the previous one, run `opencode service restart`.
334
334
  Exact versions stay pinned, so `opencode plugin update` leaves them unchanged.
335
- See the [0.3.2 release notes](docs/releases/v0.3.2.md) for what changed and the
335
+ See the [0.3.4 release notes](docs/releases/v0.3.4.md) for what changed and the
336
336
  [0.2.0 release notes](docs/releases/v0.2.0.md) for automatic comments, which
337
337
  remain disabled unless you configure `afterReview` or request them with a
338
338
  review command flag.
@@ -342,8 +342,8 @@ review command flag.
342
342
  <details>
343
343
  <summary>Source installation and replacement</summary>
344
344
 
345
- Download the [v0.3.2 source archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.3.2.tar.gz)
346
- and extract it, or check out tag `v0.3.2`. The installer needs POSIX `sh` and
345
+ Download the [v0.3.4 source archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.3.4.tar.gz)
346
+ and extract it, or check out tag `v0.3.4`. The installer needs POSIX `sh` and
347
347
  Python 3's standard library. From that source directory:
348
348
 
349
349
  ```sh
@@ -475,7 +475,14 @@ never blocks `/pr-review`. Comment planning uses the review's risk model
475
475
  | `quick.reviewer` | `/pr-quick` only: both focuses in one session per shard, its own source checks, and comment planning for quick reviews. Strong code comprehension, evidence judgment and reliable tool use. |
476
476
 
477
477
  A role's focus orders its attention and is not a filter: every reviewer files
478
- every concrete defect it finds, in any area, as a finding.
478
+ every concrete defect it finds, in any area, as a finding. Concrete gaps the
479
+ change leaves are findings too, usually low: a changed behavior no test would
480
+ catch where the project already tests comparable code, a test that cannot fail,
481
+ a comment or document that now contradicts the code, and duplicated or dead
482
+ code the change adds. A mistake repeated in places that each need their own fix
483
+ is one finding per place. Identical copies of one file count as one place when
484
+ one reviewer has them; in a large PR split into shards, copies that different
485
+ reviewers get can each produce a finding.
479
486
 
480
487
  ### All settings and defaults
481
488
 
@@ -498,14 +505,14 @@ every concrete defect it finds, in any area, as a finding.
498
505
  | `azure.concurrency` | `3` simultaneous Azure DevOps calls across all AZPR commands. |
499
506
  | `azure.callTimeoutSeconds` | `120`; a hung call is aborted and its slot released (reads are retried). |
500
507
  | `azure.archiveMegabytes` | `100` (1–1024): the largest repository zip that content search downloads per run and commit; a larger repository is not searched. It is held in memory during a review. |
501
- | `azure.proxy` | `""`: no AZPR proxy (`HTTPS_PROXY` and `NO_PROXY` in OpenCode's environment still apply). A forward proxy for AZPR's Azure DevOps calls only, such as `http://proxy.example.com:8080`; credentials go in the URL as `http://user:password@host:port` (percent-encoded) and are never shown. See [proxies](docs/AZURE_DEVOPS.md#proxies-and-tls-inspection). |
508
+ | `azure.proxy` | `""`: no AZPR proxy (`HTTPS_PROXY` and `NO_PROXY` in OpenCode's environment still apply; a host in `NO_PROXY` bypasses a set proxy too). A forward proxy for AZPR's Azure DevOps calls only, such as `http://proxy.example.com:8080`; credentials go in the URL as `http://user:password@host:port` (percent-encoded) and are never shown. See [proxies](docs/AZURE_DEVOPS.md#proxies-and-tls-inspection). |
502
509
  | `azure.caFile` | `""`. The absolute path of a PEM file with CA certificates AZPR trusts in addition to the built-in roots, for a proxy that inspects HTTPS. |
503
510
  | `azure.verifyTls` | `true`. `false` skips certificate checks for AZPR's Azure DevOps calls (like `curl -k`), so anyone who can intercept the connection can read the PAT; prefer `azure.caFile`. `/pr-check` warns while it is off. |
504
511
  | `workflow.shardFiles` | `25` changed files per initial-review session. |
505
512
  | `workflow.shardFindings` | At most `15` findings per verification session; one file's findings stay in the same session (a file is split only when it alone has more). |
506
513
  | `workflow.parallelSessions` | `4` reviewer sessions at once within a command; comment planning runs at most two pages at once (one when this is `1`). |
507
514
  | `workflow.repairAttempts` | `2` correction turns when an answer breaks the output contract. A quick review's one follow-up turn for unfinished work uses the same budget. |
508
- | `workflow.stageRetries` | `1` new-session retry after a transient failure (provider 429/5xx, interrupted stream) or an inactivity stop. A used-up provider quota or OpenCode free-model limit is named and not retried, whatever its status. |
515
+ | `workflow.stageRetries` | `1` new-session retry after a transient failure (provider 429/5xx, interrupted stream) or an inactivity stop. A used-up usage or spend limit (provider quota, ChatGPT or OpenCode Go usage limit, OpenCode free-model or spend limit) is named and not retried, whatever its status, and AZPR refuses OpenCode's own retries of it. |
509
516
  | `workflow.stageIdleSeconds` | `600` (`0` turns it off, otherwise 60–7200): a reviewer stage that shows no activity this long while it waits on OpenCode (the model stream, a tool or the host stopped responding) is stopped with `failure=idle` and an error naming its last activity, then retried in a new session. Every model request, streamed chunk of output, tool start or end and announced host retry restarts the window, so a stage that keeps working, including a long answer that keeps streaming, is never cut. With shell allowed, an approval or a command that takes longer counts as inactivity. |
510
517
  | `debug.enabled` / `debug.directory` / `debug.keepRuns` | `false` / `""` / `20` run directories kept (`0` keeps all); see [debugging](docs/DEBUGGING.md). |
511
518
 
@@ -761,8 +768,8 @@ and a loopback fake Azure DevOps REST service in disposable directories under
761
768
  Uninstall without `--apply` previews; `--apply` archives only this package under
762
769
  `azpr-v2-backups` and leaves the private state directory for you to delete.
763
770
  For a native installation, remove the entry you added, for example
764
- `opencode plugin remove opencode-azure-devops-pr-review@0.3.2` or
765
- `opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.2'`;
771
+ `opencode plugin remove opencode-azure-devops-pr-review@0.3.4` or
772
+ `opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.4'`;
766
773
  the external settings, PAT file and private review state remain available.
767
774
 
768
775
  [Architecture](docs/ARCHITECTURE.md), [commenting](docs/COMMENTING.md),
@@ -775,7 +782,7 @@ or personal model selections.
775
782
  ## License and releases
776
783
 
777
784
  [MIT](LICENSE), copyright 2026 WTLAIB. See the [changelog](CHANGELOG.md) for the
778
- release scope, [v0.3.2](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.3.2)
785
+ release scope, [v0.3.4](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.3.4)
779
786
  for downloads, the [npm package](https://www.npmjs.com/package/opencode-azure-devops-pr-review),
780
787
  [v0.2.0](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.2.0)
781
788
  for the recorded demonstration, and [releasing](docs/RELEASING.md) for the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-azure-devops-pr-review",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "description": "Azure DevOps PR reviews from a URL in OpenCode, with no checkout, configurable models, separate verification, and comment previews you can adjust before posting",
6
6
  "scripts": {
@@ -1,5 +1,4 @@
1
1
  import { ROLES } from './config.mjs';
2
- import { TESTED_HOST_VERSION } from './host.mjs';
3
2
  // Deterministic attribution from invoked reviewer stages, not model-authored claims.
4
3
  const vocabulary = {
5
4
  en: { title: 'AI review provenance', disclaimer: 'AI-generated review, not human approval. Posting through a user account does not imply that person verified these conclusions.', method: 'Independent initial reviews, followed by source-based verification, duplicate merging, and rejection of unsupported findings; not majority voting.', roles: ['Source check', 'Functional review', 'Risk review', 'Verification', 'Duplicate check', 'Quick review'], stage: 'Stage', model: 'Selected provider/model ID', sessions: 'Sessions', count: 'Initial findings', dispositions: 'Finding dispositions', finding: 'Finding', result: 'Result', merged: 'Merged into', extra: 'New verifier findings', note: 'IDs identify the models selected in OpenCode, not independently verified provider backend identities. Host auxiliary models and the original chat model are not part of this ledger.', comment: 'AI-generated review; not human review or approval. Models:',
@@ -273,7 +272,6 @@ export function renderReceipt(run, report, status, error, settings) {
273
272
  ? '\nIncomplete draft notice: the quick review did not complete; its observations are unconfirmed and not input for PR comments.\n'
274
273
  : '\nIncomplete draft notice: initial observations are unconfirmed because verification did not complete; they are not input for PR comments.\n';
275
274
  body += renderDiagnosticNotices(run);
276
- if (run.compatibility && !run.compatibility.tested && run.compatibility.version !== 'unknown') body += `\nHost notice: OpenCode ${run.compatibility.version} differs from the tested ${TESTED_HOST_VERSION}; capabilities were detected at runtime.\n`;
277
275
  body += run.mode === 'check'
278
276
  ? '\nStatus: READY means AZPR can read the PR through the Azure DevOps REST API; it does not review or approve the PR.\n'
279
277
  : run.mode === 'comment'
package/src/azure.mjs CHANGED
@@ -105,14 +105,17 @@ export function targetKey(target) {
105
105
 
106
106
  /**
107
107
  * A REST base URL other than dev.azure.com is accepted only for loopback test
108
- * servers, so a mistaken override can never send the PAT to another host.
108
+ * servers, so a mistaken override can never send the PAT to another host. All
109
+ * of 127.0.0.0/8 is loopback: OpenCode 2.2.4 adds 127.0.0.1, localhost and ::1
110
+ * to NO_PROXY, and Bun then bypasses even an explicit proxy, so a proxied test
111
+ * server needs another loopback address.
109
112
  */
110
113
  export function restBaseUrl(override) {
111
114
  if (override === undefined || override === null || override === '') return DEFAULT_BASE_URL;
112
115
  let url;
113
116
  try { url = new URL(override); } catch { throw new Error('[AZPR] The Azure DevOps test base URL is not a valid URL.'); }
114
117
  if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.search || url.hash ||
115
- !['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)) {
118
+ !(url.hostname === 'localhost' || url.hostname === '[::1]' || /^127(?:\.\d{1,3}){3}$/.test(url.hostname))) {
116
119
  throw new Error('[AZPR] An Azure DevOps base URL override must be a loopback test server.');
117
120
  }
118
121
  return url.href.replace(/\/+$/, '');
package/src/host.mjs CHANGED
@@ -6,9 +6,9 @@
6
6
  * constant and response normalization lives here so an upgrade has one place
7
7
  * to adjust.
8
8
  */
9
- export const TESTED_HOST_VERSION = '2.1.4';
9
+ export const TESTED_HOST_VERSION = '2.2.4';
10
10
 
11
- // Text OpenCode (2.0.32 through 2.1.4) queues after resuming an interrupted text stream.
11
+ // Text OpenCode (2.0.32 through 2.2.4) queues after resuming an interrupted text stream.
12
12
  export const HOST_CONTINUATION_TEXT = 'The previous response was interrupted. Continue from where you left off without repeating completed content.';
13
13
 
14
14
  // Context message types that mean someone other than the admitted prompt
@@ -57,7 +57,7 @@ export function packageNamed(target, name, repository) {
57
57
  }
58
58
 
59
59
  /**
60
- * This plugin's entries in the host's plugin list. OpenCode 2.1.4 lists
60
+ * This plugin's entries in the host's plugin list. OpenCode 2.1.4 through 2.2.4 list
61
61
  * { id?, source: { type: package|local|builtin|sdk, target?, version? },
62
62
  * state: { status: active|failed, error? } } and keeps only the first entry
63
63
  * of a plugin ID: a second one is listed as failed with "Duplicate plugin ID".
@@ -93,7 +93,7 @@ export function pluginSourceLabel(source) {
93
93
 
94
94
  /**
95
95
  * Session events that show a turn progressing while no hook runs. OpenCode
96
- * 2.1.2 and 2.1.4 emit one delta event per streamed chunk of answer text,
96
+ * 2.1.2 through 2.2.4 emit one delta event per streamed chunk of answer text,
97
97
  * reasoning or tool-call input; the projected session context shows the text
98
98
  * only once the step ends.
99
99
  */
@@ -107,6 +107,13 @@ const PROGRESS_EVENTS = new Map([
107
107
  ['session.step.ended', 'a model step ended'],
108
108
  ]);
109
109
 
110
+ /**
111
+ * The event types to subscribe to. OpenCode 2.2.0 and later deliver only
112
+ * these (`event.subscribe({ types })`); earlier releases ignore the option and
113
+ * `sessionProgress` skips the rest.
114
+ */
115
+ export const PROGRESS_EVENT_TYPES = Object.freeze([...PROGRESS_EVENTS.keys()]);
116
+
110
117
  /** The session and activity a progress event stands for, or null. */
111
118
  export function sessionProgress(event) {
112
119
  const activity = PROGRESS_EVENTS.get(event?.type);
@@ -115,7 +122,7 @@ export function sessionProgress(event) {
115
122
  }
116
123
 
117
124
  /**
118
- * OpenCode runs plugins on Bun (1.4.2 in 2.0.32 and 2.1.2, 1.4.4 in 2.1.4),
125
+ * OpenCode runs plugins on Bun (1.4.2 in 2.0.32 and 2.1.2, 1.4.4 in 2.1.4 through 2.2.4),
119
126
  * whose fetch accepts per-request `proxy` and `tls` options. Node's fetch
120
127
  * silently ignores both, so a configured proxy would be bypassed; callers
121
128
  * refuse instead.
@@ -144,6 +151,22 @@ export function usageTotals(requests) {
144
151
  return { ...total, cachedInputShare: prompt ? Number((total.cacheRead / prompt).toFixed(4)) : null };
145
152
  }
146
153
 
154
+ /**
155
+ * Provider error types that mean a usage or spend limit is used up. Another
156
+ * attempt fails the same way, so AZPR refuses OpenCode's retries of them and
157
+ * starts no new session. OpenCode 2.2.0 added the spend limits and 2.2.3 the
158
+ * ChatGPT and OpenCode Go usage limits; before, a ChatGPT limit arrived as a
159
+ * rate limit.
160
+ */
161
+ export const USED_UP_LIMITS = Object.freeze({
162
+ 'provider.quota': 'The provider reports the usage quota as used up',
163
+ 'provider.free-limit': "OpenCode reports the free model's usage limit as reached",
164
+ 'provider.chatgpt-limit': 'ChatGPT reports the subscription usage limit as reached',
165
+ 'provider.go-limit': 'OpenCode Go reports its usage limit as reached',
166
+ 'provider.budget-limit': 'OpenCode reports the workspace usage limit as reached',
167
+ 'provider.model-budget-limit': "OpenCode reports this model's spend limit as reached",
168
+ });
169
+
147
170
  /** Throw one readable error naming every missing host method. */
148
171
  export function requireMethods(context, paths, purpose) {
149
172
  const missing = paths.filter(path => typeof path.split('.').reduce((value, key) => value?.[key], context) !== 'function');
@@ -82,18 +82,29 @@ missing instead of guessing.
82
82
 
83
83
  ## Finding quality
84
84
 
85
- Report concrete defects introduced or exposed by this PR, not style preferences,
86
- speculation or unrelated pre-existing issues. Trace callers, guards, retries,
87
- transactions, locks and idempotency before concluding. A defect that needs a
88
- race, an unusual input, a partial failure or a permission boundary counts when
89
- that trigger is reachable; a working happy path excludes nothing. Assess
90
- performance from time, memory and I/O costs at realistic sizes and frequencies.
85
+ Report concrete defects and gaps introduced or exposed by this PR, not generic
86
+ style preferences, speculation or unrelated pre-existing issues. Trace callers,
87
+ guards, retries, transactions, locks and idempotency before concluding. A
88
+ defect that needs a race, an unusual input, a partial failure or a permission
89
+ boundary counts when that trigger is reachable; a working happy path excludes
90
+ nothing. Assess performance from time, memory and I/O costs at realistic sizes
91
+ and frequencies.
91
92
 
92
93
  File every concrete defect you identify as its own entry in `findings`,
93
- whatever your role's focus and however many there are. One entry per root
94
- cause: separately wrong modules or functions are separate findings, even when
95
- they break the same kind of rule; one wrong piece of code that affects many
96
- callers, files or records is one finding at that code, with the affected
94
+ whatever your role's focus and however many there are. One entry per place
95
+ that needs its own correction: separately wrong modules, functions, files or
96
+ routes are separate findings, each at its own lines, even when they repeat the
97
+ same mistake (copied logic, parallel handlers, callers that each make the same
98
+ wrong call) and their summaries match; name the sibling places in each
99
+ finding's evidence. Identical copies of one file among your assigned files (the
100
+ same template, example, document or vendored file repeated with identical
101
+ content in several directories) are one place: file the defect once, at one
102
+ copy, and list the other copies in evidence; copies assigned to other sessions
103
+ are reviewed there, and files whose content differs, such as each package's own
104
+ manifest or configuration, stay separate places. When you find a defect,
105
+ check your other assigned files for the same mistake. One wrong piece of code
106
+ that affects many callers, files or records is one finding at that code, with
107
+ the affected
97
108
  <!-- azpr:verified -->
98
109
  places in evidence. Only `findings` are verified and can become
99
110
  comments; a defect described only in `report` is lost. There is no maximum: do
@@ -119,12 +130,18 @@ Severity measures supported impact, not confidence:
119
130
  a broad service failure with a concrete reachable path.
120
131
  - medium: a material functional or data-correctness failure with bounded impact
121
132
  or practical recovery.
122
- - low: a small but concrete behavioral defect.
123
-
124
- Useful non-defect advice (duplicated logic, design trade-offs, missing tests for
125
- a concrete behavior, outdated documentation) belongs in report with the affected
126
- code, the benefit and a proportionate direction. Zero findings is a valid result
127
- and does not prove the code is bug-free.
133
+ - low: a small but concrete behavioral defect, or a concrete gap (below).
134
+
135
+ Concrete gaps the change leaves are findings too, usually low severity: a
136
+ changed or added behavior that no test would catch where the project already
137
+ tests comparable code (name the missing case and the tests it belongs with), a
138
+ test that cannot fail or checks the wrong thing, a comment, document, example,
139
+ schema or configuration that now contradicts the code, and duplicated, dead,
140
+ misleading or inconsistent code the change introduces. Name the specific code
141
+ and the concrete consequence. Design trade-offs and general advice without a
142
+ specific defect or location belong in report with the affected code, the
143
+ benefit and a proportionate direction. Zero findings is a valid result and does
144
+ not prove the code is bug-free.
128
145
 
129
146
  ## Output
130
147
 
@@ -21,7 +21,8 @@ with AZPR's tools; thinking it over again is not a check:
21
21
  validation, retries, tests) and why they do not refute the finding;
22
22
  - a concern you could not confirm from source goes to `report` as an open
23
23
  question, not to `findings`;
24
- - one entry per root cause, with severity from the decisive impact.
24
+ - one entry per place that needs its own correction, with severity from the
25
+ decisive impact.
25
26
 
26
27
  ## Location
27
28
 
package/src/runtime.mjs CHANGED
@@ -27,7 +27,7 @@ import { API_VERSION, createAzureClient, fetchTransport, pemCertificates, proxyL
27
27
  import { REVIEW_TOOL_NAMES, reviewToolDefinitions, runReviewTool } from './review-tools.mjs';
28
28
  import { runReview } from './review-work.mjs';
29
29
  import { createReviewStore, stateRoot, REVIEW_LIMIT } from './store.mjs';
30
- import { TESTED_HOST_VERSION, fetchTransportSupported, hostCapabilities, listOf, packageNamed, pluginEntries, pluginSourceLabel, recordOf, requireMethods, sessionProgress, tokenUsage, usageTotals, withoutCredentials } from './host.mjs';
30
+ import { PROGRESS_EVENT_TYPES, TESTED_HOST_VERSION, USED_UP_LIMITS, fetchTransportSupported, hostCapabilities, listOf, packageNamed, pluginEntries, pluginSourceLabel, recordOf, requireMethods, sessionProgress, tokenUsage, usageTotals, withoutCredentials } from './host.mjs';
31
31
  import {
32
32
  reviewProvenance, provenanceReport, commentAttribution, renderFinalReport, renderCommentActions,
33
33
  renderIncompleteDraft, renderReceipt, renderDiagnosticNotices, renderCheckReport, renderPublication,
@@ -412,7 +412,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
412
412
  eventFollowers++;
413
413
  if (eventFeed || disposed || !capabilities.eventSubscribe) return;
414
414
  let iterator;
415
- try { iterator = context.event.subscribe()[Symbol.asyncIterator](); } catch { return; }
415
+ try { iterator = context.event.subscribe({ types: [...PROGRESS_EVENT_TYPES] })[Symbol.asyncIterator](); } catch { return; }
416
416
  eventFeed = iterator;
417
417
  void (async () => {
418
418
  try {
@@ -681,7 +681,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
681
681
  }
682
682
  requireMethods(context, ['session.create', 'session.prompt', 'session.wait', 'session.context', 'session.interrupt', 'session.synthetic'], 'the review workflow');
683
683
  let id; do { id = randomUUID().slice(0, 8); } while (runs.has(id) || completed.has(id));
684
- const run = { ...details, id, active: true, controller: new AbortController(), stages: [], toolText: new Map(), compatibility: capabilities,
684
+ const run = { ...details, id, active: true, controller: new AbortController(), stages: [], toolText: new Map(),
685
685
  deadlineAt: settings.runTimeoutSeconds === null ? null : Date.now() + settings.runTimeoutSeconds * 1000 };
686
686
  runs.set(id, run);
687
687
  sourceRuns.set(run.origin, id);
@@ -765,6 +765,10 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
765
765
  else if (modelSlots('deep').every(slot => settings.models.deep[slot] === settings.models.review[slot])) {
766
766
  checks.push({ name: 'Deep models', ok: true, warning: true, detail: 'models.deep repeats models.review, so /pr-deep would only repeat /pr-review; set stronger models there for the PRs that need them.' });
767
767
  }
768
+ // One OpenCode release is validated; on others, reviews still run and what AZPR needs is detected at runtime.
769
+ const host = capabilities.version === 'unknown' ? 'OpenCode did not report its version' : `OpenCode ${capabilities.version}`;
770
+ checks.push(capabilities.tested ? { name: 'OpenCode', ok: true, detail: `${host}, the tested version.` }
771
+ : { name: 'OpenCode', ok: true, warning: true, detail: `${host}; AZPR is tested with ${TESTED_HOST_VERSION}. Reviews still run: AZPR detects what this OpenCode provides and refuses to start if something it needs is missing.` });
768
772
  checks.push(await installationCheck(run));
769
773
  // What follows a COMPLETE review of each mode; automatic publication posts as the PAT owner.
770
774
  const publishing = MODES.filter(mode => settings.afterReview[mode] === 'publish').map(mode => `/pr-${mode}`);
@@ -1223,7 +1227,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1223
1227
  try {
1224
1228
  const g = authorize(event.sessionID, event.agent, event.model);
1225
1229
  // Refused before anything is sent. Whether the stage overflowed is read from its failed turn: a
1226
- // compaction OpenCode attempts there ends it, a background summary (OpenCode 2.1.4) does not.
1230
+ // compaction OpenCode attempts there ends it, a background summary (OpenCode 2.1.4 and later) does not.
1227
1231
  if (event.kind !== 'primary') {
1228
1232
  throw new Error(event.kind === 'compaction'
1229
1233
  ? '[AZPR] Private review compaction is not authorized; a reviewer whose context fills is split into smaller sessions instead.'
@@ -1243,12 +1247,14 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1243
1247
  if (!ownRole(event.agent) && !seenSessions.has(event.sessionID)) return;
1244
1248
  const g = grants.get(event.sessionID);
1245
1249
  const proposed = event.decision?.retry === true;
1250
+ // A used-up usage or spend limit fails every attempt the same way; the failed turn names it.
1251
+ const usedUp = Object.hasOwn(USED_UP_LIMITS, event.error?.type) ? event.error.type : null;
1246
1252
  let authorized = false;
1247
- try { if (g?.run.active) { authorize(event.sessionID, event.agent, event.model); authorized = true; } } catch { /* Revoked. */ }
1253
+ try { if (g?.run.active && !usedUp) { authorize(event.sessionID, event.agent, event.model); authorized = true; } } catch { /* Revoked. */ }
1248
1254
  if (!authorized) event.decision = { retry: false };
1249
1255
  const attempt = Number.isInteger(event.attempt) ? event.attempt : null;
1250
1256
  const delayMs = Number.isFinite(event.decision?.delay) && event.decision.delay > 0 ? event.decision.delay : 0;
1251
- g?.retryEvents.push({ attempt, proposed, allowed: authorized && proposed, ...(delayMs ? { delayMs } : {}) });
1257
+ g?.retryEvents.push({ attempt, proposed, allowed: authorized && proposed, ...(usedUp ? { usedUp } : {}), ...(delayMs ? { delayMs } : {}) });
1252
1258
  // OpenCode waits before it prepares the request again; that wait is not inactivity.
1253
1259
  if (authorized && proposed) touch(g, `the host scheduled a retry${attempt === null ? '' : ` (attempt ${attempt})`}`, delayMs);
1254
1260
  }));
@@ -1256,7 +1262,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
1256
1262
  // Enforce the shell setting and the project boundary, regardless of
1257
1263
  // permission rules the host appends after this plugin. Outside the
1258
1264
  // project only AZPR's own private data is readable; the host's default
1259
- // for other paths is not trusted (OpenCode 2.0.22 asked; 2.0.31 through 2.1.4 allow).
1265
+ // for other paths is not trusted (OpenCode 2.0.22 asked; 2.0.31 through 2.2.4 allow).
1260
1266
  // Private reviewers run unattended: a request that would wait for
1261
1267
  // approval is refused at once. Only shell keeps host approvals, and only
1262
1268
  // when the user allowed it (shell: "ask" or "inherit").
package/src/session.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /** OpenCode V2 session transport. No provider, Azure or HTTP client. */
2
2
  import { isDeepStrictEqual } from 'node:util';
3
- import { FOREIGN_MESSAGE_TYPES, isHostContinuation, requireMethods } from './host.mjs';
3
+ import { FOREIGN_MESSAGE_TYPES, USED_UP_LIMITS, isHostContinuation, requireMethods } from './host.mjs';
4
4
 
5
5
  const pendingAdmissions = new WeakMap();
6
6
  const textValue = value => typeof value === 'string' && value.length > 0;
@@ -104,16 +104,10 @@ function responseError(message, response, execution) {
104
104
  }
105
105
 
106
106
  // Bounded host metadata only; provider bodies can contain private request data.
107
- // Provider errors that a new session cannot fix: the usage limit is used up.
108
- const EXHAUSTED = {
109
- 'provider.quota': 'The provider reports the usage quota as used up',
110
- 'provider.free-limit': "OpenCode reports the free model's usage limit as reached",
111
- };
112
-
113
107
  function providerFailure(final, assistants) {
114
108
  const error = final?.error;
115
109
  if (typeof error?.type !== 'string' || !error.type.startsWith('provider.')) return undefined;
116
- const exhausted = Object.hasOwn(EXHAUSTED, error.type);
110
+ const exhausted = Object.hasOwn(USED_UP_LIMITS, error.type);
117
111
  const status = Number.isInteger(error.status) && error.status >= 400 && error.status <= 599 ? error.status : undefined;
118
112
  if (status === undefined && !exhausted) return undefined;
119
113
  return { ...(status === undefined ? {} : { status }), ...(exhausted ? { exhausted: error.type } : {}),
@@ -171,8 +165,8 @@ export function restartIndex(texts) {
171
165
  * its own failure decides.
172
166
  * - transient: interrupted streams, provider 408/409/425/429/5xx, missing idle,
173
167
  * unexpected host messages.
174
- * - permanent: everything else (authentication, bad request, a used-up quota or
175
- * free-model limit, whatever its HTTP status, cancellation).
168
+ * - permanent: everything else (authentication, bad request, a used-up usage or
169
+ * spend limit, whatever its HTTP status, cancellation).
176
170
  */
177
171
  export function classifyFailure(error) {
178
172
  const execution = error?.execution;
@@ -235,13 +229,13 @@ export async function requestReview(context, { sessionID, text, role, model, met
235
229
  assistantResponses: assistants.length, lastFinish: finish,
236
230
  interrupted: session.outcome === 'interrupted' || terminal?.outcome === 'interrupted' || final?.error?.type === 'aborted' };
237
231
  // OpenCode opens a compaction's message before it asks for the summary, so a compaction it attempted in this
238
- // turn, which AZPR refuses, shows here. A background summary (OpenCode 2.1.4) publishes nothing.
232
+ // turn, which AZPR refuses, shows here. A background summary (OpenCode 2.1.4 and later) publishes nothing.
239
233
  const compaction = turn.filter(message => message?.type === 'compaction').at(-1);
240
234
  if (compaction) execution.compaction = ['running', 'completed', 'failed'].includes(compaction.status) ? compaction.status : 'unknown';
241
235
  const provider = !execution.interrupted && providerFailure(final, assistants);
242
236
  if (provider) execution.provider = provider;
243
237
  const hint = provider?.exhausted
244
- ? ` ${EXHAUSTED[provider.exhausted]} (${provider.exhausted}), so a new session would fail the same way and is not started. Choose another model in the settings or wait until the limit resets.`
238
+ ? ` ${USED_UP_LIMITS[provider.exhausted]} (${provider.exhausted}), so a new session would fail the same way and is not started. Choose another model in the settings or wait until the limit resets.`
245
239
  : [401, 403].includes(provider?.status) ? ' Check provider access and the role\'s tool permissions.' : '';
246
240
  const detail = provider
247
241
  ? `Model provider request failed (${provider.status ? `HTTP ${provider.status}; ` : ''}${provider.toolCallsObserved} tool calls observed).${hint} `