@robhowley/pi-structured-return 1.9.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 +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 +27 -43
  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
  // Rust 1.73+: thread 'name' (optional-id) panicked at file:line:col:
6
6
  // message on following line(s)
@@ -17,20 +17,21 @@ const TEST_RESULT_RE = /^test result: \w+\. (\d+) passed; (\d+) failed/;
17
17
  const BLOCK_HEADER_RE = /^---- (.+) stdout ----$/;
18
18
 
19
19
  const parser: ParserModule = {
20
- id: "cargo-test",
20
+ id: 'cargo-test',
21
21
  async parse(ctx) {
22
22
  // Use combined log — test binary output goes to stdout, cargo progress to stderr;
23
23
  // reading both ensures we catch everything regardless of buffering order.
24
24
  const log = safeReadFile(ctx.logPath);
25
- const lines = log.split("\n").map((l) => l.trim());
25
+ const lines = log.split('\n').map((l) => l.trim());
26
26
 
27
27
  // If compilation failed there will be no "test result:" line
28
28
  const hasTestResult = lines.some((l) => TEST_RESULT_RE.test(l));
29
29
  if (!hasTestResult) {
30
30
  return {
31
- tool: "cargo",
32
- status: "error",
33
- summary: "compilation failed — run `cargo build --message-format=json` for structured errors",
31
+ tool: 'cargo',
32
+ status: 'error',
33
+ summary:
34
+ 'compilation failed — run `cargo build --message-format=json` for structured errors',
34
35
  failures: [],
35
36
  logPath: ctx.logPath,
36
37
  };
@@ -62,12 +63,12 @@ const parser: ParserModule = {
62
63
  if (current) blocks.push(current);
63
64
 
64
65
  const failures: ParsedFailure[] = blocks.map(({ name, lines: blockLines }) =>
65
- parseFailureBlock(name, blockLines, ctx.cwd)
66
+ parseFailureBlock(name, blockLines, ctx.cwd),
66
67
  );
67
68
 
68
69
  return {
69
- tool: "cargo",
70
- status: failed > 0 ? "fail" : "pass",
70
+ tool: 'cargo',
71
+ status: failed > 0 ? 'fail' : 'pass',
71
72
  summary: failed > 0 ? `${failed} failed, ${passed} passed` : `${passed} passed`,
72
73
  failures,
73
74
  logPath: ctx.logPath,
@@ -91,7 +92,7 @@ function parseFailureBlock(testName: string, lines: string[], cwd: string): Pars
91
92
  const msgLines: string[] = [];
92
93
  for (let j = i + 1; j < lines.length; j++) {
93
94
  const next = lines[j];
94
- if (next === "" || next.startsWith("note:") || next.startsWith("error:")) break;
95
+ if (next === '' || next.startsWith('note:') || next.startsWith('error:')) break;
95
96
  msgLines.push(next);
96
97
  }
97
98
  message = formatMessage(msgLines);
@@ -101,17 +102,17 @@ function parseFailureBlock(testName: string, lines: string[], cwd: string): Pars
101
102
 
102
103
  // Fall back to pre-1.73 format; join block so dotall regex handles multi-line messages
103
104
  if (!file) {
104
- const blockText = lines.join("\n");
105
+ const blockText = lines.join('\n');
105
106
  const oldMatch = PANIC_OLD.exec(blockText);
106
107
  if (oldMatch) {
107
108
  // Collapse internal newlines in message to a single space
108
- message = oldMatch[1].replace(/\s+/g, " ").trim();
109
+ message = oldMatch[1].replace(/\s+/g, ' ').trim();
109
110
  file = path.relative(cwd, path.resolve(cwd, oldMatch[2]));
110
111
  lineNum = Number(oldMatch[3]);
111
112
  }
112
113
  }
113
114
 
114
- const id = [file, lineNum, testName].filter(Boolean).join(":");
115
+ const id = [file, lineNum, testName].filter(Boolean).join(':');
115
116
  return {
116
117
  id: id || testName,
117
118
  file,
@@ -122,14 +123,14 @@ function parseFailureBlock(testName: string, lines: string[], cwd: string): Pars
122
123
 
123
124
  /** Compact assertion left/right onto one line; otherwise join with "; " */
124
125
  function formatMessage(msgLines: string[]): string {
125
- if (msgLines.length === 0) return "";
126
+ if (msgLines.length === 0) return '';
126
127
  const main = msgLines[0];
127
- const leftLine = msgLines.find((l) => l.trimStart().startsWith("left:"));
128
- const rightLine = msgLines.find((l) => l.trimStart().startsWith("right:"));
128
+ const leftLine = msgLines.find((l) => l.trimStart().startsWith('left:'));
129
+ const rightLine = msgLines.find((l) => l.trimStart().startsWith('right:'));
129
130
  if (leftLine && rightLine) {
130
131
  return `${main}\n${leftLine.trim()}, ${rightLine.trim()}`;
131
132
  }
132
- return msgLines.filter(Boolean).join("; ");
133
+ return msgLines.filter(Boolean).join('; ');
133
134
  }
134
135
 
135
136
  export default parser;
@@ -0,0 +1,183 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { XMLParser } from 'fast-xml-parser';
4
+ import type { ParserModule, ParsedFailure } from '../types';
5
+
6
+ interface CheckstyleError {
7
+ line?: string | number;
8
+ column?: string | number;
9
+ message?: string;
10
+ source?: string;
11
+ severity?: string;
12
+ }
13
+
14
+ interface CheckstyleFile {
15
+ name: string;
16
+ error?: CheckstyleError | CheckstyleError[];
17
+ }
18
+
19
+ interface CheckstyleDocument {
20
+ '?xml'?: { version: string; encoding: string };
21
+ checkstyle?: {
22
+ version?: string;
23
+ file?: CheckstyleFile | CheckstyleFile[];
24
+ };
25
+ }
26
+
27
+ const xmlParser = new XMLParser({
28
+ ignoreAttributes: false,
29
+ attributeNamePrefix: '',
30
+ isArray: (name) => name === 'error',
31
+ });
32
+
33
+ /** Normalize a file path: relativize absolute paths, passthrough relative. */
34
+ function normalizePath(filePath: string, cwd: string): string {
35
+ if (path.isAbsolute(filePath)) {
36
+ return path.relative(cwd, path.resolve(filePath));
37
+ }
38
+ return filePath;
39
+ }
40
+
41
+ /** Shorten Java FQCN source names, preserve category:id format. */
42
+ function normalizeRule(source?: string): string | undefined {
43
+ if (!source) return undefined;
44
+
45
+ // category:id format (e.g., "standard:semicolon") — keep unchanged
46
+ if (source.includes(':')) return source;
47
+
48
+ // Java FQCN format (e.g., "com.foo.BarCheck") — extract short name
49
+ const fqcnMatch = source.match(/\.([A-Z][a-zA-Z0-9]*Check)$/);
50
+ if (fqcnMatch) return fqcnMatch[1];
51
+
52
+ // Keep other sources as-is
53
+ return source;
54
+ }
55
+
56
+ /** Generate a unique finding ID. */
57
+ function generateId(file: string, line?: number, rule?: string): string {
58
+ return `${file}:${line ?? 0}:${rule ?? 'unknown'}`;
59
+ }
60
+
61
+ /** Check if severity should be filtered (ignored). */
62
+ function isIgnoredSeverity(severity?: string): boolean {
63
+ return severity === 'ignore';
64
+ }
65
+
66
+ /** Extract severity category from the severity string. */
67
+ function getSeverityCategory(severity?: string): 'error' | 'warning' | 'info' | 'unknown' {
68
+ if (!severity) return 'error'; // Default to error if missing
69
+ const sev = severity.toLowerCase();
70
+ if (sev === 'error' || sev === 'critical' || sev === 'fatal') return 'error';
71
+ if (sev === 'warning' || sev === 'warn') return 'warning';
72
+ if (sev === 'info' || sev === 'information') return 'info';
73
+ return 'unknown';
74
+ }
75
+
76
+ const parser: ParserModule = {
77
+ id: 'checkstyle-xml',
78
+ async parse(ctx) {
79
+ const artifactSources = ctx.artifactPaths.length > 0 ? ctx.artifactPaths : [ctx.stdoutPath];
80
+
81
+ const allErrors: ParsedFailure[] = [];
82
+ let errorCount = 0;
83
+ let warningCount = 0;
84
+ let infoCount = 0;
85
+
86
+ for (const artifactPath of artifactSources) {
87
+ let xml: string;
88
+ try {
89
+ xml = fs.readFileSync(artifactPath, 'utf8');
90
+ } catch (err: unknown) {
91
+ if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
92
+ // File not found - skip it
93
+ continue;
94
+ }
95
+ throw err;
96
+ }
97
+
98
+ if (!xml.trim()) continue;
99
+
100
+ let doc: CheckstyleDocument;
101
+ try {
102
+ doc = xmlParser.parse(xml) as CheckstyleDocument;
103
+ } catch {
104
+ return {
105
+ tool: 'checkstyle',
106
+ status: 'error',
107
+ summary: 'failed to parse checkstyle XML output',
108
+ failures: [],
109
+ logPath: ctx.logPath,
110
+ };
111
+ }
112
+
113
+ const files = Array.isArray(doc.checkstyle?.file)
114
+ ? doc.checkstyle.file
115
+ : doc.checkstyle?.file
116
+ ? [doc.checkstyle.file]
117
+ : [];
118
+
119
+ for (const file of files) {
120
+ if (!file.name) continue;
121
+
122
+ const normalizedFile = normalizePath(file.name, ctx.cwd);
123
+ const errors = Array.isArray(file.error) ? file.error : file.error ? [file.error] : [];
124
+
125
+ for (const err of errors) {
126
+ // Skip ignored severity
127
+ if (isIgnoredSeverity(err.severity)) continue;
128
+
129
+ const line = err.line !== undefined ? Number(err.line) : undefined;
130
+ const column = err.column !== undefined ? Number(err.column) : undefined;
131
+ const rule = normalizeRule(err.source);
132
+ const severity = err.severity ? getSeverityCategory(err.severity) : undefined;
133
+
134
+ const failure: ParsedFailure = {
135
+ id: generateId(normalizedFile, line, rule),
136
+ file: normalizedFile,
137
+ line: line,
138
+ column: column,
139
+ message: err.message?.trim() || undefined,
140
+ rule: rule,
141
+ severity: severity === 'unknown' ? undefined : severity,
142
+ };
143
+
144
+ // Track severity for summary - count per category
145
+ const sevCategory = getSeverityCategory(err.severity);
146
+ if (sevCategory === 'error') errorCount++;
147
+ else if (sevCategory === 'warning') warningCount++;
148
+ else if (sevCategory === 'info') infoCount++;
149
+
150
+ allErrors.push(failure);
151
+ }
152
+ }
153
+ }
154
+
155
+ // Determine status and build summary
156
+ let status: 'pass' | 'fail' | 'error';
157
+ let summary: string;
158
+
159
+ if (allErrors.length === 0) {
160
+ status = 'pass';
161
+ summary = 'no lint errors';
162
+ } else {
163
+ // Default to fail on any finding (error or warning), pass only on info
164
+ status = errorCount > 0 || warningCount > 0 ? 'fail' : 'pass';
165
+
166
+ const parts = [];
167
+ if (errorCount > 0) parts.push(`${errorCount} errors`);
168
+ if (warningCount > 0) parts.push(`${warningCount} warnings`);
169
+ if (infoCount > 0) parts.push(`${infoCount} info`);
170
+ summary = `${allErrors.length} findings (${parts.join(', ')})`;
171
+ }
172
+
173
+ return {
174
+ tool: 'checkstyle',
175
+ status,
176
+ summary,
177
+ failures: allErrors,
178
+ logPath: ctx.logPath,
179
+ };
180
+ },
181
+ };
182
+
183
+ export default parser;
@@ -1,28 +1,28 @@
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
  // Clang/GCC error format: file:line:col: error: message [-Wflag]
6
6
  const ERROR_LINE = /^(.+?):(\d+):\d+: (error|fatal error): (.+?)(\s+\[-.+\])?$/;
7
7
  const SUMMARY_LINE = /^(\d+) errors? generated/;
8
8
 
9
9
  const parser: ParserModule = {
10
- id: "clang-text",
10
+ id: 'clang-text',
11
11
  async parse(ctx) {
12
12
  const stderr = safeReadFile(ctx.stderrPath).trim();
13
13
  if (!stderr) {
14
14
  return {
15
- tool: "clang",
16
- status: "pass",
17
- summary: "compilation successful",
15
+ tool: 'clang',
16
+ status: 'pass',
17
+ summary: 'compilation successful',
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
- let summaryLine = "";
25
+ let summaryLine = '';
26
26
 
27
27
  for (const line of lines) {
28
28
  const errorMatch = line.match(ERROR_LINE);
@@ -34,7 +34,7 @@ const parser: ParserModule = {
34
34
  file: relPath,
35
35
  line: parseInt(lineNum, 10),
36
36
  message,
37
- rule: flag?.trim().replace(/^\[/, "").replace(/\]$/, ""),
37
+ rule: flag?.trim().replace(/^\[/, '').replace(/\]$/, ''),
38
38
  });
39
39
  continue;
40
40
  }
@@ -44,11 +44,13 @@ const parser: ParserModule = {
44
44
 
45
45
  const summary =
46
46
  summaryLine ||
47
- (failures.length > 0 ? `${failures.length} error${failures.length !== 1 ? "s" : ""}` : "compilation successful");
47
+ (failures.length > 0
48
+ ? `${failures.length} error${failures.length !== 1 ? 's' : ''}`
49
+ : 'compilation successful');
48
50
 
49
51
  return {
50
- tool: "clang",
51
- status: failures.length > 0 ? "fail" : "pass",
52
+ tool: 'clang',
53
+ status: failures.length > 0 ? 'fail' : 'pass',
52
54
  summary,
53
55
  failures,
54
56
  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
  interface DbtEvent {
5
5
  data: Record<string, unknown>;
@@ -26,13 +26,13 @@ function parseSummaryCounts(msg: string): Record<string, number> {
26
26
  }
27
27
 
28
28
  const parser: ParserModule = {
29
- id: "dbt-json",
29
+ id: 'dbt-json',
30
30
  async parse(ctx) {
31
31
  // dbt --log-format json writes JSONL to stdout
32
32
  const raw = safeReadFile(ctx.stdoutPath);
33
33
  const events: DbtEvent[] = [];
34
- for (const line of raw.split("\n")) {
35
- if (!line.trim().startsWith("{")) continue;
34
+ for (const line of raw.split('\n')) {
35
+ if (!line.trim().startsWith('{')) continue;
36
36
  try {
37
37
  events.push(JSON.parse(line) as DbtEvent);
38
38
  } catch {
@@ -40,27 +40,29 @@ const parser: ParserModule = {
40
40
  }
41
41
  }
42
42
 
43
- const summary = events.find((e) => e.info.name === "EndOfRunSummary");
44
- const errors = events.filter((e) => e.info.name === "RunResultError");
45
- const warnings = events.filter((e) => e.info.name === "RunResultWarning");
46
- const compiled = events.filter((e) => e.info.name === "CompiledNode");
43
+ const summary = events.find((e) => e.info.name === 'EndOfRunSummary');
44
+ const errors = events.filter((e) => e.info.name === 'RunResultError');
45
+ const warnings = events.filter((e) => e.info.name === 'RunResultWarning');
46
+ const compiled = events.filter((e) => e.info.name === 'CompiledNode');
47
47
 
48
48
  // ---------- compile mode (no EndOfRunSummary, has CompiledNode) ----------
49
49
  if (compiled.length > 0 && !summary) {
50
- const names = compiled.map((n) => ((n.data.node_info ?? {}) as NodeInfo).node_name).filter(Boolean);
50
+ const names = compiled
51
+ .map((n) => ((n.data.node_info ?? {}) as NodeInfo).node_name)
52
+ .filter(Boolean);
51
53
  const sqlParts = compiled
52
54
  .map((n) => {
53
55
  const info = (n.data.node_info ?? {}) as NodeInfo;
54
56
  const sql = n.data.compiled as string | undefined;
55
- return sql ? `-- ${info.node_name ?? "model"}\n${sql}` : undefined;
57
+ return sql ? `-- ${info.node_name ?? 'model'}\n${sql}` : undefined;
56
58
  })
57
59
  .filter(Boolean);
58
60
  return {
59
- tool: "dbt",
60
- status: "pass",
61
- summary: `compiled ${compiled.length} model${compiled.length === 1 ? "" : "s"}: ${names.join(", ")}`,
61
+ tool: 'dbt',
62
+ status: 'pass',
63
+ summary: `compiled ${compiled.length} model${compiled.length === 1 ? '' : 's'}: ${names.join(', ')}`,
62
64
  failures: [],
63
- rawTail: sqlParts.join("\n\n"),
65
+ rawTail: sqlParts.join('\n\n'),
64
66
  logPath: ctx.logPath,
65
67
  };
66
68
  }
@@ -68,15 +70,18 @@ const parser: ParserModule = {
68
70
  // ---------- compile failure (no summary, no compiled nodes) ----------
69
71
  if (!summary && compiled.length === 0) {
70
72
  // Look for any error-level messages for context
71
- const errorMsgs = events.filter((e) => e.info.level === "error");
73
+ const errorMsgs = events.filter((e) => e.info.level === 'error');
72
74
  const failures: ParsedFailure[] = errorMsgs.map((e, i) => ({
73
75
  id: String(i),
74
76
  message: e.info.msg,
75
77
  }));
76
78
  return {
77
- tool: "dbt",
78
- status: "error",
79
- summary: failures.length > 0 ? `${failures.length} error${failures.length === 1 ? "" : "s"}` : "failed",
79
+ tool: 'dbt',
80
+ status: 'error',
81
+ summary:
82
+ failures.length > 0
83
+ ? `${failures.length} error${failures.length === 1 ? '' : 's'}`
84
+ : 'failed',
80
85
  failures,
81
86
  logPath: ctx.logPath,
82
87
  };
@@ -114,13 +119,13 @@ const parser: ParserModule = {
114
119
  const parts: string[] = [];
115
120
  if (numErrors > 0) parts.push(`${numErrors} failed`);
116
121
  if (numPassed > 0) parts.push(`${numPassed} passed`);
117
- if (numWarnings > 0) parts.push(`${numWarnings} warning${numWarnings === 1 ? "" : "s"}`);
122
+ if (numWarnings > 0) parts.push(`${numWarnings} warning${numWarnings === 1 ? '' : 's'}`);
118
123
  if (numSkipped > 0) parts.push(`${numSkipped} skipped`);
119
- const summaryStr = `${parts.join(", ")} in ${elapsed.toFixed(2)}s`;
124
+ const summaryStr = `${parts.join(', ')} in ${elapsed.toFixed(2)}s`;
120
125
 
121
126
  return {
122
- tool: "dbt",
123
- status: numErrors > 0 ? "fail" : "pass",
127
+ tool: 'dbt',
128
+ status: numErrors > 0 ? 'fail' : 'pass',
124
129
  summary: summaryStr,
125
130
  failures,
126
131
  logPath: ctx.logPath,
@@ -1,15 +1,15 @@
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
  // MSBuild error format: file(line,col): error CODE: message [project]
6
6
  const ERROR_LINE = /^(.+?)\((\d+),\d+\): error (\w+): (.+?)(?:\s+\[.+\])?$/;
7
7
 
8
8
  const parser: ParserModule = {
9
- id: "dotnet-build-text",
9
+ id: 'dotnet-build-text',
10
10
  async parse(ctx) {
11
11
  const combined = safeReadFile(ctx.stdoutPath) + safeReadFile(ctx.stderrPath);
12
- const lines = combined.split("\n");
12
+ const lines = combined.split('\n');
13
13
 
14
14
  // Deduplicate — MSBuild prints errors twice (inline + summary)
15
15
  const seen = new Set<string>();
@@ -33,11 +33,13 @@ const parser: ParserModule = {
33
33
  }
34
34
 
35
35
  const summary =
36
- failures.length > 0 ? `${failures.length} error${failures.length !== 1 ? "s" : ""}` : "build succeeded";
36
+ failures.length > 0
37
+ ? `${failures.length} error${failures.length !== 1 ? 's' : ''}`
38
+ : 'build succeeded';
37
39
 
38
40
  return {
39
- tool: "dotnet build",
40
- status: failures.length > 0 ? "fail" : "pass",
41
+ tool: 'dotnet build',
42
+ status: failures.length > 0 ? 'fail' : 'pass',
41
43
  summary,
42
44
  failures,
43
45
  logPath: ctx.logPath,
@@ -1,18 +1,24 @@
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
  const parser: ParserModule = {
6
- id: "eslint-json",
6
+ id: 'eslint-json',
7
7
  async parse(ctx) {
8
8
  const stdout = safeReadFile(ctx.stdoutPath).trim();
9
9
  const files = stdout ? JSON.parse(stdout) : [];
10
- const failures = [] as Array<{ id: string; file?: string; line?: number; message?: string; rule?: string }>;
10
+ const failures = [] as Array<{
11
+ id: string;
12
+ file?: string;
13
+ line?: number;
14
+ message?: string;
15
+ rule?: string;
16
+ }>;
11
17
  for (const file of Array.isArray(files) ? files : []) {
12
18
  const relPath = path.relative(ctx.cwd, file.filePath);
13
19
  for (const msg of file.messages ?? []) {
14
20
  failures.push({
15
- id: `${relPath}:${msg.line}:${msg.ruleId ?? "unknown"}`,
21
+ id: `${relPath}:${msg.line}:${msg.ruleId ?? 'unknown'}`,
16
22
  file: relPath,
17
23
  line: msg.line,
18
24
  message: msg.message,
@@ -21,9 +27,9 @@ const parser: ParserModule = {
21
27
  }
22
28
  }
23
29
  return {
24
- tool: "eslint",
25
- status: failures.length > 0 ? "fail" : "pass",
26
- summary: failures.length > 0 ? `${failures.length} lint errors` : "no lint errors",
30
+ tool: 'eslint',
31
+ status: failures.length > 0 ? 'fail' : 'pass',
32
+ summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
27
33
  failures,
28
34
  logPath: ctx.logPath,
29
35
  };
@@ -1,6 +1,6 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import type { ParserModule, ParsedFailure } from "../types";
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import type { ParserModule, ParsedFailure } from '../types';
4
4
 
5
5
  interface GoTestEvent {
6
6
  Action: string;
@@ -11,7 +11,9 @@ interface GoTestEvent {
11
11
  }
12
12
 
13
13
  /** Extract file:line and message from a Go t.Error/t.Errorf output line. */
14
- function parseTestOutput(output: string): { file?: string; line?: number; message?: string } | undefined {
14
+ function parseTestOutput(
15
+ output: string,
16
+ ): { file?: string; line?: number; message?: string } | undefined {
15
17
  // Format: " file.go:line: message"
16
18
  const m = output.match(/^\s+(\S+\.go):(\d+):\s+(.+)/);
17
19
  if (m) return { file: m[1], line: Number(m[2]), message: m[3].trim() };
@@ -21,14 +23,14 @@ function parseTestOutput(output: string): { file?: string; line?: number; messag
21
23
  /** Extract panic message and user-code file:line from a stack trace. */
22
24
  function parsePanic(
23
25
  outputs: string[],
24
- testName: string
26
+ testName: string,
25
27
  ): { message?: string; file?: string; line?: number } | undefined {
26
- const panicLine = outputs.find((o) => o.trim().startsWith("panic:"));
28
+ const panicLine = outputs.find((o) => o.trim().startsWith('panic:'));
27
29
  if (!panicLine) return undefined;
28
30
  const message = panicLine
29
31
  .trim()
30
- .replace(/^panic:\s*/, "")
31
- .replace(/\s*\[.*\]$/, "")
32
+ .replace(/^panic:\s*/, '')
33
+ .replace(/\s*\[.*\]$/, '')
32
34
  .trim();
33
35
 
34
36
  // Find the user code frame: "module.TestName(..." followed by "\tfile.go:line"
@@ -42,15 +44,15 @@ function parsePanic(
42
44
  }
43
45
 
44
46
  const parser: ParserModule = {
45
- id: "go-test-json",
47
+ id: 'go-test-json',
46
48
  async parse(ctx) {
47
- const stdout = fs.readFileSync(ctx.stdoutPath, "utf8").trim();
49
+ const stdout = fs.readFileSync(ctx.stdoutPath, 'utf8').trim();
48
50
  if (!stdout) {
49
- return { tool: "go test", status: "error", summary: "no output", logPath: ctx.logPath };
51
+ return { tool: 'go test', status: 'error', summary: 'no output', logPath: ctx.logPath };
50
52
  }
51
53
 
52
54
  const events: GoTestEvent[] = [];
53
- for (const line of stdout.split("\n")) {
55
+ for (const line of stdout.split('\n')) {
54
56
  if (!line.trim()) continue;
55
57
  try {
56
58
  events.push(JSON.parse(line) as GoTestEvent);
@@ -66,20 +68,20 @@ const parser: ParserModule = {
66
68
 
67
69
  for (const e of events) {
68
70
  if (!e.Test) continue;
69
- if (e.Action === "output") {
71
+ if (e.Action === 'output') {
70
72
  const outputs = testOutputs.get(e.Test) ?? [];
71
- outputs.push(e.Output ?? "");
73
+ outputs.push(e.Output ?? '');
72
74
  testOutputs.set(e.Test, outputs);
73
- } else if (e.Action === "pass") {
75
+ } else if (e.Action === 'pass') {
74
76
  passed++;
75
- } else if (e.Action === "fail") {
77
+ } else if (e.Action === 'fail') {
76
78
  failed++;
77
79
  }
78
80
  }
79
81
 
80
82
  const failures: ParsedFailure[] = [];
81
83
  for (const e of events) {
82
- if (e.Action !== "fail" || !e.Test) continue;
84
+ if (e.Action !== 'fail' || !e.Test) continue;
83
85
  const outputs = testOutputs.get(e.Test) ?? [];
84
86
 
85
87
  // Try parsing as a t.Error/t.Errorf output first
@@ -116,17 +118,17 @@ const parser: ParserModule = {
116
118
  id: e.Test,
117
119
  file: relFile,
118
120
  line: panic.line,
119
- message: panic.message ?? "panic",
121
+ message: panic.message ?? 'panic',
120
122
  });
121
123
  } else {
122
- failures.push({ id: e.Test, message: "test failed" });
124
+ failures.push({ id: e.Test, message: 'test failed' });
123
125
  }
124
126
  }
125
127
  }
126
128
 
127
129
  return {
128
- tool: "go test",
129
- status: failed > 0 ? "fail" : "pass",
130
+ tool: 'go test',
131
+ status: failed > 0 ? 'fail' : 'pass',
130
132
  summary: failed > 0 ? `${failed} failed, ${passed} passed` : `${passed} passed`,
131
133
  failures,
132
134
  logPath: ctx.logPath,