@robhowley/pi-structured-return 1.9.0 → 1.10.1

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 +2 -1
  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 +61 -43
  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 +29 -44
  50. package/skills/structured-return/SKILL.md +7 -0
  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 -627
  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,6 +1,6 @@
1
- import path from "node:path";
2
- import type { ParserModule, ParsedFailure } from "../types";
3
- import { safeReadFile } from "./utils";
1
+ import path from 'node:path';
2
+ import type { ParserModule, ParsedFailure } from '../types';
3
+ import { safeReadFile } from './utils';
4
4
 
5
5
  interface HadolintItem {
6
6
  code: string;
@@ -12,11 +12,17 @@ interface HadolintItem {
12
12
  }
13
13
 
14
14
  const parser: ParserModule = {
15
- id: "hadolint-json",
15
+ id: 'hadolint-json',
16
16
  async parse(ctx) {
17
17
  const stdout = safeReadFile(ctx.stdoutPath).trim();
18
- if (!stdout || stdout === "[]") {
19
- return { tool: "hadolint", status: "pass", summary: "no lint errors", failures: [], logPath: ctx.logPath };
18
+ if (!stdout || stdout === '[]') {
19
+ return {
20
+ tool: 'hadolint',
21
+ status: 'pass',
22
+ summary: 'no lint errors',
23
+ failures: [],
24
+ logPath: ctx.logPath,
25
+ };
20
26
  }
21
27
 
22
28
  let items: HadolintItem[];
@@ -24,9 +30,9 @@ const parser: ParserModule = {
24
30
  items = JSON.parse(stdout) as HadolintItem[];
25
31
  } catch {
26
32
  return {
27
- tool: "hadolint",
28
- status: "error",
29
- summary: "failed to parse hadolint JSON output",
33
+ tool: 'hadolint',
34
+ status: 'error',
35
+ summary: 'failed to parse hadolint JSON output',
30
36
  logPath: ctx.logPath,
31
37
  };
32
38
  }
@@ -43,9 +49,9 @@ const parser: ParserModule = {
43
49
  });
44
50
 
45
51
  return {
46
- tool: "hadolint",
47
- status: failures.length > 0 ? "fail" : "pass",
48
- summary: failures.length > 0 ? `${failures.length} lint errors` : "no lint errors",
52
+ tool: 'hadolint',
53
+ status: failures.length > 0 ? 'fail' : 'pass',
54
+ summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
49
55
  failures,
50
56
  logPath: ctx.logPath,
51
57
  };
@@ -1,6 +1,6 @@
1
- import path from "node:path";
2
- import type { ParserModule, ParsedFailure } from "../types";
3
- import { safeReadFile } from "./utils";
1
+ import path from 'node:path';
2
+ import type { ParserModule, ParsedFailure } from '../types';
3
+ import { safeReadFile } from './utils';
4
4
 
5
5
  interface HtmlHintMessage {
6
6
  type: string;
@@ -16,15 +16,15 @@ interface HtmlHintFile {
16
16
  }
17
17
 
18
18
  const parser: ParserModule = {
19
- id: "htmlhint-json",
19
+ id: 'htmlhint-json',
20
20
  async parse(ctx) {
21
21
  // htmlhint --format json writes JSON to stderr (not stdout), so read stderr first.
22
22
  const output = (safeReadFile(ctx.stderrPath) + safeReadFile(ctx.stdoutPath)).trim();
23
23
  if (!output) {
24
24
  return {
25
- tool: "htmlhint",
26
- status: "pass",
27
- summary: "no lint errors",
25
+ tool: 'htmlhint',
26
+ status: 'pass',
27
+ summary: 'no lint errors',
28
28
  failures: [],
29
29
  logPath: ctx.logPath,
30
30
  };
@@ -35,9 +35,9 @@ const parser: ParserModule = {
35
35
  files = JSON.parse(output);
36
36
  } catch {
37
37
  return {
38
- tool: "htmlhint",
39
- status: "error",
40
- summary: "failed to parse htmlhint JSON output",
38
+ tool: 'htmlhint',
39
+ status: 'error',
40
+ summary: 'failed to parse htmlhint JSON output',
41
41
  logPath: ctx.logPath,
42
42
  };
43
43
  }
@@ -57,11 +57,13 @@ const parser: ParserModule = {
57
57
  }
58
58
 
59
59
  const summary =
60
- failures.length > 0 ? `${failures.length} lint error${failures.length !== 1 ? "s" : ""}` : "no lint errors";
60
+ failures.length > 0
61
+ ? `${failures.length} lint error${failures.length !== 1 ? 's' : ''}`
62
+ : 'no lint errors';
61
63
 
62
64
  return {
63
- tool: "htmlhint",
64
- status: failures.length > 0 ? "fail" : "pass",
65
+ tool: 'htmlhint',
66
+ status: failures.length > 0 ? 'fail' : 'pass',
65
67
  summary,
66
68
  failures,
67
69
  logPath: ctx.logPath,
@@ -1,24 +1,24 @@
1
- import path from "node:path";
2
- import type { ParserModule, ParsedFailure } from "../types";
3
- import { safeReadFile } from "./utils";
1
+ import path from 'node:path';
2
+ import type { ParserModule, ParsedFailure } from '../types';
3
+ import { safeReadFile } from './utils';
4
4
 
5
5
  // ERROR: /path/to/file.py Imports are incorrectly sorted and/or formatted.
6
6
  const ERROR_LINE = /^ERROR: (.+?) Imports are incorrectly sorted/;
7
7
  const parser: ParserModule = {
8
- id: "isort-text",
8
+ id: 'isort-text',
9
9
  async parse(ctx) {
10
- const combined = (safeReadFile(ctx.stdoutPath) + "\n" + safeReadFile(ctx.stderrPath)).trim();
10
+ const combined = (safeReadFile(ctx.stdoutPath) + '\n' + safeReadFile(ctx.stderrPath)).trim();
11
11
  if (!combined) {
12
12
  return {
13
- tool: "isort",
14
- status: "pass",
15
- summary: "all imports sorted",
13
+ tool: 'isort',
14
+ status: 'pass',
15
+ summary: 'all imports sorted',
16
16
  failures: [],
17
17
  logPath: ctx.logPath,
18
18
  };
19
19
  }
20
20
 
21
- const lines = combined.split("\n");
21
+ const lines = combined.split('\n');
22
22
  const failures: ParsedFailure[] = [];
23
23
 
24
24
  for (const line of lines) {
@@ -28,16 +28,16 @@ const parser: ParserModule = {
28
28
  failures.push({
29
29
  id: relPath,
30
30
  file: relPath,
31
- message: "imports are incorrectly sorted",
31
+ message: 'imports are incorrectly sorted',
32
32
  });
33
33
  }
34
34
  }
35
35
 
36
- if (failures.length === 0 && !combined.includes("ERROR")) {
36
+ if (failures.length === 0 && !combined.includes('ERROR')) {
37
37
  return {
38
- tool: "isort",
39
- status: "pass",
40
- summary: "all imports sorted",
38
+ tool: 'isort',
39
+ status: 'pass',
40
+ summary: 'all imports sorted',
41
41
  failures: [],
42
42
  logPath: ctx.logPath,
43
43
  };
@@ -46,14 +46,14 @@ const parser: ParserModule = {
46
46
  const n = failures.length;
47
47
  const summary =
48
48
  n === 0
49
- ? "all imports sorted"
49
+ ? 'all imports sorted'
50
50
  : n === 1
51
- ? "1 file has incorrectly sorted imports"
51
+ ? '1 file has incorrectly sorted imports'
52
52
  : `${n} files have incorrectly sorted imports`;
53
53
 
54
54
  return {
55
- tool: "isort",
56
- status: n > 0 ? "fail" : "pass",
55
+ tool: 'isort',
56
+ status: n > 0 ? 'fail' : 'pass',
57
57
  summary,
58
58
  failures,
59
59
  logPath: ctx.logPath,
@@ -1,6 +1,6 @@
1
- import path from "node:path";
2
- import type { ParserModule, ParsedFailure } from "../types";
3
- import { safeReadFile } from "./utils";
1
+ import path from 'node:path';
2
+ import type { ParserModule, ParsedFailure } from '../types';
3
+ import { safeReadFile } from './utils';
4
4
 
5
5
  const ERROR_LINE = /^(.+?):(\d+): error: (.+)$/;
6
6
  const SYMBOL_LINE = /^\s+symbol:\s+(.+)$/;
@@ -9,22 +9,22 @@ const CARET_LINE = /^\s+\^/;
9
9
  const SOURCE_SNIPPET = /^\s{8,}\S/;
10
10
 
11
11
  const parser: ParserModule = {
12
- id: "javac-text",
12
+ id: 'javac-text',
13
13
  async parse(ctx) {
14
14
  const stderr = safeReadFile(ctx.stderrPath).trim();
15
15
  if (!stderr) {
16
16
  return {
17
- tool: "javac",
18
- status: "pass",
19
- summary: "compilation successful",
17
+ tool: 'javac',
18
+ status: 'pass',
19
+ summary: 'compilation successful',
20
20
  failures: [],
21
21
  logPath: ctx.logPath,
22
22
  };
23
23
  }
24
24
 
25
- const lines = stderr.split("\n");
25
+ const lines = stderr.split('\n');
26
26
  const failures: ParsedFailure[] = [];
27
- let summaryLine = "";
27
+ let summaryLine = '';
28
28
 
29
29
  for (let i = 0; i < lines.length; i++) {
30
30
  const errorMatch = lines[i].match(ERROR_LINE);
@@ -66,11 +66,13 @@ const parser: ParserModule = {
66
66
 
67
67
  const summary =
68
68
  summaryLine ||
69
- (failures.length > 0 ? `${failures.length} error${failures.length !== 1 ? "s" : ""}` : "compilation successful");
69
+ (failures.length > 0
70
+ ? `${failures.length} error${failures.length !== 1 ? 's' : ''}`
71
+ : 'compilation successful');
70
72
 
71
73
  return {
72
- tool: "javac",
73
- status: failures.length > 0 ? "fail" : "pass",
74
+ tool: 'javac',
75
+ status: failures.length > 0 ? 'fail' : 'pass',
74
76
  summary,
75
77
  failures,
76
78
  logPath: ctx.logPath,
@@ -1,5 +1,5 @@
1
- import type { ParserModule, ParsedFailure } from "../types";
2
- import { safeReadFile } from "./utils";
1
+ import type { ParserModule, ParsedFailure } from '../types';
2
+ import { safeReadFile } from './utils';
3
3
 
4
4
  // Error: Parse error on line N:
5
5
  const ERROR_HEADER = /^Error: Parse error on line (\d+):$/;
@@ -7,14 +7,14 @@ const ERROR_HEADER = /^Error: Parse error on line (\d+):$/;
7
7
  const EXPECTING_LINE = /^(Expecting .+)$/;
8
8
 
9
9
  const parser: ParserModule = {
10
- id: "jsonlint-text",
10
+ id: 'jsonlint-text',
11
11
  async parse(ctx) {
12
- const combined = (safeReadFile(ctx.stdoutPath) + "\n" + safeReadFile(ctx.stderrPath)).trim();
12
+ const combined = (safeReadFile(ctx.stdoutPath) + '\n' + safeReadFile(ctx.stderrPath)).trim();
13
13
  if (!combined) {
14
14
  return {
15
- tool: "jsonlint",
16
- status: "pass",
17
- summary: "valid JSON",
15
+ tool: 'jsonlint',
16
+ status: 'pass',
17
+ summary: 'valid JSON',
18
18
  failures: [],
19
19
  logPath: ctx.logPath,
20
20
  };
@@ -22,12 +22,14 @@ const parser: ParserModule = {
22
22
 
23
23
  // Derive filename from argv — use last non-flag arg since earlier positional
24
24
  // args may be flag values (e.g. npx --yes jsonlint file.json).
25
- const file = ctx.argv.filter((a) => !a.startsWith("-") && a !== "jsonlint" && a !== "npx").pop() ?? "input";
25
+ const file =
26
+ ctx.argv.filter((a) => !a.startsWith('-') && a !== 'jsonlint' && a !== 'npx').pop() ??
27
+ 'input';
26
28
 
27
- const lines = combined.split("\n");
29
+ const lines = combined.split('\n');
28
30
  const failures: ParsedFailure[] = [];
29
31
  let line: number | undefined;
30
- let message = "";
32
+ let message = '';
31
33
 
32
34
  for (const l of lines) {
33
35
  const headerMatch = l.match(ERROR_HEADER);
@@ -47,14 +49,14 @@ const parser: ParserModule = {
47
49
  id: `${file}:${line}`,
48
50
  file,
49
51
  line,
50
- message: message || "parse error",
52
+ message: message || 'parse error',
51
53
  });
52
54
  }
53
55
 
54
56
  return {
55
- tool: "jsonlint",
56
- status: failures.length > 0 ? "fail" : "pass",
57
- summary: failures.length > 0 ? "parse error" : "valid JSON",
57
+ tool: 'jsonlint',
58
+ status: failures.length > 0 ? 'fail' : 'pass',
59
+ summary: failures.length > 0 ? 'parse error' : 'valid JSON',
58
60
  failures,
59
61
  logPath: ctx.logPath,
60
62
  };
@@ -1,12 +1,12 @@
1
- import path from "node:path";
2
- import { XMLParser } from "fast-xml-parser";
3
- import type { ParserModule, ParsedFailure } from "../types";
4
- import { safeReadFile } from "./utils";
1
+ import path from 'node:path';
2
+ import { XMLParser } from 'fast-xml-parser';
3
+ import type { ParserModule, ParsedFailure } from '../types';
4
+ import { safeReadFile } from './utils';
5
5
 
6
6
  interface JUnitFailureOrError {
7
7
  message?: string;
8
8
  type?: string;
9
- "#text"?: string;
9
+ '#text'?: string;
10
10
  }
11
11
 
12
12
  interface JUnitTestCase {
@@ -26,7 +26,7 @@ interface JUnitTestSuite {
26
26
  errors?: string | number;
27
27
  testcase?: JUnitTestCase[];
28
28
  testsuite?: JUnitTestSuite[]; // PHPUnit nests testsuites
29
- "system-out"?: string;
29
+ 'system-out'?: string;
30
30
  }
31
31
 
32
32
  interface JUnitDocument {
@@ -36,8 +36,8 @@ interface JUnitDocument {
36
36
 
37
37
  const xmlParser = new XMLParser({
38
38
  ignoreAttributes: false,
39
- attributeNamePrefix: "",
40
- isArray: (name) => ["testsuite", "testcase"].includes(name),
39
+ attributeNamePrefix: '',
40
+ isArray: (name) => ['testsuite', 'testcase'].includes(name),
41
41
  });
42
42
 
43
43
  /** Decode numeric XML character references (e.g. &#xA; → newline) in attribute values. */
@@ -58,11 +58,11 @@ function stripPestTestNamePrefix(text: string, testName?: string): string {
58
58
  /** Extract Expected/Received/Actual diff lines from a failure body, e.g. Jest assertion output. */
59
59
  function extractAssertionDiff(text: string): string | undefined {
60
60
  const diffLines: string[] = [];
61
- for (const line of text.split("\n")) {
61
+ for (const line of text.split('\n')) {
62
62
  const trimmed = line.trim();
63
63
  if (/^(Expected|Received|Actual)\s*:/.test(trimmed)) diffLines.push(trimmed);
64
64
  }
65
- return diffLines.length > 0 ? diffLines.join("\n") : undefined;
65
+ return diffLines.length > 0 ? diffLines.join('\n') : undefined;
66
66
  }
67
67
 
68
68
  /** Extract file, line, and message from failure body text.
@@ -77,28 +77,30 @@ function extractAssertionDiff(text: string): string | undefined {
77
77
  * preferring the frame whose class matches `classname`. */
78
78
  function parseBodyLocation(
79
79
  text: string,
80
- classname?: string
80
+ classname?: string,
81
81
  ): { file: string; line: number; message?: string } | undefined {
82
82
  const lines = text
83
- .split("\n")
83
+ .split('\n')
84
84
  .map((l) => l.trim())
85
85
  .filter(Boolean);
86
86
 
87
87
  const phpMessage = () =>
88
- lines.find((l) => !/^\w+::\w+/.test(l) && !/^at\s+.+?\.php:\d+$/.test(l) && !/^.+?\.php:\d+$/.test(l));
88
+ lines.find(
89
+ (l) => !/^\w+::\w+/.test(l) && !/^at\s+.+?\.php:\d+$/.test(l) && !/^.+?\.php:\d+$/.test(l),
90
+ );
89
91
 
90
92
  // Check stack frames first so Playwright/Jest locations win over header lines like
91
93
  // "math.test.ts:8:7 › suite › test", which would otherwise match the generic file:line pattern.
92
94
  for (const line of lines) {
93
95
  const m = line.match(/^at\s+\S+\s+\(([^)]+\.(?:[jt]sx?|mjs|cjs)):(\d+):\d+\)/);
94
- if (m && !m[1].includes("node_modules")) {
96
+ if (m && !m[1].includes('node_modules')) {
95
97
  return { file: path.basename(m[1]), line: Number(m[2]) };
96
98
  }
97
99
  }
98
100
 
99
101
  for (const line of lines) {
100
102
  const m = line.match(/^at\s+(.+?\.(?:[jt]sx?|mjs|cjs)):(\d+):\d+$/);
101
- if (m && !m[1].includes("node_modules")) {
103
+ if (m && !m[1].includes('node_modules')) {
102
104
  return { file: path.basename(m[1]), line: Number(m[2]) };
103
105
  }
104
106
  }
@@ -122,8 +124,16 @@ function parseBodyLocation(
122
124
 
123
125
  // Java/JVM: "at [module/]pkg.Class.method(File.java:N)"
124
126
  const javaRe = /^at (?:[\w.$]+\/)?([\w.$]+)\.\w+\(([\w]+\.(?:java|kt|scala|groovy)):(\d+)\)$/;
125
- const frameworkPrefixes = ["java.", "javax.", "sun.", "com.sun.", "org.junit.", "org.opentest4j.", "junit."];
126
- const simpleClass = classname?.split(".").pop();
127
+ const frameworkPrefixes = [
128
+ 'java.',
129
+ 'javax.',
130
+ 'sun.',
131
+ 'com.sun.',
132
+ 'org.junit.',
133
+ 'org.opentest4j.',
134
+ 'junit.',
135
+ ];
136
+ const simpleClass = classname?.split('.').pop();
127
137
  let firstUserFrame: { file: string; line: number } | undefined;
128
138
 
129
139
  for (const line of lines) {
@@ -154,22 +164,22 @@ function parseBodyLocation(
154
164
  /** Extract panic message and file:line for a specific test from Go's system-out. */
155
165
  function parsePanicInfo(
156
166
  systemOut: string,
157
- testName: string
167
+ testName: string,
158
168
  ): { message?: string; file?: string; line?: number } | undefined {
159
- const lines = systemOut.split("\n");
160
- const panicLine = lines.find((l) => l.trim().startsWith("panic:"));
169
+ const lines = systemOut.split('\n');
170
+ const panicLine = lines.find((l) => l.trim().startsWith('panic:'));
161
171
  if (!panicLine) return undefined;
162
172
  const message = panicLine
163
173
  .trim()
164
- .replace(/^panic:\s*/, "")
165
- .replace(/\s*\[.*\]$/, "")
174
+ .replace(/^panic:\s*/, '')
175
+ .replace(/\s*\[.*\]$/, '')
166
176
  .trim();
167
177
 
168
178
  // Find the stack frame for this test function, then grab the file:line on the next line
169
179
  for (let i = 0; i < lines.length - 1; i++) {
170
180
  if (lines[i].includes(`.${testName}(`)) {
171
181
  const m = lines[i + 1].trim().match(/^([^:]+\.go):(\d+)/);
172
- if (m) return { message, file: m[1].split("/").pop(), line: Number(m[2]) };
182
+ if (m) return { message, file: m[1].split('/').pop(), line: Number(m[2]) };
173
183
  }
174
184
  }
175
185
  return { message };
@@ -177,26 +187,26 @@ function parsePanicInfo(
177
187
 
178
188
  function resolveClassnameFile(classname?: string): string | undefined {
179
189
  if (!classname) return undefined;
180
- const normalized = classname.replace(/\\/g, "/");
190
+ const normalized = classname.replace(/\\/g, '/');
181
191
  if (/\.(?:[jt]sx?|mjs|cjs|py|rb|go|php|cs|fs|vb|java|kt|scala|groovy)$/.test(normalized)) {
182
192
  return normalized;
183
193
  }
184
- if (normalized.includes("/")) return undefined;
194
+ if (normalized.includes('/')) return undefined;
185
195
  if (/^[\w$]+(?:\.[\w$]+)*$/.test(classname)) {
186
- return classname.replace(/\./g, "/") + ".java";
196
+ return classname.replace(/\./g, '/') + '.java';
187
197
  }
188
198
  return undefined;
189
199
  }
190
200
 
191
201
  function resolveFile(tc: JUnitTestCase, suite: JUnitTestSuite, cwd: string): string | undefined {
192
- const raw = (tc.file ?? suite.file)?.split("::")[0];
202
+ const raw = (tc.file ?? suite.file)?.split('::')[0];
193
203
  if (raw) return path.relative(cwd, path.resolve(cwd, raw));
194
204
  return resolveClassnameFile(tc.classname);
195
205
  }
196
206
 
197
207
  function isPhpFile(candidate?: string): boolean {
198
208
  if (!candidate) return false;
199
- return candidate.split("::")[0].replace(/\\/g, "/").endsWith(".php");
209
+ return candidate.split('::')[0].replace(/\\/g, '/').endsWith('.php');
200
210
  }
201
211
 
202
212
  /** Recursively collect all testsuites including nested ones (PHPUnit/Pest style). */
@@ -212,7 +222,7 @@ function flattenSuites(suites: JUnitTestSuite[]): JUnitTestSuite[] {
212
222
  }
213
223
 
214
224
  const parser: ParserModule = {
215
- id: "junit-xml",
225
+ id: 'junit-xml',
216
226
  async parse(ctx) {
217
227
  const artifactSources = ctx.artifactPaths.length > 0 ? ctx.artifactPaths : [ctx.stdoutPath];
218
228
 
@@ -240,11 +250,16 @@ const parser: ParserModule = {
240
250
  for (const tc of suite.testcase ?? []) {
241
251
  const rawProblem = tc.failure ?? tc.error;
242
252
  if (!rawProblem) continue;
243
- const problem: JUnitFailureOrError = typeof rawProblem === "string" ? { "#text": rawProblem } : rawProblem;
253
+ const problem: JUnitFailureOrError =
254
+ typeof rawProblem === 'string' ? { '#text': rawProblem } : rawProblem;
244
255
 
245
- const bodyLocation = problem["#text"] ? parseBodyLocation(problem["#text"], tc.classname) : undefined;
256
+ const bodyLocation = problem['#text']
257
+ ? parseBodyLocation(problem['#text'], tc.classname)
258
+ : undefined;
246
259
  const panicInfo =
247
- !bodyLocation && suite["system-out"] && tc.name ? parsePanicInfo(suite["system-out"], tc.name) : undefined;
260
+ !bodyLocation && suite['system-out'] && tc.name
261
+ ? parsePanicInfo(suite['system-out'], tc.name)
262
+ : undefined;
248
263
  const file =
249
264
  (tc.file ?? suite.file)
250
265
  ? resolveFile(tc, suite, ctx.cwd)
@@ -253,11 +268,14 @@ const parser: ParserModule = {
253
268
  // PHPUnit/Pest report tc.line as the test method definition line, not the failure line.
254
269
  // Other JUnit producers historically prefer tc.line when it is present.
255
270
  const preferBodyLine =
256
- isPhpFile(file) || isPhpFile(tc.file) || isPhpFile(suite.file) || isPhpFile(bodyLocation?.file);
271
+ isPhpFile(file) ||
272
+ isPhpFile(tc.file) ||
273
+ isPhpFile(suite.file) ||
274
+ isPhpFile(bodyLocation?.file);
257
275
  const line = preferBodyLine
258
276
  ? (bodyLocation?.line ?? panicInfo?.line ?? tcLine)
259
277
  : (tcLine ?? bodyLocation?.line ?? panicInfo?.line);
260
- const id = [file, line, tc.name].filter(Boolean).join(":");
278
+ const id = [file, line, tc.name].filter(Boolean).join(':');
261
279
 
262
280
  failures.push({
263
281
  id: id || String(failures.length),
@@ -265,24 +283,24 @@ const parser: ParserModule = {
265
283
  line: Number.isNaN(line) ? undefined : line,
266
284
  message: (() => {
267
285
  let raw =
268
- problem.message && problem.message.toLowerCase() !== "failed"
286
+ problem.message && problem.message.toLowerCase() !== 'failed'
269
287
  ? problem.message
270
288
  : (bodyLocation?.message ??
271
289
  panicInfo?.message ??
272
290
  problem.message ??
273
- problem["#text"]?.trim().split("\n")[0]);
291
+ problem['#text']?.trim().split('\n')[0]);
274
292
  if (!raw) return undefined;
275
293
  raw = stripPestTestNamePrefix(raw, tc.name);
276
294
  const decoded = decodeXmlEntities(raw);
277
295
  // Append assertion diff lines (Expected/Received/Actual) from the body when not already present.
278
296
  // Covers Jest-style failures where the diff follows the error type line in #text.
279
297
  if (
280
- problem["#text"] &&
281
- !decoded.includes("Expected") &&
282
- !decoded.includes("Received") &&
283
- !decoded.includes("Actual")
298
+ problem['#text'] &&
299
+ !decoded.includes('Expected') &&
300
+ !decoded.includes('Received') &&
301
+ !decoded.includes('Actual')
284
302
  ) {
285
- const diff = extractAssertionDiff(problem["#text"]);
303
+ const diff = extractAssertionDiff(problem['#text']);
286
304
  if (diff) return `${decoded}\n${diff}`;
287
305
  }
288
306
  return decoded;
@@ -296,8 +314,8 @@ const parser: ParserModule = {
296
314
  const passed = totalTests - totalFailed;
297
315
 
298
316
  return {
299
- tool: "junit",
300
- status: totalFailed > 0 ? "fail" : "pass",
317
+ tool: 'junit',
318
+ status: totalFailed > 0 ? 'fail' : 'pass',
301
319
  summary: totalFailed > 0 ? `${totalFailed} failed, ${passed} passed` : `${passed} passed`,
302
320
  failures,
303
321
  logPath: ctx.logPath,
@@ -1,6 +1,6 @@
1
- import path from "node:path";
2
- import type { ParserModule, ParsedFailure } from "../types";
3
- import { safeReadFile } from "./utils";
1
+ import path from 'node:path';
2
+ import type { ParserModule, ParsedFailure } from '../types';
3
+ import { safeReadFile } from './utils';
4
4
 
5
5
  interface MarkdownlintItem {
6
6
  fileName: string;
@@ -11,14 +11,14 @@ interface MarkdownlintItem {
11
11
  }
12
12
 
13
13
  const parser: ParserModule = {
14
- id: "markdownlint-json",
14
+ id: 'markdownlint-json',
15
15
  async parse(ctx) {
16
16
  const stdout = safeReadFile(ctx.stdoutPath).trim();
17
17
  if (!stdout) {
18
18
  return {
19
- tool: "markdownlint",
20
- status: "pass",
21
- summary: "no lint errors",
19
+ tool: 'markdownlint',
20
+ status: 'pass',
21
+ summary: 'no lint errors',
22
22
  failures: [],
23
23
  logPath: ctx.logPath,
24
24
  };
@@ -29,18 +29,18 @@ const parser: ParserModule = {
29
29
  items = JSON.parse(stdout);
30
30
  } catch {
31
31
  return {
32
- tool: "markdownlint",
33
- status: "error",
34
- summary: "failed to parse markdownlint JSON output",
32
+ tool: 'markdownlint',
33
+ status: 'error',
34
+ summary: 'failed to parse markdownlint JSON output',
35
35
  logPath: ctx.logPath,
36
36
  };
37
37
  }
38
38
 
39
39
  if (!Array.isArray(items) || items.length === 0) {
40
40
  return {
41
- tool: "markdownlint",
42
- status: "pass",
43
- summary: "no lint errors",
41
+ tool: 'markdownlint',
42
+ status: 'pass',
43
+ summary: 'no lint errors',
44
44
  failures: [],
45
45
  logPath: ctx.logPath,
46
46
  };
@@ -50,7 +50,9 @@ const parser: ParserModule = {
50
50
  const relPath = path.relative(ctx.cwd, item.fileName);
51
51
  // Use the short MD code (first rule name, e.g. "MD041")
52
52
  const rule = item.ruleNames[0];
53
- const message = item.errorDetail ? `${item.ruleDescription}: ${item.errorDetail}` : item.ruleDescription;
53
+ const message = item.errorDetail
54
+ ? `${item.ruleDescription}: ${item.errorDetail}`
55
+ : item.ruleDescription;
54
56
  return {
55
57
  id: `${relPath}:${item.lineNumber}:${rule}`,
56
58
  file: relPath,
@@ -61,9 +63,9 @@ const parser: ParserModule = {
61
63
  });
62
64
 
63
65
  return {
64
- tool: "markdownlint",
65
- status: "fail",
66
- summary: `${failures.length} lint error${failures.length !== 1 ? "s" : ""}`,
66
+ tool: 'markdownlint',
67
+ status: 'fail',
68
+ summary: `${failures.length} lint error${failures.length !== 1 ? 's' : ''}`,
67
69
  failures,
68
70
  logPath: ctx.logPath,
69
71
  };