stigmergy 1.0.61 → 1.0.63
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 +2 -2
- package/src/enhanced-main-fixed.js +282 -0
- package/src/main.js +1 -4
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stigmergy",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.63",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Stigmergy CLI - Multi-Agents跨AI CLI工具协作系统",
|
|
6
6
|
"main": "src/main.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"stigmergy": "src/
|
|
8
|
+
"stigmergy": "src/main.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"start": "node src/main.js",
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stigmergy CLI - Enhanced Main Entry Point
|
|
5
|
+
* 支持自动扫描本地CLI环境并提供交互式安装选项
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { spawn } from 'child_process';
|
|
9
|
+
import fs from 'fs/promises';
|
|
10
|
+
import { join, dirname } from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
import { homedir } from 'os';
|
|
13
|
+
import { createInterface } from 'readline';
|
|
14
|
+
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = dirname(__filename);
|
|
17
|
+
|
|
18
|
+
// 定义支持的AI工具及其版本检测命令
|
|
19
|
+
const AI_TOOLS = [
|
|
20
|
+
{
|
|
21
|
+
name: 'claude',
|
|
22
|
+
displayName: 'Claude CLI',
|
|
23
|
+
required: true,
|
|
24
|
+
description: 'Anthropic Claude AI助手',
|
|
25
|
+
versionCommand: ['claude', '--version']
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'gemini',
|
|
29
|
+
displayName: 'Gemini CLI',
|
|
30
|
+
required: true,
|
|
31
|
+
description: 'Google Gemini AI助手',
|
|
32
|
+
versionCommand: ['gemini', '--version']
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'qwen',
|
|
36
|
+
displayName: 'QwenCode CLI',
|
|
37
|
+
required: false,
|
|
38
|
+
description: '阿里云通义千问代码助手',
|
|
39
|
+
versionCommand: ['qwen', '--version']
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'iflow',
|
|
43
|
+
displayName: 'iFlow CLI',
|
|
44
|
+
required: false,
|
|
45
|
+
description: 'iFlow工作流自动化工具',
|
|
46
|
+
versionCommand: ['iflow', '--version']
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'qoder',
|
|
50
|
+
displayName: 'Qoder CLI',
|
|
51
|
+
required: false,
|
|
52
|
+
description: 'Qoder代码生成工具',
|
|
53
|
+
versionCommand: ['qoder', '--version']
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'codebuddy',
|
|
57
|
+
displayName: 'CodeBuddy CLI',
|
|
58
|
+
required: false,
|
|
59
|
+
description: '腾讯CodeBuddy编程助手',
|
|
60
|
+
versionCommand: ['codebuddy', '--version']
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'copilot',
|
|
64
|
+
displayName: 'GitHub Copilot CLI',
|
|
65
|
+
required: false,
|
|
66
|
+
description: 'GitHub Copilot命令行工具',
|
|
67
|
+
versionCommand: ['copilot', '--version']
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'ollama',
|
|
71
|
+
displayName: 'Ollama CLI',
|
|
72
|
+
required: false,
|
|
73
|
+
description: '本地AI模型运行工具',
|
|
74
|
+
versionCommand: ['ollama', '--version']
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
class EnhancedStigmergyCLI {
|
|
79
|
+
constructor() {
|
|
80
|
+
this.configDir = join(homedir(), '.stigmergy-cli');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async checkToolAvailable(tool) {
|
|
84
|
+
return new Promise((resolve) => {
|
|
85
|
+
const [command, ...args] = tool.versionCommand;
|
|
86
|
+
|
|
87
|
+
const child = spawn(command, args, {
|
|
88
|
+
stdio: 'pipe',
|
|
89
|
+
timeout: 5000
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
let stdout = '';
|
|
93
|
+
let stderr = '';
|
|
94
|
+
|
|
95
|
+
child.stdout.on('data', (data) => {
|
|
96
|
+
stdout += data.toString();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
child.stderr.on('data', (data) => {
|
|
100
|
+
stderr += data.toString();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
child.on('close', (code) => {
|
|
104
|
+
// 如果命令成功执行并返回版本信息,则工具可用
|
|
105
|
+
if (code === 0 && (stdout.trim() !== '' || stderr.trim() !== '')) {
|
|
106
|
+
resolve(true);
|
|
107
|
+
} else {
|
|
108
|
+
resolve(false);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
child.on('error', () => {
|
|
113
|
+
// 命令不存在或执行失败
|
|
114
|
+
resolve(false);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async scanLocalEnvironment() {
|
|
120
|
+
console.log('🔍 正在扫描本地AI CLI工具环境...');
|
|
121
|
+
console.log('');
|
|
122
|
+
|
|
123
|
+
const availableTools = [];
|
|
124
|
+
const missingTools = [];
|
|
125
|
+
|
|
126
|
+
// 并行检测所有工具以提高性能
|
|
127
|
+
const detectionPromises = AI_TOOLS.map(async (tool) => {
|
|
128
|
+
const isAvailable = await this.checkToolAvailable(tool);
|
|
129
|
+
return { tool, isAvailable };
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const results = await Promise.all(detectionPromises);
|
|
133
|
+
|
|
134
|
+
results.forEach(({ tool, isAvailable }) => {
|
|
135
|
+
if (isAvailable) {
|
|
136
|
+
availableTools.push(tool);
|
|
137
|
+
console.log(`✅ ${tool.displayName} - 已安装`);
|
|
138
|
+
} else {
|
|
139
|
+
missingTools.push(tool);
|
|
140
|
+
const status = tool.required ? '❌ (必需)' : '⚠️ (可选)';
|
|
141
|
+
console.log(`${status} ${tool.displayName} - 未安装`);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
console.log('');
|
|
146
|
+
console.log(`📊 扫描结果: ${availableTools.length} 个工具已安装, ${missingTools.length} 个工具缺失`);
|
|
147
|
+
|
|
148
|
+
// 显示一些调试信息帮助用户理解
|
|
149
|
+
if (availableTools.length === 0) {
|
|
150
|
+
console.log('💡 提示: 如果您确信已安装某些工具但未被检测到,可能是因为:');
|
|
151
|
+
console.log(' • 工具命令名称与我们检测的名称不同');
|
|
152
|
+
console.log(' • 工具未添加到系统PATH环境变量');
|
|
153
|
+
console.log(' • 工具需要特殊的方式检测版本');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return { availableTools, missingTools };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async interactiveInstall(missingTools) {
|
|
160
|
+
if (missingTools.length === 0) {
|
|
161
|
+
console.log('🎉 所有工具都已安装!');
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
console.log('\n🔧 可以自动安装以下缺失的工具:');
|
|
166
|
+
missingTools.forEach((tool, index) => {
|
|
167
|
+
const required = tool.required ? '(必需)' : '(可选)';
|
|
168
|
+
console.log(` ${index + 1}. ${tool.displayName} ${required} - ${tool.description}`);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const rl = createInterface({
|
|
172
|
+
input: process.stdin,
|
|
173
|
+
output: process.stdout
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
return new Promise((resolve) => {
|
|
177
|
+
rl.question('\n是否要安装缺失的工具? (y/N): ', async (answer) => {
|
|
178
|
+
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
|
179
|
+
console.log('\n🚀 开始安装缺失的工具...');
|
|
180
|
+
for (const tool of missingTools) {
|
|
181
|
+
await this.installTool(tool);
|
|
182
|
+
}
|
|
183
|
+
console.log('✅ 工具安装完成!');
|
|
184
|
+
} else {
|
|
185
|
+
console.log('💡 您可以稍后手动安装这些工具。');
|
|
186
|
+
}
|
|
187
|
+
rl.close();
|
|
188
|
+
resolve();
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async installTool(tool) {
|
|
194
|
+
console.log(`📥 正在安装 ${tool.displayName}...`);
|
|
195
|
+
|
|
196
|
+
try {
|
|
197
|
+
// 这里应该实现具体的安装逻辑
|
|
198
|
+
// 例如:npm install -g @some/package
|
|
199
|
+
console.log(`⚠️ ${tool.displayName} 安装功能待实现`);
|
|
200
|
+
|
|
201
|
+
// 模拟安装过程
|
|
202
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
203
|
+
console.log(`✅ ${tool.displayName} 安装完成`);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.log(`❌ ${tool.displayName} 安装失败: ${error.message}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async deployAdapters() {
|
|
210
|
+
console.log('🔧 正在部署Stigmergy适配器到各个CLI工具...');
|
|
211
|
+
|
|
212
|
+
// 这里应该实现适配器部署逻辑
|
|
213
|
+
// 例如:将配置文件复制到各个CLI工具的配置目录
|
|
214
|
+
console.log('✅ 适配器部署完成!');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async run() {
|
|
218
|
+
const args = process.argv.slice(2);
|
|
219
|
+
const command = args[0];
|
|
220
|
+
|
|
221
|
+
switch (command) {
|
|
222
|
+
case 'scan':
|
|
223
|
+
const { missingTools } = await this.scanLocalEnvironment();
|
|
224
|
+
if (missingTools.length > 0) {
|
|
225
|
+
await this.interactiveInstall(missingTools);
|
|
226
|
+
}
|
|
227
|
+
break;
|
|
228
|
+
|
|
229
|
+
case 'install':
|
|
230
|
+
console.log('📥 安装Stigmergy CLI系统...');
|
|
231
|
+
// 实现安装逻辑
|
|
232
|
+
console.log('✅ Stigmergy CLI安装完成!');
|
|
233
|
+
break;
|
|
234
|
+
|
|
235
|
+
case 'deploy':
|
|
236
|
+
await this.deployAdapters();
|
|
237
|
+
break;
|
|
238
|
+
|
|
239
|
+
case 'init':
|
|
240
|
+
console.log('🚀 初始化Stigmergy项目...');
|
|
241
|
+
await this.scanLocalEnvironment();
|
|
242
|
+
console.log('✅ 项目初始化完成!');
|
|
243
|
+
break;
|
|
244
|
+
|
|
245
|
+
default:
|
|
246
|
+
await this.showHelp();
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async showHelp() {
|
|
252
|
+
console.log(`
|
|
253
|
+
🤖 Stigmergy CLI v1.0.0 - Multi-Agents跨AI CLI工具协作系统
|
|
254
|
+
|
|
255
|
+
📚 主要功能:
|
|
256
|
+
scan - 扫描本地AI CLI工具环境并提供安装建议
|
|
257
|
+
install - 安装Stigmergy CLI系统
|
|
258
|
+
deploy - 部署适配器到各个CLI工具
|
|
259
|
+
init - 初始化项目并扫描环境
|
|
260
|
+
|
|
261
|
+
💡 使用示例:
|
|
262
|
+
stigmergy scan # 扫描环境并交互式安装缺失工具
|
|
263
|
+
stigmergy init # 初始化项目
|
|
264
|
+
stigmergy deploy # 部署适配器
|
|
265
|
+
|
|
266
|
+
🌟 特色功能:
|
|
267
|
+
• 自动扫描本地已安装的AI CLI工具
|
|
268
|
+
• 交互式选择安装缺失的工具
|
|
269
|
+
• 智能部署适配器到各个CLI工具的正确目录
|
|
270
|
+
• 支持跨AI工具协作指令生成
|
|
271
|
+
|
|
272
|
+
📖 文档: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents#readme
|
|
273
|
+
`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// 运行CLI
|
|
278
|
+
const cli = new EnhancedStigmergyCLI();
|
|
279
|
+
cli.run().catch(error => {
|
|
280
|
+
console.error('❌ 程序运行出错:', error.message);
|
|
281
|
+
process.exit(1);
|
|
282
|
+
});
|
package/src/main.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Stigmergy CLI - Multi-Agents NPX 部署管理器
|
|
5
5
|
* 支持一键部署到各个AI CLI工具,实现真正的Stigmergy协作
|
|
6
6
|
*/
|
|
7
|
-
import { spawn } from 'child_process';
|
|
7
|
+
import { spawn, spawnSync } from 'child_process';
|
|
8
8
|
import fs from 'fs/promises';
|
|
9
9
|
import { join, dirname } from 'path';
|
|
10
10
|
import { fileURLToPath } from 'url';
|
|
@@ -441,19 +441,16 @@ class StigmergyCLIRouter {
|
|
|
441
441
|
|
|
442
442
|
async checkToolAvailable(cliName) {
|
|
443
443
|
try {
|
|
444
|
-
const { spawnSync } = require('child_process');
|
|
445
444
|
let result;
|
|
446
445
|
if (process.platform === 'win32') {
|
|
447
446
|
result = spawnSync('where', [cliName], { stdio: 'pipe' });
|
|
448
447
|
} else {
|
|
449
448
|
result = spawnSync('which', [cliName], { stdio: 'pipe' });
|
|
450
449
|
}
|
|
451
|
-
|
|
452
450
|
return result.status === 0;
|
|
453
451
|
} catch (e) {
|
|
454
452
|
// 如果系统命令失败,尝试npm检查
|
|
455
453
|
try {
|
|
456
|
-
const { spawnSync } = require('child_process');
|
|
457
454
|
const npmResult = spawnSync('npm', ['list', '-g', '--depth=0'], { encoding: 'utf-8' });
|
|
458
455
|
if (npmResult.status === 0 && npmResult.stdout) {
|
|
459
456
|
return npmResult.stdout.includes(cliName);
|