stigmergy 1.0.93 → 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 (51) hide show
  1. package/bin/stigmergy +26 -12
  2. package/bin/stigmergy.cmd +1 -1
  3. package/docs/HASH_TABLE.md +83 -0
  4. package/docs/WEATHER_PROCESSOR_API.md +230 -0
  5. package/docs/best_practices.md +135 -0
  6. package/docs/development_guidelines.md +392 -0
  7. package/docs/requirements_specification.md +148 -0
  8. package/docs/system_design.md +314 -0
  9. package/docs/tdd_implementation_plan.md +384 -0
  10. package/docs/test_report.md +49 -0
  11. package/examples/calculator-example.js +72 -0
  12. package/examples/json-validation-example.js +64 -0
  13. package/examples/rest-client-example.js +52 -0
  14. package/package.json +21 -17
  15. package/scripts/post-deployment-config.js +9 -2
  16. package/src/auth.js +171 -0
  17. package/src/auth_command.js +195 -0
  18. package/src/calculator.js +220 -0
  19. package/src/core/cli_help_analyzer.js +625 -562
  20. package/src/core/cli_parameter_handler.js +121 -0
  21. package/src/core/cli_tools.js +89 -0
  22. package/src/core/error_handler.js +307 -0
  23. package/src/core/memory_manager.js +76 -0
  24. package/src/core/smart_router.js +133 -0
  25. package/src/deploy.js +50 -0
  26. package/src/main_english.js +643 -720
  27. package/src/main_fixed.js +1035 -0
  28. package/src/utils.js +529 -0
  29. package/src/weatherProcessor.js +205 -0
  30. package/test/calculator.test.js +215 -0
  31. package/test/collision-test.js +26 -0
  32. package/test/csv-processing-test.js +36 -0
  33. package/test/e2e/claude-cli-test.js +128 -0
  34. package/test/e2e/collaboration-test.js +75 -0
  35. package/test/e2e/comprehensive-test.js +431 -0
  36. package/test/e2e/error-handling-test.js +90 -0
  37. package/test/e2e/individual-tool-test.js +143 -0
  38. package/test/e2e/other-cli-test.js +130 -0
  39. package/test/e2e/qoder-cli-test.js +128 -0
  40. package/test/e2e/run-e2e-tests.js +73 -0
  41. package/test/e2e/test-data.js +88 -0
  42. package/test/e2e/test-utils.js +222 -0
  43. package/test/hash-table-demo.js +33 -0
  44. package/test/hash-table-test.js +26 -0
  45. package/test/json-validation-test.js +164 -0
  46. package/test/rest-client-test.js +56 -0
  47. package/test/unit/calculator-full.test.js +191 -0
  48. package/test/unit/calculator-simple.test.js +96 -0
  49. package/test/unit/calculator.test.js +97 -0
  50. package/test/unit/cli_parameter_handler.test.js +116 -0
  51. package/test/weather-processor.test.js +104 -0
@@ -0,0 +1,116 @@
1
+ // Unit tests for CLI Parameter Handler
2
+ const CLIParameterHandler = require('../../src/core/cli_parameter_handler');
3
+
4
+ // Mock CLI pattern data for testing
5
+ const mockCLIPatterns = {
6
+ claude: {
7
+ commandStructure: {
8
+ nonInteractiveSupport: true,
9
+ promptFlag: '-p',
10
+ nonInteractiveFlag: '--print',
11
+ executionPattern: 'flag-based'
12
+ }
13
+ },
14
+ codex: {
15
+ commandStructure: {
16
+ nonInteractiveSupport: true,
17
+ promptFlag: '-p',
18
+ nonInteractiveFlag: '--print',
19
+ executionPattern: 'subcommand-based'
20
+ }
21
+ },
22
+ iflow: {
23
+ commandStructure: {
24
+ nonInteractiveSupport: true,
25
+ promptFlag: '-p',
26
+ executionPattern: 'flag-based'
27
+ }
28
+ },
29
+ generic: {
30
+ commandStructure: {
31
+ nonInteractiveSupport: false,
32
+ executionPattern: 'interactive-default'
33
+ }
34
+ }
35
+ };
36
+
37
+ // Test cases
38
+ const testCases = [
39
+ {
40
+ name: 'Claude CLI with pattern data',
41
+ toolName: 'claude',
42
+ prompt: 'Write a function to add two numbers',
43
+ cliPattern: mockCLIPatterns.claude,
44
+ expected: ['-p', '"Write a function to add two numbers"']
45
+ },
46
+ {
47
+ name: 'Codex CLI with subcommand pattern',
48
+ toolName: 'codex',
49
+ prompt: 'Generate a Fibonacci function',
50
+ cliPattern: mockCLIPatterns.codex,
51
+ expected: ['exec', '-p', '"Generate a Fibonacci function"']
52
+ },
53
+ {
54
+ name: 'iFlow CLI with pattern data',
55
+ toolName: 'iflow',
56
+ prompt: 'Check if number is even',
57
+ cliPattern: mockCLIPatterns.iflow,
58
+ expected: ['-p', '"Check if number is even"']
59
+ },
60
+ {
61
+ name: 'Generic CLI without pattern data',
62
+ toolName: 'generic',
63
+ prompt: 'Generic prompt',
64
+ cliPattern: mockCLIPatterns.generic,
65
+ expected: ['"Generic prompt"']
66
+ },
67
+ {
68
+ name: 'Unknown CLI without pattern data',
69
+ toolName: 'unknown',
70
+ prompt: 'Unknown prompt',
71
+ cliPattern: null,
72
+ expected: ['"Unknown prompt"']
73
+ }
74
+ ];
75
+
76
+ // Run tests
77
+ console.log('Running CLI Parameter Handler Unit Tests...\n');
78
+
79
+ let passedTests = 0;
80
+ let totalTests = testCases.length;
81
+
82
+ for (const testCase of testCases) {
83
+ try {
84
+ const result = CLIParameterHandler.generateArguments(
85
+ testCase.toolName,
86
+ testCase.prompt,
87
+ testCase.cliPattern
88
+ );
89
+
90
+ // Compare results
91
+ const passed = JSON.stringify(result) === JSON.stringify(testCase.expected);
92
+
93
+ console.log(`Test: ${testCase.name}`);
94
+ console.log(`Expected: ${JSON.stringify(testCase.expected)}`);
95
+ console.log(`Actual: ${JSON.stringify(result)}`);
96
+ console.log(`Status: ${passed ? 'PASS' : 'FAIL'}\n`);
97
+
98
+ if (passed) {
99
+ passedTests++;
100
+ }
101
+ } catch (error) {
102
+ console.log(`Test: ${testCase.name}`);
103
+ console.log(`Error: ${error.message}`);
104
+ console.log(`Status: FAIL\n`);
105
+ }
106
+ }
107
+
108
+ console.log(`\nUnit Test Results: ${passedTests}/${totalTests} tests passed`);
109
+
110
+ if (passedTests === totalTests) {
111
+ console.log('All unit tests passed!');
112
+ process.exit(0);
113
+ } else {
114
+ console.log('Some unit tests failed!');
115
+ process.exit(1);
116
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Test for Weather Data Processing Module
3
+ */
4
+
5
+ const { processWeatherData } = require('../src/weatherProcessor');
6
+
7
+ // Sample raw weather data
8
+ const sampleData = {
9
+ location: {
10
+ name: "London",
11
+ country: "UK",
12
+ lat: 51.5074,
13
+ lon: -0.1278
14
+ },
15
+ current: {
16
+ temp: 285.15, // Kelvin
17
+ feels_like: 283.15, // Kelvin
18
+ humidity: 72,
19
+ pressure: 1013,
20
+ wind_speed: 3.5,
21
+ wind_deg: 180,
22
+ visibility: 10000,
23
+ clouds: 40,
24
+ weather: [{
25
+ description: "scattered clouds",
26
+ icon: "03d"
27
+ }]
28
+ },
29
+ forecast: [
30
+ {
31
+ dt: 1640995200,
32
+ temp: { min: 282.15, max: 286.15 }, // Kelvin
33
+ humidity: 65,
34
+ pressure: 1015,
35
+ wind_speed: 2.8,
36
+ wind_deg: 160,
37
+ pop: 0.2,
38
+ weather: [{ description: "light rain" }]
39
+ }
40
+ ]
41
+ };
42
+
43
+ console.log("Testing weather data processing...");
44
+
45
+ try {
46
+ // Test with default options
47
+ console.log("\n1. Testing with default options:");
48
+ const result1 = processWeatherData(sampleData);
49
+ console.log("Success:", {
50
+ location: result1.location.name,
51
+ temperature: result1.current.temperature.value + "°" + result1.current.temperature.unit,
52
+ forecasts: result1.forecasts.length
53
+ });
54
+
55
+ // Test with Celsius
56
+ console.log("\n2. Testing with Celsius:");
57
+ const result2 = processWeatherData(sampleData, { unit: 'celsius' });
58
+ console.log("Success:", {
59
+ temperature: result2.current.temperature.value + "°C",
60
+ feelsLike: result2.current.temperature.feelsLike + "°C"
61
+ });
62
+
63
+ // Test with Fahrenheit
64
+ console.log("\n3. Testing with Fahrenheit:");
65
+ const result3 = processWeatherData(sampleData, { unit: 'fahrenheit' });
66
+ console.log("Success:", {
67
+ temperature: result3.current.temperature.value + "°F",
68
+ feelsLike: result3.current.temperature.feelsLike + "°F"
69
+ });
70
+
71
+ // Test with forecasts
72
+ console.log("\n4. Testing with forecasts:");
73
+ const result4 = processWeatherData(sampleData, {
74
+ unit: 'celsius',
75
+ includeForecasts: true,
76
+ forecastDays: 1
77
+ });
78
+ console.log("Success:", {
79
+ forecasts: result4.forecasts.length,
80
+ forecastTempMin: result4.forecasts[0].temperature.min + "°C",
81
+ forecastTempMax: result4.forecasts[0].temperature.max + "°C"
82
+ });
83
+
84
+ console.log("\n✅ All tests passed!");
85
+ } catch (error) {
86
+ console.error("❌ Test failed:", error.message);
87
+ }
88
+
89
+ // Test error cases
90
+ console.log("\n5. Testing error handling:");
91
+
92
+ try {
93
+ processWeatherData(null);
94
+ console.log("❌ Should have thrown an error for null input");
95
+ } catch (error) {
96
+ console.log("✅ Correctly threw error for null input:", error.message);
97
+ }
98
+
99
+ try {
100
+ processWeatherData({}, { unit: 'invalid' });
101
+ console.log("❌ Should have thrown an error for invalid unit");
102
+ } catch (error) {
103
+ console.log("✅ Correctly threw error for invalid unit:", error.message);
104
+ }