From 15cb154a19cabb5c3c66491a61f215ef104d5280 Mon Sep 17 00:00:00 2001
From: TevinClaw <510129976@qq.com>
Date: Sat, 14 Mar 2026 13:03:06 +0800
Subject: [PATCH] feat(早报): 增加昨日总结模块

---
 workspace/skills/self-improving-agent/scripts/error-detector.sh |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/workspace/skills/self-improving-agent/scripts/error-detector.sh b/workspace/skills/self-improving-agent/scripts/error-detector.sh
new file mode 100644
index 0000000..3c310dd
--- /dev/null
+++ b/workspace/skills/self-improving-agent/scripts/error-detector.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+# Self-Improvement Error Detector Hook
+# Triggers on PostToolUse for Bash to detect command failures
+# Reads CLAUDE_TOOL_OUTPUT environment variable
+
+set -e
+
+# Check if tool output indicates an error
+# CLAUDE_TOOL_OUTPUT contains the result of the tool execution
+OUTPUT="${CLAUDE_TOOL_OUTPUT:-}"
+
+# Patterns indicating errors (case-insensitive matching)
+ERROR_PATTERNS=(
+    "error:"
+    "Error:"
+    "ERROR:"
+    "failed"
+    "FAILED"
+    "command not found"
+    "No such file"
+    "Permission denied"
+    "fatal:"
+    "Exception"
+    "Traceback"
+    "npm ERR!"
+    "ModuleNotFoundError"
+    "SyntaxError"
+    "TypeError"
+    "exit code"
+    "non-zero"
+)
+
+# Check if output contains any error pattern
+contains_error=false
+for pattern in "${ERROR_PATTERNS[@]}"; do
+    if [[ "$OUTPUT" == *"$pattern"* ]]; then
+        contains_error=true
+        break
+    fi
+done
+
+# Only output reminder if error detected
+if [ "$contains_error" = true ]; then
+    cat << 'EOF'
+<error-detected>
+A command error was detected. Consider logging this to .learnings/ERRORS.md if:
+- The error was unexpected or non-obvious
+- It required investigation to resolve
+- It might recur in similar contexts
+- The solution could benefit future sessions
+
+Use the self-improvement skill format: [ERR-YYYYMMDD-XXX]
+</error-detected>
+EOF
+fi

--
Gitblit v1.9.1