opencode-azure-devops-pr-review 0.4.5 → 0.4.6
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 +70 -0
- package/README.md +51 -15
- package/package.json +1 -1
- package/src/attribution.mjs +92 -1
- package/src/azure.mjs +12 -0
- package/src/comment-work.mjs +192 -16
- package/src/comments.mjs +364 -20
- package/src/config.mjs +4 -3
- package/src/prompts/comment-plan.md +46 -3
- package/src/prompts/comment-policy.md +2 -0
- package/src/runtime.mjs +17 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.6 — 2026-11-21
|
|
4
|
+
|
|
5
|
+
One defect that a pull request makes at several places now gets one inline
|
|
6
|
+
comment that lists the other places, where each place had a thread of its own.
|
|
7
|
+
The reviewer and verifier instructions are those of 0.4.5, so a review finds
|
|
8
|
+
and verifies as before; the comment planner's instructions changed, and no
|
|
9
|
+
setting is new.
|
|
10
|
+
|
|
11
|
+
Comments:
|
|
12
|
+
|
|
13
|
+
- A mistake repeated in several places (the same wrong call in each handler,
|
|
14
|
+
the same stale text in each copy) is one finding per place, since each place
|
|
15
|
+
needs its own correction. Each of them used to get an inline thread with
|
|
16
|
+
much the same text: twelve moved files with one inherited defect were twelve
|
|
17
|
+
threads to read and resolve. The comment planner may now write one comment
|
|
18
|
+
for such findings, at the place that shows the mistake most clearly.
|
|
19
|
+
- AZPR lists every other place under that comment, in a section
|
|
20
|
+
`**📍 Also at** (the same defect; fix these places with it):` (in Chinese
|
|
21
|
+
`**📍 其他位置**`): one row per other finding with its file, its lines and
|
|
22
|
+
its ID. The rows are the findings' own locations, not text the planner
|
|
23
|
+
wrote, and the list is plain: nothing is collapsed or linked, so its own
|
|
24
|
+
markup holds nothing back in automatic publication (a file name is checked
|
|
25
|
+
like any other text of the comment).
|
|
26
|
+
- Findings share a comment only when they have the same severity (high or
|
|
27
|
+
medium), lie on different lines of files the pull request changes, and the
|
|
28
|
+
planner says they are the same mistake with the same correction. Places
|
|
29
|
+
that need different corrections keep their own comments, and when unsure
|
|
30
|
+
the planner keeps findings apart. The preview shows a shared comment with
|
|
31
|
+
all its findings and the planner's reason.
|
|
32
|
+
- A place is listed as its finding states it. The runtime therefore offers a
|
|
33
|
+
finding only when the file has those lines at the reviewed commit and its
|
|
34
|
+
name can stand in a list unchanged, and it accepts a shared comment only
|
|
35
|
+
when its anchor touches the lines of exactly one of its findings, which is
|
|
36
|
+
where the comment stands. A text that ends inside a code fence or a raw
|
|
37
|
+
HTML block, which would take the list in, is sent back for correction.
|
|
38
|
+
- The review is unchanged: it still has one finding per place. Each keeps
|
|
39
|
+
its row in the summary index, its ID, and can be left out or given another
|
|
40
|
+
severity after a preview.
|
|
41
|
+
- A shared comment has a marker of its own, made of its file, the lines it
|
|
42
|
+
quotes and the other places it lists. Publication skips it only when that
|
|
43
|
+
marker is on the pull request, so `ALREADY_PRESENT` means that this very
|
|
44
|
+
comment, with every place, is there. The markers of comments for one place
|
|
45
|
+
are unchanged, and so is publication.
|
|
46
|
+
- Which findings may be such repeats is settled before the planning pages are
|
|
47
|
+
made, and only when at least two of them have one severity and lie at
|
|
48
|
+
different places. When all findings fit one page (at most four, within a
|
|
49
|
+
page's text), that page is offered its findings of equal severity at
|
|
50
|
+
different places. Otherwise, where two of them fit one page together, a
|
|
51
|
+
grouping pass runs first: one more stage of the comment planner, usually
|
|
52
|
+
one request, whose input is the findings that could share a page with
|
|
53
|
+
another one of their severity, and which says which are one mistake at
|
|
54
|
+
several places. A group then shares a
|
|
55
|
+
page, which can hold more than four findings. A pass that fails costs only
|
|
56
|
+
the grouping (a progress notice says so, and the comments are planned one
|
|
57
|
+
per place), and a run that is stopped during it plans nothing more.
|
|
58
|
+
- Nothing posted is ever changed, and an item the PR already has is skipped
|
|
59
|
+
as always. When a pull request with a shared comment is planned again, the
|
|
60
|
+
planner is told which other places that thread says it covers, so they get
|
|
61
|
+
no thread of their own; the list is read back only where AZPR wrote it, in
|
|
62
|
+
the comment that opened the thread.
|
|
63
|
+
- A shared comment and a comment for one place are not put on the same
|
|
64
|
+
quoted lines (a thread per place from an earlier version, say): when
|
|
65
|
+
planning, the comment is sent back and the planner is asked for another
|
|
66
|
+
place or to skip the finding as discussed, and a comment that still stands
|
|
67
|
+
there is not planned, with the reason shown in the preview.
|
|
68
|
+
|
|
69
|
+
The README's benchmark section now says what each precision measures: the
|
|
70
|
+
share of comments on Martian's list of issues, next to the share of findings
|
|
71
|
+
that ReviewBench's judge rated valid.
|
|
72
|
+
|
|
3
73
|
## 0.4.5 — 2026-11-20
|
|
4
74
|
|
|
5
75
|
While a run is under way, the terminal panel offers to stop it. The reviewer,
|
package/README.md
CHANGED
|
@@ -12,7 +12,8 @@ and choose what gets published. No MCP server or CI pipeline setup is required.
|
|
|
12
12
|
|
|
13
13
|
On Martian's open [Code Review Bench](#benchmark-results), `/pr-deep` found
|
|
14
14
|
more of the listed issues in 50 real pull requests than any of the 21 tools on
|
|
15
|
-
the benchmark's dashboard.
|
|
15
|
+
the benchmark's dashboard. On ReviewBench's test set, which scores each finding
|
|
16
|
+
on its own merits, 97.4% of its findings were judged valid.
|
|
16
17
|
|
|
17
18
|
AZPR is an independent community project. It is not built by or affiliated with
|
|
18
19
|
the OpenCode team.
|
|
@@ -61,7 +62,7 @@ Waiting time is shortened, so the length is not the review duration.
|
|
|
61
62
|
[company networks](docs/ENTERPRISE.md#company-networks) first):
|
|
62
63
|
|
|
63
64
|
```sh
|
|
64
|
-
opencode plugin add opencode-azure-devops-pr-review@0.4.
|
|
65
|
+
opencode plugin add opencode-azure-devops-pr-review@0.4.6
|
|
65
66
|
```
|
|
66
67
|
|
|
67
68
|
2. In OpenCode's terminal UI, type `/pr-setup`. Dialogs ask for your Azure
|
|
@@ -197,8 +198,14 @@ tools on its public dashboard.**
|
|
|
197
198
|
- **Built for interactive triage (F2 54.1, would rank 6th):** `/pr-deep`
|
|
198
199
|
reports every defect it confirms instead of holding findings back, and you
|
|
199
200
|
choose which ones to publish.
|
|
200
|
-
|
|
201
|
-
|
|
201
|
+
- **Findings that hold up when checked (95.6% judged valid):** this
|
|
202
|
+
benchmark's precision is the share of comments that are on its list of about
|
|
203
|
+
three issues per PR, so it counts an accurate comment outside that list as
|
|
204
|
+
wrong. [ReviewBench](#checked-on-a-second-benchmark) scores each finding on
|
|
205
|
+
its own merits instead: it judged 95.6% of this release's findings valid, and
|
|
206
|
+
97.4% of 0.3.7's.
|
|
207
|
+
|
|
208
|
+
| Tool | Issues found (recall) | High and Critical found | Comments on the benchmark's list (precision) | F2 |
|
|
202
209
|
| :--- | ---: | ---: | ---: | ---: |
|
|
203
210
|
| **AZPR 0.3.5 (`/pr-deep`, Claude Opus 5.5)** | **67.7%** 🏆 | **74.2%** 🏆 | **30.0%** | **54.1** |
|
|
204
211
|
| copilot-v2 | 66.5% | 71.2% | 38.5% | 58.0 |
|
|
@@ -232,6 +239,12 @@ The benchmark's precision also counts accurate comments it does not list:
|
|
|
232
239
|
AZPR findings that matched no expected issue against the source code:
|
|
233
240
|
**36 were accurate**, and **18 were genuine defects** introduced or exposed
|
|
234
241
|
by the PR that the benchmark's list does not include.
|
|
242
|
+
3. **A judge that checks each finding found them valid.** ReviewBench does not
|
|
243
|
+
compare findings with a list alone: its judge checks every finding that
|
|
244
|
+
matches no listed issue against the code. On its 25-PR test set it judged
|
|
245
|
+
**95.6%** of this release's findings valid, and **97.4%** of 0.3.7's
|
|
246
|
+
([the runs](#checked-on-a-second-benchmark)). We ran its scoring pipeline
|
|
247
|
+
ourselves, so this is not a leaderboard result.
|
|
235
248
|
|
|
236
249
|
### Model and effort recommendations
|
|
237
250
|
|
|
@@ -435,14 +448,14 @@ Azure DevOps REST API with the runtime's built-in `fetch`.
|
|
|
435
448
|
Install the npm package with OpenCode's plugin manager:
|
|
436
449
|
|
|
437
450
|
```sh
|
|
438
|
-
opencode plugin add opencode-azure-devops-pr-review@0.4.
|
|
451
|
+
opencode plugin add opencode-azure-devops-pr-review@0.4.6
|
|
439
452
|
```
|
|
440
453
|
|
|
441
454
|
The same release is also a versioned Git package, which needs Git but not the
|
|
442
455
|
npm registry:
|
|
443
456
|
|
|
444
457
|
```sh
|
|
445
|
-
opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.
|
|
458
|
+
opencode plugin add 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.6'
|
|
446
459
|
```
|
|
447
460
|
|
|
448
461
|
Add only one of them. OpenCode 2.3.0 loads the plugin into a running OpenCode
|
|
@@ -457,7 +470,7 @@ To select another configuration file, use an absolute path in the host config:
|
|
|
457
470
|
```json
|
|
458
471
|
{
|
|
459
472
|
"plugins": [{
|
|
460
|
-
"package": "opencode-azure-devops-pr-review@0.4.
|
|
473
|
+
"package": "opencode-azure-devops-pr-review@0.4.6",
|
|
461
474
|
"options": { "settingsFile": "/absolute/path/to/azpr/settings.json" }
|
|
462
475
|
}]
|
|
463
476
|
}
|
|
@@ -482,7 +495,7 @@ For an entry that `opencode plugin add` created, add the new version and,
|
|
|
482
495
|
only when that succeeds, remove the previous one:
|
|
483
496
|
|
|
484
497
|
```sh
|
|
485
|
-
opencode plugin add opencode-azure-devops-pr-review@0.4.
|
|
498
|
+
opencode plugin add opencode-azure-devops-pr-review@0.4.6 &&
|
|
486
499
|
opencode plugin remove opencode-azure-devops-pr-review@PREVIOUS_VERSION
|
|
487
500
|
```
|
|
488
501
|
|
|
@@ -514,7 +527,8 @@ the first one (`Unknown setting settings.terminalPanel`) instead of starting. `o
|
|
|
514
527
|
show a single `azpr` row with the new version (from 0.3.1, `/pr-check` names
|
|
515
528
|
it too); if it still shows the previous one, run `opencode service restart`.
|
|
516
529
|
Exact versions stay pinned, so `opencode plugin update` leaves them unchanged.
|
|
517
|
-
See the [0.4.
|
|
530
|
+
See the [0.4.6 release notes](docs/releases/v0.4.6.md) for what changed, the
|
|
531
|
+
[0.4.5 release notes](docs/releases/v0.4.5.md) for stopping a run from the panel, the
|
|
518
532
|
[0.4.4 release notes](docs/releases/v0.4.4.md) for the steps at the panel's foot, the
|
|
519
533
|
[0.4.3 release notes](docs/releases/v0.4.3.md) for setup in the terminal UI, the
|
|
520
534
|
[0.4.0 release notes](docs/releases/v0.4.0.md) for commands without review IDs and the
|
|
@@ -528,8 +542,8 @@ review command flag.
|
|
|
528
542
|
<details>
|
|
529
543
|
<summary>Source installation and replacement</summary>
|
|
530
544
|
|
|
531
|
-
Download the [v0.4.
|
|
532
|
-
and extract it, or check out tag `v0.4.
|
|
545
|
+
Download the [v0.4.6 source archive](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/archive/refs/tags/v0.4.6.tar.gz)
|
|
546
|
+
and extract it, or check out tag `v0.4.6`. The installer needs POSIX `sh` and
|
|
533
547
|
Python 3's standard library. From that source directory:
|
|
534
548
|
|
|
535
549
|
```sh
|
|
@@ -1066,7 +1080,8 @@ notices as before. The same terminal part brings the
|
|
|
1066
1080
|
|
|
1067
1081
|
`/pr-comment` plans one general summary plus inline comments for confirmed high
|
|
1068
1082
|
and medium findings (low findings stay in the summary index). Planning runs in
|
|
1069
|
-
pages of at most four findings
|
|
1083
|
+
pages of at most four findings (more only where one defect at several places
|
|
1084
|
+
keeps its findings together), two pages at a time, and the pages are joined
|
|
1070
1085
|
in page order, so the result does not depend on which page finishes first; each
|
|
1071
1086
|
page may get a correction turn, and an item that still cannot be posted
|
|
1072
1087
|
faithfully is skipped with a reason instead of failing the command. Inline
|
|
@@ -1079,6 +1094,27 @@ coverage), and their inline comments need a location on a changed HEAD file.
|
|
|
1079
1094
|
When two shards of a quick review report one defect, the planner may combine
|
|
1080
1095
|
them into one comment under fixed rules (see [commenting](docs/COMMENTING.md)).
|
|
1081
1096
|
|
|
1097
|
+
One mistake is often made at several places of a pull request: the same wrong
|
|
1098
|
+
call in each handler, the same stale text in each copy. Each place is a
|
|
1099
|
+
finding of its own, and the planner may give such findings one inline comment
|
|
1100
|
+
instead of a thread per place. The comment stands at the place that shows the
|
|
1101
|
+
mistake most clearly, and AZPR lists every other place under it:
|
|
1102
|
+
|
|
1103
|
+
```text
|
|
1104
|
+
**📍 Also at** (the same defect; fix these places with it):
|
|
1105
|
+
- `/src/orders/refund.ts:41-44` (F-3)
|
|
1106
|
+
- `/src/orders/cancel.ts:18` (F-5)
|
|
1107
|
+
```
|
|
1108
|
+
|
|
1109
|
+
The findings must have the same severity and need the same correction; places
|
|
1110
|
+
that need different corrections keep their own comments. Every place keeps
|
|
1111
|
+
its row in the summary index, and you can still exclude or regrade each one
|
|
1112
|
+
after a preview. A shared comment has a marker of its own, so it counts as
|
|
1113
|
+
already posted only when this very comment, with every place, is on the pull
|
|
1114
|
+
request; and a shared comment and a comment for one place are not planned
|
|
1115
|
+
onto the same quoted lines (see
|
|
1116
|
+
[one defect at several places](docs/COMMENTING.md#one-defect-at-several-places)).
|
|
1117
|
+
|
|
1082
1118
|
### Adjusting findings after a preview
|
|
1083
1119
|
|
|
1084
1120
|
When a preview contains findings you disagree with, leave them out or change
|
|
@@ -1281,8 +1317,8 @@ dependency and is not built on your machine.
|
|
|
1281
1317
|
Uninstall without `--apply` previews; `--apply` archives only this package under
|
|
1282
1318
|
`azpr-v2-backups` and leaves the private state directory for you to delete.
|
|
1283
1319
|
For a native installation, remove the entry you added, for example
|
|
1284
|
-
`opencode plugin remove opencode-azure-devops-pr-review@0.4.
|
|
1285
|
-
`opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.
|
|
1320
|
+
`opencode plugin remove opencode-azure-devops-pr-review@0.4.6` or
|
|
1321
|
+
`opencode plugin remove 'github:WTLAIB/opencode-azure-devops-pr-review-v2#v0.4.6'`;
|
|
1286
1322
|
the external settings, PAT file and private review state remain available.
|
|
1287
1323
|
|
|
1288
1324
|
[Architecture](docs/ARCHITECTURE.md), [commenting](docs/COMMENTING.md),
|
|
@@ -1295,7 +1331,7 @@ or personal model selections.
|
|
|
1295
1331
|
## License and releases
|
|
1296
1332
|
|
|
1297
1333
|
[MIT](LICENSE), copyright 2026 WTLAIB. See the [changelog](CHANGELOG.md) for the
|
|
1298
|
-
release scope, [v0.4.
|
|
1334
|
+
release scope, [v0.4.6](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.4.6)
|
|
1299
1335
|
for downloads, the [npm package](https://www.npmjs.com/package/opencode-azure-devops-pr-review),
|
|
1300
1336
|
[v0.2.0](https://github.com/WTLAIB/opencode-azure-devops-pr-review-v2/releases/tag/v0.2.0)
|
|
1301
1337
|
for the recorded demonstration, and [releasing](docs/RELEASING.md) for the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-azure-devops-pr-review",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
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/attribution.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ROLES, MAX_ARCHIVE_MEGABYTES } from './config.mjs';
|
|
1
|
+
import { ROLES, MAX_ARCHIVE_MEGABYTES, isModelReference } from './config.mjs';
|
|
2
2
|
// Deterministic attribution from invoked reviewer stages, not model-authored claims.
|
|
3
3
|
const vocabulary = {
|
|
4
4
|
en: { title: 'AI review provenance', disclaimer: 'AI-generated review, not human approval. Posting through a user account does not imply that person verified these conclusions.', method: 'Independent initial reviews, followed by source-based verification, duplicate merging, and rejection of unsupported findings; not majority voting.', roles: ['Source check', 'Functional review', 'Risk review', 'Verification', 'Duplicate check', 'Quick review', 'Severity rating'], stage: 'Stage', model: 'Selected provider/model ID', sessions: 'Sessions', count: 'Initial findings', dispositions: 'Finding dispositions', finding: 'Finding', result: 'Result', merged: 'Merged into', extra: 'New verifier findings', note: 'IDs identify the models selected in OpenCode, not independently verified provider backend identities. Host auxiliary models and the original chat model are not part of this ledger.', comment: 'AI-generated review; not human review or approval. Models:',
|
|
@@ -142,6 +142,97 @@ function displayLocation(value) {
|
|
|
142
142
|
return value;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
/** The heading of the list of other places in each language it is written in; what reads the list back knows it by these lines. */
|
|
146
|
+
export const OTHER_PLACES_HEADINGS = Object.freeze(['**📍 Also at** (the same defect; fix these places with it):', '**📍 其他位置**(同一個問題,請一併修正):', '**📍 其他位置**(同一个问题,请一并修正):']);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The other places of one defect that a comment covers, as the runtime adds
|
|
150
|
+
* them under the comment's own text: one row per finding with its file and
|
|
151
|
+
* lines, from the findings' own locations, never from text a model wrote.
|
|
152
|
+
* A plain list: nothing here is collapsed or linked.
|
|
153
|
+
* @param {{findingId: string, place: string}[]} places
|
|
154
|
+
*/
|
|
155
|
+
export function renderOtherPlaces(places, language) {
|
|
156
|
+
const [english, traditional, simplified] = OTHER_PLACES_HEADINGS;
|
|
157
|
+
const heading = pick(language, english, traditional, simplified);
|
|
158
|
+
return `${heading}\n${places.map(({ findingId, place }) => placeRow(place, findingId, pick(language, ROW_BRACKETS[0], ROW_BRACKETS[1], ROW_BRACKETS[1]))).join('\n')}`;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// How a row puts its finding ID in brackets: in English, and in Chinese.
|
|
162
|
+
const ROW_BRACKETS = [[' (', ')'], ['(', ')']];
|
|
163
|
+
|
|
164
|
+
/** One row of that list: the place in a code span that holds any text (longer than the longest run of backticks inside it), then the finding ID. */
|
|
165
|
+
function placeRow(place, findingId, [open, close]) {
|
|
166
|
+
const text = String(place).replace(/[\r\n\t]+/g, ' ');
|
|
167
|
+
const run = Math.max(0, ...(text.match(/`+/g) ?? []).map(match => match.length));
|
|
168
|
+
const fence = '`'.repeat(run + 1);
|
|
169
|
+
return `- ${run ? `${fence} ${text} ${fence}` : `\`${text}\``}${open}${String(findingId).replace(/[^A-Za-z0-9_-]/g, '')}${close}`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Whether a place can be written into that list and read back as it is: its
|
|
174
|
+
* text holds no control character, no line separator and neither end of an
|
|
175
|
+
* HTML comment, which the posted text would have to change.
|
|
176
|
+
*/
|
|
177
|
+
export const listablePlace = place => typeof place === 'string' && !/[\u0000-\u001f\u007f-\u009f\u2028\u2029]|<!--|-->/.test(place);
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The places a posted comment of AZPR's lists, read back from its text for a
|
|
181
|
+
* later plan (`alsoAt` in the digest of a thread): the rows under the heading
|
|
182
|
+
* `renderOtherPlaces` writes, where they end the comment's own text as
|
|
183
|
+
* `assemblePlan` writes it. A row counts only when writing its place and its
|
|
184
|
+
* finding ID again gives the very line (so a row is one a finding's place
|
|
185
|
+
* could have produced: a path, its lines in order, an ID). After the rows
|
|
186
|
+
* comes a blank line, then the attribution if there is one (a rule, the line
|
|
187
|
+
* `commentAttribution` writes for a comment, and a blank line), then the two
|
|
188
|
+
* markers of such a comment (`linesMarker`, then its own) with a blank line
|
|
189
|
+
* between them.
|
|
190
|
+
* [] for any other text: one that merely holds such a heading or such rows,
|
|
191
|
+
* one whose row has another form, one that was continued after the list.
|
|
192
|
+
* What is read here tells a planner what a thread says it covers, as the
|
|
193
|
+
* start of the thread's text does; nothing is posted or skipped because of it.
|
|
194
|
+
*/
|
|
195
|
+
export function listedPlaces(content) {
|
|
196
|
+
// Line by line as written: only the line ends a service may return differ from what the runtime wrote.
|
|
197
|
+
const lines = String(content ?? '').split(/\r?\n/);
|
|
198
|
+
while (lines.length && lines.at(-1) === '') lines.pop();
|
|
199
|
+
const heading = lines.findLastIndex(line => OTHER_PLACES_HEADINGS.includes(line));
|
|
200
|
+
if (heading < 0) return [];
|
|
201
|
+
// The rows are written in the heading's language: English brackets under the English heading, Chinese ones otherwise.
|
|
202
|
+
const brackets = ROW_BRACKETS[OTHER_PLACES_HEADINGS.indexOf(lines[heading]) ? 1 : 0];
|
|
203
|
+
const places = [];
|
|
204
|
+
let next = heading + 1;
|
|
205
|
+
for (; next < lines.length && lines[next].startsWith('- `'); next++) {
|
|
206
|
+
// The row's parts, each read once: the opening code-span delimiter, the finding ID at the end, the place
|
|
207
|
+
// between them. Writing the row again must give the very line, so nothing else passes.
|
|
208
|
+
const line = lines[next], fence = /^`+/.exec(line.slice(2))[0], id = /[((]([A-Za-z]+-\d+)[))]$/.exec(line);
|
|
209
|
+
const inner = id && line.slice(2 + fence.length, id.index).trimEnd();
|
|
210
|
+
const place = inner && inner.endsWith(fence) ? inner.slice(0, -fence.length).trim() : '';
|
|
211
|
+
const at = /^\/[^:]+:([1-9]\d*)(?:-([1-9]\d*))?$/.exec(place);
|
|
212
|
+
// A place as a finding's is written (lines in order), in the row the runtime writes for it under this heading.
|
|
213
|
+
if (!at || Number(at[2] ?? at[1]) < Number(at[1]) || !listablePlace(place) || placeRow(place, id[1], brackets) !== line) return [];
|
|
214
|
+
places.push(place);
|
|
215
|
+
}
|
|
216
|
+
const rest = lines.slice(next);
|
|
217
|
+
const marker = /^<!-- azpr-comment:[a-f0-9]{32} -->$/;
|
|
218
|
+
// The end of a comment for several places: the marker of its lines, a blank line, its own marker.
|
|
219
|
+
if (!places.length || rest.shift() !== '' || !marker.test(rest.pop() ?? '') || rest.pop() !== '' || !marker.test(rest.pop() ?? '')) return [];
|
|
220
|
+
if (!rest.length) return places;
|
|
221
|
+
// The attribution: a rule, the line the runtime writes for a comment, and a blank line.
|
|
222
|
+
return rest.length === 3 && rest[0] === '---' && commentAttributionLine(rest[1]) && rest[2] === '' ? places : [];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Whether a line is the attribution `commentAttribution` writes for an inline
|
|
227
|
+
* comment, in any language: its fixed wording for a verified or a quick
|
|
228
|
+
* review, then the models (references as settings take them), each in a code
|
|
229
|
+
* span, and nothing else.
|
|
230
|
+
*/
|
|
231
|
+
function commentAttributionLine(line) {
|
|
232
|
+
return Object.values(vocabulary).flatMap(words => [`${words.comment} `, `${words.lead}${words.quick}${words.end}${words.models} `])
|
|
233
|
+
.some(wording => line.startsWith(wording) && line.slice(wording.length).split(', ').every(span => /^`[^`]+`$/.test(span) && isModelReference(span.slice(1, -1))));
|
|
234
|
+
}
|
|
235
|
+
|
|
145
236
|
/** A compact index of existing claims, not another model-authored assessment. */
|
|
146
237
|
export function renderReviewSummary(findings, language, introduction = '', { verification = 'independent', groups = [] } = {}) {
|
|
147
238
|
const w = reportWords(language);
|
package/src/azure.mjs
CHANGED
|
@@ -238,6 +238,18 @@ export function markersInThreads(threads) {
|
|
|
238
238
|
return found;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
+
/** The AZPR markers each live thread holds in its live comments, by thread: AZPR's comments on the PR, thread by thread. */
|
|
242
|
+
export function threadMarkers(threads) {
|
|
243
|
+
const found = new Map();
|
|
244
|
+
for (const thread of threads) {
|
|
245
|
+
if (thread?.isDeleted === true) continue;
|
|
246
|
+
const markers = (Array.isArray(thread?.comments) ? thread.comments : []).filter(comment => comment?.isDeleted !== true && typeof comment?.content === 'string')
|
|
247
|
+
.flatMap(comment => [...comment.content.matchAll(MARKER_PATTERN)].map(match => match[0]));
|
|
248
|
+
if (markers.length) found.set(thread.id, new Set(markers));
|
|
249
|
+
}
|
|
250
|
+
return found;
|
|
251
|
+
}
|
|
252
|
+
|
|
241
253
|
/** The text of the live comment that carries each marker, found as markersInThreads finds its thread. */
|
|
242
254
|
export function markerTexts(threads) {
|
|
243
255
|
const found = new Map();
|