Repository navigation
Azure DevOps PR Review for OpenCode — 0.5.10
This release moves the tested host to OpenCode 2.4.5. OpenCode 2.4.5 was
compared with 2.4.2, the last version studied, through 2.4.3 and 2.4.4: in the
three smoke runs of the host fixtures, private sessions were sent on 2.4.5
what they were sent on 2.4.2, request by request, once what differs between
any two runs (paths, IDs, times) is set aside. Two behaviours of the host that
AZPR relies on changed, and this release follows them. The prompt files are
those of 0.5.9, no setting is new, and your settings and saved reviews are
used as they are.
What changed
- A step that OpenCode 2.4.5 retried no longer fails its pass. Where a
model's response broke off and OpenCode retried the step by itself, AZPR
took the turn's answer only where the failed step carried OpenCode's mark
that it was retried. OpenCode 2.4.5 clears that mark once the retried step
starts, so with AZPR 0.5.9 a turn that OpenCode had recovered failed as
transient, the pass was tried again in a new session, and a second break
failed it. AZPR now also counts a failed step that it saw marked while it
prepared the turn's next request, after a retry that it allowed in that
turn: each allowed retry stands for the one failed step that the request
after it follows, so no other error is taken for a retried step. On
OpenCode 2.3.0 through 2.4.4, which keep the mark, nothing changes. The
stage record lists the steps seen so (retriedMarks; see
debugging). - A declined shell request on OpenCode 2.4.5. With
shell: "ask"or
"inherit", a shell request of one of AZPR's sessions that a person
declines without a reason still ends that session's turn, which fails and
is not tried again. Through 2.4.4 OpenCode recorded that end as a
shutdown, without a marker, and could start another execution at once,
whose request AZPR refused. On 2.4.5 the decline ends the execution as a
person's stop does, with the marker of an interrupt, and withdraws what
woke the session until then: the notice of a background command that
waited starts no execution. Where the model's response in that step had
already failed (a stream that broke off, say), the execution ends as that
failure, on 2.4.2 to 2.4.4 as on 2.4.5, and such a notice can start
another one, whose request AZPR refuses. The host fixture holds the forms of 2.4.5, and now also a
turn whose last request the provider refused while such a notice waited:
OpenCode starts the next execution before AZPR's wait for the session
ends, and AZPR's check of the turn refuses its request. - A message that OpenCode 2.4.5 left unfinished ends its turn there. From
2.4.5 OpenCode settles an assistant message that it finds unfinished when an
execution starts or ends: with the error of an interrupt, or, where the
execution failed, with that execution's error. AZPR takes a message with
the error of an interrupt for the end of the execution, as it takes a step
that OpenCode interrupted: the turn fails as interrupted and nothing of it
is taken. A turn whose execution failed fails by that failure, as before. - Rows of AZPR's private data stay within 2,000 characters. From OpenCode
2.4.3 the native read returns a line whole where it fits a page of 50 KiB;
through 2.4.2 it cut a line after 2,000 characters. AZPR keeps writing rows
that every supported host returns whole, and the host fixture now holds
both: rows of at most 2,000 characters, and a line of 2,001 that 2.4.5
returns whole. - What OpenCode 2.4.3 to 2.4.5 change around a review, now documented.
- From 2.4.5 a new session that names no model (
opencode runwithout
-m, an ACP or API client) and whose agent names none gets themodel
ofopencode.jsonwhere that model is enabled, and otherwise can get the
model of the most recently updated top-level session that is not
archived, in any project. AZPR gives each of its sessions the model of
its stage, so during a review, and afterwards through the session that
keeps its report, that can be the model of one of AZPR's stages: set
modelinopencode.jsonto a model that is enabled to keep that
default your own. - A phone notification of a run that ended carries the last 500 characters
of the session's last answer (2.4.3), here a reviewer's or a planner's,
sealed for that phone. A level set for one session, on the phone or on
the server, decides before the phone's default, and a pause of the
server stops every notice. - A session ID from a receipt (
session=ses_…), pasted into the terminal
UI's command palette, opens that session (2.4.4). -pis the short form of--prompt(2.4.5), which should not send
AZPR's commands either: the terminal UI can submit it before it has
loaded them.- Where a provider reports the size of a request's context, OpenCode
records the prompt's token counts sized to it (2.4.4), so a stage's
tokensin the debug records can differ from the provider's bill. - The team guide
adds the experimentcodemode_agents(2.4.3),home_memoryreading the
sessions of every directory (2.4.4), and managed
experimental.tool.autopolicies, which from 2.4.4 can make a reviewer
wait for a person. - From 2.4.3 the full-screen terminal UI reads its commands again after a
first setup by itself; AZPR's own event for that stays, for the releases
before.
- From 2.4.5 a new session that names no model (
Upgrading OpenCode
Upgrade AZPR first, then OpenCode. AZPR 0.5.10 runs on OpenCode 2.4.2 as
well, while 0.5.9 on 2.4.5 fails a pass whose step OpenCode retried (see
above).
Back up OpenCode's database before the upgrade. OpenCode 2.4.3 to 2.4.5 add
six database migrations, and 2.4.4 moves the files it keeps beside the
database (the blobs directory) to names made of their content and deletes
the files of the earlier names, which 2.4.2 looks for. So going back to 2.4.2 needs the database and that directory as
they were before the upgrade. Close every OpenCode that uses the database
first: the commands below stop the background service, but a terminal UI or
an opencode serve that you started yourself writes to the same database,
and files copied while one of them writes may not fit together.
The commands ask OpenCode where it keeps the database and that directory
(opencode debug paths), as it finds them in the shell you run them in
(XDG_DATA_HOME and OPENCODE_DB can move them). Where you gave OpenCode's
background service an environment of its own (the env of its settings)
that names another database or data directory, export the same values in
that shell first (export OPENCODE_DB=…, export XDG_DATA_HOME=…), for
these commands and for those that go back: they then back up and restore
what the service uses. The commands install OpenCode with npm; use sudo
for the install (sudo npm install -g …) where your npm prefix needs it.
Run them only where that npm installed the opencode your shell runs:
command -v opencode is then in the bin directory that npm prefix -g
names (sudo npm prefix -g where you install with sudo). Another npm
changes another copy, which stays changed.
data=$(opencode debug paths data) &&
db=$(realpath "$(opencode debug paths db)") &&
backup=~/opencode-db-backup-$(date +%Y%m%d-%H%M%S) &&
test -f "$db" &&
mkdir -m 700 "$backup" "$backup/db" &&
opencode service stop &&
cp -p "$db" "$backup/db"/ &&
{ test ! -e "$db-wal" || cp -p "$db-wal" "$backup/db"/; } &&
{ test ! -e "$db-shm" || cp -p "$db-shm" "$backup/db"/; } &&
{ test ! -e "$data/blobs" || cp -pRH "$data/blobs" "$backup"/; } &&
npm install -g @opencode/cli@2.4.5 &&
test "$(NO_COLOR=1 opencode --version)" = "opencode v2.4.5" &&
opencode service start &&
echo "Database as it was before the upgrade: $backup"Each step runs only when the one before it succeeded, so OpenCode is not
upgraded without its backup, and where no database is found where OpenCode
says it keeps it, the commands end before they make the backup directory or
stop the service. Only the database with the two files SQLite keeps beside
it (in the backup's db directory) and the blobs directory are copied. A
database that is a link is copied from the file it names, beside which
SQLite keeps those two files, and a blobs directory that is a link to
another place is copied as the directory it names. Every run makes a
directory of its own, readable by you alone, so this backup is never mixed
with an earlier one and never replaces it; the last line says where it is.
The line after the install checks that the opencode your shell runs is
now 2.4.5 (NO_COLOR=1 keeps its answer plain where colours are forced).
Where npm installed it somewhere else (another prefix, another Node
version), or where your OpenCode came another way (its install script, a
package manager), the commands end there: run them again with the install
line replaced by the way you install OpenCode. If a step before the service
starts fails (a copy, the install, that check), the database is as it was
and the service is still stopped: start it with opencode service start.
If the commands' own opencode service start fails, 2.4.5 may have begun
to change the database, which it does as it starts, and may still be at it:
keep the backup (the newest ~/opencode-db-backup-…), run opencode service start again after a while (it waits for a service that is still
starting), and do not run these commands again, which would back up the
changed database as the one before the upgrade.
To go back to 2.4.2, the backup takes the place of the database, and what was
done since the upgrade (every conversation of that time, not only reviews) is
not in it. So the database of that time is moved aside, into a directory of
its own that only you can read, and nothing is deleted. Close every OpenCode
first, as for the upgrade; put the directory the upgrade named and the
version you go back to in the first two lines:
backup=~/opencode-db-backup-YYYYMMDD-HHMMSS
version=2.4.2
data=$(opencode debug paths data) &&
db=$(realpath "$(opencode debug paths db)") &&
name=$(basename "$db") &&
since=~/opencode-db-since-upgrade-$(date +%Y%m%d-%H%M%S) &&
test -f "$backup/db/$name" &&
mkdir -m 700 "$since" "$since/db" &&
opencode service stop &&
npm install -g "@opencode/cli@$version" &&
test "$(NO_COLOR=1 opencode --version)" = "opencode v$version" &&
{ test ! -e "$db" || mv "$db" "$since/db"/; } &&
{ test ! -e "$db-wal" || mv "$db-wal" "$since/db"/; } &&
{ test ! -e "$db-shm" || mv "$db-shm" "$since/db"/; } &&
{ test ! -L "$data/blobs" || { blobs=$(realpath "$data/blobs") &&
ln -s "$blobs" "$since/blobs" && rm "$data/blobs"; }; } &&
{ test ! -e "$data/blobs" || mv "$data/blobs" "$since"/; } &&
{ test ! -e "$backup/blobs" || cp -pR "$backup/blobs" "$data"/; } &&
cp -p "$backup/db/$name" "$db" &&
{ test ! -e "$backup/db/$name-wal" || cp -p "$backup/db/$name-wal" "$db-wal"; } &&
{ test ! -e "$backup/db/$name-shm" || cp -p "$backup/db/$name-shm" "$db-shm"; } &&
opencode service start &&
echo "Database as it was since the upgrade: $since"When the backup is not where the first line says, the commands end before
they stop the service, and nothing is moved or installed. They find
the database and the blobs directory as the upgrade did, so run them in the
same environment. The check after the install ends them before anything is
moved where the opencode your shell runs is not the version of the second
line. The files SQLite keeps beside the database are moved with it: one of
the newer database left beside the restored one would be applied to it. A
database that is a link stays in place, and the file it names is moved and
restored. A blobs directory that was a link is put aside as a link to the
place it named, which keeps what OpenCode made of it since the upgrade, and
the copy takes its place as a directory. If a step fails, nothing
is lost: the backup stays where it was, and what was moved is in the
directory the command made (~/opencode-db-since-upgrade-…). Where it was
a step before the service starts, the service is still stopped: start it
with opencode service start once the database is in place. Keep that
directory, and the place a blobs link named, until you know you will not
want what they hold.
Both sets of commands were run as written here, with bash and with dash,
in a sandbox with a home directory of its own, OpenCode's managed service and
the real OpenCode 2.4.2 and 2.4.5 (only npm was replaced by a stand-in that
switched between them). 2.4.5 kept the sessions and moved a file that 2.4.2
had stored to its new name; after going back, 2.4.2 served that file again.
Without the lines for the blobs directory, 2.4.2 no longer found it;
where that directory was a link, a backup that copied the link (cp -pR
without -H) lost the file the same way, and the commands as written kept
it. With OPENCODE_DB set in the shell, they backed up and restored the
database it names and left the one at the default place as it was; set in
the service's own environment and in the shell, they did the same for the
service's database. A database that was a link went up and back with the
files SQLite had left beside the file it names, a session among them, and
stayed a link. A blobs link of a relative target was put aside as a link
that still named that place, a database named blobs was kept apart from
that directory, and one kept inside that directory went up and back. With
colours forced (FORCE_COLOR=1), both sets went through. Where npm
installed somewhere else than the opencode the shell runs, the check
ended the commands before anything was moved. A profile without that
directory went up and back, a copy that failed stopped the commands before
the install, and where the database or the backup was missing they ended
before the service was stopped. Without what does so, the same runs went
wrong: a backup of the link's own path lost that session, and going back
put a file in the link's place; a relative link moved as it was named
another place; the copy of the blobs directory failed beside a database
of that name; going back reported a return to 2.4.2 while 2.4.5 ran; with
colours forced, the check refused 2.4.2 once it was installed, before the
database of 2.4.5 was put aside; and with that directory restored after the
database, going back ended at the copy of a database kept inside it.
Installation
opencode plugin add opencode-azure-devops-pr-review@0.5.10Alternatively, install the same release from Git:
opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.5.10'Add only one of them. Then open OpenCode's terminal UI and type /pr-setup;
the
quickstart
walks through it and shows the way without the terminal UI.
Upgrading AZPR
From 0.5.9, settings, the PAT file, saved reviews and saved previews are used
as they are. Add 0.5.10 and remove the previous version only when the
download succeeded. Replace PREVIOUS_VERSION with the version in your
plugins entry:
opencode plugin add opencode-azure-devops-pr-review@0.5.10 &&
opencode plugin remove opencode-azure-devops-pr-review@PREVIOUS_VERSIONRun them when no AZPR command is running. For an entry with options, change
only its package value. For a Git installation, add the new tag and remove
the spec your entry names (replace YOUR_ENTRY with it, for example
github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.5.9):
opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.5.10' &&
opencode plugin remove 'YOUR_ENTRY'Coming from a version before 0.5.6,
read the
0.5.6 release notes
first;
upgrading
gives the details. Manual copying needs the same 33 files as 0.5.6.
Known limitations
New with OpenCode 2.4.3 to 2.4.5, and documented above: the default model
that a new session takes from AZPR's sessions where opencode.json sets no
model, the excerpt of a session's last answer in a phone notification, and
a managed experimental.tool.auto policy that makes a reviewer wait for a
person. Not changed by this release: the limitations that the
validation record
keeps current.
Compatibility and validation
The tested target is OpenCode CLI 2.4.5 (V2 plugin API), Node.js
22.23.3, Ubuntu 22.04.5 under WSL2, and Azure DevOps Services REST API
7.1. /pr-check notes other OpenCode versions in its OpenCode row.
OpenCode 1.x and Azure DevOps Server are not supported; other operating
systems remain unvalidated.
The prompt files under src/prompts are unchanged. The
comparison of OpenCode 2.4.5 with 2.4.2
says what was measured on which version and what was only read from
OpenCode's source.
The npm package, Git package and source archive contain the same runtime, with
no npm dependencies or install scripts; the source archive also contains the
documentation, installers and settings example. The release source artifact is
opencode-azure-devops-pr-review-v2-0.5.10.tar.gz, and SHA256SUMS lists its
checksum.