Skip to content

Commit 1d4d9b1

Browse files
committed
feat: implement language-specific distillation logic for non-Bash tools in post-tool hook
1 parent 086ceaa commit 1d4d9b1

5 files changed

Lines changed: 546 additions & 18 deletions

File tree

src/distillers/build.rs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,39 @@ impl Distiller for BuildDistiller {
1212
) -> String {
1313
let mut errors = Vec::new();
1414
let mut warnings = Vec::new();
15+
let mut current_block = Vec::new();
16+
let mut is_error_block = false;
1517

1618
for seg in segments {
17-
if seg.tier == SignalTier::Critical {
18-
errors.push(seg.content.clone());
19-
} else if seg.tier == SignalTier::Important {
20-
warnings.push(seg.content.clone());
19+
if seg.tier == SignalTier::Critical || seg.tier == SignalTier::Important {
20+
if current_block.is_empty() {
21+
is_error_block = seg.tier == SignalTier::Critical;
22+
}
23+
// If we see a new critical and we're currently in a warning block,
24+
// or if it's a clear new error boundary, flush it
25+
if seg.tier == SignalTier::Critical && !current_block.is_empty() && !is_error_block
26+
{
27+
warnings.push(current_block.join("\n"));
28+
current_block.clear();
29+
is_error_block = true;
30+
}
31+
current_block.push(seg.content.clone());
32+
} else {
33+
if !current_block.is_empty() {
34+
if is_error_block {
35+
errors.push(current_block.join("\n"));
36+
} else {
37+
warnings.push(current_block.join("\n"));
38+
}
39+
current_block.clear();
40+
}
41+
}
42+
}
43+
if !current_block.is_empty() {
44+
if is_error_block {
45+
errors.push(current_block.join("\n"));
46+
} else {
47+
warnings.push(current_block.join("\n"));
2148
}
2249
}
2350

src/distillers/snapshots/omni__distillers__tests__cargo_build_distillation.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ expression: output
44
---
55
Build: 1 errors, 0 warnings
66
error[E0432]: unresolved import `std::collections`
7+
--> src/main.rs:1:5
8+
|
9+
1 | use std::collections::Foo;
10+
| ^^^^^^^^^^^^^^^^^^^^^ no `Foo` in `collections`

src/distillers/test.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ impl Distiller for TestDistiller {
2424
if !seg.content.to_lowercase().contains("failed tests/")
2525
&& !seg.content.contains("===")
2626
{
27-
failure_details.push(seg.content.clone());
27+
// Truncate to max 12 lines to keep just the assertion and stack trace
28+
let lines: Vec<&str> = seg.content.lines().collect();
29+
if lines.len() > 12 {
30+
let truncated =
31+
lines[..12].join("\n") + "\n ... [stack trace truncated]";
32+
failure_details.push(truncated);
33+
} else {
34+
failure_details.push(seg.content.clone());
35+
}
2836
}
2937
} else if seg.tier == SignalTier::Important
3038
|| seg.content.contains("PASS")
@@ -53,7 +61,7 @@ impl Distiller for TestDistiller {
5361

5462
out.push_str(&format!("Tests: {} passed, {} failed\n", passed, failed));
5563

56-
let max_fails = 5;
64+
let max_fails = 10;
5765
for (i, fail) in failure_details.iter().enumerate() {
5866
if i < max_fails {
5967
out.push_str(fail);

0 commit comments

Comments
 (0)