@robhowley/pi-structured-return 1.9.0 → 1.10.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 +2 -1
- package/extensions/structured-return/config/project-config.ts +10 -0
- package/extensions/structured-return/config/registry.ts +306 -0
- package/extensions/structured-return/examples/.pi/machine-readable.json +18 -0
- package/extensions/structured-return/examples/.pi/parsers/foo-cli.ts +25 -0
- package/extensions/structured-return/{src/index.ts → index.ts} +94 -69
- package/extensions/structured-return/{src/parsers → parsers}/ava-text.ts +23 -15
- package/extensions/structured-return/{src/parsers → parsers}/bandit-json.ts +17 -15
- package/extensions/structured-return/{src/parsers → parsers}/black-text.ts +18 -18
- package/extensions/structured-return/{src/parsers → parsers}/cargo-build.ts +19 -14
- package/extensions/structured-return/{src/parsers → parsers}/cargo-test.ts +20 -19
- package/extensions/structured-return/parsers/checkstyle-xml.ts +183 -0
- package/extensions/structured-return/{src/parsers → parsers}/clang-text.ts +15 -13
- package/extensions/structured-return/{src/parsers → parsers}/dbt-json.ts +28 -23
- package/extensions/structured-return/{src/parsers → parsers}/dotnet-build-text.ts +10 -8
- package/extensions/structured-return/{src/parsers → parsers}/eslint-json.ts +15 -9
- package/extensions/structured-return/{src/parsers → parsers}/go-test-json.ts +23 -21
- package/extensions/structured-return/{src/parsers → parsers}/hadolint-json.ts +18 -12
- package/extensions/structured-return/{src/parsers → parsers}/htmlhint-json.ts +15 -13
- package/extensions/structured-return/{src/parsers → parsers}/isort-text.ts +18 -18
- package/extensions/structured-return/{src/parsers → parsers}/javac-text.ts +14 -12
- package/extensions/structured-return/{src/parsers → parsers}/jsonlint-text.ts +16 -14
- package/extensions/structured-return/{src/parsers → parsers}/junit-xml.ts +61 -43
- package/extensions/structured-return/{src/parsers → parsers}/markdownlint-json.ts +19 -17
- package/extensions/structured-return/{src/parsers → parsers}/minitest-text.ts +24 -15
- package/extensions/structured-return/{src/parsers → parsers}/mocha-json.ts +17 -10
- package/extensions/structured-return/{src/parsers → parsers}/mypy-json.ts +16 -16
- package/extensions/structured-return/{src/parsers → parsers}/node-test-text.ts +17 -14
- package/extensions/structured-return/{src/parsers → parsers}/npm-audit-json.ts +19 -16
- package/extensions/structured-return/{src/parsers → parsers}/prettier-text.ts +21 -17
- package/extensions/structured-return/{src/parsers → parsers}/pylint-json.ts +17 -17
- package/extensions/structured-return/{src/parsers → parsers}/pyright-json.ts +20 -18
- package/extensions/structured-return/{src/parsers → parsers}/rspec-json.ts +14 -14
- package/extensions/structured-return/{src/parsers → parsers}/rubocop-json.ts +22 -11
- package/extensions/structured-return/{src/parsers → parsers}/ruff-json.ts +7 -7
- package/extensions/structured-return/{src/parsers → parsers}/shellcheck-json.ts +14 -14
- package/extensions/structured-return/{src/parsers → parsers}/stylelint-json.ts +21 -13
- package/extensions/structured-return/{src/parsers → parsers}/swiftc-text.ts +16 -10
- package/extensions/structured-return/parsers/tail-fallback.ts +20 -0
- package/extensions/structured-return/{src/parsers → parsers}/tidy-text.ts +13 -13
- package/extensions/structured-return/{src/parsers → parsers}/tsc-text.ts +11 -11
- package/extensions/structured-return/{src/parsers → parsers}/unittest-text.ts +24 -14
- package/extensions/structured-return/{src/parsers → parsers}/utils.ts +9 -6
- package/extensions/structured-return/{src/parsers → parsers}/vale-json.ts +18 -18
- package/extensions/structured-return/{src/parsers → parsers}/vitest-json.ts +14 -14
- package/extensions/structured-return/{src/storage → storage}/log-store.ts +5 -5
- package/extensions/structured-return/{src/storage → storage}/session-stats.ts +11 -11
- package/extensions/structured-return/{src/types.ts → types.ts} +4 -2
- package/package.json +27 -43
- package/skills/structured-return/SKILL.md +7 -0
- package/LICENSE +0 -21
- package/extensions/structured-return/src/config/project-config.ts +0 -10
- package/extensions/structured-return/src/config/registry.test.ts +0 -171
- package/extensions/structured-return/src/config/registry.ts +0 -282
- package/extensions/structured-return/src/index.test.ts +0 -220
- package/extensions/structured-return/src/parsers/ava-text.test.ts +0 -116
- package/extensions/structured-return/src/parsers/bandit-json.test.ts +0 -90
- package/extensions/structured-return/src/parsers/black-text.test.ts +0 -67
- package/extensions/structured-return/src/parsers/cargo-build.test.ts +0 -170
- package/extensions/structured-return/src/parsers/cargo-test.test.ts +0 -191
- package/extensions/structured-return/src/parsers/clang-text.test.ts +0 -61
- package/extensions/structured-return/src/parsers/dbt-json.test.ts +0 -172
- package/extensions/structured-return/src/parsers/dotnet-build-text.test.ts +0 -85
- package/extensions/structured-return/src/parsers/eslint-json.test.ts +0 -60
- package/extensions/structured-return/src/parsers/go-test-json.test.ts +0 -119
- package/extensions/structured-return/src/parsers/hadolint-json.test.ts +0 -73
- package/extensions/structured-return/src/parsers/htmlhint-json.test.ts +0 -72
- package/extensions/structured-return/src/parsers/isort-text.test.ts +0 -58
- package/extensions/structured-return/src/parsers/javac-text.test.ts +0 -75
- package/extensions/structured-return/src/parsers/jsonlint-text.test.ts +0 -52
- package/extensions/structured-return/src/parsers/junit-xml.test.ts +0 -627
- package/extensions/structured-return/src/parsers/markdownlint-json.test.ts +0 -76
- package/extensions/structured-return/src/parsers/minitest-text.test.ts +0 -110
- package/extensions/structured-return/src/parsers/mocha-json.test.ts +0 -108
- package/extensions/structured-return/src/parsers/mypy-json.test.ts +0 -101
- package/extensions/structured-return/src/parsers/node-test-text.test.ts +0 -117
- package/extensions/structured-return/src/parsers/npm-audit-json.test.ts +0 -83
- package/extensions/structured-return/src/parsers/prettier-text.test.ts +0 -76
- package/extensions/structured-return/src/parsers/pylint-json.test.ts +0 -120
- package/extensions/structured-return/src/parsers/pyright-json.test.ts +0 -112
- package/extensions/structured-return/src/parsers/rspec-json.test.ts +0 -126
- package/extensions/structured-return/src/parsers/rubocop-json.test.ts +0 -118
- package/extensions/structured-return/src/parsers/ruff-json.test.ts +0 -57
- package/extensions/structured-return/src/parsers/shellcheck-json.test.ts +0 -110
- package/extensions/structured-return/src/parsers/stylelint-json.test.ts +0 -120
- package/extensions/structured-return/src/parsers/swiftc-text.test.ts +0 -73
- package/extensions/structured-return/src/parsers/tail-fallback.test.ts +0 -41
- package/extensions/structured-return/src/parsers/tail-fallback.ts +0 -20
- package/extensions/structured-return/src/parsers/tidy-text.test.ts +0 -74
- package/extensions/structured-return/src/parsers/tsc-text.test.ts +0 -81
- package/extensions/structured-return/src/parsers/unittest-text.test.ts +0 -126
- package/extensions/structured-return/src/parsers/vale-json.test.ts +0 -84
- package/extensions/structured-return/src/parsers/vitest-json.test.ts +0 -118
- package/extensions/structured-return/src/storage/session-stats.test.ts +0 -156
- package/extensions/structured-return/tsconfig.json +0 -11
- package/extensions/structured-return/vitest.config.ts +0 -9
- /package/extensions/structured-return/{src/ui → ui}/widget.ts +0 -0
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule, ParsedFailure } from
|
|
3
|
-
import { safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
+
import { safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Parses minitest's default text output. No flags or reporters required —
|
|
7
7
|
* works with plain `ruby test/my_test.rb` or `bundle exec ruby test/my_test.rb`.
|
|
8
8
|
*/
|
|
9
9
|
const parser: ParserModule = {
|
|
10
|
-
id:
|
|
10
|
+
id: 'minitest-text',
|
|
11
11
|
async parse(ctx) {
|
|
12
12
|
const output = safeReadFile(ctx.stdoutPath);
|
|
13
13
|
|
|
14
14
|
// "3 runs, 2 assertions, 1 failures, 1 errors, 0 skips"
|
|
15
|
-
const summaryMatch = output.match(
|
|
15
|
+
const summaryMatch = output.match(
|
|
16
|
+
/(\d+) runs?, \d+ assertions?, (\d+) failures?, (\d+) errors?, (\d+) skips?/,
|
|
17
|
+
);
|
|
16
18
|
if (!summaryMatch) {
|
|
17
|
-
return {
|
|
19
|
+
return {
|
|
20
|
+
tool: 'minitest',
|
|
21
|
+
status: 'error',
|
|
22
|
+
summary: 'no minitest output found',
|
|
23
|
+
logPath: ctx.logPath,
|
|
24
|
+
};
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
const totalRuns = parseInt(summaryMatch[1], 10);
|
|
@@ -27,8 +34,8 @@ const parser: ParserModule = {
|
|
|
27
34
|
const failures = parseBlocks(output, ctx.cwd);
|
|
28
35
|
|
|
29
36
|
return {
|
|
30
|
-
tool:
|
|
31
|
-
status: totalFailed > 0 ?
|
|
37
|
+
tool: 'minitest',
|
|
38
|
+
status: totalFailed > 0 ? 'fail' : 'pass',
|
|
32
39
|
summary: totalFailed > 0 ? `${totalFailed} failed, ${passed} passed` : `${passed} passed`,
|
|
33
40
|
failures,
|
|
34
41
|
logPath: ctx.logPath,
|
|
@@ -40,7 +47,7 @@ export default parser;
|
|
|
40
47
|
|
|
41
48
|
function parseBlocks(output: string, cwd: string): ParsedFailure[] {
|
|
42
49
|
const failures: ParsedFailure[] = [];
|
|
43
|
-
const lines = output.split(
|
|
50
|
+
const lines = output.split('\n');
|
|
44
51
|
let i = 0;
|
|
45
52
|
|
|
46
53
|
while (i < lines.length) {
|
|
@@ -53,7 +60,7 @@ function parseBlocks(output: string, cwd: string): ParsedFailure[] {
|
|
|
53
60
|
const type = headerMatch[1];
|
|
54
61
|
i++;
|
|
55
62
|
|
|
56
|
-
if (type ===
|
|
63
|
+
if (type === 'Failure') {
|
|
57
64
|
// "ClassName#method [file:line]:"
|
|
58
65
|
const nameMatch = lines[i]?.match(/^(.+?)\s+\[(.+):(\d+)\]:$/);
|
|
59
66
|
if (nameMatch) {
|
|
@@ -61,7 +68,7 @@ function parseBlocks(output: string, cwd: string): ParsedFailure[] {
|
|
|
61
68
|
i++;
|
|
62
69
|
// Message lines until blank line
|
|
63
70
|
const msgLines: string[] = [];
|
|
64
|
-
while (i < lines.length && lines[i].trim() !==
|
|
71
|
+
while (i < lines.length && lines[i].trim() !== '') {
|
|
65
72
|
msgLines.push(lines[i].trim());
|
|
66
73
|
i++;
|
|
67
74
|
}
|
|
@@ -69,7 +76,7 @@ function parseBlocks(output: string, cwd: string): ParsedFailure[] {
|
|
|
69
76
|
id,
|
|
70
77
|
file: path.relative(cwd, path.resolve(cwd, rawFile)),
|
|
71
78
|
line: parseInt(lineStr, 10),
|
|
72
|
-
message: msgLines.filter(Boolean).join(
|
|
79
|
+
message: msgLines.filter(Boolean).join(' / ') || undefined,
|
|
73
80
|
});
|
|
74
81
|
}
|
|
75
82
|
} else {
|
|
@@ -79,15 +86,17 @@ function parseBlocks(output: string, cwd: string): ParsedFailure[] {
|
|
|
79
86
|
const id = nameMatch[1];
|
|
80
87
|
i++;
|
|
81
88
|
// "ExceptionClass: message"
|
|
82
|
-
const exceptionLine = lines[i]?.trim() ??
|
|
83
|
-
const colonIdx = exceptionLine.indexOf(
|
|
89
|
+
const exceptionLine = lines[i]?.trim() ?? '';
|
|
90
|
+
const colonIdx = exceptionLine.indexOf(': ');
|
|
84
91
|
const message = colonIdx !== -1 ? exceptionLine.slice(colonIdx + 2) : exceptionLine;
|
|
85
92
|
i++;
|
|
86
93
|
// First backtrace line: " file.rb:line:in 'method'"
|
|
87
94
|
const backtraceMatch = lines[i]?.match(/^\s+(.+\.rb):(\d+):/);
|
|
88
95
|
failures.push({
|
|
89
96
|
id,
|
|
90
|
-
file: backtraceMatch
|
|
97
|
+
file: backtraceMatch
|
|
98
|
+
? path.relative(cwd, path.resolve(cwd, backtraceMatch[1]))
|
|
99
|
+
: undefined,
|
|
91
100
|
line: backtraceMatch ? parseInt(backtraceMatch[2], 10) : undefined,
|
|
92
101
|
message: message || undefined,
|
|
93
102
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule, ParsedFailure } from
|
|
3
|
-
import { extractJsStackLocation, safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
+
import { extractJsStackLocation, safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
interface MochaErr {
|
|
6
6
|
message?: string;
|
|
@@ -30,28 +30,35 @@ function buildMessage(err: MochaErr): string {
|
|
|
30
30
|
return `expected ${err.expected}, got ${err.actual}`;
|
|
31
31
|
}
|
|
32
32
|
// First line of message, stripped of newlines
|
|
33
|
-
const firstLine = (err.message ??
|
|
33
|
+
const firstLine = (err.message ?? 'test failed').split('\n')[0].trim();
|
|
34
34
|
return firstLine;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const parser: ParserModule = {
|
|
38
|
-
id:
|
|
38
|
+
id: 'mocha-json',
|
|
39
39
|
async parse(ctx) {
|
|
40
40
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
41
41
|
if (!stdout) {
|
|
42
|
-
return { tool:
|
|
42
|
+
return { tool: 'mocha', status: 'error', summary: 'no output', logPath: ctx.logPath };
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
let report: MochaReport;
|
|
46
46
|
try {
|
|
47
47
|
report = JSON.parse(stdout) as MochaReport;
|
|
48
48
|
} catch {
|
|
49
|
-
return {
|
|
49
|
+
return {
|
|
50
|
+
tool: 'mocha',
|
|
51
|
+
status: 'error',
|
|
52
|
+
summary: 'failed to parse mocha JSON output',
|
|
53
|
+
logPath: ctx.logPath,
|
|
54
|
+
};
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
const failures: ParsedFailure[] = report.failures.map((test) => {
|
|
53
58
|
const loc = extractJsStackLocation(test.err.stack);
|
|
54
|
-
const relFile = loc.file
|
|
59
|
+
const relFile = loc.file
|
|
60
|
+
? path.relative(ctx.cwd, path.resolve(ctx.cwd, loc.file))
|
|
61
|
+
: undefined;
|
|
55
62
|
return {
|
|
56
63
|
id: test.fullTitle,
|
|
57
64
|
file: relFile,
|
|
@@ -65,8 +72,8 @@ const parser: ParserModule = {
|
|
|
65
72
|
const passed = report.stats.passes;
|
|
66
73
|
|
|
67
74
|
return {
|
|
68
|
-
tool:
|
|
69
|
-
status: failed > 0 ?
|
|
75
|
+
tool: 'mocha',
|
|
76
|
+
status: failed > 0 ? 'fail' : 'pass',
|
|
70
77
|
summary: failed > 0 ? `${failed} failed, ${passed} passed` : `${passed} passed`,
|
|
71
78
|
failures,
|
|
72
79
|
logPath: ctx.logPath,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule, ParsedFailure } from
|
|
3
|
-
import { safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
+
import { safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
interface MypyItem {
|
|
6
6
|
file: string;
|
|
@@ -9,26 +9,26 @@ interface MypyItem {
|
|
|
9
9
|
message: string;
|
|
10
10
|
hint: string | null;
|
|
11
11
|
code: string | null;
|
|
12
|
-
severity:
|
|
12
|
+
severity: 'error' | 'note';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const parser: ParserModule = {
|
|
16
|
-
id:
|
|
16
|
+
id: 'mypy-json',
|
|
17
17
|
async parse(ctx) {
|
|
18
18
|
// mypy --output json writes JSON diagnostics to stderr (stdout gets the human summary).
|
|
19
19
|
const stderr = safeReadFile(ctx.stderrPath).trim();
|
|
20
20
|
if (!stderr) {
|
|
21
21
|
return {
|
|
22
|
-
tool:
|
|
23
|
-
status:
|
|
24
|
-
summary:
|
|
22
|
+
tool: 'mypy',
|
|
23
|
+
status: 'pass',
|
|
24
|
+
summary: 'no type errors',
|
|
25
25
|
failures: [],
|
|
26
26
|
logPath: ctx.logPath,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const items: MypyItem[] = [];
|
|
31
|
-
for (const line of stderr.split(
|
|
31
|
+
for (const line of stderr.split('\n')) {
|
|
32
32
|
const trimmed = line.trim();
|
|
33
33
|
if (!trimmed) continue;
|
|
34
34
|
try {
|
|
@@ -38,13 +38,13 @@ const parser: ParserModule = {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const errors = items.filter((item) => item.severity ===
|
|
41
|
+
const errors = items.filter((item) => item.severity === 'error');
|
|
42
42
|
// Build a map of notes keyed by normalized relative path:line so lookups
|
|
43
43
|
// match regardless of whether mypy emits absolute or relative paths.
|
|
44
44
|
const relPathOf = (f: string) => (path.isAbsolute(f) ? path.relative(ctx.cwd, f) : f);
|
|
45
45
|
const notesByLocation = new Map<string, string[]>();
|
|
46
46
|
for (const item of items) {
|
|
47
|
-
if (item.severity ===
|
|
47
|
+
if (item.severity === 'note') {
|
|
48
48
|
const key = `${relPathOf(item.file)}:${item.line}`;
|
|
49
49
|
const notes = notesByLocation.get(key) ?? [];
|
|
50
50
|
notes.push(item.message);
|
|
@@ -56,10 +56,10 @@ const parser: ParserModule = {
|
|
|
56
56
|
const relPath = relPathOf(item.file);
|
|
57
57
|
const key = `${relPath}:${item.line}`;
|
|
58
58
|
const notes = notesByLocation.get(key);
|
|
59
|
-
const hint = item.hint ?? (notes ? notes.join(
|
|
59
|
+
const hint = item.hint ?? (notes ? notes.join('; ') : undefined);
|
|
60
60
|
const message = hint ? `${item.message} (${hint})` : item.message;
|
|
61
61
|
return {
|
|
62
|
-
id: `${relPath}:${item.line}:${item.code ??
|
|
62
|
+
id: `${relPath}:${item.line}:${item.code ?? 'error'}`,
|
|
63
63
|
file: relPath,
|
|
64
64
|
line: item.line,
|
|
65
65
|
message,
|
|
@@ -68,9 +68,9 @@ const parser: ParserModule = {
|
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
return {
|
|
71
|
-
tool:
|
|
72
|
-
status: failures.length > 0 ?
|
|
73
|
-
summary: failures.length > 0 ? `${failures.length} type errors` :
|
|
71
|
+
tool: 'mypy',
|
|
72
|
+
status: failures.length > 0 ? 'fail' : 'pass',
|
|
73
|
+
summary: failures.length > 0 ? `${failures.length} type errors` : 'no type errors',
|
|
74
74
|
failures,
|
|
75
75
|
logPath: ctx.logPath,
|
|
76
76
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule, ParsedFailure } from
|
|
3
|
-
import { safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
+
import { safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
// Summary lines: ℹ pass 1, ℹ fail 2
|
|
6
6
|
const SUMMARY_PASS = /^ℹ pass (\d+)/m;
|
|
@@ -10,14 +10,14 @@ const SUMMARY_FAIL = /^ℹ fail (\d+)/m;
|
|
|
10
10
|
const TEST_AT_LINE = /^test at (.+?):(\d+):\d+/;
|
|
11
11
|
|
|
12
12
|
const parser: ParserModule = {
|
|
13
|
-
id:
|
|
13
|
+
id: 'node-test-text',
|
|
14
14
|
async parse(ctx) {
|
|
15
15
|
const combined = safeReadFile(ctx.stdoutPath) + safeReadFile(ctx.stderrPath);
|
|
16
16
|
if (!combined.trim()) {
|
|
17
17
|
return {
|
|
18
|
-
tool:
|
|
19
|
-
status:
|
|
20
|
-
summary:
|
|
18
|
+
tool: 'node:test',
|
|
19
|
+
status: 'pass',
|
|
20
|
+
summary: 'no tests found',
|
|
21
21
|
failures: [],
|
|
22
22
|
logPath: ctx.logPath,
|
|
23
23
|
};
|
|
@@ -29,7 +29,7 @@ const parser: ParserModule = {
|
|
|
29
29
|
const failed = failMatch ? parseInt(failMatch[1], 10) : 0;
|
|
30
30
|
|
|
31
31
|
// Parse the "failing tests:" section
|
|
32
|
-
const failingSection = combined.split(
|
|
32
|
+
const failingSection = combined.split('✖ failing tests:')[1] ?? '';
|
|
33
33
|
const failures: ParsedFailure[] = [];
|
|
34
34
|
|
|
35
35
|
if (failingSection) {
|
|
@@ -47,12 +47,14 @@ const parser: ParserModule = {
|
|
|
47
47
|
line = parseInt(atMatch[2], 10);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const name = nameMatch ? nameMatch[1] :
|
|
50
|
+
const name = nameMatch ? nameMatch[1] : 'unknown test';
|
|
51
51
|
|
|
52
52
|
// Extract meaningful error message — try specific patterns first, then generic
|
|
53
53
|
let message = name;
|
|
54
54
|
const strictMatch = block.match(/Expected values to be strictly equal:\s*\n\s*\n\s*(.+)/);
|
|
55
|
-
const falsyMatch = block.match(
|
|
55
|
+
const falsyMatch = block.match(
|
|
56
|
+
/The expression evaluated to a falsy value:\s*\n\s*\n\s*(.+)/,
|
|
57
|
+
);
|
|
56
58
|
if (strictMatch) {
|
|
57
59
|
message = `Expected values to be strictly equal: ${strictMatch[1].trim()}`;
|
|
58
60
|
} else if (falsyMatch) {
|
|
@@ -60,7 +62,8 @@ const parser: ParserModule = {
|
|
|
60
62
|
} else {
|
|
61
63
|
// Match any Error type (AssertionError, TypeError, ReferenceError, etc.)
|
|
62
64
|
const errorMatch = block.match(/^\s+(\w*Error\b.*?)$/m);
|
|
63
|
-
if (errorMatch)
|
|
65
|
+
if (errorMatch)
|
|
66
|
+
message = errorMatch[1].replace(/\s*\[ERR_\w+\]:\s*/, ': ').replace(/^\w+Error: /, '');
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
failures.push({
|
|
@@ -75,11 +78,11 @@ const parser: ParserModule = {
|
|
|
75
78
|
const parts: string[] = [];
|
|
76
79
|
if (failed > 0) parts.push(`${failed} failed`);
|
|
77
80
|
if (passed > 0) parts.push(`${passed} passed`);
|
|
78
|
-
const summary = parts.join(
|
|
81
|
+
const summary = parts.join(', ') || 'tests completed';
|
|
79
82
|
|
|
80
83
|
return {
|
|
81
|
-
tool:
|
|
82
|
-
status: failed > 0 ?
|
|
84
|
+
tool: 'node:test',
|
|
85
|
+
status: failed > 0 ? 'fail' : 'pass',
|
|
83
86
|
summary,
|
|
84
87
|
failures,
|
|
85
88
|
logPath: ctx.logPath,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ParserModule, ParsedFailure } from
|
|
2
|
-
import { safeReadFile } from
|
|
1
|
+
import type { ParserModule, ParsedFailure } from '../types';
|
|
2
|
+
import { safeReadFile } from './utils';
|
|
3
3
|
|
|
4
4
|
interface NpmAuditVia {
|
|
5
5
|
title?: string;
|
|
@@ -24,14 +24,14 @@ interface NpmAuditReport {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const parser: ParserModule = {
|
|
27
|
-
id:
|
|
27
|
+
id: 'npm-audit-json',
|
|
28
28
|
async parse(ctx) {
|
|
29
29
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
30
30
|
if (!stdout) {
|
|
31
31
|
return {
|
|
32
|
-
tool:
|
|
33
|
-
status:
|
|
34
|
-
summary:
|
|
32
|
+
tool: 'npm audit',
|
|
33
|
+
status: 'pass',
|
|
34
|
+
summary: 'no vulnerabilities found',
|
|
35
35
|
failures: [],
|
|
36
36
|
logPath: ctx.logPath,
|
|
37
37
|
};
|
|
@@ -42,9 +42,9 @@ const parser: ParserModule = {
|
|
|
42
42
|
report = JSON.parse(stdout);
|
|
43
43
|
} catch {
|
|
44
44
|
return {
|
|
45
|
-
tool:
|
|
46
|
-
status:
|
|
47
|
-
summary:
|
|
45
|
+
tool: 'npm audit',
|
|
46
|
+
status: 'error',
|
|
47
|
+
summary: 'failed to parse npm audit JSON output',
|
|
48
48
|
logPath: ctx.logPath,
|
|
49
49
|
};
|
|
50
50
|
}
|
|
@@ -54,8 +54,11 @@ const parser: ParserModule = {
|
|
|
54
54
|
|
|
55
55
|
for (const [pkg, vuln] of Object.entries(vulns)) {
|
|
56
56
|
// Extract advisory titles from 'via' (skip string refs to other packages)
|
|
57
|
-
const titles = vuln.via
|
|
58
|
-
|
|
57
|
+
const titles = vuln.via
|
|
58
|
+
.filter((v): v is NpmAuditVia => typeof v !== 'string' && !!v.title)
|
|
59
|
+
.map((v) => v.title!);
|
|
60
|
+
const message =
|
|
61
|
+
titles.length > 0 ? titles.join('; ') : `${vuln.severity} severity vulnerability`;
|
|
59
62
|
failures.push({
|
|
60
63
|
id: pkg,
|
|
61
64
|
file: pkg,
|
|
@@ -66,18 +69,18 @@ const parser: ParserModule = {
|
|
|
66
69
|
|
|
67
70
|
// Build severity summary from metadata
|
|
68
71
|
const meta = report.metadata?.vulnerabilities ?? {};
|
|
69
|
-
const sevParts = [
|
|
72
|
+
const sevParts = ['critical', 'high', 'moderate', 'low', 'info']
|
|
70
73
|
.filter((s) => meta[s])
|
|
71
74
|
.map((s) => `${meta[s]} ${s}`);
|
|
72
75
|
const total = meta.total ?? failures.length;
|
|
73
76
|
const summary =
|
|
74
77
|
total > 0
|
|
75
|
-
? `${total} vulnerabilit${total !== 1 ?
|
|
76
|
-
:
|
|
78
|
+
? `${total} vulnerabilit${total !== 1 ? 'ies' : 'y'} (${sevParts.join(', ')})`
|
|
79
|
+
: 'no vulnerabilities found';
|
|
77
80
|
|
|
78
81
|
return {
|
|
79
|
-
tool:
|
|
80
|
-
status: total > 0 ?
|
|
82
|
+
tool: 'npm audit',
|
|
83
|
+
status: total > 0 ? 'fail' : 'pass',
|
|
81
84
|
summary,
|
|
82
85
|
failures,
|
|
83
86
|
logPath: ctx.logPath,
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule, ParsedFailure } from
|
|
3
|
-
import { safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
+
import { safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
// [warn] /path/to/file — but not summary lines like "[warn] Code style issues..."
|
|
6
6
|
const WARN_LINE = /^\[warn\] (.+)$/;
|
|
7
7
|
const SUMMARY_PREFIX = /^Code style issues|^Run Prettier/;
|
|
8
8
|
|
|
9
9
|
const parser: ParserModule = {
|
|
10
|
-
id:
|
|
10
|
+
id: 'prettier-text',
|
|
11
11
|
async parse(ctx) {
|
|
12
|
-
const combined = (safeReadFile(ctx.stdoutPath) +
|
|
12
|
+
const combined = (safeReadFile(ctx.stdoutPath) + '\n' + safeReadFile(ctx.stderrPath)).trim();
|
|
13
13
|
if (!combined) {
|
|
14
14
|
return {
|
|
15
|
-
tool:
|
|
16
|
-
status:
|
|
17
|
-
summary:
|
|
15
|
+
tool: 'prettier',
|
|
16
|
+
status: 'pass',
|
|
17
|
+
summary: 'all files formatted',
|
|
18
18
|
failures: [],
|
|
19
19
|
logPath: ctx.logPath,
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const lines = combined.split(
|
|
23
|
+
const lines = combined.split('\n');
|
|
24
24
|
const failures: ParsedFailure[] = [];
|
|
25
25
|
|
|
26
26
|
for (const line of lines) {
|
|
@@ -30,17 +30,17 @@ const parser: ParserModule = {
|
|
|
30
30
|
failures.push({
|
|
31
31
|
id: relPath,
|
|
32
32
|
file: relPath,
|
|
33
|
-
message:
|
|
33
|
+
message: 'needs formatting',
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// All done, no warnings
|
|
39
|
-
if (failures.length === 0 && combined.includes(
|
|
39
|
+
if (failures.length === 0 && combined.includes('All matched files use Prettier code style')) {
|
|
40
40
|
return {
|
|
41
|
-
tool:
|
|
42
|
-
status:
|
|
43
|
-
summary:
|
|
41
|
+
tool: 'prettier',
|
|
42
|
+
status: 'pass',
|
|
43
|
+
summary: 'all files formatted',
|
|
44
44
|
failures: [],
|
|
45
45
|
logPath: ctx.logPath,
|
|
46
46
|
};
|
|
@@ -48,11 +48,15 @@ const parser: ParserModule = {
|
|
|
48
48
|
|
|
49
49
|
const n = failures.length;
|
|
50
50
|
const summary =
|
|
51
|
-
n > 0
|
|
51
|
+
n > 0
|
|
52
|
+
? n === 1
|
|
53
|
+
? '1 file has formatting issues'
|
|
54
|
+
: `${n} files have formatting issues`
|
|
55
|
+
: 'all files formatted';
|
|
52
56
|
|
|
53
57
|
return {
|
|
54
|
-
tool:
|
|
55
|
-
status: n > 0 ?
|
|
58
|
+
tool: 'prettier',
|
|
59
|
+
status: n > 0 ? 'fail' : 'pass',
|
|
56
60
|
summary,
|
|
57
61
|
failures,
|
|
58
62
|
logPath: ctx.logPath,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule, ParsedFailure } from
|
|
3
|
-
import { safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
+
import { safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
interface PylintItem {
|
|
6
6
|
type: string;
|
|
@@ -11,18 +11,18 @@ interface PylintItem {
|
|
|
11
11
|
path: string;
|
|
12
12
|
symbol: string;
|
|
13
13
|
message: string;
|
|
14
|
-
|
|
14
|
+
'message-id': string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const parser: ParserModule = {
|
|
18
|
-
id:
|
|
18
|
+
id: 'pylint-json',
|
|
19
19
|
async parse(ctx) {
|
|
20
20
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
21
|
-
if (!stdout || stdout ===
|
|
21
|
+
if (!stdout || stdout === '[]') {
|
|
22
22
|
return {
|
|
23
|
-
tool:
|
|
24
|
-
status:
|
|
25
|
-
summary:
|
|
23
|
+
tool: 'pylint',
|
|
24
|
+
status: 'pass',
|
|
25
|
+
summary: 'no lint errors',
|
|
26
26
|
failures: [],
|
|
27
27
|
logPath: ctx.logPath,
|
|
28
28
|
};
|
|
@@ -33,9 +33,9 @@ const parser: ParserModule = {
|
|
|
33
33
|
items = JSON.parse(stdout) as PylintItem[];
|
|
34
34
|
} catch {
|
|
35
35
|
return {
|
|
36
|
-
tool:
|
|
37
|
-
status:
|
|
38
|
-
summary:
|
|
36
|
+
tool: 'pylint',
|
|
37
|
+
status: 'error',
|
|
38
|
+
summary: 'failed to parse pylint JSON output',
|
|
39
39
|
logPath: ctx.logPath,
|
|
40
40
|
};
|
|
41
41
|
}
|
|
@@ -43,18 +43,18 @@ const parser: ParserModule = {
|
|
|
43
43
|
const failures: ParsedFailure[] = items.map((item) => {
|
|
44
44
|
const relPath = path.isAbsolute(item.path) ? path.relative(ctx.cwd, item.path) : item.path;
|
|
45
45
|
return {
|
|
46
|
-
id: `${relPath}:${item.line}:${item[
|
|
46
|
+
id: `${relPath}:${item.line}:${item['message-id']}`,
|
|
47
47
|
file: relPath,
|
|
48
48
|
line: item.line,
|
|
49
49
|
message: item.message,
|
|
50
|
-
rule: `${item[
|
|
50
|
+
rule: `${item['message-id']}(${item.symbol})`,
|
|
51
51
|
};
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
return {
|
|
55
|
-
tool:
|
|
56
|
-
status: failures.length > 0 ?
|
|
57
|
-
summary: failures.length > 0 ? `${failures.length} lint errors` :
|
|
55
|
+
tool: 'pylint',
|
|
56
|
+
status: failures.length > 0 ? 'fail' : 'pass',
|
|
57
|
+
summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
|
|
58
58
|
failures,
|
|
59
59
|
logPath: ctx.logPath,
|
|
60
60
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule, ParsedFailure } from
|
|
3
|
-
import { safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
+
import { safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
interface PyrightDiagnostic {
|
|
6
6
|
file: string;
|
|
@@ -20,14 +20,14 @@ interface PyrightOutput {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const parser: ParserModule = {
|
|
23
|
-
id:
|
|
23
|
+
id: 'pyright-json',
|
|
24
24
|
async parse(ctx) {
|
|
25
25
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
26
26
|
if (!stdout) {
|
|
27
27
|
return {
|
|
28
|
-
tool:
|
|
29
|
-
status:
|
|
30
|
-
summary:
|
|
28
|
+
tool: 'pyright',
|
|
29
|
+
status: 'pass',
|
|
30
|
+
summary: 'no type errors',
|
|
31
31
|
failures: [],
|
|
32
32
|
logPath: ctx.logPath,
|
|
33
33
|
};
|
|
@@ -38,22 +38,22 @@ const parser: ParserModule = {
|
|
|
38
38
|
output = JSON.parse(stdout);
|
|
39
39
|
} catch {
|
|
40
40
|
return {
|
|
41
|
-
tool:
|
|
42
|
-
status:
|
|
43
|
-
summary:
|
|
41
|
+
tool: 'pyright',
|
|
42
|
+
status: 'error',
|
|
43
|
+
summary: 'failed to parse pyright JSON output',
|
|
44
44
|
logPath: ctx.logPath,
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const diagnostics = (output.generalDiagnostics ?? []).filter((d) => d.severity ===
|
|
48
|
+
const diagnostics = (output.generalDiagnostics ?? []).filter((d) => d.severity === 'error');
|
|
49
49
|
const failures: ParsedFailure[] = diagnostics.map((d) => {
|
|
50
50
|
const relPath = path.relative(ctx.cwd, d.file);
|
|
51
51
|
// pyright uses 0-based lines in JSON
|
|
52
52
|
const line = d.range ? d.range.start.line + 1 : undefined;
|
|
53
53
|
// Collapse multi-line messages (detail line after \n) into a single line
|
|
54
|
-
const message = d.message.split(
|
|
54
|
+
const message = d.message.split('\n')[0];
|
|
55
55
|
return {
|
|
56
|
-
id: `${relPath}:${line}:${d.rule ??
|
|
56
|
+
id: `${relPath}:${line}:${d.rule ?? 'error'}`,
|
|
57
57
|
file: relPath,
|
|
58
58
|
line,
|
|
59
59
|
message,
|
|
@@ -64,14 +64,16 @@ const parser: ParserModule = {
|
|
|
64
64
|
const summary = output.summary;
|
|
65
65
|
const parts: string[] = [];
|
|
66
66
|
if (summary) {
|
|
67
|
-
if (summary.errorCount)
|
|
68
|
-
|
|
67
|
+
if (summary.errorCount)
|
|
68
|
+
parts.push(`${summary.errorCount} error${summary.errorCount !== 1 ? 's' : ''}`);
|
|
69
|
+
if (summary.warningCount)
|
|
70
|
+
parts.push(`${summary.warningCount} warning${summary.warningCount !== 1 ? 's' : ''}`);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
return {
|
|
72
|
-
tool:
|
|
73
|
-
status: failures.length > 0 ?
|
|
74
|
-
summary: parts.length > 0 ? parts.join(
|
|
74
|
+
tool: 'pyright',
|
|
75
|
+
status: failures.length > 0 ? 'fail' : 'pass',
|
|
76
|
+
summary: parts.length > 0 ? parts.join(', ') : 'no type errors',
|
|
75
77
|
failures,
|
|
76
78
|
logPath: ctx.logPath,
|
|
77
79
|
};
|