@robhowley/pi-structured-return 1.3.0 → 1.4.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.
- package/README.md +26 -3
- package/extensions/structured-return/src/config/registry.ts +9 -0
- package/extensions/structured-return/src/parsers/dbt-json.test.ts +172 -0
- package/extensions/structured-return/src/parsers/dbt-json.ts +131 -0
- package/package.json +1 -1
- package/skills/structured-return/SKILL.md +5 -0
package/README.md
CHANGED
|
@@ -6,12 +6,15 @@ Cross-platform Pi package that combines:
|
|
|
6
6
|
- a `structured-return` skill for choosing compact / machine-readable command forms
|
|
7
7
|
- a `structured-return` extension that captures output, stores artifacts, applies parsers, and falls back to tail + log path
|
|
8
8
|
|
|
9
|
+
Tens of thousands of tokens per session saved by filtering noise from test suites, linters, build tools, and data pipelines
|
|
10
|
+
so LLMs spend tokens on signal, not boilerplate.
|
|
11
|
+
|
|
9
12
|
## Token reduction
|
|
10
13
|
|
|
11
14
|
Tool output is designed for humans: source diffs, line annotations, timing breakdowns, absolute paths repeated on every line. Useful on a terminal. Expensive in a model context, especially on failure when output is most verbose and the model needs to act fast.
|
|
12
15
|
|
|
13
|
-
Test runners: 3 tests, 1 passing, 1 assertion failure, 1 unexpected error.
|
|
14
|
-
Linters: 1 unused variable warning in a single file.
|
|
16
|
+
- Test runners: 3 tests, 1 passing, 1 assertion failure, 1 unexpected error.
|
|
17
|
+
- Linters: 1 unused variable warning in a single file.
|
|
15
18
|
|
|
16
19
|
| Parser | Raw (tokens) | Structured (tokens) | Reduction | Notes |
|
|
17
20
|
|---|---|---|---|---|
|
|
@@ -19,9 +22,9 @@ Linters: 1 unused variable warning in a single file.
|
|
|
19
22
|
| `junit-xml` (go) | 400 | 58 | **86%** | verbose output with full stack trace per failure |
|
|
20
23
|
| `junit-xml` (dotnet) | 487 | 107 | **78%** | build header and VSTest output with per-failure stack traces |
|
|
21
24
|
| `vitest-json` | 348 | 75 | **78%** | source diff with inline arrows and ANSI color codes per failure |
|
|
25
|
+
| `cargo-test` | 285 | 68 | **76%** | cargo progress + test binary output with panic traces per failure |
|
|
22
26
|
| `junit-xml` (pytest) | 289 | 71 | **75%** | verbose output with source snippets and summary footer |
|
|
23
27
|
| `rspec-json` | 212 | 55 | **74%** | default output with backtrace |
|
|
24
|
-
| `cargo-test` | 285 | 68 | **76%** | cargo progress + test binary output with panic traces per failure |
|
|
25
28
|
| `junit-xml` (gradle) | 263 | 81 | **69%** | gradle console output with build lifecycle noise |
|
|
26
29
|
| `junit-xml` (jest) | 309 | 99 | **68%** | source annotations with deep jest-circus stack traces per failure |
|
|
27
30
|
| `cargo-build` | 225 | 77 | **66%** | rustc error annotations with code spans and help text per error |
|
|
@@ -31,11 +34,31 @@ Linters: 1 unused variable warning in a single file.
|
|
|
31
34
|
|
|
32
35
|
Tokens counted with `cl100k_base` (tiktoken). Linter output is more compact than test runner output to begin with, so the baseline reduction is lower. The numbers above are measured against a single file with a single error — a conservative lower bound. Both ruff and eslint repeat absolute file paths per error in their raw output, so reduction grows as violations spread across more files.
|
|
33
36
|
|
|
37
|
+
### Pipeline tools
|
|
38
|
+
|
|
39
|
+
dbt output is the noisiest tool in this repo relative to useful signal. Every run prints version info, adapter registration, project stats, concurrency settings, and per-node start/finish lines — all before any result.
|
|
40
|
+
|
|
41
|
+
The numbers below use 3–4 model toy examples; real projects run hundreds of models where the noise scales linearly and reduction compounds.
|
|
42
|
+
|
|
43
|
+
- dbt run: 4 models, 1 passing, 1 DB error, 1 permissions error, 1 DAG skip.
|
|
44
|
+
- dbt test: 3 tests, 1 passing, 1 uniqueness failure, 1 unit test diff.
|
|
45
|
+
- dbt compile: 3 models compiled to SQL.
|
|
46
|
+
|
|
47
|
+
| Parser | Raw (tokens) | Structured (tokens) | Reduction | Notes |
|
|
48
|
+
|---|---|---|---|---|
|
|
49
|
+
| `dbt-json` (run, success) | 428 | 20 | **95%** | version, adapter, concurrency, per-model start/finish — all noise on success |
|
|
50
|
+
| `dbt-json` (run, failure) | 618 | 198 | **68%** | error messages, model paths, compiled code paths preserved |
|
|
51
|
+
| `dbt-json` (test) | 720 | 274 | **62%** | unit test diff tables preserved verbatim; preamble stripped |
|
|
52
|
+
| `dbt-json` (compile) | 775 | 683 | **12%** | compiled SQL is the signal and returned verbatim |
|
|
53
|
+
|
|
54
|
+
At 12 models, run failures hit 85% reduction. An 18-model DAG success: 1,645 → 20 tokens (99%).
|
|
55
|
+
|
|
34
56
|
## Built-in parsers
|
|
35
57
|
- `junit-xml` (JUnit XML — covers pytest `--junitxml`, Gradle, Maven, Jest with `jest-junit`, Go with `go-junit-report`, and any other tool that emits the JUnit XML schema)
|
|
36
58
|
- `vitest-json`
|
|
37
59
|
- `rspec-json`
|
|
38
60
|
- `minitest-text` (parses default minitest output — no flags or reporters needed)
|
|
61
|
+
- `dbt-json` (`dbt run/test/compile --log-format json` — errors, warnings, and unit test diffs from JSONL; compiled SQL returned for compile; success runs reduced to a one-line summary)
|
|
39
62
|
- `cargo-build` (`cargo build --message-format=json` — errors with file, line, error code, and primary span label; warnings filtered out)
|
|
40
63
|
- `cargo-test` (`cargo test` — assertion left/right values, panic messages, and file:line per failure; detects compilation failures and directs to `cargo build --message-format=json`)
|
|
41
64
|
- `ruff-json` (`ruff check` only — `ruff format` has no json support)
|
|
@@ -8,6 +8,7 @@ import minitestText from "../parsers/minitest-text";
|
|
|
8
8
|
import junitXml from "../parsers/junit-xml";
|
|
9
9
|
import cargoBuild from "../parsers/cargo-build";
|
|
10
10
|
import cargoTest from "../parsers/cargo-test";
|
|
11
|
+
import dbtJson from "../parsers/dbt-json";
|
|
11
12
|
import tailFallback from "../parsers/tail-fallback";
|
|
12
13
|
|
|
13
14
|
const builtIns: Record<string, ParserModule> = {
|
|
@@ -19,6 +20,7 @@ const builtIns: Record<string, ParserModule> = {
|
|
|
19
20
|
"junit-xml": junitXml,
|
|
20
21
|
"cargo-build": cargoBuild,
|
|
21
22
|
"cargo-test": cargoTest,
|
|
23
|
+
"dbt-json": dbtJson,
|
|
22
24
|
"tail-fallback": tailFallback,
|
|
23
25
|
};
|
|
24
26
|
|
|
@@ -61,6 +63,13 @@ const AUTO_DETECT: Array<{ parserId: string; detect: (argv: string[]) => boolean
|
|
|
61
63
|
parserId: "cargo-test",
|
|
62
64
|
detect: (argv) => argv.includes("cargo") && argv.includes("test"),
|
|
63
65
|
},
|
|
66
|
+
{
|
|
67
|
+
parserId: "dbt-json",
|
|
68
|
+
detect: (argv) =>
|
|
69
|
+
argv.includes("dbt") &&
|
|
70
|
+
(argv.includes("run") || argv.includes("test") || argv.includes("compile")) &&
|
|
71
|
+
argv.some((a) => a === "--log-format" || a === "json" || a === "--log-format=json"),
|
|
72
|
+
},
|
|
64
73
|
];
|
|
65
74
|
|
|
66
75
|
export function listParsers(): { id: string; autoDetect: boolean }[] {
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { describe, it, expect } from "vitest";
|
|
5
|
+
import parser from "./dbt-json";
|
|
6
|
+
import type { RunContext } from "../types";
|
|
7
|
+
|
|
8
|
+
const SAMPLES_DIR = path.resolve(__dirname, "../../../../benchmarks/pipeline-tools/dbt");
|
|
9
|
+
|
|
10
|
+
function makeCtx(stdout: string, cwd = "/project"): RunContext {
|
|
11
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "dbt-test-"));
|
|
12
|
+
const stdoutPath = path.join(dir, "stdout");
|
|
13
|
+
fs.writeFileSync(stdoutPath, stdout);
|
|
14
|
+
return {
|
|
15
|
+
command: "dbt run --log-format json",
|
|
16
|
+
argv: ["dbt", "run", "--log-format", "json"],
|
|
17
|
+
cwd,
|
|
18
|
+
artifactPaths: [],
|
|
19
|
+
stdoutPath,
|
|
20
|
+
stderrPath: path.join(dir, "stderr"),
|
|
21
|
+
logPath: path.join(dir, "log"),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function loadSample(filename: string): string {
|
|
26
|
+
return fs.readFileSync(path.join(SAMPLES_DIR, filename), "utf8");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe("dbt-json parser", () => {
|
|
30
|
+
describe("dbt run success", () => {
|
|
31
|
+
it("3 models pass → status pass, correct summary, no failures", async () => {
|
|
32
|
+
const result = await parser.parse(makeCtx(loadSample("dbt-run-success.jsonl")));
|
|
33
|
+
expect(result.status).toBe("pass");
|
|
34
|
+
expect(result.summary).toBe("3 passed in 34.22s");
|
|
35
|
+
expect(result.failures).toHaveLength(0);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("dbt run failure", () => {
|
|
40
|
+
it("2 errors, 1 skip → status fail, both errors surfaced with node name and path", async () => {
|
|
41
|
+
const result = await parser.parse(makeCtx(loadSample("dbt-run-failure.jsonl")));
|
|
42
|
+
expect(result.status).toBe("fail");
|
|
43
|
+
expect(result.summary).toMatch(/2 failed/);
|
|
44
|
+
expect(result.summary).toMatch(/1 passed/);
|
|
45
|
+
expect(result.summary).toMatch(/1 skipped/);
|
|
46
|
+
expect(result.summary).toMatch(/34\.22s/);
|
|
47
|
+
expect(result.failures).toHaveLength(2);
|
|
48
|
+
|
|
49
|
+
const dbErr = result.failures![0];
|
|
50
|
+
expect(dbErr.id).toBe("mart__core__daily_active_customers");
|
|
51
|
+
expect(dbErr.file).toBe("models/mart/core/mart__core__daily_active_customers.sql");
|
|
52
|
+
expect(dbErr.message).toMatch(/Column customer_id in USING clause not found/);
|
|
53
|
+
|
|
54
|
+
const rtErr = result.failures![1];
|
|
55
|
+
expect(rtErr.id).toBe("mart__core__daily_summary");
|
|
56
|
+
expect(rtErr.file).toBe("models/mart/core/mart__core__daily_summary.sql");
|
|
57
|
+
expect(rtErr.message).toMatch(/Access Denied/);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe("dbt test failure", () => {
|
|
62
|
+
it("2 errors → status fail, both errors surfaced", async () => {
|
|
63
|
+
const result = await parser.parse(makeCtx(loadSample("dbt-test-failure.jsonl")));
|
|
64
|
+
expect(result.status).toBe("fail");
|
|
65
|
+
expect(result.summary).toMatch(/2 failed/);
|
|
66
|
+
expect(result.summary).toMatch(/1 passed/);
|
|
67
|
+
expect(result.failures).toHaveLength(2);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("uniqueness test failure has result count in message", async () => {
|
|
71
|
+
const result = await parser.parse(makeCtx(loadSample("dbt-test-failure.jsonl")));
|
|
72
|
+
const uniqueTest = result.failures!.find((f) => f.id.includes("unique_"));
|
|
73
|
+
expect(uniqueTest).toBeDefined();
|
|
74
|
+
expect(uniqueTest!.message).toMatch(/Got 3 results/);
|
|
75
|
+
expect(uniqueTest!.file).toBe("models/mart/core/_core__models.yml");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("unit test failure preserves actual/expected diff table", async () => {
|
|
79
|
+
const result = await parser.parse(makeCtx(loadSample("dbt-test-failure.jsonl")));
|
|
80
|
+
const unitTest = result.failures!.find((f) => f.id.includes("unit_test"));
|
|
81
|
+
expect(unitTest).toBeDefined();
|
|
82
|
+
expect(unitTest!.message).toMatch(/actual differs from expected/);
|
|
83
|
+
expect(unitTest!.message).toMatch(/engagement_score/);
|
|
84
|
+
expect(unitTest!.message).toMatch(/85\.5/);
|
|
85
|
+
expect(unitTest!.message).toMatch(/90\.0/);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("warnings are included with [warn] prefix when present", async () => {
|
|
89
|
+
// Inline JSONL with a warning event
|
|
90
|
+
const jsonl = [
|
|
91
|
+
JSON.stringify({
|
|
92
|
+
data: {
|
|
93
|
+
msg: "Got 12 results, configured to warn if != 0",
|
|
94
|
+
node_info: { node_name: "relationships_test", node_path: "models/test.yml", node_status: "warn" },
|
|
95
|
+
},
|
|
96
|
+
info: { name: "RunResultWarning", level: "warn", msg: "Got 12 results" },
|
|
97
|
+
}),
|
|
98
|
+
JSON.stringify({
|
|
99
|
+
data: { elapsed_time: 5.0, num_errors: 0, num_warnings: 1, num_skipped: 0 },
|
|
100
|
+
info: { name: "EndOfRunSummary", level: "info", msg: "Done. PASS=2 WARN=1 ERROR=0 SKIP=0 TOTAL=3" },
|
|
101
|
+
}),
|
|
102
|
+
].join("\n");
|
|
103
|
+
const result = await parser.parse(makeCtx(jsonl));
|
|
104
|
+
expect(result.status).toBe("pass");
|
|
105
|
+
const warning = result.failures!.find((f) => f.id === "relationships_test");
|
|
106
|
+
expect(warning).toBeDefined();
|
|
107
|
+
expect(warning!.message).toMatch(/^\[warn\]/);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe("dbt compile success", () => {
|
|
112
|
+
it("3 models compiled, all SQL returned in rawTail", async () => {
|
|
113
|
+
const result = await parser.parse(makeCtx(loadSample("dbt-compile.jsonl")));
|
|
114
|
+
expect(result.status).toBe("pass");
|
|
115
|
+
expect(result.summary).toMatch(/compiled 3 models/);
|
|
116
|
+
expect(result.summary).toMatch(/mart__core__customer_engagement/);
|
|
117
|
+
expect(result.summary).toMatch(/mart__core__daily_summary/);
|
|
118
|
+
expect(result.failures).toHaveLength(0);
|
|
119
|
+
expect(result.rawTail).toBeDefined();
|
|
120
|
+
expect(result.rawTail).toMatch(/WITH user_events AS/);
|
|
121
|
+
expect(result.rawTail).toMatch(/-- mart__core__daily_active_customers/);
|
|
122
|
+
expect(result.rawTail).toMatch(/-- mart__core__daily_summary/);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe("dbt compile failure", () => {
|
|
127
|
+
it("no summary + no compiled nodes → status error", async () => {
|
|
128
|
+
// Simulate a compile failure: error-level message, no EndOfRunSummary, no CompiledNode
|
|
129
|
+
const jsonl = [
|
|
130
|
+
JSON.stringify({
|
|
131
|
+
data: {},
|
|
132
|
+
info: { name: "MainReportVersion", level: "info", msg: "Running with dbt=1.8.4" },
|
|
133
|
+
}),
|
|
134
|
+
JSON.stringify({
|
|
135
|
+
data: {},
|
|
136
|
+
info: {
|
|
137
|
+
name: "CompilationError",
|
|
138
|
+
level: "error",
|
|
139
|
+
msg: "Compilation Error in model mart__core__customer_engagement (models/mart/core/mart__core__customer_engagement.sql)\n Model 'ref(\"stg__missing_model\")' was not found",
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
].join("\n");
|
|
143
|
+
|
|
144
|
+
const result = await parser.parse(makeCtx(jsonl));
|
|
145
|
+
expect(result.status).toBe("error");
|
|
146
|
+
expect(result.summary).toBe("1 error");
|
|
147
|
+
expect(result.failures).toHaveLength(1);
|
|
148
|
+
expect(result.failures![0].message).toMatch(/stg__missing_model/);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe("empty / malformed input", () => {
|
|
153
|
+
it("empty stdout → error status, no crash", async () => {
|
|
154
|
+
const result = await parser.parse(makeCtx(""));
|
|
155
|
+
expect(result.status).toBe("error");
|
|
156
|
+
expect(result.failures).toHaveLength(0);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("non-JSON lines are skipped gracefully", async () => {
|
|
160
|
+
const input =
|
|
161
|
+
"some garbage\n" +
|
|
162
|
+
JSON.stringify({
|
|
163
|
+
data: { elapsed_time: 1.0, num_errors: 0, num_warnings: 0, num_skipped: 0 },
|
|
164
|
+
info: { name: "EndOfRunSummary", level: "info", msg: "Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1" },
|
|
165
|
+
}) +
|
|
166
|
+
"\nmore garbage";
|
|
167
|
+
const result = await parser.parse(makeCtx(input));
|
|
168
|
+
expect(result.status).toBe("pass");
|
|
169
|
+
expect(result.summary).toBe("1 passed in 1.00s");
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import type { ParserModule, ParsedFailure } from "../types";
|
|
3
|
+
|
|
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 = fs.readFileSync(ctx.stdoutPath, "utf8");
|
|
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.map((n) => ((n.data.node_info ?? {}) as NodeInfo).node_name).filter(Boolean);
|
|
51
|
+
const sqlParts = compiled
|
|
52
|
+
.map((n) => {
|
|
53
|
+
const info = (n.data.node_info ?? {}) as NodeInfo;
|
|
54
|
+
const sql = n.data.compiled as string | undefined;
|
|
55
|
+
return sql ? `-- ${info.node_name ?? "model"}\n${sql}` : undefined;
|
|
56
|
+
})
|
|
57
|
+
.filter(Boolean);
|
|
58
|
+
return {
|
|
59
|
+
tool: "dbt",
|
|
60
|
+
status: "pass",
|
|
61
|
+
summary: `compiled ${compiled.length} model${compiled.length === 1 ? "" : "s"}: ${names.join(", ")}`,
|
|
62
|
+
failures: [],
|
|
63
|
+
rawTail: sqlParts.join("\n\n"),
|
|
64
|
+
logPath: ctx.logPath,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ---------- compile failure (no summary, no compiled nodes) ----------
|
|
69
|
+
if (!summary && compiled.length === 0) {
|
|
70
|
+
// Look for any error-level messages for context
|
|
71
|
+
const errorMsgs = events.filter((e) => e.info.level === "error");
|
|
72
|
+
const failures: ParsedFailure[] = errorMsgs.map((e, i) => ({
|
|
73
|
+
id: String(i),
|
|
74
|
+
message: e.info.msg,
|
|
75
|
+
}));
|
|
76
|
+
return {
|
|
77
|
+
tool: "dbt",
|
|
78
|
+
status: "error",
|
|
79
|
+
summary: failures.length > 0 ? `${failures.length} error${failures.length === 1 ? "" : "s"}` : "failed",
|
|
80
|
+
failures,
|
|
81
|
+
logPath: ctx.logPath,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ---------- run / test mode ----------
|
|
86
|
+
const counts = parseSummaryCounts(summary!.info.msg);
|
|
87
|
+
const elapsed = (summary!.data.elapsed_time as number) ?? 0;
|
|
88
|
+
const numErrors = counts.ERROR ?? (summary!.data.num_errors as number) ?? 0;
|
|
89
|
+
const numWarnings = counts.WARN ?? (summary!.data.num_warnings as number) ?? 0;
|
|
90
|
+
const numSkipped = counts.SKIP ?? (summary!.data.num_skipped as number) ?? 0;
|
|
91
|
+
const numPassed = counts.PASS ?? 0;
|
|
92
|
+
|
|
93
|
+
const failures: ParsedFailure[] = [];
|
|
94
|
+
|
|
95
|
+
for (const err of errors) {
|
|
96
|
+
const nodeInfo = (err.data.node_info ?? {}) as NodeInfo;
|
|
97
|
+
failures.push({
|
|
98
|
+
id: nodeInfo.node_name ?? String(failures.length),
|
|
99
|
+
file: nodeInfo.node_path,
|
|
100
|
+
message: (err.data.msg as string) ?? err.info.msg,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
for (const warn of warnings) {
|
|
105
|
+
const nodeInfo = (warn.data.node_info ?? {}) as NodeInfo;
|
|
106
|
+
failures.push({
|
|
107
|
+
id: nodeInfo.node_name ?? String(failures.length),
|
|
108
|
+
file: nodeInfo.node_path,
|
|
109
|
+
message: `[warn] ${(warn.data.msg as string) ?? warn.info.msg}`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Build summary string
|
|
114
|
+
const parts: string[] = [];
|
|
115
|
+
if (numErrors > 0) parts.push(`${numErrors} failed`);
|
|
116
|
+
if (numPassed > 0) parts.push(`${numPassed} passed`);
|
|
117
|
+
if (numWarnings > 0) parts.push(`${numWarnings} warning${numWarnings === 1 ? "" : "s"}`);
|
|
118
|
+
if (numSkipped > 0) parts.push(`${numSkipped} skipped`);
|
|
119
|
+
const summaryStr = `${parts.join(", ")} in ${elapsed.toFixed(2)}s`;
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
tool: "dbt",
|
|
123
|
+
status: numErrors > 0 ? "fail" : "pass",
|
|
124
|
+
summary: summaryStr,
|
|
125
|
+
failures,
|
|
126
|
+
logPath: ctx.logPath,
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export default parser;
|
package/package.json
CHANGED
|
@@ -45,6 +45,11 @@ Prefer better output at the source.
|
|
|
45
45
|
### minitest
|
|
46
46
|
- `structured_return({ command: "ruby [any minitest args]", parseAs: "minitest-text" })` — no format flags needed; works with plain ruby invocation
|
|
47
47
|
|
|
48
|
+
### dbt (run, test, compile)
|
|
49
|
+
- `structured_return({ command: "dbt run [any dbt args] --log-format json", parseAs: "dbt-json" })` — `--log-format json` required; model selectors, flags, etc. go in `[any dbt args]`
|
|
50
|
+
- `structured_return({ command: "dbt test [any dbt args] --log-format json", parseAs: "dbt-json" })` — same parser handles run and test; unit test diffs preserved verbatim
|
|
51
|
+
- `structured_return({ command: "dbt compile [any dbt args] --log-format json", parseAs: "dbt-json" })` — returns compiled SQL; preamble stripped
|
|
52
|
+
|
|
48
53
|
### cargo build
|
|
49
54
|
- `structured_return({ command: "cargo build --message-format=json", parseAs: "cargo-build" })` — `--message-format=json` is built into cargo; errors include file, line, error code (E0308 etc.), and primary span label (expected X, found Y); warnings are filtered out
|
|
50
55
|
|