co-maintainer 0.4.7 → 0.4.8
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/dist/package.json +1 -1
- package/dist/src/cli/args.js +5 -1
- package/dist/src/config.d.ts +1 -0
- package/dist/src/github/collect.js +52 -18
- package/dist/src/knowledge/types.d.ts +3 -0
- package/dist/src/services/remote_review.js +1 -0
- package/dist/src/services/review.js +1 -0
- package/dist/src/services/setup.js +2 -0
- package/dist/src/types.d.ts +3 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/src/cli/args.js
CHANGED
|
@@ -52,6 +52,7 @@ export async function parseArgs(args) {
|
|
|
52
52
|
console.log("Options: --include-codebase --include-pull-requests --include-pull-request-changes");
|
|
53
53
|
console.log(" --include-commit-history --include-how-repo-works");
|
|
54
54
|
console.log(" --max-commits=N --max-pr-months=N --max-pull-request-change-lines=N --max-comment=N");
|
|
55
|
+
console.log(" --only-request-changed-pr");
|
|
55
56
|
console.log(" --auth=gh|pat --github-pat=... --ai=none|openrouter|hetzner --token=... --low-model=... --high-model=...");
|
|
56
57
|
process.exit(0);
|
|
57
58
|
}
|
|
@@ -145,7 +146,8 @@ export async function parseArgs(args) {
|
|
|
145
146
|
if (arg === "--debug" ||
|
|
146
147
|
arg === "--log-time" ||
|
|
147
148
|
arg === "--review-upstream" ||
|
|
148
|
-
arg === "--disable-codegraph"
|
|
149
|
+
arg === "--disable-codegraph" ||
|
|
150
|
+
arg === "--only-request-changed-pr")
|
|
149
151
|
continue;
|
|
150
152
|
if (arg.startsWith("--") && !known)
|
|
151
153
|
die(`Unknown option: ${arg}`);
|
|
@@ -241,6 +243,8 @@ export async function parseArgs(args) {
|
|
|
241
243
|
includePullRequestChanges: enabled("include-pull-request-changes"),
|
|
242
244
|
includeCommitHistory: enabled("include-commit-history"),
|
|
243
245
|
includeHowRepoWorks: enabled("include-how-repo-works"),
|
|
246
|
+
onlyRequestChangedPr: rest.includes("--only-request-changed-pr") ||
|
|
247
|
+
repoConfig.onlyRequestChangedPr === true,
|
|
244
248
|
maxCommits: value("max-commits") ?? repoConfig.maxCommits ?? configDefault.maxCommits,
|
|
245
249
|
maxPrMonths: value("max-pr-months") ??
|
|
246
250
|
repoConfig.maxPrMonths ??
|
package/dist/src/config.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type RepoConfig = {
|
|
|
17
17
|
includePullRequestChanges?: boolean;
|
|
18
18
|
includeCommitHistory?: boolean;
|
|
19
19
|
includeHowRepoWorks?: boolean;
|
|
20
|
+
onlyRequestChangedPr?: boolean;
|
|
20
21
|
/** Five field cron in UTC, checked by `serve` to queue a remake. */
|
|
21
22
|
remakeCron?: string;
|
|
22
23
|
};
|
|
@@ -10,6 +10,12 @@ function percent(done, total) {
|
|
|
10
10
|
return "0%";
|
|
11
11
|
return `${Math.round((done / total) * 100)}%`;
|
|
12
12
|
}
|
|
13
|
+
function changesRequested(reviews) {
|
|
14
|
+
return reviews.some((review) => review.state === "CHANGES_REQUESTED");
|
|
15
|
+
}
|
|
16
|
+
function reviewBodies(reviews) {
|
|
17
|
+
return reviews.map((review) => String(review.body ?? "")).filter(Boolean);
|
|
18
|
+
}
|
|
13
19
|
function withinPrWindow(updatedAt, months) {
|
|
14
20
|
if (months === undefined || months === 0)
|
|
15
21
|
return true;
|
|
@@ -258,13 +264,44 @@ async function pullRequests(client, options, previous, phase, progress) {
|
|
|
258
264
|
changedFiles: cached?.changedFiles ?? [],
|
|
259
265
|
diff: cached?.diff ?? "",
|
|
260
266
|
};
|
|
267
|
+
if (typeof cached?.changesRequested === "boolean") {
|
|
268
|
+
current.changesRequested = cached.changesRequested;
|
|
269
|
+
}
|
|
270
|
+
const only = options.onlyRequestChangedPr;
|
|
261
271
|
const discussionUnchanged = cached?.updatedAt === current.updatedAt;
|
|
272
|
+
const decisionKnown = typeof cached?.changesRequested === "boolean";
|
|
262
273
|
const diffUnchanged = cached?.headSha === current.headSha && Boolean(cached?.diff);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
274
|
+
let dropped = only && discussionUnchanged && cached?.changesRequested === false;
|
|
275
|
+
const loadComments = async () => {
|
|
276
|
+
const comments = await client.pages(`repos/${options.repo}/issues/${number}/comments`);
|
|
277
|
+
current.comments = comments
|
|
278
|
+
.map((comment) => String(comment.body ?? ""))
|
|
279
|
+
.filter(Boolean)
|
|
280
|
+
.slice(0, options.maxComments);
|
|
281
|
+
};
|
|
282
|
+
const loadReviews = async () => {
|
|
283
|
+
const reviews = await client.pages(`repos/${options.repo}/pulls/${number}/reviews`);
|
|
284
|
+
current.reviews = reviewBodies(reviews);
|
|
285
|
+
current.changesRequested = changesRequested(reviews);
|
|
286
|
+
};
|
|
287
|
+
if (!dropped && only && (!discussionUnchanged || !decisionKnown)) {
|
|
288
|
+
await loadReviews();
|
|
289
|
+
if (!current.changesRequested)
|
|
290
|
+
dropped = true;
|
|
291
|
+
else if (!discussionUnchanged)
|
|
292
|
+
await loadComments();
|
|
293
|
+
}
|
|
294
|
+
else if (!dropped && !discussionUnchanged) {
|
|
295
|
+
await loadComments();
|
|
296
|
+
await loadReviews();
|
|
297
|
+
}
|
|
298
|
+
const discussionStatus = dropped
|
|
299
|
+
? "dropped"
|
|
300
|
+
: discussionUnchanged
|
|
301
|
+
? "comments/reviews cache"
|
|
302
|
+
: "download comments/reviews";
|
|
266
303
|
let diffStatus = "diff disabled";
|
|
267
|
-
if (options.includePullRequestChanges) {
|
|
304
|
+
if (!dropped && options.includePullRequestChanges) {
|
|
268
305
|
const lines = current.additions + current.deletions;
|
|
269
306
|
diffStatus = diffUnchanged
|
|
270
307
|
? "diff cache"
|
|
@@ -278,18 +315,10 @@ async function pullRequests(client, options, previous, phase, progress) {
|
|
|
278
315
|
if (phase) {
|
|
279
316
|
phase.text = `PR #${number} · ${discussionStatus} · ${diffStatus} · ${completed}/${selected.length} · ${percent(completed, selected.length)}`;
|
|
280
317
|
}
|
|
281
|
-
if (!
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
.map((comment) => String(comment.body ?? ""))
|
|
286
|
-
.filter(Boolean)
|
|
287
|
-
.slice(0, options.maxComments);
|
|
288
|
-
current.reviews = reviews
|
|
289
|
-
.map((review) => String(review.body ?? ""))
|
|
290
|
-
.filter(Boolean);
|
|
291
|
-
}
|
|
292
|
-
if (options.includePullRequestChanges && !diffUnchanged && detail) {
|
|
318
|
+
if (!dropped &&
|
|
319
|
+
options.includePullRequestChanges &&
|
|
320
|
+
!diffUnchanged &&
|
|
321
|
+
detail) {
|
|
293
322
|
const lines = current.additions + current.deletions;
|
|
294
323
|
if (options.maxPullRequestChangeLines === undefined ||
|
|
295
324
|
lines <= options.maxPullRequestChangeLines) {
|
|
@@ -311,7 +340,8 @@ async function pullRequests(client, options, previous, phase, progress) {
|
|
|
311
340
|
current.diff = "";
|
|
312
341
|
}
|
|
313
342
|
}
|
|
314
|
-
|
|
343
|
+
if (!dropped)
|
|
344
|
+
result[index] = current;
|
|
315
345
|
completed++;
|
|
316
346
|
if (phase) {
|
|
317
347
|
phase.text = `pull requests ${completed}/${selected.length} · ${percent(completed, selected.length)}`;
|
|
@@ -322,7 +352,11 @@ async function pullRequests(client, options, previous, phase, progress) {
|
|
|
322
352
|
await save;
|
|
323
353
|
}
|
|
324
354
|
});
|
|
325
|
-
|
|
355
|
+
const kept = result.filter((item) => !!item);
|
|
356
|
+
if (options.onlyRequestChangedPr) {
|
|
357
|
+
log("fetch", `only request-changed pr · kept ${kept.length} · dropped ${selected.length - kept.length}`);
|
|
358
|
+
}
|
|
359
|
+
return kept;
|
|
326
360
|
}
|
|
327
361
|
async function commits(client, options, meta, phase) {
|
|
328
362
|
const branch = String(meta.default_branch ?? "main");
|
|
@@ -12,6 +12,9 @@ export type PullRequest = {
|
|
|
12
12
|
deletions: number;
|
|
13
13
|
comments: string[];
|
|
14
14
|
reviews: string[];
|
|
15
|
+
/** Set once reviews have been read. Missing means an older checkpoint
|
|
16
|
+
* never stored the review state. */
|
|
17
|
+
changesRequested?: boolean;
|
|
15
18
|
changedFiles: string[];
|
|
16
19
|
diff: string;
|
|
17
20
|
};
|
|
@@ -259,6 +259,7 @@ export async function runInitOrRemake(options) {
|
|
|
259
259
|
includePullRequestChanges: options.includePullRequestChanges,
|
|
260
260
|
includeCommitHistory: options.includeCommitHistory,
|
|
261
261
|
includeHowRepoWorks: options.includeHowRepoWorks,
|
|
262
|
+
onlyRequestChangedPr: options.onlyRequestChangedPr,
|
|
262
263
|
});
|
|
263
264
|
});
|
|
264
265
|
log("write", `${path} · ${result.changed.length
|
|
@@ -306,6 +307,7 @@ export function optionsFromConfig(repo, command) {
|
|
|
306
307
|
includePullRequestChanges: repoConfig.includePullRequestChanges ?? true,
|
|
307
308
|
includeCommitHistory: repoConfig.includeCommitHistory ?? true,
|
|
308
309
|
includeHowRepoWorks: repoConfig.includeHowRepoWorks ?? true,
|
|
310
|
+
onlyRequestChangedPr: repoConfig.onlyRequestChangedPr === true,
|
|
309
311
|
maxCommits: repoConfig.maxCommits ?? config.defaults?.maxCommits,
|
|
310
312
|
maxPrMonths: repoConfig.maxPrMonths ?? config.defaults?.maxPrMonths,
|
|
311
313
|
maxPullRequestChangeLines: repoConfig.maxPullRequestChangeLines ??
|
package/dist/src/types.d.ts
CHANGED
|
@@ -34,6 +34,9 @@ export type Options = {
|
|
|
34
34
|
includePullRequestChanges: boolean;
|
|
35
35
|
includeCommitHistory: boolean;
|
|
36
36
|
includeHowRepoWorks: boolean;
|
|
37
|
+
/** Keep only pull requests in the window that have at least one
|
|
38
|
+
* `CHANGES_REQUESTED` review. Off by default, so the window is unchanged. */
|
|
39
|
+
onlyRequestChangedPr: boolean;
|
|
37
40
|
maxCommits?: number;
|
|
38
41
|
maxPrMonths?: number;
|
|
39
42
|
maxPullRequestChangeLines?: number;
|