stigmergy 1.0.66 → 1.0.67

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.
package/package.json CHANGED
@@ -1,82 +1,82 @@
1
- {
2
- "name": "stigmergy",
3
- "version": "1.0.66",
4
- "type": "module",
5
- "description": "Stigmergy CLI - Multi-Agents跨AI CLI工具协作系统",
6
- "main": "src/main.js",
7
- "bin": {
8
- "stigmergy": "src/main.js"
9
- },
10
- "scripts": {
11
- "start": "node src/main.js",
12
- "deploy": "node src/deploy.js",
13
- "deploy-tools": "node deployment/deploy.js",
14
- "deploy-tools-all": "node deployment/deploy-with-install.js",
15
- "status": "node src/main.js status",
16
- "scan": "node src/main.js scan",
17
- "init": "node src/main.js init",
18
- "check-project": "node src/main.js check-project",
19
- "validate": "node src/main.js validate",
20
- "clean": "node src/main.js clean",
21
- "build": "node src/main.js validate",
22
- "build-only": "node src/deploy.js --build",
23
- "quick-install": "node src/quick_install.js",
24
- "quick-deploy": "node src/main.js quick-deploy",
25
- "postinstall": "node src/postinstall.js",
26
- "publish-to-npm": "node src/main.js validate",
27
- "unpublish": "npm unpublish",
28
- "version": "npm version patch",
29
- "test": "npm run validate"
30
- },
31
- "keywords": [
32
- "ai",
33
- "cli",
34
- "router",
35
- "collaboration",
36
- "smart-cli",
37
- "claude-cli",
38
- "gemini-cli",
39
- "qwen-cli",
40
- "iflow-cli",
41
- "qoder-cli",
42
- "codebuddy-cli",
43
- "copilot-cli",
44
- "cross-platform",
45
- "automation",
46
- "tools",
47
- "stigmergy",
48
- "multi-agents"
49
- ],
50
- "files": [
51
- "src/**/*.js",
52
- "src/**/*.py",
53
- "config/**/*.json",
54
- "templates/**/*.md",
55
- "bin/**/*.bat",
56
- "adapters/**/*"
57
- ],
58
- "repository": {
59
- "type": "git",
60
- "url": "git+https://github.com/ptreezh/stigmergy-CLI-Multi-Agents.git"
61
- },
62
- "author": "Stigmergy CLI Team",
63
- "license": "MIT",
64
- "engines": {
65
- "node": ">=16.0.0"
66
- },
67
- "dependencies": {
68
- "commander": "^12.0.0",
69
- "inquirer": "^9.0.0",
70
- "chalk": "^5.0.0",
71
- "js-yaml": "^4.1.0",
72
- "node-fetch": "^3.3.2"
73
- },
74
- "devDependencies": {},
75
- "npx": {
76
- "stigmergy-cli": "src/main.js"
77
- },
78
- "homepage": "https://github.com/ptreezh/stigmergy-CLI-Multi-Agents#readme",
79
- "bugs": {
80
- "url": "https://github.com/ptreezh/stigmergy-CLI-Multi-Agents/issues"
81
- }
82
- }
1
+ {
2
+ "name": "stigmergy",
3
+ "version": "1.0.67",
4
+ "type": "module",
5
+ "description": "Stigmergy CLI - Multi-Agents跨AI CLI工具协作系统",
6
+ "main": "src/main.js",
7
+ "bin": {
8
+ "stigmergy": "src/main.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node src/main.js",
12
+ "deploy": "node src/deploy.js",
13
+ "deploy-tools": "node deployment/deploy.js",
14
+ "deploy-tools-all": "node deployment/deploy-with-install.js",
15
+ "status": "node src/main.js status",
16
+ "scan": "node src/main.js scan",
17
+ "init": "node src/main.js init",
18
+ "check-project": "node src/main.js check-project",
19
+ "validate": "node src/main.js validate",
20
+ "clean": "node src/main.js clean",
21
+ "build": "node src/main.js validate",
22
+ "build-only": "node src/deploy.js --build",
23
+ "quick-install": "node src/quick_install.js",
24
+ "quick-deploy": "node src/main.js quick-deploy",
25
+ "postinstall": "node src/postinstall.js",
26
+ "publish-to-npm": "node src/main.js validate",
27
+ "unpublish": "npm unpublish",
28
+ "version": "npm version patch",
29
+ "test": "npm run validate"
30
+ },
31
+ "keywords": [
32
+ "ai",
33
+ "cli",
34
+ "router",
35
+ "collaboration",
36
+ "smart-cli",
37
+ "claude-cli",
38
+ "gemini-cli",
39
+ "qwen-cli",
40
+ "iflow-cli",
41
+ "qoder-cli",
42
+ "codebuddy-cli",
43
+ "copilot-cli",
44
+ "cross-platform",
45
+ "automation",
46
+ "tools",
47
+ "stigmergy",
48
+ "multi-agents"
49
+ ],
50
+ "files": [
51
+ "src/**/*.js",
52
+ "src/**/*.py",
53
+ "config/**/*.json",
54
+ "templates/**/*.md",
55
+ "bin/**/*.bat",
56
+ "adapters/**/*"
57
+ ],
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "git+https://github.com/ptreezh/stigmergy-CLI-Multi-Agents.git"
61
+ },
62
+ "author": "Stigmergy CLI Team",
63
+ "license": "MIT",
64
+ "engines": {
65
+ "node": ">=16.0.0"
66
+ },
67
+ "dependencies": {
68
+ "commander": "^12.0.0",
69
+ "inquirer": "^9.0.0",
70
+ "chalk": "^5.0.0",
71
+ "js-yaml": "^4.1.0",
72
+ "node-fetch": "^3.3.2"
73
+ },
74
+ "devDependencies": {},
75
+ "npx": {
76
+ "stigmergy-cli": "src/main.js"
77
+ },
78
+ "homepage": "https://github.com/ptreezh/stigmergy-CLI-Multi-Agents#readme",
79
+ "bugs": {
80
+ "url": "https://github.com/ptreezh/stigmergy-CLI-Multi-Agents/issues"
81
+ }
82
+ }
@@ -0,0 +1,486 @@
1
+ /**
2
+ * CLI命令行工具 - 智能适配器管理器
3
+ * 提供命令行接口管理Python/Node.js智能适配器
4
+ */
5
+
6
+ import fs from 'fs/promises';
7
+ import path from 'path';
8
+ import { SmartAdapterIntegration } from './smart_adapter_integration.js';
9
+
10
+ class CLIAdapterManager {
11
+ constructor() {
12
+ this.integration = new SmartAdapterIntegration();
13
+ this.cliCommands = ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot', 'codex'];
14
+ }
15
+
16
+ /**
17
+ * 初始化管理器
18
+ */
19
+ async initialize() {
20
+ await this.integration.initialize();
21
+ console.log('✅ CLI适配器管理器初始化完成');
22
+ }
23
+
24
+ /**
25
+ * 主命令处理
26
+ */
27
+ async handleCommand(command, args = []) {
28
+ switch (command) {
29
+ case 'init':
30
+ return await this.handleInit(args);
31
+ case 'status':
32
+ return await this.handleStatus(args);
33
+ case 'check':
34
+ return await this.handleCheck(args);
35
+ case 'execute':
36
+ return await this.handleExecute(args);
37
+ case 'install':
38
+ return await this.handleInstall(args);
39
+ case 'config':
40
+ return await this.handleConfig(args);
41
+ case 'switch-mode':
42
+ return await this.handleSwitchMode(args);
43
+ case 'stats':
44
+ return await this.handleStats(args);
45
+ case 'help':
46
+ return this.showHelp();
47
+ default:
48
+ console.log(`❌ 未知命令: ${command}`);
49
+ return this.showHelp();
50
+ }
51
+ }
52
+
53
+ /**
54
+ * 初始化适配器
55
+ */
56
+ async handleInit(args) {
57
+ console.log('🚀 初始化智能适配器系统...');
58
+
59
+ const force = args.includes('--force');
60
+ const mode = args.find(arg => arg.startsWith('--mode='))?.split('=')[1] || 'hybrid';
61
+
62
+ try {
63
+ // 初始化集成系统
64
+ await this.integration.initialize();
65
+
66
+ // 切换到指定模式
67
+ if (mode !== 'hybrid') {
68
+ const switchResult = await this.integration.switchIntegrationMode(mode);
69
+ if (!switchResult.success) {
70
+ console.error(`❌ 模式切换失败: ${switchResult.error}`);
71
+ return false;
72
+ }
73
+ }
74
+
75
+ // 检查所有适配器状态
76
+ const status = await this.integration.getSmartAdapterStatus();
77
+
78
+ console.log('\n📊 适配器状态:');
79
+ for (const [cliName, cliStatus] of Object.entries(status.systemStatus)) {
80
+ const adapterType = cliStatus.recommended?.type || 'none';
81
+ const adapterIcon = adapterType === 'python' ? '🐍' : adapterType === 'nodejs' ? '🟢' : '❌';
82
+ const fallbackIcon = cliStatus.fallback ? '🔄' : '';
83
+
84
+ console.log(` ${adapterIcon} ${fallbackIcon} ${cliName}: ${adapterType}`);
85
+
86
+ if (cliStatus.pythonAdapter && cliStatus.pythonAdapter.available) {
87
+ console.log(` 🐍 Python适配器: 可用`);
88
+ }
89
+ if (cliStatus.nodejsAdapter && cliStatus.nodejsAdapter.available) {
90
+ console.log(` 🟢 Node.js适配器: 可用`);
91
+ }
92
+ }
93
+
94
+ console.log('\n✅ 智能适配器系统初始化完成!');
95
+ console.log(` 集成模式: ${mode}`);
96
+ console.log(` Python可用: ${status.pythonAvailable}`);
97
+ console.log(` Node.js可用: ${status.nodeAvailable}`);
98
+ console.log(` 总适配器: ${status.totalCLIs}`);
99
+ console.log(` 可用适配器: ${status.availableCLIs}`);
100
+
101
+ return true;
102
+
103
+ } catch (error) {
104
+ console.error(`❌ 初始化失败: ${error.message}`);
105
+ return false;
106
+ }
107
+ }
108
+
109
+ /**
110
+ * 处理状态检查
111
+ */
112
+ async handleStatus(args) {
113
+ console.log('📊 检查智能适配器状态...\n');
114
+
115
+ const status = await this.integration.getSmartAdapterStatus();
116
+
117
+ console.log('🔍 系统环境:');
118
+ console.log(` 平台: ${status.nodeAvailable ? process.platform : 'N/A'}`);
119
+ console.log(` Python: ${status.pythonAvailable ? '✅ 可用' : '❌ 不可用'}`);
120
+ console.log(` Node.js: ${status.nodeAvailable ? '✅ 可用' : '❌ 不可用'}`);
121
+ console.log(` 降级模式: ${status.fallbackMode ? '✅ 启用' : '❌ 未启用'}`);
122
+
123
+ console.log('\n📋 适配器详情:');
124
+ for (const [cliName, cliStatus] of Object.entries(status.systemStatus)) {
125
+ const available = cliStatus.pythonAdapter?.available || cliStatus.nodejsAdapter?.available;
126
+ const icon = available ? '✅' : '❌';
127
+ const adapterType = cliStatus.recommended?.type || 'none';
128
+ const confidence = cliStatus.recommended?.confidence || 0;
129
+
130
+ console.log(` ${icon} ${cliName} - ${adapterType} (${confidence})`);
131
+
132
+ if (cliStatus.pythonAdapter) {
133
+ const pyStatus = cliStatus.pythonAdapter.available ? '✅ 可用' : '❌ 不可用';
134
+ const pyReason = cliStatus.pythonAdapter.reason || '';
135
+ console.log(` 🐍 Python: ${pyReason}`);
136
+ }
137
+
138
+ if (cliStatus.nodejsAdapter) {
139
+ const nodeStatus = cliStatus.nodejsAdapter.available ? '✅ 可用' : '❌ 不可用';
140
+ const nodeReason = cliStatus.nodejsAdapter.reason || '';
141
+ console.log(` 🟢 Node.js: ${nodeReason}`);
142
+ }
143
+
144
+ if (cliStatus.fallback) {
145
+ console.log(` 🔄 已启用降级模式`);
146
+ }
147
+ }
148
+
149
+ console.log('\n📈 统计信息:');
150
+ console.log(` 总适配器: ${status.totalCLIs}`);
151
+ console.log(` 可用适配器: ${status.availableCLIs}`);
152
+ console.log(` Python适配器: ${status.pythonAdapters}`);
153
+ console.log(` Node.js适配器: ${status.nodeAdapters}`);
154
+ console.log(` 降级适配器: ${status.fallbackAdapters}`);
155
+
156
+ return status;
157
+ }
158
+
159
+ /**
160
+ * 处理适配器检查
161
+ */
162
+ async handleCheck(args) {
163
+ const cliName = args[0];
164
+
165
+ if (!cliName) {
166
+ console.error('❌ 请指定要检查的CLI名称');
167
+ console.log('用法: stigmergy-cli check <cli-name>');
168
+ return false;
169
+ }
170
+
171
+ console.log(`🔍 检查 ${cliName} 适配器状态...\n`);
172
+
173
+ const status = await this.integration.getSmartAdapterStatus();
174
+ const cliStatus = status.systemStatus[cliName];
175
+
176
+ if (!cliStatus) {
177
+ console.error(`❌ 未找到 ${cliName} 适配器`);
178
+ return false;
179
+ }
180
+
181
+ console.log(`📋 ${cliName} 详细状态:`);
182
+ console.log(` 推荐适配器: ${cliStatus.recommended?.type || 'none'}`);
183
+ console.log(` 置信度: ${cliStatus.recommended?.confidence || 0}`);
184
+ console.log(` 降级模式: ${cliStatus.fallback ? '是' : '否'}`);
185
+
186
+ if (cliStatus.pythonAdapter) {
187
+ console.log(`\n🐍 Python适配器:`);
188
+ console.log(` 状态: ${cliStatus.pythonAdapter.available ? '✅ 可用' : '❌ 不可用'}`);
189
+ console.log(` 原因: ${cliStatus.pythonAdapter.reason || 'N/A'}`);
190
+
191
+ if (cliStatus.pythonAdapter.files) {
192
+ console.log(` 文件: ${cliStatus.pythonAdapter.files.length} 个`);
193
+ cliStatus.pythonAdapter.files.forEach(file => {
194
+ console.log(` - ${file}`);
195
+ });
196
+ }
197
+ }
198
+
199
+ if (cliStatus.nodejsAdapter) {
200
+ console.log(`\n🟢 Node.js适配器:`);
201
+ console.log(` 状态: ${cliStatus.nodejsAdapter.available ? '✅ 可用' : '❌ 不可用'}`);
202
+ console.log(` 原因: ${cliStatus.nodejsAdapter.reason || 'N/A'}`);
203
+ console.log(` 命令: ${cliStatus.nodejsAdapter.command || 'N/A'}`);
204
+ }
205
+
206
+ return cliStatus;
207
+ }
208
+
209
+ /**
210
+ * 处理CLI执行
211
+ */
212
+ async handleExecute(args) {
213
+ if (args.length === 0) {
214
+ console.error('❌ 请指定要执行的CLI和参数');
215
+ console.log('用法: stigmergy-cli execute <cli-name> [args...]');
216
+ return false;
217
+ }
218
+
219
+ const cliName = args[0];
220
+ const cliArgs = args.slice(1);
221
+
222
+ console.log(`🚀 执行 ${cliName} (智能选择适配器)...\n`);
223
+
224
+ try {
225
+ const result = await this.integration.smartExecuteCLI(cliName, cliArgs);
226
+
227
+ if (result.success) {
228
+ console.log(`✅ ${cliName} 执行成功`);
229
+ console.log(` 适配器: ${result.adapter}`);
230
+ console.log(` 方法: ${result.method}`);
231
+ if (result.fallback) {
232
+ console.log(` 降级: 是`);
233
+ }
234
+ } else {
235
+ console.error(`❌ ${cliName} 执行失败: ${result.error}`);
236
+ if (result.installCommand) {
237
+ console.log(`💡 安装命令: ${result.installCommand}`);
238
+ }
239
+ }
240
+
241
+ return result;
242
+
243
+ } catch (error) {
244
+ console.error(`❌ 执行异常: ${error.message}`);
245
+ return false;
246
+ }
247
+ }
248
+
249
+ /**
250
+ * 处理安装
251
+ */
252
+ async handleInstall(args) {
253
+ const cliName = args[0];
254
+ const force = args.includes('--force');
255
+
256
+ if (!cliName) {
257
+ console.error('❌ 请指定要安装的CLI');
258
+ console.log('用法: stigmergy-cli install <cli-name> [--force]');
259
+ return false;
260
+ }
261
+
262
+ console.log(`📦 安装 ${cliName} (智能选择适配器)...\n`);
263
+
264
+ try {
265
+ const result = await this.integration.installCLI(cliName);
266
+
267
+ if (result.success) {
268
+ console.log(`✅ ${cliName} 安装/检查完成`);
269
+ } else {
270
+ console.error(`❌ ${cliName} 安装失败: ${result.message}`);
271
+ if (result.installCommand) {
272
+ console.log(`💡 请手动运行: ${result.installCommand}`);
273
+ }
274
+ }
275
+
276
+ return result;
277
+
278
+ } catch (error) {
279
+ console.error(`❌ 安装异常: ${error.message}`);
280
+ return false;
281
+ }
282
+ }
283
+
284
+ /**
285
+ * 处理配置
286
+ */
287
+ async handleConfig(args) {
288
+ console.log('⚙️ 配置智能适配器系统\n');
289
+
290
+ if (args.length === 0) {
291
+ // 显示当前配置
292
+ const config = this.integration.config;
293
+ console.log('当前配置:');
294
+ console.log(JSON.stringify(config, null, 2));
295
+ return config;
296
+ }
297
+
298
+ const [action, ...configArgs] = args;
299
+
300
+ switch (action) {
301
+ case 'set':
302
+ return await this.setConfig(configArgs);
303
+ case 'get':
304
+ return await this.getConfig(configArgs);
305
+ case 'reset':
306
+ return await this.resetConfig();
307
+ default:
308
+ console.error(`❌ 未知配置操作: ${action}`);
309
+ return false;
310
+ }
311
+ }
312
+
313
+ /**
314
+ * 处理模式切换
315
+ */
316
+ async handleSwitchMode(args) {
317
+ const mode = args[0];
318
+
319
+ if (!mode) {
320
+ console.error('❌ 请指定要切换的模式');
321
+ console.log('用法: stigmergy-cli switch-mode <mode>');
322
+ console.log('可用模式: hybrid, python-only, nodejs-only');
323
+ return false;
324
+ }
325
+
326
+ console.log(`🔄 切换到 ${mode} 模式...`);
327
+
328
+ const result = await this.integration.switchIntegrationMode(mode);
329
+
330
+ if (result.success) {
331
+ console.log(`✅ 已切换到 ${result.mode} 模式`);
332
+ } else {
333
+ console.error(`❌ 模式切换失败: ${result.error}`);
334
+ }
335
+
336
+ return result;
337
+ }
338
+
339
+ /**
340
+ * 处理统计信息
341
+ */
342
+ async handleStats(args) {
343
+ console.log('📈 智能适配器统计信息\n');
344
+
345
+ const stats = await this.integration.getExecutionStats();
346
+
347
+ console.log('执行统计:');
348
+ console.log(` 总执行次数: ${stats.totalExecutions || 0}`);
349
+ console.log(` Python执行: ${stats.pythonExecutions || 0}`);
350
+ console.log(` Node.js执行: ${stats.nodeExecutions || 0}`);
351
+ console.log(` 成功率: ${stats.successRate || '0%'}`);
352
+
353
+ if (stats.error) {
354
+ console.log(` 错误: ${stats.error}`);
355
+ }
356
+
357
+ return stats;
358
+ }
359
+
360
+ /**
361
+ * 设置配置
362
+ */
363
+ async setConfig(args) {
364
+ if (args.length !== 2) {
365
+ console.error('❌ 用法: config set <key> <value>');
366
+ return false;
367
+ }
368
+
369
+ const [key, value] = args;
370
+
371
+ // 处理特殊值
372
+ let parsedValue = value;
373
+ if (value === 'true') parsedValue = true;
374
+ if (value === 'false') parsedValue = false;
375
+ if (!isNaN(value)) parsedValue = parseFloat(value);
376
+
377
+ this.integration.config[key] = parsedValue;
378
+ await this.integration.saveConfig();
379
+
380
+ console.log(`✅ 配置已设置: ${key} = ${parsedValue}`);
381
+ return true;
382
+ }
383
+
384
+ /**
385
+ * 获取配置
386
+ */
387
+ async getConfig(args) {
388
+ if (args.length !== 1) {
389
+ console.error('❌ 用法: config get <key>');
390
+ return false;
391
+ }
392
+
393
+ const key = args[0];
394
+ const value = this.integration.config[key];
395
+
396
+ console.log(`${key}: ${JSON.stringify(value)}`);
397
+ return value;
398
+ }
399
+
400
+ /**
401
+ * 重置配置
402
+ */
403
+ async resetConfig() {
404
+ // 重置为默认配置
405
+ this.integration.config = {
406
+ enablePython: true,
407
+ enableNodeJS: true,
408
+ autoFallback: true,
409
+ cacheStatus: true,
410
+ logLevel: 'info',
411
+ integrationMode: 'hybrid'
412
+ };
413
+
414
+ await this.integration.saveConfig();
415
+
416
+ console.log('✅ 配置已重置为默认值');
417
+ return true;
418
+ }
419
+
420
+ /**
421
+ * 显示帮助信息
422
+ */
423
+ showHelp() {
424
+ console.log(`
425
+ 🤖 智能适配器管理器 v1.0.0
426
+
427
+ 📚 可用命令:
428
+ init [options] - 初始化适配器系统
429
+ status - 显示系统状态
430
+ check <cli-name> - 检查指定CLI适配器
431
+ execute <cli> [args...] - 执行CLI (智能选择适配器)
432
+ install <cli> [--force] - 安装指定CLI适配器
433
+ config <action> [args] - 配置管理
434
+ switch-mode <mode> - 切换集成模式
435
+ stats - 显示执行统计
436
+ help - 显示此帮助信息
437
+
438
+ 💡 模式选项:
439
+ --mode=<mode> - 初始化时指定模式 (hybrid/python-only/nodejs-only)
440
+ --force - 强制重新安装
441
+
442
+ ⚙️ 配置操作:
443
+ set <key> <value> - 设置配置项
444
+ get <key> - 获取配置项
445
+ reset - 重置为默认配置
446
+
447
+ 🎯 集成模式:
448
+ hybrid - 智能选择 (Python > Node.js)
449
+ python-only - 仅使用Python适配器
450
+ nodejs-only - 仅使用Node.js适配器
451
+
452
+ 🔗 示例:
453
+ stigmergy-cli init --mode=hybrid
454
+ stigmergy-cli status
455
+ stigmergy-cli execute claude "生成代码"
456
+ stigmergy-cli check claude
457
+ stigmergy-cli install gemini --force
458
+ stigmergy-cli config set autoFallback true
459
+ stigmergy-cli switch-mode python-only
460
+ stigmergy-cli stats
461
+ `);
462
+ }
463
+ }
464
+
465
+ // 命令行入口
466
+ async function main() {
467
+ const args = process.argv.slice(2);
468
+ const command = args[0];
469
+
470
+ if (!command) {
471
+ const manager = new CLIAdapterManager();
472
+ manager.showHelp();
473
+ return;
474
+ }
475
+
476
+ const manager = new CLIAdapterManager();
477
+ await manager.initialize();
478
+ await manager.handleCommand(command, args.slice(1));
479
+ }
480
+
481
+ // 如果直接运行此文件
482
+ if (import.meta.url === `file://${process.argv[1]}`) {
483
+ main().catch(console.error);
484
+ }
485
+
486
+ export { CLIAdapterManager };