stigmergy 1.0.94 → 1.0.95

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 (50) hide show
  1. package/bin/stigmergy +26 -12
  2. package/docs/HASH_TABLE.md +83 -0
  3. package/docs/WEATHER_PROCESSOR_API.md +230 -0
  4. package/docs/best_practices.md +135 -0
  5. package/docs/development_guidelines.md +392 -0
  6. package/docs/requirements_specification.md +148 -0
  7. package/docs/system_design.md +314 -0
  8. package/docs/tdd_implementation_plan.md +384 -0
  9. package/docs/test_report.md +49 -0
  10. package/examples/calculator-example.js +72 -0
  11. package/examples/json-validation-example.js +64 -0
  12. package/examples/rest-client-example.js +52 -0
  13. package/package.json +21 -17
  14. package/scripts/post-deployment-config.js +9 -2
  15. package/src/auth.js +171 -0
  16. package/src/auth_command.js +195 -0
  17. package/src/calculator.js +220 -0
  18. package/src/core/cli_help_analyzer.js +625 -562
  19. package/src/core/cli_parameter_handler.js +121 -0
  20. package/src/core/cli_tools.js +89 -0
  21. package/src/core/error_handler.js +307 -0
  22. package/src/core/memory_manager.js +76 -0
  23. package/src/core/smart_router.js +133 -0
  24. package/src/deploy.js +50 -0
  25. package/src/main_english.js +642 -719
  26. package/src/main_fixed.js +1035 -0
  27. package/src/utils.js +529 -0
  28. package/src/weatherProcessor.js +205 -0
  29. package/test/calculator.test.js +215 -0
  30. package/test/collision-test.js +26 -0
  31. package/test/csv-processing-test.js +36 -0
  32. package/test/e2e/claude-cli-test.js +128 -0
  33. package/test/e2e/collaboration-test.js +75 -0
  34. package/test/e2e/comprehensive-test.js +431 -0
  35. package/test/e2e/error-handling-test.js +90 -0
  36. package/test/e2e/individual-tool-test.js +143 -0
  37. package/test/e2e/other-cli-test.js +130 -0
  38. package/test/e2e/qoder-cli-test.js +128 -0
  39. package/test/e2e/run-e2e-tests.js +73 -0
  40. package/test/e2e/test-data.js +88 -0
  41. package/test/e2e/test-utils.js +222 -0
  42. package/test/hash-table-demo.js +33 -0
  43. package/test/hash-table-test.js +26 -0
  44. package/test/json-validation-test.js +164 -0
  45. package/test/rest-client-test.js +56 -0
  46. package/test/unit/calculator-full.test.js +191 -0
  47. package/test/unit/calculator-simple.test.js +96 -0
  48. package/test/unit/calculator.test.js +97 -0
  49. package/test/unit/cli_parameter_handler.test.js +116 -0
  50. package/test/weather-processor.test.js +104 -0
@@ -0,0 +1,130 @@
1
+ // Other CLI Tools Integration Tests
2
+ const { executeCommand, recordTestResult } = require('./test-utils');
3
+
4
+ async function testOtherCLIIntegration() {
5
+ console.log('Starting other CLI tools integration testing...\n');
6
+
7
+ // Test 1: Qwen CLI - Java code generation
8
+ console.log('--- Test 1: Qwen CLI - Java code generation ---');
9
+ try {
10
+ const result = await executeCommand('node src/main_english.js call "qwen generate a simple Java method to calculate area of rectangle"', 45000);
11
+
12
+ const passed = result.success &&
13
+ result.stdout.length > 100 &&
14
+ (result.stdout.includes('public') || result.stdout.includes('private')) &&
15
+ (result.stdout.includes('double') || result.stdout.includes('int') || result.stdout.includes('float')) &&
16
+ result.stdout.includes('area') &&
17
+ !result.stdout.includes('Error') &&
18
+ !result.stdout.includes('error');
19
+
20
+ recordTestResult('Qwen CLI - Java Code Generation', passed, {
21
+ command: result.command,
22
+ executionTime: result.executionTime,
23
+ outputLength: result.stdout.length,
24
+ hasError: !result.success || result.stderr.length > 0
25
+ });
26
+
27
+ console.log(` Result: ${passed ? 'PASS' : 'FAIL'}`);
28
+ console.log(` Execution time: ${result.executionTime}ms`);
29
+ console.log(` Output length: ${result.stdout.length} characters`);
30
+
31
+ } catch (error) {
32
+ recordTestResult('Qwen CLI - Java Code Generation', false, {
33
+ error: error.message
34
+ });
35
+ console.log(` Result: FAIL - ${error.message}`);
36
+ }
37
+
38
+ // Test 2: Gemini CLI - JavaScript function
39
+ console.log('\n--- Test 2: Gemini CLI - JavaScript function ---');
40
+ try {
41
+ const result = await executeCommand('node src/main_english.js call "gemini create a basic JavaScript function for string reversal"', 45000);
42
+
43
+ const passed = result.success &&
44
+ result.stdout.length > 50 &&
45
+ (result.stdout.includes('function') || result.stdout.includes('=>')) &&
46
+ result.stdout.includes('reverse') &&
47
+ !result.stdout.includes('Error') &&
48
+ !result.stdout.includes('error');
49
+
50
+ recordTestResult('Gemini CLI - JavaScript Function', passed, {
51
+ command: result.command,
52
+ executionTime: result.executionTime,
53
+ outputLength: result.stdout.length,
54
+ hasError: !result.success || result.stderr.length > 0
55
+ });
56
+
57
+ console.log(` Result: ${passed ? 'PASS' : 'FAIL'}`);
58
+ console.log(` Execution time: ${result.executionTime}ms`);
59
+ console.log(` Output length: ${result.stdout.length} characters`);
60
+
61
+ } catch (error) {
62
+ recordTestResult('Gemini CLI - JavaScript Function', false, {
63
+ error: error.message
64
+ });
65
+ console.log(` Result: FAIL - ${error.message}`);
66
+ }
67
+
68
+ // Test 3: iFlow CLI - Algorithm implementation
69
+ console.log('\n--- Test 3: iFlow CLI - Algorithm implementation ---');
70
+ try {
71
+ const result = await executeCommand('node src/main_english.js call "iflow write a basic function to check if a number is even"', 45000);
72
+
73
+ const passed = result.success &&
74
+ result.stdout.length > 50 &&
75
+ (result.stdout.includes('function') || result.stdout.includes('=>')) &&
76
+ (result.stdout.includes('%') || result.stdout.includes('mod')) &&
77
+ !result.stdout.includes('Error') &&
78
+ !result.stdout.includes('error');
79
+
80
+ recordTestResult('iFlow CLI - Algorithm Implementation', passed, {
81
+ command: result.command,
82
+ executionTime: result.executionTime,
83
+ outputLength: result.stdout.length,
84
+ hasError: !result.success || result.stderr.length > 0
85
+ });
86
+
87
+ console.log(` Result: ${passed ? 'PASS' : 'FAIL'}`);
88
+ console.log(` Execution time: ${result.executionTime}ms`);
89
+ console.log(` Output length: ${result.stdout.length} characters`);
90
+
91
+ } catch (error) {
92
+ recordTestResult('iFlow CLI - Algorithm Implementation', false, {
93
+ error: error.message
94
+ });
95
+ console.log(` Result: FAIL - ${error.message}`);
96
+ }
97
+
98
+ // Test 4: CodeBuddy CLI - Code analysis
99
+ console.log('\n--- Test 4: CodeBuddy CLI - Code analysis ---');
100
+ try {
101
+ const result = await executeCommand('node src/main_english.js call "codebuddy analyze this code for potential memory leaks: let arr = []; for(let i=0; i<1000000; i++) { arr.push(new Object()); }"', 45000);
102
+
103
+ const passed = result.success &&
104
+ result.stdout.length > 50 &&
105
+ (result.stdout.includes('memory') || result.stdout.includes('leak')) &&
106
+ !result.stdout.includes('Error') &&
107
+ !result.stdout.includes('error');
108
+
109
+ recordTestResult('CodeBuddy CLI - Code Analysis', passed, {
110
+ command: result.command,
111
+ executionTime: result.executionTime,
112
+ outputLength: result.stdout.length,
113
+ hasError: !result.success || result.stderr.length > 0
114
+ });
115
+
116
+ console.log(` Result: ${passed ? 'PASS' : 'FAIL'}`);
117
+ console.log(` Execution time: ${result.executionTime}ms`);
118
+ console.log(` Output length: ${result.stdout.length} characters`);
119
+
120
+ } catch (error) {
121
+ recordTestResult('CodeBuddy CLI - Code Analysis', false, {
122
+ error: error.message
123
+ });
124
+ console.log(` Result: FAIL - ${error.message}`);
125
+ }
126
+
127
+ console.log('\n--- Other CLI tools integration testing completed ---\n');
128
+ }
129
+
130
+ module.exports = testOtherCLIIntegration;
@@ -0,0 +1,128 @@
1
+ // Qoder CLI Integration Tests
2
+ const { executeCommand, recordTestResult } = require('./test-utils');
3
+
4
+ async function testQoderCLIIntegration() {
5
+ console.log('Starting Qoder CLI integration testing...\n');
6
+
7
+ // Test 1: Function implementation
8
+ console.log('--- Test 1: Function implementation ---');
9
+ try {
10
+ const result = await executeCommand('node src/main_english.js call "qodercli write a simple function to find maximum of two numbers"', 45000);
11
+
12
+ const passed = result.success &&
13
+ result.stdout.length > 100 &&
14
+ (result.stdout.includes('function') || result.stdout.includes('max')) &&
15
+ (result.stdout.includes('return') || result.stdout.includes('=>')) &&
16
+ !result.stdout.includes('Error') &&
17
+ !result.stdout.includes('error');
18
+
19
+ recordTestResult('Qoder CLI - Function Implementation', 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('Qoder CLI - Function Implementation', false, {
32
+ error: error.message
33
+ });
34
+ console.log(` Result: FAIL - ${error.message}`);
35
+ }
36
+
37
+ // Test 2: Code refactoring
38
+ console.log('\n--- Test 2: Code refactoring ---');
39
+ try {
40
+ const result = await executeCommand('node src/main_english.js call "qodercli refactor this JavaScript function to be more readable: function calc(a,b,c){if(c==\"add\")return a+b;if(c==\"sub\")return a-b;if(c==\"mul\")return a*b;}', 60000);
41
+
42
+ const passed = result.success &&
43
+ result.stdout.length > 100 &&
44
+ (result.stdout.includes('function') || result.stdout.includes('calc')) &&
45
+ (result.stdout.includes('if') || result.stdout.includes('switch')) &&
46
+ !result.stdout.includes('Error') &&
47
+ !result.stdout.includes('error');
48
+
49
+ recordTestResult('Qoder CLI - Code Refactoring', 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('Qoder CLI - Code Refactoring', false, {
62
+ error: error.message
63
+ });
64
+ console.log(` Result: FAIL - ${error.message}`);
65
+ }
66
+
67
+ // Test 3: Test generation
68
+ console.log('\n--- Test 3: Test generation ---');
69
+ try {
70
+ const result = await executeCommand('node src/main_english.js call "qodercli generate unit tests for this function: function multiply(a, b) { return a * b; }"', 45000);
71
+
72
+ const passed = result.success &&
73
+ result.stdout.length > 100 &&
74
+ (result.stdout.includes('test') || result.stdout.includes('assert') || result.stdout.includes('expect')) &&
75
+ !result.stdout.includes('Error') &&
76
+ !result.stdout.includes('error');
77
+
78
+ recordTestResult('Qoder CLI - Test Generation', 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('Qoder CLI - Test Generation', false, {
91
+ error: error.message
92
+ });
93
+ console.log(` Result: FAIL - ${error.message}`);
94
+ }
95
+
96
+ // Test 4: Project structure analysis
97
+ console.log('\n--- Test 4: Project structure analysis ---');
98
+ try {
99
+ const result = await executeCommand('node src/main_english.js call "qodercli analyze the project structure in this directory and suggest improvements"', 45000);
100
+
101
+ const passed = result.success &&
102
+ result.stdout.length > 100 &&
103
+ (result.stdout.includes('structure') || result.stdout.includes('project') || result.stdout.includes('directory')) &&
104
+ !result.stdout.includes('Error') &&
105
+ !result.stdout.includes('error');
106
+
107
+ recordTestResult('Qoder CLI - Project Structure Analysis', 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('Qoder CLI - Project Structure Analysis', false, {
120
+ error: error.message
121
+ });
122
+ console.log(` Result: FAIL - ${error.message}`);
123
+ }
124
+
125
+ console.log('\n--- Qoder CLI integration testing completed ---\n');
126
+ }
127
+
128
+ module.exports = testQoderCLIIntegration;
@@ -0,0 +1,73 @@
1
+ // Main end-to-end test runner
2
+ const { getTestSummary, saveTestReport, logFilePath } = require('./test-utils');
3
+ const testIndividualTools = require('./individual-tool-test');
4
+ const testCollaboration = require('./collaboration-test');
5
+ const testErrorHandling = require('./error-handling-test');
6
+ const runComprehensiveTest = require('./comprehensive-test');
7
+ const testClaudeCLIIntegration = require('./claude-cli-test');
8
+ const testQoderCLIIntegration = require('./qoder-cli-test');
9
+ const testOtherCLIIntegration = require('./other-cli-test');
10
+
11
+ async function runEndToEndTests() {
12
+ console.log('Stigmergy CLI End-to-End Testing');
13
+ console.log('================================\n');
14
+
15
+ // Check if we should run comprehensive tests
16
+ const runComprehensive = process.argv.includes('--comprehensive');
17
+ const runClaudeTests = process.argv.includes('--claude');
18
+ const runQoderTests = process.argv.includes('--qoder');
19
+ const runOtherCLITests = process.argv.includes('--other');
20
+
21
+ try {
22
+ if (runComprehensive) {
23
+ // Run comprehensive test suite
24
+ await runComprehensiveTest();
25
+ } else if (runClaudeTests) {
26
+ // Run Claude CLI integration tests
27
+ await testClaudeCLIIntegration();
28
+ } else if (runQoderTests) {
29
+ // Run Qoder CLI integration tests
30
+ await testQoderCLIIntegration();
31
+ } else if (runOtherCLITests) {
32
+ // Run other CLI tools integration tests
33
+ await testOtherCLIIntegration();
34
+ } else {
35
+ // Run individual tool tests
36
+ await testIndividualTools();
37
+
38
+ // Run collaboration tests
39
+ await testCollaboration();
40
+
41
+ // Run error handling tests
42
+ await testErrorHandling();
43
+ }
44
+
45
+ // Generate final report
46
+ const summary = getTestSummary();
47
+ const { reportPath, summaryPath } = saveTestReport();
48
+
49
+ console.log('\n' + '='.repeat(50));
50
+ console.log('FINAL TEST RESULTS');
51
+ console.log('='.repeat(50));
52
+ console.log(`Total Tests: ${summary.total}`);
53
+ console.log(`Passed: ${summary.passed}`);
54
+ console.log(`Failed: ${summary.failed}`);
55
+ console.log(`Pass Rate: ${summary.passRate}%`);
56
+ console.log(`Detailed Report: ${reportPath}`);
57
+ console.log(`Summary Report: ${summaryPath}`);
58
+ console.log(`Full Log: ${logFilePath}`);
59
+ console.log('='.repeat(50));
60
+
61
+ // Exit with appropriate code
62
+ process.exit(summary.failed > 0 ? 1 : 0);
63
+
64
+ } catch (error) {
65
+ console.error('Test execution failed:', error);
66
+ process.exit(1);
67
+ }
68
+ }
69
+
70
+ // Run the tests
71
+ if (require.main === module) {
72
+ runEndToEndTests();
73
+ }
@@ -0,0 +1,88 @@
1
+ // Test data for end-to-end testing
2
+ const testData = {
3
+ // Simple code generation prompts for each tool
4
+ simpleCodeGeneration: {
5
+ claude: "claude write a simple Python function to add two numbers",
6
+ gemini: "gemini create a basic JavaScript function for string reversal",
7
+ qwen: "qwen generate a simple Java method to calculate area of rectangle",
8
+ iflow: "iflow write a basic function to check if a number is even",
9
+ qodercli: "qodercli write a simple function to find maximum of two numbers",
10
+ codebuddy: "codebuddy create a basic function to calculate circle circumference",
11
+ copilot: "copilot generate a simple function to convert Celsius to Fahrenheit",
12
+ codex: "codex write a basic function to calculate factorial of a number"
13
+ },
14
+
15
+ // Complex code generation prompts
16
+ complexCodeGeneration: {
17
+ claude: "claude implement a binary search algorithm in Python with proper error handling",
18
+ gemini: "gemini create a JavaScript class for a simple banking system with deposit and withdraw methods",
19
+ qwen: "qwen generate a Java implementation of a linked list with insert and delete operations",
20
+ iflow: "iflow write a function to sort an array using quicksort algorithm",
21
+ qodercli: "qodercli implement a hash table data structure with collision handling",
22
+ codebuddy: "codebuddy create a function to parse JSON data and validate its structure",
23
+ copilot: "copilot generate a function to implement a simple REST API client",
24
+ codex: "codex write a function to process CSV data and generate statistics"
25
+ },
26
+
27
+ // Analysis prompts
28
+ analysis: {
29
+ claude: "claude analyze this Python code for potential security vulnerabilities",
30
+ gemini: "gemini review this JavaScript code for performance optimization opportunities",
31
+ qwen: "qwen check this Java code for adherence to best practices",
32
+ iflow: "iflow evaluate this code for potential bugs and logical errors",
33
+ qodercli: "qodercli assess this function for code quality and maintainability",
34
+ codebuddy: "codebuddy analyze this code for potential memory leaks",
35
+ copilot: "copilot review this code for proper error handling",
36
+ codex: "codex examine this code for potential scalability issues"
37
+ },
38
+
39
+ // Documentation prompts
40
+ documentation: {
41
+ claude: "claude generate documentation for a Python function that sorts arrays",
42
+ gemini: "gemini create JSDoc for a JavaScript function that validates email addresses",
43
+ qwen: "qwen write JavaDoc for a Java method that connects to database",
44
+ iflow: "iflow generate comments for a C++ function that processes image data",
45
+ qodercli: "qodercli create documentation for a function that handles HTTP requests",
46
+ codebuddy: "codebuddy write documentation for a function that encrypts data",
47
+ copilot: "copilot generate README section for a machine learning model API",
48
+ codex: "codex create API documentation for a weather data processing function"
49
+ },
50
+
51
+ // Collaboration scenarios
52
+ collaborationScenarios: [
53
+ {
54
+ name: "Code Review Workflow",
55
+ steps: [
56
+ "qodercli write a Python function to handle user authentication",
57
+ "claude analyze the security of the authentication function",
58
+ "gemini suggest performance improvements for the function"
59
+ ]
60
+ },
61
+ {
62
+ name: "Multi-language Implementation",
63
+ steps: [
64
+ "qwen generate a Java implementation of a calculator class",
65
+ "copilot create a C# version of the same calculator",
66
+ "codex write a JavaScript equivalent of the calculator"
67
+ ]
68
+ },
69
+ {
70
+ name: "Documentation and Testing",
71
+ steps: [
72
+ "iflow write a complex algorithm in Python",
73
+ "codebuddy generate unit tests for the algorithm",
74
+ "qodercli create comprehensive documentation for the algorithm"
75
+ ]
76
+ }
77
+ ],
78
+
79
+ // Error handling test cases
80
+ errorHandling: {
81
+ invalidTool: "xyz generate a function to add two numbers",
82
+ malformedInput: "claude ",
83
+ extremelyLongInput: "claude " + "very long prompt ".repeat(1000),
84
+ specialCharacters: "gemini analyze code with special chars: \n\t\r\\\"'"
85
+ }
86
+ };
87
+
88
+ module.exports = testData;
@@ -0,0 +1,222 @@
1
+ // Utility functions for end-to-end testing
2
+ const { spawn } = require('child_process');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ // Test result tracker
7
+ const testResults = {
8
+ passed: 0,
9
+ failed: 0,
10
+ total: 0,
11
+ details: []
12
+ };
13
+
14
+ // Log file path
15
+ const logFilePath = path.join(__dirname, 'logs', `e2e-test-${new Date().toISOString().replace(/[:.]/g, '-')}.log`);
16
+
17
+ // Initialize log file
18
+ fs.writeFileSync(logFilePath, `Stigmergy CLI End-to-End Test Log\n`);
19
+ fs.appendFileSync(logFilePath, `Started at: ${new Date().toISOString()}\n`);
20
+ fs.appendFileSync(logFilePath, `=`.repeat(80) + '\n\n');
21
+
22
+ /**
23
+ * Execute a command and return the result
24
+ * @param {string} command - Command to execute
25
+ * @param {number} timeout - Timeout in milliseconds (default: 30000)
26
+ * @returns {Promise<Object>} Result object with status, stdout, stderr
27
+ */
28
+ function executeCommand(command, timeout = 30000) {
29
+ return new Promise((resolve) => {
30
+ const startTime = Date.now();
31
+
32
+ // Log the command
33
+ const logEntry = `[${new Date().toISOString()}] Executing: ${command}\n`;
34
+ fs.appendFileSync(logFilePath, logEntry);
35
+ console.log(`Executing: ${command}`);
36
+
37
+ // Spawn the process
38
+ const child = spawn(command, {
39
+ shell: true,
40
+ stdio: ['pipe', 'pipe', 'pipe']
41
+ });
42
+
43
+ let stdout = '';
44
+ let stderr = '';
45
+
46
+ // Capture stdout
47
+ child.stdout.on('data', (data) => {
48
+ stdout += data.toString();
49
+ });
50
+
51
+ // Capture stderr
52
+ child.stderr.on('data', (data) => {
53
+ stderr += data.toString();
54
+ });
55
+
56
+ // Handle process close
57
+ child.on('close', (code) => {
58
+ const executionTime = Date.now() - startTime;
59
+ const result = {
60
+ command,
61
+ code,
62
+ stdout,
63
+ stderr,
64
+ executionTime,
65
+ success: code === 0
66
+ };
67
+
68
+ // Log the result
69
+ const resultLog = ` Status: ${code}, Time: ${executionTime}ms\n`;
70
+ fs.appendFileSync(logFilePath, resultLog);
71
+
72
+ if (stdout) {
73
+ fs.appendFileSync(logFilePath, ` STDOUT:\n${stdout}\n`);
74
+ }
75
+ if (stderr) {
76
+ fs.appendFileSync(logFilePath, ` STDERR:\n${stderr}\n`);
77
+ }
78
+
79
+ fs.appendFileSync(logFilePath, ` ---\n\n`);
80
+
81
+ resolve(result);
82
+ });
83
+
84
+ // Handle errors
85
+ child.on('error', (error) => {
86
+ const executionTime = Date.now() - startTime;
87
+ const result = {
88
+ command,
89
+ code: -1,
90
+ stdout: '',
91
+ stderr: error.message,
92
+ executionTime,
93
+ success: false
94
+ };
95
+
96
+ // Log the error
97
+ const errorLog = ` ERROR: ${error.message}, Time: ${executionTime}ms\n ---\n\n`;
98
+ fs.appendFileSync(logFilePath, errorLog);
99
+
100
+ resolve(result);
101
+ });
102
+
103
+ // Handle timeout
104
+ setTimeout(() => {
105
+ if (child.exitCode === null) {
106
+ child.kill();
107
+ const executionTime = Date.now() - startTime;
108
+ const result = {
109
+ command,
110
+ code: -2,
111
+ stdout: '',
112
+ stderr: 'TIMEOUT',
113
+ executionTime,
114
+ success: false
115
+ };
116
+
117
+ // Log the timeout
118
+ const timeoutLog = ` TIMEOUT after ${timeout}ms\n ---\n\n`;
119
+ fs.appendFileSync(logFilePath, timeoutLog);
120
+
121
+ resolve(result);
122
+ }
123
+ }, timeout);
124
+ });
125
+ }
126
+
127
+ /**
128
+ * Record test result
129
+ * @param {string} testName - Name of the test
130
+ * @param {boolean} passed - Whether the test passed
131
+ * @param {Object} details - Additional details about the test
132
+ */
133
+ function recordTestResult(testName, passed, details = {}) {
134
+ testResults.total++;
135
+ if (passed) {
136
+ testResults.passed++;
137
+ } else {
138
+ testResults.failed++;
139
+ }
140
+
141
+ const result = {
142
+ name: testName,
143
+ passed,
144
+ details
145
+ };
146
+
147
+ testResults.details.push(result);
148
+
149
+ // Log to file
150
+ const status = passed ? 'PASS' : 'FAIL';
151
+ const logEntry = `[${status}] ${testName}\n`;
152
+ fs.appendFileSync(logFilePath, logEntry);
153
+
154
+ // Log to console
155
+ console.log(`${status}: ${testName}`);
156
+ }
157
+
158
+ /**
159
+ * Get test summary
160
+ * @returns {Object} Test summary
161
+ */
162
+ function getTestSummary() {
163
+ return {
164
+ ...testResults,
165
+ passRate: testResults.total > 0 ? (testResults.passed / testResults.total * 100).toFixed(2) : 0
166
+ };
167
+ }
168
+
169
+ /**
170
+ * Save detailed test report
171
+ */
172
+ function saveTestReport() {
173
+ const summary = getTestSummary();
174
+ const reportPath = path.join(__dirname, 'logs', `e2e-report-${new Date().toISOString().replace(/[:.]/g, '-')}.json`);
175
+
176
+ const report = {
177
+ timestamp: new Date().toISOString(),
178
+ summary,
179
+ details: testResults.details
180
+ };
181
+
182
+ fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
183
+
184
+ // Also save a human-readable summary
185
+ const summaryPath = path.join(__dirname, 'logs', `e2e-summary-${new Date().toISOString().replace(/[:.]/g, '-')}.txt`);
186
+ let summaryContent = `Stigmergy CLI End-to-End Test Summary\n`;
187
+ summaryContent += `=====================================\n\n`;
188
+ summaryContent += `Timestamp: ${report.timestamp}\n`;
189
+ summaryContent += `Total Tests: ${summary.total}\n`;
190
+ summaryContent += `Passed: ${summary.passed}\n`;
191
+ summaryContent += `Failed: ${summary.failed}\n`;
192
+ summaryContent += `Pass Rate: ${summary.passRate}%\n\n`;
193
+
194
+ summaryContent += `Detailed Results:\n`;
195
+ summaryContent += `-----------------\n`;
196
+ testResults.details.forEach(detail => {
197
+ const status = detail.passed ? 'PASS' : 'FAIL';
198
+ summaryContent += `${status}: ${detail.name}\n`;
199
+ });
200
+
201
+ fs.writeFileSync(summaryPath, summaryContent);
202
+
203
+ return { reportPath, summaryPath };
204
+ }
205
+
206
+ /**
207
+ * Wait for a specified time
208
+ * @param {number} ms - Milliseconds to wait
209
+ * @returns {Promise<void>}
210
+ */
211
+ function wait(ms) {
212
+ return new Promise(resolve => setTimeout(resolve, ms));
213
+ }
214
+
215
+ module.exports = {
216
+ executeCommand,
217
+ recordTestResult,
218
+ getTestSummary,
219
+ saveTestReport,
220
+ wait,
221
+ logFilePath
222
+ };
@@ -0,0 +1,33 @@
1
+ const { HashTable } = require('../src/utils');
2
+
3
+ // Test without linting issues
4
+ function runHashTableTests() {
5
+ console.log('=== Hash Table Implementation Test ===');
6
+
7
+ // Create a new hash table
8
+ const ht = new HashTable(17);
9
+
10
+ // Test setting values
11
+ ht.set('maroon', '#800000');
12
+ ht.set('yellow', '#FFFF00');
13
+ ht.set('olive', '#808000');
14
+ ht.set('salmon', '#FA8072');
15
+ ht.set('lightcoral', '#F08080');
16
+ ht.set('mediumvioletred', '#C71585');
17
+ ht.set('plum', '#DDA0DD');
18
+
19
+ // Test getting values
20
+ console.log('Get maroon:', ht.get('maroon')); // #800000
21
+ console.log('Get yellow:', ht.get('yellow')); // #FFFF00
22
+ console.log('Get invalid:', ht.get('invalid')); // undefined
23
+
24
+ // Test keys method
25
+ console.log('Keys:', ht.keys());
26
+
27
+ // Test values method
28
+ console.log('Values:', ht.values());
29
+
30
+ console.log('=== Hash Table tests completed successfully! ===');
31
+ }
32
+
33
+ runHashTableTests();