@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
package/dist/commands/setup.js
CHANGED
|
@@ -54,7 +54,10 @@ export async function runSetup(options) {
|
|
|
54
54
|
throw new ValidationError(formatUnknownKeyError(key, 'setup'));
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
// Named so the Gist conflict path can re-apply the same settings on a
|
|
58
|
+
// refreshed baseline (maybeCheckpoint below).
|
|
59
|
+
const applySettings = () => {
|
|
60
|
+
warnings.length = 0;
|
|
58
61
|
for (const setting of options.set) {
|
|
59
62
|
const [key, ...valueParts] = setting.split('=');
|
|
60
63
|
const value = valueParts.join('=');
|
|
@@ -368,11 +371,12 @@ export async function runSetup(options) {
|
|
|
368
371
|
}
|
|
369
372
|
}
|
|
370
373
|
}
|
|
371
|
-
}
|
|
374
|
+
};
|
|
375
|
+
stateManager.batch(applySettings);
|
|
372
376
|
// Push the settings mutation to the Gist in gist mode (no-op locally).
|
|
373
377
|
// Without this the change only hits the local cache and the next
|
|
374
378
|
// bootstrap reverts it from the Gist (#1440).
|
|
375
|
-
const gistSyncWarning = await maybeCheckpoint(stateManager, MODULE);
|
|
379
|
+
const gistSyncWarning = await maybeCheckpoint(stateManager, MODULE, () => stateManager.batch(applySettings));
|
|
376
380
|
return {
|
|
377
381
|
success: true,
|
|
378
382
|
settings: results,
|
|
@@ -7,6 +7,12 @@ export declare const PR_URL_PATTERN: RegExp;
|
|
|
7
7
|
export declare const ISSUE_URL_PATTERN: RegExp;
|
|
8
8
|
/** Matches GitHub issue or PR URLs: /issues/123 or /pull/123 */
|
|
9
9
|
export declare const ISSUE_OR_PR_URL_PATTERN: RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* Matches a full 40-hex commit SHA, as GitHub reports PR heads (#1857). A
|
|
12
|
+
* short SHA is rejected: the daily run compares the recorded head with the
|
|
13
|
+
* PR's full head SHA by equality, so an abbreviated one would never match.
|
|
14
|
+
*/
|
|
15
|
+
export declare const COMMIT_SHA_PATTERN: RegExp;
|
|
10
16
|
/**
|
|
11
17
|
* Validate a GitHub URL against a pattern. Throws if invalid.
|
|
12
18
|
*/
|
|
@@ -16,6 +22,11 @@ export declare function validateGitHubUrl(url: string, pattern: RegExp, entityTy
|
|
|
16
22
|
* Returns the URL if valid, throws if too long.
|
|
17
23
|
*/
|
|
18
24
|
export declare function validateUrl(url: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Validate a full commit SHA (40 hex digits). Returns it lowercased, throws
|
|
27
|
+
* if abbreviated or malformed.
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateCommitSha(sha: string): string;
|
|
19
30
|
/**
|
|
20
31
|
* Validate that a PR/issue number is a positive integer within bounds.
|
|
21
32
|
* Returns the number if valid, throws if invalid.
|
|
@@ -9,6 +9,12 @@ export const PR_URL_PATTERN = /^https:\/\/github\.com\/[^/]+\/[^/]+\/pull\/\d+$/
|
|
|
9
9
|
export const ISSUE_URL_PATTERN = /^https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+$/;
|
|
10
10
|
/** Matches GitHub issue or PR URLs: /issues/123 or /pull/123 */
|
|
11
11
|
export const ISSUE_OR_PR_URL_PATTERN = /^https:\/\/github\.com\/[^/]+\/[^/]+\/(issues|pull)\/\d+$/;
|
|
12
|
+
/**
|
|
13
|
+
* Matches a full 40-hex commit SHA, as GitHub reports PR heads (#1857). A
|
|
14
|
+
* short SHA is rejected: the daily run compares the recorded head with the
|
|
15
|
+
* PR's full head SHA by equality, so an abbreviated one would never match.
|
|
16
|
+
*/
|
|
17
|
+
export const COMMIT_SHA_PATTERN = /^[0-9a-f]{40}$/i;
|
|
12
18
|
/** Maximum allowed URL length */
|
|
13
19
|
const MAX_URL_LENGTH = 2048;
|
|
14
20
|
/** Maximum allowed PR/issue number */
|
|
@@ -40,6 +46,16 @@ export function validateUrl(url) {
|
|
|
40
46
|
}
|
|
41
47
|
return url;
|
|
42
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Validate a full commit SHA (40 hex digits). Returns it lowercased, throws
|
|
51
|
+
* if abbreviated or malformed.
|
|
52
|
+
*/
|
|
53
|
+
export function validateCommitSha(sha) {
|
|
54
|
+
if (!COMMIT_SHA_PATTERN.test(sha)) {
|
|
55
|
+
throw new ValidationError(`Invalid commit SHA: ${sha}. Expected the full 40-character hex SHA`);
|
|
56
|
+
}
|
|
57
|
+
return sha.toLowerCase();
|
|
58
|
+
}
|
|
43
59
|
/**
|
|
44
60
|
* Validate that a PR/issue number is a positive integer within bounds.
|
|
45
61
|
* Returns the number if valid, throws if invalid.
|
|
@@ -58,8 +74,30 @@ export function validateMessage(message) {
|
|
|
58
74
|
if (message.length > MAX_MESSAGE_LENGTH) {
|
|
59
75
|
throw new ValidationError(`Message exceeds maximum length of ${MAX_MESSAGE_LENGTH} characters`);
|
|
60
76
|
}
|
|
77
|
+
// The no-AI-attribution rule (CLAUDE.md, skills/contribution-ethics) was
|
|
78
|
+
// prompt-level only; this is the one write boundary every post/claim
|
|
79
|
+
// crosses, so enforce it here (audit 2026-10-30 L1).
|
|
80
|
+
// Best-effort guard, not enforcement: the prompt-level rule stays the
|
|
81
|
+
// contract; this catches the common pasted shapes. Format characters are
|
|
82
|
+
// stripped so "C\u200Blaude" is seen, and fenced code blocks are ignored
|
|
83
|
+
// so a reply quoting the trailer it removed is not rejected.
|
|
84
|
+
const cleaned = message.replace(/\p{Cf}/gu, '').replace(/```[\s\S]*?```/g, '');
|
|
85
|
+
if (AI_ATTRIBUTION_PATTERNS.some((pattern) => pattern.test(cleaned))) {
|
|
86
|
+
throw new ValidationError('Message contains AI attribution (a Co-Authored-By / Claude-Session trailer or "Generated with Claude Code"); remove it');
|
|
87
|
+
}
|
|
61
88
|
return message;
|
|
62
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Markers the contribution-ethics skill forbids in anything posted to GitHub:
|
|
92
|
+
* trailer lines and the "Generated/Made/Built with|by Claude Code" footer,
|
|
93
|
+
* both anchored to line start (leading indent allowed, so a pasted Git log
|
|
94
|
+
* still matches) so quoting or negating one mid-sentence is fine.
|
|
95
|
+
*/
|
|
96
|
+
const AI_ATTRIBUTION_PATTERNS = [
|
|
97
|
+
/^[ \t]*co-authored-by:.*\b(?:claude|anthropic)\b/im,
|
|
98
|
+
/^[ \t]*claude-session:/im,
|
|
99
|
+
/^[ \t]*(?:\u{1F916} ?)?(?:generated|made|built) (?:with|by) [[*]*claude code\b/imu,
|
|
100
|
+
];
|
|
63
101
|
/**
|
|
64
102
|
* Validate that a repository identifier matches the "owner/repo" format.
|
|
65
103
|
* Returns the identifier if valid, throws if invalid.
|
|
@@ -54,6 +54,16 @@ const ANY_CHECKBOX_RE = /^.*- \[[ x]\].*$/i;
|
|
|
54
54
|
* where exactly one option should be selected. (#1718)
|
|
55
55
|
*/
|
|
56
56
|
const TYPE_OF_CHANGE_RE = /type\s+of\s+change|kind\s+of\s+change|category/i;
|
|
57
|
+
/**
|
|
58
|
+
* Matches headings whose first checkbox run is a pick-one semver choice
|
|
59
|
+
* (Patch / Minor / Major) even without a pick-one comment (#1853). Only that
|
|
60
|
+
* first run is exempt; later boxes in the section still count.
|
|
61
|
+
*/
|
|
62
|
+
const RELEASE_IMPACT_HEADING_RE = /\brelease\s+impact\b|\bsemver\b|\bversion\s+bump\b/i;
|
|
63
|
+
/** A top-level box that opens with a semver option: "- [x] **Patch**: ...". */
|
|
64
|
+
const SEMVER_OPTION_RE = /^- \[[ x]\]\s*(?:\*\*)?(?:patch|minor|major|none)\b/i;
|
|
65
|
+
/** An indented line that wraps the checkbox line above it. */
|
|
66
|
+
const CONTINUATION_RE = /^\s+\S/;
|
|
57
67
|
/**
|
|
58
68
|
* Split a PR body into sections delimited by markdown headings.
|
|
59
69
|
* Content before the first heading is returned as a section with heading = null.
|
|
@@ -158,6 +168,27 @@ function collectRunExemptLineIndices(lines) {
|
|
|
158
168
|
}
|
|
159
169
|
return exempt;
|
|
160
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Semver pick-one run under a release-impact heading (#1853): the semver option
|
|
173
|
+
* boxes that open the section's first checkbox run, past blank and indented
|
|
174
|
+
* wrap lines. Any other line ends the run, and a first box that is not a semver
|
|
175
|
+
* option exempts nothing, so ordinary required boxes under the heading count.
|
|
176
|
+
*/
|
|
177
|
+
function markFirstRunPickOneExempt(lines, exempt) {
|
|
178
|
+
const runStart = lines.findIndex((l) => ANY_CHECKBOX_RE.test(l));
|
|
179
|
+
if (runStart === -1 || !SEMVER_OPTION_RE.test(lines[runStart]))
|
|
180
|
+
return;
|
|
181
|
+
let runEnd = runStart + 1;
|
|
182
|
+
for (let j = runEnd; j < lines.length; j++) {
|
|
183
|
+
const line = lines[j];
|
|
184
|
+
const isOption = SEMVER_OPTION_RE.test(line);
|
|
185
|
+
if (isOption)
|
|
186
|
+
runEnd = j + 1;
|
|
187
|
+
if (!isOption && (ANY_CHECKBOX_RE.test(line) || (line.trim() !== '' && !CONTINUATION_RE.test(line))))
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
markPickOneRunExempt(lines, runStart, runEnd, exempt);
|
|
191
|
+
}
|
|
161
192
|
/**
|
|
162
193
|
* Analyze a single checkbox section and return its effective counts.
|
|
163
194
|
* Returns null if the section should be entirely skipped.
|
|
@@ -177,6 +208,9 @@ function analyzeSectionItems(section) {
|
|
|
177
208
|
return { checked, nonConditionalUnchecked: 0 };
|
|
178
209
|
// Pick-one groups (#1760) and runs under a conditional lead-in line (#1796).
|
|
179
210
|
const runExempt = collectRunExemptLineIndices(section.lines);
|
|
211
|
+
if (section.heading !== null && RELEASE_IMPACT_HEADING_RE.test(section.heading)) {
|
|
212
|
+
markFirstRunPickOneExempt(section.lines, runExempt);
|
|
213
|
+
}
|
|
180
214
|
const nonConditionalUnchecked = section.lines.filter((l, idx) => /^.*- \[ \].*$/.test(l) && !isConditionalChecklistItem(l) && !runExempt.has(idx));
|
|
181
215
|
return { checked, nonConditionalUnchecked: nonConditionalUnchecked.length };
|
|
182
216
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status updates for issues whose PR closed without merge (#1863).
|
|
3
|
+
*
|
|
4
|
+
* When the user closes their own PR unmerged, the write-up usually stays in
|
|
5
|
+
* the PR thread while the linked issue still shows their "I'll work on this"
|
|
6
|
+
* as the latest word. The daily run turns such closes into a one-off nudge:
|
|
7
|
+
* draft a short status comment on the linked issue (the user posts it
|
|
8
|
+
* themselves) and release the local claim so the issue re-enters the
|
|
9
|
+
* commented-issue monitor instead of reading as in progress.
|
|
10
|
+
*
|
|
11
|
+
* Pure selection logic lives here: which recently closed PRs still have a
|
|
12
|
+
* live successor, which fall outside the window, and which link the same
|
|
13
|
+
* issue. Everything that needs GitHub (who closed the PR, whether the user
|
|
14
|
+
* has commented since) sits in `PRMonitor.fetchPRClosedBy` and
|
|
15
|
+
* `IssueConversationMonitor.hasUserCommentSince`, orchestrated by daily.ts.
|
|
16
|
+
*
|
|
17
|
+
* URLs are compared through `issueRefKey`, so `Org/Repo` and `org/repo`,
|
|
18
|
+
* trailing slashes and `#fragment`s all name the same issue.
|
|
19
|
+
*/
|
|
20
|
+
import type { ClosedPR } from './types.js';
|
|
21
|
+
/**
|
|
22
|
+
* How long after the close a PR may prompt a status update. Matches the
|
|
23
|
+
* default lookback of `PRMonitor.fetchRecentlyClosedPRs`; re-checked here
|
|
24
|
+
* because that search is bounded on `updated`, not on the close date.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CLOSED_PR_STATUS_WINDOW_DAYS = 7;
|
|
27
|
+
/** One closed-unmerged PR whose linked issue still needs a status update. */
|
|
28
|
+
export interface ClosedPRStatusUpdate {
|
|
29
|
+
/** The PR that closed without merge; its closing comment seeds the draft. */
|
|
30
|
+
prUrl: string;
|
|
31
|
+
/** Issue the PR claimed to close, parsed from its body. */
|
|
32
|
+
issueUrl: string;
|
|
33
|
+
/** When the PR closed; the status comment must land after this. */
|
|
34
|
+
closedAt: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Any PR of the user's that may supersede a closed one: open PRs
|
|
38
|
+
* (`FetchedPR`, which also carry `mentionedIssueUrls`), recently merged PRs,
|
|
39
|
+
* or merged-ledger entries (issue link only).
|
|
40
|
+
*/
|
|
41
|
+
export interface IssueLinkedPR {
|
|
42
|
+
url: string;
|
|
43
|
+
/** Issue the PR closes via a closing keyword. */
|
|
44
|
+
issueUrl?: string;
|
|
45
|
+
/** Every issue/PR the title and body mention, keyword or not (open PRs only). */
|
|
46
|
+
mentionedIssueUrls?: readonly string[];
|
|
47
|
+
}
|
|
48
|
+
/** A recently closed PR with a parsed issue link. */
|
|
49
|
+
export type ClosedPRStatusCandidate = ClosedPR & {
|
|
50
|
+
issueUrl: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Pick the recently closed PRs that should prompt a status update.
|
|
54
|
+
*
|
|
55
|
+
* Drops, in this order:
|
|
56
|
+
* - PRs with no parsed issue link (nothing to update) or an issue URL that
|
|
57
|
+
* does not parse.
|
|
58
|
+
* - PRs whose `closedAt` is unparseable or older than
|
|
59
|
+
* {@link CLOSED_PR_STATUS_WINDOW_DAYS} relative to `now`. The search behind
|
|
60
|
+
* `recentlyClosedPRs` is bounded on `updated`, so a stale close that just
|
|
61
|
+
* got a comment can come back.
|
|
62
|
+
* - Superseded PRs: another of the user's PRs in `otherPRs` closes the same
|
|
63
|
+
* issue, or mentions the issue or the closed PR anywhere in its title or
|
|
64
|
+
* body (`#N`, `owner/repo#N`, or the URL). The issue thread then already
|
|
65
|
+
* has a live successor and the claim stays. Superseding is the safe
|
|
66
|
+
* direction, so any mention counts, closing keyword or not.
|
|
67
|
+
*
|
|
68
|
+
* When several closed PRs link the same issue, only the latest close
|
|
69
|
+
* survives so the user is asked about each issue once.
|
|
70
|
+
*/
|
|
71
|
+
export declare function selectClosedPRStatusCandidates(recentlyClosedPRs: readonly ClosedPR[], otherPRs: readonly IssueLinkedPR[], now?: Date): ClosedPRStatusCandidate[];
|
|
72
|
+
/** Project a candidate onto the digest shape. */
|
|
73
|
+
export declare function toClosedPRStatusUpdate(pr: ClosedPRStatusCandidate): ClosedPRStatusUpdate;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status updates for issues whose PR closed without merge (#1863).
|
|
3
|
+
*
|
|
4
|
+
* When the user closes their own PR unmerged, the write-up usually stays in
|
|
5
|
+
* the PR thread while the linked issue still shows their "I'll work on this"
|
|
6
|
+
* as the latest word. The daily run turns such closes into a one-off nudge:
|
|
7
|
+
* draft a short status comment on the linked issue (the user posts it
|
|
8
|
+
* themselves) and release the local claim so the issue re-enters the
|
|
9
|
+
* commented-issue monitor instead of reading as in progress.
|
|
10
|
+
*
|
|
11
|
+
* Pure selection logic lives here: which recently closed PRs still have a
|
|
12
|
+
* live successor, which fall outside the window, and which link the same
|
|
13
|
+
* issue. Everything that needs GitHub (who closed the PR, whether the user
|
|
14
|
+
* has commented since) sits in `PRMonitor.fetchPRClosedBy` and
|
|
15
|
+
* `IssueConversationMonitor.hasUserCommentSince`, orchestrated by daily.ts.
|
|
16
|
+
*
|
|
17
|
+
* URLs are compared through `issueRefKey`, so `Org/Repo` and `org/repo`,
|
|
18
|
+
* trailing slashes and `#fragment`s all name the same issue.
|
|
19
|
+
*/
|
|
20
|
+
import { issueRefKey } from './urls.js';
|
|
21
|
+
import { debug } from './logger.js';
|
|
22
|
+
const MODULE = 'closed-pr-status';
|
|
23
|
+
/**
|
|
24
|
+
* How long after the close a PR may prompt a status update. Matches the
|
|
25
|
+
* default lookback of `PRMonitor.fetchRecentlyClosedPRs`; re-checked here
|
|
26
|
+
* because that search is bounded on `updated`, not on the close date.
|
|
27
|
+
*/
|
|
28
|
+
export const CLOSED_PR_STATUS_WINDOW_DAYS = 7;
|
|
29
|
+
const WINDOW_MS = CLOSED_PR_STATUS_WINDOW_DAYS * 24 * 60 * 60 * 1000;
|
|
30
|
+
function toSuccessor(other) {
|
|
31
|
+
const keys = new Set();
|
|
32
|
+
const closes = other.issueUrl && issueRefKey(other.issueUrl);
|
|
33
|
+
if (closes)
|
|
34
|
+
keys.add(closes);
|
|
35
|
+
if (other.mentionedIssueUrls) {
|
|
36
|
+
for (const mention of other.mentionedIssueUrls) {
|
|
37
|
+
const key = issueRefKey(mention);
|
|
38
|
+
if (key)
|
|
39
|
+
keys.add(key);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { url: other.url, selfKey: issueRefKey(other.url) ?? other.url, keys };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The normalized issue key a closed PR should be nudged about, or null when
|
|
46
|
+
* it should be left alone (reason debug-logged). See
|
|
47
|
+
* {@link selectClosedPRStatusCandidates} for the rules.
|
|
48
|
+
*/
|
|
49
|
+
function eligibleIssueKey(pr, successors, nowMs) {
|
|
50
|
+
if (pr.issueUrl === undefined)
|
|
51
|
+
return null;
|
|
52
|
+
const issueKey = issueRefKey(pr.issueUrl);
|
|
53
|
+
if (!issueKey) {
|
|
54
|
+
debug(MODULE, `Skipping ${pr.url}: issue URL ${pr.issueUrl} does not parse`);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const closedMs = Date.parse(pr.closedAt);
|
|
58
|
+
if (Number.isNaN(closedMs)) {
|
|
59
|
+
debug(MODULE, `Skipping ${pr.url}: closedAt ${JSON.stringify(pr.closedAt)} does not parse`);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (nowMs - closedMs > WINDOW_MS) {
|
|
63
|
+
debug(MODULE, `Skipping ${pr.url}: closed ${pr.closedAt}, outside the ${CLOSED_PR_STATUS_WINDOW_DAYS}-day window`);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const prKey = issueRefKey(pr.url);
|
|
67
|
+
const selfKey = prKey ?? pr.url;
|
|
68
|
+
const wanted = prKey === null ? [issueKey] : [issueKey, prKey];
|
|
69
|
+
const successor = successors.find((other) => other.selfKey !== selfKey && wanted.some((key) => other.keys.has(key)));
|
|
70
|
+
if (successor) {
|
|
71
|
+
debug(MODULE, `Skipping ${pr.url}: superseded by ${successor.url}`);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return issueKey;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Pick the recently closed PRs that should prompt a status update.
|
|
78
|
+
*
|
|
79
|
+
* Drops, in this order:
|
|
80
|
+
* - PRs with no parsed issue link (nothing to update) or an issue URL that
|
|
81
|
+
* does not parse.
|
|
82
|
+
* - PRs whose `closedAt` is unparseable or older than
|
|
83
|
+
* {@link CLOSED_PR_STATUS_WINDOW_DAYS} relative to `now`. The search behind
|
|
84
|
+
* `recentlyClosedPRs` is bounded on `updated`, so a stale close that just
|
|
85
|
+
* got a comment can come back.
|
|
86
|
+
* - Superseded PRs: another of the user's PRs in `otherPRs` closes the same
|
|
87
|
+
* issue, or mentions the issue or the closed PR anywhere in its title or
|
|
88
|
+
* body (`#N`, `owner/repo#N`, or the URL). The issue thread then already
|
|
89
|
+
* has a live successor and the claim stays. Superseding is the safe
|
|
90
|
+
* direction, so any mention counts, closing keyword or not.
|
|
91
|
+
*
|
|
92
|
+
* When several closed PRs link the same issue, only the latest close
|
|
93
|
+
* survives so the user is asked about each issue once.
|
|
94
|
+
*/
|
|
95
|
+
export function selectClosedPRStatusCandidates(recentlyClosedPRs, otherPRs, now = new Date()) {
|
|
96
|
+
const successors = otherPRs.map((other) => toSuccessor(other));
|
|
97
|
+
const nowMs = now.getTime();
|
|
98
|
+
const latestPerIssue = new Map();
|
|
99
|
+
for (const pr of recentlyClosedPRs) {
|
|
100
|
+
const issueKey = eligibleIssueKey(pr, successors, nowMs);
|
|
101
|
+
if (issueKey === null)
|
|
102
|
+
continue;
|
|
103
|
+
const current = latestPerIssue.get(issueKey);
|
|
104
|
+
if (!current || Date.parse(pr.closedAt) > Date.parse(current.closedAt)) {
|
|
105
|
+
latestPerIssue.set(issueKey, pr);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return Array.from(latestPerIssue, ([, pr]) => pr);
|
|
109
|
+
}
|
|
110
|
+
/** Project a candidate onto the digest shape. */
|
|
111
|
+
export function toClosedPRStatusUpdate(pr) {
|
|
112
|
+
return { prUrl: pr.url, issueUrl: pr.issueUrl, closedAt: pr.closedAt };
|
|
113
|
+
}
|
|
@@ -15,7 +15,12 @@
|
|
|
15
15
|
* #1243 (strategy), #1252 (pr-quality-rubric), and #1264 (issue-effort /
|
|
16
16
|
* maintainer-hints).
|
|
17
17
|
*/
|
|
18
|
-
export type FeedbackCategory = 'code_request' | 'question' | 'explanation_request' | 'style_request' | 'design_discussion' | 'approval_with_nit' | 'formatting_complaint'
|
|
18
|
+
export type FeedbackCategory = 'code_request' | 'question' | 'explanation_request' | 'style_request' | 'design_discussion' | 'approval_with_nit' | 'formatting_complaint'
|
|
19
|
+
/**
|
|
20
|
+
* A maintainer comment whose main content is thanks or praise (not a polite
|
|
21
|
+
* opener on a request); always gets a short acknowledgment (#1852).
|
|
22
|
+
*/
|
|
23
|
+
| 'appreciation';
|
|
19
24
|
export interface FeedbackClassification {
|
|
20
25
|
category: FeedbackCategory;
|
|
21
26
|
/**
|
|
@@ -54,14 +59,16 @@ export interface CommentDecisionResult {
|
|
|
54
59
|
* - Skip the comment entirely when ALL of these are true:
|
|
55
60
|
* 1. Every piece of maintainer feedback that requested code changes
|
|
56
61
|
* has a corresponding code change.
|
|
57
|
-
* 2. No question was asked
|
|
62
|
+
* 2. No question was asked and no maintainer thanks or praise is
|
|
63
|
+
* waiting for an acknowledgment.
|
|
58
64
|
* 3. Nothing was intentionally left unchanged (a "yes the maintainer
|
|
59
65
|
* asked but I did not change it" item always needs explanation).
|
|
60
66
|
* 4. The diff makes the fix self-evident — modeled here as the
|
|
61
67
|
* `allRequestedChangesAddressed` flag the caller passes in.
|
|
62
68
|
*
|
|
63
69
|
* - Draft a comment if ANY of these are true:
|
|
64
|
-
* 1. The maintainer asked a question
|
|
70
|
+
* 1. The maintainer asked a question, or thanked or praised the
|
|
71
|
+
* contributor (#1852).
|
|
65
72
|
* 2. The feedback is conceptual or design-level (the diff alone
|
|
66
73
|
* cannot answer "why").
|
|
67
74
|
* 3. Something was intentionally left unchanged (`needsComment: true`
|
|
@@ -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
|
+
}
|