opencode-azure-devops-pr-review 0.4.2 → 0.4.3
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 +92 -0
- package/README.md +121 -40
- package/package.json +2 -2
- package/src/azure.mjs +12 -2
- package/src/config.mjs +3 -0
- package/src/runtime.mjs +33 -11
- package/src/session.mjs +8 -5
- package/src/setup.mjs +904 -85
- package/src/tui-setup.mjs +344 -0
- package/src/tui-view.jsx +394 -154
- package/src/tui.js +446 -173
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,97 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.3 — 2026-11-18
|
|
4
|
+
|
|
5
|
+
`/pr-setup` sets AZPR up in OpenCode's terminal UI: dialogs ask for the
|
|
6
|
+
organization, a proxy if the network needs one, the token and a model, check
|
|
7
|
+
the token with Azure DevOps and save it in a file only you can read; a first
|
|
8
|
+
setup needs no restart. Afterwards the same command lists the settings to
|
|
9
|
+
change. And after a review, the next thing you say in the same conversation
|
|
10
|
+
no longer costs one model request per AZPR notice. The reviewer, verifier and
|
|
11
|
+
comment-planning instructions are those of 0.4.2, and no setting is new.
|
|
12
|
+
|
|
13
|
+
Setup in the terminal UI:
|
|
14
|
+
|
|
15
|
+
- Until now a first setup meant creating the PAT file by hand in a terminal,
|
|
16
|
+
typing a model ID into `/pr-setup`, editing JSON for a proxy, and
|
|
17
|
+
restarting the OpenCode service. In OpenCode's terminal UI, `/pr-setup`
|
|
18
|
+
without options now opens dialogs for it: the organization (its name, or
|
|
19
|
+
the URL of a pull request), a proxy, the token, and a model picked from
|
|
20
|
+
OpenCode's list.
|
|
21
|
+
- The proxy is asked before the token, because the token is checked over the
|
|
22
|
+
network; Enter skips it. After a proxy, the CA certificate file of a
|
|
23
|
+
company that inspects HTTPS is asked the same way.
|
|
24
|
+
- The token is typed or pasted into a field that shows only how many
|
|
25
|
+
characters it holds. AZPR asks Azure DevOps once whether it works for the
|
|
26
|
+
organization and says what was refused: the token, the organization, or
|
|
27
|
+
the way there. When Azure DevOps cannot be reached, the proxy or the CA
|
|
28
|
+
file can be set right there and the same token tried again; it can also be
|
|
29
|
+
saved unchecked.
|
|
30
|
+
- The token is saved alone in a file only you can read (mode 600), in one
|
|
31
|
+
step: a file made for it, `${XDG_CONFIG_HOME:-~/.config}/azpr/pat-<organization>`
|
|
32
|
+
(with a number where that name is taken), which the settings then name;
|
|
33
|
+
or, for a new token of the same organization, the token file the settings
|
|
34
|
+
name already. Setup overwrites no other file: the default PAT file of
|
|
35
|
+
setup with options, `azpr/pat`, may be the PAT file of several settings
|
|
36
|
+
files, so the dialogs only read it. The token is in no conversation,
|
|
37
|
+
notice or log.
|
|
38
|
+
- With settings in place, `/pr-setup` lists them with their values:
|
|
39
|
+
organization, token, proxy, CA certificate file, the review, quick and deep
|
|
40
|
+
models, output language, what follows a review, the report in the
|
|
41
|
+
conversation, progress notices, the review panel and debug records. A
|
|
42
|
+
change is saved at once. Posting comments without a preview asks once
|
|
43
|
+
more, with "no" first. The command palette has the list too ("AZPR:
|
|
44
|
+
settings").
|
|
45
|
+
- A saved token belongs to the organization it was checked for: it is never
|
|
46
|
+
sent to another one, and another organization in the list asks for a token
|
|
47
|
+
of its own, which is checked and saved together with it, in a new file
|
|
48
|
+
beside the first. The earlier token's file is left as it is, and AZPR says
|
|
49
|
+
where it is.
|
|
50
|
+
- When AZPR has no usable settings, the terminal UI says so once after it
|
|
51
|
+
starts and names `/pr-setup`.
|
|
52
|
+
- The dialogs only ask: the plugin's server part checks every answer, writes
|
|
53
|
+
the two files, and is the only part that contacts Azure DevOps. Other
|
|
54
|
+
clients, such as the desktop app, do not load the dialogs; there
|
|
55
|
+
`/pr-setup` prints its instructions as before.
|
|
56
|
+
|
|
57
|
+
Setup, in every client:
|
|
58
|
+
|
|
59
|
+
- A first setup is loaded at once, with the dialogs and with options: the
|
|
60
|
+
review commands work without a restart of the OpenCode service, in the
|
|
61
|
+
project directory where setup ran. Another project directory that the same
|
|
62
|
+
OpenCode service had already opened without settings still needs the
|
|
63
|
+
restart, and its review commands say so. A change to settings that are in
|
|
64
|
+
use takes effect after a restart as before, and `/pr-setup` says so.
|
|
65
|
+
- `/pr-setup` takes options that change one setting each in existing
|
|
66
|
+
settings, without `--replace`: `--proxy`, `--ca-file`, `--review-model`,
|
|
67
|
+
`--quick-model`, `--deep-model`, `--language`, `--after-review`, `--report`,
|
|
68
|
+
`--progress`, `--panel` and `--debug`. They can be combined, also with the
|
|
69
|
+
options of a first setup (`--proxy` behind a company proxy, for example).
|
|
70
|
+
`/pr-setup --help` lists them.
|
|
71
|
+
- A source installation has one more file, `src/tui-setup.mjs`: 35 in all
|
|
72
|
+
for manual copying.
|
|
73
|
+
|
|
74
|
+
Notices and the conversation's model:
|
|
75
|
+
|
|
76
|
+
- AZPR's notices (`STARTED`, `PROGRESS`, the receipts) wait in the
|
|
77
|
+
conversation's inbox and start no response of its model. Until now, when
|
|
78
|
+
you then prompted that conversation, OpenCode 2.3.0 answered your prompt
|
|
79
|
+
and after it gave each waiting notice a turn of the conversation's model:
|
|
80
|
+
a review with its comment preview leaves about eight notices, so about
|
|
81
|
+
eight more requests, each carrying the whole conversation, and the model
|
|
82
|
+
replied to each notice. The notices are now left in the inbox the way
|
|
83
|
+
OpenCode leaves its own notices about background shells, and the
|
|
84
|
+
conversation's model reads all of them together with your prompt, in one
|
|
85
|
+
request. In the terminal fixture, a prompt after 16 notices made 17
|
|
86
|
+
requests of the conversation's model before and makes 1 now.
|
|
87
|
+
- A notice that arrives while the conversation's model is working is handed
|
|
88
|
+
to it at its next step, or in one request right after its answer; before,
|
|
89
|
+
each such notice took a request of its own after the answer.
|
|
90
|
+
- The notices themselves, the panel and the report session are as in 0.4.2,
|
|
91
|
+
and a conversation used only for AZPR's commands still costs no request of
|
|
92
|
+
its model. The text of the notices still enters the conversation's context
|
|
93
|
+
once, when its model next runs.
|
|
94
|
+
|
|
3
95
|
## 0.4.2 — 2026-11-17
|
|
4
96
|
|
|
5
97
|
A panel in OpenCode's terminal UI shows the report and the comment preview
|
package/README.md
CHANGED
|
@@ -52,12 +52,16 @@ is an actual capture excerpt with identifying UI removed and its text unchanged.
|
|
|
52
52
|
[company networks](docs/ENTERPRISE.md#company-networks) first):
|
|
53
53
|
|
|
54
54
|
```sh
|
|
55
|
-
opencode plugin add opencode-azure-devops-pr-review@0.4.
|
|
55
|
+
opencode plugin add opencode-azure-devops-pr-review@0.4.3
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
2.
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
2. In OpenCode's terminal UI, type `/pr-setup`. Dialogs ask for your Azure
|
|
59
|
+
DevOps organization, a proxy if your network needs one, your token (PAT) and
|
|
60
|
+
a model. AZPR checks the token with Azure DevOps, saves it in a file only
|
|
61
|
+
you can read, and is ready at once: no restart. The
|
|
62
|
+
[quickstart](docs/QUICKSTART.md) walks through it; in another client, such
|
|
63
|
+
as the desktop app, see
|
|
64
|
+
[without the terminal UI](docs/QUICKSTART.md#without-the-terminal-ui).
|
|
61
65
|
3. In one OpenCode conversation, check access, then review:
|
|
62
66
|
|
|
63
67
|
```text
|
|
@@ -306,7 +310,7 @@ models and runs.
|
|
|
306
310
|
| Operating system | **Ubuntu 22.04** (validation environment: WSL2). Other operating systems are not yet validated. |
|
|
307
311
|
| Azure | **Azure DevOps Services**, REST API **7.1**. Azure DevOps Server is not supported by the current URL handling. |
|
|
308
312
|
| 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. |
|
|
309
|
-
| Terminal
|
|
313
|
+
| Terminal UI | The [review panel](#terminal-panel) and the [setup dialogs](#setup-in-the-terminal-ui) need OpenCode's terminal UI. Other clients, such as the desktop app, show AZPR's notices as text and take `/pr-setup` with options. |
|
|
310
314
|
| Models | Your OpenCode provider/model IDs with tool support. Each mode checks the models it uses. Name a concrete model, not one that routes each session to another model (see [configuration](#configuration)). |
|
|
311
315
|
|
|
312
316
|
The npm package, the Git package and the release source archive contain the
|
|
@@ -380,7 +384,9 @@ regressions that the everyday model missed, at many times its cost and time
|
|
|
380
384
|
|
|
381
385
|
Readiness checks, reviews, comment planning, adjustments and publication
|
|
382
386
|
acknowledge `STARTED` and continue in the current OpenCode process; short
|
|
383
|
-
`PROGRESS` notices and a final receipt return to the invoking conversation.
|
|
387
|
+
`PROGRESS` notices and a final receipt return to the invoking conversation.
|
|
388
|
+
They start no response of that conversation's own model; when you prompt it
|
|
389
|
+
later, it reads them together with your prompt, in one request. Use
|
|
384
390
|
the displayed `/pr-stop <run-id>` to cancel. `/pr-setup` (including `--help`),
|
|
385
391
|
`/pr-stop`, `/pr-comment --show`, an adjustment that changes nothing and a
|
|
386
392
|
refused command answer directly, without a background run.
|
|
@@ -402,20 +408,21 @@ Azure DevOps REST API with the runtime's built-in `fetch`.
|
|
|
402
408
|
Install the npm package with OpenCode's plugin manager:
|
|
403
409
|
|
|
404
410
|
```sh
|
|
405
|
-
opencode plugin add opencode-azure-devops-pr-review@0.4.
|
|
411
|
+
opencode plugin add opencode-azure-devops-pr-review@0.4.3
|
|
406
412
|
```
|
|
407
413
|
|
|
408
414
|
The same release is also a versioned Git package, which needs Git but not the
|
|
409
415
|
npm registry:
|
|
410
416
|
|
|
411
417
|
```sh
|
|
412
|
-
opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.
|
|
418
|
+
opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.3'
|
|
413
419
|
```
|
|
414
420
|
|
|
415
421
|
Add only one of them. OpenCode 2.3.0 loads the plugin into a running OpenCode
|
|
416
422
|
service within a few seconds; if `/pr-setup` does not appear in a new
|
|
417
|
-
conversation, run `opencode service restart`. Then run `/pr-setup
|
|
418
|
-
instructions.
|
|
423
|
+
conversation, run `opencode service restart`. Then run `/pr-setup`: in the
|
|
424
|
+
terminal UI it asks for what it needs, elsewhere it prints the instructions.
|
|
425
|
+
Native packages
|
|
419
426
|
use `${XDG_CONFIG_HOME:-~/.config}/azpr/settings.json`; configuration and the
|
|
420
427
|
separate PAT file stay outside the package cache when the plugin is updated.
|
|
421
428
|
To select another configuration file, use an absolute path in the host config:
|
|
@@ -423,7 +430,7 @@ To select another configuration file, use an absolute path in the host config:
|
|
|
423
430
|
```json
|
|
424
431
|
{
|
|
425
432
|
"plugins": [{
|
|
426
|
-
"package": "opencode-azure-devops-pr-review@0.4.
|
|
433
|
+
"package": "opencode-azure-devops-pr-review@0.4.3",
|
|
427
434
|
"options": { "settingsFile": "/absolute/path/to/azpr/settings.json" }
|
|
428
435
|
}]
|
|
429
436
|
}
|
|
@@ -448,7 +455,7 @@ For an entry that `opencode plugin add` created, add the new version and,
|
|
|
448
455
|
only when that succeeds, remove the previous one:
|
|
449
456
|
|
|
450
457
|
```sh
|
|
451
|
-
opencode plugin add opencode-azure-devops-pr-review@0.4.
|
|
458
|
+
opencode plugin add opencode-azure-devops-pr-review@0.4.3 &&
|
|
452
459
|
opencode plugin remove opencode-azure-devops-pr-review@PREVIOUS_VERSION
|
|
453
460
|
```
|
|
454
461
|
|
|
@@ -480,7 +487,7 @@ the first one (`Unknown setting settings.terminalPanel`) instead of starting. `o
|
|
|
480
487
|
show a single `azpr` row with the new version (from 0.3.1, `/pr-check` names
|
|
481
488
|
it too); if it still shows the previous one, run `opencode service restart`.
|
|
482
489
|
Exact versions stay pinned, so `opencode plugin update` leaves them unchanged.
|
|
483
|
-
See the [0.4.
|
|
490
|
+
See the [0.4.3 release notes](docs/releases/v0.4.3.md) for what changed, the
|
|
484
491
|
[0.4.0 release notes](docs/releases/v0.4.0.md) for commands without review IDs and the
|
|
485
492
|
[0.2.0 release notes](docs/releases/v0.2.0.md) for automatic comments. A
|
|
486
493
|
preview follows each COMPLETE review unless `afterReview` says otherwise;
|
|
@@ -492,8 +499,8 @@ review command flag.
|
|
|
492
499
|
<details>
|
|
493
500
|
<summary>Source installation and replacement</summary>
|
|
494
501
|
|
|
495
|
-
Download the [v0.4.
|
|
496
|
-
and extract it, or check out tag `v0.4.
|
|
502
|
+
Download the [v0.4.3 source archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.4.3.tar.gz)
|
|
503
|
+
and extract it, or check out tag `v0.4.3`. The installer needs POSIX `sh` and
|
|
497
504
|
Python 3's standard library. From that source directory:
|
|
498
505
|
|
|
499
506
|
```sh
|
|
@@ -504,8 +511,9 @@ The installer creates `plugins/azpr-v2/` with a generated ESM `package.json`
|
|
|
504
511
|
and a `server.js` entry that re-exports `plugin.js`. It never edits the main
|
|
505
512
|
OpenCode configuration, provider choices or MCP connections, and it refuses
|
|
506
513
|
conflicting legacy files, reserved command names and unowned packages. Run
|
|
507
|
-
`/pr-setup
|
|
508
|
-
them yourself
|
|
514
|
+
`/pr-setup` in the terminal UI to complete the generated starter settings
|
|
515
|
+
(with options: `/pr-setup ... --replace`), or edit them yourself and restart
|
|
516
|
+
OpenCode.
|
|
509
517
|
|
|
510
518
|
To replace an existing source installation (current settings are kept, new defaults
|
|
511
519
|
are added, and a retired `mcp` section is moved into `azure`):
|
|
@@ -519,7 +527,7 @@ sh install.sh --config-dir /absolute/path/to/v2-opencode-config --replace
|
|
|
519
527
|
### Manual copying without Git
|
|
520
528
|
|
|
521
529
|
Keep these relative paths under one source directory, then run its installer.
|
|
522
|
-
These **
|
|
530
|
+
These **35 files** include the runtime and its license:
|
|
523
531
|
|
|
524
532
|
<details>
|
|
525
533
|
<summary>Show the required files</summary>
|
|
@@ -549,6 +557,7 @@ src/review-tools.mjs
|
|
|
549
557
|
src/review-work.mjs
|
|
550
558
|
src/store.mjs
|
|
551
559
|
src/tui-model.mjs
|
|
560
|
+
src/tui-setup.mjs
|
|
552
561
|
src/tui.js
|
|
553
562
|
src/prompts/common.md
|
|
554
563
|
src/prompts/functional.md
|
|
@@ -568,17 +577,61 @@ Keep `LICENSE` with copied or redistributed packages.
|
|
|
568
577
|
|
|
569
578
|
## Configuration
|
|
570
579
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
[all settings](#all-settings-and-defaults)).
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
580
|
+
`/pr-setup` sets AZPR up and changes its settings; what it answers names the
|
|
581
|
+
settings file. Native packages use the external configuration described
|
|
582
|
+
above; source installations retain their installed
|
|
583
|
+
`plugins/azpr-v2/settings.json`. The file names every setting, each at its
|
|
584
|
+
default until you change it (see [all settings](#all-settings-and-defaults)).
|
|
585
|
+
|
|
586
|
+
A first setup is loaded at once. A later change, made with `/pr-setup` or by
|
|
587
|
+
editing the file, takes effect when the OpenCode service restarts
|
|
588
|
+
(`opencode service restart`, or your own `opencode serve` process). A changed
|
|
589
|
+
file blocks new commands until the restart; running commands keep the settings
|
|
590
|
+
they started with.
|
|
591
|
+
|
|
592
|
+
### Setup in the terminal UI
|
|
593
|
+
|
|
594
|
+
In OpenCode's terminal UI, `/pr-setup` without options opens dialogs. The
|
|
595
|
+
command palette has them too ("AZPR: settings").
|
|
596
|
+
|
|
597
|
+
- **First setup.** Your organization (its name, or the URL of a pull request);
|
|
598
|
+
a proxy, only if your network needs one (Enter skips it; after a proxy, the
|
|
599
|
+
CA certificate file of a company that inspects HTTPS, which Enter skips
|
|
600
|
+
too); your token; and a model from OpenCode's list, which fills the review
|
|
601
|
+
roles and `/pr-quick`. The proxy is asked before the token because the token
|
|
602
|
+
is checked over the network.
|
|
603
|
+
- **The token** is typed or pasted into a field that shows only how many
|
|
604
|
+
characters it holds. AZPR asks Azure DevOps once whether the token works for
|
|
605
|
+
your organization, and says what was refused when it does not: the token,
|
|
606
|
+
the organization, or the way there. If Azure DevOps cannot be reached, you
|
|
607
|
+
can set the proxy or the CA file right there and try the same token again,
|
|
608
|
+
or save it unchecked. The token is then saved alone in a file only you can
|
|
609
|
+
read (mode 600): a new file, `${XDG_CONFIG_HOME:-~/.config}/azpr/pat-<organization>`
|
|
610
|
+
(with a number where that name is taken), or the token file your settings
|
|
611
|
+
name already for that organization. Setup overwrites no other file. The
|
|
612
|
+
token is in no conversation, notice or log, and is not shown again.
|
|
613
|
+
- **Afterwards** `/pr-setup` lists the settings with their values:
|
|
614
|
+
organization, token, proxy, CA certificate file, the review, quick and deep
|
|
615
|
+
models, output language, what follows a review, the report in the
|
|
616
|
+
conversation, progress notices, the review panel and debug records. Choose
|
|
617
|
+
one to change it. It is saved at once, and the list says that a restart is
|
|
618
|
+
needed. Posting comments without a preview asks once more, with "no" first.
|
|
619
|
+
Another organization asks for a token of its own, since the saved one was
|
|
620
|
+
saved for the organization it was checked for; the two are saved together,
|
|
621
|
+
the new token in a new file beside the first, and AZPR says where the
|
|
622
|
+
earlier token still is.
|
|
623
|
+
The other settings are in the settings file, which the list names.
|
|
624
|
+
|
|
625
|
+
The dialogs only ask. The plugin's server part checks every answer, writes
|
|
626
|
+
the two files, and is the only part that contacts Azure DevOps. Other OpenCode
|
|
627
|
+
clients, such as the desktop app, do not load the dialogs; there `/pr-setup`
|
|
628
|
+
prints the instructions and takes options.
|
|
629
|
+
|
|
630
|
+
### Setup with options
|
|
631
|
+
|
|
632
|
+
Without the terminal UI, or from a script, one command sets the organization,
|
|
633
|
+
an existing PAT file and the same model for review and quick roles, without
|
|
634
|
+
calling a model or Azure:
|
|
582
635
|
|
|
583
636
|
```text
|
|
584
637
|
/pr-setup --organization YOUR_ORG --model YOUR_PROVIDER/YOUR_MODEL --pat-file "/absolute/path/to/pat"
|
|
@@ -586,12 +639,37 @@ the same model for review and quick roles without calling a model or Azure:
|
|
|
586
639
|
|
|
587
640
|
`--organization` also accepts a PR or organization URL. Without `--pat-file`,
|
|
588
641
|
setup uses `${XDG_CONFIG_HOME:-~/.config}/azpr/pat`, the file the
|
|
589
|
-
[quickstart](docs/QUICKSTART.md#
|
|
642
|
+
[quickstart](docs/QUICKSTART.md#save-the-pat-in-a-private-file-terminal)
|
|
590
643
|
creates. An existing file requires `--replace`, which keeps the PAT file
|
|
591
644
|
already set unless you name another; unrelated advanced settings and deep
|
|
592
645
|
models are preserved. Setup checks the model catalog and PAT file before
|
|
593
|
-
saving. It never accepts the PAT itself as a command argument.
|
|
594
|
-
|
|
646
|
+
saving. It never accepts the PAT itself as a command argument. A first setup
|
|
647
|
+
is loaded at once; run `/pr-check` to verify Azure read access.
|
|
648
|
+
|
|
649
|
+
Each of these options changes one setting of existing settings, without
|
|
650
|
+
`--replace`, and several can be given together:
|
|
651
|
+
|
|
652
|
+
| Option | Sets |
|
|
653
|
+
| --- | --- |
|
|
654
|
+
| `--proxy URL` (or `none`) | `azure.proxy` |
|
|
655
|
+
| `--ca-file PATH` (or `none`) | `azure.caFile` |
|
|
656
|
+
| `--review-model PROVIDER/MODEL` | The three review roles |
|
|
657
|
+
| `--quick-model PROVIDER/MODEL` (or `off`) | `models.quick.reviewer` |
|
|
658
|
+
| `--deep-model PROVIDER/MODEL` (or `off`) | The three deep roles |
|
|
659
|
+
| `--language TAG` | `outputLanguage` |
|
|
660
|
+
| `--after-review preview`, `none` or `publish` | `afterReview` of every mode |
|
|
661
|
+
| `--report receipt` or `full` | `returnReport` |
|
|
662
|
+
| `--progress on` or `off` | `progressNotices` |
|
|
663
|
+
| `--panel auto` or `manual` | `terminalPanel` |
|
|
664
|
+
| `--debug on` or `off` | `debug.enabled` |
|
|
665
|
+
|
|
666
|
+
```text
|
|
667
|
+
/pr-setup --language zh-TW --deep-model YOUR_PROVIDER/YOUR_STRONGER_MODEL
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
They also go with the options of a first setup, for example `--proxy` behind
|
|
671
|
+
a company proxy. After a change to settings that are in use, restart the
|
|
672
|
+
OpenCode service. For separate models per role, edit the settings file:
|
|
595
673
|
|
|
596
674
|
```json
|
|
597
675
|
{
|
|
@@ -735,10 +813,12 @@ a PAT scoped to **one organization** (global "all accessible organizations"
|
|
|
735
813
|
PATs stop working on 2026-12-01) with **Code: Read** and **Pull Request Threads:
|
|
736
814
|
Read & write**, which cover every call AZPR makes, and give it an expiry you
|
|
737
815
|
renew. Keep it alone in a file that only you can read and point `azure.patFile`
|
|
738
|
-
at it, so `settings.json` holds no secret
|
|
739
|
-
[
|
|
816
|
+
at it, so `settings.json` holds no secret. In the terminal UI, `/pr-setup`
|
|
817
|
+
does both for you (see [setup](#setup-in-the-terminal-ui)). Without it, the
|
|
818
|
+
[quickstart](docs/QUICKSTART.md#save-the-pat-in-a-private-file-terminal) shows
|
|
740
819
|
how to create that file without echoing the PAT, recording it in your shell
|
|
741
|
-
history or overwriting an existing file, and `/pr-setup` sets
|
|
820
|
+
history or overwriting an existing file, and `/pr-setup` with options sets
|
|
821
|
+
`azure.patFile`.
|
|
742
822
|
|
|
743
823
|
To set it by hand, put that file's absolute path (for example
|
|
744
824
|
`/home/you/.config/azpr/pat`) in `"patFile"`, leave `"pat"` empty in the
|
|
@@ -768,7 +848,7 @@ troubleshooting.
|
|
|
768
848
|
|
|
769
849
|
| Command | Behavior |
|
|
770
850
|
| --- | --- |
|
|
771
|
-
| `/pr-setup [options]` |
|
|
851
|
+
| `/pr-setup [options]` | Set AZPR up, or change its settings. Without options, the terminal UI asks in dialogs and checks the token with Azure DevOps (other clients get the instructions). With options: an organization, one model and an existing PAT file, or one setting per option, without an Azure request. No model request either way. A first setup is loaded at once; a later change needs a restart of the OpenCode service. |
|
|
772
852
|
| `/pr-check <PR URL> [context]` | Deterministic readiness check: PR metadata, changed files, a HEAD and BASE file read, discussions and model availability (configured quick and deep models only as warnings, and whether `/pr-deep` is off or would repeat `/pr-review`), and `afterReview` (the configured modes and posting identity, shown as information); warns when OpenCode has no permission hook to keep native read tools inside the project. No model is used. |
|
|
773
853
|
| `/pr-review <PR URL> [flag] [context]` | Sharded functional and risk reviews, then sharded verification. |
|
|
774
854
|
| `/pr-deep <PR URL> [flag] [context]` | The same review with the stronger models of `models.deep`; usually slower and costlier. |
|
|
@@ -874,7 +954,8 @@ session that holds a report. It sends no prompt, starts no review and posts
|
|
|
874
954
|
nothing; `/pr-comment --publish` is still a command you type. It comes with
|
|
875
955
|
the package and needs no setup; `terminalPanel` is its one setting. Other
|
|
876
956
|
OpenCode clients, such as the desktop app, do not load it and show AZPR's
|
|
877
|
-
notices as before.
|
|
957
|
+
notices as before. The same terminal part brings the
|
|
958
|
+
[setup dialogs](#setup-in-the-terminal-ui).
|
|
878
959
|
|
|
879
960
|
## Comments
|
|
880
961
|
|
|
@@ -1072,8 +1153,8 @@ dependency and is not built on your machine.
|
|
|
1072
1153
|
Uninstall without `--apply` previews; `--apply` archives only this package under
|
|
1073
1154
|
`azpr-v2-backups` and leaves the private state directory for you to delete.
|
|
1074
1155
|
For a native installation, remove the entry you added, for example
|
|
1075
|
-
`opencode plugin remove opencode-azure-devops-pr-review@0.4.
|
|
1076
|
-
`opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.
|
|
1156
|
+
`opencode plugin remove opencode-azure-devops-pr-review@0.4.3` or
|
|
1157
|
+
`opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.3'`;
|
|
1077
1158
|
the external settings, PAT file and private review state remain available.
|
|
1078
1159
|
|
|
1079
1160
|
[Architecture](docs/ARCHITECTURE.md), [commenting](docs/COMMENTING.md),
|
|
@@ -1086,7 +1167,7 @@ or personal model selections.
|
|
|
1086
1167
|
## License and releases
|
|
1087
1168
|
|
|
1088
1169
|
[MIT](LICENSE), copyright 2026 WTLAIB. See the [changelog](CHANGELOG.md) for the
|
|
1089
|
-
release scope, [v0.4.
|
|
1170
|
+
release scope, [v0.4.3](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.4.3)
|
|
1090
1171
|
for downloads, the [npm package](https://www.npmjs.com/package/opencode-azure-devops-pr-review),
|
|
1091
1172
|
[v0.2.0](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.2.0)
|
|
1092
1173
|
for the recorded demonstration, and [releasing](docs/RELEASING.md) for the
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-azure-devops-pr-review",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
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": {
|
|
7
7
|
"test": "node --test tests/*.test.mjs",
|
|
8
|
-
"check": "node --check src/session.mjs && node --check src/runtime.mjs && node --check src/comment-data.mjs && node --check src/comment-work.mjs && node --check src/comments.mjs && node --check src/config.mjs && node --check src/output.mjs && node --check src/diagnostics.mjs && node --check src/attribution.mjs && node --check src/host.mjs && node --check src/tool-queue.mjs && node --check src/azure.mjs && node --check src/diff.mjs && node --check src/search.mjs && node --check src/review-tools.mjs && node --check src/review-work.mjs && node --check src/store.mjs && node --check src/plugin.js && node --check src/setup.mjs && node --check src/tui-model.mjs && node --check src/tui.js && node --check server.js && node --check scripts/build-tui.mjs && node scripts/build-tui.mjs --check && sh -n install.sh && sh -n uninstall.sh",
|
|
8
|
+
"check": "node --check src/session.mjs && node --check src/runtime.mjs && node --check src/comment-data.mjs && node --check src/comment-work.mjs && node --check src/comments.mjs && node --check src/config.mjs && node --check src/output.mjs && node --check src/diagnostics.mjs && node --check src/attribution.mjs && node --check src/host.mjs && node --check src/tool-queue.mjs && node --check src/azure.mjs && node --check src/diff.mjs && node --check src/search.mjs && node --check src/review-tools.mjs && node --check src/review-work.mjs && node --check src/store.mjs && node --check src/plugin.js && node --check src/setup.mjs && node --check src/tui-model.mjs && node --check src/tui-setup.mjs && node --check src/tui.js && node --check server.js && node --check scripts/build-tui.mjs && node scripts/build-tui.mjs --check && sh -n install.sh && sh -n uninstall.sh",
|
|
9
9
|
"build:tui": "node scripts/build-tui.mjs"
|
|
10
10
|
},
|
|
11
11
|
"engines": {
|
package/src/azure.mjs
CHANGED
|
@@ -436,8 +436,9 @@ export function createAzureClient({ organization, pat, baseUrl = DEFAULT_BASE_UR
|
|
|
436
436
|
* because publication resolves uncertainty by reading markers back.
|
|
437
437
|
* `signal` also ends a call that only its caller waits for (a tool call
|
|
438
438
|
* the host stopped); a call whose result several callers share takes none.
|
|
439
|
+
* `retries` is how often a read is repeated: none where a person waits for the answer.
|
|
439
440
|
*/
|
|
440
|
-
async function request(run, { method = 'GET', path, query = {}, body, accept = 'json', maxBytes, label, record = {}, signal }) {
|
|
441
|
+
async function request(run, { method = 'GET', path, query = {}, body, accept = 'json', maxBytes, label, record = {}, signal, retries = READ_RETRIES }) {
|
|
441
442
|
const url = new URL(`${root}/${path}`);
|
|
442
443
|
for (const [key, value] of Object.entries(query)) if (value !== undefined && value !== null) url.searchParams.set(key, String(value));
|
|
443
444
|
url.searchParams.set('api-version', API_VERSION);
|
|
@@ -457,7 +458,7 @@ export function createAzureClient({ organization, pat, baseUrl = DEFAULT_BASE_UR
|
|
|
457
458
|
const error = caught instanceof AzureError ? caught : caught?.timeout
|
|
458
459
|
? new AzureError(`Azure DevOps ${label} did not finish within the per-call timeout.`, { kind: 'timeout', transient: true, uncertain: method !== 'GET', cause: caught })
|
|
459
460
|
: new AzureError(`Azure DevOps ${label} failed: ${clean(caught?.message ?? caught)}`, { kind: 'unexpected', cause: caught });
|
|
460
|
-
const again = retry && error.transient && attempt <=
|
|
461
|
+
const again = retry && error.transient && attempt <= retries;
|
|
461
462
|
onCall?.(run, { ...entry, ok: false, durationMs: Math.round(performance.now() - started), status: error.status, kind: error.kind,
|
|
462
463
|
error: error.message.slice(0, 300), transient: error.transient, willRetry: again });
|
|
463
464
|
if (again) {
|
|
@@ -534,6 +535,15 @@ export function createAzureClient({ organization, pat, baseUrl = DEFAULT_BASE_UR
|
|
|
534
535
|
return {
|
|
535
536
|
organization,
|
|
536
537
|
request,
|
|
538
|
+
/**
|
|
539
|
+
* Whether Azure DevOps accepts the PAT for this organization and lets it read code: one small read that
|
|
540
|
+
* needs no project (at most one pull request of the organization), for setup. It is sent once, since a
|
|
541
|
+
* person waits for the answer; an AzureError says by its kind what was refused.
|
|
542
|
+
*/
|
|
543
|
+
async access(run) {
|
|
544
|
+
const result = await request(run, { path: '_apis/git/pullrequests', query: { $top: 1 }, label: 'pull request list', retries: 0 });
|
|
545
|
+
if (!Array.isArray(result?.value)) throw new AzureError('Azure DevOps returned no pull request list.');
|
|
546
|
+
},
|
|
537
547
|
/** Read the PR, its latest iteration and every changed file into a runtime-owned snapshot. */
|
|
538
548
|
async snapshot(run, target) {
|
|
539
549
|
const pr = await request(run, { path: `${encodeURIComponent(target.project)}/_apis/git/repositories/${encodeURIComponent(target.repository)}/pullRequests/${target.pullRequestId}`, label: 'PR' });
|
package/src/config.mjs
CHANGED
|
@@ -197,6 +197,9 @@ function languageTag(value) {
|
|
|
197
197
|
try { return Intl.getCanonicalLocales(value)[0]; } catch { throw new Error(message); }
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
/** The checks of single values that setup also applies to an answer; each throws what is wrong, never the value. */
|
|
201
|
+
export const SETTING_CHECKS = Object.freeze({ model, proxy: proxyUrl, language: languageTag });
|
|
202
|
+
|
|
200
203
|
/** Why a value cannot be the PAT ('' when it can); it never contains the value. */
|
|
201
204
|
export const patProblem = value => typeof value !== 'string' || !/^[\x21-\x7e]{20,1024}$/.test(value)
|
|
202
205
|
? 'not one token of 20 to 1024 printable characters' : /REPLACE|YOUR_/i.test(value) ? 'still a placeholder' : '';
|
package/src/runtime.mjs
CHANGED
|
@@ -72,12 +72,17 @@ export async function readPatFile(path) {
|
|
|
72
72
|
if (problem) throw new Error(`[AZPR] azure.patFile must hold only the Azure DevOps PAT (${problem}).`);
|
|
73
73
|
return text;
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
76
|
-
|
|
75
|
+
/**
|
|
76
|
+
* azure.caFile: extra CA certificates (PEM), read and checked once at load like the settings, and by setup
|
|
77
|
+
* for a path a person names. Only a regular file is read: a device or a FIFO would never end.
|
|
78
|
+
*/
|
|
79
|
+
export async function readCaCertificates(path) {
|
|
77
80
|
if (!path) return [];
|
|
78
81
|
let raw;
|
|
79
82
|
try {
|
|
80
|
-
|
|
83
|
+
const info = await stat(path);
|
|
84
|
+
if (!info.isFile()) throw new Error('not a regular file');
|
|
85
|
+
if (info.size > CA_FILE_BYTES) throw new Error('larger than 1 MB');
|
|
81
86
|
raw = await readFile(path, 'utf8');
|
|
82
87
|
} catch (error) { throw new Error(`[AZPR] azure.caFile could not be read (${error.code ?? error.message}).`); }
|
|
83
88
|
const certificates = pemCertificates(raw);
|
|
@@ -118,6 +123,8 @@ function completedText(text) {
|
|
|
118
123
|
* AZPR_TEST_AZURE_BASE_URL for exact-host fixtures) must be a loopback test server.
|
|
119
124
|
* setup.mjs passes settingsPath and settingsCompletion (what it added to the
|
|
120
125
|
* settings file before this read, for /pr-check).
|
|
126
|
+
* Returns the function that unloads it; its `settingsDrift()` says whether the settings file and the PAT
|
|
127
|
+
* file are still what was loaded (not for settings that are switched off, which load nothing).
|
|
121
128
|
*/
|
|
122
129
|
export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, options = {}) {
|
|
123
130
|
const settingsPath = options.settingsPath ?? join(baseDirectory, 'settings.json');
|
|
@@ -360,20 +367,32 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
360
367
|
if (problems.length && run.mode !== 'check') throw new Error(`[AZPR] ${problems.join(' ')} No fallback was selected.`);
|
|
361
368
|
}
|
|
362
369
|
|
|
363
|
-
|
|
364
|
-
|
|
370
|
+
/**
|
|
371
|
+
* What is no longer as this runtime loaded it, so that new runs are refused: 'unreadable' (the settings
|
|
372
|
+
* file), 'settings' (its text), 'pat' (the content of the PAT file) or '' (nothing). One policy for the
|
|
373
|
+
* preflight and for what setup reports as waiting for a restart. A PAT file that cannot be used throws
|
|
374
|
+
* what `readPatFile` says.
|
|
375
|
+
*/
|
|
376
|
+
async function settingsDrift(signal) {
|
|
365
377
|
let now;
|
|
366
|
-
try { now = await scoped(() => readFile(settingsPath, 'utf8'), signal); } catch {
|
|
378
|
+
try { now = await scoped(() => readFile(settingsPath, 'utf8'), signal); } catch { return 'unreadable'; }
|
|
367
379
|
if (now !== state.raw) {
|
|
368
380
|
// The loaded settings with nothing but the defaults another load of AZPR wrote into the file since (it was
|
|
369
381
|
// still writing when this load stopped waiting for it): the settings in use are the file's, and no person's
|
|
370
382
|
// change is passed over. Any other difference blocks new runs as before.
|
|
371
|
-
if (now !== completedText(state.raw))
|
|
383
|
+
if (now !== completedText(state.raw)) return 'settings';
|
|
372
384
|
state.raw = now;
|
|
373
385
|
}
|
|
374
|
-
if (settings.azure.patFile && await scoped(() => readPatFile(settings.azure.patFile), signal) !== pat)
|
|
375
|
-
|
|
376
|
-
|
|
386
|
+
if (settings.azure.patFile && await scoped(() => readPatFile(settings.azure.patFile), signal) !== pat) return 'pat';
|
|
387
|
+
return '';
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
async function preflight(run) {
|
|
391
|
+
const signal = run.controller.signal;
|
|
392
|
+
const drift = await settingsDrift(signal);
|
|
393
|
+
if (drift === 'unreadable') throw new Error('[AZPR] settings.json is not readable.');
|
|
394
|
+
if (drift === 'settings') 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.');
|
|
395
|
+
if (drift === 'pat') 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.');
|
|
377
396
|
await checkCommands(signal);
|
|
378
397
|
await pinAgents(run.profile, signal);
|
|
379
398
|
await readiness(run);
|
|
@@ -1794,7 +1813,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1794
1813
|
await Promise.allSettled(registrations.reverse().map(r => r.dispose()));
|
|
1795
1814
|
throw error;
|
|
1796
1815
|
}
|
|
1797
|
-
|
|
1816
|
+
const unload = async () => {
|
|
1798
1817
|
disposed = true;
|
|
1799
1818
|
await Promise.allSettled([...runs.values()].map(run => abortRun(run, 'OpenCode V2 plugin unloaded.')));
|
|
1800
1819
|
await Promise.allSettled([...jobs]);
|
|
@@ -1803,4 +1822,7 @@ export async function setupAzurePrReview(context, baseDirectory = DEFAULT_DIR, o
|
|
|
1803
1822
|
openStores.clear();
|
|
1804
1823
|
await Promise.allSettled(registrations.reverse().map(r => r.dispose()));
|
|
1805
1824
|
};
|
|
1825
|
+
// Setup asks with it whether the settings and the PAT file are still what is in use here (src/setup.mjs).
|
|
1826
|
+
unload.settingsDrift = () => settingsDrift();
|
|
1827
|
+
return unload;
|
|
1806
1828
|
}
|
package/src/session.mjs
CHANGED
|
@@ -336,9 +336,12 @@ export async function interruptSession(context, { sessionID, signal }) {
|
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
/**
|
|
339
|
-
*
|
|
339
|
+
* Leave report data in the session's inbox without starting a formatting or ordinary-agent model call.
|
|
340
|
+
* `steer` decides what happens when that session's own model runs next: the host hands every steered item
|
|
341
|
+
* that waits to the model at once, together with the prompt that woke it, while it gives each queued item
|
|
342
|
+
* a turn of its own (one model request per notice, each with the whole conversation).
|
|
340
343
|
* `metadata` is stored with the notice for clients that read it (the terminal panel); no model sees it,
|
|
341
|
-
* and a call without it
|
|
344
|
+
* and a call without it carries none.
|
|
342
345
|
*/
|
|
343
346
|
export async function appendReport(context, { sessionID, text, signal, metadata }) {
|
|
344
347
|
const api = sessionApi(context, ['synthetic']);
|
|
@@ -346,11 +349,11 @@ export async function appendReport(context, { sessionID, text, signal, metadata
|
|
|
346
349
|
const result = await cancellable(() => api.synthetic({
|
|
347
350
|
sessionID, text, description: text,
|
|
348
351
|
...(metadata ? { metadata } : {}),
|
|
349
|
-
delivery: '
|
|
352
|
+
delivery: 'steer', resume: false,
|
|
350
353
|
}), signal);
|
|
351
354
|
if (!record(result) || !textValue(result.id) || result.sessionID !== sessionID || result.type !== 'synthetic' ||
|
|
352
|
-
result.payload?.text !== text || result.delivery !== '
|
|
353
|
-
throw new Error('[AZPR] OpenCode V2 did not acknowledge the
|
|
355
|
+
result.payload?.text !== text || result.delivery !== 'steer') {
|
|
356
|
+
throw new Error('[AZPR] OpenCode V2 did not acknowledge the report.');
|
|
354
357
|
}
|
|
355
358
|
return { queued: true, id: result.id };
|
|
356
359
|
}
|