@oss-autopilot/core 3.38.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 +139 -132
- 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 +287 -107
- package/dist/commands/dashboard-cache.js +9 -2
- package/dist/commands/dashboard-data.js +40 -20
- package/dist/commands/dashboard-gist-sync.d.ts +4 -0
- package/dist/commands/dashboard-gist-sync.js +5 -1
- package/dist/commands/dismiss.d.ts +25 -5
- package/dist/commands/dismiss.js +38 -10
- package/dist/commands/overnight.js +14 -1
- package/dist/commands/scout-bridge.js +4 -1
- package/dist/commands/validation.d.ts +11 -0
- package/dist/commands/validation.js +16 -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 +10 -0
- 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/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 +4 -23
- package/dist/core/state-schema.d.ts +6 -0
- package/dist/core/state-schema.js +9 -0
- package/dist/core/state.d.ts +70 -8
- package/dist/core/state.js +101 -10
- 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
|
@@ -24,14 +24,16 @@
|
|
|
24
24
|
* - Skip the comment entirely when ALL of these are true:
|
|
25
25
|
* 1. Every piece of maintainer feedback that requested code changes
|
|
26
26
|
* has a corresponding code change.
|
|
27
|
-
* 2. No question was asked
|
|
27
|
+
* 2. No question was asked and no maintainer thanks or praise is
|
|
28
|
+
* waiting for an acknowledgment.
|
|
28
29
|
* 3. Nothing was intentionally left unchanged (a "yes the maintainer
|
|
29
30
|
* asked but I did not change it" item always needs explanation).
|
|
30
31
|
* 4. The diff makes the fix self-evident — modeled here as the
|
|
31
32
|
* `allRequestedChangesAddressed` flag the caller passes in.
|
|
32
33
|
*
|
|
33
34
|
* - Draft a comment if ANY of these are true:
|
|
34
|
-
* 1. The maintainer asked a question
|
|
35
|
+
* 1. The maintainer asked a question, or thanked or praised the
|
|
36
|
+
* contributor (#1852).
|
|
35
37
|
* 2. The feedback is conceptual or design-level (the diff alone
|
|
36
38
|
* cannot answer "why").
|
|
37
39
|
* 3. Something was intentionally left unchanged (`needsComment: true`
|
|
@@ -44,13 +46,19 @@ export function shouldDraftResponse(input) {
|
|
|
44
46
|
return { shouldDraft: false, reason: 'no maintainer feedback to address' };
|
|
45
47
|
}
|
|
46
48
|
// Categories that always demand a written reply, regardless of the
|
|
47
|
-
// diff. The diff cannot answer a question
|
|
48
|
-
|
|
49
|
+
// diff. The diff cannot answer a question, carry a design decision, or
|
|
50
|
+
// acknowledge a maintainer's thanks.
|
|
51
|
+
const alwaysDraftCategories = new Set([
|
|
52
|
+
'question',
|
|
53
|
+
'explanation_request',
|
|
54
|
+
'design_discussion',
|
|
55
|
+
'appreciation',
|
|
56
|
+
]);
|
|
49
57
|
for (const item of input.feedback) {
|
|
50
58
|
if (alwaysDraftCategories.has(item.category)) {
|
|
51
59
|
return {
|
|
52
60
|
shouldDraft: true,
|
|
53
|
-
reason: `${item.category.replaceAll('_', ' ')}
|
|
61
|
+
reason: `${item.category.replaceAll('_', ' ')} needs a written reply the diff cannot give`,
|
|
54
62
|
};
|
|
55
63
|
}
|
|
56
64
|
}
|
|
@@ -11,8 +11,45 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function isBotAuthor(author: string, userType?: string | null): boolean;
|
|
13
13
|
/**
|
|
14
|
-
* Detect acknowledgment comments that don't
|
|
14
|
+
* Detect short acknowledgment comments that don't need code or a status change.
|
|
15
|
+
* Such a comment does not mark the PR as needing attention, so a thanks-only
|
|
16
|
+
* comment never reaches pr-responder's `appreciation` rule (#1852 follow-up).
|
|
15
17
|
* Returns true only when: no question mark, matches an acknowledgment keyword, and under 100 chars.
|
|
16
18
|
* Conservative -- missing a real acknowledgment (false negative) is safer than suppressing a substantive response (false positive).
|
|
17
19
|
*/
|
|
18
20
|
export declare function isAcknowledgmentComment(body: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether a comment is a reaction rather than a reply (#1862): nothing but
|
|
23
|
+
* emoji, `:shortcode:`s or punctuation, or one of the "+1" / "same here" /
|
|
24
|
+
* "any update" phrases. Used on engaged issues, where any substantive
|
|
25
|
+
* non-bot comment counts as a reply, to keep me-too traffic out. Anything
|
|
26
|
+
* longer or wordier passes: a false negative here surfaces one extra reply,
|
|
27
|
+
* a false positive hides one.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isReactionOnlyComment(body: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether a comment is a bare status request ("Any update?", "ping") (#1862).
|
|
32
|
+
* A subset of {@link isReactionOnlyComment}: these read as reactions on an
|
|
33
|
+
* issue the user only commented on, but on a claimed issue they ask the
|
|
34
|
+
* claimant, so the monitor counts them there.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isStatusNudge(body: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The prose of `body` with code and quotes removed: `>` quote lines, fenced
|
|
39
|
+
* and indented code blocks (see {@link ownProseLines}) and inline `code`
|
|
40
|
+
* spans. An @mention inside any of those is someone else's words or a
|
|
41
|
+
* literal, not an address to the user (#1857).
|
|
42
|
+
*/
|
|
43
|
+
export declare function proseWithoutCode(body: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether `body` quotes `quoted` (#1862): a Markdown `>` block in `body`
|
|
46
|
+
* contains a line (at least `MIN_QUOTE_LENGTH` characters once whitespace is
|
|
47
|
+
* collapsed) that appears verbatim in the prose of `quoted`. GitHub's "Quote
|
|
48
|
+
* reply" copies the quoted comment line by line with a `> ` prefix, so a
|
|
49
|
+
* reply built that way is addressed to the quoted comment's author as
|
|
50
|
+
* explicitly as an @mention. Nested quotes (`> > text`) in `body` are read
|
|
51
|
+
* too. Only the prose the author of `quoted` wrote counts as theirs: a quote
|
|
52
|
+
* they included, or an error line they pasted, matches a later quote of the
|
|
53
|
+
* same text without the reply being aimed at them (see {@link ownProseLines}).
|
|
54
|
+
*/
|
|
55
|
+
export declare function isQuoteReplyTo(body: string, quoted: string): boolean;
|
|
@@ -33,7 +33,9 @@ export function isBotAuthor(author, userType) {
|
|
|
33
33
|
return (lower.includes('[bot]') || lower.endsWith('-bot') || lower.endsWith('-robot') || KNOWN_BOT_USERNAMES.has(lower));
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Detect acknowledgment comments that don't
|
|
36
|
+
* Detect short acknowledgment comments that don't need code or a status change.
|
|
37
|
+
* Such a comment does not mark the PR as needing attention, so a thanks-only
|
|
38
|
+
* comment never reaches pr-responder's `appreciation` rule (#1852 follow-up).
|
|
37
39
|
* Returns true only when: no question mark, matches an acknowledgment keyword, and under 100 chars.
|
|
38
40
|
* Conservative -- missing a real acknowledgment (false negative) is safer than suppressing a substantive response (false positive).
|
|
39
41
|
*/
|
|
@@ -58,3 +60,124 @@ export function isAcknowledgmentComment(body) {
|
|
|
58
60
|
];
|
|
59
61
|
return ackKeywords.some((kw) => lower.includes(kw));
|
|
60
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Whole-comment phrases that add nothing to a thread once emoji, emoji
|
|
65
|
+
* shortcodes and punctuation are stripped (#1862).
|
|
66
|
+
*/
|
|
67
|
+
const LOW_SIGNAL_PHRASES = new Set([
|
|
68
|
+
'+1',
|
|
69
|
+
'bump',
|
|
70
|
+
'same',
|
|
71
|
+
'same here',
|
|
72
|
+
'same issue',
|
|
73
|
+
'same problem',
|
|
74
|
+
'me too',
|
|
75
|
+
'me as well',
|
|
76
|
+
'any update',
|
|
77
|
+
'any updates',
|
|
78
|
+
'any news',
|
|
79
|
+
'following',
|
|
80
|
+
'subscribed',
|
|
81
|
+
'ping',
|
|
82
|
+
'up',
|
|
83
|
+
]);
|
|
84
|
+
/**
|
|
85
|
+
* The low-signal phrases that ask whoever is working on the issue for a
|
|
86
|
+
* status ("any update?", "ping"). On a claimed issue they are addressed to
|
|
87
|
+
* the claimant, so the engaged rule surfaces them there; "+1" and "same
|
|
88
|
+
* here" are addressed to nobody and stay out.
|
|
89
|
+
*/
|
|
90
|
+
const STATUS_NUDGES = new Set(['any update', 'any updates', 'any news', 'ping']);
|
|
91
|
+
/** The comment's words: emoji, shortcodes and punctuation stripped, lower-cased. */
|
|
92
|
+
function significantWords(body) {
|
|
93
|
+
return body
|
|
94
|
+
.replaceAll(/:[\w+-]+:/g, ' ')
|
|
95
|
+
.replaceAll(/[^\p{L}\p{N}+]+/gu, ' ')
|
|
96
|
+
.trim()
|
|
97
|
+
.toLowerCase();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Whether a comment is a reaction rather than a reply (#1862): nothing but
|
|
101
|
+
* emoji, `:shortcode:`s or punctuation, or one of the "+1" / "same here" /
|
|
102
|
+
* "any update" phrases. Used on engaged issues, where any substantive
|
|
103
|
+
* non-bot comment counts as a reply, to keep me-too traffic out. Anything
|
|
104
|
+
* longer or wordier passes: a false negative here surfaces one extra reply,
|
|
105
|
+
* a false positive hides one.
|
|
106
|
+
*/
|
|
107
|
+
export function isReactionOnlyComment(body) {
|
|
108
|
+
const words = significantWords(body);
|
|
109
|
+
return words === '' || LOW_SIGNAL_PHRASES.has(words);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Whether a comment is a bare status request ("Any update?", "ping") (#1862).
|
|
113
|
+
* A subset of {@link isReactionOnlyComment}: these read as reactions on an
|
|
114
|
+
* issue the user only commented on, but on a claimed issue they ask the
|
|
115
|
+
* claimant, so the monitor counts them there.
|
|
116
|
+
*/
|
|
117
|
+
export function isStatusNudge(body) {
|
|
118
|
+
return STATUS_NUDGES.has(significantWords(body));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Shortest quoted line that identifies a comment. Short lines ("> LGTM",
|
|
122
|
+
* "> yes, agreed") recur across unrelated comments, so a quote that short
|
|
123
|
+
* says nothing about who is being answered.
|
|
124
|
+
*/
|
|
125
|
+
const MIN_QUOTE_LENGTH = 20;
|
|
126
|
+
function collapseWhitespace(text) {
|
|
127
|
+
return text.replaceAll(/\s+/g, ' ').trim();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The lines of `body` the author wrote themselves: Markdown `>` quotes,
|
|
131
|
+
* fenced code blocks and indented code are dropped. Quoted text belongs to
|
|
132
|
+
* someone else, and a pasted stack trace or error line is likely to be
|
|
133
|
+
* pasted by others too, so neither identifies the author's comment.
|
|
134
|
+
*/
|
|
135
|
+
function ownProseLines(body) {
|
|
136
|
+
const lines = [];
|
|
137
|
+
let isInFence = false;
|
|
138
|
+
for (const line of body.split('\n')) {
|
|
139
|
+
if (/^\s{0,3}(?:```|~~~)/.test(line)) {
|
|
140
|
+
isInFence = !isInFence;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const isQuoteOrCode = /^\s*>/.test(line) || /^(?: {4}|\t)/.test(line);
|
|
144
|
+
if (!isInFence && !isQuoteOrCode)
|
|
145
|
+
lines.push(line);
|
|
146
|
+
}
|
|
147
|
+
return lines;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The prose of `body` with code and quotes removed: `>` quote lines, fenced
|
|
151
|
+
* and indented code blocks (see {@link ownProseLines}) and inline `code`
|
|
152
|
+
* spans. An @mention inside any of those is someone else's words or a
|
|
153
|
+
* literal, not an address to the user (#1857).
|
|
154
|
+
*/
|
|
155
|
+
export function proseWithoutCode(body) {
|
|
156
|
+
return ownProseLines(body)
|
|
157
|
+
.join('\n')
|
|
158
|
+
.replaceAll(/`[^`\n]*`/g, ' ');
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Whether `body` quotes `quoted` (#1862): a Markdown `>` block in `body`
|
|
162
|
+
* contains a line (at least `MIN_QUOTE_LENGTH` characters once whitespace is
|
|
163
|
+
* collapsed) that appears verbatim in the prose of `quoted`. GitHub's "Quote
|
|
164
|
+
* reply" copies the quoted comment line by line with a `> ` prefix, so a
|
|
165
|
+
* reply built that way is addressed to the quoted comment's author as
|
|
166
|
+
* explicitly as an @mention. Nested quotes (`> > text`) in `body` are read
|
|
167
|
+
* too. Only the prose the author of `quoted` wrote counts as theirs: a quote
|
|
168
|
+
* they included, or an error line they pasted, matches a later quote of the
|
|
169
|
+
* same text without the reply being aimed at them (see {@link ownProseLines}).
|
|
170
|
+
*/
|
|
171
|
+
export function isQuoteReplyTo(body, quoted) {
|
|
172
|
+
const source = collapseWhitespace(ownProseLines(quoted).join('\n')).toLowerCase();
|
|
173
|
+
if (source.length < MIN_QUOTE_LENGTH)
|
|
174
|
+
return false;
|
|
175
|
+
for (const line of body.split('\n')) {
|
|
176
|
+
if (!line.trimStart().startsWith('>'))
|
|
177
|
+
continue;
|
|
178
|
+
const text = collapseWhitespace(line.replace(/^\s*(?:>\s*)+/, '')).toLowerCase();
|
|
179
|
+
if (text.length >= MIN_QUOTE_LENGTH && source.includes(text))
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
@@ -11,3 +11,9 @@ export declare function sleep(ms: number): Promise<void>;
|
|
|
11
11
|
* workers are aborted via a shared flag and the error is propagated.
|
|
12
12
|
*/
|
|
13
13
|
export declare function runWorkerPool<T>(items: T[], worker: (item: T) => Promise<void>, concurrency: number): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Rethrow the first rejection among `settled`, a rate-limit or auth error
|
|
16
|
+
* ahead of any other so a run stops instead of reporting a 404 that the
|
|
17
|
+
* throttled call never got to verify. No-op when nothing rejected.
|
|
18
|
+
*/
|
|
19
|
+
export declare function rethrowRejections(settled: readonly PromiseSettledResult<unknown>[]): void;
|
package/dist/core/concurrency.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Concurrency primitives shared across modules.
|
|
3
3
|
*/
|
|
4
|
+
import { isRateLimitOrAuthError } from './errors.js';
|
|
4
5
|
/** Default concurrency limit for parallel GitHub API requests. */
|
|
5
6
|
export const DEFAULT_CONCURRENCY = 5;
|
|
6
7
|
/** Async sleep — exported for mockability in tests. */
|
|
@@ -32,3 +33,15 @@ export async function runWorkerPool(items, worker, concurrency) {
|
|
|
32
33
|
const workerCount = Math.min(concurrency, items.length);
|
|
33
34
|
await Promise.all(Array.from({ length: workerCount }, () => poolWorker()));
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Rethrow the first rejection among `settled`, a rate-limit or auth error
|
|
38
|
+
* ahead of any other so a run stops instead of reporting a 404 that the
|
|
39
|
+
* throttled call never got to verify. No-op when nothing rejected.
|
|
40
|
+
*/
|
|
41
|
+
export function rethrowRejections(settled) {
|
|
42
|
+
const rejections = settled.filter((result) => result.status === 'rejected');
|
|
43
|
+
if (rejections.length === 0)
|
|
44
|
+
return;
|
|
45
|
+
const fatal = rejections.find((result) => isRateLimitOrAuthError(result.reason));
|
|
46
|
+
throw (fatal ?? rejections[0]).reason;
|
|
47
|
+
}
|
|
@@ -190,9 +190,21 @@ export declare function collectActionableIssues(prs: FetchedPR[], lastDigestAt?:
|
|
|
190
190
|
* @param commentedIssues - Issues with comment activity
|
|
191
191
|
* @param attention - Attention bucket counts; non-zero stuck-CI / dormant-followup buckets add a follow_up item
|
|
192
192
|
* @param unextractedMergeCount - Recently merged PRs whose learnings have not been extracted yet (#1463); non-zero adds an extract_learnings item
|
|
193
|
+
* @param closedPRStatusCount - Closed-unmerged PRs whose linked issue still needs a status update (#1863); non-zero adds a closed_pr_status item
|
|
194
|
+
* @param mergedPRNotesCount - Recently merged PRs carrying maintainer notes the user has not answered (#1861); non-zero adds a merged_pr_notes item
|
|
195
|
+
* @param reviewedPRCount - PRs the user reviewed where the author pushed or replied since (#1857); non-zero adds a review_follow_ups item
|
|
193
196
|
* @returns Action menu with context flags for orchestration
|
|
194
197
|
*/
|
|
195
198
|
export declare function computeActionMenu(actionableIssues: ActionableIssue[], capacity: CapacityAssessment, commentedIssues?: CommentedIssue[], attention?: Pick<AttentionSummary, 'stuckCI' | 'dormantFollowup'> & {
|
|
196
199
|
closeSuggested?: number;
|
|
197
|
-
}, unextractedMergeCount?: number): ActionMenu;
|
|
200
|
+
}, unextractedMergeCount?: number, closedPRStatusCount?: number, mergedPRNotesCount?: number, reviewedPRCount?: number): ActionMenu;
|
|
201
|
+
/**
|
|
202
|
+
* Whether a dismiss stamped at `dismissedAt` still covers the reply posted
|
|
203
|
+
* at `lastResponseAt`: both parse and the dismiss is not older than the
|
|
204
|
+
* reply. A reply newer than the dismiss resurfaces the issue, so the daily
|
|
205
|
+
* run and the dashboard must agree on this one comparison (#1862). An
|
|
206
|
+
* unreadable stamp fails open (not covered), matching the daily run's
|
|
207
|
+
* dismiss filter.
|
|
208
|
+
*/
|
|
209
|
+
export declare function isCoveredByDismiss(dismissedAt: string, lastResponseAt: string): boolean;
|
|
198
210
|
export { formatActionHint, formatBriefSummary, formatSummary, printDigest } from '../commands/daily-render.js';
|
package/dist/core/daily-logic.js
CHANGED
|
@@ -487,9 +487,12 @@ export function collectActionableIssues(prs, lastDigestAt) {
|
|
|
487
487
|
* @param commentedIssues - Issues with comment activity
|
|
488
488
|
* @param attention - Attention bucket counts; non-zero stuck-CI / dormant-followup buckets add a follow_up item
|
|
489
489
|
* @param unextractedMergeCount - Recently merged PRs whose learnings have not been extracted yet (#1463); non-zero adds an extract_learnings item
|
|
490
|
+
* @param closedPRStatusCount - Closed-unmerged PRs whose linked issue still needs a status update (#1863); non-zero adds a closed_pr_status item
|
|
491
|
+
* @param mergedPRNotesCount - Recently merged PRs carrying maintainer notes the user has not answered (#1861); non-zero adds a merged_pr_notes item
|
|
492
|
+
* @param reviewedPRCount - PRs the user reviewed where the author pushed or replied since (#1857); non-zero adds a review_follow_ups item
|
|
490
493
|
* @returns Action menu with context flags for orchestration
|
|
491
494
|
*/
|
|
492
|
-
export function computeActionMenu(actionableIssues, capacity, commentedIssues = [], attention, unextractedMergeCount) {
|
|
495
|
+
export function computeActionMenu(actionableIssues, capacity, commentedIssues = [], attention, unextractedMergeCount, closedPRStatusCount = 0, mergedPRNotesCount = 0, reviewedPRCount = 0) {
|
|
493
496
|
const issueResponses = commentedIssues.filter((i) => i.status === 'new_response');
|
|
494
497
|
const items = [];
|
|
495
498
|
const hasActionableIssues = actionableIssues.length > 0;
|
|
@@ -511,7 +514,7 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
|
|
|
511
514
|
items.push({
|
|
512
515
|
key: 'issue_replies',
|
|
513
516
|
label: `Review ${issueResponses.length} issue repl${issueResponses.length === 1 ? 'y' : 'ies'}`,
|
|
514
|
-
description: '
|
|
517
|
+
description: 'Replies on issues you commented on or are working on',
|
|
515
518
|
});
|
|
516
519
|
}
|
|
517
520
|
// Follow-up nudges (#1462) — the stuck_ci / dormant_followup buckets from
|
|
@@ -553,6 +556,45 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
|
|
|
553
556
|
description: 'Distill maintainer review feedback into per-repo contribution guidelines',
|
|
554
557
|
});
|
|
555
558
|
}
|
|
559
|
+
// Closed-PR status nudge (#1863) — the user's PR closed without merge and
|
|
560
|
+
// the linked issue has heard nothing from them since. Routes to
|
|
561
|
+
// workflows/closed-pr-status-update.md, which drafts the comment through
|
|
562
|
+
// draft-review-post; nothing posts automatically. Self-clears once the
|
|
563
|
+
// user comments on the issue or the PR leaves the recently-closed window.
|
|
564
|
+
if (closedPRStatusCount > 0) {
|
|
565
|
+
items.push({
|
|
566
|
+
key: 'closed_pr_status',
|
|
567
|
+
label: `Post status update on linked issue${closedPRStatusCount === 1 ? '' : 's'} (${closedPRStatusCount})`,
|
|
568
|
+
description: 'Your PR closed without merge; tell the issue what you found and whether you are stepping away',
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
// Merged-PR notes (#1861) — a maintainer thanked the user or explained a
|
|
572
|
+
// change at merge time and nobody answered. Routes to
|
|
573
|
+
// workflows/merged-pr-notes.md, which classifies each note and drafts the
|
|
574
|
+
// reply through draft-review-post; nothing posts automatically. Self-clears
|
|
575
|
+
// once the user comments on the PR, dismisses its URL, or the PR leaves
|
|
576
|
+
// the recently-merged window.
|
|
577
|
+
if (mergedPRNotesCount > 0) {
|
|
578
|
+
items.push({
|
|
579
|
+
key: 'merged_pr_notes',
|
|
580
|
+
label: `Merged PR${mergedPRNotesCount === 1 ? '' : 's'} with maintainer notes (${mergedPRNotesCount})`,
|
|
581
|
+
description: 'Maintainers left thanks or a follow-up note at merge; draft a short acknowledgment or reply',
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
// Review follow-ups (#1857) — a PR the user reviewed (not authored) where
|
|
585
|
+
// the author pushed commits or replied since the user's last review or
|
|
586
|
+
// comment. Routes to workflows/review-follow-ups.md, which re-reviews the
|
|
587
|
+
// compare range (or the commit list after a rebase) through review-panel
|
|
588
|
+
// and drafts answers through draft-review-post; nothing posts
|
|
589
|
+
// automatically. Self-clears once the user reviews or comments again,
|
|
590
|
+
// dismisses the PR URL, or the PR closes. Never counted in capacity.
|
|
591
|
+
if (reviewedPRCount > 0) {
|
|
592
|
+
items.push({
|
|
593
|
+
key: 'review_follow_ups',
|
|
594
|
+
label: `Review follow-ups (${reviewedPRCount})`,
|
|
595
|
+
description: 'PRs you reviewed where the author pushed or replied since; re-review the changes and answer their questions',
|
|
596
|
+
});
|
|
597
|
+
}
|
|
556
598
|
// The orchestration layer (commands/oss.md Action Menu section) may insert issue-list
|
|
557
599
|
// options before the search item when a curated list is available.
|
|
558
600
|
const searchItem = {
|
|
@@ -589,6 +631,21 @@ export function computeActionMenu(actionableIssues, capacity, commentedIssues =
|
|
|
589
631
|
},
|
|
590
632
|
};
|
|
591
633
|
}
|
|
634
|
+
/**
|
|
635
|
+
* Whether a dismiss stamped at `dismissedAt` still covers the reply posted
|
|
636
|
+
* at `lastResponseAt`: both parse and the dismiss is not older than the
|
|
637
|
+
* reply. A reply newer than the dismiss resurfaces the issue, so the daily
|
|
638
|
+
* run and the dashboard must agree on this one comparison (#1862). An
|
|
639
|
+
* unreadable stamp fails open (not covered), matching the daily run's
|
|
640
|
+
* dismiss filter.
|
|
641
|
+
*/
|
|
642
|
+
export function isCoveredByDismiss(dismissedAt, lastResponseAt) {
|
|
643
|
+
const dismissedMs = Date.parse(dismissedAt);
|
|
644
|
+
const responseMs = Date.parse(lastResponseAt);
|
|
645
|
+
if (Number.isNaN(dismissedMs) || Number.isNaN(responseMs))
|
|
646
|
+
return false;
|
|
647
|
+
return dismissedMs >= responseMs;
|
|
648
|
+
}
|
|
592
649
|
// ---------------------------------------------------------------------------
|
|
593
650
|
// Rendering re-exports (back-compat)
|
|
594
651
|
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engaged issues (#1862): the issues the user is working on, as opposed to
|
|
3
|
+
* ones they commented on in passing.
|
|
4
|
+
*
|
|
5
|
+
* An issue is engaged when the user claimed it locally (`activeIssues`,
|
|
6
|
+
* candidates excluded) or one of their PRs closes it through a closing
|
|
7
|
+
* keyword: an open PR, a recently closed or merged PR, or a merged/closed
|
|
8
|
+
* ledger entry no older than {@link LEDGER_LINK_MAX_AGE_DAYS}. Plain
|
|
9
|
+
* mentions in a PR body ("similar to #12", "see #4 for the upstream bug") are
|
|
10
|
+
* not engagement: they named unrelated issues, bumped the engagement time
|
|
11
|
+
* past earlier maintainer replies, and ate into the direct-fetch cap.
|
|
12
|
+
* `IssueConversationMonitor` scans engaged issues under a wider reply rule
|
|
13
|
+
* (any substantive non-bot comment counts, not only maintainer or @mention
|
|
14
|
+
* replies) and fetches the live ones directly when the commenter search does
|
|
15
|
+
* not return them.
|
|
16
|
+
*
|
|
17
|
+
* Pure: builds a keyed map from the lists the daily run already holds. URLs
|
|
18
|
+
* are compared through `issueRefKey`, so `Org/Repo` and `org/repo`, trailing
|
|
19
|
+
* slashes and `#fragment`s all name the same issue.
|
|
20
|
+
*/
|
|
21
|
+
import type { FetchedPR, IssueEngagement, TrackedIssue } from './types.js';
|
|
22
|
+
/**
|
|
23
|
+
* Oldest ledger link that still counts as engagement. A PR merged or closed
|
|
24
|
+
* longer ago than this is finished work: a comment on its issue months later
|
|
25
|
+
* is a new conversation, and the passing-comment rule (maintainer, @mention
|
|
26
|
+
* or quote reply) is the right one for it.
|
|
27
|
+
*/
|
|
28
|
+
export declare const LEDGER_LINK_MAX_AGE_DAYS = 90;
|
|
29
|
+
/** One engaged issue, keyed for lookup against search results. */
|
|
30
|
+
export interface EngagedIssue extends IssueEngagement {
|
|
31
|
+
/** `issueRefKey` of the issue. */
|
|
32
|
+
key: string;
|
|
33
|
+
/** Canonical `https://github.com/owner/repo/issues/N` URL. */
|
|
34
|
+
url: string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the user claimed the issue locally, whatever `reason` says. An
|
|
37
|
+
* open PR outranks the claim as the reason, but a bare "any update?" on the
|
|
38
|
+
* issue still asks the claimant, so the monitor reads this, not `reason`.
|
|
39
|
+
*/
|
|
40
|
+
claimed: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Fetch the issue directly when the comment search misses it. True for
|
|
43
|
+
* live engagements (claims, open PRs, the recent closed/merged lists);
|
|
44
|
+
* false for ledger links, which count only when the search already found
|
|
45
|
+
* the issue active.
|
|
46
|
+
*/
|
|
47
|
+
fetchWhenMissing: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** A closed or merged PR with its issue link, from the digest lists or the ledger. */
|
|
50
|
+
export interface EngagedPRLink {
|
|
51
|
+
url: string;
|
|
52
|
+
/** Issue the PR closes via a closing keyword. */
|
|
53
|
+
issueUrl?: string;
|
|
54
|
+
/** When the PR was opened; optional on older ledger entries. */
|
|
55
|
+
openedAt?: string;
|
|
56
|
+
}
|
|
57
|
+
/** Everything the daily run knows about the user's claims and PRs. */
|
|
58
|
+
export interface EngagedIssuesInput {
|
|
59
|
+
/** Local claims; `updatedAt` is the claim stamp (see `StateManager.addIssue`). `candidate` entries are not claims. */
|
|
60
|
+
claims: readonly Pick<TrackedIssue, 'url' | 'updatedAt' | 'status'>[];
|
|
61
|
+
/** Open PRs; only the closing link (`issueUrl`) is engagement, not body mentions. */
|
|
62
|
+
openPRs: readonly Pick<FetchedPR, 'url' | 'issueUrl' | 'createdAt'>[];
|
|
63
|
+
recentlyClosedPRs: readonly (EngagedPRLink & {
|
|
64
|
+
closedAt: string;
|
|
65
|
+
})[];
|
|
66
|
+
recentlyMergedPRs: readonly (EngagedPRLink & {
|
|
67
|
+
mergedAt: string;
|
|
68
|
+
})[];
|
|
69
|
+
ledgerClosedPRs: readonly (EngagedPRLink & {
|
|
70
|
+
closedAt: string;
|
|
71
|
+
})[];
|
|
72
|
+
ledgerMergedPRs: readonly (EngagedPRLink & {
|
|
73
|
+
mergedAt: string;
|
|
74
|
+
})[];
|
|
75
|
+
}
|
|
76
|
+
export interface CollectEngagedIssuesOptions {
|
|
77
|
+
/** Reference time for the ledger age bound; defaults to now. */
|
|
78
|
+
now?: Date;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Collect the user's engaged issues, keyed by `issueRefKey`. When several
|
|
82
|
+
* engagements name one issue, the entry keeps the strongest reason (and its
|
|
83
|
+
* PR), the latest `since`, is `claimed` if any engagement is a claim, and
|
|
84
|
+
* fetches directly if any engagement is live.
|
|
85
|
+
* Links that do not parse as GitHub URLs, or that name one of the user's own
|
|
86
|
+
* PRs, are skipped. Iteration order is strongest-reason first (engagements
|
|
87
|
+
* are visited in that order, so an issue is inserted at its strongest
|
|
88
|
+
* reason's position), so a caller that caps direct fetches keeps the open-PR
|
|
89
|
+
* and claim issues.
|
|
90
|
+
*/
|
|
91
|
+
export declare function collectEngagedIssues(input: EngagedIssuesInput, options?: CollectEngagedIssuesOptions): Map<string, EngagedIssue>;
|
|
92
|
+
/** The `IssueEngagement` projection of an engaged issue, for the digest entry. */
|
|
93
|
+
export declare function toIssueEngagement({ reason, prUrl, since }: EngagedIssue): IssueEngagement;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engaged issues (#1862): the issues the user is working on, as opposed to
|
|
3
|
+
* ones they commented on in passing.
|
|
4
|
+
*
|
|
5
|
+
* An issue is engaged when the user claimed it locally (`activeIssues`,
|
|
6
|
+
* candidates excluded) or one of their PRs closes it through a closing
|
|
7
|
+
* keyword: an open PR, a recently closed or merged PR, or a merged/closed
|
|
8
|
+
* ledger entry no older than {@link LEDGER_LINK_MAX_AGE_DAYS}. Plain
|
|
9
|
+
* mentions in a PR body ("similar to #12", "see #4 for the upstream bug") are
|
|
10
|
+
* not engagement: they named unrelated issues, bumped the engagement time
|
|
11
|
+
* past earlier maintainer replies, and ate into the direct-fetch cap.
|
|
12
|
+
* `IssueConversationMonitor` scans engaged issues under a wider reply rule
|
|
13
|
+
* (any substantive non-bot comment counts, not only maintainer or @mention
|
|
14
|
+
* replies) and fetches the live ones directly when the commenter search does
|
|
15
|
+
* not return them.
|
|
16
|
+
*
|
|
17
|
+
* Pure: builds a keyed map from the lists the daily run already holds. URLs
|
|
18
|
+
* are compared through `issueRefKey`, so `Org/Repo` and `org/repo`, trailing
|
|
19
|
+
* slashes and `#fragment`s all name the same issue.
|
|
20
|
+
*/
|
|
21
|
+
import { issueRefKey, parseGitHubUrl } from './urls.js';
|
|
22
|
+
const REASON_RANK = { open_pr: 0, claim: 1, closed_pr: 2, merged_pr: 3 };
|
|
23
|
+
/**
|
|
24
|
+
* Oldest ledger link that still counts as engagement. A PR merged or closed
|
|
25
|
+
* longer ago than this is finished work: a comment on its issue months later
|
|
26
|
+
* is a new conversation, and the passing-comment rule (maintainer, @mention
|
|
27
|
+
* or quote reply) is the right one for it.
|
|
28
|
+
*/
|
|
29
|
+
export const LEDGER_LINK_MAX_AGE_DAYS = 90;
|
|
30
|
+
/** The later of two optional ISO stamps; an unreadable or missing one loses. */
|
|
31
|
+
function laterOf(a, b) {
|
|
32
|
+
const aMs = a === undefined ? NaN : Date.parse(a);
|
|
33
|
+
const bMs = b === undefined ? NaN : Date.parse(b);
|
|
34
|
+
if (Number.isNaN(bMs))
|
|
35
|
+
return a;
|
|
36
|
+
if (Number.isNaN(aMs))
|
|
37
|
+
return b;
|
|
38
|
+
return bMs > aMs ? b : a;
|
|
39
|
+
}
|
|
40
|
+
/** Issues an open PR closes. */
|
|
41
|
+
function* openPREngagements(prs) {
|
|
42
|
+
for (const pr of prs) {
|
|
43
|
+
if (!pr.issueUrl)
|
|
44
|
+
continue;
|
|
45
|
+
yield { issueUrl: pr.issueUrl, reason: 'open_pr', prUrl: pr.url, since: pr.createdAt, fetchWhenMissing: true };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Issues closed or merged PRs link, dated by the opening time. An entry
|
|
50
|
+
* without one (older ledger rows) carries no `since`: the close or merge time
|
|
51
|
+
* is not when the user engaged, and a baseline later than the real engagement
|
|
52
|
+
* would hide replies, so the monitor falls back to the user's last comment.
|
|
53
|
+
*/
|
|
54
|
+
function* linkedPREngagements(input, nowMs) {
|
|
55
|
+
const lists = [
|
|
56
|
+
{ prs: input.recentlyClosedPRs, reason: 'closed_pr', isRecent: true },
|
|
57
|
+
{ prs: input.recentlyMergedPRs, reason: 'merged_pr', isRecent: true },
|
|
58
|
+
{ prs: input.ledgerClosedPRs, reason: 'closed_pr', isRecent: false },
|
|
59
|
+
{ prs: input.ledgerMergedPRs, reason: 'merged_pr', isRecent: false },
|
|
60
|
+
];
|
|
61
|
+
for (const { prs, reason, isRecent } of lists) {
|
|
62
|
+
for (const pr of prs) {
|
|
63
|
+
const engagement = linkedEngagement(pr, reason, isRecent, nowMs);
|
|
64
|
+
if (engagement)
|
|
65
|
+
yield engagement;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The engagement one finished PR carries, or undefined when it has no link or
|
|
71
|
+
* is too old a ledger row. `isRecent` marks the digest's recent lists, which
|
|
72
|
+
* are fetched directly when the search misses them; ledger rows are not.
|
|
73
|
+
*/
|
|
74
|
+
function linkedEngagement(pr, reason, isRecent, nowMs) {
|
|
75
|
+
if (!pr.issueUrl)
|
|
76
|
+
return undefined;
|
|
77
|
+
if (!isRecent && !isWithinLedgerBound(pr, nowMs))
|
|
78
|
+
return undefined;
|
|
79
|
+
return { reason, issueUrl: pr.issueUrl, prUrl: pr.url, since: pr.openedAt, fetchWhenMissing: isRecent };
|
|
80
|
+
}
|
|
81
|
+
function isWithinLedgerBound(pr, nowMs) {
|
|
82
|
+
const endedMs = Date.parse('closedAt' in pr ? pr.closedAt : pr.mergedAt);
|
|
83
|
+
return !Number.isNaN(endedMs) && nowMs - endedMs <= LEDGER_LINK_MAX_AGE_DAYS * 24 * 60 * 60 * 1000;
|
|
84
|
+
}
|
|
85
|
+
/** Every engagement, strongest reason first. */
|
|
86
|
+
function* engagements(input, nowMs) {
|
|
87
|
+
yield* openPREngagements(input.openPRs);
|
|
88
|
+
for (const claim of input.claims) {
|
|
89
|
+
if (claim.status === 'candidate')
|
|
90
|
+
continue;
|
|
91
|
+
yield { issueUrl: claim.url, reason: 'claim', since: claim.updatedAt, fetchWhenMissing: true };
|
|
92
|
+
}
|
|
93
|
+
yield* linkedPREngagements(input, nowMs);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Keys of the user's own PRs. A closing keyword can name one of them
|
|
97
|
+
* ("closes #50" on a follow-up to PR #50); that is not an issue, and fetching
|
|
98
|
+
* it would spend one of the capped direct lookups to learn so.
|
|
99
|
+
*/
|
|
100
|
+
function ownPRKeys(input) {
|
|
101
|
+
const keys = new Set();
|
|
102
|
+
const lists = [
|
|
103
|
+
input.openPRs,
|
|
104
|
+
input.recentlyClosedPRs,
|
|
105
|
+
input.recentlyMergedPRs,
|
|
106
|
+
input.ledgerClosedPRs,
|
|
107
|
+
input.ledgerMergedPRs,
|
|
108
|
+
];
|
|
109
|
+
for (const prs of lists) {
|
|
110
|
+
for (const pr of prs) {
|
|
111
|
+
const key = issueRefKey(pr.url);
|
|
112
|
+
if (key)
|
|
113
|
+
keys.add(key);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return keys;
|
|
117
|
+
}
|
|
118
|
+
/** Fold one engagement into the map: strongest reason, latest since, claimed or fetched if any is. */
|
|
119
|
+
function record(byKey, engagement) {
|
|
120
|
+
const parsed = parseGitHubUrl(engagement.issueUrl);
|
|
121
|
+
const key = issueRefKey(engagement.issueUrl);
|
|
122
|
+
if (!parsed || !key)
|
|
123
|
+
return;
|
|
124
|
+
const isClaim = engagement.reason === 'claim';
|
|
125
|
+
const current = byKey.get(key);
|
|
126
|
+
if (!current) {
|
|
127
|
+
byKey.set(key, {
|
|
128
|
+
key,
|
|
129
|
+
url: `https://github.com/${parsed.owner}/${parsed.repo}/issues/${parsed.number}`,
|
|
130
|
+
reason: engagement.reason,
|
|
131
|
+
...(engagement.prUrl !== undefined && { prUrl: engagement.prUrl }),
|
|
132
|
+
...(engagement.since !== undefined && { since: engagement.since }),
|
|
133
|
+
claimed: isClaim,
|
|
134
|
+
fetchWhenMissing: engagement.fetchWhenMissing,
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
current.claimed ||= isClaim;
|
|
139
|
+
if (REASON_RANK[engagement.reason] < REASON_RANK[current.reason]) {
|
|
140
|
+
current.reason = engagement.reason;
|
|
141
|
+
if (engagement.prUrl === undefined)
|
|
142
|
+
delete current.prUrl;
|
|
143
|
+
else
|
|
144
|
+
current.prUrl = engagement.prUrl;
|
|
145
|
+
}
|
|
146
|
+
const since = laterOf(current.since, engagement.since);
|
|
147
|
+
if (since === undefined)
|
|
148
|
+
delete current.since;
|
|
149
|
+
else
|
|
150
|
+
current.since = since;
|
|
151
|
+
current.fetchWhenMissing ||= engagement.fetchWhenMissing;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Collect the user's engaged issues, keyed by `issueRefKey`. When several
|
|
155
|
+
* engagements name one issue, the entry keeps the strongest reason (and its
|
|
156
|
+
* PR), the latest `since`, is `claimed` if any engagement is a claim, and
|
|
157
|
+
* fetches directly if any engagement is live.
|
|
158
|
+
* Links that do not parse as GitHub URLs, or that name one of the user's own
|
|
159
|
+
* PRs, are skipped. Iteration order is strongest-reason first (engagements
|
|
160
|
+
* are visited in that order, so an issue is inserted at its strongest
|
|
161
|
+
* reason's position), so a caller that caps direct fetches keeps the open-PR
|
|
162
|
+
* and claim issues.
|
|
163
|
+
*/
|
|
164
|
+
export function collectEngagedIssues(input, options = {}) {
|
|
165
|
+
const nowMs = (options.now ?? new Date()).getTime();
|
|
166
|
+
const ownPRs = ownPRKeys(input);
|
|
167
|
+
const byKey = new Map();
|
|
168
|
+
for (const engagement of engagements(input, nowMs)) {
|
|
169
|
+
const key = issueRefKey(engagement.issueUrl);
|
|
170
|
+
if (key !== null && ownPRs.has(key))
|
|
171
|
+
continue;
|
|
172
|
+
record(byKey, engagement);
|
|
173
|
+
}
|
|
174
|
+
return byKey;
|
|
175
|
+
}
|
|
176
|
+
/** The `IssueEngagement` projection of an engaged issue, for the digest entry. */
|
|
177
|
+
export function toIssueEngagement({ reason, prUrl, since }) {
|
|
178
|
+
return {
|
|
179
|
+
reason,
|
|
180
|
+
...(prUrl !== undefined && { prUrl }),
|
|
181
|
+
...(since !== undefined && { since }),
|
|
182
|
+
};
|
|
183
|
+
}
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -114,6 +114,10 @@ export declare function errorMessage(e: unknown): string;
|
|
|
114
114
|
* Returns undefined if the error doesn't have a numeric `status` property.
|
|
115
115
|
*/
|
|
116
116
|
export declare function getHttpStatusCode(error: unknown): number | undefined;
|
|
117
|
+
/** `HTTP 404` when the error carries a status, else undefined. */
|
|
118
|
+
export declare function httpStatusLabel(error: unknown): string | undefined;
|
|
119
|
+
/** Warning text with the HTTP status in front when there is one (`HTTP 502: Bad Gateway`). */
|
|
120
|
+
export declare function describeError(error: unknown): string;
|
|
117
121
|
/** Check if an error is a GitHub rate limit error (429 or rate-limit 403). */
|
|
118
122
|
export declare function isRateLimitError(error: unknown): boolean;
|
|
119
123
|
/**
|