stigmergy 1.2.6 → 1.2.10

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 (82) hide show
  1. package/README.md +69 -20
  2. package/STIGMERGY.md +26 -7
  3. package/docs/MULTI_USER_WIKI_COLLABORATION_SYSTEM.md +523 -0
  4. package/docs/PROMPT_BASED_SKILLS_SYSTEM_DESIGN.md +458 -0
  5. package/docs/SKILL_IMPLEMENTATION_CONSTRAINTS_AND_ALIGNMENT.md +423 -0
  6. package/docs/TECHNICAL_FEASIBILITY_ANALYSIS.md +308 -0
  7. package/examples/multilingual-hook-demo.js +125 -0
  8. package/package.json +30 -19
  9. package/scripts/dependency-analyzer.js +101 -0
  10. package/scripts/generate-cli-docs.js +64 -0
  11. package/scripts/postuninstall.js +46 -0
  12. package/scripts/preuninstall.js +85 -0
  13. package/scripts/run-layered-tests.js +3 -3
  14. package/src/adapters/claude/install_claude_integration.js +37 -37
  15. package/src/adapters/codebuddy/install_codebuddy_integration.js +66 -63
  16. package/src/adapters/codex/install_codex_integration.js +54 -55
  17. package/src/adapters/copilot/install_copilot_integration.js +46 -46
  18. package/src/adapters/gemini/install_gemini_integration.js +68 -68
  19. package/src/adapters/iflow/install_iflow_integration.js +77 -77
  20. package/src/adapters/qoder/install_qoder_integration.js +76 -76
  21. package/src/adapters/qwen/install_qwen_integration.js +23 -23
  22. package/src/cli/router.js +713 -163
  23. package/src/commands/skill-bridge.js +39 -0
  24. package/src/commands/skill-handler.js +150 -0
  25. package/src/commands/skill.js +127 -0
  26. package/src/core/cache_cleaner.js +767 -767
  27. package/src/core/cli_help_analyzer.js +680 -680
  28. package/src/core/cli_parameter_handler.js +132 -132
  29. package/src/core/cli_path_detector.js +573 -0
  30. package/src/core/cli_tools.js +160 -89
  31. package/src/core/coordination/index.js +16 -16
  32. package/src/core/coordination/nodejs/AdapterManager.js +130 -102
  33. package/src/core/coordination/nodejs/CLCommunication.js +132 -132
  34. package/src/core/coordination/nodejs/CLIIntegrationManager.js +272 -272
  35. package/src/core/coordination/nodejs/HealthChecker.js +76 -76
  36. package/src/core/coordination/nodejs/HookDeploymentManager.js +463 -274
  37. package/src/core/coordination/nodejs/StatisticsCollector.js +71 -71
  38. package/src/core/coordination/nodejs/index.js +90 -90
  39. package/src/core/coordination/nodejs/utils/Logger.js +29 -29
  40. package/src/core/directory_permission_manager.js +568 -0
  41. package/src/core/enhanced_cli_installer.js +609 -0
  42. package/src/core/error_handler.js +406 -406
  43. package/src/core/installer.js +263 -119
  44. package/src/core/memory_manager.js +83 -83
  45. package/src/core/multilingual/language-pattern-manager.js +200 -0
  46. package/src/core/persistent_shell_configurator.js +468 -0
  47. package/src/core/rest_client.js +160 -160
  48. package/src/core/skills/StigmergySkillManager.js +357 -0
  49. package/src/core/skills/__tests__/SkillInstaller.test.js +275 -0
  50. package/src/core/skills/__tests__/SkillParser.test.js +202 -0
  51. package/src/core/skills/__tests__/SkillReader.test.js +189 -0
  52. package/src/core/skills/cli-command-test.js +201 -0
  53. package/src/core/skills/comprehensive-e2e-test.js +473 -0
  54. package/src/core/skills/e2e-test.js +267 -0
  55. package/src/core/skills/embedded-openskills/SkillInstaller.js +438 -0
  56. package/src/core/skills/embedded-openskills/SkillParser.js +123 -0
  57. package/src/core/skills/embedded-openskills/SkillReader.js +143 -0
  58. package/src/core/skills/integration-test.js +248 -0
  59. package/src/core/skills/package.json +6 -0
  60. package/src/core/skills/regression-test.js +285 -0
  61. package/src/core/skills/run-all-tests.js +129 -0
  62. package/src/core/skills/sync-test.js +210 -0
  63. package/src/core/skills/test-runner.js +242 -0
  64. package/src/core/smart_router.js +261 -249
  65. package/src/core/upgrade_manager.js +48 -20
  66. package/src/index.js +30 -30
  67. package/src/test/cli-availability-checker.js +194 -194
  68. package/src/test/test-environment.js +289 -289
  69. package/src/utils/helpers.js +18 -35
  70. package/src/utils.js +921 -921
  71. package/src/weatherProcessor.js +228 -228
  72. package/test/multilingual/hook-deployment.test.js +91 -0
  73. package/test/multilingual/language-pattern-manager.test.js +140 -0
  74. package/test/multilingual/system-test.js +85 -0
  75. package/src/auth.js +0 -173
  76. package/src/auth_command.js +0 -208
  77. package/src/calculator.js +0 -313
  78. package/src/core/enhanced_installer.js +0 -479
  79. package/src/core/enhanced_uninstaller.js +0 -638
  80. package/src/data_encryption.js +0 -143
  81. package/src/data_structures.js +0 -440
  82. package/src/deploy.js +0 -55
@@ -1,272 +1,272 @@
1
- // src/core/coordination/nodejs/CLIIntegrationManager.js
2
- const fs = require('fs');
3
- const path = require('path');
4
- const os = require('os');
5
- const { spawn, spawnSync } = require('child_process');
6
-
7
- class CLIIntegrationManager {
8
- constructor() {
9
- this.supportedCLIs = {
10
- claude: {
11
- name: 'Claude CLI',
12
- executable: 'claude',
13
- hooks: [
14
- 'user_prompt_submit',
15
- 'tool_use_pre',
16
- 'tool_use_post',
17
- 'response_generated',
18
- ],
19
- },
20
- gemini: {
21
- name: 'Gemini CLI',
22
- executable: 'gemini',
23
- extensions: [
24
- 'on_user_input',
25
- 'on_response_generated',
26
- 'on_tool_execution',
27
- ],
28
- },
29
- qwencode: {
30
- name: 'QwenCode CLI',
31
- executable: 'qwencode',
32
- inheritance: [
33
- 'on_code_generation',
34
- 'on_analysis_request',
35
- 'on_refactor_request',
36
- ],
37
- },
38
- iflow: {
39
- name: 'iFlow CLI',
40
- executable: 'iflow',
41
- workflows: [
42
- 'on_workflow_start',
43
- 'on_stage_complete',
44
- 'on_workflow_success',
45
- ],
46
- },
47
- qoder: {
48
- name: 'Qoder CLI',
49
- executable: 'qoder',
50
- notifications: [
51
- 'on_user_notification',
52
- 'on_system_alert',
53
- 'on_task_completion',
54
- ],
55
- },
56
- codebuddy: {
57
- name: 'CodeBuddy CLI',
58
- executable: 'codebuddy',
59
- skills: [
60
- 'on_skill_invocation',
61
- 'on_buddy_request',
62
- 'on_cross_cli_task',
63
- ],
64
- },
65
- codex: {
66
- name: 'Codex CLI',
67
- executable: 'codex',
68
- slashCommands: ['/x', '/cross-cli', '/delegate'],
69
- },
70
- copilot: {
71
- name: 'Copilot CLI',
72
- executable: 'copilot',
73
- mcp: ['cross_cli_execute'],
74
- },
75
- };
76
- }
77
-
78
- async checkCLIAvailability(cliName) {
79
- console.log(`[CLI_INTEGRATION] Checking availability of ${cliName}...`);
80
-
81
- const cliInfo = this.supportedCLIs[cliName.toLowerCase()];
82
- if (!cliInfo) {
83
- return { available: false, error: `Unsupported CLI: ${cliName}` };
84
- }
85
-
86
- try {
87
- // Check if CLI executable is available
88
- const result = spawnSync(cliInfo.executable, ['--version'], {
89
- timeout: 5000,
90
- stdio: ['pipe', 'pipe', 'pipe'],
91
- });
92
-
93
- if (result.status === 0) {
94
- const version = result.stdout
95
- ? result.stdout.toString().trim()
96
- : 'Unknown';
97
- return {
98
- available: true,
99
- version: version,
100
- name: cliInfo.name,
101
- };
102
- } else {
103
- return {
104
- available: false,
105
- error: `CLI returned non-zero exit code: ${result.status}`,
106
- stderr: result.stderr ? result.stderr.toString() : '',
107
- };
108
- }
109
- } catch (error) {
110
- return {
111
- available: false,
112
- error: `Failed to execute CLI: ${error.message}`,
113
- };
114
- }
115
- }
116
-
117
- async listAvailableCLIs() {
118
- console.log('[CLI_INTEGRATION] Listing available CLIs...');
119
-
120
- const results = {};
121
- for (const [cliName, cliInfo] of Object.entries(this.supportedCLIs)) {
122
- results[cliName] = await this.checkCLIAvailability(cliName);
123
- }
124
-
125
- return results;
126
- }
127
-
128
- async getNodeJsIntegrationScript(cliName) {
129
- console.log(
130
- `[CLI_INTEGRATION] Generating Node.js integration script for ${cliName}...`,
131
- );
132
-
133
- const cliInfo = this.supportedCLIs[cliName.toLowerCase()];
134
- if (!cliInfo) {
135
- throw new Error(`Unsupported CLI: ${cliName}`);
136
- }
137
-
138
- // Generate a Node.js integration script
139
- const script = `#!/usr/bin/env node
140
-
141
- /**
142
- * Node.js Integration Script for ${cliInfo.name}
143
- * Auto-generated by Stigmergy CLI Integration Manager
144
- */
145
-
146
- const { spawn } = require('child_process');
147
-
148
- class ${this.capitalize(cliName)}NodeJsIntegration {
149
- constructor() {
150
- this.cliName = '${cliName}';
151
- this.executable = '${cliInfo.executable}';
152
- }
153
-
154
- async executeCommand(command, args = [], options = {}) {
155
- return new Promise((resolve, reject) => {
156
- const cliProcess = spawn(this.executable, [command, ...args], {
157
- timeout: options.timeout || 30000,
158
- ...options
159
- });
160
-
161
- let stdout = '';
162
- let stderr = '';
163
-
164
- cliProcess.stdout.on('data', (data) => {
165
- stdout += data.toString();
166
- });
167
-
168
- cliProcess.stderr.on('data', (data) => {
169
- stderr += data.toString();
170
- });
171
-
172
- cliProcess.on('close', (code) => {
173
- if (code === 0) {
174
- resolve(stdout.trim());
175
- } else {
176
- reject(new Error(\`CLI process exited with code \${code}: \${stderr}\`));
177
- }
178
- });
179
-
180
- cliProcess.on('error', (error) => {
181
- reject(new Error(\`Failed to start CLI process: \${error.message}\`));
182
- });
183
- });
184
- }
185
-
186
- async getVersion() {
187
- try {
188
- const version = await this.executeCommand('--version');
189
- return version;
190
- } catch (error) {
191
- throw new Error(\`Failed to get ${cliName} version: \${error.message}\`);
192
- }
193
- }
194
-
195
- async executeTask(task, context = {}) {
196
- // This would depend on the specific CLI's interface
197
- // For demonstration, we'll simulate execution
198
- return \`[NODE.JS INTEGRATION] Simulated execution of task: \${task}\`;
199
- }
200
-
201
- capitalize(str) {
202
- return str.charAt(0).toUpperCase() + str.slice(1);
203
- }
204
- }
205
-
206
- module.exports = ${this.capitalize(cliName)}NodeJsIntegration;
207
-
208
- // If run directly, test the integration
209
- if (require.main === module) {
210
- const integration = new ${this.capitalize(cliName)}NodeJsIntegration();
211
-
212
- integration.getVersion()
213
- .then(version => {
214
- console.log('${cliInfo.name} version:', version);
215
- })
216
- .catch(error => {
217
- console.error('Failed to get version:', error.message);
218
- });
219
- }
220
- `;
221
-
222
- return script;
223
- }
224
-
225
- capitalize(str) {
226
- return str.charAt(0).toUpperCase() + str.slice(1);
227
- }
228
-
229
- async deployNodeJsIntegration(cliName, targetDir) {
230
- console.log(
231
- `[CLI_INTEGRATION] Deploying Node.js integration for ${cliName}...`,
232
- );
233
-
234
- if (!fs.existsSync(targetDir)) {
235
- fs.mkdirSync(targetDir, { recursive: true });
236
- }
237
-
238
- const script = await this.getNodeJsIntegrationScript(cliName);
239
- const scriptPath = path.join(targetDir, `${cliName}_nodejs_integration.js`);
240
-
241
- fs.writeFileSync(scriptPath, script);
242
-
243
- // Make executable
244
- try {
245
- fs.chmodSync(scriptPath, 0o755);
246
- } catch (error) {
247
- console.warn(
248
- '[CLI_INTEGRATION] Failed to make script executable:',
249
- error.message,
250
- );
251
- }
252
-
253
- return scriptPath;
254
- }
255
-
256
- async getSupportedFeatures(cliName) {
257
- const cliInfo = this.supportedCLIs[cliName.toLowerCase()];
258
- if (!cliInfo) {
259
- return null;
260
- }
261
-
262
- return {
263
- name: cliInfo.name,
264
- executable: cliInfo.executable,
265
- features: Object.keys(cliInfo).filter(
266
- (key) => key !== 'name' && key !== 'executable',
267
- ),
268
- };
269
- }
270
- }
271
-
272
- module.exports = CLIIntegrationManager;
1
+ // src/core/coordination/nodejs/CLIIntegrationManager.js
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const os = require('os');
5
+ const { spawn, spawnSync } = require('child_process');
6
+
7
+ class CLIIntegrationManager {
8
+ constructor() {
9
+ this.supportedCLIs = {
10
+ claude: {
11
+ name: 'Claude CLI',
12
+ executable: 'claude',
13
+ hooks: [
14
+ 'user_prompt_submit',
15
+ 'tool_use_pre',
16
+ 'tool_use_post',
17
+ 'response_generated',
18
+ ],
19
+ },
20
+ gemini: {
21
+ name: 'Gemini CLI',
22
+ executable: 'gemini',
23
+ extensions: [
24
+ 'on_user_input',
25
+ 'on_response_generated',
26
+ 'on_tool_execution',
27
+ ],
28
+ },
29
+ qwencode: {
30
+ name: 'QwenCode CLI',
31
+ executable: 'qwencode',
32
+ inheritance: [
33
+ 'on_code_generation',
34
+ 'on_analysis_request',
35
+ 'on_refactor_request',
36
+ ],
37
+ },
38
+ iflow: {
39
+ name: 'iFlow CLI',
40
+ executable: 'iflow',
41
+ workflows: [
42
+ 'on_workflow_start',
43
+ 'on_stage_complete',
44
+ 'on_workflow_success',
45
+ ],
46
+ },
47
+ qoder: {
48
+ name: 'Qoder CLI',
49
+ executable: 'qoder',
50
+ notifications: [
51
+ 'on_user_notification',
52
+ 'on_system_alert',
53
+ 'on_task_completion',
54
+ ],
55
+ },
56
+ codebuddy: {
57
+ name: 'CodeBuddy CLI',
58
+ executable: 'codebuddy',
59
+ skills: [
60
+ 'on_skill_invocation',
61
+ 'on_buddy_request',
62
+ 'on_cross_cli_task',
63
+ ],
64
+ },
65
+ codex: {
66
+ name: 'Codex CLI',
67
+ executable: 'codex',
68
+ slashCommands: ['/x', '/cross-cli', '/delegate'],
69
+ },
70
+ copilot: {
71
+ name: 'Copilot CLI',
72
+ executable: 'copilot',
73
+ mcp: ['cross_cli_execute'],
74
+ },
75
+ };
76
+ }
77
+
78
+ async checkCLIAvailability(cliName) {
79
+ console.log(`[CLI_INTEGRATION] Checking availability of ${cliName}...`);
80
+
81
+ const cliInfo = this.supportedCLIs[cliName.toLowerCase()];
82
+ if (!cliInfo) {
83
+ return { available: false, error: `Unsupported CLI: ${cliName}` };
84
+ }
85
+
86
+ try {
87
+ // Check if CLI executable is available
88
+ const result = spawnSync(cliInfo.executable, ['--version'], {
89
+ timeout: 5000,
90
+ stdio: ['pipe', 'pipe', 'pipe'],
91
+ });
92
+
93
+ if (result.status === 0) {
94
+ const version = result.stdout
95
+ ? result.stdout.toString().trim()
96
+ : 'Unknown';
97
+ return {
98
+ available: true,
99
+ version: version,
100
+ name: cliInfo.name,
101
+ };
102
+ } else {
103
+ return {
104
+ available: false,
105
+ error: `CLI returned non-zero exit code: ${result.status}`,
106
+ stderr: result.stderr ? result.stderr.toString() : '',
107
+ };
108
+ }
109
+ } catch (error) {
110
+ return {
111
+ available: false,
112
+ error: `Failed to execute CLI: ${error.message}`,
113
+ };
114
+ }
115
+ }
116
+
117
+ async listAvailableCLIs() {
118
+ console.log('[CLI_INTEGRATION] Listing available CLIs...');
119
+
120
+ const results = {};
121
+ for (const [cliName, cliInfo] of Object.entries(this.supportedCLIs)) {
122
+ results[cliName] = await this.checkCLIAvailability(cliName);
123
+ }
124
+
125
+ return results;
126
+ }
127
+
128
+ async getNodeJsIntegrationScript(cliName) {
129
+ console.log(
130
+ `[CLI_INTEGRATION] Generating Node.js integration script for ${cliName}...`,
131
+ );
132
+
133
+ const cliInfo = this.supportedCLIs[cliName.toLowerCase()];
134
+ if (!cliInfo) {
135
+ throw new Error(`Unsupported CLI: ${cliName}`);
136
+ }
137
+
138
+ // Generate a Node.js integration script
139
+ const script = `#!/usr/bin/env node
140
+
141
+ /**
142
+ * Node.js Integration Script for ${cliInfo.name}
143
+ * Auto-generated by Stigmergy CLI Integration Manager
144
+ */
145
+
146
+ const { spawn } = require('child_process');
147
+
148
+ class ${this.capitalize(cliName)}NodeJsIntegration {
149
+ constructor() {
150
+ this.cliName = '${cliName}';
151
+ this.executable = '${cliInfo.executable}';
152
+ }
153
+
154
+ async executeCommand(command, args = [], options = {}) {
155
+ return new Promise((resolve, reject) => {
156
+ const cliProcess = spawn(this.executable, [command, ...args], {
157
+ timeout: options.timeout || 30000,
158
+ ...options
159
+ });
160
+
161
+ let stdout = '';
162
+ let stderr = '';
163
+
164
+ cliProcess.stdout.on('data', (data) => {
165
+ stdout += data.toString();
166
+ });
167
+
168
+ cliProcess.stderr.on('data', (data) => {
169
+ stderr += data.toString();
170
+ });
171
+
172
+ cliProcess.on('close', (code) => {
173
+ if (code === 0) {
174
+ resolve(stdout.trim());
175
+ } else {
176
+ reject(new Error(\`CLI process exited with code \${code}: \${stderr}\`));
177
+ }
178
+ });
179
+
180
+ cliProcess.on('error', (error) => {
181
+ reject(new Error(\`Failed to start CLI process: \${error.message}\`));
182
+ });
183
+ });
184
+ }
185
+
186
+ async getVersion() {
187
+ try {
188
+ const version = await this.executeCommand('--version');
189
+ return version;
190
+ } catch (error) {
191
+ throw new Error(\`Failed to get ${cliName} version: \${error.message}\`);
192
+ }
193
+ }
194
+
195
+ async executeTask(task, context = {}) {
196
+ // This would depend on the specific CLI's interface
197
+ // For demonstration, we'll simulate execution
198
+ return \`[NODE.JS INTEGRATION] Simulated execution of task: \${task}\`;
199
+ }
200
+
201
+ capitalize(str) {
202
+ return str.charAt(0).toUpperCase() + str.slice(1);
203
+ }
204
+ }
205
+
206
+ module.exports = ${this.capitalize(cliName)}NodeJsIntegration;
207
+
208
+ // If run directly, test the integration
209
+ if (require.main === module) {
210
+ const integration = new ${this.capitalize(cliName)}NodeJsIntegration();
211
+
212
+ integration.getVersion()
213
+ .then(version => {
214
+ console.log('${cliInfo.name} version:', version);
215
+ })
216
+ .catch(error => {
217
+ console.error('Failed to get version:', error.message);
218
+ });
219
+ }
220
+ `;
221
+
222
+ return script;
223
+ }
224
+
225
+ capitalize(str) {
226
+ return str.charAt(0).toUpperCase() + str.slice(1);
227
+ }
228
+
229
+ async deployNodeJsIntegration(cliName, targetDir) {
230
+ console.log(
231
+ `[CLI_INTEGRATION] Deploying Node.js integration for ${cliName}...`,
232
+ );
233
+
234
+ if (!fs.existsSync(targetDir)) {
235
+ fs.mkdirSync(targetDir, { recursive: true });
236
+ }
237
+
238
+ const script = await this.getNodeJsIntegrationScript(cliName);
239
+ const scriptPath = path.join(targetDir, `${cliName}_nodejs_integration.js`);
240
+
241
+ fs.writeFileSync(scriptPath, script);
242
+
243
+ // Make executable
244
+ try {
245
+ fs.chmodSync(scriptPath, 0o755);
246
+ } catch (error) {
247
+ console.warn(
248
+ '[CLI_INTEGRATION] Failed to make script executable:',
249
+ error.message,
250
+ );
251
+ }
252
+
253
+ return scriptPath;
254
+ }
255
+
256
+ async getSupportedFeatures(cliName) {
257
+ const cliInfo = this.supportedCLIs[cliName.toLowerCase()];
258
+ if (!cliInfo) {
259
+ return null;
260
+ }
261
+
262
+ return {
263
+ name: cliInfo.name,
264
+ executable: cliInfo.executable,
265
+ features: Object.keys(cliInfo).filter(
266
+ (key) => key !== 'name' && key !== 'executable',
267
+ ),
268
+ };
269
+ }
270
+ }
271
+
272
+ module.exports = CLIIntegrationManager;