stigmergy 1.0.71 → 1.0.73

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 (2) hide show
  1. package/package.json +3 -2
  2. package/src/main.js +561 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stigmergy",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "type": "commonjs",
5
5
  "description": "Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System",
6
6
  "main": "src/index.js",
@@ -21,7 +21,8 @@
21
21
  "clean": "node src/index.js clean",
22
22
  "dev": "node --watch src/index.js",
23
23
  "lint": "eslint src/",
24
- "format": "prettier --write src/"
24
+ "format": "prettier --write src/",
25
+ "postinstall": "node src/main.js auto-install"
25
26
  },
26
27
  "keywords": [
27
28
  "ai",
package/src/main.js CHANGED
@@ -1,22 +1,500 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Stigmergy CLI - Main Entry Point (CommonJS)
4
+ * Stigmergy CLI - Automated Installation and Deployment System
5
5
  * Multi-Agents Cross-AI CLI Tools Collaboration System
6
6
  */
7
7
 
8
- const { spawn } = require('child_process');
8
+ const { spawn, spawnSync } = require('child_process');
9
9
  const path = require('path');
10
- const fs = require('fs');
10
+ const fs = require('fs/promises');
11
11
  const os = require('os');
12
12
 
13
+ // CLI Tools Configuration
14
+ const CLI_TOOLS = {
15
+ claude: {
16
+ name: 'Claude CLI',
17
+ version: 'claude --version',
18
+ install: 'npm install -g @anthropic-ai/claude-cli',
19
+ hooksDir: path.join(os.homedir(), '.claude', 'hooks'),
20
+ config: path.join(os.homedir(), '.claude', 'config.json')
21
+ },
22
+ gemini: {
23
+ name: 'Gemini CLI',
24
+ version: 'gemini --version',
25
+ install: 'npm install -g @google/generative-ai-cli',
26
+ hooksDir: path.join(os.homedir(), '.gemini', 'extensions'),
27
+ config: path.join(os.homedir(), '.gemini', 'config.json')
28
+ },
29
+ qwen: {
30
+ name: 'Qwen CLI',
31
+ version: 'qwen --version',
32
+ install: 'npm install -g @alibaba/qwen-cli',
33
+ hooksDir: path.join(os.homedir(), '.qwen', 'hooks'),
34
+ config: path.join(os.homedir(), '.qwen', 'config.json')
35
+ },
36
+ iflow: {
37
+ name: 'iFlow CLI',
38
+ version: 'iflow --version',
39
+ install: 'npm install -g iflow-cli',
40
+ hooksDir: path.join(os.homedir(), '.iflow', 'hooks'),
41
+ config: path.join(os.homedir(), '.iflow', 'config.json')
42
+ },
43
+ qoder: {
44
+ name: 'Qoder CLI',
45
+ version: 'qodercli --version',
46
+ install: 'npm install -g @qoder-ai/qodercli',
47
+ hooksDir: path.join(os.homedir(), '.qoder', 'hooks'),
48
+ config: path.join(os.homedir(), '.qoder', 'config.json')
49
+ },
50
+ codebuddy: {
51
+ name: 'CodeBuddy CLI',
52
+ version: 'codebuddy --version',
53
+ install: 'npm install -g codebuddy-cli',
54
+ hooksDir: path.join(os.homedir(), '.codebuddy', 'hooks'),
55
+ config: path.join(os.homedir(), '.codebuddy', 'config.json')
56
+ },
57
+ copilot: {
58
+ name: 'GitHub Copilot CLI',
59
+ version: 'copilot --version',
60
+ install: 'npm install -g @github/copilot-cli',
61
+ hooksDir: path.join(os.homedir(), '.copilot', 'mcp'),
62
+ config: path.join(os.homedir(), '.copilot', 'config.json')
63
+ },
64
+ codex: {
65
+ name: 'OpenAI Codex CLI',
66
+ version: 'codex --version',
67
+ install: 'npm install -g openai-codex-cli',
68
+ hooksDir: path.join(os.homedir(), '.config', 'codex', 'slash_commands'),
69
+ config: path.join(os.homedir(), '.codex', 'config.json')
70
+ }
71
+ };
72
+
73
+ class StigmergyInstaller {
74
+ constructor() {
75
+ this.homeDir = os.homedir();
76
+ this.stigmergyDir = path.join(this.homeDir, '.stigmergy');
77
+ this.projectDir = process.cwd();
78
+ }
79
+
80
+ async ensureDirectory(dirPath) {
81
+ try {
82
+ await fs.mkdir(dirPath, { recursive: true });
83
+ return true;
84
+ } catch (error) {
85
+ return false;
86
+ }
87
+ }
88
+
89
+ checkCLI(toolName) {
90
+ try {
91
+ const tool = CLI_TOOLS[toolName];
92
+ const command = tool.version.split(' ')[0];
93
+ const args = tool.version.split(' ').slice(1);
94
+
95
+ const result = spawnSync(command, args, {
96
+ stdio: 'ignore',
97
+ timeout: 10000,
98
+ env: { ...process.env }
99
+ });
100
+ return result.status === 0;
101
+ } catch (error) {
102
+ return false;
103
+ }
104
+ }
105
+
106
+ async scanAvailableTools() {
107
+ const results = {
108
+ total: Object.keys(CLI_TOOLS).length,
109
+ available: [],
110
+ unavailable: [],
111
+ details: []
112
+ };
113
+
114
+ console.log('[SCAN] Scanning for AI CLI tools on your system...');
115
+ console.log('='.repeat(60));
116
+
117
+ for (const [key, tool] of Object.entries(CLI_TOOLS)) {
118
+ const isAvailable = this.checkCLI(key);
119
+
120
+ if (isAvailable) {
121
+ results.available.push(key);
122
+ console.log(`[OK] ${tool.name}: Available (${tool.version})`);
123
+ results.details.push({
124
+ key,
125
+ name: tool.name,
126
+ status: 'Available',
127
+ install: tool.install,
128
+ hooksDir: tool.hooksDir
129
+ });
130
+ } else {
131
+ results.unavailable.push(key);
132
+ console.log(`[X] ${tool.name}: Not Available`);
133
+ results.details.push({
134
+ key,
135
+ name: tool.name,
136
+ status: 'Not Available',
137
+ install: tool.install,
138
+ hooksDir: tool.hooksDir
139
+ });
140
+ }
141
+ }
142
+
143
+ console.log('='.repeat(60));
144
+ console.log(`[SUMMARY] ${results.available.length}/${results.total} tools available`);
145
+ console.log('');
146
+
147
+ return results;
148
+ }
149
+
150
+ async promptForInstallation(scanResults) {
151
+ if (scanResults.unavailable.length === 0) {
152
+ console.log('[SUCCESS] All AI CLI tools are already installed!');
153
+ return [];
154
+ }
155
+
156
+ console.log('[INSTALL] The following AI CLI tools can be automatically installed:');
157
+ console.log('');
158
+
159
+ scanResults.unavailable.forEach((toolKey, index) => {
160
+ const tool = CLI_TOOLS[toolKey];
161
+ console.log(` ${index + 1}. ${tool.name}`);
162
+ console.log(` Install: ${tool.install}`);
163
+ console.log('');
164
+ });
165
+
166
+ console.log('[OPTIONS] Installation Options:');
167
+ console.log(' - Enter numbers separated by spaces (e.g: 1 3 5)');
168
+ console.log(' - Enter "all" to install all missing tools');
169
+ console.log(' - Enter "skip" to skip CLI installation');
170
+
171
+ return new Promise((resolve) => {
172
+ process.stdout.write('\n[SELECT] Select tools to install: ');
173
+
174
+ process.stdin.once('data', (data) => {
175
+ const input = data.toString().trim();
176
+
177
+ if (input === '' || input.toLowerCase() === 'skip') {
178
+ resolve([]);
179
+ } else if (input.toLowerCase() === 'all') {
180
+ resolve(scanResults.unavailable);
181
+ } else {
182
+ const numbers = input.split(/\s+/).map(n => parseInt(n) - 1);
183
+ const selected = numbers
184
+ .filter(n => n >= 0 && n < scanResults.unavailable.length)
185
+ .map(n => scanResults.unavailable[n]);
186
+ resolve(selected);
187
+ }
188
+ });
189
+ });
190
+ }
191
+
192
+ async installTools(toolKeys) {
193
+ if (toolKeys.length === 0) {
194
+ console.log('[SKIP] Skipping CLI tool installation.');
195
+ return;
196
+ }
197
+
198
+ console.log(`\n[INSTALL] Installing ${toolKeys.length} AI CLI tools...`);
199
+ console.log('='.repeat(60));
200
+
201
+ for (const toolKey of toolKeys) {
202
+ const tool = CLI_TOOLS[toolKey];
203
+ console.log(`\n[INSTALLING] Installing ${tool.name}...`);
204
+
205
+ try {
206
+ const installProcess = spawn('npm', ['install', '-g'], {
207
+ stdio: 'inherit',
208
+ shell: true
209
+ });
210
+
211
+ // Install specific package
212
+ const packageInstall = spawn('npm', ['install', '-g'].concat(tool.install.split(' ').slice(3)), {
213
+ stdio: 'inherit',
214
+ shell: true
215
+ });
216
+
217
+ await new Promise((resolve, reject) => {
218
+ packageInstall.on('close', (code) => {
219
+ if (code === 0) {
220
+ console.log(`[OK] ${tool.name} installed successfully!`);
221
+ resolve();
222
+ } else {
223
+ console.log(`[ERROR] Failed to install ${tool.name}`);
224
+ reject(new Error(`Installation failed with code ${code}`));
225
+ }
226
+ });
227
+ });
228
+ } catch (error) {
229
+ console.log(`[ERROR] Error installing ${tool.name}:`, error.message);
230
+ }
231
+ }
232
+
233
+ console.log('\n[VERIFY] CLI Installation completed! Verifying...');
234
+ await this.verifyInstallation(toolKeys);
235
+ }
236
+
237
+ async verifyInstallation(toolKeys) {
238
+ console.log('='.repeat(60));
239
+ let successCount = 0;
240
+
241
+ for (const toolKey of toolKeys) {
242
+ const tool = CLI_TOOLS[toolKey];
243
+ if (this.checkCLI(toolKey)) {
244
+ console.log(`[OK] ${tool.name}: Successfully installed and functional!`);
245
+ successCount++;
246
+ } else {
247
+ console.log(`[FAIL] ${tool.name}: Installation verification failed`);
248
+ }
249
+ }
250
+
251
+ console.log(`\n[RESULT] Installation Result: ${successCount}/${toolKeys.length} tools successfully installed`);
252
+
253
+ if (successCount === toolKeys.length) {
254
+ console.log('[SUCCESS] All selected CLI tools are now ready to use!');
255
+ }
256
+ }
257
+
258
+ async deployHooks(availableTools) {
259
+ if (availableTools.length === 0) {
260
+ console.log('[SKIP] No CLI tools available for hook deployment.');
261
+ return;
262
+ }
263
+
264
+ console.log(`\n[DEPLOY] Deploying Stigmergy hooks to ${availableTools.length} CLI tools...`);
265
+ console.log('='.repeat(60));
266
+
267
+ const hookTemplate = `#!/usr/bin/env node
268
+
269
+ /**
270
+ * Stigmergy Hook - ${new Date().toISOString()}
271
+ * Generated by Stigmergy CLI
272
+ */
273
+
274
+ const { spawn } = require('child_process');
275
+
276
+ // Stigmergy Hook Implementation
277
+ class StigmergyHook {
278
+ constructor() {
279
+ this.processArgs();
280
+ }
281
+
282
+ processArgs() {
283
+ const args = process.argv.slice(2);
284
+ if (args.length === 0) {
285
+ this.showHelp();
286
+ return;
287
+ }
288
+
289
+ const command = args[0];
290
+ switch (command) {
291
+ case 'collaborate':
292
+ this.handleCollaborate(args.slice(1));
293
+ break;
294
+ case 'status':
295
+ this.showStatus();
296
+ break;
297
+ case 'init':
298
+ this.initProject(args.slice(1));
299
+ break;
300
+ default:
301
+ this.showHelp();
302
+ }
303
+ }
304
+
305
+ handleCollaborate(args) {
306
+ console.log('[COLLAB] Stigmergy Collaboration System');
307
+ console.log('Available AI CLI tools:', Object.keys(CLI_TOOLS).join(', '));
308
+ }
309
+
310
+ showStatus() {
311
+ console.log('[STATUS] Stigmergy Hook Status: Active');
312
+ console.log('Configuration: Loaded successfully');
313
+ }
314
+
315
+ initProject(projectName) {
316
+ console.log('[INIT] Initializing Stigmergy project:', projectName || 'current');
317
+ console.log('[OK] Project configuration created');
318
+ }
319
+
320
+ showHelp() {
321
+ console.log('Stigmergy Hook - Multi-AI CLI Collaboration');
322
+ console.log('');
323
+ console.log('Commands:');
324
+ console.log(' collaborate [options] Start collaboration with other AI CLI tools');
325
+ console.log(' status Show hook status');
326
+ console.log(' init [project] Initialize Stigmergy project');
327
+ console.log(' help Show this help message');
328
+ console.log('');
329
+ console.log('Examples:');
330
+ console.log(' stigmergy-hook collaborate claude gemini');
331
+ console.log(' stigmergy-hook status');
332
+ console.log(' stigmergy-hook init my-project');
333
+ }
334
+ }
335
+
336
+ // Initialize hook
337
+ const hook = new StigmergyHook();
338
+ `;
339
+
340
+ let deployedCount = 0;
341
+
342
+ for (const toolKey of availableTools) {
343
+ const tool = CLI_TOOLS[toolKey];
344
+ const hooksDir = tool.hooksDir;
345
+
346
+ // Create hooks directory
347
+ await this.ensureDirectory(hooksDir);
348
+
349
+ // Deploy hook file
350
+ const hookFile = path.join(hooksDir, 'stigmergy-hook.cjs');
351
+ try {
352
+ await fs.writeFile(hookFile, hookTemplate, 'utf8');
353
+
354
+ // Make file executable on Unix systems
355
+ if (process.platform !== 'win32') {
356
+ const { spawn } = require('child_process');
357
+ spawn('chmod', ['+x', hookFile], { stdio: 'ignore' });
358
+ }
359
+
360
+ console.log(`[OK] ${tool.name}: Hook deployed to ${hooksDir}`);
361
+ deployedCount++;
362
+ } catch (error) {
363
+ console.log(`[FAIL] ${tool.name}: Failed to deploy hook - ${error.message}`);
364
+ }
365
+ }
366
+
367
+ console.log('\n[RESULT] Hook Deployment Result: ' + deployedCount + '/' + availableTools.length + ' hooks deployed');
368
+ }
369
+
370
+ async setupGlobalConfiguration() {
371
+ await this.ensureDirectory(this.stigmergyDir);
372
+
373
+ const globalConfig = {
374
+ version: '1.0.71',
375
+ installed: new Date().toISOString(),
376
+ projectPath: this.projectDir,
377
+ availableTools: [],
378
+ deployedHooks: [],
379
+ collaboration: {
380
+ enabled: true,
381
+ protocols: [
382
+ 'Use {cli} to {task}',
383
+ 'Call {cli} to {task}',
384
+ 'Ask {cli} for {task}',
385
+ 'Get {cli} to {task}',
386
+ 'Have {cli} {task}'
387
+ ],
388
+ examples: [
389
+ 'Use claude to help debug this code',
390
+ 'Call gemini to analyze the file',
391
+ 'Ask qwen to translate this text'
392
+ ]
393
+ }
394
+ };
395
+
396
+ const configPath = path.join(this.stigmergyDir, 'config.json');
397
+ try {
398
+ await fs.writeFile(configPath, JSON.stringify(globalConfig, null, 2));
399
+ console.log('[CONFIG] Global configuration saved to:', configPath);
400
+ } catch (error) {
401
+ console.log('[WARN] Warning: Could not save global configuration');
402
+ }
403
+
404
+ // Create project documentation template
405
+ const projectDocs = path.join(this.projectDir, 'STIGMERGY.md');
406
+ const docsTemplate = `# Stigmergy Multi-AI CLI Collaboration
407
+
408
+ This project is configured for Stigmergy-based multi-AI CLI collaboration.
409
+
410
+ ## Available AI CLI Tools
411
+
412
+ ${availableTools.map(tool => `- **${CLI_TOOLS[tool].name}**: \`stigmergy call ${tool}\``).join('\n')}
413
+
414
+ ## Usage Examples
415
+
416
+ ### Cross-CLI Collaboration
417
+ \`\`\bash
418
+ # Use Claude to analyze code
419
+ stigmergy call claude "analyze this function"
420
+
421
+ # Use Gemini for documentation
422
+ stigmergy call gemini "generate docs for this file"
423
+
424
+ # Use Qwen for translation
425
+ stigmergy call qwen "translate to English"
426
+ \`\`\`
427
+
428
+ ### Project Initialization
429
+ \`\`\bash
430
+ # Initialize with Claude as primary AI
431
+ stigmergy init --primary claude
432
+
433
+ # Initialize with multiple AI tools
434
+ stigmergy init --all-tools
435
+ \`\`\`
436
+
437
+ ## Configuration
438
+
439
+ Global configuration: \`~/.stigmergy/config.json\`
440
+
441
+ ## Getting Started
442
+
443
+ 1. Run \`stigmergy status\` to verify setup
444
+ 2. Use \`stigmergy call <ai-tool> "<prompt>"\` to collaborate with AI CLI tools
445
+ 3. Check project-specific configurations in individual CLI tool directories
446
+
447
+ For more information: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents
448
+ `;
449
+
450
+ try {
451
+ await fs.writeFile(projectDocs, docsTemplate, 'utf8');
452
+ console.log('[DOCS] Project documentation created: STIGMERGY.md');
453
+ } catch (error) {
454
+ console.log('[WARN] Warning: Could not create project documentation');
455
+ }
456
+ }
457
+
458
+ async showUsageInstructions() {
459
+ console.log('\n' + '='.repeat(60));
460
+ console.log('[SUCCESS] Stigmergy Installation and Deployment Complete!');
461
+ console.log('='.repeat(60));
462
+ console.log('');
463
+ console.log('[NEXT] Next Steps:');
464
+ console.log('');
465
+ console.log('1. Verify Installation:');
466
+ console.log(' stigmergy status');
467
+ console.log('');
468
+ console.log('2. Check Available Tools:');
469
+ console.log(' stigmergy scan');
470
+ console.log('');
471
+ console.log('3. Start Using AI CLI Collaboration:');
472
+ console.log(' stigmergy call claude "help me debug this code"');
473
+ console.log(' stigmergy call gemini "generate documentation"');
474
+ console.log(' stigmergy call qwen "translate to English"');
475
+ console.log('');
476
+ console.log('4. Initialize New Projects:');
477
+ console.log(' stigmergy init --primary claude');
478
+ console.log('');
479
+ console.log('[INFO] Documentation:');
480
+ console.log(' - Global Config: ~/.stigmergy/config.json');
481
+ console.log(' - Project Docs: ./STIGMERGY.md');
482
+ console.log(' - GitHub: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents');
483
+ console.log('');
484
+ console.log('[END] Happy collaborating with multiple AI CLI tools!');
485
+ }
486
+ }
487
+
13
488
  // Main CLI functionality
14
- function main() {
489
+ async function main() {
15
490
  const args = process.argv.slice(2);
491
+ const installer = new StigmergyInstaller();
16
492
 
17
493
  if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
18
494
  console.log('Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System');
19
- console.log('Version: 1.0.70');
495
+ console.log('Version: 1.0.73');
496
+ console.log('');
497
+ console.log('[SYSTEM] Automated Installation and Deployment System');
20
498
  console.log('');
21
499
  console.log('Usage: stigmergy [command] [options]');
22
500
  console.log('');
@@ -25,56 +503,102 @@ function main() {
25
503
  console.log(' version, --version Show version information');
26
504
  console.log(' status Check CLI tools status');
27
505
  console.log(' scan Scan for available AI CLI tools');
506
+ console.log(' install Auto-install missing CLI tools');
507
+ console.log(' deploy Deploy hooks to installed tools');
508
+ console.log(' setup Complete setup and configuration');
28
509
  console.log('');
29
- console.log('Examples:');
30
- console.log(' stigmergy --version');
31
- console.log(' stigmergy status');
510
+ console.log('[WORKFLOW] Automated Workflow:');
511
+ console.log(' 1. npm install -g stigmergy # Install Stigmergy');
512
+ console.log(' 2. stigmergy install # Auto-scan & install CLI tools');
513
+ console.log(' 3. stigmergy setup # Deploy hooks & config');
514
+ console.log(' 4. stigmergy call <ai> <prompt> # Start collaborating');
32
515
  console.log('');
33
516
  console.log('For more information, visit: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents');
34
517
  return;
35
518
  }
36
519
 
37
520
  if (args.includes('--version') || args.includes('version')) {
38
- console.log('1.0.70');
521
+ console.log('1.0.73');
39
522
  return;
40
523
  }
41
524
 
42
- if (args.includes('status')) {
43
- console.log('Checking AI CLI tools status...');
44
- console.log('Claude CLI:', checkCLI('claude'));
45
- console.log('Gemini CLI:', checkCLI('gemini'));
46
- console.log('Qwen CLI:', checkCLI('qwen'));
47
- console.log('iFlow CLI:', checkCLI('iflow'));
48
- console.log('Qoder CLI:', checkCLI('qodercli'));
49
- return;
50
- }
525
+ // Auto-install mode for postinstall script
526
+ if (args.includes('auto-install')) {
527
+ console.log('[AUTO-INSTALL] Stigmergy CLI - Automated Installation and Deployment');
528
+ console.log('Multi-AI CLI Tools Collaboration System v1.0.73');
529
+ console.log('='.repeat(60));
530
+
531
+ // Disable interactive prompts for auto-install mode
532
+ const originalPrompt = installer.promptForInstallation;
533
+ installer.promptForInstallation = async () => {
534
+ console.log('[AUTO-INSTALL] Skipping interactive CLI installation in postinstall mode');
535
+ console.log('[AUTO-INSTALL] You can run "stigmergy" manually to install CLI tools interactively');
536
+ return [];
537
+ };
538
+
539
+ // Run automated installation and deployment
540
+ console.log('\n[STEP 1] Scanning for AI CLI tools...');
541
+ const scanResults = await installer.scanAvailableTools();
51
542
 
52
- if (args.includes('scan')) {
53
- console.log('Scanning for available AI CLI tools...');
54
- const tools = ['claude', 'gemini', 'qwen', 'iflow', 'codebuddy', 'copilot', 'codex', 'qoder'];
55
- const available = tools.filter(tool => checkCLI(tool === 'qoder' ? 'qodercli' : tool));
56
- console.log(`Found ${available.length}/${tools.length} AI CLI tools:`, available.join(', '));
543
+ console.log('\n[STEP 2] Deploying Stigmergy hooks...');
544
+ await installer.deployHooks(scanResults.available);
545
+
546
+ console.log('\n[STEP 3] Setting up configuration...');
547
+ await installer.setupGlobalConfiguration(scanResults.available);
548
+
549
+ console.log('\n[AUTO-INSTALL] Stigmergy automated setup completed!');
550
+ console.log('[AUTO-INSTALL] Run "stigmergy" to start interactive CLI tool installation');
57
551
  return;
58
552
  }
59
553
 
60
- console.log('Unknown command. Use --help for usage information.');
61
- }
554
+ // Start automated installation and deployment
555
+ console.log('[START] Stigmergy CLI - Automated Installation and Deployment');
556
+ console.log('Multi-AI CLI Tools Collaboration System v1.0.73');
557
+ console.log('='.repeat(60));
62
558
 
63
- function checkCLI(command) {
64
- try {
65
- const result = require('child_process').spawnSync(command, ['--version'], {
66
- stdio: 'ignore',
67
- timeout: 5000
68
- });
69
- return result.status === 0 ? 'Available' : 'Not Available';
70
- } catch (error) {
71
- return 'Not Available';
559
+ // Step 1: Scan available CLI tools
560
+ console.log('\n[STEP 1] Scanning for AI CLI tools...');
561
+ const scanResults = await installer.scanAvailableTools();
562
+
563
+ // Step 2: Prompt for CLI tool installation
564
+ if (scanResults.unavailable.length > 0) {
565
+ console.log('\n[STEP 2] CLI Tool Installation');
566
+ const selectedTools = await installer.promptForInstallation(scanResults);
567
+ await installer.installTools(selectedTools);
568
+
569
+ // Re-scan after installation
570
+ if (selectedTools.length > 0) {
571
+ console.log('\n[RESCAN] Re-scanning after installation...');
572
+ scanResults.available = scanResults.available.concat(selectedTools.filter(tool => installer.checkCLI(tool)));
573
+ scanResults.unavailable = scanResults.unavailable.filter(tool => !selectedTools.includes(tool));
574
+ }
575
+ } else {
576
+ console.log('\n[STEP 2] All CLI tools already available!');
72
577
  }
578
+
579
+ // Step 3: Deploy hooks
580
+ console.log('\n[STEP 3] Deploying Stigmergy hooks...');
581
+ await installer.deployHooks(scanResults.available);
582
+
583
+ // Step 4: Setup configuration
584
+ console.log('\n[STEP 4] Setting up configuration...');
585
+ await installer.setupGlobalConfiguration(scanResults.available);
586
+
587
+ // Final instructions
588
+ await installer.showUsageInstructions();
73
589
  }
74
590
 
75
- // Execute main function
591
+ // Setup stdin for interactive prompts
76
592
  if (require.main === module) {
77
- main();
593
+ if (process.stdin.isTTY) {
594
+ process.stdin.resume();
595
+ process.stdin.setEncoding('utf8');
596
+ }
597
+
598
+ main().catch(error => {
599
+ console.error('[ERROR] Error:', error.message);
600
+ process.exit(1);
601
+ });
78
602
  }
79
603
 
80
- module.exports = { main, checkCLI };
604
+ module.exports = { main, StigmergyInstaller, CLI_TOOLS };