@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
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import * as path from 'node:path';
|
|
6
6
|
import { execFileSync } from 'node:child_process';
|
|
7
7
|
import { debug } from '../core/index.js';
|
|
8
|
-
import { errorMessage } from '../core/errors.js';
|
|
8
|
+
import { ValidationError, errorMessage } from '../core/errors.js';
|
|
9
|
+
import { BRANCH_NAME_PATTERN } from './validation.js';
|
|
9
10
|
/** File extensions we consider "code" that should be imported/referenced */
|
|
10
11
|
const CODE_EXTENSIONS = new Set([
|
|
11
12
|
'.ts',
|
|
@@ -65,8 +66,11 @@ function suggestEntryPoints(newFile, existingFiles) {
|
|
|
65
66
|
}
|
|
66
67
|
return [...new Set(suggestions)];
|
|
67
68
|
}
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- async keeps the Promise-returning contract callers rely on; the body has no await yet
|
|
68
70
|
export async function runCheckIntegration(options) {
|
|
69
71
|
const base = options.base;
|
|
72
|
+
if (!BRANCH_NAME_PATTERN.test(base))
|
|
73
|
+
throw new ValidationError(`Invalid base branch name: ${base}`);
|
|
70
74
|
// Get new files added in this branch vs base
|
|
71
75
|
let newFiles;
|
|
72
76
|
try {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cleanup` (#1956): report, and with `--apply` remove, stale data under
|
|
3
|
+
* `~/.oss-autopilot`: overnight worktrees and rejected state copies.
|
|
4
|
+
*
|
|
5
|
+
* Overnight worktrees (`worktrees/<owner>-<repo>-<n>`) are created by the
|
|
6
|
+
* overnight-preparer agent, not by this CLI, and nothing recorded their
|
|
7
|
+
* removal. A worktree is removed only when every check below passes, in this
|
|
8
|
+
* order; a check that fails or errors keeps it, with the reason in the output:
|
|
9
|
+
*
|
|
10
|
+
* 1. it is a direct child of `worktrees/`, a real directory (not a symlink)
|
|
11
|
+
* with a name the preparer creates, and it resolves inside the data dir;
|
|
12
|
+
* 2. it is the root of a linked Git worktree (`.git` is a file), its own
|
|
13
|
+
* config names no clean or process filter, no config names a promisor
|
|
14
|
+
* remote, and it holds no submodule, so the checks below neither run a
|
|
15
|
+
* filter the worktree chose nor fetch (#2047);
|
|
16
|
+
* 3. `git status --porcelain --untracked-files=all` is empty: no modified and
|
|
17
|
+
* no untracked files, whatever `status.showUntrackedFiles` says;
|
|
18
|
+
* 4. HEAD is contained in a remote-tracking ref, so no commit lives only here;
|
|
19
|
+
* 5. no rebase, merge, cherry-pick (a leftover `sequencer` included), revert
|
|
20
|
+
* or bisect is in progress;
|
|
21
|
+
* 6. every ignored file sits under a build-output directory
|
|
22
|
+
* ({@link BUILD_OUTPUT}); an ignored `.env`, or an ignored file that is
|
|
23
|
+
* merely named `build`, keeps the worktree;
|
|
24
|
+
* 7. no file is flagged skip-worktree or assume-unchanged, which would hide
|
|
25
|
+
* an edit from 3;
|
|
26
|
+
* 8. every commit in this worktree's HEAD reflog is reachable from a branch,
|
|
27
|
+
* a remote-tracking ref or a tag;
|
|
28
|
+
* 9. nothing touched it for {@link WORKTREE_MIN_AGE_DAYS} days.
|
|
29
|
+
*
|
|
30
|
+
* Each worktree is judged and, with `--apply`, removed at once, so nothing
|
|
31
|
+
* happens to it between the two. Removal is `git worktree remove` without
|
|
32
|
+
* `--force`, which re-checks 3 itself and leaves the branch in the clone. No
|
|
33
|
+
* network access, no `rm`. `--apply` refuses during an unattended run. A
|
|
34
|
+
* check that throws, and a removal Git refuses, are listed in `errors`.
|
|
35
|
+
*
|
|
36
|
+
* Two deliberate differences from the issue text:
|
|
37
|
+
* - PR merged/closed is not checked (that needs the network). A clean,
|
|
38
|
+
* pushed, idle worktree of a still-open PR is removed too; the preparer
|
|
39
|
+
* recreates it on demand.
|
|
40
|
+
* - `doctor` reports counts only, not sizes or ages; the detail is here.
|
|
41
|
+
*/
|
|
42
|
+
import { WORKTREE_MIN_AGE_DAYS } from '../core/stale-data.js';
|
|
43
|
+
export { WORKTREE_MIN_AGE_DAYS };
|
|
44
|
+
/** Ignored paths under a directory with one of these names are rebuildable, not work. */
|
|
45
|
+
export declare const BUILD_OUTPUT: Set<string>;
|
|
46
|
+
export type WorktreeAction = 'removed' | 'would-remove' | 'kept';
|
|
47
|
+
export interface WorktreeReport {
|
|
48
|
+
path: string;
|
|
49
|
+
/** Whole days since the directory or its index last changed; null when unreadable. */
|
|
50
|
+
ageDays: number | null;
|
|
51
|
+
/** null: the check did not run or errored. */
|
|
52
|
+
clean: boolean | null;
|
|
53
|
+
pushed: boolean | null;
|
|
54
|
+
action: WorktreeAction;
|
|
55
|
+
/** Why it was kept, or why it is safe to remove. */
|
|
56
|
+
reason: string;
|
|
57
|
+
}
|
|
58
|
+
export interface WorktreeScan {
|
|
59
|
+
worktrees: WorktreeReport[];
|
|
60
|
+
/** What went wrong: a scan that threw, a removal that was planned and then refused. */
|
|
61
|
+
errors: string[];
|
|
62
|
+
}
|
|
63
|
+
export interface CleanupOutput extends WorktreeScan {
|
|
64
|
+
/** False: a dry run, nothing was deleted. */
|
|
65
|
+
applied: boolean;
|
|
66
|
+
/** Rejected state copies past retention: removed when `applied`, else listed. */
|
|
67
|
+
rejectedCopies: string[];
|
|
68
|
+
}
|
|
69
|
+
export interface CleanupOptions {
|
|
70
|
+
apply: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** Every direct child of `<dataDir>/worktrees`, judged; removed only with `apply`. Never throws. */
|
|
73
|
+
export declare function cleanWorktrees(dataDir: string, options: CleanupOptions, now?: number): WorktreeScan;
|
|
74
|
+
/**
|
|
75
|
+
* `errors` is non-empty when anything went wrong, in a dry run too; the CLI
|
|
76
|
+
* action turns that into a non-zero exit code, since a scheduler or a script
|
|
77
|
+
* sees only that and a partial `--apply` is not success.
|
|
78
|
+
*/
|
|
79
|
+
export declare function runCleanup(options: CleanupOptions): CleanupOutput;
|
|
80
|
+
export declare function printCleanup(data: CleanupOutput): void;
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cleanup` (#1956): report, and with `--apply` remove, stale data under
|
|
3
|
+
* `~/.oss-autopilot`: overnight worktrees and rejected state copies.
|
|
4
|
+
*
|
|
5
|
+
* Overnight worktrees (`worktrees/<owner>-<repo>-<n>`) are created by the
|
|
6
|
+
* overnight-preparer agent, not by this CLI, and nothing recorded their
|
|
7
|
+
* removal. A worktree is removed only when every check below passes, in this
|
|
8
|
+
* order; a check that fails or errors keeps it, with the reason in the output:
|
|
9
|
+
*
|
|
10
|
+
* 1. it is a direct child of `worktrees/`, a real directory (not a symlink)
|
|
11
|
+
* with a name the preparer creates, and it resolves inside the data dir;
|
|
12
|
+
* 2. it is the root of a linked Git worktree (`.git` is a file), its own
|
|
13
|
+
* config names no clean or process filter, no config names a promisor
|
|
14
|
+
* remote, and it holds no submodule, so the checks below neither run a
|
|
15
|
+
* filter the worktree chose nor fetch (#2047);
|
|
16
|
+
* 3. `git status --porcelain --untracked-files=all` is empty: no modified and
|
|
17
|
+
* no untracked files, whatever `status.showUntrackedFiles` says;
|
|
18
|
+
* 4. HEAD is contained in a remote-tracking ref, so no commit lives only here;
|
|
19
|
+
* 5. no rebase, merge, cherry-pick (a leftover `sequencer` included), revert
|
|
20
|
+
* or bisect is in progress;
|
|
21
|
+
* 6. every ignored file sits under a build-output directory
|
|
22
|
+
* ({@link BUILD_OUTPUT}); an ignored `.env`, or an ignored file that is
|
|
23
|
+
* merely named `build`, keeps the worktree;
|
|
24
|
+
* 7. no file is flagged skip-worktree or assume-unchanged, which would hide
|
|
25
|
+
* an edit from 3;
|
|
26
|
+
* 8. every commit in this worktree's HEAD reflog is reachable from a branch,
|
|
27
|
+
* a remote-tracking ref or a tag;
|
|
28
|
+
* 9. nothing touched it for {@link WORKTREE_MIN_AGE_DAYS} days.
|
|
29
|
+
*
|
|
30
|
+
* Each worktree is judged and, with `--apply`, removed at once, so nothing
|
|
31
|
+
* happens to it between the two. Removal is `git worktree remove` without
|
|
32
|
+
* `--force`, which re-checks 3 itself and leaves the branch in the clone. No
|
|
33
|
+
* network access, no `rm`. `--apply` refuses during an unattended run. A
|
|
34
|
+
* check that throws, and a removal Git refuses, are listed in `errors`.
|
|
35
|
+
*
|
|
36
|
+
* Two deliberate differences from the issue text:
|
|
37
|
+
* - PR merged/closed is not checked (that needs the network). A clean,
|
|
38
|
+
* pushed, idle worktree of a still-open PR is removed too; the preparer
|
|
39
|
+
* recreates it on demand.
|
|
40
|
+
* - `doctor` reports counts only, not sizes or ages; the detail is here.
|
|
41
|
+
*/
|
|
42
|
+
import * as fs from 'node:fs';
|
|
43
|
+
import path from 'node:path';
|
|
44
|
+
import { assertAttended, errorMessage } from '../core/errors.js';
|
|
45
|
+
import { resolveDataDir } from '../core/paths.js';
|
|
46
|
+
import { DAY_MS, WORKTREE_MIN_AGE_DAYS, WORKTREE_NAME, isInside, pruneRejectedCopies, staleRejectedCopies, } from '../core/stale-data.js';
|
|
47
|
+
import { GIT_TIMEOUT_MS, git } from './overnight-push-prep.js';
|
|
48
|
+
export { WORKTREE_MIN_AGE_DAYS };
|
|
49
|
+
/** Ignored paths under a directory with one of these names are rebuildable, not work. */
|
|
50
|
+
export const BUILD_OUTPUT = new Set(['node_modules', 'dist', 'build', 'target', 'coverage', '.venv']);
|
|
51
|
+
// Every call, the removal included: no index lock for a read, no
|
|
52
|
+
// `core.fsmonitor` program the repo's config names, and untracked files
|
|
53
|
+
// always count (`worktree remove` runs its own status and would otherwise
|
|
54
|
+
// honour `status.showUntrackedFiles=no` and delete them).
|
|
55
|
+
const SAFE_GIT = ['--no-optional-locks', '-c', 'core.fsmonitor=false', '-c', 'status.showUntrackedFiles=all'];
|
|
56
|
+
// The environment form of `--no-lazy-fetch`, which Git before 2.44 rejects as
|
|
57
|
+
// an unknown option; older Git ignores the variable.
|
|
58
|
+
const NO_LAZY_FETCH = { GIT_NO_LAZY_FETCH: '1' };
|
|
59
|
+
const IN_PROGRESS = [
|
|
60
|
+
'rebase-merge',
|
|
61
|
+
'rebase-apply',
|
|
62
|
+
'MERGE_HEAD',
|
|
63
|
+
'CHERRY_PICK_HEAD',
|
|
64
|
+
'REVERT_HEAD',
|
|
65
|
+
'BISECT_LOG',
|
|
66
|
+
'sequencer',
|
|
67
|
+
];
|
|
68
|
+
// Deleting a large `node_modules` on a loaded disk outlasts the runner's 60 s.
|
|
69
|
+
const REMOVE_TIMEOUT_MS = 10 * 60_000;
|
|
70
|
+
const MAX_NAMED_PATHS = 3;
|
|
71
|
+
const COMMIT_MESSAGE_SUFFIX = '.commit-msg.txt';
|
|
72
|
+
function gitOut(worktree, args) {
|
|
73
|
+
return git(worktree, [...SAFE_GIT, ...args], GIT_TIMEOUT_MS, NO_LAZY_FETCH).trim();
|
|
74
|
+
}
|
|
75
|
+
function gitDirOf(dir) {
|
|
76
|
+
return gitOut(dir, ['rev-parse', '--absolute-git-dir']);
|
|
77
|
+
}
|
|
78
|
+
function kept(dir, reason) {
|
|
79
|
+
return { path: dir, ageDays: null, clean: null, pushed: null, action: 'kept', reason };
|
|
80
|
+
}
|
|
81
|
+
/** Reason the path is not a worktree this command may judge, or null. */
|
|
82
|
+
function refusal(dataDir, dir) {
|
|
83
|
+
if (!WORKTREE_NAME.test(path.basename(dir)))
|
|
84
|
+
return 'name is not one the overnight preparer creates';
|
|
85
|
+
if (!fs.lstatSync(dir).isDirectory())
|
|
86
|
+
return 'not a real directory (symlink or file)';
|
|
87
|
+
if (!isInside(dataDir, dir))
|
|
88
|
+
return 'resolves outside the data directory';
|
|
89
|
+
const dotGit = path.join(dir, '.git');
|
|
90
|
+
if (!fs.existsSync(dotGit) || !fs.lstatSync(dotGit).isFile())
|
|
91
|
+
return 'not a linked git worktree';
|
|
92
|
+
const toplevel = gitOut(dir, ['rev-parse', '--show-toplevel']);
|
|
93
|
+
if (fs.realpathSync(toplevel) !== fs.realpathSync(dir))
|
|
94
|
+
return 'not the root of its git worktree';
|
|
95
|
+
return programsInRepoConfig(dir) ?? lazyFetch(dir) ?? submodules(dir);
|
|
96
|
+
}
|
|
97
|
+
/** `[scope, key]` for every config key matching `pattern`, includes followed. Reads no objects. */
|
|
98
|
+
function configKeys(dir, pattern) {
|
|
99
|
+
let entries;
|
|
100
|
+
try {
|
|
101
|
+
entries = gitOut(dir, ['config', '--show-scope', '--name-only', '-z', '--get-regexp', pattern]).split('\0');
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
// Exit 1: no key matched.
|
|
105
|
+
if (err?.status === 1)
|
|
106
|
+
return [];
|
|
107
|
+
throw err;
|
|
108
|
+
}
|
|
109
|
+
const keys = [];
|
|
110
|
+
for (let i = 0; i + 1 < entries.length; i += 2)
|
|
111
|
+
keys.push([entries[i], entries[i + 1]]);
|
|
112
|
+
return keys;
|
|
113
|
+
}
|
|
114
|
+
const FILTER_PROGRAM = String.raw `^(filter\..+\.(clean|process)|lfs\.extension\..+\.(clean|smudge))$`;
|
|
115
|
+
/**
|
|
116
|
+
* A clean or process filter defined in the repository's own config (#2047).
|
|
117
|
+
* `status`, and the one `worktree remove` runs, re-hash a file whose stat data
|
|
118
|
+
* changed through its filter, so a tick that wrote `filter.<x>.clean` and a
|
|
119
|
+
* matching `info/attributes` line would run its program here while the
|
|
120
|
+
* worktree still reports clean. Only the local and worktree scopes count
|
|
121
|
+
* (includes they pull in report as local): a driver from the user's own global
|
|
122
|
+
* or system config, such as Git LFS, is theirs; an `lfs.extension` program in
|
|
123
|
+
* the repository's config, which that driver may run, is not.
|
|
124
|
+
*/
|
|
125
|
+
function programsInRepoConfig(dir) {
|
|
126
|
+
const keys = configKeys(dir, FILTER_PROGRAM)
|
|
127
|
+
.filter(([scope]) => scope === 'local' || scope === 'worktree')
|
|
128
|
+
.map(([, key]) => key);
|
|
129
|
+
return keys.length > 0 ? `repository config names a filter program git would run: ${keys.join(', ')}` : null;
|
|
130
|
+
}
|
|
131
|
+
const LAZY_FETCH = String.raw `^(extensions\.partialclone|remote\..+\.(promisor|partialclonefilter))$`;
|
|
132
|
+
/**
|
|
133
|
+
* A promisor remote (#2047): `extensions.partialClone`,
|
|
134
|
+
* `remote.<name>.promisor` or `remote.<name>.partialCloneFilter`, each of
|
|
135
|
+
* which makes one on its own. Any command that finds an object missing (a
|
|
136
|
+
* dangling remote-tracking ref for `for-each-ref --contains`, a reflog entry,
|
|
137
|
+
* the HEAD tree for `status`) fetches it from that remote, which runs the
|
|
138
|
+
* remote's `uploadpack`, `core.sshCommand` or credential helper: programs the
|
|
139
|
+
* repository's config chooses. Every scope counts, since the promisor flag
|
|
140
|
+
* can sit in the user's config while the program comes from the repository's.
|
|
141
|
+
* `GIT_NO_LAZY_FETCH` on every call is a second layer, not relied on.
|
|
142
|
+
*/
|
|
143
|
+
function lazyFetch(dir) {
|
|
144
|
+
const keys = configKeys(dir, LAZY_FETCH).map(([, key]) => key);
|
|
145
|
+
return keys.length > 0 ? `config names a promisor remote git would fetch from: ${keys.join(', ')}` : null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* `status` runs inside each submodule, under that submodule's own config,
|
|
149
|
+
* which the check above does not read. `worktree remove` refuses a worktree
|
|
150
|
+
* with submodules anyway, so refusing first loses nothing.
|
|
151
|
+
*/
|
|
152
|
+
function submodules(dir) {
|
|
153
|
+
const hasGitlink = /^160000 /m.test(gitOut(dir, ['ls-files', '--stage']));
|
|
154
|
+
return hasGitlink ? 'contains submodules (git would run status under their config)' : null;
|
|
155
|
+
}
|
|
156
|
+
/** Whole days since the directory itself or the worktree's index last changed. */
|
|
157
|
+
function idleDays(dir, now) {
|
|
158
|
+
const index = path.join(gitDirOf(dir), 'index');
|
|
159
|
+
const dirMtime = fs.statSync(dir).mtimeMs;
|
|
160
|
+
const lastTouched = fs.existsSync(index) ? Math.max(dirMtime, fs.statSync(index).mtimeMs) : dirMtime;
|
|
161
|
+
return Math.max(0, Math.floor((now - lastTouched) / DAY_MS));
|
|
162
|
+
}
|
|
163
|
+
function operationInProgress(dir) {
|
|
164
|
+
const gitDir = gitDirOf(dir);
|
|
165
|
+
const found = IN_PROGRESS.filter((name) => fs.existsSync(path.join(gitDir, name)));
|
|
166
|
+
return found.length > 0 ? `operation in progress (${found.join(', ')})` : null;
|
|
167
|
+
}
|
|
168
|
+
/** Directory segments only: an ignored regular file named `build` is not build output. */
|
|
169
|
+
function isBuildOutput(ignoredPath) {
|
|
170
|
+
// A directory entry ends in `/`, so its own name is not the last segment.
|
|
171
|
+
const directories = ignoredPath.split('/').slice(0, -1);
|
|
172
|
+
return directories.some((segment) => BUILD_OUTPUT.has(segment));
|
|
173
|
+
}
|
|
174
|
+
function ignoredOutsideBuildOutput(dir) {
|
|
175
|
+
// `matching` lists an ignored directory once instead of every file in it.
|
|
176
|
+
const status = gitOut(dir, ['status', '--porcelain', '--ignored=matching', '--untracked-files=normal']);
|
|
177
|
+
const ignored = status.split('\n').filter((line) => line.startsWith('!! '));
|
|
178
|
+
const precious = ignored.map((line) => line.slice(3)).filter((ignoredPath) => !isBuildOutput(ignoredPath));
|
|
179
|
+
if (precious.length === 0)
|
|
180
|
+
return null;
|
|
181
|
+
const more = precious.length > MAX_NAMED_PATHS ? `, and ${precious.length - MAX_NAMED_PATHS} more` : '';
|
|
182
|
+
return `ignored files outside build output: ${precious.slice(0, MAX_NAMED_PATHS).join(', ')}${more}`;
|
|
183
|
+
}
|
|
184
|
+
function hiddenEdits(dir) {
|
|
185
|
+
// `ls-files -v` tags: `S` skip-worktree, a lowercase letter assume-unchanged.
|
|
186
|
+
const isFlagged = /^[a-zS] /m.test(gitOut(dir, ['ls-files', '-v']));
|
|
187
|
+
return isFlagged ? 'files flagged skip-worktree or assume-unchanged (edits to them are invisible)' : null;
|
|
188
|
+
}
|
|
189
|
+
function reflogOnlyCommits(dir) {
|
|
190
|
+
// This worktree's own HEAD reflog; `rev-list -g` cannot take `--not`.
|
|
191
|
+
// ponytail: the commits go on the command line; a reflog too long for that
|
|
192
|
+
// makes the spawn fail, and a failed check keeps the worktree.
|
|
193
|
+
const reflog = gitOut(dir, ['reflog', 'show', '--format=%H', 'HEAD']);
|
|
194
|
+
const commits = new Set(reflog.split('\n').filter((sha) => sha !== ''));
|
|
195
|
+
if (commits.size === 0)
|
|
196
|
+
return null;
|
|
197
|
+
const lost = gitOut(dir, ['rev-list', ...commits, '--not', '--branches', '--remotes', '--tags']);
|
|
198
|
+
if (lost === '')
|
|
199
|
+
return null;
|
|
200
|
+
return `${lost.split('\n').length} commit(s) reachable only from this worktree's HEAD reflog`;
|
|
201
|
+
}
|
|
202
|
+
const DEEP_CHECKS = [operationInProgress, ignoredOutsideBuildOutput, hiddenEdits, reflogOnlyCommits];
|
|
203
|
+
/** Why a clean-or-not, pushed-or-not worktree of `ageDays` is kept, or null when it may go. */
|
|
204
|
+
function keepReason(dir, report, ageDays) {
|
|
205
|
+
if (!report.clean)
|
|
206
|
+
return 'uncommitted or untracked files';
|
|
207
|
+
if (!report.pushed)
|
|
208
|
+
return 'HEAD is not on any remote-tracking branch (unpushed work)';
|
|
209
|
+
for (const check of DEEP_CHECKS) {
|
|
210
|
+
const reason = check(dir);
|
|
211
|
+
if (reason)
|
|
212
|
+
return reason;
|
|
213
|
+
}
|
|
214
|
+
if (ageDays < WORKTREE_MIN_AGE_DAYS)
|
|
215
|
+
return `touched ${ageDays} day(s) ago (kept for ${WORKTREE_MIN_AGE_DAYS})`;
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
function judge(dataDir, dir, now) {
|
|
219
|
+
const refused = refusal(dataDir, dir);
|
|
220
|
+
if (refused)
|
|
221
|
+
return kept(dir, refused);
|
|
222
|
+
const ageDays = idleDays(dir, now);
|
|
223
|
+
const isClean = gitOut(dir, ['status', '--porcelain', '--untracked-files=all']) === '';
|
|
224
|
+
const isPushed = gitOut(dir, ['for-each-ref', '--count=1', '--contains', 'HEAD', 'refs/remotes']) !== '';
|
|
225
|
+
const report = { ...kept(dir, ''), ageDays, clean: isClean, pushed: isPushed };
|
|
226
|
+
const reason = keepReason(dir, report, ageDays);
|
|
227
|
+
if (reason)
|
|
228
|
+
return { ...report, reason };
|
|
229
|
+
return { ...report, action: 'would-remove', reason: `clean, pushed, idle ${ageDays} days` };
|
|
230
|
+
}
|
|
231
|
+
function inspect(dataDir, dir, now) {
|
|
232
|
+
try {
|
|
233
|
+
return { report: judge(dataDir, dir, now) };
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
const reason = `check failed: ${errorMessage(err)}`;
|
|
237
|
+
return { report: kept(dir, reason), error: `${dir}: ${reason}` };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function removalFailure(err) {
|
|
241
|
+
if (err?.code === 'ETIMEDOUT')
|
|
242
|
+
return `git worktree remove was killed after ${REMOVE_TIMEOUT_MS / 1000}s; the worktree may be partly removed`;
|
|
243
|
+
return `git worktree remove refused: ${errorMessage(err)}`;
|
|
244
|
+
}
|
|
245
|
+
/** Judged removable and then not removed: an error, not a keep. */
|
|
246
|
+
function remove(report) {
|
|
247
|
+
try {
|
|
248
|
+
git(report.path, [...SAFE_GIT, 'worktree', 'remove', report.path], REMOVE_TIMEOUT_MS, NO_LAZY_FETCH);
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
const reason = removalFailure(err);
|
|
252
|
+
return { report: { ...report, action: 'kept', reason }, error: `${report.path}: ${reason}` };
|
|
253
|
+
}
|
|
254
|
+
// The preparer's commit message file sits beside the worktree and goes with it.
|
|
255
|
+
const message = report.path + COMMIT_MESSAGE_SUFFIX;
|
|
256
|
+
if (isRegularFile(message))
|
|
257
|
+
fs.rmSync(message);
|
|
258
|
+
return { report: { ...report, action: 'removed' } };
|
|
259
|
+
}
|
|
260
|
+
function isRegularFile(file) {
|
|
261
|
+
return fs.existsSync(file) && fs.lstatSync(file).isFile();
|
|
262
|
+
}
|
|
263
|
+
/** `<worktree name>.commit-msg.txt` (agents/overnight-preparer.md): not a worktree, so not judged or reported. */
|
|
264
|
+
function isCommitMessageFile(root, name) {
|
|
265
|
+
if (!name.endsWith(COMMIT_MESSAGE_SUFFIX))
|
|
266
|
+
return false;
|
|
267
|
+
return WORKTREE_NAME.test(name.slice(0, -COMMIT_MESSAGE_SUFFIX.length)) && isRegularFile(path.join(root, name));
|
|
268
|
+
}
|
|
269
|
+
/** Judge one worktree and, with `apply`, remove it straight away if it may go. */
|
|
270
|
+
function judgeAndRemove(dataDir, dir, options, now) {
|
|
271
|
+
const outcome = inspect(dataDir, dir, now);
|
|
272
|
+
return options.apply && outcome.report.action === 'would-remove' ? remove(outcome.report) : outcome;
|
|
273
|
+
}
|
|
274
|
+
function scan(dataDir, root, options, now) {
|
|
275
|
+
// A symlinked `worktrees` would have every child resolve outside the data dir.
|
|
276
|
+
if (!fs.existsSync(root) || !fs.lstatSync(root).isDirectory())
|
|
277
|
+
return { worktrees: [], errors: [] };
|
|
278
|
+
const names = fs.readdirSync(root).filter((name) => !isCommitMessageFile(root, name));
|
|
279
|
+
const outcomes = names.map((name) => judgeAndRemove(dataDir, path.join(root, name), options, now));
|
|
280
|
+
const errors = outcomes.flatMap((outcome) => outcome.error ?? []);
|
|
281
|
+
return { worktrees: outcomes.map((outcome) => outcome.report), errors };
|
|
282
|
+
}
|
|
283
|
+
/** Every direct child of `<dataDir>/worktrees`, judged; removed only with `apply`. Never throws. */
|
|
284
|
+
export function cleanWorktrees(dataDir, options, now = Date.now()) {
|
|
285
|
+
const root = path.join(dataDir, 'worktrees');
|
|
286
|
+
try {
|
|
287
|
+
return scan(dataDir, root, options, now);
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
return { worktrees: [], errors: [`could not scan ${root}: ${errorMessage(err)}`] };
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function listRejectedCopies(dataDir) {
|
|
294
|
+
try {
|
|
295
|
+
return { removed: staleRejectedCopies(dataDir), errors: [] };
|
|
296
|
+
}
|
|
297
|
+
catch (err) {
|
|
298
|
+
return { removed: [], errors: [`could not list rejected state copies in ${dataDir}: ${errorMessage(err)}`] };
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* `errors` is non-empty when anything went wrong, in a dry run too; the CLI
|
|
303
|
+
* action turns that into a non-zero exit code, since a scheduler or a script
|
|
304
|
+
* sees only that and a partial `--apply` is not success.
|
|
305
|
+
*/
|
|
306
|
+
export function runCleanup(options) {
|
|
307
|
+
if (options.apply)
|
|
308
|
+
assertAttended('remove worktrees and rejected state copies');
|
|
309
|
+
const dataDir = resolveDataDir();
|
|
310
|
+
const rejected = options.apply ? pruneRejectedCopies(dataDir) : listRejectedCopies(dataDir);
|
|
311
|
+
const scanned = cleanWorktrees(dataDir, options);
|
|
312
|
+
const errors = [...scanned.errors, ...rejected.errors];
|
|
313
|
+
return { applied: options.apply, worktrees: scanned.worktrees, rejectedCopies: rejected.removed, errors };
|
|
314
|
+
}
|
|
315
|
+
export function printCleanup(data) {
|
|
316
|
+
const verb = data.applied ? 'Removed' : 'Would remove';
|
|
317
|
+
const going = data.worktrees.filter((w) => w.action !== 'kept');
|
|
318
|
+
const kept = data.worktrees.filter((w) => w.action === 'kept');
|
|
319
|
+
console.log(`${verb} ${going.length} worktree(s), ${data.rejectedCopies.length} rejected state copy(ies)`);
|
|
320
|
+
for (const w of going)
|
|
321
|
+
console.log(` ${w.path}: ${w.reason}`);
|
|
322
|
+
for (const file of data.rejectedCopies)
|
|
323
|
+
console.log(` ${file}`);
|
|
324
|
+
if (kept.length > 0)
|
|
325
|
+
console.log(`Kept ${kept.length} worktree(s):`);
|
|
326
|
+
for (const w of kept)
|
|
327
|
+
console.log(` ${w.path}: ${w.reason}`);
|
|
328
|
+
if (data.errors.length > 0)
|
|
329
|
+
console.log(`${data.errors.length} error(s):`);
|
|
330
|
+
for (const error of data.errors)
|
|
331
|
+
console.log(` ${error}`);
|
|
332
|
+
if (!data.applied && going.length + data.rejectedCopies.length > 0)
|
|
333
|
+
console.log('Re-run with --apply to remove.');
|
|
334
|
+
}
|
|
@@ -7,22 +7,33 @@ export { type CommentsOutput, type PostOutput, type ClaimOutput } from '../forma
|
|
|
7
7
|
interface CommentsOptions {
|
|
8
8
|
prUrl: string;
|
|
9
9
|
showBots?: boolean;
|
|
10
|
+
/** Keep the user's own comments and reviews, and reviews with no body, for flows that read the whole thread (#2046). */
|
|
11
|
+
includeOwn?: boolean;
|
|
10
12
|
}
|
|
11
13
|
interface PostOptions {
|
|
12
14
|
url: string;
|
|
13
15
|
message: string;
|
|
16
|
+
/** When set, refuse unless `message` hashes to it: the text the user approved via `draft show` (#1930). */
|
|
17
|
+
expectSha256?: string;
|
|
18
|
+
/** CLI `--allow-script-mismatch` only: post despite a script mismatch, reported as a warning (#1909). */
|
|
19
|
+
allowScriptMismatch?: boolean;
|
|
14
20
|
}
|
|
15
21
|
interface ClaimOptions {
|
|
16
22
|
issueUrl: string;
|
|
17
23
|
message?: string;
|
|
24
|
+
/** When set, refuse unless the claim message hashes to it (#1930). */
|
|
25
|
+
expectSha256?: string;
|
|
26
|
+
/** CLI `--allow-script-mismatch` only: claim despite a script mismatch, reported as a warning (#1909). */
|
|
27
|
+
allowScriptMismatch?: boolean;
|
|
18
28
|
}
|
|
19
29
|
/**
|
|
20
30
|
* Fetch all comments, reviews, and inline review comments for a PR.
|
|
21
|
-
* Filters out the user's own comments and optionally bot comments.
|
|
31
|
+
* Filters out the user's own comments (unless `includeOwn`) and optionally bot comments.
|
|
22
32
|
*
|
|
23
33
|
* @param options - Comment fetch options
|
|
24
34
|
* @param options.prUrl - Full GitHub PR URL
|
|
25
35
|
* @param options.showBots - Include bot comments (default: false)
|
|
36
|
+
* @param options.includeOwn - Include the user's own comments and reviews, and verdict-only reviews (default: false)
|
|
26
37
|
* @returns Categorized comments with review, inline, and discussion sections
|
|
27
38
|
* @throws {ValidationError} If the URL is not a valid GitHub PR URL
|
|
28
39
|
*/
|
|
@@ -37,6 +48,8 @@ export declare function runComments(options: CommentsOptions): Promise<CommentsO
|
|
|
37
48
|
* @throws {ValidationError} If the URL or message is invalid
|
|
38
49
|
*/
|
|
39
50
|
export declare function runPost(options: PostOptions): Promise<PostOutput>;
|
|
51
|
+
/** The comment `claim` posts when no message is given; the MCP approval form shows this exact text. */
|
|
52
|
+
export declare const DEFAULT_CLAIM_MESSAGE = "Hi! I'd like to work on this issue. Could you assign it to me?";
|
|
40
53
|
/**
|
|
41
54
|
* Post a claim comment on a GitHub issue and track it locally.
|
|
42
55
|
*
|
|
@@ -6,17 +6,20 @@ import { getStateManager, getOctokit, parseGitHubUrl, requireGitHubToken, maybeC
|
|
|
6
6
|
import { wrapUntrustedContent } from '../core/untrusted-content.js';
|
|
7
7
|
import { ValidationError, assertAttended, isRateLimitOrAuthError } from '../core/errors.js';
|
|
8
8
|
import { warn } from '../core/logger.js';
|
|
9
|
+
import { checkRepoScript } from '../core/prose-script.js';
|
|
9
10
|
const MODULE = 'comments';
|
|
10
11
|
import { paginateAllDetailed } from '../core/pagination.js';
|
|
11
12
|
import { buildStalenessWarning } from '../formatters/json.js';
|
|
12
13
|
import { validateUrl, validateMessage, validateGitHubUrl, PR_URL_PATTERN, ISSUE_OR_PR_URL_PATTERN, ISSUE_URL_PATTERN, } from './validation.js';
|
|
14
|
+
import { assertSha256 } from './draft.js';
|
|
13
15
|
/**
|
|
14
16
|
* Fetch all comments, reviews, and inline review comments for a PR.
|
|
15
|
-
* Filters out the user's own comments and optionally bot comments.
|
|
17
|
+
* Filters out the user's own comments (unless `includeOwn`) and optionally bot comments.
|
|
16
18
|
*
|
|
17
19
|
* @param options - Comment fetch options
|
|
18
20
|
* @param options.prUrl - Full GitHub PR URL
|
|
19
21
|
* @param options.showBots - Include bot comments (default: false)
|
|
22
|
+
* @param options.includeOwn - Include the user's own comments and reviews, and verdict-only reviews (default: false)
|
|
20
23
|
* @returns Categorized comments with review, inline, and discussion sections
|
|
21
24
|
* @throws {ValidationError} If the URL is not a valid GitHub PR URL
|
|
22
25
|
*/
|
|
@@ -79,7 +82,7 @@ export async function runComments(options) {
|
|
|
79
82
|
// non-canonical-case configured username must not leak the user's own
|
|
80
83
|
// comments into "needs response" (#1456). Mirrors review-analysis.ts
|
|
81
84
|
// and issue-conversation.ts.
|
|
82
|
-
if (c.user.login?.toLowerCase() === username?.toLowerCase())
|
|
85
|
+
if (!options.includeOwn && c.user.login?.toLowerCase() === username?.toLowerCase())
|
|
83
86
|
return false;
|
|
84
87
|
if (c.user.type === 'Bot' && !options.showBots)
|
|
85
88
|
return false;
|
|
@@ -92,7 +95,9 @@ export async function runComments(options) {
|
|
|
92
95
|
.filter(filterComment)
|
|
93
96
|
.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
|
94
97
|
const relevantReviews = reviews
|
|
95
|
-
|
|
98
|
+
// A verdict-only review (bare APPROVE / REQUEST_CHANGES) has no body: kept
|
|
99
|
+
// with includeOwn, for flows that read the user's earlier verdict (#2046).
|
|
100
|
+
.filter((r) => filterComment(r) && (options.includeOwn || r.body?.trim()))
|
|
96
101
|
.sort((a, b) => new Date(b.submitted_at || 0).getTime() - new Date(a.submitted_at || 0).getTime());
|
|
97
102
|
// Fence every third-party body at this boundary: the output feeds agents
|
|
98
103
|
// directly (CLI --json, the MCP `comments` tool, and the `respond-to-pr`
|
|
@@ -158,6 +163,7 @@ export async function runComments(options) {
|
|
|
158
163
|
*/
|
|
159
164
|
export async function runPost(options) {
|
|
160
165
|
assertAttended('post a comment');
|
|
166
|
+
assertSha256(options.message, options.expectSha256);
|
|
161
167
|
validateUrl(options.url);
|
|
162
168
|
validateGitHubUrl(options.url, ISSUE_OR_PR_URL_PATTERN, 'issue or PR');
|
|
163
169
|
if (!options.message.trim()) {
|
|
@@ -172,6 +178,7 @@ export async function runPost(options) {
|
|
|
172
178
|
}
|
|
173
179
|
const { owner, repo, number } = parsed;
|
|
174
180
|
const octokit = getOctokit(token);
|
|
181
|
+
const scriptMismatchWarning = await checkRepoScript(octokit, { owner, repo }, options.message, options.allowScriptMismatch === true);
|
|
175
182
|
const { data: comment } = await octokit.issues.createComment({
|
|
176
183
|
owner,
|
|
177
184
|
repo,
|
|
@@ -181,8 +188,11 @@ export async function runPost(options) {
|
|
|
181
188
|
return {
|
|
182
189
|
commentUrl: comment.html_url,
|
|
183
190
|
url: options.url,
|
|
191
|
+
...(scriptMismatchWarning && { scriptMismatchWarning }),
|
|
184
192
|
};
|
|
185
193
|
}
|
|
194
|
+
/** The comment `claim` posts when no message is given; the MCP approval form shows this exact text. */
|
|
195
|
+
export const DEFAULT_CLAIM_MESSAGE = "Hi! I'd like to work on this issue. Could you assign it to me?";
|
|
186
196
|
/**
|
|
187
197
|
* Post a claim comment on a GitHub issue and track it locally.
|
|
188
198
|
*
|
|
@@ -197,9 +207,9 @@ export async function runClaim(options) {
|
|
|
197
207
|
validateUrl(options.issueUrl);
|
|
198
208
|
validateGitHubUrl(options.issueUrl, ISSUE_URL_PATTERN, 'issue');
|
|
199
209
|
const token = requireGitHubToken();
|
|
200
|
-
|
|
201
|
-
const message = options.message || "Hi! I'd like to work on this issue. Could you assign it to me?";
|
|
210
|
+
const message = options.message || DEFAULT_CLAIM_MESSAGE;
|
|
202
211
|
validateMessage(message);
|
|
212
|
+
assertSha256(message, options.expectSha256);
|
|
203
213
|
// Parse URL
|
|
204
214
|
const parsed = parseGitHubUrl(options.issueUrl);
|
|
205
215
|
if (!parsed || parsed.type !== 'issues') {
|
|
@@ -207,6 +217,7 @@ export async function runClaim(options) {
|
|
|
207
217
|
}
|
|
208
218
|
const { owner, repo, number } = parsed;
|
|
209
219
|
const octokit = getOctokit(token);
|
|
220
|
+
const scriptMismatchWarning = await checkRepoScript(octokit, { owner, repo }, message, options.allowScriptMismatch === true);
|
|
210
221
|
// Fetch the real issue title + labels so the tracked entry has useful metadata
|
|
211
222
|
// rather than a permanent "(claimed)" placeholder that never gets backfilled
|
|
212
223
|
// (#1056 M24). Best-effort: if the fetch fails, fall back to the placeholder
|
|
@@ -277,5 +288,6 @@ export async function runClaim(options) {
|
|
|
277
288
|
issueUrl: options.issueUrl,
|
|
278
289
|
...(gistSyncWarning && { gistSyncWarning }),
|
|
279
290
|
...(stateSaveWarning && { stateSaveWarning }),
|
|
291
|
+
...(scriptMismatchWarning && { scriptMismatchWarning }),
|
|
280
292
|
};
|
|
281
293
|
}
|
|
@@ -13,6 +13,8 @@ export interface ConfigSetOutput {
|
|
|
13
13
|
success: true;
|
|
14
14
|
key: string;
|
|
15
15
|
value: string;
|
|
16
|
+
/** Setup's warnings for a setup-scoped key, e.g. list entries it skipped. */
|
|
17
|
+
warnings?: string[];
|
|
16
18
|
/** Set when the post-mutation Gist checkpoint failed; the local mutation succeeded (#1440). */
|
|
17
19
|
gistSyncWarning?: string;
|
|
18
20
|
}
|