@robhowley/pi-structured-return 1.8.0 → 1.9.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
CHANGED
|
@@ -5,6 +5,7 @@ A [Pi](https://pi.dev/) extension that adds a `structured_return` tool alongside
|
|
|
5
5
|
A failing test run, before and after:
|
|
6
6
|
|
|
7
7
|
**Raw pytest output (262 tokens):**
|
|
8
|
+
|
|
8
9
|
```
|
|
9
10
|
============================= test session starts ==============================
|
|
10
11
|
platform darwin -- Python 3.14.2, pytest-9.0.2
|
|
@@ -37,6 +38,7 @@ FAILED test_math.py::test_does_not_divide_by_zero - ZeroDivisionError: ...
|
|
|
37
38
|
```
|
|
38
39
|
|
|
39
40
|
**Structured result returned to the model (56 tokens):**
|
|
41
|
+
|
|
40
42
|
```
|
|
41
43
|
pytest test_math.py --junitxml=.tmp/report.xml → cwd: project
|
|
42
44
|
2 failed, 1 passed
|
|
@@ -64,66 +66,69 @@ Measured with `cl100k_base` (tiktoken). All benchmarks use tiny fixtures — red
|
|
|
64
66
|
|
|
65
67
|
Benchmark: 3 tests — 1 passing, 1 assertion failure, 1 unexpected error.
|
|
66
68
|
|
|
67
|
-
| Tool
|
|
68
|
-
|
|
69
|
-
| `mvn test`
|
|
70
|
-
| `node --test`
|
|
71
|
-
| `npx ava`
|
|
72
|
-
| `go test`
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
| `
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
69
|
+
| Tool | Raw | Structured | Reduction | Notes |
|
|
70
|
+
| --------------------- | ---- | ---------- | --------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
71
|
+
| `mvn test` | 1063 | 86 | **92%** | build lifecycle noise with surefire stack traces per failure |
|
|
72
|
+
| `node --test` | 629 | 64 | **90%** | strips full stack traces, assertion internals, timing; preserves expected/actual |
|
|
73
|
+
| `npx ava` | 483 | 56 | **88%** | source snippets, diffs, full stack traces stripped; expected/actual preserved |
|
|
74
|
+
| `go test` | 394 | 48 | **88%** | stack traces, goroutine frames, panic recovery noise stripped; file:line + expected/actual preserved |
|
|
75
|
+
| `npx playwright test` | 542 | 91 | **83%** | ANSI output, attachment paths, source snippets, and stack traces stripped; file:line + expected/actual preserved |
|
|
76
|
+
| `pest` | 382 | 81 | **79%** | source snippets, test-name prefixes, and repeated file refs stripped; file:line preserved |
|
|
77
|
+
| `dotnet test` | 487 | 107 | **78%** | build header and VSTest output with per-failure stack traces |
|
|
78
|
+
| `npx vitest` | 348 | 75 | **78%** | source diff with inline arrows and ANSI color codes per failure |
|
|
79
|
+
| `python -m unittest` | 231 | 52 | **78%** | full tracebacks with source annotations; expected/actual from AssertionError |
|
|
80
|
+
| `cargo test` | 285 | 68 | **76%** | cargo progress + test binary output with panic traces per failure |
|
|
81
|
+
| `pytest` | 289 | 71 | **75%** | verbose output with source snippets and summary footer |
|
|
82
|
+
| `phpunit` | 288 | 75 | **74%** | method headers and absolute paths stripped; body file:line preferred over tc.line |
|
|
83
|
+
| `rspec` | 212 | 55 | **74%** | default output with backtrace |
|
|
84
|
+
| `gradle test` | 263 | 81 | **69%** | gradle console output with build lifecycle noise |
|
|
85
|
+
| `npx mocha` | 180 | 55 | **69%** | stack traces + assertion diff formatting; expected/actual preserved |
|
|
86
|
+
| `npx jest` | 309 | 99 | **68%** | source annotations with deep jest-circus stack traces per failure |
|
|
87
|
+
| `ruby` (minitest) | 168 | 59 | **65%** | default output with backtrace |
|
|
83
88
|
|
|
84
89
|
### Build tools and compilers
|
|
85
90
|
|
|
86
91
|
Benchmark: 1 file, 1–2 errors. Reduction scales with error count since raw output includes source snippets, caret indicators, and annotations per error.
|
|
87
92
|
|
|
88
|
-
| Tool
|
|
89
|
-
|
|
90
|
-
| `dotnet build`
|
|
91
|
-
| `npx jsonlint`
|
|
92
|
-
| `tidy`
|
|
93
|
-
| `cargo build`
|
|
94
|
-
| `swiftc`
|
|
95
|
-
| `gcc` / `clang` | 109 | 77
|
|
96
|
-
| `javac`
|
|
93
|
+
| Tool | Raw | Structured | Reduction | Notes |
|
|
94
|
+
| --------------- | --- | ---------- | --------- | ------------------------------------------------------------------------------------------ |
|
|
95
|
+
| `dotnet build` | 383 | 53 | **86%** | strips restore/timing noise, deduplicates repeated error lines, absolute paths relativized |
|
|
96
|
+
| `npx jsonlint` | 148 | 28 | **81%** | strips stack trace, source pointer line; preserves line number and expecting message |
|
|
97
|
+
| `tidy` | 233 | 51 | **78%** | strips remediation advice, accessibility tips, reformatted HTML output, Info lines |
|
|
98
|
+
| `cargo build` | 225 | 77 | **66%** | rustc error annotations with code spans and help text per error |
|
|
99
|
+
| `swiftc` | 161 | 58 | **64%** | source annotations with backtick markers deduplicated |
|
|
100
|
+
| `gcc` / `clang` | 109 | 77 | **29%** | strips source snippets, caret indicators, line numbers from gutter |
|
|
101
|
+
| `javac` | 79 | 66 | **16%** | strips source snippets, caret indicators; folds symbol/location into message |
|
|
97
102
|
|
|
98
103
|
### Linters and type checkers
|
|
99
104
|
|
|
100
105
|
Benchmark: 1 file, 1–2 violations. Reduction is a conservative lower bound — scales with file and error count since raw output repeats paths, source snippets, and annotations per violation.
|
|
101
106
|
|
|
102
|
-
| Tool
|
|
103
|
-
|
|
104
|
-
| `isort --check`
|
|
105
|
-
| `black --check`
|
|
106
|
-
| `ruff check`
|
|
107
|
-
| `shellcheck`
|
|
108
|
-
| `npx htmlhint`
|
|
109
|
-
| `vale`
|
|
110
|
-
| `markdownlint`
|
|
111
|
-
| `pyright`
|
|
112
|
-
| `rubocop`
|
|
113
|
-
| `tsc`
|
|
114
|
-
| `stylelint`
|
|
115
|
-
| `pylint`
|
|
116
|
-
| `prettier --check` | 38
|
|
117
|
-
| `hadolint`
|
|
118
|
-
| `eslint`
|
|
119
|
-
| `mypy`
|
|
107
|
+
| Tool | Raw | Structured | Reduction | Notes |
|
|
108
|
+
| ------------------ | --- | ---------- | --------- | -------------------------------------------------------------------------------- |
|
|
109
|
+
| `isort --check` | 143 | 29 | **80%** | strips diff hunks, absolute paths, timestamps; lists files with unsorted imports |
|
|
110
|
+
| `black --check` | 155 | 31 | **80%** | strips diff hunks, emoji, timestamps; lists files needing reformatting |
|
|
111
|
+
| `ruff check` | 107 | 52 | **51%** | source context + help text per error |
|
|
112
|
+
| `shellcheck` | 224 | 117 | **48%** | strips source snippets, carets, suggestions, wiki URLs |
|
|
113
|
+
| `npx htmlhint` | 174 | 92 | **47%** | strips ANSI codes, source evidence, rule descriptions, URLs |
|
|
114
|
+
| `vale` | 141 | 79 | **44%** | strips ANSI codes, Action/Span metadata, column-aligned formatting |
|
|
115
|
+
| `markdownlint` | 199 | 117 | **41%** | strips context quotes, URLs, fix info, error ranges |
|
|
116
|
+
| `pyright` | 100 | 59 | **41%** | strips version, timing, absolute paths; detail lines collapsed |
|
|
117
|
+
| `rubocop` | 149 | 90 | **40%** | strips source snippets, caret indicators, summary line |
|
|
118
|
+
| `tsc` | 107 | 72 | **33%** | vs `--pretty true` default; source snippets and underlines stripped |
|
|
119
|
+
| `stylelint` | 70 | 51 | **27%** | strips summary footer and fix hint |
|
|
120
|
+
| `pylint` | 141 | 120 | **15%** | strips header, score line, separator; scales with error count |
|
|
121
|
+
| `prettier --check` | 38 | 33 | **13%** | strips preamble, [warn] prefixes, footer hint; scales with file count |
|
|
122
|
+
| `hadolint` | 178 | 156 | **12%** | strips ANSI color codes and level labels; measured vs colored output |
|
|
123
|
+
| `eslint` | 64 | 59 | **8%** | already compact formatter |
|
|
124
|
+
| `mypy` | 75 | 72 | **4%** | mypy text is already compact; notes folded into parent errors |
|
|
120
125
|
|
|
121
126
|
### Security and audit
|
|
122
127
|
|
|
123
|
-
| Tool
|
|
124
|
-
|
|
125
|
-
| `bandit`
|
|
126
|
-
| `npm audit` | 158 | 50
|
|
128
|
+
| Tool | Raw | Structured | Reduction | Notes |
|
|
129
|
+
| ----------- | --- | ---------- | --------- | ---------------------------------------------------------------------------------------- |
|
|
130
|
+
| `bandit` | 402 | 99 | **75%** | strips source snippets, CWE URLs, run metrics, confidence labels |
|
|
131
|
+
| `npm audit` | 158 | 50 | **68%** | strips advisory URLs, fix instructions, CVSS vectors; advisory titles joined per package |
|
|
127
132
|
|
|
128
133
|
### Pipeline tools
|
|
129
134
|
|
|
@@ -131,12 +136,12 @@ dbt output is the noisiest tool in this repo relative to useful signal. Every ru
|
|
|
131
136
|
|
|
132
137
|
The numbers below use 3–4 model toy examples; real projects run hundreds of models where the noise scales linearly and reduction compounds.
|
|
133
138
|
|
|
134
|
-
| Tool
|
|
135
|
-
|
|
136
|
-
| `dbt run` (success) | 428 | 20
|
|
137
|
-
| `dbt run` (failure) | 618 | 198
|
|
138
|
-
| `dbt test`
|
|
139
|
-
| `dbt compile`
|
|
139
|
+
| Tool | Raw | Structured | Reduction | Notes |
|
|
140
|
+
| ------------------- | --- | ---------- | --------- | ---------------------------------------------------------------------------- |
|
|
141
|
+
| `dbt run` (success) | 428 | 20 | **95%** | version, adapter, concurrency, per-model start/finish — all noise on success |
|
|
142
|
+
| `dbt run` (failure) | 618 | 198 | **68%** | error messages, model paths, compiled code paths preserved |
|
|
143
|
+
| `dbt test` | 720 | 274 | **62%** | unit test diff tables preserved verbatim; preamble stripped |
|
|
144
|
+
| `dbt compile` | 775 | 683 | **12%** | compiled SQL is the signal and returned verbatim |
|
|
140
145
|
|
|
141
146
|
At 12 models, run failures hit 85% reduction. An 18-model DAG success: 1,645 → 20 tokens (99%).
|
|
142
147
|
|
|
@@ -144,15 +149,15 @@ At 12 models, run failures hit 85% reduction. An 18-model DAG success: 1,645 →
|
|
|
144
149
|
|
|
145
150
|
Evaluated for structured parsing but raw output is already compact enough that a parser adds no reduction (or goes negative). Use `bash` instead of `structured_return` for these tools.
|
|
146
151
|
|
|
147
|
-
| Tool
|
|
148
|
-
|
|
149
|
-
| `go build`
|
|
150
|
-
| `flake8`
|
|
151
|
-
| `yamllint`
|
|
152
|
-
| `golangci-lint` | 59
|
|
153
|
-
| `go vet`
|
|
154
|
-
| `vulture`
|
|
155
|
-
| `pydocstyle`
|
|
152
|
+
| Tool | Raw tokens | Format | Why no parser |
|
|
153
|
+
| --------------- | ---------- | ------------------------------------ | ---------------------------------------------------------------- |
|
|
154
|
+
| `go build` | 85 | `file:line:col: message` | one line per error, no decoration |
|
|
155
|
+
| `flake8` | 75 | `file:line:col: CODE message` | no JSON without a plugin; text is already one line per violation |
|
|
156
|
+
| `yamllint` | 72 | `file:line:col level message (rule)` | filename printed once; one line per issue |
|
|
157
|
+
| `golangci-lint` | 59 | `file:line:col: message (linter)` | text output already minimal; JSON includes massive linter report |
|
|
158
|
+
| `go vet` | ~60 | `file:line:col: message` | same format as `go build` |
|
|
159
|
+
| `vulture` | 58 | `file:line: message (confidence%)` | single line per finding |
|
|
160
|
+
| `pydocstyle` | 48 | `file:line context + CODE: message` | two lines per issue; structured format would repeat file paths |
|
|
156
161
|
|
|
157
162
|
## How it works
|
|
158
163
|
|
|
@@ -220,7 +225,12 @@ export default {
|
|
|
220
225
|
tool: "foo-cli",
|
|
221
226
|
status: data.ok ? "pass" : "fail",
|
|
222
227
|
summary: data.ok ? "passed" : `${data.errors.length} errors`,
|
|
223
|
-
failures: data.errors.map((e, i) => ({
|
|
228
|
+
failures: data.errors.map((e, i) => ({
|
|
229
|
+
id: e.id ?? `error-${i}`,
|
|
230
|
+
file: e.file,
|
|
231
|
+
line: e.line,
|
|
232
|
+
message: e.message,
|
|
233
|
+
})),
|
|
224
234
|
logPath: ctx.logPath,
|
|
225
235
|
};
|
|
226
236
|
},
|
|
@@ -233,13 +243,13 @@ The parser receives a `RunContext` (command, argv, cwd, stdout/stderr paths, art
|
|
|
233
243
|
|
|
234
244
|
Every parser returns the same shape. The model always knows where to look.
|
|
235
245
|
|
|
236
|
-
| Field
|
|
237
|
-
|
|
238
|
-
| `tool`
|
|
239
|
-
| `exitCode` | `number`
|
|
240
|
-
| `status`
|
|
241
|
-
| `summary`
|
|
242
|
-
| `cwd`
|
|
243
|
-
| `failures` | `{ id, file?, line?, message?, rule? }[]` | Per-failure details with relative file paths
|
|
244
|
-
| `logPath`
|
|
245
|
-
| `rawTail`
|
|
246
|
+
| Field | Type | Description |
|
|
247
|
+
| ---------- | ----------------------------------------- | ------------------------------------------------------------------- |
|
|
248
|
+
| `tool` | `string` | Name of the tool that ran (`eslint`, `pytest`, etc.) |
|
|
249
|
+
| `exitCode` | `number` | Raw process exit code |
|
|
250
|
+
| `status` | `pass \| fail \| error` | Normalized outcome |
|
|
251
|
+
| `summary` | `string` | One-line human+model readable result (`3 failed, 12 passed`) |
|
|
252
|
+
| `cwd` | `string` | Working directory — anchor for resolving relative paths in failures |
|
|
253
|
+
| `failures` | `{ id, file?, line?, message?, rule? }[]` | Per-failure details with relative file paths |
|
|
254
|
+
| `logPath` | `string` | Path to full stdout+stderr log |
|
|
255
|
+
| `rawTail` | `string?` | Last 200 lines of log, included on fallback when no parser matched |
|
|
@@ -132,6 +132,20 @@ describe("junit-xml parser", () => {
|
|
|
132
132
|
expect(result.failures![0].line).toBe(42);
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
+
it("non-php keeps testcase line when the body also has a parseable location", async () => {
|
|
136
|
+
const xml = `<testsuite name="MathTest" tests="1" failures="0" errors="1">
|
|
137
|
+
<testcase name="multipliesTwoNumbersCorrectly" classname="MathTest" file="/project/src/test/MyTest.java" line="42" time="0.001">
|
|
138
|
+
<error message="expected: <99> but was: <12>" type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: expected: <99> but was: <12>
|
|
139
|
+
at MathTest.multipliesTwoNumbersCorrectly(MyTest.java:13)
|
|
140
|
+
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
|
|
141
|
+
]]></error>
|
|
142
|
+
</testcase>
|
|
143
|
+
</testsuite>`;
|
|
144
|
+
const result = await parser.parse(makeCtx(xml, "/project"));
|
|
145
|
+
expect(result.failures![0].file).toBe("src/test/MyTest.java");
|
|
146
|
+
expect(result.failures![0].line).toBe(42);
|
|
147
|
+
});
|
|
148
|
+
|
|
135
149
|
it("file on testsuite (not testcase) → used as fallback", async () => {
|
|
136
150
|
const xml = `<testsuite name="suite" tests="1" failures="1" errors="0" file="src/spec/foo_spec.rb">
|
|
137
151
|
${FAILING("test_b", "MyTest", "oops")}
|
|
@@ -147,6 +161,14 @@ describe("junit-xml parser", () => {
|
|
|
147
161
|
const result = await parser.parse(makeCtx(xml));
|
|
148
162
|
expect(result.failures![0].file).toBe("com/example/service/MyTest.java");
|
|
149
163
|
});
|
|
164
|
+
|
|
165
|
+
it("path-like classname with extension is treated as a file, not a java package", async () => {
|
|
166
|
+
const xml = `<testsuite name="suite" tests="1" failures="1" errors="0">
|
|
167
|
+
${FAILING("test_b", "math.test.ts", "oops")}
|
|
168
|
+
</testsuite>`;
|
|
169
|
+
const result = await parser.parse(makeCtx(xml));
|
|
170
|
+
expect(result.failures![0].file).toBe("math.test.ts");
|
|
171
|
+
});
|
|
150
172
|
});
|
|
151
173
|
|
|
152
174
|
describe("failure message", () => {
|
|
@@ -321,6 +343,183 @@ Received: 12
|
|
|
321
343
|
});
|
|
322
344
|
});
|
|
323
345
|
|
|
346
|
+
describe("playwright --reporter=junit output", () => {
|
|
347
|
+
it("extracts file, line, and message from failure and error elements", async () => {
|
|
348
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
349
|
+
<testsuites id="" name="" tests="3" failures="1" skipped="0" errors="1" time="0.488">
|
|
350
|
+
<testsuite name="math.test.ts" tests="3" failures="1" errors="1" skipped="0" time="0.004">
|
|
351
|
+
<testcase name="basic math › adds two numbers correctly" classname="math.test.ts" time="0.002"></testcase>
|
|
352
|
+
<testcase name="basic math › multiplies two numbers correctly" classname="math.test.ts" time="0.001">
|
|
353
|
+
<failure message="expect(received).toBe(expected) // Object.is equality" type="expect.toBe">
|
|
354
|
+
<![CDATA[ math.test.ts:8:7 › basic math › multiplies two numbers correctly
|
|
355
|
+
|
|
356
|
+
Error: expect(received).toBe(expected) // Object.is equality
|
|
357
|
+
|
|
358
|
+
Expected: 99
|
|
359
|
+
Received: 12
|
|
360
|
+
|
|
361
|
+
7 |
|
|
362
|
+
8 | test("multiplies two numbers correctly", () => {
|
|
363
|
+
> 9 | expect(3 * 4).toBe(99);
|
|
364
|
+
| ^
|
|
365
|
+
10 | });
|
|
366
|
+
at /project/math.test.ts:9:19
|
|
367
|
+
]]>
|
|
368
|
+
</failure>
|
|
369
|
+
</testcase>
|
|
370
|
+
<testcase name="basic math › does not divide by zero" classname="math.test.ts" time="0.001">
|
|
371
|
+
<error message="Cannot read properties of null (reading 'value')" type="TypeError">
|
|
372
|
+
<![CDATA[ math.test.ts:12:7 › basic math › does not divide by zero
|
|
373
|
+
|
|
374
|
+
TypeError: Cannot read properties of null (reading 'value')
|
|
375
|
+
|
|
376
|
+
11 |
|
|
377
|
+
12 | test("does not divide by zero", () => {
|
|
378
|
+
> 13 | const result = (null as unknown as Record<string, number>).value;
|
|
379
|
+
| ^
|
|
380
|
+
at /project/math.test.ts:13:64
|
|
381
|
+
]]>
|
|
382
|
+
</error>
|
|
383
|
+
</testcase>
|
|
384
|
+
</testsuite>
|
|
385
|
+
</testsuites>`;
|
|
386
|
+
const result = await parser.parse(makeCtx(xml, "/project"));
|
|
387
|
+
expect(result.status).toBe("fail");
|
|
388
|
+
expect(result.summary).toBe("2 failed, 1 passed");
|
|
389
|
+
expect(result.failures![0].file).toBe("math.test.ts");
|
|
390
|
+
expect(result.failures![0].line).toBe(9);
|
|
391
|
+
expect(result.failures![0].message).toContain("expect(received).toBe(expected)");
|
|
392
|
+
expect(result.failures![0].message).toContain("Expected: 99");
|
|
393
|
+
expect(result.failures![0].message).toContain("Received: 12");
|
|
394
|
+
expect(result.failures![1].file).toBe("math.test.ts");
|
|
395
|
+
expect(result.failures![1].line).toBe(13);
|
|
396
|
+
expect(result.failures![1].message).toBe("Cannot read properties of null (reading 'value')");
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
describe("phpunit output", () => {
|
|
401
|
+
it("extracts file:line from body when tc.line is method definition line", async () => {
|
|
402
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
403
|
+
<testsuites>
|
|
404
|
+
<testsuite name="MathTest" file="/project/MathTest.php" tests="2" assertions="2" errors="0" failures="1">
|
|
405
|
+
<testcase name="testAddsTwoNumbersCorrectly" file="/project/MathTest.php" line="9" class="MathTest" classname="MathTest" assertions="1" time="0.000"/>
|
|
406
|
+
<testcase name="testMultipliesTwoNumbersCorrectly" file="/project/MathTest.php" line="14" class="MathTest" classname="MathTest" assertions="1" time="0.001">
|
|
407
|
+
<failure type="PHPUnit\\Framework\\ExpectationFailedException">MathTest::testMultipliesTwoNumbersCorrectly
|
|
408
|
+
Failed asserting that 12 is identical to 99.
|
|
409
|
+
|
|
410
|
+
/project/MathTest.php:16</failure>
|
|
411
|
+
</testcase>
|
|
412
|
+
</testsuite>
|
|
413
|
+
</testsuites>`;
|
|
414
|
+
const result = await parser.parse(makeCtx(xml, "/project"));
|
|
415
|
+
expect(result.status).toBe("fail");
|
|
416
|
+
expect(result.summary).toBe("1 failed, 1 passed");
|
|
417
|
+
expect(result.failures![0].file).toBe("MathTest.php");
|
|
418
|
+
expect(result.failures![0].line).toBe(16);
|
|
419
|
+
expect(result.failures![0].message).toBe("Failed asserting that 12 is identical to 99.");
|
|
420
|
+
expect(result.failures![0].rule).toBe("PHPUnit\\Framework\\ExpectationFailedException");
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it("handles deeply nested testsuites (PHPUnit wraps in 3 levels)", async () => {
|
|
424
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
425
|
+
<testsuites>
|
|
426
|
+
<testsuite name="phpunit.xml" tests="3" assertions="2" errors="1" failures="1">
|
|
427
|
+
<testsuite name="default" tests="3" assertions="2" errors="1" failures="1">
|
|
428
|
+
<testsuite name="MathTest" file="/project/MathTest.php" tests="3" assertions="2" errors="1" failures="1">
|
|
429
|
+
<testcase name="testAddsTwoNumbersCorrectly" file="/project/MathTest.php" line="9" class="MathTest" classname="MathTest" assertions="1" time="0.000"/>
|
|
430
|
+
<testcase name="testMultipliesTwoNumbersCorrectly" file="/project/MathTest.php" line="14" class="MathTest" classname="MathTest" assertions="1" time="0.001">
|
|
431
|
+
<failure type="PHPUnit\\Framework\\ExpectationFailedException">MathTest::testMultipliesTwoNumbersCorrectly
|
|
432
|
+
Failed asserting that 12 is identical to 99.
|
|
433
|
+
|
|
434
|
+
/project/MathTest.php:16</failure>
|
|
435
|
+
</testcase>
|
|
436
|
+
<testcase name="testDoesNotDivideByZero" file="/project/MathTest.php" line="19" class="MathTest" classname="MathTest" assertions="0" time="0.000">
|
|
437
|
+
<error type="DivisionByZeroError">MathTest::testDoesNotDivideByZero
|
|
438
|
+
DivisionByZeroError: Division by zero
|
|
439
|
+
|
|
440
|
+
/project/MathTest.php:21</error>
|
|
441
|
+
</testcase>
|
|
442
|
+
</testsuite>
|
|
443
|
+
</testsuite>
|
|
444
|
+
</testsuite>
|
|
445
|
+
</testsuites>`;
|
|
446
|
+
const result = await parser.parse(makeCtx(xml, "/project"));
|
|
447
|
+
expect(result.status).toBe("fail");
|
|
448
|
+
expect(result.summary).toBe("2 failed, 1 passed");
|
|
449
|
+
expect(result.failures).toHaveLength(2);
|
|
450
|
+
expect(result.failures![0].file).toBe("MathTest.php");
|
|
451
|
+
expect(result.failures![0].line).toBe(16);
|
|
452
|
+
expect(result.failures![1].file).toBe("MathTest.php");
|
|
453
|
+
expect(result.failures![1].line).toBe(21);
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
it("extracts file:line from error body for exceptions", async () => {
|
|
457
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
458
|
+
<testsuites>
|
|
459
|
+
<testsuite name="MathTest" file="/project/MathTest.php" tests="1" assertions="0" errors="1" failures="0">
|
|
460
|
+
<testcase name="testDoesNotDivideByZero" file="/project/MathTest.php" line="19" class="MathTest" classname="MathTest" assertions="0" time="0.000">
|
|
461
|
+
<error type="DivisionByZeroError">MathTest::testDoesNotDivideByZero
|
|
462
|
+
DivisionByZeroError: Division by zero
|
|
463
|
+
|
|
464
|
+
/project/MathTest.php:21</error>
|
|
465
|
+
</testcase>
|
|
466
|
+
</testsuite>
|
|
467
|
+
</testsuites>`;
|
|
468
|
+
const result = await parser.parse(makeCtx(xml, "/project"));
|
|
469
|
+
expect(result.status).toBe("fail");
|
|
470
|
+
expect(result.failures![0].file).toBe("MathTest.php");
|
|
471
|
+
expect(result.failures![0].line).toBe(21);
|
|
472
|
+
expect(result.failures![0].message).toBe("DivisionByZeroError: Division by zero");
|
|
473
|
+
expect(result.failures![0].rule).toBe("DivisionByZeroError");
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
describe("pest (PHP) output", () => {
|
|
478
|
+
it("handles nested testsuites and extracts file:line from Pest stack frames", async () => {
|
|
479
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
480
|
+
<testsuites>
|
|
481
|
+
<testsuite name="phpunit.xml" tests="3" assertions="2" errors="1" failures="1" skipped="0" time="0.012">
|
|
482
|
+
<testsuite name="Tests" tests="3" assertions="2" errors="1" failures="1" skipped="0" time="0.012">
|
|
483
|
+
<testsuite name="Tests\\MathTest" file="tests/MathTest.php" tests="3" assertions="2" errors="1" failures="1" skipped="0" time="0.012">
|
|
484
|
+
<testcase name="it adds two numbers correctly" file="tests/MathTest.php::it adds two numbers correctly" class="Tests\\MathTest" classname="Tests.MathTest" assertions="1" time="0.005"/>
|
|
485
|
+
<testcase name="it multiplies two numbers correctly" file="tests/MathTest.php::it multiplies two numbers correctly" class="Tests\\MathTest" classname="Tests.MathTest" assertions="1" time="0.007">
|
|
486
|
+
<failure type="PHPUnit\\Framework\\ExpectationFailedException">it multiplies two numbers correctlyFailed asserting that 12 is identical to 99.
|
|
487
|
+
at tests/MathTest.php:8</failure>
|
|
488
|
+
</testcase>
|
|
489
|
+
<testcase name="it does not divide by zero" file="tests/MathTest.php::it does not divide by zero" class="Tests\\MathTest" classname="Tests.MathTest" assertions="0" time="0.0003">
|
|
490
|
+
<error type="DivisionByZeroError">it does not divide by zeroDivisionByZeroError: Division by zero
|
|
491
|
+
at tests/MathTest.php:12</error>
|
|
492
|
+
</testcase>
|
|
493
|
+
</testsuite>
|
|
494
|
+
</testsuite>
|
|
495
|
+
</testsuite>
|
|
496
|
+
</testsuites>`;
|
|
497
|
+
const result = await parser.parse(makeCtx(xml, "/project"));
|
|
498
|
+
expect(result.status).toBe("fail");
|
|
499
|
+
expect(result.summary).toBe("2 failed, 1 passed");
|
|
500
|
+
expect(result.failures).toHaveLength(2);
|
|
501
|
+
expect(result.failures![0].file).toBe("tests/MathTest.php");
|
|
502
|
+
expect(result.failures![0].line).toBe(8);
|
|
503
|
+
expect(result.failures![0].message).toBe("Failed asserting that 12 is identical to 99.");
|
|
504
|
+
expect(result.failures![0].rule).toBe("PHPUnit\\Framework\\ExpectationFailedException");
|
|
505
|
+
expect(result.failures![1].file).toBe("tests/MathTest.php");
|
|
506
|
+
expect(result.failures![1].line).toBe(12);
|
|
507
|
+
expect(result.failures![1].message).toBe("DivisionByZeroError: Division by zero");
|
|
508
|
+
expect(result.failures![1].rule).toBe("DivisionByZeroError");
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it("strips '::test name' suffix from file attributes", async () => {
|
|
512
|
+
const xml = `<testsuite name="Tests\\MathTest" file="tests/MathTest.php" tests="1" failures="1" errors="0">
|
|
513
|
+
<testcase name="it fails" file="tests/MathTest.php::it fails" classname="Tests.MathTest">
|
|
514
|
+
<failure type="Error">it failsOops
|
|
515
|
+
at tests/MathTest.php:5</failure>
|
|
516
|
+
</testcase>
|
|
517
|
+
</testsuite>`;
|
|
518
|
+
const result = await parser.parse(makeCtx(xml, "/project"));
|
|
519
|
+
expect(result.failures![0].file).toBe("tests/MathTest.php");
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
|
|
324
523
|
describe("multi-suite totals", () => {
|
|
325
524
|
it("failures and errors summed across suites", async () => {
|
|
326
525
|
const xml = `<testsuites>
|
|
@@ -338,6 +537,24 @@ Received: 12
|
|
|
338
537
|
expect(result.summary).toBe("2 failed, 2 passed");
|
|
339
538
|
expect(result.failures).toHaveLength(2);
|
|
340
539
|
});
|
|
540
|
+
|
|
541
|
+
it("collects direct and nested testcases without double counting", async () => {
|
|
542
|
+
const xml = `<testsuites>
|
|
543
|
+
<testsuite name="root" tests="3" failures="2" errors="0">
|
|
544
|
+
${FAILING("direct_failure", "RootTest", "direct broke")}
|
|
545
|
+
<testsuite name="nested" tests="2" failures="1" errors="0">
|
|
546
|
+
${PASSING("nested_pass", "NestedTest")}
|
|
547
|
+
${FAILING("nested_failure", "NestedTest", "nested broke")}
|
|
548
|
+
</testsuite>
|
|
549
|
+
</testsuite>
|
|
550
|
+
</testsuites>`;
|
|
551
|
+
const result = await parser.parse(makeCtx(xml));
|
|
552
|
+
expect(result.status).toBe("fail");
|
|
553
|
+
expect(result.summary).toBe("2 failed, 1 passed");
|
|
554
|
+
expect(result.failures).toHaveLength(2);
|
|
555
|
+
expect(result.failures![0].message).toBe("direct broke");
|
|
556
|
+
expect(result.failures![1].message).toBe("nested broke");
|
|
557
|
+
});
|
|
341
558
|
});
|
|
342
559
|
|
|
343
560
|
describe("multi-file artifact paths (Gradle-style)", () => {
|
|
@@ -25,6 +25,7 @@ interface JUnitTestSuite {
|
|
|
25
25
|
failures?: string | number;
|
|
26
26
|
errors?: string | number;
|
|
27
27
|
testcase?: JUnitTestCase[];
|
|
28
|
+
testsuite?: JUnitTestSuite[]; // PHPUnit nests testsuites
|
|
28
29
|
"system-out"?: string;
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -46,6 +47,14 @@ function decodeXmlEntities(s: string): string {
|
|
|
46
47
|
.replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(Number(dec)));
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
/** Strip a Pest-style test name prefix from a failure body.
|
|
51
|
+
* Pest can concatenate the test name directly with the error message, e.g.
|
|
52
|
+
* "it multiplies two numbers correctlyFailed asserting that 12 is identical to 99." */
|
|
53
|
+
function stripPestTestNamePrefix(text: string, testName?: string): string {
|
|
54
|
+
if (!testName || !text.startsWith(testName)) return text;
|
|
55
|
+
return text.slice(testName.length).trimStart();
|
|
56
|
+
}
|
|
57
|
+
|
|
49
58
|
/** Extract Expected/Received/Actual diff lines from a failure body, e.g. Jest assertion output. */
|
|
50
59
|
function extractAssertionDiff(text: string): string | undefined {
|
|
51
60
|
const diffLines: string[] = [];
|
|
@@ -60,6 +69,9 @@ function extractAssertionDiff(text: string): string | undefined {
|
|
|
60
69
|
* Handles:
|
|
61
70
|
* - pytest-style: "file.py:line: message"
|
|
62
71
|
* - Go-style: " file.go:line: message"
|
|
72
|
+
* - Playwright-style: "at /path/file.ts:line:col"
|
|
73
|
+
* - Pest-style: "at tests/MathTest.php:8"
|
|
74
|
+
* - PHPUnit-style: "/path/to/File.php:21" trailer lines
|
|
63
75
|
* - .NET-style: "in /path/File.cs:line N"
|
|
64
76
|
* - Java/JVM-style: "at [module/]pkg.Class.method(File.java:N)"
|
|
65
77
|
* preferring the frame whose class matches `classname`. */
|
|
@@ -72,6 +84,30 @@ function parseBodyLocation(
|
|
|
72
84
|
.map((l) => l.trim())
|
|
73
85
|
.filter(Boolean);
|
|
74
86
|
|
|
87
|
+
const phpMessage = () =>
|
|
88
|
+
lines.find((l) => !/^\w+::\w+/.test(l) && !/^at\s+.+?\.php:\d+$/.test(l) && !/^.+?\.php:\d+$/.test(l));
|
|
89
|
+
|
|
90
|
+
// Check stack frames first so Playwright/Jest locations win over header lines like
|
|
91
|
+
// "math.test.ts:8:7 › suite › test", which would otherwise match the generic file:line pattern.
|
|
92
|
+
for (const line of lines) {
|
|
93
|
+
const m = line.match(/^at\s+\S+\s+\(([^)]+\.(?:[jt]sx?|mjs|cjs)):(\d+):\d+\)/);
|
|
94
|
+
if (m && !m[1].includes("node_modules")) {
|
|
95
|
+
return { file: path.basename(m[1]), line: Number(m[2]) };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (const line of lines) {
|
|
100
|
+
const m = line.match(/^at\s+(.+?\.(?:[jt]sx?|mjs|cjs)):(\d+):\d+$/);
|
|
101
|
+
if (m && !m[1].includes("node_modules")) {
|
|
102
|
+
return { file: path.basename(m[1]), line: Number(m[2]) };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
for (const line of lines) {
|
|
107
|
+
const m = line.match(/^at\s+(.+?\.php):(\d+)$/);
|
|
108
|
+
if (m) return { file: m[1], line: Number(m[2]) };
|
|
109
|
+
}
|
|
110
|
+
|
|
75
111
|
// pytest / Go: "file.ext:line: message"
|
|
76
112
|
for (const line of lines) {
|
|
77
113
|
const m = line.match(/^([^:\s]+\.\w+):(\d+):\s*(.*)/);
|
|
@@ -84,14 +120,6 @@ function parseBodyLocation(
|
|
|
84
120
|
if (m) return { file: path.basename(m[1]), line: Number(m[2]) };
|
|
85
121
|
}
|
|
86
122
|
|
|
87
|
-
// Jest/Node-style: " at Something (file.js:line:col)" — skip node_modules frames
|
|
88
|
-
for (const line of lines) {
|
|
89
|
-
const m = line.match(/^at\s+\S+\s+\(([^)]+\.(?:[jt]sx?|mjs|cjs)):(\d+):\d+\)/);
|
|
90
|
-
if (m && !m[1].includes("node_modules")) {
|
|
91
|
-
return { file: path.basename(m[1]), line: Number(m[2]) };
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
123
|
// Java/JVM: "at [module/]pkg.Class.method(File.java:N)"
|
|
96
124
|
const javaRe = /^at (?:[\w.$]+\/)?([\w.$]+)\.\w+\(([\w]+\.(?:java|kt|scala|groovy)):(\d+)\)$/;
|
|
97
125
|
const frameworkPrefixes = ["java.", "javax.", "sun.", "com.sun.", "org.junit.", "org.opentest4j.", "junit."];
|
|
@@ -109,6 +137,17 @@ function parseBodyLocation(
|
|
|
109
137
|
}
|
|
110
138
|
|
|
111
139
|
if (firstUserFrame) return firstUserFrame;
|
|
140
|
+
|
|
141
|
+
for (const line of lines) {
|
|
142
|
+
const m = line.match(/^(.+?\.php):(\d+)$/);
|
|
143
|
+
if (m) return { file: m[1], line: Number(m[2]), message: phpMessage() };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
for (const line of lines) {
|
|
147
|
+
const m = line.match(/(?:^#\d+\s+)?(.+?\.php)\((\d+)\)(?::|$)/);
|
|
148
|
+
if (m) return { file: m[1], line: Number(m[2]), message: phpMessage() };
|
|
149
|
+
}
|
|
150
|
+
|
|
112
151
|
return undefined;
|
|
113
152
|
}
|
|
114
153
|
|
|
@@ -136,12 +175,40 @@ function parsePanicInfo(
|
|
|
136
175
|
return { message };
|
|
137
176
|
}
|
|
138
177
|
|
|
178
|
+
function resolveClassnameFile(classname?: string): string | undefined {
|
|
179
|
+
if (!classname) return undefined;
|
|
180
|
+
const normalized = classname.replace(/\\/g, "/");
|
|
181
|
+
if (/\.(?:[jt]sx?|mjs|cjs|py|rb|go|php|cs|fs|vb|java|kt|scala|groovy)$/.test(normalized)) {
|
|
182
|
+
return normalized;
|
|
183
|
+
}
|
|
184
|
+
if (normalized.includes("/")) return undefined;
|
|
185
|
+
if (/^[\w$]+(?:\.[\w$]+)*$/.test(classname)) {
|
|
186
|
+
return classname.replace(/\./g, "/") + ".java";
|
|
187
|
+
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
|
|
139
191
|
function resolveFile(tc: JUnitTestCase, suite: JUnitTestSuite, cwd: string): string | undefined {
|
|
140
|
-
const raw = tc.file ?? suite.file;
|
|
192
|
+
const raw = (tc.file ?? suite.file)?.split("::")[0];
|
|
141
193
|
if (raw) return path.relative(cwd, path.resolve(cwd, raw));
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
194
|
+
return resolveClassnameFile(tc.classname);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function isPhpFile(candidate?: string): boolean {
|
|
198
|
+
if (!candidate) return false;
|
|
199
|
+
return candidate.split("::")[0].replace(/\\/g, "/").endsWith(".php");
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Recursively collect all testsuites including nested ones (PHPUnit/Pest style). */
|
|
203
|
+
function flattenSuites(suites: JUnitTestSuite[]): JUnitTestSuite[] {
|
|
204
|
+
const result: JUnitTestSuite[] = [];
|
|
205
|
+
for (const suite of suites) {
|
|
206
|
+
result.push(suite);
|
|
207
|
+
if (suite.testsuite) {
|
|
208
|
+
result.push(...flattenSuites(suite.testsuite));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return result;
|
|
145
212
|
}
|
|
146
213
|
|
|
147
214
|
const parser: ParserModule = {
|
|
@@ -158,12 +225,18 @@ const parser: ParserModule = {
|
|
|
158
225
|
if (!xml.trim()) continue;
|
|
159
226
|
const doc = xmlParser.parse(xml) as JUnitDocument;
|
|
160
227
|
|
|
161
|
-
const
|
|
228
|
+
const topLevelSuites: JUnitTestSuite[] = doc.testsuites?.testsuite ?? doc.testsuite ?? [];
|
|
162
229
|
|
|
163
|
-
|
|
230
|
+
// Count tests/failures from top-level only (nested suites report aggregates)
|
|
231
|
+
for (const suite of topLevelSuites) {
|
|
164
232
|
totalTests += Number(suite.tests ?? 0);
|
|
165
233
|
totalFailed += Number(suite.failures ?? 0) + Number(suite.errors ?? 0);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Process testcases from all suites including nested ones (PHPUnit nests testsuites)
|
|
237
|
+
const allSuites = flattenSuites(topLevelSuites);
|
|
166
238
|
|
|
239
|
+
for (const suite of allSuites) {
|
|
167
240
|
for (const tc of suite.testcase ?? []) {
|
|
168
241
|
const rawProblem = tc.failure ?? tc.error;
|
|
169
242
|
if (!rawProblem) continue;
|
|
@@ -176,7 +249,14 @@ const parser: ParserModule = {
|
|
|
176
249
|
(tc.file ?? suite.file)
|
|
177
250
|
? resolveFile(tc, suite, ctx.cwd)
|
|
178
251
|
: (bodyLocation?.file ?? panicInfo?.file ?? resolveFile(tc, suite, ctx.cwd));
|
|
179
|
-
const
|
|
252
|
+
const tcLine = tc.line !== undefined ? Number(tc.line) : undefined;
|
|
253
|
+
// PHPUnit/Pest report tc.line as the test method definition line, not the failure line.
|
|
254
|
+
// Other JUnit producers historically prefer tc.line when it is present.
|
|
255
|
+
const preferBodyLine =
|
|
256
|
+
isPhpFile(file) || isPhpFile(tc.file) || isPhpFile(suite.file) || isPhpFile(bodyLocation?.file);
|
|
257
|
+
const line = preferBodyLine
|
|
258
|
+
? (bodyLocation?.line ?? panicInfo?.line ?? tcLine)
|
|
259
|
+
: (tcLine ?? bodyLocation?.line ?? panicInfo?.line);
|
|
180
260
|
const id = [file, line, tc.name].filter(Boolean).join(":");
|
|
181
261
|
|
|
182
262
|
failures.push({
|
|
@@ -184,7 +264,7 @@ const parser: ParserModule = {
|
|
|
184
264
|
file,
|
|
185
265
|
line: Number.isNaN(line) ? undefined : line,
|
|
186
266
|
message: (() => {
|
|
187
|
-
|
|
267
|
+
let raw =
|
|
188
268
|
problem.message && problem.message.toLowerCase() !== "failed"
|
|
189
269
|
? problem.message
|
|
190
270
|
: (bodyLocation?.message ??
|
|
@@ -192,6 +272,7 @@ const parser: ParserModule = {
|
|
|
192
272
|
problem.message ??
|
|
193
273
|
problem["#text"]?.trim().split("\n")[0]);
|
|
194
274
|
if (!raw) return undefined;
|
|
275
|
+
raw = stripPestTestNamePrefix(raw, tc.name);
|
|
195
276
|
const decoded = decodeXmlEntities(raw);
|
|
196
277
|
// Append assertion diff lines (Expected/Received/Actual) from the body when not already present.
|
|
197
278
|
// Covers Jest-style failures where the diff follows the error type line in #text.
|
package/package.json
CHANGED
|
@@ -25,119 +25,155 @@ Prefer better output at the source.
|
|
|
25
25
|
## Examples
|
|
26
26
|
|
|
27
27
|
### pytest
|
|
28
|
+
|
|
28
29
|
- `structured_return({ command: "pytest [any pytest args] --junitxml=.tmp/report.xml", parseAs: "junit-xml", artifactPaths: [".tmp/report.xml"] })` — `--junitxml` is built into pytest, no extra dependencies needed; scope, filters, markers, etc. go in `[any pytest args]`
|
|
29
30
|
|
|
30
31
|
### ruff check
|
|
32
|
+
|
|
31
33
|
- `structured_return({ command: "ruff check [any ruff args] --output-format=json", parseAs: "ruff-json" })` — scope, selects, ignores, etc. go in `[any ruff args]`
|
|
32
34
|
|
|
33
35
|
### mypy
|
|
36
|
+
|
|
34
37
|
- `structured_return({ command: "mypy [any mypy args] --output json", parseAs: "mypy-json" })` — `--output json` is built into mypy (1.0+); outputs NDJSON to stderr with file, line, column, message, error code, and severity; notes are folded into their parent error's message
|
|
35
38
|
|
|
36
39
|
### htmlhint
|
|
40
|
+
|
|
37
41
|
- `structured_return({ command: "npx htmlhint --format json [any htmlhint args]", parseAs: "htmlhint-json" })` — `--format json` outputs structured array; strips ANSI codes, source evidence, rule descriptions, and URLs
|
|
38
42
|
|
|
39
43
|
### isort
|
|
44
|
+
|
|
40
45
|
- `structured_return({ command: "isort --check --diff [any isort args]", parseAs: "isort-text" })` — parses `--check` output; strips diff hunks, absolute paths, timestamps; lists files with unsorted imports
|
|
41
46
|
|
|
42
47
|
### npm audit
|
|
48
|
+
|
|
43
49
|
- `structured_return({ command: "npm audit --json", parseAs: "npm-audit-json" })` — `--json` is built into npm; strips advisory URLs, CVSS vectors, fix instructions; advisory titles joined per package; severity breakdown in summary
|
|
44
50
|
|
|
45
51
|
### jsonlint
|
|
52
|
+
|
|
46
53
|
- `structured_return({ command: "npx jsonlint [file]", parseAs: "jsonlint-text" })` — strips stack trace and source pointer; extracts line number and "Expecting X, got Y" message
|
|
47
54
|
|
|
48
55
|
### tidy (HTML Tidy)
|
|
56
|
+
|
|
49
57
|
- `structured_return({ command: "tidy -errors [any tidy args]", parseAs: "tidy-text" })` — parses `line N column N - Warning/Error: message` from stderr; strips remediation advice, accessibility tips, reformatted HTML output, and Info lines
|
|
50
58
|
|
|
51
59
|
### vale
|
|
60
|
+
|
|
52
61
|
- `structured_return({ command: "vale --output JSON [any vale args]", parseAs: "vale-json" })` — `--output JSON` is built into vale; strips ANSI codes, Action/Span metadata, column-aligned formatting; severity breakdown in summary
|
|
53
62
|
|
|
54
63
|
### prettier
|
|
64
|
+
|
|
55
65
|
- `structured_return({ command: "prettier --check [any prettier args]", parseAs: "prettier-text" })` — parses `--check` output; strips "Checking formatting..." preamble, [warn] prefixes, and "Run Prettier with --write to fix" footer
|
|
56
66
|
|
|
57
67
|
### markdownlint
|
|
68
|
+
|
|
58
69
|
- `structured_return({ command: "markdownlint --json [any markdownlint args]", parseAs: "markdownlint-json" })` — `--json` outputs structured array; strips context quotes, rule info URLs, fix info, and error ranges; error details folded into description
|
|
59
70
|
|
|
60
71
|
### black
|
|
72
|
+
|
|
61
73
|
- `structured_return({ command: "black --check [any black args]", parseAs: "black-text" })` — parses `--check` output; strips diff hunks, emoji banners, timestamps; lists files needing reformatting; also handles `--check --diff` mode
|
|
62
74
|
|
|
63
75
|
### bandit
|
|
76
|
+
|
|
64
77
|
- `structured_return({ command: "bandit -f json [any bandit args]", parseAs: "bandit-json" })` — `-f json` is built into bandit; strips source snippets, CWE URLs, run metrics, and confidence labels; severity breakdown in summary
|
|
65
78
|
|
|
66
79
|
### gcc / clang
|
|
80
|
+
|
|
67
81
|
- `structured_return({ command: "gcc -c [any gcc args]", parseAs: "clang-text" })` — works with gcc, g++, clang, clang++; parses `file:line:col: error: message` from stderr; source snippets and caret indicators stripped; warning flags preserved as rule
|
|
68
82
|
|
|
69
83
|
### dotnet build
|
|
84
|
+
|
|
70
85
|
- `structured_return({ command: "dotnet build [any dotnet args]", parseAs: "dotnet-build-text" })` — parses MSBuild `file(line,col): error CODE: message` format; strips restore/timing noise; deduplicates the inline+summary error repetition; absolute paths relativized
|
|
71
86
|
|
|
72
87
|
### javac
|
|
88
|
+
|
|
73
89
|
- `structured_return({ command: "javac [any javac args]", parseAs: "javac-text" })` — parses `file:line: error: message` from stderr; source snippets and caret indicators stripped; `cannot find symbol` errors fold the symbol continuation line into the message
|
|
74
90
|
|
|
75
91
|
### pyright
|
|
92
|
+
|
|
76
93
|
- `structured_return({ command: "pyright --outputjson [any pyright args]", parseAs: "pyright-json" })` — `--outputjson` is built into pyright; JSON output includes file, line, message, and rule code; multi-line detail messages collapsed; warnings excluded from failures
|
|
77
94
|
|
|
78
95
|
### tsc
|
|
96
|
+
|
|
79
97
|
- `structured_return({ command: "tsc --noEmit --pretty false [any tsc args]", parseAs: "tsc-text" })` — `--pretty false` suppresses source snippets and ANSI codes; parser extracts file, line, TS error code, and message from the compact `file(line,col): error TSXXXX: message` format
|
|
80
98
|
|
|
81
99
|
### pylint
|
|
100
|
+
|
|
82
101
|
- `structured_return({ command: "pylint [any pylint args] --output-format=json", parseAs: "pylint-json" })` — `--output-format=json` is built into pylint; rule includes both message-id and symbol name (e.g. `W0612(unused-variable)`)
|
|
83
102
|
|
|
84
103
|
### shellcheck
|
|
104
|
+
|
|
85
105
|
- `structured_return({ command: "shellcheck [any shellcheck args] --format=json", parseAs: "shellcheck-json" })` — `--format=json` is built into shellcheck; strips source snippets, caret indicators, "Did you mean" suggestions, and wiki URLs
|
|
86
106
|
|
|
87
107
|
### rubocop
|
|
108
|
+
|
|
88
109
|
- `structured_return({ command: "rubocop [any rubocop args] --format json", parseAs: "rubocop-json" })` — `--format json` is built into rubocop; cop name prefix stripped from messages; source snippets and caret indicators removed
|
|
89
110
|
|
|
90
111
|
### swiftc
|
|
112
|
+
|
|
91
113
|
- `structured_return({ command: "swiftc -typecheck [any swiftc args]", parseAs: "swiftc-text" })` — parses `file:line:col: error: message` from stderr; source annotations and duplicate error lines deduplicated; warnings filtered out
|
|
92
114
|
|
|
93
115
|
### hadolint
|
|
116
|
+
|
|
94
117
|
- `structured_return({ command: "hadolint [any hadolint args] --format json", parseAs: "hadolint-json" })` — `--format json` is built into hadolint; strips ANSI color codes and level labels from text output
|
|
95
118
|
|
|
96
119
|
### stylelint
|
|
120
|
+
|
|
97
121
|
- `structured_return({ command: "stylelint [any stylelint args] --formatter json", parseAs: "stylelint-json" })` — `--formatter json` is built into stylelint; rule name suffix stripped from message text; requires a `.stylelintrc` config
|
|
98
122
|
|
|
99
123
|
### node --test
|
|
124
|
+
|
|
100
125
|
- `structured_return({ command: "node --test [any node test args]", parseAs: "node-test-text" })` — parses the default spec reporter output; strips full stack traces, assertion error internals, timing data; preserves expected/actual values from assertion failures
|
|
101
126
|
|
|
102
127
|
### ava
|
|
128
|
+
|
|
103
129
|
- `structured_return({ command: "npx ava [any ava args] --no-color", parseAs: "ava-text" })` — parses default text output from stderr; assertion failures extract expected/actual from diff lines and file:line; runtime errors extract message and file:line from stack trace
|
|
104
130
|
|
|
105
131
|
### mocha
|
|
132
|
+
|
|
106
133
|
- `structured_return({ command: "mocha [any mocha args] --reporter json", parseAs: "mocha-json" })` — `--reporter json` is built into mocha; assertion failures surface explicit expected/actual values; runtime errors surface message and file:line from stack trace
|
|
107
134
|
|
|
108
135
|
### Python unittest
|
|
136
|
+
|
|
109
137
|
- `structured_return({ command: "python3 -m unittest [any unittest args]", parseAs: "unittest-text" })` — no special flags needed; parses the default verbose traceback output from stderr; assertion messages extracted from `AssertionError` lines; file:line from traceback frames
|
|
110
138
|
|
|
111
139
|
### go test
|
|
140
|
+
|
|
112
141
|
- `structured_return({ command: "go test -json [any go test args]", parseAs: "go-test-json" })` — `-json` is built into `go test`; NDJSON output; assertion failures extract file:line and message from `t.Error`/`t.Errorf` output; panics extract message and user-code file:line from stack trace; 97% reduction vs raw NDJSON
|
|
113
142
|
|
|
114
143
|
### vitest
|
|
144
|
+
|
|
115
145
|
- `structured_return({ command: "vitest run [any vitest args] --reporter=json", parseAs: "vitest-json" })` — file paths, filters, etc. go in `[any vitest args]`
|
|
116
146
|
|
|
117
147
|
### eslint
|
|
148
|
+
|
|
118
149
|
- `structured_return({ command: "eslint [any eslint args] -f json", parseAs: "eslint-json" })` — paths, configs, rules, etc. go in `[any eslint args]`
|
|
119
150
|
|
|
120
151
|
### rspec
|
|
152
|
+
|
|
121
153
|
- `structured_return({ command: "bundle exec rspec [any rspec args] --format json", parseAs: "rspec-json" })` — `--format json` is required; without it output is not parseable
|
|
122
154
|
|
|
123
155
|
### minitest
|
|
156
|
+
|
|
124
157
|
- `structured_return({ command: "ruby [any minitest args]", parseAs: "minitest-text" })` — no format flags needed; works with plain ruby invocation
|
|
125
158
|
|
|
126
159
|
### dbt (run, test, compile)
|
|
160
|
+
|
|
127
161
|
- `structured_return({ command: "dbt run [any dbt args] --log-format json", parseAs: "dbt-json" })` — `--log-format json` required; model selectors, flags, etc. go in `[any dbt args]`
|
|
128
162
|
- `structured_return({ command: "dbt test [any dbt args] --log-format json", parseAs: "dbt-json" })` — same parser handles run and test; unit test diffs preserved verbatim
|
|
129
163
|
- `structured_return({ command: "dbt compile [any dbt args] --log-format json", parseAs: "dbt-json" })` — returns compiled SQL; preamble stripped
|
|
130
164
|
|
|
131
165
|
### cargo build
|
|
166
|
+
|
|
132
167
|
- `structured_return({ command: "cargo build --message-format=json", parseAs: "cargo-build" })` — `--message-format=json` is built into cargo; errors include file, line, error code (E0308 etc.), and primary span label (expected X, found Y); warnings are filtered out
|
|
133
168
|
|
|
134
169
|
### cargo test
|
|
170
|
+
|
|
135
171
|
- `structured_return({ command: "cargo test", parseAs: "cargo-test" })` — no extra flags needed; assertion failures surface left/right values and file:line; panics surface the message and file:line; if compilation fails, the summary says so and tells the model to run `cargo build --message-format=json` for structured errors
|
|
136
172
|
- `structured_return({ command: "cargo test [filter]", parseAs: "cargo-test" })` — filter by test name substring, module path, or `--test integration_test_name`
|
|
137
173
|
|
|
138
174
|
### junit-xml
|
|
139
175
|
|
|
140
|
-
JUnit XML is the de facto standard output format across the JVM ecosystem and many others — Maven, Gradle, pytest (`--junitxml`), Go (`go-junit-report`), .NET (`--logger trx` with conversion), Jest (`jest-junit`), and more. If a tool can emit JUnit XML, `junit-xml` covers it without a custom parser.
|
|
176
|
+
JUnit XML is the de facto standard output format across the JVM ecosystem and many others — Maven, Gradle, pytest (`--junitxml`), Playwright (`--reporter=junit`), PHPUnit/Pest (`--log-junit`), Go (`go-junit-report`), .NET (`--logger trx` with conversion), Jest (`jest-junit`), and more. If a tool can emit JUnit XML, `junit-xml` covers it without a custom parser.
|
|
141
177
|
|
|
142
178
|
`artifactPaths` supports glob patterns — the parser aggregates results across all matching files. Use globs for tools that write one XML per test class (Gradle, Maven/Surefire). Use a single path for tools that write one consolidated file (pytest, Jest, etc.).
|
|
143
179
|
|
|
@@ -171,6 +207,24 @@ Jest requires the `jest-junit` reporter (`npm install --save-dev jest-junit`). P
|
|
|
171
207
|
|
|
172
208
|
- `structured_return({ command: "jest [any jest args] --reporters=jest-junit", parseAs: "junit-xml", artifactPaths: [".tmp/junit.xml"] })` — set `JEST_JUNIT_OUTPUT_FILE=.tmp/junit.xml` or configure `outputFile` in `jest-junit` config; file paths, `--testPathPattern`, etc. go in `[any jest args]`
|
|
173
209
|
|
|
210
|
+
#### Playwright
|
|
211
|
+
|
|
212
|
+
Playwright has a built-in JUnit reporter. Set the output file inline so `junit-xml` has a concrete artifact to parse.
|
|
213
|
+
|
|
214
|
+
- `structured_return({ command: "PLAYWRIGHT_JUNIT_OUTPUT_FILE=.tmp/report.xml playwright test [any playwright args] --reporter=junit", parseAs: "junit-xml", artifactPaths: [".tmp/report.xml"] })` — built-in JUnit reporter; file paths, `--grep`, project names, and shard flags go in `[any playwright args]`
|
|
215
|
+
|
|
216
|
+
#### PHPUnit
|
|
217
|
+
|
|
218
|
+
PHPUnit writes JUnit XML directly via `--log-junit`.
|
|
219
|
+
|
|
220
|
+
- `structured_return({ command: "vendor/bin/phpunit [any phpunit args] --log-junit .tmp/report.xml", parseAs: "junit-xml", artifactPaths: [".tmp/report.xml"] })` — built-in JUnit logging; test paths, `--filter`, and suite selection flags go in `[any phpunit args]`
|
|
221
|
+
|
|
222
|
+
#### Pest
|
|
223
|
+
|
|
224
|
+
Pest supports the same JUnit XML logging flag as PHPUnit.
|
|
225
|
+
|
|
226
|
+
- `structured_return({ command: "vendor/bin/pest [any pest args] --log-junit .tmp/report.xml", parseAs: "junit-xml", artifactPaths: [".tmp/report.xml"] })` — built-in JUnit logging; file paths, `--filter`, and parallelization flags go in `[any pest args]`
|
|
227
|
+
|
|
174
228
|
#### Swift / XCTest (Swift Package Manager)
|
|
175
229
|
|
|
176
230
|
`swift test` has native JUnit XML output via `--xunit-output` (Swift 5.7+). Use this for all SPM projects — no third-party reporter needed.
|