claude-pangu 2.2.21 → 2.2.22

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 (41) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +1 -0
  3. package/hooks/agent-collaboration.sh +14 -1
  4. package/hooks/agent-handoff-prompt.sh +15 -4
  5. package/hooks/agent-ready-notification.sh +13 -2
  6. package/hooks/agent-usage-reminder.sh +12 -2
  7. package/hooks/anthropic-context-window-limit-recovery.sh +14 -2
  8. package/hooks/ast-grep.sh +14 -1
  9. package/hooks/atlas.sh +13 -4
  10. package/hooks/auto-update-checker.sh +20 -1
  11. package/hooks/background-compaction.sh +15 -2
  12. package/hooks/background-notification.sh +1 -1
  13. package/hooks/code-quality-checker.sh +14 -1
  14. package/hooks/compaction-context-injector.sh +218 -0
  15. package/hooks/context-compression.sh +14 -1
  16. package/hooks/context-smart-alert.sh +15 -3
  17. package/hooks/context-window-monitor.sh +15 -3
  18. package/hooks/delegate-task-retry.sh +4 -4
  19. package/hooks/directory-agents-injector.sh +14 -1
  20. package/hooks/directory-readme-injector.sh +16 -2
  21. package/hooks/edit-error-recovery.sh +17 -3
  22. package/hooks/empty-message-sanitizer.sh +150 -0
  23. package/hooks/empty-task-response-detector.sh +14 -3
  24. package/hooks/error-friendly-display.sh +17 -7
  25. package/hooks/error-recovery.sh +14 -1
  26. package/hooks/first-use-onboarding.sh +1 -4
  27. package/hooks/hook-performance-monitor.sh +1 -1
  28. package/hooks/hooks.json +30 -1
  29. package/hooks/interactive-bash-session.sh +12 -2
  30. package/hooks/lsp-tools.sh +14 -1
  31. package/hooks/non-interactive-env.sh +186 -0
  32. package/hooks/output-truncator.sh +14 -1
  33. package/hooks/preemptive-compaction.sh +14 -1
  34. package/hooks/rules-injector.sh +14 -1
  35. package/hooks/session-notification.sh +17 -3
  36. package/hooks/session-recovery.sh +12 -2
  37. package/hooks/task-checkpointing.sh +14 -1
  38. package/hooks/think-mode.sh +14 -1
  39. package/hooks/thinking-block-validator.sh +14 -3
  40. package/hooks/tmux-agent-visualizer.sh +17 -2
  41. package/package.json +1 -1
@@ -453,5 +453,18 @@ main() {
453
453
  exit 0
454
454
  }
455
455
 
456
+ # 从 stdin 读取 JSON 数据(Claude Code Hook API 通过 stdin 传递事件数据)
457
+ _STDIN_INPUT=$(cat 2>/dev/null) || _STDIN_INPUT=""
458
+ if [ -z "$_STDIN_INPUT" ]; then
459
+ exit 0
460
+ fi
461
+
462
+ # 解析 stdin JSON 的 prompt 字段
463
+ if command -v jq > /dev/null 2>&1; then
464
+ _STDIN_PROMPT=$(echo "$_STDIN_INPUT" | jq -r '.prompt // empty' 2>/dev/null) || _STDIN_PROMPT=""
465
+ else
466
+ _STDIN_PROMPT=$(echo "$_STDIN_INPUT" | grep -o '"prompt"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"prompt"[[:space:]]*:[[:space:]]*"\([^"]*\)"/\1/' 2>/dev/null) || _STDIN_PROMPT=""
467
+ fi
468
+
456
469
  # 执行主函数
457
- main "$@"
470
+ main "$_STDIN_PROMPT"
@@ -10,9 +10,20 @@
10
10
  # 3. 提供错误恢复建议
11
11
  # ============================================================================
12
12
 
13
- # 获取工具调用结果
14
- tool_result="${CLAUDE_TOOL_RESULT:-}"
15
- tool_name="${CLAUDE_TOOL_NAME:-}"
13
+ # 从 stdin 读取 JSON 数据(Claude Code Hook API 通过 stdin 传递事件数据)
14
+ _STDIN_INPUT=$(cat 2>/dev/null) || _STDIN_INPUT=""
15
+ if [ -z "$_STDIN_INPUT" ]; then
16
+ exit 0
17
+ fi
18
+
19
+ # 解析 stdin JSON 字段
20
+ if command -v jq > /dev/null 2>&1; then
21
+ tool_name=$(echo "$_STDIN_INPUT" | jq -r '.tool_name // empty' 2>/dev/null) || tool_name=""
22
+ tool_result=$(echo "$_STDIN_INPUT" | jq -r '(.tool_output // empty) | if type == "object" then tostring else . end' 2>/dev/null) || tool_result=""
23
+ else
24
+ tool_name=$(echo "$_STDIN_INPUT" | grep -o '"tool_name"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"tool_name"[[:space:]]*:[[:space:]]*"\([^"]*\)"/\1/' 2>/dev/null) || tool_name=""
25
+ tool_result=$(echo "$_STDIN_INPUT" | grep -o '"tool_output"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"tool_output"[[:space:]]*:[[:space:]]*"\([^"]*\)"/\1/' 2>/dev/null) || tool_result=""
26
+ fi
16
27
 
17
28
  # 如果没有结果,直接退出
18
29
  if [ -z "$tool_result" ]; then
@@ -151,8 +151,23 @@ if ! check_tmux; then
151
151
  exit 0
152
152
  fi
153
153
 
154
- # 读取工具输出
155
- tool_output=$(cat)
154
+ # 读取 stdin JSON 数据(Claude Code Hook API 通过 stdin 传递事件数据)
155
+ _stdin_input=$(cat 2>/dev/null) || _stdin_input=""
156
+ if [ -z "$_stdin_input" ]; then
157
+ exit 0
158
+ fi
159
+
160
+ # 解析 tool_output 字段
161
+ if command -v jq > /dev/null 2>&1; then
162
+ tool_output=$(echo "$_stdin_input" | jq -r '.tool_output // empty' 2>/dev/null) || tool_output=""
163
+ else
164
+ tool_output=$(echo "$_stdin_input" | grep -o '"tool_output"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"tool_output"[[:space:]]*:[[:space:]]*"\([^"]*\)"/\1/' 2>/dev/null) || tool_output=""
165
+ fi
166
+
167
+ # 如果 tool_output 为空,尝试使用整个 stdin(兼容旧格式)
168
+ if [ -z "$tool_output" ]; then
169
+ tool_output="$_stdin_input"
170
+ fi
156
171
 
157
172
  # 检测是否是后台任务启动
158
173
  if echo "$tool_output" | grep -qE 'run_in_background.*true|background.*task.*started'; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-pangu",
3
- "version": "2.2.21",
3
+ "version": "2.2.22",
4
4
  "description": "基于中国传统文化的 Claude Code 智能编排插件 - A Claude Code plugin inspired by Chinese traditional culture (原名 oh-my-claude)",
5
5
  "keywords": [
6
6
  "claude-code",