opencode-azure-devops-pr-review 0.3.1 → 0.3.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 +46 -0
- package/README.md +128 -86
- package/package.json +2 -11
- package/src/attribution.mjs +2 -4
- package/src/azure.mjs +5 -2
- package/src/host.mjs +28 -5
- package/src/runtime.mjs +13 -7
- package/src/session.mjs +6 -12
- package/AGENTS.md +0 -164
- package/CODE_OF_CONDUCT.md +0 -83
- package/CONTRIBUTING.md +0 -84
- package/SECURITY.md +0 -38
- package/config/settings.example.json +0 -55
- package/config/settings.schema.json +0 -316
- package/docs/ARCHITECTURE.md +0 -414
- package/docs/AZURE_DEVOPS.md +0 -217
- package/docs/COMMENTING.md +0 -399
- package/docs/DEBUGGING.md +0 -146
- package/docs/DEMO.md +0 -195
- package/docs/ENTERPRISE.md +0 -236
- package/docs/QUICKSTART.md +0 -238
- package/docs/RELEASING.md +0 -95
- package/docs/ROADMAP.md +0 -241
- package/docs/VALIDATION.md +0 -2127
- package/docs/VALIDATION_HISTORY.md +0 -1845
- package/docs/VERIFICATION.md +0 -42
- package/docs/assets/RECORDING.md +0 -131
- package/docs/assets/adjust-findings-teaser.gif +0 -0
- package/docs/assets/adjust-preview.png +0 -0
- package/docs/assets/adjust-publication.png +0 -0
- package/docs/assets/example-comments.md +0 -38
- package/docs/assets/generate-demo-gif.py +0 -25
- package/docs/assets/generate-demo.mjs +0 -141
- package/docs/assets/live-azure-readback.png +0 -0
- package/docs/assets/live-preview.png +0 -0
- package/docs/assets/live-review-teaser.gif +0 -0
- package/docs/assets/live-review.png +0 -0
- package/docs/assets/quick-review-demo.gif +0 -0
- package/docs/assets/record-terminal.py +0 -124
- package/docs/assets/render-terminal-demo.py +0 -168
- package/docs/assets/review-example.svg +0 -1
- package/docs/assets/walkthrough.svg +0 -1
- package/docs/releases/v0.1.0.md +0 -74
- package/docs/releases/v0.2.0.md +0 -107
- package/docs/releases/v0.2.1.md +0 -65
- package/docs/releases/v0.2.2.md +0 -76
- package/docs/releases/v0.2.3.md +0 -93
- package/docs/releases/v0.3.0.md +0 -125
- package/docs/releases/v0.3.1.md +0 -87
- package/install.sh +0 -171
- package/scripts/merge-settings.py +0 -120
- package/uninstall.sh +0 -50
package/docs/releases/v0.3.0.md
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# Azure DevOps PR Review for OpenCode — 0.3.0
|
|
2
|
-
|
|
3
|
-
AI reviews. You decide what gets posted. This release lets you exclude findings
|
|
4
|
-
or change their severity after reading a comment preview. AZPR prepares a new
|
|
5
|
-
preview without rerunning the review, while keeping the original findings and
|
|
6
|
-
report intact.
|
|
7
|
-
|
|
8
|
-
## Try it after a preview
|
|
9
|
-
|
|
10
|
-
Use your review ID and finding IDs from its report:
|
|
11
|
-
|
|
12
|
-
```text
|
|
13
|
-
/pr-comment <review-id> --exclude F-1 --severity F-2=low
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
F-1 is excluded from the new preview; F-2 appears as low in the summary, with no
|
|
17
|
-
new inline comment. Comment planning uses a model again, so other wording may
|
|
18
|
-
change. Read the whole new preview, then publish from the same conversation:
|
|
19
|
-
|
|
20
|
-
```text
|
|
21
|
-
/pr-comment <review-id> --publish
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## What changed
|
|
25
|
-
|
|
26
|
-
- **Choose the findings and severity.** `--exclude` and `--severity` each
|
|
27
|
-
replace their own saved list; `none` empties that list. For example,
|
|
28
|
-
`--exclude F-1` followed by `--exclude F-2` excludes only F-2. Name both to
|
|
29
|
-
keep both out. `--reset` clears both lists and plans again. A changed
|
|
30
|
-
severity changes publication, not the evidence or verification of a finding.
|
|
31
|
-
Excluding every finding plans and posts nothing (`NOTHING_TO_POST`).
|
|
32
|
-
- **Reopen the saved preview.** `/pr-comment [review-id] --show` displays it
|
|
33
|
-
without a model or Azure DevOps request. It includes the saved adjustments.
|
|
34
|
-
- **Read the new preview before publishing.** An adjusted review, including
|
|
35
|
-
one reset since, needs a saved preview planned after its latest adjustment.
|
|
36
|
-
Adjustments are saved together with dropping the earlier preview; a failed
|
|
37
|
-
save changes nothing. A new preview whose save fails is dropped. After a
|
|
38
|
-
stop or restart during planning, prepare a new preview before publishing.
|
|
39
|
-
Once publication starts, the review cannot be adjusted or planned again;
|
|
40
|
-
`--publish` retries the same saved content.
|
|
41
|
-
- **Excluded IDs stay out of new comments.** The planner receives the adjusted
|
|
42
|
-
findings, and the assembled preview is checked too. When a retained
|
|
43
|
-
finding's summary names an excluded ID, publication is held until you
|
|
44
|
-
exclude that finding as well or restore the other. References without the
|
|
45
|
-
ID cannot be detected by this check.
|
|
46
|
-
- **Earlier PR comments keep their text.** AZPR still skips comments it already
|
|
47
|
-
posted and never edits them. An adjusted review's receipt names items whose
|
|
48
|
-
actual text differs from the preview, including comments that appear only
|
|
49
|
-
when AZPR reads the threads back. It also counts other AZPR comments on the
|
|
50
|
-
PR, where an excluded finding may still be visible.
|
|
51
|
-
- The README opens with a real OpenCode 2.1.4 recording of adjusting findings
|
|
52
|
-
and publishing, and the README and quickstart show the adjustment workflow.
|
|
53
|
-
The npm package includes the code of conduct. CI actions are pinned by commit
|
|
54
|
-
and updated with Dependabot.
|
|
55
|
-
|
|
56
|
-
The options work with review, deep and quick results. Quick findings remain
|
|
57
|
-
not independently verified. Without adjustments, comment planning and
|
|
58
|
-
publication retain their existing behavior. See the
|
|
59
|
-
[commenting guide](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/blob/v0.3.0/docs/COMMENTING.md#adjusting-findings-after-a-preview)
|
|
60
|
-
for the complete rules.
|
|
61
|
-
|
|
62
|
-
## Installation
|
|
63
|
-
|
|
64
|
-
```sh
|
|
65
|
-
opencode plugin add opencode-azure-devops-pr-review@0.3.0
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
Alternatively, install the same release from Git:
|
|
69
|
-
|
|
70
|
-
```sh
|
|
71
|
-
opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.3.0'
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Add only one of them. Follow the
|
|
75
|
-
[quickstart](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/blob/v0.3.0/docs/QUICKSTART.md)
|
|
76
|
-
for a private PAT file, `/pr-setup`, a service restart and the first review.
|
|
77
|
-
|
|
78
|
-
## Upgrading
|
|
79
|
-
|
|
80
|
-
For a native installation, edit its existing entry in the OpenCode
|
|
81
|
-
configuration's `plugins` list:
|
|
82
|
-
|
|
83
|
-
- For npm, change the package specification to
|
|
84
|
-
`opencode-azure-devops-pr-review@0.3.0`.
|
|
85
|
-
- For Git, change the tag suffix to `#v0.3.0`.
|
|
86
|
-
|
|
87
|
-
If the entry is an object, change only `package`; preserve `options.settingsFile`
|
|
88
|
-
and any other options. Keep one AZPR entry and restart the OpenCode service.
|
|
89
|
-
External settings, the PAT file and review records remain in place; a working
|
|
90
|
-
configuration needs no new `/pr-setup`. Exact version pins are not advanced by
|
|
91
|
-
`opencode plugin update`. This release adds no settings or required migration.
|
|
92
|
-
|
|
93
|
-
For a source installation, extract the new archive and run its installer with
|
|
94
|
-
`--replace` to retain settings:
|
|
95
|
-
|
|
96
|
-
```sh
|
|
97
|
-
sh install.sh --config-dir /absolute/path/to/v2-opencode-config --replace
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Automatic comments remain opt-in through `afterReview` or a review command
|
|
101
|
-
flag. Use `/pr-review <PR URL> --preview` when you want to inspect and adjust
|
|
102
|
-
findings before publication.
|
|
103
|
-
|
|
104
|
-
## Compatibility and validation
|
|
105
|
-
|
|
106
|
-
The tested target remains OpenCode CLI **2.1.4** (V2 plugin API), Node.js
|
|
107
|
-
**22.23.3**, Ubuntu **22.04.5** under WSL2, and Azure DevOps Services REST API
|
|
108
|
-
**7.1**. OpenCode 1.x and Azure DevOps Server are not supported; other operating
|
|
109
|
-
systems remain unvalidated.
|
|
110
|
-
|
|
111
|
-
The [validation record](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/blob/v0.3.0/docs/VALIDATION.md)
|
|
112
|
-
separates release checks with fake services from live runs. The earlier live
|
|
113
|
-
adjustment runs on 1-file and 316-file Azure DevOps test PRs preceded the final
|
|
114
|
-
persistence and read-back fixes; a recorded live run on the 1-file test PR used
|
|
115
|
-
this release's runtime. None of them establish a general review accuracy score.
|
|
116
|
-
|
|
117
|
-
The npm package, Git package and source archive contain the same runtime, with
|
|
118
|
-
no npm dependencies or install scripts. The release source artifact is
|
|
119
|
-
`opencode-azure-devops-pr-review-v2-0.3.0.tar.gz`, with checksums in `SHA256SUMS`.
|
|
120
|
-
The README's 15-second recording of adjusting findings and publishing comes
|
|
121
|
-
from that live run. The earlier walkthrough of the review, preview and
|
|
122
|
-
publication workflow remains attached to
|
|
123
|
-
[v0.2.0](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.2.0).
|
|
124
|
-
The [demo guide](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/blob/v0.3.0/docs/DEMO.md)
|
|
125
|
-
describes both recordings.
|
package/docs/releases/v0.3.1.md
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
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/install.sh
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# Install only this integration. Never edit OpenCode configuration or execute settings.
|
|
3
|
-
set -eu
|
|
4
|
-
umask 077
|
|
5
|
-
|
|
6
|
-
src=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
|
|
7
|
-
root=${XDG_CONFIG_HOME:-${HOME:?HOME is required}/.config}/opencode
|
|
8
|
-
profile=
|
|
9
|
-
replace=0
|
|
10
|
-
|
|
11
|
-
usage() {
|
|
12
|
-
cat <<'TXT'
|
|
13
|
-
Usage: sh install.sh [--settings FILE] [--replace] [--config-dir DIR]
|
|
14
|
-
--settings Select a trusted version-2 JSON profile and add missing defaults.
|
|
15
|
-
--replace Replace this V2 integration without keeping an installation backup.
|
|
16
|
-
Preserve operational settings and add missing defaults.
|
|
17
|
-
--config-dir OpenCode configuration directory (default: XDG_CONFIG_HOME/opencode).
|
|
18
|
-
Retired models._help documentation is omitted with a notice.
|
|
19
|
-
Python 3 (standard library only) is required to merge JSON safely.
|
|
20
|
-
No npm install, pip packages, jq, sudo, or network access is required.
|
|
21
|
-
README.md, docs/, CHANGELOG.md, uninstall.sh, and config/settings.schema.json are optional.
|
|
22
|
-
Installed module metadata is generated; the source package.json is not required.
|
|
23
|
-
TXT
|
|
24
|
-
}
|
|
25
|
-
die() { printf 'ERROR: %s\n' "$*" >&2; exit 1; }
|
|
26
|
-
|
|
27
|
-
while [ "$#" -gt 0 ]; do
|
|
28
|
-
case $1 in
|
|
29
|
-
--settings) [ "$#" -ge 2 ] || die '--settings needs a file'; profile=$2; shift 2 ;;
|
|
30
|
-
--config-dir) [ "$#" -ge 2 ] || die '--config-dir needs a directory'; root=$2; shift 2 ;;
|
|
31
|
-
--replace) replace=1; shift ;;
|
|
32
|
-
--help|-h) usage; exit 0 ;;
|
|
33
|
-
*) die "Unknown argument: $1" ;;
|
|
34
|
-
esac
|
|
35
|
-
done
|
|
36
|
-
command -v python3 >/dev/null 2>&1 || die 'Python 3 is required for safe JSON settings merging. Install python3 and retry; no installation files were changed.'
|
|
37
|
-
runtime_files='session.mjs runtime.mjs comment-data.mjs comment-work.mjs comments.mjs config.mjs output.mjs diagnostics.mjs attribution.mjs host.mjs tool-queue.mjs azure.mjs diff.mjs search.mjs review-tools.mjs review-work.mjs store.mjs setup.mjs plugin.js'
|
|
38
|
-
prompt_names='common functional risk final dedupe quick comment-policy comment-plan'
|
|
39
|
-
command_names='pr-setup pr-check pr-review pr-deep pr-quick pr-stop pr-comment'
|
|
40
|
-
require_file() { [ -f "$src/$1" ] && [ -r "$src/$1" ] || die "Incomplete package: $1 is missing or unreadable."; }
|
|
41
|
-
for file in LICENSE scripts/merge-settings.py config/settings.example.json; do require_file "$file"; done
|
|
42
|
-
for file in $runtime_files; do require_file "src/$file"; done
|
|
43
|
-
for name in $prompt_names; do require_file "src/prompts/$name.md"; done
|
|
44
|
-
copy_optional() {
|
|
45
|
-
if [ -f "$src/$1" ]; then
|
|
46
|
-
cp "$src/$1" "$stage/new/plugins/azpr-v2/" || printf 'WARNING: Could not copy optional file: %s\n' "$1" >&2
|
|
47
|
-
fi
|
|
48
|
-
}
|
|
49
|
-
if [ -n "$profile" ]; then
|
|
50
|
-
[ -f "$profile" ] && [ -r "$profile" ] || die 'The settings file is not readable.'
|
|
51
|
-
fi
|
|
52
|
-
case $root in /*) ;; *) root=$(pwd -P)/$root ;; esac
|
|
53
|
-
mkdir -p "$root"
|
|
54
|
-
root=$(CDPATH= cd -- "$root" && pwd -P)
|
|
55
|
-
lock=$root/.azpr-v2-install.lock
|
|
56
|
-
mkdir "$lock" 2>/dev/null || die "Installation lock exists: $lock"
|
|
57
|
-
stage=
|
|
58
|
-
success=0
|
|
59
|
-
|
|
60
|
-
cleanup() {
|
|
61
|
-
rc=$?
|
|
62
|
-
recovery_required=0
|
|
63
|
-
trap - EXIT HUP INT TERM
|
|
64
|
-
if [ "$success" -ne 1 ] && [ -n "$stage" ] && [ -d "$stage" ]; then
|
|
65
|
-
if [ -f "$stage/installed" ]; then
|
|
66
|
-
while IFS= read -r rel; do
|
|
67
|
-
[ -n "$rel" ] && rm -rf -- "$root/$rel"
|
|
68
|
-
done < "$stage/installed"
|
|
69
|
-
fi
|
|
70
|
-
if [ -f "$stage/moved" ]; then
|
|
71
|
-
while IFS= read -r rel; do
|
|
72
|
-
if [ -e "$stage/previous/$rel" ] || [ -L "$stage/previous/$rel" ]; then
|
|
73
|
-
mkdir -p "$(dirname -- "$root/$rel")"
|
|
74
|
-
if ! mv -- "$stage/previous/$rel" "$root/$rel"; then
|
|
75
|
-
recovery_required=1
|
|
76
|
-
printf 'Restore manually: %s\n' "$stage/previous/$rel" >&2
|
|
77
|
-
fi
|
|
78
|
-
fi
|
|
79
|
-
done < "$stage/moved"
|
|
80
|
-
fi
|
|
81
|
-
fi
|
|
82
|
-
if [ "$recovery_required" -eq 0 ]; then
|
|
83
|
-
[ -z "$stage" ] || rm -rf -- "$stage"
|
|
84
|
-
else
|
|
85
|
-
printf 'Automatic recovery failed; emergency files retained: %s\n' "$stage" >&2
|
|
86
|
-
fi
|
|
87
|
-
rmdir "$lock" 2>/dev/null || true
|
|
88
|
-
exit "$rc"
|
|
89
|
-
}
|
|
90
|
-
trap cleanup EXIT
|
|
91
|
-
trap 'exit 130' HUP INT TERM
|
|
92
|
-
# A closed output pipe (for example `| head`) must not kill the installer before
|
|
93
|
-
# cleanup: writes then fail instead, and a failure before success rolls back.
|
|
94
|
-
trap '' PIPE
|
|
95
|
-
|
|
96
|
-
# Refuse conflicts rather than trying to rewrite JSONC.
|
|
97
|
-
for config in "$root/opencode.json" "$root/opencode.jsonc" "$root/config.json"; do
|
|
98
|
-
if [ -f "$config" ] && grep -Eq '"(pr-setup|pr-check|pr-review|pr-deep|pr-quick|pr-stop|pr-comment|azpr-[^"]+)"[[:space:]]*:' "$config"; then
|
|
99
|
-
die "Reserved command/agent keys appear in $config. Resolve them manually."
|
|
100
|
-
fi
|
|
101
|
-
done
|
|
102
|
-
for path in "$root"/agent/azpr-*.md "$root"/agents/azpr-*.md; do
|
|
103
|
-
[ ! -e "$path" ] && [ ! -L "$path" ] || die "Conflicting agent file: $path"
|
|
104
|
-
done
|
|
105
|
-
for sub in commands command plugins plugin plugins/azpr-v2; do
|
|
106
|
-
[ ! -L "$root/$sub" ] || die "Symlinked integration directory: $root/$sub"
|
|
107
|
-
done
|
|
108
|
-
# A V1 integration shares command names and cannot coexist in this config root.
|
|
109
|
-
# Preserve every old file; --replace applies only to this V2 package directory.
|
|
110
|
-
for rel in azpr plugins/azpr plugins/azpr.js plugin/azpr plugin/azpr.js plugin/azpr-v2 .azpr-install.lock; do
|
|
111
|
-
[ ! -e "$root/$rel" ] && [ ! -L "$root/$rel" ] || die "Conflicting integration path: $root/$rel. Use a separate V2 configuration directory or resolve the conflict manually."
|
|
112
|
-
done
|
|
113
|
-
for name in $command_names; do
|
|
114
|
-
for sub in command commands; do
|
|
115
|
-
rel=$sub/$name.md
|
|
116
|
-
[ ! -e "$root/$rel" ] && [ ! -L "$root/$rel" ] || die "Conflicting command file: $root/$rel. Resolve it manually."
|
|
117
|
-
done
|
|
118
|
-
done
|
|
119
|
-
|
|
120
|
-
target=plugins/azpr-v2
|
|
121
|
-
if [ -e "$root/$target" ]; then
|
|
122
|
-
[ "$replace" -eq 1 ] || die "Target exists: $root/$target. Use --replace to replace this V2 integration without an installation backup."
|
|
123
|
-
[ -d "$root/$target" ] && [ -f "$root/$target/runtime.mjs" ] &&
|
|
124
|
-
grep -Fq 'AZPR opt-in OpenCode adapter' "$root/$target/runtime.mjs" || die "Not owned; refusing: $root/$target"
|
|
125
|
-
fi
|
|
126
|
-
stage=$(mktemp -d "$root/.azpr-v2-stage.XXXXXX")
|
|
127
|
-
mkdir -p "$stage/new/$target/prompts"
|
|
128
|
-
for file in $runtime_files; do cp "$src/src/$file" "$stage/new/$target/"; done
|
|
129
|
-
for name in $prompt_names; do cp "$src/src/prompts/$name.md" "$stage/new/$target/prompts/"; done
|
|
130
|
-
cp "$src/LICENSE" "$stage/new/$target/LICENSE"
|
|
131
|
-
# OpenCode 2.0.22 resolves local package directories through server, then index.
|
|
132
|
-
# Keep the entry inside the staged package so replacement and rollback own it.
|
|
133
|
-
printf '%s\n' "export { default } from './plugin.js';" > "$stage/new/$target/server.js"
|
|
134
|
-
printf '%s\n' '{"type":"module","exports":"./server.js","private":true}' > "$stage/new/$target/package.json"
|
|
135
|
-
for file in config/settings.schema.json README.md CHANGELOG.md uninstall.sh; do copy_optional "$file"; done
|
|
136
|
-
if [ -d "$src/docs" ]; then
|
|
137
|
-
cp -R "$src/docs" "$stage/new/plugins/azpr-v2/docs" || printf 'WARNING: Could not copy optional docs directory.\n' >&2
|
|
138
|
-
fi
|
|
139
|
-
if [ -n "$profile" ]; then
|
|
140
|
-
settings_source=$profile
|
|
141
|
-
elif [ "$replace" -eq 1 ] && [ -f "$root/plugins/azpr-v2/settings.json" ]; then
|
|
142
|
-
settings_source=$root/plugins/azpr-v2/settings.json
|
|
143
|
-
else
|
|
144
|
-
settings_source=$src/config/settings.example.json
|
|
145
|
-
fi
|
|
146
|
-
python3 -I "$src/scripts/merge-settings.py" "$src/config/settings.example.json" "$settings_source" "$stage/new/plugins/azpr-v2/settings.json"
|
|
147
|
-
chmod 600 "$stage/new/plugins/azpr-v2/settings.json"
|
|
148
|
-
|
|
149
|
-
: > "$stage/moved"
|
|
150
|
-
: > "$stage/installed"
|
|
151
|
-
if [ -e "$root/$target" ]; then
|
|
152
|
-
mkdir -p "$stage/previous/plugins"
|
|
153
|
-
printf '%s\n' "$target" >> "$stage/moved"
|
|
154
|
-
mv -- "$root/$target" "$stage/previous/$target"
|
|
155
|
-
fi
|
|
156
|
-
mkdir -p "$root/plugins"
|
|
157
|
-
printf '%s\n' "$target" >> "$stage/installed"
|
|
158
|
-
mv -- "$stage/new/$target" "$root/$target"
|
|
159
|
-
success=1
|
|
160
|
-
# Informational output only; an unwritable output must not fail a completed install.
|
|
161
|
-
{
|
|
162
|
-
printf '\nAzure PR Review installed (target host: @opencode/cli 2.1.4; Ubuntu 22.04).\nSettings: %s\n' "$root/plugins/azpr-v2/settings.json"
|
|
163
|
-
printf 'No installation backup is retained after success. Existing older backups are untouched.\n'
|
|
164
|
-
cat <<'TXT'
|
|
165
|
-
1. Configure models.review.functional/risk/verifier. Configure all three models.deep roles to enable /pr-deep, the same review with models stronger than models.review for the PRs that need them, and models.quick.reviewer to enable /pr-quick.
|
|
166
|
-
2. Set azure.organization and the PAT: an Azure DevOps PAT for that organization with Code (Read) and Pull Request Threads (Read & write), alone in a file only you can read (chmod 600) named by azure.patFile (recommended), or in azure.pat. AZPR calls the Azure DevOps REST API (api-version 7.1) itself; no MCP server is needed.
|
|
167
|
-
3. Fully restart OpenCode and run /pr-check on a small, known PR.
|
|
168
|
-
Alternatively, run /pr-setup --help in OpenCode for guided configuration.
|
|
169
|
-
Settings have not been API-validated. Review commands stay blocked until configuration is complete.
|
|
170
|
-
TXT
|
|
171
|
-
} 2>/dev/null || true
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Check settings, omit retired help and add defaults without exposing private values."""
|
|
3
|
-
import json
|
|
4
|
-
import math
|
|
5
|
-
import sys
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def unique_object(pairs):
|
|
9
|
-
result = {}
|
|
10
|
-
for key, value in pairs:
|
|
11
|
-
if key in result:
|
|
12
|
-
raise ValueError("Duplicate JSON key; resolve it before installation.")
|
|
13
|
-
result[key] = value
|
|
14
|
-
return result
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def reject_constant(value):
|
|
18
|
-
raise ValueError("Non-standard JSON numeric constant.")
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def finite_float(value):
|
|
22
|
-
number = float(value)
|
|
23
|
-
if not math.isfinite(number):
|
|
24
|
-
raise ValueError("Non-finite JSON number.")
|
|
25
|
-
return number
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def load(path):
|
|
29
|
-
with open(path, encoding="utf-8") as stream:
|
|
30
|
-
raw = stream.read()
|
|
31
|
-
value = json.loads(raw, object_pairs_hook=unique_object, parse_constant=reject_constant, parse_float=finite_float)
|
|
32
|
-
if not isinstance(value, dict):
|
|
33
|
-
raise ValueError("Settings must be a JSON object.")
|
|
34
|
-
return raw, value
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def merge(existing, defaults, prefix=""):
|
|
38
|
-
added = []
|
|
39
|
-
for key, value in defaults.items():
|
|
40
|
-
path = prefix + key
|
|
41
|
-
if key not in existing:
|
|
42
|
-
existing[key] = value
|
|
43
|
-
added.append(path)
|
|
44
|
-
elif isinstance(existing[key], dict) and isinstance(value, dict):
|
|
45
|
-
added.extend(merge(existing[key], value, path + "."))
|
|
46
|
-
return added
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def current_settings(existing):
|
|
50
|
-
"""Accept the current layout only; this V2 package does not migrate V1."""
|
|
51
|
-
version = existing.get("version", 2)
|
|
52
|
-
if type(version) is not int or version != 2:
|
|
53
|
-
raise ValueError("Unsupported settings version.")
|
|
54
|
-
models = existing.get("models", {})
|
|
55
|
-
if not isinstance(models, dict):
|
|
56
|
-
raise ValueError("Models must be a current-layout JSON object.")
|
|
57
|
-
if any(key in models for key in ("freeA", "freeB", "final")):
|
|
58
|
-
raise ValueError("Legacy model settings are unsupported.")
|
|
59
|
-
if any(key in models and not isinstance(models[key], dict) for key in ("review", "deep", "quick")):
|
|
60
|
-
raise ValueError("Model roles must use the current nested layout.")
|
|
61
|
-
if "_help" in models:
|
|
62
|
-
help_text = models["_help"]
|
|
63
|
-
if not isinstance(help_text, dict) or any(
|
|
64
|
-
key not in ("functional", "risk", "verifier") or not isinstance(value, str)
|
|
65
|
-
for key, value in help_text.items()
|
|
66
|
-
):
|
|
67
|
-
raise ValueError("Legacy model help must contain only role documentation strings.")
|
|
68
|
-
if any(key in existing for key in ("steps", "maxStageCharacters", "structuredOutput", "comments", "auxiliaryModels", "outputRetries", "verification", "shellToolPermission")):
|
|
69
|
-
raise ValueError("Removed settings are unsupported.")
|
|
70
|
-
for key in ("azure", "mcp"):
|
|
71
|
-
if key in existing and not isinstance(existing[key], dict):
|
|
72
|
-
raise ValueError("Azure settings must be JSON objects.")
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def migrate(existing):
|
|
76
|
-
"""AZPR calls Azure DevOps REST itself: move the retired mcp limits into azure."""
|
|
77
|
-
if "mcp" not in existing:
|
|
78
|
-
return False
|
|
79
|
-
mcp = existing.pop("mcp")
|
|
80
|
-
azure = existing.setdefault("azure", {})
|
|
81
|
-
for key in ("concurrency", "callTimeoutSeconds"):
|
|
82
|
-
if key in mcp and key not in azure:
|
|
83
|
-
azure[key] = mcp[key]
|
|
84
|
-
return True
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def main():
|
|
88
|
-
if len(sys.argv) != 4:
|
|
89
|
-
print("Usage: merge-settings.py DEFAULTS SOURCE DESTINATION", file=sys.stderr)
|
|
90
|
-
return 2
|
|
91
|
-
defaults_path, source_path, destination = sys.argv[1:]
|
|
92
|
-
try:
|
|
93
|
-
_, defaults = load(defaults_path)
|
|
94
|
-
raw, existing = load(source_path)
|
|
95
|
-
current_settings(defaults)
|
|
96
|
-
current_settings(existing)
|
|
97
|
-
# Remove only the retired documentation, not model choices or other values.
|
|
98
|
-
# A stale defaults file must not add it back. Source files stay untouched.
|
|
99
|
-
removed_help = "_help" in existing.get("models", {})
|
|
100
|
-
existing.get("models", {}).pop("_help", None)
|
|
101
|
-
defaults.get("models", {}).pop("_help", None)
|
|
102
|
-
migrated = migrate(existing)
|
|
103
|
-
added = merge(existing, defaults)
|
|
104
|
-
content = json.dumps(existing, ensure_ascii=False, indent=2, allow_nan=False) + "\n" if added or removed_help or migrated else raw
|
|
105
|
-
with open(destination, "x", encoding="utf-8") as stream:
|
|
106
|
-
stream.write(content)
|
|
107
|
-
except (ValueError, OSError, UnicodeError, RecursionError):
|
|
108
|
-
# Parser exceptions can contain secrets from the profile. Never print them.
|
|
109
|
-
print("ERROR: Settings must be readable, valid JSON objects with unique keys, finite numbers, and the current version-2 nested model layout without removed settings. No installed files were replaced. Fix the selected settings file or choose --settings FILE.", file=sys.stderr)
|
|
110
|
-
return 1
|
|
111
|
-
print("Settings defaults added: " + (", ".join(added) if added else "none."))
|
|
112
|
-
if removed_help:
|
|
113
|
-
print("Removed documentation-only models._help; see README.md for model-selection guidance.")
|
|
114
|
-
if migrated:
|
|
115
|
-
print("Moved mcp.concurrency/callTimeoutSeconds to azure; mcp.server is no longer used. Set azure.organization and azure.patFile (or azure.pat).")
|
|
116
|
-
return 0
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if __name__ == "__main__":
|
|
120
|
-
sys.exit(main())
|
package/uninstall.sh
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# Archive this integration only; never delete user settings.
|
|
3
|
-
set -eu
|
|
4
|
-
umask 077
|
|
5
|
-
root=${XDG_CONFIG_HOME:-${HOME:?HOME is required}/.config}/opencode
|
|
6
|
-
apply=0
|
|
7
|
-
while [ "$#" -gt 0 ]; do
|
|
8
|
-
case $1 in
|
|
9
|
-
--config-dir) [ "$#" -ge 2 ] || exit 2; root=$2; shift 2 ;;
|
|
10
|
-
--apply) apply=1; shift ;;
|
|
11
|
-
--help|-h) printf 'Usage: sh uninstall.sh [--config-dir DIR] [--apply]\nPreview by default; --apply archives only this integration. Restart OpenCode.\n'; exit 0 ;;
|
|
12
|
-
*) printf 'Unknown argument: %s\n' "$1" >&2; exit 2 ;;
|
|
13
|
-
esac
|
|
14
|
-
done
|
|
15
|
-
[ -d "$root" ] || { printf 'No config directory.\n'; exit 0; }
|
|
16
|
-
root=$(CDPATH= cd -- "$root" && pwd -P)
|
|
17
|
-
lock=$root/.azpr-v2-install.lock
|
|
18
|
-
mkdir "$lock" 2>/dev/null || { printf 'Installation lock exists: %s\n' "$lock" >&2; exit 1; }
|
|
19
|
-
trap 'rmdir "$lock" 2>/dev/null || true' EXIT
|
|
20
|
-
trap 'exit 130' HUP INT TERM
|
|
21
|
-
trap '' PIPE
|
|
22
|
-
for sub in plugins plugins/azpr-v2 azpr-v2-backups; do
|
|
23
|
-
[ ! -L "$root/$sub" ] || { printf 'Resolve symlink manually: %s\n' "$sub" >&2; exit 1; }
|
|
24
|
-
done
|
|
25
|
-
target=$root/plugins/azpr-v2
|
|
26
|
-
if [ ! -e "$target" ]; then
|
|
27
|
-
printf 'No Azure PR Review V2 package is installed in this configuration directory.\n'
|
|
28
|
-
exit 0
|
|
29
|
-
fi
|
|
30
|
-
if [ ! -d "$target" ] || [ ! -f "$target/runtime.mjs" ] || ! grep -Fq 'AZPR opt-in OpenCode adapter' "$target/runtime.mjs"; then
|
|
31
|
-
printf 'Not owned; refusing: %s\n' "$target" >&2
|
|
32
|
-
exit 1
|
|
33
|
-
fi
|
|
34
|
-
if [ "$apply" -eq 0 ]; then
|
|
35
|
-
printf 'Preview: archive plugins/azpr-v2/ from:\n%s\nRe-run with --apply. Existing configuration, credentials, agents, commands, and other plugins are preserved.\n' "$root"
|
|
36
|
-
printf 'Saved reviews stay in %s/opencode/azpr-v2; delete that directory yourself when no longer needed.\n' "${XDG_STATE_HOME:-$HOME/.local/state}"
|
|
37
|
-
exit 0
|
|
38
|
-
fi
|
|
39
|
-
mkdir -p "$root/azpr-v2-backups"
|
|
40
|
-
backup=$(mktemp -d "$root/azpr-v2-backups/uninstalled.XXXXXX")
|
|
41
|
-
mkdir -p "$backup/plugins"
|
|
42
|
-
if ! mv -- "$target" "$backup/plugins/azpr-v2"; then
|
|
43
|
-
rmdir "$backup/plugins" "$backup" 2>/dev/null || true
|
|
44
|
-
printf 'Archive failed; inspect the source and destination before retrying.\n' >&2
|
|
45
|
-
exit 1
|
|
46
|
-
fi
|
|
47
|
-
{
|
|
48
|
-
printf 'Archived: %s\nRestart OpenCode.\n' "$backup"
|
|
49
|
-
printf 'Saved reviews stay in %s/opencode/azpr-v2; delete that directory yourself when no longer needed.\n' "${XDG_STATE_HOME:-$HOME/.local/state}"
|
|
50
|
-
} 2>/dev/null || true
|