stigmergy 1.1.6 → 1.2.6

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 (118) hide show
  1. package/LICENSE +18 -18
  2. package/README.md +28 -223
  3. package/STIGMERGY.md +61 -61
  4. package/docs/PROJECT_CONSTITUTION.md +433 -433
  5. package/docs/PROJECT_STRUCTURE_CURRENT.md +80 -80
  6. package/examples/calculator-example.js +72 -72
  7. package/examples/cline_usage_examples.md +364 -364
  8. package/examples/encryption-example.js +67 -67
  9. package/examples/json-parser-example.js +120 -120
  10. package/examples/json-validation-example.js +64 -64
  11. package/examples/rest-client-example.js +52 -52
  12. package/examples/rest_client_example.js +54 -54
  13. package/package.json +15 -7
  14. package/scripts/build.js +74 -74
  15. package/scripts/post-deployment-config.js +296 -296
  16. package/scripts/preinstall-check.js +173 -111
  17. package/scripts/publish.js +58 -268
  18. package/scripts/run-layered-tests.js +247 -0
  19. package/scripts/safe-install.js +139 -139
  20. package/scripts/simple-publish.js +57 -59
  21. package/src/adapters/claude/install_claude_integration.js +292 -0
  22. package/src/adapters/codebuddy/install_codebuddy_integration.js +349 -0
  23. package/src/adapters/codex/install_codex_integration.js +395 -0
  24. package/src/adapters/copilot/install_copilot_integration.js +716 -0
  25. package/src/adapters/gemini/install_gemini_integration.js +304 -0
  26. package/src/adapters/iflow/install_iflow_integration.js +304 -0
  27. package/src/adapters/qoder/install_qoder_integration.js +1090 -0
  28. package/src/adapters/qwen/install_qwen_integration.js +285 -0
  29. package/src/auth.js +173 -173
  30. package/src/auth_command.js +208 -208
  31. package/src/calculator.js +313 -313
  32. package/src/cli/router.js +792 -67
  33. package/src/core/cache_cleaner.js +767 -0
  34. package/src/core/cli_help_analyzer.js +680 -674
  35. package/src/core/cli_parameter_handler.js +132 -127
  36. package/src/core/cli_tools.js +89 -89
  37. package/src/core/coordination/index.js +16 -16
  38. package/src/core/coordination/nodejs/AdapterManager.js +102 -89
  39. package/src/core/coordination/nodejs/CLCommunication.js +132 -124
  40. package/src/core/coordination/nodejs/CLIIntegrationManager.js +272 -236
  41. package/src/core/coordination/nodejs/HealthChecker.js +76 -77
  42. package/src/core/coordination/nodejs/HookDeploymentManager.js +263 -190
  43. package/src/core/coordination/nodejs/StatisticsCollector.js +71 -71
  44. package/src/core/coordination/nodejs/index.js +90 -72
  45. package/src/core/coordination/nodejs/utils/Logger.js +29 -29
  46. package/src/core/enhanced_installer.js +479 -0
  47. package/src/core/enhanced_uninstaller.js +638 -0
  48. package/src/core/error_handler.js +406 -406
  49. package/src/core/installer.js +816 -294
  50. package/src/core/memory_manager.js +83 -83
  51. package/src/core/rest_client.js +160 -160
  52. package/src/core/smart_router.js +249 -146
  53. package/src/core/upgrade_manager.js +420 -0
  54. package/src/data_encryption.js +143 -143
  55. package/src/data_structures.js +440 -440
  56. package/src/deploy.js +55 -55
  57. package/src/index.js +30 -30
  58. package/src/test/cli-availability-checker.js +194 -0
  59. package/src/test/test-environment.js +289 -0
  60. package/src/utils/helpers.js +35 -35
  61. package/src/utils.js +921 -915
  62. package/src/weatherProcessor.js +228 -228
  63. package/test/calculator.test.js +0 -215
  64. package/test/collision-test.js +0 -26
  65. package/test/comprehensive-execution-test.js +0 -428
  66. package/test/conflict-prevention-test.js +0 -95
  67. package/test/cross-cli-detection-test.js +0 -33
  68. package/test/csv-processing-test.js +0 -36
  69. package/test/deploy-hooks-test.js +0 -250
  70. package/test/e2e/claude-cli-test.js +0 -128
  71. package/test/e2e/collaboration-test.js +0 -75
  72. package/test/e2e/comprehensive-test.js +0 -431
  73. package/test/e2e/error-handling-test.js +0 -90
  74. package/test/e2e/individual-tool-test.js +0 -143
  75. package/test/e2e/other-cli-test.js +0 -130
  76. package/test/e2e/qoder-cli-test.js +0 -128
  77. package/test/e2e/run-e2e-tests.js +0 -73
  78. package/test/e2e/test-data.js +0 -88
  79. package/test/e2e/test-utils.js +0 -222
  80. package/test/encryption-simple-test.js +0 -110
  81. package/test/encryption.test.js +0 -129
  82. package/test/enhanced-main-alignment.test.js +0 -298
  83. package/test/error-handling-test.js +0 -341
  84. package/test/fibonacci.test.js +0 -178
  85. package/test/final-deploy-test.js +0 -221
  86. package/test/final-install-test.js +0 -226
  87. package/test/hash-table-demo.js +0 -33
  88. package/test/hash-table-test.js +0 -26
  89. package/test/hash_table_test.js +0 -114
  90. package/test/hook-system-integration-test.js +0 -307
  91. package/test/iflow-integration-test.js +0 -292
  92. package/test/improved-install-test.js +0 -362
  93. package/test/install-command-test.js +0 -370
  94. package/test/json-parser-test.js +0 -161
  95. package/test/json-validation-test.js +0 -164
  96. package/test/natural-language-skills-test.js +0 -320
  97. package/test/nl-integration-test.js +0 -179
  98. package/test/parameter-parsing-test.js +0 -143
  99. package/test/plugin-deployment-test.js +0 -316
  100. package/test/postinstall-test.js +0 -269
  101. package/test/python-plugins-test.js +0 -259
  102. package/test/real-test.js +0 -435
  103. package/test/remaining-adapters-test.js +0 -256
  104. package/test/rest-client-test.js +0 -56
  105. package/test/rest_client.test.js +0 -85
  106. package/test/simple-iflow-hook-test.js +0 -137
  107. package/test/system-compatibility-test.js +0 -467
  108. package/test/tdd-deploy-fix-test.js +0 -324
  109. package/test/tdd-fixes-test.js +0 -211
  110. package/test/third-party-skills-test.js +0 -321
  111. package/test/tool-selection-integration-test.js +0 -158
  112. package/test/unit/calculator-full.test.js +0 -191
  113. package/test/unit/calculator-simple.test.js +0 -96
  114. package/test/unit/calculator.test.js +0 -97
  115. package/test/unit/cli-scanner.test.js +0 -291
  116. package/test/unit/cli_parameter_handler.test.js +0 -116
  117. package/test/unit/cross-cli-executor.test.js +0 -399
  118. package/test/weather-processor.test.js +0 -104
@@ -1,362 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Improved Test for CLI Installation with Better Error Handling
5
- * This test verifies installation commands with improved error handling
6
- * and Windows compatibility
7
- */
8
-
9
- const { spawnSync, spawn } = require('child_process');
10
- const path = require('path');
11
- const os = require('os');
12
-
13
- class ImprovedInstallTester {
14
- constructor() {
15
- this.testResults = [];
16
- }
17
-
18
- // Test 1: Verify npm availability with multiple methods
19
- async testNpmAvailability() {
20
- console.log('[TEST 1] Verifying npm availability with multiple methods...');
21
-
22
- try {
23
- // Method 1: Direct npm command
24
- console.log(' Testing direct npm command...');
25
- const npmDirect = spawnSync('npm', ['--version'], {
26
- encoding: 'utf8',
27
- timeout: 10000
28
- });
29
-
30
- console.log(` Direct npm - Status: ${npmDirect.status}`);
31
- if (npmDirect.stdout) {
32
- console.log(` Direct npm - Version: ${npmDirect.stdout.trim()}`);
33
- }
34
-
35
- // Method 2: npm through cmd.exe on Windows
36
- const isWindows = process.platform === 'win32';
37
- let npmThroughCmd = { status: null };
38
-
39
- if (isWindows) {
40
- console.log(' Testing npm through cmd.exe...');
41
- npmThroughCmd = spawnSync('cmd.exe', ['/c', 'npm', '--version'], {
42
- encoding: 'utf8',
43
- timeout: 10000
44
- });
45
- console.log(` npm through cmd.exe - Status: ${npmThroughCmd.status}`);
46
- }
47
-
48
- // Method 3: Check PATH for npm
49
- console.log(' Checking PATH for npm...');
50
- const pathEnv = process.env.PATH || '';
51
- const hasNpmInPath = pathEnv.toLowerCase().includes('npm');
52
- console.log(` npm in PATH: ${hasNpmInPath}`);
53
-
54
- const npmAvailable = npmDirect.status === 0 || npmThroughCmd.status === 0;
55
-
56
- this.testResults.push({
57
- name: 'npm Availability',
58
- passed: npmAvailable,
59
- details: `Direct: ${npmDirect.status === 0}, Cmd: ${npmThroughCmd.status === 0}, PATH: ${hasNpmInPath}`
60
- });
61
-
62
- return npmAvailable;
63
- } catch (error) {
64
- console.log(` ✗ Failed to check npm availability: ${error.message}`);
65
- this.testResults.push({
66
- name: 'npm Availability',
67
- passed: false,
68
- details: `Failed to check: ${error.message}`
69
- });
70
- return false;
71
- }
72
- }
73
-
74
- // Test 2: Test Qoder CLI installation with shell options
75
- async testQoderInstallationWithShellOptions() {
76
- console.log('\n[TEST 2] Testing Qoder CLI installation with shell options...');
77
-
78
- try {
79
- const installCommand = 'npm install -g @qoder-ai/qodercli';
80
- const commandParts = installCommand.split(' ');
81
- const command = commandParts[0];
82
- const args = commandParts.slice(1);
83
-
84
- console.log(` Installation command: ${installCommand}`);
85
-
86
- // Test 1: Without shell option
87
- console.log(' Testing without shell option...');
88
- const test1 = spawnSync(command, args, {
89
- encoding: 'utf8',
90
- timeout: 15000,
91
- stdio: 'pipe'
92
- });
93
-
94
- console.log(` Without shell - Status: ${test1.status}`);
95
-
96
- // Test 2: With shell=true
97
- console.log(' Testing with shell=true...');
98
- const test2 = spawnSync(command, args, {
99
- encoding: 'utf8',
100
- timeout: 15000,
101
- stdio: 'pipe',
102
- shell: true
103
- });
104
-
105
- console.log(` With shell - Status: ${test2.status}`);
106
-
107
- // Test 3: On Windows, try cmd.exe explicitly
108
- let test3 = { status: null };
109
- if (process.platform === 'win32') {
110
- console.log(' Testing with explicit cmd.exe...');
111
- const fullCommand = [command, ...args].join(' ');
112
- test3 = spawnSync('cmd.exe', ['/c', fullCommand], {
113
- encoding: 'utf8',
114
- timeout: 15000,
115
- stdio: 'pipe'
116
- });
117
- console.log(` Explicit cmd.exe - Status: ${test3.status}`);
118
- }
119
-
120
- // Determine which method works
121
- const worksWithoutShell = test1.status === 0;
122
- const worksWithShell = test2.status === 0;
123
- const worksWithCmd = test3.status === 0;
124
-
125
- console.log(` Results - Without shell: ${worksWithoutShell}, With shell: ${worksWithShell}, With cmd: ${worksWithCmd}`);
126
-
127
- this.testResults.push({
128
- name: 'Qoder Installation Shell Options',
129
- passed: worksWithoutShell || worksWithShell || worksWithCmd,
130
- details: `Without shell: ${worksWithoutShell}, With shell: ${worksWithShell}, With cmd: ${worksWithCmd}`
131
- });
132
-
133
- return worksWithoutShell || worksWithShell || worksWithCmd;
134
- } catch (error) {
135
- console.log(` ✗ Failed to test installation with shell options: ${error.message}`);
136
- this.testResults.push({
137
- name: 'Qoder Installation Shell Options',
138
- passed: false,
139
- details: `Failed to test: ${error.message}`
140
- });
141
- return false;
142
- }
143
- }
144
-
145
- // Test 3: Test spawn vs spawnSync behavior
146
- async testSpawnVsSpawnSync() {
147
- console.log('\n[TEST 3] Testing spawn vs spawnSync behavior...');
148
-
149
- try {
150
- const command = 'npm';
151
- const args = ['--version'];
152
-
153
- // Test spawnSync
154
- console.log(' Testing spawnSync...');
155
- const syncResult = spawnSync(command, args, {
156
- encoding: 'utf8',
157
- timeout: 10000,
158
- shell: true
159
- });
160
-
161
- console.log(` spawnSync - Status: ${syncResult.status}`);
162
-
163
- // Test spawn
164
- console.log(' Testing spawn...');
165
- const spawnResult = await new Promise((resolve) => {
166
- const child = spawn(command, args, {
167
- encoding: 'utf8',
168
- timeout: 10000,
169
- shell: true
170
- });
171
-
172
- let stdout = '';
173
- let stderr = '';
174
-
175
- child.stdout.on('data', (data) => {
176
- stdout += data.toString();
177
- });
178
-
179
- child.stderr.on('data', (data) => {
180
- stderr += data.toString();
181
- });
182
-
183
- child.on('close', (code) => {
184
- resolve({
185
- status: code,
186
- stdout: stdout,
187
- stderr: stderr
188
- });
189
- });
190
-
191
- child.on('error', (error) => {
192
- resolve({
193
- status: null,
194
- error: error.message
195
- });
196
- });
197
-
198
- // Timeout
199
- setTimeout(() => {
200
- child.kill();
201
- resolve({
202
- status: null,
203
- error: 'Timeout'
204
- });
205
- }, 11000);
206
- });
207
-
208
- console.log(` spawn - Status: ${spawnResult.status}`);
209
- if (spawnResult.error) {
210
- console.log(` spawn - Error: ${spawnResult.error}`);
211
- }
212
-
213
- const bothWork = syncResult.status === 0 && spawnResult.status === 0;
214
-
215
- this.testResults.push({
216
- name: 'Spawn vs SpawnSync',
217
- passed: bothWork,
218
- details: `spawnSync: ${syncResult.status}, spawn: ${spawnResult.status}`
219
- });
220
-
221
- return bothWork;
222
- } catch (error) {
223
- console.log(` ✗ Failed to test spawn behavior: ${error.message}`);
224
- this.testResults.push({
225
- name: 'Spawn vs SpawnSync',
226
- passed: false,
227
- details: `Failed to test: ${error.message}`
228
- });
229
- return false;
230
- }
231
- }
232
-
233
- // Test 4: Verify current installation implementation issues
234
- async testCurrentInstallationImplementation() {
235
- console.log('\n[TEST 4] Verifying current installation implementation...');
236
-
237
- try {
238
- // Simulate the current implementation from main_english.js
239
- const toolInfo = {
240
- name: 'Qoder CLI',
241
- install: 'npm install -g @qoder-ai/qodercli'
242
- };
243
-
244
- console.log(` Simulating current implementation for: ${toolInfo.name}`);
245
- console.log(` Install command: ${toolInfo.install}`);
246
-
247
- const installCmd = toolInfo.install.split(' ');
248
- console.log(` Command parts: ${JSON.stringify(installCmd)}`);
249
-
250
- // Current implementation (similar to lines 512-518 in main_english.js)
251
- console.log(' Testing current implementation approach...');
252
- const result = spawnSync(installCmd[0], installCmd.slice(1), {
253
- encoding: 'utf8',
254
- timeout: 300000, // 5 minutes
255
- stdio: 'pipe', // Changed from 'inherit' to 'pipe' for testing
256
- env: process.env
257
- });
258
-
259
- console.log(` Current implementation - Status: ${result.status}`);
260
- if (result.error) {
261
- console.log(` Current implementation - Error: ${result.error.message}`);
262
- }
263
- if (result.stderr && result.stderr.length > 0) {
264
- const stderrPreview = result.stderr.substring(0, 200);
265
- console.log(` Current implementation - Stderr preview: ${stderrPreview}${result.stderr.length > 200 ? '...' : ''}`);
266
- }
267
-
268
- // Test with shell=true
269
- console.log(' Testing current implementation with shell=true...');
270
- const resultWithShell = spawnSync(installCmd[0], installCmd.slice(1), {
271
- encoding: 'utf8',
272
- timeout: 300000,
273
- stdio: 'pipe',
274
- env: process.env,
275
- shell: true
276
- });
277
-
278
- console.log(` Current implementation with shell - Status: ${resultWithShell.status}`);
279
- if (resultWithShell.error) {
280
- console.log(` Current implementation with shell - Error: ${resultWithShell.error.message}`);
281
- }
282
- if (resultWithShell.stderr && resultWithShell.stderr.length > 0) {
283
- const stderrPreview = resultWithShell.stderr.substring(0, 200);
284
- console.log(` Current implementation with shell - Stderr preview: ${stderrPreview}${resultWithShell.stderr.length > 200 ? '...' : ''}`);
285
- }
286
-
287
- this.testResults.push({
288
- name: 'Current Installation Implementation',
289
- passed: result.status === 0 || resultWithShell.status === 0,
290
- details: `Without shell: ${result.status}, With shell: ${resultWithShell.status}`
291
- });
292
-
293
- return result.status === 0 || resultWithShell.status === 0;
294
- } catch (error) {
295
- console.log(` ✗ Failed to test current implementation: ${error.message}`);
296
- this.testResults.push({
297
- name: 'Current Installation Implementation',
298
- passed: false,
299
- details: `Failed to test: ${error.message}`
300
- });
301
- return false;
302
- }
303
- }
304
-
305
- // Run all tests
306
- async runAllTests() {
307
- console.log('Improved CLI Installation Test');
308
- console.log('='.repeat(40));
309
-
310
- await this.testNpmAvailability();
311
- await this.testQoderInstallationWithShellOptions();
312
- await this.testSpawnVsSpawnSync();
313
- await this.testCurrentInstallationImplementation();
314
-
315
- // Summary
316
- console.log('\n' + '='.repeat(40));
317
- console.log('Improved Installation Test Summary:');
318
- console.log('='.repeat(40));
319
-
320
- let passedTests = 0;
321
- this.testResults.forEach(result => {
322
- console.log(`${result.name}: ${result.passed ? '✓ PASS' : '✗ FAIL'} - ${result.details}`);
323
- if (result.passed) passedTests++;
324
- });
325
-
326
- console.log(`\nOverall Result: ${passedTests}/${this.testResults.length} tests passed`);
327
-
328
- if (passedTests === this.testResults.length) {
329
- console.log('✓ All improved installation tests passed!');
330
- } else if (passedTests > 0) {
331
- console.log('⚠ Some improved installation tests passed.');
332
- } else {
333
- console.log('✗ All improved installation tests failed.');
334
- }
335
-
336
- return {
337
- totalTests: this.testResults.length,
338
- passedTests: passedTests,
339
- results: this.testResults
340
- };
341
- }
342
- }
343
-
344
- // Run the tests
345
- async function runImprovedInstallTests() {
346
- const tester = new ImprovedInstallTester();
347
- const results = await tester.runAllTests();
348
- return results;
349
- }
350
-
351
- // Export for use in other modules
352
- module.exports = { ImprovedInstallTester };
353
-
354
- // Run if called directly
355
- if (require.main === module) {
356
- runImprovedInstallTests().then(results => {
357
- process.exit(results.passedTests === results.totalTests ? 0 : 1);
358
- }).catch(error => {
359
- console.error('[Test Failed]:', error.message);
360
- process.exit(1);
361
- });
362
- }