@oss-autopilot/core 3.37.0 → 3.39.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/dist/cli-registry.js +7 -4
- package/dist/cli.bundle.cjs +134 -127
- package/dist/commands/comments.js +4 -3
- package/dist/commands/config.js +18 -11
- package/dist/commands/daily-dismiss-filter.d.ts +37 -0
- package/dist/commands/daily-dismiss-filter.js +80 -0
- package/dist/commands/daily-merged-pr-notes.d.ts +27 -0
- package/dist/commands/daily-merged-pr-notes.js +166 -0
- package/dist/commands/daily-reviewed-prs.d.ts +41 -0
- package/dist/commands/daily-reviewed-prs.js +270 -0
- package/dist/commands/daily-warnings.d.ts +28 -0
- package/dist/commands/daily-warnings.js +37 -0
- package/dist/commands/daily.d.ts +22 -1
- package/dist/commands/daily.js +299 -108
- package/dist/commands/dashboard-cache.js +9 -2
- package/dist/commands/dashboard-data.js +40 -20
- package/dist/commands/dashboard-gist-sync.d.ts +9 -1
- package/dist/commands/dashboard-gist-sync.js +24 -3
- package/dist/commands/dashboard-server.js +9 -5
- package/dist/commands/dismiss.d.ts +25 -5
- package/dist/commands/dismiss.js +40 -11
- package/dist/commands/guidelines.js +21 -14
- package/dist/commands/init.js +3 -2
- package/dist/commands/ledger-backfill.js +4 -3
- package/dist/commands/move.js +9 -6
- package/dist/commands/overnight-push-prep.js +5 -2
- package/dist/commands/overnight.js +62 -24
- package/dist/commands/scout-bridge.js +4 -1
- package/dist/commands/search.js +9 -6
- package/dist/commands/setup.js +7 -3
- package/dist/commands/validation.d.ts +11 -0
- package/dist/commands/validation.js +38 -0
- package/dist/core/checklist-analysis.js +34 -0
- package/dist/core/closed-pr-status.d.ts +73 -0
- package/dist/core/closed-pr-status.js +113 -0
- package/dist/core/comment-decision.d.ts +10 -3
- package/dist/core/comment-decision.js +13 -5
- package/dist/core/comment-utils.d.ts +38 -1
- package/dist/core/comment-utils.js +124 -1
- package/dist/core/concurrency.d.ts +6 -0
- package/dist/core/concurrency.js +13 -0
- package/dist/core/daily-logic.d.ts +13 -1
- package/dist/core/daily-logic.js +59 -2
- package/dist/core/engaged-issues.d.ts +93 -0
- package/dist/core/engaged-issues.js +183 -0
- package/dist/core/errors.d.ts +4 -0
- package/dist/core/errors.js +11 -1
- package/dist/core/eval-report.d.ts +9 -0
- package/dist/core/eval-report.js +4 -0
- package/dist/core/gist-state-store.d.ts +5 -2
- package/dist/core/gist-state-store.js +7 -4
- package/dist/core/github-stats.d.ts +10 -0
- package/dist/core/github-stats.js +35 -0
- package/dist/core/index.d.ts +10 -5
- package/dist/core/index.js +9 -4
- package/dist/core/issue-conversation.d.ts +83 -12
- package/dist/core/issue-conversation.js +306 -118
- package/dist/core/merged-pr-notes.d.ts +192 -0
- package/dist/core/merged-pr-notes.js +340 -0
- package/dist/core/pick-snapshot.js +1 -1
- package/dist/core/pr-assembly.js +3 -0
- package/dist/core/pr-monitor.d.ts +62 -0
- package/dist/core/pr-monitor.js +113 -3
- package/dist/core/reviewed-prs-fetch.d.ts +91 -0
- package/dist/core/reviewed-prs-fetch.js +271 -0
- package/dist/core/reviewed-prs.d.ts +244 -0
- package/dist/core/reviewed-prs.js +380 -0
- package/dist/core/state-persistence.js +8 -24
- package/dist/core/state-schema.d.ts +6 -0
- package/dist/core/state-schema.js +9 -0
- package/dist/core/state.d.ts +106 -11
- package/dist/core/state.js +246 -24
- package/dist/core/types.d.ts +47 -0
- package/dist/core/urls.d.ts +13 -0
- package/dist/core/urls.js +16 -0
- package/dist/formatters/json.d.ts +186 -1
- package/dist/formatters/json.js +78 -0
- package/package.json +1 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maintainer notes on recently merged PRs (#1861).
|
|
3
|
+
*
|
|
4
|
+
* The daily run stops looking at a PR once it merges, so a maintainer's
|
|
5
|
+
* thank-you or follow-up note posted at merge time never surfaced. This
|
|
6
|
+
* module decides, for one merged PR and its fetched activity, which notes
|
|
7
|
+
* still wait for a word from the user: comments, reviews and inline review
|
|
8
|
+
* comments from maintainers that landed after the user's last comment or
|
|
9
|
+
* commit and no earlier than an hour before the merge, plus commits someone
|
|
10
|
+
* else pushed on top of the user's last commit (the maintainer changed what
|
|
11
|
+
* shipped).
|
|
12
|
+
*
|
|
13
|
+
* Pure logic only. Fetching lives in `PRMonitor.fetchMergedPRActivity`;
|
|
14
|
+
* orchestration, the dismiss check and the warnings live in
|
|
15
|
+
* commands/daily-merged-pr-notes.ts.
|
|
16
|
+
*
|
|
17
|
+
* The <100-character acknowledgment filter in `isAcknowledgmentComment` is
|
|
18
|
+
* deliberately NOT applied here: it exists so a thanks never marks an open PR
|
|
19
|
+
* as needing work, and after merge a short thanks is exactly the note this
|
|
20
|
+
* path is for.
|
|
21
|
+
*/
|
|
22
|
+
import type { MergedPR } from './types.js';
|
|
23
|
+
/**
|
|
24
|
+
* How long before the merge a maintainer note still counts. A thanks typed
|
|
25
|
+
* just before clicking merge belongs to the merge; process chatter resolved
|
|
26
|
+
* earlier ("CI is failing", "needs a rebase") does not.
|
|
27
|
+
*/
|
|
28
|
+
export declare const MERGED_PR_NOTES_PRE_MERGE_GRACE_MS: number;
|
|
29
|
+
export type MergedPRNoteKind = 'comment' | 'review' | 'review_comment' | 'commit';
|
|
30
|
+
/** One maintainer note on a merged PR, as surfaced in the digest. */
|
|
31
|
+
export interface MergedPRNote {
|
|
32
|
+
author: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
kind: MergedPRNoteKind;
|
|
35
|
+
/** First 200 characters of the comment body or the commit subject line. */
|
|
36
|
+
excerpt: string;
|
|
37
|
+
}
|
|
38
|
+
/** A merged PR with at least one maintainer note the user has not answered. */
|
|
39
|
+
export interface MergedPRNotes {
|
|
40
|
+
prUrl: string;
|
|
41
|
+
repo: string;
|
|
42
|
+
number: number;
|
|
43
|
+
title: string;
|
|
44
|
+
mergedAt: string;
|
|
45
|
+
/** Oldest first. */
|
|
46
|
+
notes: MergedPRNote[];
|
|
47
|
+
/** Commits by someone other than the user pushed after the user's last commit. */
|
|
48
|
+
maintainerCommits: number;
|
|
49
|
+
/**
|
|
50
|
+
* Heuristic: every note reads as thanks or praise (keyword, no question,
|
|
51
|
+
* short, no change-related wording) and nobody pushed on top. The workflow
|
|
52
|
+
* confirms this with the comment-decision classification before acting on
|
|
53
|
+
* it; see {@link groupThanksOnlyAcknowledgments}.
|
|
54
|
+
*/
|
|
55
|
+
thanksOnly: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Set when another thanks-only merged PR in the same repo was merged more
|
|
58
|
+
* recently: one acknowledgment on that PR covers this one too, so the
|
|
59
|
+
* workflow should not draft a separate reply here.
|
|
60
|
+
*/
|
|
61
|
+
ackCoveredBy?: string;
|
|
62
|
+
}
|
|
63
|
+
type Actor = {
|
|
64
|
+
user?: {
|
|
65
|
+
login?: string;
|
|
66
|
+
type?: string | null;
|
|
67
|
+
} | null;
|
|
68
|
+
author_association?: string | null;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Everything on a merged PR the selection reads, in the shapes the Octokit
|
|
72
|
+
* list endpoints return (structural, so responses assign directly).
|
|
73
|
+
*/
|
|
74
|
+
export interface MergedPRActivity {
|
|
75
|
+
comments: Array<Actor & {
|
|
76
|
+
body?: string | null;
|
|
77
|
+
created_at: string;
|
|
78
|
+
}>;
|
|
79
|
+
reviews: Array<Actor & {
|
|
80
|
+
body?: string | null;
|
|
81
|
+
submitted_at?: string | null;
|
|
82
|
+
state?: string | null;
|
|
83
|
+
}>;
|
|
84
|
+
reviewComments: Array<Actor & {
|
|
85
|
+
body?: string | null;
|
|
86
|
+
created_at: string;
|
|
87
|
+
}>;
|
|
88
|
+
commits: Array<{
|
|
89
|
+
author?: {
|
|
90
|
+
login?: string;
|
|
91
|
+
type?: string | null;
|
|
92
|
+
} | null;
|
|
93
|
+
/** GitHub account that last rewrote the commit (`web-flow` for merges and rebases done on github.com). */
|
|
94
|
+
committer?: {
|
|
95
|
+
login?: string;
|
|
96
|
+
type?: string | null;
|
|
97
|
+
} | null;
|
|
98
|
+
commit: {
|
|
99
|
+
message?: string | null;
|
|
100
|
+
author?: {
|
|
101
|
+
date?: string | null;
|
|
102
|
+
} | null;
|
|
103
|
+
committer?: {
|
|
104
|
+
date?: string | null;
|
|
105
|
+
} | null;
|
|
106
|
+
};
|
|
107
|
+
/** More than one parent marks a merge commit ("Update branch"), which carries no new work. */
|
|
108
|
+
parents?: Array<{
|
|
109
|
+
sha?: string;
|
|
110
|
+
}>;
|
|
111
|
+
}>;
|
|
112
|
+
}
|
|
113
|
+
/** The four lists `PRMonitor.fetchMergedPRActivity` fetches, as named in truncation warnings. */
|
|
114
|
+
export type MergedPRActivityList = 'comments' | 'reviews' | 'review comments' | 'commits';
|
|
115
|
+
/**
|
|
116
|
+
* Whether a note is thanks or praise and nothing else. Conservative: a
|
|
117
|
+
* question mark, change-related wording, or a long body all disqualify it,
|
|
118
|
+
* so a "thanks, but I renamed the flag" never collapses into a bare ack.
|
|
119
|
+
*/
|
|
120
|
+
export declare function isThanksOnlyNote(body: string): boolean;
|
|
121
|
+
/** Everything the daily phase needs to know about one merged PR's thread. */
|
|
122
|
+
export interface MergedPRScan {
|
|
123
|
+
/** Notes still waiting for the user, or null when there are none. */
|
|
124
|
+
pending: MergedPRNotes | null;
|
|
125
|
+
/**
|
|
126
|
+
* The maintainer notes inside the merge window, answered or not, were all
|
|
127
|
+
* thanks and nobody pushed on top: this PR can carry the repo's single
|
|
128
|
+
* acknowledgment. False when there were no maintainer notes at all.
|
|
129
|
+
*/
|
|
130
|
+
thanksOnlyThread: boolean;
|
|
131
|
+
/** Timestamp of the user's latest comment, review or inline comment; -Infinity when none. */
|
|
132
|
+
lastUserCommentMs: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Scan one merged PR's activity. {@link MergedPRScan.pending} holds the
|
|
136
|
+
* notes that still wait for the user, following these rules:
|
|
137
|
+
*
|
|
138
|
+
* A comment, review (non-empty body) or inline review comment counts when:
|
|
139
|
+
* - it is maintainer engagement in the issue-comment sense of
|
|
140
|
+
* {@link isMaintainerEngagement} (never the user, never a bot; an OWNER /
|
|
141
|
+
* MEMBER / COLLABORATOR association when one is known, for reviews and
|
|
142
|
+
* inline comments too);
|
|
143
|
+
* - it was posted after the user's last comment, review, inline review
|
|
144
|
+
* comment AND last commit on the PR, so anything the user already answered
|
|
145
|
+
* in words or in code drops out;
|
|
146
|
+
* - it was posted no earlier than {@link MERGED_PR_NOTES_PRE_MERGE_GRACE_MS}
|
|
147
|
+
* before `mergedAt`.
|
|
148
|
+
*
|
|
149
|
+
* A commit counts when it is not a merge commit, its GitHub author is a
|
|
150
|
+
* non-bot account other than the user and its author date is after both the
|
|
151
|
+
* user's last commit and the user's last comment (see {@link scanCommits}
|
|
152
|
+
* for why a maintainer's rebase does not move the user's commits). Commits
|
|
153
|
+
* are not bound to the merge time: a maintainer who pushed on top the day
|
|
154
|
+
* before merging still changed what shipped.
|
|
155
|
+
*/
|
|
156
|
+
export declare function scanMergedPR(pr: MergedPR, activity: MergedPRActivity, username: string): MergedPRScan;
|
|
157
|
+
/**
|
|
158
|
+
* Collect the maintainer notes on one merged PR that still wait for the
|
|
159
|
+
* user, or null when there are none. See {@link scanMergedPR} for the rules.
|
|
160
|
+
*/
|
|
161
|
+
export declare function collectMergedPRNotes(pr: MergedPR, activity: MergedPRActivity, username: string): MergedPRNotes | null;
|
|
162
|
+
/** ISO timestamp of the newest note, for the dismiss comparison in the daily phase. */
|
|
163
|
+
export declare function latestNoteAt(entry: Pick<MergedPRNotes, 'notes'>): string;
|
|
164
|
+
/** A merged PR that could carry a repo's acknowledgment, with the user's last word on it. */
|
|
165
|
+
export interface CarrierReply {
|
|
166
|
+
prUrl: string;
|
|
167
|
+
repo: string;
|
|
168
|
+
mergedAt: string;
|
|
169
|
+
/** Timestamp of the user's latest comment or review on that PR; -Infinity when none. */
|
|
170
|
+
lastUserCommentMs: number;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Drop the thanks-only entries the user already acknowledged through the
|
|
174
|
+
* group's carrier: {@link groupThanksOnlyAcknowledgments} points older
|
|
175
|
+
* thanks-only PRs in a repo at the most recently merged one, and the
|
|
176
|
+
* workflow posts one acknowledgment there. On the next run that carrier has
|
|
177
|
+
* no pending note of its own, so without this step the covered PRs would
|
|
178
|
+
* come back as a new group. A thanks-only entry is covered when the user
|
|
179
|
+
* commented on a thanks-only PR in the same repo that merged after it, and
|
|
180
|
+
* that comment is newer than the entry's newest note. Substantive entries
|
|
181
|
+
* are never dropped here.
|
|
182
|
+
*/
|
|
183
|
+
export declare function omitAcknowledgedViaCarrier(entries: readonly MergedPRNotes[], carriers: readonly CarrierReply[]): MergedPRNotes[];
|
|
184
|
+
/**
|
|
185
|
+
* When several thanks-only merged PRs share a repo, mark all but the most
|
|
186
|
+
* recently merged one as covered by it (`ackCoveredBy`), so the user is
|
|
187
|
+
* offered one acknowledgment per repo instead of N near-identical comments.
|
|
188
|
+
* Entries with substantive notes are untouched. Returns a new array in the
|
|
189
|
+
* input order.
|
|
190
|
+
*/
|
|
191
|
+
export declare function groupThanksOnlyAcknowledgments(entries: readonly MergedPRNotes[]): MergedPRNotes[];
|
|
192
|
+
export {};
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maintainer notes on recently merged PRs (#1861).
|
|
3
|
+
*
|
|
4
|
+
* The daily run stops looking at a PR once it merges, so a maintainer's
|
|
5
|
+
* thank-you or follow-up note posted at merge time never surfaced. This
|
|
6
|
+
* module decides, for one merged PR and its fetched activity, which notes
|
|
7
|
+
* still wait for a word from the user: comments, reviews and inline review
|
|
8
|
+
* comments from maintainers that landed after the user's last comment or
|
|
9
|
+
* commit and no earlier than an hour before the merge, plus commits someone
|
|
10
|
+
* else pushed on top of the user's last commit (the maintainer changed what
|
|
11
|
+
* shipped).
|
|
12
|
+
*
|
|
13
|
+
* Pure logic only. Fetching lives in `PRMonitor.fetchMergedPRActivity`;
|
|
14
|
+
* orchestration, the dismiss check and the warnings live in
|
|
15
|
+
* commands/daily-merged-pr-notes.ts.
|
|
16
|
+
*
|
|
17
|
+
* The <100-character acknowledgment filter in `isAcknowledgmentComment` is
|
|
18
|
+
* deliberately NOT applied here: it exists so a thanks never marks an open PR
|
|
19
|
+
* as needing work, and after merge a short thanks is exactly the note this
|
|
20
|
+
* path is for.
|
|
21
|
+
*/
|
|
22
|
+
import { isBotAuthor } from './comment-utils.js';
|
|
23
|
+
import { isMaintainerEngagement } from './review-analysis.js';
|
|
24
|
+
import { debug } from './logger.js';
|
|
25
|
+
const MODULE = 'merged-pr-notes';
|
|
26
|
+
/**
|
|
27
|
+
* How long before the merge a maintainer note still counts. A thanks typed
|
|
28
|
+
* just before clicking merge belongs to the merge; process chatter resolved
|
|
29
|
+
* earlier ("CI is failing", "needs a rebase") does not.
|
|
30
|
+
*/
|
|
31
|
+
export const MERGED_PR_NOTES_PRE_MERGE_GRACE_MS = 60 * 60 * 1000;
|
|
32
|
+
/** Longest excerpt carried in the digest; matches `lastMaintainerComment`. */
|
|
33
|
+
const EXCERPT_LENGTH = 200;
|
|
34
|
+
const THANKS_PATTERN = /\b(?:thanks|thank you|thank u|thx|appreciate[ds]?|kudos|nice work|great work|good work|well done|great job|nice job|good job)\b/i;
|
|
35
|
+
/**
|
|
36
|
+
* Word stems that mean the note says more than thanks: something changed or
|
|
37
|
+
* is still to come. Each matches at a word start (`\b` + stem + `\w*`), so
|
|
38
|
+
* "fix" covers "fixed" / "fixes" but not "prefix".
|
|
39
|
+
*/
|
|
40
|
+
const CHANGE_STEMS = [
|
|
41
|
+
'chang',
|
|
42
|
+
'rework',
|
|
43
|
+
'moved',
|
|
44
|
+
'renam',
|
|
45
|
+
'push',
|
|
46
|
+
'commit',
|
|
47
|
+
'instead',
|
|
48
|
+
'replac',
|
|
49
|
+
'revert',
|
|
50
|
+
'follow[- ]?up',
|
|
51
|
+
'release',
|
|
52
|
+
'ship',
|
|
53
|
+
'tweak',
|
|
54
|
+
'adjust',
|
|
55
|
+
'also',
|
|
56
|
+
'however',
|
|
57
|
+
'but',
|
|
58
|
+
'fix',
|
|
59
|
+
'add',
|
|
60
|
+
'remov',
|
|
61
|
+
'updat',
|
|
62
|
+
'drop',
|
|
63
|
+
'delet',
|
|
64
|
+
'rebas',
|
|
65
|
+
'squash',
|
|
66
|
+
'simplif',
|
|
67
|
+
'tid',
|
|
68
|
+
'clean',
|
|
69
|
+
];
|
|
70
|
+
const CHANGE_PATTERN = new RegExp(String.raw `\b(?:${CHANGE_STEMS.join('|')})\w*`, 'i');
|
|
71
|
+
/**
|
|
72
|
+
* Whether a note is thanks or praise and nothing else. Conservative: a
|
|
73
|
+
* question mark, change-related wording, or a long body all disqualify it,
|
|
74
|
+
* so a "thanks, but I renamed the flag" never collapses into a bare ack.
|
|
75
|
+
*/
|
|
76
|
+
export function isThanksOnlyNote(body) {
|
|
77
|
+
const text = body.trim();
|
|
78
|
+
if (!text || text.length > 160 || text.includes('?'))
|
|
79
|
+
return false;
|
|
80
|
+
return THANKS_PATTERN.test(text) && !CHANGE_PATTERN.test(text);
|
|
81
|
+
}
|
|
82
|
+
function excerptOf(body) {
|
|
83
|
+
const flat = body.replaceAll(/\s+/g, ' ').trim();
|
|
84
|
+
return flat.length > EXCERPT_LENGTH ? `${flat.slice(0, EXCERPT_LENGTH)}...` : flat;
|
|
85
|
+
}
|
|
86
|
+
function parseMs(value) {
|
|
87
|
+
if (!value)
|
|
88
|
+
return undefined;
|
|
89
|
+
const ms = Date.parse(value);
|
|
90
|
+
return Number.isNaN(ms) ? undefined : ms;
|
|
91
|
+
}
|
|
92
|
+
/** Insert `note` keeping `notes` ordered oldest first (lists are tiny). */
|
|
93
|
+
function insertByTime(notes, note) {
|
|
94
|
+
let index = notes.length;
|
|
95
|
+
while (index > 0 && Date.parse(notes[index - 1].createdAt) > Date.parse(note.createdAt))
|
|
96
|
+
index--;
|
|
97
|
+
notes.splice(index, 0, note);
|
|
98
|
+
}
|
|
99
|
+
function toMergedPRNote({ author, createdAt, kind, excerpt }) {
|
|
100
|
+
return { author, createdAt, kind, excerpt };
|
|
101
|
+
}
|
|
102
|
+
/** The comment-shaped activity (issue comments, reviews, inline comments) as one stream. */
|
|
103
|
+
function* threadEntries(activity) {
|
|
104
|
+
for (const comment of activity.comments) {
|
|
105
|
+
yield { actor: comment, body: comment.body, at: comment.created_at, kind: 'comment' };
|
|
106
|
+
}
|
|
107
|
+
for (const review of activity.reviews) {
|
|
108
|
+
yield { actor: review, body: review.body, at: review.submitted_at, kind: 'review' };
|
|
109
|
+
}
|
|
110
|
+
for (const comment of activity.reviewComments) {
|
|
111
|
+
yield { actor: comment, body: comment.body, at: comment.created_at, kind: 'review_comment' };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Walk the comment-shaped activity once, separating the user's own entries
|
|
116
|
+
* from maintainer candidates. The user's entries count whatever their body
|
|
117
|
+
* (an empty-body APPROVED review is still a reply); a candidate needs a body
|
|
118
|
+
* and the issue-comment maintainer rule of {@link isMaintainerEngagement}
|
|
119
|
+
* for every kind, so a community member's "LGTM" review (CONTRIBUTOR / NONE)
|
|
120
|
+
* is not a note. An unknown association (older data) still passes.
|
|
121
|
+
*/
|
|
122
|
+
function scanThread(activity, username, earliestNoteMs) {
|
|
123
|
+
const usernameLower = username.toLowerCase();
|
|
124
|
+
const scan = { candidates: [], lastUserCommentMs: -Infinity };
|
|
125
|
+
const consider = ({ actor, body, at, kind }) => {
|
|
126
|
+
const atMs = parseMs(at);
|
|
127
|
+
if (!at || atMs === undefined)
|
|
128
|
+
return;
|
|
129
|
+
if (actor.user?.login?.toLowerCase() === usernameLower) {
|
|
130
|
+
scan.lastUserCommentMs = Math.max(scan.lastUserCommentMs, atMs);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const text = (body ?? '').trim();
|
|
134
|
+
if (!text || atMs < earliestNoteMs || !isMaintainerEngagement(actor, username, 'issue-comment'))
|
|
135
|
+
return;
|
|
136
|
+
scan.candidates.push({
|
|
137
|
+
kind,
|
|
138
|
+
author: actor.user?.login ?? 'unknown',
|
|
139
|
+
createdAt: at,
|
|
140
|
+
excerpt: excerptOf(text),
|
|
141
|
+
body: text,
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
for (const entry of threadEntries(activity))
|
|
145
|
+
consider(entry);
|
|
146
|
+
return scan;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The date a commit is scanned under: the committer date when the user both
|
|
150
|
+
* authored and committed it (their own rebase moved it), the author date
|
|
151
|
+
* otherwise. Either falls back to the other when missing.
|
|
152
|
+
*/
|
|
153
|
+
function commitDateOf(entry, isUserRebase) {
|
|
154
|
+
const authorDate = entry.commit.author?.date;
|
|
155
|
+
const committerDate = entry.commit.committer?.date;
|
|
156
|
+
return isUserRebase ? (committerDate ?? authorDate) : (authorDate ?? committerDate);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Walk the PR's commits once, by GitHub author login.
|
|
160
|
+
*
|
|
161
|
+
* Which date a commit carries depends on who last rewrote it. A rebase
|
|
162
|
+
* resets the committer date on every commit it touches and stamps the
|
|
163
|
+
* rebaser as committer, while the author date survives. So the user's own
|
|
164
|
+
* commit uses the committer date only when the user is also the committer
|
|
165
|
+
* (a fix the user rebased onto the base branch answers the review it
|
|
166
|
+
* followed, not the one it predates); when a maintainer or `web-flow`
|
|
167
|
+
* rebased the branch, that committer date is the maintainer's time, and the
|
|
168
|
+
* author date is the user's last real activity. Maintainer commits always
|
|
169
|
+
* use the author date, so a maintainer's rebase does not push their own
|
|
170
|
+
* earlier commit onto the same instant as the user's. Either date falls
|
|
171
|
+
* back to the other when missing. Merge commits (more than one parent, e.g.
|
|
172
|
+
* GitHub's "Update branch") carry no new work and are skipped on both sides.
|
|
173
|
+
*/
|
|
174
|
+
function scanCommits(commits, usernameLower) {
|
|
175
|
+
const scan = { commitNotes: [], lastUserCommitMs: -Infinity };
|
|
176
|
+
const consider = (entry) => {
|
|
177
|
+
if ((entry.parents?.length ?? 0) > 1)
|
|
178
|
+
return;
|
|
179
|
+
const login = entry.author?.login;
|
|
180
|
+
const isUser = login?.toLowerCase() === usernameLower;
|
|
181
|
+
const date = commitDateOf(entry, isUser && entry.committer?.login?.toLowerCase() === usernameLower);
|
|
182
|
+
const atMs = parseMs(date);
|
|
183
|
+
if (!date || atMs === undefined)
|
|
184
|
+
return;
|
|
185
|
+
if (isUser) {
|
|
186
|
+
scan.lastUserCommitMs = Math.max(scan.lastUserCommitMs, atMs);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
// A commit with no linked GitHub account is left alone: there is no way
|
|
190
|
+
// to tell whose it is, so never claim a maintainer pushed on top.
|
|
191
|
+
if (!login || isBotAuthor(login, entry.author?.type))
|
|
192
|
+
return;
|
|
193
|
+
const subject = (entry.commit.message ?? '').split('\n', 1)[0].trim();
|
|
194
|
+
scan.commitNotes.push({
|
|
195
|
+
kind: 'commit',
|
|
196
|
+
author: login,
|
|
197
|
+
createdAt: date,
|
|
198
|
+
excerpt: excerptOf(subject),
|
|
199
|
+
body: subject,
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
for (const entry of commits)
|
|
203
|
+
consider(entry);
|
|
204
|
+
return scan;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Scan one merged PR's activity. {@link MergedPRScan.pending} holds the
|
|
208
|
+
* notes that still wait for the user, following these rules:
|
|
209
|
+
*
|
|
210
|
+
* A comment, review (non-empty body) or inline review comment counts when:
|
|
211
|
+
* - it is maintainer engagement in the issue-comment sense of
|
|
212
|
+
* {@link isMaintainerEngagement} (never the user, never a bot; an OWNER /
|
|
213
|
+
* MEMBER / COLLABORATOR association when one is known, for reviews and
|
|
214
|
+
* inline comments too);
|
|
215
|
+
* - it was posted after the user's last comment, review, inline review
|
|
216
|
+
* comment AND last commit on the PR, so anything the user already answered
|
|
217
|
+
* in words or in code drops out;
|
|
218
|
+
* - it was posted no earlier than {@link MERGED_PR_NOTES_PRE_MERGE_GRACE_MS}
|
|
219
|
+
* before `mergedAt`.
|
|
220
|
+
*
|
|
221
|
+
* A commit counts when it is not a merge commit, its GitHub author is a
|
|
222
|
+
* non-bot account other than the user and its author date is after both the
|
|
223
|
+
* user's last commit and the user's last comment (see {@link scanCommits}
|
|
224
|
+
* for why a maintainer's rebase does not move the user's commits). Commits
|
|
225
|
+
* are not bound to the merge time: a maintainer who pushed on top the day
|
|
226
|
+
* before merging still changed what shipped.
|
|
227
|
+
*/
|
|
228
|
+
export function scanMergedPR(pr, activity, username) {
|
|
229
|
+
const mergedMs = parseMs(pr.mergedAt);
|
|
230
|
+
if (mergedMs === undefined) {
|
|
231
|
+
debug(MODULE, `Skipping ${pr.url}: mergedAt ${JSON.stringify(pr.mergedAt)} does not parse`);
|
|
232
|
+
return { pending: null, thanksOnlyThread: false, lastUserCommentMs: -Infinity };
|
|
233
|
+
}
|
|
234
|
+
const thread = scanThread(activity, username, mergedMs - MERGED_PR_NOTES_PRE_MERGE_GRACE_MS);
|
|
235
|
+
const commits = scanCommits(activity.commits, username.toLowerCase());
|
|
236
|
+
const threadCutoffMs = Math.max(thread.lastUserCommentMs, commits.lastUserCommitMs);
|
|
237
|
+
// Commits by someone else after the user's last commit: "changed what shipped".
|
|
238
|
+
const commitNotes = commits.commitNotes.filter((note) => Date.parse(note.createdAt) > commits.lastUserCommitMs);
|
|
239
|
+
const isThanksOnlyThread = thread.candidates.length > 0 &&
|
|
240
|
+
commitNotes.length === 0 &&
|
|
241
|
+
thread.candidates.every((note) => isThanksOnlyNote(note.body));
|
|
242
|
+
const scan = {
|
|
243
|
+
pending: null,
|
|
244
|
+
thanksOnlyThread: isThanksOnlyThread,
|
|
245
|
+
lastUserCommentMs: thread.lastUserCommentMs,
|
|
246
|
+
};
|
|
247
|
+
const notes = [];
|
|
248
|
+
for (const note of thread.candidates) {
|
|
249
|
+
if (Date.parse(note.createdAt) > threadCutoffMs)
|
|
250
|
+
insertByTime(notes, note);
|
|
251
|
+
}
|
|
252
|
+
for (const note of commitNotes) {
|
|
253
|
+
if (Date.parse(note.createdAt) > thread.lastUserCommentMs)
|
|
254
|
+
insertByTime(notes, note);
|
|
255
|
+
}
|
|
256
|
+
if (notes.length === 0)
|
|
257
|
+
return scan;
|
|
258
|
+
const maintainerCommits = notes.filter((note) => note.kind === 'commit').length;
|
|
259
|
+
scan.pending = {
|
|
260
|
+
prUrl: pr.url,
|
|
261
|
+
repo: pr.repo,
|
|
262
|
+
number: pr.number,
|
|
263
|
+
title: pr.title,
|
|
264
|
+
mergedAt: pr.mergedAt,
|
|
265
|
+
notes: notes.map((note) => toMergedPRNote(note)),
|
|
266
|
+
thanksOnly: maintainerCommits === 0 && notes.every((note) => isThanksOnlyNote(note.body)),
|
|
267
|
+
maintainerCommits,
|
|
268
|
+
};
|
|
269
|
+
return scan;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Collect the maintainer notes on one merged PR that still wait for the
|
|
273
|
+
* user, or null when there are none. See {@link scanMergedPR} for the rules.
|
|
274
|
+
*/
|
|
275
|
+
export function collectMergedPRNotes(pr, activity, username) {
|
|
276
|
+
return scanMergedPR(pr, activity, username).pending;
|
|
277
|
+
}
|
|
278
|
+
/** ISO timestamp of the newest note, for the dismiss comparison in the daily phase. */
|
|
279
|
+
export function latestNoteAt(entry) {
|
|
280
|
+
let latest = entry.notes[0].createdAt;
|
|
281
|
+
for (const note of entry.notes) {
|
|
282
|
+
if (Date.parse(note.createdAt) > Date.parse(latest))
|
|
283
|
+
latest = note.createdAt;
|
|
284
|
+
}
|
|
285
|
+
return latest;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Drop the thanks-only entries the user already acknowledged through the
|
|
289
|
+
* group's carrier: {@link groupThanksOnlyAcknowledgments} points older
|
|
290
|
+
* thanks-only PRs in a repo at the most recently merged one, and the
|
|
291
|
+
* workflow posts one acknowledgment there. On the next run that carrier has
|
|
292
|
+
* no pending note of its own, so without this step the covered PRs would
|
|
293
|
+
* come back as a new group. A thanks-only entry is covered when the user
|
|
294
|
+
* commented on a thanks-only PR in the same repo that merged after it, and
|
|
295
|
+
* that comment is newer than the entry's newest note. Substantive entries
|
|
296
|
+
* are never dropped here.
|
|
297
|
+
*/
|
|
298
|
+
export function omitAcknowledgedViaCarrier(entries, carriers) {
|
|
299
|
+
return entries.filter((entry) => {
|
|
300
|
+
if (!entry.thanksOnly)
|
|
301
|
+
return true;
|
|
302
|
+
const repoKey = entry.repo.toLowerCase();
|
|
303
|
+
const entryMergedMs = Date.parse(entry.mergedAt);
|
|
304
|
+
const newestNoteMs = Date.parse(latestNoteAt(entry));
|
|
305
|
+
const carrier = carriers.find((candidate) => candidate.prUrl !== entry.prUrl &&
|
|
306
|
+
candidate.repo.toLowerCase() === repoKey &&
|
|
307
|
+
Date.parse(candidate.mergedAt) > entryMergedMs &&
|
|
308
|
+
candidate.lastUserCommentMs > newestNoteMs);
|
|
309
|
+
if (carrier) {
|
|
310
|
+
debug(MODULE, `${entry.prUrl}: thanks acknowledged through the user's comment on ${carrier.prUrl}; skipping`);
|
|
311
|
+
}
|
|
312
|
+
return !carrier;
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* When several thanks-only merged PRs share a repo, mark all but the most
|
|
317
|
+
* recently merged one as covered by it (`ackCoveredBy`), so the user is
|
|
318
|
+
* offered one acknowledgment per repo instead of N near-identical comments.
|
|
319
|
+
* Entries with substantive notes are untouched. Returns a new array in the
|
|
320
|
+
* input order.
|
|
321
|
+
*/
|
|
322
|
+
export function groupThanksOnlyAcknowledgments(entries) {
|
|
323
|
+
const latestThanksByRepo = new Map();
|
|
324
|
+
for (const entry of entries) {
|
|
325
|
+
if (!entry.thanksOnly)
|
|
326
|
+
continue;
|
|
327
|
+
const key = entry.repo.toLowerCase();
|
|
328
|
+
const current = latestThanksByRepo.get(key);
|
|
329
|
+
if (!current || Date.parse(entry.mergedAt) > Date.parse(current.mergedAt))
|
|
330
|
+
latestThanksByRepo.set(key, entry);
|
|
331
|
+
}
|
|
332
|
+
return entries.map((entry) => {
|
|
333
|
+
if (!entry.thanksOnly)
|
|
334
|
+
return { ...entry };
|
|
335
|
+
const carrier = latestThanksByRepo.get(entry.repo.toLowerCase());
|
|
336
|
+
if (!carrier || carrier === entry)
|
|
337
|
+
return { ...entry };
|
|
338
|
+
return { ...entry, ackCoveredBy: carrier.prUrl };
|
|
339
|
+
});
|
|
340
|
+
}
|
|
@@ -72,6 +72,6 @@ export async function persistPickSnapshots(stateManager, snapshots) {
|
|
|
72
72
|
warn(MODULE, pickRecordError);
|
|
73
73
|
return { pickRecordError };
|
|
74
74
|
}
|
|
75
|
-
const gistSyncWarning = await maybeCheckpoint(stateManager, MODULE);
|
|
75
|
+
const gistSyncWarning = await maybeCheckpoint(stateManager, MODULE, () => stateManager.recordPickSnapshots(snapshots));
|
|
76
76
|
return gistSyncWarning ? { gistSyncWarning } : {};
|
|
77
77
|
}
|
package/dist/core/pr-assembly.js
CHANGED
|
@@ -13,6 +13,7 @@ import { daysBetween } from './dates.js';
|
|
|
13
13
|
import { determineStatus } from './status-determination.js';
|
|
14
14
|
import { determineReviewDecision, getLatestChangesRequestedDate, checkUnrespondedComments, getFirstMaintainerResponseAt, getLastMaintainerActivity, } from './review-analysis.js';
|
|
15
15
|
import { analyzeChecklist } from './checklist-analysis.js';
|
|
16
|
+
import { closingIssueUrl, mentionedIssueUrls } from './github-stats.js';
|
|
16
17
|
import { extractMaintainerActionHints } from './maintainer-analysis.js';
|
|
17
18
|
import { categorizeCIStatus, classifyFailingChecks } from './ci-analysis.js';
|
|
18
19
|
import { computeDisplayLabel } from './display-utils.js';
|
|
@@ -95,6 +96,8 @@ export async function assembleFetchedPR(signals, config, commitInfo) {
|
|
|
95
96
|
repo: `${signals.owner}/${signals.repo}`,
|
|
96
97
|
number: signals.number,
|
|
97
98
|
title: signals.title,
|
|
99
|
+
issueUrl: closingIssueUrl(signals.body, signals.prUrl),
|
|
100
|
+
mentionedIssueUrls: mentionedIssueUrls(signals.title, signals.body, signals.prUrl),
|
|
98
101
|
status,
|
|
99
102
|
actionReason,
|
|
100
103
|
waitReason,
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { FetchedPR, DailyDigest, ClosedPR, MergedPR, StarFilter } from './types.js';
|
|
16
16
|
import { type ActivityEvent } from './review-analysis.js';
|
|
17
|
+
import type { MergedPRActivity, MergedPRActivityList } from './merged-pr-notes.js';
|
|
18
|
+
import type { ReviewedPRActivity, ReviewedPRActivityList } from './reviewed-prs.js';
|
|
19
|
+
import { type CompareStatus, type ReviewedPRSearchResult } from './reviewed-prs-fetch.js';
|
|
17
20
|
import { type PRCountsResult } from './github-stats.js';
|
|
18
21
|
export { computeDisplayLabel } from './display-utils.js';
|
|
19
22
|
export { categorizeCIStatus, classifyCICheck, classifyFailingChecks, getCIStatus } from './ci-analysis.js';
|
|
@@ -46,6 +49,14 @@ export interface FetchPRsResult {
|
|
|
46
49
|
* Callers (daily, dashboard) surface these so users see the signal.
|
|
47
50
|
*/
|
|
48
51
|
warnings?: string[];
|
|
52
|
+
/**
|
|
53
|
+
* Set when the open-PR search hit the Search API's 1000-result cap, so
|
|
54
|
+
* `prs` is missing some of the user's open PRs (#1863). Structured twin of
|
|
55
|
+
* the truncation warning above: the daily run's closed-PR status check
|
|
56
|
+
* reads this flag, not the warning text, to decide whether a successor PR
|
|
57
|
+
* could be missing from the list. Absent when the search was complete.
|
|
58
|
+
*/
|
|
59
|
+
searchTruncated?: true;
|
|
49
60
|
}
|
|
50
61
|
/**
|
|
51
62
|
* Fetches and enriches open PRs from GitHub for the configured user.
|
|
@@ -138,12 +149,63 @@ export declare class PRMonitor {
|
|
|
138
149
|
* @returns Recently closed PRs
|
|
139
150
|
*/
|
|
140
151
|
fetchRecentlyClosedPRs(days?: number): Promise<ClosedPR[]>;
|
|
152
|
+
/**
|
|
153
|
+
* Login of the account that closed a PR (#1863), or undefined when GitHub
|
|
154
|
+
* reports none. The Search API items behind `fetchRecentlyClosedPRs` carry
|
|
155
|
+
* no `closed_by`, so this is one `issues.get` per PR (PRs are issues to
|
|
156
|
+
* that endpoint). Lets the daily run act only on PRs the user closed
|
|
157
|
+
* themselves, not ones a maintainer or bot closed.
|
|
158
|
+
*
|
|
159
|
+
* @throws {ValidationError} If `prUrl` is not a GitHub PR or issue URL
|
|
160
|
+
* @throws Octokit errors (404 when the PR is gone, rate limit, auth) unchanged
|
|
161
|
+
*/
|
|
162
|
+
fetchPRClosedBy(prUrl: string): Promise<string | undefined>;
|
|
141
163
|
/**
|
|
142
164
|
* Fetch PRs merged in the last N days.
|
|
143
165
|
* @param days - Lookback window in days (default: 7)
|
|
144
166
|
* @returns Recently merged PRs
|
|
145
167
|
*/
|
|
146
168
|
fetchRecentlyMergedPRs(days?: number): Promise<MergedPR[]>;
|
|
169
|
+
/**
|
|
170
|
+
* Everything the merged-PR notes selection reads for one PR (#1861): issue
|
|
171
|
+
* comments, reviews, inline review comments and commits, each paginated.
|
|
172
|
+
* Four calls per PR (more past 100 items). `truncatedLists` names the
|
|
173
|
+
* lists that hit the pagination cap; the lists arrive oldest-first, so it
|
|
174
|
+
* is the newest activity (including the user's own reply) that would be
|
|
175
|
+
* missing from those.
|
|
176
|
+
*
|
|
177
|
+
* The four calls run together; when more than one fails, a rate-limit or
|
|
178
|
+
* auth error is rethrown ahead of the others so the run stops instead of
|
|
179
|
+
* reporting a 404 that the throttled call never got to verify.
|
|
180
|
+
*
|
|
181
|
+
* @throws {ValidationError} If `prUrl` is not a GitHub PR URL
|
|
182
|
+
* @throws Octokit errors (404 when the PR is gone, rate limit, auth) unchanged
|
|
183
|
+
*/
|
|
184
|
+
fetchMergedPRActivity(prUrl: string): Promise<MergedPRActivity & {
|
|
185
|
+
truncatedLists: MergedPRActivityList[];
|
|
186
|
+
}>;
|
|
187
|
+
/**
|
|
188
|
+
* Open PRs the configured user reviewed or commented on but did not
|
|
189
|
+
* author (#1857); see `fetchReviewedOpenPRs` in reviewed-prs-fetch.ts for the searches,
|
|
190
|
+
* the exclusions and the cap warnings.
|
|
191
|
+
*/
|
|
192
|
+
fetchReviewedOpenPRs(): Promise<ReviewedPRSearchResult>;
|
|
193
|
+
/**
|
|
194
|
+
* The PR, comments, reviews, inline comments and commits the review
|
|
195
|
+
* follow-up scan reads for one reviewed PR (#1857); five calls, a
|
|
196
|
+
* rate-limit or auth error rethrown ahead of any other. See
|
|
197
|
+
* `fetchReviewedPRActivity` in reviewed-prs-fetch.ts.
|
|
198
|
+
*/
|
|
199
|
+
fetchReviewedPRActivity(prUrl: string): Promise<ReviewedPRActivity & {
|
|
200
|
+
truncatedLists: ReviewedPRActivityList[];
|
|
201
|
+
}>;
|
|
202
|
+
/**
|
|
203
|
+
* Whether `base` is still an ancestor of `head` in the PR's repository
|
|
204
|
+
* (#1857): `ahead` / `identical` yes, `behind` / `diverged` no (rebase or
|
|
205
|
+
* force-push), `missing` when GitHub no longer has `base`. See
|
|
206
|
+
* `fetchCompareStatus` in reviewed-prs-fetch.ts.
|
|
207
|
+
*/
|
|
208
|
+
fetchCompareStatus(prUrl: string, base: string, head: string): Promise<CompareStatus>;
|
|
147
209
|
/**
|
|
148
210
|
* Generate a daily digest from fetched PRs.
|
|
149
211
|
* @param prs - All open PRs (active + shelved)
|