@oss-autopilot/core 3.42.5 → 3.43.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 +272 -25
- package/dist/cli.bundle.cjs +183 -154
- package/dist/commands/check-integration.js +1 -0
- package/dist/commands/cleanup.d.ts +76 -0
- package/dist/commands/cleanup.js +269 -0
- package/dist/commands/comments.d.ts +6 -0
- package/dist/commands/comments.js +6 -2
- package/dist/commands/config.js +37 -5
- 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 +122 -0
- package/dist/commands/daily-ledger.js +225 -0
- package/dist/commands/daily-recent-prs.d.ts +26 -0
- package/dist/commands/daily-recent-prs.js +55 -0
- package/dist/commands/daily.d.ts +2 -1
- package/dist/commands/daily.js +59 -89
- package/dist/commands/dashboard-cache.d.ts +2 -0
- package/dist/commands/dashboard-cache.js +33 -8
- package/dist/commands/dashboard-data.js +71 -36
- package/dist/commands/dashboard-gist-sync.js +3 -1
- package/dist/commands/dashboard-lifecycle.js +1 -1
- package/dist/commands/dashboard-process.d.ts +14 -1
- package/dist/commands/dashboard-process.js +46 -7
- package/dist/commands/dashboard-server.js +89 -23
- package/dist/commands/detect-formatters.js +1 -0
- package/dist/commands/dismiss.js +5 -2
- package/dist/commands/doctor.d.ts +15 -1
- package/dist/commands/doctor.js +73 -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/guidelines.d.ts +23 -1
- package/dist/commands/guidelines.js +49 -4
- package/dist/commands/index.d.ts +24 -4
- package/dist/commands/index.js +15 -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 +13 -8
- package/dist/commands/overnight-push-prep.js +106 -34
- 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 +86 -0
- package/dist/commands/policy.js +263 -0
- package/dist/commands/pr-preflight.d.ts +43 -0
- package/dist/commands/pr-preflight.js +294 -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 +46 -18
- package/dist/commands/skip-add.js +10 -1
- package/dist/commands/startup.d.ts +5 -3
- package/dist/commands/startup.js +65 -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 +1 -0
- package/dist/commands/strategy.js +1 -0
- package/dist/commands/vet-list.d.ts +6 -0
- package/dist/commands/vet-list.js +25 -0
- package/dist/commands/vet.d.ts +12 -0
- package/dist/commands/vet.js +118 -1
- 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 +19 -0
- package/dist/core/commit-date.js +17 -0
- package/dist/core/config-registry.js +11 -5
- package/dist/core/contributing.d.ts +2 -3
- package/dist/core/contributing.js +2 -3
- package/dist/core/daily-logic.d.ts +27 -5
- package/dist/core/daily-logic.js +57 -19
- package/dist/core/errors.d.ts +37 -3
- package/dist/core/errors.js +54 -5
- 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 +97 -46
- package/dist/core/github-stats.d.ts +104 -16
- package/dist/core/github-stats.js +282 -97
- package/dist/core/http-cache.d.ts +0 -10
- package/dist/core/http-cache.js +0 -19
- package/dist/core/index.d.ts +12 -5
- package/dist/core/index.js +15 -5
- 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 +271 -0
- package/dist/core/merged-pr-notes.d.ts +2 -2
- 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.js +6 -2
- package/dist/core/pr-graphql.d.ts +37 -3
- package/dist/core/pr-graphql.js +73 -12
- package/dist/core/pr-monitor.d.ts +29 -12
- package/dist/core/pr-monitor.js +71 -23
- package/dist/core/pr-preflight.d.ts +113 -0
- package/dist/core/pr-preflight.js +364 -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/repo-policy.d.ts +105 -0
- package/dist/core/repo-policy.js +400 -0
- package/dist/core/repo-score-manager.d.ts +48 -0
- package/dist/core/repo-score-manager.js +111 -1
- package/dist/core/review-analysis.d.ts +34 -19
- package/dist/core/review-analysis.js +67 -10
- package/dist/core/reviewed-prs-fetch.js +11 -29
- package/dist/core/reviewed-prs.js +8 -15
- package/dist/core/stale-data.d.ts +41 -0
- package/dist/core/stale-data.js +115 -0
- package/dist/core/state-persistence.d.ts +62 -27
- package/dist/core/state-persistence.js +338 -117
- package/dist/core/state-schema.d.ts +113 -210
- package/dist/core/state-schema.js +165 -80
- package/dist/core/state.d.ts +60 -8
- package/dist/core/state.js +192 -46
- package/dist/core/status-determination.js +26 -8
- 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 +77 -42
- package/dist/core/urls.d.ts +9 -0
- package/dist/core/urls.js +18 -0
- package/dist/dashboard/assets/{chart-panel-DPKNBUts.js → chart-panel-C_C1lFTI.js} +1 -1
- package/dist/dashboard/assets/{index-B25bZOYX.js → index-B--H66Jk.js} +1 -1
- package/dist/dashboard/index.html +1 -1
- package/dist/formatters/json.d.ts +262 -6
- package/dist/formatters/json.js +77 -1
- package/package.json +1 -1
- 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
|
@@ -8,19 +8,22 @@
|
|
|
8
8
|
* thing in the overnight pipeline that pushes. Three gates, all enforced in
|
|
9
9
|
* code rather than by convention:
|
|
10
10
|
*
|
|
11
|
-
* 1. The push target is
|
|
12
|
-
*
|
|
13
|
-
* never trusted
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* 1. The push target is the repository GitHub names: the PR's head repo, or
|
|
12
|
+
* `<login>/<repo>` for an issue. The worktree must hold a remote whose
|
|
13
|
+
* parsed URL names that same repo; remote names are never trusted, and
|
|
14
|
+
* neither is the remote's URL, which the worktree's config can rewrite
|
|
15
|
+
* (#1937). The push goes to a URL built from GitHub's answer, keeping only
|
|
16
|
+
* that remote's transport (pickRemote).
|
|
17
|
+
* 2. That repo must be a fork (`GET /repos/{owner}/{repo}` says `fork: true`)
|
|
18
|
+
* of the PR's repo, so the user's own source repos never grow `prep/*`
|
|
19
|
+
* branches.
|
|
16
20
|
* 3. The ref is always `refs/heads/prep/<branch>` and never `--force`; a
|
|
17
21
|
* non-fast-forward is a skip with a reason.
|
|
18
22
|
*
|
|
19
23
|
* With `OSS_AUTOPILOT_HANDOFF_DIR` set the tick ran as another user, and the
|
|
20
24
|
* branches arrive as bundles (overnight-handoff.ts). Then there is no
|
|
21
|
-
* worktree
|
|
22
|
-
*
|
|
23
|
-
* and the push goes out of a private repo filled from the bundle.
|
|
25
|
+
* worktree, so no remote to compare. Either way the push goes out of a
|
|
26
|
+
* private repo, filled from the bundle or from the worktree's branch.
|
|
24
27
|
*/
|
|
25
28
|
import { execFileSync } from 'node:child_process';
|
|
26
29
|
import * as fs from 'node:fs';
|
|
@@ -28,13 +31,17 @@ import * as path from 'node:path';
|
|
|
28
31
|
import { errorMessage, getOctokit, getStateManager, isRateLimitError, maybeCheckpoint, parseGitHubUrl, requireGitHubToken, } from '../core/index.js';
|
|
29
32
|
import { assertAttended } from '../core/errors.js';
|
|
30
33
|
import { warn } from '../core/logger.js';
|
|
31
|
-
import { getReportsDir } from '../core/paths.js';
|
|
32
|
-
import { handoffDir, importHandoffBundle, loadHandoff } from './overnight-handoff.js';
|
|
34
|
+
import { getReportsDir, resolveDataDir } from '../core/paths.js';
|
|
35
|
+
import { handoffDir, importHandoffBundle, importWorktreeBranch, loadHandoff } from './overnight-handoff.js';
|
|
33
36
|
import { publishReport, reportDateFor, writePreparedSection } from './overnight.js';
|
|
34
37
|
const MODULE = 'overnight-push-prep';
|
|
35
38
|
/** The only ref namespace this command ever pushes to. */
|
|
36
39
|
export const PREP_REF_PREFIX = 'refs/heads/prep/';
|
|
37
40
|
const GIT_TIMEOUT_MS = 60_000;
|
|
41
|
+
// Inherited, any of these would point `git -C <worktree>` at another repository.
|
|
42
|
+
const GIT_REDIRECTS = new Set(['GIT_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE', 'GIT_COMMON_DIR']);
|
|
43
|
+
// `ls-files` on a large repository outgrows the 1 MiB default.
|
|
44
|
+
const GIT_MAX_BUFFER = 64 * 1024 * 1024;
|
|
38
45
|
/** A ref outside `prep/` reached the push gate: a programming error, so the run stops instead of skipping. */
|
|
39
46
|
export class PrepNamespaceError extends Error {
|
|
40
47
|
constructor(ref) {
|
|
@@ -120,15 +127,75 @@ export function prepBranchName(ref) {
|
|
|
120
127
|
export function compareUrlFor(target, prHead, prepBranch) {
|
|
121
128
|
return `https://github.com/${target.owner}/${target.repo}/compare/${prHead}...${prepBranch}`;
|
|
122
129
|
}
|
|
123
|
-
|
|
130
|
+
/** Run `git -C <worktree> <args>` and return its stdout. Also the runner `cleanup` uses. */
|
|
131
|
+
export function git(worktree, args, timeoutMs = GIT_TIMEOUT_MS) {
|
|
132
|
+
const inherited = Object.entries(process.env).filter(([name]) => !GIT_REDIRECTS.has(name));
|
|
124
133
|
return execFileSync('git', ['-C', worktree, ...args], {
|
|
125
134
|
encoding: 'utf8',
|
|
126
|
-
timeout:
|
|
135
|
+
timeout: timeoutMs,
|
|
136
|
+
maxBuffer: GIT_MAX_BUFFER,
|
|
127
137
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
128
138
|
// Unattended: a credential prompt must fail, not hang until the timeout.
|
|
129
|
-
env: { ...
|
|
139
|
+
env: { ...Object.fromEntries(inherited), GIT_TERMINAL_PROMPT: '0' },
|
|
130
140
|
});
|
|
131
141
|
}
|
|
142
|
+
/** Where the preparer puts its worktrees (agents/overnight-preparer.md). */
|
|
143
|
+
function worktreesRoot() {
|
|
144
|
+
return path.join(resolveDataDir(), 'worktrees');
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* True when `worktree`, symlinks resolved, sits below the worktrees root. Both
|
|
148
|
+
* must exist. The path comes from the preparer's report, so Git never runs
|
|
149
|
+
* with the token in a directory it named elsewhere.
|
|
150
|
+
*/
|
|
151
|
+
function isPreparerWorktree(worktree) {
|
|
152
|
+
const root = worktreesRoot();
|
|
153
|
+
if (!fs.existsSync(root))
|
|
154
|
+
return false;
|
|
155
|
+
return fs.realpathSync(worktree).startsWith(fs.realpathSync(root) + path.sep);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The private repo the push runs from: filled from the bundle (handoff) or
|
|
159
|
+
* from the worktree's branch, never anything the tick can write, so the push
|
|
160
|
+
* reads none of the worktree's config or hooks (#1937). The worktree's remote
|
|
161
|
+
* list is read before this, and its config can rewrite what that list shows;
|
|
162
|
+
* the caller only compares it with the target GitHub names.
|
|
163
|
+
*/
|
|
164
|
+
function importBranchToPush(dropDir, entry) {
|
|
165
|
+
return dropDir
|
|
166
|
+
? importHandoffBundle(dropDir, entry.branch)
|
|
167
|
+
: importWorktreeBranch(fs.realpathSync(entry.worktree), entry.branch);
|
|
168
|
+
}
|
|
169
|
+
/** Skip reason when the worktree's remote is not the repo the push must go to; null when it is. */
|
|
170
|
+
function remoteMismatch(found, expected) {
|
|
171
|
+
const [actual, wanted] = [`${found.owner}/${found.repo}`, `${expected.owner}/${expected.repo}`];
|
|
172
|
+
return actual.toLowerCase() === wanted.toLowerCase()
|
|
173
|
+
? null
|
|
174
|
+
: `remote ${found.remote} points at ${actual}, not ${wanted}`;
|
|
175
|
+
}
|
|
176
|
+
// The two SSH spellings of github.com with no port. Only the scheme is taken from the remote.
|
|
177
|
+
const SSH_REMOTE = /^(?:git@github\.com:|ssh:\/\/git@github\.com\/)/;
|
|
178
|
+
/**
|
|
179
|
+
* The login-owned remote that names `expected`, and the URL to push to: built
|
|
180
|
+
* from `expected` and the literal host, over SSH when that remote's own push
|
|
181
|
+
* URL is an SSH form for github.com, else HTTPS. The remote's string is never
|
|
182
|
+
* pushed to.
|
|
183
|
+
*/
|
|
184
|
+
function pickRemote(remotes, login, expected, worktree) {
|
|
185
|
+
const names = [...new Set(remotes.map((r) => r.name))];
|
|
186
|
+
const owned = names.flatMap((name) => resolvePushRemote(remotes.filter((r) => r.name === name), login) ?? []);
|
|
187
|
+
if (owned.length === 0)
|
|
188
|
+
return { reason: `no remote in ${worktree} is owned by ${login}` };
|
|
189
|
+
const target = owned.find((candidate) => remoteMismatch(candidate, expected) === null);
|
|
190
|
+
if (!target)
|
|
191
|
+
return { reason: remoteMismatch(owned[0], expected) ?? undefined };
|
|
192
|
+
const url = remotes.find((r) => r.name === target.remote)?.url ?? '';
|
|
193
|
+
const pushUrl = SSH_REMOTE.test(url) ? `git@github.com:${expected.owner}/${expected.repo}.git` : expected.remote;
|
|
194
|
+
return { target, pushUrl };
|
|
195
|
+
}
|
|
196
|
+
function outsideRoot(worktree) {
|
|
197
|
+
return `worktree ${worktree} is not under ${worktreesRoot()}`;
|
|
198
|
+
}
|
|
132
199
|
function gitStderr(err) {
|
|
133
200
|
const stderr = err?.stderr;
|
|
134
201
|
return typeof stderr === 'string' ? stderr.trim() : '';
|
|
@@ -246,8 +313,8 @@ export async function runOvernightPushPrep(options) {
|
|
|
246
313
|
}
|
|
247
314
|
return pending;
|
|
248
315
|
}
|
|
249
|
-
/**
|
|
250
|
-
async function
|
|
316
|
+
/** Where a branch for `url` must go: the PR's head repo, or `<login>/<repo>` for an issue; a string is a skip reason. */
|
|
317
|
+
async function expectedTarget(url) {
|
|
251
318
|
const parsed = parseGitHubUrl(url);
|
|
252
319
|
if (!parsed)
|
|
253
320
|
return `${url} is not a GitHub PR or issue URL`;
|
|
@@ -266,24 +333,29 @@ export async function runOvernightPushPrep(options) {
|
|
|
266
333
|
return { target: { owner, repo, remote: `https://github.com/${owner}/${repo}.git` }, upstream };
|
|
267
334
|
}
|
|
268
335
|
async function pushOne(entry) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
({ target, upstream } = resolved);
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
336
|
+
// Without the handoff, the worktree's remotes are read; a remote's URL is
|
|
337
|
+
// the worktree's word (a `pushurl` or `pushInsteadOf` there can name any
|
|
338
|
+
// repo the login owns), so one of them only has to agree with the target
|
|
339
|
+
// GitHub names. The push goes to a URL built from that target.
|
|
340
|
+
let remotes;
|
|
341
|
+
if (!dropDir) {
|
|
278
342
|
if (!entry.worktree)
|
|
279
343
|
return skip(entry, 'no worktree recorded');
|
|
280
344
|
if (!fs.existsSync(entry.worktree))
|
|
281
345
|
return skip(entry, `worktree ${entry.worktree} does not exist`);
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
target = found;
|
|
346
|
+
if (!isPreparerWorktree(entry.worktree))
|
|
347
|
+
return skip(entry, outsideRoot(entry.worktree));
|
|
348
|
+
remotes = parseRemotesOutput(git(entry.worktree, ['remote', '-v']));
|
|
286
349
|
}
|
|
350
|
+
const expected = await expectedTarget(entry.url);
|
|
351
|
+
if (typeof expected === 'string')
|
|
352
|
+
return skip(entry, expected);
|
|
353
|
+
const picked = remotes ? pickRemote(remotes, login, expected.target, entry.worktree) : {};
|
|
354
|
+
if (picked.reason)
|
|
355
|
+
return skip(entry, picked.reason);
|
|
356
|
+
const { upstream } = expected;
|
|
357
|
+
const target = picked.target ?? expected.target;
|
|
358
|
+
const pushUrl = picked.pushUrl ?? expected.target.remote;
|
|
287
359
|
const notFork = await forkSkipReason(target, upstream);
|
|
288
360
|
if (notFork)
|
|
289
361
|
return skip(entry, notFork, target);
|
|
@@ -314,18 +386,18 @@ export async function runOvernightPushPrep(options) {
|
|
|
314
386
|
// from writing refs/tags/*; `--` keeps the remote name out of option
|
|
315
387
|
// parsing.
|
|
316
388
|
assertPrepRef(ref);
|
|
317
|
-
//
|
|
318
|
-
//
|
|
319
|
-
// failure (the tick recorded a branch it did not deliver), not a gate.
|
|
389
|
+
// A branch that cannot be imported is a failure (the tick recorded a
|
|
390
|
+
// branch it did not deliver), not a gate.
|
|
320
391
|
let source;
|
|
321
392
|
try {
|
|
322
|
-
source =
|
|
393
|
+
source = importBranchToPush(dropDir, entry);
|
|
323
394
|
}
|
|
324
395
|
catch (err) {
|
|
325
|
-
|
|
396
|
+
const what = dropDir ? 'bundle import' : 'reading the branch from the worktree';
|
|
397
|
+
return notPushed('failed', entry, `${what} failed: ${errorMessage(err)}`, target, ref);
|
|
326
398
|
}
|
|
327
399
|
try {
|
|
328
|
-
git(source.repo, ['push', '--no-follow-tags', '--',
|
|
400
|
+
git(source.repo, ['push', '--no-follow-tags', '--', pushUrl, `refs/heads/${entry.branch}:${ref}`]);
|
|
329
401
|
}
|
|
330
402
|
catch (err) {
|
|
331
403
|
return isNonFastForward(err)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool rules and Git environment of the scheduled overnight run
|
|
3
|
+
* (commands/oss-overnight.md, "Scheduling").
|
|
4
|
+
*
|
|
5
|
+
* How Claude Code matches a `Bash(<pattern>)` rule, per its permissions
|
|
6
|
+
* documentation:
|
|
7
|
+
*
|
|
8
|
+
* - `*` matches any text, spaces included, at any position. Only the literal
|
|
9
|
+
* text before the first `*` limits a rule.
|
|
10
|
+
* - A trailing ` *` that is the rule's only wildcard also matches the bare
|
|
11
|
+
* command, so the paired bare rules below are redundant and harmless.
|
|
12
|
+
* - A compound command is split on `&&`, `||`, `;`, `|`, `|&`, `&` and
|
|
13
|
+
* newlines. Every part must be allowed; a deny applies when any part
|
|
14
|
+
* matches, inside a subshell or a command substitution too.
|
|
15
|
+
* - Deny is checked before allow, and an allow cannot carve an exception out
|
|
16
|
+
* of a deny.
|
|
17
|
+
* - `Read(~/path)` denies cover the file tools and, best effort, Grep, Glob and
|
|
18
|
+
* the file commands Bash recognises. A subprocess can still read the file.
|
|
19
|
+
*
|
|
20
|
+
* The same documentation says argument patterns are fragile and not a
|
|
21
|
+
* security boundary. That holds here (#1937): the lists filter spelling, not
|
|
22
|
+
* capability. `node`, `pnpm` and `npm` stay because the CLI bundle and a
|
|
23
|
+
* repository's test suite are already arbitrary code, and `Write` can plant a
|
|
24
|
+
* script, a hook or an alias. The `*` in `git -C * <sub>` (which Claude Code
|
|
25
|
+
* warns about at startup, a wildcard before the subcommand) also admits any
|
|
26
|
+
* other subcommand whose arguments end in an allowed word. The boundary is a
|
|
27
|
+
* dedicated user with no push credentials ("Split users" in the command doc),
|
|
28
|
+
* or an OS sandbox.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Deny list layered under the allowlist: even if a future allow rule widens,
|
|
32
|
+
* these never run unattended. `AskUserQuestion` is denied because nobody can
|
|
33
|
+
* answer; the preparer agent reports `blocked` instead.
|
|
34
|
+
*/
|
|
35
|
+
export declare const OVERNIGHT_DISALLOWED_TOOLS: string;
|
|
36
|
+
/**
|
|
37
|
+
* Tools the headless run may use without a prompt: enumerated, not
|
|
38
|
+
* wildcarded. No `bash`, `sh` or `npx`.
|
|
39
|
+
*/
|
|
40
|
+
export declare const OVERNIGHT_ALLOWED_TOOLS: string;
|
|
41
|
+
export declare const PUSH_DISABLED_URL = "https://push-disabled.invalid/";
|
|
42
|
+
/** The spellings of a GitHub remote whose pushes are rewritten; any other spelling is not. */
|
|
43
|
+
export declare const GITHUB_PUSH_PREFIXES: string[];
|
|
44
|
+
/**
|
|
45
|
+
* Git environment for the scheduled run (#1937): a seat belt under the deny
|
|
46
|
+
* list, not a boundary, because code the run executes can unset it.
|
|
47
|
+
* `pushInsteadOf` sends a push to one of the prefixes above to a host that
|
|
48
|
+
* cannot resolve while fetches keep working; a remote with an explicit
|
|
49
|
+
* `pushurl`, or a URL spelled another way, is not rewritten.
|
|
50
|
+
* `GIT_ALLOW_PROTOCOL` drops the `ext::` transport, which runs a command.
|
|
51
|
+
* Values are never empty: a plist entry launchd dropped would make every Git
|
|
52
|
+
* call fail on a missing value.
|
|
53
|
+
*/
|
|
54
|
+
export declare const OVERNIGHT_GIT_ENV: Record<string, string>;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool rules and Git environment of the scheduled overnight run
|
|
3
|
+
* (commands/oss-overnight.md, "Scheduling").
|
|
4
|
+
*
|
|
5
|
+
* How Claude Code matches a `Bash(<pattern>)` rule, per its permissions
|
|
6
|
+
* documentation:
|
|
7
|
+
*
|
|
8
|
+
* - `*` matches any text, spaces included, at any position. Only the literal
|
|
9
|
+
* text before the first `*` limits a rule.
|
|
10
|
+
* - A trailing ` *` that is the rule's only wildcard also matches the bare
|
|
11
|
+
* command, so the paired bare rules below are redundant and harmless.
|
|
12
|
+
* - A compound command is split on `&&`, `||`, `;`, `|`, `|&`, `&` and
|
|
13
|
+
* newlines. Every part must be allowed; a deny applies when any part
|
|
14
|
+
* matches, inside a subshell or a command substitution too.
|
|
15
|
+
* - Deny is checked before allow, and an allow cannot carve an exception out
|
|
16
|
+
* of a deny.
|
|
17
|
+
* - `Read(~/path)` denies cover the file tools and, best effort, Grep, Glob and
|
|
18
|
+
* the file commands Bash recognises. A subprocess can still read the file.
|
|
19
|
+
*
|
|
20
|
+
* The same documentation says argument patterns are fragile and not a
|
|
21
|
+
* security boundary. That holds here (#1937): the lists filter spelling, not
|
|
22
|
+
* capability. `node`, `pnpm` and `npm` stay because the CLI bundle and a
|
|
23
|
+
* repository's test suite are already arbitrary code, and `Write` can plant a
|
|
24
|
+
* script, a hook or an alias. The `*` in `git -C * <sub>` (which Claude Code
|
|
25
|
+
* warns about at startup, a wildcard before the subcommand) also admits any
|
|
26
|
+
* other subcommand whose arguments end in an allowed word. The boundary is a
|
|
27
|
+
* dedicated user with no push credentials ("Split users" in the command doc),
|
|
28
|
+
* or an OS sandbox.
|
|
29
|
+
*/
|
|
30
|
+
/** The subcommands the procedure uses; never `push`. */
|
|
31
|
+
const GIT_SUBCOMMANDS = [
|
|
32
|
+
'clone',
|
|
33
|
+
'fetch',
|
|
34
|
+
'worktree',
|
|
35
|
+
'checkout',
|
|
36
|
+
'switch',
|
|
37
|
+
'branch',
|
|
38
|
+
'rebase',
|
|
39
|
+
'merge-base',
|
|
40
|
+
'status',
|
|
41
|
+
'diff',
|
|
42
|
+
'log',
|
|
43
|
+
'show',
|
|
44
|
+
'add',
|
|
45
|
+
'commit',
|
|
46
|
+
'rev-parse',
|
|
47
|
+
'remote',
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* The read side of `gh` only: no `gh api` (it can POST), no `gh auth` (it can
|
|
51
|
+
* print the token), no `gh issue view` (raw output is unfenced; the
|
|
52
|
+
* `issue-thread` CLI command is the fenced read, #1932).
|
|
53
|
+
*/
|
|
54
|
+
const GH_READ_SUBCOMMANDS = ['pr view', 'pr checks', 'pr diff', 'pr list', 'run view', 'run list', 'repo view'];
|
|
55
|
+
/** `git <tail>` as the first argument, and anywhere after it (`git -C <dir> <tail>`). */
|
|
56
|
+
function gitAnywhere(tail) {
|
|
57
|
+
return [`Bash(git ${tail})`, `Bash(git * ${tail})`];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Deny list layered under the allowlist: even if a future allow rule widens,
|
|
61
|
+
* these never run unattended. `AskUserQuestion` is denied because nobody can
|
|
62
|
+
* answer; the preparer agent reports `blocked` instead.
|
|
63
|
+
*/
|
|
64
|
+
export const OVERNIGHT_DISALLOWED_TOOLS = [
|
|
65
|
+
// Spelled out, not built with gitAnywhere: unattended-write-guard.test.ts
|
|
66
|
+
// reads a quoted `push` on its own as a spawned push.
|
|
67
|
+
'Bash(git push)',
|
|
68
|
+
'Bash(git push *)',
|
|
69
|
+
'Bash(git * push)',
|
|
70
|
+
'Bash(git * push *)',
|
|
71
|
+
'Bash(gh pr create *)',
|
|
72
|
+
'Bash(gh pr comment *)',
|
|
73
|
+
'Bash(gh pr merge *)',
|
|
74
|
+
'Bash(gh pr close *)',
|
|
75
|
+
'Bash(gh pr edit *)',
|
|
76
|
+
'Bash(gh pr ready *)',
|
|
77
|
+
'Bash(gh issue create *)',
|
|
78
|
+
'Bash(gh issue comment *)',
|
|
79
|
+
'Bash(gh issue close *)',
|
|
80
|
+
'Bash(gh issue view)',
|
|
81
|
+
'Bash(gh issue view *)',
|
|
82
|
+
'Bash(gh run rerun *)',
|
|
83
|
+
'Bash(gh api *)',
|
|
84
|
+
// Registry writes: a token in ~/.npmrc would let them ship a release
|
|
85
|
+
// unattended. Also after a leading flag (`pnpm -r publish`), as a whole
|
|
86
|
+
// word, so `npm run publish:docs` and a package named `publish-utils` pass.
|
|
87
|
+
'Bash(npm publish)',
|
|
88
|
+
'Bash(npm publish *)',
|
|
89
|
+
'Bash(npm * publish)',
|
|
90
|
+
'Bash(npm * publish *)',
|
|
91
|
+
'Bash(npm unpublish *)',
|
|
92
|
+
'Bash(npm deprecate *)',
|
|
93
|
+
'Bash(pnpm publish)',
|
|
94
|
+
'Bash(pnpm publish *)',
|
|
95
|
+
'Bash(pnpm * publish)',
|
|
96
|
+
'Bash(pnpm * publish *)',
|
|
97
|
+
// Direct shell escapes inside the allowed programs (#1728): `npm exec` is
|
|
98
|
+
// npx, `pnpm dlx` and `pnpm exec` run any package, `node -e` runs any
|
|
99
|
+
// JavaScript. Each could spawn a push and void the push denies above.
|
|
100
|
+
'Bash(npm exec)',
|
|
101
|
+
'Bash(npm exec *)',
|
|
102
|
+
'Bash(npm x)',
|
|
103
|
+
'Bash(npm x *)',
|
|
104
|
+
'Bash(npm * exec *)',
|
|
105
|
+
'Bash(npm * x *)',
|
|
106
|
+
'Bash(pnpm dlx *)',
|
|
107
|
+
'Bash(pnpm * dlx *)',
|
|
108
|
+
'Bash(pnpm exec)',
|
|
109
|
+
'Bash(pnpm exec *)',
|
|
110
|
+
'Bash(pnpm * exec *)',
|
|
111
|
+
'Bash(node -e *)',
|
|
112
|
+
'Bash(node --eval *)',
|
|
113
|
+
'Bash(node -p *)',
|
|
114
|
+
'Bash(node -pe *)',
|
|
115
|
+
'Bash(node --print *)',
|
|
116
|
+
'Bash(node * -e *)',
|
|
117
|
+
'Bash(node * --eval *)',
|
|
118
|
+
'Bash(node * -p *)',
|
|
119
|
+
'Bash(node * -pe *)',
|
|
120
|
+
'Bash(node * --print *)',
|
|
121
|
+
// The `=` forms take no space: `node --eval=<js>` runs like `node --eval <js>`.
|
|
122
|
+
'Bash(node --eval=*)',
|
|
123
|
+
'Bash(node * --eval=*)',
|
|
124
|
+
'Bash(node --print=*)',
|
|
125
|
+
'Bash(node * --print=*)',
|
|
126
|
+
// Git option forms that run a program or inject config from an allowed
|
|
127
|
+
// subcommand (#1937). These trip on the plain spellings, including the
|
|
128
|
+
// abbreviations Git accepts (`--upl`, clone's `--u`, `--co` and `--te`,
|
|
129
|
+
// rebase's `--ex`) and a short option with its value attached (`-x<cmd>`).
|
|
130
|
+
// An option with quotes or escapes inside it (`--upl"oad-pack"`) still gets
|
|
131
|
+
// through. They also match the same text inside a quoted argument, which is
|
|
132
|
+
// why the preparer commits with `-F <file>` and never `-m`.
|
|
133
|
+
'Bash(git -c *)',
|
|
134
|
+
// `-c name=value` needs its `=`, so `switch -c <branch>` still works.
|
|
135
|
+
'Bash(git * -c*=*)',
|
|
136
|
+
'Bash(git * -x*)',
|
|
137
|
+
'Bash(git *--config*)',
|
|
138
|
+
'Bash(git *--exec*)',
|
|
139
|
+
'Bash(git *--upl*)',
|
|
140
|
+
'Bash(git *--receive-pack*)',
|
|
141
|
+
'Bash(git *--template*)',
|
|
142
|
+
'Bash(git *--ext-diff*)',
|
|
143
|
+
'Bash(git *--output*)',
|
|
144
|
+
'Bash(git *ext::*)',
|
|
145
|
+
...['clone -u*', 'clone * -u*', 'clone *--u*', 'clone *--co*', 'clone *--te*', 'rebase *--ex*'].flatMap((tail) => gitAnywhere(tail)),
|
|
146
|
+
// Push by another name, and anything that hands out a credential. Whole
|
|
147
|
+
// words after a space, so a path such as `src/credential-store.ts` or a
|
|
148
|
+
// repository named `git-credential-manager` does not match.
|
|
149
|
+
'Bash(git send-pack*)',
|
|
150
|
+
'Bash(git http-push*)',
|
|
151
|
+
'Bash(git credential*)',
|
|
152
|
+
...['send-pack', 'send-pack *', 'http-push', 'http-push *', 'credential', 'credential *'].map((tail) => `Bash(git * ${tail})`),
|
|
153
|
+
'Bash(git * credential-* get*)',
|
|
154
|
+
'Bash(gh auth)',
|
|
155
|
+
'Bash(gh auth *)',
|
|
156
|
+
'Bash(security *)',
|
|
157
|
+
// Credential files, kept from the file tools (see the header for the limit).
|
|
158
|
+
'Read(~/.config/gh/**)',
|
|
159
|
+
'Read(~/.ssh/**)',
|
|
160
|
+
'Read(~/.npmrc)',
|
|
161
|
+
'Read(~/.netrc)',
|
|
162
|
+
'Read(~/.git-credentials)',
|
|
163
|
+
'AskUserQuestion',
|
|
164
|
+
].join(',');
|
|
165
|
+
/**
|
|
166
|
+
* Tools the headless run may use without a prompt: enumerated, not
|
|
167
|
+
* wildcarded. No `bash`, `sh` or `npx`.
|
|
168
|
+
*/
|
|
169
|
+
export const OVERNIGHT_ALLOWED_TOOLS = [
|
|
170
|
+
'Read',
|
|
171
|
+
'Edit',
|
|
172
|
+
'Write',
|
|
173
|
+
'Glob',
|
|
174
|
+
'Grep',
|
|
175
|
+
'Task',
|
|
176
|
+
// Both the bare and the `-C <dir>` forms: a preparer's worktree is never its
|
|
177
|
+
// cwd, and `cd <dir> && git ...` is denied under dontAsk, so without `-C`
|
|
178
|
+
// every preparer blocks (#1697).
|
|
179
|
+
...GIT_SUBCOMMANDS.flatMap((sub) => [
|
|
180
|
+
`Bash(git ${sub})`,
|
|
181
|
+
`Bash(git ${sub} *)`,
|
|
182
|
+
`Bash(git -C * ${sub})`,
|
|
183
|
+
`Bash(git -C * ${sub} *)`,
|
|
184
|
+
]),
|
|
185
|
+
...GH_READ_SUBCOMMANDS.map((sub) => `Bash(gh ${sub} *)`),
|
|
186
|
+
'Bash(node *)',
|
|
187
|
+
'Bash(pnpm *)',
|
|
188
|
+
'Bash(npm *)',
|
|
189
|
+
].join(',');
|
|
190
|
+
export const PUSH_DISABLED_URL = 'https://push-disabled.invalid/';
|
|
191
|
+
/** The spellings of a GitHub remote whose pushes are rewritten; any other spelling is not. */
|
|
192
|
+
export const GITHUB_PUSH_PREFIXES = [
|
|
193
|
+
'https://github.com/',
|
|
194
|
+
'git@github.com:',
|
|
195
|
+
'ssh://git@github.com/',
|
|
196
|
+
'ssh://git@github.com:22/',
|
|
197
|
+
'git@ssh.github.com:',
|
|
198
|
+
];
|
|
199
|
+
/**
|
|
200
|
+
* Git environment for the scheduled run (#1937): a seat belt under the deny
|
|
201
|
+
* list, not a boundary, because code the run executes can unset it.
|
|
202
|
+
* `pushInsteadOf` sends a push to one of the prefixes above to a host that
|
|
203
|
+
* cannot resolve while fetches keep working; a remote with an explicit
|
|
204
|
+
* `pushurl`, or a URL spelled another way, is not rewritten.
|
|
205
|
+
* `GIT_ALLOW_PROTOCOL` drops the `ext::` transport, which runs a command.
|
|
206
|
+
* Values are never empty: a plist entry launchd dropped would make every Git
|
|
207
|
+
* call fail on a missing value.
|
|
208
|
+
*/
|
|
209
|
+
export const OVERNIGHT_GIT_ENV = {
|
|
210
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
211
|
+
GIT_ALLOW_PROTOCOL: 'file:git:http:https:ssh',
|
|
212
|
+
GIT_CONFIG_COUNT: String(GITHUB_PUSH_PREFIXES.length),
|
|
213
|
+
...Object.fromEntries(GITHUB_PUSH_PREFIXES.flatMap((prefix, i) => [
|
|
214
|
+
[`GIT_CONFIG_KEY_${i}`, `url.${PUSH_DISABLED_URL}.pushInsteadOf`],
|
|
215
|
+
[`GIT_CONFIG_VALUE_${i}`, prefix],
|
|
216
|
+
])),
|
|
217
|
+
};
|
|
@@ -218,13 +218,13 @@ export interface ScheduleOptions {
|
|
|
218
218
|
install: boolean;
|
|
219
219
|
}
|
|
220
220
|
export declare const LAUNCHD_LABEL = "com.oss-autopilot.overnight";
|
|
221
|
+
export { OVERNIGHT_ALLOWED_TOOLS, OVERNIGHT_DISALLOWED_TOOLS, OVERNIGHT_GIT_ENV, PUSH_DISABLED_URL, } from './overnight-tool-rules.js';
|
|
221
222
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
223
|
+
* Pure: whether an installed plist carries the rules and environment this
|
|
224
|
+
* version renders. The lists are baked in when the plist is written, so a
|
|
225
|
+
* schedule installed before an upgrade keeps the old ones (`doctor` warns).
|
|
225
226
|
*/
|
|
226
|
-
export declare
|
|
227
|
-
export declare const OVERNIGHT_ALLOWED_TOOLS: string;
|
|
227
|
+
export declare function isScheduleCurrent(plist: string): boolean;
|
|
228
228
|
/**
|
|
229
229
|
* The settings layer the scheduled job runs with instead of the user's own
|
|
230
230
|
* (#1697). Permission allow rules union across settings layers, and a user
|
|
@@ -252,4 +252,3 @@ export interface ScheduleOutput {
|
|
|
252
252
|
*/
|
|
253
253
|
export declare function resolveClaudePath(claudePath: string, envPath?: string | undefined): string;
|
|
254
254
|
export declare function runOvernightSchedule(options: ScheduleOptions): ScheduleOutput;
|
|
255
|
-
export {};
|