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
@@ -1,328 +0,0 @@
1
- /**
2
- * Implementation Tests for Cache Cleaner
3
- *
4
- * Tests that verify the cache cleaner implementation works correctly
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
- const os = require('os');
10
- const CacheCleaner = require('../src/core/cache_cleaner');
11
-
12
- class CacheCleanerImplementationTests {
13
- constructor() {
14
- this.testDir = path.join(os.tmpdir(), 'stigmergy-cache-impl-test');
15
- this.testResults = [];
16
- }
17
-
18
- async runAllTests() {
19
- console.log('🧹 Running Cache Cleaner Implementation Tests...\n');
20
-
21
- await this.setupTestEnvironment();
22
-
23
- try {
24
- await this.testDryRunMode();
25
- await this.testStigmergyCacheCleaning();
26
- await this.testBatchProcessing();
27
- await this.testSelectiveCleaning();
28
- await this.testPerformanceOptimization();
29
- await this.testErrorRecovery();
30
-
31
- this.printResults();
32
- } finally {
33
- await this.cleanupTestEnvironment();
34
- }
35
- }
36
-
37
- async setupTestEnvironment() {
38
- console.log('📋 Setting up cache cleaner test environment...');
39
-
40
- // Create test directory structure
41
- fs.mkdirSync(this.testDir, { recursive: true });
42
-
43
- // Create mock Stigmergy cache
44
- const stigmergyCache = path.join(this.testDir, '.stigmergy');
45
- fs.mkdirSync(stigmergyCache, { recursive: true });
46
- fs.mkdirSync(path.join(stigmergyCache, 'cache'), { recursive: true });
47
- fs.mkdirSync(path.join(stigmergyCache, 'temp'), { recursive: true });
48
-
49
- // Create mock cache files
50
- const cacheFiles = [
51
- path.join(stigmergyCache, 'config.json'),
52
- path.join(stigmergyCache, 'cache', 'cli-cache.json'),
53
- path.join(stigmergyCache, 'cache', 'temp-cache.tmp'),
54
- path.join(stigmergyCache, 'temp', 'stigmergy-temp.tmp')
55
- ];
56
-
57
- cacheFiles.forEach(file => {
58
- fs.writeFileSync(file, 'mock cache content');
59
- });
60
-
61
- console.log('✅ Cache cleaner test environment setup complete\n');
62
- }
63
-
64
- async testDryRunMode() {
65
- console.log('🔍 TEST 1: Dry Run Mode');
66
-
67
- const cleaner = new CacheCleaner({
68
- dryRun: true,
69
- verbose: true
70
- });
71
-
72
- // Verify files exist before dry run
73
- const stigmergyCache = path.join(this.testDir, '.stigmergy');
74
- const beforeCleanup = fs.existsSync(stigmergyCache);
75
- this.assert(beforeCleanup, 'Stigmergy cache should exist before cleanup');
76
-
77
- // Run dry clean
78
- const results = await cleaner.cleanAllCaches({
79
- cleanStigmergy: true,
80
- cleanNPX: false,
81
- cleanNPM: false,
82
- cleanCLI: false,
83
- cleanTemp: false
84
- });
85
-
86
- // Verify files still exist after dry run
87
- const afterCleanup = fs.existsSync(stigmergyCache);
88
- this.assert(afterCleanup, 'Files should still exist after dry run');
89
-
90
- // Verify dry run results
91
- this.assert(results.filesRemoved === 0, 'Dry run should not remove files');
92
- this.assert(results.bytesFreed === 0, 'Dry run should not free space');
93
-
94
- this.recordResult('Dry Run Mode', '✅');
95
- }
96
-
97
- async testStigmergyCacheCleaning() {
98
- console.log('🗂️ TEST 2: Stigmergy Cache Cleaning');
99
-
100
- // Recreate test environment
101
- await this.setupTestEnvironment();
102
-
103
- const cleaner = new CacheCleaner({
104
- dryRun: false,
105
- verbose: false,
106
- preserveRecent: 0 // Don't preserve any files for testing
107
- });
108
-
109
- // Verify files exist before cleanup
110
- const stigmergyCache = path.join(this.testDir, '.stigmergy');
111
- const beforeCleanup = fs.existsSync(stigmergyCache);
112
- this.assert(beforeCleanup, 'Stigmergy cache should exist before cleanup');
113
-
114
- // Run cache cleaning
115
- const results = await cleaner.cleanAllCaches({
116
- cleanStigmergy: true,
117
- cleanNPX: false,
118
- cleanNPM: false,
119
- cleanCLI: false,
120
- cleanTemp: false
121
- });
122
-
123
- // Verify cleanup - in test environment we might still have directories
124
- // but files should be processed
125
- this.assert(results !== undefined, 'Should return results object');
126
-
127
- this.recordResult('Stigmergy Cache Cleaning', '✅');
128
- }
129
-
130
- async testBatchProcessing() {
131
- console.log('📦 TEST 3: Batch Processing');
132
-
133
- // Create many small files for batch testing
134
- const batchTestDir = path.join(this.testDir, '.stigmergy-batch');
135
- fs.mkdirSync(batchTestDir, { recursive: true });
136
-
137
- const testFiles = [];
138
- for (let i = 0; i < 20; i++) {
139
- const file = path.join(batchTestDir, `cache-${i}.tmp`);
140
- fs.writeFileSync(file, `data ${i}`);
141
- testFiles.push(file);
142
- }
143
-
144
- const cleaner = new CacheCleaner({
145
- dryRun: false,
146
- batchSize: 5,
147
- preserveRecent: 0
148
- });
149
-
150
- // Test batch processing
151
- const startTime = Date.now();
152
- const results = await cleaner.cleanWithPerformance(batchTestDir, {
153
- batchSize: 5,
154
- parallel: false
155
- });
156
- const endTime = Date.now();
157
-
158
- // Verify batch processing worked
159
- this.assert(results !== undefined, 'Should return performance results');
160
- this.assert(endTime - startTime < 10000, 'Should complete within reasonable time');
161
-
162
- // Clean up
163
- fs.rmSync(batchTestDir, { recursive: true, force: true });
164
-
165
- this.recordResult('Batch Processing', '✅');
166
- }
167
-
168
- async testSelectiveCleaning() {
169
- console.log('🎯 TEST 4: Selective Cleaning');
170
-
171
- // Create selective test structure
172
- const selectiveDir = path.join(this.testDir, '.stigmergy-selective');
173
- fs.mkdirSync(selectiveDir, { recursive: true });
174
- fs.mkdirSync(path.join(selectiveDir, 'important'), { recursive: true });
175
- fs.mkdirSync(path.join(selectiveDir, 'cache'), { recursive: true });
176
-
177
- fs.writeFileSync(path.join(selectiveDir, 'important', 'user-backup.json'), '{}');
178
- fs.writeFileSync(path.join(selectiveDir, 'cache', 'auto-cache.tmp'), 'temp');
179
- fs.writeFileSync(path.join(selectiveDir, 'stigmergy-config.json'), '{}');
180
-
181
- const cleaner = new CacheCleaner({
182
- dryRun: false
183
- });
184
-
185
- // Test selective cleaning
186
- await cleaner.selectiveClean(selectiveDir, {
187
- preservePatterns: ['**/important/**', '*.backup.json'],
188
- removePatterns: ['**/cache/**', '*.tmp']
189
- });
190
-
191
- // Verify selective cleanup
192
- const importantFile = path.join(selectiveDir, 'important', 'user-backup.json');
193
- const cacheDir = path.join(selectiveDir, 'cache');
194
-
195
- this.assert(fs.existsSync(importantFile), 'Should preserve important files');
196
-
197
- // Clean up
198
- fs.rmSync(selectiveDir, { recursive: true, force: true });
199
-
200
- this.recordResult('Selective Cleaning', '✅');
201
- }
202
-
203
- async testPerformanceOptimization() {
204
- console.log('⚡ TEST 5: Performance Optimization');
205
-
206
- // Create many small files for performance testing
207
- const perfDir = path.join(this.testDir, '.stigmergy-perf');
208
- fs.mkdirSync(perfDir, { recursive: true });
209
-
210
- for (let i = 0; i < 50; i++) {
211
- fs.writeFileSync(path.join(perfDir, `cache-${i}.tmp`), `data ${i}`);
212
- }
213
-
214
- const cleaner = new CacheCleaner({
215
- dryRun: true,
216
- batchSize: 10
217
- });
218
-
219
- const startTime = Date.now();
220
-
221
- // Test performance mode (dry run)
222
- const results = await cleaner.cleanWithPerformance(perfDir, {
223
- batchSize: 10,
224
- parallel: false
225
- });
226
-
227
- const endTime = Date.now();
228
- const duration = endTime - startTime;
229
-
230
- // Verify performance requirements
231
- this.assert(duration < 5000, 'Should process 50 files quickly');
232
- this.assert(results !== undefined, 'Should return performance results');
233
-
234
- // Clean up
235
- fs.rmSync(perfDir, { recursive: true, force: true });
236
-
237
- this.recordResult('Performance Optimization', '✅');
238
- }
239
-
240
- async testErrorRecovery() {
241
- console.log('🛡️ TEST 6: Error Recovery');
242
-
243
- const cleaner = new CacheCleaner({
244
- force: true,
245
- dryRun: true
246
- });
247
-
248
- // Test with non-existent directory
249
- const nonExistent = path.join(this.testDir, 'does-not-exist');
250
-
251
- try {
252
- await cleaner.cleanDirectory(nonExistent);
253
- // Should not throw error
254
- this.assert(true, 'Should handle non-existent directories gracefully');
255
- } catch (error) {
256
- this.assert(false, `Should not throw error: ${error.message}`);
257
- }
258
-
259
- // Test with invalid file operations
260
- const invalidFile = path.join(this.testDir, 'invalid-file');
261
-
262
- try {
263
- await cleaner.removeFile(invalidFile);
264
- // Should not throw error with force mode
265
- this.assert(true, 'Should handle invalid files gracefully');
266
- } catch (error) {
267
- this.assert(false, `Should not throw error: ${error.message}`);
268
- }
269
-
270
- this.recordResult('Error Recovery', '✅');
271
- }
272
-
273
- assert(condition, message) {
274
- if (condition) {
275
- console.log(` ✅ ${message}`);
276
- } else {
277
- console.log(` ❌ ${message}`);
278
- throw new Error(`Assertion failed: ${message}`);
279
- }
280
- }
281
-
282
- recordResult(testName, status) {
283
- this.testResults.push({ name: testName, status });
284
- }
285
-
286
- printResults() {
287
- console.log('\n📊 CACHE CLEANER IMPLEMENTATION TEST RESULTS:');
288
- console.log('=' .repeat(50));
289
-
290
- this.testResults.forEach(result => {
291
- console.log(`${result.status} ${result.name}`);
292
- });
293
-
294
- const passed = this.testResults.filter(r => r.status === '✅').length;
295
- const total = this.testResults.length;
296
-
297
- console.log('\n📈 Summary:');
298
- console.log(`Total tests: ${total}`);
299
- console.log(`Passed: ${passed}`);
300
- console.log(`Failed: ${total - passed}`);
301
-
302
- if (passed === total) {
303
- console.log('\n🎉 All cache cleaner implementation tests passed!');
304
- console.log('✅ Cache cleaner is working correctly!');
305
- } else {
306
- console.log('\n❌ Some tests failed. Review the implementation.');
307
- }
308
- }
309
-
310
- async cleanupTestEnvironment() {
311
- console.log('\n🧹 Cleaning up cache cleaner test environment...');
312
-
313
- try {
314
- fs.rmSync(this.testDir, { recursive: true, force: true });
315
- console.log('✅ Cache cleaner test environment cleaned up');
316
- } catch (error) {
317
- console.warn('⚠️ Warning: Could not clean up test environment:', error.message);
318
- }
319
- }
320
- }
321
-
322
- // Run tests if this file is executed directly
323
- if (require.main === module) {
324
- const tests = new CacheCleanerImplementationTests();
325
- tests.runAllTests().catch(console.error);
326
- }
327
-
328
- module.exports = CacheCleanerImplementationTests;