This commit is contained in:
Jonas H
2026-03-03 19:29:09 +01:00
parent 82c3e1e3b0
commit f615810509
5 changed files with 131 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env python3
import sys
import json
import re
data = json.load(sys.stdin)
if data.get("tool_name") != "Bash":
sys.exit(0)
cmd = data.get("tool_input", {}).get("command", "")
if not re.search(r"\bcargo\s+(check|build|test|clippy|run)\b", cmd):
sys.exit(0)
output = data.get("tool_response", {}).get("output", "")
if not output:
sys.exit(0)
blocks = re.split(r"\n{2,}", output)
warning_blocks = [b for b in blocks if re.match(r"\s*warning:", b)]
other_blocks = [b for b in blocks if not re.match(r"\s*warning:", b)]
if not warning_blocks:
sys.exit(0)
filtered = "\n\n".join(other_blocks).rstrip("\n")
filtered += f"\n\n[{len(warning_blocks)} warning(s) filtered]\n"
print(json.dumps({"type": "result", "content": filtered}))