opencode-azure-devops-pr-review 0.4.5 → 0.5.0
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 +231 -0
- package/README.md +552 -219
- package/package.json +2 -2
- package/src/attribution.mjs +252 -93
- package/src/azure.mjs +12 -0
- package/src/comment-work.mjs +199 -18
- package/src/comments.mjs +484 -55
- package/src/config.mjs +163 -75
- package/src/host.mjs +1 -1
- package/src/output.mjs +89 -320
- package/src/prompts/comment-plan.md +51 -8
- package/src/prompts/comment-policy.md +6 -4
- package/src/prompts/common.md +2 -13
- package/src/prompts/dedupe.md +19 -11
- package/src/prompts/rating.md +4 -4
- package/src/prompts/{quick.md → review.md} +19 -6
- package/src/review-work.mjs +434 -426
- package/src/runtime.mjs +154 -90
- package/src/session.mjs +3 -2
- package/src/setup.mjs +253 -54
- package/src/tui-setup.mjs +87 -12
- package/src/prompts/final.md +0 -64
- package/src/prompts/functional.md +0 -34
- package/src/prompts/risk.md +0 -36
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# Role: comment planner
|
|
2
2
|
|
|
3
3
|
`commentWork` identifies this work page. Account for every finding in `findings`
|
|
4
|
-
(at most four per page): each one appears exactly once, either in
|
|
5
|
-
in `skipped` with a reason. Other pages handle other findings.
|
|
4
|
+
(usually at most four per page): each one appears exactly once, either in
|
|
5
|
+
`comments` or in `skipped` with a reason. Other pages handle other findings.
|
|
6
6
|
<!-- azpr:verified -->
|
|
7
7
|
The verifier already merged duplicate findings: each finding is a separate
|
|
8
8
|
issue, so never skip one because another finding of this review has or will get
|
|
9
9
|
a comment.
|
|
10
|
-
<!-- azpr:
|
|
10
|
+
<!-- azpr:reviewers -->
|
|
11
11
|
Treat each finding as a separate issue, as the reviewer reported it: never skip
|
|
12
12
|
one because another finding of this review has or will get a comment.
|
|
13
|
-
|
|
14
|
-
lists such candidates
|
|
15
|
-
overlapping lines of one file, with the same severity). Combine findings of one
|
|
13
|
+
Where the input has `mergeCandidates`, different sessions may have reported one
|
|
14
|
+
defect twice: the runtime lists such candidates there (findings of different
|
|
15
|
+
sessions on overlapping lines of one file, with the same severity). Combine findings of one
|
|
16
16
|
group into one comment only when they state the same root cause, with
|
|
17
17
|
compatible triggers and the same correction: give that comment `findingIds`
|
|
18
18
|
with every finding it covers and a `mergeReason`, keep each trigger and the
|
|
@@ -22,6 +22,27 @@ when unsure, comment on each finding separately; never combine findings
|
|
|
22
22
|
outside a listed group.
|
|
23
23
|
<!-- azpr:end -->
|
|
24
24
|
|
|
25
|
+
One mistake is sometimes made at several places (the same wrong call in each
|
|
26
|
+
handler, the same stale text in each copy), and each place is a finding of its
|
|
27
|
+
own. `repeatCandidates`, when present, lists groups of this page's findings
|
|
28
|
+
that may be such repeats: findings of one severity at different places. Give
|
|
29
|
+
findings of one group a single comment only when they are the same mistake and
|
|
30
|
+
one instruction corrects every place: anchor it at the place that shows the
|
|
31
|
+
mistake most clearly, quoting lines of that one finding only, give it
|
|
32
|
+
`findingIds` with every finding it covers and a `mergeReason`, and word the
|
|
33
|
+
body so that it holds for each of them. Do not list the other places: the
|
|
34
|
+
runtime adds each other finding's file and lines under your text. A thread of
|
|
35
|
+
AZPR's in `existingDiscussions` (`azpr: true`) that already covers findings,
|
|
36
|
+
at its own place or in its `alsoAt`, settles them: skip them with cause
|
|
37
|
+
`existing-thread`, and do not write the comment again at another place. The
|
|
38
|
+
runtime puts no second comment on lines that carry a different comment of
|
|
39
|
+
AZPR's: when the place you would choose has such a thread, anchor the comment
|
|
40
|
+
at another of its places, or leave that finding out of it. Findings that only
|
|
41
|
+
resemble each other, that follow from one another, or whose places need
|
|
42
|
+
different corrections keep their own comments; when unsure, comment on each
|
|
43
|
+
finding separately. A combined comment accounts for every finding it names;
|
|
44
|
+
never combine findings outside a listed group.
|
|
45
|
+
|
|
25
46
|
The runtime already read what this page normally needs, so most pages need no
|
|
26
47
|
tool call at all:
|
|
27
48
|
|
|
@@ -33,7 +54,9 @@ tool call at all:
|
|
|
33
54
|
and `allDispositions` holding the complete lists.
|
|
34
55
|
- `existingDiscussions` (when `discussionsRead` is true): every live thread on
|
|
35
56
|
the PR with its path, line, author and the start of its first comment.
|
|
36
|
-
Deleted threads are already excluded.
|
|
57
|
+
Deleted threads are already excluded. A thread whose comment lists further
|
|
58
|
+
places of the same defect names them in `alsoAt`: those places are discussed
|
|
59
|
+
there too.
|
|
37
60
|
|
|
38
61
|
Read more only when these do not answer a question: azpr_read_file at version
|
|
39
62
|
"head" for lines outside an excerpt, azpr_pr_threads when you need a full
|
|
@@ -59,7 +82,7 @@ priority if useful. No finding recap, counts, run IDs or SHAs.
|
|
|
59
82
|
<!-- azpr:verified -->
|
|
60
83
|
content, for example `### Additional finding details` (confirmed findings
|
|
61
84
|
without an inline comment, including low severity) and
|
|
62
|
-
<!-- azpr:
|
|
85
|
+
<!-- azpr:reviewers -->
|
|
63
86
|
content, for example `### Additional finding details` (findings without an
|
|
64
87
|
inline comment, including low severity) and
|
|
65
88
|
<!-- azpr:end -->
|
|
@@ -98,6 +121,26 @@ Every `skipped` entry names its `cause`, one of:
|
|
|
98
121
|
severity, the location, the thread, the lines in `sourceExcerpts`) and asks you
|
|
99
122
|
to correct a skip whose cause does not hold.
|
|
100
123
|
|
|
124
|
+
## Grouping pass
|
|
125
|
+
|
|
126
|
+
When `commentWork.kind` is `"group"`, the work is not a page: write no comments
|
|
127
|
+
and no skips. `findings` then holds the review's high and medium findings (ID,
|
|
128
|
+
severity, location, summary, suggestion, and the evidence unless the list is
|
|
129
|
+
long). Say which of them are one mistake made at several places, as described
|
|
130
|
+
above: the same defect, and one instruction corrects every place. A group has
|
|
131
|
+
two or more findings of one severity at different places; a finding belongs to
|
|
132
|
+
one group at most, and most findings belong to none. No tool call is needed,
|
|
133
|
+
and the pass has one answer, without a continuation. Return only:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{"status": "READY", "groups": [{"findingIds": ["F-2", "F-5"], "reason": "The shared mistake and the one correction, in a sentence."}]}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Use `"groups": []` when nothing repeats. The pages decide afterwards whether a
|
|
140
|
+
group gets one comment.
|
|
141
|
+
|
|
142
|
+
## Longer pages
|
|
143
|
+
|
|
101
144
|
When this page needs more reading than fits, return `"status": "CONTINUE"` with
|
|
102
145
|
the comments and skips you finished plus `"continuation"`: exact data
|
|
103
146
|
references, the checks already done and what remains. A fresh session continues
|
|
@@ -13,10 +13,10 @@ revive rejected claims, inflate severity or add new findings.
|
|
|
13
13
|
|
|
14
14
|
One general PR summary plus inline comments for confirmed high and medium
|
|
15
15
|
findings:
|
|
16
|
-
<!-- azpr:
|
|
17
|
-
The supplied findings come from
|
|
18
|
-
|
|
19
|
-
this review's final findings and authoritative for trigger, impact, location,
|
|
16
|
+
<!-- azpr:reviewers -->
|
|
17
|
+
The supplied findings come from this review's reviewers: each checked its own
|
|
18
|
+
findings against the source, and no separate verification re-checked them. They
|
|
19
|
+
are this review's final findings and authoritative for trigger, impact, location,
|
|
20
20
|
severity and qualifications. Do not judge them again, revive dispositions that
|
|
21
21
|
are not findings, inflate severity or add new findings. A finding with
|
|
22
22
|
`"inline": false` has no location that can carry an inline comment: put it in
|
|
@@ -26,6 +26,8 @@ One general PR summary plus inline comments for high and medium findings:
|
|
|
26
26
|
<!-- azpr:end -->
|
|
27
27
|
- Each inline comment discusses one root cause on a changed HEAD file, with the
|
|
28
28
|
smallest useful RIGHT-side line range.
|
|
29
|
+
- One mistake made at several places gets one comment at one of them; the
|
|
30
|
+
runtime lists the other places under it.
|
|
29
31
|
- Low-severity findings are not inline; they appear in the summary index.
|
|
30
32
|
- Skip a finding (with a local reason) when it cannot be anchored reliably, its
|
|
31
33
|
claim cannot be stated faithfully within the length limit, or an existing
|
package/src/prompts/common.md
CHANGED
|
@@ -68,17 +68,11 @@ is its own finding; a wrong pattern is one finding at the code that produces
|
|
|
68
68
|
or consumes it, not one per file. Large PRs are split across sessions and every
|
|
69
69
|
changed file has its own reviewer. Follow your assigned files' leads wherever
|
|
70
70
|
they go: a defect you reach in unchanged code is yours to file, since nobody
|
|
71
|
-
<!-- azpr:verified -->
|
|
72
|
-
else reviews it; other changed files are context only, their own sessions
|
|
73
|
-
review them. If you cannot read something you need, say what is missing
|
|
74
|
-
instead of guessing.
|
|
75
|
-
<!-- azpr:quick -->
|
|
76
71
|
else reviews it. When your files lead you to a defect in another changed file,
|
|
77
72
|
file it at that file's defective lines, never at a line of your own files that
|
|
78
|
-
only uses the code; its own reviewer may report it too, and
|
|
79
|
-
|
|
73
|
+
only uses the code; its own reviewer may report it too, and a duplicate check
|
|
74
|
+
merges such repeats. If you cannot read something you need, say what is
|
|
80
75
|
missing instead of guessing.
|
|
81
|
-
<!-- azpr:end -->
|
|
82
76
|
|
|
83
77
|
## Finding quality
|
|
84
78
|
|
|
@@ -116,13 +110,8 @@ file in several directories) are one finding at one copy, with the other copies
|
|
|
116
110
|
listed in evidence. Copies assigned to other sessions are reviewed there; files
|
|
117
111
|
whose content differs, such as each package's own manifest or configuration,
|
|
118
112
|
are separate places.
|
|
119
|
-
<!-- azpr:verified -->
|
|
120
|
-
Only `findings` are verified and can become comments; a defect described only
|
|
121
|
-
in `report` is lost. There is no maximum: do not sample, keep "the main ones" or
|
|
122
|
-
<!-- azpr:quick -->
|
|
123
113
|
Only `findings` can become comments; a defect described only in `report` is
|
|
124
114
|
lost. There is no maximum: do not sample, keep "the main ones" or
|
|
125
|
-
<!-- azpr:end -->
|
|
126
115
|
summarize the rest in prose; a plain defect needs one sentence per field.
|
|
127
116
|
|
|
128
117
|
Give each field one job:
|
package/src/prompts/dedupe.md
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
# Role: duplicate check
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`assignment.file`,
|
|
6
|
-
|
|
7
|
-
(`
|
|
8
|
-
|
|
3
|
+
Several reviewer sessions reviewed the same files independently, without
|
|
4
|
+
seeing each other's work. The findings in `assignment.findings` are all located
|
|
5
|
+
in one file, `assignment.file`, on one side of the change (`assignment.side`:
|
|
6
|
+
`head` is the pull request's code, `base` the code before it), and different
|
|
7
|
+
sessions reported them (`session`). No session has compared them with each
|
|
8
|
+
other yet.
|
|
9
9
|
|
|
10
10
|
Decide which of them are duplicates. Two findings are duplicates only when they
|
|
11
11
|
state the same root cause and need the same correction. Findings that need
|
|
12
12
|
different corrections stay separate, even on the same lines or when one is a
|
|
13
|
-
consequence of the other.
|
|
14
|
-
|
|
13
|
+
consequence of the other. The same kind of mistake made at several places,
|
|
14
|
+
each needing its own change, is several findings, however alike their texts
|
|
15
|
+
are. Compare the claims themselves; read the source with azpr_read_file at
|
|
16
|
+
that side's commit (`snapshot.head`, or `snapshot.base` for the base side) when
|
|
17
|
+
they alone do not settle it.
|
|
18
|
+
|
|
19
|
+
Merge only findings of different sessions (`session`): two findings that one
|
|
20
|
+
session reported are that reviewer's two findings, and the runtime refuses a
|
|
21
|
+
merge that would bring them together, also through a third finding.
|
|
15
22
|
|
|
16
23
|
Merge each duplicate into the finding that states the defect most completely:
|
|
17
24
|
`mergedInto` names another ID from `assignment.findingIds` that you do not
|
|
18
|
-
merge. You only merge: findings stay as
|
|
19
|
-
finding you do not merge stays
|
|
25
|
+
merge. You only merge: findings stay as their reviewer wrote them, and every
|
|
26
|
+
finding you do not merge stays reported. A merged finding's own text is dropped,
|
|
27
|
+
so merge only a finding whose defect the kept one states.
|
|
20
28
|
|
|
21
29
|
Return:
|
|
22
30
|
```json
|
|
23
|
-
{"status":"COMPLETE","merged":[{"id":"
|
|
31
|
+
{"status":"COMPLETE","merged":[{"id":"F-12","mergedInto":"F-3","reason":"Same root cause and correction"}],"report":"Optional note"}
|
|
24
32
|
```
|
|
25
33
|
|
|
26
34
|
Use `"merged": []` when none of them are duplicates.
|
package/src/prompts/rating.md
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
You work in a private review session started by an explicit command. Your input
|
|
4
4
|
is the findings of one pull-request review, and you have no tools.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
without a severity. Rate each finding with the Severity rules below, from
|
|
9
|
-
own text alone: `summary`, `evidence` (what the review read in the code; HEAD is
|
|
6
|
+
Each finding in `assignment.findings` was checked against the source by the
|
|
7
|
+
reviewer that reported it; treat each one as factually correct as written. They
|
|
8
|
+
arrive without a severity. Rate each finding with the Severity rules below, from
|
|
9
|
+
its own text alone: `summary`, `evidence` (what the review read in the code; HEAD is
|
|
10
10
|
the pull request's code, BASE the code before it), `counterevidence` (the
|
|
11
11
|
safeguards it checked and why they do not refute the finding) and `suggestion`.
|
|
12
12
|
`change` gives the pull request's title and description, the author's account
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# Role:
|
|
1
|
+
# Role: reviewer
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Independently review the files in `assignment.files`: you receive no other
|
|
4
|
+
reviewer's work, and no verifier checks your findings afterwards; they go to
|
|
5
5
|
the report and to comment planning as you write them. Review the files at
|
|
6
6
|
`snapshot.head` against `snapshot.base` with two focuses:
|
|
7
7
|
- functional correctness: requirements, boundary inputs, state transitions, API
|
|
@@ -11,6 +11,19 @@ the report and to comment planning as you write them. Review the files at
|
|
|
11
11
|
authorization and data consistency.
|
|
12
12
|
The focuses order your attention; they do not limit what you report.
|
|
13
13
|
|
|
14
|
+
Check how the change fits the surrounding system: responsibilities, dependency
|
|
15
|
+
direction, data ownership, public interfaces and invariants. For changed types
|
|
16
|
+
or data models, check construction, deserialization and mutation boundaries:
|
|
17
|
+
can invalid states enter, related fields diverge, or exposed mutable references
|
|
18
|
+
bypass an invariant? Check affected comments and docs against signatures, return
|
|
19
|
+
values, side effects and errors.
|
|
20
|
+
|
|
21
|
+
Follow control and data paths across trust and failure boundaries. Trace how a
|
|
22
|
+
failure reaches its caller or user: does an exception become an apparent
|
|
23
|
+
success, an empty result or an unjustified fallback, and can the caller tell and
|
|
24
|
+
recover? Check documented failure guarantees against the actual cleanup and
|
|
25
|
+
recovery paths.
|
|
26
|
+
|
|
14
27
|
## Check each finding yourself
|
|
15
28
|
|
|
16
29
|
Before you answer, check every finding against source you read in this session
|
|
@@ -44,15 +57,15 @@ that fails.
|
|
|
44
57
|
`assignment.discoverFiles` is true, Azure listed only part of the changed files:
|
|
45
58
|
find other changed paths you need and list them in `additionalFiles`.
|
|
46
59
|
|
|
47
|
-
Number findings consecutively from `assignment.firstFindingId` (
|
|
48
|
-
|
|
60
|
+
Number findings consecutively from `assignment.firstFindingId` (F-1, F-2, …);
|
|
61
|
+
an empty array is valid. Use status COMPLETE when you reviewed every
|
|
49
62
|
assigned file and filed every defect you found; otherwise PARTIAL with concrete
|
|
50
63
|
`coverage.gaps`. `coverage.files` lists the assigned paths you actually
|
|
51
64
|
reviewed; zero findings never hide unfinished work.
|
|
52
65
|
|
|
53
66
|
Return:
|
|
54
67
|
```json
|
|
55
|
-
{"status":"COMPLETE","coverage":{"files":["/src/example.ts"],"gaps":[]},"additionalFiles":[],"findings":[{"id":"
|
|
68
|
+
{"status":"COMPLETE","coverage":{"files":["/src/example.ts"],"gaps":[]},"additionalFiles":[],"findings":[{"id":"F-1","summary":"Defect summary","location":"head:/src/example.ts:12","evidence":"HEAD/BASE pair you read, reachable trigger and impact","counterevidence":"Safeguards you checked and why they do not refute it","severity":"medium","suggestion":"Correction and a focused regression case"}],"report":"What you checked, important exclusions with evidence, improvement advice, open questions and limitations"}
|
|
56
69
|
```
|
|
57
70
|
|
|
58
71
|
Keep `report` for what you checked, exclusions, advice, open questions and
|