stigmergy 1.0.63 → 1.0.65
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 +5 -4
- package/src/adapters/claude/install_claude_integration.js +289 -0
- package/src/adapters/codebuddy/install_codebuddy_integration.js +275 -0
- package/src/adapters/codex/install_codex_integration.js +307 -0
- package/src/adapters/copilot/install_copilot_integration.js +391 -0
- package/src/adapters/gemini/install_gemini_integration.js +281 -0
- package/src/adapters/iflow/install_iflow_integration.js +318 -0
- package/src/adapters/qoder/install_qoder_integration.js +256 -0
- package/src/adapters/qoder/install_qoder_integration.py +72 -119
- package/src/adapters/qwencode/install_qwencode_integration.js +317 -0
- package/src/core/cli_interaction_detector.js +290 -0
- package/src/core/cross_cli_executor.py +712 -712
- package/src/core/environment_stigmergy_system.js +454 -0
- package/src/core/lightweight_cli_enhancer.js +282 -0
- package/src/core/models.py +217 -217
- package/src/core/verified_cross_cli_system.py +2 -6
- package/src/deploy.js +21 -1
- package/src/main.js +37 -8
- package/src/postinstall.js +383 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stigmergy",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.65",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Stigmergy CLI - Multi-Agents跨AI CLI工具协作系统",
|
|
6
6
|
"main": "src/main.js",
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"check-project": "node src/main.js check-project",
|
|
19
19
|
"validate": "node src/main.js validate",
|
|
20
20
|
"clean": "node src/main.js clean",
|
|
21
|
-
"build": "node src/
|
|
21
|
+
"build": "node src/main.js validate",
|
|
22
22
|
"build-only": "node src/deploy.js --build",
|
|
23
23
|
"quick-install": "node src/quick_install.js",
|
|
24
24
|
"quick-deploy": "node src/main.js quick-deploy",
|
|
25
|
-
"
|
|
25
|
+
"postinstall": "node src/postinstall.js",
|
|
26
|
+
"publish-to-npm": "node src/main.js validate",
|
|
26
27
|
"unpublish": "npm unpublish",
|
|
27
28
|
"version": "npm version patch",
|
|
28
29
|
"test": "npm run validate"
|
|
@@ -78,4 +79,4 @@
|
|
|
78
79
|
"bugs": {
|
|
79
80
|
"url": "https://github.com/ptreezh/stigmergy-CLI-Multi-Agents/issues"
|
|
80
81
|
}
|
|
81
|
-
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Claude CLI Hook集成安装脚本
|
|
5
|
+
* 为Claude CLI安装跨CLI协作感知能力
|
|
6
|
+
*
|
|
7
|
+
* 使用方法:
|
|
8
|
+
* node install_claude_integration.js [--verify|--uninstall]
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import fs from 'fs/promises';
|
|
12
|
+
import path from 'path';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
import { homedir } from 'os';
|
|
15
|
+
|
|
16
|
+
// 获取当前文件目录
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = path.dirname(__filename);
|
|
19
|
+
const projectRoot = path.join(__dirname, '..', '..', '..');
|
|
20
|
+
|
|
21
|
+
// Claude CLI配置路径
|
|
22
|
+
const CLAUDE_CONFIG_DIR = path.join(homedir(), '.config', 'claude');
|
|
23
|
+
const CLAUDE_HOOKS_FILE = path.join(CLAUDE_CONFIG_DIR, 'hooks.json');
|
|
24
|
+
|
|
25
|
+
async function createClaudeConfigDirectory() {
|
|
26
|
+
/** 创建Claude配置目录 */
|
|
27
|
+
try {
|
|
28
|
+
await fs.mkdir(CLAUDE_CONFIG_DIR, { recursive: true });
|
|
29
|
+
console.log(`[OK] 创建Claude配置目录: ${CLAUDE_CONFIG_DIR}`);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error(`[ERROR] 创建Claude配置目录失败: ${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function installClaudeHooks() {
|
|
36
|
+
/** 安装Claude Hook配置 */
|
|
37
|
+
// 读取现有hooks配置
|
|
38
|
+
let existingHooks = {};
|
|
39
|
+
try {
|
|
40
|
+
const hooksExists = await fs.access(CLAUDE_HOOKS_FILE).then(() => true).catch(() => false);
|
|
41
|
+
if (hooksExists) {
|
|
42
|
+
const hooksContent = await fs.readFile(CLAUDE_HOOKS_FILE, 'utf8');
|
|
43
|
+
existingHooks = JSON.parse(hooksContent);
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.warn(`⚠️ 读取现有hooks配置失败: ${error.message}`);
|
|
47
|
+
existingHooks = {};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 定义跨CLI协作的Hook配置
|
|
51
|
+
const crossCliHooks = {
|
|
52
|
+
"user_prompt_submit": {
|
|
53
|
+
"module": "src.adapters.claude.hook_adapter",
|
|
54
|
+
"class": "ClaudeHookAdapter",
|
|
55
|
+
"enabled": true,
|
|
56
|
+
"priority": 100,
|
|
57
|
+
"config": {
|
|
58
|
+
"cross_cli_enabled": true,
|
|
59
|
+
"supported_clis": ["gemini", "qwencode", "iflow", "qoder", "codebuddy", "copilot"],
|
|
60
|
+
"auto_detect": true,
|
|
61
|
+
"timeout": 30
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"tool_use_pre": {
|
|
65
|
+
"module": "src.adapters.claude.hook_adapter",
|
|
66
|
+
"class": "ClaudeHookAdapter",
|
|
67
|
+
"enabled": true,
|
|
68
|
+
"priority": 90,
|
|
69
|
+
"config": {
|
|
70
|
+
"cross_cli_enabled": true,
|
|
71
|
+
"log_requests": true
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"response_generated": {
|
|
75
|
+
"module": "src.adapters.claude.hook_adapter",
|
|
76
|
+
"class": "ClaudeHookAdapter",
|
|
77
|
+
"enabled": true,
|
|
78
|
+
"priority": 85,
|
|
79
|
+
"config": {
|
|
80
|
+
"add_collaboration_header": true,
|
|
81
|
+
"format_cross_cli_results": true
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// 合并配置(保留现有配置,添加协作功能)
|
|
87
|
+
const mergedHooks = { ...existingHooks };
|
|
88
|
+
Object.assign(mergedHooks, crossCliHooks);
|
|
89
|
+
|
|
90
|
+
// 写入hooks配置文件
|
|
91
|
+
try {
|
|
92
|
+
await fs.writeFile(CLAUDE_HOOKS_FILE, JSON.stringify(mergedHooks, null, 2), 'utf8');
|
|
93
|
+
console.log(`[OK] Claude Hook配置已安装: ${CLAUDE_HOOKS_FILE}`);
|
|
94
|
+
console.log("🔗 已安装的Hook:");
|
|
95
|
+
for (const hookName in crossCliHooks) {
|
|
96
|
+
console.log(` - ${hookName}: [OK] 跨CLI协作感知`);
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error(`❌ 安装Claude Hook配置失败: ${error.message}`);
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function copyAdapterFiles() {
|
|
106
|
+
/** 复制适配器文件到Claude配置目录 */
|
|
107
|
+
try {
|
|
108
|
+
// 创建适配器目录
|
|
109
|
+
const adapterDir = path.join(CLAUDE_CONFIG_DIR, 'adapters');
|
|
110
|
+
await fs.mkdir(adapterDir, { recursive: true });
|
|
111
|
+
|
|
112
|
+
// 复制适配器文件
|
|
113
|
+
const adapterFiles = [
|
|
114
|
+
'hook_adapter.py',
|
|
115
|
+
'claude_skills_integration.py',
|
|
116
|
+
'skills_hook_adapter.py'
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
for (const fileName of adapterFiles) {
|
|
120
|
+
const srcFile = path.join(__dirname, fileName);
|
|
121
|
+
const dstFile = path.join(adapterDir, fileName);
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
await fs.access(srcFile);
|
|
125
|
+
await fs.copyFile(srcFile, dstFile);
|
|
126
|
+
console.log(`[OK] 复制适配器文件: ${fileName}`);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.warn(`⚠️ 适配器文件不存在: ${fileName}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return true;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error(`❌ 复制适配器文件失败: ${error.message}`);
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function verifyInstallation() {
|
|
140
|
+
/** 验证安装是否成功 */
|
|
141
|
+
console.log('\n🔍 验证Claude CLI集成安装...');
|
|
142
|
+
|
|
143
|
+
// 检查配置目录
|
|
144
|
+
try {
|
|
145
|
+
await fs.access(CLAUDE_CONFIG_DIR);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error(`❌ 配置目录不存在: ${CLAUDE_CONFIG_DIR}`);
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// 检查hooks文件
|
|
152
|
+
try {
|
|
153
|
+
await fs.access(CLAUDE_HOOKS_FILE);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.error(`❌ Hooks配置文件不存在: ${CLAUDE_HOOKS_FILE}`);
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// 检查适配器目录
|
|
160
|
+
const adapterDir = path.join(CLAUDE_CONFIG_DIR, 'adapters');
|
|
161
|
+
try {
|
|
162
|
+
await fs.access(adapterDir);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
console.error(`❌ 适配器目录不存在: ${adapterDir}`);
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 读取并验证hooks配置
|
|
169
|
+
try {
|
|
170
|
+
const hooksContent = await fs.readFile(CLAUDE_HOOKS_FILE, 'utf8');
|
|
171
|
+
const hooks = JSON.parse(hooksContent);
|
|
172
|
+
|
|
173
|
+
// 检查关键hook是否存在
|
|
174
|
+
const requiredHooks = ['user_prompt_submit', 'tool_use_pre', 'response_generated'];
|
|
175
|
+
for (const hookName of requiredHooks) {
|
|
176
|
+
if (!hooks[hookName]) {
|
|
177
|
+
console.warn(`⚠️ 缺少必要Hook: ${hookName}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
console.log('[OK] Claude CLI集成安装验证通过');
|
|
182
|
+
return true;
|
|
183
|
+
} catch (error) {
|
|
184
|
+
console.error(`❌ 验证hooks配置失败: ${error.message}`);
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function uninstallClaudeIntegration() {
|
|
190
|
+
/** 卸载Claude集成 */
|
|
191
|
+
try {
|
|
192
|
+
// 删除hooks配置
|
|
193
|
+
try {
|
|
194
|
+
await fs.unlink(CLAUDE_HOOKS_FILE);
|
|
195
|
+
console.log(`[OK] 已删除Claude Hooks配置: ${CLAUDE_HOOKS_FILE}`);
|
|
196
|
+
} catch (error) {
|
|
197
|
+
if (error.code !== 'ENOENT') {
|
|
198
|
+
console.warn(`⚠️ 删除Hooks配置失败: ${error.message}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 删除适配器目录
|
|
203
|
+
const adapterDir = path.join(CLAUDE_CONFIG_DIR, 'adapters');
|
|
204
|
+
try {
|
|
205
|
+
await fs.rm(adapterDir, { recursive: true, force: true });
|
|
206
|
+
console.log(`[OK] 已删除Claude适配器目录: ${adapterDir}`);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
if (error.code !== 'ENOENT') {
|
|
209
|
+
console.warn(`⚠️ 删除适配器目录失败: ${error.message}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
console.log('[OK] Claude CLI集成卸载完成');
|
|
214
|
+
return true;
|
|
215
|
+
} catch (error) {
|
|
216
|
+
console.error(`❌ 卸载Claude集成失败: ${error.message}`);
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
async function main() {
|
|
222
|
+
/** 主函数 */
|
|
223
|
+
const args = process.argv.slice(2);
|
|
224
|
+
const options = {
|
|
225
|
+
verify: args.includes('--verify'),
|
|
226
|
+
uninstall: args.includes('--uninstall'),
|
|
227
|
+
install: args.includes('--install') || args.length === 0
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
console.log('Claude CLI跨CLI协作集成安装器');
|
|
231
|
+
console.log('='.repeat(50));
|
|
232
|
+
|
|
233
|
+
if (options.uninstall) {
|
|
234
|
+
console.log('[UNINSTALL] 卸载模式...');
|
|
235
|
+
await uninstallClaudeIntegration();
|
|
236
|
+
} else if (options.verify) {
|
|
237
|
+
console.log('🔍 验证模式...');
|
|
238
|
+
await verifyInstallation();
|
|
239
|
+
} else if (options.install) {
|
|
240
|
+
console.log('📦 安装模式...');
|
|
241
|
+
|
|
242
|
+
// 1. 创建配置目录
|
|
243
|
+
await createClaudeConfigDirectory();
|
|
244
|
+
|
|
245
|
+
// 2. 安装Hook配置
|
|
246
|
+
const hookSuccess = await installClaudeHooks();
|
|
247
|
+
|
|
248
|
+
// 3. 复制适配器文件
|
|
249
|
+
const adapterSuccess = await copyAdapterFiles();
|
|
250
|
+
|
|
251
|
+
const success = hookSuccess && adapterSuccess;
|
|
252
|
+
|
|
253
|
+
if (success) {
|
|
254
|
+
console.log('\n🎉 Claude CLI跨CLI协作集成安装成功!');
|
|
255
|
+
console.log('\n[INFO] 安装摘要:');
|
|
256
|
+
console.log(` [OK] 配置目录: ${CLAUDE_CONFIG_DIR}`);
|
|
257
|
+
console.log(` [OK] Hooks文件: ${CLAUDE_HOOKS_FILE}`);
|
|
258
|
+
console.log(` [OK] 适配器目录: ${path.join(CLAUDE_CONFIG_DIR, 'adapters')}`);
|
|
259
|
+
console.log(` [OK] 跨CLI协作Hook: 已启用`);
|
|
260
|
+
|
|
261
|
+
console.log('\n[INSTALL] 下一步:');
|
|
262
|
+
console.log(' 1. 运行其他CLI工具的安装脚本');
|
|
263
|
+
console.log(' 2. 使用 stigmergy-cli deploy --all 安装所有工具');
|
|
264
|
+
console.log(' 3. 使用 stigmergy-cli init 初始化项目');
|
|
265
|
+
} else {
|
|
266
|
+
console.log('\n❌ Claude CLI跨CLI协作集成安装失败');
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
console.log('使用方法:');
|
|
270
|
+
console.log(' node install_claude_integration.js [--install|--verify|--uninstall]');
|
|
271
|
+
console.log(' 默认为安装模式');
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// 运行主函数
|
|
276
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
277
|
+
main().catch(error => {
|
|
278
|
+
console.error(`[FATAL] ${error.message}`);
|
|
279
|
+
process.exit(1);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export {
|
|
284
|
+
createClaudeConfigDirectory,
|
|
285
|
+
installClaudeHooks,
|
|
286
|
+
copyAdapterFiles,
|
|
287
|
+
verifyInstallation,
|
|
288
|
+
uninstallClaudeIntegration
|
|
289
|
+
};
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CodeBuddy CLI Skills集成安装脚本
|
|
5
|
+
* 为CodeBuddy CLI安装跨CLI协作感知能力
|
|
6
|
+
*
|
|
7
|
+
* 使用方法:
|
|
8
|
+
* node install_codebuddy_integration.js [--verify|--uninstall]
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import fs from 'fs/promises';
|
|
12
|
+
import path from 'path';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
import { homedir } from 'os';
|
|
15
|
+
|
|
16
|
+
// 获取当前文件目录
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = path.dirname(__filename);
|
|
19
|
+
const projectRoot = path.join(__dirname, '..', '..', '..');
|
|
20
|
+
|
|
21
|
+
// CodeBuddy CLI配置路径
|
|
22
|
+
const CODEBUDDY_CONFIG_DIR = path.join(homedir(), '.codebuddy');
|
|
23
|
+
const CODEBUDDY_CONFIG_FILE = path.join(CODEBUDDY_CONFIG_DIR, 'buddy_config.json');
|
|
24
|
+
|
|
25
|
+
async function createCodeBuddyConfigDirectory() {
|
|
26
|
+
/** 创建CodeBuddy配置目录 */
|
|
27
|
+
try {
|
|
28
|
+
await fs.mkdir(CODEBUDDY_CONFIG_DIR, { recursive: true });
|
|
29
|
+
console.log(`[OK] 创建CodeBuddy配置目录: ${CODEBUDDY_CONFIG_DIR}`);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error(`[ERROR] 创建CodeBuddy配置目录失败: ${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function installCodeBuddySkills() {
|
|
36
|
+
/** 安装CodeBuddy Skills配置 */
|
|
37
|
+
// 读取现有buddy_config配置
|
|
38
|
+
let existingConfig = {};
|
|
39
|
+
try {
|
|
40
|
+
const configExists = await fs.access(CODEBUDDY_CONFIG_FILE).then(() => true).catch(() => false);
|
|
41
|
+
if (configExists) {
|
|
42
|
+
const configContent = await fs.readFile(CODEBUDDY_CONFIG_FILE, 'utf8');
|
|
43
|
+
existingConfig = JSON.parse(configContent);
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.warn(`⚠️ 读取现有buddy_config配置失败: ${error.message}`);
|
|
47
|
+
existingConfig = {};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 定义跨CLI协作的Skills配置
|
|
51
|
+
const crossCliSkills = {
|
|
52
|
+
"cross_cli_skill": {
|
|
53
|
+
"name": "CrossCLICoordinationSkill",
|
|
54
|
+
"description": "Cross-CLI工具协调技能",
|
|
55
|
+
"module": "src.adapters.codebuddy.skills_hook_adapter",
|
|
56
|
+
"class": "CodeBuddySkillsHookAdapter",
|
|
57
|
+
"enabled": true,
|
|
58
|
+
"priority": 100,
|
|
59
|
+
"triggers": [
|
|
60
|
+
"on_skill_activation",
|
|
61
|
+
"on_user_command"
|
|
62
|
+
],
|
|
63
|
+
"config": {
|
|
64
|
+
"cross_cli_enabled": true,
|
|
65
|
+
"supported_clis": ["claude", "gemini", "qwencode", "iflow", "qoder", "copilot"],
|
|
66
|
+
"auto_route": true,
|
|
67
|
+
"timeout": 30,
|
|
68
|
+
"collaboration_mode": "active"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// 合并配置(保留现有skills,添加协作功能)
|
|
74
|
+
const mergedConfig = { ...existingConfig };
|
|
75
|
+
if (!mergedConfig.skills) {
|
|
76
|
+
mergedConfig.skills = [];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 检查是否已存在跨CLI协调技能
|
|
80
|
+
const existingSkillNames = mergedConfig.skills.map(skill => skill.name || '');
|
|
81
|
+
const crossCliSkillName = "CrossCLICoordinationSkill";
|
|
82
|
+
|
|
83
|
+
if (!existingSkillNames.includes(crossCliSkillName)) {
|
|
84
|
+
mergedConfig.skills.push(crossCliSkills.cross_cli_skill);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 写入配置文件
|
|
88
|
+
try {
|
|
89
|
+
await fs.writeFile(CODEBUDDY_CONFIG_FILE, JSON.stringify(mergedConfig, null, 2), 'utf8');
|
|
90
|
+
console.log(`[OK] CodeBuddy配置已安装: ${CODEBUDDY_CONFIG_FILE}`);
|
|
91
|
+
console.log("🔗 已安装的Skills:");
|
|
92
|
+
|
|
93
|
+
for (const skill of mergedConfig.skills) {
|
|
94
|
+
const status = skill.enabled ? "[OK]" : "❌";
|
|
95
|
+
console.log(` - ${skill.name}: ${status}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return true;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error(`❌ 安装CodeBuddy配置失败: ${error.message}`);
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function copyAdapterFiles() {
|
|
106
|
+
/** 复制适配器文件到CodeBuddy配置目录 */
|
|
107
|
+
try {
|
|
108
|
+
// 创建适配器目录
|
|
109
|
+
await fs.mkdir(CODEBUDDY_CONFIG_DIR, { recursive: true });
|
|
110
|
+
|
|
111
|
+
// 复制适配器文件
|
|
112
|
+
const adapterFiles = [
|
|
113
|
+
'skills_hook_adapter.py',
|
|
114
|
+
'buddy_adapter.py'
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
for (const fileName of adapterFiles) {
|
|
118
|
+
const srcFile = path.join(__dirname, fileName);
|
|
119
|
+
const dstFile = path.join(CODEBUDDY_CONFIG_DIR, fileName);
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
await fs.access(srcFile);
|
|
123
|
+
await fs.copyFile(srcFile, dstFile);
|
|
124
|
+
console.log(`[OK] 复制适配器文件: ${fileName}`);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.warn(`⚠️ 适配器文件不存在: ${fileName}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return true;
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error(`❌ 复制适配器文件失败: ${error.message}`);
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function verifyInstallation() {
|
|
138
|
+
/** 验证安装是否成功 */
|
|
139
|
+
console.log('\n🔍 验证CodeBuddy CLI集成安装...');
|
|
140
|
+
|
|
141
|
+
// 检查配置目录
|
|
142
|
+
try {
|
|
143
|
+
await fs.access(CODEBUDDY_CONFIG_DIR);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error(`❌ 配置目录不存在: ${CODEBUDDY_CONFIG_DIR}`);
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 检查配置文件
|
|
150
|
+
try {
|
|
151
|
+
await fs.access(CODEBUDDY_CONFIG_FILE);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error(`❌ 配置文件不存在: ${CODEBUDDY_CONFIG_FILE}`);
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 读取并验证配置
|
|
158
|
+
try {
|
|
159
|
+
const configContent = await fs.readFile(CODEBUDDY_CONFIG_FILE, 'utf8');
|
|
160
|
+
const config = JSON.parse(configContent);
|
|
161
|
+
|
|
162
|
+
// 检查关键skill是否存在
|
|
163
|
+
const skills = config.skills || [];
|
|
164
|
+
const hasCrossCliSkill = skills.some(skill => skill.name === 'CrossCLICoordinationSkill');
|
|
165
|
+
|
|
166
|
+
if (!hasCrossCliSkill) {
|
|
167
|
+
console.warn('⚠️ 缺少跨CLI协作技能: CrossCLICoordinationSkill');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
console.log('[OK] CodeBuddy CLI集成安装验证通过');
|
|
171
|
+
return true;
|
|
172
|
+
} catch (error) {
|
|
173
|
+
console.error(`❌ 验证配置失败: ${error.message}`);
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async function uninstallCodeBuddyIntegration() {
|
|
179
|
+
/** 卸载CodeBuddy集成 */
|
|
180
|
+
try {
|
|
181
|
+
// 检查配置文件
|
|
182
|
+
const configExists = await fs.access(CODEBUDDY_CONFIG_FILE).then(() => true).catch(() => false);
|
|
183
|
+
if (!configExists) {
|
|
184
|
+
console.warn('⚠️ 配置文件不存在');
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 读取配置文件
|
|
189
|
+
const configContent = await fs.readFile(CODEBUDDY_CONFIG_FILE, 'utf8');
|
|
190
|
+
const config = JSON.parse(configContent);
|
|
191
|
+
|
|
192
|
+
// 移除跨CLI协调技能
|
|
193
|
+
const skills = config.skills || [];
|
|
194
|
+
const filteredSkills = skills.filter(skill => skill.name !== 'CrossCLICoordinationSkill');
|
|
195
|
+
config.skills = filteredSkills;
|
|
196
|
+
|
|
197
|
+
// 写入更新后的配置
|
|
198
|
+
await fs.writeFile(CODEBUDDY_CONFIG_FILE, JSON.stringify(config, null, 2), 'utf8');
|
|
199
|
+
|
|
200
|
+
console.log('[OK] CodeBuddy CLI集成卸载完成');
|
|
201
|
+
return true;
|
|
202
|
+
} catch (error) {
|
|
203
|
+
console.error(`❌ 卸载CodeBuddy集成失败: ${error.message}`);
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async function main() {
|
|
209
|
+
/** 主函数 */
|
|
210
|
+
const args = process.argv.slice(2);
|
|
211
|
+
const options = {
|
|
212
|
+
verify: args.includes('--verify'),
|
|
213
|
+
uninstall: args.includes('--uninstall'),
|
|
214
|
+
install: args.includes('--install') || args.length === 0
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
console.log('CodeBuddy CLI跨CLI协作集成安装器');
|
|
218
|
+
console.log('='.repeat(50));
|
|
219
|
+
|
|
220
|
+
if (options.uninstall) {
|
|
221
|
+
console.log('[UNINSTALL] 卸载模式...');
|
|
222
|
+
await uninstallCodeBuddyIntegration();
|
|
223
|
+
} else if (options.verify) {
|
|
224
|
+
console.log('🔍 验证模式...');
|
|
225
|
+
await verifyInstallation();
|
|
226
|
+
} else if (options.install) {
|
|
227
|
+
console.log('📦 安装模式...');
|
|
228
|
+
|
|
229
|
+
// 1. 创建配置目录
|
|
230
|
+
await createCodeBuddyConfigDirectory();
|
|
231
|
+
|
|
232
|
+
// 2. 安装Skills配置
|
|
233
|
+
const skillSuccess = await installCodeBuddySkills();
|
|
234
|
+
|
|
235
|
+
// 3. 复制适配器文件
|
|
236
|
+
const adapterSuccess = await copyAdapterFiles();
|
|
237
|
+
|
|
238
|
+
const success = skillSuccess && adapterSuccess;
|
|
239
|
+
|
|
240
|
+
if (success) {
|
|
241
|
+
console.log('\n🎉 CodeBuddy CLI跨CLI协作集成安装成功!');
|
|
242
|
+
console.log('\n[INFO] 安装摘要:');
|
|
243
|
+
console.log(` [OK] 配置目录: ${CODEBUDDY_CONFIG_DIR}`);
|
|
244
|
+
console.log(` [OK] 配置文件: ${CODEBUDDY_CONFIG_FILE}`);
|
|
245
|
+
console.log(` [OK] 跨CLI协作Skill: 已启用`);
|
|
246
|
+
|
|
247
|
+
console.log('\n[INSTALL] 下一步:');
|
|
248
|
+
console.log(' 1. 运行其他CLI工具的安装脚本');
|
|
249
|
+
console.log(' 2. 使用 stigmergy-cli deploy --all 安装所有工具');
|
|
250
|
+
console.log(' 3. 使用 stigmergy-cli init 初始化项目');
|
|
251
|
+
} else {
|
|
252
|
+
console.log('\n❌ CodeBuddy CLI跨CLI协作集成安装失败');
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
console.log('使用方法:');
|
|
256
|
+
console.log(' node install_codebuddy_integration.js [--install|--verify|--uninstall]');
|
|
257
|
+
console.log(' 默认为安装模式');
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// 运行主函数
|
|
262
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
263
|
+
main().catch(error => {
|
|
264
|
+
console.error(`[FATAL] ${error.message}`);
|
|
265
|
+
process.exit(1);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export {
|
|
270
|
+
createCodeBuddyConfigDirectory,
|
|
271
|
+
installCodeBuddySkills,
|
|
272
|
+
copyAdapterFiles,
|
|
273
|
+
verifyInstallation,
|
|
274
|
+
uninstallCodeBuddyIntegration
|
|
275
|
+
};
|