opencode-azure-devops-pr-review 0.3.0 → 0.3.1

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.
@@ -1,60 +1,34 @@
1
1
  # Your first review
2
2
 
3
3
  This guide gets you from a clean installation to a private comment preview.
4
- Use a small, active Azure DevOps Services PR for the first run.
4
+ Use a small, active Azure DevOps Services PR for the first run. Steps 1–3 and
5
+ 5 run in a terminal; steps 4, 6 and 7 run in OpenCode.
5
6
 
6
- ## 1. Check the prerequisites
7
+ Already using an earlier version? Follow [upgrading](../README.md#upgrading)
8
+ instead, to keep your configuration and one AZPR installation.
9
+
10
+ ## 1. Check the prerequisites (terminal)
7
11
 
8
12
  - **OpenCode CLI 2.1.4** (`@opencode/cli`, V2 plugin API), tested on **Ubuntu
9
13
  22.04.5 LTS (WSL2)**. Other host versions and operating systems are not
10
14
  validated; see [validation](VALIDATION.md). OpenCode 1.x is not supported.
11
- - An authenticated OpenCode model with tool support. Copy its exact
12
- `provider/model` ID from your host's model selection or `opencode models`.
15
+ - An authenticated OpenCode model with tool support, and its exact
16
+ `provider/model` ID from `opencode models` or your host's model selection.
13
17
  AZPR uses your existing provider account.
14
- - Access to the npm registry for the npm package, or Git for the Git package.
15
- The alternative source installer needs POSIX `sh` and Python 3. AZPR has no
16
- build step or npm dependencies.
17
- - An organization-scoped Azure DevOps PAT. The recommended scopes are **Code:
18
- Read** and **Pull Request Threads: Read & write**; see
18
+ - Your Azure DevOps organization (the `<org>` in `https://dev.azure.com/<org>`)
19
+ and an organization-scoped PAT. The recommended scopes are **Code: Read** and
20
+ **Pull Request Threads: Read & write**; see
19
21
  [access and validation limits](ENTERPRISE.md).
20
-
21
- Check the host version:
22
+ - Access to the npm registry for the npm package, or Git for the Git package.
23
+ AZPR has no build step or npm dependencies. Behind a company proxy, set up
24
+ the terminal first: see [company networks](ENTERPRISE.md#company-networks).
22
25
 
23
26
  ```sh
24
27
  opencode --version
28
+ opencode models
25
29
  ```
26
30
 
27
- ## 2. Install v0.3.0
28
-
29
- Already using an earlier version? Follow the [upgrade instructions](releases/v0.3.0.md#upgrading)
30
- to preserve your current configuration and use one AZPR installation.
31
-
32
- In your terminal:
33
-
34
- ```sh
35
- opencode plugin add opencode-azure-devops-pr-review@0.3.0
36
- ```
37
-
38
- Restart OpenCode and open an ordinary conversation. This is the host's native
39
- package installation; no npm account or separate build is needed. The
40
- plugin exposes `/pr-setup` even before its review configuration exists.
41
-
42
- To install the same release from Git instead of the npm registry, use
43
- `opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.0'`.
44
- Add only one of the two.
45
-
46
- For an existing source installation, keep using `install.sh --replace`, or
47
- follow the migration notes in [installation](../README.md#native-package-npm-or-git).
48
- Do not load both copies in the same OpenCode profile.
49
-
50
- Prefer a source archive? Download and extract the
51
- [v0.3.0 archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.3.0.tar.gz),
52
- then run `sh install.sh --config-dir /absolute/path/to/your/opencode-config`
53
- inside it. That directory must be the one your OpenCode actually loads. The
54
- source installer creates starter settings; add `--replace` to the setup
55
- command below to configure that existing file.
56
-
57
- ## 3. Configure one model and your Azure organization
31
+ ## 2. Save the PAT in a private file (terminal)
58
32
 
59
33
  Put the PAT alone in a file only you can read. The following **Bash** example
60
34
  creates a new file and refuses to overwrite an existing one. Input is hidden
@@ -73,26 +47,52 @@ mkdir -p "$AZPR_USER_DIR"
73
47
  printf 'PAT file: %s\n' "$AZPR_USER_DIR/pat"
74
48
  ```
75
49
 
76
- If the file already exists, reuse your existing owner-only PAT file, or choose
77
- another unused path. Do not paste a PAT into a conversation or command argument.
50
+ This is the default PAT file that `/pr-setup` uses. If the file already
51
+ exists, reuse your existing owner-only PAT file, or choose another unused path
52
+ and name it with `--pat-file` in step 4. Do not paste a PAT into a
53
+ conversation or command argument.
78
54
 
79
- In OpenCode, run `/pr-setup` to see the settings path and available model IDs.
80
- Then replace all three placeholders in this command:
55
+ ## 3. Install the package (terminal)
56
+
57
+ ```sh
58
+ opencode plugin add opencode-azure-devops-pr-review@0.3.1
59
+ ```
60
+
61
+ This is the host's native package installation; no npm account or separate
62
+ build is needed. OpenCode 2.1.4 loads the plugin into a running OpenCode
63
+ service within a few seconds, and otherwise when OpenCode next starts. The
64
+ plugin exposes `/pr-setup` even before its review configuration exists.
65
+
66
+ To install the same release from Git instead of the npm registry, use
67
+ `opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.1'`.
68
+ Add only one of the two. For a source archive or an existing source
69
+ installation, see [other installation methods](#other-installation-methods).
70
+
71
+ ## 4. Configure one model and your Azure organization (OpenCode)
72
+
73
+ Open OpenCode and start an ordinary conversation. If `/pr-setup` is not
74
+ listed, run `opencode service restart` in your terminal and reopen OpenCode.
75
+
76
+ Run `/pr-setup` alone to see the settings path, the default PAT file and the
77
+ available model IDs. Then replace both placeholders in this command:
81
78
 
82
79
  ```text
83
- /pr-setup --organization YOUR_ORGANIZATION --model YOUR_PROVIDER/YOUR_MODEL --pat-file "/absolute/path/to/azpr/pat"
80
+ /pr-setup --organization YOUR_ORGANIZATION --model YOUR_PROVIDER/YOUR_MODEL
84
81
  ```
85
82
 
86
- Use the organization name from `https://dev.azure.com/<organization>`, not the
87
- full URL. Use the absolute PAT file path printed above. The command checks the
88
- model catalog and the PAT file, then saves configuration with owner-only
89
- permissions. It makes no model request and does not contact Azure.
83
+ Use the organization name from `https://dev.azure.com/<organization>`;
84
+ `--organization` also accepts your PR's URL. Add
85
+ `--pat-file "/absolute/path/to/pat"` when your PAT file is not the default one
86
+ from step 2. The command checks the model catalog and the PAT file, then saves
87
+ configuration with owner-only permissions. It makes no model request and does
88
+ not contact Azure.
90
89
 
91
90
  One model selection configures the quick reviewer and all three review roles.
92
91
  `/pr-quick` still runs only its own reviewer; `/pr-review` uses separate reviewer
93
92
  and verifier sessions. Deep models remain unset until you choose stronger
94
93
  models for that mode. Setup preserves other settings when explicitly replacing
95
- an existing file with `--replace`.
94
+ an existing file with `--replace`, and then keeps the PAT file already set
95
+ unless you name another one.
96
96
 
97
97
  Native installations save settings outside the package cache at
98
98
  `${XDG_CONFIG_HOME:-~/.config}/azpr/settings.json`. Source installations keep
@@ -100,24 +100,29 @@ Native installations save settings outside the package cache at
100
100
  `options.settingsFile` can select a different absolute path; see
101
101
  [configuration](../README.md#configuration).
102
102
 
103
- **Restart the OpenCode service after saving.** Settings are read once at plugin
104
- startup; closing a conversation or reopening the terminal UI alone does not
105
- reload a running background service. For the usual managed service, run this
106
- in your terminal, then reopen OpenCode:
103
+ Make any other changes to that settings file now, before the restart in step 5:
104
+ behind a company proxy, AZPR's Azure DevOps requests need `azure.proxy` (and
105
+ `azure.caFile` for a company CA) as described in
106
+ [company networks](ENTERPRISE.md#company-networks); leave `shell: "deny"` and TLS
107
+ verification enabled. See [all settings](../README.md#all-settings-and-defaults)
108
+ for output language and other options, and
109
+ [model configuration](../README.md#configuration) for model variants and
110
+ separate models for each role.
111
+
112
+ ## 5. Restart the OpenCode service (terminal)
113
+
114
+ Settings are read when OpenCode loads AZPR, so restart the service once after
115
+ saving them:
107
116
 
108
117
  ```sh
109
118
  opencode service restart
110
119
  ```
111
120
 
112
- If you run `opencode serve` yourself, restart that process instead.
113
- If your network needs a proxy or company CA, configure it in that settings file
114
- as described in [enterprise setup](ENTERPRISE.md), then restart. Leave
115
- `shell: "deny"` and TLS verification enabled. See
116
- [all settings](../README.md#all-settings-and-defaults) for output language and
117
- other options, and [model configuration](../README.md#configuration) for model
118
- variants and separate models for each role.
121
+ If you run `opencode serve` yourself, restart that process instead. Closing a
122
+ conversation or reopening the terminal UI alone does not reload a running
123
+ background service.
119
124
 
120
- ## 4. Check access without a model request
125
+ ## 6. Check access without a model request (OpenCode)
121
126
 
122
127
  In OpenCode, replace this sample with your PR's URL:
123
128
 
@@ -131,14 +136,15 @@ it neither runs a review nor tests model-provider authentication or Azure write
131
136
  permissions. Fix any `NOT_READY` result before continuing. A **Quick model
132
137
  WARNING** also needs fixing before `/pr-quick`, even if the overall result is
133
138
  `READY`; a **Deep model** WARNING likewise before `/pr-deep`. The **Deep models**
134
- row says whether `/pr-deep` is set up (see below).
139
+ row says whether `/pr-deep` is set up (see below), and the **AZPR** row names
140
+ the installation that answered.
135
141
 
136
142
  On a host without `permission.hook`, **Project boundary WARNING** means the
137
143
  host's own permission rules control where native read tools can read; reviews
138
144
  remain available. The tested OpenCode 2.1.4 host has that hook. `READY` is an
139
145
  access check, not a security audit or an approval of the PR.
140
146
 
141
- ## 5. Run a review and preview its comments
147
+ ## 7. Run a review and preview its comments (OpenCode)
142
148
 
143
149
  ```text
144
150
  /pr-review https://dev.azure.com/YOUR_ORGANIZATION/YOUR_PROJECT/_git/YOUR_REPO/pullrequest/123 --preview
@@ -217,3 +223,16 @@ in all three deep slots and keep it for changes that justify the cost; with
217
223
  the review's models it would only repeat `/pr-review`, and `/pr-check` warns
218
224
  about that. All modes produce AI findings that require human judgment; see
219
225
  [commands](../README.md#commands).
226
+
227
+ ## Other installation methods
228
+
229
+ For an existing source installation, keep using `install.sh --replace`, or
230
+ follow the migration notes in [installation](../README.md#native-package-npm-or-git).
231
+ Do not load both copies in the same OpenCode profile.
232
+
233
+ Prefer a source archive? Download and extract the
234
+ [v0.3.1 archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.3.1.tar.gz),
235
+ then run `sh install.sh --config-dir /absolute/path/to/your/opencode-config`
236
+ inside it. That directory must be the one your OpenCode actually loads. The
237
+ source installer creates starter settings, so add `--replace` to the setup
238
+ command in step 4, then restart the OpenCode service as in step 5.
@@ -1,8 +1,8 @@
1
1
  # Validation
2
2
 
3
- This page records validation of the Azure DevOps REST implementation and the
4
- 0.1.0, 0.2.0, 0.2.1, 0.2.2 and 0.2.3 distributions, and the 0.3.0 release
5
- candidate. Host integration, provider
3
+ This page records validation of the Azure DevOps REST implementation, the
4
+ 0.1.0 through 0.3.0 distributions and the 0.3.1 release candidate. Host
5
+ integration, provider
6
6
  admission, source fidelity, model quality and publication are separate claims; a
7
7
  passing fixture establishes only the first. Earlier revisions and their live
8
8
  acceptance runs, including the MCP-based runs, are preserved in
@@ -32,6 +32,64 @@ These checks show that the workflow works and what it found on these test
32
32
  PRs. Findings vary between models and runs, so they are not a general
33
33
  accuracy score; see [known limitations](#known-limitations).
34
34
 
35
+ ## 0.3.1 release candidate acceptance (2026-10-27)
36
+
37
+ Environment: Ubuntu 22.04.5 under WSL2, Node 22.23.3, npm 10.9.9 and OpenCode
38
+ CLI 2.1.4. The candidate contains the installation, setup and upgrade changes
39
+ of PR #31 and the fixes from its review (commits `6e2c71e` and `4b3b6af`).
40
+ Release preparation changes the package version, changelog, release notes,
41
+ version pins and documentation; the runtime, prompts, settings and installers
42
+ are those of the reviewed commits.
43
+
44
+ - `npm run check` and **420 offline tests** passed, including the `/pr-check`
45
+ AZPR row, masked package specifications and the `/pr-setup` defaults.
46
+ - All five real-host fixtures passed with isolated profiles and fake model and
47
+ Azure services: fresh source installation, replacement installation, native
48
+ packed package installation, comment scale and background compaction. The
49
+ native run also covers setup with the default PAT file and a PR URL, the
50
+ AZPR row and a second AZPR entry that stays unloaded. The scale fixture's
51
+ largest provider request was 33,419 characters, as for 0.3.0.
52
+ - `npm pack --dry-run --json` lists **76 files**, adding the 0.3.1 release
53
+ notes. Tests, private settings and `.local/` records are excluded.
54
+ - No paid-model request or real Azure publication was made: setup and the
55
+ AZPR row make neither, and reviews and publication are unchanged from 0.3.0.
56
+
57
+ This is a pre-publication record. Public Git installation and clean-source
58
+ archive acceptance are checked on the release candidate; registry integrity
59
+ and installation from npm are checked only after publication, following the
60
+ [releasing guide](RELEASING.md).
61
+
62
+ ## Installation, setup and upgrades on OpenCode 2.1.4 (2026-10-27)
63
+
64
+ Environment: Ubuntu 22.04.5 under WSL2, OpenCode CLI 2.1.4 and the published
65
+ packages 0.2.2, 0.2.3 and 0.3.0 from npm. Each probe used an isolated profile
66
+ (its own `XDG_*` directories and `OPENCODE_CONFIG_DIR`) with `opencode serve`
67
+ and OpenCode's file watcher on, as in a normal installation. Where a proxy was
68
+ set, a loopback proxy recorded and refused every request. No model or Azure
69
+ DevOps request was made.
70
+
71
+ | Step | Observed |
72
+ | --- | --- |
73
+ | `opencode plugin add …@0.2.3` while the server runs | Installed in 1.2 s; the running server listed the seven commands 0.5 s later, without a restart. |
74
+ | `opencode plugin add …@0.3.0` with 0.2.3 configured | A second entry: 0.2.3 kept running and 0.3.0 was listed as failed with `Duplicate plugin ID: azpr`. |
75
+ | `opencode plugin remove …@0.2.3` | 0.3.0 was running 0.5 s later, without a restart. |
76
+ | `/pr-setup` saved settings | The commands still answered `SETUP REQUIRED` until the plugin was loaded again. |
77
+ | Changing the version in the `plugins` entry | The running server switched versions within 0.5 s. A long-running managed service on the same machine had likewise loaded each of three earlier entry changes before its planned restart. |
78
+ | The same change to a version not yet installed, with the server behind the refusing proxy | The server downloaded it itself (`CONNECT registry.npmjs.org:443` through its proxy). AZPR's commands disappeared, and installing the package from the terminal did not bring them back until the server restarted. |
79
+ | `plugin add` with `HTTPS_PROXY`, `npm_config_https_proxy` or `https-proxy` in `~/.npmrc` | Each sent `CONNECT registry.npmjs.org:443` to the proxy, and the refusal failed the command (HTTP 403). `plugin add` writes the configuration only after a successful download. |
80
+
81
+ `tests/host-v2-smoke.mjs --native` now also checks on the exact host that
82
+ `/pr-setup` takes the organization from a PR URL and uses the default PAT file
83
+ without `--pat-file`, that `/pr-check` names the running package, and that a
84
+ second AZPR entry stays unloaded (`Duplicate plugin ID: azpr`) while
85
+ `/pr-check` warns about it. The fresh and replacement runs check that the row
86
+ names a local source installation.
87
+
88
+ Not covered: the terminal UI's command list after a reload, what a reload does
89
+ to a command that is running, authenticating or NTLM proxies and company CAs
90
+ for package downloads, Git-package downloads through a proxy, and proxy
91
+ inheritance between Windows and WSL.
92
+
35
93
  ## 0.3.0 release candidate acceptance (2026-10-26)
36
94
 
37
95
  Environment: Ubuntu 22.04.5 under WSL2, Node 22.23.3, npm 10.9.9 and OpenCode
@@ -77,7 +135,10 @@ This is a pre-publication record. Public Git installation and clean-source
77
135
  archive acceptance are checked on the release candidate; registry integrity
78
136
  and installation from npm are checked only after publication, following the
79
137
  [releasing guide](RELEASING.md). This record does not claim a published 0.3.0
80
- package has been tested.
138
+ package has been tested. After publication on 2026-10-26, the registry
139
+ package's integrity matched the package built from the tag, and installing
140
+ `opencode-azure-devops-pr-review@0.3.0` and the `v0.3.0` Git tag passed
141
+ `host-v2-smoke.mjs --native --package`.
81
142
 
82
143
  ## Adjusting findings after a preview (2026-10-25)
83
144
 
@@ -460,7 +460,7 @@ lost advice across stages, unjustified defect severity and filler topic sections
460
460
 
461
461
  A release report distinguishes offline checks, exact-host fixtures, live service
462
462
  behavior, factual/presentation quality and remote publication. Mark unexercised
463
- cases explicitly. See [comment acceptance](COMMENTING.md#acceptance-test-before-real-use),
463
+ cases explicitly. See [comment acceptance](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/blob/c450fddef5c90d16dac03373052d89febdb8f2fd/docs/COMMENTING.md#acceptance-test-before-real-use),
464
464
  [project verification](VERIFICATION.md) and [debugging](DEBUGGING.md) for details.
465
465
 
466
466
  ## 2026-10-06 prompt-only BASE/HEAD direction acceptance
@@ -651,7 +651,7 @@ change that historical run, recreate its cache, or verify live publication.
651
651
 
652
652
  No additional live model review or publication tested these post-comparison
653
653
  changes. Cold MCP tool-registration timing remains unresolved; see
654
- [startup diagnostics](DEBUGGING.md#connected-mcp-before-tool-registration).
654
+ [startup diagnostics](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/blob/c450fddef5c90d16dac03373052d89febdb8f2fd/docs/DEBUGGING.md#connected-mcp-before-tool-registration).
655
655
 
656
656
  ## 2026-10-05 remote-source guidance and provider diagnostics
657
657
 
@@ -0,0 +1,87 @@
1
+ # Azure DevOps PR Review for OpenCode — 0.3.1
2
+
3
+ This release makes installation, first-run setup and upgrades easier to
4
+ follow on OpenCode 2.1.4, and lets `/pr-check` show which AZPR is running.
5
+ Reviews, comment previews, adjustments and publication work as in 0.3.0.
6
+
7
+ ## What changed
8
+
9
+ - **Shorter setup.** `/pr-setup --organization YOUR_ORGANIZATION --model
10
+ PROVIDER/MODEL` uses the PAT file the quickstart creates,
11
+ `${XDG_CONFIG_HOME:-~/.config}/azpr/pat`, and `--organization` also accepts
12
+ your PR's URL. With `--replace`, setup keeps the PAT file already set unless
13
+ you name another one. The receipt names the organization and the PAT file.
14
+ - **See what runs.** `/pr-check` has an **AZPR** row that names the running
15
+ package and version. When another AZPR entry is configured but not running,
16
+ for example after `opencode plugin add` with a new version, which leaves the
17
+ old one running, the row is a WARNING. User names, passwords and query
18
+ strings in package specifications are masked.
19
+ - **Restart only for settings.** On OpenCode 2.1.4, adding or changing the
20
+ plugin entry loads it into the running service within seconds. Saved
21
+ settings still need a restart, and AZPR's messages now name
22
+ `opencode service restart`.
23
+ - **Documentation.** The quickstart runs the terminal steps first. The README
24
+ has an Upgrading section. The team guide explains proxies and certificates
25
+ for package downloads, model providers and Azure DevOps separately, and the
26
+ Azure DevOps guide names the actual settings locations.
27
+
28
+ ## Installation
29
+
30
+ ```sh
31
+ opencode plugin add opencode-azure-devops-pr-review@0.3.1
32
+ ```
33
+
34
+ Alternatively, install the same release from Git:
35
+
36
+ ```sh
37
+ opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.1'
38
+ ```
39
+
40
+ Add only one of them. Follow the
41
+ [quickstart](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/blob/v0.3.1/docs/QUICKSTART.md)
42
+ for a private PAT file, `/pr-setup`, a service restart and the first review.
43
+
44
+ ## Upgrading
45
+
46
+ For an entry that `opencode plugin add` created, add 0.3.1 and remove the
47
+ previous version only when the download succeeded. Replace `PREVIOUS_VERSION`
48
+ with the version in your `plugins` entry, such as 0.3.0:
49
+
50
+ ```sh
51
+ opencode plugin add opencode-azure-devops-pr-review@0.3.1 &&
52
+ opencode plugin remove opencode-azure-devops-pr-review@PREVIOUS_VERSION
53
+ ```
54
+
55
+ Run them when no AZPR command is running: OpenCode 2.1.4 switches the running
56
+ service to 0.3.1 within seconds, without a restart, and `opencode plugin list`
57
+ should then show a single `azpr` row with 0.3.1. Running only the first command
58
+ leaves the previous version running. For an entry with options, change only
59
+ its `package` value; the OpenCode service then downloads 0.3.1 with its own
60
+ network settings. See
61
+ [upgrading](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/blob/v0.3.1/README.md#upgrading)
62
+ for the details. External settings, the PAT file and review records remain in
63
+ place, and this release adds no settings or required migration.
64
+
65
+ For a source installation, extract the new archive and run its installer with
66
+ `--replace` to retain settings:
67
+
68
+ ```sh
69
+ sh install.sh --config-dir /absolute/path/to/v2-opencode-config --replace
70
+ ```
71
+
72
+ ## Compatibility and validation
73
+
74
+ The tested target remains OpenCode CLI **2.1.4** (V2 plugin API), Node.js
75
+ **22.23.3**, Ubuntu **22.04.5** under WSL2, and Azure DevOps Services REST API
76
+ **7.1**. OpenCode 1.x and Azure DevOps Server are not supported; other operating
77
+ systems remain unvalidated.
78
+
79
+ The [validation record](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/blob/v0.3.1/docs/VALIDATION.md)
80
+ describes the installation and upgrade behaviour measured on OpenCode 2.1.4
81
+ and the release checks with fake services. Setup and the AZPR row make no model
82
+ or Azure request, and reviews and publication are unchanged, so this release
83
+ needed no live model run.
84
+
85
+ The npm package, Git package and source archive contain the same runtime, with
86
+ no npm dependencies or install scripts. The release source artifact is
87
+ `opencode-azure-devops-pr-review-v2-0.3.1.tar.gz`, with checksums in `SHA256SUMS`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-azure-devops-pr-review",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
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": {
package/src/azure.mjs CHANGED
@@ -52,6 +52,21 @@ const clean = value => String(value ?? '').replace(/[\x00-\x1f\x7f]+/g, ' ').rep
52
52
  export const normalizePath = path => (path.startsWith('/') ? path : '/' + path);
53
53
  export const isCommitSha = sha;
54
54
 
55
+ /** An organization name as given, or the organization of an HTTPS dev.azure.com/<org>/… or <org>.visualstudio.com URL. */
56
+ export function organizationName(raw) {
57
+ if (typeof raw !== 'string' || !/^https?:\/\//i.test(raw.trim())) return raw;
58
+ let url;
59
+ try { url = new URL(raw.trim()); } catch { url = null; }
60
+ if (!url || url.protocol !== 'https:' || url.username || url.password || url.port) {
61
+ throw new Error('[AZPR] Use an organization name, or an HTTPS Azure DevOps URL without credentials or a custom port.');
62
+ }
63
+ if (url.hostname.toLowerCase() === 'dev.azure.com') {
64
+ try { return decodeURIComponent(url.pathname.split('/').filter(Boolean)[0] ?? ''); } catch { return ''; }
65
+ }
66
+ if (/^[a-z0-9-]+\.visualstudio\.com$/i.test(url.hostname)) return url.hostname.split('.')[0];
67
+ throw new Error('[AZPR] Only dev.azure.com and <organization>.visualstudio.com URLs name an organization.');
68
+ }
69
+
55
70
  /**
56
71
  * Parse an Azure DevOps Services PR URL. Only cloud URLs are supported; the
57
72
  * REST client always talks to dev.azure.com/<organization>.
@@ -317,7 +332,7 @@ export function createAzureClient({ organization, pat, baseUrl = DEFAULT_BASE_UR
317
332
  function intermediaryFailure(status, label, method, forwarded = true) {
318
333
  if (status === 407) {
319
334
  return new AzureError(`A proxy refused ${label}: it requires authentication (HTTP 407).`, { kind: 'proxy', status,
320
- hint: 'Put the proxy user name and password in azure.proxy (http://user:password@host:port, percent-encoded) and restart OpenCode.' });
335
+ hint: 'Put the proxy user name and password in azure.proxy (http://user:password@host:port, percent-encoded) and restart the OpenCode service (opencode service restart).' });
321
336
  }
322
337
  // A gateway that already forwarded a write may have delivered it.
323
338
  return new AzureError(`A proxy or gateway answered ${label} with HTTP ${status} instead of Azure DevOps (no Azure DevOps response headers).`, {
@@ -332,7 +347,7 @@ export function createAzureClient({ organization, pat, baseUrl = DEFAULT_BASE_UR
332
347
  const detail = clean(body?.message);
333
348
  const suffix = `${code ? ` ${code}` : ''}${detail ? `: ${detail}` : ''}`;
334
349
  if (status === 203 || status === 401 || (status >= 300 && status < 400)) {
335
- return new AzureError(`Azure DevOps rejected the PAT for organization "${organization}" (HTTP ${status}). Check that the PAT (azure.pat, or the file named by azure.patFile) is valid, not expired and created for this organization, then restart OpenCode.`, { kind: 'auth', status });
350
+ return new AzureError(`Azure DevOps rejected the PAT for organization "${organization}" (HTTP ${status}). Check that the PAT (azure.pat, or the file named by azure.patFile) is valid, not expired and created for this organization, then restart the OpenCode service (opencode service restart).`, { kind: 'auth', status });
336
351
  }
337
352
  if (status === 403) return new AzureError(`Azure DevOps refused ${label} (HTTP 403${suffix}). The PAT needs Code (Read) and Pull Request Threads (Read & write) for this organization.`, { kind: 'permission', status, code });
338
353
  if (status === 404) return new AzureError(`Azure DevOps could not find ${label} (HTTP 404${suffix}).`, { kind: 'not-found', status, code });
@@ -367,7 +382,7 @@ export function createAzureClient({ organization, pat, baseUrl = DEFAULT_BASE_UR
367
382
  // A rejected certificate fails the handshake before anything is sent; retrying cannot help.
368
383
  if (CERTIFICATE_CODES.test(known)) {
369
384
  throw new AzureError(`Azure DevOps ${label} failed: the server's TLS certificate was not accepted (${clean(known)}).`, { kind: 'tls', code: known, cause: error,
370
- hint: 'If a proxy inspects HTTPS, set azure.caFile to its root CA certificate (PEM) and restart OpenCode.' });
385
+ hint: 'If a proxy inspects HTTPS, set azure.caFile to its root CA certificate (PEM) and restart the OpenCode service (opencode service restart).' });
371
386
  }
372
387
  throw new AzureError(`Azure DevOps ${label} failed: network error${code ? ` (${clean(code)})` : ''}.`, { kind: 'network', transient: true, cause: error,
373
388
  uncertain: method !== 'GET' && !NOT_SENT_CODES.test(known),
package/src/config.mjs CHANGED
@@ -5,6 +5,11 @@ import { REVIEW_TOOL_NAMES } from './review-tools.mjs';
5
5
  export const MODES = Object.freeze(['review', 'deep', 'quick']);
6
6
  export const COMMANDS = Object.freeze({ 'pr-check': 'check', 'pr-review': 'review', 'pr-deep': 'deep', 'pr-quick': 'quick', 'pr-stop': 'stop', 'pr-comment': 'comment' });
7
7
 
8
+ // How the host identifies this plugin and its published packages in its plugin list.
9
+ export const PLUGIN_ID = 'azpr';
10
+ export const PACKAGE_NAME = 'opencode-azure-devops-pr-review';
11
+ export const REPOSITORY = 'WTLAIB/opencode-azure-devops-pr-review-v2';
12
+
8
13
  // Native tools no private role may use. Shell is governed by the `shell` setting.
9
14
  export const NATIVE_TOOL_PERMISSIONS = Object.freeze({
10
15
  execute: 'deny', edit: 'deny', write: 'deny', patch: 'deny', skill: 'deny', subagent: 'deny',
package/src/host.mjs CHANGED
@@ -44,9 +44,53 @@ export function hostCapabilities(context) {
44
44
  toolTransform: fn('tool.transform'),
45
45
  sessionRemove: fn('session.remove'),
46
46
  eventSubscribe: fn('event.subscribe'),
47
+ pluginList: fn('plugin.list'),
47
48
  };
48
49
  }
49
50
 
51
+ /** Whether a package specification names the npm package, or the Git repository (github:, git URLs, owner/repo). */
52
+ export function packageNamed(target, name, repository) {
53
+ const spec = typeof target === 'string' ? target.trim() : '';
54
+ if (spec === name || spec.startsWith(`${name}@`)) return true;
55
+ const repo = repository.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
56
+ return new RegExp(`(?:^|[:/])${repo}(?:\\.git)?(?:[?#]|$)`).test(spec.toLowerCase());
57
+ }
58
+
59
+ /**
60
+ * This plugin's entries in the host's plugin list. OpenCode 2.1.4 lists
61
+ * { id?, source: { type: package|local|builtin|sdk, target?, version? },
62
+ * state: { status: active|failed, error? } } and keeps only the first entry
63
+ * of a plugin ID: a second one is listed as failed with "Duplicate plugin ID".
64
+ * `running` is the active entry with the plugin's ID; `others` are the other
65
+ * entries with that ID or naming one of its packages. null without a list.
66
+ */
67
+ export function pluginEntries(value, { id, ownPackage }) {
68
+ const entries = listOf(value);
69
+ if (!entries) return null;
70
+ const ours = entries.filter(entry => isRecord(entry) && (entry.id === id || (entry.source?.type === 'package' && ownPackage(entry.source.target))));
71
+ const running = ours.find(entry => entry.id === id && entry.state?.status === 'active') ?? null;
72
+ return { running, others: ours.filter(entry => entry !== running) };
73
+ }
74
+
75
+ /**
76
+ * Text with each URL's user name, password and query string masked: a Git or
77
+ * tarball package specification, and host messages that quote one, can carry
78
+ * a token there.
79
+ */
80
+ export function withoutCredentials(text) {
81
+ return String(text ?? '').replace(/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/?#]*@)?([^\s?#]*)(\?[^\s#]*)?/gi,
82
+ (match, scheme, userinfo, rest, query) => `${scheme}${userinfo ? '***@' : ''}${rest}${query ? '?***' : ''}`);
83
+ }
84
+
85
+ /** A path- and credential-free label for a plugin list entry's source: its package specification and installed version or commit. */
86
+ export function pluginSourceLabel(source) {
87
+ if (source?.type === 'local') return 'a local source installation';
88
+ if (source?.type !== 'package' || typeof source.target !== 'string') return 'an entry of unknown origin';
89
+ const version = typeof source.version === 'string' && source.version && !source.target.endsWith(`@${source.version}`) && !source.target.endsWith(`#${source.version}`)
90
+ ? /^[a-f0-9]{40}(?:[a-f0-9]{24})?$/i.test(source.version) ? `commit ${source.version.slice(0, 7)}` : `version ${source.version}` : '';
91
+ return `${withoutCredentials(source.target)}${version ? ` (${version})` : ''}`;
92
+ }
93
+
50
94
  /**
51
95
  * Session events that show a turn progressing while no hook runs. OpenCode
52
96
  * 2.1.2 and 2.1.4 emit one delta event per streamed chunk of answer text,
package/src/plugin.js CHANGED
@@ -1,7 +1,8 @@
1
+ import { PLUGIN_ID } from './config.mjs';
1
2
  import { setupPlugin } from './setup.mjs';
2
3
 
3
4
  // Pure OpenCode V2 definition; the host supplies its domain APIs.
4
5
  export default {
5
- id: 'azpr',
6
+ id: PLUGIN_ID,
6
7
  setup: setupPlugin,
7
8
  };
package/src/runtime.mjs CHANGED
@@ -15,7 +15,7 @@ import { dirname, join } from 'node:path';
15
15
  import { fileURLToPath } from 'node:url';
16
16
  import { randomUUID, X509Certificate } from 'node:crypto';
17
17
  import { createReviewSession, requestReview, interruptSession, appendReport, classifyFailure } from './session.mjs';
18
- import { COMMANDS, MODES, ROLES, PROMPTS, roleFor, privateAgent, commentRole, allowedTools, buildAgents, validateSettings, modelRef, modelSlots, commentSlot, patProblem } from './config.mjs';
18
+ import { COMMANDS, MODES, ROLES, PROMPTS, PLUGIN_ID, PACKAGE_NAME, REPOSITORY, roleFor, privateAgent, commentRole, allowedTools, buildAgents, validateSettings, modelRef, modelSlots, commentSlot, patProblem } from './config.mjs';
19
19
  import { parseUniqueJSON, parseReviewRequest, parseCommentRequest, visibleText } from './output.mjs';
20
20
  import { createDiagnostics, diagnosticResponse, diagnosticToolError, createStageTiming, collectToolObservations } from './diagnostics.mjs';
21
21
  import { createCommentData, captureObservation, PAGE_CHARACTERS, COMMENT_TURN_CHARACTERS } from './comment-data.mjs';
@@ -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, recordOf, requireMethods, sessionProgress, tokenUsage, usageTotals } from './host.mjs';
30
+ import { TESTED_HOST_VERSION, 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,
@@ -270,9 +270,9 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
270
270
  const signal = run.controller.signal;
271
271
  let now;
272
272
  try { now = await scoped(() => readFile(settingsPath, 'utf8'), signal); } catch { throw new Error('[AZPR] settings.json is not readable.'); }
273
- if (now !== state.raw) throw new Error('[AZPR] settings.json changed since OpenCode loaded it. Restart OpenCode to use the new settings; running reviews are unaffected.');
273
+ if (now !== state.raw) throw new Error('[AZPR] settings.json changed since OpenCode loaded it. Restart the OpenCode service (opencode service restart) to use the new settings; running reviews are unaffected.');
274
274
  if (settings.azure.patFile && await scoped(() => readPatFile(settings.azure.patFile), signal) !== pat) {
275
- throw new Error('[AZPR] azure.patFile changed since OpenCode loaded it. Restart OpenCode to use the new PAT; running reviews are unaffected.');
275
+ throw new Error('[AZPR] azure.patFile changed since OpenCode loaded it. Restart the OpenCode service (opencode service restart) to use the new PAT; running reviews are unaffected.');
276
276
  }
277
277
  await checkCommands(signal);
278
278
  await pinAgents(run.profile, signal);
@@ -728,6 +728,27 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
728
728
  const ownerOf = sessionID => [...completed.values()].find(review => review.reportSessions.has(sessionID))?.origin
729
729
  ?? [...runs.values()].find(run => run.stages.some(stage => stage.sessionID === sessionID))?.origin ?? sessionID;
730
730
 
731
+ // Which installation answers, and other AZPR entries the host configured but does not run (such as a second version).
732
+ async function installationCheck(run) {
733
+ if (!capabilities.pluginList) return { name: 'AZPR', ok: true, detail: 'This OpenCode does not list its plugins, so the running version is not shown.' };
734
+ let entries;
735
+ try {
736
+ entries = pluginEntries(await bounded(() => context.plugin.list(), run.controller.signal),
737
+ { id: PLUGIN_ID, ownPackage: target => packageNamed(target, PACKAGE_NAME, REPOSITORY) });
738
+ } catch (error) {
739
+ if (!run.active) throw error;
740
+ return { name: 'AZPR', ok: true, detail: `The plugin list could not be read (${errorText(error)}).` };
741
+ }
742
+ if (!entries) return { name: 'AZPR', ok: true, detail: 'OpenCode returned no plugin list, so the running version is not shown.' };
743
+ const running = entries.running ? `Running ${pluginSourceLabel(entries.running.source)}` : 'This installation is not listed as running';
744
+ if (!entries.others.length) return { name: 'AZPR', ok: true, detail: `${running}.` };
745
+ // The advice comes first: a long package specification may be cut off at the end of the row.
746
+ // Host errors can quote the entry's specification, so mask credentials before shortening them.
747
+ const others = entries.others.map(entry => `${pluginSourceLabel(entry.source)}${typeof entry.state?.error === 'string' ? ` (${withoutCredentials(entry.state.error).slice(0, 80)})` : ''}`);
748
+ return { name: 'AZPR', ok: true, warning: true,
749
+ detail: `Another AZPR entry is configured but not running; keep one (see Upgrading in the README). ${running}; not running: ${others.join('; ')}.` };
750
+ }
751
+
731
752
  async function runCheck(run, request) {
732
753
  const checks = [];
733
754
  for (const problem of run.readiness?.modelProblems ?? []) checks.push({ name: 'Model', ok: false, detail: problem });
@@ -744,6 +765,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
744
765
  else if (modelSlots('deep').every(slot => settings.models.deep[slot] === settings.models.review[slot])) {
745
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.' });
746
767
  }
768
+ checks.push(await installationCheck(run));
747
769
  // What follows a COMPLETE review of each mode; automatic publication posts as the PAT owner.
748
770
  const publishing = MODES.filter(mode => settings.afterReview[mode] === 'publish').map(mode => `/pr-${mode}`);
749
771
  const listed = publishing.length > 1 ? `${publishing.slice(0, -1).join(', ')} or ${publishing.at(-1)}` : publishing[0];
@@ -797,7 +819,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
797
819
  if (request.target.organization.toLowerCase() !== settings.azure.organization.toLowerCase()) {
798
820
  throw new Error(`[AZPR] The PR belongs to organization "${request.target.organization}", but azure.organization is "${settings.azure.organization}". Use a PAT and settings for that organization.`);
799
821
  }
800
- if (mode === 'deep' && !settings.deepReady) throw new Error(`[AZPR] /pr-deep runs the review with the models of models.deep: set all three roles${settings.deepPartial ? ' (only some are set)' : ''}, preferably to models stronger than models.review, then restart OpenCode. No fallback to review models.`);
822
+ if (mode === 'deep' && !settings.deepReady) throw new Error(`[AZPR] /pr-deep runs the review with the models of models.deep: set all three roles${settings.deepPartial ? ' (only some are set)' : ''}, preferably to models stronger than models.review, then restart the OpenCode service (opencode service restart). No fallback to review models.`);
801
823
  if (mode === 'quick' && !settings.quickReady) throw new Error('[AZPR] Set models.quick.reviewer before /pr-quick. No fallback to other models.');
802
824
  // /pr-check checks the review profile's models.
803
825
  const profile = mode === 'check' ? 'review' : mode;