@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,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Daily Phase 3.8: review follow-ups on PRs the user reviewed (#1857).
|
|
3
|
+
*
|
|
4
|
+
* Kept out of daily.ts (file-size ceiling). Pure selection lives in
|
|
5
|
+
* core/reviewed-prs.ts; this module owns the search, the per-PR fetch, the
|
|
6
|
+
* compare call that turns `reviewedSha` into a range or a rebase flag, the
|
|
7
|
+
* dismiss check, the warnings, and the agent-facing fencing of excerpts.
|
|
8
|
+
*
|
|
9
|
+
* API cost per run: two searches (up to three pages each), then for the
|
|
10
|
+
* {@link REVIEWED_PR_MAX_PER_RUN} most recently updated reviewed PRs not
|
|
11
|
+
* already dismissed at or after their last update, five calls each (PR,
|
|
12
|
+
* comments, reviews, inline comments, commits) and, when the PR turns out
|
|
13
|
+
* actionable, the head moved and a range could be honest, one compare.
|
|
14
|
+
*/
|
|
15
|
+
import { getStateManager, scanReviewedPR, } from '../core/index.js';
|
|
16
|
+
import { isRateLimitOrAuthError } from '../core/errors.js';
|
|
17
|
+
import { DEFAULT_CONCURRENCY, runWorkerPool } from '../core/concurrency.js';
|
|
18
|
+
import { debug, warn } from '../core/logger.js';
|
|
19
|
+
import { wrapUntrustedContent } from '../core/untrusted-content.js';
|
|
20
|
+
import { describeError, httpStatusLabel, isGoneError, recordWarning } from './daily-warnings.js';
|
|
21
|
+
const MODULE = 'daily';
|
|
22
|
+
const OPERATION = 'review follow-ups';
|
|
23
|
+
/**
|
|
24
|
+
* Reviewed PRs enriched per run, most recently updated first (#1857). Five
|
|
25
|
+
* calls each, so this bounds the phase at roughly 250 calls plus compares;
|
|
26
|
+
* a reviewer with more open reviewed PRs than this sees one warning naming
|
|
27
|
+
* how many were left unchecked. The search result is sorted by `updated_at`
|
|
28
|
+
* across both searches and dismissed PRs are dropped before the cap, so the
|
|
29
|
+
* PRs left out are the ones nothing has happened on for longest.
|
|
30
|
+
*/
|
|
31
|
+
export const REVIEWED_PR_MAX_PER_RUN = 50;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the user declined this PR: its URL was dismissed at or after
|
|
34
|
+
* `activityAt` (the search's `updated_at` before the fetch, the newest
|
|
35
|
+
* qualifying commit or comment after the scan). Newer activity resurfaces
|
|
36
|
+
* the PR, same as merged-PR notes. An unreadable stamp fails open (the PR is
|
|
37
|
+
* listed) with a log line, matching the issue path's dismiss filter.
|
|
38
|
+
*/
|
|
39
|
+
function isDismissed(prUrl, activityAt, dismissedAt) {
|
|
40
|
+
if (dismissedAt === undefined)
|
|
41
|
+
return false;
|
|
42
|
+
const dismissedMs = Date.parse(dismissedAt);
|
|
43
|
+
const activityMs = Date.parse(activityAt);
|
|
44
|
+
if (Number.isNaN(dismissedMs) || Number.isNaN(activityMs)) {
|
|
45
|
+
warn(MODULE, `reviewed-prs: ${prUrl} has an unreadable dismiss (${JSON.stringify(dismissedAt)}) or activity (${JSON.stringify(activityAt)}) timestamp; listing`);
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (dismissedMs >= activityMs) {
|
|
49
|
+
debug(MODULE, `reviewed-prs: ${prUrl} dismissed at ${dismissedAt}, after latest activity ${activityAt}; skipping`);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The dismiss check after the scan, in two modes.
|
|
56
|
+
*
|
|
57
|
+
* With a recorded head (`dismiss <pr-url> --head <sha>`, what the workflow's
|
|
58
|
+
* "skip" passes): the head is the push signal. A different head means the
|
|
59
|
+
* author pushed since the dismiss, so the PR is listed; the same head means
|
|
60
|
+
* the commit list is what the user saw when dismissing, so only a qualifying
|
|
61
|
+
* comment posted after the stamp (`latestCommentAt`) brings it back. Bot,
|
|
62
|
+
* label and bystander updates move the search's `updated_at` but neither of
|
|
63
|
+
* these, so they no longer resurface a skipped PR.
|
|
64
|
+
*
|
|
65
|
+
* Without one (a dismiss made before heads were recorded, or by hand): the
|
|
66
|
+
* stamp is all there is. Comment dates are when the comment was posted, so
|
|
67
|
+
* `latestActivityAt` settles a comments-only follow-up. Commit dates say when
|
|
68
|
+
* a commit was written, not when it was pushed, so a commit the scan found
|
|
69
|
+
* after the reviewed one (cherry-pick, rebased fix) can carry a date before
|
|
70
|
+
* the dismiss and would hide a push that happened after it. When any listed
|
|
71
|
+
* commit is dated at or before the stamp, the search's `updated_at`, which
|
|
72
|
+
* does move on push, stands in for the activity time; since every commit the
|
|
73
|
+
* user saw when dismissing is dated before the stamp too, a follow-up with
|
|
74
|
+
* commits is then hidden only by the pre-fetch `updated_at` check, which errs
|
|
75
|
+
* toward showing the PR again rather than missing a push.
|
|
76
|
+
*/
|
|
77
|
+
function isEntryDismissed(pr, entry, dismissedAt, dismissedHead) {
|
|
78
|
+
if (dismissedAt === undefined)
|
|
79
|
+
return false;
|
|
80
|
+
if (dismissedHead !== undefined) {
|
|
81
|
+
if (entry.headSha !== dismissedHead) {
|
|
82
|
+
debug(MODULE, `reviewed-prs: ${pr.url} head moved since the dismiss (${dismissedHead.slice(0, 7)}); listing`);
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (entry.latestCommentAt === undefined) {
|
|
86
|
+
debug(MODULE, `reviewed-prs: ${pr.url} dismissed at head ${dismissedHead.slice(0, 7)}, no comment since; skipping`);
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return isDismissed(pr.url, entry.latestCommentAt, dismissedAt);
|
|
90
|
+
}
|
|
91
|
+
const dismissedMs = Date.parse(dismissedAt);
|
|
92
|
+
const hasCommitDatedBeforeStamp = entry.commits.some((commit) => Date.parse(commit.date) <= dismissedMs);
|
|
93
|
+
return isDismissed(pr.url, hasCommitDatedBeforeStamp ? pr.updatedAt : entry.latestActivityAt, dismissedAt);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Fetch one PR's activity, turning a failure into a warning that names the
|
|
97
|
+
* PR and its HTTP status. Returns undefined when the PR is dropped for this
|
|
98
|
+
* run: on a fetch error, or when any list hit the pagination cap (the cap
|
|
99
|
+
* cuts the newest items, which is where the author's reply and the user's
|
|
100
|
+
* own re-review would be). Rate-limit/auth errors propagate.
|
|
101
|
+
*/
|
|
102
|
+
async function fetchActivity(source, pr, warnings) {
|
|
103
|
+
const operation = `fetch activity on ${pr.url}`;
|
|
104
|
+
let activity;
|
|
105
|
+
try {
|
|
106
|
+
activity = await source.fetchReviewedPRActivity(pr.url);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (isRateLimitOrAuthError(error))
|
|
110
|
+
throw error;
|
|
111
|
+
const detail = isGoneError(error)
|
|
112
|
+
? `PR no longer reachable (${httpStatusLabel(error)}); dropped`
|
|
113
|
+
: `${describeError(error)}; dropped`;
|
|
114
|
+
recordWarning(warnings, 'reviewed-prs', operation, error, detail);
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
if (activity.truncatedLists.length > 0) {
|
|
118
|
+
recordWarning(warnings, 'reviewed-prs', operation, null, `pagination cap reached on ${activity.truncatedLists.join(', ')}; the newest activity (including any re-review of yours) may be missing; dropped`);
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
return activity;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Fill in `compareRange` / `compareUrl` or `rebased` from GitHub's compare
|
|
125
|
+
* status. No call when the head is where the review left it (comments
|
|
126
|
+
* only), when the reviewed commit could not be named (plain comment), or
|
|
127
|
+
* when the scan already ruled a range out from the commit list (`rebased`:
|
|
128
|
+
* the reviewed commit is gone; `mergedUpstream`: upstream was merged in
|
|
129
|
+
* after it; `baseUnknown`: the reviewed commit's place in the list is
|
|
130
|
+
* unknown). On an error other than 404 (which `fetchCompareStatus` maps to
|
|
131
|
+
* `missing`) the entry keeps neither range nor flag, with a warning: an
|
|
132
|
+
* unverified range could be wrong, and the commit list is still there.
|
|
133
|
+
* Rate-limit/auth errors propagate.
|
|
134
|
+
*/
|
|
135
|
+
async function resolveCompare(source, entry, warnings) {
|
|
136
|
+
if (entry.reviewedSha === undefined || entry.reviewedSha === entry.headSha)
|
|
137
|
+
return;
|
|
138
|
+
if (entry.rebased || entry.mergedUpstream || entry.baseUnknown)
|
|
139
|
+
return;
|
|
140
|
+
let status;
|
|
141
|
+
try {
|
|
142
|
+
status = await source.fetchCompareStatus(entry.prUrl, entry.reviewedSha, entry.headSha);
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
if (isRateLimitOrAuthError(error))
|
|
146
|
+
throw error;
|
|
147
|
+
recordWarning(warnings, 'reviewed-prs', `compare ${entry.reviewedSha.slice(0, 7)}...${entry.headSha.slice(0, 7)} on ${entry.prUrl}`, error, `${describeError(error)}; cannot tell whether the branch was rebased, showing the commit list only`);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (status === 'ahead' || status === 'identical') {
|
|
151
|
+
entry.compareRange = `${entry.reviewedSha}...${entry.headSha}`;
|
|
152
|
+
entry.compareUrl = `${entry.prUrl.replace(/\/pull\/\d+$/, '')}/compare/${entry.compareRange}`;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
debug(MODULE, `reviewed-prs: ${entry.prUrl} compare status ${status}; flagging as rebased`);
|
|
156
|
+
entry.rebased = true;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Search for the open PRs the user reviewed or commented on but did not
|
|
160
|
+
* author, fetch each one's thread, and keep the PRs where the author has
|
|
161
|
+
* moved things since the user's last review or comment (`scanReviewedPR`):
|
|
162
|
+
* commits pushed, a reply from the author, or a comment addressed to the
|
|
163
|
+
* user. For each kept PR whose head moved and whose commit list did not
|
|
164
|
+
* already rule a range out, ask GitHub whether the reviewed commit is still
|
|
165
|
+
* an ancestor of the head: if so the entry carries the compare range, if
|
|
166
|
+
* not it is flagged `rebased` and carries the commit list instead.
|
|
167
|
+
*
|
|
168
|
+
* "Only once": nothing is written to state. An entry disappears when the
|
|
169
|
+
* user comments or reviews again (their last word moves past the activity),
|
|
170
|
+
* when they dismiss the PR URL (the workflow's "skip" runs the existing
|
|
171
|
+
* `dismiss` with the entry's `headSha`, so the PR stays hidden until a new
|
|
172
|
+
* push or a comment after the dismiss; see `isEntryDismissed`), and when
|
|
173
|
+
* the PR closes or merges. A PR dismissed at or after its search
|
|
174
|
+
* `updated_at` is skipped before any per-PR call, and the dismiss filter
|
|
175
|
+
* runs before the per-run cap so dismissed PRs do not use up its slots.
|
|
176
|
+
*
|
|
177
|
+
* Never counted toward capacity or `needsAddressingPRs`: these are other
|
|
178
|
+
* people's PRs.
|
|
179
|
+
*
|
|
180
|
+
* Non-fatal: a per-PR failure (fetch error, pagination cap, an error while
|
|
181
|
+
* reading the thread, or a failed compare) drops or degrades that PR with a
|
|
182
|
+
* `reviewed-prs` warning naming it; rate-limit/auth errors propagate like
|
|
183
|
+
* every other phase's.
|
|
184
|
+
*/
|
|
185
|
+
async function prepareReviewedPRs(source, warnings) {
|
|
186
|
+
const stateManager = getStateManager();
|
|
187
|
+
const username = stateManager.getState().config.githubUsername;
|
|
188
|
+
if (!username) {
|
|
189
|
+
recordWarning(warnings, 'reviewed-prs', OPERATION, null, 'skipped: no GitHub username configured');
|
|
190
|
+
return [];
|
|
191
|
+
}
|
|
192
|
+
const search = await source.fetchReviewedOpenPRs();
|
|
193
|
+
for (const message of search.warnings) {
|
|
194
|
+
recordWarning(warnings, 'reviewed-prs', 'search reviewed PRs (incomplete)', null, message);
|
|
195
|
+
}
|
|
196
|
+
const notDismissed = search.prs.filter((pr) => !isDismissed(pr.url, pr.updatedAt, stateManager.getIssueDismissedAt(pr.url)));
|
|
197
|
+
const candidates = notDismissed.slice(0, REVIEWED_PR_MAX_PER_RUN);
|
|
198
|
+
if (notDismissed.length > candidates.length) {
|
|
199
|
+
recordWarning(warnings, 'reviewed-prs', OPERATION, null, `${notDismissed.length - candidates.length} reviewed PR(s) beyond the per-run cap of ${REVIEWED_PR_MAX_PER_RUN} were not checked (the least recently updated); dismiss or re-review stale ones to make room`);
|
|
200
|
+
}
|
|
201
|
+
if (candidates.length === 0)
|
|
202
|
+
return [];
|
|
203
|
+
// Keyed by PR so the output keeps the search order however the workers finish.
|
|
204
|
+
const pending = new Map();
|
|
205
|
+
await runWorkerPool(candidates, async (pr) => {
|
|
206
|
+
const activity = await fetchActivity(source, pr, warnings);
|
|
207
|
+
if (!activity)
|
|
208
|
+
return;
|
|
209
|
+
let entry;
|
|
210
|
+
try {
|
|
211
|
+
entry = scanReviewedPR(pr, activity, username);
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
if (isRateLimitOrAuthError(error))
|
|
215
|
+
throw error;
|
|
216
|
+
recordWarning(warnings, 'reviewed-prs', `read activity on ${pr.url}`, error, `${describeError(error)}; dropped`);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (!entry)
|
|
220
|
+
return;
|
|
221
|
+
if (isEntryDismissed(pr, entry, stateManager.getIssueDismissedAt(pr.url), stateManager.getDismissedPRHead(pr.url)))
|
|
222
|
+
return;
|
|
223
|
+
await resolveCompare(source, entry, warnings);
|
|
224
|
+
pending.set(pr, entry);
|
|
225
|
+
}, DEFAULT_CONCURRENCY);
|
|
226
|
+
const ordered = [];
|
|
227
|
+
for (const pr of candidates) {
|
|
228
|
+
const entry = pending.get(pr);
|
|
229
|
+
if (entry)
|
|
230
|
+
ordered.push(entry);
|
|
231
|
+
}
|
|
232
|
+
return ordered;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Phase 3.8 entry point: runs {@link prepareReviewedPRs} and turns any
|
|
236
|
+
* non-fatal failure (including a failed search) into a `reviewed-prs`
|
|
237
|
+
* warning plus an empty list. Rate-limit/auth errors end the run like every
|
|
238
|
+
* other phase's.
|
|
239
|
+
*/
|
|
240
|
+
export async function runReviewedPRsPhase(source, warnings) {
|
|
241
|
+
try {
|
|
242
|
+
return await prepareReviewedPRs(source, warnings);
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
if (isRateLimitOrAuthError(error))
|
|
246
|
+
throw error;
|
|
247
|
+
recordWarning(warnings, 'reviewed-prs', `prepare ${OPERATION}`, error, describeError(error));
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Fence the GitHub-sourced text for agent-facing JSON (#1372), at the same
|
|
253
|
+
* boundary as daily.ts's `fenceCommentedIssue`: question excerpts and commit
|
|
254
|
+
* subjects. The internal result keeps raw text for the text renderer and
|
|
255
|
+
* tests.
|
|
256
|
+
*/
|
|
257
|
+
export function fenceReviewedPR(entry) {
|
|
258
|
+
const label = `${entry.repo}#${entry.number}`;
|
|
259
|
+
return {
|
|
260
|
+
...entry,
|
|
261
|
+
questions: entry.questions.map((question) => ({
|
|
262
|
+
...question,
|
|
263
|
+
excerpt: wrapUntrustedContent(question.excerpt, label, { author: question.author, source: 'pr-comment' }),
|
|
264
|
+
})),
|
|
265
|
+
commits: entry.commits.map((commit) => ({
|
|
266
|
+
...commit,
|
|
267
|
+
subject: wrapUntrustedContent(commit.subject, label, { author: commit.author, source: 'pr-commit' }),
|
|
268
|
+
})),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-fatal warning helpers shared by the daily phases (#1042). Split out of
|
|
3
|
+
* daily.ts so the per-phase modules (closed-PR status, merged-PR notes) can
|
|
4
|
+
* record warnings the same way without importing the orchestrator.
|
|
5
|
+
*/
|
|
6
|
+
import type { DailyWarning, DailyWarningPhase } from '../formatters/json.js';
|
|
7
|
+
/** Defined in core/errors.ts so core modules can word their own warnings the same way. */
|
|
8
|
+
export { describeError, httpStatusLabel } from '../core/errors.js';
|
|
9
|
+
/**
|
|
10
|
+
* Record a non-fatal failure: push a structured entry into the run's warnings
|
|
11
|
+
* collector AND emit the existing log line. Consumers (dashboard, MCP, tests)
|
|
12
|
+
* inspect `DailyOutput.warnings` so a partial run is visible beyond log noise.
|
|
13
|
+
* See #1042.
|
|
14
|
+
*/
|
|
15
|
+
export declare function recordWarning(warnings: DailyWarning[], phase: DailyWarningPhase, operation: string, err: unknown, humanMessage?: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Variant of `nonFatalCatch` that also records a structured warning. Returns
|
|
18
|
+
* the fallback value on error (same semantics as `nonFatalCatch`) AND pushes
|
|
19
|
+
* an entry into the collector so the failure shows up in `DailyOutput.warnings`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function nonFatalCatchWithWarning<T>(opts: {
|
|
22
|
+
warnings: DailyWarning[];
|
|
23
|
+
phase: DailyWarningPhase;
|
|
24
|
+
operation: string;
|
|
25
|
+
fallback: T;
|
|
26
|
+
}): (err: unknown) => T;
|
|
27
|
+
/** 404/410: the issue or PR is gone (deleted, transferred, or now private). */
|
|
28
|
+
export declare function isGoneError(error: unknown): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-fatal warning helpers shared by the daily phases (#1042). Split out of
|
|
3
|
+
* daily.ts so the per-phase modules (closed-PR status, merged-PR notes) can
|
|
4
|
+
* record warnings the same way without importing the orchestrator.
|
|
5
|
+
*/
|
|
6
|
+
import { errorMessage, getHttpStatusCode } from '../core/errors.js';
|
|
7
|
+
import { warn } from '../core/logger.js';
|
|
8
|
+
/** Defined in core/errors.ts so core modules can word their own warnings the same way. */
|
|
9
|
+
export { describeError, httpStatusLabel } from '../core/errors.js';
|
|
10
|
+
const MODULE = 'daily';
|
|
11
|
+
/**
|
|
12
|
+
* Record a non-fatal failure: push a structured entry into the run's warnings
|
|
13
|
+
* collector AND emit the existing log line. Consumers (dashboard, MCP, tests)
|
|
14
|
+
* inspect `DailyOutput.warnings` so a partial run is visible beyond log noise.
|
|
15
|
+
* See #1042.
|
|
16
|
+
*/
|
|
17
|
+
export function recordWarning(warnings, phase, operation, err, humanMessage) {
|
|
18
|
+
const message = humanMessage ?? errorMessage(err);
|
|
19
|
+
warnings.push({ phase, operation, message });
|
|
20
|
+
warn(MODULE, `${operation}: ${message}`);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Variant of `nonFatalCatch` that also records a structured warning. Returns
|
|
24
|
+
* the fallback value on error (same semantics as `nonFatalCatch`) AND pushes
|
|
25
|
+
* an entry into the collector so the failure shows up in `DailyOutput.warnings`.
|
|
26
|
+
*/
|
|
27
|
+
export function nonFatalCatchWithWarning(opts) {
|
|
28
|
+
return (err) => {
|
|
29
|
+
recordWarning(opts.warnings, opts.phase, opts.operation, err);
|
|
30
|
+
return opts.fallback;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** 404/410: the issue or PR is gone (deleted, transferred, or now private). */
|
|
34
|
+
export function isGoneError(error) {
|
|
35
|
+
const status = getHttpStatusCode(error);
|
|
36
|
+
return status === 404 || status === 410;
|
|
37
|
+
}
|
package/dist/commands/daily.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Domain logic lives in src/core/daily-logic.ts; this file is a thin
|
|
7
7
|
* orchestration layer that wires up the phases and handles I/O.
|
|
8
8
|
*/
|
|
9
|
-
import { type AttentionSummary, type DailyDigest, type CommentedIssue, type PRCheckFailure, type RepoGroup } from '../core/index.js';
|
|
9
|
+
import { type ClosedPRStatusUpdate, type MergedPRNotes, type ReviewedPRFollowUp, type AttentionSummary, type DailyDigest, type CommentedIssue, type PRCheckFailure, type RepoGroup } from '../core/index.js';
|
|
10
10
|
import { type StrategyResult } from '../core/strategy.js';
|
|
11
11
|
import { type DailyOutput, type DailyWarning, type CapacityAssessment, type ActionableIssue, type ActionMenu, type MergedPRListUpdate, type PendingLearnings } from '../formatters/json.js';
|
|
12
12
|
export { applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, formatBriefSummary, formatSummary, printDigest, CRITICAL_STATUSES, } from '../core/index.js';
|
|
@@ -49,6 +49,25 @@ export interface DailyCheckResult {
|
|
|
49
49
|
* absent, so goldens and merge-free runs are unchanged.
|
|
50
50
|
*/
|
|
51
51
|
pendingLearnings?: PendingLearnings;
|
|
52
|
+
/**
|
|
53
|
+
* Closed-unmerged PRs whose linked issue still needs a status update from
|
|
54
|
+
* the user (#1863). Set only when at least one exists; see
|
|
55
|
+
* {@link DailyOutput.closedPRStatusUpdates}.
|
|
56
|
+
*/
|
|
57
|
+
closedPRStatusUpdates?: ClosedPRStatusUpdate[];
|
|
58
|
+
/**
|
|
59
|
+
* Recently merged PRs with maintainer notes the user has not answered
|
|
60
|
+
* (#1861). Set only when at least one exists; see
|
|
61
|
+
* {@link DailyOutput.mergedPRNotes}. Raw excerpts here; `toDailyOutput`
|
|
62
|
+
* fences them.
|
|
63
|
+
*/
|
|
64
|
+
mergedPRNotes?: MergedPRNotes[];
|
|
65
|
+
/**
|
|
66
|
+
* PRs the user reviewed where the author pushed or replied since (#1857).
|
|
67
|
+
* Set only when at least one exists; see {@link DailyOutput.reviewedPRs}.
|
|
68
|
+
* Raw excerpts here; `toDailyOutput` fences them.
|
|
69
|
+
*/
|
|
70
|
+
reviewedPRs?: ReviewedPRFollowUp[];
|
|
52
71
|
}
|
|
53
72
|
/**
|
|
54
73
|
* Convert a full DailyCheckResult to the compact DailyOutput for JSON serialization (#287).
|
|
@@ -72,6 +91,8 @@ export declare function toDailyOutput(result: DailyCheckResult): DailyOutput;
|
|
|
72
91
|
* 3. updateAnalytics — store monthly chart data
|
|
73
92
|
* 4. partitionPRs — shelve/unshelve, generate digest
|
|
74
93
|
* 5. generateDigestOutput — capacity, dismiss filter, action menu assembly
|
|
94
|
+
* plus the read-only side phases 3.6 (closed-PR status), 3.7 (merged-PR
|
|
95
|
+
* notes) and 3.8 (review follow-ups on PRs the user reviewed, #1857).
|
|
75
96
|
*
|
|
76
97
|
* @param token - GitHub personal access token
|
|
77
98
|
* @returns Deduplicated daily output
|