@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.
Files changed (78) hide show
  1. package/dist/cli-registry.js +7 -4
  2. package/dist/cli.bundle.cjs +134 -127
  3. package/dist/commands/comments.js +4 -3
  4. package/dist/commands/config.js +18 -11
  5. package/dist/commands/daily-dismiss-filter.d.ts +37 -0
  6. package/dist/commands/daily-dismiss-filter.js +80 -0
  7. package/dist/commands/daily-merged-pr-notes.d.ts +27 -0
  8. package/dist/commands/daily-merged-pr-notes.js +166 -0
  9. package/dist/commands/daily-reviewed-prs.d.ts +41 -0
  10. package/dist/commands/daily-reviewed-prs.js +270 -0
  11. package/dist/commands/daily-warnings.d.ts +28 -0
  12. package/dist/commands/daily-warnings.js +37 -0
  13. package/dist/commands/daily.d.ts +22 -1
  14. package/dist/commands/daily.js +299 -108
  15. package/dist/commands/dashboard-cache.js +9 -2
  16. package/dist/commands/dashboard-data.js +40 -20
  17. package/dist/commands/dashboard-gist-sync.d.ts +9 -1
  18. package/dist/commands/dashboard-gist-sync.js +24 -3
  19. package/dist/commands/dashboard-server.js +9 -5
  20. package/dist/commands/dismiss.d.ts +25 -5
  21. package/dist/commands/dismiss.js +40 -11
  22. package/dist/commands/guidelines.js +21 -14
  23. package/dist/commands/init.js +3 -2
  24. package/dist/commands/ledger-backfill.js +4 -3
  25. package/dist/commands/move.js +9 -6
  26. package/dist/commands/overnight-push-prep.js +5 -2
  27. package/dist/commands/overnight.js +62 -24
  28. package/dist/commands/scout-bridge.js +4 -1
  29. package/dist/commands/search.js +9 -6
  30. package/dist/commands/setup.js +7 -3
  31. package/dist/commands/validation.d.ts +11 -0
  32. package/dist/commands/validation.js +38 -0
  33. package/dist/core/checklist-analysis.js +34 -0
  34. package/dist/core/closed-pr-status.d.ts +73 -0
  35. package/dist/core/closed-pr-status.js +113 -0
  36. package/dist/core/comment-decision.d.ts +10 -3
  37. package/dist/core/comment-decision.js +13 -5
  38. package/dist/core/comment-utils.d.ts +38 -1
  39. package/dist/core/comment-utils.js +124 -1
  40. package/dist/core/concurrency.d.ts +6 -0
  41. package/dist/core/concurrency.js +13 -0
  42. package/dist/core/daily-logic.d.ts +13 -1
  43. package/dist/core/daily-logic.js +59 -2
  44. package/dist/core/engaged-issues.d.ts +93 -0
  45. package/dist/core/engaged-issues.js +183 -0
  46. package/dist/core/errors.d.ts +4 -0
  47. package/dist/core/errors.js +11 -1
  48. package/dist/core/eval-report.d.ts +9 -0
  49. package/dist/core/eval-report.js +4 -0
  50. package/dist/core/gist-state-store.d.ts +5 -2
  51. package/dist/core/gist-state-store.js +7 -4
  52. package/dist/core/github-stats.d.ts +10 -0
  53. package/dist/core/github-stats.js +35 -0
  54. package/dist/core/index.d.ts +10 -5
  55. package/dist/core/index.js +9 -4
  56. package/dist/core/issue-conversation.d.ts +83 -12
  57. package/dist/core/issue-conversation.js +306 -118
  58. package/dist/core/merged-pr-notes.d.ts +192 -0
  59. package/dist/core/merged-pr-notes.js +340 -0
  60. package/dist/core/pick-snapshot.js +1 -1
  61. package/dist/core/pr-assembly.js +3 -0
  62. package/dist/core/pr-monitor.d.ts +62 -0
  63. package/dist/core/pr-monitor.js +113 -3
  64. package/dist/core/reviewed-prs-fetch.d.ts +91 -0
  65. package/dist/core/reviewed-prs-fetch.js +271 -0
  66. package/dist/core/reviewed-prs.d.ts +244 -0
  67. package/dist/core/reviewed-prs.js +380 -0
  68. package/dist/core/state-persistence.js +8 -24
  69. package/dist/core/state-schema.d.ts +6 -0
  70. package/dist/core/state-schema.js +9 -0
  71. package/dist/core/state.d.ts +106 -11
  72. package/dist/core/state.js +246 -24
  73. package/dist/core/types.d.ts +47 -0
  74. package/dist/core/urls.d.ts +13 -0
  75. package/dist/core/urls.js +16 -0
  76. package/dist/formatters/json.d.ts +186 -1
  77. package/dist/formatters/json.js +78 -0
  78. package/package.json +1 -1
@@ -245,7 +245,7 @@ export async function runClaim(options) {
245
245
  let stateSaveWarning;
246
246
  try {
247
247
  const stateManager = getStateManager();
248
- stateManager.addIssue({
248
+ const issue = {
249
249
  id: number,
250
250
  url: options.issueUrl,
251
251
  repo: `${owner}/${repo}`,
@@ -256,11 +256,12 @@ export async function runClaim(options) {
256
256
  createdAt: issueCreatedAt,
257
257
  updatedAt: new Date().toISOString(),
258
258
  vetted: false,
259
- });
259
+ };
260
+ stateManager.addIssue(issue);
260
261
  // Push state to Gist if in Gist mode. Best-effort — the warning is
261
262
  // threaded into the structured output so MCP/dashboard consumers see
262
263
  // the degraded-sync signal, not just the stderr log (#1036 audit H1, #1370).
263
- gistSyncWarning = await maybeCheckpoint(stateManager, MODULE);
264
+ gistSyncWarning = await maybeCheckpoint(stateManager, MODULE, () => stateManager.addIssue(issue));
264
265
  }
265
266
  catch (error) {
266
267
  // The claim comment is live on GitHub but local state never tracked it —
@@ -34,17 +34,29 @@ export async function runConfig(options) {
34
34
  return { keys: CONFIG_KEY_REGISTRY };
35
35
  }
36
36
  const stateManager = getStateManager();
37
- const currentConfig = stateManager.getState().config;
38
37
  if (!options.key) {
39
38
  // Show current config
40
- return { config: currentConfig };
39
+ return { config: stateManager.getState().config };
41
40
  }
42
41
  if (!options.value) {
43
42
  throw new Error('Value required');
44
43
  }
45
- const value = options.value;
46
- // Handle specific config keys
47
- switch (options.key) {
44
+ const { key, value } = options;
45
+ const apply = () => applyConfigKey(stateManager, key, value);
46
+ apply();
47
+ // Push the config mutation to the Gist in gist mode (no-op locally).
48
+ // Without this the change only hits the local cache and the next
49
+ // bootstrap reverts it from the Gist (#1440).
50
+ const gistSyncWarning = await maybeCheckpoint(stateManager, MODULE, apply);
51
+ return { success: true, key, value, ...(gistSyncWarning && { gistSyncWarning }) };
52
+ }
53
+ /**
54
+ * Apply one config key. Reads the current config fresh so the Gist conflict
55
+ * path can re-run it on a refreshed baseline without stale array merges.
56
+ */
57
+ function applyConfigKey(stateManager, key, value) {
58
+ const currentConfig = stateManager.getState().config;
59
+ switch (key) {
48
60
  case 'username': {
49
61
  stateManager.updateConfig({ githubUsername: validateGitHubUsername(value) });
50
62
  break;
@@ -177,12 +189,7 @@ export async function runConfig(options) {
177
189
  break;
178
190
  }
179
191
  default: {
180
- throw new ValidationError(formatUnknownKeyError(options.key, 'config'));
192
+ throw new ValidationError(formatUnknownKeyError(key, 'config'));
181
193
  }
182
194
  }
183
- // Push the config mutation to the Gist in gist mode (no-op locally).
184
- // Without this the change only hits the local cache and the next
185
- // bootstrap reverts it from the Gist (#1440).
186
- const gistSyncWarning = await maybeCheckpoint(stateManager, MODULE);
187
- return { success: true, key: options.key, value, ...(gistSyncWarning && { gistSyncWarning }) };
188
195
  }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The daily run's dismissed-issue filter and the fresh-baseline batch helper
3
+ * it persists through. Split out of daily.ts so the filter can be exercised
4
+ * against a real StateManager (dismiss, resurface, reload from disk) without
5
+ * mocking the whole daily pipeline.
6
+ */
7
+ import { getStateManager, type CommentedIssue } from '../core/index.js';
8
+ import type { DailyWarning } from '../formatters/json.js';
9
+ type StateManagerLike = Pick<ReturnType<typeof getStateManager>, 'reloadIfChanged' | 'batch' | 'getIssueDismissedAt' | 'undismissIssue'>;
10
+ /**
11
+ * Run a batch against a baseline that is fresh as of right now.
12
+ *
13
+ * A daily run spends tens of seconds on the network between loading state and
14
+ * each of its saves. If the dashboard, `move`, or another CLI call writes
15
+ * state.json in that time, the compare-and-swap in `saveState` rejects the
16
+ * save, and because the baseline never moved, every later batch in the run is
17
+ * rejected too: repo scores, analytics, the merged/closed ledger and lastDigest
18
+ * were all dropped, surfacing only as warnings. Reloading first picks up the
19
+ * other writer's change and shrinks the window to the batch itself.
20
+ *
21
+ * Only safe where the callback reads state live through the manager, as the
22
+ * batches in daily.ts do. A callback that writes from a snapshot taken
23
+ * earlier would overwrite the other writer's fields, which is why this is not
24
+ * done inside `StateManager.batch` for every caller.
25
+ */
26
+ export declare function batchOnFreshBaseline(stateManager: Pick<StateManagerLike, 'reloadIfChanged' | 'batch'>, fn: () => void): void;
27
+ /**
28
+ * Drop the commented issues the user dismissed, unless a reply newer than
29
+ * the dismiss arrived: that issue comes back and its dismiss record is
30
+ * removed, so the dashboard (which applies the same `isCoveredByDismiss`
31
+ * comparison, #1862) and the next run agree. Runs inside one fresh-baseline
32
+ * batch so every auto-undismiss lands in a single disk write; a persistence
33
+ * failure is recorded under the `dismiss-filter` phase and the issues are
34
+ * still returned.
35
+ */
36
+ export declare function filterDismissedIssues(stateManager: StateManagerLike, issues: CommentedIssue[], warnings: DailyWarning[]): CommentedIssue[];
37
+ export {};
@@ -0,0 +1,80 @@
1
+ /**
2
+ * The daily run's dismissed-issue filter and the fresh-baseline batch helper
3
+ * it persists through. Split out of daily.ts so the filter can be exercised
4
+ * against a real StateManager (dismiss, resurface, reload from disk) without
5
+ * mocking the whole daily pipeline.
6
+ */
7
+ import { isCoveredByDismiss } from '../core/index.js';
8
+ import { warn } from '../core/logger.js';
9
+ import { recordWarning } from './daily-warnings.js';
10
+ const MODULE = 'daily';
11
+ /**
12
+ * Run a batch against a baseline that is fresh as of right now.
13
+ *
14
+ * A daily run spends tens of seconds on the network between loading state and
15
+ * each of its saves. If the dashboard, `move`, or another CLI call writes
16
+ * state.json in that time, the compare-and-swap in `saveState` rejects the
17
+ * save, and because the baseline never moved, every later batch in the run is
18
+ * rejected too: repo scores, analytics, the merged/closed ledger and lastDigest
19
+ * were all dropped, surfacing only as warnings. Reloading first picks up the
20
+ * other writer's change and shrinks the window to the batch itself.
21
+ *
22
+ * Only safe where the callback reads state live through the manager, as the
23
+ * batches in daily.ts do. A callback that writes from a snapshot taken
24
+ * earlier would overwrite the other writer's fields, which is why this is not
25
+ * done inside `StateManager.batch` for every caller.
26
+ */
27
+ export function batchOnFreshBaseline(stateManager, fn) {
28
+ stateManager.reloadIfChanged();
29
+ stateManager.batch(fn);
30
+ }
31
+ /**
32
+ * Drop the commented issues the user dismissed, unless a reply newer than
33
+ * the dismiss arrived: that issue comes back and its dismiss record is
34
+ * removed, so the dashboard (which applies the same `isCoveredByDismiss`
35
+ * comparison, #1862) and the next run agree. Runs inside one fresh-baseline
36
+ * batch so every auto-undismiss lands in a single disk write; a persistence
37
+ * failure is recorded under the `dismiss-filter` phase and the issues are
38
+ * still returned.
39
+ */
40
+ export function filterDismissedIssues(stateManager, issues, warnings) {
41
+ let filtered = [];
42
+ try {
43
+ batchOnFreshBaseline(stateManager, () => {
44
+ filtered = issues.filter((issue) => shouldKeep(stateManager, issue, warnings));
45
+ });
46
+ }
47
+ catch (error) {
48
+ recordWarning(warnings, 'dismiss-filter', 'persist auto-undismiss state', error);
49
+ }
50
+ return filtered;
51
+ }
52
+ /** Whether `issue` stays in the digest; undismisses it when a newer reply arrived. */
53
+ function shouldKeep(stateManager, issue, warnings) {
54
+ const dismissedAt = stateManager.getIssueDismissedAt(issue.url);
55
+ if (!dismissedAt)
56
+ return true; // Not dismissed — include
57
+ if (issue.status !== 'new_response')
58
+ return false; // Still dismissed
59
+ if (Number.isNaN(Date.parse(issue.lastResponseAt)) || Number.isNaN(Date.parse(dismissedAt))) {
60
+ // Invalid timestamp — fail open (include issue to be safe) without
61
+ // permanently removing dismiss record (may be a transient data issue)
62
+ warn(MODULE, `Invalid timestamp in dismiss check for ${issue.url}, including issue`);
63
+ return true;
64
+ }
65
+ // Still dismissed when the last response is at or before the dismiss timestamp.
66
+ if (isCoveredByDismiss(dismissedAt, issue.lastResponseAt))
67
+ return false;
68
+ // New activity after dismiss — auto-undismiss and resurface
69
+ warn(MODULE, `Auto-undismissing issue ${issue.url}: new response at ${issue.lastResponseAt} after dismiss at ${dismissedAt}`);
70
+ undismissSafely(stateManager, issue.url, warnings);
71
+ return true;
72
+ }
73
+ function undismissSafely(stateManager, url, warnings) {
74
+ try {
75
+ stateManager.undismissIssue(url);
76
+ }
77
+ catch (error) {
78
+ recordWarning(warnings, 'dismiss-filter', `persist auto-undismiss for ${url}`, error);
79
+ }
80
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Daily Phase 3.7: maintainer notes on recently merged PRs (#1861).
3
+ *
4
+ * Kept out of daily.ts (file-size ceiling). Pure selection lives in
5
+ * core/merged-pr-notes.ts; this module owns the per-PR fetch, the dismiss
6
+ * check, the warnings, and the agent-facing fencing of note excerpts.
7
+ */
8
+ import { type PRMonitor, type MergedPR, type MergedPRNotes } from '../core/index.js';
9
+ import type { DailyWarning } from '../formatters/json.js';
10
+ /** What Phase 1 learned about the recently merged list. */
11
+ export interface MergedPRNotesInput {
12
+ recentlyMergedPRs: MergedPR[];
13
+ /** The list is the [] fallback of a failed fetch; the phase is skipped with a warning. */
14
+ recentlyMergedFetchFailed: boolean;
15
+ }
16
+ /**
17
+ * Phase 3.7 entry point: runs {@link prepareMergedPRNotes} and turns any
18
+ * non-fatal failure into a `merged-pr-notes` warning plus an empty list.
19
+ * Rate-limit/auth errors end the run like every other phase's.
20
+ */
21
+ export declare function runMergedPRNotesPhase(prMonitor: PRMonitor, input: MergedPRNotesInput, warnings: DailyWarning[]): Promise<MergedPRNotes[]>;
22
+ /**
23
+ * Fence the GitHub-sourced note excerpts for agent-facing JSON (#1372), at
24
+ * the same boundary as daily.ts's `fenceCommentedIssue`: the internal result
25
+ * keeps raw text for the text renderer and tests.
26
+ */
27
+ export declare function fenceMergedPRNotes(entry: MergedPRNotes): MergedPRNotes;
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Daily Phase 3.7: maintainer notes on recently merged PRs (#1861).
3
+ *
4
+ * Kept out of daily.ts (file-size ceiling). Pure selection lives in
5
+ * core/merged-pr-notes.ts; this module owns the per-PR fetch, the dismiss
6
+ * check, the warnings, and the agent-facing fencing of note excerpts.
7
+ */
8
+ import { getStateManager, groupThanksOnlyAcknowledgments, latestNoteAt, omitAcknowledgedViaCarrier, scanMergedPR, } from '../core/index.js';
9
+ import { isRateLimitOrAuthError } from '../core/errors.js';
10
+ import { DEFAULT_CONCURRENCY, runWorkerPool } from '../core/concurrency.js';
11
+ import { debug, warn } from '../core/logger.js';
12
+ import { wrapUntrustedContent } from '../core/untrusted-content.js';
13
+ import { describeError, httpStatusLabel, isGoneError, recordWarning } from './daily-warnings.js';
14
+ const MODULE = 'daily';
15
+ const OPERATION = 'merged-PR maintainer notes';
16
+ /**
17
+ * Whether the user declined this PR's notes: its URL was dismissed at or
18
+ * after the newest note. A note newer than the dismiss resurfaces the PR,
19
+ * same as issue replies. An unreadable stamp fails open (the PR is listed)
20
+ * with a log line, matching the issue path's dismiss filter.
21
+ */
22
+ function isDismissed(prUrl, notes, dismissedAt) {
23
+ if (dismissedAt === undefined)
24
+ return false;
25
+ const dismissedMs = Date.parse(dismissedAt);
26
+ if (Number.isNaN(dismissedMs)) {
27
+ warn(MODULE, `merged-pr-notes: ${prUrl} has an unreadable dismiss timestamp ${JSON.stringify(dismissedAt)}; listing`);
28
+ return false;
29
+ }
30
+ const newestNoteAt = latestNoteAt(notes);
31
+ if (dismissedMs >= Date.parse(newestNoteAt)) {
32
+ debug(MODULE, `merged-pr-notes: ${prUrl} dismissed at ${dismissedAt}, after newest note ${newestNoteAt}; skipping`);
33
+ return true;
34
+ }
35
+ return false;
36
+ }
37
+ /**
38
+ * Fetch one PR's activity, turning a failure into a warning that names the
39
+ * PR and its HTTP status. Returns undefined when the PR is dropped for this
40
+ * run: on a fetch error, or when any of the four lists hit the pagination
41
+ * cap (the cap cuts the newest items, which is where the user's own reply
42
+ * would be, so an incomplete thread would nag about an answered note).
43
+ * Rate-limit/auth errors propagate.
44
+ */
45
+ async function fetchActivity(prMonitor, pr, warnings) {
46
+ const operation = `fetch activity on ${pr.url}`;
47
+ let activity;
48
+ try {
49
+ activity = await prMonitor.fetchMergedPRActivity(pr.url);
50
+ }
51
+ catch (error) {
52
+ if (isRateLimitOrAuthError(error))
53
+ throw error;
54
+ const detail = isGoneError(error)
55
+ ? `PR no longer reachable (${httpStatusLabel(error)}); dropped`
56
+ : `${describeError(error)}; dropped`;
57
+ recordWarning(warnings, 'merged-pr-notes', operation, error, detail);
58
+ return undefined;
59
+ }
60
+ if (activity.truncatedLists.length > 0) {
61
+ recordWarning(warnings, 'merged-pr-notes', operation, null, `pagination cap reached on ${activity.truncatedLists.join(', ')}; the newest activity (including any reply of yours) may be missing; dropped`);
62
+ return undefined;
63
+ }
64
+ return activity;
65
+ }
66
+ /**
67
+ * For each PR in this run's recently merged list (already limited to repos
68
+ * the user does not own and outside `untrackedOrgs` by the search), fetch its
69
+ * comments, reviews, inline review comments and commits and keep the notes
70
+ * `scanMergedPR` says still wait for the user: maintainer comments after the
71
+ * user's last word (comment or commit) and no earlier than an hour before
72
+ * the merge, plus commits someone else pushed on top. Thanks-only entries in
73
+ * one repo collapse onto the most recent PR (`ackCoveredBy`), and once the
74
+ * user has commented on that carrier the covered entries stop coming back
75
+ * (`omitAcknowledgedViaCarrier`).
76
+ *
77
+ * "Only once": nothing is written to state. An entry disappears when the
78
+ * user comments on the PR (or on its group's carrier) after the notes, when
79
+ * they dismiss the PR URL at or after the newest note (the workflow's "skip"
80
+ * runs the existing `dismiss`, which accepts PR URLs and re-stamps on
81
+ * repeat), and at the latest when the PR leaves the recently-merged window.
82
+ *
83
+ * Non-fatal: a per-PR failure (fetch error, pagination cap, or an error
84
+ * while reading the thread) drops that PR with a `merged-pr-notes` warning
85
+ * naming it; rate-limit/auth errors propagate like every other phase's.
86
+ */
87
+ async function prepareMergedPRNotes(prMonitor, { recentlyMergedPRs, recentlyMergedFetchFailed }, warnings) {
88
+ if (recentlyMergedFetchFailed) {
89
+ recordWarning(warnings, 'merged-pr-notes', OPERATION, null, 'skipped: recently-merged fetch failed');
90
+ return [];
91
+ }
92
+ if (recentlyMergedPRs.length === 0)
93
+ return [];
94
+ const stateManager = getStateManager();
95
+ const username = stateManager.getState().config.githubUsername;
96
+ if (!username) {
97
+ recordWarning(warnings, 'merged-pr-notes', OPERATION, null, 'skipped: no GitHub username configured');
98
+ return [];
99
+ }
100
+ // Keyed by PR so the output keeps the fetched order however the workers finish.
101
+ const pending = new Map();
102
+ const carriers = [];
103
+ const recordScan = (pr, activity) => {
104
+ const scan = scanMergedPR(pr, activity, username);
105
+ if (scan.thanksOnlyThread) {
106
+ carriers.push({ prUrl: pr.url, repo: pr.repo, mergedAt: pr.mergedAt, lastUserCommentMs: scan.lastUserCommentMs });
107
+ }
108
+ if (!scan.pending || isDismissed(pr.url, scan.pending, stateManager.getIssueDismissedAt(pr.url)))
109
+ return;
110
+ pending.set(pr, scan.pending);
111
+ };
112
+ await runWorkerPool(recentlyMergedPRs, async (pr) => {
113
+ const activity = await fetchActivity(prMonitor, pr, warnings);
114
+ if (!activity)
115
+ return;
116
+ try {
117
+ recordScan(pr, activity);
118
+ }
119
+ catch (error) {
120
+ if (isRateLimitOrAuthError(error))
121
+ throw error;
122
+ recordWarning(warnings, 'merged-pr-notes', `read activity on ${pr.url}`, error, `${describeError(error)}; dropped`);
123
+ }
124
+ }, DEFAULT_CONCURRENCY);
125
+ const ordered = [];
126
+ for (const pr of recentlyMergedPRs) {
127
+ const notes = pending.get(pr);
128
+ if (notes)
129
+ ordered.push(notes);
130
+ }
131
+ return groupThanksOnlyAcknowledgments(omitAcknowledgedViaCarrier(ordered, carriers));
132
+ }
133
+ /**
134
+ * Phase 3.7 entry point: runs {@link prepareMergedPRNotes} and turns any
135
+ * non-fatal failure into a `merged-pr-notes` warning plus an empty list.
136
+ * Rate-limit/auth errors end the run like every other phase's.
137
+ */
138
+ export async function runMergedPRNotesPhase(prMonitor, input, warnings) {
139
+ try {
140
+ return await prepareMergedPRNotes(prMonitor, input, warnings);
141
+ }
142
+ catch (error) {
143
+ if (isRateLimitOrAuthError(error))
144
+ throw error;
145
+ recordWarning(warnings, 'merged-pr-notes', 'prepare merged-PR maintainer notes', error);
146
+ return [];
147
+ }
148
+ }
149
+ /**
150
+ * Fence the GitHub-sourced note excerpts for agent-facing JSON (#1372), at
151
+ * the same boundary as daily.ts's `fenceCommentedIssue`: the internal result
152
+ * keeps raw text for the text renderer and tests.
153
+ */
154
+ export function fenceMergedPRNotes(entry) {
155
+ const label = `${entry.repo}#${entry.number}`;
156
+ return {
157
+ ...entry,
158
+ notes: entry.notes.map((note) => ({
159
+ ...note,
160
+ excerpt: wrapUntrustedContent(note.excerpt, label, {
161
+ author: note.author,
162
+ source: note.kind === 'commit' ? 'pr-commit' : 'pr-comment',
163
+ }),
164
+ })),
165
+ };
166
+ }
@@ -0,0 +1,41 @@
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 { type PRMonitor, type ReviewedPRFollowUp } from '../core/index.js';
16
+ import type { DailyWarning } from '../formatters/json.js';
17
+ /**
18
+ * Reviewed PRs enriched per run, most recently updated first (#1857). Five
19
+ * calls each, so this bounds the phase at roughly 250 calls plus compares;
20
+ * a reviewer with more open reviewed PRs than this sees one warning naming
21
+ * how many were left unchecked. The search result is sorted by `updated_at`
22
+ * across both searches and dismissed PRs are dropped before the cap, so the
23
+ * PRs left out are the ones nothing has happened on for longest.
24
+ */
25
+ export declare const REVIEWED_PR_MAX_PER_RUN = 50;
26
+ /** The three PRMonitor calls this phase makes; a structural type so tests can pass a stub. */
27
+ export type ReviewedPRSource = Pick<PRMonitor, 'fetchReviewedOpenPRs' | 'fetchReviewedPRActivity' | 'fetchCompareStatus'>;
28
+ /**
29
+ * Phase 3.8 entry point: runs {@link prepareReviewedPRs} and turns any
30
+ * non-fatal failure (including a failed search) into a `reviewed-prs`
31
+ * warning plus an empty list. Rate-limit/auth errors end the run like every
32
+ * other phase's.
33
+ */
34
+ export declare function runReviewedPRsPhase(source: ReviewedPRSource, warnings: DailyWarning[]): Promise<ReviewedPRFollowUp[]>;
35
+ /**
36
+ * Fence the GitHub-sourced text for agent-facing JSON (#1372), at the same
37
+ * boundary as daily.ts's `fenceCommentedIssue`: question excerpts and commit
38
+ * subjects. The internal result keeps raw text for the text renderer and
39
+ * tests.
40
+ */
41
+ export declare function fenceReviewedPR(entry: ReviewedPRFollowUp): ReviewedPRFollowUp;