@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,6 +1,6 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule } from
|
|
3
|
-
import { safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule } from '../types';
|
|
3
|
+
import { safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
interface RSpecException {
|
|
6
6
|
class: string;
|
|
@@ -11,7 +11,7 @@ interface RSpecException {
|
|
|
11
11
|
interface RSpecExample {
|
|
12
12
|
id: string;
|
|
13
13
|
full_description: string;
|
|
14
|
-
status:
|
|
14
|
+
status: 'passed' | 'failed' | 'pending';
|
|
15
15
|
file_path: string;
|
|
16
16
|
line_number: number;
|
|
17
17
|
exception?: RSpecException;
|
|
@@ -28,31 +28,31 @@ interface RSpecReport {
|
|
|
28
28
|
|
|
29
29
|
/** Take all non-empty lines before the first blank line — captures expected/got pairs intact. */
|
|
30
30
|
function firstParagraph(message: string): string {
|
|
31
|
-
const lines = message.trim().split(
|
|
31
|
+
const lines = message.trim().split('\n');
|
|
32
32
|
const paragraph: string[] = [];
|
|
33
33
|
for (const line of lines) {
|
|
34
|
-
if (line.trim() ===
|
|
34
|
+
if (line.trim() === '') break;
|
|
35
35
|
paragraph.push(line.trim());
|
|
36
36
|
}
|
|
37
|
-
return paragraph.join(
|
|
37
|
+
return paragraph.join(' / ');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const parser: ParserModule = {
|
|
41
|
-
id:
|
|
41
|
+
id: 'rspec-json',
|
|
42
42
|
async parse(ctx) {
|
|
43
43
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
44
44
|
const report = stdout ? (JSON.parse(stdout) as RSpecReport) : null;
|
|
45
45
|
if (!report) {
|
|
46
46
|
return {
|
|
47
|
-
tool:
|
|
48
|
-
status:
|
|
49
|
-
summary:
|
|
47
|
+
tool: 'rspec',
|
|
48
|
+
status: 'error',
|
|
49
|
+
summary: 'no output',
|
|
50
50
|
logPath: ctx.logPath,
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const failures = report.examples
|
|
55
|
-
.filter((e) => e.status ===
|
|
55
|
+
.filter((e) => e.status === 'failed')
|
|
56
56
|
.map((e) => ({
|
|
57
57
|
id: e.id,
|
|
58
58
|
file: path.relative(ctx.cwd, path.resolve(ctx.cwd, e.file_path)),
|
|
@@ -64,8 +64,8 @@ const parser: ParserModule = {
|
|
|
64
64
|
const passed = report.summary.example_count - failed - report.summary.pending_count;
|
|
65
65
|
|
|
66
66
|
return {
|
|
67
|
-
tool:
|
|
68
|
-
status: failed > 0 ?
|
|
67
|
+
tool: 'rspec',
|
|
68
|
+
status: failed > 0 ? 'fail' : 'pass',
|
|
69
69
|
summary: failed > 0 ? `${failed} failed, ${passed} passed` : `${passed} passed`,
|
|
70
70
|
failures,
|
|
71
71
|
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 RubocopOffense {
|
|
6
6
|
severity: string;
|
|
@@ -20,18 +20,29 @@ interface RubocopOutput {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const parser: ParserModule = {
|
|
23
|
-
id:
|
|
23
|
+
id: 'rubocop-json',
|
|
24
24
|
async parse(ctx) {
|
|
25
25
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
26
26
|
if (!stdout) {
|
|
27
|
-
return {
|
|
27
|
+
return {
|
|
28
|
+
tool: 'rubocop',
|
|
29
|
+
status: 'pass',
|
|
30
|
+
summary: 'no lint errors',
|
|
31
|
+
failures: [],
|
|
32
|
+
logPath: ctx.logPath,
|
|
33
|
+
};
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
let data: RubocopOutput;
|
|
31
37
|
try {
|
|
32
38
|
data = JSON.parse(stdout) as RubocopOutput;
|
|
33
39
|
} catch {
|
|
34
|
-
return {
|
|
40
|
+
return {
|
|
41
|
+
tool: 'rubocop',
|
|
42
|
+
status: 'error',
|
|
43
|
+
summary: 'failed to parse rubocop JSON output',
|
|
44
|
+
logPath: ctx.logPath,
|
|
45
|
+
};
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
const failures: ParsedFailure[] = [];
|
|
@@ -40,8 +51,8 @@ const parser: ParserModule = {
|
|
|
40
51
|
for (const o of file.offenses) {
|
|
41
52
|
// Strip the "CopName: " prefix from the message if present.
|
|
42
53
|
// Escape special regex chars in cop_name (e.g. "." in Style/Foo.Bar).
|
|
43
|
-
const escapedCop = o.cop_name.replace(/[.*+?^${}()|[\]\\]/g,
|
|
44
|
-
const msg = o.message.replace(new RegExp(`^${escapedCop}:\\s*`),
|
|
54
|
+
const escapedCop = o.cop_name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
55
|
+
const msg = o.message.replace(new RegExp(`^${escapedCop}:\\s*`), '');
|
|
45
56
|
failures.push({
|
|
46
57
|
id: `${relPath}:${o.location.line}:${o.cop_name}`,
|
|
47
58
|
file: relPath,
|
|
@@ -53,9 +64,9 @@ const parser: ParserModule = {
|
|
|
53
64
|
}
|
|
54
65
|
|
|
55
66
|
return {
|
|
56
|
-
tool:
|
|
57
|
-
status: failures.length > 0 ?
|
|
58
|
-
summary: failures.length > 0 ? `${failures.length} lint errors` :
|
|
67
|
+
tool: 'rubocop',
|
|
68
|
+
status: failures.length > 0 ? 'fail' : 'pass',
|
|
69
|
+
summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
|
|
59
70
|
failures,
|
|
60
71
|
logPath: ctx.logPath,
|
|
61
72
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule } from
|
|
3
|
-
import { safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule } from '../types';
|
|
3
|
+
import { safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
interface RuffItem {
|
|
6
6
|
filename: string;
|
|
@@ -10,7 +10,7 @@ interface RuffItem {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const parser: ParserModule = {
|
|
13
|
-
id:
|
|
13
|
+
id: 'ruff-json',
|
|
14
14
|
async parse(ctx) {
|
|
15
15
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
16
16
|
const items = stdout ? (JSON.parse(stdout) as RuffItem[]) : [];
|
|
@@ -25,9 +25,9 @@ const parser: ParserModule = {
|
|
|
25
25
|
};
|
|
26
26
|
});
|
|
27
27
|
return {
|
|
28
|
-
tool:
|
|
29
|
-
status: failures.length > 0 ?
|
|
30
|
-
summary: failures.length > 0 ? `${failures.length} lint errors` :
|
|
28
|
+
tool: 'ruff',
|
|
29
|
+
status: failures.length > 0 ? 'fail' : 'pass',
|
|
30
|
+
summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
|
|
31
31
|
failures,
|
|
32
32
|
logPath: ctx.logPath,
|
|
33
33
|
};
|
|
@@ -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 ShellCheckItem {
|
|
6
6
|
file: string;
|
|
@@ -12,14 +12,14 @@ interface ShellCheckItem {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const parser: ParserModule = {
|
|
15
|
-
id:
|
|
15
|
+
id: 'shellcheck-json',
|
|
16
16
|
async parse(ctx) {
|
|
17
17
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
18
|
-
if (!stdout || stdout ===
|
|
18
|
+
if (!stdout || stdout === '[]') {
|
|
19
19
|
return {
|
|
20
|
-
tool:
|
|
21
|
-
status:
|
|
22
|
-
summary:
|
|
20
|
+
tool: 'shellcheck',
|
|
21
|
+
status: 'pass',
|
|
22
|
+
summary: 'no lint errors',
|
|
23
23
|
failures: [],
|
|
24
24
|
logPath: ctx.logPath,
|
|
25
25
|
};
|
|
@@ -30,9 +30,9 @@ const parser: ParserModule = {
|
|
|
30
30
|
items = JSON.parse(stdout) as ShellCheckItem[];
|
|
31
31
|
} catch {
|
|
32
32
|
return {
|
|
33
|
-
tool:
|
|
34
|
-
status:
|
|
35
|
-
summary:
|
|
33
|
+
tool: 'shellcheck',
|
|
34
|
+
status: 'error',
|
|
35
|
+
summary: 'failed to parse shellcheck JSON output',
|
|
36
36
|
logPath: ctx.logPath,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
@@ -49,9 +49,9 @@ const parser: ParserModule = {
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
return {
|
|
52
|
-
tool:
|
|
53
|
-
status: failures.length > 0 ?
|
|
54
|
-
summary: failures.length > 0 ? `${failures.length} lint errors` :
|
|
52
|
+
tool: 'shellcheck',
|
|
53
|
+
status: failures.length > 0 ? 'fail' : 'pass',
|
|
54
|
+
summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
|
|
55
55
|
failures,
|
|
56
56
|
logPath: ctx.logPath,
|
|
57
57
|
};
|
|
@@ -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 StylelintWarning {
|
|
6
6
|
line: number;
|
|
@@ -16,11 +16,17 @@ interface StylelintResult {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const parser: ParserModule = {
|
|
19
|
-
id:
|
|
19
|
+
id: 'stylelint-json',
|
|
20
20
|
async parse(ctx) {
|
|
21
21
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
22
|
-
if (!stdout || stdout ===
|
|
23
|
-
return {
|
|
22
|
+
if (!stdout || stdout === '[]') {
|
|
23
|
+
return {
|
|
24
|
+
tool: 'stylelint',
|
|
25
|
+
status: 'pass',
|
|
26
|
+
summary: 'no lint errors',
|
|
27
|
+
failures: [],
|
|
28
|
+
logPath: ctx.logPath,
|
|
29
|
+
};
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
let results: StylelintResult[];
|
|
@@ -28,16 +34,18 @@ const parser: ParserModule = {
|
|
|
28
34
|
results = JSON.parse(stdout) as StylelintResult[];
|
|
29
35
|
} catch {
|
|
30
36
|
return {
|
|
31
|
-
tool:
|
|
32
|
-
status:
|
|
33
|
-
summary:
|
|
37
|
+
tool: 'stylelint',
|
|
38
|
+
status: 'error',
|
|
39
|
+
summary: 'failed to parse stylelint JSON output',
|
|
34
40
|
logPath: ctx.logPath,
|
|
35
41
|
};
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
const failures: ParsedFailure[] = [];
|
|
39
45
|
for (const result of results) {
|
|
40
|
-
const relPath = path.isAbsolute(result.source)
|
|
46
|
+
const relPath = path.isAbsolute(result.source)
|
|
47
|
+
? path.relative(ctx.cwd, result.source)
|
|
48
|
+
: result.source;
|
|
41
49
|
for (const w of result.warnings) {
|
|
42
50
|
// Strip the trailing " (rule-name)" from text, but only if the
|
|
43
51
|
// parenthesized content matches the actual rule name. Avoids
|
|
@@ -56,9 +64,9 @@ const parser: ParserModule = {
|
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
return {
|
|
59
|
-
tool:
|
|
60
|
-
status: failures.length > 0 ?
|
|
61
|
-
summary: failures.length > 0 ? `${failures.length} lint errors` :
|
|
67
|
+
tool: 'stylelint',
|
|
68
|
+
status: failures.length > 0 ? 'fail' : 'pass',
|
|
69
|
+
summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
|
|
62
70
|
failures,
|
|
63
71
|
logPath: ctx.logPath,
|
|
64
72
|
};
|
|
@@ -1,26 +1,32 @@
|
|
|
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
|
// swiftc format: file:line:col: error: message (or warning:, note:)
|
|
6
6
|
const SWIFT_LINE = /^(.+?):(\d+):\d+:\s+(error|warning):\s+(.+)$/;
|
|
7
7
|
|
|
8
8
|
const parser: ParserModule = {
|
|
9
|
-
id:
|
|
9
|
+
id: 'swiftc-text',
|
|
10
10
|
async parse(ctx) {
|
|
11
11
|
// swiftc writes diagnostics (errors, warnings, notes) to stderr.
|
|
12
12
|
const stderr = safeReadFile(ctx.stderrPath).trim();
|
|
13
13
|
if (!stderr) {
|
|
14
|
-
return {
|
|
14
|
+
return {
|
|
15
|
+
tool: 'swiftc',
|
|
16
|
+
status: 'pass',
|
|
17
|
+
summary: 'no errors',
|
|
18
|
+
failures: [],
|
|
19
|
+
logPath: ctx.logPath,
|
|
20
|
+
};
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
const failures: ParsedFailure[] = [];
|
|
18
24
|
const seen = new Set<string>();
|
|
19
|
-
for (const line of stderr.split(
|
|
25
|
+
for (const line of stderr.split('\n')) {
|
|
20
26
|
const m = line.match(SWIFT_LINE);
|
|
21
27
|
if (!m) continue;
|
|
22
28
|
const [, file, lineNum, severity, message] = m;
|
|
23
|
-
if (severity !==
|
|
29
|
+
if (severity !== 'error') continue; // skip warnings for now
|
|
24
30
|
const relPath = path.isAbsolute(file) ? path.relative(ctx.cwd, file) : file;
|
|
25
31
|
// Deduplicate: swiftc repeats the same error in source annotation lines
|
|
26
32
|
const id = `${relPath}:${lineNum}:${message}`;
|
|
@@ -35,9 +41,9 @@ const parser: ParserModule = {
|
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
return {
|
|
38
|
-
tool:
|
|
39
|
-
status: failures.length > 0 ?
|
|
40
|
-
summary: failures.length > 0 ? `${failures.length} errors` :
|
|
44
|
+
tool: 'swiftc',
|
|
45
|
+
status: failures.length > 0 ? 'fail' : 'pass',
|
|
46
|
+
summary: failures.length > 0 ? `${failures.length} errors` : 'no errors',
|
|
41
47
|
failures,
|
|
42
48
|
logPath: ctx.logPath,
|
|
43
49
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ParserModule } from '../types';
|
|
2
|
+
import { safeReadFile } from './utils';
|
|
3
|
+
|
|
4
|
+
const parser: ParserModule = {
|
|
5
|
+
id: 'tail-fallback',
|
|
6
|
+
async parse(ctx) {
|
|
7
|
+
const log = safeReadFile(ctx.logPath);
|
|
8
|
+
const lines = log.split(/\r?\n/);
|
|
9
|
+
const tail = lines.slice(-200).join('\n');
|
|
10
|
+
return {
|
|
11
|
+
tool: 'unknown',
|
|
12
|
+
status: 'error',
|
|
13
|
+
summary: 'no parser matched; returning tail + log path',
|
|
14
|
+
logPath: ctx.logPath,
|
|
15
|
+
rawTail: tail,
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default parser;
|
|
@@ -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
|
// line N column N - Warning/Error: message
|
|
5
5
|
const ISSUE_LINE = /^line (\d+) column \d+ - (Warning|Error): (.+)$/;
|
|
@@ -7,27 +7,27 @@ const ISSUE_LINE = /^line (\d+) column \d+ - (Warning|Error): (.+)$/;
|
|
|
7
7
|
const SUMMARY_LINE = /^(\d+) warnings?, (\d+) errors? were found/;
|
|
8
8
|
|
|
9
9
|
const parser: ParserModule = {
|
|
10
|
-
id:
|
|
10
|
+
id: 'tidy-text',
|
|
11
11
|
async parse(ctx) {
|
|
12
12
|
const stderr = safeReadFile(ctx.stderrPath).trim();
|
|
13
13
|
if (!stderr) {
|
|
14
14
|
return {
|
|
15
|
-
tool:
|
|
16
|
-
status:
|
|
17
|
-
summary:
|
|
15
|
+
tool: 'tidy',
|
|
16
|
+
status: 'pass',
|
|
17
|
+
summary: 'no issues found',
|
|
18
18
|
failures: [],
|
|
19
19
|
logPath: ctx.logPath,
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const lines = stderr.split(
|
|
23
|
+
const lines = stderr.split('\n');
|
|
24
24
|
const failures: ParsedFailure[] = [];
|
|
25
25
|
let warnings = 0;
|
|
26
26
|
let errors = 0;
|
|
27
27
|
|
|
28
28
|
// Derive filename from command argv — tidy doesn't include filenames in output.
|
|
29
29
|
// Use last non-flag arg since flags like `-indent auto` have value arguments.
|
|
30
|
-
const file = ctx.argv.filter((a) => !a.startsWith(
|
|
30
|
+
const file = ctx.argv.filter((a) => !a.startsWith('-') && a !== 'tidy').pop() ?? 'input';
|
|
31
31
|
|
|
32
32
|
for (const line of lines) {
|
|
33
33
|
const issueMatch = line.match(ISSUE_LINE);
|
|
@@ -50,13 +50,13 @@ const parser: ParserModule = {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const parts: string[] = [];
|
|
53
|
-
if (errors > 0) parts.push(`${errors} error${errors !== 1 ?
|
|
54
|
-
if (warnings > 0) parts.push(`${warnings} warning${warnings !== 1 ?
|
|
55
|
-
const summary = parts.join(
|
|
53
|
+
if (errors > 0) parts.push(`${errors} error${errors !== 1 ? 's' : ''}`);
|
|
54
|
+
if (warnings > 0) parts.push(`${warnings} warning${warnings !== 1 ? 's' : ''}`);
|
|
55
|
+
const summary = parts.join(', ') || 'no issues found';
|
|
56
56
|
|
|
57
57
|
return {
|
|
58
|
-
tool:
|
|
59
|
-
status: errors > 0 ?
|
|
58
|
+
tool: 'tidy',
|
|
59
|
+
status: errors > 0 ? 'fail' : 'pass',
|
|
60
60
|
summary,
|
|
61
61
|
failures,
|
|
62
62
|
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
|
// tsc --pretty false format: file(line,col): error TSXXXX: message
|
|
6
6
|
const TSC_LINE = /^(.+?)\((\d+),(\d+)\):\s+error\s+(TS\d+):\s+(.+)$/;
|
|
7
7
|
|
|
8
8
|
const parser: ParserModule = {
|
|
9
|
-
id:
|
|
9
|
+
id: 'tsc-text',
|
|
10
10
|
async parse(ctx) {
|
|
11
11
|
const raw = safeReadFile(ctx.stdoutPath).trim();
|
|
12
12
|
if (!raw) {
|
|
13
13
|
return {
|
|
14
|
-
tool:
|
|
15
|
-
status:
|
|
16
|
-
summary:
|
|
14
|
+
tool: 'tsc',
|
|
15
|
+
status: 'pass',
|
|
16
|
+
summary: 'no type errors',
|
|
17
17
|
failures: [],
|
|
18
18
|
logPath: ctx.logPath,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const failures: ParsedFailure[] = [];
|
|
23
|
-
for (const line of raw.split(
|
|
23
|
+
for (const line of raw.split('\n')) {
|
|
24
24
|
const m = line.match(TSC_LINE);
|
|
25
25
|
if (!m) continue;
|
|
26
26
|
const [, file, lineNum, , code, message] = m;
|
|
@@ -35,9 +35,9 @@ const parser: ParserModule = {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return {
|
|
38
|
-
tool:
|
|
39
|
-
status: failures.length > 0 ?
|
|
40
|
-
summary: failures.length > 0 ? `${failures.length} type errors` :
|
|
38
|
+
tool: 'tsc',
|
|
39
|
+
status: failures.length > 0 ? 'fail' : 'pass',
|
|
40
|
+
summary: failures.length > 0 ? `${failures.length} type errors` : 'no type errors',
|
|
41
41
|
failures,
|
|
42
42
|
logPath: ctx.logPath,
|
|
43
43
|
};
|
|
@@ -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
|
// unittest output blocks are separated by ======
|
|
6
6
|
// Each block starts with ERROR: or FAIL: line
|
|
@@ -10,12 +10,18 @@ const BLOCK_HEADER = /(ERROR|FAIL):\s+(\S+)\s+\(([^)]+)\)/;
|
|
|
10
10
|
const FILE_LINE = /File\s+"([^"]+)",\s+line\s+(\d+)/;
|
|
11
11
|
|
|
12
12
|
const parser: ParserModule = {
|
|
13
|
-
id:
|
|
13
|
+
id: 'unittest-text',
|
|
14
14
|
async parse(ctx) {
|
|
15
15
|
// Python unittest writes all output (results, tracebacks, summary) to stderr.
|
|
16
16
|
const stderr = safeReadFile(ctx.stderrPath).trim();
|
|
17
17
|
if (!stderr) {
|
|
18
|
-
return {
|
|
18
|
+
return {
|
|
19
|
+
tool: 'unittest',
|
|
20
|
+
status: 'pass',
|
|
21
|
+
summary: 'no output',
|
|
22
|
+
failures: [],
|
|
23
|
+
logPath: ctx.logPath,
|
|
24
|
+
};
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
// Parse the summary line: "Ran N tests in Xs" and "FAILED (failures=N, errors=N)" or "OK"
|
|
@@ -24,13 +30,13 @@ const parser: ParserModule = {
|
|
|
24
30
|
// Parse skipped count from "FAILED (failures=N, skipped=N)" or "OK (skipped=N)"
|
|
25
31
|
const skippedMatch = stderr.match(/skipped=(\d+)/);
|
|
26
32
|
const skipped = skippedMatch ? Number(skippedMatch[1]) : 0;
|
|
27
|
-
const isOk = stderr.includes(
|
|
33
|
+
const isOk = stderr.includes('\nOK');
|
|
28
34
|
|
|
29
35
|
if (isOk) {
|
|
30
36
|
const passed = totalTests - skipped;
|
|
31
37
|
return {
|
|
32
|
-
tool:
|
|
33
|
-
status:
|
|
38
|
+
tool: 'unittest',
|
|
39
|
+
status: 'pass',
|
|
34
40
|
summary: `${passed} passed`,
|
|
35
41
|
failures: [],
|
|
36
42
|
logPath: ctx.logPath,
|
|
@@ -46,7 +52,7 @@ const parser: ParserModule = {
|
|
|
46
52
|
if (!headerMatch) continue;
|
|
47
53
|
|
|
48
54
|
const [, kind, testName] = headerMatch;
|
|
49
|
-
const lines = block.split(
|
|
55
|
+
const lines = block.split('\n');
|
|
50
56
|
|
|
51
57
|
// Find the last File "..." line in the traceback (the user code, not framework)
|
|
52
58
|
let file: string | undefined;
|
|
@@ -80,7 +86,7 @@ const parser: ParserModule = {
|
|
|
80
86
|
traceLines.push(trimmed);
|
|
81
87
|
}
|
|
82
88
|
const nonEmpty = traceLines.filter(Boolean);
|
|
83
|
-
const errorLine = nonEmpty[nonEmpty.length - 1] ??
|
|
89
|
+
const errorLine = nonEmpty[nonEmpty.length - 1] ?? 'test failed';
|
|
84
90
|
|
|
85
91
|
// For assertions, extract expected/actual from "AssertionError: X != Y"
|
|
86
92
|
let message = errorLine;
|
|
@@ -89,14 +95,18 @@ const parser: ParserModule = {
|
|
|
89
95
|
message = assertMatch[1];
|
|
90
96
|
}
|
|
91
97
|
|
|
92
|
-
const relFile = file
|
|
98
|
+
const relFile = file
|
|
99
|
+
? path.isAbsolute(file)
|
|
100
|
+
? path.relative(ctx.cwd, file)
|
|
101
|
+
: file
|
|
102
|
+
: undefined;
|
|
93
103
|
|
|
94
104
|
failures.push({
|
|
95
105
|
id: `${testName}`,
|
|
96
106
|
file: relFile,
|
|
97
107
|
line,
|
|
98
108
|
message,
|
|
99
|
-
rule: kind ===
|
|
109
|
+
rule: kind === 'ERROR' ? 'error' : 'assertion',
|
|
100
110
|
});
|
|
101
111
|
}
|
|
102
112
|
|
|
@@ -104,8 +114,8 @@ const parser: ParserModule = {
|
|
|
104
114
|
const passed = totalTests - failed - skipped;
|
|
105
115
|
|
|
106
116
|
return {
|
|
107
|
-
tool:
|
|
108
|
-
status: failed > 0 ?
|
|
117
|
+
tool: 'unittest',
|
|
118
|
+
status: failed > 0 ? 'fail' : 'pass',
|
|
109
119
|
summary: failed > 0 ? `${failed} failed, ${passed} passed` : `${passed} passed`,
|
|
110
120
|
failures,
|
|
111
121
|
logPath: ctx.logPath,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs from
|
|
1
|
+
import fs from 'node:fs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Safely read a file, returning empty string if it doesn't exist.
|
|
@@ -6,9 +6,9 @@ import fs from "node:fs";
|
|
|
6
6
|
*/
|
|
7
7
|
export function safeReadFile(filePath: string): string {
|
|
8
8
|
try {
|
|
9
|
-
return fs.readFileSync(filePath,
|
|
9
|
+
return fs.readFileSync(filePath, 'utf8');
|
|
10
10
|
} catch (err: unknown) {
|
|
11
|
-
if (err instanceof Error &&
|
|
11
|
+
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') return '';
|
|
12
12
|
throw err;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -21,9 +21,12 @@ export function safeReadFile(filePath: string): string {
|
|
|
21
21
|
* at functionName (file.ts:10:5)
|
|
22
22
|
* at file.ts:10:5
|
|
23
23
|
*/
|
|
24
|
-
export function extractJsStackLocation(stack: string | undefined): {
|
|
24
|
+
export function extractJsStackLocation(stack: string | undefined): {
|
|
25
|
+
file?: string;
|
|
26
|
+
line?: number;
|
|
27
|
+
} {
|
|
25
28
|
if (!stack) return {};
|
|
26
|
-
for (const line of stack.split(
|
|
29
|
+
for (const line of stack.split('\n')) {
|
|
27
30
|
// "at name (file:line:col)"
|
|
28
31
|
const withParens = line.match(/at\s+\S+\s+\(([^)]+\.(?:[jt]sx?|mjs|cjs)):(\d+):\d+\)/);
|
|
29
32
|
if (withParens && isUserFrame(withParens[1])) {
|
|
@@ -39,5 +42,5 @@ export function extractJsStackLocation(stack: string | undefined): { file?: stri
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
function isUserFrame(filePath: string): boolean {
|
|
42
|
-
return !filePath.includes(
|
|
45
|
+
return !filePath.includes('node_modules') && !filePath.includes('node:');
|
|
43
46
|
}
|