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