@oss-autopilot/core 3.33.0 → 3.34.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 (86) hide show
  1. package/dist/cli-pre-action.js +20 -20
  2. package/dist/cli-registry.js +59 -23
  3. package/dist/cli.bundle.cjs +140 -129
  4. package/dist/commands/check-integration.d.ts +2 -2
  5. package/dist/commands/comments.js +3 -3
  6. package/dist/commands/compliance-score.js +1 -1
  7. package/dist/commands/config.js +1 -1
  8. package/dist/commands/daily-render.js +6 -13
  9. package/dist/commands/daily.d.ts +1 -2
  10. package/dist/commands/daily.js +8 -4
  11. package/dist/commands/dashboard-cache.js +1 -1
  12. package/dist/commands/dashboard-data.js +7 -6
  13. package/dist/commands/dashboard-lifecycle.js +3 -5
  14. package/dist/commands/dashboard-server.js +3 -3
  15. package/dist/commands/detect-formatters.d.ts +1 -1
  16. package/dist/commands/dismiss.js +2 -2
  17. package/dist/commands/doctor.js +3 -3
  18. package/dist/commands/eval.d.ts +11 -0
  19. package/dist/commands/eval.js +11 -0
  20. package/dist/commands/features.js +1 -1
  21. package/dist/commands/guidelines.js +5 -5
  22. package/dist/commands/index.d.ts +1 -0
  23. package/dist/commands/index.js +1 -0
  24. package/dist/commands/init.js +1 -1
  25. package/dist/commands/ledger-backfill.d.ts +40 -0
  26. package/dist/commands/ledger-backfill.js +216 -0
  27. package/dist/commands/local-repos.d.ts +1 -1
  28. package/dist/commands/overnight.js +13 -18
  29. package/dist/commands/parse-list.d.ts +2 -2
  30. package/dist/commands/parse-list.js +7 -7
  31. package/dist/commands/repo-vet.js +3 -3
  32. package/dist/commands/search.js +9 -10
  33. package/dist/commands/setup.js +8 -8
  34. package/dist/commands/startup.js +1 -1
  35. package/dist/commands/status.d.ts +1 -1
  36. package/dist/commands/vet-list.js +17 -7
  37. package/dist/commands/vet.js +5 -3
  38. package/dist/core/__fixtures__/prompt-injection-payloads.js +1 -1
  39. package/dist/core/anti-llm-policy.js +3 -3
  40. package/dist/core/checklist-analysis.d.ts +3 -0
  41. package/dist/core/checklist-analysis.js +67 -16
  42. package/dist/core/ci-analysis.js +1 -1
  43. package/dist/core/close-reason.d.ts +25 -0
  44. package/dist/core/close-reason.js +28 -0
  45. package/dist/core/comment-decision.js +1 -1
  46. package/dist/core/compliance-score.js +2 -2
  47. package/dist/core/daily-logic.d.ts +12 -0
  48. package/dist/core/daily-logic.js +11 -2
  49. package/dist/core/display-utils.js +1 -1
  50. package/dist/core/errors.js +4 -5
  51. package/dist/core/eval-report.d.ts +55 -0
  52. package/dist/core/eval-report.js +211 -0
  53. package/dist/core/follow-up-history.d.ts +1 -2
  54. package/dist/core/follow-up-history.js +1 -1
  55. package/dist/core/github-stats.d.ts +9 -0
  56. package/dist/core/github-stats.js +27 -1
  57. package/dist/core/guidelines-store.js +2 -2
  58. package/dist/core/http-cache.js +1 -2
  59. package/dist/core/index.d.ts +3 -2
  60. package/dist/core/index.js +3 -2
  61. package/dist/core/issue-conversation.js +1 -1
  62. package/dist/core/issue-effort.js +12 -6
  63. package/dist/core/paths.d.ts +7 -0
  64. package/dist/core/paths.js +25 -3
  65. package/dist/core/pick-snapshot.d.ts +23 -0
  66. package/dist/core/pick-snapshot.js +51 -0
  67. package/dist/core/pr-comments-fetcher.js +1 -1
  68. package/dist/core/review-analysis.js +5 -9
  69. package/dist/core/state-persistence.js +1 -1
  70. package/dist/core/state-schema.d.ts +117 -0
  71. package/dist/core/state-schema.js +48 -0
  72. package/dist/core/state.d.ts +22 -1
  73. package/dist/core/state.js +65 -12
  74. package/dist/core/strategy.js +2 -3
  75. package/dist/core/types.d.ts +1 -1
  76. package/dist/core/untrusted-content.js +9 -9
  77. package/dist/core/urls.js +1 -1
  78. package/dist/dashboard/assets/chart-panel-DPKNBUts.js +3 -0
  79. package/dist/dashboard/assets/{confetti.module-BYDB1iN2.js → confetti.module-D2UmBLOm.js} +1 -1
  80. package/dist/dashboard/assets/index-B25bZOYX.js +55 -0
  81. package/dist/dashboard/index.html +1 -1
  82. package/dist/formatters/json.d.ts +10 -2
  83. package/dist/formatters/json.js +2 -2
  84. package/package.json +1 -1
  85. package/dist/dashboard/assets/chart-panel-CmNIsCjO.js +0 -3
  86. package/dist/dashboard/assets/index-CTKGc-Ns.js +0 -55
@@ -2,9 +2,9 @@
2
2
  * Check integration command (#83)
3
3
  * Detects new files in the current branch that aren't referenced elsewhere
4
4
  */
5
- import type { CheckIntegrationOutput, NewFileInfo } from '../formatters/json.js';
5
+ import type { CheckIntegrationOutput } from '../formatters/json.js';
6
6
  interface CheckIntegrationOptions {
7
7
  base: string;
8
8
  }
9
- export type { CheckIntegrationOutput, NewFileInfo };
10
9
  export declare function runCheckIntegration(options: CheckIntegrationOptions): Promise<CheckIntegrationOutput>;
10
+ export { type CheckIntegrationOutput, type NewFileInfo } from '../formatters/json.js';
@@ -144,7 +144,7 @@ export async function runComments(options) {
144
144
  inlineCommentCount: relevantReviewComments.length,
145
145
  discussionCommentCount: relevantIssueComments.length,
146
146
  },
147
- ...(warnings.length > 0 ? { warnings } : {}),
147
+ ...(warnings.length > 0 && { warnings }),
148
148
  };
149
149
  }
150
150
  /**
@@ -274,7 +274,7 @@ export async function runClaim(options) {
274
274
  return {
275
275
  commentUrl: comment.html_url,
276
276
  issueUrl: options.issueUrl,
277
- ...(gistSyncWarning ? { gistSyncWarning } : {}),
278
- ...(stateSaveWarning ? { stateSaveWarning } : {}),
277
+ ...(gistSyncWarning && { gistSyncWarning }),
278
+ ...(stateSaveWarning && { stateSaveWarning }),
279
279
  };
280
280
  }
@@ -92,7 +92,7 @@ async function verifyLinkedIssues(octokit, prRepo, refs, now = new Date()) {
92
92
  return { number, repo: fullRepo, crossRepo, state: 'open' };
93
93
  }
94
94
  const closedAt = data.closed_at ? new Date(data.closed_at) : null;
95
- const closedDaysAgo = closedAt ? Math.floor((now.getTime() - closedAt.getTime()) / 86400000) : undefined;
95
+ const closedDaysAgo = closedAt ? Math.floor((now.getTime() - closedAt.getTime()) / 86_400_000) : undefined;
96
96
  return { number, repo: fullRepo, crossRepo, state: 'closed', closedDaysAgo };
97
97
  }
98
98
  catch (err) {
@@ -184,5 +184,5 @@ export async function runConfig(options) {
184
184
  // Without this the change only hits the local cache and the next
185
185
  // bootstrap reverts it from the Gist (#1440).
186
186
  const gistSyncWarning = await maybeCheckpoint(stateManager, MODULE);
187
- return { success: true, key: options.key, value, ...(gistSyncWarning ? { gistSyncWarning } : {}) };
187
+ return { success: true, key: options.key, value, ...(gistSyncWarning && { gistSyncWarning }) };
188
188
  }
@@ -60,24 +60,18 @@ export function formatBriefSummary(digest, issueCount, issueResponseCount = 0, a
60
60
  */
61
61
  export function formatSummary(digest, capacity, issueResponses = []) {
62
62
  const lines = [];
63
- lines.push('## OSS Dashboard');
64
- lines.push('');
65
- lines.push(`\u{1F4CA} **${digest.summary.totalActivePRs} Active PRs** | ${digest.summary.totalMergedAllTime} Merged | ${digest.summary.mergeRate}% Merge Rate`);
66
- lines.push('✓ Dashboard generated — say "open dashboard" to view in browser');
67
- lines.push('');
63
+ lines.push('## OSS Dashboard', '', `\u{1F4CA} **${digest.summary.totalActivePRs} Active PRs** | ${digest.summary.totalMergedAllTime} Merged | ${digest.summary.mergeRate}% Merge Rate`, '✓ Dashboard generated — say "open dashboard" to view in browser', '');
68
64
  if (digest.needsAddressingPRs.length > 0) {
69
65
  lines.push('### ❌ Needs Addressing');
70
66
  for (const pr of digest.needsAddressingPRs) {
71
- lines.push(`- [${pr.repo}#${pr.number}](${pr.url}): ${pr.title}`);
72
- lines.push(` └─ ${pr.displayLabel} ${pr.displayDescription}`);
67
+ lines.push(`- [${pr.repo}#${pr.number}](${pr.url}): ${pr.title}`, ` └─ ${pr.displayLabel} ${pr.displayDescription}`);
73
68
  }
74
69
  lines.push('');
75
70
  }
76
71
  if (digest.waitingOnMaintainerPRs.length > 0) {
77
72
  lines.push('### ⏳ Waiting on Maintainer');
78
73
  for (const pr of digest.waitingOnMaintainerPRs) {
79
- lines.push(`- [${pr.repo}#${pr.number}](${pr.url}): ${pr.title}`);
80
- lines.push(` └─ ${pr.displayDescription}`);
74
+ lines.push(`- [${pr.repo}#${pr.number}](${pr.url}): ${pr.title}`, ` └─ ${pr.displayDescription}`);
81
75
  }
82
76
  lines.push('');
83
77
  }
@@ -98,10 +92,9 @@ export function formatSummary(digest, capacity, issueResponses = []) {
98
92
  lines.push('');
99
93
  }
100
94
  if (digest.autoUnshelvedPRs.length > 0) {
101
- lines.push('### \u{1F514} Auto-Unshelved');
102
- lines.push('> These PRs were shelved but a maintainer engaged — moved back to active.');
95
+ lines.push('### \u{1F514} Auto-Unshelved', '> These PRs were shelved but a maintainer engaged — moved back to active.');
103
96
  for (const pr of digest.autoUnshelvedPRs) {
104
- lines.push(`- [${pr.repo}#${pr.number}](${pr.url}): ${pr.title} (${pr.status.replace(/_/g, ' ')})`);
97
+ lines.push(`- [${pr.repo}#${pr.number}](${pr.url}): ${pr.title} (${pr.status.replaceAll('_', ' ')})`);
105
98
  }
106
99
  lines.push('');
107
100
  }
@@ -178,7 +171,7 @@ export function printDigest(digest, capacity, commentedIssues = []) {
178
171
  if (digest.autoUnshelvedPRs.length > 0) {
179
172
  console.log('\u{1F514} Auto-Unshelved:');
180
173
  for (const pr of digest.autoUnshelvedPRs) {
181
- console.log(` - ${pr.repo}#${pr.number}: ${pr.title} (${pr.status.replace(/_/g, ' ')})`);
174
+ console.log(` - ${pr.repo}#${pr.number}: ${pr.title} (${pr.status.replaceAll('_', ' ')})`);
182
175
  }
183
176
  console.log('');
184
177
  }
@@ -10,8 +10,6 @@ import { type AttentionSummary, type DailyDigest, type CommentedIssue, type PRCh
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';
13
- import { buildStarFilter } from '../core/daily-logic.js';
14
- export { buildStarFilter };
15
13
  /**
16
14
  * Internal result of the daily check, using full (non-deduplicated) types.
17
15
  * Consumed by printDigest() (text mode) and converted to DailyOutput (JSON mode)
@@ -107,3 +105,4 @@ export declare function runDaily(): Promise<DailyOutput>;
107
105
  * @throws {ConfigurationError} If no GitHub token is available
108
106
  */
109
107
  export declare function runDailyForDisplay(): Promise<DailyCheckResult>;
108
+ export { buildStarFilter } from '../core/daily-logic.js';
@@ -66,8 +66,7 @@ export { applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacit
66
66
  // reuse it without crossing the commands → sibling-command boundary
67
67
  // (#1208 M7). Re-exported here for backward compatibility with anyone
68
68
  // importing from this module.
69
- import { buildStarFilter, firstMaintainerResponseFromDigest } from '../core/daily-logic.js';
70
- export { buildStarFilter };
69
+ import { buildStarFilter, firstMaintainerResponseFromDigest, lastReviewStateFromDigest } from '../core/daily-logic.js';
71
70
  // ---------------------------------------------------------------------------
72
71
  // Phase functions
73
72
  // ---------------------------------------------------------------------------
@@ -584,8 +583,8 @@ export function toDailyOutput(result) {
584
583
  strategySummary: result.strategySummary,
585
584
  // Conditional spread (not a plain assignment) so merge-free runs carry
586
585
  // no `listUpdates` key at all — serialized output and goldens unchanged.
587
- ...(result.listUpdates ? { listUpdates: result.listUpdates } : {}),
588
- ...(result.pendingLearnings ? { pendingLearnings: result.pendingLearnings } : {}),
586
+ ...(result.listUpdates && { listUpdates: result.listUpdates }),
587
+ ...(result.pendingLearnings && { pendingLearnings: result.pendingLearnings }),
589
588
  };
590
589
  }
591
590
  /**
@@ -675,6 +674,8 @@ async function executeDailyCheckInternal(token) {
675
674
  mergedAt: pr.mergedAt,
676
675
  openedAt: pr.openedAt,
677
676
  firstMaintainerResponseAt: firstMaintainerResponseFromDigest(previousDigest, pr.url),
677
+ issueUrl: pr.issueUrl,
678
+ ...lastReviewStateFromDigest(previousDigest, pr.url),
678
679
  })));
679
680
  }
680
681
  if (recentlyClosedPRs.length > 0) {
@@ -684,6 +685,8 @@ async function executeDailyCheckInternal(token) {
684
685
  closedAt: pr.closedAt,
685
686
  openedAt: pr.openedAt,
686
687
  firstMaintainerResponseAt: firstMaintainerResponseFromDigest(previousDigest, pr.url),
688
+ issueUrl: pr.issueUrl,
689
+ ...lastReviewStateFromDigest(previousDigest, pr.url),
687
690
  })));
688
691
  }
689
692
  });
@@ -814,3 +817,4 @@ export async function runDailyForDisplay() {
814
817
  const token = requireGitHubToken();
815
818
  return executeDailyCheckInternal(token);
816
819
  }
820
+ export { buildStarFilter } from '../core/daily-logic.js';
@@ -214,6 +214,6 @@ export class DashboardCache {
214
214
  * call sites re-stat after the build. */
215
215
  rebuild(state, allMergedPRs, allClosedPRs, issueListMtimeMs) {
216
216
  this.cachedJsonData = buildDashboardJson(this.cachedDigest, state, this.cachedCommentedIssues, allMergedPRs, allClosedPRs, this.mergeWarnings(this.cachedPartialFailures));
217
- this.cachedIssueListMtimeMs = issueListMtimeMs !== undefined ? issueListMtimeMs : getIssueListMtimeMs();
217
+ this.cachedIssueListMtimeMs = issueListMtimeMs === undefined ? getIssueListMtimeMs() : issueListMtimeMs;
218
218
  }
219
219
  }
@@ -3,13 +3,12 @@
3
3
  * Handles GitHub API calls, PR grouping, stats computation, and monthly chart data.
4
4
  * Consumed by the dashboard HTTP server (dashboard-server.ts) for the SPA API.
5
5
  */
6
- import { getStateManager, PRMonitor, IssueConversationMonitor, getOctokit, CRITICAL_STATUSES, applyStatusOverrides, } from '../core/index.js';
6
+ import { getStateManager, PRMonitor, IssueConversationMonitor, getOctokit, CRITICAL_STATUSES, applyStatusOverrides, toShelvedPRRef, buildStarFilter, firstMaintainerResponseFromDigest, lastReviewStateFromDigest, } from '../core/index.js';
7
7
  import { errorMessage, isRateLimitOrAuthError } from '../core/errors.js';
8
8
  import { warn } from '../core/logger.js';
9
9
  import { emptyPRCountsResult, fetchMergedPRsSince, fetchClosedPRsSince } from '../core/github-stats.js';
10
10
  import { parseGitHubUrl } from '../core/urls.js';
11
11
  import { isBelowMinStars, } from '../core/types.js';
12
- import { toShelvedPRRef, buildStarFilter, firstMaintainerResponseFromDigest } from '../core/index.js';
13
12
  const MODULE = 'dashboard-data';
14
13
  export function buildDashboardStats(digest, state, storedMergedCount, storedClosedCount) {
15
14
  const summary = digest.summary || {
@@ -21,12 +20,12 @@ export function buildDashboardStats(digest, state, storedMergedCount, storedClos
21
20
  const minStars = state.config.minStars ?? 50;
22
21
  // Merged: use the higher of stored count vs repoScores aggregate to avoid regressions
23
22
  // when the stored list hasn't caught up yet (initial fetch caps at 300 PRs)
24
- const mergedPRs = storedMergedCount !== undefined
25
- ? Math.max(storedMergedCount, summary.totalMergedAllTime)
26
- : summary.totalMergedAllTime;
23
+ const mergedPRs = storedMergedCount === undefined
24
+ ? summary.totalMergedAllTime
25
+ : Math.max(storedMergedCount, summary.totalMergedAllTime);
27
26
  // Closed: same anti-regression strategy — use the higher of stored count vs repoScores aggregate
28
27
  const aggregateClosedCount = Object.values(state.repoScores || {}).reduce((sum, s) => sum + (isBelowMinStars(s.stargazersCount, minStars) ? 0 : s.closedWithoutMergeCount || 0), 0);
29
- const closedPRs = storedClosedCount !== undefined ? Math.max(storedClosedCount, aggregateClosedCount) : aggregateClosedCount;
28
+ const closedPRs = storedClosedCount === undefined ? aggregateClosedCount : Math.max(storedClosedCount, aggregateClosedCount);
30
29
  return {
31
30
  activePRs: summary.totalActivePRs,
32
31
  shelvedPRs: (digest.shelvedPRs || []).length,
@@ -288,6 +287,7 @@ export async function fetchDashboardData(token) {
288
287
  const { dropped } = stateManager.addMergedPRs(newMergedPRs.map((pr) => ({
289
288
  ...pr,
290
289
  firstMaintainerResponseAt: pr.firstMaintainerResponseAt ?? firstMaintainerResponseFromDigest(previousDigest, pr.url),
290
+ ...lastReviewStateFromDigest(previousDigest, pr.url),
291
291
  })));
292
292
  if (dropped > 0) {
293
293
  partialFailures.push(`Dropped ${dropped} merged PR(s) with invalid URLs before persistence`);
@@ -303,6 +303,7 @@ export async function fetchDashboardData(token) {
303
303
  const { dropped } = stateManager.addClosedPRs(newClosedPRs.map((pr) => ({
304
304
  ...pr,
305
305
  firstMaintainerResponseAt: pr.firstMaintainerResponseAt ?? firstMaintainerResponseFromDigest(previousDigest, pr.url),
306
+ ...lastReviewStateFromDigest(previousDigest, pr.url),
306
307
  })));
307
308
  if (dropped > 0) {
308
309
  partialFailures.push(`Dropped ${dropped} closed PR(s) with invalid URLs before persistence`);
@@ -125,11 +125,9 @@ export async function launchDashboardServer(options) {
125
125
  return null;
126
126
  }
127
127
  const info = readDashboardServerInfo();
128
- if (info) {
129
- // PID file appeared — verify the server is responding
130
- if (await isDashboardServerRunning(info.port)) {
131
- return { url: `http://oss.localhost:${info.port}`, port: info.port, alreadyRunning: false };
132
- }
128
+ // PID file appeared — verify the server is responding
129
+ if (info && (await isDashboardServerRunning(info.port))) {
130
+ return { url: `http://oss.localhost:${info.port}`, port: info.port, alreadyRunning: false };
133
131
  }
134
132
  }
135
133
  // 5. Timeout — server didn't start in time; kill orphan process
@@ -165,7 +165,7 @@ function sendError(res, statusCode, message) {
165
165
  * from arbitrary error messages (#1446 item 2).
166
166
  */
167
167
  function sanitizeHeaderValue(value) {
168
- return value.replace(/[\r\n]+/g, ' ').trim();
168
+ return value.replaceAll(/[\r\n]+/g, ' ').trim();
169
169
  }
170
170
  /**
171
171
  * True when an error is an optimistic-concurrency conflict on state.json
@@ -580,9 +580,9 @@ export async function startDashboardServer(options) {
580
580
  // Decode URL, handling malformed percent-encoding
581
581
  let urlPath;
582
582
  try {
583
- urlPath = decodeURIComponent(requestUrl.split('?')[0]);
583
+ urlPath = decodeURIComponent(requestUrl.split('?', 1)[0]);
584
584
  }
585
- catch (_err) {
585
+ catch {
586
586
  warn(MODULE, `Malformed URL received: ${requestUrl}`);
587
587
  sendError(res, 400, 'Malformed URL');
588
588
  return;
@@ -4,8 +4,8 @@
4
4
  * Optionally diagnoses CI log output for formatting failures.
5
5
  */
6
6
  import type { DetectFormattersOutput } from '../formatters/json.js';
7
- export type { DetectFormattersOutput };
8
7
  export declare function runDetectFormatters(options: {
9
8
  repoPath?: string;
10
9
  ciLog?: string;
11
10
  }): Promise<DetectFormattersOutput>;
11
+ export { type DetectFormattersOutput } from '../formatters/json.js';
@@ -21,7 +21,7 @@ export async function runDismiss(options) {
21
21
  const stateManager = getStateManager();
22
22
  const added = stateManager.dismissIssue(options.url, new Date().toISOString());
23
23
  const gistSyncWarning = await maybeCheckpoint(stateManager, MODULE);
24
- return { dismissed: added, url: options.url, ...(gistSyncWarning ? { gistSyncWarning } : {}) };
24
+ return { dismissed: added, url: options.url, ...(gistSyncWarning && { gistSyncWarning }) };
25
25
  }
26
26
  /**
27
27
  * Restore a dismissed issue to notifications.
@@ -37,5 +37,5 @@ export async function runUndismiss(options) {
37
37
  const stateManager = getStateManager();
38
38
  const removed = stateManager.undismissIssue(options.url);
39
39
  const gistSyncWarning = await maybeCheckpoint(stateManager, MODULE);
40
- return { undismissed: removed, url: options.url, ...(gistSyncWarning ? { gistSyncWarning } : {}) };
40
+ return { undismissed: removed, url: options.url, ...(gistSyncWarning && { gistSyncWarning }) };
41
41
  }
@@ -31,7 +31,7 @@ function errCode(err) {
31
31
  export async function checkGhCli() {
32
32
  try {
33
33
  const { stdout } = await execFileAsync('gh', ['--version'], { timeout: GH_CMD_TIMEOUT_MS });
34
- const versionLine = stdout.split('\n')[0]?.trim() || 'gh present';
34
+ const versionLine = stdout.split('\n', 1)[0]?.trim() || 'gh present';
35
35
  return { name: 'gh CLI installed', status: 'ok', message: versionLine };
36
36
  }
37
37
  catch (err) {
@@ -74,7 +74,7 @@ export async function checkGhAuth() {
74
74
  }
75
75
  }
76
76
  export async function checkGitHubToken(preloadedToken) {
77
- const token = preloadedToken !== undefined ? preloadedToken : await getGitHubTokenAsync();
77
+ const token = preloadedToken === undefined ? await getGitHubTokenAsync() : preloadedToken;
78
78
  if (!token) {
79
79
  return {
80
80
  name: 'GitHub token resolvable',
@@ -258,7 +258,7 @@ export async function checkScoutResolvable(importer = defaultScoutImporter) {
258
258
  }
259
259
  }
260
260
  export async function checkGitHubRateLimit(preloadedToken) {
261
- const token = preloadedToken !== undefined ? preloadedToken : await getGitHubTokenAsync();
261
+ const token = preloadedToken === undefined ? await getGitHubTokenAsync() : preloadedToken;
262
262
  if (!token) {
263
263
  return {
264
264
  name: 'GitHub rate limit',
@@ -0,0 +1,11 @@
1
+ /**
2
+ * eval command (#1825): calibration and outcome metrics from the outcome
3
+ * ledger. Local-only: reads state, never calls GitHub. Run `ledger-backfill`
4
+ * first so historical entries carry close reasons and list vet scores.
5
+ */
6
+ import { type EvalReport } from '../core/eval-report.js';
7
+ export interface EvalOutput {
8
+ report: EvalReport;
9
+ markdown: string;
10
+ }
11
+ export declare function runEval(): Promise<EvalOutput>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * eval command (#1825): calibration and outcome metrics from the outcome
3
+ * ledger. Local-only: reads state, never calls GitHub. Run `ledger-backfill`
4
+ * first so historical entries carry close reasons and list vet scores.
5
+ */
6
+ import { computeEvalReport, formatEvalMarkdown } from '../core/eval-report.js';
7
+ import { getStateManager } from '../core/index.js';
8
+ export async function runEval() {
9
+ const report = computeEvalReport(getStateManager().getState());
10
+ return { report, markdown: formatEvalMarkdown(report) };
11
+ }
@@ -87,7 +87,7 @@ function toFeaturesCandidate(scoutCandidate, getState) {
87
87
  lastMergedAt: repoScoreRecord.lastMergedAt,
88
88
  }
89
89
  : undefined,
90
- ...(linkedPR ? { linkedPR } : {}),
90
+ ...(linkedPR && { linkedPR }),
91
91
  horizon: scoutCandidate.horizon,
92
92
  };
93
93
  }
@@ -78,7 +78,7 @@ export async function runGuidelinesStore(options) {
78
78
  repo: options.repo,
79
79
  byteSize: Buffer.byteLength(options.content, 'utf8'),
80
80
  stored: true,
81
- ...(gistSyncWarning ? { gistSyncWarning } : {}),
81
+ ...(gistSyncWarning && { gistSyncWarning }),
82
82
  };
83
83
  }
84
84
  /**
@@ -101,7 +101,7 @@ export async function runMarkExtracted(options) {
101
101
  marked++;
102
102
  }
103
103
  const gistSyncWarning = marked > 0 ? await maybeCheckpoint(sm, MODULE) : null;
104
- return { repo: options.repo, marked, ...(gistSyncWarning ? { gistSyncWarning } : {}) };
104
+ return { repo: options.repo, marked, ...(gistSyncWarning && { gistSyncWarning }) };
105
105
  }
106
106
  /** Tombstone the guidelines file for `repo`. */
107
107
  export async function runGuidelinesReset(options) {
@@ -117,7 +117,7 @@ export async function runGuidelinesReset(options) {
117
117
  // Push to Gist — see runGuidelinesStore note (#1200).
118
118
  gistSyncWarning = await maybeCheckpoint(sm, MODULE);
119
119
  }
120
- return { repo: options.repo, deleted: existed, ...(gistSyncWarning ? { gistSyncWarning } : {}) };
120
+ return { repo: options.repo, deleted: existed, ...(gistSyncWarning && { gistSyncWarning }) };
121
121
  }
122
122
  /**
123
123
  * Fetch raw PR comment bundles for the most recent merged/closed PRs in `repo`
@@ -202,8 +202,8 @@ export async function runFetchCorpus(options) {
202
202
  prCount: bundles.length,
203
203
  skipped,
204
204
  failures,
205
- ...(gistSyncWarning ? { gistSyncWarning } : {}),
206
- ...(warnings.length > 0 ? { warnings } : {}),
205
+ ...(gistSyncWarning && { gistSyncWarning }),
206
+ ...(warnings.length > 0 && { warnings }),
207
207
  };
208
208
  }
209
209
  function clampLimit(limit) {
@@ -37,6 +37,7 @@ export { runVet } from './vet.js';
37
37
  export { runVerifyIssue, type VerifyIssueOptions } from './verify-issue.js';
38
38
  /** Re-vet all available issues in a curated issue list for freshness. */
39
39
  export { runVetList } from './vet-list.js';
40
+ export { runEval, type EvalOutput } from './eval.js';
40
41
  /** Fetch PR metadata from GitHub (informational; nothing is persisted). */
41
42
  export { runTrack } from './track.js';
42
43
  /** Score a PR against opensource.guide best practices via the typed core function (#1245). */
@@ -38,6 +38,7 @@ export { runVet } from './vet.js';
38
38
  export { runVerifyIssue } from './verify-issue.js';
39
39
  /** Re-vet all available issues in a curated issue list for freshness. */
40
40
  export { runVetList } from './vet-list.js';
41
+ export { runEval } from './eval.js';
41
42
  // ── PR Management ───────────────────────────────────────────────────────────
42
43
  /** Fetch PR metadata from GitHub (informational; nothing is persisted). */
43
44
  export { runTrack } from './track.js';
@@ -25,6 +25,6 @@ export async function runInit(options) {
25
25
  return {
26
26
  username: options.username,
27
27
  message: 'Username saved. Run `daily` to fetch your open PRs from GitHub.',
28
- ...(gistSyncWarning ? { gistSyncWarning } : {}),
28
+ ...(gistSyncWarning && { gistSyncWarning }),
29
29
  };
30
30
  }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Backfill the outcome ledger (#1824 step 2).
3
+ *
4
+ * Entries written before the ledger carried `openedAt`, `issueUrl`, `pick`
5
+ * and `closeReason` have none of them, so the eval report (#1825) would have
6
+ * no history to calibrate against. This fills what can still be recovered:
7
+ *
8
+ * - `openedAt` and `issueUrl` (GitHub's `closingIssuesReferences`) via
9
+ * batched GraphQL; each answered PR is stamped `backfilledAt` so later
10
+ * runs only query new entries.
11
+ * - `closeReason` for closed-unmerged entries, from who closed the PR and its
12
+ * last comments (core/close-reason.ts).
13
+ * - `pick` for entries with no vet-time snapshot, from the curated issue list
14
+ * and its sibling archives: an entry whose status line links the PR carries
15
+ * the vet score as `**Tier (N/10)**`.
16
+ *
17
+ * Only missing fields are filled (addMergedPRs/addClosedPRs never overwrite),
18
+ * so the command is safe to re-run; the weekly eval job runs it first.
19
+ */
20
+ export interface LedgerBackfillOutput {
21
+ /** Ledger PRs sent to GitHub because they had not been backfilled yet. */
22
+ queried: number;
23
+ /** Entries that gained each field in this run. */
24
+ filled: {
25
+ openedAt: number;
26
+ issueUrl: number;
27
+ closeReason: number;
28
+ pick: number;
29
+ };
30
+ /** Curated-list files scanned for vet scores. */
31
+ listFiles: string[];
32
+ /** PRs GitHub returned nothing for this run; retried next run. */
33
+ unresolved: number;
34
+ /** Partial failures: failed batches, missing PRs by error type, unreadable list files. */
35
+ warnings: string[];
36
+ gistSyncWarning?: string;
37
+ }
38
+ export declare function runLedgerBackfill(options?: {
39
+ issueListPath?: string;
40
+ }): Promise<LedgerBackfillOutput>;