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,250 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * TDD Test for deployHooks Functionality
5
- * This test verifies that the deployHooks function properly installs and configures CLI tools
6
- */
7
-
8
- const fs = require('fs').promises;
9
- const path = require('path');
10
- const os = require('os');
11
- const { spawn } = require('child_process');
12
-
13
- class DeployHooksTester {
14
- constructor() {
15
- this.testResults = [];
16
- this.stigmergyAssetsDir = path.join(os.homedir(), '.stigmergy', 'assets', 'adapters');
17
- }
18
-
19
- // Test 1: Verify deployHooks copies adapter files correctly
20
- async testAdapterFileCopy() {
21
- console.log('[TEST 1] Verifying adapter file copying...');
22
-
23
- try {
24
- // Check if adapter directories exist in assets
25
- const adapterDirs = await fs.readdir(this.stigmergyAssetsDir);
26
- console.log(` Found adapter directories: ${adapterDirs.join(', ')}`);
27
-
28
- // Check if key adapter files exist
29
- const expectedFiles = {
30
- 'iflow': ['hook_adapter.py', 'install_iflow_integration.py'],
31
- 'claude': ['hook_adapter.py', 'install_claude_integration.py'],
32
- 'qoder': ['notification_hook_adapter.py', 'install_qoder_integration.py']
33
- };
34
-
35
- let allFilesExist = true;
36
- for (const [tool, files] of Object.entries(expectedFiles)) {
37
- const toolDir = path.join(this.stigmergyAssetsDir, tool);
38
- try {
39
- const dirFiles = await fs.readdir(toolDir);
40
- console.log(` ${tool} adapter files: ${dirFiles.join(', ')}`);
41
-
42
- for (const expectedFile of files) {
43
- if (!dirFiles.includes(expectedFile)) {
44
- console.log(` ✗ Missing file: ${expectedFile} in ${tool}`);
45
- allFilesExist = false;
46
- }
47
- }
48
- } catch (error) {
49
- console.log(` ✗ Cannot access ${tool} adapter directory: ${error.message}`);
50
- allFilesExist = false;
51
- }
52
- }
53
-
54
- this.testResults.push({
55
- name: 'Adapter File Copy',
56
- passed: allFilesExist,
57
- details: 'Verified adapter files exist in assets directory'
58
- });
59
-
60
- return allFilesExist;
61
- } catch (error) {
62
- console.log(` ✗ Failed to check adapter files: ${error.message}`);
63
- this.testResults.push({
64
- name: 'Adapter File Copy',
65
- passed: false,
66
- details: `Failed to check adapter files: ${error.message}`
67
- });
68
- return false;
69
- }
70
- }
71
-
72
- // Test 2: Verify installation script execution
73
- async testInstallationScriptExecution() {
74
- console.log('\n[TEST 2] Verifying installation script execution...');
75
-
76
- try {
77
- // Check if post-deployment config script exists
78
- const postDeployScript = path.join(__dirname, '..', 'scripts', 'post-deployment-config.js');
79
- await fs.access(postDeployScript);
80
- console.log(' ✓ Post-deployment config script exists');
81
-
82
- // Try to import and test the PostDeploymentConfigurer
83
- const { PostDeploymentConfigurer } = require('../scripts/post-deployment-config.js');
84
- const configurer = new PostDeploymentConfigurer();
85
-
86
- // Test checking install script for a tool
87
- const scriptCheck = await configurer.checkInstallScript('iflow');
88
- console.log(` iFlow install script check: ${scriptCheck.exists ? '✓ Found' : '✗ Not found'}`);
89
- console.log(` Script path: ${scriptCheck.path}`);
90
-
91
- this.testResults.push({
92
- name: 'Installation Script Execution',
93
- passed: scriptCheck.exists,
94
- details: `iFlow install script ${scriptCheck.exists ? 'found' : 'not found'}`
95
- });
96
-
97
- return scriptCheck.exists;
98
- } catch (error) {
99
- console.log(` ✗ Failed to test installation script execution: ${error.message}`);
100
- this.testResults.push({
101
- name: 'Installation Script Execution',
102
- passed: false,
103
- details: `Failed to test: ${error.message}`
104
- });
105
- return false;
106
- }
107
- }
108
-
109
- // Test 3: Verify hook configuration files are created
110
- async testHookConfigurationCreation() {
111
- console.log('\n[TEST 3] Verifying hook configuration creation...');
112
-
113
- try {
114
- // Check common hook configuration locations
115
- const configPaths = [
116
- path.join(os.homedir(), '.config', 'iflow', 'hooks.yml'),
117
- path.join(os.homedir(), '.config', 'claude', 'hooks.json'),
118
- path.join(os.homedir(), '.qoder', 'config.json')
119
- ];
120
-
121
- let configsFound = 0;
122
- for (const configPath of configPaths) {
123
- try {
124
- await fs.access(configPath);
125
- console.log(` ✓ Configuration found: ${configPath}`);
126
- configsFound++;
127
- } catch (error) {
128
- console.log(` ✗ Configuration not found: ${configPath}`);
129
- }
130
- }
131
-
132
- const passed = configsFound > 0;
133
- this.testResults.push({
134
- name: 'Hook Configuration Creation',
135
- passed: passed,
136
- details: `Found ${configsFound}/${configPaths.length} configuration files`
137
- });
138
-
139
- return passed;
140
- } catch (error) {
141
- console.log(` ✗ Failed to check hook configurations: ${error.message}`);
142
- this.testResults.push({
143
- name: 'Hook Configuration Creation',
144
- passed: false,
145
- details: `Failed to check: ${error.message}`
146
- });
147
- return false;
148
- }
149
- }
150
-
151
- // Test 4: Verify deployHooks function integration
152
- async testDeployHooksIntegration() {
153
- console.log('\n[TEST 4] Verifying deployHooks function integration...');
154
-
155
- try {
156
- // Try to import and test the deployHooks function
157
- const { StigmergyInstaller } = require('../src/main_english.js');
158
- const installer = new StigmergyInstaller();
159
-
160
- // Check if deployHooks method exists
161
- if (typeof installer.deployHooks === 'function') {
162
- console.log(' ✓ deployHooks method exists');
163
-
164
- this.testResults.push({
165
- name: 'DeployHooks Integration',
166
- passed: true,
167
- details: 'deployHooks method exists in StigmergyInstaller'
168
- });
169
-
170
- return true;
171
- } else {
172
- console.log(' ✗ deployHooks method not found');
173
-
174
- this.testResults.push({
175
- name: 'DeployHooks Integration',
176
- passed: false,
177
- details: 'deployHooks method not found in StigmergyInstaller'
178
- });
179
-
180
- return false;
181
- }
182
- } catch (error) {
183
- console.log(` ✗ Failed to test deployHooks integration: ${error.message}`);
184
- this.testResults.push({
185
- name: 'DeployHooks Integration',
186
- passed: false,
187
- details: `Failed to test: ${error.message}`
188
- });
189
- return false;
190
- }
191
- }
192
-
193
- // Run all tests
194
- async runAllTests() {
195
- console.log('TDD Test for deployHooks Functionality');
196
- console.log('='.repeat(50));
197
-
198
- await this.testAdapterFileCopy();
199
- await this.testInstallationScriptExecution();
200
- await this.testHookConfigurationCreation();
201
- await this.testDeployHooksIntegration();
202
-
203
- // Summary
204
- console.log('\n' + '='.repeat(50));
205
- console.log('Test Summary:');
206
- console.log('='.repeat(50));
207
-
208
- let passedTests = 0;
209
- this.testResults.forEach(result => {
210
- console.log(`${result.name}: ${result.passed ? '✓ PASS' : '✗ FAIL'} - ${result.details}`);
211
- if (result.passed) passedTests++;
212
- });
213
-
214
- console.log(`\nOverall Result: ${passedTests}/${this.testResults.length} tests passed`);
215
-
216
- if (passedTests === this.testResults.length) {
217
- console.log('✓ All tests passed! deployHooks functionality is working correctly.');
218
- } else if (passedTests > 0) {
219
- console.log('⚠ Some tests failed. deployHooks functionality needs improvement.');
220
- } else {
221
- console.log('✗ All tests failed. deployHooks functionality is not working.');
222
- }
223
-
224
- return {
225
- totalTests: this.testResults.length,
226
- passedTests: passedTests,
227
- results: this.testResults
228
- };
229
- }
230
- }
231
-
232
- // Run the tests
233
- async function runDeployHooksTests() {
234
- const tester = new DeployHooksTester();
235
- const results = await tester.runAllTests();
236
- return results;
237
- }
238
-
239
- // Export for use in other modules
240
- module.exports = { DeployHooksTester };
241
-
242
- // Run if called directly
243
- if (require.main === module) {
244
- runDeployHooksTests().then(results => {
245
- process.exit(results.passedTests === results.totalTests ? 0 : 1);
246
- }).catch(error => {
247
- console.error('[Test Failed]:', error.message);
248
- process.exit(1);
249
- });
250
- }
@@ -1,128 +0,0 @@
1
- // Claude CLI Integration Tests
2
- const { executeCommand, recordTestResult } = require('./test-utils');
3
-
4
- async function testClaudeCLIIntegration() {
5
- console.log('Starting Claude CLI integration testing...\n');
6
-
7
- // Test 1: Simple code generation
8
- console.log('--- Test 1: Simple code generation ---');
9
- try {
10
- const result = await executeCommand('node src/main_english.js call "claude write a simple Python function to add two numbers"', 45000);
11
-
12
- const passed = result.success &&
13
- result.stdout.length > 100 &&
14
- result.stdout.includes('def') &&
15
- result.stdout.includes('return') &&
16
- !result.stdout.includes('Error') &&
17
- !result.stdout.includes('error');
18
-
19
- recordTestResult('Claude CLI - Simple Code Generation', passed, {
20
- command: result.command,
21
- executionTime: result.executionTime,
22
- outputLength: result.stdout.length,
23
- hasError: !result.success || result.stderr.length > 0
24
- });
25
-
26
- console.log(` Result: ${passed ? 'PASS' : 'FAIL'}`);
27
- console.log(` Execution time: ${result.executionTime}ms`);
28
- console.log(` Output length: ${result.stdout.length} characters`);
29
-
30
- } catch (error) {
31
- recordTestResult('Claude CLI - Simple Code Generation', false, {
32
- error: error.message
33
- });
34
- console.log(` Result: FAIL - ${error.message}`);
35
- }
36
-
37
- // Test 2: Complex algorithm implementation
38
- console.log('\n--- Test 2: Complex algorithm implementation ---');
39
- try {
40
- const result = await executeCommand('node src/main_english.js call "claude implement a binary search algorithm in Python with proper error handling"', 60000);
41
-
42
- const passed = result.success &&
43
- result.stdout.length > 200 &&
44
- (result.stdout.includes('def') || result.stdout.includes('class')) &&
45
- result.stdout.includes('binary') &&
46
- !result.stdout.includes('Error') &&
47
- !result.stdout.includes('error');
48
-
49
- recordTestResult('Claude CLI - Complex Algorithm Implementation', passed, {
50
- command: result.command,
51
- executionTime: result.executionTime,
52
- outputLength: result.stdout.length,
53
- hasError: !result.success || result.stderr.length > 0
54
- });
55
-
56
- console.log(` Result: ${passed ? 'PASS' : 'FAIL'}`);
57
- console.log(` Execution time: ${result.executionTime}ms`);
58
- console.log(` Output length: ${result.stdout.length} characters`);
59
-
60
- } catch (error) {
61
- recordTestResult('Claude CLI - Complex Algorithm Implementation', false, {
62
- error: error.message
63
- });
64
- console.log(` Result: FAIL - ${error.message}`);
65
- }
66
-
67
- // Test 3: Code analysis and review
68
- console.log('\n--- Test 3: Code analysis and review ---');
69
- try {
70
- const result = await executeCommand('node src/main_english.js call "claude analyze this Python code for potential security vulnerabilities: def login(user, password): if user == \"admin\" and password == \"123456\": return True"', 45000);
71
-
72
- const passed = result.success &&
73
- result.stdout.length > 100 &&
74
- (result.stdout.includes('security') || result.stdout.includes('vulnerab')) &&
75
- !result.stdout.includes('Error') &&
76
- !result.stdout.includes('error');
77
-
78
- recordTestResult('Claude CLI - Code Analysis and Review', passed, {
79
- command: result.command,
80
- executionTime: result.executionTime,
81
- outputLength: result.stdout.length,
82
- hasError: !result.success || result.stderr.length > 0
83
- });
84
-
85
- console.log(` Result: ${passed ? 'PASS' : 'FAIL'}`);
86
- console.log(` Execution time: ${result.executionTime}ms`);
87
- console.log(` Output length: ${result.stdout.length} characters`);
88
-
89
- } catch (error) {
90
- recordTestResult('Claude CLI - Code Analysis and Review', false, {
91
- error: error.message
92
- });
93
- console.log(` Result: FAIL - ${error.message}`);
94
- }
95
-
96
- // Test 4: Documentation generation
97
- console.log('\n--- Test 4: Documentation generation ---');
98
- try {
99
- const result = await executeCommand('node src/main_english.js call "claude generate documentation for a Python function that sorts arrays"', 45000);
100
-
101
- const passed = result.success &&
102
- result.stdout.length > 100 &&
103
- (result.stdout.includes('def') || result.stdout.includes('function') || result.stdout.includes('doc')) &&
104
- !result.stdout.includes('Error') &&
105
- !result.stdout.includes('error');
106
-
107
- recordTestResult('Claude CLI - Documentation Generation', passed, {
108
- command: result.command,
109
- executionTime: result.executionTime,
110
- outputLength: result.stdout.length,
111
- hasError: !result.success || result.stderr.length > 0
112
- });
113
-
114
- console.log(` Result: ${passed ? 'PASS' : 'FAIL'}`);
115
- console.log(` Execution time: ${result.executionTime}ms`);
116
- console.log(` Output length: ${result.stdout.length} characters`);
117
-
118
- } catch (error) {
119
- recordTestResult('Claude CLI - Documentation Generation', false, {
120
- error: error.message
121
- });
122
- console.log(` Result: FAIL - ${error.message}`);
123
- }
124
-
125
- console.log('\n--- Claude CLI integration testing completed ---\n');
126
- }
127
-
128
- module.exports = testClaudeCLIIntegration;
@@ -1,75 +0,0 @@
1
- // Collaboration functionality testing
2
- const { executeCommand, recordTestResult, wait } = require('./test-utils');
3
- const testData = require('./test-data');
4
-
5
- async function testCollaboration() {
6
- console.log('Starting collaboration functionality testing...\n');
7
-
8
- // Test each collaboration scenario
9
- for (const scenario of testData.collaborationScenarios) {
10
- console.log(`\n--- Testing ${scenario.name} ---`);
11
-
12
- let allStepsPassed = true;
13
- const stepResults = [];
14
-
15
- // Execute each step in the scenario
16
- for (let i = 0; i < scenario.steps.length; i++) {
17
- const step = scenario.steps[i];
18
- console.log(` Step ${i + 1}: ${step}`);
19
-
20
- try {
21
- const result = await executeCommand(`stigmergy call "${step}"`, 60000);
22
-
23
- // Check if the command executed successfully
24
- const stepPassed = result.success &&
25
- result.stdout.length > 30 &&
26
- !result.stdout.includes('Error') &&
27
- !result.stdout.includes('error');
28
-
29
- stepResults.push({
30
- step: i + 1,
31
- command: step,
32
- passed: stepPassed,
33
- executionTime: result.executionTime,
34
- outputLength: result.stdout.length
35
- });
36
-
37
- if (!stepPassed) {
38
- allStepsPassed = false;
39
- }
40
-
41
- // Log result summary
42
- console.log(` Result: ${stepPassed ? 'PASS' : 'FAIL'}`);
43
- console.log(` Execution time: ${result.executionTime}ms`);
44
- console.log(` Output length: ${result.stdout.length} characters`);
45
-
46
- // Wait a bit between steps to avoid overwhelming the system
47
- await wait(2000);
48
-
49
- } catch (error) {
50
- stepResults.push({
51
- step: i + 1,
52
- command: step,
53
- passed: false,
54
- error: error.message
55
- });
56
-
57
- allStepsPassed = false;
58
- console.log(` Result: FAIL - ${error.message}`);
59
- }
60
- }
61
-
62
- // Record overall scenario result
63
- recordTestResult(`Collaboration - ${scenario.name}`, allStepsPassed, {
64
- steps: stepResults,
65
- totalSteps: scenario.steps.length,
66
- passedSteps: stepResults.filter(s => s.passed).length
67
- });
68
-
69
- console.log(` Overall: ${allStepsPassed ? 'PASS' : 'FAIL'}`);
70
- }
71
-
72
- console.log('\n--- Collaboration testing completed ---\n');
73
- }
74
-
75
- module.exports = testCollaboration;