stigmergy 1.2.12 → 1.3.1-beta

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 (84) hide show
  1. package/README.md +39 -3
  2. package/STIGMERGY.md +3 -0
  3. package/config/builtin-skills.json +43 -0
  4. package/config/enhanced-cli-config.json +438 -0
  5. package/docs/CLI_TOOLS_AGENT_SKILL_ANALYSIS.md +463 -0
  6. package/docs/DESIGN_CLI_HELP_ANALYZER_REFACTOR.md +726 -0
  7. package/docs/ENHANCED_CLI_AGENT_SKILL_CONFIG.md +285 -0
  8. package/docs/IMPLEMENTATION_CHECKLIST_CLI_HELP_ANALYZER_REFACTOR.md +1268 -0
  9. package/docs/INSTALLER_ARCHITECTURE.md +257 -0
  10. package/docs/LESSONS_LEARNED.md +252 -0
  11. package/docs/SPECS_CLI_HELP_ANALYZER_REFACTOR.md +287 -0
  12. package/docs/SUDO_PROBLEM_AND_SOLUTION.md +529 -0
  13. package/docs/correct-skillsio-implementation.md +368 -0
  14. package/docs/development_guidelines.md +276 -0
  15. package/docs/independent-resume-implementation.md +198 -0
  16. package/docs/resumesession-final-implementation.md +195 -0
  17. package/docs/resumesession-usage.md +87 -0
  18. package/package.json +19 -9
  19. package/scripts/analyze-router.js +168 -0
  20. package/scripts/run-comprehensive-tests.js +230 -0
  21. package/scripts/run-quick-tests.js +90 -0
  22. package/scripts/test-runner.js +344 -0
  23. package/skills/resumesession/INDEPENDENT_SKILL.md +171 -0
  24. package/skills/resumesession/SKILL.md +127 -0
  25. package/skills/resumesession/__init__.py +33 -0
  26. package/skills/resumesession/implementations/simple-resume.js +13 -0
  27. package/src/adapters/claude/install_claude_integration.js +9 -1
  28. package/src/adapters/codebuddy/install_codebuddy_integration.js +3 -1
  29. package/src/adapters/codex/install_codex_integration.js +15 -5
  30. package/src/adapters/gemini/install_gemini_integration.js +3 -1
  31. package/src/adapters/qwen/install_qwen_integration.js +3 -1
  32. package/src/cli/commands/autoinstall.js +65 -0
  33. package/src/cli/commands/errors.js +190 -0
  34. package/src/cli/commands/independent-resume.js +395 -0
  35. package/src/cli/commands/install.js +179 -0
  36. package/src/cli/commands/permissions.js +108 -0
  37. package/src/cli/commands/project.js +485 -0
  38. package/src/cli/commands/scan.js +97 -0
  39. package/src/cli/commands/simple-resume.js +377 -0
  40. package/src/cli/commands/skills.js +158 -0
  41. package/src/cli/commands/status.js +113 -0
  42. package/src/cli/commands/stigmergy-resume.js +775 -0
  43. package/src/cli/commands/system.js +301 -0
  44. package/src/cli/commands/universal-resume.js +394 -0
  45. package/src/cli/router-beta.js +471 -0
  46. package/src/cli/utils/environment.js +75 -0
  47. package/src/cli/utils/formatters.js +47 -0
  48. package/src/cli/utils/skills_cache.js +92 -0
  49. package/src/core/cache_cleaner.js +1 -0
  50. package/src/core/cli_adapters.js +345 -0
  51. package/src/core/cli_help_analyzer.js +582 -26
  52. package/src/core/cli_path_detector.js +702 -709
  53. package/src/core/cli_tools.js +515 -160
  54. package/src/core/coordination/nodejs/CLIIntegrationManager.js +18 -0
  55. package/src/core/coordination/nodejs/HookDeploymentManager.js +242 -412
  56. package/src/core/coordination/nodejs/HookDeploymentManager.refactored.js +323 -0
  57. package/src/core/coordination/nodejs/generators/CLIAdapterGenerator.js +363 -0
  58. package/src/core/coordination/nodejs/generators/ResumeSessionGenerator.js +932 -0
  59. package/src/core/coordination/nodejs/generators/SkillsIntegrationGenerator.js +1395 -0
  60. package/src/core/coordination/nodejs/generators/index.js +12 -0
  61. package/src/core/enhanced_cli_installer.js +1208 -608
  62. package/src/core/enhanced_cli_parameter_handler.js +402 -0
  63. package/src/core/execution_mode_detector.js +222 -0
  64. package/src/core/installer.js +151 -106
  65. package/src/core/local_skill_scanner.js +732 -0
  66. package/src/core/multilingual/language-pattern-manager.js +1 -1
  67. package/src/core/skills/BuiltinSkillsDeployer.js +188 -0
  68. package/src/core/skills/StigmergySkillManager.js +123 -16
  69. package/src/core/skills/embedded-openskills/SkillParser.js +7 -3
  70. package/src/core/smart_router.js +291 -2
  71. package/src/index.js +10 -4
  72. package/src/utils.js +66 -7
  73. package/test/cli-integration.test.js +304 -0
  74. package/test/direct_smart_router_test.js +88 -0
  75. package/test/enhanced-cli-agent-skill-test.js +485 -0
  76. package/test/simple_test.js +82 -0
  77. package/test/smart_router_test_runner.js +123 -0
  78. package/test/smart_routing_edge_cases.test.js +284 -0
  79. package/test/smart_routing_simple_verification.js +139 -0
  80. package/test/smart_routing_verification.test.js +346 -0
  81. package/test/specific-cli-agent-skill-analysis.js +385 -0
  82. package/test/unit/smart_router.test.js +295 -0
  83. package/test/very_simple_test.js +54 -0
  84. package/src/cli/router.js +0 -1737
@@ -0,0 +1,323 @@
1
+ // src/core/coordination/nodejs/HookDeploymentManager.js
2
+ // 重构后的简洁版本 - 核心协调功能
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const os = require('os');
6
+ const { spawn, spawnSync } = require('child_process');
7
+
8
+ // Import specialized generators
9
+ const { ResumeSessionGenerator, SkillsIntegrationGenerator, CLIAdapterGenerator } = require('./generators');
10
+
11
+ class HookDeploymentManager {
12
+ constructor() {
13
+ this.deploymentDir = path.join(os.homedir(), '.stigmergy', 'hooks');
14
+ this.supportedCLIs = [
15
+ 'claude',
16
+ 'gemini',
17
+ 'qwen',
18
+ 'iflow',
19
+ 'qodercli',
20
+ 'codebuddy',
21
+ 'codex',
22
+ 'copilot',
23
+ ];
24
+
25
+ // Initialize generators
26
+ this.resumeSessionGenerator = new ResumeSessionGenerator();
27
+ this.skillsIntegrationGenerator = new SkillsIntegrationGenerator();
28
+ this.cliAdapterGenerator = new CLIAdapterGenerator();
29
+ }
30
+
31
+ async initialize() {
32
+ console.log('[HOOK_DEPLOYMENT] Initializing hook deployment manager...');
33
+ await this.ensureDeploymentDirectory();
34
+ }
35
+
36
+ async ensureDeploymentDirectory() {
37
+ if (!fs.existsSync(this.deploymentDir)) {
38
+ fs.mkdirSync(this.deploymentDir, { recursive: true });
39
+ console.log(
40
+ `[HOOK_DEPLOYMENT] Created deployment directory: ${this.deploymentDir}`,
41
+ );
42
+ }
43
+ }
44
+
45
+ async deployHooksForCLI(cliName, options = {}) {
46
+ console.log(`[HOOK_DEPLOYMENT] Deploying hooks for ${cliName}...`);
47
+
48
+ if (!this.supportedCLIs.includes(cliName.toLowerCase())) {
49
+ throw new Error(`Unsupported CLI: ${cliName}`);
50
+ }
51
+
52
+ try {
53
+ // Create CLI-specific hook directory
54
+ const cliHookDir = path.join(this.deploymentDir, cliName);
55
+ if (!fs.existsSync(cliHookDir)) {
56
+ fs.mkdirSync(cliHookDir, { recursive: true });
57
+ }
58
+
59
+ // Deploy Node.js specific hooks and extensions
60
+ await this.deployNodeJsHooks(cliName, cliHookDir, options);
61
+
62
+ console.log(
63
+ `[HOOK_DEPLOYMENT] Hooks deployed successfully for ${cliName}`,
64
+ );
65
+ return true;
66
+ } catch (error) {
67
+ console.error(
68
+ `[HOOK_DEPLOYMENT] Failed to deploy hooks for ${cliName}:`,
69
+ error,
70
+ );
71
+ return false;
72
+ }
73
+ }
74
+
75
+ async deployNodeJsHooks(cliName, hookDir, options) {
76
+ console.log(`[HOOK_DEPLOYMENT] Deploying Node.js hooks for ${cliName}...`);
77
+
78
+ // Deploy ResumeSession extension
79
+ await this.deployResumeSessionExtension(cliName, hookDir);
80
+
81
+ // Deploy Skills integration
82
+ await this.deploySkillsIntegration(cliName, hookDir);
83
+
84
+ // Deploy CLI adapter
85
+ await this.deployCLIAdapter(cliName, hookDir);
86
+
87
+ // Create basic configuration
88
+ await this.createBasicConfiguration(cliName, hookDir);
89
+ }
90
+
91
+ async deployResumeSessionExtension(cliName, hookDir) {
92
+ console.log(`[HOOK_DEPLOYMENT] Deploying ResumeSession extension for ${cliName}...`);
93
+
94
+ try {
95
+ const extensionContent = this.resumeSessionGenerator.generateForCLI(cliName);
96
+ const fileName = this.resumeSessionGenerator.getFileName(cliName);
97
+ const extensionPath = path.join(hookDir, fileName);
98
+
99
+ fs.writeFileSync(extensionPath, extensionContent);
100
+ console.log(`[HOOK_DEPLOYMENT] Created ResumeSession extension: ${extensionPath}`);
101
+
102
+ // Make the extension executable
103
+ try {
104
+ fs.chmodSync(extensionPath, 0o755);
105
+ console.log(`[HOOK_DEPLOYMENT] Made extension executable: ${extensionPath}`);
106
+ } catch (error) {
107
+ console.warn(
108
+ `[HOOK_DEPLOYMENT] Failed to make extension executable: ${error.message}`,
109
+ );
110
+ }
111
+
112
+ return true;
113
+ } catch (error) {
114
+ console.error(`[HOOK_DEPLOYMENT] Failed to deploy ResumeSession extension for ${cliName}:`, error);
115
+ return false;
116
+ }
117
+ }
118
+
119
+ async deploySkillsIntegration(cliName, hookDir) {
120
+ console.log(`[HOOK_DEPLOYMENT] Deploying skills integration for ${cliName}...`);
121
+
122
+ try {
123
+ const skillsResult = this.skillsIntegrationGenerator.generateForCLI(cliName);
124
+ const skillsPath = path.join(hookDir, skillsResult.fileName);
125
+
126
+ fs.writeFileSync(skillsPath, skillsResult.content);
127
+ console.log(`[HOOK_DEPLOYMENT] Created skills integration: ${skillsPath}`);
128
+
129
+ // Make the skills file executable
130
+ try {
131
+ fs.chmodSync(skillsPath, 0o755);
132
+ console.log(`[HOOK_DEPLOYMENT] Made skills integration executable: ${skillsPath}`);
133
+ } catch (error) {
134
+ console.warn(`[HOOK_DEPLOYMENT] Failed to make skills integration executable: ${error.message}`);
135
+ }
136
+
137
+ // Create skills configuration
138
+ const skillsConfig = {
139
+ cli: cliName,
140
+ skillsPath: skillsPath,
141
+ skillsDirectory: path.join(os.homedir(), '.stigmergy', 'skills'),
142
+ deploymentTime: new Date().toISOString(),
143
+ version: '1.0.0-skills'
144
+ };
145
+
146
+ const configPath = path.join(hookDir, 'skills-config.json');
147
+ fs.writeFileSync(configPath, JSON.stringify(skillsConfig, null, 2));
148
+ console.log(`[HOOK_DEPLOYMENT] Created skills configuration: ${configPath}`);
149
+
150
+ return true;
151
+ } catch (error) {
152
+ console.error(`[HOOK_DEPLOYMENT] Failed to deploy skills integration for ${cliName}:`, error);
153
+ return false;
154
+ }
155
+ }
156
+
157
+ async deployCLIAdapter(cliName, hookDir) {
158
+ console.log(`[HOOK_DEPLOYMENT] Deploying CLI adapter for ${cliName}...`);
159
+
160
+ try {
161
+ const adapterContent = this.cliAdapterGenerator.generateForCLI(cliName);
162
+ const fileName = this.cliAdapterGenerator.getFileName(cliName);
163
+ const adapterPath = path.join(hookDir, fileName);
164
+
165
+ fs.writeFileSync(adapterPath, adapterContent);
166
+ console.log(`[HOOK_DEPLOYMENT] Created CLI adapter: ${adapterPath}`);
167
+
168
+ // Make the adapter executable
169
+ try {
170
+ fs.chmodSync(adapterPath, 0o755);
171
+ console.log(`[HOOK_DEPLOYMENT] Made adapter executable: ${adapterPath}`);
172
+ } catch (error) {
173
+ console.warn(`[HOOK_DEPLOYMENT] Failed to make adapter executable: ${error.message}`);
174
+ }
175
+
176
+ return true;
177
+ } catch (error) {
178
+ console.error(`[HOOK_DEPLOYMENT] Failed to deploy CLI adapter for ${cliName}:`, error);
179
+ return false;
180
+ }
181
+ }
182
+
183
+ async createBasicConfiguration(cliName, hookDir) {
184
+ console.log(`[HOOK_DEPLOYMENT] Creating basic configuration for ${cliName}...`);
185
+
186
+ try {
187
+ // Create main configuration file
188
+ const config = {
189
+ cli: cliName,
190
+ hookPath: hookDir,
191
+ deploymentTime: new Date().toISOString(),
192
+ version: '1.0.0-nodejs',
193
+ modules: {
194
+ resumeSession: true,
195
+ skillsIntegration: true,
196
+ cliAdapter: true
197
+ }
198
+ };
199
+
200
+ const configPath = path.join(hookDir, 'config.json');
201
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
202
+ console.log(`[HOOK_DEPLOYMENT] Created configuration: ${configPath}`);
203
+
204
+ return true;
205
+ } catch (error) {
206
+ console.error(`[HOOK_DEPLOYMENT] Failed to create configuration for ${cliName}:`, error);
207
+ return false;
208
+ }
209
+ }
210
+
211
+ async deployHooksForAllCLIs(options = {}) {
212
+ console.log('[HOOK_DEPLOYMENT] Deploying hooks for all supported CLIs...');
213
+
214
+ const results = [];
215
+ for (const cliName of this.supportedCLIs) {
216
+ const success = await this.deployHooksForCLI(cliName, options);
217
+ results.push({ cli: cliName, success });
218
+ }
219
+
220
+ const successful = results.filter(r => r.success).length;
221
+ console.log(
222
+ `[HOOK_DEPLOYMENT] Deployment complete: ${successful}/${this.supportedCLIs.length} CLIs configured`,
223
+ );
224
+
225
+ return results;
226
+ }
227
+
228
+ async getDeployedHooks() {
229
+ try {
230
+ const cliDirs = fs.readdirSync(this.deploymentDir, { withFileTypes: true })
231
+ .filter(dirent => dirent.isDirectory())
232
+ .map(dirent => dirent.name);
233
+
234
+ const hooks = [];
235
+ for (const cliName of cliDirs) {
236
+ const configPath = path.join(this.deploymentDir, cliName, 'config.json');
237
+ if (fs.existsSync(configPath)) {
238
+ try {
239
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
240
+ hooks.push(config);
241
+ } catch (error) {
242
+ console.warn(
243
+ `[HOOK_DEPLOYMENT] Failed to read config for ${cliName}:`,
244
+ error.message,
245
+ );
246
+ }
247
+ }
248
+ }
249
+
250
+ return hooks;
251
+ } catch (error) {
252
+ console.error('[HOOK_DEPLOYMENT] Failed to get deployed hooks:', error);
253
+ return [];
254
+ }
255
+ }
256
+
257
+ async validateHookDeployment(cliName) {
258
+ console.log(
259
+ `[HOOK_DEPLOYMENT] Validating hook deployment for ${cliName}...`,
260
+ );
261
+
262
+ const cliHookDir = path.join(this.deploymentDir, cliName);
263
+ if (!fs.existsSync(cliHookDir)) {
264
+ return { valid: false, error: 'Hook directory not found' };
265
+ }
266
+
267
+ const configPath = path.join(cliHookDir, 'config.json');
268
+ if (!fs.existsSync(configPath)) {
269
+ return { valid: false, error: 'Configuration file not found' };
270
+ }
271
+
272
+ try {
273
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
274
+
275
+ // Validate that all expected modules are present
276
+ const expectedModules = ['resumeSession', 'skillsIntegration', 'cliAdapter'];
277
+ if (!config.modules) {
278
+ return { valid: false, error: 'Module configuration not found' };
279
+ }
280
+
281
+ for (const module of expectedModules) {
282
+ if (!config.modules[module]) {
283
+ return { valid: false, error: `Module ${module} not configured` };
284
+ }
285
+ }
286
+
287
+ return {
288
+ valid: true,
289
+ message: 'Hook deployment is valid',
290
+ modules: config.modules
291
+ };
292
+ } catch (error) {
293
+ return { valid: false, error: `Failed to validate deployment: ${error.message}` };
294
+ }
295
+ }
296
+
297
+ async validateAllDeployments() {
298
+ console.log('[HOOK_DEPLOYMENT] Validating all hook deployments...');
299
+
300
+ const results = [];
301
+ for (const cliName of this.supportedCLIs) {
302
+ const validation = await this.validateHookDeployment(cliName);
303
+ results.push({ cli: cliName, ...validation });
304
+ }
305
+
306
+ const valid = results.filter(r => r.valid).length;
307
+ console.log(
308
+ `[HOOK_DEPLOYMENT] Validation complete: ${valid}/${this.supportedCLIs.length} deployments valid`,
309
+ );
310
+
311
+ return results;
312
+ }
313
+
314
+ getDeploymentStatus() {
315
+ return {
316
+ deploymentDir: this.deploymentDir,
317
+ supportedCLIs: this.supportedCLIs,
318
+ initialized: fs.existsSync(this.deploymentDir)
319
+ };
320
+ }
321
+ }
322
+
323
+ module.exports = HookDeploymentManager;
@@ -0,0 +1,363 @@
1
+ // CLI Adapter Generator
2
+ // 专门负责生成各CLI的基础适配器文件
3
+
4
+ const path = require('path');
5
+
6
+ class CLIAdapterGenerator {
7
+ constructor() {
8
+ this.supportedCLIs = [
9
+ 'claude', 'gemini', 'qwen', 'codebuddy', 'codex',
10
+ 'iflow', 'qodercli', 'copilot', 'kode'
11
+ ];
12
+ }
13
+
14
+ generateForCLI(cliName) {
15
+ return this.generateAdapterContent(cliName);
16
+ }
17
+
18
+ generateAdapterContent(cliName) {
19
+ const currentProjectPath = process.cwd();
20
+
21
+ switch (cliName.toLowerCase()) {
22
+ case 'claude':
23
+ return this.generateClaudeAdapter(currentProjectPath);
24
+ case 'gemini':
25
+ return this.generateGeminiAdapter(currentProjectPath);
26
+ case 'qwen':
27
+ return this.generateQwenAdapter(currentProjectPath);
28
+ case 'codebuddy':
29
+ return this.generateCodeBuddyAdapter(currentProjectPath);
30
+ case 'codex':
31
+ return this.generateCodexAdapter(currentProjectPath);
32
+ case 'qodercli':
33
+ return this.generateQoderCliAdapter(currentProjectPath);
34
+ case 'iflow':
35
+ return this.generateIFlowAdapter(currentProjectPath);
36
+ case 'copilot':
37
+ return this.generateCopilotAdapter(currentProjectPath);
38
+ default:
39
+ return this.generateGenericAdapter(cliName, currentProjectPath);
40
+ }
41
+ }
42
+
43
+ generateClaudeAdapter(projectPath) {
44
+ return `#!/usr/bin/env node
45
+ /**
46
+ * Claude CLI Integration Hook
47
+ * Auto-generated by Stigmergy CLI v1.2.1
48
+ * Project: ${projectPath}
49
+ */
50
+
51
+ const fs = require('fs');
52
+ const path = require('path');
53
+
54
+ class ClaudeHook {
55
+ constructor() {
56
+ this.toolName = 'claude';
57
+ this.configPath = path.join(require('os').homedir(), '.claude', 'config.json');
58
+ this.hooksDir = path.join(require('os').homedir(), '.claude', 'hooks');
59
+ }
60
+
61
+ async onPrompt(prompt) {
62
+ // Handle incoming prompts from other CLI tools
63
+ console.log(\`[\${this.toolName.toUpperCase()}] Received cross-CLI prompt: \${prompt}\`);
64
+ return { handled: true, response: 'Prompt processed by ' + this.toolName };
65
+ }
66
+
67
+ async onResponse(response) {
68
+ // Handle responses to be sent to other CLI tools
69
+ console.log(\`[\${this.toolName.toUpperCase()}] Sending cross-CLI response\`);
70
+ return response;
71
+ }
72
+ }
73
+
74
+ module.exports = ClaudeHook;
75
+ `;
76
+ }
77
+
78
+ generateGeminiAdapter(projectPath) {
79
+ return `#!/usr/bin/env node
80
+ /**
81
+ * Gemini CLI Integration Hook
82
+ * Auto-generated by Stigmergy CLI v1.2.1
83
+ * Project: ${projectPath}
84
+ */
85
+
86
+ const fs = require('fs');
87
+ const path = require('path');
88
+
89
+ class GeminiHook {
90
+ constructor() {
91
+ this.toolName = 'gemini';
92
+ this.configPath = path.join(require('os').homedir(), '.gemini', 'config.json');
93
+ this.hooksDir = path.join(require('os').homedir(), '.gemini', 'extensions');
94
+ }
95
+
96
+ async onPrompt(prompt) {
97
+ // Handle incoming prompts from other CLI tools
98
+ console.log(\`[\${this.toolName.toUpperCase()}] Received cross-CLI prompt: \${prompt}\`);
99
+ return { handled: true, response: 'Prompt processed by ' + this.toolName };
100
+ }
101
+
102
+ async onResponse(response) {
103
+ // Handle responses to be sent to other CLI tools
104
+ console.log(\`[\${this.toolName.toUpperCase()}] Sending cross-CLI response\`);
105
+ return response;
106
+ }
107
+ }
108
+
109
+ module.exports = GeminiHook;
110
+ `;
111
+ }
112
+
113
+ generateQwenAdapter(projectPath) {
114
+ return `#!/usr/bin/env node
115
+ /**
116
+ * Qwen CLI Integration Hook
117
+ * Auto-generated by Stigmergy CLI v1.2.1
118
+ * Project: ${projectPath}
119
+ */
120
+
121
+ const fs = require('fs');
122
+ const path = require('path');
123
+
124
+ class QwenHook {
125
+ constructor() {
126
+ this.toolName = 'qwen';
127
+ this.configPath = path.join(require('os').homedir(), '.qwen', 'config.json');
128
+ this.hooksDir = path.join(require('os').homedir(), '.qwen', 'hooks');
129
+ }
130
+
131
+ async onPrompt(prompt) {
132
+ // Handle incoming prompts from other CLI tools
133
+ console.log(\`[\${this.toolName.toUpperCase()}] Received cross-CLI prompt: \${prompt}\`);
134
+ return { handled: true, response: 'Prompt processed by ' + this.toolName };
135
+ }
136
+
137
+ async onResponse(response) {
138
+ // Handle responses to be sent to other CLI tools
139
+ console.log(\`[\${this.toolName.toUpperCase()}] Sending cross-CLI response\`);
140
+ return response;
141
+ }
142
+ }
143
+
144
+ module.exports = QwenHook;
145
+ `;
146
+ }
147
+
148
+ generateCodeBuddyAdapter(projectPath) {
149
+ return `#!/usr/bin/env node
150
+ /**
151
+ * CodeBuddy CLI Integration Hook
152
+ * Auto-generated by Stigmergy CLI v1.2.1
153
+ * Project: ${projectPath}
154
+ */
155
+
156
+ const fs = require('fs');
157
+ const path = require('path');
158
+
159
+ class CodeBuddyHook {
160
+ constructor() {
161
+ this.toolName = 'codebuddy';
162
+ this.configPath = path.join(require('os').homedir(), '.codebuddy', 'config.json');
163
+ this.hooksDir = path.join(require('os').homedir(), '.codebuddy', 'hooks');
164
+ }
165
+
166
+ async onPrompt(prompt) {
167
+ // Handle incoming prompts from other CLI tools
168
+ console.log(\`[\${this.toolName.toUpperCase()}] Received cross-CLI prompt: \${prompt}\`);
169
+ return { handled: true, response: 'Prompt processed by ' + this.toolName };
170
+ }
171
+
172
+ async onResponse(response) {
173
+ // Handle responses to be sent to other CLI tools
174
+ console.log(\`[\${this.toolName.toUpperCase()}] Sending cross-CLI response\`);
175
+ return response;
176
+ }
177
+ }
178
+
179
+ module.exports = CodeBuddyHook;
180
+ `;
181
+ }
182
+
183
+ generateCodexAdapter(projectPath) {
184
+ return `#!/usr/bin/env node
185
+ /**
186
+ * Codex CLI Integration Hook
187
+ * Auto-generated by Stigmergy CLI v1.2.1
188
+ * Project: ${projectPath}
189
+ */
190
+
191
+ const fs = require('fs');
192
+ const path = require('path');
193
+
194
+ class CodexHook {
195
+ constructor() {
196
+ this.toolName = 'codex';
197
+ this.configPath = path.join(require('os').homedir(), '.codex', 'config.json');
198
+ this.hooksDir = path.join(require('os').homedir(), '.codex', 'hooks');
199
+ }
200
+
201
+ async onPrompt(prompt) {
202
+ // Handle incoming prompts from other CLI tools
203
+ console.log(\`[\${this.toolName.toUpperCase()}] Received cross-CLI prompt: \${prompt}\`);
204
+ return { handled: true, response: 'Prompt processed by ' + this.toolName };
205
+ }
206
+
207
+ async onResponse(response) {
208
+ // Handle responses to be sent to other CLI tools
209
+ console.log(\`[\${this.toolName.toUpperCase()}] Sending cross-CLI response\`);
210
+ return response;
211
+ }
212
+ }
213
+
214
+ module.exports = CodexHook;
215
+ `;
216
+ }
217
+
218
+ generateQoderCliAdapter(projectPath) {
219
+ return `#!/usr/bin/env node
220
+ /**
221
+ * QoderCLI Integration Hook
222
+ * Auto-generated by Stigmergy CLI v1.2.1
223
+ * Project: ${projectPath}
224
+ */
225
+
226
+ const fs = require('fs');
227
+ const path = require('path');
228
+
229
+ class QoderCliHook {
230
+ constructor() {
231
+ this.toolName = 'qodercli';
232
+ this.configPath = path.join(require('os').homedir(), '.qodercli', 'config.json');
233
+ this.hooksDir = path.join(require('os').homedir(), '.qodercli', 'hooks');
234
+ }
235
+
236
+ async onPrompt(prompt) {
237
+ // Handle incoming prompts from other CLI tools
238
+ console.log(\`[\${this.toolName.toUpperCase()}] Received cross-CLI prompt: \${prompt}\`);
239
+ return { handled: true, response: 'Prompt processed by ' + this.toolName };
240
+ }
241
+
242
+ async onResponse(response) {
243
+ // Handle responses to be sent to other CLI tools
244
+ console.log(\`[\${this.toolName.toUpperCase()}] Sending cross-CLI response\`);
245
+ return response;
246
+ }
247
+ }
248
+
249
+ module.exports = QoderCliHook;
250
+ `;
251
+ }
252
+
253
+ generateIFlowAdapter(projectPath) {
254
+ return `#!/usr/bin/env node
255
+ /**
256
+ * IFlow CLI Integration Hook
257
+ * Auto-generated by Stigmergy CLI v1.2.1
258
+ * Project: ${projectPath}
259
+ */
260
+
261
+ const fs = require('fs');
262
+ const path = require('path');
263
+
264
+ class IFlowHook {
265
+ constructor() {
266
+ this.toolName = 'iflow';
267
+ this.configPath = path.join(require('os').homedir(), '.iflow', 'config.json');
268
+ this.hooksDir = path.join(require('os').homedir(), '.iflow', 'hooks');
269
+ }
270
+
271
+ async onPrompt(prompt) {
272
+ // Handle incoming prompts from other CLI tools
273
+ console.log(\`[\${this.toolName.toUpperCase()}] Received cross-CLI prompt: \${prompt}\`);
274
+ return { handled: true, response: 'Prompt processed by ' + this.toolName };
275
+ }
276
+
277
+ async onResponse(response) {
278
+ // Handle responses to be sent to other CLI tools
279
+ console.log(\`[\${this.toolName.toUpperCase()}] Sending cross-CLI response\`);
280
+ return response;
281
+ }
282
+ }
283
+
284
+ module.exports = IFlowHook;
285
+ `;
286
+ }
287
+
288
+ generateCopilotAdapter(projectPath) {
289
+ return `#!/usr/bin/env node
290
+ /**
291
+ * Copilot CLI Integration Hook
292
+ * Auto-generated by Stigmergy CLI v1.2.1
293
+ * Project: ${projectPath}
294
+ */
295
+
296
+ const fs = require('fs');
297
+ const path = require('path');
298
+
299
+ class CopilotHook {
300
+ constructor() {
301
+ this.toolName = 'copilot';
302
+ this.configPath = path.join(require('os').homedir(), '.copilot', 'config.json');
303
+ this.hooksDir = path.join(require('os').homedir(), '.copilot', 'hooks');
304
+ }
305
+
306
+ async onPrompt(prompt) {
307
+ // Handle incoming prompts from other CLI tools
308
+ console.log(\`[\${this.toolName.toUpperCase()}] Received cross-CLI prompt: \${prompt}\`);
309
+ return { handled: true, response: 'Prompt processed by ' + this.toolName };
310
+ }
311
+
312
+ async onResponse(response) {
313
+ // Handle responses to be sent to other CLI tools
314
+ console.log(\`[\${this.toolName.toUpperCase()}] Sending cross-CLI response\`);
315
+ return response;
316
+ }
317
+ }
318
+
319
+ module.exports = CopilotHook;
320
+ `;
321
+ }
322
+
323
+ generateGenericAdapter(cliName, projectPath) {
324
+ return `#!/usr/bin/env node
325
+ /**
326
+ * ${cliName.charAt(0).toUpperCase() + cliName.slice(1)} CLI Integration Hook
327
+ * Auto-generated by Stigmergy CLI v1.2.1
328
+ * Project: ${projectPath}
329
+ */
330
+
331
+ const fs = require('fs');
332
+ const path = require('path');
333
+
334
+ class ${cliName.charAt(0).toUpperCase() + cliName.slice(1)}Hook {
335
+ constructor() {
336
+ this.toolName = '${cliName}';
337
+ this.configPath = path.join(require('os').homedir(), '.${cliName}', 'config.json');
338
+ this.hooksDir = path.join(require('os').homedir(), '.${cliName}', 'hooks');
339
+ }
340
+
341
+ async onPrompt(prompt) {
342
+ // Handle incoming prompts from other CLI tools
343
+ console.log(\`[\${this.toolName.toUpperCase()}] Received cross-CLI prompt: \${prompt}\`);
344
+ return { handled: true, response: 'Prompt processed by ' + this.toolName };
345
+ }
346
+
347
+ async onResponse(response) {
348
+ // Handle responses to be sent to other CLI tools
349
+ console.log(\`[\${this.toolName.toUpperCase()}] Sending cross-CLI response\`);
350
+ return response;
351
+ }
352
+ }
353
+
354
+ module.exports = ${cliName.charAt(0).toUpperCase() + cliName.slice(1)}Hook;
355
+ `;
356
+ }
357
+
358
+ getFileName(cliName) {
359
+ return `${cliName}_adapter.js`;
360
+ }
361
+ }
362
+
363
+ module.exports = CLIAdapterGenerator;