agentvibes 5.6.8 → 5.7.0

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 (128) hide show
  1. package/.agentvibes/config.json +2 -0
  2. package/.claude/commands/agent-vibes-bmad-voices.md +117 -117
  3. package/.claude/commands/agent-vibes-rdp.md +24 -24
  4. package/.claude/config/audio-effects.cfg +2 -2
  5. package/.claude/config/background-music-position.txt +0 -1
  6. package/.claude/docs/TERMUX_SETUP.md +408 -408
  7. package/.claude/github-star-reminder.txt +1 -1
  8. package/.claude/hooks/audio-cache-utils.sh +0 -0
  9. package/.claude/hooks/audio-processor.sh +0 -0
  10. package/.claude/hooks/background-music-manager.sh +0 -0
  11. package/.claude/hooks/bmad-party-manager.sh +225 -0
  12. package/.claude/hooks/bmad-party-speak.sh +0 -0
  13. package/.claude/hooks/bmad-speak-enhanced.sh +0 -0
  14. package/.claude/hooks/bmad-speak.sh +0 -0
  15. package/.claude/hooks/bmad-tts-injector.sh +49 -21
  16. package/.claude/hooks/bmad-voice-manager.sh +0 -0
  17. package/.claude/hooks/clawdbot-receiver-SECURE.sh +0 -0
  18. package/.claude/hooks/clawdbot-receiver.sh +0 -0
  19. package/.claude/hooks/clean-audio-cache.sh +0 -0
  20. package/.claude/hooks/cleanup-cache.sh +0 -0
  21. package/.claude/hooks/configure-rdp-mode.sh +0 -0
  22. package/.claude/hooks/download-extra-voices.sh +0 -0
  23. package/.claude/hooks/effects-manager.sh +0 -0
  24. package/.claude/hooks/github-star-reminder.sh +0 -0
  25. package/.claude/hooks/language-manager.sh +0 -0
  26. package/.claude/hooks/learn-manager.sh +0 -0
  27. package/.claude/hooks/macos-voice-manager.sh +0 -0
  28. package/.claude/hooks/migrate-background-music.sh +0 -0
  29. package/.claude/hooks/migrate-to-agentvibes.sh +0 -0
  30. package/.claude/hooks/optimize-background-music.sh +0 -0
  31. package/.claude/hooks/path-resolver.sh +0 -0
  32. package/.claude/hooks/personality-manager.sh +0 -0
  33. package/.claude/hooks/piper-download-voices.sh +0 -0
  34. package/.claude/hooks/piper-installer.sh +0 -0
  35. package/.claude/hooks/piper-multispeaker-registry.sh +0 -0
  36. package/.claude/hooks/piper-voice-manager.sh +0 -0
  37. package/.claude/hooks/play-tts-agentvibes-receiver-for-voiceless-connections.sh +0 -0
  38. package/.claude/hooks/play-tts-enhanced.sh +0 -0
  39. package/.claude/hooks/play-tts-macos.sh +0 -0
  40. package/.claude/hooks/play-tts-piper.sh +1 -1
  41. package/.claude/hooks/play-tts-soprano.sh +0 -0
  42. package/.claude/hooks/play-tts-ssh-remote.sh +0 -0
  43. package/.claude/hooks/play-tts-termux-ssh.sh +0 -0
  44. package/.claude/hooks/play-tts-windows-receiver.sh +0 -0
  45. package/.claude/hooks/play-tts.sh +4 -0
  46. package/.claude/hooks/prepare-release.sh +0 -0
  47. package/.claude/hooks/provider-commands.sh +16 -4
  48. package/.claude/hooks/provider-manager.sh +38 -0
  49. package/.claude/hooks/replay-target-audio.sh +0 -0
  50. package/.claude/hooks/sentiment-manager.sh +0 -0
  51. package/.claude/hooks/session-start-tts.sh +0 -0
  52. package/.claude/hooks/soprano-gradio-synth.py +0 -0
  53. package/.claude/hooks/speed-manager.sh +0 -0
  54. package/.claude/hooks/stop-tts.sh +0 -0
  55. package/.claude/hooks/stop.sh +38 -0
  56. package/.claude/hooks/termux-installer.sh +0 -0
  57. package/.claude/hooks/translate-manager.sh +0 -0
  58. package/.claude/hooks/translator.py +0 -0
  59. package/.claude/hooks/tts-queue-worker.sh +0 -0
  60. package/.claude/hooks/tts-queue.sh +0 -0
  61. package/.claude/hooks/verbosity-manager.sh +0 -0
  62. package/.claude/hooks/voice-manager.sh +50 -2
  63. package/.claude/hooks-windows/audio-cache-utils.ps1 +119 -119
  64. package/.claude/hooks-windows/play-tts.ps1 +34 -1
  65. package/.claude/hooks-windows/tts-watcher.ps1 +122 -0
  66. package/.claude/piper-voices-dir.txt +1 -0
  67. package/.clawdbot/README.md +105 -105
  68. package/.mcp.json +14 -5
  69. package/README.md +10 -2
  70. package/RELEASE_NOTES.md +61 -0
  71. package/WINDOWS-SETUP.md +208 -208
  72. package/bin/agent-vibes +39 -39
  73. package/bin/agentvibes-voice-browser.js +59 -4
  74. package/bin/agentvibes.js +0 -0
  75. package/bin/mcp-server.js +121 -121
  76. package/bin/mcp-server.sh +0 -0
  77. package/bin/test-bmad-pr +78 -78
  78. package/mcp-server/QUICK_START.md +203 -203
  79. package/mcp-server/README.md +345 -345
  80. package/mcp-server/WINDOWS_SETUP.md +260 -260
  81. package/mcp-server/docs/troubleshooting-audio.md +313 -313
  82. package/mcp-server/examples/claude_desktop_config.json +11 -11
  83. package/mcp-server/examples/claude_desktop_config_piper.json +9 -9
  84. package/mcp-server/examples/custom_instructions.md +169 -169
  85. package/mcp-server/install-deps.js +177 -130
  86. package/mcp-server/server.py +1797 -1787
  87. package/mcp-server/test_server.py +0 -0
  88. package/package.json +1 -1
  89. package/src/bmad-detector.js +85 -71
  90. package/src/cli/list-personalities.js +110 -110
  91. package/src/cli/list-voices.js +114 -114
  92. package/src/commands/bmad-voices.js +394 -394
  93. package/src/commands/install-mcp.js +476 -476
  94. package/src/console/brand-colors.js +13 -13
  95. package/src/console/constants/personalities.js +44 -44
  96. package/src/console/tabs/help-tab.js +314 -314
  97. package/src/console/tabs/music-tab.js +18 -2
  98. package/src/console/tabs/readme-tab.js +272 -272
  99. package/src/console/widgets/destroy-list.js +25 -25
  100. package/src/console/widgets/notice.js +55 -55
  101. package/src/console/widgets/personality-picker.js +213 -213
  102. package/src/i18n/de.js +202 -202
  103. package/src/i18n/es.js +202 -202
  104. package/src/i18n/fr.js +202 -202
  105. package/src/i18n/hi.js +202 -202
  106. package/src/i18n/ja.js +202 -202
  107. package/src/i18n/ko.js +202 -202
  108. package/src/i18n/pt.js +202 -202
  109. package/src/i18n/strings.js +54 -54
  110. package/src/i18n/zh-CN.js +202 -202
  111. package/src/installer/language-screen.js +31 -31
  112. package/src/installer/music-file-input.js +304 -304
  113. package/src/installer.js +70 -7
  114. package/src/services/agent-voice-store.js +59 -12
  115. package/src/services/config-service.js +264 -264
  116. package/src/services/language-service.js +47 -47
  117. package/src/services/provider-service.js +143 -143
  118. package/src/utils/audio-duration-validator.js +298 -298
  119. package/src/utils/audio-format-validator.js +277 -277
  120. package/src/utils/dependency-checker.js +469 -469
  121. package/src/utils/file-ownership-verifier.js +358 -358
  122. package/src/utils/list-formatter.js +194 -194
  123. package/src/utils/music-file-validator.js +285 -285
  124. package/src/utils/preview-list-prompt.js +136 -136
  125. package/src/utils/secure-music-storage.js +412 -412
  126. package/templates/agentvibes-receiver.sh +0 -0
  127. package/templates/audio/welcome-music.mp3 +0 -0
  128. package/.claude/hooks/play-tts-agentvibes-receiver.sh +0 -1
@@ -1,476 +1,476 @@
1
- #!/usr/bin/env node
2
- /**
3
- * AgentVibes MCP Server Installer
4
- *
5
- * Interactive installer for setting up AgentVibes MCP server with Claude Desktop
6
- * Handles platform-specific installation (Windows/Mac/Linux)
7
- */
8
-
9
- import inquirer from 'inquirer';
10
- import { execSync, execFileSync } from 'child_process';
11
- import fs from 'fs';
12
- import path from 'path';
13
- import os from 'os';
14
- import chalk from 'chalk';
15
- import ora from 'ora';
16
- import boxen from 'boxen';
17
- import { checkDependencies, displayMissingDependencies } from '../utils/dependency-checker.js';
18
-
19
- /**
20
- * Check if WSL is installed on Windows
21
- */
22
- function checkWSL() {
23
- try {
24
- // Security: Use execFileSync with array args to prevent command injection
25
- execFileSync('wsl', ['--version'], { stdio: 'pipe' });
26
- return true;
27
- } catch {
28
- return false;
29
- }
30
- }
31
-
32
- /**
33
- * Check if Python is available
34
- */
35
- function checkPython() {
36
- const commands = ['python3', 'python', 'py'];
37
-
38
- for (const cmd of commands) {
39
- try {
40
- // Security: Use execFileSync with array args to prevent command injection
41
- const version = execFileSync(cmd, ['--version'], { encoding: 'utf8', stdio: 'pipe' });
42
- return { available: true, command: cmd, version: version.trim() };
43
- } catch {
44
- continue;
45
- }
46
- }
47
-
48
- return { available: false };
49
- }
50
-
51
- /**
52
- * Check if Python MCP package is installed
53
- */
54
- function checkMCPPackage(pythonCmd) {
55
- try {
56
- // Security: Use execFileSync with array args to prevent command injection
57
- execFileSync(pythonCmd, ['-c', 'import mcp'], { stdio: 'pipe' });
58
- return true;
59
- } catch {
60
- return false;
61
- }
62
- }
63
-
64
- /**
65
- * Get Claude Desktop config path for current platform
66
- */
67
- function getClaudeConfigPath() {
68
- const platform = os.platform();
69
-
70
- switch (platform) {
71
- case 'darwin': // macOS
72
- return path.join(os.homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
73
- case 'win32': // Windows
74
- return path.join(os.homedir(), 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json');
75
- default: // Linux
76
- return path.join(os.homedir(), '.config', 'Claude', 'claude_desktop_config.json');
77
- }
78
- }
79
-
80
- /**
81
- * Get AgentVibes installation directory
82
- */
83
- function getAgentVibesDir() {
84
- // Try to find AgentVibes directory
85
- // 1. Current directory
86
- if (fs.existsSync('./.claude/hooks/play-tts.sh')) {
87
- return process.cwd();
88
- }
89
-
90
- // 2. Parent directory
91
- const parentDir = path.resolve(process.cwd(), '..');
92
- if (fs.existsSync(path.join(parentDir, '.claude/hooks/play-tts.sh'))) {
93
- return parentDir;
94
- }
95
-
96
- // 3. Ask user
97
- return null;
98
- }
99
-
100
- /**
101
- * Update Claude Desktop configuration
102
- */
103
- function updateClaudeConfig(agentVibesPath, provider, apiKey = null) {
104
- const configPath = getClaudeConfigPath();
105
- const platform = os.platform();
106
-
107
- // Create config directory if it doesn't exist
108
- const configDir = path.dirname(configPath);
109
- if (!fs.existsSync(configDir)) {
110
- fs.mkdirSync(configDir, { recursive: true });
111
- }
112
-
113
- // Read existing config or create new one
114
- let config = { mcpServers: {} };
115
- if (fs.existsSync(configPath)) {
116
- const content = fs.readFileSync(configPath, 'utf8');
117
- config = JSON.parse(content);
118
- if (!config.mcpServers) {
119
- config.mcpServers = {};
120
- }
121
- }
122
-
123
- // Prepare MCP server config
124
- let serverPath = path.join(agentVibesPath, 'mcp-server', 'server.py');
125
-
126
- if (platform === 'win32') {
127
- // Windows: Use WSL
128
- serverPath = serverPath.replace(/\\/g, '/').replace(/^([A-Z]):/, (match, drive) => {
129
- return `/mnt/${drive.toLowerCase()}`;
130
- });
131
-
132
- config.mcpServers.agentvibes = {
133
- command: 'wsl',
134
- args: ['python3', serverPath],
135
- env: {}
136
- };
137
- } else {
138
- // macOS/Linux: Use native Python
139
- config.mcpServers.agentvibes = {
140
- command: 'python3',
141
- args: [serverPath],
142
- env: {}
143
- };
144
- }
145
-
146
-
147
- // Write config atomically to prevent race conditions (TOCTOU)
148
- // Write to temp file first, then rename atomically
149
- const tempPath = `${configPath}.tmp.${process.pid}`;
150
- try {
151
- fs.writeFileSync(tempPath, JSON.stringify(config, null, 2), { mode: 0o600 });
152
- fs.renameSync(tempPath, configPath);
153
- } catch (error) {
154
- // Clean up temp file if rename fails
155
- try { fs.unlinkSync(tempPath); } catch { /* ignore cleanup errors */ }
156
- throw error;
157
- }
158
-
159
- return configPath;
160
- }
161
-
162
- /**
163
- * Install Piper TTS
164
- */
165
- async function installPiper(useWSL = false) {
166
- const spinner = ora('Installing Piper TTS...').start();
167
-
168
- try {
169
- // Security: Use execFileSync with array args to prevent command injection
170
- if (useWSL) {
171
- execFileSync('wsl', ['pipx', 'install', 'piper-tts'], { stdio: 'inherit' });
172
- } else {
173
- execFileSync('pipx', ['install', 'piper-tts'], { stdio: 'inherit' });
174
- }
175
- spinner.succeed('Piper TTS installed successfully!');
176
- return true;
177
- } catch (error) {
178
- spinner.fail('Failed to install Piper TTS');
179
- console.error(chalk.yellow('\n⚠️ You may need to install pipx first:'));
180
- if (useWSL) {
181
- console.log(chalk.cyan(' wsl sudo apt install pipx'));
182
- } else {
183
- console.log(chalk.cyan(' brew install pipx (macOS)'));
184
- console.log(chalk.cyan(' sudo apt install pipx (Linux)'));
185
- }
186
- return false;
187
- }
188
- }
189
-
190
- /**
191
- * Install Python MCP package
192
- */
193
- async function installMCPPackage(pythonCmd, useWSL = false) {
194
- const spinner = ora('Installing Python MCP package...').start();
195
-
196
- try {
197
- // Security: Use execFileSync with array args to prevent command injection
198
- if (useWSL) {
199
- execFileSync('wsl', [pythonCmd, '-m', 'pip', 'install', '--break-system-packages', 'mcp'], { stdio: 'pipe' });
200
- } else {
201
- execFileSync(pythonCmd, ['-m', 'pip', 'install', '--user', 'mcp'], { stdio: 'pipe' });
202
- }
203
- spinner.succeed('Python MCP package installed successfully!');
204
- return true;
205
- } catch (error) {
206
- spinner.fail('Failed to install Python MCP package');
207
- console.error(chalk.red(`\n❌ Error: ${error.message}`));
208
- return false;
209
- }
210
- }
211
-
212
- /**
213
- * Main installer
214
- */
215
- /**
216
- * Check system dependencies and handle missing ones
217
- * @returns {Promise<void>}
218
- */
219
- async function checkSystemDependencies() {
220
- console.log(chalk.bold('🔍 Step 1: Checking system dependencies...\n'));
221
-
222
- const depResults = checkDependencies();
223
- const hasMissingDeps = displayMissingDependencies(depResults);
224
-
225
- if (!hasMissingDeps) {
226
- console.log(chalk.green('✓ All dependencies installed!\n'));
227
- return;
228
- }
229
-
230
- const hasCoreMissing = depResults.missing.node || depResults.missing.python || depResults.missing.bash;
231
-
232
- if (hasCoreMissing) {
233
- console.log(chalk.red('\n❌ Critical dependencies are missing. Please install them before continuing.\n'));
234
- process.exit(1);
235
- }
236
-
237
- // Only optional dependencies missing
238
- const { continueAnyway } = await inquirer.prompt([{
239
- type: 'confirm',
240
- name: 'continueAnyway',
241
- message: 'Some optional dependencies are missing. Continue anyway?',
242
- default: true
243
- }]);
244
-
245
- if (!continueAnyway) {
246
- console.log(chalk.yellow('\nInstallation cancelled. Please install the dependencies and try again.\n'));
247
- process.exit(0);
248
- }
249
- }
250
-
251
- /**
252
- * Locate AgentVibes installation directory
253
- * @param {boolean} isWindows - Whether running on Windows
254
- * @returns {Promise<string>} AgentVibes directory path
255
- */
256
- async function locateAgentVibesDir(isWindows) {
257
- console.log(chalk.bold('📁 Step 2: Locating AgentVibes installation...\n'));
258
-
259
- let agentVibesDir = getAgentVibesDir();
260
-
261
- if (!agentVibesDir) {
262
- const { customPath } = await inquirer.prompt([{
263
- type: 'input',
264
- name: 'customPath',
265
- message: 'Enter the path to your AgentVibes installation:',
266
- default: isWindows ? 'C:\\Users\\USERNAME\\AgentVibes' : '~/AgentVibes',
267
- validate: (input) => {
268
- const expanded = input.replace(/^~/, os.homedir());
269
- if (fs.existsSync(path.join(expanded, '.claude/hooks/play-tts.sh'))) {
270
- return true;
271
- }
272
- return 'AgentVibes not found at this path. Please check and try again.';
273
- }
274
- }]);
275
-
276
- agentVibesDir = customPath.replace(/^~/, os.homedir());
277
- }
278
-
279
- console.log(chalk.green(`✓ Found AgentVibes at: ${agentVibesDir}\n`));
280
- return agentVibesDir;
281
- }
282
-
283
- /**
284
- * Check and setup WSL on Windows
285
- * @returns {Promise<void>}
286
- */
287
- async function setupWindowsWSL() {
288
- console.log(chalk.bold('🪟 Step 3: Windows environment setup...\n'));
289
-
290
- const hasWSL = checkWSL();
291
-
292
- if (hasWSL) {
293
- console.log(chalk.green('✓ WSL is installed\n'));
294
- return;
295
- }
296
-
297
- console.log(chalk.yellow('⚠️ WSL (Windows Subsystem for Linux) is required but not installed.'));
298
- const { installWSL } = await inquirer.prompt([{
299
- type: 'confirm',
300
- name: 'installWSL',
301
- message: 'Install WSL now? (Requires restart)',
302
- default: true
303
- }]);
304
-
305
- if (!installWSL) {
306
- console.log(chalk.red('\n❌ WSL is required for AgentVibes MCP server on Windows'));
307
- process.exit(1);
308
- }
309
-
310
- console.log(chalk.cyan('\n📦 Installing WSL...'));
311
- try {
312
- // Security: Use execFileSync with array args to prevent command injection
313
- execFileSync('wsl', ['--install'], { stdio: 'inherit' });
314
- console.log(chalk.green('\n✅ WSL installed successfully!'));
315
- console.log(chalk.yellow('⚠️ Please restart your computer and run this installer again.'));
316
- process.exit(0);
317
- } catch (error) {
318
- console.error(chalk.red('\n❌ Failed to install WSL'));
319
- console.error(chalk.yellow('Please install WSL manually: https://aka.ms/wsl'));
320
- process.exit(1);
321
- }
322
- }
323
-
324
- /**
325
- * Select and install TTS provider
326
- * @param {boolean} isWindows - Whether running on Windows
327
- * @returns {Promise<string>} Selected provider name
328
- */
329
- async function setupTTSProvider(isWindows) {
330
- console.log(chalk.bold('🎤 Step 4: Choose TTS provider...\n'));
331
-
332
- const { provider } = await inquirer.prompt([{
333
- type: 'list',
334
- name: 'provider',
335
- message: 'Select your preferred TTS provider:',
336
- choices: [
337
- {
338
- name: 'Piper TTS (Free, Offline, Open Source) - Recommended',
339
- value: 'piper',
340
- short: 'Piper'
341
- },
342
- {
343
- name: 'macOS TTS (Native macOS text-to-speech)',
344
- value: 'macos',
345
- short: 'macOS'
346
- }
347
- ]
348
- }]);
349
-
350
- if (provider === 'piper') {
351
- console.log(chalk.cyan('\n📦 Installing Piper TTS...'));
352
- await installPiper(isWindows);
353
- } else if (provider === 'macos') {
354
- console.log(chalk.cyan('\n✅ macOS TTS uses native system voices - no installation needed'));
355
- }
356
-
357
- return provider;
358
- }
359
-
360
- /**
361
- * Setup Python dependencies
362
- * @param {boolean} isWindows - Whether running on Windows
363
- * @returns {Promise<void>}
364
- */
365
- async function setupPythonDependencies(isWindows) {
366
- console.log(chalk.bold('\n🐍 Step 5: Installing Python dependencies...\n'));
367
-
368
- const pythonCheck = isWindows
369
- ? { available: true, command: 'python3' } // WSL Python
370
- : checkPython();
371
-
372
- if (!pythonCheck.available) {
373
- console.error(chalk.red('❌ Python not found!'));
374
- console.log(chalk.yellow('Please install Python 3.10+ from https://python.org'));
375
- process.exit(1);
376
- }
377
-
378
- console.log(chalk.green(`✓ Python found: ${pythonCheck.version || 'python3'}\n`));
379
-
380
- // Check and install MCP package
381
- const hasMCP = isWindows
382
- ? false // Always install in WSL
383
- : checkMCPPackage(pythonCheck.command);
384
-
385
- if (!hasMCP) {
386
- await installMCPPackage(pythonCheck.command, isWindows);
387
- } else {
388
- console.log(chalk.green('✓ Python MCP package already installed\n'));
389
- }
390
- }
391
-
392
- /**
393
- * Display welcome banner
394
- * @param {string} platform - Platform name
395
- */
396
- function showWelcomeBanner(platform) {
397
- console.log(boxen(
398
- chalk.bold.cyan('AgentVibes MCP Server Installer') + '\n\n' +
399
- 'Give Claude Desktop a voice! 🎤',
400
- {
401
- padding: 1,
402
- margin: 1,
403
- borderStyle: 'round',
404
- borderColor: 'cyan'
405
- }
406
- ));
407
-
408
- const platformLabel = platform === 'win32' ? 'Windows' : platform === 'darwin' ? 'macOS' : 'Linux';
409
- console.log(chalk.gray(`Platform: ${platformLabel}\n`));
410
- }
411
-
412
- /**
413
- * Display success message
414
- * @param {string} configPath - Config file path
415
- * @param {string} provider - Provider name
416
- */
417
- function showSuccessMessage(configPath, provider) {
418
- console.log(boxen(
419
- chalk.bold.green('✅ Installation Complete!') + '\n\n' +
420
- chalk.white('Next steps:\n') +
421
- chalk.cyan('1. Restart Claude Desktop\n') +
422
- chalk.cyan('2. Try: "Say hello using text to speech"\n') +
423
- chalk.cyan('3. Enjoy your talking Claude! 🎤'),
424
- {
425
- padding: 1,
426
- margin: 1,
427
- borderStyle: 'round',
428
- borderColor: 'green'
429
- }
430
- ));
431
-
432
- console.log(chalk.gray('\nConfiguration saved to:'));
433
- console.log(chalk.gray(` ${configPath}\n`));
434
-
435
- if (provider === 'piper') {
436
- console.log(chalk.gray('Voice models will download automatically on first use.\n'));
437
- }
438
- }
439
-
440
- export async function installMCP() {
441
- const platform = os.platform();
442
- const isWindows = platform === 'win32';
443
-
444
- showWelcomeBanner(platform);
445
-
446
- // Step 1: Check system dependencies
447
- await checkSystemDependencies();
448
-
449
- // Step 2: Find AgentVibes directory
450
- const agentVibesDir = await locateAgentVibesDir(isWindows);
451
-
452
- // Step 3: Windows-specific checks
453
- if (isWindows) {
454
- await setupWindowsWSL();
455
- }
456
-
457
- // Step 4: Choose TTS provider
458
- const provider = await setupTTSProvider(isWindows);
459
-
460
- // Step 5: Install Python dependencies
461
- await setupPythonDependencies(isWindows);
462
-
463
- // Step 6: Configure provider in AgentVibes
464
- console.log(chalk.bold('⚙️ Step 6: Configuring AgentVibes...\n'));
465
- const providerFile = path.join(agentVibesDir, '.claude', 'tts-provider.txt');
466
- fs.writeFileSync(providerFile, provider);
467
- console.log(chalk.green(`✓ Set provider to: ${provider}\n`));
468
-
469
- // Step 7: Update Claude Desktop config
470
- console.log(chalk.bold('📝 Step 7: Updating Claude Desktop configuration...\n'));
471
- const configPath = updateClaudeConfig(agentVibesDir, provider, apiKey);
472
- console.log(chalk.green(`✓ Updated: ${configPath}\n`));
473
-
474
- // Success!
475
- showSuccessMessage(configPath, provider);
476
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AgentVibes MCP Server Installer
4
+ *
5
+ * Interactive installer for setting up AgentVibes MCP server with Claude Desktop
6
+ * Handles platform-specific installation (Windows/Mac/Linux)
7
+ */
8
+
9
+ import inquirer from 'inquirer';
10
+ import { execSync, execFileSync } from 'child_process';
11
+ import fs from 'fs';
12
+ import path from 'path';
13
+ import os from 'os';
14
+ import chalk from 'chalk';
15
+ import ora from 'ora';
16
+ import boxen from 'boxen';
17
+ import { checkDependencies, displayMissingDependencies } from '../utils/dependency-checker.js';
18
+
19
+ /**
20
+ * Check if WSL is installed on Windows
21
+ */
22
+ function checkWSL() {
23
+ try {
24
+ // Security: Use execFileSync with array args to prevent command injection
25
+ execFileSync('wsl', ['--version'], { stdio: 'pipe' });
26
+ return true;
27
+ } catch {
28
+ return false;
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Check if Python is available
34
+ */
35
+ function checkPython() {
36
+ const commands = ['python3', 'python', 'py'];
37
+
38
+ for (const cmd of commands) {
39
+ try {
40
+ // Security: Use execFileSync with array args to prevent command injection
41
+ const version = execFileSync(cmd, ['--version'], { encoding: 'utf8', stdio: 'pipe' });
42
+ return { available: true, command: cmd, version: version.trim() };
43
+ } catch {
44
+ continue;
45
+ }
46
+ }
47
+
48
+ return { available: false };
49
+ }
50
+
51
+ /**
52
+ * Check if Python MCP package is installed
53
+ */
54
+ function checkMCPPackage(pythonCmd) {
55
+ try {
56
+ // Security: Use execFileSync with array args to prevent command injection
57
+ execFileSync(pythonCmd, ['-c', 'import mcp'], { stdio: 'pipe' });
58
+ return true;
59
+ } catch {
60
+ return false;
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Get Claude Desktop config path for current platform
66
+ */
67
+ function getClaudeConfigPath() {
68
+ const platform = os.platform();
69
+
70
+ switch (platform) {
71
+ case 'darwin': // macOS
72
+ return path.join(os.homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
73
+ case 'win32': // Windows
74
+ return path.join(os.homedir(), 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json');
75
+ default: // Linux
76
+ return path.join(os.homedir(), '.config', 'Claude', 'claude_desktop_config.json');
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Get AgentVibes installation directory
82
+ */
83
+ function getAgentVibesDir() {
84
+ // Try to find AgentVibes directory
85
+ // 1. Current directory
86
+ if (fs.existsSync('./.claude/hooks/play-tts.sh')) {
87
+ return process.cwd();
88
+ }
89
+
90
+ // 2. Parent directory
91
+ const parentDir = path.resolve(process.cwd(), '..');
92
+ if (fs.existsSync(path.join(parentDir, '.claude/hooks/play-tts.sh'))) {
93
+ return parentDir;
94
+ }
95
+
96
+ // 3. Ask user
97
+ return null;
98
+ }
99
+
100
+ /**
101
+ * Update Claude Desktop configuration
102
+ */
103
+ function updateClaudeConfig(agentVibesPath, provider, apiKey = null) {
104
+ const configPath = getClaudeConfigPath();
105
+ const platform = os.platform();
106
+
107
+ // Create config directory if it doesn't exist
108
+ const configDir = path.dirname(configPath);
109
+ if (!fs.existsSync(configDir)) {
110
+ fs.mkdirSync(configDir, { recursive: true });
111
+ }
112
+
113
+ // Read existing config or create new one
114
+ let config = { mcpServers: {} };
115
+ if (fs.existsSync(configPath)) {
116
+ const content = fs.readFileSync(configPath, 'utf8');
117
+ config = JSON.parse(content);
118
+ if (!config.mcpServers) {
119
+ config.mcpServers = {};
120
+ }
121
+ }
122
+
123
+ // Prepare MCP server config
124
+ let serverPath = path.join(agentVibesPath, 'mcp-server', 'server.py');
125
+
126
+ if (platform === 'win32') {
127
+ // Windows: Use WSL
128
+ serverPath = serverPath.replace(/\\/g, '/').replace(/^([A-Z]):/, (match, drive) => {
129
+ return `/mnt/${drive.toLowerCase()}`;
130
+ });
131
+
132
+ config.mcpServers.agentvibes = {
133
+ command: 'wsl',
134
+ args: ['python3', serverPath],
135
+ env: {}
136
+ };
137
+ } else {
138
+ // macOS/Linux: Use native Python
139
+ config.mcpServers.agentvibes = {
140
+ command: 'python3',
141
+ args: [serverPath],
142
+ env: {}
143
+ };
144
+ }
145
+
146
+
147
+ // Write config atomically to prevent race conditions (TOCTOU)
148
+ // Write to temp file first, then rename atomically
149
+ const tempPath = `${configPath}.tmp.${process.pid}`;
150
+ try {
151
+ fs.writeFileSync(tempPath, JSON.stringify(config, null, 2), { mode: 0o600 });
152
+ fs.renameSync(tempPath, configPath);
153
+ } catch (error) {
154
+ // Clean up temp file if rename fails
155
+ try { fs.unlinkSync(tempPath); } catch { /* ignore cleanup errors */ }
156
+ throw error;
157
+ }
158
+
159
+ return configPath;
160
+ }
161
+
162
+ /**
163
+ * Install Piper TTS
164
+ */
165
+ async function installPiper(useWSL = false) {
166
+ const spinner = ora('Installing Piper TTS...').start();
167
+
168
+ try {
169
+ // Security: Use execFileSync with array args to prevent command injection
170
+ if (useWSL) {
171
+ execFileSync('wsl', ['pipx', 'install', 'piper-tts'], { stdio: 'inherit' });
172
+ } else {
173
+ execFileSync('pipx', ['install', 'piper-tts'], { stdio: 'inherit' });
174
+ }
175
+ spinner.succeed('Piper TTS installed successfully!');
176
+ return true;
177
+ } catch (error) {
178
+ spinner.fail('Failed to install Piper TTS');
179
+ console.error(chalk.yellow('\n⚠️ You may need to install pipx first:'));
180
+ if (useWSL) {
181
+ console.log(chalk.cyan(' wsl sudo apt install pipx'));
182
+ } else {
183
+ console.log(chalk.cyan(' brew install pipx (macOS)'));
184
+ console.log(chalk.cyan(' sudo apt install pipx (Linux)'));
185
+ }
186
+ return false;
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Install Python MCP package
192
+ */
193
+ async function installMCPPackage(pythonCmd, useWSL = false) {
194
+ const spinner = ora('Installing Python MCP package...').start();
195
+
196
+ try {
197
+ // Security: Use execFileSync with array args to prevent command injection
198
+ if (useWSL) {
199
+ execFileSync('wsl', [pythonCmd, '-m', 'pip', 'install', '--break-system-packages', 'mcp'], { stdio: 'pipe' });
200
+ } else {
201
+ execFileSync(pythonCmd, ['-m', 'pip', 'install', '--user', 'mcp'], { stdio: 'pipe' });
202
+ }
203
+ spinner.succeed('Python MCP package installed successfully!');
204
+ return true;
205
+ } catch (error) {
206
+ spinner.fail('Failed to install Python MCP package');
207
+ console.error(chalk.red(`\n❌ Error: ${error.message}`));
208
+ return false;
209
+ }
210
+ }
211
+
212
+ /**
213
+ * Main installer
214
+ */
215
+ /**
216
+ * Check system dependencies and handle missing ones
217
+ * @returns {Promise<void>}
218
+ */
219
+ async function checkSystemDependencies() {
220
+ console.log(chalk.bold('🔍 Step 1: Checking system dependencies...\n'));
221
+
222
+ const depResults = checkDependencies();
223
+ const hasMissingDeps = displayMissingDependencies(depResults);
224
+
225
+ if (!hasMissingDeps) {
226
+ console.log(chalk.green('✓ All dependencies installed!\n'));
227
+ return;
228
+ }
229
+
230
+ const hasCoreMissing = depResults.missing.node || depResults.missing.python || depResults.missing.bash;
231
+
232
+ if (hasCoreMissing) {
233
+ console.log(chalk.red('\n❌ Critical dependencies are missing. Please install them before continuing.\n'));
234
+ process.exit(1);
235
+ }
236
+
237
+ // Only optional dependencies missing
238
+ const { continueAnyway } = await inquirer.prompt([{
239
+ type: 'confirm',
240
+ name: 'continueAnyway',
241
+ message: 'Some optional dependencies are missing. Continue anyway?',
242
+ default: true
243
+ }]);
244
+
245
+ if (!continueAnyway) {
246
+ console.log(chalk.yellow('\nInstallation cancelled. Please install the dependencies and try again.\n'));
247
+ process.exit(0);
248
+ }
249
+ }
250
+
251
+ /**
252
+ * Locate AgentVibes installation directory
253
+ * @param {boolean} isWindows - Whether running on Windows
254
+ * @returns {Promise<string>} AgentVibes directory path
255
+ */
256
+ async function locateAgentVibesDir(isWindows) {
257
+ console.log(chalk.bold('📁 Step 2: Locating AgentVibes installation...\n'));
258
+
259
+ let agentVibesDir = getAgentVibesDir();
260
+
261
+ if (!agentVibesDir) {
262
+ const { customPath } = await inquirer.prompt([{
263
+ type: 'input',
264
+ name: 'customPath',
265
+ message: 'Enter the path to your AgentVibes installation:',
266
+ default: isWindows ? 'C:\\Users\\USERNAME\\AgentVibes' : '~/AgentVibes',
267
+ validate: (input) => {
268
+ const expanded = input.replace(/^~/, os.homedir());
269
+ if (fs.existsSync(path.join(expanded, '.claude/hooks/play-tts.sh'))) {
270
+ return true;
271
+ }
272
+ return 'AgentVibes not found at this path. Please check and try again.';
273
+ }
274
+ }]);
275
+
276
+ agentVibesDir = customPath.replace(/^~/, os.homedir());
277
+ }
278
+
279
+ console.log(chalk.green(`✓ Found AgentVibes at: ${agentVibesDir}\n`));
280
+ return agentVibesDir;
281
+ }
282
+
283
+ /**
284
+ * Check and setup WSL on Windows
285
+ * @returns {Promise<void>}
286
+ */
287
+ async function setupWindowsWSL() {
288
+ console.log(chalk.bold('🪟 Step 3: Windows environment setup...\n'));
289
+
290
+ const hasWSL = checkWSL();
291
+
292
+ if (hasWSL) {
293
+ console.log(chalk.green('✓ WSL is installed\n'));
294
+ return;
295
+ }
296
+
297
+ console.log(chalk.yellow('⚠️ WSL (Windows Subsystem for Linux) is required but not installed.'));
298
+ const { installWSL } = await inquirer.prompt([{
299
+ type: 'confirm',
300
+ name: 'installWSL',
301
+ message: 'Install WSL now? (Requires restart)',
302
+ default: true
303
+ }]);
304
+
305
+ if (!installWSL) {
306
+ console.log(chalk.red('\n❌ WSL is required for AgentVibes MCP server on Windows'));
307
+ process.exit(1);
308
+ }
309
+
310
+ console.log(chalk.cyan('\n📦 Installing WSL...'));
311
+ try {
312
+ // Security: Use execFileSync with array args to prevent command injection
313
+ execFileSync('wsl', ['--install'], { stdio: 'inherit' });
314
+ console.log(chalk.green('\n✅ WSL installed successfully!'));
315
+ console.log(chalk.yellow('⚠️ Please restart your computer and run this installer again.'));
316
+ process.exit(0);
317
+ } catch (error) {
318
+ console.error(chalk.red('\n❌ Failed to install WSL'));
319
+ console.error(chalk.yellow('Please install WSL manually: https://aka.ms/wsl'));
320
+ process.exit(1);
321
+ }
322
+ }
323
+
324
+ /**
325
+ * Select and install TTS provider
326
+ * @param {boolean} isWindows - Whether running on Windows
327
+ * @returns {Promise<string>} Selected provider name
328
+ */
329
+ async function setupTTSProvider(isWindows) {
330
+ console.log(chalk.bold('🎤 Step 4: Choose TTS provider...\n'));
331
+
332
+ const { provider } = await inquirer.prompt([{
333
+ type: 'list',
334
+ name: 'provider',
335
+ message: 'Select your preferred TTS provider:',
336
+ choices: [
337
+ {
338
+ name: 'Piper TTS (Free, Offline, Open Source) - Recommended',
339
+ value: 'piper',
340
+ short: 'Piper'
341
+ },
342
+ {
343
+ name: 'macOS TTS (Native macOS text-to-speech)',
344
+ value: 'macos',
345
+ short: 'macOS'
346
+ }
347
+ ]
348
+ }]);
349
+
350
+ if (provider === 'piper') {
351
+ console.log(chalk.cyan('\n📦 Installing Piper TTS...'));
352
+ await installPiper(isWindows);
353
+ } else if (provider === 'macos') {
354
+ console.log(chalk.cyan('\n✅ macOS TTS uses native system voices - no installation needed'));
355
+ }
356
+
357
+ return provider;
358
+ }
359
+
360
+ /**
361
+ * Setup Python dependencies
362
+ * @param {boolean} isWindows - Whether running on Windows
363
+ * @returns {Promise<void>}
364
+ */
365
+ async function setupPythonDependencies(isWindows) {
366
+ console.log(chalk.bold('\n🐍 Step 5: Installing Python dependencies...\n'));
367
+
368
+ const pythonCheck = isWindows
369
+ ? { available: true, command: 'python3' } // WSL Python
370
+ : checkPython();
371
+
372
+ if (!pythonCheck.available) {
373
+ console.error(chalk.red('❌ Python not found!'));
374
+ console.log(chalk.yellow('Please install Python 3.10+ from https://python.org'));
375
+ process.exit(1);
376
+ }
377
+
378
+ console.log(chalk.green(`✓ Python found: ${pythonCheck.version || 'python3'}\n`));
379
+
380
+ // Check and install MCP package
381
+ const hasMCP = isWindows
382
+ ? false // Always install in WSL
383
+ : checkMCPPackage(pythonCheck.command);
384
+
385
+ if (!hasMCP) {
386
+ await installMCPPackage(pythonCheck.command, isWindows);
387
+ } else {
388
+ console.log(chalk.green('✓ Python MCP package already installed\n'));
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Display welcome banner
394
+ * @param {string} platform - Platform name
395
+ */
396
+ function showWelcomeBanner(platform) {
397
+ console.log(boxen(
398
+ chalk.bold.cyan('AgentVibes MCP Server Installer') + '\n\n' +
399
+ 'Give Claude Desktop a voice! 🎤',
400
+ {
401
+ padding: 1,
402
+ margin: 1,
403
+ borderStyle: 'round',
404
+ borderColor: 'cyan'
405
+ }
406
+ ));
407
+
408
+ const platformLabel = platform === 'win32' ? 'Windows' : platform === 'darwin' ? 'macOS' : 'Linux';
409
+ console.log(chalk.gray(`Platform: ${platformLabel}\n`));
410
+ }
411
+
412
+ /**
413
+ * Display success message
414
+ * @param {string} configPath - Config file path
415
+ * @param {string} provider - Provider name
416
+ */
417
+ function showSuccessMessage(configPath, provider) {
418
+ console.log(boxen(
419
+ chalk.bold.green('✅ Installation Complete!') + '\n\n' +
420
+ chalk.white('Next steps:\n') +
421
+ chalk.cyan('1. Restart Claude Desktop\n') +
422
+ chalk.cyan('2. Try: "Say hello using text to speech"\n') +
423
+ chalk.cyan('3. Enjoy your talking Claude! 🎤'),
424
+ {
425
+ padding: 1,
426
+ margin: 1,
427
+ borderStyle: 'round',
428
+ borderColor: 'green'
429
+ }
430
+ ));
431
+
432
+ console.log(chalk.gray('\nConfiguration saved to:'));
433
+ console.log(chalk.gray(` ${configPath}\n`));
434
+
435
+ if (provider === 'piper') {
436
+ console.log(chalk.gray('Voice models will download automatically on first use.\n'));
437
+ }
438
+ }
439
+
440
+ export async function installMCP() {
441
+ const platform = os.platform();
442
+ const isWindows = platform === 'win32';
443
+
444
+ showWelcomeBanner(platform);
445
+
446
+ // Step 1: Check system dependencies
447
+ await checkSystemDependencies();
448
+
449
+ // Step 2: Find AgentVibes directory
450
+ const agentVibesDir = await locateAgentVibesDir(isWindows);
451
+
452
+ // Step 3: Windows-specific checks
453
+ if (isWindows) {
454
+ await setupWindowsWSL();
455
+ }
456
+
457
+ // Step 4: Choose TTS provider
458
+ const provider = await setupTTSProvider(isWindows);
459
+
460
+ // Step 5: Install Python dependencies
461
+ await setupPythonDependencies(isWindows);
462
+
463
+ // Step 6: Configure provider in AgentVibes
464
+ console.log(chalk.bold('⚙️ Step 6: Configuring AgentVibes...\n'));
465
+ const providerFile = path.join(agentVibesDir, '.claude', 'tts-provider.txt');
466
+ fs.writeFileSync(providerFile, provider);
467
+ console.log(chalk.green(`✓ Set provider to: ${provider}\n`));
468
+
469
+ // Step 7: Update Claude Desktop config
470
+ console.log(chalk.bold('📝 Step 7: Updating Claude Desktop configuration...\n'));
471
+ const configPath = updateClaudeConfig(agentVibesDir, provider, apiKey);
472
+ console.log(chalk.green(`✓ Updated: ${configPath}\n`));
473
+
474
+ // Success!
475
+ showSuccessMessage(configPath, provider);
476
+ }