@oss-autopilot/core 1.15.0 → 1.15.2
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 +34 -1
- package/dist/cli.bundle.cjs +69 -65
- package/dist/commands/daily.d.ts +9 -0
- package/dist/commands/daily.js +4 -1
- package/dist/commands/dashboard-server.d.ts +10 -0
- package/dist/commands/dashboard-server.js +10 -2
- package/dist/commands/scout-bridge.js +2 -1
- package/dist/commands/skip-add.d.ts +25 -0
- package/dist/commands/skip-add.js +48 -0
- package/dist/commands/skip-file-parser.d.ts +25 -0
- package/dist/commands/skip-file-parser.js +92 -0
- package/dist/commands/vet-list.js +10 -0
- package/dist/commands/vet.js +8 -0
- package/dist/core/anti-llm-policy.d.ts +32 -0
- package/dist/core/anti-llm-policy.js +101 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/core/issue-grading.d.ts +75 -0
- package/dist/core/issue-grading.js +146 -0
- package/dist/core/linked-pr-classification.d.ts +30 -0
- package/dist/core/linked-pr-classification.js +53 -0
- package/dist/formatters/json.d.ts +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Issue success-likelihood grade (#858).
|
|
3
|
+
*
|
|
4
|
+
* Predicts the probability that a contribution to a given repo will be
|
|
5
|
+
* accepted and merged, using signals already collected during vetting.
|
|
6
|
+
*
|
|
7
|
+
* The grade is letter-based (A/B/C/F — no D). Each signal is graded
|
|
8
|
+
* independently; the overall grade is the worst of the three, and is
|
|
9
|
+
* further degraded one step if any signal is unknown (missing data is
|
|
10
|
+
* treated as a risk, not ignored). This matches the policy previously
|
|
11
|
+
* described as prose in agents/issue-scout.md.
|
|
12
|
+
*/
|
|
13
|
+
const SEVERITY = { A: 0, B: 1, C: 2, F: 3 };
|
|
14
|
+
const LETTERS = ['A', 'B', 'C', 'F'];
|
|
15
|
+
function worst(grades) {
|
|
16
|
+
return grades.reduce((acc, g) => (SEVERITY[g.letter] > SEVERITY[acc.letter] ? g : acc));
|
|
17
|
+
}
|
|
18
|
+
function degradeOneStep(letter) {
|
|
19
|
+
return LETTERS[Math.min(SEVERITY[letter] + 1, LETTERS.length - 1)];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Coerce a candidate numeric signal to `number` if it's finite and in
|
|
23
|
+
* the given range, otherwise `null`. Non-finite, NaN, and out-of-range
|
|
24
|
+
* values are treated as unknown (and therefore trigger the degrade
|
|
25
|
+
* rule) rather than silently producing bogus grades from garbage input.
|
|
26
|
+
*/
|
|
27
|
+
function sanitize(value, min, max) {
|
|
28
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
29
|
+
return null;
|
|
30
|
+
if (value < min || value > max)
|
|
31
|
+
return null;
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
function gradeResponsiveness(avgResponseDays) {
|
|
35
|
+
if (avgResponseDays < 3)
|
|
36
|
+
return { letter: 'A', detail: `~${Math.round(avgResponseDays)}-day avg response` };
|
|
37
|
+
if (avgResponseDays < 14)
|
|
38
|
+
return { letter: 'B', detail: `${Math.round(avgResponseDays)}-day avg response` };
|
|
39
|
+
if (avgResponseDays <= 60)
|
|
40
|
+
return { letter: 'C', detail: `${Math.round(avgResponseDays)}-day avg response` };
|
|
41
|
+
return { letter: 'F', detail: 'unresponsive maintainers' };
|
|
42
|
+
}
|
|
43
|
+
function gradeMergeRate(mergeRate) {
|
|
44
|
+
const pct = Math.round(mergeRate * 100);
|
|
45
|
+
if (mergeRate > 0.7)
|
|
46
|
+
return { letter: 'A', detail: `merges ${pct}% of PRs` };
|
|
47
|
+
if (mergeRate >= 0.4)
|
|
48
|
+
return { letter: 'B', detail: `merges ${pct}% of PRs` };
|
|
49
|
+
if (mergeRate >= 0.1)
|
|
50
|
+
return { letter: 'C', detail: `merges ${pct}% of PRs` };
|
|
51
|
+
return { letter: 'F', detail: `merges ${pct}% of PRs` };
|
|
52
|
+
}
|
|
53
|
+
function gradeActivity(daysSinceLastCommit) {
|
|
54
|
+
if (daysSinceLastCommit < 7)
|
|
55
|
+
return { letter: 'A', detail: 'commits in last week' };
|
|
56
|
+
if (daysSinceLastCommit < 30)
|
|
57
|
+
return { letter: 'B', detail: 'commits in last month' };
|
|
58
|
+
if (daysSinceLastCommit < 90)
|
|
59
|
+
return { letter: 'C', detail: 'commits in last 90 days' };
|
|
60
|
+
return { letter: 'F', detail: `no commits in ${daysSinceLastCommit}+ days` };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Build `GradeSignals` from a vet candidate's project health plus the
|
|
64
|
+
* optional autopilot-tracked repo score.
|
|
65
|
+
*
|
|
66
|
+
* Notes on each signal:
|
|
67
|
+
*
|
|
68
|
+
* - `avgResponseDays` — `@oss-scout/core`'s `projectHealth.avgIssueResponseDays`
|
|
69
|
+
* is a hardcoded `0` placeholder (it doesn't yet make the additional API
|
|
70
|
+
* calls needed to compute a real value). We therefore prefer
|
|
71
|
+
* `repoScore.avgResponseDays`, which autopilot derives from its own PR
|
|
72
|
+
* tracking, and fall back to `null` (unknown) if neither source has a
|
|
73
|
+
* usable value.
|
|
74
|
+
* - `mergeRate` — derived from repoScore counts. Requires a non-empty PR
|
|
75
|
+
* history; `0/0` is `null`, not `0`.
|
|
76
|
+
* - `daysSinceLastCommit` — taken from scout's `projectHealth`, but only
|
|
77
|
+
* when scout's health check succeeded (`checkFailed` means scout filled
|
|
78
|
+
* in sentinels and shouldn't be trusted).
|
|
79
|
+
*/
|
|
80
|
+
export function deriveGradeSignals(params) {
|
|
81
|
+
const { projectHealth, repoScore } = params;
|
|
82
|
+
const healthTrusted = !projectHealth.checkFailed;
|
|
83
|
+
const avgResponseDays = sanitize(repoScore?.avgResponseDays, 0, Number.MAX_SAFE_INTEGER) ??
|
|
84
|
+
(healthTrusted ? sanitize(projectHealth.avgIssueResponseDays, 0.001, Number.MAX_SAFE_INTEGER) : null);
|
|
85
|
+
const daysSinceLastCommit = healthTrusted
|
|
86
|
+
? sanitize(projectHealth.daysSinceLastCommit, 0, Number.MAX_SAFE_INTEGER)
|
|
87
|
+
: null;
|
|
88
|
+
let mergeRate = null;
|
|
89
|
+
if (repoScore) {
|
|
90
|
+
const merged = sanitize(repoScore.mergedPRCount, 0, Number.MAX_SAFE_INTEGER);
|
|
91
|
+
const closed = sanitize(repoScore.closedWithoutMergeCount, 0, Number.MAX_SAFE_INTEGER);
|
|
92
|
+
if (merged !== null && closed !== null) {
|
|
93
|
+
const total = merged + closed;
|
|
94
|
+
mergeRate = total === 0 ? null : merged / total;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { avgResponseDays, mergeRate, daysSinceLastCommit };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* End-to-end helper for vet callers: reads the repo score, derives
|
|
101
|
+
* signals from a scout candidate, and returns the grade. Callers pass
|
|
102
|
+
* the `projectHealth` straight through from `scout.vetIssue()`.
|
|
103
|
+
*/
|
|
104
|
+
export function gradeFromCandidate(params) {
|
|
105
|
+
const repoScore = params.getRepoScore(params.repo);
|
|
106
|
+
return computeSuccessGrade(deriveGradeSignals({
|
|
107
|
+
projectHealth: params.projectHealth,
|
|
108
|
+
repoScore: repoScore
|
|
109
|
+
? {
|
|
110
|
+
mergedPRCount: repoScore.mergedPRCount,
|
|
111
|
+
closedWithoutMergeCount: repoScore.closedWithoutMergeCount,
|
|
112
|
+
avgResponseDays: repoScore.avgResponseDays,
|
|
113
|
+
}
|
|
114
|
+
: null,
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
export function computeSuccessGrade(signals) {
|
|
118
|
+
const graded = [];
|
|
119
|
+
const unknowns = [];
|
|
120
|
+
const resp = sanitize(signals.avgResponseDays, 0, Number.MAX_SAFE_INTEGER);
|
|
121
|
+
if (resp === null)
|
|
122
|
+
unknowns.push('maintainer responsiveness');
|
|
123
|
+
else
|
|
124
|
+
graded.push(gradeResponsiveness(resp));
|
|
125
|
+
const mr = sanitize(signals.mergeRate, 0, 1);
|
|
126
|
+
if (mr === null)
|
|
127
|
+
unknowns.push('merge rate');
|
|
128
|
+
else
|
|
129
|
+
graded.push(gradeMergeRate(mr));
|
|
130
|
+
const act = sanitize(signals.daysSinceLastCommit, 0, Number.MAX_SAFE_INTEGER);
|
|
131
|
+
if (act === null)
|
|
132
|
+
unknowns.push('activity');
|
|
133
|
+
else
|
|
134
|
+
graded.push(gradeActivity(act));
|
|
135
|
+
// No signal available at all — give F so callers see missing data as a
|
|
136
|
+
// strong negative rather than a neutral grade.
|
|
137
|
+
if (graded.length === 0) {
|
|
138
|
+
return { letter: 'F', reason: `unknown ${unknowns.join(', ')}` };
|
|
139
|
+
}
|
|
140
|
+
const worstKnown = worst(graded);
|
|
141
|
+
const finalLetter = unknowns.length > 0 ? degradeOneStep(worstKnown.letter) : worstKnown.letter;
|
|
142
|
+
const reasonParts = [worstKnown.detail];
|
|
143
|
+
if (unknowns.length > 0)
|
|
144
|
+
reasonParts.push(`unknown ${unknowns.join(', ')}`);
|
|
145
|
+
return { letter: finalLetter, reason: reasonParts.join(', ') };
|
|
146
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linked-PR classification (#910, #978).
|
|
3
|
+
*
|
|
4
|
+
* Given the first linked PR on an issue, decide how it affects whether
|
|
5
|
+
* the issue is actionable for the current user. Previously described as
|
|
6
|
+
* prose in agents/issue-scout.md; extracted here as a pure function so
|
|
7
|
+
* the classification is unit-testable and uniform across callers.
|
|
8
|
+
*
|
|
9
|
+
* Integration with the vet flow is deferred — scout does not yet surface
|
|
10
|
+
* linked-PR metadata on `IssueCandidate`, so consumers need to fetch the
|
|
11
|
+
* linked PR themselves (e.g. via Octokit) and hand the shape to this
|
|
12
|
+
* function. See #978 for the upstream data-contract work.
|
|
13
|
+
*/
|
|
14
|
+
export type LinkedPRClassification = 'none' | 'user_open' | 'user_closed' | 'user_merged' | 'other_open' | 'other_closed' | 'other_merged';
|
|
15
|
+
export type LinkedPRState = 'open' | 'closed' | 'merged';
|
|
16
|
+
export interface LinkedPR {
|
|
17
|
+
/**
|
|
18
|
+
* May be `null` for deleted GitHub accounts ("ghost" users); the
|
|
19
|
+
* declared type on GitHub's API allows null here even though the REST
|
|
20
|
+
* schema example typically shows a populated user.
|
|
21
|
+
*/
|
|
22
|
+
author: {
|
|
23
|
+
login: string;
|
|
24
|
+
} | null;
|
|
25
|
+
state: LinkedPRState;
|
|
26
|
+
}
|
|
27
|
+
export declare function classifyLinkedPR(params: {
|
|
28
|
+
linkedPR: LinkedPR | null;
|
|
29
|
+
userLogin: string;
|
|
30
|
+
}): LinkedPRClassification;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linked-PR classification (#910, #978).
|
|
3
|
+
*
|
|
4
|
+
* Given the first linked PR on an issue, decide how it affects whether
|
|
5
|
+
* the issue is actionable for the current user. Previously described as
|
|
6
|
+
* prose in agents/issue-scout.md; extracted here as a pure function so
|
|
7
|
+
* the classification is unit-testable and uniform across callers.
|
|
8
|
+
*
|
|
9
|
+
* Integration with the vet flow is deferred — scout does not yet surface
|
|
10
|
+
* linked-PR metadata on `IssueCandidate`, so consumers need to fetch the
|
|
11
|
+
* linked PR themselves (e.g. via Octokit) and hand the shape to this
|
|
12
|
+
* function. See #978 for the upstream data-contract work.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Normalize a state value from either REST (lowercase `open`/`closed`
|
|
16
|
+
* plus a separate `merged` boolean) or GraphQL (uppercase `OPEN`/
|
|
17
|
+
* `CLOSED`/`MERGED` union) into our internal lowercase form. Callers
|
|
18
|
+
* converting from REST should pre-mix `merged` into the state before
|
|
19
|
+
* calling; see the tests for expected shapes.
|
|
20
|
+
*/
|
|
21
|
+
function normalizeState(state) {
|
|
22
|
+
const lower = state.toLowerCase();
|
|
23
|
+
if (lower === 'open' || lower === 'closed' || lower === 'merged')
|
|
24
|
+
return lower;
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
export function classifyLinkedPR(params) {
|
|
28
|
+
const { linkedPR, userLogin } = params;
|
|
29
|
+
if (!linkedPR)
|
|
30
|
+
return 'none';
|
|
31
|
+
const state = normalizeState(linkedPR.state);
|
|
32
|
+
// Unknown state (e.g., future-extended values) is safest to treat as
|
|
33
|
+
// "closed" — skip-worthy but non-fatal — rather than throwing and
|
|
34
|
+
// breaking the whole vetting pipeline on one malformed payload.
|
|
35
|
+
const effectiveState = state ?? 'closed';
|
|
36
|
+
// GitHub usernames are case-insensitive ASCII. Ghost authors (deleted
|
|
37
|
+
// accounts) return `null` or an empty login; in both cases we can't
|
|
38
|
+
// prove the PR is the user's own, so we classify it as "other_*".
|
|
39
|
+
const authorLogin = linkedPR.author?.login ?? '';
|
|
40
|
+
const isUserOwn = authorLogin !== '' && userLogin !== '' && authorLogin.toLowerCase() === userLogin.toLowerCase();
|
|
41
|
+
if (isUserOwn) {
|
|
42
|
+
if (effectiveState === 'open')
|
|
43
|
+
return 'user_open';
|
|
44
|
+
if (effectiveState === 'merged')
|
|
45
|
+
return 'user_merged';
|
|
46
|
+
return 'user_closed';
|
|
47
|
+
}
|
|
48
|
+
if (effectiveState === 'open')
|
|
49
|
+
return 'other_open';
|
|
50
|
+
if (effectiveState === 'merged')
|
|
51
|
+
return 'other_merged';
|
|
52
|
+
return 'other_closed';
|
|
53
|
+
}
|
|
@@ -313,6 +313,11 @@ export interface VetOutput {
|
|
|
313
313
|
reasonsToSkip: string[];
|
|
314
314
|
projectHealth: unknown;
|
|
315
315
|
vettingResult: unknown;
|
|
316
|
+
/** Success-likelihood grade (#858): predicts whether a PR will merge. */
|
|
317
|
+
grade: {
|
|
318
|
+
letter: 'A' | 'B' | 'C' | 'F';
|
|
319
|
+
reason: string;
|
|
320
|
+
};
|
|
316
321
|
}
|
|
317
322
|
/** Output of the comments command */
|
|
318
323
|
export interface CommentsOutput {
|