stigmergy 1.3.77 → 1.4.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "stigmergy",
3
- "version": "1.3.77",
3
+ "version": "1.4.0",
4
4
  "description": "Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -53,6 +53,7 @@
53
53
  "gemini-cli",
54
54
  "qwen-cli",
55
55
  "iflow-cli",
56
+ "kilocode-cli",
56
57
  "real-testing",
57
58
  "python-free"
58
59
  ],
@@ -92,6 +93,7 @@
92
93
  "iFlow",
93
94
  "QoderCLI",
94
95
  "GLM4.5",
96
+ "KiloCode",
95
97
  "Other AI Systems"
96
98
  ],
97
99
  "license": "MIT"
@@ -2,77 +2,75 @@
2
2
  * Stigmergy Post-install 部署脚本
3
3
  * 在 npm install -g stigmergy 后自动:
4
4
  * 1. 运行 auto-install(安装 CLI tools)
5
- * 2. 部署 iflow 的 agents 和 skills 到各 CLI
5
+ * 2. 部署 hooks 和 skills
6
+ * 3. 自动进入交互模式
6
7
  */
7
8
 
8
- const { spawn } = require('child_process');
9
- const path = require('path');
10
- const fs = require('fs').promises;
9
+ const { spawn } = require("child_process");
10
+ const path = require("path");
11
+ const fs = require("fs").promises;
11
12
 
12
13
  async function postInstallDeploy() {
13
- console.log('\n🚀 Stigmergy 安装后配置...');
14
- console.log('=' .repeat(60));
14
+ console.log("\n🚀 Stigmergy 安装后配置...");
15
+ console.log("=".repeat(60));
15
16
 
16
- // 步骤1: 运行 auto-install
17
- console.log('\n📦 步骤 1/2: 自动安装 CLI tools...\n');
17
+ // 步骤1: 运行 auto-install(安装 CLI tools)
18
+ console.log("\n📦 步骤 1/3: 自动安装 CLI tools...\n");
18
19
 
19
20
  try {
20
- await runCommand('node', ['src/index.js', 'auto-install']);
21
+ await runCommand("node", ["src/index.js", "auto-install"]);
22
+ console.log("\n✅ CLI tools 安装完成\n");
21
23
  } catch (error) {
22
- console.log(' ⚠️ Auto-install 遇到问题(这是正常的)');
24
+ console.log(" ⚠️ Auto-install 遇到问题,继续部署...\n");
23
25
  }
24
26
 
25
- // 步骤2: 部署 iflow 资源
26
- console.log('\n📦 步骤 2/2: 部署 iflow 的 agents 和 skills...\n');
27
+ // 步骤2: 部署 hooks 和 skills
28
+ console.log("📦 步骤 2/3: 部署 hooks 和 skills...\n");
27
29
 
28
- const bundleDir = path.join(__dirname, '..', 'config', 'bundle', 'iflow-bundle');
29
-
30
- // 检查 bundle 是否存在
31
30
  try {
32
- await fs.access(bundleDir);
31
+ const ConfigDeployer = require("../src/core/config/ConfigDeployer");
32
+ const deployer = new ConfigDeployer({
33
+ packageDir: path.join(
34
+ __dirname,
35
+ "..",
36
+ "config",
37
+ "bundle",
38
+ "iflow-bundle",
39
+ ),
40
+ force: false,
41
+ verbose: false,
42
+ dryRun: false,
43
+ });
44
+ await deployer.run();
33
45
  } catch (error) {
34
- console.log(' ⚠️ 未找到 iflow 资源包(这是正常的)');
35
- console.log(' 💡 如需部署,请先运行: node scripts/bundle-iflow-resources.js');
36
- return;
46
+ console.log(" ⚠️ 资源包部署跳过(可稍后手动运行: stigmergy deploy)\n");
37
47
  }
38
48
 
39
- // 检查 config-bundle.json 是否存在
40
- const bundlePath = path.join(bundleDir, 'config-bundle.json');
41
49
  try {
42
- await fs.access(bundlePath);
50
+ await runCommand("node", ["src/index.js", "deploy"]);
43
51
  } catch (error) {
44
- console.log(' ⚠️ config-bundle.json 不存在');
45
- console.log(' 💡 请先运行: node scripts/bundle-iflow-resources.js');
46
- return;
52
+ console.log(" ⚠️ Hooks 部署遇到问题(这是正常的)");
47
53
  }
48
54
 
49
- try {
50
- const ConfigDeployer = require('../src/core/config/ConfigDeployer');
51
-
52
- // 创建 deployer 实例
53
- const deployer = new ConfigDeployer({
54
- packageDir: bundleDir,
55
- force: true, // 强制覆盖,确保首次安装时正确部署
56
- verbose: false, // 静默模式,不干扰安装
57
- dryRun: false
58
- });
59
-
60
- // 执行部署
61
- const result = await deployer.run();
55
+ console.log("\n✅ 部署完成!");
62
56
 
63
- if (result.success) {
64
- console.log('\n 部署完成!');
65
- console.log(`📊 统计: ${result.summary.totalSuccess} 项成功, ${result.summary.totalSkip} 项跳过`);
66
- }
57
+ // 步骤3: 自动进入交互模式
58
+ console.log("\n📦 步骤 3/3: 启动交互模式...\n");
59
+ console.log("=".repeat(60));
60
+ console.log("✅ Stigmergy 安装配置完成!");
61
+ console.log("🚀 正在进入交互模式...\n");
67
62
 
68
- } catch (error) {
69
- console.log(' ⚠️ 资源部署遇到问题(这是正常的)');
70
- console.log(` 💡 可以稍后手动运行: stigmergy deploy`);
71
- }
63
+ const interactiveProcess = spawn("node", ["src/index.js", "interactive"], {
64
+ stdio: "inherit",
65
+ shell: true,
66
+ detached: true,
67
+ });
72
68
 
73
- console.log('\n' + '=' .repeat(60));
74
- console.log('✅ Stigmergy 安装完成!');
75
- console.log('💡 运行: stigmergy status\n');
69
+ interactiveProcess.on("error", (error) => {
70
+ console.log(
71
+ " ⚠️ 无法自动进入交互模式,请手动运行: stigmergy interactive",
72
+ );
73
+ });
76
74
  }
77
75
 
78
76
  /**
@@ -81,11 +79,19 @@ async function postInstallDeploy() {
81
79
  function runCommand(cmd, args) {
82
80
  return new Promise((resolve, reject) => {
83
81
  const child = spawn(cmd, args, {
84
- stdio: 'inherit',
85
- shell: true
82
+ stdio: "pipe",
83
+ shell: true,
84
+ });
85
+
86
+ child.stdout.on("data", (data) => {
87
+ process.stdout.write(data.toString());
88
+ });
89
+
90
+ child.stderr.on("data", (data) => {
91
+ process.stderr.write(data.toString());
86
92
  });
87
93
 
88
- child.on('close', (code) => {
94
+ child.on("close", (code) => {
89
95
  if (code === 0) {
90
96
  resolve();
91
97
  } else {
@@ -93,7 +99,7 @@ function runCommand(cmd, args) {
93
99
  }
94
100
  });
95
101
 
96
- child.on('error', (error) => {
102
+ child.on("error", (error) => {
97
103
  reject(error);
98
104
  });
99
105
  });
@@ -101,6 +107,5 @@ function runCommand(cmd, args) {
101
107
 
102
108
  // 运行部署(异步,不阻塞安装)
103
109
  postInstallDeploy().catch(() => {
104
- // 静默失败,不干扰 npm install
105
110
  process.exit(0);
106
111
  });
@@ -0,0 +1,340 @@
1
+ # CLI Integration SOP for Stigmergy
2
+
3
+ ## Overview
4
+
5
+ This document provides a standardized Standard Operating Procedure (SOP) for integrating a new CLI tool into the Stigmergy Multi-Agents CLI Collaboration System.
6
+
7
+ ## CLI Integration Checklist
8
+
9
+ ### Phase 1: Basic Configuration (Files to Modify)
10
+
11
+ #### 1.1 Add to `src/core/cli_tools.js`
12
+
13
+ ```javascript
14
+ // Add new CLI entry to CLI_TOOLS object
15
+ <CLI_NAME>: {
16
+ name: '<CLI Full Name>',
17
+ version: '<CLI_NAME> --version',
18
+ install: 'npm install -g <NPM_PACKAGE>',
19
+ hooksDir: path.join(os.homedir(), '.<CLI_NAME>', 'hooks'),
20
+ config: path.join(os.homedir(), '.<CLI_NAME>', 'config.json'),
21
+ autoInstall: true/false, // Set to true for auto-install during postinstall
22
+ },
23
+ ```
24
+
25
+ #### 1.2 Add to `src/core/cli_path_detector.js`
26
+
27
+ ```javascript
28
+ // Add to cliNameMap
29
+ this.cliNameMap = {
30
+ // ... existing entries
31
+ "<CLI_NAME>": ["<CLI_COMMAND>"], // Command to detect (e.g., 'kilo' for kilocode)
32
+ };
33
+ ```
34
+
35
+ ### Phase 2: CLI Adapters (src/core/cli_adapters.js)
36
+
37
+ #### 2.1 Add adapter configuration
38
+
39
+ ```javascript
40
+ <CLI_NAME>: {
41
+ // Interactive mode: prompt -> CLI args for interactive execution
42
+ interactive: (prompt) => {
43
+ return prompt ? ['-i', prompt] : [];
44
+ },
45
+
46
+ // One-time mode: prompt -> CLI args for non-interactive execution
47
+ oneTime: (prompt) => {
48
+ return ['-p', prompt];
49
+ },
50
+
51
+ // Auto mode: args for concurrent/routing modes
52
+ autoMode: () => ['--yolo', '--print'],
53
+
54
+ supportsInteractive: true,
55
+ supportsOneTime: true,
56
+ defaultMode: 'interactive',
57
+ verified: false // Set to true after testing
58
+ }
59
+ ```
60
+
61
+ ### Phase 3: Help Analyzer (src/core/cli_help_analyzer.js)
62
+
63
+ #### 3.1 Add to enhancedPatterns
64
+
65
+ ```javascript
66
+ enhancedPatterns: {
67
+ // ... existing entries
68
+ '<CLI_NAME>': {
69
+ commandFormat: '<CLI_COMMAND> -p "{prompt}"',
70
+ agentDetection: true,
71
+ skillDetection: true,
72
+ naturalLanguageSupport: true,
73
+ positionalArgs: true/false,
74
+ agentTypes: ['expert', 'skill', 'analysis', 'agent'],
75
+ skillKeywords: ['技能', '智能体', '分析', '工具', '方法'],
76
+ examples: [
77
+ '<CLI_COMMAND> -p "请使用分析技能分析问题"',
78
+ '<CLI_COMMAND> -p "执行某个任务"'
79
+ ]
80
+ }
81
+ }
82
+ ```
83
+
84
+ #### 3.2 Add to skillMapping (for cross-CLI skill translation)
85
+
86
+ ```javascript
87
+ skillMapping: {
88
+ '<SKILL_NAME>': {
89
+ // ... existing CLI entries
90
+ '<CLI_NAME>': '<SKILL_NAME_IN_CLI>'
91
+ }
92
+ }
93
+ ```
94
+
95
+ ### Phase 4: Concurrent Execution (src/cli/commands/concurrent.js)
96
+
97
+ #### 4.1 Add to availableCLIs array
98
+
99
+ ```javascript
100
+ const availableCLIs = ["claude", "qwen", "gemini", "iflow", "<CLI_NAME>"];
101
+ ```
102
+
103
+ #### 4.2 Add switch case for command arguments
104
+
105
+ ```javascript
106
+ case '<CLI_NAME>':
107
+ // Determine correct argument format
108
+ args = ['-p', prompt]; // or positional args
109
+ break;
110
+ ```
111
+
112
+ ### Phase 5: Interactive Mode (src/interactive/InteractiveModeController.js)
113
+
114
+ #### 5.1 Add to fallback registry in \_scanInstalledCLITools
115
+
116
+ ```javascript
117
+ <CLI_NAME>: { name: '<CLI_NAME>', available: false }
118
+ ```
119
+
120
+ ### Phase 6: Hook Deployment (src/core/coordination/nodejs/HookDeploymentManager.js)
121
+
122
+ #### 6.1 Add to supportedCLIs array
123
+
124
+ ```javascript
125
+ this.supportedCLIs = [
126
+ // ... existing CLIs
127
+ "<CLI_NAME>",
128
+ ];
129
+ ```
130
+
131
+ ### Phase 7: Resume Session (src/core/coordination/nodejs/generators/ResumeSessionGenerator.js)
132
+
133
+ #### 7.1 Add to supportedCLIs
134
+
135
+ ```javascript
136
+ this.supportedCLIs = [
137
+ // ... existing CLIs
138
+ "<CLI_NAME>",
139
+ ];
140
+ ```
141
+
142
+ #### 7.2 Add session path configuration
143
+
144
+ ```javascript
145
+ getAllCLISessionPaths = () => ({
146
+ // ... existing paths
147
+ <CLI_NAME>: [path.join(homeDir, '.<CLI_NAME>', 'projects')]
148
+ });
149
+ ```
150
+
151
+ #### 7.3 Add CLI registration code case
152
+
153
+ ```javascript
154
+ generateCLIRegistrationCode(cliName) {
155
+ switch(cliName.toLowerCase()) {
156
+ // ... existing cases
157
+ case '<CLI_NAME>':
158
+ // Add CLI-specific registration logic
159
+ break;
160
+ }
161
+ }
162
+ ```
163
+
164
+ ### Phase 8: Skills Sync (src/core/skills/StigmergySkillManager.js)
165
+
166
+ #### 8.1 Add CLI skill directory
167
+
168
+ ```javascript
169
+ const cliSkillDirs = [
170
+ // ... existing dirs
171
+ {
172
+ name: "<CLI Display Name>",
173
+ path: path.join(os.homedir(), ".<CLI_NAME>", "skills"),
174
+ },
175
+ ];
176
+ ```
177
+
178
+ ### Phase 9: Adapter Installation Script
179
+
180
+ #### 9.1 Create `src/adapters/<CLI_NAME>/install_<CLI_NAME>_integration.js`
181
+
182
+ ```javascript
183
+ const fs = require('fs').promises;
184
+ const path = require('path');
185
+ const os = require('os');
186
+
187
+ class <CLI_NAME>Installer {
188
+ constructor() {
189
+ this.toolName = '<CLI_NAME>';
190
+ this.configDir = path.join(os.homedir(), '.<CLI_NAME>');
191
+ this.configFile = path.join(this.configDir, 'config.json');
192
+ this.hooksFile = path.join(this.configDir, 'hooks.json');
193
+ }
194
+
195
+ async install() {
196
+ // Create config directory
197
+ await fs.mkdir(this.configDir, { recursive: true });
198
+
199
+ // Install configuration
200
+ await this.installConfig();
201
+
202
+ // Install hooks
203
+ await this.installHooks();
204
+
205
+ // Create documentation
206
+ await this.createCrossCliDocumentation();
207
+ }
208
+
209
+ async installConfig() {
210
+ // Create cross-CLI configuration
211
+ const config = {
212
+ cross_cli_enabled: true,
213
+ supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qodercli', 'codebuddy', 'copilot', 'codex', '<CLI_NAME>'],
214
+ stigmergy_integration: true
215
+ };
216
+ await fs.writeFile(this.configFile, JSON.stringify(config, null, 2));
217
+ }
218
+
219
+ async installHooks() {
220
+ const hooks = {
221
+ cross_cli_adapter: {
222
+ enabled: true,
223
+ supported_tools: ['claude', 'gemini', 'qwen', 'iflow', 'qodercli', 'codebuddy', 'copilot', 'codex', '<CLI_NAME>']
224
+ }
225
+ };
226
+ await fs.writeFile(this.hooksFile, JSON.stringify(hooks, null, 2));
227
+ }
228
+
229
+ async createCrossCliDocumentation() {
230
+ const docPath = path.join(this.configDir, 'CROSS_CLI_GUIDE.md');
231
+ const content = `# <CLI_NAME> CLI Cross-CLI Communication Guide
232
+
233
+ Cross-CLI communication: <<<Execute: stigmergy distcli "Prompt">>>
234
+
235
+ Available tools: claude, gemini, qwen, iflow, qodercli, codebuddy, copilot, codex, <CLI_NAME>
236
+ `;
237
+ await fs.writeFile(docPath, content);
238
+ }
239
+ }
240
+
241
+ module.exports = <CLI_NAME>Installer;
242
+ ```
243
+
244
+ ### Phase 10: Update Documentation
245
+
246
+ #### 10.1 Update AGENTS.md
247
+
248
+ - Add CLI to `stigmergy install <tool>` command documentation
249
+ - Update any relevant sections
250
+
251
+ ## Verification Steps
252
+
253
+ After integration, verify:
254
+
255
+ ### 1. Path Detection
256
+
257
+ ```bash
258
+ node -e "
259
+ const detector = require('./src/core/cli_path_detector');
260
+ detector.detectCLIPath('<CLI_NAME>').then(console.log);
261
+ "
262
+ ```
263
+
264
+ ### 2. CLI Adapter
265
+
266
+ ```bash
267
+ node -e "
268
+ const { CLI_ADAPTERS } = require('./src/core/cli_adapters');
269
+ console.log(CLI_ADAPTERS['<CLI_NAME>']);
270
+ "
271
+ ```
272
+
273
+ ### 3. Concurrent Execution
274
+
275
+ ```bash
276
+ stigmergy concurrent --concurrency 1 "test prompt"
277
+ ```
278
+
279
+ ### 4. Interactive Mode
280
+
281
+ ```bash
282
+ stigmergy interactive
283
+ # Then type: use <CLI_NAME>
284
+ ```
285
+
286
+ ### 5. Skill Sync
287
+
288
+ ```bash
289
+ stigmergy skill install <SOME_SKILL>
290
+ # Verify skill appears in ~.<CLI_NAME>/skills/
291
+ ```
292
+
293
+ ### 6. Resume Session
294
+
295
+ ```bash
296
+ stigmergy resume --cli <CLI_NAME>
297
+ ```
298
+
299
+ ## Rollback Plan
300
+
301
+ If integration causes issues:
302
+
303
+ 1. Remove from `cli_tools.js`: Comment out or set `autoInstall: false`
304
+ 2. Remove from `cli_path_detector.js`: Remove from `cliNameMap`
305
+ 3. Remove adapter: Comment out in `cli_adapters.js`
306
+ 4. Remove help patterns: Comment out in `cli_help_analyzer.js`
307
+ 5. Re-run: `stigmergy deploy`
308
+
309
+ ## Common Issues
310
+
311
+ ### CLI Not Detected
312
+
313
+ - Check npm global path: `npm config get prefix`
314
+ - Verify command exists: `which <CLI_COMMAND>` or `where <CLI_COMMAND>`
315
+ - Check PATH includes npm global bin directory
316
+
317
+ ### Hook Deployment Fails
318
+
319
+ - Ensure CLI config directory exists: `~/.CLI_NAME/`
320
+ - Check file permissions
321
+ - Verify JSON format is valid
322
+
323
+ ### Skills Not Syncing
324
+
325
+ - Check CLI skills directory exists
326
+ - Verify write permissions
327
+ - Check skill format compatibility
328
+
329
+ ## Related Files
330
+
331
+ - `src/core/cli_tools.js` - CLI configuration
332
+ - `src/core/cli_path_detector.js` - Path detection
333
+ - `src/core/cli_adapters.js` - Execution adapters
334
+ - `src/core/cli_help_analyzer.js` - Help pattern analysis
335
+ - `src/cli/commands/concurrent.js` - Concurrent execution
336
+ - `src/interactive/InteractiveModeController.js` - Interactive mode
337
+ - `src/core/coordination/nodejs/HookDeploymentManager.js` - Hook deployment
338
+ - `src/core/coordination/nodejs/generators/ResumeSessionGenerator.js` - Resume session
339
+ - `src/core/skills/StigmergySkillManager.js` - Skills sync
340
+ - `src/adapters/<CLI_NAME>/install_<CLI_NAME>_integration.js` - Installation script