@robhowley/pi-structured-return 1.5.0 → 1.6.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.
Files changed (34) hide show
  1. package/README.md +34 -4
  2. package/extensions/structured-return/src/config/registry.ts +92 -0
  3. package/extensions/structured-return/src/parsers/bandit-json.test.ts +90 -0
  4. package/extensions/structured-return/src/parsers/bandit-json.ts +78 -0
  5. package/extensions/structured-return/src/parsers/black-text.test.ts +67 -0
  6. package/extensions/structured-return/src/parsers/black-text.ts +74 -0
  7. package/extensions/structured-return/src/parsers/clang-text.test.ts +61 -0
  8. package/extensions/structured-return/src/parsers/clang-text.ts +59 -0
  9. package/extensions/structured-return/src/parsers/dotnet-build-text.test.ts +85 -0
  10. package/extensions/structured-return/src/parsers/dotnet-build-text.ts +48 -0
  11. package/extensions/structured-return/src/parsers/htmlhint-json.test.ts +72 -0
  12. package/extensions/structured-return/src/parsers/htmlhint-json.ts +72 -0
  13. package/extensions/structured-return/src/parsers/isort-text.test.ts +58 -0
  14. package/extensions/structured-return/src/parsers/isort-text.ts +64 -0
  15. package/extensions/structured-return/src/parsers/javac-text.test.ts +75 -0
  16. package/extensions/structured-return/src/parsers/javac-text.ts +81 -0
  17. package/extensions/structured-return/src/parsers/jsonlint-text.test.ts +52 -0
  18. package/extensions/structured-return/src/parsers/jsonlint-text.ts +64 -0
  19. package/extensions/structured-return/src/parsers/markdownlint-json.test.ts +76 -0
  20. package/extensions/structured-return/src/parsers/markdownlint-json.ts +73 -0
  21. package/extensions/structured-return/src/parsers/node-test-text.test.ts +117 -0
  22. package/extensions/structured-return/src/parsers/node-test-text.ts +90 -0
  23. package/extensions/structured-return/src/parsers/npm-audit-json.test.ts +83 -0
  24. package/extensions/structured-return/src/parsers/npm-audit-json.ts +88 -0
  25. package/extensions/structured-return/src/parsers/prettier-text.test.ts +76 -0
  26. package/extensions/structured-return/src/parsers/prettier-text.ts +63 -0
  27. package/extensions/structured-return/src/parsers/pyright-json.test.ts +112 -0
  28. package/extensions/structured-return/src/parsers/pyright-json.ts +81 -0
  29. package/extensions/structured-return/src/parsers/tidy-text.test.ts +74 -0
  30. package/extensions/structured-return/src/parsers/tidy-text.ts +67 -0
  31. package/extensions/structured-return/src/parsers/vale-json.test.ts +84 -0
  32. package/extensions/structured-return/src/parsers/vale-json.ts +80 -0
  33. package/package.json +1 -1
  34. package/skills/structured-return/SKILL.md +58 -6
@@ -0,0 +1,112 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { describe, it, expect } from "vitest";
5
+ import parser from "./pyright-json";
6
+ import type { RunContext } from "../types";
7
+
8
+ function makeCtx(stdout: string, cwd = "/project"): RunContext {
9
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "pyright-test-"));
10
+ const stdoutPath = path.join(dir, "stdout");
11
+ fs.writeFileSync(stdoutPath, stdout);
12
+ return {
13
+ command: "pyright --outputjson .",
14
+ argv: ["pyright", "--outputjson", "."],
15
+ cwd,
16
+ artifactPaths: [],
17
+ stdoutPath,
18
+ stderrPath: path.join(dir, "stderr"),
19
+ logPath: path.join(dir, "log"),
20
+ };
21
+ }
22
+
23
+ describe("pyright-json parser", () => {
24
+ it("single error → correct relative path, 1-based line, rule mapped, status fail", async () => {
25
+ const cwd = "/project";
26
+ const stdout = JSON.stringify({
27
+ version: "1.1.408",
28
+ generalDiagnostics: [
29
+ {
30
+ file: "/project/src/app.py",
31
+ severity: "error",
32
+ message: 'Type "str" is not assignable to declared type "int"\n "str" is not assignable to "int"',
33
+ range: { start: { line: 3, character: 14 }, end: { line: 3, character: 28 } },
34
+ rule: "reportAssignmentType",
35
+ },
36
+ ],
37
+ summary: { filesAnalyzed: 1, errorCount: 1, warningCount: 0, informationCount: 0 },
38
+ });
39
+ const result = await parser.parse(makeCtx(stdout, cwd));
40
+ expect(result.status).toBe("fail");
41
+ expect(result.summary).toBe("1 error");
42
+ expect(result.failures).toHaveLength(1);
43
+ expect(result.failures![0].file).toBe("src/app.py");
44
+ expect(result.failures![0].line).toBe(4); // 0-based → 1-based
45
+ expect(result.failures![0].rule).toBe("reportAssignmentType");
46
+ expect(result.failures![0].message).not.toContain("\n");
47
+ });
48
+
49
+ it("multiple errors across files → correct count and paths", async () => {
50
+ const cwd = "/project";
51
+ const stdout = JSON.stringify({
52
+ generalDiagnostics: [
53
+ {
54
+ file: "/project/a.py",
55
+ severity: "error",
56
+ message: 'Cannot access attribute "foo" for class "Bar"',
57
+ range: { start: { line: 0, character: 0 }, end: { line: 0, character: 5 } },
58
+ rule: "reportAttributeAccessIssue",
59
+ },
60
+ {
61
+ file: "/project/b.py",
62
+ severity: "error",
63
+ message: 'Argument missing for parameter "x"',
64
+ range: { start: { line: 9, character: 0 }, end: { line: 9, character: 10 } },
65
+ rule: "reportCallIssue",
66
+ },
67
+ ],
68
+ summary: { filesAnalyzed: 2, errorCount: 2, warningCount: 0, informationCount: 0 },
69
+ });
70
+ const result = await parser.parse(makeCtx(stdout, cwd));
71
+ expect(result.status).toBe("fail");
72
+ expect(result.summary).toBe("2 errors");
73
+ expect(result.failures).toHaveLength(2);
74
+ expect(result.failures![0].file).toBe("a.py");
75
+ expect(result.failures![1].file).toBe("b.py");
76
+ });
77
+
78
+ it("warnings only (no errors) → status pass, empty failures", async () => {
79
+ const stdout = JSON.stringify({
80
+ generalDiagnostics: [
81
+ {
82
+ file: "/project/c.py",
83
+ severity: "warning",
84
+ message: 'Import "os" is not accessed',
85
+ range: { start: { line: 0, character: 0 }, end: { line: 0, character: 9 } },
86
+ rule: "reportUnusedImport",
87
+ },
88
+ ],
89
+ summary: { filesAnalyzed: 1, errorCount: 0, warningCount: 1, informationCount: 0 },
90
+ });
91
+ const result = await parser.parse(makeCtx(stdout));
92
+ expect(result.status).toBe("pass");
93
+ expect(result.summary).toBe("1 warning");
94
+ expect(result.failures).toHaveLength(0);
95
+ });
96
+
97
+ it("no diagnostics → status pass", async () => {
98
+ const stdout = JSON.stringify({
99
+ generalDiagnostics: [],
100
+ summary: { filesAnalyzed: 1, errorCount: 0, warningCount: 0, informationCount: 0 },
101
+ });
102
+ const result = await parser.parse(makeCtx(stdout));
103
+ expect(result.status).toBe("pass");
104
+ expect(result.failures).toHaveLength(0);
105
+ });
106
+
107
+ it("empty stdout → no crash, status pass", async () => {
108
+ const result = await parser.parse(makeCtx(""));
109
+ expect(result.status).toBe("pass");
110
+ expect(result.failures).toHaveLength(0);
111
+ });
112
+ });
@@ -0,0 +1,81 @@
1
+ import path from "node:path";
2
+ import type { ParserModule, ParsedFailure } from "../types";
3
+ import { safeReadFile } from "./utils";
4
+
5
+ interface PyrightDiagnostic {
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) parts.push(`${summary.errorCount} error${summary.errorCount !== 1 ? "s" : ""}`);
68
+ if (summary.warningCount) parts.push(`${summary.warningCount} warning${summary.warningCount !== 1 ? "s" : ""}`);
69
+ }
70
+
71
+ return {
72
+ tool: "pyright",
73
+ status: failures.length > 0 ? "fail" : "pass",
74
+ summary: parts.length > 0 ? parts.join(", ") : "no type errors",
75
+ failures,
76
+ logPath: ctx.logPath,
77
+ };
78
+ },
79
+ };
80
+
81
+ export default parser;
@@ -0,0 +1,74 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { describe, it, expect } from "vitest";
5
+ import parser from "./tidy-text";
6
+ import type { RunContext } from "../types";
7
+
8
+ function makeCtx(stderr: string, cwd = "/project"): RunContext {
9
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "tidy-test-"));
10
+ const stderrPath = path.join(dir, "stderr");
11
+ fs.writeFileSync(stderrPath, stderr);
12
+ return {
13
+ command: "tidy -errors src/index.html",
14
+ argv: ["tidy", "-errors", "src/index.html"],
15
+ cwd,
16
+ artifactPaths: [],
17
+ stdoutPath: path.join(dir, "stdout"),
18
+ stderrPath,
19
+ logPath: path.join(dir, "log"),
20
+ };
21
+ }
22
+
23
+ describe("tidy-text parser", () => {
24
+ it("warnings with remediation noise → strips advice, extracts line and message", async () => {
25
+ const stderr = `line 1 column 1 - Warning: missing <!DOCTYPE> declaration
26
+ line 1 column 9 - Warning: inserting missing 'title' element
27
+ line 1 column 35 - Warning: <img> lacks "alt" attribute
28
+ Info: Document content looks like HTML 3.2
29
+ 3 warnings, 0 errors were found!
30
+
31
+ The alt attribute should be used to give a short description
32
+ of an image; longer descriptions should be given with the
33
+ longdesc attribute which takes a URL linked to the description.
34
+ These measures are needed for people using non-graphical browsers.
35
+
36
+ For further advice on how to make your pages accessible
37
+ see http://www.w3.org/WAI/GL.
38
+
39
+ To learn more about HTML Tidy see http://tidy.sourceforge.net`;
40
+ const result = await parser.parse(makeCtx(stderr));
41
+ expect(result.status).toBe("pass");
42
+ expect(result.summary).toBe("3 warnings");
43
+ expect(result.failures).toHaveLength(3);
44
+ expect(result.failures![0].file).toBe("src/index.html");
45
+ expect(result.failures![0].line).toBe(1);
46
+ expect(result.failures![0].message).toBe("missing <!DOCTYPE> declaration");
47
+ expect(result.failures![2].message).toBe('<img> lacks "alt" attribute');
48
+ // No remediation text in failures
49
+ expect(result.failures!.every((f) => !f.message!.includes("should be used"))).toBe(true);
50
+ });
51
+
52
+ it("errors and warnings → both counted in summary", async () => {
53
+ const stderr = `line 1 column 1 - Error: unexpected end of file
54
+ line 1 column 1 - Warning: missing <!DOCTYPE> declaration
55
+ 1 warning, 1 error were found!`;
56
+ const result = await parser.parse(makeCtx(stderr));
57
+ expect(result.status).toBe("fail");
58
+ expect(result.summary).toBe("1 error, 1 warning");
59
+ expect(result.failures).toHaveLength(2);
60
+ });
61
+
62
+ it("no issues → status pass", async () => {
63
+ const stderr = `No warnings or errors were found.`;
64
+ const result = await parser.parse(makeCtx(stderr));
65
+ expect(result.status).toBe("pass");
66
+ expect(result.failures).toHaveLength(0);
67
+ });
68
+
69
+ it("empty stderr → no crash, status pass", async () => {
70
+ const result = await parser.parse(makeCtx(""));
71
+ expect(result.status).toBe("pass");
72
+ expect(result.failures).toHaveLength(0);
73
+ });
74
+ });
@@ -0,0 +1,67 @@
1
+ import type { ParserModule, ParsedFailure } from "../types";
2
+ import { safeReadFile } from "./utils";
3
+
4
+ // line N column N - Warning/Error: message
5
+ const ISSUE_LINE = /^line (\d+) column \d+ - (Warning|Error): (.+)$/;
6
+ // Summary: N warnings, N errors were found!
7
+ const SUMMARY_LINE = /^(\d+) warnings?, (\d+) errors? were found/;
8
+
9
+ const parser: ParserModule = {
10
+ id: "tidy-text",
11
+ async parse(ctx) {
12
+ const stderr = safeReadFile(ctx.stderrPath).trim();
13
+ if (!stderr) {
14
+ return {
15
+ tool: "tidy",
16
+ status: "pass",
17
+ summary: "no issues found",
18
+ failures: [],
19
+ logPath: ctx.logPath,
20
+ };
21
+ }
22
+
23
+ const lines = stderr.split("\n");
24
+ const failures: ParsedFailure[] = [];
25
+ let warnings = 0;
26
+ let errors = 0;
27
+
28
+ // Derive filename from command argv — tidy doesn't include filenames in output.
29
+ // Use last non-flag arg since flags like `-indent auto` have value arguments.
30
+ const file = ctx.argv.filter((a) => !a.startsWith("-") && a !== "tidy").pop() ?? "input";
31
+
32
+ for (const line of lines) {
33
+ const issueMatch = line.match(ISSUE_LINE);
34
+ if (issueMatch) {
35
+ const [, lineNum, level, message] = issueMatch;
36
+ failures.push({
37
+ id: `${file}:${lineNum}:${message}`,
38
+ file,
39
+ line: parseInt(lineNum, 10),
40
+ message,
41
+ rule: level.toLowerCase(),
42
+ });
43
+ continue;
44
+ }
45
+ const sumMatch = line.match(SUMMARY_LINE);
46
+ if (sumMatch) {
47
+ warnings = parseInt(sumMatch[1], 10);
48
+ errors = parseInt(sumMatch[2], 10);
49
+ }
50
+ }
51
+
52
+ const parts: string[] = [];
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
+
57
+ return {
58
+ tool: "tidy",
59
+ status: errors > 0 ? "fail" : "pass",
60
+ summary,
61
+ failures,
62
+ logPath: ctx.logPath,
63
+ };
64
+ },
65
+ };
66
+
67
+ export default parser;
@@ -0,0 +1,84 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { describe, it, expect } from "vitest";
5
+ import parser from "./vale-json";
6
+ import type { RunContext } from "../types";
7
+
8
+ function makeCtx(stdout: string, cwd = "/project"): RunContext {
9
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "vale-test-"));
10
+ const stdoutPath = path.join(dir, "stdout");
11
+ fs.writeFileSync(stdoutPath, stdout);
12
+ return {
13
+ command: "vale --output JSON .",
14
+ argv: ["vale", "--output", "JSON", "."],
15
+ cwd,
16
+ artifactPaths: [],
17
+ stdoutPath,
18
+ stderrPath: path.join(dir, "stderr"),
19
+ logPath: path.join(dir, "log"),
20
+ };
21
+ }
22
+
23
+ describe("vale-json parser", () => {
24
+ it("multiple errors across files → correct relative paths, rule names, severity summary", async () => {
25
+ const cwd = "/project";
26
+ const stdout = JSON.stringify({
27
+ "/project/docs/readme.md": [
28
+ {
29
+ Line: 3,
30
+ Message: "Did you really mean 'writen'?",
31
+ Severity: "error",
32
+ Check: "Vale.Spelling",
33
+ Action: { Name: "suggest", Params: ["spellings"] },
34
+ Span: [57, 62],
35
+ },
36
+ {
37
+ Line: 5,
38
+ Message: "Use 'basically' instead of 'basicly'.",
39
+ Severity: "warning",
40
+ Check: "Vale.Terms",
41
+ Action: { Name: "replace", Params: ["basically"] },
42
+ Span: [10, 17],
43
+ },
44
+ ],
45
+ });
46
+ const result = await parser.parse(makeCtx(stdout, cwd));
47
+ expect(result.status).toBe("fail");
48
+ expect(result.summary).toBe("1 error, 1 warning");
49
+ expect(result.failures).toHaveLength(2);
50
+ expect(result.failures![0].file).toBe("docs/readme.md");
51
+ expect(result.failures![0].rule).toBe("Vale.Spelling");
52
+ expect(result.failures![1].rule).toBe("Vale.Terms");
53
+ });
54
+
55
+ it("warnings only → status pass (no errors)", async () => {
56
+ const stdout = JSON.stringify({
57
+ "/project/doc.md": [
58
+ {
59
+ Line: 1,
60
+ Message: "Consider using active voice.",
61
+ Severity: "warning",
62
+ Check: "Vale.Passive",
63
+ Action: {},
64
+ Span: [1, 10],
65
+ },
66
+ ],
67
+ });
68
+ const result = await parser.parse(makeCtx(stdout));
69
+ expect(result.status).toBe("pass");
70
+ expect(result.summary).toBe("1 warning");
71
+ });
72
+
73
+ it("no alerts → status pass", async () => {
74
+ const result = await parser.parse(makeCtx(JSON.stringify({})));
75
+ expect(result.status).toBe("pass");
76
+ expect(result.summary).toBe("no prose issues");
77
+ });
78
+
79
+ it("empty stdout → no crash, status pass", async () => {
80
+ const result = await parser.parse(makeCtx(""));
81
+ expect(result.status).toBe("pass");
82
+ expect(result.failures).toHaveLength(0);
83
+ });
84
+ });
@@ -0,0 +1,80 @@
1
+ import path from "node:path";
2
+ import type { ParserModule, ParsedFailure } from "../types";
3
+ import { safeReadFile } from "./utils";
4
+
5
+ interface ValeAlert {
6
+ Line: number;
7
+ Message: string;
8
+ Severity: string;
9
+ Check: string;
10
+ }
11
+
12
+ const parser: ParserModule = {
13
+ id: "vale-json",
14
+ async parse(ctx) {
15
+ const stdout = safeReadFile(ctx.stdoutPath).trim();
16
+ if (!stdout) {
17
+ return {
18
+ tool: "vale",
19
+ status: "pass",
20
+ summary: "no prose issues",
21
+ failures: [],
22
+ logPath: ctx.logPath,
23
+ };
24
+ }
25
+
26
+ let output: Record<string, ValeAlert[]>;
27
+ try {
28
+ output = JSON.parse(stdout);
29
+ } catch {
30
+ return {
31
+ tool: "vale",
32
+ status: "error",
33
+ summary: "failed to parse vale JSON output",
34
+ logPath: ctx.logPath,
35
+ };
36
+ }
37
+
38
+ const failures: ParsedFailure[] = [];
39
+ const bySeverity: Record<string, number> = {};
40
+
41
+ for (const [filePath, alerts] of Object.entries(output)) {
42
+ const relPath = path.relative(ctx.cwd, filePath);
43
+ for (const alert of alerts) {
44
+ const sev = alert.Severity.toLowerCase();
45
+ bySeverity[sev] = (bySeverity[sev] ?? 0) + 1;
46
+ failures.push({
47
+ id: `${relPath}:${alert.Line}:${alert.Check}`,
48
+ file: relPath,
49
+ line: alert.Line,
50
+ message: alert.Message,
51
+ rule: alert.Check,
52
+ });
53
+ }
54
+ }
55
+
56
+ if (failures.length === 0) {
57
+ return {
58
+ tool: "vale",
59
+ status: "pass",
60
+ summary: "no prose issues",
61
+ failures: [],
62
+ logPath: ctx.logPath,
63
+ };
64
+ }
65
+
66
+ const parts = ["error", "warning", "suggestion"]
67
+ .filter((s) => bySeverity[s])
68
+ .map((s) => `${bySeverity[s]} ${s}${bySeverity[s] !== 1 ? "s" : ""}`);
69
+
70
+ return {
71
+ tool: "vale",
72
+ status: bySeverity["error"] ? "fail" : "pass",
73
+ summary: parts.join(", "),
74
+ failures,
75
+ logPath: ctx.logPath,
76
+ };
77
+ },
78
+ };
79
+
80
+ export default parser;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robhowley/pi-structured-return",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Structured command execution for Pi agents: compact results for the model, full logs for humans.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,12 +30,51 @@ Prefer better output at the source.
30
30
  ### ruff check
31
31
  - `structured_return({ command: "ruff check [any ruff args] --output-format=json", parseAs: "ruff-json" })` — scope, selects, ignores, etc. go in `[any ruff args]`
32
32
 
33
- ### ruff format
34
- - `ruff format --check .` (no structured_return — json output not supported)
35
-
36
33
  ### mypy
37
34
  - `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
38
35
 
36
+ ### htmlhint
37
+ - `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
+
39
+ ### isort
40
+ - `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
+
42
+ ### npm audit
43
+ - `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
+
45
+ ### jsonlint
46
+ - `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
+
48
+ ### tidy (HTML Tidy)
49
+ - `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
+
51
+ ### vale
52
+ - `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
+
54
+ ### prettier
55
+ - `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
+
57
+ ### markdownlint
58
+ - `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
+
60
+ ### black
61
+ - `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
+
63
+ ### bandit
64
+ - `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
+
66
+ ### gcc / clang
67
+ - `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
+
69
+ ### dotnet build
70
+ - `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
+
72
+ ### javac
73
+ - `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
+
75
+ ### pyright
76
+ - `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
+
39
78
  ### tsc
40
79
  - `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
41
80
 
@@ -48,9 +87,6 @@ Prefer better output at the source.
48
87
  ### rubocop
49
88
  - `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
50
89
 
51
- ### flake8
52
- - `flake8 [any flake8 args]` (no structured_return — default output is already compact `file:line:col: CODE message`; no JSON without a plugin; use `bash` directly)
53
-
54
90
  ### swiftc
55
91
  - `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
56
92
 
@@ -60,6 +96,9 @@ Prefer better output at the source.
60
96
  ### stylelint
61
97
  - `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
62
98
 
99
+ ### node --test
100
+ - `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
+
63
102
  ### ava
64
103
  - `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
65
104
 
@@ -134,3 +173,16 @@ Jest requires the `jest-junit` reporter (`npm install --save-dev jest-junit`). P
134
173
  `xcodebuild` output is high-volume and not directly parseable. Pipe through `xcbeautify` (install with `brew install xcbeautify`) to get JUnit XML:
135
174
 
136
175
  - `structured_return({ command: "xcodebuild test -scheme [scheme] -destination '[destination]' 2>&1 | xcbeautify --report junit --output .tmp", parseAs: "junit-xml", artifactPaths: [".tmp/report.junit.xml"] })` — xcbeautify writes `report.junit.xml` into the `--output` directory; run `xcodebuild -showdestinations -scheme [scheme]` first to find the correct `[destination]` string for the project
176
+
177
+ ## Already compact — use `bash` directly
178
+
179
+ These tools were evaluated for structured parsing but their output is already compact enough that a parser adds no token reduction. Use `bash` instead of `structured_return`.
180
+
181
+ - `flake8 [any flake8 args]` — `file:line:col: CODE message`, one line per violation
182
+ - `ruff format --check .` — just lists files needing formatting
183
+ - `go build [any go build args]` — `file:line:col: message`, one line per error
184
+ - `go vet [any go vet args]` — same format as go build
185
+ - `golangci-lint run [any golangci-lint args]` — `file:line:col: message (linter)`, already minimal
186
+ - `yamllint [any yamllint args]` — `file:line:col level message (rule)`, one line per issue
187
+ - `pydocstyle [any pydocstyle args]` — `file:line context + CODE: message`, two lines per issue
188
+ - `vulture [any vulture args]` — `file:line: message (confidence%)`, one line per finding