agentvibes 2.0.12 → 2.0.13

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 (138) hide show
  1. package/.claude/commands/agent-vibes/bmad.md +0 -7
  2. package/.claude/github-star-reminder.txt +1 -1
  3. package/.claude/hooks/piper-installer.sh +7 -57
  4. package/.claude/hooks/play-tts-piper.sh +2 -10
  5. package/.claude/hooks/play-tts.sh +0 -31
  6. package/README.md +2 -2
  7. package/RELEASE_NOTES.md +0 -199
  8. package/package.json +1 -1
  9. package/src/installer.js +1 -112
  10. package/.claude/hooks/play-tts-local-wrapper.sh +0 -44
  11. package/.claude/hooks/play-tts-remote.sh +0 -81
  12. package/agentvibes.org/.claude/commands/agent-vibes/add.md +0 -21
  13. package/agentvibes.org/.claude/commands/agent-vibes/agent-vibes.md +0 -68
  14. package/agentvibes.org/.claude/commands/agent-vibes/commands.json +0 -53
  15. package/agentvibes.org/.claude/commands/agent-vibes/get.md +0 -9
  16. package/agentvibes.org/.claude/commands/agent-vibes/list.md +0 -13
  17. package/agentvibes.org/.claude/commands/agent-vibes/personality.md +0 -79
  18. package/agentvibes.org/.claude/commands/agent-vibes/preview.md +0 -16
  19. package/agentvibes.org/.claude/commands/agent-vibes/provider.md +0 -54
  20. package/agentvibes.org/.claude/commands/agent-vibes/replay.md +0 -19
  21. package/agentvibes.org/.claude/commands/agent-vibes/sample.md +0 -12
  22. package/agentvibes.org/.claude/commands/agent-vibes/sentiment.md +0 -52
  23. package/agentvibes.org/.claude/commands/agent-vibes/set-language.md +0 -47
  24. package/agentvibes.org/.claude/commands/agent-vibes/set-pretext.md +0 -65
  25. package/agentvibes.org/.claude/commands/agent-vibes/switch.md +0 -53
  26. package/agentvibes.org/.claude/commands/agent-vibes/update.md +0 -20
  27. package/agentvibes.org/.claude/commands/agent-vibes/version.md +0 -10
  28. package/agentvibes.org/.claude/commands/agent-vibes/whoami.md +0 -7
  29. package/agentvibes.org/.claude/hooks/bmad-voice-manager.sh +0 -278
  30. package/agentvibes.org/.claude/hooks/language-manager.sh +0 -190
  31. package/agentvibes.org/.claude/hooks/personality-manager.sh +0 -279
  32. package/agentvibes.org/.claude/hooks/piper-download-voices.sh +0 -133
  33. package/agentvibes.org/.claude/hooks/piper-voice-manager.sh +0 -227
  34. package/agentvibes.org/.claude/hooks/play-tts-elevenlabs.sh +0 -201
  35. package/agentvibes.org/.claude/hooks/play-tts-piper.sh +0 -175
  36. package/agentvibes.org/.claude/hooks/play-tts.sh +0 -138
  37. package/agentvibes.org/.claude/hooks/provider-commands.sh +0 -374
  38. package/agentvibes.org/.claude/hooks/provider-manager.sh +0 -196
  39. package/agentvibes.org/.claude/hooks/sentiment-manager.sh +0 -163
  40. package/agentvibes.org/.claude/hooks/voice-manager.sh +0 -349
  41. package/agentvibes.org/.claude/hooks/voices-config.sh +0 -33
  42. package/agentvibes.org/.claude/journal/2025-10-07.html +0 -373
  43. package/agentvibes.org/.claude/journal/index.html +0 -91
  44. package/agentvibes.org/.claude/output-styles/agent-vibes.md +0 -203
  45. package/agentvibes.org/.claude/personalities/angry.md +0 -16
  46. package/agentvibes.org/.claude/personalities/annoying.md +0 -16
  47. package/agentvibes.org/.claude/personalities/crass.md +0 -16
  48. package/agentvibes.org/.claude/personalities/dramatic.md +0 -16
  49. package/agentvibes.org/.claude/personalities/dry-humor.md +0 -52
  50. package/agentvibes.org/.claude/personalities/flirty.md +0 -22
  51. package/agentvibes.org/.claude/personalities/funny.md +0 -16
  52. package/agentvibes.org/.claude/personalities/grandpa.md +0 -34
  53. package/agentvibes.org/.claude/personalities/millennial.md +0 -16
  54. package/agentvibes.org/.claude/personalities/moody.md +0 -16
  55. package/agentvibes.org/.claude/personalities/normal.md +0 -18
  56. package/agentvibes.org/.claude/personalities/pirate.md +0 -16
  57. package/agentvibes.org/.claude/personalities/poetic.md +0 -16
  58. package/agentvibes.org/.claude/personalities/professional.md +0 -16
  59. package/agentvibes.org/.claude/personalities/robot.md +0 -16
  60. package/agentvibes.org/.claude/personalities/sarcastic.md +0 -40
  61. package/agentvibes.org/.claude/personalities/sassy.md +0 -16
  62. package/agentvibes.org/.claude/personalities/surfer-dude.md +0 -16
  63. package/agentvibes.org/.claude/personalities/zen.md +0 -16
  64. package/agentvibes.org/.mcp-minimal.json +0 -60
  65. package/agentvibes.org/CHANGELOG.md +0 -56
  66. package/agentvibes.org/README.md +0 -93
  67. package/agentvibes.org/app/(auth)/layout.tsx +0 -15
  68. package/agentvibes.org/app/(auth)/reset-password/page.tsx +0 -45
  69. package/agentvibes.org/app/(auth)/signin/page.tsx +0 -82
  70. package/agentvibes.org/app/(auth)/signup/page.tsx +0 -104
  71. package/agentvibes.org/app/(default)/layout.tsx +0 -31
  72. package/agentvibes.org/app/(default)/page.tsx +0 -20
  73. package/agentvibes.org/app/api/hello/route.ts +0 -3
  74. package/agentvibes.org/app/css/additional-styles/theme.css +0 -82
  75. package/agentvibes.org/app/css/additional-styles/utility-patterns.css +0 -55
  76. package/agentvibes.org/app/css/style.css +0 -100
  77. package/agentvibes.org/app/layout.tsx +0 -63
  78. package/agentvibes.org/components/cta.tsx +0 -58
  79. package/agentvibes.org/components/features.tsx +0 -256
  80. package/agentvibes.org/components/hero-home.tsx +0 -133
  81. package/agentvibes.org/components/modal-video.tsx +0 -137
  82. package/agentvibes.org/components/page-illustration.tsx +0 -55
  83. package/agentvibes.org/components/spotlight.tsx +0 -77
  84. package/agentvibes.org/components/testimonials.tsx +0 -282
  85. package/agentvibes.org/components/ui/footer.tsx +0 -82
  86. package/agentvibes.org/components/ui/header.tsx +0 -53
  87. package/agentvibes.org/components/ui/logo.tsx +0 -10
  88. package/agentvibes.org/components/workflows.tsx +0 -176
  89. package/agentvibes.org/next.config.js +0 -4
  90. package/agentvibes.org/package-lock.json +0 -1974
  91. package/agentvibes.org/package.json +0 -30
  92. package/agentvibes.org/pnpm-lock.yaml +0 -1141
  93. package/agentvibes.org/postcss.config.js +0 -5
  94. package/agentvibes.org/public/audio/02-sarcastic.mp3 +0 -0
  95. package/agentvibes.org/public/audio/03-angry.mp3 +0 -0
  96. package/agentvibes.org/public/audio/04-grandpa.mp3 +0 -0
  97. package/agentvibes.org/public/audio/05-sarcastic-example2.mp3 +0 -0
  98. package/agentvibes.org/public/audio/french-rachel.mp3 +0 -0
  99. package/agentvibes.org/public/audio/spanish-antoni.mp3 +0 -0
  100. package/agentvibes.org/public/favicon.ico +0 -0
  101. package/agentvibes.org/public/fonts/nacelle-italic.woff2 +0 -0
  102. package/agentvibes.org/public/fonts/nacelle-regular.woff2 +0 -0
  103. package/agentvibes.org/public/fonts/nacelle-semibold.woff2 +0 -0
  104. package/agentvibes.org/public/fonts/nacelle-semibolditalic.woff2 +0 -0
  105. package/agentvibes.org/public/images/blurred-shape-gray.svg +0 -1
  106. package/agentvibes.org/public/images/blurred-shape.svg +0 -1
  107. package/agentvibes.org/public/images/client-logo-01.svg +0 -1
  108. package/agentvibes.org/public/images/client-logo-02.svg +0 -1
  109. package/agentvibes.org/public/images/client-logo-03.svg +0 -1
  110. package/agentvibes.org/public/images/client-logo-04.svg +0 -1
  111. package/agentvibes.org/public/images/client-logo-05.svg +0 -1
  112. package/agentvibes.org/public/images/client-logo-06.svg +0 -1
  113. package/agentvibes.org/public/images/client-logo-07.svg +0 -1
  114. package/agentvibes.org/public/images/client-logo-08.svg +0 -1
  115. package/agentvibes.org/public/images/client-logo-09.svg +0 -1
  116. package/agentvibes.org/public/images/features.png +0 -0
  117. package/agentvibes.org/public/images/footer-illustration.svg +0 -1
  118. package/agentvibes.org/public/images/hero-image-01.jpg +0 -0
  119. package/agentvibes.org/public/images/logo.svg +0 -1
  120. package/agentvibes.org/public/images/page-illustration.svg +0 -1
  121. package/agentvibes.org/public/images/secondary-illustration.svg +0 -1
  122. package/agentvibes.org/public/images/testimonial-01.jpg +0 -0
  123. package/agentvibes.org/public/images/testimonial-02.jpg +0 -0
  124. package/agentvibes.org/public/images/testimonial-03.jpg +0 -0
  125. package/agentvibes.org/public/images/testimonial-04.jpg +0 -0
  126. package/agentvibes.org/public/images/testimonial-05.jpg +0 -0
  127. package/agentvibes.org/public/images/testimonial-06.jpg +0 -0
  128. package/agentvibes.org/public/images/testimonial-07.jpg +0 -0
  129. package/agentvibes.org/public/images/testimonial-08.jpg +0 -0
  130. package/agentvibes.org/public/images/testimonial-09.jpg +0 -0
  131. package/agentvibes.org/public/images/workflow-01.png +0 -0
  132. package/agentvibes.org/public/images/workflow-02.png +0 -0
  133. package/agentvibes.org/public/images/workflow-03.png +0 -0
  134. package/agentvibes.org/public/videos/video.mp4 +0 -0
  135. package/agentvibes.org/tsconfig.json +0 -28
  136. package/agentvibes.org/utils/useMasonry.tsx +0 -67
  137. package/agentvibes.org/utils/useMousePosition.tsx +0 -27
  138. package/docs/REMOTE_TTS_SETUP.md +0 -190
@@ -1,374 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # @fileoverview Provider management slash commands
4
- # @context User-facing commands for switching and managing TTS providers
5
- # @architecture Part of /agent-vibes:* command system
6
- #
7
-
8
- # Get script directory
9
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
- source "$SCRIPT_DIR/provider-manager.sh"
11
- source "$SCRIPT_DIR/language-manager.sh"
12
-
13
- COMMAND="${1:-help}"
14
-
15
- # @function provider_list
16
- # @intent Display all available providers with status
17
- provider_list() {
18
- local current_provider
19
- current_provider=$(get_active_provider)
20
-
21
- echo "┌────────────────────────────────────────────────────────────┐"
22
- echo "│ Available TTS Providers │"
23
- echo "├────────────────────────────────────────────────────────────┤"
24
-
25
- # ElevenLabs
26
- if [[ "$current_provider" == "elevenlabs" ]]; then
27
- echo "│ ✓ ElevenLabs Premium quality ⭐⭐⭐⭐⭐ [ACTIVE] │"
28
- else
29
- echo "│ ElevenLabs Premium quality ⭐⭐⭐⭐⭐ │"
30
- fi
31
- echo "│ Cost: Free tier + \$5-22/mo │"
32
- echo "│ Platform: All (Windows, macOS, Linux, WSL) │"
33
- echo "│ Offline: No │"
34
- echo "│ │"
35
-
36
- # Piper
37
- if [[ "$current_provider" == "piper" ]]; then
38
- echo "│ ✓ Piper TTS Free, offline ⭐⭐⭐⭐ [ACTIVE] │"
39
- else
40
- echo "│ Piper TTS Free, offline ⭐⭐⭐⭐ │"
41
- fi
42
- echo "│ Cost: Free forever │"
43
- echo "│ Platform: WSL, Linux only │"
44
- echo "│ Offline: Yes │"
45
- echo "└────────────────────────────────────────────────────────────┘"
46
- echo ""
47
- echo "Learn more: agentvibes.org/providers"
48
- }
49
-
50
- # @function provider_switch
51
- # @intent Switch to a different TTS provider
52
- provider_switch() {
53
- local new_provider="$1"
54
-
55
- if [[ -z "$new_provider" ]]; then
56
- echo "❌ Error: Provider name required"
57
- echo "Usage: /agent-vibes:provider switch <provider>"
58
- echo "Available: elevenlabs, piper"
59
- return 1
60
- fi
61
-
62
- # Validate provider
63
- if ! validate_provider "$new_provider"; then
64
- echo "❌ Invalid provider: $new_provider"
65
- echo ""
66
- echo "Available providers:"
67
- list_providers
68
- return 1
69
- fi
70
-
71
- local current_provider
72
- current_provider=$(get_active_provider)
73
-
74
- if [[ "$current_provider" == "$new_provider" ]]; then
75
- echo "✓ Already using $new_provider"
76
- return 0
77
- fi
78
-
79
- # Platform check for Piper
80
- if [[ "$new_provider" == "piper" ]]; then
81
- if ! grep -qi microsoft /proc/version 2>/dev/null && [[ "$(uname -s)" != "Linux" ]]; then
82
- echo "❌ Piper is only supported on WSL and Linux"
83
- echo "Your platform: $(uname -s)"
84
- echo "See: agentvibes.org/platform-support"
85
- return 1
86
- fi
87
-
88
- # Check if Piper is installed
89
- if ! command -v piper &> /dev/null; then
90
- echo "❌ Piper TTS is not installed"
91
- echo ""
92
- echo "Install with: pipx install piper-tts"
93
- echo "Or run: .claude/hooks/piper-installer.sh"
94
- echo ""
95
- echo "Visit: agentvibes.org/install-piper"
96
- return 1
97
- fi
98
- fi
99
-
100
- # Check language compatibility
101
- local current_language
102
- current_language=$(get_current_language)
103
-
104
- if [[ "$current_language" != "english" ]]; then
105
- if ! is_language_supported "$current_language" "$new_provider" 2>/dev/null; then
106
- echo "⚠️ Language Compatibility Warning"
107
- echo ""
108
- echo "Current language: $current_language"
109
- echo "Target provider: $new_provider"
110
- echo ""
111
- echo "❌ Language '$current_language' is not natively supported by $new_provider"
112
- echo " Will fall back to English when using $new_provider"
113
- echo ""
114
- echo "Options:"
115
- echo " 1. Continue anyway (will use English)"
116
- echo " 2. Switch language to English"
117
- echo " 3. Cancel provider switch"
118
- echo ""
119
- read -p "Choose option [1-3]: " -n 1 -r
120
- echo
121
-
122
- case $REPLY in
123
- 1)
124
- echo "⏩ Continuing with fallback to English..."
125
- ;;
126
- 2)
127
- echo "🔄 Switching language to English..."
128
- "$SCRIPT_DIR/language-manager.sh" set english
129
- ;;
130
- 3)
131
- echo "❌ Provider switch cancelled"
132
- return 1
133
- ;;
134
- *)
135
- echo "❌ Invalid option, cancelling"
136
- return 1
137
- ;;
138
- esac
139
- fi
140
- fi
141
-
142
- # Confirm switch
143
- echo ""
144
- echo "⚠️ Switch to $(echo $new_provider | tr '[:lower:]' '[:upper:]')?"
145
- echo ""
146
- echo "Current: $current_provider"
147
- echo "New: $new_provider"
148
- if [[ "$current_language" != "english" ]]; then
149
- echo "Language: $current_language"
150
- fi
151
- echo ""
152
- read -p "Continue? [y/N]: " -n 1 -r
153
- echo
154
-
155
- if [[ ! $REPLY =~ ^[Yy]$ ]]; then
156
- echo "❌ Switch cancelled"
157
- return 1
158
- fi
159
-
160
- # Perform switch
161
- set_active_provider "$new_provider"
162
-
163
- # Test new provider
164
- echo ""
165
- echo "🔊 Testing provider..."
166
- "$SCRIPT_DIR/play-tts.sh" "Provider switched to $new_provider successfully" 2>/dev/null
167
-
168
- echo ""
169
- echo "✓ Provider switch complete!"
170
- echo "Visit agentvibes.org for tips and tricks"
171
- }
172
-
173
- # @function provider_info
174
- # @intent Show detailed information about a provider
175
- provider_info() {
176
- local provider_name="$1"
177
-
178
- if [[ -z "$provider_name" ]]; then
179
- echo "❌ Error: Provider name required"
180
- echo "Usage: /agent-vibes:provider info <provider>"
181
- return 1
182
- fi
183
-
184
- case "$provider_name" in
185
- elevenlabs)
186
- echo "┌────────────────────────────────────────────────────────────┐"
187
- echo "│ ElevenLabs - Premium TTS Provider │"
188
- echo "├────────────────────────────────────────────────────────────┤"
189
- echo "│ Quality: ⭐⭐⭐⭐⭐ (Highest available) │"
190
- echo "│ Cost: Free tier + \$5-22/mo │"
191
- echo "│ Platform: All (Windows, macOS, Linux, WSL) │"
192
- echo "│ Offline: No (requires internet) │"
193
- echo "│ │"
194
- echo "│ Trade-offs: │"
195
- echo "│ + Highest voice quality and naturalness │"
196
- echo "│ + 50+ premium voices available │"
197
- echo "│ + Multilingual support (30+ languages) │"
198
- echo "│ - Requires API key and internet │"
199
- echo "│ - Costs money after free tier │"
200
- echo "│ │"
201
- echo "│ Best for: Premium quality, multilingual needs │"
202
- echo "└────────────────────────────────────────────────────────────┘"
203
- echo ""
204
- echo "Full comparison: agentvibes.org/providers"
205
- ;;
206
-
207
- piper)
208
- echo "┌────────────────────────────────────────────────────────────┐"
209
- echo "│ Piper TTS - Free Offline Provider │"
210
- echo "├────────────────────────────────────────────────────────────┤"
211
- echo "│ Quality: ⭐⭐⭐⭐ (Very good) │"
212
- echo "│ Cost: Free forever │"
213
- echo "│ Platform: WSL, Linux only │"
214
- echo "│ Offline: Yes (fully local) │"
215
- echo "│ │"
216
- echo "│ Trade-offs: │"
217
- echo "│ + Completely free, no API costs │"
218
- echo "│ + Works offline, no internet needed │"
219
- echo "│ + Fast synthesis (local processing) │"
220
- echo "│ - WSL/Linux only (no macOS/Windows) │"
221
- echo "│ - Slightly lower quality than ElevenLabs │"
222
- echo "│ │"
223
- echo "│ Best for: Budget-conscious, offline use, privacy │"
224
- echo "└────────────────────────────────────────────────────────────┘"
225
- echo ""
226
- echo "Full comparison: agentvibes.org/providers"
227
- ;;
228
-
229
- *)
230
- echo "❌ Unknown provider: $provider_name"
231
- echo "Available: elevenlabs, piper"
232
- ;;
233
- esac
234
- }
235
-
236
- # @function provider_test
237
- # @intent Test current provider with sample audio
238
- provider_test() {
239
- local current_provider
240
- current_provider=$(get_active_provider)
241
-
242
- echo "🔊 Testing provider: $current_provider"
243
- echo ""
244
-
245
- "$SCRIPT_DIR/play-tts.sh" "Provider test successful. Audio is working correctly with $current_provider."
246
-
247
- echo ""
248
- echo "✓ Test complete"
249
- }
250
-
251
- # @function provider_get
252
- # @intent Show currently active provider
253
- provider_get() {
254
- local current_provider
255
- current_provider=$(get_active_provider)
256
-
257
- echo "🎤 Current Provider: $current_provider"
258
- echo ""
259
-
260
- # Show brief info
261
- case "$current_provider" in
262
- elevenlabs)
263
- echo "Quality: ⭐⭐⭐⭐⭐"
264
- echo "Cost: Free tier + \$5-22/mo"
265
- echo "Offline: No"
266
- ;;
267
- piper)
268
- echo "Quality: ⭐⭐⭐⭐"
269
- echo "Cost: Free forever"
270
- echo "Offline: Yes"
271
- ;;
272
- esac
273
-
274
- echo ""
275
- echo "Use /agent-vibes:provider info $current_provider for details"
276
- }
277
-
278
- # @function provider_preview
279
- # @intent Preview voices for the currently active provider
280
- # @architecture Delegates to provider-specific voice managers
281
- provider_preview() {
282
- local current_provider
283
- current_provider=$(get_active_provider)
284
-
285
- echo "🎤 Voice Preview ($current_provider)"
286
- echo ""
287
-
288
- case "$current_provider" in
289
- elevenlabs)
290
- # Use the ElevenLabs voice manager
291
- "$SCRIPT_DIR/voice-manager.sh" preview "$@"
292
- ;;
293
- piper)
294
- # Use the Piper voice manager's list functionality
295
- # For Piper, we'll list and play sample from available voices
296
- source "$SCRIPT_DIR/piper-voice-manager.sh"
297
-
298
- # Play intro announcement
299
- echo "🎤 Piper Preview of 3 people"
300
- echo ""
301
-
302
- # Play first 3 Piper voices as samples
303
- local sample_voices=(
304
- "en_US-lessac-medium:Lessac"
305
- "en_US-amy-medium:Amy"
306
- "en_US-joe-medium:Joe"
307
- )
308
-
309
- for voice_entry in "${sample_voices[@]}"; do
310
- local voice_name="${voice_entry%%:*}"
311
- local display_name="${voice_entry##*:}"
312
-
313
- echo "🔊 ${display_name}..."
314
- "$SCRIPT_DIR/play-tts.sh" "Hi, my name is ${display_name}" "$voice_name"
315
-
316
- # Wait for the voice to finish playing before starting next one
317
- sleep 3
318
- done
319
-
320
- echo ""
321
- echo "✓ Preview complete"
322
- echo "💡 Use /agent-vibes:list to see all available Piper voices"
323
- ;;
324
- *)
325
- echo "❌ Unknown provider: $current_provider"
326
- ;;
327
- esac
328
- }
329
-
330
- # @function provider_help
331
- # @intent Show help for provider commands
332
- provider_help() {
333
- echo "Provider Management Commands"
334
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
335
- echo ""
336
- echo "Usage:"
337
- echo " /agent-vibes:provider list # Show all providers"
338
- echo " /agent-vibes:provider switch <name> # Switch provider"
339
- echo " /agent-vibes:provider info <name> # Provider details"
340
- echo " /agent-vibes:provider test # Test current provider"
341
- echo " /agent-vibes:provider get # Show active provider"
342
- echo ""
343
- echo "Examples:"
344
- echo " /agent-vibes:provider switch piper"
345
- echo " /agent-vibes:provider info elevenlabs"
346
- echo ""
347
- echo "Learn more: agentvibes.org/docs/providers"
348
- }
349
-
350
- # Route to appropriate function
351
- case "$COMMAND" in
352
- list)
353
- provider_list
354
- ;;
355
- switch)
356
- provider_switch "$2"
357
- ;;
358
- info)
359
- provider_info "$2"
360
- ;;
361
- test)
362
- provider_test
363
- ;;
364
- get)
365
- provider_get
366
- ;;
367
- preview)
368
- shift # Remove 'preview' from args
369
- provider_preview "$@"
370
- ;;
371
- help|*)
372
- provider_help
373
- ;;
374
- esac
@@ -1,196 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # @fileoverview TTS Provider Management Functions
4
- # @context Core provider abstraction layer for multi-provider TTS system
5
- # @architecture Provides functions to get/set/list/validate TTS providers
6
- # @dependencies None - pure bash implementation
7
- # @entrypoints Sourced by play-tts.sh and provider management commands
8
- # @patterns File-based state management with project-local and global fallback
9
- # @related play-tts.sh, play-tts-elevenlabs.sh, GitHub Issue #25
10
- #
11
-
12
- # @function get_provider_config_path
13
- # @intent Determine path to tts-provider.txt file
14
- # @why Supports both project-local (.claude/) and global (~/.claude/) storage
15
- # @returns Echoes path to provider config file
16
- # @exitcode 0=always succeeds
17
- # @sideeffects None
18
- # @edgecases Creates parent directory if missing
19
- get_provider_config_path() {
20
- local provider_file
21
-
22
- # Check project-local first
23
- if [[ -n "$CLAUDE_PROJECT_DIR" ]] && [[ -d "$CLAUDE_PROJECT_DIR/.claude" ]]; then
24
- provider_file="$CLAUDE_PROJECT_DIR/.claude/tts-provider.txt"
25
- else
26
- # Search up directory tree for .claude/
27
- local current_dir="$PWD"
28
- while [[ "$current_dir" != "/" ]]; do
29
- if [[ -d "$current_dir/.claude" ]]; then
30
- provider_file="$current_dir/.claude/tts-provider.txt"
31
- break
32
- fi
33
- current_dir=$(dirname "$current_dir")
34
- done
35
-
36
- # Fallback to global if no project .claude found
37
- if [[ -z "$provider_file" ]]; then
38
- provider_file="$HOME/.claude/tts-provider.txt"
39
- fi
40
- fi
41
-
42
- echo "$provider_file"
43
- }
44
-
45
- # @function get_active_provider
46
- # @intent Read currently active TTS provider from config file
47
- # @why Central function for determining which provider to use
48
- # @returns Echoes provider name (e.g., "elevenlabs", "piper")
49
- # @exitcode 0=success
50
- # @sideeffects None
51
- # @edgecases Returns "elevenlabs" if file missing or empty (default)
52
- get_active_provider() {
53
- local provider_file
54
- provider_file=$(get_provider_config_path)
55
-
56
- # Read provider from file, default to elevenlabs if not found
57
- if [[ -f "$provider_file" ]]; then
58
- local provider
59
- provider=$(cat "$provider_file" | tr -d '[:space:]')
60
- if [[ -n "$provider" ]]; then
61
- echo "$provider"
62
- return 0
63
- fi
64
- fi
65
-
66
- # Default to elevenlabs
67
- echo "elevenlabs"
68
- }
69
-
70
- # @function set_active_provider
71
- # @intent Write active provider to config file
72
- # @why Allows runtime provider switching without restart
73
- # @param $1 {string} provider - Provider name (e.g., "elevenlabs", "piper")
74
- # @returns None (outputs success/error message)
75
- # @exitcode 0=success, 1=invalid provider
76
- # @sideeffects Writes to tts-provider.txt file
77
- # @edgecases Creates file and parent directory if missing
78
- set_active_provider() {
79
- local provider="$1"
80
-
81
- if [[ -z "$provider" ]]; then
82
- echo "❌ Error: Provider name required"
83
- echo "Usage: set_active_provider <provider_name>"
84
- return 1
85
- fi
86
-
87
- # Validate provider exists
88
- if ! validate_provider "$provider"; then
89
- echo "❌ Error: Provider '$provider' not found"
90
- echo "Available providers:"
91
- list_providers
92
- return 1
93
- fi
94
-
95
- local provider_file
96
- provider_file=$(get_provider_config_path)
97
-
98
- # Create directory if it doesn't exist
99
- mkdir -p "$(dirname "$provider_file")"
100
-
101
- # Write provider to file
102
- echo "$provider" > "$provider_file"
103
-
104
- echo "✓ Active provider set to: $provider"
105
- }
106
-
107
- # @function list_providers
108
- # @intent List all available TTS providers
109
- # @why Discover which providers are installed
110
- # @returns Echoes provider names (one per line)
111
- # @exitcode 0=success
112
- # @sideeffects None
113
- # @edgecases Returns empty if no play-tts-*.sh files found
114
- list_providers() {
115
- local script_dir
116
- script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
117
-
118
- # Find all play-tts-*.sh files
119
- local providers=()
120
- shopt -s nullglob # Handle case where no files match
121
- for file in "$script_dir"/play-tts-*.sh; do
122
- if [[ -f "$file" ]] && [[ "$file" != *"play-tts.sh" ]]; then
123
- # Extract provider name from filename (play-tts-elevenlabs.sh -> elevenlabs)
124
- local basename
125
- basename=$(basename "$file")
126
- local provider
127
- provider="${basename#play-tts-}"
128
- provider="${provider%.sh}"
129
- providers+=("$provider")
130
- fi
131
- done
132
- shopt -u nullglob
133
-
134
- # Output providers
135
- if [[ ${#providers[@]} -eq 0 ]]; then
136
- echo "⚠️ No providers found"
137
- return 0
138
- fi
139
-
140
- for provider in "${providers[@]}"; do
141
- echo "$provider"
142
- done
143
- }
144
-
145
- # @function validate_provider
146
- # @intent Check if provider implementation exists
147
- # @why Prevent errors from switching to non-existent provider
148
- # @param $1 {string} provider - Provider name to validate
149
- # @returns None
150
- # @exitcode 0=provider exists, 1=provider not found
151
- # @sideeffects None
152
- # @edgecases Checks for corresponding play-tts-*.sh file
153
- validate_provider() {
154
- local provider="$1"
155
-
156
- if [[ -z "$provider" ]]; then
157
- return 1
158
- fi
159
-
160
- local script_dir
161
- script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
162
- local provider_script="$script_dir/play-tts-${provider}.sh"
163
-
164
- [[ -f "$provider_script" ]]
165
- }
166
-
167
- # @function get_provider_script_path
168
- # @intent Get absolute path to provider implementation script
169
- # @why Used by router to execute provider-specific logic
170
- # @param $1 {string} provider - Provider name
171
- # @returns Echoes absolute path to play-tts-*.sh file
172
- # @exitcode 0=success, 1=provider not found
173
- # @sideeffects None
174
- get_provider_script_path() {
175
- local provider="$1"
176
-
177
- if [[ -z "$provider" ]]; then
178
- echo "❌ Error: Provider name required" >&2
179
- return 1
180
- fi
181
-
182
- local script_dir
183
- script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
184
- local provider_script="$script_dir/play-tts-${provider}.sh"
185
-
186
- if [[ ! -f "$provider_script" ]]; then
187
- echo "❌ Error: Provider '$provider' not found at $provider_script" >&2
188
- return 1
189
- fi
190
-
191
- echo "$provider_script"
192
- }
193
-
194
- # AI NOTE: This file provides the core abstraction layer for multi-provider TTS.
195
- # All provider state is managed through simple text files for simplicity and reliability.
196
- # Project-local configuration takes precedence over global to support per-project providers.