stigmergy 1.0.71 → 1.0.72

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 +1 -1
  2. package/src/main.js +273 -35
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stigmergy",
3
- "version": "1.0.71",
3
+ "version": "1.0.72",
4
4
  "type": "commonjs",
5
5
  "description": "Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System",
6
6
  "main": "src/index.js",
package/src/main.js CHANGED
@@ -1,80 +1,318 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Stigmergy CLI - Main Entry Point (CommonJS)
4
+ * Stigmergy CLI - Enhanced Main Entry Point (CommonJS)
5
5
  * Multi-Agents Cross-AI CLI Tools Collaboration System
6
+ * Includes auto-scanning and installation capabilities
6
7
  */
7
8
 
8
- const { spawn } = require('child_process');
9
+ const { spawn, spawnSync } = require('child_process');
9
10
  const path = require('path');
10
11
  const fs = require('fs');
11
12
  const os = require('os');
12
13
 
14
+ // CLI Tools Configuration
15
+ const CLI_TOOLS = {
16
+ claude: { name: 'Claude CLI', version: 'claude --version', install: 'npm install -g @anthropic-ai/claude-3' },
17
+ gemini: { name: 'Gemini CLI', version: 'gemini --version', install: 'npm install -g @google/generative-ai-cli' },
18
+ qwen: { name: 'Qwen CLI', version: 'qwen --version', install: 'npm install -g @alibaba/qwen-cli' },
19
+ iflow: { name: 'iFlow CLI', version: 'iflow --version', install: 'npm install -g iflow-cli' },
20
+ qoder: { name: 'Qoder CLI', version: 'qodercli --version', install: 'npm install -g @qoder-ai/qodercli' },
21
+ codebuddy: { name: 'CodeBuddy CLI', version: 'codebuddy --version', install: 'npm install -g codebuddy-cli' },
22
+ copilot: { name: 'GitHub Copilot CLI', version: 'copilot --version', install: 'npm install -g @github/copilot-cli' },
23
+ codex: { name: 'OpenAI Codex CLI', version: 'codex --version', install: 'npm install -g openai-codex-cli' }
24
+ };
25
+
26
+ class StigmergyInstaller {
27
+ constructor() {
28
+ this.homeDir = os.homedir();
29
+ this.stigmergyDir = path.join(this.homeDir, '.stigmergy');
30
+ }
31
+
32
+ async ensureDirectory(dirPath) {
33
+ try {
34
+ await fs.promises.mkdir(dirPath, { recursive: true });
35
+ return true;
36
+ } catch (error) {
37
+ return false;
38
+ }
39
+ }
40
+
41
+ checkCLI(toolName) {
42
+ try {
43
+ const tool = CLI_TOOLS[toolName];
44
+ const result = spawnSync(tool.version.split(' ')[0], tool.version.split(' ').slice(1), {
45
+ stdio: 'ignore',
46
+ timeout: 10000,
47
+ env: { ...process.env }
48
+ });
49
+ return result.status === 0;
50
+ } catch (error) {
51
+ return false;
52
+ }
53
+ }
54
+
55
+ async scanAvailableTools() {
56
+ const results = {
57
+ total: Object.keys(CLI_TOOLS).length,
58
+ available: [],
59
+ unavailable: [],
60
+ details: []
61
+ };
62
+
63
+ console.log('šŸ” Scanning for AI CLI tools...');
64
+ console.log('='.repeat(50));
65
+
66
+ for (const [key, tool] of Object.entries(CLI_TOOLS)) {
67
+ const isAvailable = this.checkCLI(key);
68
+
69
+ if (isAvailable) {
70
+ results.available.push(key);
71
+ console.log(`āœ… ${tool.name}: Available`);
72
+ results.details.push({ name: tool.name, status: 'Available', install: tool.install });
73
+ } else {
74
+ results.unavailable.push(key);
75
+ console.log(`āŒ ${tool.name}: Not Available`);
76
+ results.details.push({ name: tool.name, status: 'Not Available', install: tool.install });
77
+ }
78
+ }
79
+
80
+ console.log('='.repeat(50));
81
+ console.log(`šŸ“Š Summary: ${results.available.length}/${results.total} tools available`);
82
+
83
+ return results;
84
+ }
85
+
86
+ async promptForInstallation(scanResults) {
87
+ if (scanResults.unavailable.length === 0) {
88
+ console.log('šŸŽ‰ All CLI tools are already installed!');
89
+ return [];
90
+ }
91
+
92
+ console.log('\nšŸŽÆ The following AI CLI tools can be automatically installed:');
93
+ scanResults.unavailable.forEach((toolKey, index) => {
94
+ const tool = CLI_TOOLS[toolKey];
95
+ console.log(` ${index + 1}. ${tool.name} - ${tool.install}`);
96
+ });
97
+
98
+ console.log('\nšŸ’” Installation Options:');
99
+ console.log(' - Enter numbers separated by spaces (e.g: 1 3 5)');
100
+ console.log(' - Enter "all" to install all missing tools');
101
+ console.log(' - Press Enter to skip installation');
102
+
103
+ return new Promise((resolve) => {
104
+ process.stdout.write('\nšŸ”§ Select tools to install: ');
105
+
106
+ process.stdin.once('data', (data) => {
107
+ const input = data.toString().trim();
108
+
109
+ if (input === '' || input.toLowerCase() === 'skip') {
110
+ resolve([]);
111
+ } else if (input.toLowerCase() === 'all') {
112
+ resolve(scanResults.unavailable);
113
+ } else {
114
+ const numbers = input.split(/\s+/).map(n => parseInt(n) - 1);
115
+ const selected = numbers
116
+ .filter(n => n >= 0 && n < scanResults.unavailable.length)
117
+ .map(n => scanResults.unavailable[n]);
118
+ resolve(selected);
119
+ }
120
+ });
121
+ });
122
+ }
123
+
124
+ async installTools(toolKeys) {
125
+ if (toolKeys.length === 0) {
126
+ console.log('ā­ļø Skipping installation.');
127
+ return;
128
+ }
129
+
130
+ console.log(`\nšŸš€ Installing ${toolKeys.length} AI CLI tools...`);
131
+ console.log('='.repeat(50));
132
+
133
+ for (const toolKey of toolKeys) {
134
+ const tool = CLI_TOOLS[toolKey];
135
+ console.log(`\nšŸ“¦ Installing ${tool.name}...`);
136
+
137
+ try {
138
+ const installProcess = spawn('npm', ['install', '-g'].concat(tool.install.split(' ').slice(3)), {
139
+ stdio: 'inherit'
140
+ });
141
+
142
+ await new Promise((resolve, reject) => {
143
+ installProcess.on('close', (code) => {
144
+ if (code === 0) {
145
+ console.log(`āœ… ${tool.name} installed successfully!`);
146
+ resolve();
147
+ } else {
148
+ console.log(`āŒ Failed to install ${tool.name}`);
149
+ reject(new Error(`Installation failed with code ${code}`));
150
+ }
151
+ });
152
+ });
153
+ } catch (error) {
154
+ console.log(`āŒ Error installing ${tool.name}:`, error.message);
155
+ }
156
+ }
157
+
158
+ console.log('\nšŸŽÆ Installation completed! Verifying...');
159
+ await this.verifyInstallation(toolKeys);
160
+ }
161
+
162
+ async verifyInstallation(toolKeys) {
163
+ console.log('='.repeat(50));
164
+ let successCount = 0;
165
+
166
+ for (const toolKey of toolKeys) {
167
+ const tool = CLI_TOOLS[toolKey];
168
+ if (this.checkCLI(toolKey)) {
169
+ console.log(`āœ… ${tool.name}: Successfully installed and functional!`);
170
+ successCount++;
171
+ } else {
172
+ console.log(`āŒ ${tool.name}: Installation verification failed`);
173
+ }
174
+ }
175
+
176
+ console.log(`\nšŸ“Š Installation Result: ${successCount}/${toolKeys.length} tools successfully installed`);
177
+
178
+ if (successCount === toolKeys.length) {
179
+ console.log('šŸŽ‰ All selected tools are now ready to use!');
180
+ }
181
+ }
182
+
183
+ async setupConfiguration() {
184
+ await this.ensureDirectory(this.stigmergyDir);
185
+
186
+ const configPath = path.join(this.stigmergyDir, 'config.json');
187
+ const defaultConfig = {
188
+ version: '1.0.71',
189
+ installed: new Date().toISOString(),
190
+ tools: {},
191
+ autoScan: true,
192
+ plugins: {
193
+ skills: false,
194
+ hooks: false,
195
+ collaboration: false
196
+ }
197
+ };
198
+
199
+ try {
200
+ await fs.promises.writeFile(configPath, JSON.stringify(defaultConfig, null, 2));
201
+ console.log('āš™ļø Configuration saved to:', configPath);
202
+ } catch (error) {
203
+ console.log('āš ļø Warning: Could not save configuration file');
204
+ }
205
+ }
206
+ }
207
+
13
208
  // Main CLI functionality
14
- function main() {
209
+ async function main() {
15
210
  const args = process.argv.slice(2);
211
+ const installer = new StigmergyInstaller();
16
212
 
213
+ // Setup stdin for interactive prompts
17
214
  if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
18
215
  console.log('Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System');
19
- console.log('Version: 1.0.70');
216
+ console.log('Version: 1.0.71');
20
217
  console.log('');
21
218
  console.log('Usage: stigmergy [command] [options]');
22
219
  console.log('');
23
220
  console.log('Commands:');
24
- console.log(' help, --help Show this help message');
25
- console.log(' version, --version Show version information');
26
- console.log(' status Check CLI tools status');
27
- console.log(' scan Scan for available AI CLI tools');
221
+ console.log(' help, --help Show this help message');
222
+ console.log(' version, --version Show version information');
223
+ console.log(' status Check CLI tools status');
224
+ console.log(' scan Scan for available AI CLI tools');
225
+ console.log(' install Interactive CLI tools installation');
226
+ console.log(' setup Initial setup and configuration');
28
227
  console.log('');
29
228
  console.log('Examples:');
30
- console.log(' stigmergy --version');
31
- console.log(' stigmergy status');
229
+ console.log(' stigmergy --help');
230
+ console.log(' stigmergy scan');
231
+ console.log(' stigmergy install');
232
+ console.log('');
233
+ console.log('Features:');
234
+ console.log(' āœ… Auto-scan for AI CLI tools');
235
+ console.log(' āœ… Interactive installation prompts');
236
+ console.log(' āœ… Automatic npm package installation');
237
+ console.log(' āœ… Configuration file management');
238
+ console.log(' āœ… Cross-platform support');
32
239
  console.log('');
33
240
  console.log('For more information, visit: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents');
34
241
  return;
35
242
  }
36
243
 
37
244
  if (args.includes('--version') || args.includes('version')) {
38
- console.log('1.0.70');
245
+ console.log('1.0.71');
39
246
  return;
40
247
  }
41
248
 
42
249
  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'));
250
+ console.log('šŸ” Checking AI CLI tools status...');
251
+ const scanResults = await installer.scanAvailableTools();
252
+
253
+ if (scanResults.available.length > 0) {
254
+ console.log('\nāœ… Available tools:');
255
+ scanResults.available.forEach(toolKey => {
256
+ console.log(` - ${CLI_TOOLS[toolKey].name}`);
257
+ });
258
+ }
49
259
  return;
50
260
  }
51
261
 
52
262
  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(', '));
263
+ const scanResults = await installer.scanAvailableTools();
264
+
265
+ if (scanResults.unavailable.length > 0) {
266
+ console.log('\nšŸ’” Run "stigmergy install" to install missing tools');
267
+ }
57
268
  return;
58
269
  }
59
270
 
60
- console.log('Unknown command. Use --help for usage information.');
61
- }
271
+ if (args.includes('install')) {
272
+ console.log('šŸš€ Stigmergy CLI Tools Installer');
273
+ console.log('This will help you install missing AI CLI tools.\n');
62
274
 
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';
275
+ const scanResults = await installer.scanAvailableTools();
276
+ const selectedTools = await installer.promptForInstallation(scanResults);
277
+ await installer.installTools(selectedTools);
278
+ await installer.setupConfiguration();
279
+
280
+ console.log('\nšŸŽ‰ Installation and setup completed!');
281
+ console.log('You can now use "stigmergy status" to verify all tools.');
282
+ return;
283
+ }
284
+
285
+ if (args.includes('setup')) {
286
+ console.log('āš™ļø Setting up Stigmergy CLI configuration...');
287
+ await installer.setupConfiguration();
288
+
289
+ const scanResults = await installer.scanAvailableTools();
290
+ console.log('\nšŸ“Š Current Status:');
291
+ console.log(` Available: ${scanResults.available.length} tools`);
292
+ console.log(` Missing: ${scanResults.unavailable.length} tools`);
293
+
294
+ if (scanResults.unavailable.length > 0) {
295
+ console.log('\nšŸ’” Run "stigmergy install" to install missing tools');
296
+ }
297
+
298
+ return;
72
299
  }
300
+
301
+ console.log('ā“ Unknown command. Use --help for usage information.');
73
302
  }
74
303
 
75
- // Execute main function
304
+ // Check if this file is being run directly
76
305
  if (require.main === module) {
77
- main();
306
+ // Enable stdin for interactive prompts
307
+ if (process.stdin.isTTY) {
308
+ process.stdin.resume();
309
+ process.stdin.setEncoding('utf8');
310
+ }
311
+
312
+ main().catch(error => {
313
+ console.error('āŒ Error:', error.message);
314
+ process.exit(1);
315
+ });
78
316
  }
79
317
 
80
- module.exports = { main, checkCLI };
318
+ module.exports = { main, StigmergyInstaller, CLI_TOOLS };