@robhowley/pi-structured-return 1.10.0 → 2.0.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/LICENSE +21 -0
- package/README.md +33 -83
- package/extensions/structured-return/config/registry.ts +4 -30
- package/extensions/structured-return/index.ts +105 -76
- package/extensions/structured-return/native.ts +223 -0
- package/extensions/structured-return/parsers/ava-text.ts +2 -168
- package/extensions/structured-return/parsers/bandit-json.ts +2 -79
- package/extensions/structured-return/parsers/black-text.ts +2 -73
- package/extensions/structured-return/parsers/cargo-build.ts +2 -78
- package/extensions/structured-return/parsers/cargo-test.ts +2 -135
- package/extensions/structured-return/parsers/checkstyle-xml.ts +2 -182
- package/extensions/structured-return/parsers/clang-text.ts +2 -60
- package/extensions/structured-return/parsers/dbt-json.ts +2 -135
- package/extensions/structured-return/parsers/dotnet-build-text.ts +2 -49
- package/extensions/structured-return/parsers/eslint-json.ts +2 -38
- package/extensions/structured-return/parsers/go-test-json.ts +2 -138
- package/extensions/structured-return/parsers/hadolint-json.ts +2 -60
- package/extensions/structured-return/parsers/htmlhint-json.ts +2 -73
- package/extensions/structured-return/parsers/isort-text.ts +2 -63
- package/extensions/structured-return/parsers/javac-text.ts +2 -82
- package/extensions/structured-return/parsers/jsonlint-text.ts +2 -65
- package/extensions/structured-return/parsers/junit-xml.ts +2 -325
- package/extensions/structured-return/parsers/markdownlint-json.ts +2 -74
- package/extensions/structured-return/parsers/minitest-text.ts +2 -107
- package/extensions/structured-return/parsers/mocha-json.ts +2 -83
- package/extensions/structured-return/parsers/mypy-json.ts +2 -79
- package/extensions/structured-return/parsers/node-test-text.ts +2 -92
- package/extensions/structured-return/parsers/npm-audit-json.ts +2 -90
- package/extensions/structured-return/parsers/prettier-text.ts +2 -66
- package/extensions/structured-return/parsers/pylint-json.ts +2 -63
- package/extensions/structured-return/parsers/pyright-json.ts +2 -82
- package/extensions/structured-return/parsers/rspec-json.ts +2 -75
- package/extensions/structured-return/parsers/rubocop-json.ts +2 -75
- package/extensions/structured-return/parsers/ruff-json.ts +2 -36
- package/extensions/structured-return/parsers/shellcheck-json.ts +2 -60
- package/extensions/structured-return/parsers/stylelint-json.ts +2 -75
- package/extensions/structured-return/parsers/swiftc-text.ts +2 -52
- package/extensions/structured-return/parsers/tail-fallback.ts +2 -19
- package/extensions/structured-return/parsers/tidy-text.ts +2 -66
- package/extensions/structured-return/parsers/tsc-text.ts +2 -46
- package/extensions/structured-return/parsers/unittest-text.ts +2 -125
- package/extensions/structured-return/parsers/utils.ts +28 -0
- package/extensions/structured-return/parsers/vale-json.ts +2 -79
- package/extensions/structured-return/parsers/vitest-json.ts +2 -59
- package/extensions/structured-return/storage/log-store.ts +0 -15
- package/extensions/structured-return/types.ts +1 -14
- package/native/Cargo.lock +193 -0
- package/native/Cargo.toml +21 -0
- package/native/THIRD-PARTY-LICENSES.txt +3660 -0
- package/native/bin/darwin-arm64/build.json +7 -0
- package/native/bin/darwin-arm64/structured-return-native +0 -0
- package/native/bin/darwin-x64/build.json +7 -0
- package/native/bin/darwin-x64/structured-return-native +0 -0
- package/native/bin/linux-arm64-musl/build.json +7 -0
- package/native/bin/linux-arm64-musl/structured-return-native +0 -0
- package/native/bin/linux-x64-musl/build.json +7 -0
- package/native/bin/linux-x64-musl/structured-return-native +0 -0
- package/native/src/common.rs +118 -0
- package/native/src/main.rs +55 -0
- package/native/src/parsers/ava_text.rs +125 -0
- package/native/src/parsers/bandit_json.rs +120 -0
- package/native/src/parsers/black_text.rs +45 -0
- package/native/src/parsers/cargo_build.rs +96 -0
- package/native/src/parsers/cargo_test.rs +140 -0
- package/native/src/parsers/checkstyle_xml.rs +137 -0
- package/native/src/parsers/clang_text.rs +39 -0
- package/native/src/parsers/compiler_helpers.rs +74 -0
- package/native/src/parsers/dbt_json.rs +243 -0
- package/native/src/parsers/dotnet_build_text.rs +50 -0
- package/native/src/parsers/eslint_json.rs +58 -0
- package/native/src/parsers/go_test_json.rs +346 -0
- package/native/src/parsers/hadolint_json.rs +37 -0
- package/native/src/parsers/htmlhint_json.rs +71 -0
- package/native/src/parsers/isort_text.rs +22 -0
- package/native/src/parsers/javac_text.rs +49 -0
- package/native/src/parsers/json_support.rs +287 -0
- package/native/src/parsers/jsonlint_text.rs +50 -0
- package/native/src/parsers/junit_xml.rs +430 -0
- package/native/src/parsers/markdownlint_json.rs +68 -0
- package/native/src/parsers/minitest_text.rs +91 -0
- package/native/src/parsers/mocha_json.rs +75 -0
- package/native/src/parsers/mod.rs +119 -0
- package/native/src/parsers/mypy_json.rs +93 -0
- package/native/src/parsers/node_test_text.rs +106 -0
- package/native/src/parsers/npm_audit_json.rs +119 -0
- package/native/src/parsers/prettier_text.rs +34 -0
- package/native/src/parsers/pylint_json.rs +44 -0
- package/native/src/parsers/pyright_json.rs +88 -0
- package/native/src/parsers/rspec_json.rs +84 -0
- package/native/src/parsers/rubocop_json.rs +46 -0
- package/native/src/parsers/ruff_json.rs +30 -0
- package/native/src/parsers/shellcheck_json.rs +40 -0
- package/native/src/parsers/stylelint_json.rs +46 -0
- package/native/src/parsers/swiftc_text.rs +38 -0
- package/native/src/parsers/tail_fallback.rs +51 -0
- package/native/src/parsers/test_helpers.rs +172 -0
- package/native/src/parsers/tidy_text.rs +77 -0
- package/native/src/parsers/tsc_text.rs +28 -0
- package/native/src/parsers/unittest_text.rs +125 -0
- package/native/src/parsers/vale_json.rs +66 -0
- package/native/src/parsers/vitest_json.rs +71 -0
- package/native/src/parsers/xml_support.rs +241 -0
- package/native/src/runner.rs +252 -0
- package/package.json +22 -7
- package/scripts/build-native.mjs +73 -0
- package/scripts/native-artifacts.mjs +69 -0
- package/skills/structured-return/SKILL.md +103 -249
- package/extensions/structured-return/config/project-config.ts +0 -10
- package/extensions/structured-return/examples/.pi/machine-readable.json +0 -18
- package/extensions/structured-return/examples/.pi/parsers/foo-cli.ts +0 -25
|
@@ -1,93 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
-
import { safeReadFile } from './utils';
|
|
1
|
+
import { nativeParser } from '../native';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
const SUMMARY_PASS = /^ℹ pass (\d+)/m;
|
|
7
|
-
const SUMMARY_FAIL = /^ℹ fail (\d+)/m;
|
|
8
|
-
|
|
9
|
-
// Failing test header: test at file:line:col
|
|
10
|
-
const TEST_AT_LINE = /^test at (.+?):(\d+):\d+/;
|
|
11
|
-
|
|
12
|
-
const parser: ParserModule = {
|
|
13
|
-
id: 'node-test-text',
|
|
14
|
-
async parse(ctx) {
|
|
15
|
-
const combined = safeReadFile(ctx.stdoutPath) + safeReadFile(ctx.stderrPath);
|
|
16
|
-
if (!combined.trim()) {
|
|
17
|
-
return {
|
|
18
|
-
tool: 'node:test',
|
|
19
|
-
status: 'pass',
|
|
20
|
-
summary: 'no tests found',
|
|
21
|
-
failures: [],
|
|
22
|
-
logPath: ctx.logPath,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const passMatch = combined.match(SUMMARY_PASS);
|
|
27
|
-
const failMatch = combined.match(SUMMARY_FAIL);
|
|
28
|
-
const passed = passMatch ? parseInt(passMatch[1], 10) : 0;
|
|
29
|
-
const failed = failMatch ? parseInt(failMatch[1], 10) : 0;
|
|
30
|
-
|
|
31
|
-
// Parse the "failing tests:" section
|
|
32
|
-
const failingSection = combined.split('✖ failing tests:')[1] ?? '';
|
|
33
|
-
const failures: ParsedFailure[] = [];
|
|
34
|
-
|
|
35
|
-
if (failingSection) {
|
|
36
|
-
// Split into per-test blocks by "test at" lines
|
|
37
|
-
const blocks = failingSection.split(/(?=^test at )/m).filter((b) => b.trim());
|
|
38
|
-
|
|
39
|
-
for (const block of blocks) {
|
|
40
|
-
const atMatch = block.match(TEST_AT_LINE);
|
|
41
|
-
const nameMatch = block.match(/^✖ (.+?) \(/m);
|
|
42
|
-
|
|
43
|
-
let file: string | undefined;
|
|
44
|
-
let line: number | undefined;
|
|
45
|
-
if (atMatch) {
|
|
46
|
-
file = path.relative(ctx.cwd, atMatch[1]);
|
|
47
|
-
line = parseInt(atMatch[2], 10);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const name = nameMatch ? nameMatch[1] : 'unknown test';
|
|
51
|
-
|
|
52
|
-
// Extract meaningful error message — try specific patterns first, then generic
|
|
53
|
-
let message = name;
|
|
54
|
-
const strictMatch = block.match(/Expected values to be strictly equal:\s*\n\s*\n\s*(.+)/);
|
|
55
|
-
const falsyMatch = block.match(
|
|
56
|
-
/The expression evaluated to a falsy value:\s*\n\s*\n\s*(.+)/,
|
|
57
|
-
);
|
|
58
|
-
if (strictMatch) {
|
|
59
|
-
message = `Expected values to be strictly equal: ${strictMatch[1].trim()}`;
|
|
60
|
-
} else if (falsyMatch) {
|
|
61
|
-
message = `The expression evaluated to a falsy value: ${falsyMatch[1].trim()}`;
|
|
62
|
-
} else {
|
|
63
|
-
// Match any Error type (AssertionError, TypeError, ReferenceError, etc.)
|
|
64
|
-
const errorMatch = block.match(/^\s+(\w*Error\b.*?)$/m);
|
|
65
|
-
if (errorMatch)
|
|
66
|
-
message = errorMatch[1].replace(/\s*\[ERR_\w+\]:\s*/, ': ').replace(/^\w+Error: /, '');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
failures.push({
|
|
70
|
-
id: `${file}:${line}`,
|
|
71
|
-
file,
|
|
72
|
-
line,
|
|
73
|
-
message,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const parts: string[] = [];
|
|
79
|
-
if (failed > 0) parts.push(`${failed} failed`);
|
|
80
|
-
if (passed > 0) parts.push(`${passed} passed`);
|
|
81
|
-
const summary = parts.join(', ') || 'tests completed';
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
tool: 'node:test',
|
|
85
|
-
status: failed > 0 ? 'fail' : 'pass',
|
|
86
|
-
summary,
|
|
87
|
-
failures,
|
|
88
|
-
logPath: ctx.logPath,
|
|
89
|
-
};
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export default parser;
|
|
3
|
+
export default nativeParser('node-test-text');
|
|
@@ -1,91 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { safeReadFile } from './utils';
|
|
1
|
+
import { nativeParser } from '../native';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
title?: string;
|
|
6
|
-
severity?: string;
|
|
7
|
-
url?: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface NpmAuditVuln {
|
|
12
|
-
name: string;
|
|
13
|
-
severity: string;
|
|
14
|
-
isDirect: boolean;
|
|
15
|
-
via: Array<NpmAuditVia | string>;
|
|
16
|
-
fixAvailable?: boolean | { name: string; version: string };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface NpmAuditReport {
|
|
20
|
-
vulnerabilities?: Record<string, NpmAuditVuln>;
|
|
21
|
-
metadata?: {
|
|
22
|
-
vulnerabilities?: Record<string, number>;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const parser: ParserModule = {
|
|
27
|
-
id: 'npm-audit-json',
|
|
28
|
-
async parse(ctx) {
|
|
29
|
-
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
30
|
-
if (!stdout) {
|
|
31
|
-
return {
|
|
32
|
-
tool: 'npm audit',
|
|
33
|
-
status: 'pass',
|
|
34
|
-
summary: 'no vulnerabilities found',
|
|
35
|
-
failures: [],
|
|
36
|
-
logPath: ctx.logPath,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let report: NpmAuditReport;
|
|
41
|
-
try {
|
|
42
|
-
report = JSON.parse(stdout);
|
|
43
|
-
} catch {
|
|
44
|
-
return {
|
|
45
|
-
tool: 'npm audit',
|
|
46
|
-
status: 'error',
|
|
47
|
-
summary: 'failed to parse npm audit JSON output',
|
|
48
|
-
logPath: ctx.logPath,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const vulns = report.vulnerabilities ?? {};
|
|
53
|
-
const failures: ParsedFailure[] = [];
|
|
54
|
-
|
|
55
|
-
for (const [pkg, vuln] of Object.entries(vulns)) {
|
|
56
|
-
// Extract advisory titles from 'via' (skip string refs to other packages)
|
|
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`;
|
|
62
|
-
failures.push({
|
|
63
|
-
id: pkg,
|
|
64
|
-
file: pkg,
|
|
65
|
-
message,
|
|
66
|
-
rule: vuln.severity,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Build severity summary from metadata
|
|
71
|
-
const meta = report.metadata?.vulnerabilities ?? {};
|
|
72
|
-
const sevParts = ['critical', 'high', 'moderate', 'low', 'info']
|
|
73
|
-
.filter((s) => meta[s])
|
|
74
|
-
.map((s) => `${meta[s]} ${s}`);
|
|
75
|
-
const total = meta.total ?? failures.length;
|
|
76
|
-
const summary =
|
|
77
|
-
total > 0
|
|
78
|
-
? `${total} vulnerabilit${total !== 1 ? 'ies' : 'y'} (${sevParts.join(', ')})`
|
|
79
|
-
: 'no vulnerabilities found';
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
tool: 'npm audit',
|
|
83
|
-
status: total > 0 ? 'fail' : 'pass',
|
|
84
|
-
summary,
|
|
85
|
-
failures,
|
|
86
|
-
logPath: ctx.logPath,
|
|
87
|
-
};
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export default parser;
|
|
3
|
+
export default nativeParser('npm-audit-json');
|
|
@@ -1,67 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
-
import { safeReadFile } from './utils';
|
|
1
|
+
import { nativeParser } from '../native';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
const WARN_LINE = /^\[warn\] (.+)$/;
|
|
7
|
-
const SUMMARY_PREFIX = /^Code style issues|^Run Prettier/;
|
|
8
|
-
|
|
9
|
-
const parser: ParserModule = {
|
|
10
|
-
id: 'prettier-text',
|
|
11
|
-
async parse(ctx) {
|
|
12
|
-
const combined = (safeReadFile(ctx.stdoutPath) + '\n' + safeReadFile(ctx.stderrPath)).trim();
|
|
13
|
-
if (!combined) {
|
|
14
|
-
return {
|
|
15
|
-
tool: 'prettier',
|
|
16
|
-
status: 'pass',
|
|
17
|
-
summary: 'all files formatted',
|
|
18
|
-
failures: [],
|
|
19
|
-
logPath: ctx.logPath,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const lines = combined.split('\n');
|
|
24
|
-
const failures: ParsedFailure[] = [];
|
|
25
|
-
|
|
26
|
-
for (const line of lines) {
|
|
27
|
-
const warnMatch = line.match(WARN_LINE);
|
|
28
|
-
if (warnMatch && !SUMMARY_PREFIX.test(warnMatch[1])) {
|
|
29
|
-
const relPath = path.relative(ctx.cwd, warnMatch[1]);
|
|
30
|
-
failures.push({
|
|
31
|
-
id: relPath,
|
|
32
|
-
file: relPath,
|
|
33
|
-
message: 'needs formatting',
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// All done, no warnings
|
|
39
|
-
if (failures.length === 0 && combined.includes('All matched files use Prettier code style')) {
|
|
40
|
-
return {
|
|
41
|
-
tool: 'prettier',
|
|
42
|
-
status: 'pass',
|
|
43
|
-
summary: 'all files formatted',
|
|
44
|
-
failures: [],
|
|
45
|
-
logPath: ctx.logPath,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const n = failures.length;
|
|
50
|
-
const summary =
|
|
51
|
-
n > 0
|
|
52
|
-
? n === 1
|
|
53
|
-
? '1 file has formatting issues'
|
|
54
|
-
: `${n} files have formatting issues`
|
|
55
|
-
: 'all files formatted';
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
tool: 'prettier',
|
|
59
|
-
status: n > 0 ? 'fail' : 'pass',
|
|
60
|
-
summary,
|
|
61
|
-
failures,
|
|
62
|
-
logPath: ctx.logPath,
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export default parser;
|
|
3
|
+
export default nativeParser('prettier-text');
|
|
@@ -1,64 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
-
import { safeReadFile } from './utils';
|
|
1
|
+
import { nativeParser } from '../native';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
type: string;
|
|
7
|
-
module: string;
|
|
8
|
-
obj: string;
|
|
9
|
-
line: number;
|
|
10
|
-
column: number;
|
|
11
|
-
path: string;
|
|
12
|
-
symbol: string;
|
|
13
|
-
message: string;
|
|
14
|
-
'message-id': string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const parser: ParserModule = {
|
|
18
|
-
id: 'pylint-json',
|
|
19
|
-
async parse(ctx) {
|
|
20
|
-
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
21
|
-
if (!stdout || stdout === '[]') {
|
|
22
|
-
return {
|
|
23
|
-
tool: 'pylint',
|
|
24
|
-
status: 'pass',
|
|
25
|
-
summary: 'no lint errors',
|
|
26
|
-
failures: [],
|
|
27
|
-
logPath: ctx.logPath,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let items: PylintItem[];
|
|
32
|
-
try {
|
|
33
|
-
items = JSON.parse(stdout) as PylintItem[];
|
|
34
|
-
} catch {
|
|
35
|
-
return {
|
|
36
|
-
tool: 'pylint',
|
|
37
|
-
status: 'error',
|
|
38
|
-
summary: 'failed to parse pylint JSON output',
|
|
39
|
-
logPath: ctx.logPath,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const failures: ParsedFailure[] = items.map((item) => {
|
|
44
|
-
const relPath = path.isAbsolute(item.path) ? path.relative(ctx.cwd, item.path) : item.path;
|
|
45
|
-
return {
|
|
46
|
-
id: `${relPath}:${item.line}:${item['message-id']}`,
|
|
47
|
-
file: relPath,
|
|
48
|
-
line: item.line,
|
|
49
|
-
message: item.message,
|
|
50
|
-
rule: `${item['message-id']}(${item.symbol})`,
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
tool: 'pylint',
|
|
56
|
-
status: failures.length > 0 ? 'fail' : 'pass',
|
|
57
|
-
summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
|
|
58
|
-
failures,
|
|
59
|
-
logPath: ctx.logPath,
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export default parser;
|
|
3
|
+
export default nativeParser('pylint-json');
|
|
@@ -1,83 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
-
import { safeReadFile } from './utils';
|
|
1
|
+
import { nativeParser } from '../native';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
file: string;
|
|
7
|
-
severity: string;
|
|
8
|
-
message: string;
|
|
9
|
-
range?: { start: { line: number; character: number } };
|
|
10
|
-
rule?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface PyrightOutput {
|
|
14
|
-
generalDiagnostics?: PyrightDiagnostic[];
|
|
15
|
-
summary?: {
|
|
16
|
-
errorCount: number;
|
|
17
|
-
warningCount: number;
|
|
18
|
-
informationCount: number;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const parser: ParserModule = {
|
|
23
|
-
id: 'pyright-json',
|
|
24
|
-
async parse(ctx) {
|
|
25
|
-
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
26
|
-
if (!stdout) {
|
|
27
|
-
return {
|
|
28
|
-
tool: 'pyright',
|
|
29
|
-
status: 'pass',
|
|
30
|
-
summary: 'no type errors',
|
|
31
|
-
failures: [],
|
|
32
|
-
logPath: ctx.logPath,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let output: PyrightOutput;
|
|
37
|
-
try {
|
|
38
|
-
output = JSON.parse(stdout);
|
|
39
|
-
} catch {
|
|
40
|
-
return {
|
|
41
|
-
tool: 'pyright',
|
|
42
|
-
status: 'error',
|
|
43
|
-
summary: 'failed to parse pyright JSON output',
|
|
44
|
-
logPath: ctx.logPath,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const diagnostics = (output.generalDiagnostics ?? []).filter((d) => d.severity === 'error');
|
|
49
|
-
const failures: ParsedFailure[] = diagnostics.map((d) => {
|
|
50
|
-
const relPath = path.relative(ctx.cwd, d.file);
|
|
51
|
-
// pyright uses 0-based lines in JSON
|
|
52
|
-
const line = d.range ? d.range.start.line + 1 : undefined;
|
|
53
|
-
// Collapse multi-line messages (detail line after \n) into a single line
|
|
54
|
-
const message = d.message.split('\n')[0];
|
|
55
|
-
return {
|
|
56
|
-
id: `${relPath}:${line}:${d.rule ?? 'error'}`,
|
|
57
|
-
file: relPath,
|
|
58
|
-
line,
|
|
59
|
-
message,
|
|
60
|
-
rule: d.rule,
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
const summary = output.summary;
|
|
65
|
-
const parts: string[] = [];
|
|
66
|
-
if (summary) {
|
|
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' : ''}`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
tool: 'pyright',
|
|
75
|
-
status: failures.length > 0 ? 'fail' : 'pass',
|
|
76
|
-
summary: parts.length > 0 ? parts.join(', ') : 'no type errors',
|
|
77
|
-
failures,
|
|
78
|
-
logPath: ctx.logPath,
|
|
79
|
-
};
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export default parser;
|
|
3
|
+
export default nativeParser('pyright-json');
|
|
@@ -1,76 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ParserModule } from '../types';
|
|
3
|
-
import { safeReadFile } from './utils';
|
|
1
|
+
import { nativeParser } from '../native';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
class: string;
|
|
7
|
-
message: string;
|
|
8
|
-
backtrace: string[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface RSpecExample {
|
|
12
|
-
id: string;
|
|
13
|
-
full_description: string;
|
|
14
|
-
status: 'passed' | 'failed' | 'pending';
|
|
15
|
-
file_path: string;
|
|
16
|
-
line_number: number;
|
|
17
|
-
exception?: RSpecException;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface RSpecReport {
|
|
21
|
-
examples: RSpecExample[];
|
|
22
|
-
summary: {
|
|
23
|
-
example_count: number;
|
|
24
|
-
failure_count: number;
|
|
25
|
-
pending_count: number;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Take all non-empty lines before the first blank line — captures expected/got pairs intact. */
|
|
30
|
-
function firstParagraph(message: string): string {
|
|
31
|
-
const lines = message.trim().split('\n');
|
|
32
|
-
const paragraph: string[] = [];
|
|
33
|
-
for (const line of lines) {
|
|
34
|
-
if (line.trim() === '') break;
|
|
35
|
-
paragraph.push(line.trim());
|
|
36
|
-
}
|
|
37
|
-
return paragraph.join(' / ');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const parser: ParserModule = {
|
|
41
|
-
id: 'rspec-json',
|
|
42
|
-
async parse(ctx) {
|
|
43
|
-
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
44
|
-
const report = stdout ? (JSON.parse(stdout) as RSpecReport) : null;
|
|
45
|
-
if (!report) {
|
|
46
|
-
return {
|
|
47
|
-
tool: 'rspec',
|
|
48
|
-
status: 'error',
|
|
49
|
-
summary: 'no output',
|
|
50
|
-
logPath: ctx.logPath,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const failures = report.examples
|
|
55
|
-
.filter((e) => e.status === 'failed')
|
|
56
|
-
.map((e) => ({
|
|
57
|
-
id: e.id,
|
|
58
|
-
file: path.relative(ctx.cwd, path.resolve(ctx.cwd, e.file_path)),
|
|
59
|
-
line: e.line_number,
|
|
60
|
-
message: e.exception ? firstParagraph(e.exception.message) : e.full_description,
|
|
61
|
-
}));
|
|
62
|
-
|
|
63
|
-
const failed = report.summary.failure_count;
|
|
64
|
-
const passed = report.summary.example_count - failed - report.summary.pending_count;
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
tool: 'rspec',
|
|
68
|
-
status: failed > 0 ? 'fail' : 'pass',
|
|
69
|
-
summary: failed > 0 ? `${failed} failed, ${passed} passed` : `${passed} passed`,
|
|
70
|
-
failures,
|
|
71
|
-
logPath: ctx.logPath,
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default parser;
|
|
3
|
+
export default nativeParser('rspec-json');
|
|
@@ -1,76 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
-
import { safeReadFile } from './utils';
|
|
1
|
+
import { nativeParser } from '../native';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
severity: string;
|
|
7
|
-
message: string;
|
|
8
|
-
cop_name: string;
|
|
9
|
-
location: { line: number; column: number };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface RubocopFile {
|
|
13
|
-
path: string;
|
|
14
|
-
offenses: RubocopOffense[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface RubocopOutput {
|
|
18
|
-
files: RubocopFile[];
|
|
19
|
-
summary: { offense_count: number };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const parser: ParserModule = {
|
|
23
|
-
id: 'rubocop-json',
|
|
24
|
-
async parse(ctx) {
|
|
25
|
-
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
26
|
-
if (!stdout) {
|
|
27
|
-
return {
|
|
28
|
-
tool: 'rubocop',
|
|
29
|
-
status: 'pass',
|
|
30
|
-
summary: 'no lint errors',
|
|
31
|
-
failures: [],
|
|
32
|
-
logPath: ctx.logPath,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let data: RubocopOutput;
|
|
37
|
-
try {
|
|
38
|
-
data = JSON.parse(stdout) as RubocopOutput;
|
|
39
|
-
} catch {
|
|
40
|
-
return {
|
|
41
|
-
tool: 'rubocop',
|
|
42
|
-
status: 'error',
|
|
43
|
-
summary: 'failed to parse rubocop JSON output',
|
|
44
|
-
logPath: ctx.logPath,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const failures: ParsedFailure[] = [];
|
|
49
|
-
for (const file of data.files) {
|
|
50
|
-
const relPath = path.isAbsolute(file.path) ? path.relative(ctx.cwd, file.path) : file.path;
|
|
51
|
-
for (const o of file.offenses) {
|
|
52
|
-
// Strip the "CopName: " prefix from the message if present.
|
|
53
|
-
// Escape special regex chars in cop_name (e.g. "." in Style/Foo.Bar).
|
|
54
|
-
const escapedCop = o.cop_name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
55
|
-
const msg = o.message.replace(new RegExp(`^${escapedCop}:\\s*`), '');
|
|
56
|
-
failures.push({
|
|
57
|
-
id: `${relPath}:${o.location.line}:${o.cop_name}`,
|
|
58
|
-
file: relPath,
|
|
59
|
-
line: o.location.line,
|
|
60
|
-
message: msg,
|
|
61
|
-
rule: o.cop_name,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
tool: 'rubocop',
|
|
68
|
-
status: failures.length > 0 ? 'fail' : 'pass',
|
|
69
|
-
summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
|
|
70
|
-
failures,
|
|
71
|
-
logPath: ctx.logPath,
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default parser;
|
|
3
|
+
export default nativeParser('rubocop-json');
|
|
@@ -1,37 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ParserModule } from '../types';
|
|
3
|
-
import { safeReadFile } from './utils';
|
|
1
|
+
import { nativeParser } from '../native';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
filename: string;
|
|
7
|
-
code: string;
|
|
8
|
-
message: string;
|
|
9
|
-
location?: { row: number };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const parser: ParserModule = {
|
|
13
|
-
id: 'ruff-json',
|
|
14
|
-
async parse(ctx) {
|
|
15
|
-
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
16
|
-
const items = stdout ? (JSON.parse(stdout) as RuffItem[]) : [];
|
|
17
|
-
const failures = (Array.isArray(items) ? items : []).map((item) => {
|
|
18
|
-
const relPath = path.relative(ctx.cwd, item.filename);
|
|
19
|
-
return {
|
|
20
|
-
id: `${relPath}:${item.location?.row}:${item.code}`,
|
|
21
|
-
file: relPath,
|
|
22
|
-
line: item.location?.row,
|
|
23
|
-
message: item.message,
|
|
24
|
-
rule: item.code,
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
tool: 'ruff',
|
|
29
|
-
status: failures.length > 0 ? 'fail' : 'pass',
|
|
30
|
-
summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
|
|
31
|
-
failures,
|
|
32
|
-
logPath: ctx.logPath,
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default parser;
|
|
3
|
+
export default nativeParser('ruff-json');
|
|
@@ -1,61 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
-
import { safeReadFile } from './utils';
|
|
1
|
+
import { nativeParser } from '../native';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
file: string;
|
|
7
|
-
line: number;
|
|
8
|
-
column: number;
|
|
9
|
-
level: string;
|
|
10
|
-
code: number;
|
|
11
|
-
message: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const parser: ParserModule = {
|
|
15
|
-
id: 'shellcheck-json',
|
|
16
|
-
async parse(ctx) {
|
|
17
|
-
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
18
|
-
if (!stdout || stdout === '[]') {
|
|
19
|
-
return {
|
|
20
|
-
tool: 'shellcheck',
|
|
21
|
-
status: 'pass',
|
|
22
|
-
summary: 'no lint errors',
|
|
23
|
-
failures: [],
|
|
24
|
-
logPath: ctx.logPath,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let items: ShellCheckItem[];
|
|
29
|
-
try {
|
|
30
|
-
items = JSON.parse(stdout) as ShellCheckItem[];
|
|
31
|
-
} catch {
|
|
32
|
-
return {
|
|
33
|
-
tool: 'shellcheck',
|
|
34
|
-
status: 'error',
|
|
35
|
-
summary: 'failed to parse shellcheck JSON output',
|
|
36
|
-
logPath: ctx.logPath,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const failures: ParsedFailure[] = items.map((item) => {
|
|
41
|
-
const relPath = path.isAbsolute(item.file) ? path.relative(ctx.cwd, item.file) : item.file;
|
|
42
|
-
return {
|
|
43
|
-
id: `${relPath}:${item.line}:SC${item.code}`,
|
|
44
|
-
file: relPath,
|
|
45
|
-
line: item.line,
|
|
46
|
-
message: item.message,
|
|
47
|
-
rule: `SC${item.code}`,
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
tool: 'shellcheck',
|
|
53
|
-
status: failures.length > 0 ? 'fail' : 'pass',
|
|
54
|
-
summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
|
|
55
|
-
failures,
|
|
56
|
-
logPath: ctx.logPath,
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default parser;
|
|
3
|
+
export default nativeParser('shellcheck-json');
|