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,26 +0,0 @@
1
- const { HashTable } = require('../src/utils');
2
-
3
- console.log("=== Hash Table Collision Handling Demo ===");
4
-
5
- // Create a hash table with a small size to force collisions
6
- const ht = new HashTable(4); // Small size to demonstrate collisions
7
-
8
- // Add several key-value pairs that will cause collisions
9
- ht.set("key1", "value1");
10
- ht.set("key2", "value2");
11
- ht.set("key3", "value3");
12
- ht.set("key4", "value4");
13
- ht.set("key5", "value5"); // This will collide with one of the above
14
-
15
- console.log("Values retrieved:");
16
- console.log("key1:", ht.get("key1"));
17
- console.log("key2:", ht.get("key2"));
18
- console.log("key3:", ht.get("key3"));
19
- console.log("key4:", ht.get("key4"));
20
- console.log("key5:", ht.get("key5"));
21
- console.log("nonexistent_key:", ht.get("nonexistent_key"));
22
-
23
- console.log("\nAll keys:", ht.keys());
24
- console.log("All values:", ht.values());
25
-
26
- console.log("\n=== Test completed successfully! ===");
@@ -1,428 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Comprehensive Execution Test
5
- * This test thoroughly validates that the improved execution mechanisms
6
- * will guarantee correct command execution across different platforms
7
- */
8
-
9
- const { spawnSync } = require('child_process');
10
- const path = require('path');
11
- const os = require('os');
12
-
13
- class ComprehensiveExecutionTest {
14
- constructor() {
15
- this.testResults = [];
16
- }
17
-
18
- // Test 1: Verify shell execution reliability
19
- async testShellExecutionReliability() {
20
- console.log('[TEST 1] Verifying shell execution reliability...');
21
-
22
- try {
23
- // Test multiple commands with shell: true
24
- const testCommands = [
25
- { cmd: 'npm', args: ['--version'] },
26
- { cmd: 'node', args: ['--version'] },
27
- { cmd: 'echo', args: ['test'] }
28
- ];
29
-
30
- let allPassed = true;
31
-
32
- for (const test of testCommands) {
33
- console.log(` Testing: ${test.cmd} ${test.args.join(' ')} with shell=true`);
34
-
35
- const result = spawnSync(test.cmd, test.args, {
36
- encoding: 'utf8',
37
- timeout: 10000,
38
- shell: true
39
- });
40
-
41
- const passed = result.status === 0;
42
- console.log(` Status: ${result.status}, Passed: ${passed}`);
43
-
44
- if (!passed) {
45
- allPassed = false;
46
- if (result.error) {
47
- console.log(` Error: ${result.error.message}`);
48
- }
49
- }
50
- }
51
-
52
- this.testResults.push({
53
- name: 'Shell Execution Reliability',
54
- passed: allPassed,
55
- details: `All ${testCommands.length} commands executed successfully with shell=true`
56
- });
57
-
58
- return allPassed;
59
- } catch (error) {
60
- console.log(` ✗ Failed to test shell execution reliability: ${error.message}`);
61
- this.testResults.push({
62
- name: 'Shell Execution Reliability',
63
- passed: false,
64
- details: `Failed to test: ${error.message}`
65
- });
66
- return false;
67
- }
68
- }
69
-
70
- // Test 2: Verify fallback mechanism effectiveness
71
- async testFallbackMechanism() {
72
- console.log('\n[TEST 2] Verifying fallback mechanism effectiveness...');
73
-
74
- try {
75
- // Simulate the exact fallback logic from our implementation
76
- const testCommand = 'npm';
77
- const testArgs = ['--version'];
78
-
79
- console.log(` Testing fallback mechanism for: ${testCommand} ${testArgs.join(' ')}`);
80
-
81
- // Step 1: Try with shell=true (should work)
82
- console.log(' Step 1: Trying with shell=true...');
83
- let result = spawnSync(testCommand, testArgs, {
84
- encoding: 'utf8',
85
- timeout: 10000,
86
- shell: true
87
- });
88
-
89
- const shellWorked = result.status === 0;
90
- console.log(` Shell execution status: ${result.status}`);
91
-
92
- // Step 2: Simulate fallback (try without shell if first failed)
93
- let fallbackWorked = true;
94
- if (result.status !== 0 && result.status !== null) {
95
- console.log(' Step 2: Simulating fallback to without shell...');
96
- result = spawnSync(testCommand, testArgs, {
97
- encoding: 'utf8',
98
- timeout: 10000
99
- });
100
-
101
- fallbackWorked = result.status === 0;
102
- console.log(` Fallback execution status: ${result.status}`);
103
- } else {
104
- console.log(' Step 2: Skipping fallback (first attempt succeeded)');
105
- }
106
-
107
- const fallbackEffective = shellWorked || fallbackWorked;
108
-
109
- this.testResults.push({
110
- name: 'Fallback Mechanism Effectiveness',
111
- passed: fallbackEffective,
112
- details: `Shell worked: ${shellWorked}, Fallback effective: ${fallbackEffective}`
113
- });
114
-
115
- return fallbackEffective;
116
- } catch (error) {
117
- console.log(` ✗ Failed to test fallback mechanism: ${error.message}`);
118
- this.testResults.push({
119
- name: 'Fallback Mechanism Effectiveness',
120
- passed: false,
121
- details: `Failed to test: ${error.message}`
122
- });
123
- return false;
124
- }
125
- }
126
-
127
- // Test 3: Verify timeout and error handling
128
- async testTimeoutAndErrorHandling() {
129
- console.log('\n[TEST 3] Verifying timeout and error handling...');
130
-
131
- try {
132
- // Test with reasonable timeout
133
- console.log(' Testing with 5-second timeout...');
134
- const result = spawnSync('npm', ['--version'], {
135
- encoding: 'utf8',
136
- timeout: 5000, // 5 seconds
137
- shell: true
138
- });
139
-
140
- const completedInTime = result.status === 0;
141
- console.log(` Completed in time: ${completedInTime}, Status: ${result.status}`);
142
-
143
- // Test error handling with invalid command
144
- console.log(' Testing error handling with invalid command...');
145
- const errorResult = spawnSync('this-command-definitely-does-not-exist', [], {
146
- encoding: 'utf8',
147
- timeout: 5000,
148
- shell: true
149
- });
150
-
151
- const errorHandled = errorResult.status !== 0 || errorResult.error;
152
- console.log(` Error handled properly: ${errorHandled}`);
153
- if (errorResult.error) {
154
- console.log(` Error type: ${errorResult.error.code || errorResult.error.message}`);
155
- }
156
-
157
- const bothTestsPassed = completedInTime && errorHandled;
158
-
159
- this.testResults.push({
160
- name: 'Timeout and Error Handling',
161
- passed: bothTestsPassed,
162
- details: `Timeout handling: ${completedInTime}, Error handling: ${errorHandled}`
163
- });
164
-
165
- return bothTestsPassed;
166
- } catch (error) {
167
- console.log(` ✗ Failed to test timeout and error handling: ${error.message}`);
168
- this.testResults.push({
169
- name: 'Timeout and Error Handling',
170
- passed: false,
171
- details: `Failed to test: ${error.message}`
172
- });
173
- return false;
174
- }
175
- }
176
-
177
- // Test 4: Verify cross-platform compatibility
178
- async testCrossPlatformCompatibility() {
179
- console.log('\n[TEST 4] Verifying cross-platform compatibility...');
180
-
181
- try {
182
- const platform = process.platform;
183
- console.log(` Current platform: ${platform}`);
184
-
185
- // Test platform-specific behaviors
186
- let platformCompatible = true;
187
-
188
- if (platform === 'win32') {
189
- console.log(' Testing Windows-specific compatibility...');
190
-
191
- // Test cmd.exe execution
192
- const cmdResult = spawnSync('cmd.exe', ['/c', 'echo test'], {
193
- encoding: 'utf8',
194
- timeout: 5000
195
- });
196
-
197
- const cmdWorks = cmdResult.status === 0;
198
- console.log(` cmd.exe works: ${cmdWorks}`);
199
-
200
- // Test PowerShell execution
201
- const psResult = spawnSync('powershell.exe', ['-Command', 'Write-Output "test"'], {
202
- encoding: 'utf8',
203
- timeout: 10000
204
- });
205
-
206
- const psWorks = psResult.status === 0;
207
- console.log(` PowerShell works: ${psWorks}`);
208
-
209
- platformCompatible = cmdWorks && psWorks;
210
- } else {
211
- console.log(' Testing Unix-like platform compatibility...');
212
-
213
- // Test sh execution
214
- const shResult = spawnSync('sh', ['-c', 'echo test'], {
215
- encoding: 'utf8',
216
- timeout: 5000
217
- });
218
-
219
- const shWorks = shResult.status === 0;
220
- console.log(` sh works: ${shWorks}`);
221
-
222
- platformCompatible = shWorks;
223
- }
224
-
225
- this.testResults.push({
226
- name: 'Cross-Platform Compatibility',
227
- passed: platformCompatible,
228
- details: `Platform: ${platform}, Compatible: ${platformCompatible}`
229
- });
230
-
231
- return platformCompatible;
232
- } catch (error) {
233
- console.log(` ✗ Failed to test cross-platform compatibility: ${error.message}`);
234
- this.testResults.push({
235
- name: 'Cross-Platform Compatibility',
236
- passed: false,
237
- details: `Failed to test: ${error.message}`
238
- });
239
- return false;
240
- }
241
- }
242
-
243
- // Test 5: Verify environment variable handling
244
- async testEnvironmentVariableHandling() {
245
- console.log('\n[TEST 5] Verifying environment variable handling...');
246
-
247
- try {
248
- // Test with inherited environment
249
- console.log(' Testing with inherited environment...');
250
- const result1 = spawnSync('npm', ['--version'], {
251
- encoding: 'utf8',
252
- timeout: 10000,
253
- shell: true,
254
- env: process.env
255
- });
256
-
257
- const inheritedEnvWorks = result1.status === 0;
258
- console.log(` Inherited environment works: ${inheritedEnvWorks}`);
259
-
260
- // Test with minimal environment
261
- console.log(' Testing with minimal environment...');
262
- const minimalEnv = {
263
- PATH: process.env.PATH,
264
- HOME: process.env.HOME,
265
- USERPROFILE: process.env.USERPROFILE, // Windows
266
- HOMEPATH: process.env.HOMEPATH // Windows
267
- };
268
-
269
- const result2 = spawnSync('npm', ['--version'], {
270
- encoding: 'utf8',
271
- timeout: 10000,
272
- shell: true,
273
- env: minimalEnv
274
- });
275
-
276
- const minimalEnvWorks = result2.status === 0;
277
- console.log(` Minimal environment works: ${minimalEnvWorks}`);
278
-
279
- const envHandlingGood = inheritedEnvWorks || minimalEnvWorks;
280
-
281
- this.testResults.push({
282
- name: 'Environment Variable Handling',
283
- passed: envHandlingGood,
284
- details: `Inherited env: ${inheritedEnvWorks}, Minimal env: ${minimalEnvWorks}`
285
- });
286
-
287
- return envHandlingGood;
288
- } catch (error) {
289
- console.log(` ✗ Failed to test environment variable handling: ${error.message}`);
290
- this.testResults.push({
291
- name: 'Environment Variable Handling',
292
- passed: false,
293
- details: `Failed to test: ${error.message}`
294
- });
295
- return false;
296
- }
297
- }
298
-
299
- // Test 6: Simulate real installation scenario
300
- async testRealInstallationScenario() {
301
- console.log('\n[TEST 6] Simulating real installation scenario...');
302
-
303
- try {
304
- // Simulate the exact logic used in the improved implementation
305
- const toolInfo = {
306
- name: 'Test CLI Tool',
307
- install: 'npm install -g @qoder-ai/qodercli'
308
- };
309
-
310
- console.log(` Simulating installation for: ${toolInfo.name}`);
311
- console.log(` Install command: ${toolInfo.install}`);
312
-
313
- const installCmd = toolInfo.install.split(' ');
314
- console.log(` Command parts: ${JSON.stringify(installCmd)}`);
315
-
316
- // Exact implementation from our improved code
317
- console.log(' Executing with improved implementation...');
318
-
319
- // Try with shell=true first (works better on Windows)
320
- let result = spawnSync(installCmd[0], installCmd.slice(1), {
321
- encoding: 'utf8',
322
- timeout: 300000, // 5 minutes
323
- stdio: 'pipe', // Use pipe for testing
324
- env: process.env,
325
- shell: true
326
- });
327
-
328
- // If shell=true fails, try without shell
329
- if (result.status !== 0 && result.status !== null) {
330
- console.log(' Shell execution failed, trying without shell...');
331
- result = spawnSync(installCmd[0], installCmd.slice(1), {
332
- encoding: 'utf8',
333
- timeout: 300000,
334
- stdio: 'pipe',
335
- env: process.env
336
- });
337
- }
338
-
339
- const installationWouldWork = result.status === 0 || result.status === null; // null means timeout or killed
340
-
341
- console.log(` Final result status: ${result.status}`);
342
- if (result.error) {
343
- console.log(` Error (if any): ${result.error.message}`);
344
- }
345
-
346
- this.testResults.push({
347
- name: 'Real Installation Scenario',
348
- passed: installationWouldWork,
349
- details: `Final status: ${result.status}, Would work: ${installationWouldWork}`
350
- });
351
-
352
- return installationWouldWork;
353
- } catch (error) {
354
- console.log(` ✗ Failed to simulate real installation scenario: ${error.message}`);
355
- this.testResults.push({
356
- name: 'Real Installation Scenario',
357
- passed: false,
358
- details: `Failed to simulate: ${error.message}`
359
- });
360
- return false;
361
- }
362
- }
363
-
364
- // Run all tests
365
- async runAllTests() {
366
- console.log('Comprehensive Execution Test');
367
- console.log('='.repeat(40));
368
-
369
- await this.testShellExecutionReliability();
370
- await this.testFallbackMechanism();
371
- await this.testTimeoutAndErrorHandling();
372
- await this.testCrossPlatformCompatibility();
373
- await this.testEnvironmentVariableHandling();
374
- await this.testRealInstallationScenario();
375
-
376
- // Summary
377
- console.log('\n' + '='.repeat(40));
378
- console.log('Comprehensive Execution Test Summary:');
379
- console.log('='.repeat(40));
380
-
381
- let passedTests = 0;
382
- this.testResults.forEach(result => {
383
- console.log(`${result.name}: ${result.passed ? '✓ PASS' : '✗ FAIL'} - ${result.details}`);
384
- if (result.passed) passedTests++;
385
- });
386
-
387
- const totalTests = this.testResults.length;
388
- console.log(`\nOverall Result: ${passedTests}/${totalTests} tests passed`);
389
-
390
- if (passedTests === totalTests) {
391
- console.log('🎉 ALL TESTS PASSED!');
392
- console.log('✅ The improved execution mechanisms WILL guarantee correct command execution!');
393
- console.log('✅ Shell strengthening and fallback measures are working perfectly!');
394
- } else if (passedTests >= totalTests * 0.8) {
395
- console.log('✅ MOST TESTS PASSED!');
396
- console.log('✅ The improvements significantly increase execution reliability!');
397
- } else {
398
- console.log('⚠ SOME TESTS FAILED!');
399
- console.log('⚠ Further improvements may be needed.');
400
- }
401
-
402
- return {
403
- totalTests: totalTests,
404
- passedTests: passedTests,
405
- results: this.testResults
406
- };
407
- }
408
- }
409
-
410
- // Run the tests
411
- async function runComprehensiveExecutionTests() {
412
- const tester = new ComprehensiveExecutionTest();
413
- const results = await tester.runAllTests();
414
- return results;
415
- }
416
-
417
- // Export for use in other modules
418
- module.exports = { ComprehensiveExecutionTest };
419
-
420
- // Run if called directly
421
- if (require.main === module) {
422
- runComprehensiveExecutionTests().then(results => {
423
- process.exit(results.passedTests === results.totalTests ? 0 : 1);
424
- }).catch(error => {
425
- console.error('[Test Failed]:', error.message);
426
- process.exit(1);
427
- });
428
- }
@@ -1,95 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Stigmergy Conflict Prevention System Test
5
- * This script verifies that the conflict prevention system works correctly
6
- */
7
-
8
- const fs = require('fs').promises;
9
- const path = require('path');
10
- const { spawn } = require('child_process');
11
-
12
- async function runTests() {
13
- console.log('Stigmergy Conflict Prevention System Test');
14
- console.log('='.repeat(50));
15
-
16
- let passedTests = 0;
17
- let totalTests = 0;
18
-
19
- // Test 1: Pre-installation check exists
20
- totalTests++;
21
- try {
22
- await fs.access(path.join(__dirname, '..', 'scripts', 'preinstall-check.js'));
23
- console.log('[PASS] Test 1: Pre-installation check script exists');
24
- passedTests++;
25
- } catch (error) {
26
- console.log('[FAIL] Test 1: Pre-installation check script missing');
27
- }
28
-
29
- // Test 2: Conflict fixer exists
30
- totalTests++;
31
- try {
32
- await fs.access(path.join(__dirname, '..', 'fix-node-conflict.js'));
33
- console.log('[PASS] Test 2: Conflict fixer script exists');
34
- passedTests++;
35
- } catch (error) {
36
- console.log('[FAIL] Test 2: Conflict fixer script missing');
37
- }
38
-
39
- // Test 3: Safety check in main script
40
- totalTests++;
41
- try {
42
- const mainScript = await fs.readFile(path.join(__dirname, '..', 'src', 'main_english.js'), 'utf8');
43
- if (mainScript.includes('safetyCheck')) {
44
- console.log('[PASS] Test 3: Safety check implemented in main script');
45
- passedTests++;
46
- } else {
47
- console.log('[FAIL] Test 3: Safety check not found in main script');
48
- }
49
- } catch (error) {
50
- console.log('[FAIL] Test 3: Could not read main script');
51
- }
52
-
53
- // Test 4: Package.json includes safety scripts
54
- totalTests++;
55
- try {
56
- const packageJson = JSON.parse(await fs.readFile(path.join(__dirname, '..', 'package.json'), 'utf8'));
57
- if (packageJson.scripts && packageJson.scripts['fix-node-conflict']) {
58
- console.log('[PASS] Test 4: Safety scripts registered in package.json');
59
- passedTests++;
60
- } else {
61
- console.log('[FAIL] Test 4: Safety scripts missing from package.json');
62
- }
63
- } catch (error) {
64
- console.log('[FAIL] Test 4: Could not read package.json');
65
- }
66
-
67
- // Test 5: Documentation exists
68
- totalTests++;
69
- try {
70
- await fs.access(path.join(__dirname, '..', 'docs', 'CONFLICT_PREVENTION.md'));
71
- console.log('[PASS] Test 5: Conflict prevention documentation exists');
72
- passedTests++;
73
- } catch (error) {
74
- console.log('[FAIL] Test 5: Conflict prevention documentation missing');
75
- }
76
-
77
- console.log('\n' + '='.repeat(50));
78
- console.log(`Test Results: ${passedTests}/${totalTests} tests passed`);
79
-
80
- if (passedTests === totalTests) {
81
- console.log('[SUCCESS] All conflict prevention mechanisms are in place!');
82
- return true;
83
- } else {
84
- console.log('[WARNING] Some conflict prevention mechanisms are missing.');
85
- return false;
86
- }
87
- }
88
-
89
- // Run tests
90
- runTests().then(success => {
91
- process.exit(success ? 0 : 1);
92
- }).catch(error => {
93
- console.error('[ERROR] Test suite failed:', error.message);
94
- process.exit(1);
95
- });
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Test the cross-CLI detection functionality
4
- const fs = require('fs');
5
- const path = require('path');
6
-
7
- // Load the generated hook
8
- const hookPath = path.join(process.env.HOME || process.env.USERPROFILE, '.stigmergy', 'hooks', 'claude', 'claude_nodejs_hook.js');
9
-
10
- if (fs.existsSync(hookPath)) {
11
- const ClaudeHook = require(hookPath);
12
- const hook = new ClaudeHook();
13
-
14
- console.log('Testing cross-CLI detection...');
15
-
16
- // Test cases
17
- const testCases = [
18
- 'use gemini to generate a python function',
19
- 'call qwencode to refactor this code',
20
- 'ask codex for help with javascript',
21
- 'please help me with this task', // Should not match
22
- 'use copilot to write a test' // Should match
23
- ];
24
-
25
- testCases.forEach(testCase => {
26
- const result = hook.detectCrossCLIRequest(testCase);
27
- console.log(`Input: "${testCase}"`);
28
- console.log(`Result:`, result ? JSON.stringify(result, null, 2) : 'No match');
29
- console.log('---');
30
- });
31
- } else {
32
- console.log('Hook file not found at:', hookPath);
33
- }
@@ -1,36 +0,0 @@
1
- const { processCSV } = require('../src/utils');
2
-
3
- // Test basic CSV processing
4
- console.log('Testing basic CSV processing...');
5
-
6
- const csvData = `name,age,city
7
- John,25,New York
8
- Jane,30,Boston
9
- Bob,35,Chicago
10
- Alice,28,Los Angeles`;
11
-
12
- const stats = processCSV(csvData);
13
- console.log('Basic CSV Stats:', JSON.stringify(stats, null, 2));
14
-
15
- // Test CSV without headers
16
- console.log('\nTesting CSV without headers...');
17
-
18
- const csvWithoutHeaders = `John,25,New York
19
- Jane,30,Boston
20
- Bob,35,Chicago`;
21
-
22
- const statsNoHeaders = processCSV(csvWithoutHeaders, { hasHeader: false });
23
- console.log('CSV without headers Stats:', JSON.stringify(statsNoHeaders, null, 2));
24
-
25
- // Test CSV with numeric data
26
- console.log('\nTesting CSV with numeric data...');
27
-
28
- const csvNumeric = `product,price,quantity
29
- Apple,1.20,100
30
- Banana,0.50,200
31
- Orange,0.80,150`;
32
-
33
- const statsNumeric = processCSV(csvNumeric);
34
- console.log('Numeric CSV Stats:', JSON.stringify(statsNumeric, null, 2));
35
-
36
- console.log('\nCSV processing tests completed successfully!');