stigmergy 1.0.70 → 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 +3 -3
  2. package/src/main.js +318 -0
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "stigmergy",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "type": "commonjs",
5
5
  "description": "Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System",
6
- "main": "src/main.js",
6
+ "main": "src/index.js",
7
7
  "bin": {
8
- "stigmergy": "src/main.js"
8
+ "stigmergy": "src/index.js"
9
9
  },
10
10
  "scripts": {
11
11
  "start": "node src/main.js",
package/src/main.js ADDED
@@ -0,0 +1,318 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Stigmergy CLI - Enhanced Main Entry Point (CommonJS)
5
+ * Multi-Agents Cross-AI CLI Tools Collaboration System
6
+ * Includes auto-scanning and installation capabilities
7
+ */
8
+
9
+ const { spawn, spawnSync } = require('child_process');
10
+ const path = require('path');
11
+ const fs = require('fs');
12
+ const os = require('os');
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
+
208
+ // Main CLI functionality
209
+ async function main() {
210
+ const args = process.argv.slice(2);
211
+ const installer = new StigmergyInstaller();
212
+
213
+ // Setup stdin for interactive prompts
214
+ if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
215
+ console.log('Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System');
216
+ console.log('Version: 1.0.71');
217
+ console.log('');
218
+ console.log('Usage: stigmergy [command] [options]');
219
+ console.log('');
220
+ console.log('Commands:');
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');
227
+ console.log('');
228
+ console.log('Examples:');
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');
239
+ console.log('');
240
+ console.log('For more information, visit: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents');
241
+ return;
242
+ }
243
+
244
+ if (args.includes('--version') || args.includes('version')) {
245
+ console.log('1.0.71');
246
+ return;
247
+ }
248
+
249
+ if (args.includes('status')) {
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
+ }
259
+ return;
260
+ }
261
+
262
+ if (args.includes('scan')) {
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
+ }
268
+ return;
269
+ }
270
+
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');
274
+
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;
299
+ }
300
+
301
+ console.log('ā“ Unknown command. Use --help for usage information.');
302
+ }
303
+
304
+ // Check if this file is being run directly
305
+ if (require.main === module) {
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
+ });
316
+ }
317
+
318
+ module.exports = { main, StigmergyInstaller, CLI_TOOLS };