@oss-autopilot/core 3.42.5 → 3.44.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-pre-action.js +8 -3
- package/dist/cli-registry.js +428 -27
- package/dist/cli.bundle.cjs +212 -156
- package/dist/commands/check-integration.js +5 -1
- package/dist/commands/cleanup.d.ts +80 -0
- package/dist/commands/cleanup.js +334 -0
- package/dist/commands/comments.d.ts +14 -1
- package/dist/commands/comments.js +17 -5
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.js +63 -6
- package/dist/commands/daily-dismiss-filter.d.ts +7 -0
- package/dist/commands/daily-dismiss-filter.js +17 -1
- package/dist/commands/daily-ledger.d.ts +150 -0
- package/dist/commands/daily-ledger.js +248 -0
- package/dist/commands/daily-recent-prs.d.ts +26 -0
- package/dist/commands/daily-recent-prs.js +55 -0
- package/dist/commands/daily-render.d.ts +2 -1
- package/dist/commands/daily-render.js +4 -1
- package/dist/commands/daily.d.ts +5 -1
- package/dist/commands/daily.js +83 -93
- package/dist/commands/dashboard-cache.d.ts +2 -0
- package/dist/commands/dashboard-cache.js +33 -8
- package/dist/commands/dashboard-data.js +113 -69
- package/dist/commands/dashboard-gist-sync.js +3 -1
- package/dist/commands/dashboard-lifecycle.d.ts +36 -8
- package/dist/commands/dashboard-lifecycle.js +132 -39
- package/dist/commands/dashboard-process.d.ts +49 -1
- package/dist/commands/dashboard-process.js +111 -12
- package/dist/commands/dashboard-server.js +89 -23
- package/dist/commands/detect-formatters.js +1 -0
- package/dist/commands/dismiss.js +11 -7
- package/dist/commands/doctor.d.ts +15 -1
- package/dist/commands/doctor.js +66 -5
- package/dist/commands/draft.d.ts +77 -0
- package/dist/commands/draft.js +218 -0
- package/dist/commands/eval.js +1 -0
- package/dist/commands/fork-prune.d.ts +58 -0
- package/dist/commands/fork-prune.js +247 -0
- package/dist/commands/guidelines.d.ts +69 -2
- package/dist/commands/guidelines.js +158 -14
- package/dist/commands/index.d.ts +29 -4
- package/dist/commands/index.js +20 -3
- package/dist/commands/issue-thread.d.ts +46 -0
- package/dist/commands/issue-thread.js +123 -0
- package/dist/commands/ledger-backfill.d.ts +9 -0
- package/dist/commands/ledger-backfill.js +44 -1
- package/dist/commands/list-mark-done.d.ts +2 -1
- package/dist/commands/list-mark-done.js +3 -1
- package/dist/commands/list-move-tier.d.ts +2 -1
- package/dist/commands/list-move-tier.js +3 -1
- package/dist/commands/local-repos.js +10 -5
- package/dist/commands/locate-issue-list.d.ts +40 -17
- package/dist/commands/locate-issue-list.js +148 -88
- package/dist/commands/move.js +7 -1
- package/dist/commands/overnight-handoff.d.ts +17 -7
- package/dist/commands/overnight-handoff.js +36 -14
- package/dist/commands/overnight-push-prep.d.ts +14 -8
- package/dist/commands/overnight-push-prep.js +107 -35
- package/dist/commands/overnight-tool-rules.d.ts +54 -0
- package/dist/commands/overnight-tool-rules.js +217 -0
- package/dist/commands/overnight.d.ts +5 -6
- package/dist/commands/overnight.js +61 -140
- package/dist/commands/parse-list.js +7 -1
- package/dist/commands/policy.d.ts +90 -0
- package/dist/commands/policy.js +276 -0
- package/dist/commands/pr-create.d.ts +48 -0
- package/dist/commands/pr-create.js +200 -0
- package/dist/commands/pr-preflight.d.ts +69 -0
- package/dist/commands/pr-preflight.js +348 -0
- package/dist/commands/repo-vet.d.ts +9 -0
- package/dist/commands/repo-vet.js +36 -11
- package/dist/commands/scout-bridge.js +18 -8
- package/dist/commands/search.js +7 -0
- package/dist/commands/setup.d.ts +3 -3
- package/dist/commands/setup.js +160 -48
- package/dist/commands/skip-add.js +10 -1
- package/dist/commands/startup.d.ts +12 -3
- package/dist/commands/startup.js +82 -49
- package/dist/commands/state-cmd.d.ts +2 -0
- package/dist/commands/state-cmd.js +5 -1
- package/dist/commands/stats.js +1 -0
- package/dist/commands/status.js +6 -0
- package/dist/commands/strategy.js +1 -0
- package/dist/commands/validation.d.ts +5 -0
- package/dist/commands/validation.js +5 -0
- package/dist/commands/vet-list.d.ts +6 -0
- package/dist/commands/vet-list.js +26 -1
- package/dist/commands/vet.d.ts +20 -0
- package/dist/commands/vet.js +133 -2
- package/dist/commands/work.d.ts +4 -0
- package/dist/commands/work.js +34 -11
- package/dist/core/__fixtures__/prompt-injection-payloads.js +31 -0
- package/dist/core/anti-llm-policy.d.ts +3 -0
- package/dist/core/anti-llm-policy.js +3 -0
- package/dist/core/auth.js +2 -0
- package/dist/core/ci-analysis.d.ts +7 -2
- package/dist/core/ci-analysis.js +76 -21
- package/dist/core/commit-date.d.ts +45 -0
- package/dist/core/commit-date.js +45 -0
- package/dist/core/compliance-score.d.ts +3 -0
- package/dist/core/compliance-score.js +13 -9
- package/dist/core/config-registry.d.ts +27 -2
- package/dist/core/config-registry.js +94 -7
- package/dist/core/contributing.d.ts +2 -3
- package/dist/core/contributing.js +2 -3
- package/dist/core/daily-logic.d.ts +30 -5
- package/dist/core/daily-logic.js +68 -19
- package/dist/core/errors.d.ts +37 -3
- package/dist/core/errors.js +54 -5
- package/dist/core/fork-prune.d.ts +149 -0
- package/dist/core/fork-prune.js +333 -0
- package/dist/core/gist-health.d.ts +15 -3
- package/dist/core/gist-health.js +8 -0
- package/dist/core/gist-state-store.d.ts +24 -4
- package/dist/core/gist-state-store.js +98 -51
- package/dist/core/github-stats.d.ts +110 -16
- package/dist/core/github-stats.js +295 -110
- package/dist/core/http-cache.d.ts +0 -10
- package/dist/core/http-cache.js +0 -19
- package/dist/core/index.d.ts +13 -6
- package/dist/core/index.js +16 -6
- package/dist/core/issue-conversation.d.ts +8 -2
- package/dist/core/issue-conversation.js +31 -12
- package/dist/core/local-config.d.ts +95 -0
- package/dist/core/local-config.js +270 -0
- package/dist/core/merged-pr-notes.d.ts +2 -2
- package/dist/core/pacing.d.ts +41 -0
- package/dist/core/pacing.js +115 -0
- package/dist/core/pagination.d.ts +55 -0
- package/dist/core/pagination.js +59 -0
- package/dist/core/paths.d.ts +7 -0
- package/dist/core/paths.js +9 -0
- package/dist/core/pr-assembly.d.ts +2 -0
- package/dist/core/pr-assembly.js +6 -2
- package/dist/core/pr-graphql.d.ts +53 -4
- package/dist/core/pr-graphql.js +87 -14
- package/dist/core/pr-monitor.d.ts +35 -12
- package/dist/core/pr-monitor.js +110 -26
- package/dist/core/pr-preflight.d.ts +154 -0
- package/dist/core/pr-preflight.js +753 -0
- package/dist/core/pr-quality-rubric.d.ts +0 -6
- package/dist/core/pr-quality-rubric.js +0 -8
- package/dist/core/pr-template.d.ts +2 -0
- package/dist/core/pr-template.js +5 -1
- package/dist/core/prose-script.d.ts +72 -0
- package/dist/core/prose-script.js +223 -0
- package/dist/core/repo-policy.d.ts +111 -0
- package/dist/core/repo-policy.js +428 -0
- package/dist/core/repo-score-manager.d.ts +66 -0
- package/dist/core/repo-score-manager.js +140 -1
- package/dist/core/review-analysis.d.ts +49 -21
- package/dist/core/review-analysis.js +89 -15
- package/dist/core/reviewed-prs-fetch.js +11 -29
- package/dist/core/reviewed-prs.js +8 -15
- package/dist/core/stale-data.d.ts +78 -0
- package/dist/core/stale-data.js +153 -0
- package/dist/core/state-persistence.d.ts +62 -27
- package/dist/core/state-persistence.js +338 -119
- package/dist/core/state-schema.d.ts +152 -210
- package/dist/core/state-schema.js +232 -80
- package/dist/core/state.d.ts +81 -8
- package/dist/core/state.js +239 -46
- package/dist/core/status-determination.js +32 -12
- package/dist/core/strategy.js +3 -1
- package/dist/core/types.d.ts +22 -1
- package/dist/core/types.js +1 -0
- package/dist/core/untrusted-content.d.ts +30 -11
- package/dist/core/untrusted-content.js +95 -42
- package/dist/core/urls.d.ts +33 -0
- package/dist/core/urls.js +94 -0
- package/dist/dashboard/assets/chart-panel-B-nLVgzQ.js +3 -0
- package/dist/dashboard/assets/index-5IvMGokL.js +55 -0
- package/dist/dashboard/index.html +1 -1
- package/dist/formatters/json.d.ts +432 -10
- package/dist/formatters/json.js +156 -1
- package/package.json +6 -6
- package/dist/core/ci-enforced-tools.d.ts +0 -35
- package/dist/core/ci-enforced-tools.js +0 -109
- package/dist/core/comment-decision.d.ts +0 -79
- package/dist/core/comment-decision.js +0 -82
- package/dist/core/extraction-categories.d.ts +0 -55
- package/dist/core/extraction-categories.js +0 -108
- package/dist/core/follow-up-history.d.ts +0 -40
- package/dist/core/follow-up-history.js +0 -71
- package/dist/core/issue-effort.d.ts +0 -29
- package/dist/core/issue-effort.js +0 -47
- package/dist/core/maintainer-hints.d.ts +0 -23
- package/dist/core/maintainer-hints.js +0 -36
- package/dist/core/workflow-state.d.ts +0 -56
- package/dist/core/workflow-state.js +0 -101
- package/dist/dashboard/assets/chart-panel-DPKNBUts.js +0 -3
- package/dist/dashboard/assets/index-B25bZOYX.js +0 -55
package/dist/commands/startup.js
CHANGED
|
@@ -16,12 +16,11 @@ import { executeDailyCheck } from './daily.js';
|
|
|
16
16
|
import { launchDashboardServer } from './dashboard-lifecycle.js';
|
|
17
17
|
import { recordBrowserOpened } from './dashboard-process.js';
|
|
18
18
|
import { parseIssueList } from './parse-list.js';
|
|
19
|
-
import { detectIssueListPath, persistConfigPath } from './locate-issue-list.js';
|
|
19
|
+
import { detectIssueListPath, persistConfigPath, suggestIssueListPath } from './locate-issue-list.js';
|
|
20
|
+
import { getMachinePath, setMachinePath } from '../core/local-config.js';
|
|
20
21
|
import { overnightFreshness } from './overnight.js';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Re-exported here for back-compat with existing consumers/tests.
|
|
24
|
-
export { parseIssueListPathFromConfig } from './locate-issue-list.js';
|
|
22
|
+
import { resolveDataDir } from '../core/paths.js';
|
|
23
|
+
import { countStaleData } from '../core/stale-data.js';
|
|
25
24
|
/**
|
|
26
25
|
* Count available and completed items in an issue list file.
|
|
27
26
|
* Available items exclude any vetting status that moves an item out of the
|
|
@@ -36,34 +35,11 @@ export function countIssueListItems(content) {
|
|
|
36
35
|
return { availableCount, completedCount, blockedCount };
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* The skipped-issues file for a configured list: the configured path (a
|
|
39
|
+
* relative one anchored to the list's directory), else `skipped-issues.md`
|
|
40
|
+
* next to the list, saved for this machine when found.
|
|
41
41
|
*/
|
|
42
|
-
|
|
43
|
-
// Steps 1-3 (state config → legacy config.md → known-path probes) live in
|
|
44
|
-
// locate-issue-list.ts (#1463), shared with the daily merge-loop.
|
|
45
|
-
const located = detectIssueListPath();
|
|
46
|
-
if (!located)
|
|
47
|
-
return undefined;
|
|
48
|
-
const issueListPath = located.path;
|
|
49
|
-
const source = located.source;
|
|
50
|
-
// 4. Count available/completed items
|
|
51
|
-
let availableCount = 0;
|
|
52
|
-
let completedCount = 0;
|
|
53
|
-
let blockedCount = 0;
|
|
54
|
-
let readError;
|
|
55
|
-
try {
|
|
56
|
-
const content = fs.readFileSync(issueListPath, 'utf8');
|
|
57
|
-
({ availableCount, completedCount, blockedCount } = countIssueListItems(content));
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
// Surface the failure in the envelope (#1448): a 0/0 count from an
|
|
61
|
-
// unreadable list is indistinguishable from a genuinely empty list, and
|
|
62
|
-
// an agent seeing 0 available may trigger a redundant fresh search.
|
|
63
|
-
readError = errorMessage(error);
|
|
64
|
-
console.error(`[STARTUP] Failed to read issue list at ${issueListPath}:`, readError);
|
|
65
|
-
}
|
|
66
|
-
// 5. Detect skipped issues file
|
|
42
|
+
function detectSkippedIssuesPath(issueListPath) {
|
|
67
43
|
let skippedIssuesPath;
|
|
68
44
|
// Check config first. A relative skippedIssuesPath is anchored to the issue
|
|
69
45
|
// list's (now absolute) directory — a stable base — not CWD, and upgraded to
|
|
@@ -73,8 +49,7 @@ export function detectIssueList() {
|
|
|
73
49
|
// unrelated working directory. A multi-segment relative that doesn't resolve
|
|
74
50
|
// here safely falls through to the list-dir default probe below.
|
|
75
51
|
try {
|
|
76
|
-
const
|
|
77
|
-
const configuredSkipPath = stateManager.getState().config.skippedIssuesPath;
|
|
52
|
+
const configuredSkipPath = getMachinePath('skippedIssuesPath', getStateManager().getState().config);
|
|
78
53
|
if (configuredSkipPath) {
|
|
79
54
|
const resolvedSkip = path.isAbsolute(configuredSkipPath)
|
|
80
55
|
? configuredSkipPath
|
|
@@ -99,18 +74,17 @@ export function detectIssueList() {
|
|
|
99
74
|
// (#1330). Without persistence, the auto-detect printed the path on
|
|
100
75
|
// every startup but nothing else honored it — search would re-surface
|
|
101
76
|
// already-skipped candidates round after round.
|
|
102
|
-
if (!skippedIssuesPath
|
|
77
|
+
if (!skippedIssuesPath) {
|
|
103
78
|
const defaultSkipPath = path.join(path.dirname(issueListPath), 'skipped-issues.md');
|
|
104
79
|
if (fs.existsSync(defaultSkipPath)) {
|
|
105
80
|
skippedIssuesPath = defaultSkipPath;
|
|
106
81
|
try {
|
|
107
|
-
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
const current = stateManager.getState().config.skippedIssuesPath;
|
|
82
|
+
// Only write when no path is configured: re-running startup
|
|
83
|
+
// shouldn't rewrite the value on every run if it is already there.
|
|
84
|
+
// The write goes to this machine's local settings (#1950).
|
|
85
|
+
const current = getMachinePath('skippedIssuesPath', getStateManager().getState().config);
|
|
112
86
|
if (!current) {
|
|
113
|
-
|
|
87
|
+
setMachinePath('skippedIssuesPath', defaultSkipPath, 'probe');
|
|
114
88
|
}
|
|
115
89
|
}
|
|
116
90
|
catch (err) {
|
|
@@ -121,6 +95,41 @@ export function detectIssueList() {
|
|
|
121
95
|
}
|
|
122
96
|
}
|
|
123
97
|
}
|
|
98
|
+
return skippedIssuesPath;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Detect the configured issue list file.
|
|
102
|
+
* @param shouldSuggest - With no configured list, return a list found in
|
|
103
|
+
* the current directory as `source: 'auto-detected'` for the user to confirm
|
|
104
|
+
* (#1933). Only `/oss` startup asks; nothing about it is saved.
|
|
105
|
+
* @returns Issue list info with path and item counts, or undefined if not found
|
|
106
|
+
*/
|
|
107
|
+
export function detectIssueList(shouldSuggest = false) {
|
|
108
|
+
// Path lookup lives in locate-issue-list.ts (#1463), shared with the daily merge-loop.
|
|
109
|
+
const located = detectIssueListPath() ?? (shouldSuggest ? suggestIssueListPath() : undefined);
|
|
110
|
+
if (!located)
|
|
111
|
+
return undefined;
|
|
112
|
+
const issueListPath = located.path;
|
|
113
|
+
const source = located.source;
|
|
114
|
+
// 4. Count available/completed items
|
|
115
|
+
let availableCount = 0;
|
|
116
|
+
let completedCount = 0;
|
|
117
|
+
let blockedCount = 0;
|
|
118
|
+
let readError;
|
|
119
|
+
try {
|
|
120
|
+
const content = fs.readFileSync(issueListPath, 'utf8');
|
|
121
|
+
({ availableCount, completedCount, blockedCount } = countIssueListItems(content));
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
// Surface the failure in the envelope (#1448): a 0/0 count from an
|
|
125
|
+
// unreadable list is indistinguishable from a genuinely empty list, and
|
|
126
|
+
// an agent seeing 0 available may trigger a redundant fresh search.
|
|
127
|
+
readError = errorMessage(error);
|
|
128
|
+
console.error(`[STARTUP] Failed to read issue list at ${issueListPath}:`, readError);
|
|
129
|
+
}
|
|
130
|
+
// 5. Detect skipped issues file. A suggested list is not confirmed yet
|
|
131
|
+
// (#1933), so its directory is not searched for one.
|
|
132
|
+
const skippedIssuesPath = source === 'configured' ? detectSkippedIssuesPath(issueListPath) : undefined;
|
|
124
133
|
return {
|
|
125
134
|
path: issueListPath,
|
|
126
135
|
source,
|
|
@@ -208,6 +217,10 @@ function shouldOpenBrowser(spaResult, throttleMs) {
|
|
|
208
217
|
return true; // clock skew or future timestamp; treat as stale
|
|
209
218
|
return elapsed >= throttleMs;
|
|
210
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Returns `refresh-started` for a 202 (the server refreshes in the background
|
|
222
|
+
* and has not finished), `refreshed` for a completed refresh, null on failure.
|
|
223
|
+
*/
|
|
211
224
|
async function triggerDashboardRefresh(port) {
|
|
212
225
|
try {
|
|
213
226
|
const base = `http://127.0.0.1:${port}`;
|
|
@@ -218,24 +231,41 @@ async function triggerDashboardRefresh(port) {
|
|
|
218
231
|
await prime.text().catch(() => { });
|
|
219
232
|
if (!prime.ok || !csrfToken) {
|
|
220
233
|
console.error(`[STARTUP] Dashboard refresh returned ${prime.status}: no CSRF token from /api/data`);
|
|
221
|
-
return
|
|
234
|
+
return null;
|
|
222
235
|
}
|
|
223
236
|
const res = await fetch(`${base}/api/refresh`, {
|
|
224
237
|
method: 'POST',
|
|
225
|
-
|
|
238
|
+
// Ask for a 202 and a background refresh: the full GitHub fetch outlives
|
|
239
|
+
// this timeout, which used to log a failure for a refresh that then
|
|
240
|
+
// completed (#1927).
|
|
241
|
+
headers: { Origin: `http://oss.localhost:${port}`, 'X-CSRF-Token': csrfToken, Prefer: 'respond-async' },
|
|
226
242
|
signal: AbortSignal.timeout(5000),
|
|
227
243
|
});
|
|
228
244
|
if (!res.ok) {
|
|
229
245
|
const body = await res.text().catch(() => '');
|
|
230
246
|
console.error(`[STARTUP] Dashboard refresh returned ${res.status}: ${body}`);
|
|
231
|
-
return
|
|
247
|
+
return null;
|
|
232
248
|
}
|
|
233
249
|
await res.text().catch(() => { });
|
|
234
|
-
return
|
|
250
|
+
return res.status === 202 ? 'refresh-started' : 'refreshed';
|
|
235
251
|
}
|
|
236
252
|
catch (error) {
|
|
237
253
|
console.error(`[STARTUP] Could not trigger dashboard refresh: ${errorMessage(error)}`);
|
|
238
|
-
return
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Stale-data counts for the `/oss` summary (#2049), from directory listings
|
|
259
|
+
* only (no Git in the worktrees). Any error leaves the field out: this must
|
|
260
|
+
* never fail startup.
|
|
261
|
+
*/
|
|
262
|
+
export function staleDataForStartup() {
|
|
263
|
+
try {
|
|
264
|
+
return countStaleData(resolveDataDir());
|
|
265
|
+
}
|
|
266
|
+
catch (err) {
|
|
267
|
+
warn('startup', `Could not count stale data: ${errorMessage(err)}`);
|
|
268
|
+
return undefined;
|
|
239
269
|
}
|
|
240
270
|
}
|
|
241
271
|
/**
|
|
@@ -302,8 +332,7 @@ export async function runStartup() {
|
|
|
302
332
|
if (spaResult) {
|
|
303
333
|
dashboardUrl = spaResult.url;
|
|
304
334
|
if (spaResult.alreadyRunning) {
|
|
305
|
-
|
|
306
|
-
dashboardStatus = refreshed ? 'refreshed' : 'running';
|
|
335
|
+
dashboardStatus = (await triggerDashboardRefresh(spaResult.port)) ?? 'running';
|
|
307
336
|
}
|
|
308
337
|
else {
|
|
309
338
|
dashboardStatus = 'opened';
|
|
@@ -334,11 +363,14 @@ export async function runStartup() {
|
|
|
334
363
|
else if (dashboardStatus === 'refreshed') {
|
|
335
364
|
daily.briefSummary += ' | Dashboard refreshed';
|
|
336
365
|
}
|
|
366
|
+
else if (dashboardStatus === 'refresh-started') {
|
|
367
|
+
daily.briefSummary += ' | Dashboard refresh started';
|
|
368
|
+
}
|
|
337
369
|
else if (dashboardStatus === 'running') {
|
|
338
370
|
daily.briefSummary += ' | Dashboard running';
|
|
339
371
|
}
|
|
340
372
|
// 5. Detect issue list
|
|
341
|
-
const issueList = detectIssueList();
|
|
373
|
+
const issueList = detectIssueList(true);
|
|
342
374
|
// 6. Pass through dashboard-build status set by the workflow shell (#1293).
|
|
343
375
|
// The workflow runs the SPA build BEFORE invoking startup, so the status
|
|
344
376
|
// arrives here via env vars rather than being something runStartup itself
|
|
@@ -368,5 +400,6 @@ export async function runStartup() {
|
|
|
368
400
|
// State is already loaded and schema-parsed by this point (getStateManager
|
|
369
401
|
// above), so this is an in-memory read that cannot fail (#1574).
|
|
370
402
|
overnight: overnightFreshness(),
|
|
403
|
+
staleData: staleDataForStartup(),
|
|
371
404
|
};
|
|
372
405
|
}
|
|
@@ -9,6 +9,8 @@ export interface InvalidUrlEntry {
|
|
|
9
9
|
}
|
|
10
10
|
export interface StateShowOutput {
|
|
11
11
|
persistence: 'local' | 'gist';
|
|
12
|
+
/** The stored mode, present only when it is one a newer release added (#2005); `persistence` is then `local`. */
|
|
13
|
+
storedPersistence?: string;
|
|
12
14
|
gistId: string | null;
|
|
13
15
|
gistDegraded: boolean;
|
|
14
16
|
lastRunAt: string | undefined;
|
|
@@ -9,11 +9,15 @@ import { getStatePath, getGistIdPath } from '../core/paths.js';
|
|
|
9
9
|
import { parseGitHubUrl } from '../core/urls.js';
|
|
10
10
|
import { warn } from '../core/logger.js';
|
|
11
11
|
const MODULE = 'state-cmd';
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- async keeps the Promise-returning contract callers rely on; the body has no await yet
|
|
12
13
|
export async function runStateShow(options = {}) {
|
|
13
14
|
const sm = getStateManager();
|
|
14
15
|
const state = sm.getState();
|
|
16
|
+
const stored = state.config.persistence;
|
|
15
17
|
const output = {
|
|
16
|
-
|
|
18
|
+
// An unknown mode a newer release wrote runs as local (#2005).
|
|
19
|
+
persistence: stored === 'gist' ? 'gist' : 'local',
|
|
20
|
+
...(stored && stored !== 'local' && stored !== 'gist' && { storedPersistence: stored }),
|
|
17
21
|
gistId: state.gistId ?? null,
|
|
18
22
|
gistDegraded: sm.isGistDegraded(),
|
|
19
23
|
lastRunAt: state.lastRunAt,
|
package/dist/commands/stats.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { getStateManager } from '../core/index.js';
|
|
6
6
|
import { computeContributionStats } from '../core/stats.js';
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- async keeps the Promise-returning contract callers rely on; the body has no await yet
|
|
7
8
|
export async function runStats() {
|
|
8
9
|
const stateManager = getStateManager();
|
|
9
10
|
const state = stateManager.getState();
|
package/dist/commands/status.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { getStateManager } from '../core/index.js';
|
|
6
6
|
import { buildStalenessWarning } from '../formatters/json.js';
|
|
7
|
+
import { getPacingStatus } from '../core/pacing.js';
|
|
7
8
|
/**
|
|
8
9
|
* Return contribution statistics from local state.
|
|
9
10
|
* No API calls — reads from ~/.oss-autopilot/state.json.
|
|
@@ -12,6 +13,7 @@ import { buildStalenessWarning } from '../formatters/json.js';
|
|
|
12
13
|
* @param options.offline - When true, adds cache freshness metadata
|
|
13
14
|
* @returns Contribution stats (merge rate, PR counts, repo breakdown)
|
|
14
15
|
*/
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- async keeps the Promise-returning contract callers rely on; the body has no await yet
|
|
15
17
|
export async function runStatus(options) {
|
|
16
18
|
const stateManager = getStateManager();
|
|
17
19
|
const stats = stateManager.getStats();
|
|
@@ -29,6 +31,10 @@ export async function runStatus(options) {
|
|
|
29
31
|
output.offline = true;
|
|
30
32
|
output.lastUpdated = lastUpdated;
|
|
31
33
|
}
|
|
34
|
+
// Only when a pacing cap is set (#1911).
|
|
35
|
+
const pacing = getPacingStatus(state);
|
|
36
|
+
if (pacing)
|
|
37
|
+
output.pacing = pacing;
|
|
32
38
|
// Surface Gist staleness as a structured warning so cron / dashboard
|
|
33
39
|
// consumers don't need to scrape stderr (#1193).
|
|
34
40
|
const staleness = stateManager.getStateStaleness();
|
|
@@ -17,6 +17,7 @@ import { computeStrategy, STRATEGY_MIN_PRS } from '../core/strategy.js';
|
|
|
17
17
|
* message }` when state is below the merged-PR floor, and `{ strategy }`
|
|
18
18
|
* with the full typed result otherwise.
|
|
19
19
|
*/
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- async keeps the Promise-returning contract callers rely on; the body has no await yet
|
|
20
21
|
export async function runStrategy() {
|
|
21
22
|
const stateManager = getStateManager();
|
|
22
23
|
const state = stateManager.getState();
|
|
@@ -13,6 +13,11 @@ export declare const ISSUE_OR_PR_URL_PATTERN: RegExp;
|
|
|
13
13
|
* PR's full head SHA by equality, so an abbreviated one would never match.
|
|
14
14
|
*/
|
|
15
15
|
export declare const COMMIT_SHA_PATTERN: RegExp;
|
|
16
|
+
/**
|
|
17
|
+
* A branch name to hand Git as an argument: it cannot start with `-`, so Git
|
|
18
|
+
* never reads it as an option (`--output=<file>`, #2047).
|
|
19
|
+
*/
|
|
20
|
+
export declare const BRANCH_NAME_PATTERN: RegExp;
|
|
16
21
|
/**
|
|
17
22
|
* Validate a GitHub URL against a pattern. Throws if invalid.
|
|
18
23
|
*/
|
|
@@ -15,6 +15,11 @@ export const ISSUE_OR_PR_URL_PATTERN = /^https:\/\/github\.com\/[^/]+\/[^/]+\/(i
|
|
|
15
15
|
* PR's full head SHA by equality, so an abbreviated one would never match.
|
|
16
16
|
*/
|
|
17
17
|
export const COMMIT_SHA_PATTERN = /^[0-9a-f]{40}$/i;
|
|
18
|
+
/**
|
|
19
|
+
* A branch name to hand Git as an argument: it cannot start with `-`, so Git
|
|
20
|
+
* never reads it as an option (`--output=<file>`, #2047).
|
|
21
|
+
*/
|
|
22
|
+
export const BRANCH_NAME_PATTERN = /^[\w.][\w./-]*$/;
|
|
18
23
|
/** Maximum allowed URL length */
|
|
19
24
|
const MAX_URL_LENGTH = 2048;
|
|
20
25
|
/** Maximum allowed PR/issue number */
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vet-list command (#764)
|
|
3
3
|
* Re-vets all available issues in a curated issue list file via @oss-scout/core.
|
|
4
|
+
*
|
|
5
|
+
* Each vetted repo's contribution policy (#2013) is read from scout's
|
|
6
|
+
* CONTRIBUTING text and anti-LLM scan only (no extra GitHub reads; `vet` adds
|
|
7
|
+
* the PR template and README-linked docs), applied to the row as in `vet` (a
|
|
8
|
+
* ban makes it a skip), and recorded once after the fan-out without replacing
|
|
9
|
+
* a stored reading unless it is a ban.
|
|
4
10
|
*/
|
|
5
11
|
import { type VetListOutput, type VetOutput, type VetListItemStatus } from '../formatters/json.js';
|
|
6
12
|
import { type IssueAvailabilityVerdict } from '../core/index.js';
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vet-list command (#764)
|
|
3
3
|
* Re-vets all available issues in a curated issue list file via @oss-scout/core.
|
|
4
|
+
*
|
|
5
|
+
* Each vetted repo's contribution policy (#2013) is read from scout's
|
|
6
|
+
* CONTRIBUTING text and anti-LLM scan only (no extra GitHub reads; `vet` adds
|
|
7
|
+
* the PR template and README-linked docs), applied to the row as in `vet` (a
|
|
8
|
+
* ban makes it a skip), and recorded once after the fan-out without replacing
|
|
9
|
+
* a stored reading unless it is a ban.
|
|
4
10
|
*/
|
|
5
11
|
import * as fs from 'node:fs';
|
|
6
12
|
import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout } from './scout-bridge.js';
|
|
@@ -9,6 +15,9 @@ import { detectIssueList } from './startup.js';
|
|
|
9
15
|
import { computeSuccessGrade, gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
|
|
10
16
|
import { repoCapField } from '../core/repo-cap.js';
|
|
11
17
|
import { ValidationError } from '../core/errors.js';
|
|
18
|
+
import { storedPolicy } from '../core/repo-policy.js';
|
|
19
|
+
import { policyFields, publicVettingResult, vetPolicy } from './vet.js';
|
|
20
|
+
import { recordVetPolicies } from './policy.js';
|
|
12
21
|
import { getStateManager, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, traitsFromVerification, isFirstInRepo, getOctokit, requireGitHubToken, parseGitHubUrl, verifyIssuesBatch, RULED_OUT_VERDICTS, workClaimVetFields, } from '../core/index.js';
|
|
13
22
|
const UNKNOWN_GRADE = computeSuccessGrade({ avgResponseDays: null, mergeRate: null, daysSinceLastCommit: null });
|
|
14
23
|
const KNOWN_SKIP_REASONS = new Set([
|
|
@@ -144,6 +153,19 @@ function ruledOutVetOutput(v) {
|
|
|
144
153
|
grade: UNKNOWN_GRADE,
|
|
145
154
|
};
|
|
146
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* {@link vetPolicy} for one candidate, added to `readings` when there is one.
|
|
158
|
+
* Returns the reading to show on the row: like the write (`fillOnly`), a
|
|
159
|
+
* stored record wins over it unless it is a ban.
|
|
160
|
+
*/
|
|
161
|
+
function readPolicy(candidate, readings) {
|
|
162
|
+
const policy = vetPolicy(candidate);
|
|
163
|
+
if (!policy)
|
|
164
|
+
return null;
|
|
165
|
+
readings.push({ repo: candidate.issue.repo, policy });
|
|
166
|
+
const isStored = storedPolicy(getStateManager().getState(), candidate.issue.repo) !== null;
|
|
167
|
+
return !isStored || policy.aiPolicy === 'banned' ? policy : null;
|
|
168
|
+
}
|
|
147
169
|
function toMessage(error) {
|
|
148
170
|
return error instanceof Error ? error.message : String(error);
|
|
149
171
|
}
|
|
@@ -197,6 +219,7 @@ export async function runVetList(options = {}) {
|
|
|
197
219
|
const scout = await createAutopilotScout();
|
|
198
220
|
// Vet-time predictions for calibration (#1824), recorded once after the fan-out.
|
|
199
221
|
const picks = [];
|
|
222
|
+
const policies = [];
|
|
200
223
|
/**
|
|
201
224
|
* Run scout's grade/health vet for an issue (the search-driven path). A pick is
|
|
202
225
|
* recorded only with a `verification`: on the verify-errored fallback, without
|
|
@@ -229,13 +252,14 @@ export async function runVetList(options = {}) {
|
|
|
229
252
|
reasonsToSkip: candidate.reasonsToSkip,
|
|
230
253
|
...(candidate.complexityUnlocked && { complexityUnlocked: true }),
|
|
231
254
|
projectHealth: candidate.projectHealth,
|
|
232
|
-
vettingResult: candidate.vettingResult,
|
|
255
|
+
vettingResult: publicVettingResult(candidate.vettingResult),
|
|
233
256
|
antiLLMPolicy: candidate.antiLLMPolicy,
|
|
234
257
|
linkedPRClassification,
|
|
235
258
|
...(linkedPR && { linkedPR }),
|
|
236
259
|
slmTriage: candidate.slmTriage ?? null,
|
|
237
260
|
grade,
|
|
238
261
|
...repoCapField(getStateManager().getState(), candidate.issue.repo),
|
|
262
|
+
...policyFields(candidate, readPolicy(candidate, policies)),
|
|
239
263
|
};
|
|
240
264
|
if (verification) {
|
|
241
265
|
const pick = pickSnapshotFromVet(vetResult, 'vet-list', {
|
|
@@ -339,6 +363,7 @@ export async function runVetList(options = {}) {
|
|
|
339
363
|
const workers = Array.from({ length: Math.min(concurrency, items.length) }, () => processNext());
|
|
340
364
|
await Promise.all(workers);
|
|
341
365
|
const pickPersistence = await persistPickSnapshots(getStateManager(), picks);
|
|
366
|
+
await recordVetPolicies(policies, { fillOnly: true });
|
|
342
367
|
// 4. Compute summary
|
|
343
368
|
const summary = {
|
|
344
369
|
total: results.length,
|
package/dist/commands/vet.d.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Vet command
|
|
3
3
|
* Vets a specific issue before working on it via @oss-scout/core
|
|
4
4
|
*/
|
|
5
|
+
import { createAutopilotScout } from './scout-bridge.js';
|
|
5
6
|
import { type VetOutput } from '../formatters/json.js';
|
|
7
|
+
import { type PolicyDoc, type RepoPolicy } from '../core/repo-policy.js';
|
|
6
8
|
export { type VetOutput } from '../formatters/json.js';
|
|
7
9
|
interface VetOptions {
|
|
8
10
|
issueUrl: string;
|
|
@@ -16,3 +18,21 @@ interface VetOptions {
|
|
|
16
18
|
* @throws {ValidationError} If the URL is not a valid GitHub issue URL
|
|
17
19
|
*/
|
|
18
20
|
export declare function runVet(options: VetOptions): Promise<VetOutput>;
|
|
21
|
+
export type ScoutCandidate = Awaited<ReturnType<Awaited<ReturnType<typeof createAutopilotScout>>['vetIssue']>>;
|
|
22
|
+
/**
|
|
23
|
+
* Scout's vetting result as vet and vet-list print it: without
|
|
24
|
+
* `contributionGuidelines.rawContent` (#2046). That field is the target repo's
|
|
25
|
+
* whole CONTRIBUTING file, written by the repo and unfenced. Vet reads it only
|
|
26
|
+
* through {@link vetPolicy}; the output keeps scout's parsed fields and the
|
|
27
|
+
* derived `policy`. Returns a copy; never mutates.
|
|
28
|
+
*/
|
|
29
|
+
export declare function publicVettingResult(result: ScoutCandidate['vettingResult']): ScoutCandidate['vettingResult'];
|
|
30
|
+
/**
|
|
31
|
+
* The repo's contribution policy as far as vet read it (#1953): scout's
|
|
32
|
+
* CONTRIBUTING text and `extraDocs` through the policy parsers, plus scout's own
|
|
33
|
+
* anti-LLM scan (which also reads README and CODE_OF_CONDUCT). Null when vet
|
|
34
|
+
* read nothing or the scan result is missing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function vetPolicy(candidate: ScoutCandidate, extraDocs?: readonly PolicyDoc[]): RepoPolicy | null;
|
|
37
|
+
/** The policy that applies to the candidate's repo, with `derived` as the fresh reading; a ban makes the issue a skip. */
|
|
38
|
+
export declare function policyFields(candidate: ScoutCandidate, derived: RepoPolicy | null): Partial<VetOutput>;
|
package/dist/commands/vet.js
CHANGED
|
@@ -6,7 +6,11 @@ import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout } from
|
|
|
6
6
|
import { ISSUE_URL_PATTERN, validateGitHubUrl, validateUrl } from './validation.js';
|
|
7
7
|
import { gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
|
|
8
8
|
import { repoCapField } from '../core/repo-cap.js';
|
|
9
|
-
import {
|
|
9
|
+
import { banNote, derivePolicy, effectivePolicy, linkedPolicyDocs, policyField, quote, storedPolicy, } from '../core/repo-policy.js';
|
|
10
|
+
import { decodeBase64, fetchPRTemplate } from '../core/pr-template.js';
|
|
11
|
+
import { recordVetPolicies } from './policy.js';
|
|
12
|
+
import { probePath } from './repo-vet.js';
|
|
13
|
+
import { getStateManager, getOctokit, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, fetchIssueVerification, RULED_OUT_VERDICTS, traitsFromVerification, isFirstInRepo, requireGitHubToken, splitRepo, getHttpStatusCode, errorMessage, warn, workClaimVetFields, } from '../core/index.js';
|
|
10
14
|
/**
|
|
11
15
|
* Vet a specific GitHub issue for claimability and project health.
|
|
12
16
|
*
|
|
@@ -44,13 +48,15 @@ export async function runVet(options) {
|
|
|
44
48
|
reasonsToSkip: candidate.reasonsToSkip,
|
|
45
49
|
...(candidate.complexityUnlocked && { complexityUnlocked: true }),
|
|
46
50
|
projectHealth: candidate.projectHealth,
|
|
47
|
-
vettingResult: candidate.vettingResult,
|
|
51
|
+
vettingResult: publicVettingResult(candidate.vettingResult),
|
|
48
52
|
antiLLMPolicy: candidate.antiLLMPolicy,
|
|
49
53
|
linkedPRClassification,
|
|
50
54
|
...(linkedPR && { linkedPR }),
|
|
51
55
|
slmTriage: candidate.slmTriage ?? null,
|
|
52
56
|
grade,
|
|
53
57
|
...repoCapField(getStateManager().getState(), candidate.issue.repo),
|
|
58
|
+
// Last: a banned policy overrides the recommendation and adds a skip reason.
|
|
59
|
+
...(await recordedPolicyFields(candidate)),
|
|
54
60
|
};
|
|
55
61
|
// A fix already being built somewhere (#1856) overrides the grade: the
|
|
56
62
|
// issue is skipped like one with a linked PR, and no pick is recorded.
|
|
@@ -61,6 +67,131 @@ export async function runVet(options) {
|
|
|
61
67
|
const pick = await pickFor(output);
|
|
62
68
|
return { ...output, ...(await persistPickSnapshots(getStateManager(), pick ? [pick] : [])) };
|
|
63
69
|
}
|
|
70
|
+
const BANNED_REASON = 'repo policy: the project does not accept AI-assisted contributions';
|
|
71
|
+
/** Linked docs are cut to this many characters before the parsers read them. */
|
|
72
|
+
const LINKED_DOC_MAX_CHARS = 100_000;
|
|
73
|
+
/**
|
|
74
|
+
* Scout's vetting result as vet and vet-list print it: without
|
|
75
|
+
* `contributionGuidelines.rawContent` (#2046). That field is the target repo's
|
|
76
|
+
* whole CONTRIBUTING file, written by the repo and unfenced. Vet reads it only
|
|
77
|
+
* through {@link vetPolicy}; the output keeps scout's parsed fields and the
|
|
78
|
+
* derived `policy`. Returns a copy; never mutates.
|
|
79
|
+
*/
|
|
80
|
+
export function publicVettingResult(result) {
|
|
81
|
+
if (result.contributionGuidelines?.rawContent === undefined)
|
|
82
|
+
return result;
|
|
83
|
+
const guidelines = { ...result.contributionGuidelines };
|
|
84
|
+
delete guidelines.rawContent;
|
|
85
|
+
return { ...result, contributionGuidelines: guidelines };
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The repo's contribution policy as far as vet read it (#1953): scout's
|
|
89
|
+
* CONTRIBUTING text and `extraDocs` through the policy parsers, plus scout's own
|
|
90
|
+
* anti-LLM scan (which also reads README and CODE_OF_CONDUCT). Null when vet
|
|
91
|
+
* read nothing or the scan result is missing.
|
|
92
|
+
*/
|
|
93
|
+
export function vetPolicy(candidate, extraDocs = []) {
|
|
94
|
+
const guidelines = candidate.vettingResult.contributionGuidelines;
|
|
95
|
+
const scan = candidate.antiLLMPolicy;
|
|
96
|
+
// Without scout's README / CODE_OF_CONDUCT scan the AI reading is partial: record nothing.
|
|
97
|
+
if (!scan)
|
|
98
|
+
return null;
|
|
99
|
+
const contributing = guidelines?.rawContent ? [{ file: 'CONTRIBUTING.md', content: guidelines.rawContent }] : [];
|
|
100
|
+
const docs = [...contributing, ...extraDocs];
|
|
101
|
+
if (docs.length === 0 && !scan.matched)
|
|
102
|
+
return null;
|
|
103
|
+
const policy = derivePolicy(docs);
|
|
104
|
+
if (guidelines?.claRequired)
|
|
105
|
+
policy.cla = 'required';
|
|
106
|
+
if (!scan.matched || policy.aiPolicy === 'banned')
|
|
107
|
+
return policy;
|
|
108
|
+
const line = { file: scan.sourceFile ?? 'repo docs', quotedLine: quote(scan.matchedKeywords.join(', ')) };
|
|
109
|
+
return { ...policy, aiPolicy: 'banned', source: [line, ...policy.source].slice(0, 10) };
|
|
110
|
+
}
|
|
111
|
+
/** A doc's text: '' when it does not exist, null when the read failed. */
|
|
112
|
+
async function docText(octokit, owner, repo, path) {
|
|
113
|
+
let text;
|
|
114
|
+
try {
|
|
115
|
+
text = await probePath(octokit, owner, repo, path);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return text ?? '';
|
|
121
|
+
}
|
|
122
|
+
/** The README's text: '' when there is none, null when the read failed. */
|
|
123
|
+
async function readmeText(octokit, owner, repo) {
|
|
124
|
+
let response;
|
|
125
|
+
try {
|
|
126
|
+
response = await octokit.repos.getReadme({ owner, repo });
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
return getHttpStatusCode(error) === 404 ? '' : null;
|
|
130
|
+
}
|
|
131
|
+
return decodeBase64(response.data.content);
|
|
132
|
+
}
|
|
133
|
+
/** The PR template and the README-linked docs. A failed read leaves its doc out and marks the set incomplete. */
|
|
134
|
+
async function readExtraDocs(repoSlug) {
|
|
135
|
+
const { owner, repo } = splitRepo(repoSlug);
|
|
136
|
+
const octokit = getOctokit(requireGitHubToken());
|
|
137
|
+
const [template, readme] = await Promise.all([
|
|
138
|
+
fetchPRTemplate(octokit, owner, repo),
|
|
139
|
+
readmeText(octokit, owner, repo),
|
|
140
|
+
]);
|
|
141
|
+
const linked = await Promise.all(linkedPolicyDocs(readme ?? '', repoSlug).map(async (file) => ({
|
|
142
|
+
file,
|
|
143
|
+
content: await docText(octokit, owner, repo, file),
|
|
144
|
+
})));
|
|
145
|
+
const templateDoc = template.template && template.source ? [{ file: template.source, content: template.template }] : [];
|
|
146
|
+
const docs = [...templateDoc, ...linked]
|
|
147
|
+
.filter((d) => d.content !== null)
|
|
148
|
+
.map((d) => ({ file: d.file, content: d.content.slice(0, LINKED_DOC_MAX_CHARS) }));
|
|
149
|
+
const isComplete = template.error === undefined && readme !== null && linked.every((d) => d.content !== null);
|
|
150
|
+
return { docs, complete: isComplete };
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Docs beyond scout's CONTRIBUTING: the PR template and up to two
|
|
154
|
+
* contribution-guide docs the README links to in the same repo. At most 7 REST
|
|
155
|
+
* reads (README, up to 4 template paths, 2 linked docs). Best effort: a failed
|
|
156
|
+
* read leaves docs out and never fails the vet.
|
|
157
|
+
*/
|
|
158
|
+
async function extraPolicyDocs(repoSlug) {
|
|
159
|
+
try {
|
|
160
|
+
return await readExtraDocs(repoSlug);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
warn('vet', `Could not read the PR template and linked docs of ${repoSlug}: ${errorMessage(error)}`);
|
|
164
|
+
return { docs: [], complete: false };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Record what vet read, then report the policy that applies. A reading from an
|
|
169
|
+
* incomplete set of docs only fills a gap (or records a ban), like vet-list's.
|
|
170
|
+
*/
|
|
171
|
+
async function recordedPolicyFields(candidate) {
|
|
172
|
+
const repo = candidate.issue.repo;
|
|
173
|
+
const extra = await extraPolicyDocs(repo);
|
|
174
|
+
const derived = vetPolicy(candidate, extra.docs);
|
|
175
|
+
if (derived)
|
|
176
|
+
await recordVetPolicies([{ repo, policy: derived }], { fillOnly: !extra.complete });
|
|
177
|
+
// Show what was kept: a partial reading does not override a stored record unless it is a ban.
|
|
178
|
+
const isKept = extra.complete || derived?.aiPolicy === 'banned' || !storedPolicy(getStateManager().getState(), repo);
|
|
179
|
+
return policyFields(candidate, isKept ? derived : null);
|
|
180
|
+
}
|
|
181
|
+
/** The policy that applies to the candidate's repo, with `derived` as the fresh reading; a ban makes the issue a skip. */
|
|
182
|
+
export function policyFields(candidate, derived) {
|
|
183
|
+
const repo = candidate.issue.repo;
|
|
184
|
+
const policy = effectivePolicy(getStateManager().getState(), repo, derived ?? undefined);
|
|
185
|
+
if (policy?.aiPolicy !== 'banned')
|
|
186
|
+
return policyField(policy);
|
|
187
|
+
// One ban reason: scout's when its scan matched (then ours only adds how to lift it), else ours.
|
|
188
|
+
const note = banNote(policy, repo);
|
|
189
|
+
let reason = BANNED_REASON + note;
|
|
190
|
+
if (candidate.antiLLMPolicy?.matched)
|
|
191
|
+
reason = note === '' ? null : `repo policy${note}`;
|
|
192
|
+
const reasonsToSkip = reason === null ? candidate.reasonsToSkip : [...candidate.reasonsToSkip, reason];
|
|
193
|
+
return { ...policyField(policy), recommendation: 'skip', reasonsToSkip };
|
|
194
|
+
}
|
|
64
195
|
/**
|
|
65
196
|
* The pick to record for this vet. One verify GraphQL call supplies the issue
|
|
66
197
|
* author, comment count and competing PRs, and applies vet-list's rule: no pick
|
package/dist/commands/work.d.ts
CHANGED
|
@@ -60,10 +60,14 @@ export interface WorkReleaseOptions {
|
|
|
60
60
|
/** Release every claim this session holds (optionally only `kind`). */
|
|
61
61
|
session?: string;
|
|
62
62
|
kind?: WorkClaimKind;
|
|
63
|
+
/** A PR the session just opened, recorded for the pacing caps (#1911). */
|
|
64
|
+
pr?: string;
|
|
63
65
|
}
|
|
64
66
|
export interface WorkReleaseOutput {
|
|
65
67
|
/** URLs of the live claims released, in stored order. */
|
|
66
68
|
released: string[];
|
|
69
|
+
/** The `pr` recorded for the pacing caps; absent when none was given or it is to the user's own repo. */
|
|
70
|
+
recordedPR?: string;
|
|
67
71
|
gistSyncWarning?: string;
|
|
68
72
|
}
|
|
69
73
|
export interface WorkListOutput {
|