@fullstackhouse/cerber 1.4.1 → 1.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/README.md +7 -8
- package/dist/core/artifact.js +5 -0
- package/dist/core/refresh.js +25 -4
- package/dist/core/revise.js +3 -0
- package/dist/runner/review.js +11 -7
- package/dist/server/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -437,14 +437,13 @@ The AI's summary and verdict still describe the commit that was reviewed. To
|
|
|
437
437
|
get its opinion of the new code, hit **Re-review at the new head** in the
|
|
438
438
|
cockpit (or `cerber review <pr> --force`).
|
|
439
439
|
|
|
440
|
-
>
|
|
441
|
-
> rewrote,
|
|
442
|
-
>
|
|
443
|
-
>
|
|
444
|
-
>
|
|
445
|
-
>
|
|
446
|
-
>
|
|
447
|
-
> what went to GitHub (see the next section).
|
|
440
|
+
> **A re-review replaces the AI's draft and keeps your comments.** The ones you
|
|
441
|
+
> wrote, rewrote, or had the chat add or rewrite move onto the new head by
|
|
442
|
+
> their line's text; one whose code is gone posts in the body instead
|
|
443
|
+
> ([`docs/lifecycle.md`](docs/lifecycle.md)). A send body you wrote yourself
|
|
444
|
+
> does not survive — it described the old draft. Your *decisions* survive too:
|
|
445
|
+
> a `reviewed` or `skipped` you set and the chat transcript are kept, and a send
|
|
446
|
+
> is kept as a record of what went to GitHub (see the next section).
|
|
448
447
|
|
|
449
448
|
### Re-reviewing one you already sent
|
|
450
449
|
|
package/dist/core/artifact.js
CHANGED
|
@@ -90,6 +90,11 @@ export const CommentSchema = z.object({
|
|
|
90
90
|
drifted: z.boolean().default(false),
|
|
91
91
|
/** Somebody else already raised this on the PR. AI comments only. */
|
|
92
92
|
alreadyRaised: AlreadyRaisedSchema.nullable().default(null),
|
|
93
|
+
/**
|
|
94
|
+
* Added or rewritten through the chat. That was the user's call, not the
|
|
95
|
+
* run's, so a re-review carries it over like their own (`carryYours`).
|
|
96
|
+
*/
|
|
97
|
+
fromChat: z.boolean().default(false),
|
|
93
98
|
});
|
|
94
99
|
/**
|
|
95
100
|
* The last comparison of the draft against what others already said on the PR.
|
package/dist/core/refresh.js
CHANGED
|
@@ -33,6 +33,26 @@ export function refreshArtifact(artifact, pr, diff) {
|
|
|
33
33
|
results,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* A comment that is the user's call rather than the run's: one they wrote, one
|
|
38
|
+
* they rewrote, or one they had the chat add or rewrite.
|
|
39
|
+
*/
|
|
40
|
+
export function isYours(c) {
|
|
41
|
+
return c.origin === "user" || c.editedByUser || c.fromChat;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The user's comments, pulled from the diff they were written on onto the one a
|
|
45
|
+
* re-review is reading.
|
|
46
|
+
*
|
|
47
|
+
* A re-review replaces the AI's findings, not the user's. A push from the
|
|
48
|
+
* author is no reason to lose a comment they wrote or a finding they argued
|
|
49
|
+
* into shape in the chat — and the old conversation would go on naming it
|
|
50
|
+
* as though it were still there. Anchored by line text like a refresh; one
|
|
51
|
+
* whose code is gone is marked drifted and posts in the body.
|
|
52
|
+
*/
|
|
53
|
+
export function carryYours(comments, fromDiff, toDiff) {
|
|
54
|
+
return reanchorComments(comments.filter(isYours), fromDiff, toDiff).comments;
|
|
55
|
+
}
|
|
36
56
|
/**
|
|
37
57
|
* Is this artifact's status the user's to keep, rather than the run's to set?
|
|
38
58
|
*
|
|
@@ -66,10 +86,8 @@ export function supersede(a) {
|
|
|
66
86
|
* `mergeConcurrentEdits` exists to stop a chat turn making.
|
|
67
87
|
*
|
|
68
88
|
* `fresh` is what the run produced; `current` is what is on disk now. The run
|
|
69
|
-
* owns the draft — summary, chapters, verdict, comments
|
|
70
|
-
*
|
|
71
|
-
* `docs/lifecycle.md` says so plainly rather than leaving anyone to count on
|
|
72
|
-
* work surviving one. What it does *not* own are the decisions:
|
|
89
|
+
* owns the draft — summary, chapters, verdict, the AI's comments. What it does
|
|
90
|
+
* *not* own are the decisions:
|
|
73
91
|
*
|
|
74
92
|
* - **a send** stands, and takes the status with it. Without this a run
|
|
75
93
|
* finishing after a send wrote `sent: null` back over the record, and the
|
|
@@ -79,10 +97,13 @@ export function supersede(a) {
|
|
|
79
97
|
* The fresh draft still lands underneath, which is what the row shows if
|
|
80
98
|
* the user changes their mind.
|
|
81
99
|
* - **the conversation** is the user's writing, snapshot and all.
|
|
100
|
+
* - **the user's comments** (`carryYours`), read from disk so one written
|
|
101
|
+
* while the run worked is kept too, and put ahead of the run's own.
|
|
82
102
|
*/
|
|
83
103
|
export function mergeRunResult(fresh, current) {
|
|
84
104
|
return {
|
|
85
105
|
...fresh,
|
|
106
|
+
comments: [...carryYours(current.comments, current.diff, fresh.diff), ...fresh.comments],
|
|
86
107
|
status: userOwnsStatus(current) ? current.status : fresh.status,
|
|
87
108
|
// Travels with the status it dates. A settle that landed while the run
|
|
88
109
|
// worked keeps both halves of itself, and a run that reopens the row takes
|
package/dist/core/revise.js
CHANGED
|
@@ -152,6 +152,8 @@ export function applyRevisions(artifact, revisions, opts = {}) {
|
|
|
152
152
|
...rewriteFinding(c, revision.body),
|
|
153
153
|
// Omitted = the turn is not re-grading; null = "not a finding".
|
|
154
154
|
severity: revision.severity === undefined ? c.severity : revision.severity,
|
|
155
|
+
// The user's call now, so a re-review keeps it.
|
|
156
|
+
fromChat: true,
|
|
155
157
|
}
|
|
156
158
|
: c),
|
|
157
159
|
};
|
|
@@ -194,6 +196,7 @@ export function applyRevisions(artifact, revisions, opts = {}) {
|
|
|
194
196
|
originalLine: null,
|
|
195
197
|
drifted: false,
|
|
196
198
|
alreadyRaised: null,
|
|
199
|
+
fromChat: true,
|
|
197
200
|
},
|
|
198
201
|
],
|
|
199
202
|
};
|
package/dist/runner/review.js
CHANGED
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { AiReviewSchema, SCHEMA_VERSION, artifactId, artifactKey, } from "../core/artifact.js";
|
|
3
3
|
import { createRunDir, evictOldCheckouts, prepareCheckout, removeRunDir } from "../core/checkout.js";
|
|
4
4
|
import { fetchPrDiff, fetchPrInfo, isOrgMember, isTeamMember } from "../core/gh.js";
|
|
5
|
-
import { mergeRunResult, supersede, userOwnsStatus } from "../core/refresh.js";
|
|
5
|
+
import { carryYours, isYours, mergeRunResult, supersede, userOwnsStatus } from "../core/refresh.js";
|
|
6
6
|
import { loadArtifact, noteHistory, saveArtifact, updateArtifactByKey } from "../core/state.js";
|
|
7
7
|
import { withWriter } from "../core/history.js";
|
|
8
8
|
import { loadConfig } from "../core/config.js";
|
|
@@ -146,13 +146,14 @@ async function performReview(ref, pr, existing, opts, log) {
|
|
|
146
146
|
`reviewing from the diff alone.`);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
// A re-review regenerates the draft, comments
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
// when the run starts, whichever way it ends. `docs/lifecycle.md` says so
|
|
153
|
-
// where a reader would otherwise assume otherwise.
|
|
149
|
+
// A re-review regenerates the AI's draft, comments included. The user's own
|
|
150
|
+
// comments — written, rewritten, or added through the chat — are carried
|
|
151
|
+
// over at the claim below (`carryYours`), whichever way the run ends.
|
|
154
152
|
if (existing && existing.comments.length > 0) {
|
|
155
|
-
|
|
153
|
+
const yours = existing.comments.filter(isYours).length;
|
|
154
|
+
const theirs = existing.comments.length - yours;
|
|
155
|
+
log(`Replacing the previous draft's ${theirs} AI comment(s)` +
|
|
156
|
+
(yours > 0 ? `, keeping your ${yours}.` : "."));
|
|
156
157
|
}
|
|
157
158
|
let artifact = {
|
|
158
159
|
schemaVersion: SCHEMA_VERSION,
|
|
@@ -242,6 +243,8 @@ async function performReview(ref, pr, existing, opts, log) {
|
|
|
242
243
|
...artifact,
|
|
243
244
|
notified: current.notified,
|
|
244
245
|
viewed: current.viewed,
|
|
246
|
+
// Yours stay through the run, its failure included; the AI's go.
|
|
247
|
+
comments: carryYours(current.comments, current.diff, artifact.diff),
|
|
245
248
|
priorSends: supersede(current),
|
|
246
249
|
calibration: current.calibration,
|
|
247
250
|
});
|
|
@@ -287,6 +290,7 @@ async function performReview(ref, pr, existing, opts, log) {
|
|
|
287
290
|
originalLine: null,
|
|
288
291
|
drifted: false,
|
|
289
292
|
alreadyRaised: null,
|
|
293
|
+
fromChat: false,
|
|
290
294
|
})),
|
|
291
295
|
verdict: review.ai.verdict,
|
|
292
296
|
run: {
|
package/dist/server/index.js
CHANGED
package/package.json
CHANGED