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,271 +0,0 @@
1
- /**
2
- * Implementation Tests for Enhanced Stigmergy Uninstaller
3
- *
4
- * Tests that verify the actual implementation works correctly
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
- const os = require('os');
10
- const EnhancedUninstaller = require('../src/core/enhanced_uninstaller');
11
-
12
- class EnhancedUninstallerImplementationTests {
13
- constructor() {
14
- this.testDir = path.join(os.tmpdir(), 'stigmergy-uninstaller-impl-test');
15
- this.configDir = path.join(this.testDir, '.stigmergy');
16
- this.testConfigDir = path.join(this.testDir, '.stigmergy-test');
17
- this.testResults = [];
18
- }
19
-
20
- async runAllTests() {
21
- console.log('๐Ÿงช Running Enhanced Uninstaller Implementation Tests...\n');
22
-
23
- await this.setupTestEnvironment();
24
-
25
- try {
26
- await this.testDryRunMode();
27
- await this.testCompleteUninstall();
28
- await this.testErrorHandling();
29
- await this.testDirectoryScanning();
30
- await this.testFilePatternMatching();
31
-
32
- this.printResults();
33
- } finally {
34
- await this.cleanupTestEnvironment();
35
- }
36
- }
37
-
38
- async setupTestEnvironment() {
39
- console.log('๐Ÿ“‹ Setting up implementation test environment...');
40
-
41
- // Create test directories
42
- fs.mkdirSync(this.configDir, { recursive: true });
43
- fs.mkdirSync(this.testConfigDir, { recursive: true });
44
-
45
- // Create mock configuration files
46
- fs.writeFileSync(path.join(this.configDir, 'config.json'), JSON.stringify({
47
- version: '1.1.8',
48
- clis: ['claude', 'gemini', 'qwen']
49
- }, null, 2));
50
-
51
- fs.writeFileSync(path.join(this.configDir, 'auth.json'), JSON.stringify({
52
- tokens: { mock: 'token' }
53
- }, null, 2));
54
-
55
- fs.writeFileSync(path.join(this.configDir, 'error.log'), 'Mock error log\n');
56
-
57
- // Create mock hooks directory
58
- const hooksDir = path.join(this.configDir, 'hooks');
59
- fs.mkdirSync(hooksDir, { recursive: true });
60
-
61
- ['claude', 'gemini', 'qwen'].forEach(cli => {
62
- const cliHookDir = path.join(hooksDir, cli);
63
- fs.mkdirSync(cliHookDir, { recursive: true });
64
- fs.writeFileSync(path.join(cliHookDir, `${cli}_nodejs_hook.js`), '// Mock hook');
65
- fs.writeFileSync(path.join(cliHookDir, 'config.json'), '{}');
66
- });
67
-
68
- console.log('โœ… Implementation test environment setup complete\n');
69
- }
70
-
71
- async testDryRunMode() {
72
- console.log('๐Ÿ” TEST 1: Dry Run Mode');
73
-
74
- const uninstaller = new EnhancedUninstaller({
75
- dryRun: true,
76
- verbose: true
77
- });
78
-
79
- // Verify files exist before dry run
80
- const configExists = fs.existsSync(this.configDir);
81
- this.assert(configExists, 'Test configuration should exist before uninstall');
82
-
83
- // Run dry uninstall
84
- const results = await uninstaller.completeUninstall();
85
-
86
- // Verify files still exist after dry run
87
- const configStillExists = fs.existsSync(this.configDir);
88
- this.assert(configStillExists, 'Configuration should still exist after dry run');
89
-
90
- // Verify dry run detected files
91
- this.assert(results.filesRemoved === 0, 'Dry run should not remove files');
92
- this.assert(results.directoriesRemoved === 0, 'Dry run should not remove directories');
93
-
94
- this.recordResult('Dry Run Mode', 'โœ…');
95
- }
96
-
97
- async testCompleteUninstall() {
98
- console.log('๐Ÿ—‘๏ธ TEST 2: Complete Uninstall');
99
-
100
- // Recreate test environment
101
- await this.setupTestEnvironment();
102
-
103
- const uninstaller = new EnhancedUninstaller({
104
- dryRun: false,
105
- verbose: false
106
- });
107
-
108
- // Verify files exist before uninstall
109
- const beforeFiles = [
110
- path.join(this.configDir, 'config.json'),
111
- path.join(this.configDir, 'auth.json'),
112
- path.join(this.configDir, 'error.log'),
113
- path.join(this.configDir, 'hooks', 'claude', 'claude_nodejs_hook.js')
114
- ];
115
-
116
- const beforeUninstall = beforeFiles.every(file => fs.existsSync(file));
117
- this.assert(beforeUninstall, 'Test files should exist before uninstall');
118
-
119
- // Run complete uninstall
120
- const results = await uninstaller.completeUninstall();
121
-
122
- // Verify cleanup after uninstall
123
- const afterUninstall = !beforeFiles.some(file => fs.existsSync(file));
124
- this.assert(afterUninstall, 'All Stigmergy files should be removed after uninstall');
125
-
126
- // Verify results
127
- this.assert(results.filesRemoved > 0, 'Should report files removed');
128
- this.assert(results.directoriesRemoved >= 0, 'Should report directories removed');
129
-
130
- this.recordResult('Complete Uninstall', 'โœ…');
131
- }
132
-
133
- async testErrorHandling() {
134
- console.log('โš ๏ธ TEST 3: Error Handling');
135
-
136
- const uninstaller = new EnhancedUninstaller({
137
- force: true,
138
- dryRun: true
139
- });
140
-
141
- // Test with non-existent directory
142
- const nonExistentPath = path.join(this.testDir, 'does-not-exist');
143
-
144
- // Should handle missing directory gracefully
145
- const plan = await uninstaller.createUninstallPlan();
146
-
147
- // Should not crash on missing directories
148
- this.assert(plan !== undefined, 'Should handle missing directories gracefully');
149
-
150
- // Test uninstall with non-existent paths
151
- const results = await uninstaller.completeUninstall();
152
-
153
- // Should not report errors for non-existent files in dry run
154
- this.assert(Array.isArray(results.errors), 'Should return error array');
155
-
156
- this.recordResult('Error Handling', 'โœ…');
157
- }
158
-
159
- async testDirectoryScanning() {
160
- console.log('๐Ÿ“ TEST 4: Directory Scanning');
161
-
162
- // Create a more complex directory structure
163
- const complexDir = path.join(this.testDir, '.stigmergy-complex');
164
- fs.mkdirSync(complexDir, { recursive: true });
165
-
166
- fs.mkdirSync(path.join(complexDir, 'subdir1'), { recursive: true });
167
- fs.mkdirSync(path.join(complexDir, 'subdir2'), { recursive: true });
168
-
169
- fs.writeFileSync(path.join(complexDir, 'file1.txt'), 'content');
170
- fs.writeFileSync(path.join(complexDir, 'subdir1', 'file2.txt'), 'content');
171
- fs.writeFileSync(path.join(complexDir, 'subdir2', 'file3.txt'), 'content');
172
-
173
- const uninstaller = new EnhancedUninstaller({ dryRun: true });
174
-
175
- // Test plan creation
176
- const plan = await uninstaller.createUninstallPlan();
177
-
178
- // Should scan directories correctly
179
- this.assert(plan.files.length > 0, 'Should find files in directory scan');
180
- this.assert(plan.directories.length > 0, 'Should find directories in scan');
181
-
182
- // Clean up
183
- fs.rmSync(complexDir, { recursive: true, force: true });
184
-
185
- this.recordResult('Directory Scanning', 'โœ…');
186
- }
187
-
188
- async testFilePatternMatching() {
189
- console.log('๐ŸŽฏ TEST 5: File Pattern Matching');
190
-
191
- const uninstaller = new EnhancedUninstaller({ dryRun: true });
192
-
193
- // Test internal pattern matching methods
194
- const testFiles = [
195
- 'stigmergy-config.json',
196
- 'cross-cli-hook.js',
197
- 'integration-settings.json',
198
- 'cache-data.tmp',
199
- 'normal-file.txt'
200
- ];
201
-
202
- // Test if methods exist and work
203
- let stigmergyFilesFound = 0;
204
-
205
- for (const fileName of testFiles) {
206
- if (uninstaller.isStigmergyFile && uninstaller.isStigmergyFile(fileName)) {
207
- stigmergyFilesFound++;
208
- }
209
- }
210
-
211
- this.assert(stigmergyFilesFound >= 4, 'Should identify Stigmergy files correctly');
212
-
213
- this.recordResult('File Pattern Matching', 'โœ…');
214
- }
215
-
216
- assert(condition, message) {
217
- if (condition) {
218
- console.log(` โœ… ${message}`);
219
- } else {
220
- console.log(` โŒ ${message}`);
221
- throw new Error(`Assertion failed: ${message}`);
222
- }
223
- }
224
-
225
- recordResult(testName, status) {
226
- this.testResults.push({ name: testName, status });
227
- }
228
-
229
- printResults() {
230
- console.log('\n๐Ÿ“Š IMPLEMENTATION TEST RESULTS:');
231
- console.log('=' .repeat(50));
232
-
233
- this.testResults.forEach(result => {
234
- console.log(`${result.status} ${result.name}`);
235
- });
236
-
237
- const passed = this.testResults.filter(r => r.status === 'โœ…').length;
238
- const total = this.testResults.length;
239
-
240
- console.log('\n๐Ÿ“ˆ Summary:');
241
- console.log(`Total tests: ${total}`);
242
- console.log(`Passed: ${passed}`);
243
- console.log(`Failed: ${total - passed}`);
244
-
245
- if (passed === total) {
246
- console.log('\n๐ŸŽ‰ All implementation tests passed!');
247
- console.log('โœ… Enhanced uninstaller is working correctly!');
248
- } else {
249
- console.log('\nโŒ Some tests failed. Review the implementation.');
250
- }
251
- }
252
-
253
- async cleanupTestEnvironment() {
254
- console.log('\n๐Ÿงน Cleaning up implementation test environment...');
255
-
256
- try {
257
- fs.rmSync(this.testDir, { recursive: true, force: true });
258
- console.log('โœ… Implementation test environment cleaned up');
259
- } catch (error) {
260
- console.warn('โš ๏ธ Warning: Could not clean up test environment:', error.message);
261
- }
262
- }
263
- }
264
-
265
- // Run tests if this file is executed directly
266
- if (require.main === module) {
267
- const tests = new EnhancedUninstallerImplementationTests();
268
- tests.runAllTests().catch(console.error);
269
- }
270
-
271
- module.exports = EnhancedUninstallerImplementationTests;
@@ -1,284 +0,0 @@
1
- /**
2
- * TDD Tests for Enhanced Stigmergy Uninstaller
3
- *
4
- * Test-first approach to ensure complete cleanup of Stigmergy installation
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
- const os = require('os');
10
- const { spawnSync } = require('child_process');
11
-
12
- class EnhancedUninstallerTests {
13
- constructor() {
14
- this.testDir = path.join(os.tmpdir(), 'stigmergy-uninstaller-test');
15
- this.configDir = path.join(this.testDir, '.stigmergy');
16
- this.testConfigDir = path.join(this.testDir, '.stigmergy-test');
17
- this.npmCacheDir = path.join(this.testDir, 'npm-cache');
18
- this.testResults = [];
19
- }
20
-
21
- async runAllTests() {
22
- console.log('๐Ÿงช Running Enhanced Uninstaller TDD Tests...\n');
23
-
24
- await this.setupTestEnvironment();
25
-
26
- try {
27
- await this.testCompleteUninstall();
28
- await this.testCacheCleaning();
29
- await this.testNPXCacheCleaning();
30
- await this.testCLIConfigCleanup();
31
- await this.testErrorHandling();
32
- await this.testDryRunMode();
33
-
34
- this.printResults();
35
- } finally {
36
- await this.cleanupTestEnvironment();
37
- }
38
- }
39
-
40
- async setupTestEnvironment() {
41
- console.log('๐Ÿ“‹ Setting up test environment...');
42
-
43
- // Create test directories
44
- fs.mkdirSync(this.configDir, { recursive: true });
45
- fs.mkdirSync(this.testConfigDir, { recursive: true });
46
- fs.mkdirSync(this.npmCacheDir, { recursive: true });
47
-
48
- // Create mock configuration files
49
- fs.writeFileSync(path.join(this.configDir, 'config.json'), JSON.stringify({
50
- version: '1.1.8',
51
- clis: ['claude', 'gemini', 'qwen']
52
- }, null, 2));
53
-
54
- fs.writeFileSync(path.join(this.configDir, 'auth.json'), JSON.stringify({
55
- tokens: { mock: 'token' }
56
- }, null, 2));
57
-
58
- fs.writeFileSync(path.join(this.configDir, 'error.log'), 'Mock error log\n');
59
-
60
- // Create mock hooks directory
61
- const hooksDir = path.join(this.configDir, 'hooks');
62
- fs.mkdirSync(hooksDir, { recursive: true });
63
-
64
- ['claude', 'gemini', 'qwen'].forEach(cli => {
65
- const cliHookDir = path.join(hooksDir, cli);
66
- fs.mkdirSync(cliHookDir, { recursive: true });
67
- fs.writeFileSync(path.join(cliHookDir, `${cli}_nodejs_hook.js`), '// Mock hook');
68
- fs.writeFileSync(path.join(cliHookDir, 'config.json'), '{}');
69
- });
70
-
71
- // Create mock CLI config directories
72
- ['claude', 'gemini', 'qwen'].forEach(cli => {
73
- const cliConfig = path.join(this.testDir, `.${cli}`);
74
- fs.mkdirSync(cliConfig, { recursive: true });
75
- fs.writeFileSync(path.join(cliConfig, 'stigmergy-config.json'), '{}');
76
- });
77
-
78
- // Create mock npm cache files
79
- const npxCacheDir = path.join(this.npmCacheDir, '_npx');
80
- fs.mkdirSync(npxCacheDir, { recursive: true });
81
- fs.mkdirSync(path.join(npxCacheDir, 'mock-cache-id'), { recursive: true });
82
-
83
- console.log('โœ… Test environment setup complete\n');
84
- }
85
-
86
- async testCompleteUninstall() {
87
- console.log('๐Ÿ” TEST 1: Complete Uninstall Functionality');
88
-
89
- const expectedFiles = [
90
- path.join(this.configDir, 'config.json'),
91
- path.join(this.configDir, 'auth.json'),
92
- path.join(this.configDir, 'error.log'),
93
- path.join(this.configDir, 'hooks', 'claude', 'claude_nodejs_hook.js')
94
- ];
95
-
96
- // Verify test files exist before uninstall
97
- const beforeUninstall = expectedFiles.every(file => fs.existsSync(file));
98
- this.assert(beforeUninstall, 'Test files should exist before uninstall');
99
-
100
- // TODO: After implementing EnhancedUninstaller, call it here
101
- // const uninstaller = new EnhancedUninstaller();
102
- // await uninstaller.completeUninstall({ dryRun: false, testMode: true });
103
-
104
- // TODO: Verify cleanup after uninstall
105
- // const afterUninstall = !expectedFiles.some(file => fs.existsSync(file));
106
- // this.assert(afterUninstall, 'All Stigmergy files should be removed after uninstall');
107
-
108
- this.recordResult('Complete Uninstall', 'โณ Pending implementation');
109
- }
110
-
111
- async testCacheCleaning() {
112
- console.log('๐Ÿงน TEST 2: Cache Cleaning Functionality');
113
-
114
- // Mock cache files
115
- const cacheFiles = [
116
- path.join(this.configDir, 'cache', 'test-cache.json'),
117
- path.join(this.configDir, 'memory.json')
118
- ];
119
-
120
- cacheFiles.forEach(file => {
121
- const dir = path.dirname(file);
122
- fs.mkdirSync(dir, { recursive: true });
123
- fs.writeFileSync(file, 'mock cache data');
124
- });
125
-
126
- // Verify cache files exist
127
- const beforeCleanup = cacheFiles.every(file => fs.existsSync(file));
128
- this.assert(beforeCleanup, 'Cache files should exist before cleanup');
129
-
130
- // TODO: After implementing cache cleaner
131
- // const cleaner = new CacheCleaner();
132
- // await cleaner.cleanAllCaches({ includeStigmergy: true, includeNPM: false });
133
-
134
- // TODO: Verify cache files are removed
135
- // const afterCleanup = !cacheFiles.some(file => fs.existsSync(file));
136
- // this.assert(afterCleanup, 'Cache files should be removed after cleanup');
137
-
138
- this.recordResult('Cache Cleaning', 'โณ Pending implementation');
139
- }
140
-
141
- async testNPXCacheCleaning() {
142
- console.log('๐Ÿ“ฆ TEST 3: NPX Cache Cleaning');
143
-
144
- // Create mock npx cache
145
- const npxCachePath = path.join(this.npmCacheDir, '_npx', 'test-cache-id', 'node_modules', 'stigmergy');
146
- fs.mkdirSync(npxCachePath, { recursive: true });
147
- fs.writeFileSync(path.join(npxCachePath, 'package.json'), '{}');
148
-
149
- // Verify npx cache exists
150
- const beforeCleanup = fs.existsSync(npxCachePath);
151
- this.assert(beforeCleanup, 'NPX cache should exist before cleanup');
152
-
153
- // TODO: After implementing NPX cache cleaner
154
- // const cleaner = new NPXCacheCleaner();
155
- // const removed = await cleaner.cleanStigmergyFromNPXCache();
156
- // this.assert(removed > 0, 'Should remove Stigmergy from NPX cache');
157
-
158
- this.recordResult('NPX Cache Cleaning', 'โณ Pending implementation');
159
- }
160
-
161
- async testCLIConfigCleanup() {
162
- console.log('โš™๏ธ TEST 4: CLI Configuration Cleanup');
163
-
164
- const cliConfigs = ['claude', 'gemini', 'qwen'].map(cli => ({
165
- cli,
166
- configPath: path.join(this.testDir, `.${cli}`, 'stigmergy-config.json'),
167
- hooksPath: path.join(this.testDir, `.${cli}`, 'hooks', 'stigmergy')
168
- }));
169
-
170
- // Create mock CLI hooks
171
- cliConfigs.forEach(config => {
172
- fs.mkdirSync(path.dirname(config.hooksPath), { recursive: true });
173
- fs.writeFileSync(config.hooksPath, '// mock hook');
174
- });
175
-
176
- // Verify CLI configs exist
177
- const beforeCleanup = cliConfigs.every(config =>
178
- fs.existsSync(config.configPath) || fs.existsSync(config.hooksPath)
179
- );
180
- this.assert(beforeCleanup, 'CLI configurations should exist before cleanup');
181
-
182
- // TODO: After implementing CLI config cleaner
183
- // const cleaner = new CLIConfigCleaner();
184
- // const results = await cleaner.cleanCLIConfigurations(['claude', 'gemini', 'qwen']);
185
- // this.assert(results.cleaned > 0, 'Should clean CLI configurations');
186
-
187
- this.recordResult('CLI Config Cleanup', 'โณ Pending implementation');
188
- }
189
-
190
- async testErrorHandling() {
191
- console.log('โš ๏ธ TEST 5: Error Handling');
192
-
193
- // Test with non-existent directory
194
- const nonExistentPath = path.join(this.testDir, 'does-not-exist');
195
-
196
- // TODO: Test error handling for various scenarios
197
- // const uninstaller = new EnhancedUninstaller();
198
-
199
- // Should handle missing directory gracefully
200
- // const result1 = await uninstaller.removeDirectory(nonExistentPath);
201
- // this.assert(!result1.error, 'Should handle missing directory gracefully');
202
-
203
- // Should handle permission denied gracefully
204
- // const result2 = await uninstaller.removeDirectory('/root/protected');
205
- // this.assert(result2.error, 'Should detect permission errors');
206
-
207
- this.recordResult('Error Handling', 'โณ Pending implementation');
208
- }
209
-
210
- async testDryRunMode() {
211
- console.log('๐Ÿ” TEST 6: Dry Run Mode');
212
-
213
- // Create files that should be preserved in dry run
214
- const testFile = path.join(this.configDir, 'should-preserve.txt');
215
- fs.writeFileSync(testFile, 'preserve me');
216
-
217
- // TODO: Test dry run functionality
218
- // const uninstaller = new EnhancedUninstaller();
219
- // const plan = await uninstaller.createUninstallPlan({ dryRun: true });
220
-
221
- // Should return what would be deleted
222
- // this.assert(plan.files.length > 0, 'Should identify files to delete');
223
-
224
- // Should not actually delete files in dry run
225
- // const stillExists = fs.existsSync(testFile);
226
- // this.assert(stillExists, 'Files should not be deleted in dry run mode');
227
-
228
- this.recordResult('Dry Run Mode', 'โณ Pending implementation');
229
- }
230
-
231
- async cleanupTestEnvironment() {
232
- console.log('\n๐Ÿงน Cleaning up test environment...');
233
-
234
- try {
235
- fs.rmSync(this.testDir, { recursive: true, force: true });
236
- console.log('โœ… Test environment cleaned up');
237
- } catch (error) {
238
- console.warn('โš ๏ธ Warning: Could not clean up test environment:', error.message);
239
- }
240
- }
241
-
242
- assert(condition, message) {
243
- if (condition) {
244
- console.log(` โœ… ${message}`);
245
- } else {
246
- console.log(` โŒ ${message}`);
247
- throw new Error(`Assertion failed: ${message}`);
248
- }
249
- }
250
-
251
- recordResult(testName, status) {
252
- this.testResults.push({ name: testName, status });
253
- }
254
-
255
- printResults() {
256
- console.log('\n๐Ÿ“Š TEST RESULTS:');
257
- console.log('=' .repeat(50));
258
-
259
- this.testResults.forEach(result => {
260
- console.log(`${result.status} ${result.name}`);
261
- });
262
-
263
- const pending = this.testResults.filter(r => r.status.includes('Pending')).length;
264
- const total = this.testResults.length;
265
-
266
- console.log('\n๐Ÿ“ˆ Summary:');
267
- console.log(`Total tests: ${total}`);
268
- console.log(`Pending implementation: ${pending}`);
269
- console.log(`Ready for implementation: ${pending}/${total}`);
270
-
271
- if (pending === total) {
272
- console.log('\n๐Ÿš€ All test cases defined successfully!');
273
- console.log('๐Ÿ’ก Ready to implement the enhanced uninstaller functionality.');
274
- }
275
- }
276
- }
277
-
278
- // Run tests if this file is executed directly
279
- if (require.main === module) {
280
- const tests = new EnhancedUninstallerTests();
281
- tests.runAllTests().catch(console.error);
282
- }
283
-
284
- module.exports = EnhancedUninstallerTests;