@oss-autopilot/core 3.43.0 → 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-registry.js +160 -6
- package/dist/cli.bundle.cjs +207 -180
- package/dist/commands/check-integration.js +4 -1
- package/dist/commands/cleanup.d.ts +6 -2
- package/dist/commands/cleanup.js +72 -7
- package/dist/commands/comments.d.ts +8 -1
- package/dist/commands/comments.js +11 -3
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.js +26 -1
- package/dist/commands/daily-ledger.d.ts +33 -5
- package/dist/commands/daily-ledger.js +36 -13
- package/dist/commands/daily-render.d.ts +2 -1
- package/dist/commands/daily-render.js +4 -1
- package/dist/commands/daily.d.ts +3 -0
- package/dist/commands/daily.js +25 -5
- package/dist/commands/dashboard-data.js +70 -61
- package/dist/commands/dashboard-lifecycle.d.ts +36 -8
- package/dist/commands/dashboard-lifecycle.js +131 -38
- package/dist/commands/dashboard-process.d.ts +35 -0
- package/dist/commands/dashboard-process.js +65 -5
- package/dist/commands/dismiss.js +7 -6
- package/dist/commands/doctor.js +1 -8
- package/dist/commands/fork-prune.d.ts +58 -0
- package/dist/commands/fork-prune.js +247 -0
- package/dist/commands/guidelines.d.ts +46 -1
- package/dist/commands/guidelines.js +111 -12
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.js +5 -0
- package/dist/commands/overnight-push-prep.d.ts +2 -1
- package/dist/commands/overnight-push-prep.js +3 -3
- package/dist/commands/policy.d.ts +5 -1
- package/dist/commands/policy.js +14 -1
- package/dist/commands/pr-create.d.ts +48 -0
- package/dist/commands/pr-create.js +200 -0
- package/dist/commands/pr-preflight.d.ts +28 -2
- package/dist/commands/pr-preflight.js +63 -9
- package/dist/commands/setup.js +120 -36
- package/dist/commands/startup.d.ts +7 -0
- package/dist/commands/startup.js +17 -0
- package/dist/commands/status.js +5 -0
- package/dist/commands/validation.d.ts +5 -0
- package/dist/commands/validation.js +5 -0
- package/dist/commands/vet-list.js +2 -2
- package/dist/commands/vet.d.ts +8 -0
- package/dist/commands/vet.js +15 -1
- package/dist/commands/work.d.ts +4 -0
- package/dist/commands/work.js +34 -11
- package/dist/core/commit-date.d.ts +31 -5
- package/dist/core/commit-date.js +36 -8
- 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 +83 -2
- package/dist/core/daily-logic.d.ts +4 -1
- package/dist/core/daily-logic.js +13 -2
- package/dist/core/fork-prune.d.ts +149 -0
- package/dist/core/fork-prune.js +333 -0
- package/dist/core/gist-state-store.js +4 -8
- package/dist/core/github-stats.d.ts +7 -1
- package/dist/core/github-stats.js +15 -15
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/local-config.js +2 -3
- package/dist/core/pacing.d.ts +41 -0
- package/dist/core/pacing.js +115 -0
- package/dist/core/pr-assembly.d.ts +2 -0
- package/dist/core/pr-graphql.d.ts +16 -1
- package/dist/core/pr-graphql.js +15 -3
- package/dist/core/pr-monitor.d.ts +6 -0
- package/dist/core/pr-monitor.js +46 -10
- package/dist/core/pr-preflight.d.ts +41 -0
- package/dist/core/pr-preflight.js +406 -17
- package/dist/core/prose-script.d.ts +72 -0
- package/dist/core/prose-script.js +223 -0
- package/dist/core/repo-policy.d.ts +8 -2
- package/dist/core/repo-policy.js +34 -6
- package/dist/core/repo-score-manager.d.ts +18 -0
- package/dist/core/repo-score-manager.js +29 -0
- package/dist/core/review-analysis.d.ts +15 -2
- package/dist/core/review-analysis.js +22 -5
- package/dist/core/stale-data.d.ts +44 -7
- package/dist/core/stale-data.js +46 -8
- package/dist/core/state-persistence.js +2 -4
- package/dist/core/state-schema.d.ts +39 -0
- package/dist/core/state-schema.js +68 -1
- package/dist/core/state.d.ts +21 -0
- package/dist/core/state.js +47 -0
- package/dist/core/status-determination.js +10 -8
- package/dist/core/untrusted-content.d.ts +3 -3
- package/dist/core/untrusted-content.js +26 -8
- package/dist/core/urls.d.ts +24 -0
- package/dist/core/urls.js +76 -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 +171 -5
- package/dist/formatters/json.js +79 -0
- package/package.json +6 -6
- package/dist/dashboard/assets/chart-panel-C_C1lFTI.js +0 -3
- package/dist/dashboard/assets/index-B--H66Jk.js +0 -55
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* is opened. Gathers facts from the local clone (read-only commands) and from
|
|
4
4
|
* GitHub (read-only API), then runs the pure checks in core/pr-preflight.ts:
|
|
5
5
|
* upstream drift, base branch, head branch, working tree, competing work on
|
|
6
|
-
* the issue, the per-repo open-PR cap, the repo policy and
|
|
6
|
+
* the issue, the per-repo open-PR cap, the pacing caps, the repo policy and
|
|
7
|
+
* its commit rules.
|
|
7
8
|
*
|
|
8
9
|
* It only reads, so it runs in unattended mode. Without a GitHub token, or
|
|
9
10
|
* with `--local`, the local checks still run and the network checks come back
|
|
@@ -17,9 +18,11 @@ import { runPreflightChecks, } from '../core/pr-preflight.js';
|
|
|
17
18
|
import { git, parseRemoteOwner, parseRemotesOutput, resolvePushRemote } from './overnight-push-prep.js';
|
|
18
19
|
import { runRepoCap } from './repo-cap.js';
|
|
19
20
|
import { effectivePolicy } from '../core/repo-policy.js';
|
|
21
|
+
import { getPacingStatus } from '../core/pacing.js';
|
|
20
22
|
import { isFirstInRepo } from '../core/pick-snapshot.js';
|
|
21
|
-
import { ISSUE_URL_PATTERN, validateGitHubUrl, validateUrl } from './validation.js';
|
|
22
|
-
|
|
23
|
+
import { BRANCH_NAME_PATTERN, ISSUE_URL_PATTERN, validateGitHubUrl, validateUrl } from './validation.js';
|
|
24
|
+
import { readDraft } from './draft.js';
|
|
25
|
+
import { readRepoScripts } from '../core/prose-script.js';
|
|
23
26
|
const ISSUE_NUMBER = /^#?(\d+)$/;
|
|
24
27
|
const MAX_OVERLAP_LINES = 20;
|
|
25
28
|
// ponytail: a branch with more commits than this has only its newest 200 checked against the commit rules.
|
|
@@ -89,7 +92,23 @@ async function fetchGitHubFacts(octokit, repo, base) {
|
|
|
89
92
|
};
|
|
90
93
|
}
|
|
91
94
|
function offline(networkSkip) {
|
|
92
|
-
return {
|
|
95
|
+
return {
|
|
96
|
+
networkSkip,
|
|
97
|
+
github: null,
|
|
98
|
+
issue: null,
|
|
99
|
+
cap: null,
|
|
100
|
+
githubError: null,
|
|
101
|
+
issueError: null,
|
|
102
|
+
capError: null,
|
|
103
|
+
issueLabels: null,
|
|
104
|
+
labelsError: null,
|
|
105
|
+
repoScripts: null,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** The issue's label names, for a `maintainer-label` gate. */
|
|
109
|
+
async function fetchIssueLabels(octokit, issue) {
|
|
110
|
+
const { data } = await octokit.issues.get({ owner: issue.owner, repo: issue.repo, issue_number: issue.number });
|
|
111
|
+
return data.labels.map((label) => (typeof label === 'string' ? label : (label.name ?? ''))).filter((n) => n !== '');
|
|
93
112
|
}
|
|
94
113
|
const NOT_RUN = { value: null, error: null };
|
|
95
114
|
/** One GitHub read. A failure is recorded for its check; bad input (an issue that does not exist) still throws. */
|
|
@@ -103,7 +122,14 @@ async function attempt(read) {
|
|
|
103
122
|
return { value: null, error: errorMessage(err).split('\n', 1)[0] };
|
|
104
123
|
}
|
|
105
124
|
}
|
|
106
|
-
|
|
125
|
+
/** The repo's language, read only when there is staged text to compare it with (#1909). Never throws. */
|
|
126
|
+
async function repoScriptsFor(octokit, repo, staged) {
|
|
127
|
+
if (staged.prTitle === null && staged.prBody === null)
|
|
128
|
+
return null;
|
|
129
|
+
const { owner, repo: name } = splitRepo(repo);
|
|
130
|
+
return readRepoScripts(octokit, owner, name);
|
|
131
|
+
}
|
|
132
|
+
async function gatherNetworkFacts(target, options, login, shouldReadLabels, staged) {
|
|
107
133
|
const { repo, issueUrl } = target;
|
|
108
134
|
if (options.local)
|
|
109
135
|
return offline('local mode (--local)');
|
|
@@ -120,6 +146,8 @@ async function gatherNetworkFacts(target, options, login) {
|
|
|
120
146
|
: NOT_RUN;
|
|
121
147
|
// The cap gates a new PR, so it runs only for an issue; its search needs the username.
|
|
122
148
|
const cap = parsed && login ? await attempt(() => runRepoCap({ repo })) : NOT_RUN;
|
|
149
|
+
// One more read only where the recorded policy waits for a maintainer's label (#2040).
|
|
150
|
+
const labels = parsed && shouldReadLabels ? await attempt(() => fetchIssueLabels(octokit, parsed)) : NOT_RUN;
|
|
123
151
|
return {
|
|
124
152
|
networkSkip: null,
|
|
125
153
|
github: github.value,
|
|
@@ -128,6 +156,9 @@ async function gatherNetworkFacts(target, options, login) {
|
|
|
128
156
|
issueError: issue.error,
|
|
129
157
|
cap: cap.value,
|
|
130
158
|
capError: cap.error,
|
|
159
|
+
issueLabels: labels.value,
|
|
160
|
+
labelsError: labels.error,
|
|
161
|
+
repoScripts: await repoScriptsFor(octokit, repo, staged),
|
|
131
162
|
};
|
|
132
163
|
}
|
|
133
164
|
/** `git log --oneline` lines for commits in `mergeBase..upstream` touching files changed in `mergeBase..HEAD`. */
|
|
@@ -258,17 +289,35 @@ function policyFacts(state, repo) {
|
|
|
258
289
|
isFirstContribution: isFirstInRepo(repo, repoScoreFor(state, repo), state.mergedPRs),
|
|
259
290
|
};
|
|
260
291
|
}
|
|
292
|
+
/** A staged file's text, or null when no file was given. */
|
|
293
|
+
function draftOrNull(file) {
|
|
294
|
+
return file === undefined ? null : readDraft(file).content;
|
|
295
|
+
}
|
|
261
296
|
/** Run every preflight check for the branch checked out in `options.dir`. */
|
|
262
297
|
export async function runPrPreflight(options) {
|
|
263
|
-
|
|
298
|
+
// Read before anything else, so a bad path fails before any GitHub read.
|
|
299
|
+
const staged = {
|
|
300
|
+
prBody: draftOrNull(options.bodyFile),
|
|
301
|
+
prTitle: draftOrNull(options.titleFile),
|
|
302
|
+
prTemplate: draftOrNull(options.templateFile),
|
|
303
|
+
};
|
|
304
|
+
const run = await runPreflightOnText(options, staged);
|
|
305
|
+
return run.output;
|
|
306
|
+
}
|
|
307
|
+
/** Run every preflight check against staged text already read; `pr-create` sends exactly the text it checked (#2085). */
|
|
308
|
+
export async function runPreflightOnText(options, staged) {
|
|
309
|
+
if (options.base !== undefined && !BRANCH_NAME_PATTERN.test(options.base)) {
|
|
264
310
|
throw new ValidationError(`Invalid base branch name: ${options.base}`);
|
|
265
311
|
}
|
|
266
312
|
const dir = repoRoot(options.dir ?? process.cwd());
|
|
313
|
+
const headSha = tryGit(dir, ['rev-parse', '--verify', '--quiet', 'HEAD']);
|
|
267
314
|
const remotes = parseRemotesOutput(git(dir, ['remote', '-v']));
|
|
268
315
|
const target = resolveTarget(remotes, options.issue);
|
|
269
316
|
const sm = getStateManager();
|
|
270
317
|
const login = sm.getState().config.githubUsername || null;
|
|
271
|
-
const
|
|
318
|
+
const policy = policyFacts(sm.getState(), target.repo);
|
|
319
|
+
const shouldReadLabels = policy.policy?.prGate === 'maintainer-label';
|
|
320
|
+
const network = await gatherNetworkFacts(target, options, login, shouldReadLabels, staged);
|
|
272
321
|
const localDefault = localDefaultBranch(dir, target.remote);
|
|
273
322
|
const base = options.base ?? network.github?.defaultBranch ?? localDefault;
|
|
274
323
|
const facts = {
|
|
@@ -278,11 +327,16 @@ export async function runPrPreflight(options) {
|
|
|
278
327
|
...gatherDriftFacts(dir, target.remote, base, options.fetch ? 'fetch' : 'no-fetch'),
|
|
279
328
|
base,
|
|
280
329
|
localDefault,
|
|
281
|
-
...
|
|
330
|
+
...policy,
|
|
331
|
+
pacing: getPacingStatus(sm.getState()),
|
|
332
|
+
...staged,
|
|
333
|
+
isDraft: options.draft === true,
|
|
334
|
+
allowScriptMismatch: options.allowScriptMismatch === true,
|
|
282
335
|
};
|
|
283
336
|
const { repo, remote, issueUrl, branch, mergeBase, ahead, behind } = facts;
|
|
284
337
|
const result = runPreflightChecks(facts);
|
|
285
|
-
|
|
338
|
+
const output = { ...result, dir, repo, issueUrl, branch, remote, base, mergeBase, ahead, behind };
|
|
339
|
+
return { output, facts, remotes, headSha };
|
|
286
340
|
}
|
|
287
341
|
/** Text mode: the verdict, then one line per check. */
|
|
288
342
|
export function printPrPreflight(data) {
|
package/dist/commands/setup.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Interactive setup / configuration
|
|
4
4
|
*/
|
|
5
5
|
import { getStateManager, DEFAULT_CONFIG, formatUnknownKeyError, getSetupKeys, maybeCheckpoint, } from '../core/index.js';
|
|
6
|
-
import { ValidationError } from '../core/errors.js';
|
|
6
|
+
import { ValidationError, assertAttended } from '../core/errors.js';
|
|
7
7
|
import { MACHINE_PATH_KEYS, assertSafeMachinePath, setMachinePath, setMachineScanPaths } from '../core/local-config.js';
|
|
8
8
|
import { validateGitHubUsername } from './validation.js';
|
|
9
|
-
import { PROJECT_CATEGORIES, ISSUE_SCOPES, DIFF_TOOLS } from '../core/types.js';
|
|
9
|
+
import { PROJECT_CATEGORIES, ISSUE_SCOPES, DIFF_TOOLS, } from '../core/types.js';
|
|
10
10
|
const MODULE = 'setup';
|
|
11
11
|
/** Parse and validate a positive integer setting value. */
|
|
12
12
|
function parsePositiveInt(value, settingName) {
|
|
@@ -32,11 +32,18 @@ function parseComplexIssues(value) {
|
|
|
32
32
|
/** Settings kept in this machine's local file, never synced (#1950, #2010). */
|
|
33
33
|
const MACHINE_LOCAL_KEYS = new Set([...MACHINE_PATH_KEYS, 'localRepoScanPaths']);
|
|
34
34
|
/**
|
|
35
|
-
* Refuse unknown keys,
|
|
36
|
-
* before any pair is
|
|
35
|
+
* Refuse unknown keys, path values with a shell metacharacter (#1934), and
|
|
36
|
+
* an unattended run shrinking aiPolicyBlocklist (#2036), before any pair is
|
|
37
|
+
* applied.
|
|
37
38
|
*/
|
|
38
|
-
function prevalidateSettings(settings) {
|
|
39
|
+
function prevalidateSettings(settings, config) {
|
|
39
40
|
const knownKeys = new Set(getSetupKeys());
|
|
41
|
+
// Each safeguard pair is checked against the list the pairs before it
|
|
42
|
+
// leave, so a repeated key cannot shrink the list in two steps.
|
|
43
|
+
const lists = {
|
|
44
|
+
aiPolicyBlocklist: config.aiPolicyBlocklist ?? [],
|
|
45
|
+
keepForks: config.keepForks ?? [],
|
|
46
|
+
};
|
|
40
47
|
for (const setting of settings) {
|
|
41
48
|
const [key] = setting.split('=', 1);
|
|
42
49
|
if (!knownKeys.has(key)) {
|
|
@@ -45,8 +52,106 @@ function prevalidateSettings(settings) {
|
|
|
45
52
|
if (MACHINE_LOCAL_KEYS.has(key)) {
|
|
46
53
|
assertSafeMachinePath(key, setting.slice(key.length + 1));
|
|
47
54
|
}
|
|
55
|
+
if (isSafeguardList(key)) {
|
|
56
|
+
const parsed = parseBlocklist(setting.slice(key.length + 1));
|
|
57
|
+
assertBlocklistKept(key, lists[key], parsed);
|
|
58
|
+
lists[key] = parsed.stored ?? lists[key];
|
|
59
|
+
}
|
|
60
|
+
if (isPacingKey(key)) {
|
|
61
|
+
assertPacingKept(key, config[key], parsePacingCap(setting.slice(key.length + 1), key));
|
|
62
|
+
}
|
|
48
63
|
}
|
|
49
64
|
}
|
|
65
|
+
/** The owner/repo lists that protect something; an unattended run may add to them, never remove (#2036, #1912). */
|
|
66
|
+
const SAFEGUARD_LISTS = ['aiPolicyBlocklist', 'keepForks'];
|
|
67
|
+
function isSafeguardList(key) {
|
|
68
|
+
return SAFEGUARD_LISTS.includes(key);
|
|
69
|
+
}
|
|
70
|
+
/** Split an `aiPolicyBlocklist` or `keepForks` value the way the setting stores it. */
|
|
71
|
+
function parseBlocklist(value) {
|
|
72
|
+
const entries = value
|
|
73
|
+
.split(',')
|
|
74
|
+
.map((r) => r.trim())
|
|
75
|
+
.filter(Boolean);
|
|
76
|
+
const valid = [];
|
|
77
|
+
const invalid = [];
|
|
78
|
+
for (const entry of entries) {
|
|
79
|
+
const normalized = entry.replaceAll(/\s+/g, '');
|
|
80
|
+
if (/^[\w.-]+\/[\w.-]+$/.test(normalized)) {
|
|
81
|
+
valid.push(normalized);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
invalid.push(entry);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { valid, invalid, stored: valid.length === 0 && entries.length > 0 ? undefined : valid };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Refuse, during an unattended run, an `aiPolicyBlocklist` or `keepForks`
|
|
91
|
+
* value whose stored list leaves out a repo now on the list (#2036, #1912).
|
|
92
|
+
* Each repo on the blocklist is a ban and each on keepForks is a fork
|
|
93
|
+
* fork-prune must not delete, and the list is replaced whole, so `key=`
|
|
94
|
+
* lifts them all. `policy set` and `policy reset` refuse unattended runs for
|
|
95
|
+
* the same reason. Adding repos is still allowed. Entries compare
|
|
96
|
+
* case-insensitively, the way both lists are matched.
|
|
97
|
+
*/
|
|
98
|
+
function assertBlocklistKept(key, current, parsed) {
|
|
99
|
+
if (parsed.stored === undefined)
|
|
100
|
+
return;
|
|
101
|
+
const next = new Set(parsed.stored.map((repo) => repo.toLowerCase()));
|
|
102
|
+
if (current.some((repo) => !next.has(repo.toLowerCase()))) {
|
|
103
|
+
assertAttended(`remove repos from ${key}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Store an `aiPolicyBlocklist` or `keepForks` value. Invalid entries are
|
|
108
|
+
* skipped with a warning; when every entry is invalid the list is left as is
|
|
109
|
+
* (#1887). Checked again here, not only before the loop: a Gist conflict
|
|
110
|
+
* re-applies on a refreshed list that may hold repos another machine added (#2036).
|
|
111
|
+
*/
|
|
112
|
+
function applySafeguardList(stateManager, key, value, results, warnings) {
|
|
113
|
+
const parsed = parseBlocklist(value);
|
|
114
|
+
assertBlocklistKept(key, stateManager.getState().config[key] ?? [], parsed);
|
|
115
|
+
if (parsed.invalid.length > 0) {
|
|
116
|
+
warnings.push(`Warning: Skipping invalid entries (expected "owner/repo" format): ${parsed.invalid.join(', ')}`);
|
|
117
|
+
results[`${key}_invalidEntries`] = parsed.invalid.join(', ');
|
|
118
|
+
}
|
|
119
|
+
if (parsed.stored === undefined) {
|
|
120
|
+
const what = key === 'aiPolicyBlocklist' ? 'Blocklist' : key;
|
|
121
|
+
warnings.push(`Warning: All entries were invalid. ${what} not updated.`);
|
|
122
|
+
// No results entry: nothing was stored (#1887).
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
stateManager.updateConfig({ [key]: parsed.valid });
|
|
126
|
+
results[key] = parsed.valid.length > 0 ? parsed.valid.join(', ') : '(empty)';
|
|
127
|
+
}
|
|
128
|
+
const PACING_KEYS = ['maxNewPrsPerDay', 'maxNewForksPerDay'];
|
|
129
|
+
function isPacingKey(key) {
|
|
130
|
+
return PACING_KEYS.includes(key);
|
|
131
|
+
}
|
|
132
|
+
/** A pacing cap value: empty or 0 clears it (undefined), else a positive integer. */
|
|
133
|
+
function parsePacingCap(value, key) {
|
|
134
|
+
return value === '' ? undefined : parseNonNegativeInt(value, key) || undefined;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Refuse, during an unattended run, raising or clearing a pacing cap that is
|
|
138
|
+
* set (#1911): the cap limits how many PRs and forks the tool opens, so only
|
|
139
|
+
* the user lifts it, as with the AI-policy ban list (#2036). Lowering or
|
|
140
|
+
* setting a first cap is allowed.
|
|
141
|
+
*/
|
|
142
|
+
function assertPacingKept(key, current, next) {
|
|
143
|
+
if (current && (next === undefined || next > current)) {
|
|
144
|
+
assertAttended(`raise or clear ${key}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Set or clear a pacing cap; returns what was stored, for the output. */
|
|
148
|
+
function applyPacingCap(stateManager, key, value) {
|
|
149
|
+
const cap = parsePacingCap(value, key);
|
|
150
|
+
// Again here: a Gist conflict re-applies on a refreshed config.
|
|
151
|
+
assertPacingKept(key, stateManager.getState().config[key], cap);
|
|
152
|
+
stateManager.updateConfig({ [key]: cap });
|
|
153
|
+
return cap === undefined ? '(no cap)' : String(cap);
|
|
154
|
+
}
|
|
50
155
|
/** True when every `key=value` names a path kept in this machine's local file. */
|
|
51
156
|
function isMachineLocalOnly(settings) {
|
|
52
157
|
return settings.every((setting) => MACHINE_LOCAL_KEYS.has(setting.split('=', 1)[0]));
|
|
@@ -80,7 +185,7 @@ export async function runSetup(options) {
|
|
|
80
185
|
// mid-loop would leave earlier successful updates applied in memory (a real
|
|
81
186
|
// issue for long-running consumers like the MCP server and dashboard that
|
|
82
187
|
// share the StateManager singleton across requests).
|
|
83
|
-
prevalidateSettings(options.set);
|
|
188
|
+
prevalidateSettings(options.set, config);
|
|
84
189
|
// Named so the Gist conflict path can re-apply the same settings on a
|
|
85
190
|
// refreshed baseline (maybeCheckpoint below).
|
|
86
191
|
const applySettings = () => {
|
|
@@ -88,6 +193,14 @@ export async function runSetup(options) {
|
|
|
88
193
|
for (const setting of options.set) {
|
|
89
194
|
const [key, ...valueParts] = setting.split('=');
|
|
90
195
|
const value = valueParts.join('=');
|
|
196
|
+
if (isSafeguardList(key)) {
|
|
197
|
+
applySafeguardList(stateManager, key, value, results, warnings);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (isPacingKey(key)) {
|
|
201
|
+
results[key] = applyPacingCap(stateManager, key, value);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
91
204
|
switch (key) {
|
|
92
205
|
case 'username': {
|
|
93
206
|
validateGitHubUsername(value);
|
|
@@ -195,35 +308,6 @@ export async function runSetup(options) {
|
|
|
195
308
|
results[key] = value === 'true' ? 'true' : 'false';
|
|
196
309
|
break;
|
|
197
310
|
}
|
|
198
|
-
case 'aiPolicyBlocklist': {
|
|
199
|
-
const entries = value
|
|
200
|
-
.split(',')
|
|
201
|
-
.map((r) => r.trim())
|
|
202
|
-
.filter(Boolean);
|
|
203
|
-
const valid = [];
|
|
204
|
-
const invalid = [];
|
|
205
|
-
for (const entry of entries) {
|
|
206
|
-
const normalized = entry.replaceAll(/\s+/g, '');
|
|
207
|
-
if (/^[\w.-]+\/[\w.-]+$/.test(normalized)) {
|
|
208
|
-
valid.push(normalized);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
invalid.push(entry);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
if (invalid.length > 0) {
|
|
215
|
-
warnings.push(`Warning: Skipping invalid entries (expected "owner/repo" format): ${invalid.join(', ')}`);
|
|
216
|
-
results['aiPolicyBlocklist_invalidEntries'] = invalid.join(', ');
|
|
217
|
-
}
|
|
218
|
-
if (valid.length === 0 && entries.length > 0) {
|
|
219
|
-
warnings.push('Warning: All entries were invalid. Blocklist not updated.');
|
|
220
|
-
results[key] = '(all entries invalid)';
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
stateManager.updateConfig({ aiPolicyBlocklist: valid });
|
|
224
|
-
results[key] = valid.length > 0 ? valid.join(', ') : '(empty)';
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
311
|
case 'avoidRepos': {
|
|
228
312
|
// Same owner/repo validation as aiPolicyBlocklist: skip (and warn
|
|
229
313
|
// about) malformed entries instead of failing the whole set.
|
|
@@ -247,7 +331,7 @@ export async function runSetup(options) {
|
|
|
247
331
|
}
|
|
248
332
|
if (valid.length === 0 && entries.length > 0) {
|
|
249
333
|
warnings.push('Warning: All entries were invalid. avoidRepos not updated.');
|
|
250
|
-
results
|
|
334
|
+
// No results entry: nothing was stored (#1887).
|
|
251
335
|
break;
|
|
252
336
|
}
|
|
253
337
|
const dedupedRepos = [...new Set(valid)];
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* `node cli.bundle.cjs startup --json` call, reducing UI noise in Claude Code.
|
|
8
8
|
*/
|
|
9
9
|
import { type StartupOutput, type IssueListInfo } from '../formatters/json.js';
|
|
10
|
+
import { type StaleDataCounts } from '../core/stale-data.js';
|
|
10
11
|
/**
|
|
11
12
|
* Count available and completed items in an issue list file.
|
|
12
13
|
* Available items exclude any vetting status that moves an item out of the
|
|
@@ -34,6 +35,12 @@ export declare function detectIssueList(shouldSuggest?: boolean): IssueListInfo
|
|
|
34
35
|
* @param url - URL to open
|
|
35
36
|
*/
|
|
36
37
|
export declare function openInBrowser(url: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Stale-data counts for the `/oss` summary (#2049), from directory listings
|
|
40
|
+
* only (no Git in the worktrees). Any error leaves the field out: this must
|
|
41
|
+
* never fail startup.
|
|
42
|
+
*/
|
|
43
|
+
export declare function staleDataForStartup(): StaleDataCounts | undefined;
|
|
37
44
|
/**
|
|
38
45
|
* Run startup checks and return structured output.
|
|
39
46
|
* Returns StartupOutput with one of three shapes:
|
package/dist/commands/startup.js
CHANGED
|
@@ -19,6 +19,8 @@ import { parseIssueList } from './parse-list.js';
|
|
|
19
19
|
import { detectIssueListPath, persistConfigPath, suggestIssueListPath } from './locate-issue-list.js';
|
|
20
20
|
import { getMachinePath, setMachinePath } from '../core/local-config.js';
|
|
21
21
|
import { overnightFreshness } from './overnight.js';
|
|
22
|
+
import { resolveDataDir } from '../core/paths.js';
|
|
23
|
+
import { countStaleData } from '../core/stale-data.js';
|
|
22
24
|
/**
|
|
23
25
|
* Count available and completed items in an issue list file.
|
|
24
26
|
* Available items exclude any vetting status that moves an item out of the
|
|
@@ -252,6 +254,20 @@ async function triggerDashboardRefresh(port) {
|
|
|
252
254
|
return null;
|
|
253
255
|
}
|
|
254
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;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
255
271
|
/**
|
|
256
272
|
* Run startup checks and return structured output.
|
|
257
273
|
* Returns StartupOutput with one of three shapes:
|
|
@@ -384,5 +400,6 @@ export async function runStartup() {
|
|
|
384
400
|
// State is already loaded and schema-parsed by this point (getStateManager
|
|
385
401
|
// above), so this is an in-memory read that cannot fail (#1574).
|
|
386
402
|
overnight: overnightFreshness(),
|
|
403
|
+
staleData: staleDataForStartup(),
|
|
387
404
|
};
|
|
388
405
|
}
|
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.
|
|
@@ -30,6 +31,10 @@ export async function runStatus(options) {
|
|
|
30
31
|
output.offline = true;
|
|
31
32
|
output.lastUpdated = lastUpdated;
|
|
32
33
|
}
|
|
34
|
+
// Only when a pacing cap is set (#1911).
|
|
35
|
+
const pacing = getPacingStatus(state);
|
|
36
|
+
if (pacing)
|
|
37
|
+
output.pacing = pacing;
|
|
33
38
|
// Surface Gist staleness as a structured warning so cron / dashboard
|
|
34
39
|
// consumers don't need to scrape stderr (#1193).
|
|
35
40
|
const staleness = stateManager.getStateStaleness();
|
|
@@ -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 */
|
|
@@ -16,7 +16,7 @@ import { computeSuccessGrade, gradeFromCandidate, reconcileRecommendation } from
|
|
|
16
16
|
import { repoCapField } from '../core/repo-cap.js';
|
|
17
17
|
import { ValidationError } from '../core/errors.js';
|
|
18
18
|
import { storedPolicy } from '../core/repo-policy.js';
|
|
19
|
-
import { policyFields, vetPolicy } from './vet.js';
|
|
19
|
+
import { policyFields, publicVettingResult, vetPolicy } from './vet.js';
|
|
20
20
|
import { recordVetPolicies } from './policy.js';
|
|
21
21
|
import { getStateManager, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, traitsFromVerification, isFirstInRepo, getOctokit, requireGitHubToken, parseGitHubUrl, verifyIssuesBatch, RULED_OUT_VERDICTS, workClaimVetFields, } from '../core/index.js';
|
|
22
22
|
const UNKNOWN_GRADE = computeSuccessGrade({ avgResponseDays: null, mergeRate: null, daysSinceLastCommit: null });
|
|
@@ -252,7 +252,7 @@ export async function runVetList(options = {}) {
|
|
|
252
252
|
reasonsToSkip: candidate.reasonsToSkip,
|
|
253
253
|
...(candidate.complexityUnlocked && { complexityUnlocked: true }),
|
|
254
254
|
projectHealth: candidate.projectHealth,
|
|
255
|
-
vettingResult: candidate.vettingResult,
|
|
255
|
+
vettingResult: publicVettingResult(candidate.vettingResult),
|
|
256
256
|
antiLLMPolicy: candidate.antiLLMPolicy,
|
|
257
257
|
linkedPRClassification,
|
|
258
258
|
...(linkedPR && { linkedPR }),
|
package/dist/commands/vet.d.ts
CHANGED
|
@@ -19,6 +19,14 @@ interface VetOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function runVet(options: VetOptions): Promise<VetOutput>;
|
|
21
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'];
|
|
22
30
|
/**
|
|
23
31
|
* The repo's contribution policy as far as vet read it (#1953): scout's
|
|
24
32
|
* CONTRIBUTING text and `extraDocs` through the policy parsers, plus scout's own
|
package/dist/commands/vet.js
CHANGED
|
@@ -48,7 +48,7 @@ export async function runVet(options) {
|
|
|
48
48
|
reasonsToSkip: candidate.reasonsToSkip,
|
|
49
49
|
...(candidate.complexityUnlocked && { complexityUnlocked: true }),
|
|
50
50
|
projectHealth: candidate.projectHealth,
|
|
51
|
-
vettingResult: candidate.vettingResult,
|
|
51
|
+
vettingResult: publicVettingResult(candidate.vettingResult),
|
|
52
52
|
antiLLMPolicy: candidate.antiLLMPolicy,
|
|
53
53
|
linkedPRClassification,
|
|
54
54
|
...(linkedPR && { linkedPR }),
|
|
@@ -70,6 +70,20 @@ export async function runVet(options) {
|
|
|
70
70
|
const BANNED_REASON = 'repo policy: the project does not accept AI-assisted contributions';
|
|
71
71
|
/** Linked docs are cut to this many characters before the parsers read them. */
|
|
72
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
|
+
}
|
|
73
87
|
/**
|
|
74
88
|
* The repo's contribution policy as far as vet read it (#1953): scout's
|
|
75
89
|
* CONTRIBUTING text and `extraDocs` through the policy parsers, plus scout's own
|
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 {
|
package/dist/commands/work.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import os from 'node:os';
|
|
17
17
|
import { WORK_CLAIM_DEFAULT_TTL_HOURS, WORK_CLAIM_FINISHED_TTL_HOURS, WORK_CLAIM_MAX_TTL_HOURS, checkImplementationClaim, describeWorkClaim, findWorkClaim, getMachineId, getStateManager, heldByOtherSession, maybeCheckpoint, normalizeWorktreePath, } from '../core/index.js';
|
|
18
18
|
import { ValidationError } from '../core/errors.js';
|
|
19
|
+
import { isOwnRepo } from '../core/urls.js';
|
|
19
20
|
import { buildStalenessWarning } from '../formatters/json.js';
|
|
20
21
|
import { ISSUE_URL_PATTERN, PR_URL_PATTERN, validateGitHubUrl, validateUrl } from './validation.js';
|
|
21
22
|
const MODULE = 'work';
|
|
@@ -266,21 +267,43 @@ export async function finishWork(stateManager, options) {
|
|
|
266
267
|
export async function runWorkRelease(options) {
|
|
267
268
|
return releaseWork(getStateManager(), options);
|
|
268
269
|
}
|
|
269
|
-
/**
|
|
270
|
-
|
|
270
|
+
/** The claims `work release` drops, or null when it only records a PR. */
|
|
271
|
+
function releaseSelector(options) {
|
|
271
272
|
const session = validateField('session', options.session);
|
|
272
273
|
const kind = options.kind === undefined ? undefined : validateKind(options.kind);
|
|
273
274
|
if (options.url !== undefined)
|
|
274
275
|
validateUrl(options.url);
|
|
275
|
-
if (session
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
276
|
+
if (session !== undefined || options.url !== undefined)
|
|
277
|
+
return { url: options.url, session, kind };
|
|
278
|
+
if (options.pr === undefined)
|
|
279
|
+
throw new ValidationError('work release needs a URL, --session <name> or --pr <url>');
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
/** {@link runWorkRelease} against an explicit manager. */
|
|
283
|
+
export async function releaseWork(stateManager, options) {
|
|
284
|
+
const selector = releaseSelector(options);
|
|
285
|
+
const recordedPR = externalPR(stateManager, options.pr);
|
|
286
|
+
const nowMs = Date.now();
|
|
287
|
+
const apply = () => {
|
|
288
|
+
if (recordedPR)
|
|
289
|
+
stateManager.recordNewPR(recordedPR, nowMs);
|
|
290
|
+
return selector ? stateManager.releaseWorkClaims(selector) : [];
|
|
291
|
+
};
|
|
292
|
+
const released = apply();
|
|
293
|
+
// A conflict re-applies on the refreshed state, so another host's records are kept.
|
|
294
|
+
const isChanged = recordedPR !== undefined || released.length > 0;
|
|
295
|
+
const gistSyncWarning = isChanged ? await maybeCheckpoint(stateManager, MODULE, apply) : null;
|
|
296
|
+
return { released, ...(recordedPR && { recordedPR }), ...(gistSyncWarning && { gistSyncWarning }) };
|
|
297
|
+
}
|
|
298
|
+
/** The `--pr` URL to record, validated; undefined when none was given or it is to the user's own repo (never counted). */
|
|
299
|
+
function externalPR(stateManager, pr) {
|
|
300
|
+
if (pr === undefined)
|
|
301
|
+
return undefined;
|
|
302
|
+
validateUrl(pr);
|
|
303
|
+
validateGitHubUrl(pr, PR_URL_PATTERN, 'PR');
|
|
304
|
+
const login = stateManager.getState().config.githubUsername;
|
|
305
|
+
const owner = pr.split('/', 4)[3];
|
|
306
|
+
return login && isOwnRepo(owner, login) ? undefined : pr;
|
|
284
307
|
}
|
|
285
308
|
/**
|
|
286
309
|
* The live claims (#1856). Read-only: expired claims are counted, not
|
|
@@ -8,12 +8,38 @@ export interface CommitDates {
|
|
|
8
8
|
committerDate?: string | null;
|
|
9
9
|
authorLogin?: string | null;
|
|
10
10
|
committerLogin?: string | null;
|
|
11
|
+
/** Author and committer emails from the Git commit: who wrote it when the author email is linked to no GitHub account. */
|
|
12
|
+
authorEmail?: string | null;
|
|
13
|
+
committerEmail?: string | null;
|
|
14
|
+
/** First parent of this commit. */
|
|
15
|
+
parentSha?: string | null;
|
|
16
|
+
/** The commit the latest change request was made against, and its first parent (#2042). */
|
|
17
|
+
reviewedSha?: string | null;
|
|
18
|
+
reviewedParentSha?: string | null;
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
* Whether the author also committed it: their own amend or rebase. Matched on
|
|
22
|
+
* GitHub login, or on the Git email when the author email is linked to no
|
|
23
|
+
* GitHub account (no author login), so an unlinked author's amend still counts.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isOwnRewrite(c: CommitDates): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the commit sits on a different parent than the reviewed commit did
|
|
28
|
+
* (and is not a new commit on top of it): the branch was rebased since the
|
|
29
|
+
* review (#2042). False when any of the three SHAs is unknown.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isRebasedSinceReview(c: CommitDates): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The committer date when the author also committed it (their own amend moved
|
|
34
|
+
* it while Git kept the old author date), the author date when someone else
|
|
35
|
+
* rewrote it (a maintainer's rebase does not make the author's old work new,
|
|
36
|
+
* and is not the author addressing feedback). Either falls back to the other
|
|
37
|
+
* when missing.
|
|
38
|
+
*
|
|
39
|
+
* The author's own rewrite also keeps the author date when it moved the
|
|
40
|
+
* commit onto a new parent since the latest change request: a rebase onto
|
|
41
|
+
* the base branch moves the committer date without touching the review's
|
|
42
|
+
* points, so it must not read as addressing them (#2042). An amend in place
|
|
43
|
+
* keeps the reviewed commit's parent and still counts.
|
|
18
44
|
*/
|
|
19
45
|
export declare function commitDateOf(c: CommitDates): string | undefined;
|