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,173 +1,173 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Enhanced Stigmergy Pre-installation Check
5
- * This script prevents installation conflicts and cleans historical caches
6
- */
7
-
8
- const fs = require('fs');
9
- const path = require('path');
10
- const { spawnSync } = require('child_process');
11
-
12
- console.log('[PRE-INSTALL] Running enhanced installation preparation...');
13
-
14
- // Check 1: Verify no conflicting "node" package is already installed
15
- function checkConflictingNodePackage() {
16
- console.log('[CHECK] Looking for conflicting node packages...');
17
-
18
- try {
19
- const result = spawnSync('npm', ['list', '-g', 'node'], {
20
- encoding: 'utf8',
21
- timeout: 5000
22
- });
23
-
24
- if (result.stdout && result.stdout.includes('node@')) {
25
- console.error('[ERROR] Conflicting "node" package detected!');
26
- console.error('[ERROR] This will interfere with CLI tools. Please run:');
27
- console.error('[ERROR] npm uninstall -g node');
28
- console.error('[ERROR] Then try installing stigmergy again.');
29
- process.exit(1);
30
- }
31
- } catch (error) {
32
- // If npm command fails, continue anyway
33
- console.log('[INFO] Could not verify node package status, continuing...');
34
- }
35
-
36
- console.log('[OK] No conflicting node package found.');
37
- }
38
-
39
- // Check 2: Verify system Node.js installation
40
- function checkSystemNode() {
41
- console.log('[CHECK] Verifying system Node.js installation...');
42
-
43
- const nodeVersion = process.version;
44
- const majorVersion = parseInt(nodeVersion.match(/^v(\d+)/)[1]);
45
-
46
- if (majorVersion < 16) {
47
- console.error('[ERROR] Node.js version 16 or higher is required.');
48
- console.error(`[ERROR] Current version: ${nodeVersion}`);
49
- process.exit(1);
50
- }
51
-
52
- console.log(`[OK] Node.js ${nodeVersion} detected.`);
53
- }
54
-
55
- // Check 3: Verify npm installation
56
- function checkNpm() {
57
- console.log('[CHECK] Verifying npm installation...');
58
-
59
- // On Windows, npm might not be directly executable
60
- if (process.platform === 'win32') {
61
- console.log('[INFO] Skipping npm verification on Windows (may not be directly executable)');
62
- return;
63
- }
64
-
65
- try {
66
- const result = spawnSync('npm', ['--version'], {
67
- encoding: 'utf8',
68
- timeout: 5000
69
- });
70
-
71
- if (result.status !== 0) {
72
- console.error('[ERROR] npm is not properly installed or accessible.');
73
- process.exit(1);
74
- }
75
-
76
- console.log(`[OK] npm ${result.stdout.trim()} detected.`);
77
- } catch (error) {
78
- console.error('[ERROR] Failed to verify npm installation.');
79
- process.exit(1);
80
- }
81
- }
82
-
83
- // Check 4: Check for existing stigmergy installation conflicts
84
- function checkExistingInstallation() {
85
- console.log('[CHECK] Looking for existing Stigmergy installations...');
86
-
87
- const npmBinDir = path.join(process.env.APPDATA || process.env.HOME, 'npm');
88
- const stigmergyBin = path.join(npmBinDir, 'stigmergy');
89
-
90
- if (fs.existsSync(stigmergyBin)) {
91
- console.log('[WARNING] Existing Stigmergy installation detected.');
92
- console.log('[WARNING] This may cause conflicts. Consider uninstalling first:');
93
- console.log('[WARNING] npm uninstall -g stigmergy');
94
- }
95
-
96
- console.log('[OK] No conflicting Stigmergy installation found.');
97
- }
98
-
99
- // Check 5: Clean historical caches (NEW FUNCTION)
100
- function cleanHistoricalCaches() {
101
- console.log('[CLEAN] Cleaning historical caches to prevent conflicts...');
102
-
103
- try {
104
- // Import and use our enhanced cache cleaner
105
- const CacheCleaner = require('../src/core/cache_cleaner');
106
- const cleaner = new CacheCleaner({
107
- dryRun: false,
108
- force: true,
109
- verbose: false,
110
- preserveRecent: 60 * 60 * 1000 // Preserve files from last hour
111
- });
112
-
113
- // Clean only safe items before installation
114
- cleaner.cleanAllCaches({
115
- cleanStigmergy: false, // Don't clean main config during install
116
- cleanNPX: true, // Clean NPX cache (safe)
117
- cleanNPM: false, // Don't clean NPM cache during install
118
- cleanCLI: false, // Don't clean CLI configs during install
119
- cleanTemp: true // Clean temporary files (safe)
120
- }).then(results => {
121
- if (results.filesRemoved > 0) {
122
- console.log(`[CLEAN] Removed ${results.filesRemoved} cache files`);
123
- console.log(`[CLEAN] Freed ${formatBytes(results.bytesFreed)} space`);
124
- } else {
125
- console.log('[CLEAN] No cache files needed cleaning');
126
- }
127
- }).catch(error => {
128
- console.log(`[WARN] Cache cleaning failed: ${error.message}`);
129
- console.log('[INFO] Continuing with installation...');
130
- });
131
-
132
- } catch (error) {
133
- console.log(`[WARN] Could not initialize cache cleaner: ${error.message}`);
134
- console.log('[INFO] Continuing with installation...');
135
- }
136
- }
137
-
138
- // Helper function to format bytes
139
- function formatBytes(bytes) {
140
- const sizes = ['Bytes', 'KB', 'MB', 'GB'];
141
- if (bytes === 0) return '0 Bytes';
142
- const i = Math.floor(Math.log(bytes) / Math.log(1024));
143
- return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i];
144
- }
145
-
146
- // Run all checks and preparation
147
- async function runInstallationPreparation() {
148
- try {
149
- // System requirements first
150
- checkSystemNode();
151
- checkNpm();
152
- checkConflictingNodePackage();
153
- checkExistingInstallation();
154
-
155
- // Clean caches (async, but don't wait for completion to avoid blocking npm install)
156
- cleanHistoricalCaches();
157
-
158
- console.log('[SUCCESS] Enhanced installation preparation completed.');
159
- console.log('[INFO] Proceeding with package installation...');
160
-
161
- // Give cache cleaning a moment to start
162
- setTimeout(() => {
163
- process.exit(0);
164
- }, 1000);
165
-
166
- } catch (error) {
167
- console.error('[FATAL] Installation preparation failed:', error.message);
168
- process.exit(1);
169
- }
170
- }
171
-
172
- // Run the enhanced preparation
173
- runInstallationPreparation();
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Enhanced Stigmergy Pre-installation Check
5
+ * This script prevents installation conflicts and cleans historical caches
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const { spawnSync } = require('child_process');
11
+
12
+ console.log('[PRE-INSTALL] Running enhanced installation preparation...');
13
+
14
+ // Check 1: Verify no conflicting "node" package is already installed
15
+ function checkConflictingNodePackage() {
16
+ console.log('[CHECK] Looking for conflicting node packages...');
17
+
18
+ try {
19
+ const result = spawnSync('npm', ['list', '-g', 'node'], {
20
+ encoding: 'utf8',
21
+ timeout: 5000
22
+ });
23
+
24
+ if (result.stdout && result.stdout.includes('node@')) {
25
+ console.error('[ERROR] Conflicting "node" package detected!');
26
+ console.error('[ERROR] This will interfere with CLI tools. Please run:');
27
+ console.error('[ERROR] npm uninstall -g node');
28
+ console.error('[ERROR] Then try installing stigmergy again.');
29
+ process.exit(1);
30
+ }
31
+ } catch (error) {
32
+ // If npm command fails, continue anyway
33
+ console.log('[INFO] Could not verify node package status, continuing...');
34
+ }
35
+
36
+ console.log('[OK] No conflicting node package found.');
37
+ }
38
+
39
+ // Check 2: Verify system Node.js installation
40
+ function checkSystemNode() {
41
+ console.log('[CHECK] Verifying system Node.js installation...');
42
+
43
+ const nodeVersion = process.version;
44
+ const majorVersion = parseInt(nodeVersion.match(/^v(\d+)/)[1]);
45
+
46
+ if (majorVersion < 16) {
47
+ console.error('[ERROR] Node.js version 16 or higher is required.');
48
+ console.error(`[ERROR] Current version: ${nodeVersion}`);
49
+ process.exit(1);
50
+ }
51
+
52
+ console.log(`[OK] Node.js ${nodeVersion} detected.`);
53
+ }
54
+
55
+ // Check 3: Verify npm installation
56
+ function checkNpm() {
57
+ console.log('[CHECK] Verifying npm installation...');
58
+
59
+ // On Windows, npm might not be directly executable
60
+ if (process.platform === 'win32') {
61
+ console.log('[INFO] Skipping npm verification on Windows (may not be directly executable)');
62
+ return;
63
+ }
64
+
65
+ try {
66
+ const result = spawnSync('npm', ['--version'], {
67
+ encoding: 'utf8',
68
+ timeout: 5000
69
+ });
70
+
71
+ if (result.status !== 0) {
72
+ console.error('[ERROR] npm is not properly installed or accessible.');
73
+ process.exit(1);
74
+ }
75
+
76
+ console.log(`[OK] npm ${result.stdout.trim()} detected.`);
77
+ } catch (error) {
78
+ console.error('[ERROR] Failed to verify npm installation.');
79
+ process.exit(1);
80
+ }
81
+ }
82
+
83
+ // Check 4: Check for existing stigmergy installation conflicts
84
+ function checkExistingInstallation() {
85
+ console.log('[CHECK] Looking for existing Stigmergy installations...');
86
+
87
+ const npmBinDir = path.join(process.env.APPDATA || process.env.HOME, 'npm');
88
+ const stigmergyBin = path.join(npmBinDir, 'stigmergy');
89
+
90
+ if (fs.existsSync(stigmergyBin)) {
91
+ console.log('[WARNING] Existing Stigmergy installation detected.');
92
+ console.log('[WARNING] This may cause conflicts. Consider uninstalling first:');
93
+ console.log('[WARNING] npm uninstall -g stigmergy');
94
+ }
95
+
96
+ console.log('[OK] No conflicting Stigmergy installation found.');
97
+ }
98
+
99
+ // Check 5: Clean historical caches (NEW FUNCTION)
100
+ function cleanHistoricalCaches() {
101
+ console.log('[CLEAN] Cleaning historical caches to prevent conflicts...');
102
+
103
+ try {
104
+ // Import and use our enhanced cache cleaner
105
+ const CacheCleaner = require('../src/core/cache_cleaner');
106
+ const cleaner = new CacheCleaner({
107
+ dryRun: false,
108
+ force: true,
109
+ verbose: false,
110
+ preserveRecent: 60 * 60 * 1000 // Preserve files from last hour
111
+ });
112
+
113
+ // Clean only safe items before installation
114
+ cleaner.cleanAllCaches({
115
+ cleanStigmergy: false, // Don't clean main config during install
116
+ cleanNPX: true, // Clean NPX cache (safe)
117
+ cleanNPM: false, // Don't clean NPM cache during install
118
+ cleanCLI: false, // Don't clean CLI configs during install
119
+ cleanTemp: true // Clean temporary files (safe)
120
+ }).then(results => {
121
+ if (results.filesRemoved > 0) {
122
+ console.log(`[CLEAN] Removed ${results.filesRemoved} cache files`);
123
+ console.log(`[CLEAN] Freed ${formatBytes(results.bytesFreed)} space`);
124
+ } else {
125
+ console.log('[CLEAN] No cache files needed cleaning');
126
+ }
127
+ }).catch(error => {
128
+ console.log(`[WARN] Cache cleaning failed: ${error.message}`);
129
+ console.log('[INFO] Continuing with installation...');
130
+ });
131
+
132
+ } catch (error) {
133
+ console.log(`[WARN] Could not initialize cache cleaner: ${error.message}`);
134
+ console.log('[INFO] Continuing with installation...');
135
+ }
136
+ }
137
+
138
+ // Helper function to format bytes
139
+ function formatBytes(bytes) {
140
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
141
+ if (bytes === 0) return '0 Bytes';
142
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
143
+ return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i];
144
+ }
145
+
146
+ // Run all checks and preparation
147
+ async function runInstallationPreparation() {
148
+ try {
149
+ // System requirements first
150
+ checkSystemNode();
151
+ checkNpm();
152
+ checkConflictingNodePackage();
153
+ checkExistingInstallation();
154
+
155
+ // Clean caches (async, but don't wait for completion to avoid blocking npm install)
156
+ cleanHistoricalCaches();
157
+
158
+ console.log('[SUCCESS] Enhanced installation preparation completed.');
159
+ console.log('[INFO] Proceeding with package installation...');
160
+
161
+ // Give cache cleaning a moment to start
162
+ setTimeout(() => {
163
+ process.exit(0);
164
+ }, 1000);
165
+
166
+ } catch (error) {
167
+ console.error('[FATAL] Installation preparation failed:', error.message);
168
+ process.exit(1);
169
+ }
170
+ }
171
+
172
+ // Run the enhanced preparation
173
+ runInstallationPreparation();
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Pre-uninstall script for Stigmergy CLI
5
+ * Runs the enhanced uninstaller before npm removes the package
6
+ */
7
+
8
+ const path = require('path');
9
+ const { spawnSync } = require('child_process');
10
+
11
+ console.log('šŸ”„ Running pre-uninstall cleanup for Stigmergy CLI...');
12
+
13
+ try {
14
+ // Import and run the enhanced uninstaller
15
+ const EnhancedUninstaller = require('../src/core/enhanced_uninstaller');
16
+ const uninstaller = new EnhancedUninstaller({
17
+ dryRun: false, // Actually perform the uninstallation
18
+ verbose: true // Show detailed output
19
+ });
20
+
21
+ console.log('šŸ—‘ļø Starting enhanced uninstallation process...\n');
22
+
23
+ // Execute the uninstallation asynchronously
24
+ (async () => {
25
+ try {
26
+ const results = await uninstaller.completeUninstall();
27
+
28
+ console.log('\nāœ… Enhanced uninstallation completed successfully!');
29
+ console.log(`šŸ“ Directories removed: ${results.directoriesRemoved}`);
30
+ console.log(`šŸ“„ Files removed: ${results.filesRemoved}`);
31
+
32
+ if (results.errors.length > 0) {
33
+ console.log(`āš ļø Errors occurred during uninstallation: ${results.errors.length}`);
34
+ results.errors.forEach(error => {
35
+ console.log(` - ${error}`);
36
+ });
37
+ }
38
+
39
+ process.exit(0);
40
+ } catch (error) {
41
+ console.error(`āŒ Error during enhanced uninstallation: ${error.message}`);
42
+ process.exit(1);
43
+ }
44
+ })();
45
+
46
+ } catch (error) {
47
+ console.error(`āŒ Error importing EnhancedUninstaller: ${error.message}`);
48
+ console.error('Attempting manual cleanup...');
49
+
50
+ // Fallback manual cleanup
51
+ try {
52
+ const fs = require('fs');
53
+ const os = require('os');
54
+ const homeDir = os.homedir();
55
+
56
+ // Remove main stigmergy directories
57
+ const dirsToRemove = [
58
+ path.join(homeDir, '.stigmergy'),
59
+ path.join(homeDir, '.stigmergy-test')
60
+ ];
61
+
62
+ dirsToRemove.forEach(dirPath => {
63
+ if (fs.existsSync(dirPath)) {
64
+ fs.rmSync(dirPath, { recursive: true, force: true });
65
+ console.log(`šŸ—‘ļø Removed directory: ${dirPath}`);
66
+ }
67
+ });
68
+
69
+ console.log('āœ… Fallback manual cleanup completed.');
70
+ } catch (fallbackError) {
71
+ console.error(`āŒ Fallback cleanup also failed: ${fallbackError.message}`);
72
+ }
73
+
74
+ process.exit(1);
75
+ }