@robhowley/pi-structured-return 1.8.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.
Files changed (97) hide show
  1. package/README.md +84 -73
  2. package/extensions/structured-return/config/project-config.ts +10 -0
  3. package/extensions/structured-return/config/registry.ts +306 -0
  4. package/extensions/structured-return/examples/.pi/machine-readable.json +18 -0
  5. package/extensions/structured-return/examples/.pi/parsers/foo-cli.ts +25 -0
  6. package/extensions/structured-return/{src/index.ts → index.ts} +94 -69
  7. package/extensions/structured-return/{src/parsers → parsers}/ava-text.ts +23 -15
  8. package/extensions/structured-return/{src/parsers → parsers}/bandit-json.ts +17 -15
  9. package/extensions/structured-return/{src/parsers → parsers}/black-text.ts +18 -18
  10. package/extensions/structured-return/{src/parsers → parsers}/cargo-build.ts +19 -14
  11. package/extensions/structured-return/{src/parsers → parsers}/cargo-test.ts +20 -19
  12. package/extensions/structured-return/parsers/checkstyle-xml.ts +183 -0
  13. package/extensions/structured-return/{src/parsers → parsers}/clang-text.ts +15 -13
  14. package/extensions/structured-return/{src/parsers → parsers}/dbt-json.ts +28 -23
  15. package/extensions/structured-return/{src/parsers → parsers}/dotnet-build-text.ts +10 -8
  16. package/extensions/structured-return/{src/parsers → parsers}/eslint-json.ts +15 -9
  17. package/extensions/structured-return/{src/parsers → parsers}/go-test-json.ts +23 -21
  18. package/extensions/structured-return/{src/parsers → parsers}/hadolint-json.ts +18 -12
  19. package/extensions/structured-return/{src/parsers → parsers}/htmlhint-json.ts +15 -13
  20. package/extensions/structured-return/{src/parsers → parsers}/isort-text.ts +18 -18
  21. package/extensions/structured-return/{src/parsers → parsers}/javac-text.ts +14 -12
  22. package/extensions/structured-return/{src/parsers → parsers}/jsonlint-text.ts +16 -14
  23. package/extensions/structured-return/{src/parsers → parsers}/junit-xml.ts +149 -50
  24. package/extensions/structured-return/{src/parsers → parsers}/markdownlint-json.ts +19 -17
  25. package/extensions/structured-return/{src/parsers → parsers}/minitest-text.ts +24 -15
  26. package/extensions/structured-return/{src/parsers → parsers}/mocha-json.ts +17 -10
  27. package/extensions/structured-return/{src/parsers → parsers}/mypy-json.ts +16 -16
  28. package/extensions/structured-return/{src/parsers → parsers}/node-test-text.ts +17 -14
  29. package/extensions/structured-return/{src/parsers → parsers}/npm-audit-json.ts +19 -16
  30. package/extensions/structured-return/{src/parsers → parsers}/prettier-text.ts +21 -17
  31. package/extensions/structured-return/{src/parsers → parsers}/pylint-json.ts +17 -17
  32. package/extensions/structured-return/{src/parsers → parsers}/pyright-json.ts +20 -18
  33. package/extensions/structured-return/{src/parsers → parsers}/rspec-json.ts +14 -14
  34. package/extensions/structured-return/{src/parsers → parsers}/rubocop-json.ts +22 -11
  35. package/extensions/structured-return/{src/parsers → parsers}/ruff-json.ts +7 -7
  36. package/extensions/structured-return/{src/parsers → parsers}/shellcheck-json.ts +14 -14
  37. package/extensions/structured-return/{src/parsers → parsers}/stylelint-json.ts +21 -13
  38. package/extensions/structured-return/{src/parsers → parsers}/swiftc-text.ts +16 -10
  39. package/extensions/structured-return/parsers/tail-fallback.ts +20 -0
  40. package/extensions/structured-return/{src/parsers → parsers}/tidy-text.ts +13 -13
  41. package/extensions/structured-return/{src/parsers → parsers}/tsc-text.ts +11 -11
  42. package/extensions/structured-return/{src/parsers → parsers}/unittest-text.ts +24 -14
  43. package/extensions/structured-return/{src/parsers → parsers}/utils.ts +9 -6
  44. package/extensions/structured-return/{src/parsers → parsers}/vale-json.ts +18 -18
  45. package/extensions/structured-return/{src/parsers → parsers}/vitest-json.ts +14 -14
  46. package/extensions/structured-return/{src/storage → storage}/log-store.ts +5 -5
  47. package/extensions/structured-return/{src/storage → storage}/session-stats.ts +11 -11
  48. package/extensions/structured-return/{src/types.ts → types.ts} +4 -2
  49. package/package.json +27 -43
  50. package/skills/structured-return/SKILL.md +62 -1
  51. package/LICENSE +0 -21
  52. package/extensions/structured-return/src/config/project-config.ts +0 -10
  53. package/extensions/structured-return/src/config/registry.test.ts +0 -171
  54. package/extensions/structured-return/src/config/registry.ts +0 -282
  55. package/extensions/structured-return/src/index.test.ts +0 -220
  56. package/extensions/structured-return/src/parsers/ava-text.test.ts +0 -116
  57. package/extensions/structured-return/src/parsers/bandit-json.test.ts +0 -90
  58. package/extensions/structured-return/src/parsers/black-text.test.ts +0 -67
  59. package/extensions/structured-return/src/parsers/cargo-build.test.ts +0 -170
  60. package/extensions/structured-return/src/parsers/cargo-test.test.ts +0 -191
  61. package/extensions/structured-return/src/parsers/clang-text.test.ts +0 -61
  62. package/extensions/structured-return/src/parsers/dbt-json.test.ts +0 -172
  63. package/extensions/structured-return/src/parsers/dotnet-build-text.test.ts +0 -85
  64. package/extensions/structured-return/src/parsers/eslint-json.test.ts +0 -60
  65. package/extensions/structured-return/src/parsers/go-test-json.test.ts +0 -119
  66. package/extensions/structured-return/src/parsers/hadolint-json.test.ts +0 -73
  67. package/extensions/structured-return/src/parsers/htmlhint-json.test.ts +0 -72
  68. package/extensions/structured-return/src/parsers/isort-text.test.ts +0 -58
  69. package/extensions/structured-return/src/parsers/javac-text.test.ts +0 -75
  70. package/extensions/structured-return/src/parsers/jsonlint-text.test.ts +0 -52
  71. package/extensions/structured-return/src/parsers/junit-xml.test.ts +0 -410
  72. package/extensions/structured-return/src/parsers/markdownlint-json.test.ts +0 -76
  73. package/extensions/structured-return/src/parsers/minitest-text.test.ts +0 -110
  74. package/extensions/structured-return/src/parsers/mocha-json.test.ts +0 -108
  75. package/extensions/structured-return/src/parsers/mypy-json.test.ts +0 -101
  76. package/extensions/structured-return/src/parsers/node-test-text.test.ts +0 -117
  77. package/extensions/structured-return/src/parsers/npm-audit-json.test.ts +0 -83
  78. package/extensions/structured-return/src/parsers/prettier-text.test.ts +0 -76
  79. package/extensions/structured-return/src/parsers/pylint-json.test.ts +0 -120
  80. package/extensions/structured-return/src/parsers/pyright-json.test.ts +0 -112
  81. package/extensions/structured-return/src/parsers/rspec-json.test.ts +0 -126
  82. package/extensions/structured-return/src/parsers/rubocop-json.test.ts +0 -118
  83. package/extensions/structured-return/src/parsers/ruff-json.test.ts +0 -57
  84. package/extensions/structured-return/src/parsers/shellcheck-json.test.ts +0 -110
  85. package/extensions/structured-return/src/parsers/stylelint-json.test.ts +0 -120
  86. package/extensions/structured-return/src/parsers/swiftc-text.test.ts +0 -73
  87. package/extensions/structured-return/src/parsers/tail-fallback.test.ts +0 -41
  88. package/extensions/structured-return/src/parsers/tail-fallback.ts +0 -20
  89. package/extensions/structured-return/src/parsers/tidy-text.test.ts +0 -74
  90. package/extensions/structured-return/src/parsers/tsc-text.test.ts +0 -81
  91. package/extensions/structured-return/src/parsers/unittest-text.test.ts +0 -126
  92. package/extensions/structured-return/src/parsers/vale-json.test.ts +0 -84
  93. package/extensions/structured-return/src/parsers/vitest-json.test.ts +0 -118
  94. package/extensions/structured-return/src/storage/session-stats.test.ts +0 -156
  95. package/extensions/structured-return/tsconfig.json +0 -11
  96. package/extensions/structured-return/vitest.config.ts +0 -9
  97. /package/extensions/structured-return/{src/ui → ui}/widget.ts +0 -0
@@ -1,110 +0,0 @@
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 "./minitest-text";
6
- import type { RunContext } from "../types";
7
-
8
- function makeCtx(stdout: string, cwd = "/project"): RunContext {
9
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "minitest-text-test-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- fs.writeFileSync(stdoutPath, stdout);
12
- return {
13
- command: "ruby test/math_test.rb",
14
- argv: ["ruby", "test/math_test.rb"],
15
- cwd,
16
- artifactPaths: [],
17
- stdoutPath,
18
- stderrPath: path.join(dir, "stderr"),
19
- logPath: path.join(dir, "log"),
20
- };
21
- }
22
-
23
- const PASSING_OUTPUT = `Run options: --seed 12345
24
-
25
- # Running:
26
-
27
- ...
28
-
29
- Finished in 0.001s, 3000.0 runs/s, 3000.0 assertions/s.
30
-
31
- 3 runs, 3 assertions, 0 failures, 0 errors, 0 skips
32
- `;
33
-
34
- const MIXED_OUTPUT = `Run options: --seed 12345
35
-
36
- # Running:
37
-
38
- EF.
39
-
40
- Finished in 0.001s, 3000.0 runs/s, 2000.0 assertions/s.
41
-
42
- 1) Error:
43
- MathTest#test_does_not_divide_by_zero:
44
- ZeroDivisionError: divided by 0
45
- /project/test/math_test.rb:13:in 'Integer#/'
46
- /project/test/math_test.rb:13:in 'MathTest#test_does_not_divide_by_zero'
47
-
48
- 2) Failure:
49
- MathTest#test_multiplies_two_numbers_correctly [/project/test/math_test.rb:9]:
50
- Expected: 99
51
- Actual: 12
52
-
53
- 3 runs, 2 assertions, 1 failures, 1 errors, 0 skips
54
- `;
55
-
56
- describe("minitest-text parser", () => {
57
- it("all passing → status pass, summary reflects passed count", async () => {
58
- const result = await parser.parse(makeCtx(PASSING_OUTPUT));
59
- expect(result.status).toBe("pass");
60
- expect(result.summary).toBe("3 passed");
61
- expect(result.failures).toHaveLength(0);
62
- });
63
-
64
- it("mix of failure and error → status fail, correct counts", async () => {
65
- const result = await parser.parse(makeCtx(MIXED_OUTPUT, "/project"));
66
- expect(result.status).toBe("fail");
67
- expect(result.summary).toBe("2 failed, 1 passed");
68
- expect(result.failures).toHaveLength(2);
69
- });
70
-
71
- it("assertion failure → file, line, and expected/actual message", async () => {
72
- const result = await parser.parse(makeCtx(MIXED_OUTPUT, "/project"));
73
- const failure = result.failures!.find((f) => f.id?.includes("multiplies"));
74
- expect(failure?.file).toBe("test/math_test.rb");
75
- expect(failure?.line).toBe(9);
76
- expect(failure?.message).toBe("Expected: 99 / Actual: 12");
77
- });
78
-
79
- it("unexpected error → file, line from backtrace, exception message only", async () => {
80
- const result = await parser.parse(makeCtx(MIXED_OUTPUT, "/project"));
81
- const error = result.failures!.find((f) => f.id?.includes("divide_by_zero"));
82
- expect(error?.file).toBe("test/math_test.rb");
83
- expect(error?.line).toBe(13);
84
- expect(error?.message).toBe("divided by 0");
85
- });
86
-
87
- it("absolute paths in output → made relative to cwd", async () => {
88
- const result = await parser.parse(makeCtx(MIXED_OUTPUT, "/project"));
89
- for (const f of result.failures!) {
90
- expect(f.file).not.toContain("/project");
91
- }
92
- });
93
-
94
- it("relative paths in output → kept relative", async () => {
95
- const output = MIXED_OUTPUT.replace(/\/project\/test\//g, "./test/").replace(/\/project\/test\//g, "./test/");
96
- const result = await parser.parse(makeCtx(output, "/project"));
97
- const failure = result.failures!.find((f) => f.id?.includes("multiplies"));
98
- expect(failure?.file).toBe("test/math_test.rb");
99
- });
100
-
101
- it("no minitest output → status error, no crash", async () => {
102
- const result = await parser.parse(makeCtx("something completely different"));
103
- expect(result.status).toBe("error");
104
- });
105
-
106
- it("empty stdout → status error, no crash", async () => {
107
- const result = await parser.parse(makeCtx(""));
108
- expect(result.status).toBe("error");
109
- });
110
- });
@@ -1,108 +0,0 @@
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 "./mocha-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(), "mocha-test-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- fs.writeFileSync(stdoutPath, stdout);
12
- return {
13
- command: "mocha test_math.js --reporter json",
14
- argv: ["mocha", "test_math.js", "--reporter", "json"],
15
- cwd,
16
- artifactPaths: [],
17
- stdoutPath,
18
- stderrPath: path.join(dir, "stderr"),
19
- logPath: path.join(dir, "log"),
20
- };
21
- }
22
-
23
- describe("mocha-json parser", () => {
24
- it("assertion failure → expected/actual in message, file:line from stack", async () => {
25
- const stdout = JSON.stringify({
26
- stats: { passes: 1, failures: 1 },
27
- failures: [
28
- {
29
- title: "multiplies two numbers correctly",
30
- fullTitle: "basic math multiplies two numbers correctly",
31
- file: "/project/test_math.js",
32
- err: {
33
- stack:
34
- "AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\n\n12 !== 99\n\n at Context.<anonymous> (test_math.js:9:12)\n at process.processImmediate (node:internal/timers:504:21)",
35
- message: "Expected values to be strictly equal:\n\n12 !== 99\n",
36
- actual: "12",
37
- expected: "99",
38
- operator: "strictEqual",
39
- code: "ERR_ASSERTION",
40
- name: "AssertionError",
41
- },
42
- },
43
- ],
44
- });
45
- const result = await parser.parse(makeCtx(stdout));
46
- expect(result.status).toBe("fail");
47
- expect(result.summary).toBe("1 failed, 1 passed");
48
- expect(result.failures).toHaveLength(1);
49
- expect(result.failures![0].message).toBe("expected 99, got 12");
50
- expect(result.failures![0].file).toBe("test_math.js");
51
- expect(result.failures![0].line).toBe(9);
52
- expect(result.failures![0].rule).toBe("ERR_ASSERTION");
53
- });
54
-
55
- it("runtime error → message from err.message, file:line from stack", async () => {
56
- const stdout = JSON.stringify({
57
- stats: { passes: 1, failures: 1 },
58
- failures: [
59
- {
60
- title: "does not divide by zero",
61
- fullTitle: "basic math does not divide by zero",
62
- file: "/project/test_math.js",
63
- err: {
64
- stack:
65
- "TypeError: Cannot read properties of null (reading 'value')\n at Context.<anonymous> (test_math.js:13:29)\n at process.processImmediate (node:internal/timers:504:21)",
66
- message: "Cannot read properties of null (reading 'value')",
67
- },
68
- },
69
- ],
70
- });
71
- const result = await parser.parse(makeCtx(stdout));
72
- expect(result.failures![0].message).toBe("Cannot read properties of null (reading 'value')");
73
- expect(result.failures![0].file).toBe("test_math.js");
74
- expect(result.failures![0].line).toBe(13);
75
- });
76
-
77
- it("all passing → status pass", async () => {
78
- const stdout = JSON.stringify({ stats: { passes: 3, failures: 0 }, failures: [] });
79
- const result = await parser.parse(makeCtx(stdout));
80
- expect(result.status).toBe("pass");
81
- expect(result.summary).toBe("3 passed");
82
- expect(result.failures).toHaveLength(0);
83
- });
84
-
85
- it("empty stdout → status error", async () => {
86
- const result = await parser.parse(makeCtx(""));
87
- expect(result.status).toBe("error");
88
- });
89
-
90
- it("file paths relativized to cwd", async () => {
91
- const stdout = JSON.stringify({
92
- stats: { passes: 0, failures: 1 },
93
- failures: [
94
- {
95
- title: "fails",
96
- fullTitle: "suite fails",
97
- file: "/project/test/foo.js",
98
- err: {
99
- stack: "Error: oops\n at Context.<anonymous> (/project/test/foo.js:5:10)",
100
- message: "oops",
101
- },
102
- },
103
- ],
104
- });
105
- const result = await parser.parse(makeCtx(stdout, "/project"));
106
- expect(result.failures![0].file).toBe("test/foo.js");
107
- });
108
- });
@@ -1,101 +0,0 @@
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 "./mypy-json";
6
- import type { RunContext } from "../types";
7
-
8
- function makeCtx(stderr: string, cwd = "/project"): RunContext {
9
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "mypy-test-"));
10
- const stderrPath = path.join(dir, "stderr");
11
- fs.writeFileSync(stderrPath, stderr);
12
- // mypy JSON goes to stderr; stdout is empty
13
- const stdoutPath = path.join(dir, "stdout");
14
- fs.writeFileSync(stdoutPath, "");
15
- return {
16
- command: "mypy type_check.py --output json",
17
- argv: ["mypy", "type_check.py", "--output", "json"],
18
- cwd,
19
- artifactPaths: [],
20
- stdoutPath,
21
- stderrPath,
22
- logPath: path.join(dir, "log"),
23
- };
24
- }
25
-
26
- describe("mypy-json parser", () => {
27
- it("multiple type errors → correct file, line, message, rule, status fail", async () => {
28
- const stderr = [
29
- '{"file": "type_check.py", "line": 5, "column": 14, "message": "Incompatible types in assignment (expression has type \\"int\\", variable has type \\"str\\")", "hint": null, "code": "assignment", "severity": "error"}',
30
- '{"file": "type_check.py", "line": 6, "column": 17, "message": "Argument 1 to \\"add\\" has incompatible type \\"str\\"; expected \\"int\\"", "hint": null, "code": "arg-type", "severity": "error"}',
31
- ].join("\n");
32
- const result = await parser.parse(makeCtx(stderr));
33
- expect(result.status).toBe("fail");
34
- expect(result.summary).toBe("2 type errors");
35
- expect(result.failures).toHaveLength(2);
36
- expect(result.failures![0]).toMatchObject({
37
- file: "type_check.py",
38
- line: 5,
39
- message: 'Incompatible types in assignment (expression has type "int", variable has type "str")',
40
- rule: "assignment",
41
- });
42
- expect(result.failures![1]).toMatchObject({
43
- file: "type_check.py",
44
- line: 6,
45
- message: 'Argument 1 to "add" has incompatible type "str"; expected "int"',
46
- rule: "arg-type",
47
- });
48
- });
49
-
50
- it("no errors (empty stderr) → status pass", async () => {
51
- const result = await parser.parse(makeCtx(""));
52
- expect(result.status).toBe("pass");
53
- expect(result.summary).toBe("no type errors");
54
- expect(result.failures).toHaveLength(0);
55
- });
56
-
57
- it("absolute file paths → relativized to cwd", async () => {
58
- const stderr =
59
- '{"file": "/project/src/foo.py", "line": 10, "column": 5, "message": "Need type annotation", "hint": null, "code": "var-annotated", "severity": "error"}';
60
- const result = await parser.parse(makeCtx(stderr, "/project"));
61
- expect(result.failures![0].file).toBe("src/foo.py");
62
- expect(result.failures![0].file).not.toContain("/project");
63
- });
64
-
65
- it("note severity items are skipped as standalone failures", async () => {
66
- const stderr = [
67
- '{"file": "foo.py", "line": 5, "column": 1, "message": "Missing return statement", "hint": null, "code": "return", "severity": "error"}',
68
- '{"file": "foo.py", "line": 5, "column": 1, "message": "See https://mypy.readthedocs.io/...", "hint": null, "code": null, "severity": "note"}',
69
- ].join("\n");
70
- const result = await parser.parse(makeCtx(stderr));
71
- expect(result.failures).toHaveLength(1);
72
- expect(result.failures![0].rule).toBe("return");
73
- });
74
-
75
- it("notes on the same line as an error are appended to the error message", async () => {
76
- const stderr = [
77
- '{"file": "foo.py", "line": 5, "column": 1, "message": "Missing return statement", "hint": null, "code": "return", "severity": "error"}',
78
- '{"file": "foo.py", "line": 5, "column": 1, "message": "Did you forget to return a value?", "hint": null, "code": null, "severity": "note"}',
79
- ].join("\n");
80
- const result = await parser.parse(makeCtx(stderr));
81
- expect(result.failures).toHaveLength(1);
82
- expect(result.failures![0].message).toBe("Missing return statement (Did you forget to return a value?)");
83
- });
84
-
85
- it("hint field is included in message when present", async () => {
86
- const stderr =
87
- '{"file": "foo.py", "line": 3, "column": 1, "message": "Cannot find module", "hint": "Did you install types-requests?", "code": "import", "severity": "error"}';
88
- const result = await parser.parse(makeCtx(stderr));
89
- expect(result.failures![0].message).toBe("Cannot find module (Did you install types-requests?)");
90
- });
91
-
92
- it("handles non-JSON lines gracefully (e.g. summary text mixed in)", async () => {
93
- const stderr = [
94
- '{"file": "foo.py", "line": 1, "column": 1, "message": "Unused import", "hint": null, "code": "unused-import", "severity": "error"}',
95
- "Found 1 error in 1 file (checked 1 source file)",
96
- ].join("\n");
97
- const result = await parser.parse(makeCtx(stderr));
98
- expect(result.failures).toHaveLength(1);
99
- expect(result.failures![0].rule).toBe("unused-import");
100
- });
101
- });
@@ -1,117 +0,0 @@
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 "./node-test-text";
6
- import type { RunContext } from "../types";
7
-
8
- function makeCtx(stdout: string, cwd = "/project"): RunContext {
9
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "node-test-text-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- const stderrPath = path.join(dir, "stderr");
12
- fs.writeFileSync(stdoutPath, stdout);
13
- fs.writeFileSync(stderrPath, "");
14
- return {
15
- command: "node --test",
16
- argv: ["node", "--test"],
17
- cwd,
18
- artifactPaths: [],
19
- stdoutPath,
20
- stderrPath,
21
- logPath: path.join(dir, "log"),
22
- };
23
- }
24
-
25
- describe("node-test-text parser", () => {
26
- it("mixed pass/fail → correct summary, file:line, and assertion messages", async () => {
27
- const cwd = "/project";
28
- const stdout = `▶ math
29
- ✔ adds two numbers correctly (0.329ms)
30
- ✖ multiplies two numbers correctly (0.466ms)
31
- ✖ does not divide by zero (5.098ms)
32
- ✖ math (6.373ms)
33
- ℹ tests 3
34
- ℹ suites 1
35
- ℹ pass 1
36
- ℹ fail 2
37
- ℹ cancelled 0
38
- ℹ skipped 0
39
- ℹ todo 0
40
- ℹ duration_ms 68.049
41
-
42
- ✖ failing tests:
43
-
44
- test at /project/src/test_math.mjs:9:3
45
- ✖ multiplies two numbers correctly (0.466ms)
46
- AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
47
-
48
- 12 !== 99
49
-
50
- at TestContext.<anonymous> (file:///project/src/test_math.mjs:10:12)
51
- at Test.runInAsyncScope (node:async_hooks:226:14)
52
-
53
- test at /project/src/test_math.mjs:13:3
54
- ✖ does not divide by zero (5.098ms)
55
- AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
56
-
57
- assert.ok(isFinite(result))
58
-
59
- at TestContext.<anonymous> (file:///project/src/test_math.mjs:15:12)`;
60
- const result = await parser.parse(makeCtx(stdout, cwd));
61
- expect(result.status).toBe("fail");
62
- expect(result.summary).toBe("2 failed, 1 passed");
63
- expect(result.failures).toHaveLength(2);
64
- expect(result.failures![0].file).toBe("src/test_math.mjs");
65
- expect(result.failures![0].line).toBe(9);
66
- expect(result.failures![0].message).toContain("12 !== 99");
67
- expect(result.failures![1].message).toContain("assert.ok(isFinite(result))");
68
- // No stack traces in output
69
- expect(result.failures![0].message).not.toContain("at Test");
70
- });
71
-
72
- it("all passing → status pass, no failures", async () => {
73
- const stdout = `▶ math
74
- ✔ adds correctly (0.2ms)
75
- ✔ math (1ms)
76
- ℹ tests 1
77
- ℹ suites 1
78
- ℹ pass 1
79
- ℹ fail 0
80
- ℹ duration_ms 50.0`;
81
- const result = await parser.parse(makeCtx(stdout));
82
- expect(result.status).toBe("pass");
83
- expect(result.summary).toBe("1 passed");
84
- expect(result.failures).toHaveLength(0);
85
- });
86
-
87
- it("non-assertion error (TypeError) → captures error message", async () => {
88
- const cwd = "/project";
89
- const stdout = `▶ suite
90
- ✖ throws type error (1ms)
91
- ✖ suite (2ms)
92
- ℹ tests 1
93
- ℹ suites 1
94
- ℹ pass 0
95
- ℹ fail 1
96
- ℹ duration_ms 50.0
97
-
98
- ✖ failing tests:
99
-
100
- test at /project/src/test.mjs:5:3
101
- ✖ throws type error (1ms)
102
- TypeError: Cannot read properties of null (reading 'foo')
103
- at TestContext.<anonymous> (file:///project/src/test.mjs:6:10)
104
- at Test.runInAsyncScope (node:async_hooks:226:14)`;
105
- const result = await parser.parse(makeCtx(stdout, cwd));
106
- expect(result.status).toBe("fail");
107
- expect(result.failures).toHaveLength(1);
108
- expect(result.failures![0].message).toContain("Cannot read properties of null");
109
- expect(result.failures![0].message).not.toContain("at Test");
110
- });
111
-
112
- it("empty stdout → no crash, status pass", async () => {
113
- const result = await parser.parse(makeCtx(""));
114
- expect(result.status).toBe("pass");
115
- expect(result.failures).toHaveLength(0);
116
- });
117
- });
@@ -1,83 +0,0 @@
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 "./npm-audit-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(), "npm-audit-test-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- fs.writeFileSync(stdoutPath, stdout);
12
- return {
13
- command: "npm audit --json",
14
- argv: ["npm", "audit", "--json"],
15
- cwd,
16
- artifactPaths: [],
17
- stdoutPath,
18
- stderrPath: path.join(dir, "stderr"),
19
- logPath: path.join(dir, "log"),
20
- };
21
- }
22
-
23
- describe("npm-audit-json parser", () => {
24
- it("vulnerabilities with advisories → extracts package name, severity, advisory titles", async () => {
25
- const stdout = JSON.stringify({
26
- auditReportVersion: 2,
27
- vulnerabilities: {
28
- lodash: {
29
- name: "lodash",
30
- severity: "high",
31
- isDirect: true,
32
- via: [
33
- { title: "Command Injection in lodash", severity: "high", url: "https://example.com" },
34
- { title: "ReDoS in lodash", severity: "moderate", url: "https://example.com" },
35
- ],
36
- fixAvailable: true,
37
- },
38
- },
39
- metadata: { vulnerabilities: { info: 0, low: 0, moderate: 0, high: 1, critical: 0, total: 1 } },
40
- });
41
- const result = await parser.parse(makeCtx(stdout));
42
- expect(result.status).toBe("fail");
43
- expect(result.summary).toBe("1 vulnerability (1 high)");
44
- expect(result.failures).toHaveLength(1);
45
- expect(result.failures![0].file).toBe("lodash");
46
- expect(result.failures![0].rule).toBe("high");
47
- expect(result.failures![0].message).toContain("Command Injection");
48
- expect(result.failures![0].message).toContain("ReDoS");
49
- // No URLs in output
50
- expect(result.failures![0].message).not.toContain("https://");
51
- });
52
-
53
- it("no vulnerabilities → status pass", async () => {
54
- const stdout = JSON.stringify({
55
- auditReportVersion: 2,
56
- vulnerabilities: {},
57
- metadata: { vulnerabilities: { info: 0, low: 0, moderate: 0, high: 0, critical: 0, total: 0 } },
58
- });
59
- const result = await parser.parse(makeCtx(stdout));
60
- expect(result.status).toBe("pass");
61
- expect(result.summary).toBe("no vulnerabilities found");
62
- expect(result.failures).toHaveLength(0);
63
- });
64
-
65
- it("empty stdout → no crash, status pass", async () => {
66
- const result = await parser.parse(makeCtx(""));
67
- expect(result.status).toBe("pass");
68
- expect(result.failures).toHaveLength(0);
69
- });
70
-
71
- it("multiple severities → correct summary breakdown", async () => {
72
- const stdout = JSON.stringify({
73
- vulnerabilities: {
74
- "pkg-a": { name: "pkg-a", severity: "critical", isDirect: true, via: [{ title: "RCE" }] },
75
- "pkg-b": { name: "pkg-b", severity: "low", isDirect: false, via: [{ title: "Info leak" }] },
76
- },
77
- metadata: { vulnerabilities: { info: 0, low: 1, moderate: 0, high: 0, critical: 1, total: 2 } },
78
- });
79
- const result = await parser.parse(makeCtx(stdout));
80
- expect(result.summary).toBe("2 vulnerabilities (1 critical, 1 low)");
81
- expect(result.failures).toHaveLength(2);
82
- });
83
- });
@@ -1,76 +0,0 @@
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 "./prettier-text";
6
- import type { RunContext } from "../types";
7
-
8
- function makeCtx(stdout: string, stderr = "", cwd = "/project"): RunContext {
9
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "prettier-test-"));
10
- const stdoutPath = path.join(dir, "stdout");
11
- const stderrPath = path.join(dir, "stderr");
12
- fs.writeFileSync(stdoutPath, stdout);
13
- fs.writeFileSync(stderrPath, stderr);
14
- return {
15
- command: "prettier --check .",
16
- argv: ["prettier", "--check", "."],
17
- cwd,
18
- artifactPaths: [],
19
- stdoutPath,
20
- stderrPath,
21
- logPath: path.join(dir, "log"),
22
- };
23
- }
24
-
25
- describe("prettier-text parser", () => {
26
- it("files needing formatting → strips preamble/footer, lists files", async () => {
27
- const cwd = "/project";
28
- const stdout = `Checking formatting...
29
- [warn] /project/src/app.ts
30
- [warn] /project/src/utils.ts
31
- [warn] Code style issues found in 2 files. Run Prettier with --write to fix.`;
32
- const result = await parser.parse(makeCtx(stdout, "", cwd));
33
- expect(result.status).toBe("fail");
34
- expect(result.summary).toBe("2 files have formatting issues");
35
- expect(result.failures).toHaveLength(2);
36
- expect(result.failures![0].file).toBe("src/app.ts");
37
- expect(result.failures![1].file).toBe("src/utils.ts");
38
- });
39
-
40
- it("all formatted → status pass", async () => {
41
- const stdout = `Checking formatting...
42
- All matched files use Prettier code style!`;
43
- const result = await parser.parse(makeCtx(stdout));
44
- expect(result.status).toBe("pass");
45
- expect(result.summary).toBe("all files formatted");
46
- expect(result.failures).toHaveLength(0);
47
- });
48
-
49
- it("single file → singular grammar", async () => {
50
- const stdout = `Checking formatting...
51
- [warn] /project/bad.ts
52
- [warn] Code style issues found in the above file. Run Prettier with --write to fix.`;
53
- const result = await parser.parse(makeCtx(stdout));
54
- expect(result.status).toBe("fail");
55
- expect(result.summary).toBe("1 file has formatting issues");
56
- });
57
-
58
- it("extensionless files (Dockerfile, Makefile) → not dropped", async () => {
59
- const cwd = "/project";
60
- const stdout = `Checking formatting...
61
- [warn] /project/Dockerfile
62
- [warn] /project/src/app.ts
63
- [warn] Code style issues found in 2 files. Run Prettier with --write to fix.`;
64
- const result = await parser.parse(makeCtx(stdout, "", cwd));
65
- expect(result.status).toBe("fail");
66
- expect(result.failures).toHaveLength(2);
67
- expect(result.failures![0].file).toBe("Dockerfile");
68
- expect(result.failures![1].file).toBe("src/app.ts");
69
- });
70
-
71
- it("empty output → no crash, status pass", async () => {
72
- const result = await parser.parse(makeCtx(""));
73
- expect(result.status).toBe("pass");
74
- expect(result.failures).toHaveLength(0);
75
- });
76
- });