stigmergy 1.2.0 → 1.2.8

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 (130) hide show
  1. package/LICENSE +18 -18
  2. package/README.md +31 -211
  3. package/STIGMERGY.md +70 -61
  4. package/docs/MULTI_USER_WIKI_COLLABORATION_SYSTEM.md +523 -0
  5. package/docs/PROJECT_CONSTITUTION.md +433 -433
  6. package/docs/PROJECT_STRUCTURE_CURRENT.md +80 -80
  7. package/docs/PROMPT_BASED_SKILLS_SYSTEM_DESIGN.md +458 -0
  8. package/docs/SKILL_IMPLEMENTATION_CONSTRAINTS_AND_ALIGNMENT.md +423 -0
  9. package/docs/TECHNICAL_FEASIBILITY_ANALYSIS.md +308 -0
  10. package/examples/calculator-example.js +72 -72
  11. package/examples/cline_usage_examples.md +364 -364
  12. package/examples/encryption-example.js +67 -67
  13. package/examples/json-parser-example.js +120 -120
  14. package/examples/json-validation-example.js +64 -64
  15. package/examples/multilingual-hook-demo.js +125 -0
  16. package/examples/rest-client-example.js +52 -52
  17. package/examples/rest_client_example.js +54 -54
  18. package/package.json +38 -20
  19. package/scripts/build.js +74 -74
  20. package/scripts/dependency-analyzer.js +101 -0
  21. package/scripts/generate-cli-docs.js +64 -0
  22. package/scripts/post-deployment-config.js +296 -296
  23. package/scripts/postuninstall.js +46 -0
  24. package/scripts/preinstall-check.js +173 -173
  25. package/scripts/preuninstall.js +75 -0
  26. package/scripts/publish.js +58 -268
  27. package/scripts/run-layered-tests.js +247 -0
  28. package/scripts/safe-install.js +139 -139
  29. package/scripts/simple-publish.js +57 -59
  30. package/src/adapters/claude/install_claude_integration.js +292 -0
  31. package/src/adapters/codebuddy/install_codebuddy_integration.js +349 -0
  32. package/src/adapters/codex/install_codex_integration.js +395 -0
  33. package/src/adapters/copilot/install_copilot_integration.js +716 -0
  34. package/src/adapters/gemini/install_gemini_integration.js +304 -0
  35. package/src/adapters/iflow/install_iflow_integration.js +304 -0
  36. package/src/adapters/qoder/install_qoder_integration.js +1090 -0
  37. package/src/adapters/qwen/install_qwen_integration.js +285 -0
  38. package/src/cli/router.js +562 -39
  39. package/src/core/cache_cleaner.js +82 -59
  40. package/src/core/cli_help_analyzer.js +297 -291
  41. package/src/core/cli_parameter_handler.js +5 -0
  42. package/src/core/cli_tools.js +6 -6
  43. package/src/core/coordination/index.js +2 -2
  44. package/src/core/coordination/nodejs/AdapterManager.js +30 -17
  45. package/src/core/coordination/nodejs/CLCommunication.js +28 -20
  46. package/src/core/coordination/nodejs/CLIIntegrationManager.js +72 -36
  47. package/src/core/coordination/nodejs/HealthChecker.js +13 -14
  48. package/src/core/coordination/nodejs/HookDeploymentManager.js +325 -63
  49. package/src/core/coordination/nodejs/StatisticsCollector.js +6 -6
  50. package/src/core/coordination/nodejs/index.js +29 -11
  51. package/src/core/coordination/nodejs/utils/Logger.js +1 -1
  52. package/src/core/enhanced_installer.js +92 -69
  53. package/src/core/enhanced_uninstaller.js +73 -53
  54. package/src/core/installer.js +815 -294
  55. package/src/core/multilingual/language-pattern-manager.js +172 -0
  56. package/src/core/smart_router.js +141 -26
  57. package/src/core/upgrade_manager.js +91 -46
  58. package/src/data_structures.js +1 -1
  59. package/src/deploy.js +2 -2
  60. package/src/index.js +3 -3
  61. package/src/test/cli-availability-checker.js +194 -0
  62. package/src/test/test-environment.js +289 -0
  63. package/src/utils/helpers.js +2 -2
  64. package/src/utils.js +7 -1
  65. package/test/multilingual/hook-deployment.test.js +91 -0
  66. package/test/multilingual/language-pattern-manager.test.js +140 -0
  67. package/test/multilingual/system-test.js +85 -0
  68. package/test/cache-cleaner-implemented.test.js +0 -328
  69. package/test/cache-cleaner.test.js +0 -390
  70. package/test/calculator.test.js +0 -215
  71. package/test/collision-test.js +0 -26
  72. package/test/comprehensive-enhanced-features.test.js +0 -252
  73. package/test/comprehensive-execution-test.js +0 -428
  74. package/test/conflict-prevention-test.js +0 -95
  75. package/test/cross-cli-detection-test.js +0 -33
  76. package/test/csv-processing-test.js +0 -36
  77. package/test/deploy-hooks-test.js +0 -250
  78. package/test/e2e/claude-cli-test.js +0 -128
  79. package/test/e2e/collaboration-test.js +0 -75
  80. package/test/e2e/comprehensive-test.js +0 -431
  81. package/test/e2e/error-handling-test.js +0 -90
  82. package/test/e2e/individual-tool-test.js +0 -143
  83. package/test/e2e/other-cli-test.js +0 -130
  84. package/test/e2e/qoder-cli-test.js +0 -128
  85. package/test/e2e/run-e2e-tests.js +0 -73
  86. package/test/e2e/test-data.js +0 -88
  87. package/test/e2e/test-utils.js +0 -222
  88. package/test/encryption-simple-test.js +0 -110
  89. package/test/encryption.test.js +0 -129
  90. package/test/enhanced-main-alignment.test.js +0 -298
  91. package/test/enhanced-uninstaller-implemented.test.js +0 -271
  92. package/test/enhanced-uninstaller.test.js +0 -284
  93. package/test/error-handling-test.js +0 -341
  94. package/test/fibonacci.test.js +0 -178
  95. package/test/final-deploy-test.js +0 -221
  96. package/test/final-install-test.js +0 -226
  97. package/test/hash-table-demo.js +0 -33
  98. package/test/hash-table-test.js +0 -26
  99. package/test/hash_table_test.js +0 -114
  100. package/test/hook-system-integration-test.js +0 -307
  101. package/test/iflow-integration-test.js +0 -292
  102. package/test/improved-install-test.js +0 -362
  103. package/test/install-command-test.js +0 -370
  104. package/test/json-parser-test.js +0 -161
  105. package/test/json-validation-test.js +0 -164
  106. package/test/natural-language-skills-test.js +0 -320
  107. package/test/nl-integration-test.js +0 -179
  108. package/test/parameter-parsing-test.js +0 -143
  109. package/test/plugin-deployment-test.js +0 -316
  110. package/test/postinstall-test.js +0 -269
  111. package/test/python-plugins-test.js +0 -259
  112. package/test/real-test.js +0 -435
  113. package/test/remaining-adapters-test.js +0 -256
  114. package/test/rest-client-test.js +0 -56
  115. package/test/rest_client.test.js +0 -85
  116. package/test/safe-installation-cleaner.test.js +0 -343
  117. package/test/simple-iflow-hook-test.js +0 -137
  118. package/test/stigmergy-upgrade-test.js +0 -243
  119. package/test/system-compatibility-test.js +0 -467
  120. package/test/tdd-deploy-fix-test.js +0 -324
  121. package/test/tdd-fixes-test.js +0 -211
  122. package/test/third-party-skills-test.js +0 -321
  123. package/test/tool-selection-integration-test.js +0 -158
  124. package/test/unit/calculator-full.test.js +0 -191
  125. package/test/unit/calculator-simple.test.js +0 -96
  126. package/test/unit/calculator.test.js +0 -97
  127. package/test/unit/cli-scanner.test.js +0 -291
  128. package/test/unit/cli_parameter_handler.test.js +0 -116
  129. package/test/unit/cross-cli-executor.test.js +0 -399
  130. package/test/weather-processor.test.js +0 -104
@@ -0,0 +1,285 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Qwen CLI Integration Installer - JavaScript Version
5
+ * Sets up basic integration for Qwen CLI with cross-CLI collaboration capabilities
6
+ */
7
+
8
+ const fs = require('fs').promises;
9
+ const path = require('path');
10
+ const os = require('os');
11
+
12
+ // Qwen CLI config paths
13
+ const QWEN_CONFIG_DIR = path.join(os.homedir(), '.qwen');
14
+ const QWEN_CONFIG_FILE = path.join(QWEN_CONFIG_DIR, 'config.json');
15
+ const QWEN_HOOKS_FILE = path.join(QWEN_CONFIG_DIR, 'hooks.json');
16
+
17
+ class QwenInstaller {
18
+ constructor() {
19
+ this.toolName = 'qwen';
20
+ this.configDir = QWEN_CONFIG_DIR;
21
+ this.configFile = QWEN_CONFIG_FILE;
22
+ this.hooksFile = QWEN_HOOKS_FILE;
23
+ }
24
+
25
+ async createConfigDirectory() {
26
+ await fs.mkdir(this.configDir, { recursive: true });
27
+ console.log(`[OK] Created Qwen config directory: ${this.configDir}`);
28
+ }
29
+
30
+ async installConfig() {
31
+ // Read existing config
32
+ let existingConfig = {};
33
+ try {
34
+ const content = await fs.readFile(this.configFile, 'utf-8');
35
+ existingConfig = JSON.parse(content);
36
+ } catch (e) {
37
+ console.log(`Warning: Failed to read existing config: ${e.message}`);
38
+ existingConfig = {};
39
+ }
40
+
41
+ // Define cross-CLI integration config
42
+ const crossCliConfig = {
43
+ cross_cli_enabled: true,
44
+ supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qodercli', 'codebuddy', 'copilot', 'codex'],
45
+ auto_detect: true,
46
+ timeout: 30,
47
+ collaboration_mode: 'active',
48
+ qwen_oauth_integration: true
49
+ };
50
+
51
+ // Merge configs
52
+ const mergedConfig = { ...existingConfig, ...crossCliConfig };
53
+
54
+ // Write config file
55
+ await fs.writeFile(this.configFile, JSON.stringify(mergedConfig, null, 2));
56
+ console.log(`[OK] Qwen config installed: ${this.configFile}`);
57
+ return true;
58
+ }
59
+
60
+ async installHooks() {
61
+ // Read existing hooks config
62
+ let existingHooks = {};
63
+ try {
64
+ const content = await fs.readFile(this.hooksFile, 'utf-8');
65
+ existingHooks = JSON.parse(content);
66
+ } catch (e) {
67
+ console.log(`Warning: Failed to read existing hooks config: ${e.message}`);
68
+ existingHooks = {};
69
+ }
70
+
71
+ // Define cross-CLI integration hooks
72
+ const crossCliHooks = {
73
+ cross_cli_adapter: {
74
+ enabled: true,
75
+ supported_tools: ['claude', 'gemini', 'qwen', 'iflow', 'qodercli', 'codebuddy', 'copilot', 'codex'],
76
+ trigger_patterns: [
77
+ 'use\\s+(\\w+)\\s+to\\s+(.+)$',
78
+ 'call\\s+(\\w+)\\s+(.+)$',
79
+ 'ask\\s+(\\w+)\\s+(.+)$',
80
+ 'stigmergy\\s+(\\w+)\\s+(.+)$'
81
+ ]
82
+ }
83
+ };
84
+
85
+ // Merge hooks configs
86
+ const mergedHooks = { ...existingHooks, ...crossCliHooks };
87
+
88
+ // Write hooks config file
89
+ await fs.writeFile(this.hooksFile, JSON.stringify(mergedHooks, null, 2));
90
+ console.log(`[OK] Qwen hooks installed: ${this.hooksFile}`);
91
+ return true;
92
+ }
93
+
94
+ async copyAdapterFiles() {
95
+ const currentDir = __dirname;
96
+ const targetDir = path.join(this.configDir, 'hooks');
97
+
98
+ try {
99
+ // Look for adapter files to copy
100
+ const adapterFiles = await fs.readdir(currentDir);
101
+ const filesToCopy = adapterFiles.filter(file =>
102
+ file.endsWith('.js') || file.endsWith('.json') || file.endsWith('.py') || file === '__init__.py'
103
+ );
104
+
105
+ for (const file of filesToCopy) {
106
+ const srcFile = path.join(currentDir, file);
107
+ const dstFile = path.join(targetDir, file);
108
+ await fs.copyFile(srcFile, dstFile);
109
+ console.log(`[OK] Copied adapter file: ${file}`);
110
+ }
111
+
112
+ // Create global Cross-CLI documentation
113
+ await this.createGlobalCrossCliDocumentation(this.configDir);
114
+
115
+ return true;
116
+ } catch (e) {
117
+ console.log(`Warning: Failed to copy adapter files: ${e.message}`);
118
+ return true;
119
+ }
120
+ }
121
+
122
+ async createGlobalCrossCliDocumentation(configDir) {
123
+ try {
124
+ const docContent = `# Qwen CLI Cross-CLI Communication Guide
125
+
126
+ ## Cross-CLI Communication
127
+ When you need to call other AI tools, please use the following prompt <<<Execute the following command in shell: stigmergy distcli "Prompt">>>
128
+
129
+ Examples:
130
+ - Run in shell: stigmergy claude "write a Python function"
131
+ - Run in shell: stigmergy gemini "translate this text"
132
+ - Run in shell: stigmergy qwen "analyze this code"
133
+
134
+ Available tools: claude, gemini, qwen, iflow, qodercli, codebuddy, copilot, codex
135
+
136
+ ---
137
+ *This document is automatically generated and maintained by Stigmergy CLI*
138
+ `;
139
+
140
+ const docPath = path.join(configDir, 'CROSS_CLI_GUIDE.md');
141
+ await fs.writeFile(docPath, docContent);
142
+ console.log(`[OK] Created Cross-CLI Communication Guide: ${docPath}`);
143
+
144
+ // Append to qwen.md if it exists
145
+ const qwenMdPath = path.join(os.homedir(), '.qwen', 'qwen.md');
146
+ try {
147
+ await fs.access(qwenMdPath);
148
+ const crossCliContent = `
149
+
150
+ ## Cross-CLI Communication
151
+ When you need to call other AI tools, please use the following prompt <<<Execute the following command in shell: stigmergy distcli "Prompt">>>
152
+
153
+ Examples:
154
+ - Run in shell: stigmergy claude "write a Python function"
155
+ - Run in shell: stigmergy gemini "translate this text"
156
+ - Run in shell: stigmergy qwen "analyze this code"
157
+
158
+ Available tools: claude, gemini, qwen, iflow, qodercli, codebuddy, copilot, codex
159
+ `;
160
+ await fs.appendFile(qwenMdPath, crossCliContent);
161
+ console.log('[OK] 在QWEN.md末尾追加Cross-CLI通信提示');
162
+ } catch (e) {
163
+ // File doesn't exist, that's ok
164
+ }
165
+
166
+ return true;
167
+ } catch (e) {
168
+ console.log(`Warning: Failed to create Cross-CLI Communication Guide: ${e.message}`);
169
+ return false;
170
+ }
171
+ }
172
+
173
+ async verifyInstallation() {
174
+ console.log('\n验证Qwen CLI集成安装...');
175
+
176
+ // Check config directory
177
+ if (!await fs.access(this.configDir).then(() => true).catch(() => false)) {
178
+ console.log(`Warning: Config directory does not exist: ${this.configDir}`);
179
+ return true;
180
+ }
181
+
182
+ // Check config file content
183
+ try {
184
+ const content = await fs.readFile(this.configFile, 'utf-8');
185
+ const config = JSON.parse(content);
186
+
187
+ if (config.cross_cli_enabled) {
188
+ console.log('[OK] Cross-CLI integration enabled');
189
+ } else {
190
+ console.log('Note: Cross-CLI integration not enabled');
191
+ }
192
+
193
+ console.log('[OK] Qwen config file verified');
194
+ return true;
195
+ } catch (e) {
196
+ console.log(`Warning: Failed to verify config file: ${e.message}`);
197
+ return true;
198
+ }
199
+ }
200
+
201
+ async uninstallIntegration() {
202
+ try {
203
+ // Remove cross-CLI config from config file
204
+ if (await fs.access(this.configFile).then(() => true).catch(() => false)) {
205
+ const content = await fs.readFile(this.configFile, 'utf-8');
206
+ const config = JSON.parse(content);
207
+
208
+ // Remove cross-CLI settings
209
+ delete config.cross_cli_enabled;
210
+ delete config.supported_clis;
211
+ delete config.auto_detect;
212
+ delete config.collaboration_mode;
213
+ delete config.qwen_oauth_integration;
214
+
215
+ // Save updated config
216
+ await fs.writeFile(this.configFile, JSON.stringify(config, null, 2));
217
+ console.log('[OK] Removed cross-CLI settings from Qwen config');
218
+ }
219
+
220
+ // Remove hooks config file
221
+ if (await fs.access(this.hooksFile).then(() => true).catch(() => false)) {
222
+ await fs.unlink(this.hooksFile);
223
+ console.log('[OK] Removed Qwen hooks config file');
224
+ }
225
+
226
+ console.log('[OK] Qwen CLI cross-CLI integration uninstalled');
227
+ return true;
228
+ } catch (e) {
229
+ console.log(`Error: Uninstall failed: ${e.message}`);
230
+ return false;
231
+ }
232
+ }
233
+
234
+ async install() {
235
+ console.log('Qwen CLI Integration Installer');
236
+ console.log('==========================================');
237
+
238
+ // Execute installation
239
+ console.log('Step 1. 创建配置目录...');
240
+ await this.createConfigDirectory();
241
+
242
+ console.log('\nStep 2. 安装配置...');
243
+ const configSuccess = await this.installConfig();
244
+
245
+ console.log('\nStep 3. 安装钩子...');
246
+ const hooksSuccess = await this.installHooks();
247
+
248
+ console.log('\nStep 4. 复制适配器文件...');
249
+ const adapterSuccess = await this.copyAdapterFiles();
250
+
251
+ console.log('\nStep 5. 验证安装...');
252
+ const verificationSuccess = await this.verifyInstallation();
253
+
254
+ const overallSuccess = configSuccess && hooksSuccess && adapterSuccess && verificationSuccess;
255
+ if (overallSuccess) {
256
+ console.log('\n[SUCCESS] Qwen CLI integration installed successfully!');
257
+ } else {
258
+ console.log('\n[WARNING] Installation completed with warnings');
259
+ }
260
+
261
+ return overallSuccess;
262
+ }
263
+ }
264
+
265
+ // Main execution
266
+ if (require.main === module) {
267
+ const installer = new QwenInstaller();
268
+
269
+ const args = process.argv.slice(2);
270
+ const command = args[0];
271
+
272
+ switch (command) {
273
+ case '--verify':
274
+ installer.verifyInstallation().then(success => process.exit(success ? 0 : 1));
275
+ break;
276
+ case '--uninstall':
277
+ installer.uninstallIntegration().then(success => process.exit(success ? 0 : 1));
278
+ break;
279
+ default:
280
+ installer.install().then(success => process.exit(success ? 0 : 1));
281
+ break;
282
+ }
283
+ }
284
+
285
+ module.exports = QwenInstaller;