aico-cli 0.3.14 → 0.3.15

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.
@@ -13,7 +13,7 @@ import { join as join$1 } from 'node:path';
13
13
  import { join, dirname, basename } from 'pathe';
14
14
  import { fileURLToPath } from 'node:url';
15
15
 
16
- const version = "0.3.14";
16
+ const version = "0.3.15";
17
17
 
18
18
  function displayBanner(subtitle) {
19
19
  const defaultSubtitle = "\u4E00\u952E\u914D\u7F6E\u4F60\u7684\u5F00\u53D1\u73AF\u5883";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aico-cli",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "packageManager": "pnpm@9.15.9",
5
5
  "description": "AI CLI",
6
6
  "repository": {
@@ -212,10 +212,36 @@ execute_hook "pre" "requirement-identifier" "自定义参数"
212
212
  # 测试语音提醒脚本
213
213
  ~/.claude/hooks/notify.sh input
214
214
  ~/.claude/hooks/notify.sh complete
215
+
216
+ # 查看调试日志(如果有问题)
217
+ tail -f ~/.claude/hooks/notify.log
215
218
  ```
216
219
 
220
+ **调试功能:**
221
+
222
+ 脚本包含详细的调试日志功能,记录到 `~/.claude/hooks/notify.log`:
223
+ - Hook调用时间和参数
224
+ - 使用的音频播放器
225
+ - 声音文件播放状态
226
+ - 错误信息和排查提示
227
+
217
228
  **重启 Claude Code** 使配置生效。
218
229
 
230
+ **日志管理:**
231
+
232
+ ```bash
233
+ # 查看最新日志
234
+ tail -10 ~/.claude/hooks/notify.log
235
+
236
+ # 清空日志文件
237
+ > ~/.claude/hooks/notify.log
238
+
239
+ # 删除日志文件
240
+ rm ~/.claude/hooks/notify.log
241
+ ```
242
+
243
+ **注意:** 如果语音提醒功能工作正常,可以定期清理日志文件以节省存储空间。
244
+
219
245
  ## 🔧 扩展开发
220
246
 
221
247
  ### 添加新的 Hook
@@ -2,60 +2,75 @@
2
2
  # Claude Code notification hook script
3
3
  # Plays pleasant sounds when Claude needs input or completes tasks
4
4
 
5
+ # Debug logging
6
+ LOG_FILE="$HOME/.claude/hooks/notify.log"
7
+ echo "$(date): notify.sh called with args: $@" >> "$LOG_FILE"
8
+
5
9
  # Get the directory where this script is located
6
10
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
11
  SOUNDS_DIR="$SCRIPT_DIR/sounds"
12
+ echo "Script directory: $SCRIPT_DIR" >> "$LOG_FILE"
13
+ echo "Sounds directory: $SOUNDS_DIR" >> "$LOG_FILE"
8
14
 
9
15
  # Function to play a sound file with cross-platform support
10
16
  play_sound_file() {
11
17
  local sound_file="$1"
12
-
18
+
13
19
  # Check if file exists
14
20
  if [[ ! -f "$sound_file" ]]; then
15
21
  echo "Warning: Sound file not found: $sound_file" >&2
22
+ echo "Warning: Sound file not found: $sound_file" >> "$LOG_FILE"
16
23
  return 1
17
24
  fi
18
-
25
+
26
+ echo "Playing sound: $sound_file" >> "$LOG_FILE"
27
+
19
28
  # Detect OS and use appropriate command-line audio player
20
29
  local os_type="$(uname -s)"
21
-
30
+
22
31
  case "$os_type" in
23
32
  Darwin*) # macOS
24
33
  if command -v afplay &> /dev/null; then
34
+ echo "Using afplay to play: $sound_file" >> "$LOG_FILE"
25
35
  afplay "$sound_file" 2>/dev/null &
26
36
  return 0 # Exit immediately after starting playback
27
37
  fi
28
38
  ;;
29
-
39
+
30
40
  Linux*) # Linux
31
41
  # Try PulseAudio first (most common on modern desktop Linux)
32
42
  if command -v paplay &> /dev/null; then
43
+ echo "Using paplay to play: $sound_file" >> "$LOG_FILE"
33
44
  paplay "$sound_file" 2>/dev/null &
34
45
  return 0 # Exit immediately after starting playback
35
46
  fi
36
-
47
+
37
48
  # Try ALSA
38
49
  if command -v aplay &> /dev/null; then
50
+ echo "Using aplay to play: $sound_file" >> "$LOG_FILE"
39
51
  aplay -q "$sound_file" 2>/dev/null &
40
52
  return 0 # Exit immediately after starting playback
41
53
  fi
42
-
54
+
43
55
  # Try PipeWire (newer systems)
44
56
  if command -v pw-play &> /dev/null; then
57
+ echo "Using pw-play to play: $sound_file" >> "$LOG_FILE"
45
58
  pw-play "$sound_file" 2>/dev/null &
46
59
  return 0 # Exit immediately after starting playback
47
60
  fi
48
-
61
+
49
62
  # Try sox play command
50
63
  if command -v play &> /dev/null; then
64
+ echo "Using sox play to play: $sound_file" >> "$LOG_FILE"
51
65
  play -q "$sound_file" 2>/dev/null &
52
66
  return 0 # Exit immediately after starting playback
53
67
  fi
54
68
  ;;
55
-
69
+
56
70
  MINGW*|CYGWIN*|MSYS*) # Windows (Git Bash, WSL, etc.)
57
71
  # Try PowerShell
58
72
  if command -v powershell.exe &> /dev/null; then
73
+ echo "Using PowerShell to play: $sound_file" >> "$LOG_FILE"
59
74
  # Use Windows Media Player COM object for better compatibility
60
75
  # Run in background and exit immediately
61
76
  powershell.exe -NoProfile -Command "
@@ -71,31 +86,38 @@ play_sound_file() {
71
86
  fi
72
87
  ;;
73
88
  esac
74
-
89
+
75
90
  # If we have ffplay (cross-platform)
76
91
  if command -v ffplay &> /dev/null; then
92
+ echo "Using ffplay to play: $sound_file" >> "$LOG_FILE"
77
93
  ffplay -nodisp -autoexit -loglevel quiet "$sound_file" 2>/dev/null &
78
94
  return 0 # Exit immediately after starting playback
79
95
  fi
80
-
96
+
81
97
  # No audio player found - fail silently
98
+ echo "No audio player found" >> "$LOG_FILE"
82
99
  return 1
83
100
  }
84
101
 
85
102
  # Main script logic
86
103
  case "$1" in
87
104
  "input")
105
+ echo "Input needed event triggered" >> "$LOG_FILE"
88
106
  play_sound_file "$SOUNDS_DIR/input-needed.wav"
89
107
  ;;
90
-
108
+
91
109
  "complete")
110
+ echo "Complete event triggered" >> "$LOG_FILE"
92
111
  play_sound_file "$SOUNDS_DIR/complete.wav"
93
112
  ;;
94
-
113
+
95
114
  *)
96
115
  echo "Usage: $0 {input|complete}" >&2
116
+ echo "Usage: $0 {input|complete}" >> "$LOG_FILE"
97
117
  echo " input - Play sound when Claude needs user input" >&2
118
+ echo " input - Play sound when Claude needs user input" >> "$LOG_FILE"
98
119
  echo " complete - Play sound when Claude completes tasks" >&2
120
+ echo " complete - Play sound when Claude completes tasks" >> "$LOG_FILE"
99
121
  exit 1
100
122
  ;;
101
123
  esac