@robhowley/pi-structured-return 1.10.0 → 2.0.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 (110) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +33 -83
  3. package/extensions/structured-return/config/registry.ts +4 -30
  4. package/extensions/structured-return/index.ts +105 -76
  5. package/extensions/structured-return/native.ts +223 -0
  6. package/extensions/structured-return/parsers/ava-text.ts +2 -168
  7. package/extensions/structured-return/parsers/bandit-json.ts +2 -79
  8. package/extensions/structured-return/parsers/black-text.ts +2 -73
  9. package/extensions/structured-return/parsers/cargo-build.ts +2 -78
  10. package/extensions/structured-return/parsers/cargo-test.ts +2 -135
  11. package/extensions/structured-return/parsers/checkstyle-xml.ts +2 -182
  12. package/extensions/structured-return/parsers/clang-text.ts +2 -60
  13. package/extensions/structured-return/parsers/dbt-json.ts +2 -135
  14. package/extensions/structured-return/parsers/dotnet-build-text.ts +2 -49
  15. package/extensions/structured-return/parsers/eslint-json.ts +2 -38
  16. package/extensions/structured-return/parsers/go-test-json.ts +2 -138
  17. package/extensions/structured-return/parsers/hadolint-json.ts +2 -60
  18. package/extensions/structured-return/parsers/htmlhint-json.ts +2 -73
  19. package/extensions/structured-return/parsers/isort-text.ts +2 -63
  20. package/extensions/structured-return/parsers/javac-text.ts +2 -82
  21. package/extensions/structured-return/parsers/jsonlint-text.ts +2 -65
  22. package/extensions/structured-return/parsers/junit-xml.ts +2 -325
  23. package/extensions/structured-return/parsers/markdownlint-json.ts +2 -74
  24. package/extensions/structured-return/parsers/minitest-text.ts +2 -107
  25. package/extensions/structured-return/parsers/mocha-json.ts +2 -83
  26. package/extensions/structured-return/parsers/mypy-json.ts +2 -79
  27. package/extensions/structured-return/parsers/node-test-text.ts +2 -92
  28. package/extensions/structured-return/parsers/npm-audit-json.ts +2 -90
  29. package/extensions/structured-return/parsers/prettier-text.ts +2 -66
  30. package/extensions/structured-return/parsers/pylint-json.ts +2 -63
  31. package/extensions/structured-return/parsers/pyright-json.ts +2 -82
  32. package/extensions/structured-return/parsers/rspec-json.ts +2 -75
  33. package/extensions/structured-return/parsers/rubocop-json.ts +2 -75
  34. package/extensions/structured-return/parsers/ruff-json.ts +2 -36
  35. package/extensions/structured-return/parsers/shellcheck-json.ts +2 -60
  36. package/extensions/structured-return/parsers/stylelint-json.ts +2 -75
  37. package/extensions/structured-return/parsers/swiftc-text.ts +2 -52
  38. package/extensions/structured-return/parsers/tail-fallback.ts +2 -19
  39. package/extensions/structured-return/parsers/tidy-text.ts +2 -66
  40. package/extensions/structured-return/parsers/tsc-text.ts +2 -46
  41. package/extensions/structured-return/parsers/unittest-text.ts +2 -125
  42. package/extensions/structured-return/parsers/utils.ts +28 -0
  43. package/extensions/structured-return/parsers/vale-json.ts +2 -79
  44. package/extensions/structured-return/parsers/vitest-json.ts +2 -59
  45. package/extensions/structured-return/storage/log-store.ts +0 -15
  46. package/extensions/structured-return/types.ts +1 -14
  47. package/native/Cargo.lock +193 -0
  48. package/native/Cargo.toml +21 -0
  49. package/native/THIRD-PARTY-LICENSES.txt +3660 -0
  50. package/native/bin/darwin-arm64/build.json +7 -0
  51. package/native/bin/darwin-arm64/structured-return-native +0 -0
  52. package/native/bin/darwin-x64/build.json +7 -0
  53. package/native/bin/darwin-x64/structured-return-native +0 -0
  54. package/native/bin/linux-arm64-musl/build.json +7 -0
  55. package/native/bin/linux-arm64-musl/structured-return-native +0 -0
  56. package/native/bin/linux-x64-musl/build.json +7 -0
  57. package/native/bin/linux-x64-musl/structured-return-native +0 -0
  58. package/native/src/common.rs +118 -0
  59. package/native/src/main.rs +55 -0
  60. package/native/src/parsers/ava_text.rs +125 -0
  61. package/native/src/parsers/bandit_json.rs +120 -0
  62. package/native/src/parsers/black_text.rs +45 -0
  63. package/native/src/parsers/cargo_build.rs +96 -0
  64. package/native/src/parsers/cargo_test.rs +140 -0
  65. package/native/src/parsers/checkstyle_xml.rs +137 -0
  66. package/native/src/parsers/clang_text.rs +39 -0
  67. package/native/src/parsers/compiler_helpers.rs +74 -0
  68. package/native/src/parsers/dbt_json.rs +243 -0
  69. package/native/src/parsers/dotnet_build_text.rs +50 -0
  70. package/native/src/parsers/eslint_json.rs +58 -0
  71. package/native/src/parsers/go_test_json.rs +346 -0
  72. package/native/src/parsers/hadolint_json.rs +37 -0
  73. package/native/src/parsers/htmlhint_json.rs +71 -0
  74. package/native/src/parsers/isort_text.rs +22 -0
  75. package/native/src/parsers/javac_text.rs +49 -0
  76. package/native/src/parsers/json_support.rs +287 -0
  77. package/native/src/parsers/jsonlint_text.rs +50 -0
  78. package/native/src/parsers/junit_xml.rs +430 -0
  79. package/native/src/parsers/markdownlint_json.rs +68 -0
  80. package/native/src/parsers/minitest_text.rs +91 -0
  81. package/native/src/parsers/mocha_json.rs +75 -0
  82. package/native/src/parsers/mod.rs +119 -0
  83. package/native/src/parsers/mypy_json.rs +93 -0
  84. package/native/src/parsers/node_test_text.rs +106 -0
  85. package/native/src/parsers/npm_audit_json.rs +119 -0
  86. package/native/src/parsers/prettier_text.rs +34 -0
  87. package/native/src/parsers/pylint_json.rs +44 -0
  88. package/native/src/parsers/pyright_json.rs +88 -0
  89. package/native/src/parsers/rspec_json.rs +84 -0
  90. package/native/src/parsers/rubocop_json.rs +46 -0
  91. package/native/src/parsers/ruff_json.rs +30 -0
  92. package/native/src/parsers/shellcheck_json.rs +40 -0
  93. package/native/src/parsers/stylelint_json.rs +46 -0
  94. package/native/src/parsers/swiftc_text.rs +38 -0
  95. package/native/src/parsers/tail_fallback.rs +51 -0
  96. package/native/src/parsers/test_helpers.rs +172 -0
  97. package/native/src/parsers/tidy_text.rs +77 -0
  98. package/native/src/parsers/tsc_text.rs +28 -0
  99. package/native/src/parsers/unittest_text.rs +125 -0
  100. package/native/src/parsers/vale_json.rs +66 -0
  101. package/native/src/parsers/vitest_json.rs +71 -0
  102. package/native/src/parsers/xml_support.rs +241 -0
  103. package/native/src/runner.rs +252 -0
  104. package/package.json +22 -7
  105. package/scripts/build-native.mjs +73 -0
  106. package/scripts/native-artifacts.mjs +69 -0
  107. package/skills/structured-return/SKILL.md +103 -249
  108. package/extensions/structured-return/config/project-config.ts +0 -10
  109. package/extensions/structured-return/examples/.pi/machine-readable.json +0 -18
  110. package/extensions/structured-return/examples/.pi/parsers/foo-cli.ts +0 -25
@@ -1,136 +1,3 @@
1
- import path from 'node:path';
2
- import type { ParserModule, ParsedFailure } from '../types';
3
- import { safeReadFile } from './utils';
1
+ import { nativeParser } from '../native';
4
2
 
5
- // Rust 1.73+: thread 'name' (optional-id) panicked at file:line:col:
6
- // message on following line(s)
7
- const PANIC_NEW = /^thread '.+?' (?:\(\d+\) )?panicked at (.+?):(\d+):\d+:?$/;
8
-
9
- // Pre-1.73: thread 'name' panicked at 'message', file:line:col
10
- // Message may span multiple lines — use dotall flag
11
- const PANIC_OLD = /thread '.+?' panicked at '(.*)', (.+?):(\d+):\d+/s;
12
-
13
- // test result: FAILED. 1 passed; 2 failed; ...
14
- const TEST_RESULT_RE = /^test result: \w+\. (\d+) passed; (\d+) failed/;
15
-
16
- // ---- test::name stdout ----
17
- const BLOCK_HEADER_RE = /^---- (.+) stdout ----$/;
18
-
19
- const parser: ParserModule = {
20
- id: 'cargo-test',
21
- async parse(ctx) {
22
- // Use combined log — test binary output goes to stdout, cargo progress to stderr;
23
- // reading both ensures we catch everything regardless of buffering order.
24
- const log = safeReadFile(ctx.logPath);
25
- const lines = log.split('\n').map((l) => l.trim());
26
-
27
- // If compilation failed there will be no "test result:" line
28
- const hasTestResult = lines.some((l) => TEST_RESULT_RE.test(l));
29
- if (!hasTestResult) {
30
- return {
31
- tool: 'cargo',
32
- status: 'error',
33
- summary:
34
- 'compilation failed — run `cargo build --message-format=json` for structured errors',
35
- failures: [],
36
- logPath: ctx.logPath,
37
- };
38
- }
39
-
40
- let passed = 0;
41
- let failed = 0;
42
- for (const line of lines) {
43
- const m = TEST_RESULT_RE.exec(line);
44
- if (m) {
45
- passed = Number(m[1]);
46
- failed = Number(m[2]);
47
- }
48
- }
49
-
50
- // Split into per-test failure blocks delimited by "---- test::name stdout ----" headers
51
- const blocks: Array<{ name: string; lines: string[] }> = [];
52
- let current: { name: string; lines: string[] } | null = null;
53
-
54
- for (const line of lines) {
55
- const headerMatch = BLOCK_HEADER_RE.exec(line);
56
- if (headerMatch) {
57
- if (current) blocks.push(current);
58
- current = { name: headerMatch[1], lines: [] };
59
- } else if (current) {
60
- current.lines.push(line);
61
- }
62
- }
63
- if (current) blocks.push(current);
64
-
65
- const failures: ParsedFailure[] = blocks.map(({ name, lines: blockLines }) =>
66
- parseFailureBlock(name, blockLines, ctx.cwd),
67
- );
68
-
69
- return {
70
- tool: 'cargo',
71
- status: failed > 0 ? 'fail' : 'pass',
72
- summary: failed > 0 ? `${failed} failed, ${passed} passed` : `${passed} passed`,
73
- failures,
74
- logPath: ctx.logPath,
75
- };
76
- },
77
- };
78
-
79
- function parseFailureBlock(testName: string, lines: string[], cwd: string): ParsedFailure {
80
- let file: string | undefined;
81
- let lineNum: number | undefined;
82
- let message: string | undefined;
83
-
84
- // Try new format (1.73+) line by line first
85
- for (let i = 0; i < lines.length; i++) {
86
- const line = lines[i];
87
- const newMatch = PANIC_NEW.exec(line);
88
- if (newMatch) {
89
- file = path.relative(cwd, path.resolve(cwd, newMatch[1]));
90
- lineNum = Number(newMatch[2]);
91
- // Collect message lines that follow until blank line or note:/error:
92
- const msgLines: string[] = [];
93
- for (let j = i + 1; j < lines.length; j++) {
94
- const next = lines[j];
95
- if (next === '' || next.startsWith('note:') || next.startsWith('error:')) break;
96
- msgLines.push(next);
97
- }
98
- message = formatMessage(msgLines);
99
- break;
100
- }
101
- }
102
-
103
- // Fall back to pre-1.73 format; join block so dotall regex handles multi-line messages
104
- if (!file) {
105
- const blockText = lines.join('\n');
106
- const oldMatch = PANIC_OLD.exec(blockText);
107
- if (oldMatch) {
108
- // Collapse internal newlines in message to a single space
109
- message = oldMatch[1].replace(/\s+/g, ' ').trim();
110
- file = path.relative(cwd, path.resolve(cwd, oldMatch[2]));
111
- lineNum = Number(oldMatch[3]);
112
- }
113
- }
114
-
115
- const id = [file, lineNum, testName].filter(Boolean).join(':');
116
- return {
117
- id: id || testName,
118
- file,
119
- line: lineNum,
120
- message: message ?? testName,
121
- };
122
- }
123
-
124
- /** Compact assertion left/right onto one line; otherwise join with "; " */
125
- function formatMessage(msgLines: string[]): string {
126
- if (msgLines.length === 0) return '';
127
- const main = msgLines[0];
128
- const leftLine = msgLines.find((l) => l.trimStart().startsWith('left:'));
129
- const rightLine = msgLines.find((l) => l.trimStart().startsWith('right:'));
130
- if (leftLine && rightLine) {
131
- return `${main}\n${leftLine.trim()}, ${rightLine.trim()}`;
132
- }
133
- return msgLines.filter(Boolean).join('; ');
134
- }
135
-
136
- export default parser;
3
+ export default nativeParser('cargo-test');
@@ -1,183 +1,3 @@
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';
1
+ import { nativeParser } from '../native';
5
2
 
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;
3
+ export default nativeParser('checkstyle-xml');
@@ -1,61 +1,3 @@
1
- import path from 'node:path';
2
- import type { ParserModule, ParsedFailure } from '../types';
3
- import { safeReadFile } from './utils';
1
+ import { nativeParser } from '../native';
4
2
 
5
- // Clang/GCC error format: file:line:col: error: message [-Wflag]
6
- const ERROR_LINE = /^(.+?):(\d+):\d+: (error|fatal error): (.+?)(\s+\[-.+\])?$/;
7
- const SUMMARY_LINE = /^(\d+) errors? generated/;
8
-
9
- const parser: ParserModule = {
10
- id: 'clang-text',
11
- async parse(ctx) {
12
- const stderr = safeReadFile(ctx.stderrPath).trim();
13
- if (!stderr) {
14
- return {
15
- tool: 'clang',
16
- status: 'pass',
17
- summary: 'compilation successful',
18
- failures: [],
19
- logPath: ctx.logPath,
20
- };
21
- }
22
-
23
- const lines = stderr.split('\n');
24
- const failures: ParsedFailure[] = [];
25
- let summaryLine = '';
26
-
27
- for (const line of lines) {
28
- const errorMatch = line.match(ERROR_LINE);
29
- if (errorMatch) {
30
- const [, filePath, lineNum, , message, flag] = errorMatch;
31
- const relPath = path.relative(ctx.cwd, filePath);
32
- failures.push({
33
- id: `${relPath}:${lineNum}`,
34
- file: relPath,
35
- line: parseInt(lineNum, 10),
36
- message,
37
- rule: flag?.trim().replace(/^\[/, '').replace(/\]$/, ''),
38
- });
39
- continue;
40
- }
41
- const sumMatch = line.match(SUMMARY_LINE);
42
- if (sumMatch) summaryLine = line;
43
- }
44
-
45
- const summary =
46
- summaryLine ||
47
- (failures.length > 0
48
- ? `${failures.length} error${failures.length !== 1 ? 's' : ''}`
49
- : 'compilation successful');
50
-
51
- return {
52
- tool: 'clang',
53
- status: failures.length > 0 ? 'fail' : 'pass',
54
- summary,
55
- failures,
56
- logPath: ctx.logPath,
57
- };
58
- },
59
- };
60
-
61
- export default parser;
3
+ export default nativeParser('clang-text');
@@ -1,136 +1,3 @@
1
- import type { ParserModule, ParsedFailure } from '../types';
2
- import { safeReadFile } from './utils';
1
+ import { nativeParser } from '../native';
3
2
 
4
- interface DbtEvent {
5
- data: Record<string, unknown>;
6
- info: {
7
- name: string;
8
- level: string;
9
- msg: string;
10
- };
11
- }
12
-
13
- interface NodeInfo {
14
- node_name?: string;
15
- node_path?: string;
16
- node_status?: string;
17
- }
18
-
19
- /** Parse `PASS=2 WARN=1 ERROR=1 SKIP=0 TOTAL=4` from EndOfRunSummary msg */
20
- function parseSummaryCounts(msg: string): Record<string, number> {
21
- const counts: Record<string, number> = {};
22
- for (const [, key, val] of msg.matchAll(/(\w+)=(\d+)/g)) {
23
- counts[key] = Number(val);
24
- }
25
- return counts;
26
- }
27
-
28
- const parser: ParserModule = {
29
- id: 'dbt-json',
30
- async parse(ctx) {
31
- // dbt --log-format json writes JSONL to stdout
32
- const raw = safeReadFile(ctx.stdoutPath);
33
- const events: DbtEvent[] = [];
34
- for (const line of raw.split('\n')) {
35
- if (!line.trim().startsWith('{')) continue;
36
- try {
37
- events.push(JSON.parse(line) as DbtEvent);
38
- } catch {
39
- continue;
40
- }
41
- }
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');
47
-
48
- // ---------- compile mode (no EndOfRunSummary, has CompiledNode) ----------
49
- if (compiled.length > 0 && !summary) {
50
- const names = compiled
51
- .map((n) => ((n.data.node_info ?? {}) as NodeInfo).node_name)
52
- .filter(Boolean);
53
- const sqlParts = compiled
54
- .map((n) => {
55
- const info = (n.data.node_info ?? {}) as NodeInfo;
56
- const sql = n.data.compiled as string | undefined;
57
- return sql ? `-- ${info.node_name ?? 'model'}\n${sql}` : undefined;
58
- })
59
- .filter(Boolean);
60
- return {
61
- tool: 'dbt',
62
- status: 'pass',
63
- summary: `compiled ${compiled.length} model${compiled.length === 1 ? '' : 's'}: ${names.join(', ')}`,
64
- failures: [],
65
- rawTail: sqlParts.join('\n\n'),
66
- logPath: ctx.logPath,
67
- };
68
- }
69
-
70
- // ---------- compile failure (no summary, no compiled nodes) ----------
71
- if (!summary && compiled.length === 0) {
72
- // Look for any error-level messages for context
73
- const errorMsgs = events.filter((e) => e.info.level === 'error');
74
- const failures: ParsedFailure[] = errorMsgs.map((e, i) => ({
75
- id: String(i),
76
- message: e.info.msg,
77
- }));
78
- return {
79
- tool: 'dbt',
80
- status: 'error',
81
- summary:
82
- failures.length > 0
83
- ? `${failures.length} error${failures.length === 1 ? '' : 's'}`
84
- : 'failed',
85
- failures,
86
- logPath: ctx.logPath,
87
- };
88
- }
89
-
90
- // ---------- run / test mode ----------
91
- const counts = parseSummaryCounts(summary!.info.msg);
92
- const elapsed = (summary!.data.elapsed_time as number) ?? 0;
93
- const numErrors = counts.ERROR ?? (summary!.data.num_errors as number) ?? 0;
94
- const numWarnings = counts.WARN ?? (summary!.data.num_warnings as number) ?? 0;
95
- const numSkipped = counts.SKIP ?? (summary!.data.num_skipped as number) ?? 0;
96
- const numPassed = counts.PASS ?? 0;
97
-
98
- const failures: ParsedFailure[] = [];
99
-
100
- for (const err of errors) {
101
- const nodeInfo = (err.data.node_info ?? {}) as NodeInfo;
102
- failures.push({
103
- id: nodeInfo.node_name ?? String(failures.length),
104
- file: nodeInfo.node_path,
105
- message: (err.data.msg as string) ?? err.info.msg,
106
- });
107
- }
108
-
109
- for (const warn of warnings) {
110
- const nodeInfo = (warn.data.node_info ?? {}) as NodeInfo;
111
- failures.push({
112
- id: nodeInfo.node_name ?? String(failures.length),
113
- file: nodeInfo.node_path,
114
- message: `[warn] ${(warn.data.msg as string) ?? warn.info.msg}`,
115
- });
116
- }
117
-
118
- // Build summary string
119
- const parts: string[] = [];
120
- if (numErrors > 0) parts.push(`${numErrors} failed`);
121
- if (numPassed > 0) parts.push(`${numPassed} passed`);
122
- if (numWarnings > 0) parts.push(`${numWarnings} warning${numWarnings === 1 ? '' : 's'}`);
123
- if (numSkipped > 0) parts.push(`${numSkipped} skipped`);
124
- const summaryStr = `${parts.join(', ')} in ${elapsed.toFixed(2)}s`;
125
-
126
- return {
127
- tool: 'dbt',
128
- status: numErrors > 0 ? 'fail' : 'pass',
129
- summary: summaryStr,
130
- failures,
131
- logPath: ctx.logPath,
132
- };
133
- },
134
- };
135
-
136
- export default parser;
3
+ export default nativeParser('dbt-json');
@@ -1,50 +1,3 @@
1
- import path from 'node:path';
2
- import type { ParserModule, ParsedFailure } from '../types';
3
- import { safeReadFile } from './utils';
1
+ import { nativeParser } from '../native';
4
2
 
5
- // MSBuild error format: file(line,col): error CODE: message [project]
6
- const ERROR_LINE = /^(.+?)\((\d+),\d+\): error (\w+): (.+?)(?:\s+\[.+\])?$/;
7
-
8
- const parser: ParserModule = {
9
- id: 'dotnet-build-text',
10
- async parse(ctx) {
11
- const combined = safeReadFile(ctx.stdoutPath) + safeReadFile(ctx.stderrPath);
12
- const lines = combined.split('\n');
13
-
14
- // Deduplicate — MSBuild prints errors twice (inline + summary)
15
- const seen = new Set<string>();
16
- const failures: ParsedFailure[] = [];
17
-
18
- for (const line of lines) {
19
- const match = line.trim().match(ERROR_LINE);
20
- if (!match) continue;
21
- const [, filePath, lineNum, code, message] = match;
22
- const relPath = path.relative(ctx.cwd, filePath);
23
- const key = `${relPath}:${lineNum}:${code}`;
24
- if (seen.has(key)) continue;
25
- seen.add(key);
26
- failures.push({
27
- id: key,
28
- file: relPath,
29
- line: parseInt(lineNum, 10),
30
- message,
31
- rule: code,
32
- });
33
- }
34
-
35
- const summary =
36
- failures.length > 0
37
- ? `${failures.length} error${failures.length !== 1 ? 's' : ''}`
38
- : 'build succeeded';
39
-
40
- return {
41
- tool: 'dotnet build',
42
- status: failures.length > 0 ? 'fail' : 'pass',
43
- summary,
44
- failures,
45
- logPath: ctx.logPath,
46
- };
47
- },
48
- };
49
-
50
- export default parser;
3
+ export default nativeParser('dotnet-build-text');
@@ -1,39 +1,3 @@
1
- import path from 'node:path';
2
- import type { ParserModule } from '../types';
3
- import { safeReadFile } from './utils';
1
+ import { nativeParser } from '../native';
4
2
 
5
- const parser: ParserModule = {
6
- id: 'eslint-json',
7
- async parse(ctx) {
8
- const stdout = safeReadFile(ctx.stdoutPath).trim();
9
- const files = stdout ? JSON.parse(stdout) : [];
10
- const failures = [] as Array<{
11
- id: string;
12
- file?: string;
13
- line?: number;
14
- message?: string;
15
- rule?: string;
16
- }>;
17
- for (const file of Array.isArray(files) ? files : []) {
18
- const relPath = path.relative(ctx.cwd, file.filePath);
19
- for (const msg of file.messages ?? []) {
20
- failures.push({
21
- id: `${relPath}:${msg.line}:${msg.ruleId ?? 'unknown'}`,
22
- file: relPath,
23
- line: msg.line,
24
- message: msg.message,
25
- rule: msg.ruleId ?? undefined,
26
- });
27
- }
28
- }
29
- return {
30
- tool: 'eslint',
31
- status: failures.length > 0 ? 'fail' : 'pass',
32
- summary: failures.length > 0 ? `${failures.length} lint errors` : 'no lint errors',
33
- failures,
34
- logPath: ctx.logPath,
35
- };
36
- },
37
- };
38
-
39
- export default parser;
3
+ export default nativeParser('eslint-json');