@oss-autopilot/core 3.23.0 → 3.25.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 +27 -1
- package/dist/cli.bundle.cjs +115 -112
- package/dist/commands/daily.d.ts +8 -1
- package/dist/commands/daily.js +33 -3
- package/dist/commands/features.js +5 -11
- package/dist/commands/guidelines.d.ts +15 -0
- package/dist/commands/guidelines.js +22 -0
- package/dist/commands/overnight-push-prep.js +5 -1
- package/dist/commands/overnight.d.ts +32 -1
- package/dist/commands/overnight.js +67 -4
- package/dist/commands/search.js +11 -15
- package/dist/commands/setup.js +9 -0
- package/dist/commands/skip-add.js +1 -1
- package/dist/commands/startup.js +12 -2
- package/dist/core/config-registry.js +7 -1
- package/dist/core/issue-grading.d.ts +8 -10
- package/dist/core/issue-grading.js +8 -10
- package/dist/core/pr-graphql.d.ts +1 -0
- package/dist/core/pr-graphql.js +14 -6
- package/dist/core/state-schema.d.ts +2 -0
- package/dist/core/state-schema.js +6 -0
- package/dist/core/state.d.ts +14 -0
- package/dist/core/state.js +19 -0
- package/dist/formatters/json.d.ts +34 -0
- package/dist/formatters/json.js +14 -0
- package/package.json +2 -2
package/dist/commands/daily.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { type AttentionSummary, type DailyDigest, type CommentedIssue, type PRCheckFailure, type RepoGroup } from '../core/index.js';
|
|
10
10
|
import { type StrategyResult } from '../core/strategy.js';
|
|
11
|
-
import { type DailyOutput, type DailyWarning, type CapacityAssessment, type ActionableIssue, type ActionMenu, type MergedPRListUpdate } from '../formatters/json.js';
|
|
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
13
|
import { buildStarFilter } from '../core/daily-logic.js';
|
|
14
14
|
export { buildStarFilter };
|
|
@@ -44,6 +44,13 @@ export interface DailyCheckResult {
|
|
|
44
44
|
* omit it so serialized output (and contract goldens) stay unchanged.
|
|
45
45
|
*/
|
|
46
46
|
listUpdates?: MergedPRListUpdate[];
|
|
47
|
+
/**
|
|
48
|
+
* Recently merged PRs whose learnings the host should extract now, without
|
|
49
|
+
* asking (#1696). Set only when `config.autoExtractLearnings` is on, Gist
|
|
50
|
+
* persistence is available, and at least one such PR exists; otherwise
|
|
51
|
+
* absent, so goldens and merge-free runs are unchanged.
|
|
52
|
+
*/
|
|
53
|
+
pendingLearnings?: PendingLearnings;
|
|
47
54
|
}
|
|
48
55
|
/**
|
|
49
56
|
* Convert a full DailyCheckResult to the compact DailyOutput for JSON serialization (#287).
|
package/dist/commands/daily.js
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 { getStateManager, PRMonitor, IssueConversationMonitor, requireGitHubToken, renderGistWarning, CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, formatBriefSummary, formatSummary, summarizeAttentionBuckets, } from '../core/index.js';
|
|
9
|
+
import { getStateManager, parseGitHubUrl, PRMonitor, IssueConversationMonitor, requireGitHubToken, renderGistWarning, CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, formatBriefSummary, formatSummary, summarizeAttentionBuckets, } from '../core/index.js';
|
|
10
10
|
import { errorMessage, isRateLimitOrAuthError } from '../core/errors.js';
|
|
11
11
|
import { wrapUntrustedContent } from '../core/untrusted-content.js';
|
|
12
12
|
import { computeStrategy, shouldComputeStrategy } from '../core/strategy.js';
|
|
@@ -550,6 +550,7 @@ export function toDailyOutput(result) {
|
|
|
550
550
|
// Conditional spread (not a plain assignment) so merge-free runs carry
|
|
551
551
|
// no `listUpdates` key at all — serialized output and goldens unchanged.
|
|
552
552
|
...(result.listUpdates ? { listUpdates: result.listUpdates } : {}),
|
|
553
|
+
...(result.pendingLearnings ? { pendingLearnings: result.pendingLearnings } : {}),
|
|
553
554
|
};
|
|
554
555
|
}
|
|
555
556
|
/**
|
|
@@ -667,10 +668,36 @@ async function executeDailyCheckInternal(token) {
|
|
|
667
668
|
// nudge: it stays up for the whole recently-merged window (7 days) until
|
|
668
669
|
// the user runs the extraction, then self-clears.
|
|
669
670
|
let unextractedMergeCount = 0;
|
|
671
|
+
let pendingLearnings;
|
|
670
672
|
try {
|
|
671
|
-
const
|
|
673
|
+
const sm = getStateManager();
|
|
674
|
+
const ledger = sm.getState().mergedPRs ?? [];
|
|
672
675
|
const recentUrls = new Set(recentlyMergedPRs.map((pr) => pr.url));
|
|
673
|
-
|
|
676
|
+
const unextracted = ledger.filter((pr) => recentUrls.has(pr.url) && !pr.learningsExtractedAt);
|
|
677
|
+
unextractedMergeCount = unextracted.length;
|
|
678
|
+
// Auto mode (#1696): hand the repos to the host for a background
|
|
679
|
+
// extraction instead of a menu item. Guidelines live in the Gist, so
|
|
680
|
+
// local-only persistence gets one warning per run and no menu item —
|
|
681
|
+
// the manual path would only tell the user the same thing.
|
|
682
|
+
if (unextractedMergeCount > 0 && sm.getState().config.autoExtractLearnings) {
|
|
683
|
+
unextractedMergeCount = 0;
|
|
684
|
+
if (sm.isGistMode()) {
|
|
685
|
+
const repos = new Set();
|
|
686
|
+
for (const pr of unextracted) {
|
|
687
|
+
const parsed = parseGitHubUrl(pr.url);
|
|
688
|
+
if (parsed)
|
|
689
|
+
repos.add(`${parsed.owner}/${parsed.repo}`);
|
|
690
|
+
}
|
|
691
|
+
pendingLearnings = { repos: [...repos].sort(), prCount: unextracted.length };
|
|
692
|
+
}
|
|
693
|
+
else {
|
|
694
|
+
warnings.push({
|
|
695
|
+
phase: 'merge-loop',
|
|
696
|
+
operation: 'auto-extract learnings',
|
|
697
|
+
message: `${unextracted.length} recently merged PR(s) have unextracted learnings; per-repo guidelines need Gist persistence (run setup to enable Gist sync, or set autoExtractLearnings=false to hide this)`,
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
}
|
|
674
701
|
}
|
|
675
702
|
catch (error) {
|
|
676
703
|
recordWarning(warnings, 'merge-loop', 'count unextracted merged PRs', error);
|
|
@@ -693,6 +720,9 @@ async function executeDailyCheckInternal(token) {
|
|
|
693
720
|
if (listUpdates) {
|
|
694
721
|
result.listUpdates = listUpdates;
|
|
695
722
|
}
|
|
723
|
+
if (pendingLearnings) {
|
|
724
|
+
result.pendingLearnings = pendingLearnings;
|
|
725
|
+
}
|
|
696
726
|
// Checkpoint: push state to Gist if in Gist mode.
|
|
697
727
|
// If getStateManagerAsync was not called before this command ran,
|
|
698
728
|
// isGistMode() will be false and checkpoint is correctly skipped.
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { buildCandidateLinkedPR, createAutopilotScout } from './scout-bridge.js';
|
|
16
16
|
import { getStateManager } from '../core/index.js';
|
|
17
|
-
import { gradeFromCandidate } from '../core/issue-grading.js';
|
|
17
|
+
import { gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
|
|
18
18
|
import { warn } from '../core/logger.js';
|
|
19
19
|
const MODULE = 'features';
|
|
20
20
|
/**
|
|
@@ -43,19 +43,13 @@ function sanitizeViabilityScore(raw) {
|
|
|
43
43
|
*/
|
|
44
44
|
function toFeaturesCandidate(scoutCandidate, getState) {
|
|
45
45
|
const repoScoreRecord = getState.getRepoScore(scoutCandidate.issue.repo);
|
|
46
|
-
//
|
|
47
|
-
// pipeline reuses the same vetting code that does emit projectHealth on
|
|
48
|
-
// `vetIssue`, but on this surface scout returns the multi-issue list view
|
|
49
|
-
// which today does not propagate per-candidate health into IssueCandidate.
|
|
50
|
-
// Treating health as unknown grades from the autopilot-tracked repoScore
|
|
51
|
-
// alone, falling to 'F' for unfamiliar repos — an honest "we haven't seen
|
|
52
|
-
// this repo" rather than a fabricated score.
|
|
46
|
+
// Grade from the health scout fetched while vetting (#332); see runSearch.
|
|
53
47
|
const grade = gradeFromCandidate({
|
|
54
48
|
repo: scoutCandidate.issue.repo,
|
|
55
|
-
projectHealth: {
|
|
49
|
+
projectHealth: scoutCandidate.projectHealth ?? {
|
|
56
50
|
repo: scoutCandidate.issue.repo,
|
|
57
51
|
checkFailed: true,
|
|
58
|
-
failureReason: 'health not
|
|
52
|
+
failureReason: 'health not supplied by the caller',
|
|
59
53
|
},
|
|
60
54
|
getRepoScore: (repo) => {
|
|
61
55
|
const score = getState.getRepoScore(repo);
|
|
@@ -78,7 +72,7 @@ function toFeaturesCandidate(scoutCandidate, getState) {
|
|
|
78
72
|
url: scoutCandidate.issue.url,
|
|
79
73
|
labels: scoutCandidate.issue.labels,
|
|
80
74
|
},
|
|
81
|
-
recommendation: scoutCandidate.recommendation,
|
|
75
|
+
recommendation: reconcileRecommendation(scoutCandidate.recommendation, grade),
|
|
82
76
|
reasonsToApprove: scoutCandidate.reasonsToApprove,
|
|
83
77
|
reasonsToSkip: scoutCandidate.reasonsToSkip,
|
|
84
78
|
searchPriority: scoutCandidate.searchPriority,
|
|
@@ -24,6 +24,13 @@ export interface GuidelinesStoreOutput {
|
|
|
24
24
|
/** Set when the post-mutation Gist checkpoint failed; the local mutation succeeded (#1370). */
|
|
25
25
|
gistSyncWarning?: string;
|
|
26
26
|
}
|
|
27
|
+
export interface MarkExtractedOutput {
|
|
28
|
+
repo: string;
|
|
29
|
+
/** PRs stamped `learningsExtractedAt` this call. */
|
|
30
|
+
marked: number;
|
|
31
|
+
/** Set when the post-mutation Gist checkpoint failed; the local mutation succeeded (#1370). */
|
|
32
|
+
gistSyncWarning?: string;
|
|
33
|
+
}
|
|
27
34
|
export interface GuidelinesResetOutput {
|
|
28
35
|
repo: string;
|
|
29
36
|
/** True when an existing file was tombstoned, false when no file existed. */
|
|
@@ -83,6 +90,14 @@ export declare function runGuidelinesList(): Promise<GuidelinesListOutput>;
|
|
|
83
90
|
* outputJson error envelope to surface that to the host cleanly.
|
|
84
91
|
*/
|
|
85
92
|
export declare function runGuidelinesStore(options: StoreOptions): Promise<GuidelinesStoreOutput>;
|
|
93
|
+
/**
|
|
94
|
+
* Stamp `learningsExtractedAt` on every merged/closed PR of `repo` whose
|
|
95
|
+
* comment bundle was fetched (`commentsFetchedAt` set) but not yet marked
|
|
96
|
+
* extracted (#1696). The host calls this after storing guidelines, or after
|
|
97
|
+
* deciding a corpus carried no signal, so `daily` stops reporting those PRs
|
|
98
|
+
* as unextracted. Idempotent: already-stamped PRs are left alone.
|
|
99
|
+
*/
|
|
100
|
+
export declare function runMarkExtracted(options: RepoOption): Promise<MarkExtractedOutput>;
|
|
86
101
|
/** Tombstone the guidelines file for `repo`. */
|
|
87
102
|
export declare function runGuidelinesReset(options: RepoOption): Promise<GuidelinesResetOutput>;
|
|
88
103
|
/**
|
|
@@ -80,6 +80,28 @@ export async function runGuidelinesStore(options) {
|
|
|
80
80
|
...(gistSyncWarning ? { gistSyncWarning } : {}),
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Stamp `learningsExtractedAt` on every merged/closed PR of `repo` whose
|
|
85
|
+
* comment bundle was fetched (`commentsFetchedAt` set) but not yet marked
|
|
86
|
+
* extracted (#1696). The host calls this after storing guidelines, or after
|
|
87
|
+
* deciding a corpus carried no signal, so `daily` stops reporting those PRs
|
|
88
|
+
* as unextracted. Idempotent: already-stamped PRs are left alone.
|
|
89
|
+
*/
|
|
90
|
+
export async function runMarkExtracted(options) {
|
|
91
|
+
validateRepo(options.repo);
|
|
92
|
+
const sm = getStateManager();
|
|
93
|
+
const repoUrlPrefix = `https://github.com/${options.repo}/`;
|
|
94
|
+
const now = new Date().toISOString();
|
|
95
|
+
let marked = 0;
|
|
96
|
+
for (const pr of [...(sm.getMergedPRs() ?? []), ...(sm.getClosedPRs() ?? [])]) {
|
|
97
|
+
if (!pr.url.startsWith(repoUrlPrefix) || !pr.commentsFetchedAt || pr.learningsExtractedAt)
|
|
98
|
+
continue;
|
|
99
|
+
sm.markPRLearningsExtracted(pr.url, now);
|
|
100
|
+
marked++;
|
|
101
|
+
}
|
|
102
|
+
const gistSyncWarning = marked > 0 ? await maybeCheckpoint(sm, MODULE) : null;
|
|
103
|
+
return { repo: options.repo, marked, ...(gistSyncWarning ? { gistSyncWarning } : {}) };
|
|
104
|
+
}
|
|
83
105
|
/** Tombstone the guidelines file for `repo`. */
|
|
84
106
|
export async function runGuidelinesReset(options) {
|
|
85
107
|
validateRepo(options.repo);
|
|
@@ -20,7 +20,7 @@ import { execFileSync } from 'node:child_process';
|
|
|
20
20
|
import * as fs from 'node:fs';
|
|
21
21
|
import { errorMessage, getOctokit, getStateManager, isRateLimitError, maybeCheckpoint, parseGitHubUrl, requireGitHubToken, } from '../core/index.js';
|
|
22
22
|
import { warn } from '../core/logger.js';
|
|
23
|
-
import { writePreparedSection } from './overnight.js';
|
|
23
|
+
import { publishReport, writePreparedSection } from './overnight.js';
|
|
24
24
|
const MODULE = 'overnight-push-prep';
|
|
25
25
|
/** The only ref namespace this command ever pushes to. */
|
|
26
26
|
export const PREP_REF_PREFIX = 'refs/heads/prep/';
|
|
@@ -286,6 +286,10 @@ export async function runOvernightPushPrep(options) {
|
|
|
286
286
|
reportWarning = `could not rewrite ${lastRun.reportPath}: ${errorMessage(err)}`;
|
|
287
287
|
warn(MODULE, reportWarning);
|
|
288
288
|
}
|
|
289
|
+
// Outside the try: publishReport warns on its own and must never be
|
|
290
|
+
// mistaken for a failed report write.
|
|
291
|
+
if (!reportWarning)
|
|
292
|
+
publishReport(sm, lastRun.reportPath);
|
|
289
293
|
gistSyncWarning = await maybeCheckpoint(sm, MODULE);
|
|
290
294
|
}
|
|
291
295
|
try {
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
* the model: a scheduler runs it after the tick, and it only pushes to
|
|
19
19
|
* `prep/*` on the user's own fork.
|
|
20
20
|
*/
|
|
21
|
+
import { getStateManager } from '../core/index.js';
|
|
21
22
|
import type { PRCheckFailure } from '../core/pr-monitor.js';
|
|
22
23
|
import type { ActionableIssueType, OvernightPrepared } from '../core/types.js';
|
|
23
|
-
import type { DailyOutput, DailyWarning } from '../formatters/json.js';
|
|
24
|
+
import type { DailyOutput, DailyWarning, PendingLearnings } from '../formatters/json.js';
|
|
24
25
|
import type { AttentionSummary } from '../core/pr-attention.js';
|
|
25
26
|
/** One item in either bucket; which bucket is the array it lives in. */
|
|
26
27
|
export interface OvernightItem {
|
|
@@ -44,6 +45,8 @@ export interface OvernightOutput {
|
|
|
44
45
|
carriedPrepared: number;
|
|
45
46
|
/** Set when the run could not be pushed to the Gist; the local cache has it. */
|
|
46
47
|
gistSyncWarning?: string;
|
|
48
|
+
/** Repos whose merged-PR learnings the overnight run should extract (#1696); absent when none. */
|
|
49
|
+
pendingLearnings?: PendingLearnings;
|
|
47
50
|
}
|
|
48
51
|
type ReportBody = Pick<OvernightOutput, 'runAt' | 'prepare' | 'judgment' | 'attention' | 'failures' | 'warnings'>;
|
|
49
52
|
/** Freshness block `startup` surfaces (#1574). */
|
|
@@ -57,6 +60,8 @@ export interface OvernightFreshness {
|
|
|
57
60
|
judgmentCount: number;
|
|
58
61
|
/** Branches recorded via `overnight record` since the run. */
|
|
59
62
|
preparedCount: number;
|
|
63
|
+
/** `local`: the file at `reportPath` is here. `gist`: only the published copy, read it with `overnight report`. */
|
|
64
|
+
reportAvailable: ReportAvailability;
|
|
60
65
|
}
|
|
61
66
|
/** Pure: split the daily check into prepare vs judgment items. */
|
|
62
67
|
export declare function bucketize(daily: Pick<DailyOutput, 'actionableIssues' | 'commentedIssues'>): {
|
|
@@ -96,6 +101,32 @@ export interface OvernightRecordOutput {
|
|
|
96
101
|
export declare function runOvernightRecord(options: OvernightRecordOptions): Promise<OvernightRecordOutput>;
|
|
97
102
|
/** Pure: swap the "Prepared branches" section (up to the next `## `) for `section`. */
|
|
98
103
|
export declare function replacePreparedSection(report: string, section: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Stage the report file's current contents as the Gist's `overnight-report.md`
|
|
106
|
+
* (#1698), so `/oss` on another machine can read what a headless box wrote.
|
|
107
|
+
* Callers checkpoint right after. A report that cannot be read is a warning,
|
|
108
|
+
* not a failure: the run itself succeeded.
|
|
109
|
+
*/
|
|
110
|
+
export declare function publishReport(sm: ReturnType<typeof getStateManager>, reportPath: string): void;
|
|
111
|
+
/** Where `overnight report` can read the morning report from. */
|
|
112
|
+
export type ReportAvailability = 'local' | 'gist' | 'none';
|
|
113
|
+
/**
|
|
114
|
+
* The morning report's text and where it came from: the local file when it
|
|
115
|
+
* exists (the machine that ran overnight), else the Gist copy (any other
|
|
116
|
+
* machine in Gist mode), else nothing.
|
|
117
|
+
*/
|
|
118
|
+
export declare function readReport(sm: ReturnType<typeof getStateManager>, reportPath: string): {
|
|
119
|
+
source: ReportAvailability;
|
|
120
|
+
content: string | null;
|
|
121
|
+
};
|
|
122
|
+
export interface OvernightReportOutput {
|
|
123
|
+
runAt: string;
|
|
124
|
+
reportPath: string;
|
|
125
|
+
source: ReportAvailability;
|
|
126
|
+
content: string | null;
|
|
127
|
+
}
|
|
128
|
+
/** `overnight report`: print the latest morning report from wherever it is readable. */
|
|
129
|
+
export declare function runOvernightReport(): OvernightReportOutput;
|
|
99
130
|
/** Freshness for `startup` (#1574); undefined before the first overnight run. */
|
|
100
131
|
export declare function overnightFreshness(now?: Date): OvernightFreshness | undefined;
|
|
101
132
|
export interface ScheduleOptions {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import * as fs from 'node:fs';
|
|
22
22
|
import * as os from 'node:os';
|
|
23
23
|
import * as path from 'node:path';
|
|
24
|
-
import { getStateManager, maybeCheckpoint, requireGitHubToken } from '../core/index.js';
|
|
24
|
+
import { errorMessage, getStateManager, maybeCheckpoint, requireGitHubToken } from '../core/index.js';
|
|
25
25
|
import { warn } from '../core/logger.js';
|
|
26
26
|
import { getReportsDir } from '../core/paths.js';
|
|
27
27
|
import { executeDailyCheck } from './daily.js';
|
|
@@ -32,7 +32,14 @@ const BUCKET_BY_TYPE = {
|
|
|
32
32
|
ci_failing: { bucket: 'prepare', reason: 'CI is red: an agent can diagnose and prepare a fix branch' },
|
|
33
33
|
merge_conflict: { bucket: 'prepare', reason: 'merge conflict: an agent can rebase in a worktree' },
|
|
34
34
|
needs_changes: { bucket: 'prepare', reason: 'changes requested: an agent can prepare the requested edits' },
|
|
35
|
-
|
|
35
|
+
// The gaps are PR-body checkboxes, and the only way to tick them is
|
|
36
|
+
// `gh pr edit --body`, a write the unattended run must not make. Two
|
|
37
|
+
// nights of preparers spent on these both ended blocked with a suggested
|
|
38
|
+
// body edit for the morning, so that suggestion is now the judgment item.
|
|
39
|
+
incomplete_checklist: {
|
|
40
|
+
bucket: 'judgment',
|
|
41
|
+
reason: 'checklist incomplete: the gaps are PR-body checkboxes, which only you can edit',
|
|
42
|
+
},
|
|
36
43
|
needs_response: { bucket: 'judgment', reason: 'a maintainer is waiting on your reply' },
|
|
37
44
|
};
|
|
38
45
|
/** Pure: split the daily check into prepare vs judgment items. */
|
|
@@ -148,6 +155,7 @@ export async function runOvernight() {
|
|
|
148
155
|
const previous = sm.getLastOvernight();
|
|
149
156
|
const carried = previous?.reportPath === reportPath ? previous.prepared : [];
|
|
150
157
|
fs.writeFileSync(reportPath, renderReport(body, carried), { mode: 0o600 });
|
|
158
|
+
publishReport(sm, reportPath);
|
|
151
159
|
sm.setLastOvernight({
|
|
152
160
|
runAt,
|
|
153
161
|
reportPath,
|
|
@@ -158,7 +166,13 @@ export async function runOvernight() {
|
|
|
158
166
|
// executeDailyCheck already checkpointed the Gist; this write came after it,
|
|
159
167
|
// and in Gist mode setLastOvernight only reaches the local cache (#1629 class).
|
|
160
168
|
const gistSyncWarning = await maybeCheckpoint(sm, MODULE);
|
|
161
|
-
return {
|
|
169
|
+
return {
|
|
170
|
+
...body,
|
|
171
|
+
reportPath,
|
|
172
|
+
carriedPrepared: carried.length,
|
|
173
|
+
...(gistSyncWarning ? { gistSyncWarning } : {}),
|
|
174
|
+
...(daily.pendingLearnings ? { pendingLearnings: daily.pendingLearnings } : {}),
|
|
175
|
+
};
|
|
162
176
|
}
|
|
163
177
|
/** Append one prepared branch to state and to the report of the latest run. */
|
|
164
178
|
export async function runOvernightRecord(options) {
|
|
@@ -176,6 +190,7 @@ export async function runOvernightRecord(options) {
|
|
|
176
190
|
const prepared = [...last.prepared, entry];
|
|
177
191
|
sm.setLastOvernight({ ...last, prepared });
|
|
178
192
|
const { reportRecreated } = writePreparedSection(last.reportPath, prepared);
|
|
193
|
+
publishReport(sm, last.reportPath);
|
|
179
194
|
const gistSyncWarning = await maybeCheckpoint(sm, MODULE);
|
|
180
195
|
return {
|
|
181
196
|
reportPath: last.reportPath,
|
|
@@ -192,6 +207,41 @@ export function replacePreparedSection(report, section) {
|
|
|
192
207
|
const next = report.indexOf('\n## ', start + PREPARED_HEADING.length);
|
|
193
208
|
return report.slice(0, start) + section + (next === -1 ? '' : report.slice(next));
|
|
194
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Stage the report file's current contents as the Gist's `overnight-report.md`
|
|
212
|
+
* (#1698), so `/oss` on another machine can read what a headless box wrote.
|
|
213
|
+
* Callers checkpoint right after. A report that cannot be read is a warning,
|
|
214
|
+
* not a failure: the run itself succeeded.
|
|
215
|
+
*/
|
|
216
|
+
export function publishReport(sm, reportPath) {
|
|
217
|
+
if (!sm.isGistMode())
|
|
218
|
+
return;
|
|
219
|
+
try {
|
|
220
|
+
sm.setOvernightReportDocument(fs.readFileSync(reportPath, 'utf8'));
|
|
221
|
+
}
|
|
222
|
+
catch (err) {
|
|
223
|
+
warn(MODULE, `Could not publish ${reportPath} to the Gist: ${errorMessage(err)}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The morning report's text and where it came from: the local file when it
|
|
228
|
+
* exists (the machine that ran overnight), else the Gist copy (any other
|
|
229
|
+
* machine in Gist mode), else nothing.
|
|
230
|
+
*/
|
|
231
|
+
export function readReport(sm, reportPath) {
|
|
232
|
+
if (fs.existsSync(reportPath))
|
|
233
|
+
return { source: 'local', content: fs.readFileSync(reportPath, 'utf8') };
|
|
234
|
+
const gist = sm.getOvernightReportDocument();
|
|
235
|
+
return gist ? { source: 'gist', content: gist } : { source: 'none', content: null };
|
|
236
|
+
}
|
|
237
|
+
/** `overnight report`: print the latest morning report from wherever it is readable. */
|
|
238
|
+
export function runOvernightReport() {
|
|
239
|
+
const sm = getStateManager();
|
|
240
|
+
const last = sm.getLastOvernight();
|
|
241
|
+
if (!last)
|
|
242
|
+
throw new Error('No overnight run recorded yet; run `overnight` first.');
|
|
243
|
+
return { runAt: last.runAt, reportPath: last.reportPath, ...readReport(sm, last.reportPath) };
|
|
244
|
+
}
|
|
195
245
|
/** Freshness for `startup` (#1574); undefined before the first overnight run. */
|
|
196
246
|
export function overnightFreshness(now = new Date()) {
|
|
197
247
|
const last = getStateManager().getLastOvernight();
|
|
@@ -204,6 +254,7 @@ export function overnightFreshness(now = new Date()) {
|
|
|
204
254
|
prepareCount: last.prepareCount,
|
|
205
255
|
judgmentCount: last.judgmentCount,
|
|
206
256
|
preparedCount: last.prepared.length,
|
|
257
|
+
reportAvailable: readReport(getStateManager(), last.reportPath).source,
|
|
207
258
|
};
|
|
208
259
|
// Never emit a non-finite number into the JSON contract (Infinity serialises as null).
|
|
209
260
|
return Number.isNaN(ageMs)
|
|
@@ -260,6 +311,10 @@ const GH_READ_SUBCOMMANDS = [
|
|
|
260
311
|
export const OVERNIGHT_DISALLOWED_TOOLS = [
|
|
261
312
|
'Bash(git push)',
|
|
262
313
|
'Bash(git push *)',
|
|
314
|
+
// The -C form of push: `git -C <dir> push` would otherwise slip past a
|
|
315
|
+
// prefix rule on `git push`.
|
|
316
|
+
'Bash(git * push)',
|
|
317
|
+
'Bash(git * push *)',
|
|
263
318
|
'Bash(gh pr create *)',
|
|
264
319
|
'Bash(gh pr comment *)',
|
|
265
320
|
'Bash(gh pr merge *)',
|
|
@@ -289,7 +344,15 @@ export const OVERNIGHT_ALLOWED_TOOLS = [
|
|
|
289
344
|
'Glob',
|
|
290
345
|
'Grep',
|
|
291
346
|
'Task',
|
|
292
|
-
|
|
347
|
+
// Both the bare and the `-C <dir>` forms: a preparer's worktree is never its
|
|
348
|
+
// cwd, and `cd <dir> && git ...` is denied under dontAsk, so without `-C`
|
|
349
|
+
// every preparer blocks (#1697).
|
|
350
|
+
...GIT_SUBCOMMANDS.flatMap((sub) => [
|
|
351
|
+
`Bash(git ${sub})`,
|
|
352
|
+
`Bash(git ${sub} *)`,
|
|
353
|
+
`Bash(git -C * ${sub})`,
|
|
354
|
+
`Bash(git -C * ${sub} *)`,
|
|
355
|
+
]),
|
|
293
356
|
...GH_READ_SUBCOMMANDS.map((sub) => `Bash(gh ${sub} *)`),
|
|
294
357
|
'Bash(node *)',
|
|
295
358
|
'Bash(pnpm *)',
|
package/dist/commands/search.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout, SEARCH_DIVERSITY_RATIO, } from './scout-bridge.js';
|
|
6
6
|
import { SearchStrategySchema } from '@oss-scout/core';
|
|
7
7
|
import { classifyLinkedPR, getStateManager, maybeCheckpoint } from '../core/index.js';
|
|
8
|
-
import { gradeFromCandidate } from '../core/issue-grading.js';
|
|
8
|
+
import { gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
|
|
9
9
|
import { computeStrategy } from '../core/strategy.js';
|
|
10
10
|
import { refreshStarredReposIfStale } from '../core/starred-repos.js';
|
|
11
11
|
import { debug, warn } from '../core/logger.js';
|
|
@@ -210,23 +210,19 @@ export async function runSearch(options) {
|
|
|
210
210
|
const searchOutput = {
|
|
211
211
|
candidates: visibleCandidates.map((c) => {
|
|
212
212
|
const repoScoreRecord = stateManager.getRepoScore(c.issue.repo);
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
//
|
|
216
|
-
// the
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
// Note (#1465): repoScore here is the cached HISTORY score (the user's
|
|
221
|
-
// own merge outcomes — docs/repo-scores.md §History score), so this
|
|
222
|
-
// grade reflects history only; `vet` later re-grades the same issue
|
|
223
|
-
// with freshly fetched repo health and can legitimately disagree.
|
|
213
|
+
// Grade from the health scout fetched while vetting this candidate
|
|
214
|
+
// (#332). Search used to pass a `checkFailed` sentinel and grade from
|
|
215
|
+
// the user's own history alone, so every repo without a merged PR of
|
|
216
|
+
// ours scored the bottom band regardless of how healthy it was, and a
|
|
217
|
+
// grade-1 "approve" looked like a contradiction. `repoScore` is still
|
|
218
|
+
// the cached HISTORY score (#1465); `vet` re-grades with fresh health.
|
|
219
|
+
// Scout always supplies health; the fallback only serves bare fixtures.
|
|
224
220
|
const grade = gradeFromCandidate({
|
|
225
221
|
repo: c.issue.repo,
|
|
226
|
-
projectHealth: {
|
|
222
|
+
projectHealth: c.projectHealth ?? {
|
|
227
223
|
repo: c.issue.repo,
|
|
228
224
|
checkFailed: true,
|
|
229
|
-
failureReason: 'health not
|
|
225
|
+
failureReason: 'health not supplied by the caller',
|
|
230
226
|
},
|
|
231
227
|
getRepoScore: (repo) => {
|
|
232
228
|
const score = stateManager.getRepoScore(repo);
|
|
@@ -249,7 +245,7 @@ export async function runSearch(options) {
|
|
|
249
245
|
url: c.issue.url,
|
|
250
246
|
labels: c.issue.labels,
|
|
251
247
|
},
|
|
252
|
-
recommendation: c.recommendation,
|
|
248
|
+
recommendation: reconcileRecommendation(c.recommendation, grade),
|
|
253
249
|
reasonsToApprove: c.reasonsToApprove,
|
|
254
250
|
reasonsToSkip: c.reasonsToSkip,
|
|
255
251
|
searchPriority: c.searchPriority,
|
package/dist/commands/setup.js
CHANGED
|
@@ -133,6 +133,15 @@ export async function runSetup(options) {
|
|
|
133
133
|
results[key] = value || '(cleared)';
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
136
|
+
case 'autoExtractLearnings': {
|
|
137
|
+
if (value !== 'true' && value !== 'false') {
|
|
138
|
+
throw new ValidationError(`Invalid value for autoExtractLearnings: "${value}". Must be "true" or "false".`);
|
|
139
|
+
}
|
|
140
|
+
const enabled = value === 'true';
|
|
141
|
+
stateManager.updateConfig({ autoExtractLearnings: enabled });
|
|
142
|
+
results[key] = String(enabled);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
136
145
|
case 'autoFormatBeforePush': {
|
|
137
146
|
if (value !== 'true' && value !== 'false') {
|
|
138
147
|
throw new ValidationError(`Invalid value for autoFormatBeforePush: "${value}". Must be "true" or "false".`);
|
|
@@ -6,7 +6,7 @@ import { getStateManager } from '../core/index.js';
|
|
|
6
6
|
// version where the captures are needed.
|
|
7
7
|
// eslint-disable-next-line regexp/no-unused-capturing-group
|
|
8
8
|
const GITHUB_URL_RE = /^https:\/\/github\.com\/([^/]+\/[^/]+)\/(?:issues|pull)\/(\d+)(?:[#/?].*)?$/;
|
|
9
|
-
const FILE_HEADER = '# Skipped Issues —
|
|
9
|
+
const FILE_HEADER = '# Skipped Issues — permanent\n# Format: YYYY-MM-DD URL\n\n';
|
|
10
10
|
function formatUtcDate(d) {
|
|
11
11
|
return d.toISOString().slice(0, 10);
|
|
12
12
|
}
|
package/dist/commands/startup.js
CHANGED
|
@@ -206,9 +206,19 @@ function shouldOpenBrowser(spaResult, throttleMs) {
|
|
|
206
206
|
}
|
|
207
207
|
async function triggerDashboardRefresh(port) {
|
|
208
208
|
try {
|
|
209
|
-
const
|
|
209
|
+
const base = `http://127.0.0.1:${port}`;
|
|
210
|
+
// POST /api/refresh is CSRF-gated and the token is only issued on the
|
|
211
|
+
// X-CSRF-Token header of GET /api/data, so prime it first.
|
|
212
|
+
const prime = await fetch(`${base}/api/data`, { signal: AbortSignal.timeout(5000) });
|
|
213
|
+
const csrfToken = prime.headers.get('x-csrf-token');
|
|
214
|
+
await prime.text().catch(() => { });
|
|
215
|
+
if (!prime.ok || !csrfToken) {
|
|
216
|
+
console.error(`[STARTUP] Dashboard refresh returned ${prime.status}: no CSRF token from /api/data`);
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
const res = await fetch(`${base}/api/refresh`, {
|
|
210
220
|
method: 'POST',
|
|
211
|
-
headers: { Origin: `http://oss.localhost:${port}
|
|
221
|
+
headers: { Origin: `http://oss.localhost:${port}`, 'X-CSRF-Token': csrfToken },
|
|
212
222
|
signal: AbortSignal.timeout(5000),
|
|
213
223
|
});
|
|
214
224
|
if (!res.ok) {
|
|
@@ -198,7 +198,7 @@ export const CONFIG_KEY_REGISTRY = [
|
|
|
198
198
|
},
|
|
199
199
|
{
|
|
200
200
|
key: 'skippedIssuesPath',
|
|
201
|
-
description: 'Path to the skipped-issues file (
|
|
201
|
+
description: 'Path to the skipped-issues file (entries are permanent).',
|
|
202
202
|
settableVia: 'setup',
|
|
203
203
|
valueHint: 'filesystem path',
|
|
204
204
|
},
|
|
@@ -227,6 +227,12 @@ export const CONFIG_KEY_REGISTRY = [
|
|
|
227
227
|
settableVia: 'setup',
|
|
228
228
|
valueHint: 'one of: local,gist',
|
|
229
229
|
},
|
|
230
|
+
{
|
|
231
|
+
key: 'autoExtractLearnings',
|
|
232
|
+
description: 'Extract per-repo learnings from freshly merged PRs automatically at /oss startup and overnight (#1696). false restores the extract_learnings action-menu item.',
|
|
233
|
+
settableVia: 'setup',
|
|
234
|
+
valueHint: 'true|false',
|
|
235
|
+
},
|
|
230
236
|
{
|
|
231
237
|
key: 'autoFormatBeforePush',
|
|
232
238
|
description: 'No effect. The hook that used this setting was removed in #1642; the key is kept in the schema for state-file compatibility.',
|
|
@@ -41,11 +41,11 @@ export declare const KEEP_GRADE_THRESHOLD = 4;
|
|
|
41
41
|
* sees can't flatly contradict. Any non-approve recommendation is returned
|
|
42
42
|
* unchanged.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
44
|
+
* Every surface grades from the health scout fetched while vetting (`search`
|
|
45
|
+
* and `features` included since #332), so the grade is high-fidelity
|
|
46
|
+
* everywhere and this applies everywhere. A `checkFailed` health (transient API
|
|
47
|
+
* error) still grades the bottom band for missing data; that downgrade to
|
|
48
|
+
* "needs_review" is the honest answer for an unverified repo.
|
|
49
49
|
*/
|
|
50
50
|
export declare function reconcileRecommendation(recommendation: IssueRecommendation, grade: GradeResult): IssueRecommendation;
|
|
51
51
|
/**
|
|
@@ -94,11 +94,9 @@ export declare function deriveGradeSignals(params: {
|
|
|
94
94
|
* Which "repo score" this grades from (#1465): the `getRepoScore` input is
|
|
95
95
|
* the cached HISTORY record (the user's own merge outcomes, see
|
|
96
96
|
* docs/repo-scores.md §History score) — NOT `repo-vet`'s fresh health
|
|
97
|
-
* rubric. The fresh side
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* history-side signals, while `vet` re-grades with fresh health. Same 1-10
|
|
101
|
-
* scale, different inputs — the two surfaces can legitimately disagree.
|
|
97
|
+
* rubric. The fresh side enters through `projectHealth`, which scout fetches
|
|
98
|
+
* per candidate on every surface (#332); `vet` re-fetches it later, so the
|
|
99
|
+
* two surfaces can still disagree when the repo changed in between.
|
|
102
100
|
*/
|
|
103
101
|
export declare function gradeFromCandidate(params: {
|
|
104
102
|
repo: string;
|
|
@@ -24,11 +24,11 @@ export const KEEP_GRADE_THRESHOLD = 4;
|
|
|
24
24
|
* sees can't flatly contradict. Any non-approve recommendation is returned
|
|
25
25
|
* unchanged.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
27
|
+
* Every surface grades from the health scout fetched while vetting (`search`
|
|
28
|
+
* and `features` included since #332), so the grade is high-fidelity
|
|
29
|
+
* everywhere and this applies everywhere. A `checkFailed` health (transient API
|
|
30
|
+
* error) still grades the bottom band for missing data; that downgrade to
|
|
31
|
+
* "needs_review" is the honest answer for an unverified repo.
|
|
32
32
|
*/
|
|
33
33
|
export function reconcileRecommendation(recommendation, grade) {
|
|
34
34
|
return recommendation === 'approve' && grade.score < KEEP_GRADE_THRESHOLD ? 'needs_review' : recommendation;
|
|
@@ -135,11 +135,9 @@ export function deriveGradeSignals(params) {
|
|
|
135
135
|
* Which "repo score" this grades from (#1465): the `getRepoScore` input is
|
|
136
136
|
* the cached HISTORY record (the user's own merge outcomes, see
|
|
137
137
|
* docs/repo-scores.md §History score) — NOT `repo-vet`'s fresh health
|
|
138
|
-
* rubric. The fresh side
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* history-side signals, while `vet` re-grades with fresh health. Same 1-10
|
|
142
|
-
* scale, different inputs — the two surfaces can legitimately disagree.
|
|
138
|
+
* rubric. The fresh side enters through `projectHealth`, which scout fetches
|
|
139
|
+
* per candidate on every surface (#332); `vet` re-fetches it later, so the
|
|
140
|
+
* two surfaces can still disagree when the repo changed in between.
|
|
143
141
|
*/
|
|
144
142
|
export function gradeFromCandidate(params) {
|
|
145
143
|
const repoScore = params.getRepoScore(params.repo);
|