agentvibes 5.6.0 → 5.6.2

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 (101) hide show
  1. package/.agentvibes/config.json +3 -38
  2. package/.claude/config/audio-effects.cfg +1 -1
  3. package/.claude/config/background-music-enabled.txt +1 -1
  4. package/.claude/config/background-music-position.txt +6 -6
  5. package/.claude/github-star-reminder.txt +1 -1
  6. package/.claude/hooks/play-tts-ssh-remote.sh +119 -42
  7. package/.claude/hooks/play-tts-windows-receiver.sh +31 -0
  8. package/.claude/hooks/stop.sh +2 -27
  9. package/.claude/hooks-windows/play-tts-windows-sapi.ps1 +108 -108
  10. package/.claude/hooks-windows/play-tts.ps1 +58 -8
  11. package/.claude/piper-voices-dir.txt +1 -1
  12. package/.clawdbot/skill/README.md +326 -0
  13. package/.mcp.json +17 -27
  14. package/README.md +15 -2
  15. package/RELEASE_NOTES.md +64 -0
  16. package/bin/agent-vibes +39 -39
  17. package/package.json +1 -1
  18. package/src/bmad-detector.js +71 -71
  19. package/src/cli/list-personalities.js +110 -110
  20. package/src/cli/list-voices.js +114 -114
  21. package/src/commands/bmad-voices.js +394 -394
  22. package/src/commands/install-mcp.js +476 -476
  23. package/src/console/brand-colors.js +13 -13
  24. package/src/console/constants/personalities.js +44 -44
  25. package/src/console/modals/modal-overlay.js +247 -247
  26. package/src/console/navigation.js +5 -1
  27. package/src/console/tabs/agents-tab.js +5 -5
  28. package/src/console/tabs/help-tab.js +314 -314
  29. package/src/console/tabs/readme-tab.js +272 -272
  30. package/src/console/tabs/setup-tab.js +32 -17
  31. package/src/console/tabs/voices-tab.js +2 -2
  32. package/src/console/widgets/destroy-list.js +25 -25
  33. package/src/console/widgets/notice.js +55 -55
  34. package/src/console/widgets/personality-picker.js +213 -213
  35. package/src/console/widgets/reverb-picker.js +97 -97
  36. package/src/console/widgets/track-picker.js +1 -1
  37. package/src/i18n/de.js +202 -202
  38. package/src/i18n/es.js +202 -202
  39. package/src/i18n/fr.js +202 -202
  40. package/src/i18n/hi.js +202 -202
  41. package/src/i18n/ja.js +202 -202
  42. package/src/i18n/ko.js +202 -202
  43. package/src/i18n/pt.js +202 -202
  44. package/src/i18n/strings.js +54 -54
  45. package/src/i18n/zh-CN.js +202 -202
  46. package/src/installer/language-screen.js +31 -31
  47. package/src/installer/music-file-input.js +304 -304
  48. package/src/services/agent-voice-store.js +420 -423
  49. package/src/services/config-service.js +264 -264
  50. package/src/services/language-service.js +47 -47
  51. package/src/services/llm-provider-service.js +11 -4
  52. package/src/services/navigation-service.js +34 -10
  53. package/src/services/provider-service.js +143 -143
  54. package/src/utils/audio-duration-validator.js +298 -298
  55. package/src/utils/audio-format-validator.js +277 -277
  56. package/src/utils/dependency-checker.js +469 -469
  57. package/src/utils/file-ownership-verifier.js +358 -358
  58. package/src/utils/list-formatter.js +194 -194
  59. package/src/utils/music-file-validator.js +285 -285
  60. package/src/utils/preview-list-prompt.js +136 -136
  61. package/src/utils/secure-music-storage.js +412 -412
  62. package/.agentvibes/LITE-MODE.md +0 -236
  63. package/.agentvibes/README.md +0 -136
  64. package/.agentvibes/backup/session-start-tts.sh.20251210_212814 +0 -141
  65. package/.agentvibes/backups/agents/analyst_20260204_144958.md +0 -78
  66. package/.agentvibes/backups/agents/architect_20260204_144958.md +0 -72
  67. package/.agentvibes/backups/agents/dev_20260204_144958.md +0 -74
  68. package/.agentvibes/backups/agents/pm_20260204_144958.md +0 -72
  69. package/.agentvibes/backups/agents/quick-flow-solo-dev_20260204_144958.md +0 -64
  70. package/.agentvibes/backups/agents/sm_20260204_144958.md +0 -87
  71. package/.agentvibes/backups/agents/tea_20260204_144958.md +0 -79
  72. package/.agentvibes/backups/agents/tech-writer_20260204_144958.md +0 -82
  73. package/.agentvibes/backups/agents/ux-designer_20260204_144958.md +0 -80
  74. package/.agentvibes/config/README-personality-defaults.md +0 -162
  75. package/.agentvibes/config/agentvibes.json +0 -1
  76. package/.agentvibes/config/mode.txt +0 -1
  77. package/.agentvibes/config/personality-voice-defaults.default.json +0 -21
  78. package/.agentvibes/config/save-audio.txt +0 -1
  79. package/.agentvibes/config/voice-metadata.json +0 -160
  80. package/.agentvibes/hooks/help.sh +0 -191
  81. package/.agentvibes/hooks/post-tool-use-lite.sh +0 -111
  82. package/.agentvibes/hooks/save-audio-manager.sh +0 -162
  83. package/.agentvibes/hooks/session-start-full-optimized.sh +0 -102
  84. package/.agentvibes/hooks/session-start-full.sh +0 -142
  85. package/.agentvibes/hooks/session-start-lite-v2.sh +0 -34
  86. package/.agentvibes/hooks/session-start-lite.sh +0 -29
  87. package/.agentvibes/hooks/stop-lite.sh +0 -115
  88. package/.agentvibes/hooks/switch-mode.sh +0 -215
  89. package/.agentvibes/output-styles/audio-summary.md +0 -30
  90. package/.claude/audio/voice-samples/piper/alan.wav +0 -0
  91. package/.claude/audio/voice-samples/piper/amy.wav +0 -0
  92. package/.claude/audio/voice-samples/piper/charlotte.wav +0 -0
  93. package/.claude/audio/voice-samples/piper/joe.wav +0 -0
  94. package/.claude/audio/voice-samples/piper/john.wav +0 -0
  95. package/.claude/audio/voice-samples/piper/katherine.wav +0 -0
  96. package/.claude/audio/voice-samples/piper/kristin.wav +0 -0
  97. package/.claude/audio/voice-samples/piper/linda.wav +0 -0
  98. package/.claude/audio/voice-samples/piper/marcus.wav +0 -0
  99. package/.claude/audio/voice-samples/piper/ryan.wav +0 -0
  100. package/.claude/hooks/post-response.sh +0 -41
  101. package/bin/ensure-soprano-running.sh +0 -43
@@ -1,162 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # File: .agentvibes/hooks/save-audio-manager.sh
4
- #
5
- # AgentVibes Save Audio Manager
6
- # Configures whether TTS audio files are saved to disk or use temp files
7
- #
8
-
9
- set -euo pipefail
10
-
11
- # Fix locale warnings
12
- export LC_ALL=C
13
-
14
- # Directories
15
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
- AGENTVIBES_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
17
- CONFIG_DIR="$AGENTVIBES_DIR/config"
18
- SAVE_AUDIO_FILE="$CONFIG_DIR/save-audio.txt"
19
-
20
- # Colors for output
21
- RED='\033[0;31m'
22
- GREEN='\033[0;32m'
23
- YELLOW='\033[1;33m'
24
- BLUE='\033[0;34m'
25
- NC='\033[0m' # No Color
26
-
27
- # Functions
28
- print_info() {
29
- echo -e "${BLUE}ℹ${NC} $1"
30
- }
31
-
32
- print_success() {
33
- echo -e "${GREEN}✓${NC} $1"
34
- }
35
-
36
- print_warning() {
37
- echo -e "${YELLOW}⚠${NC} $1"
38
- }
39
-
40
- print_error() {
41
- echo -e "${RED}✗${NC} $1"
42
- }
43
-
44
- # Ensure directories exist
45
- ensure_dirs() {
46
- mkdir -p "$CONFIG_DIR"
47
- }
48
-
49
- # Get current setting
50
- get_save_audio_status() {
51
- if [[ -f "$SAVE_AUDIO_FILE" ]]; then
52
- cat "$SAVE_AUDIO_FILE"
53
- else
54
- echo "false"
55
- fi
56
- }
57
-
58
- # Show current status
59
- show_status() {
60
- local current_status=$(get_save_audio_status)
61
- echo ""
62
- echo "═══════════════════════════════════════════"
63
- echo " AgentVibes Audio Save Setting"
64
- echo "═══════════════════════════════════════════"
65
- echo ""
66
-
67
- if [[ "$current_status" == "true" ]]; then
68
- echo -e "${GREEN}●${NC} SAVE AUDIO: ON"
69
- echo " - Audio files saved to .claude/audio/"
70
- echo " - Files persist after playback"
71
- echo " - Useful for: debugging, archiving, replay"
72
- echo ""
73
- echo "○ SAVE AUDIO: OFF (temporary files)"
74
- else
75
- echo "○ SAVE AUDIO: ON (persistent files)"
76
- echo ""
77
- echo -e "${GREEN}●${NC} SAVE AUDIO: OFF (Default)"
78
- echo " - Audio uses temporary files"
79
- echo " - Files cleaned up after playback"
80
- echo " - Saves disk space"
81
- fi
82
-
83
- echo ""
84
- echo "═══════════════════════════════════════════"
85
- echo ""
86
- echo "Change setting: /agent-vibes:save-audio [on|off]"
87
- echo ""
88
- }
89
-
90
- # Enable save audio
91
- enable_save_audio() {
92
- ensure_dirs
93
- echo "true" > "$SAVE_AUDIO_FILE"
94
-
95
- echo ""
96
- echo "═══════════════════════════════════════════"
97
- print_success "Audio file saving ENABLED"
98
- echo "═══════════════════════════════════════════"
99
- echo ""
100
- echo "Audio files will be saved to:"
101
- echo " .claude/audio/tts-{timestamp}.wav"
102
- echo ""
103
- echo "Benefits:"
104
- echo " ✓ Persistent audio files for replay"
105
- echo " ✓ Useful for debugging TTS output"
106
- echo " ✓ Build audio archives/logs"
107
- echo ""
108
- echo "Note: Files will accumulate - consider periodic cleanup"
109
- echo ""
110
- }
111
-
112
- # Disable save audio
113
- disable_save_audio() {
114
- ensure_dirs
115
- echo "false" > "$SAVE_AUDIO_FILE"
116
-
117
- echo ""
118
- echo "═══════════════════════════════════════════"
119
- print_success "Audio file saving DISABLED"
120
- echo "═══════════════════════════════════════════"
121
- echo ""
122
- echo "Audio files will use temporary storage:"
123
- echo " - Lite Mode: /tmp/agentvibes-lite-*.wav"
124
- echo " - Full Mode: \$XDG_RUNTIME_DIR/agentvibes-tts/*.wav"
125
- echo ""
126
- echo "Benefits:"
127
- echo " ✓ Automatic cleanup after playback"
128
- echo " ✓ Saves disk space"
129
- echo " ✓ No manual file management needed"
130
- echo ""
131
- }
132
-
133
- # Main
134
- main() {
135
- local command="${1:-}"
136
-
137
- case "$command" in
138
- on|enable|true)
139
- enable_save_audio
140
- ;;
141
- off|disable|false)
142
- disable_save_audio
143
- ;;
144
- status|"")
145
- show_status
146
- ;;
147
- *)
148
- print_error "Unknown command: $command"
149
- echo ""
150
- echo "Usage: $0 [on|off|status]"
151
- echo ""
152
- echo "Commands:"
153
- echo " on - Enable audio file saving"
154
- echo " off - Disable audio file saving (default)"
155
- echo " status - Show current setting"
156
- echo ""
157
- exit 1
158
- ;;
159
- esac
160
- }
161
-
162
- main "$@"
@@ -1,102 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- #
4
- # File: .agentvibes/hooks/session-start-full-optimized.sh
5
- #
6
- # AgentVibes Full Mode - Optimized (Issue #73)
7
- # Token target: ~250 (down from ~500)
8
- #
9
-
10
- # Fix locale warnings
11
- export LC_ALL=C
12
-
13
- # Get script directory and project root
14
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
- PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
16
-
17
- # Check if AgentVibes is installed (skip in test mode)
18
- if [[ -z "${AGENTVIBES_TEST_MODE:-}" ]] && [[ ! -f "$PROJECT_ROOT/.claude/hooks/play-tts.sh" ]]; then
19
- exit 0
20
- fi
21
-
22
- # Get current settings
23
- VERBOSITY=$(cat .claude/tts-verbosity.txt 2>/dev/null || cat ~/.claude/tts-verbosity.txt 2>/dev/null || echo "medium")
24
- SENTIMENT=$(cat .claude/tts-sentiment.txt 2>/dev/null || cat ~/.claude/tts-sentiment.txt 2>/dev/null || echo "")
25
- PERSONALITY=$(cat .claude/tts-personality.txt 2>/dev/null || cat ~/.claude/tts-personality.txt 2>/dev/null || echo "professional")
26
-
27
- # Determine style
28
- if [[ -n "$SENTIMENT" ]]; then
29
- STYLE="$SENTIMENT"
30
- else
31
- STYLE="$PERSONALITY"
32
- fi
33
-
34
- # Output optimized protocol
35
- cat << 'EOF'
36
- # AgentVibes Full Mode
37
-
38
- ## Dual TTS (REQUIRED)
39
- **Execute at TWO points:**
40
- 1. **Acknowledgment** - Start of task: `Bash: .claude/hooks/play-tts.sh "[action]"`
41
- 2. **Completion** - End of task: `Bash: .claude/hooks/play-tts.sh "[result + key details]"`
42
-
43
- **Example:**
44
- ```
45
- [Bash: .claude/hooks/play-tts.sh "Creating auth module"]
46
- [work...]
47
- [Bash: .claude/hooks/play-tts.sh "Auth module created with JWT and bcrypt"]
48
- ```
49
-
50
- EOF
51
-
52
- # Conditional verbosity (only active level)
53
- case "$VERBOSITY" in
54
- low)
55
- cat << 'EOF'
56
- ## Verbosity: LOW
57
- - Acknowledgment: Action only
58
- - Completion: Result + errors only
59
- - Skip: Reasoning, decisions
60
-
61
- EOF
62
- ;;
63
-
64
- high)
65
- cat << 'EOF'
66
- ## Verbosity: HIGH
67
- - Acknowledgment: Action + approach + why
68
- - Completion: Result + decisions + trade-offs
69
- - Include: Full reasoning, alternatives
70
-
71
- EOF
72
- ;;
73
-
74
- *) # medium
75
- cat << 'EOF'
76
- ## Verbosity: MEDIUM
77
- - Acknowledgment: Action + key approach
78
- - Completion: Result + important decisions
79
- - Include: Major choices only
80
-
81
- EOF
82
- ;;
83
- esac
84
-
85
- # Style info
86
- cat << EOF
87
- ## Style: $STYLE
88
-
89
- EOF
90
-
91
- # Quick reference
92
- cat << 'EOF'
93
- ## Rules
94
- 1. Never skip acknowledgment TTS
95
- 2. Never skip completion TTS
96
- 3. Match verbosity level
97
- 4. Keep under 150 chars
98
- 5. Always include errors
99
-
100
- Quick Ref: low=endpoints | medium=+decisions | high=+reasoning
101
-
102
- EOF
@@ -1,142 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # File: .claude/hooks/session-start-tts.sh
4
- #
5
- # AgentVibes SessionStart Hook - Injects TTS Protocol Instructions
6
- #
7
- # This hook outputs TTS protocol instructions to stdout, which Claude Code
8
- # adds to the conversation context at session start.
9
- #
10
-
11
- # Fix locale warnings
12
- export LC_ALL=C
13
-
14
- # Get script directory and project root
15
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
- PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
17
-
18
- # Check if AgentVibes is installed
19
- if [[ ! -f "$PROJECT_ROOT/.claude/hooks/play-tts.sh" ]]; then
20
- # AgentVibes not installed, don't inject anything
21
- exit 0
22
- fi
23
-
24
- # Check for sentiment (priority) or personality (fallback)
25
- SENTIMENT=$(cat .claude/tts-sentiment.txt 2>/dev/null || cat ~/.claude/tts-sentiment.txt 2>/dev/null || echo "")
26
- PERSONALITY=$(cat .claude/tts-personality.txt 2>/dev/null || cat ~/.claude/tts-personality.txt 2>/dev/null || echo "normal")
27
-
28
- # Determine which to use
29
- if [[ -n "$SENTIMENT" ]]; then
30
- STYLE_MODE="sentiment"
31
- STYLE_NAME="$SENTIMENT"
32
- else
33
- STYLE_MODE="personality"
34
- STYLE_NAME="$PERSONALITY"
35
- fi
36
-
37
- # Get verbosity level (Issue #32)
38
- VERBOSITY=$(cat .claude/tts-verbosity.txt 2>/dev/null || cat ~/.claude/tts-verbosity.txt 2>/dev/null || echo "low")
39
-
40
- # Output TTS protocol instructions to stdout
41
- # Claude Code will add this to the conversation context
42
- cat <<'EOF'
43
-
44
- # AgentVibes TTS Protocol
45
-
46
- **CRITICAL: You MUST execute TTS at TWO points for EVERY user interaction:**
47
-
48
- ## 1. ACKNOWLEDGMENT (Start of Every Task)
49
- Immediately after receiving ANY user message:
50
- 1. Generate a brief, unique acknowledgment message
51
- 2. Execute: `Bash: .claude/hooks/play-tts.sh "[your message]"`
52
- 3. Then proceed with the work
53
-
54
- ## 2. COMPLETION (End of Every Task)
55
- After finishing the task:
56
- 1. Generate a brief, unique completion message
57
- 2. Execute: `Bash: .claude/hooks/play-tts.sh "[your message]"`
58
-
59
- ## Rules
60
- - Use Bash tool to execute play-tts.sh
61
- - Keep messages under 150 characters
62
- - Generate unique messages each time
63
- - Use relative path: .claude/hooks/play-tts.sh
64
- - This is NOT optional - follow for EVERY interaction
65
-
66
- ## Example
67
- ```
68
- User: "check git status"
69
- [Bash: .claude/hooks/play-tts.sh "I'll check that for you."]
70
- [... do work ...]
71
- [Bash: .claude/hooks/play-tts.sh "Done! All clean."]
72
- ```
73
-
74
- EOF
75
-
76
- # Add verbosity-specific protocol (Issue #32)
77
- case "$VERBOSITY" in
78
- low)
79
- cat <<'EOF'
80
- ## Verbosity: LOW (Minimal)
81
- - Speak only at acknowledgment (start) and completion (end)
82
- - Do NOT speak reasoning, decisions, or findings during work
83
- - Keep it quiet and focused
84
-
85
- EOF
86
- ;;
87
-
88
- medium)
89
- cat <<'EOF'
90
- ## Verbosity: MEDIUM (Balanced)
91
- - Speak at acknowledgment and completion (always)
92
- - Also speak major decisions and key findings during work
93
- - Use emoji markers for automatic TTS:
94
- 🤔 [decision text] - Major decisions (e.g., "🤔 I'll use grep to search all files")
95
- ✓ [finding text] - Key findings (e.g., "✓ Found 12 instances at line 1323")
96
-
97
- Example:
98
- ```
99
- User: "Find all TODO comments"
100
- [TTS: Acknowledgment]
101
- 🤔 I'll use grep to search for TODO comments
102
- [Work happens...]
103
- ✓ Found 12 TODO comments across 5 files
104
- [TTS: Completion]
105
- ```
106
-
107
- EOF
108
- ;;
109
-
110
- high)
111
- cat <<'EOF'
112
- ## Verbosity: HIGH (Maximum Transparency)
113
- - Speak acknowledgment and completion (always)
114
- - Speak ALL reasoning, decisions, and findings as you work
115
- - Use emoji markers for automatic TTS:
116
- 💭 [reasoning text] - Thought process (e.g., "💭 Let me search for all instances")
117
- 🤔 [decision text] - Decisions (e.g., "🤔 I'll use grep for this")
118
- ✓ [finding text] - Findings (e.g., "✓ Found it at line 1323")
119
-
120
- Example:
121
- ```
122
- User: "Find all TODO comments"
123
- [TTS: Acknowledgment]
124
- 💭 Let me search through the codebase for TODO comments
125
- 🤔 I'll use the Grep tool with pattern "TODO"
126
- [Grep runs...]
127
- ✓ Found 12 TODO comments across 5 files
128
- 💭 Let me organize these results by file
129
- [Processing...]
130
- [TTS: Completion]
131
- ```
132
-
133
- IMPORTANT: Use emoji markers naturally in your reasoning text. They trigger automatic TTS.
134
-
135
- EOF
136
- ;;
137
- esac
138
-
139
- # Add current style and verbosity info
140
- echo "Current Style: ${STYLE_NAME} (${STYLE_MODE})"
141
- echo "Current Verbosity: ${VERBOSITY}"
142
- echo ""
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # File: .agentvibes/hooks/session-start-lite-v2.sh
4
- #
5
- # AgentVibes LITE MODE v2 - Minimal Full Mode Architecture
6
- # Uses working tool-call approach with minimal token overhead
7
- #
8
-
9
- # Fix locale warnings
10
- export LC_ALL=C
11
-
12
- # Set lite mode environment variable to skip file saving
13
- export AGENTVIBES_LITE_MODE=true
14
-
15
- # Output minimal TTS protocol to stdout
16
- cat <<'EOF'
17
-
18
- # AgentVibes Lite Mode
19
-
20
- **At the END of your response, execute ONE TTS call:**
21
-
22
- `Bash: .claude/hooks/play-tts.sh "[brief summary of what you accomplished]"`
23
-
24
- **Rules:**
25
- - Only ONE TTS at completion (no acknowledgment)
26
- - Keep message under 100 characters
27
- - Summarize what you did, not how you did it
28
- - Examples:
29
- - "Fixed authentication bug in login.js"
30
- - "Found 12 TODO comments across 5 files"
31
- - "Created new user registration endpoint"
32
- - "Updated configuration and restarted service"
33
-
34
- EOF
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # File: .agentvibes/hooks/session-start-lite.sh
4
- #
5
- # AgentVibes LITE MODE SessionStart Hook
6
- # Minimal token overhead (~50 tokens vs ~500 in full mode)
7
- #
8
-
9
- # Fix locale warnings
10
- export LC_ALL=C
11
-
12
- # Get script directory
13
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
-
15
- # Check if AgentVibes is installed
16
- if [[ ! -f "$SCRIPT_DIR/../../.claude/hooks/play-tts.sh" ]]; then
17
- exit 0
18
- fi
19
-
20
- # Minimal protocol - just instruct to use output style marker
21
- cat <<'EOF'
22
- # AgentVibes Lite Mode
23
-
24
- **At the end of EVERY response, add:**
25
-
26
- **Audio Summary:** [Brief 1-sentence summary of what you accomplished]
27
-
28
- This will be spoken automatically via TTS.
29
- EOF
@@ -1,115 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # File: .agentvibes/hooks/stop-lite.sh
4
- #
5
- # AgentVibes LITE MODE Stop Hook
6
- # Extracts "Audio Summary:" marker from transcript and speaks it via TTS
7
- # - Smart verbosity (skip for very short responses)
8
- # - No .wav file saving (direct TTS)
9
- # - Silent operation (no stdout)
10
- #
11
-
12
- set -euo pipefail
13
-
14
- # Fix locale warnings
15
- export LC_ALL=C
16
-
17
- # Read token thresholds
18
- MIN_TOKENS=${AGENTVIBES_MIN_TOKENS:-50} # Skip TTS below this
19
- SHORT_TOKENS=${AGENTVIBES_SHORT_TOKENS:-200} # Simplify to "Done" below this
20
-
21
- # Function to count approximate tokens (words)
22
- count_tokens() {
23
- echo "$1" | wc -w
24
- }
25
-
26
- # Function to extract Audio Summary from transcript
27
- extract_audio_summary() {
28
- local transcript_path="$1"
29
-
30
- # Check if transcript exists
31
- [[ ! -f "$transcript_path" ]] && return 1
32
-
33
- # Get last assistant message from transcript
34
- local last_response=$(jq -r '
35
- [.[] | select(.role == "assistant") | .content[]? | select(.type == "text") | .text] | .[-1] // ""
36
- ' "$transcript_path" 2>/dev/null || echo "")
37
-
38
- [[ -z "$last_response" ]] && return 1
39
-
40
- # Look for "**Audio Summary:**" marker (case-insensitive)
41
- if echo "$last_response" | grep -qi "Audio Summary:"; then
42
- # Extract text after the marker, trim whitespace
43
- echo "$last_response" | sed -n 's/.*[Aa]udio [Ss]ummary:[[:space:]]*\(.*\)/\1/p' | head -1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'
44
- return 0
45
- fi
46
-
47
- return 1
48
- }
49
-
50
- # Function to play TTS (direct, no file saving)
51
- play_tts() {
52
- local text="$1"
53
-
54
- # Get TTS configuration
55
- local config_dir=".agentvibes/config"
56
- local provider="piper"
57
- local voice=""
58
-
59
- if [[ -f "$config_dir/provider.txt" ]]; then
60
- provider=$(cat "$config_dir/provider.txt" 2>/dev/null | tr -d '[:space:]')
61
- fi
62
-
63
- if [[ -f "$config_dir/voice.txt" ]]; then
64
- voice=$(cat "$config_dir/voice.txt" 2>/dev/null | tr -d '[:space:]')
65
- fi
66
-
67
- # Use AgentVibes play-tts.sh for consistent TTS
68
- if [[ -f ".claude/hooks/play-tts.sh" ]]; then
69
- bash .claude/hooks/play-tts.sh "$text" >/dev/null 2>&1 &
70
- fi
71
- }
72
-
73
- # Main logic
74
- main() {
75
- # Get transcript path from hook input (passed as JSON on stdin or as argument)
76
- local transcript_path=""
77
-
78
- if [[ -n "${1:-}" ]]; then
79
- # Try to parse as JSON first
80
- transcript_path=$(echo "$1" | jq -r '.transcript_path // empty' 2>/dev/null || echo "")
81
- fi
82
-
83
- # If not found, try reading from stdin
84
- if [[ -z "$transcript_path" ]] && [[ -p /dev/stdin ]]; then
85
- local input=$(cat)
86
- transcript_path=$(echo "$input" | jq -r '.transcript_path // empty' 2>/dev/null || echo "")
87
- fi
88
-
89
- # If still no transcript path, exit
90
- [[ -z "$transcript_path" ]] && exit 0
91
-
92
- # Extract Audio Summary
93
- local summary=$(extract_audio_summary "$transcript_path")
94
-
95
- # If no Audio Summary marker found, exit silently
96
- [[ -z "$summary" ]] && exit 0
97
-
98
- # Count tokens in summary
99
- local token_count=$(count_tokens "$summary")
100
-
101
- # Skip TTS for very short summaries
102
- [[ $token_count -lt $MIN_TOKENS ]] && exit 0
103
-
104
- # For short responses, simplify to "Done"
105
- if [[ $token_count -lt $SHORT_TOKENS ]]; then
106
- summary="Done"
107
- fi
108
-
109
- # Play TTS in background
110
- play_tts "$summary"
111
-
112
- exit 0
113
- }
114
-
115
- main "$@"