@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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which of the user's forks can be deleted (#1912).
|
|
3
|
+
*
|
|
4
|
+
* A fork is prunable only when none of five keep conditions holds:
|
|
5
|
+
* 1. an open PR anywhere has it as its head repository: one of the user's
|
|
6
|
+
* open PRs, or an open PR by any account on any of its branches;
|
|
7
|
+
* 2. an open PR targets the fork itself;
|
|
8
|
+
* 3. a branch tip is the user's own commit (authored or committed) and the
|
|
9
|
+
* work is not done: done means a merged or closed PR into another
|
|
10
|
+
* repository whose head was exactly this tip, or the tip commit merged
|
|
11
|
+
* through a PR into another repository (PR state, not Git ancestry:
|
|
12
|
+
* squash merges leave no ancestry). A PR merged inside the fork, a
|
|
13
|
+
* branch pushed to after its PR, or a reused branch name stays kept;
|
|
14
|
+
* 4. local state references it (claimed issues, work claims, prepared
|
|
15
|
+
* overnight branches): matched on the fork or its parent;
|
|
16
|
+
* 5. it, or its parent, is on `config.keepForks`.
|
|
17
|
+
*
|
|
18
|
+
* A fork whose parent is gone, or whose branches could not all be read, is
|
|
19
|
+
* kept too. The dry run and `--apply` share {@link evaluateFork}, so what a
|
|
20
|
+
* dry run lists is what apply would delete. Reads go through paginated GraphQL.
|
|
21
|
+
*/
|
|
22
|
+
import type { Octokit } from '@octokit/rest';
|
|
23
|
+
/** One branch of a fork: its tip commit, who wrote and committed it, and its open PRs. */
|
|
24
|
+
export interface ForkBranch {
|
|
25
|
+
name: string;
|
|
26
|
+
tipOid: string | null;
|
|
27
|
+
/** GitHub login of the tip commit's author; null when the author email is not linked to an account. */
|
|
28
|
+
tipAuthorLogin: string | null;
|
|
29
|
+
/** GitHub login of the tip commit's committer (a cherry-pick or `git am` keeps someone else as author). */
|
|
30
|
+
tipCommitterLogin: string | null;
|
|
31
|
+
tipCommittedAt: string | null;
|
|
32
|
+
/** Open PRs by any account with this branch as head; null until read ({@link evaluateAll} reads it only where it decides the verdict). */
|
|
33
|
+
openPRs: number | null;
|
|
34
|
+
}
|
|
35
|
+
/** What GitHub says about one fork. */
|
|
36
|
+
export interface ForkFacts {
|
|
37
|
+
/** `owner/name` of the fork. */
|
|
38
|
+
repo: string;
|
|
39
|
+
/** `owner/name` of the parent; null when the parent is gone or hidden. */
|
|
40
|
+
parent: string | null;
|
|
41
|
+
isFork: boolean;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
/** Open PRs whose base repository is this fork. */
|
|
44
|
+
openPRsToFork: number;
|
|
45
|
+
branchCount: number;
|
|
46
|
+
/** Every branch, all pages. */
|
|
47
|
+
branches: ForkBranch[];
|
|
48
|
+
/** False when a page of branches could not be read: the list is partial and the fork is kept. */
|
|
49
|
+
hasAllBranches: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** One PR as fork-prune reads it. */
|
|
52
|
+
export interface PRFact {
|
|
53
|
+
state: string;
|
|
54
|
+
/** `owner/name` the PR targets; null when unknown. */
|
|
55
|
+
baseRepo: string | null;
|
|
56
|
+
/** The head commit the PR last had; null when unknown or not asked for. */
|
|
57
|
+
headOid: string | null;
|
|
58
|
+
}
|
|
59
|
+
/** PR facts for one of the user's own branches. */
|
|
60
|
+
export interface BranchPRs {
|
|
61
|
+
/** PRs whose head is this branch name, at any commit. */
|
|
62
|
+
prs: PRFact[];
|
|
63
|
+
/** PRs the tip commit belongs to (a merged squash or merge commit points at its PR). */
|
|
64
|
+
tipPRs: PRFact[];
|
|
65
|
+
}
|
|
66
|
+
/** Everything outside the fork that decides its verdict. */
|
|
67
|
+
export interface PruneContext {
|
|
68
|
+
login: string;
|
|
69
|
+
/** Lowercase `owner/name` of every head repository of the user's open PRs. */
|
|
70
|
+
openPRHeadRepos: ReadonlySet<string>;
|
|
71
|
+
/** Lowercase `owner/name` of repos local state refers to. */
|
|
72
|
+
referencedRepos: ReadonlySet<string>;
|
|
73
|
+
/** Lowercase `config.keepForks`. */
|
|
74
|
+
keepForks: ReadonlySet<string>;
|
|
75
|
+
/** PR facts for the user's own branches, keyed by `branchKey`. */
|
|
76
|
+
branchPRs: ReadonlyMap<string, BranchPRs>;
|
|
77
|
+
}
|
|
78
|
+
export interface OwnBranch {
|
|
79
|
+
name: string;
|
|
80
|
+
prStates: string[];
|
|
81
|
+
}
|
|
82
|
+
export interface ForkVerdict {
|
|
83
|
+
repo: string;
|
|
84
|
+
parent: string | null;
|
|
85
|
+
verdict: 'PRUNE' | 'KEEP';
|
|
86
|
+
branchCount: number;
|
|
87
|
+
openPRsToFork: number;
|
|
88
|
+
hasOpenPRFromFork: boolean;
|
|
89
|
+
/** The branches counted as the user's own work, with their PR states. */
|
|
90
|
+
ownBranches: OwnBranch[];
|
|
91
|
+
/** Why the fork is kept; empty for PRUNE. */
|
|
92
|
+
reasons: string[];
|
|
93
|
+
}
|
|
94
|
+
export declare function branchKey(repo: string, branch: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* The tip is the user's own work: authored or committed under their login,
|
|
97
|
+
* or by an identity with no linked account committed after the fork was
|
|
98
|
+
* created (such a commit cannot be told apart from the user's, so it is kept
|
|
99
|
+
* rather than risked). Login only: there is no verified-email lookup in this
|
|
100
|
+
* code base, so a tip authored and committed under an unlinked email and
|
|
101
|
+
* dated before the fork was created is not recognised.
|
|
102
|
+
*/
|
|
103
|
+
export declare function isOwnTip(branch: ForkBranch, fork: ForkFacts, login: string): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The branch's PRs are read: the user's own tips, and any tip committed after
|
|
106
|
+
* the fork was created (someone else's PR merged into the fork in the web UI
|
|
107
|
+
* leaves a tip authored by them and committed by `web-flow`). Tips older than
|
|
108
|
+
* the fork are inherited and need no lookup.
|
|
109
|
+
*/
|
|
110
|
+
export declare function isPRLookupNeeded(branch: ForkBranch, fork: ForkFacts, login: string): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* The work on an own branch is done: a merged or closed PR into another
|
|
113
|
+
* repository had exactly this tip as head, or the tip commit itself was
|
|
114
|
+
* merged into another repository. Anything unknown counts as not done.
|
|
115
|
+
*/
|
|
116
|
+
export declare function isBranchDone(branch: ForkBranch, fork: ForkFacts, prs: BranchPRs | undefined): boolean;
|
|
117
|
+
/** The keep reason of a fork whose branches have not been checked for open PRs by other accounts yet. */
|
|
118
|
+
export declare const UNCHECKED_OPEN_PRS = "its branches were not checked for open PRs";
|
|
119
|
+
/** The verdict for one fork under the five keep conditions. Pure. */
|
|
120
|
+
export declare function evaluateFork(fork: ForkFacts, ctx: PruneContext): ForkVerdict;
|
|
121
|
+
type GraphQL = Octokit['graphql'];
|
|
122
|
+
/** Counts the GraphQL requests one scan makes. */
|
|
123
|
+
export declare class CountingGraphQL {
|
|
124
|
+
private readonly graphql;
|
|
125
|
+
requests: number;
|
|
126
|
+
constructor(graphql: GraphQL);
|
|
127
|
+
query<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
128
|
+
}
|
|
129
|
+
/** The viewer's login and every fork they own, with all branches. */
|
|
130
|
+
export declare function fetchForks(gql: CountingGraphQL): Promise<{
|
|
131
|
+
login: string;
|
|
132
|
+
forks: ForkFacts[];
|
|
133
|
+
}>;
|
|
134
|
+
/** One repository read fresh, or null when it no longer exists. */
|
|
135
|
+
export declare function fetchFork(gql: CountingGraphQL, repo: string): Promise<ForkFacts | null>;
|
|
136
|
+
/** Lowercase head repositories of the viewer's open PRs. */
|
|
137
|
+
export declare function fetchOpenPRHeadRepos(gql: CountingGraphQL): Promise<Set<string>>;
|
|
138
|
+
/** PR facts for the branches {@link isPRLookupNeeded} picks, in aliased batches; branch names travel as variables. */
|
|
139
|
+
export declare function fetchBranchPRs(gql: CountingGraphQL, forks: readonly ForkFacts[], login: string): Promise<Map<string, BranchPRs>>;
|
|
140
|
+
/** `fork` with every branch's count of open PRs (any author) read; a branch that could not be read stays null, so the fork is kept. */
|
|
141
|
+
export declare function withOpenPRCounts(gql: CountingGraphQL, fork: ForkFacts): Promise<ForkFacts>;
|
|
142
|
+
/**
|
|
143
|
+
* Verdicts for `forks`. Open PRs by other accounts are read branch by branch
|
|
144
|
+
* only for a fork whose one remaining reason is that they were not read, then
|
|
145
|
+
* it is evaluated again: every branch of every fork that could be pruned is
|
|
146
|
+
* checked, without a lookup per branch of every fork.
|
|
147
|
+
*/
|
|
148
|
+
export declare function evaluateAll(gql: CountingGraphQL, forks: readonly ForkFacts[], ctx: PruneContext): Promise<ForkVerdict[]>;
|
|
149
|
+
export {};
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which of the user's forks can be deleted (#1912).
|
|
3
|
+
*
|
|
4
|
+
* A fork is prunable only when none of five keep conditions holds:
|
|
5
|
+
* 1. an open PR anywhere has it as its head repository: one of the user's
|
|
6
|
+
* open PRs, or an open PR by any account on any of its branches;
|
|
7
|
+
* 2. an open PR targets the fork itself;
|
|
8
|
+
* 3. a branch tip is the user's own commit (authored or committed) and the
|
|
9
|
+
* work is not done: done means a merged or closed PR into another
|
|
10
|
+
* repository whose head was exactly this tip, or the tip commit merged
|
|
11
|
+
* through a PR into another repository (PR state, not Git ancestry:
|
|
12
|
+
* squash merges leave no ancestry). A PR merged inside the fork, a
|
|
13
|
+
* branch pushed to after its PR, or a reused branch name stays kept;
|
|
14
|
+
* 4. local state references it (claimed issues, work claims, prepared
|
|
15
|
+
* overnight branches): matched on the fork or its parent;
|
|
16
|
+
* 5. it, or its parent, is on `config.keepForks`.
|
|
17
|
+
*
|
|
18
|
+
* A fork whose parent is gone, or whose branches could not all be read, is
|
|
19
|
+
* kept too. The dry run and `--apply` share {@link evaluateFork}, so what a
|
|
20
|
+
* dry run lists is what apply would delete. Reads go through paginated GraphQL.
|
|
21
|
+
*/
|
|
22
|
+
export function branchKey(repo, branch) {
|
|
23
|
+
return `${repo.toLowerCase()}#${branch}`;
|
|
24
|
+
}
|
|
25
|
+
function isSameRepo(a, b) {
|
|
26
|
+
return a !== null && a.toLowerCase() === b.toLowerCase();
|
|
27
|
+
}
|
|
28
|
+
function isCommittedAfterFork(branch, fork) {
|
|
29
|
+
return branch.tipCommittedAt !== null && Date.parse(branch.tipCommittedAt) > Date.parse(fork.createdAt);
|
|
30
|
+
}
|
|
31
|
+
/** One identity on the tip is the user's: their login, or no linked account on a commit made after the fork was created. */
|
|
32
|
+
function isOwnIdentity(identityLogin, branch, fork, login) {
|
|
33
|
+
if (identityLogin !== null)
|
|
34
|
+
return identityLogin.toLowerCase() === login.toLowerCase();
|
|
35
|
+
return isCommittedAfterFork(branch, fork);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The tip is the user's own work: authored or committed under their login,
|
|
39
|
+
* or by an identity with no linked account committed after the fork was
|
|
40
|
+
* created (such a commit cannot be told apart from the user's, so it is kept
|
|
41
|
+
* rather than risked). Login only: there is no verified-email lookup in this
|
|
42
|
+
* code base, so a tip authored and committed under an unlinked email and
|
|
43
|
+
* dated before the fork was created is not recognised.
|
|
44
|
+
*/
|
|
45
|
+
export function isOwnTip(branch, fork, login) {
|
|
46
|
+
return (isOwnIdentity(branch.tipAuthorLogin, branch, fork, login) ||
|
|
47
|
+
isOwnIdentity(branch.tipCommitterLogin, branch, fork, login));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The branch's PRs are read: the user's own tips, and any tip committed after
|
|
51
|
+
* the fork was created (someone else's PR merged into the fork in the web UI
|
|
52
|
+
* leaves a tip authored by them and committed by `web-flow`). Tips older than
|
|
53
|
+
* the fork are inherited and need no lookup.
|
|
54
|
+
*/
|
|
55
|
+
export function isPRLookupNeeded(branch, fork, login) {
|
|
56
|
+
return isOwnTip(branch, fork, login) || isCommittedAfterFork(branch, fork);
|
|
57
|
+
}
|
|
58
|
+
/** A PR merged into the fork itself sits on this branch or its tip: work that may exist nowhere else. */
|
|
59
|
+
function isMergedIntoFork(fork, prs) {
|
|
60
|
+
if (prs === undefined)
|
|
61
|
+
return false;
|
|
62
|
+
return [...prs.prs, ...prs.tipPRs].some((pr) => pr.state === 'MERGED' && isSameRepo(pr.baseRepo, fork.repo));
|
|
63
|
+
}
|
|
64
|
+
function isFinished(pr) {
|
|
65
|
+
return pr.state === 'MERGED' || pr.state === 'CLOSED';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The work on an own branch is done: a merged or closed PR into another
|
|
69
|
+
* repository had exactly this tip as head, or the tip commit itself was
|
|
70
|
+
* merged into another repository. Anything unknown counts as not done.
|
|
71
|
+
*/
|
|
72
|
+
export function isBranchDone(branch, fork, prs) {
|
|
73
|
+
if (prs === undefined)
|
|
74
|
+
return false;
|
|
75
|
+
const isElsewhere = (pr) => pr.baseRepo !== null && !isSameRepo(pr.baseRepo, fork.repo);
|
|
76
|
+
const isAtTip = (pr) => pr.headOid !== null && pr.headOid === branch.tipOid;
|
|
77
|
+
const isSubmittedTip = prs.prs.some((pr) => isFinished(pr) && isElsewhere(pr) && isAtTip(pr));
|
|
78
|
+
return isSubmittedTip || prs.tipPRs.some((pr) => pr.state === 'MERGED' && isElsewhere(pr));
|
|
79
|
+
}
|
|
80
|
+
function isListed(set, fork) {
|
|
81
|
+
return set.has(fork.repo.toLowerCase()) || (fork.parent !== null && set.has(fork.parent.toLowerCase()));
|
|
82
|
+
}
|
|
83
|
+
/** The keep reason of a fork whose branches have not been checked for open PRs by other accounts yet. */
|
|
84
|
+
export const UNCHECKED_OPEN_PRS = 'its branches were not checked for open PRs';
|
|
85
|
+
/** Why the fork itself must stay: not a fork, its parent gone, or a partial branch list. */
|
|
86
|
+
function repoReasons(fork) {
|
|
87
|
+
const reasons = [];
|
|
88
|
+
if (!fork.isFork)
|
|
89
|
+
reasons.push('not a fork');
|
|
90
|
+
if (fork.parent === null)
|
|
91
|
+
reasons.push('its parent repository is gone or hidden');
|
|
92
|
+
if (!fork.hasAllBranches)
|
|
93
|
+
reasons.push('not all of its branches could be read');
|
|
94
|
+
if (fork.branches.some((branch) => branch.openPRs === null))
|
|
95
|
+
reasons.push(UNCHECKED_OPEN_PRS);
|
|
96
|
+
return reasons;
|
|
97
|
+
}
|
|
98
|
+
/** Branches with an open PR (any account), and the user's branches whose work no PR finished. */
|
|
99
|
+
function branchReasons(fork, ownBranches, ctx) {
|
|
100
|
+
const open = fork.branches
|
|
101
|
+
.filter((branch) => branch.openPRs !== null && branch.openPRs > 0)
|
|
102
|
+
.map((branch) => `branch ${branch.name} is the head of an open PR (any account)`);
|
|
103
|
+
const unfinished = ownBranches
|
|
104
|
+
.filter(({ branch, prs }) => !isBranchDone(branch, fork, prs))
|
|
105
|
+
.map(({ branch }) => `branch ${branch.name} holds your commits that no PR finished`);
|
|
106
|
+
// Someone else's tip: kept only when a PR was merged into the fork itself.
|
|
107
|
+
const mergedHere = fork.branches
|
|
108
|
+
.filter((branch) => !isOwnTip(branch, fork, ctx.login))
|
|
109
|
+
.filter((branch) => isMergedIntoFork(fork, ctx.branchPRs.get(branchKey(fork.repo, branch.name))))
|
|
110
|
+
.map((branch) => `branch ${branch.name} holds work merged into this fork`);
|
|
111
|
+
return [...open, ...unfinished, ...mergedHere];
|
|
112
|
+
}
|
|
113
|
+
/** The verdict for one fork under the five keep conditions. Pure. */
|
|
114
|
+
export function evaluateFork(fork, ctx) {
|
|
115
|
+
const reasons = repoReasons(fork);
|
|
116
|
+
const hasOpenPRFromFork = ctx.openPRHeadRepos.has(fork.repo.toLowerCase());
|
|
117
|
+
if (hasOpenPRFromFork)
|
|
118
|
+
reasons.push('an open PR has this fork as its head');
|
|
119
|
+
if (fork.openPRsToFork > 0)
|
|
120
|
+
reasons.push(`${fork.openPRsToFork} open PR(s) target this fork`);
|
|
121
|
+
const ownBranches = fork.branches
|
|
122
|
+
.filter((branch) => isOwnTip(branch, fork, ctx.login))
|
|
123
|
+
.map((branch) => ({ branch, prs: ctx.branchPRs.get(branchKey(fork.repo, branch.name)) }));
|
|
124
|
+
reasons.push(...branchReasons(fork, ownBranches, ctx));
|
|
125
|
+
if (isListed(ctx.referencedRepos, fork))
|
|
126
|
+
reasons.push('local state refers to it (claimed issue, work claim or prepared branch)');
|
|
127
|
+
if (isListed(ctx.keepForks, fork))
|
|
128
|
+
reasons.push('on keepForks');
|
|
129
|
+
return {
|
|
130
|
+
repo: fork.repo,
|
|
131
|
+
parent: fork.parent,
|
|
132
|
+
verdict: reasons.length === 0 ? 'PRUNE' : 'KEEP',
|
|
133
|
+
branchCount: fork.branchCount,
|
|
134
|
+
openPRsToFork: fork.openPRsToFork,
|
|
135
|
+
ownBranches: ownBranches.map(({ branch, prs }) => ({
|
|
136
|
+
name: branch.name,
|
|
137
|
+
prStates: (prs?.prs ?? []).map((pr) => pr.state),
|
|
138
|
+
})),
|
|
139
|
+
hasOpenPRFromFork,
|
|
140
|
+
reasons,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/** Forks per page: each carries its first 100 branches, so a page stays well inside GitHub's node limits. */
|
|
144
|
+
const FORKS_PER_PAGE = 25;
|
|
145
|
+
const REFS_PER_PAGE = 100;
|
|
146
|
+
/** Own branches looked up per aliased PR query. */
|
|
147
|
+
const BRANCHES_PER_QUERY = 20;
|
|
148
|
+
const REF_FIELDS = `name target { oid ... on Commit { committedDate author { user { login } } committer { user { login } } } }`;
|
|
149
|
+
/**
|
|
150
|
+
* Branches per open-PR lookup. Each branch's lookup is a search on GitHub's
|
|
151
|
+
* side: 25 forks of 100 branches each in one query exceeded GitHub's resource
|
|
152
|
+
* limits on a real account, so these are read only for forks nothing else
|
|
153
|
+
* keeps, a small page at a time.
|
|
154
|
+
*/
|
|
155
|
+
const OPEN_PR_REFS_PER_PAGE = 25;
|
|
156
|
+
const OPEN_PR_REFS_QUERY = `query($owner: String!, $name: String!, $after: String) { repository(owner: $owner, name: $name) {
|
|
157
|
+
refs(refPrefix: "refs/heads/", first: ${OPEN_PR_REFS_PER_PAGE}, after: $after) {
|
|
158
|
+
pageInfo { hasNextPage endCursor } nodes { name associatedPullRequests(states: OPEN, first: 1) { totalCount } } } } }`;
|
|
159
|
+
const REPO_FIELDS = `nameWithOwner isFork createdAt parent { nameWithOwner }
|
|
160
|
+
pullRequests(states: OPEN) { totalCount }
|
|
161
|
+
refs(refPrefix: "refs/heads/", first: ${REFS_PER_PAGE}) { totalCount pageInfo { hasNextPage endCursor } nodes { ${REF_FIELDS} } }`;
|
|
162
|
+
const FORKS_QUERY = `query($after: String) { viewer { login
|
|
163
|
+
repositories(isFork: true, ownerAffiliations: [OWNER], first: ${FORKS_PER_PAGE}, after: $after) {
|
|
164
|
+
pageInfo { hasNextPage endCursor } nodes { ${REPO_FIELDS} } } } }`;
|
|
165
|
+
const MORE_REFS_QUERY = `query($owner: String!, $name: String!, $after: String) { repository(owner: $owner, name: $name) {
|
|
166
|
+
refs(refPrefix: "refs/heads/", first: ${REFS_PER_PAGE}, after: $after) {
|
|
167
|
+
totalCount pageInfo { hasNextPage endCursor } nodes { ${REF_FIELDS} } } } }`;
|
|
168
|
+
const ONE_FORK_QUERY = `query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { ${REPO_FIELDS} } }`;
|
|
169
|
+
const OPEN_PRS_QUERY = `query($after: String) { viewer { login
|
|
170
|
+
pullRequests(states: OPEN, first: 100, after: $after) {
|
|
171
|
+
pageInfo { hasNextPage endCursor } nodes { headRepository { nameWithOwner } } } } }`;
|
|
172
|
+
/** Counts the GraphQL requests one scan makes. */
|
|
173
|
+
export class CountingGraphQL {
|
|
174
|
+
graphql;
|
|
175
|
+
requests = 0;
|
|
176
|
+
constructor(graphql) {
|
|
177
|
+
this.graphql = graphql;
|
|
178
|
+
}
|
|
179
|
+
async query(query, variables = {}) {
|
|
180
|
+
this.requests += 1;
|
|
181
|
+
return this.graphql(query, variables);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function splitName(repo) {
|
|
185
|
+
const [owner, name] = repo.split('/', 2);
|
|
186
|
+
return { owner, name };
|
|
187
|
+
}
|
|
188
|
+
function toBranch(node) {
|
|
189
|
+
return {
|
|
190
|
+
name: node.name,
|
|
191
|
+
tipOid: node.target?.oid ?? null,
|
|
192
|
+
tipAuthorLogin: node.target?.author?.user?.login ?? null,
|
|
193
|
+
tipCommitterLogin: node.target?.committer?.user?.login ?? null,
|
|
194
|
+
tipCommittedAt: node.target?.committedDate ?? null,
|
|
195
|
+
openPRs: null,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/** Every branch of the fork: the first page from `node`, the rest page by page; `complete` is false when a page could not be read. */
|
|
199
|
+
async function allBranches(gql, node) {
|
|
200
|
+
const branches = node.refs.nodes.map((ref) => toBranch(ref));
|
|
201
|
+
let page = node.refs.pageInfo;
|
|
202
|
+
while (page.hasNextPage) {
|
|
203
|
+
const data = await gql.query(MORE_REFS_QUERY, {
|
|
204
|
+
...splitName(node.nameWithOwner),
|
|
205
|
+
after: page.endCursor,
|
|
206
|
+
});
|
|
207
|
+
if (!data.repository)
|
|
208
|
+
return { branches, complete: false };
|
|
209
|
+
branches.push(...data.repository.refs.nodes.map((ref) => toBranch(ref)));
|
|
210
|
+
page = data.repository.refs.pageInfo;
|
|
211
|
+
}
|
|
212
|
+
return { branches, complete: true };
|
|
213
|
+
}
|
|
214
|
+
async function toFacts(gql, node) {
|
|
215
|
+
const { branches, complete } = await allBranches(gql, node);
|
|
216
|
+
return {
|
|
217
|
+
repo: node.nameWithOwner,
|
|
218
|
+
parent: node.parent?.nameWithOwner ?? null,
|
|
219
|
+
isFork: node.isFork,
|
|
220
|
+
createdAt: node.createdAt,
|
|
221
|
+
openPRsToFork: node.pullRequests.totalCount,
|
|
222
|
+
branchCount: node.refs.totalCount,
|
|
223
|
+
hasAllBranches: complete,
|
|
224
|
+
branches,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/** The viewer's login and every fork they own, with all branches. */
|
|
228
|
+
export async function fetchForks(gql) {
|
|
229
|
+
const forks = [];
|
|
230
|
+
let login;
|
|
231
|
+
let after = null;
|
|
232
|
+
do {
|
|
233
|
+
const data = await gql.query(FORKS_QUERY, { after });
|
|
234
|
+
login = data.viewer.login;
|
|
235
|
+
for (const node of data.viewer.repositories.nodes)
|
|
236
|
+
forks.push(await toFacts(gql, node));
|
|
237
|
+
after = data.viewer.repositories.pageInfo.hasNextPage ? data.viewer.repositories.pageInfo.endCursor : null;
|
|
238
|
+
} while (after !== null);
|
|
239
|
+
return { login: login ?? '', forks };
|
|
240
|
+
}
|
|
241
|
+
/** One repository read fresh, or null when it no longer exists. */
|
|
242
|
+
export async function fetchFork(gql, repo) {
|
|
243
|
+
const data = await gql.query(ONE_FORK_QUERY, splitName(repo));
|
|
244
|
+
return data.repository ? toFacts(gql, data.repository) : null;
|
|
245
|
+
}
|
|
246
|
+
/** Lowercase head repositories of the viewer's open PRs. */
|
|
247
|
+
export async function fetchOpenPRHeadRepos(gql) {
|
|
248
|
+
const heads = new Set();
|
|
249
|
+
let after = null;
|
|
250
|
+
do {
|
|
251
|
+
const data = await gql.query(OPEN_PRS_QUERY, { after });
|
|
252
|
+
for (const pr of data.viewer.pullRequests.nodes) {
|
|
253
|
+
if (pr.headRepository)
|
|
254
|
+
heads.add(pr.headRepository.nameWithOwner.toLowerCase());
|
|
255
|
+
}
|
|
256
|
+
after = data.viewer.pullRequests.pageInfo.hasNextPage ? data.viewer.pullRequests.pageInfo.endCursor : null;
|
|
257
|
+
} while (after !== null);
|
|
258
|
+
return heads;
|
|
259
|
+
}
|
|
260
|
+
function toPRFact(pr) {
|
|
261
|
+
return { state: pr.state, baseRepo: pr.baseRepository?.nameWithOwner ?? null, headOid: pr.headRefOid ?? null };
|
|
262
|
+
}
|
|
263
|
+
/** PR facts for the branches {@link isPRLookupNeeded} picks, in aliased batches; branch names travel as variables. */
|
|
264
|
+
export async function fetchBranchPRs(gql, forks, login) {
|
|
265
|
+
const wanted = forks.flatMap((fork) => fork.branches.filter((branch) => isPRLookupNeeded(branch, fork, login)).map((branch) => ({ fork, branch })));
|
|
266
|
+
const result = new Map();
|
|
267
|
+
for (let start = 0; start < wanted.length; start += BRANCHES_PER_QUERY) {
|
|
268
|
+
const batch = wanted.slice(start, start + BRANCHES_PER_QUERY);
|
|
269
|
+
const variables = {};
|
|
270
|
+
const declarations = [];
|
|
271
|
+
const fields = batch.map(({ fork, branch }, i) => {
|
|
272
|
+
const { owner, name } = splitName(fork.repo);
|
|
273
|
+
Object.assign(variables, { [`o${i}`]: owner, [`n${i}`]: name, [`r${i}`]: `refs/heads/${branch.name}` });
|
|
274
|
+
declarations.push(`$o${i}: String!, $n${i}: String!, $r${i}: String!`);
|
|
275
|
+
return `b${i}: repository(owner: $o${i}, name: $n${i}) { ref(qualifiedName: $r${i}) {
|
|
276
|
+
associatedPullRequests(first: 20) { nodes { state headRefOid baseRepository { nameWithOwner } } }
|
|
277
|
+
target { ... on Commit { associatedPullRequests(first: 5) { nodes { state baseRepository { nameWithOwner } } } } } } }`;
|
|
278
|
+
});
|
|
279
|
+
const data = await gql.query(`query(${declarations.join(', ')}) { ${fields.join('\n')} }`, variables);
|
|
280
|
+
for (const [i, { fork, branch }] of batch.entries()) {
|
|
281
|
+
const ref = data[`b${i}`]?.ref;
|
|
282
|
+
if (!ref)
|
|
283
|
+
continue;
|
|
284
|
+
result.set(branchKey(fork.repo, branch.name), {
|
|
285
|
+
prs: ref.associatedPullRequests.nodes.map((pr) => toPRFact(pr)),
|
|
286
|
+
tipPRs: (ref.target?.associatedPullRequests?.nodes ?? []).map((pr) => toPRFact(pr)),
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return result;
|
|
291
|
+
}
|
|
292
|
+
/** `fork` with every branch's count of open PRs (any author) read; a branch that could not be read stays null, so the fork is kept. */
|
|
293
|
+
export async function withOpenPRCounts(gql, fork) {
|
|
294
|
+
const counts = new Map();
|
|
295
|
+
let after = null;
|
|
296
|
+
do {
|
|
297
|
+
const data = await gql.query(OPEN_PR_REFS_QUERY, { ...splitName(fork.repo), after });
|
|
298
|
+
if (!data.repository)
|
|
299
|
+
break;
|
|
300
|
+
for (const ref of data.repository.refs.nodes)
|
|
301
|
+
counts.set(ref.name, ref.associatedPullRequests.totalCount);
|
|
302
|
+
after = data.repository.refs.pageInfo.hasNextPage ? data.repository.refs.pageInfo.endCursor : null;
|
|
303
|
+
} while (after !== null);
|
|
304
|
+
// A branch created since the first listing was never evaluated: leave the whole fork unchecked, so it is kept.
|
|
305
|
+
const known = new Set(fork.branches.map((branch) => branch.name));
|
|
306
|
+
let hasNewBranch = false;
|
|
307
|
+
for (const name of counts.keys())
|
|
308
|
+
hasNewBranch ||= !known.has(name);
|
|
309
|
+
return {
|
|
310
|
+
...fork,
|
|
311
|
+
branches: fork.branches.map((branch) => ({
|
|
312
|
+
...branch,
|
|
313
|
+
openPRs: hasNewBranch ? null : (counts.get(branch.name) ?? null),
|
|
314
|
+
})),
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Verdicts for `forks`. Open PRs by other accounts are read branch by branch
|
|
319
|
+
* only for a fork whose one remaining reason is that they were not read, then
|
|
320
|
+
* it is evaluated again: every branch of every fork that could be pruned is
|
|
321
|
+
* checked, without a lookup per branch of every fork.
|
|
322
|
+
*/
|
|
323
|
+
export async function evaluateAll(gql, forks, ctx) {
|
|
324
|
+
const verdicts = [];
|
|
325
|
+
for (const fork of forks) {
|
|
326
|
+
const first = evaluateFork(fork, ctx);
|
|
327
|
+
const isOnlyUnchecked = first.reasons.length === 1 && first.reasons[0] === UNCHECKED_OPEN_PRS;
|
|
328
|
+
// A fork kept for another reason needs no lookup; the unchecked note would only be noise next to it.
|
|
329
|
+
const kept = { ...first, reasons: first.reasons.filter((reason) => reason !== UNCHECKED_OPEN_PRS) };
|
|
330
|
+
verdicts.push(isOnlyUnchecked ? evaluateFork(await withOpenPRCounts(gql, fork), ctx) : kept);
|
|
331
|
+
}
|
|
332
|
+
return verdicts;
|
|
333
|
+
}
|
|
@@ -52,9 +52,8 @@
|
|
|
52
52
|
* a freeform-only push needs no re-read and cannot clobber another file.
|
|
53
53
|
*/
|
|
54
54
|
import * as fs from 'node:fs';
|
|
55
|
-
import path from 'node:path';
|
|
56
55
|
import { AgentStateSchema, NEWER_WRITER_HINT, unknownStateKeys } from './state-schema.js';
|
|
57
|
-
import {
|
|
56
|
+
import { preserveRejected } from './stale-data.js';
|
|
58
57
|
import { serializeState } from './state-prune.js';
|
|
59
58
|
import { assertNotNewerVersion, atomicWriteFileSync, createFreshState, migrateV1ToV2, migrateV2ToV3, migrateV3ToV4, warnMalformedWorkClaims, } from './state-persistence.js';
|
|
60
59
|
import { getGistIdPath, getStateCachePath } from './paths.js';
|
|
@@ -73,17 +72,14 @@ function extractEtag(headers) {
|
|
|
73
72
|
}
|
|
74
73
|
/**
|
|
75
74
|
* Preserve corrupt Gist content for user recovery. Returns the path written,
|
|
76
|
-
* or null if the preservation itself failed (logged at warn).
|
|
77
|
-
*
|
|
75
|
+
* or null if the preservation itself failed (logged at warn). Shares
|
|
76
|
+
* {@link preserveRejected} with the local-state path.
|
|
78
77
|
*
|
|
79
78
|
* See {@link GistCorruptError} and issue #1201.
|
|
80
79
|
*/
|
|
81
80
|
function preserveRejectedGistContent(raw, gistId) {
|
|
82
81
|
try {
|
|
83
|
-
|
|
84
|
-
fs.writeFileSync(rejectedPath, raw, { encoding: 'utf8', mode: 0o600 });
|
|
85
|
-
pruneRejectedCopies(path.dirname(rejectedPath));
|
|
86
|
-
return rejectedPath;
|
|
82
|
+
return preserveRejected(getStateCachePath(), { content: raw });
|
|
87
83
|
}
|
|
88
84
|
catch (err) {
|
|
89
85
|
warn(MODULE, `Could not preserve rejected Gist content for ${gistId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -140,8 +140,14 @@ export declare const LEDGER_BACKFILL_CEILING = 300;
|
|
|
140
140
|
/**
|
|
141
141
|
* The watermark a ledger gap fetch starts from: undefined (all time) when the
|
|
142
142
|
* ledger holds `stored` rows, fewer than `allTimeCount` and under
|
|
143
|
-
* {@link LEDGER_BACKFILL_CEILING}
|
|
143
|
+
* {@link LEDGER_BACKFILL_CEILING}, and the whole history fits in one gap fetch
|
|
144
|
+
* ({@link LEDGER_GAP_MAX_RESULTS}); otherwise `watermark`. An unknown count
|
|
144
145
|
* keeps the watermark.
|
|
146
|
+
*
|
|
147
|
+
* A history larger than one fetch would come back truncated with no rows, and
|
|
148
|
+
* the caller then stores nothing, the recent list included, on every run. So
|
|
149
|
+
* that ledger keeps growing from its watermark and the count warning points
|
|
150
|
+
* at `ledger-backfill`, which fetches without a limit.
|
|
145
151
|
*/
|
|
146
152
|
export declare function gapFetchWatermark(watermark: string | undefined, stored: number, allTimeCount: number | undefined): string | undefined;
|
|
147
153
|
/** Result of a since-watermark ledger fetch. */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* GitHub Stats - Fetching merged/closed PR counts with star-based filtering.
|
|
3
3
|
* Extracted from PRMonitor to isolate statistics-gathering API calls (#263).
|
|
4
4
|
*/
|
|
5
|
-
import { extractOwnerRepo, parseGitHubUrl, isOwnRepo, isUntrackedOrg } from './urls.js';
|
|
5
|
+
import { extractOwnerRepo, findClosingRefs, MAX_BODY_CHARS, parseGitHubUrl, isOwnRepo, isUntrackedOrg, stripNonProse, } from './urls.js';
|
|
6
6
|
import { isBelowMinStars } from './types.js';
|
|
7
7
|
import { debug, warn } from './logger.js';
|
|
8
8
|
import { describeError } from './errors.js';
|
|
@@ -17,11 +17,6 @@ export const PR_COUNTS_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
|
17
17
|
* 3 pages × 100 per_page = 300 results, which covers the vast majority of users.
|
|
18
18
|
*/
|
|
19
19
|
const MAX_PAGINATION_PAGES = 3;
|
|
20
|
-
const CLOSING_KEYWORD_RE = /\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)(?::\s*|\s+)(?:https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/issues\/(\d+)|([\w.-]+\/[\w.-]+)?#(\d+))\b/i;
|
|
21
|
-
/** HTML comments and code: where PR templates keep example `Fixes #123` lines. */
|
|
22
|
-
const NON_PROSE_RE = /<!--[\s\S]*?-->|```[\s\S]*?```|(`+)[^`]*\1/g;
|
|
23
|
-
/** GitHub's PR body limit; also bounds NON_PROSE_RE's scan on an unclosed `<!--`. */
|
|
24
|
-
const MAX_BODY_CHARS = 65_536;
|
|
25
20
|
/**
|
|
26
21
|
* Issue URL a PR closes, from the first GitHub closing keyword in its body
|
|
27
22
|
* (#1824): `Fixes #12`, `closes owner/repo#12`, or `resolves <issue url>`.
|
|
@@ -31,13 +26,13 @@ const MAX_BODY_CHARS = 65_536;
|
|
|
31
26
|
* first. Switch to GraphQL `closingIssuesReferences` if that ever matters.
|
|
32
27
|
*/
|
|
33
28
|
export function closingIssueUrl(body, prUrl) {
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
29
|
+
const [ref] = body ? findClosingRefs(body, { markdown: true }) : [];
|
|
30
|
+
if (!ref)
|
|
36
31
|
return undefined;
|
|
37
32
|
const own = extractOwnerRepo(prUrl);
|
|
38
33
|
// A bare `#12` refers to the PR's own repo.
|
|
39
|
-
const target =
|
|
40
|
-
return target ? `https://github.com/${target}/issues/${
|
|
34
|
+
const target = ref.repo ?? (own && `${own.owner}/${own.repo}`);
|
|
35
|
+
return target ? `https://github.com/${target}/issues/${ref.number}` : undefined;
|
|
41
36
|
}
|
|
42
37
|
/**
|
|
43
38
|
* A github.com issue or pull URL, rewritten to ` owner/repo#N ` before the
|
|
@@ -63,9 +58,7 @@ const ISSUE_MENTION_RE = /(?<![\w/.-])([\w-]+\/[\w.-]+)?#(\d+)\b/g;
|
|
|
63
58
|
*/
|
|
64
59
|
export function mentionedIssueUrls(title, body, prUrl) {
|
|
65
60
|
const own = extractOwnerRepo(prUrl);
|
|
66
|
-
const text = `${title ?? ''}\n${body?.slice(0, MAX_BODY_CHARS) ?? ''}`
|
|
67
|
-
.replaceAll(NON_PROSE_RE, ' ')
|
|
68
|
-
.replaceAll(ISSUE_URL_RE, ' $1#$2 ');
|
|
61
|
+
const text = stripNonProse(`${title ?? ''}\n${body?.slice(0, MAX_BODY_CHARS) ?? ''}`).replaceAll(ISSUE_URL_RE, ' $1#$2 ');
|
|
69
62
|
const urls = new Set();
|
|
70
63
|
for (const m of text.matchAll(ISSUE_MENTION_RE)) {
|
|
71
64
|
const target = m[1] ?? (own && `${own.owner}/${own.repo}`);
|
|
@@ -434,11 +427,18 @@ export const LEDGER_BACKFILL_CEILING = 300;
|
|
|
434
427
|
/**
|
|
435
428
|
* The watermark a ledger gap fetch starts from: undefined (all time) when the
|
|
436
429
|
* ledger holds `stored` rows, fewer than `allTimeCount` and under
|
|
437
|
-
* {@link LEDGER_BACKFILL_CEILING}
|
|
430
|
+
* {@link LEDGER_BACKFILL_CEILING}, and the whole history fits in one gap fetch
|
|
431
|
+
* ({@link LEDGER_GAP_MAX_RESULTS}); otherwise `watermark`. An unknown count
|
|
438
432
|
* keeps the watermark.
|
|
433
|
+
*
|
|
434
|
+
* A history larger than one fetch would come back truncated with no rows, and
|
|
435
|
+
* the caller then stores nothing, the recent list included, on every run. So
|
|
436
|
+
* that ledger keeps growing from its watermark and the count warning points
|
|
437
|
+
* at `ledger-backfill`, which fetches without a limit.
|
|
439
438
|
*/
|
|
440
439
|
export function gapFetchWatermark(watermark, stored, allTimeCount) {
|
|
441
|
-
|
|
440
|
+
const total = allTimeCount ?? 0;
|
|
441
|
+
return stored < total && stored < LEDGER_BACKFILL_CEILING && total <= LEDGER_GAP_MAX_RESULTS ? undefined : watermark;
|
|
442
442
|
}
|
|
443
443
|
/** How far before the watermark a gap fetch starts: covers clock skew and search indexing lag. */
|
|
444
444
|
const LEDGER_GAP_OVERLAP_MS = 24 * 60 * 60 * 1000;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export { scanForAntiLLMPolicy, type AntiLLMCategory, type AntiLLMMatch, type Ant
|
|
|
39
39
|
* @deprecated Since #1948; will be removed in the next major version.
|
|
40
40
|
*/
|
|
41
41
|
export { detectFormatters, diagnoseCIFormatterFailure, getPreferredFormatter, type DetectedFormatter, type FormatterDetectionResult, type CIFormatterDiagnosis, type FormatterName, } from './formatter-detection.js';
|
|
42
|
-
export { CONFIG_KEY_REGISTRY, type ConfigKeyDef, type SettableVia, isKnownKey, getKeyDef, getSetupKeys, getConfigKeys, suggestKey, formatUnknownKeyError, } from './config-registry.js';
|
|
42
|
+
export { CONFIG_KEY_REGISTRY, type ConfigKeyDef, type SettableVia, type ConfigTrust, isKnownKey, getKeyDef, getKeyTrust, getSetupKeys, getConfigKeys, suggestKey, formatUnknownKeyError, } from './config-registry.js';
|
|
43
43
|
export { DashboardDataSchema, DashboardStatsSchema, validateDashboardData, type DashboardDataParsed, } from './dashboard-data-schema.js';
|
|
44
44
|
export { fetchPRCommentBundle, fetchPRCommentBundlesBatch, type PRCommentBundle, type PRReviewEntry, type PRReviewCommentEntry, type PRIssueCommentEntry, } from './pr-comments-fetcher.js';
|
|
45
45
|
export * from './types.js';
|
package/dist/core/index.js
CHANGED
|
@@ -43,7 +43,7 @@ export { scanForAntiLLMPolicy, } from './anti-llm-policy.js';
|
|
|
43
43
|
* @deprecated Since #1948; will be removed in the next major version.
|
|
44
44
|
*/
|
|
45
45
|
export { detectFormatters, diagnoseCIFormatterFailure, getPreferredFormatter, } from './formatter-detection.js';
|
|
46
|
-
export { CONFIG_KEY_REGISTRY, isKnownKey, getKeyDef, getSetupKeys, getConfigKeys, suggestKey, formatUnknownKeyError, } from './config-registry.js';
|
|
46
|
+
export { CONFIG_KEY_REGISTRY, isKnownKey, getKeyDef, getKeyTrust, getSetupKeys, getConfigKeys, suggestKey, formatUnknownKeyError, } from './config-registry.js';
|
|
47
47
|
export { DashboardDataSchema, DashboardStatsSchema, validateDashboardData, } from './dashboard-data-schema.js';
|
|
48
48
|
// PR comment bundle types — wire shape consumed by the MCP extract-learnings
|
|
49
49
|
// prompt. Re-exported so MCP doesn't have to redeclare the interface and
|
|
@@ -21,6 +21,7 @@ import path from 'node:path';
|
|
|
21
21
|
import { z } from 'zod';
|
|
22
22
|
import { getLocalConfigPath } from './paths.js';
|
|
23
23
|
import { atomicWriteFileSync } from './state-persistence.js';
|
|
24
|
+
import { preserveRejected } from './stale-data.js';
|
|
24
25
|
import { LocalRepoCacheSchema } from './state-schema.js';
|
|
25
26
|
import { errorMessage, ValidationError } from './errors.js';
|
|
26
27
|
import { warn } from './logger.js';
|
|
@@ -55,10 +56,8 @@ const LocalConfigSchema = z.looseObject({
|
|
|
55
56
|
* not overwrite what the user had. Returns a note for the warning.
|
|
56
57
|
*/
|
|
57
58
|
function setAsideUnreadable(filePath) {
|
|
58
|
-
const rejectedPath = `${filePath}.rejected-${Date.now()}`;
|
|
59
59
|
try {
|
|
60
|
-
|
|
61
|
-
return `kept as ${rejectedPath}`;
|
|
60
|
+
return `kept as ${preserveRejected(filePath, 'move')}`;
|
|
62
61
|
}
|
|
63
62
|
catch (err) {
|
|
64
63
|
return `could not be set aside (${errorMessage(err)})`;
|