@reneturcios/greenlight 0.3.11 → 0.5.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/README.md +42 -1
- package/dist/automate.d.ts +14 -1
- package/dist/automate.js +30 -12
- package/dist/automate.js.map +1 -1
- package/dist/cli.js +194 -7
- package/dist/cli.js.map +1 -1
- package/dist/digest.d.ts +1 -1
- package/dist/digest.js +1 -1
- package/dist/digest.js.map +1 -1
- package/dist/doctor.d.ts +34 -0
- package/dist/doctor.js +158 -0
- package/dist/doctor.js.map +1 -0
- package/dist/friction.d.ts +7 -0
- package/dist/friction.js +36 -0
- package/dist/friction.js.map +1 -1
- package/dist/github.js +2 -2
- package/dist/github.js.map +1 -1
- package/dist/guard.d.ts +5 -3
- package/dist/guard.js +60 -5
- package/dist/guard.js.map +1 -1
- package/dist/help.d.ts +25 -0
- package/dist/help.js +234 -0
- package/dist/help.js.map +1 -0
- package/dist/index.js +85 -33
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +61 -0
- package/dist/init.js +298 -0
- package/dist/init.js.map +1 -0
- package/dist/protocol-fetch.d.ts +142 -0
- package/dist/protocol-fetch.js +350 -0
- package/dist/protocol-fetch.js.map +1 -0
- package/dist/protocol.d.ts +232 -0
- package/dist/protocol.js +484 -0
- package/dist/protocol.js.map +1 -0
- package/dist/verify-comment.d.ts +75 -0
- package/dist/verify-comment.js +149 -0
- package/dist/verify-comment.js.map +1 -0
- package/dist/verify-parsers.d.ts +25 -0
- package/dist/verify-parsers.js +56 -0
- package/dist/verify-parsers.js.map +1 -0
- package/dist/verify.d.ts +52 -0
- package/dist/verify.js +276 -0
- package/dist/verify.js.map +1 -0
- package/integrations/README.md +4 -1
- package/integrations/claude-code/CLAUDE.snippet.md +6 -5
- package/integrations/cline/README.md +1 -1
- package/integrations/copilot/copilot-instructions.snippet.md +6 -3
- package/integrations/cursor/greenlight.mdc +2 -1
- package/integrations/windsurf/README.md +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
const GAP = (label) => `*${label}: not recorded*`;
|
|
2
|
+
function section(title, body, gaps, gapName) {
|
|
3
|
+
if (body.trim().length === 0)
|
|
4
|
+
gaps.push(gapName);
|
|
5
|
+
return `## ${title}\n\n${body.trim().length > 0 ? body.trim() : GAP("not yet filled in")}\n`;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Assemble the verified comment. Everything comes from the contributor's
|
|
9
|
+
* inputs (or the --from-file parse); nothing is fetched and nothing is
|
|
10
|
+
* invented. The greenlight version in the footer is a real fact about the
|
|
11
|
+
* tool that assembled the comment, not a fact about the bug.
|
|
12
|
+
*/
|
|
13
|
+
export function buildVerifiedComment(issueUrl, fields, greenlightVersion) {
|
|
14
|
+
const gaps = [];
|
|
15
|
+
const f = (k) => fields[k] instanceof Array
|
|
16
|
+
? fields[k].join("\n")
|
|
17
|
+
: (fields[k] ?? "").trim();
|
|
18
|
+
const parts = [];
|
|
19
|
+
parts.push(`<!-- greenlight-verified-comment v1 -->`);
|
|
20
|
+
parts.push(`# Verified finding for ${issueUrl}`);
|
|
21
|
+
parts.push(``);
|
|
22
|
+
parts.push(section("Claim of the problem", f("claim"), gaps, "claim"));
|
|
23
|
+
parts.push(section("Environment", f("environment"), gaps, "environment"));
|
|
24
|
+
const repro = fields.reproduction ?? [];
|
|
25
|
+
const reproBody = repro.length > 0
|
|
26
|
+
? repro.map((s, i) => `${i + 1}. ${s.trim()}`).join("\n")
|
|
27
|
+
: `*Repro: not yet run*`;
|
|
28
|
+
if (repro.length === 0)
|
|
29
|
+
gaps.push("reproduction");
|
|
30
|
+
parts.push(`## Reproduction\n\n${reproBody}\n`);
|
|
31
|
+
parts.push(section("Observed vs expected", [f("observed"), f("expected")].some((s) => s.length > 0)
|
|
32
|
+
? `**Observed:** ${f("observed") || "*not recorded*"}\n\n**Expected:** ${f("expected") || "*not recorded*"}`
|
|
33
|
+
: "", gaps, "observed/expected"));
|
|
34
|
+
parts.push(section("Root cause", f("rootCause"), gaps, "root-cause").replace("not yet filled in", "not yet isolated"));
|
|
35
|
+
parts.push(section("Proposed fix", f("fixSketch"), gaps, "fix-sketch").replace("not yet filled in", "not sketched yet"));
|
|
36
|
+
const ran = f("ran");
|
|
37
|
+
if (ran.length === 0)
|
|
38
|
+
gaps.push("verification");
|
|
39
|
+
const by = f("verifiedBy");
|
|
40
|
+
parts.push(`## Verification\n\n` +
|
|
41
|
+
`What was actually run: ${ran.length > 0 ? ran : "*not yet run*"}\n\n` +
|
|
42
|
+
`Verified by: ${by.length > 0 ? by : "*contributor not stated*"}\n\n` +
|
|
43
|
+
`---\n` +
|
|
44
|
+
`*Comment drafted with Greenlight v${greenlightVersion} (verified-comment mode). ` +
|
|
45
|
+
`Assembled locally from the contributor's notes; nothing here was posted automatically.*\n`);
|
|
46
|
+
return { markdown: parts.join("\n"), gaps };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* True when the repo class is maintainer-only PRs: outside PRs are
|
|
50
|
+
* refused on sight, so the useful contribution is a verified comment.
|
|
51
|
+
* That is Greenlight's `collaborators_only` gate (inspector and servers
|
|
52
|
+
* both land there: their policy text is matched by the gate parser).
|
|
53
|
+
*/
|
|
54
|
+
export function suggestsVerifiedComment(gates) {
|
|
55
|
+
return gates.some((g) => g.detected && g.kind === "collaborators_only");
|
|
56
|
+
}
|
|
57
|
+
/** The suggestion line check_issue prints for maintainer-only repos. */
|
|
58
|
+
export function verifiedCommentSuggestion(issueUrl) {
|
|
59
|
+
return `This repo takes verified comments instead of PRs: draft one with greenlight verify-comment ${issueUrl}`;
|
|
60
|
+
}
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// --from-file parsing: headings map onto sections, everything else is kept.
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
const HEADING_MAP = [
|
|
65
|
+
{ match: /^(claim|problem|summary|title)$/i, field: "claim" },
|
|
66
|
+
{ match: /^(environment|env|setup|context)$/i, field: "environment" },
|
|
67
|
+
{ match: /^(repro|reproduction|reproduction steps|steps|how to reproduce)$/i, field: "reproduction" },
|
|
68
|
+
{ match: /^(observed)$/i, field: "observed" },
|
|
69
|
+
{ match: /^(expected)$/i, field: "expected" },
|
|
70
|
+
{ match: /^(observed vs expected|observed\/expected|behavior)$/i, field: "observed" },
|
|
71
|
+
{ match: /^(root cause|cause|analysis)$/i, field: "rootCause" },
|
|
72
|
+
{ match: /^(fix|proposed fix|fix sketch|proposal|solution)$/i, field: "fixSketch" },
|
|
73
|
+
{ match: /^(ran|verification|what was run|testing|test results)$/i, field: "ran" },
|
|
74
|
+
{ match: /^(by|verified by|author|contributor)$/i, field: "verifiedBy" },
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* Parse a markdown notes file into comment fields. Lines under a heading
|
|
78
|
+
* map to that section; unmapped headings are preserved under
|
|
79
|
+
* "Additional notes" instead of being dropped, so contributor content is
|
|
80
|
+
* never silently lost. Unheaded text at the top of the file becomes the
|
|
81
|
+
* claim.
|
|
82
|
+
*/
|
|
83
|
+
export function parseNoteFile(text) {
|
|
84
|
+
const fields = {};
|
|
85
|
+
const extras = [];
|
|
86
|
+
const lines = text.split("\n");
|
|
87
|
+
let current = {
|
|
88
|
+
field: null,
|
|
89
|
+
extraTitle: null,
|
|
90
|
+
};
|
|
91
|
+
const buffers = new Map();
|
|
92
|
+
const push = (key, line) => {
|
|
93
|
+
const b = buffers.get(key) ?? [];
|
|
94
|
+
b.push(line);
|
|
95
|
+
buffers.set(key, b);
|
|
96
|
+
};
|
|
97
|
+
const flushExtra = () => {
|
|
98
|
+
if (current.extraTitle) {
|
|
99
|
+
const b = buffers.get(`extra:${current.extraTitle}`) ?? [];
|
|
100
|
+
if (b.join("\n").trim().length > 0) {
|
|
101
|
+
extras.push(`### ${current.extraTitle}\n\n${b.join("\n").trim()}`);
|
|
102
|
+
}
|
|
103
|
+
current.extraTitle = null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
for (const line of lines) {
|
|
107
|
+
const m = /^(#{1,3})\s+(.+?)\s*$/.exec(line);
|
|
108
|
+
if (m) {
|
|
109
|
+
flushExtra();
|
|
110
|
+
const title = m[2].trim();
|
|
111
|
+
const hit = HEADING_MAP.find((h) => h.match.test(title));
|
|
112
|
+
current = hit
|
|
113
|
+
? { field: hit.field, extraTitle: null }
|
|
114
|
+
: { field: null, extraTitle: title };
|
|
115
|
+
if (!hit)
|
|
116
|
+
buffers.set(`extra:${title}`, []);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (current.field) {
|
|
120
|
+
push(current.field, line);
|
|
121
|
+
}
|
|
122
|
+
else if (current.extraTitle) {
|
|
123
|
+
push(`extra:${current.extraTitle}`, line);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Unheaded leading text: treat as the claim of the problem.
|
|
127
|
+
push("claim", line);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
flushExtra();
|
|
131
|
+
for (const [k, b] of buffers) {
|
|
132
|
+
if (k.startsWith("extra:"))
|
|
133
|
+
continue;
|
|
134
|
+
const value = b.join("\n").trim();
|
|
135
|
+
if (value.length === 0)
|
|
136
|
+
continue;
|
|
137
|
+
if (k === "reproduction") {
|
|
138
|
+
fields.reproduction = value
|
|
139
|
+
.split("\n")
|
|
140
|
+
.map((s) => s.replace(/^\s*(?:\d+[.)]|[-*])\s+/, "").trim())
|
|
141
|
+
.filter((s) => s.length > 0);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
fields[k] = value;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return { fields, additionalNotes: extras.join("\n\n") };
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=verify-comment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-comment.js","sourceRoot":"","sources":["../src/verify-comment.ts"],"names":[],"mappings":"AAkDA,MAAM,GAAG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AC;IACH,CAAC;IACD,UAAU,EAAE,CAAC;IAEb,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,SAAS;QACrC,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QACjC,IAAI,CAAC,KAAK,cAAc,EAAE,CAAC;YACzB,MAAM,CAAC,YAAY,GAAG,KAAK;iBACxB,KAAK,CAAC,IAAI,CAAC;iBACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;iBAC3D,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACL,MAAiC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;QAChD,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test-output parsers for `greenlight verify`.
|
|
3
|
+
*
|
|
4
|
+
* The delta (base vs head) is only honest if it is derived from parsed
|
|
5
|
+
* test identities, never from raw log lines. Each parser turns one
|
|
6
|
+
* runner's output into the same shape: named passing tests and named
|
|
7
|
+
* failing tests. Runners slot in by implementing TestRunnerParser; the
|
|
8
|
+
* pipeline picks the first parser whose canParse matches the test
|
|
9
|
+
* command.
|
|
10
|
+
*/
|
|
11
|
+
export interface ParsedTests {
|
|
12
|
+
passed: string[];
|
|
13
|
+
failed: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface TestRunnerParser {
|
|
16
|
+
/** Human name, e.g. "node:test". */
|
|
17
|
+
name: string;
|
|
18
|
+
/** True when this parser claims the given test command. */
|
|
19
|
+
canParse(command: string): boolean;
|
|
20
|
+
/** Parse one full run's stdout+stderr. */
|
|
21
|
+
parse(output: string): ParsedTests;
|
|
22
|
+
}
|
|
23
|
+
export declare const RUNNER_PARSERS: TestRunnerParser[];
|
|
24
|
+
/** Pick the parser for a test command, or null when none claims it. */
|
|
25
|
+
export declare function parserForCommand(command: string): TestRunnerParser | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function dedupe(xs) {
|
|
2
|
+
return [...new Set(xs)];
|
|
3
|
+
}
|
|
4
|
+
const nodeTest = {
|
|
5
|
+
name: "node:test",
|
|
6
|
+
canParse: (cmd) => /(^|\s)(node\s+--test|tsx?\s+--test)/.test(cmd) || /\bvitest\b/.test(cmd),
|
|
7
|
+
parse(output) {
|
|
8
|
+
const passed = [];
|
|
9
|
+
const failed = [];
|
|
10
|
+
for (const line of output.split("\n")) {
|
|
11
|
+
// node --test: "✔ name (1.23ms)" / "✖ name (1.23ms)"; leading spaces ok.
|
|
12
|
+
// The summary headers "✖ failing tests:" / "✔ passing tests:" are not
|
|
13
|
+
// tests (the live greenlight-verify run on 2026-10-16 caught "failing
|
|
14
|
+
// tests:" being counted as a failure).
|
|
15
|
+
const ok = /^\s*✔\s+(.+?)(?:\s+\(\d[\d.,]*m?s\))?\s*$/.exec(line);
|
|
16
|
+
if (ok && !/^(passing|failing) tests:?$/i.test(ok[1].trim())) {
|
|
17
|
+
passed.push(ok[1].trim());
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const bad = /^\s*✖\s+(.+?)(?:\s+\(\d[\d.,]*m?s\))?\s*$/.exec(line);
|
|
21
|
+
if (bad && !/^(passing|failing) tests:?$/i.test(bad[1].trim())) {
|
|
22
|
+
failed.push(bad[1].trim());
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
// vitest run: "✓ src/foo.test.ts (3 tests)" is file-level; real
|
|
26
|
+
// per-test lines come from node --test above. Skip to avoid mixing
|
|
27
|
+
// granularities.
|
|
28
|
+
}
|
|
29
|
+
return { passed: dedupe(passed), failed: dedupe(failed) };
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const pytest = {
|
|
33
|
+
name: "pytest",
|
|
34
|
+
canParse: (cmd) => /(^|\s)pytest(\s|$)/.test(cmd),
|
|
35
|
+
parse(output) {
|
|
36
|
+
const passed = [];
|
|
37
|
+
const failed = [];
|
|
38
|
+
for (const line of output.split("\n")) {
|
|
39
|
+
// -v output: "tests/x.py::TestY::test_z PASSED" / FAILED / ERROR
|
|
40
|
+
const m = /^(\S+::\S+)\s+(PASSED|FAILED|ERROR)\b/.exec(line.trim());
|
|
41
|
+
if (!m)
|
|
42
|
+
continue;
|
|
43
|
+
if (m[2] === "PASSED")
|
|
44
|
+
passed.push(m[1]);
|
|
45
|
+
else
|
|
46
|
+
failed.push(m[1]);
|
|
47
|
+
}
|
|
48
|
+
return { passed: dedupe(passed), failed: dedupe(failed) };
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
export const RUNNER_PARSERS = [nodeTest, pytest];
|
|
52
|
+
/** Pick the parser for a test command, or null when none claims it. */
|
|
53
|
+
export function parserForCommand(command) {
|
|
54
|
+
return RUNNER_PARSERS.find((p) => p.canParse(command)) ?? null;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=verify-parsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-parsers.js","sourceRoot":"","sources":["../src/verify-parsers.ts"],"names":[],"mappings":"AAwBA,SAAS,MAAM,CAAC,EAAY;IAC1B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,QAAQ,GAAqB;IACjC,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,CAAC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,IAAI,CAAC,GAAG,CAAC;IACjD,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,iEAAiE;YACjE,MAAM,CAAC,GAAG,uCAAuC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACpE,IAAI,CAAC,CAAC;gBAAE,SAAS;YACjB,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ;gBAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;gBACpC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IAC5D,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAErE,uEAAuE;AACvE,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC;AACjE,CAAC"}
|
package/dist/verify.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface VerifyOptions {
|
|
2
|
+
/** Base ref for the comparison (default: merge-base with upstream, or origin/main). */
|
|
3
|
+
base?: string;
|
|
4
|
+
/** Override the detected test command. */
|
|
5
|
+
cmd?: string;
|
|
6
|
+
/** Override the parser choice (parser name, e.g. "node:test", "pytest"). */
|
|
7
|
+
parser?: string;
|
|
8
|
+
/** Per-run timeout in seconds. */
|
|
9
|
+
timeoutSecs?: number;
|
|
10
|
+
/** Run even when the working tree has uncommitted changes. */
|
|
11
|
+
allowDirty?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface VerifyDelta {
|
|
14
|
+
newlyFailing: string[];
|
|
15
|
+
newlyPassing: string[];
|
|
16
|
+
stillFailing: string[];
|
|
17
|
+
baseTotal: {
|
|
18
|
+
passed: number;
|
|
19
|
+
failed: number;
|
|
20
|
+
};
|
|
21
|
+
headTotal: {
|
|
22
|
+
passed: number;
|
|
23
|
+
failed: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface VerifyResult {
|
|
27
|
+
ok: boolean;
|
|
28
|
+
/** Machine form of the outcome. */
|
|
29
|
+
outcome: "fixed" | "broke" | "clean" | "no-change" | "unverifiable";
|
|
30
|
+
/** "unverifiable" only: why the comparison could not be made. */
|
|
31
|
+
reason?: string;
|
|
32
|
+
command?: string;
|
|
33
|
+
parser?: string;
|
|
34
|
+
base?: string;
|
|
35
|
+
delta?: VerifyDelta;
|
|
36
|
+
markdown: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Detect the repo's test command from its manifest files. Returns null
|
|
40
|
+
* when nothing is detectable; the caller must then report unverifiable
|
|
41
|
+
* rather than guess a command.
|
|
42
|
+
*/
|
|
43
|
+
export declare function detectTestCommand(dir: string): string | null;
|
|
44
|
+
/** Resolve the default base ref: upstream merge-base, else local origin/main. */
|
|
45
|
+
export declare function defaultBase(dir: string): string | null;
|
|
46
|
+
export declare function renderVerifyMarkdown(r: VerifyResult): string;
|
|
47
|
+
/**
|
|
48
|
+
* Run the red-green comparison. All failure paths are explicit: this
|
|
49
|
+
* function would rather say "unverifiable" with a reason than report a
|
|
50
|
+
* delta it cannot defend.
|
|
51
|
+
*/
|
|
52
|
+
export declare function verifyRepo(dir: string, opts?: VerifyOptions): VerifyResult;
|
package/dist/verify.js
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Honest verify: the red-green runner.
|
|
3
|
+
*
|
|
4
|
+
* `greenlight verify` answers one question with evidence: did my change
|
|
5
|
+
* fix the failing test, break something new, or neither? It runs the
|
|
6
|
+
* repo's test command on a base worktree and on the current tree, parses
|
|
7
|
+
* both runs into test identities with verify-parsers, and reports the
|
|
8
|
+
* DELTA: newly failing (yours), newly passing (fixed), still failing
|
|
9
|
+
* (pre-existing, not yours). Counts come from parsed output, never raw
|
|
10
|
+
* log lines.
|
|
11
|
+
*
|
|
12
|
+
* CLI only, on purpose: this runs test suites on the machine where the
|
|
13
|
+
* code lives, and suites can take minutes. The MCP server is for agents
|
|
14
|
+
* on other machines; the thing that runs your tests belongs in the CLI.
|
|
15
|
+
*/
|
|
16
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
17
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
18
|
+
import { tmpdir } from "node:os";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
import { parserForCommand, RUNNER_PARSERS } from "./verify-parsers.js";
|
|
21
|
+
function sh(dir, args) {
|
|
22
|
+
return execFileSync("git", args, { cwd: dir, encoding: "utf8" }).trim();
|
|
23
|
+
}
|
|
24
|
+
function isGitRepo(dir) {
|
|
25
|
+
try {
|
|
26
|
+
sh(dir, ["rev-parse", "--git-dir"]);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function isTreeClean(dir) {
|
|
34
|
+
try {
|
|
35
|
+
return sh(dir, ["status", "--porcelain"]).length === 0;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Detect the repo's test command from its manifest files. Returns null
|
|
43
|
+
* when nothing is detectable; the caller must then report unverifiable
|
|
44
|
+
* rather than guess a command.
|
|
45
|
+
*/
|
|
46
|
+
export function detectTestCommand(dir) {
|
|
47
|
+
const pkg = join(dir, "package.json");
|
|
48
|
+
if (existsSync(pkg)) {
|
|
49
|
+
try {
|
|
50
|
+
const doc = JSON.parse(readFileSync(pkg, "utf8"));
|
|
51
|
+
// Return the script itself, not "npm test": the parser needs to see
|
|
52
|
+
// the real runner (node --test, vitest, pytest) to claim the output.
|
|
53
|
+
if (doc.scripts?.test)
|
|
54
|
+
return doc.scripts.test;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// fall through
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (existsSync(join(dir, "pyproject.toml")) || existsSync(join(dir, "pytest.ini")) || existsSync(join(dir, "setup.cfg"))) {
|
|
61
|
+
return "pytest -q";
|
|
62
|
+
}
|
|
63
|
+
if (existsSync(join(dir, "go.mod")))
|
|
64
|
+
return "go test ./...";
|
|
65
|
+
if (existsSync(join(dir, "Cargo.toml")))
|
|
66
|
+
return "cargo test";
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
/** Resolve the default base ref: upstream merge-base, else local origin/main. */
|
|
70
|
+
export function defaultBase(dir) {
|
|
71
|
+
try {
|
|
72
|
+
const upstream = sh(dir, ["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"]);
|
|
73
|
+
return sh(dir, ["merge-base", "HEAD", upstream]);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// no upstream tracking
|
|
77
|
+
}
|
|
78
|
+
for (const cand of ["origin/main", "origin/master"]) {
|
|
79
|
+
try {
|
|
80
|
+
sh(dir, ["rev-parse", "--verify", cand]);
|
|
81
|
+
return sh(dir, ["merge-base", "HEAD", cand]);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// try next
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
/** Run a shell command in dir with a timeout, capturing merged output. */
|
|
90
|
+
function runCommand(dir, command, timeoutMs) {
|
|
91
|
+
try {
|
|
92
|
+
const r = spawnSync("sh", ["-c", command], {
|
|
93
|
+
cwd: dir,
|
|
94
|
+
encoding: "utf8",
|
|
95
|
+
timeout: timeoutMs,
|
|
96
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
97
|
+
});
|
|
98
|
+
if (r.error) {
|
|
99
|
+
const err = r.error;
|
|
100
|
+
if (err.code === "ENOENT")
|
|
101
|
+
return { output: "", exitCode: -1, timedOut: false, spawnFailed: true };
|
|
102
|
+
if (err.killed)
|
|
103
|
+
return { output: r.stdout + r.stderr, exitCode: -1, timedOut: true, spawnFailed: false };
|
|
104
|
+
return { output: String(err.message), exitCode: -1, timedOut: false, spawnFailed: true };
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
output: (r.stdout ?? "") + (r.stderr ?? ""),
|
|
108
|
+
exitCode: r.status ?? -1,
|
|
109
|
+
timedOut: false,
|
|
110
|
+
spawnFailed: false,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
return { output: String(err), exitCode: -1, timedOut: false, spawnFailed: true };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function deltaOf(baseFailed, headFailed) {
|
|
118
|
+
const b = new Set(baseFailed);
|
|
119
|
+
const h = new Set(headFailed);
|
|
120
|
+
return {
|
|
121
|
+
newlyFailing: [...h].filter((t) => !b.has(t)),
|
|
122
|
+
newlyPassing: [...b].filter((t) => !h.has(t)),
|
|
123
|
+
stillFailing: [...h].filter((t) => b.has(t)),
|
|
124
|
+
baseTotal: { passed: 0, failed: baseFailed.length },
|
|
125
|
+
headTotal: { passed: 0, failed: headFailed.length },
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export function renderVerifyMarkdown(r) {
|
|
129
|
+
if (r.outcome === "unverifiable") {
|
|
130
|
+
return `## Verify: unverifiable\n\n${r.reason ?? "no reason given"}\n`;
|
|
131
|
+
}
|
|
132
|
+
const d = r.delta;
|
|
133
|
+
const lines = [
|
|
134
|
+
`## Verify: base \`${r.base}\` vs working tree`,
|
|
135
|
+
``,
|
|
136
|
+
`Test command: \`${r.command}\` (parsed with ${r.parser})`,
|
|
137
|
+
`Base: ${d.baseTotal.failed} failing | Head: ${d.headTotal.failed} failing`,
|
|
138
|
+
``,
|
|
139
|
+
];
|
|
140
|
+
if (d.newlyPassing.length > 0) {
|
|
141
|
+
lines.push(`### Fixed by your change (${d.newlyPassing.length})`);
|
|
142
|
+
for (const t of d.newlyPassing)
|
|
143
|
+
lines.push(`- ${t}`);
|
|
144
|
+
lines.push(``);
|
|
145
|
+
}
|
|
146
|
+
if (d.newlyFailing.length > 0) {
|
|
147
|
+
lines.push(`### Newly failing: these are yours (${d.newlyFailing.length})`);
|
|
148
|
+
for (const t of d.newlyFailing)
|
|
149
|
+
lines.push(`- ${t}`);
|
|
150
|
+
lines.push(``);
|
|
151
|
+
}
|
|
152
|
+
if (d.stillFailing.length > 0) {
|
|
153
|
+
lines.push(`### Still failing: pre-existing, not yours (${d.stillFailing.length})`);
|
|
154
|
+
for (const t of d.stillFailing)
|
|
155
|
+
lines.push(`- ${t}`);
|
|
156
|
+
lines.push(``);
|
|
157
|
+
}
|
|
158
|
+
if (d.newlyPassing.length === 0 && d.newlyFailing.length === 0 && d.stillFailing.length === 0) {
|
|
159
|
+
lines.push(`No failing tests on either side; nothing to report.`);
|
|
160
|
+
}
|
|
161
|
+
return lines.join("\n");
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Run the red-green comparison. All failure paths are explicit: this
|
|
165
|
+
* function would rather say "unverifiable" with a reason than report a
|
|
166
|
+
* delta it cannot defend.
|
|
167
|
+
*/
|
|
168
|
+
export function verifyRepo(dir, opts = {}) {
|
|
169
|
+
const timeoutMs = (opts.timeoutSecs ?? 600) * 1000;
|
|
170
|
+
if (!isGitRepo(dir)) {
|
|
171
|
+
return { ok: false, outcome: "unverifiable", reason: `${dir} is not a git repository`, markdown: "" };
|
|
172
|
+
}
|
|
173
|
+
if (!opts.allowDirty && !isTreeClean(dir)) {
|
|
174
|
+
return {
|
|
175
|
+
ok: false,
|
|
176
|
+
outcome: "unverifiable",
|
|
177
|
+
reason: "working tree has uncommitted changes; commit or stash first, or re-run with --allow-dirty (the head run will then include your uncommitted changes)",
|
|
178
|
+
markdown: "",
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const base = opts.base ?? defaultBase(dir);
|
|
182
|
+
if (!base) {
|
|
183
|
+
return {
|
|
184
|
+
ok: false,
|
|
185
|
+
outcome: "unverifiable",
|
|
186
|
+
reason: "could not determine a base ref (no upstream tracking branch, no local origin/main); pass --base <ref>",
|
|
187
|
+
markdown: "",
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const command = opts.cmd ?? detectTestCommand(dir);
|
|
191
|
+
if (!command) {
|
|
192
|
+
return {
|
|
193
|
+
ok: false,
|
|
194
|
+
outcome: "unverifiable",
|
|
195
|
+
reason: "no test command detected (checked package.json scripts.test, pytest, go, cargo); pass --cmd \"<test command>\"",
|
|
196
|
+
markdown: "",
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const parser = opts.parser
|
|
200
|
+
? (RUNNER_PARSERS.find((p) => p.name === opts.parser) ?? null)
|
|
201
|
+
: parserForCommand(command);
|
|
202
|
+
if (!parser) {
|
|
203
|
+
return {
|
|
204
|
+
ok: false,
|
|
205
|
+
outcome: "unverifiable",
|
|
206
|
+
reason: `no output parser claims "${command}" (parsers: ${["node:test", "pytest"].join(", ")}); pass --cmd with a supported runner`,
|
|
207
|
+
markdown: "",
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
// Base runs in a detached temp worktree so the working tree is never
|
|
211
|
+
// touched. Removed afterwards even on failure.
|
|
212
|
+
const baseDir = mkdtempSync(join(tmpdir(), "greenlight-verify-base-"));
|
|
213
|
+
try {
|
|
214
|
+
try {
|
|
215
|
+
sh(dir, ["worktree", "add", "--detach", baseDir, base]);
|
|
216
|
+
}
|
|
217
|
+
catch (err) {
|
|
218
|
+
return { ok: false, outcome: "unverifiable", reason: `could not create base worktree: ${err instanceof Error ? err.message : String(err)}`, markdown: "" };
|
|
219
|
+
}
|
|
220
|
+
const baseRun = runCommand(baseDir, command, timeoutMs);
|
|
221
|
+
const headRun = runCommand(dir, command, timeoutMs);
|
|
222
|
+
for (const [name, run] of [["base", baseRun], ["head", headRun]]) {
|
|
223
|
+
if (run.spawnFailed) {
|
|
224
|
+
return { ok: false, outcome: "unverifiable", reason: `could not run the test command on ${name}: ${run.output || "spawn failed"}`, markdown: "" };
|
|
225
|
+
}
|
|
226
|
+
if (run.timedOut) {
|
|
227
|
+
return { ok: false, outcome: "unverifiable", reason: `test command timed out on ${name} after ${opts.timeoutSecs ?? 600}s`, markdown: "" };
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const baseParsed = parser.parse(baseRun.output);
|
|
231
|
+
const headParsed = parser.parse(headRun.output);
|
|
232
|
+
if (baseParsed.passed.length + baseParsed.failed.length === 0 || headParsed.passed.length + headParsed.failed.length === 0) {
|
|
233
|
+
return {
|
|
234
|
+
ok: false,
|
|
235
|
+
outcome: "unverifiable",
|
|
236
|
+
reason: `parsed zero tests from the ${parser.name} output (base: ${baseParsed.passed.length + baseParsed.failed.length}, head: ${headParsed.passed.length + headParsed.failed.length}); the parser may not understand this runner's output format`,
|
|
237
|
+
markdown: "",
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
const delta = deltaOf(baseParsed.failed, headParsed.failed);
|
|
241
|
+
delta.baseTotal = { passed: baseParsed.passed.length, failed: baseParsed.failed.length };
|
|
242
|
+
delta.headTotal = { passed: headParsed.passed.length, failed: headParsed.failed.length };
|
|
243
|
+
const outcome = delta.newlyFailing.length > 0
|
|
244
|
+
? "broke"
|
|
245
|
+
: delta.newlyPassing.length > 0
|
|
246
|
+
? "fixed"
|
|
247
|
+
: delta.stillFailing.length > 0
|
|
248
|
+
? "no-change"
|
|
249
|
+
: "clean";
|
|
250
|
+
const result = {
|
|
251
|
+
ok: true,
|
|
252
|
+
outcome,
|
|
253
|
+
command,
|
|
254
|
+
parser: parser.name,
|
|
255
|
+
base,
|
|
256
|
+
delta,
|
|
257
|
+
markdown: "",
|
|
258
|
+
};
|
|
259
|
+
result.markdown = renderVerifyMarkdown(result);
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
finally {
|
|
263
|
+
try {
|
|
264
|
+
sh(dir, ["worktree", "remove", "--force", baseDir]);
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
try {
|
|
268
|
+
rmSync(baseDir, { recursive: true, force: true });
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
// best effort; a stale worktree dir is cleaned by git gc
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAyB,MAAM,qBAAqB,CAAC;AAoC9F,SAAS,EAAE,CAAC,GAAW,EAAE,IAAc;IACrC,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1E,CAAC;AAED,SAAS,SAAS,CAAC,GAAW;IAC5B,IAAI,CAAC;QACH,EAAE,C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,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;gBAC7B,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;oBAC7B,CAAC,CAAC,WAAW;oBACb,CAAC,CAAC,OAAO,CAAC;QAClB,MAAM,MAAM,GAAiB;YAC3B,EAAE,EAAE,IAAI;YACR,OAAO;YACP,OAAO;YACP,MAAM,EAAE,MAAM,CAAC,IAAI;YACnB,IAAI;YACJ,KAAK;YACL,QAAQ,EAAE,EAAE;SACb,CAAC;QACF,MAAM,CAAC,QAAQ,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC;IAChB,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;QACtD,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC;gBACH,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACpD,CAAC;YAAC,MAAM,CAAC;gBACP,yDAAyD;YAC3D,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/integrations/README.md
CHANGED
|
@@ -29,7 +29,7 @@ without it the tools still work but share the small anonymous budget.
|
|
|
29
29
|
## Verify it worked
|
|
30
30
|
|
|
31
31
|
Ask the agent: "list your MCP tools." You should see the `greenlight`
|
|
32
|
-
server with all
|
|
32
|
+
server with all 13 tools:
|
|
33
33
|
|
|
34
34
|
- `check_issue` — verdict on whether an issue is landable (GO / RISKY / TAKEN / GATED / STALE)
|
|
35
35
|
- `scan_repo` — find starter issues worth working in a repo
|
|
@@ -41,6 +41,9 @@ server with all 10 tools:
|
|
|
41
41
|
- `review_triage` — classify review findings and draft replies (never posts)
|
|
42
42
|
- `guard_pr` — maintainer-side: competing fix, prior claims, missing artifacts, first-time contributor (never posts)
|
|
43
43
|
- `repo_digest` — repo-level maintainer report: PR races with first-claim arbitration, claimed-by-other conflicts, stale claims, assignment-gate conflicts (never posts)
|
|
44
|
+
- `claim_status` — Claim Protocol pre-flight for one issue: who holds it, until when, who is queued, competing PRs, gates, whether the repo honors the protocol
|
|
45
|
+
- `preflight` — the one-call answer: claim_status plus the repo friction summary
|
|
46
|
+
- `verify_comment` — draft the verified-finding comment for maintainer-only repos (draft only, never posts)
|
|
44
47
|
|
|
45
48
|
## Format notes
|
|
46
49
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# Greenlight rules for Claude Code
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Drop-in rules for the Greenlight workflow through the greenlight MCP tools.
|
|
4
|
+
Installed by `greenlight init --agent claude-code`, or paste manually into
|
|
5
|
+
your project's CLAUDE.md (or keep the file and reference it from CLAUDE.md).
|
|
6
6
|
|
|
7
7
|
## Greenlight: check before you open a PR
|
|
8
8
|
|
|
9
9
|
You have the Greenlight MCP server connected (server name: greenlight,
|
|
10
|
-
|
|
11
|
-
open_pr, ci_triage, review_triage
|
|
10
|
+
12 tools: check_issue, scan_repo, repo_friction, claim_issue, prep_issue,
|
|
11
|
+
open_pr, ci_triage, review_triage, guard_pr, repo_digest, claim_status,
|
|
12
|
+
preflight). It answers one question at every step:
|
|
12
13
|
is this contribution worth doing, and is the problem mine?
|
|
13
14
|
|
|
14
15
|
Rules:
|
|
@@ -7,7 +7,7 @@ file form is:
|
|
|
7
7
|
|
|
8
8
|
Copy the `cline_mcp_settings.json` file in this folder there (merging with
|
|
9
9
|
any servers you already have), then check the Cline "MCP Servers" panel:
|
|
10
|
-
the `greenlight` server should list
|
|
10
|
+
the `greenlight` server should list 12 tools. The `disabled: false` field is
|
|
11
11
|
Cline's way of keeping the server enabled without deleting it.
|
|
12
12
|
|
|
13
13
|
Workflow: see the integrations README — your agent checks Greenlight
|