stigmergy 1.3.10 → 1.3.11
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.
- package/package.json +1 -1
- package/src/utils.js +12 -2
- package/test/simple_test.js +82 -0
- package/test/very_simple_test.js +54 -0
package/package.json
CHANGED
package/src/utils.js
CHANGED
|
@@ -712,25 +712,35 @@ async function executeCommand(command, args = [], options = {}) {
|
|
|
712
712
|
}
|
|
713
713
|
};
|
|
714
714
|
|
|
715
|
-
child.on('exit', (code) => {
|
|
715
|
+
child.on('exit', (code, signal) => {
|
|
716
716
|
// Clear timeout when process exits
|
|
717
717
|
clearTimeoutSafely();
|
|
718
718
|
|
|
719
719
|
// Resolve with collected stdout/stderr
|
|
720
720
|
resolve({
|
|
721
721
|
code,
|
|
722
|
+
signal,
|
|
722
723
|
stdout,
|
|
723
724
|
stderr,
|
|
724
725
|
success: code === 0,
|
|
725
726
|
});
|
|
726
727
|
});
|
|
727
728
|
|
|
728
|
-
child.on('close', (code) => {
|
|
729
|
+
child.on('close', (code, signal) => {
|
|
729
730
|
// Clear timeout when all stdio streams are closed
|
|
730
731
|
clearTimeoutSafely();
|
|
731
732
|
|
|
732
733
|
// Only resolve if not already resolved via 'exit' event
|
|
733
734
|
// This prevents duplicate resolution
|
|
735
|
+
if (!timeoutCleared) {
|
|
736
|
+
resolve({
|
|
737
|
+
code,
|
|
738
|
+
signal,
|
|
739
|
+
stdout,
|
|
740
|
+
stderr,
|
|
741
|
+
success: code === 0,
|
|
742
|
+
});
|
|
743
|
+
}
|
|
734
744
|
});
|
|
735
745
|
|
|
736
746
|
child.on('error', (error) => {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Simple test for basic functionality
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Mock the CLI tools to ensure they're available for testing
|
|
8
|
+
jest.doMock('../src/core/cli_tools', () => ({
|
|
9
|
+
CLI_TOOLS: {
|
|
10
|
+
claude: { name: 'Claude CLI', command: 'claude', version: 'claude --version' },
|
|
11
|
+
qwen: { name: 'Qwen CLI', command: 'qwen', version: 'qwen --version' },
|
|
12
|
+
gemini: { name: 'Gemini CLI', command: 'gemini', version: 'gemini --version' },
|
|
13
|
+
iflow: { name: 'iFlow CLI', command: 'iflow', version: 'iflow --version' },
|
|
14
|
+
codebuddy: { name: 'CodeBuddy CLI', command: 'codebuddy', version: 'codebuddy --version' },
|
|
15
|
+
codex: { name: 'Codex CLI', command: 'codex', version: 'codex --version' },
|
|
16
|
+
qodercli: { name: 'QoderCLI', command: 'qodercli', version: 'qodercli --version' },
|
|
17
|
+
copilot: { name: 'Copilot CLI', command: 'copilot', version: 'copilot --version' },
|
|
18
|
+
kode: { name: 'Kode CLI', command: 'kode', version: 'kode --version' }
|
|
19
|
+
},
|
|
20
|
+
validateCLITool: jest.fn().mockReturnValue(true)
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
// Mock CLIHelpAnalyzer to avoid actual CLI analysis during testing
|
|
24
|
+
jest.doMock('../src/core/cli_help_analyzer', () => {
|
|
25
|
+
return jest.fn().mockImplementation(() => {
|
|
26
|
+
return {
|
|
27
|
+
setCLITools: jest.fn(),
|
|
28
|
+
initialize: jest.fn().mockResolvedValue(undefined),
|
|
29
|
+
analyzeCLI: jest.fn().mockResolvedValue({
|
|
30
|
+
success: true,
|
|
31
|
+
cliName: 'test-cli',
|
|
32
|
+
patterns: {
|
|
33
|
+
commands: [{ name: 'analyze' }, { name: 'generate' }, { name: 'explain' }],
|
|
34
|
+
subcommands: []
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
loadPersistentConfig: jest.fn().mockResolvedValue({
|
|
38
|
+
failedAttempts: {},
|
|
39
|
+
cliPatterns: {}
|
|
40
|
+
}),
|
|
41
|
+
getCachedAnalysis: jest.fn().mockResolvedValue(null),
|
|
42
|
+
isCacheExpired: jest.fn().mockReturnValue(false),
|
|
43
|
+
generateOptimizedCall: jest.fn().mockReturnValue({
|
|
44
|
+
optimizedPrompt: 'test prompt'
|
|
45
|
+
}),
|
|
46
|
+
getAgentSkillCompatibilityScore: jest.fn().mockReturnValue({ score: 0.5, reasons: ['test'] }),
|
|
47
|
+
getEnhancedCLIPattern: jest.fn().mockResolvedValue({})
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const SmartRouter = require('../src/core/smart_router');
|
|
53
|
+
|
|
54
|
+
async function runSimpleTest() {
|
|
55
|
+
console.log('Running simple test...');
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const router = new SmartRouter();
|
|
59
|
+
await router.initialize();
|
|
60
|
+
|
|
61
|
+
console.log('✓ Router initialized successfully');
|
|
62
|
+
|
|
63
|
+
// Test a simple routing case
|
|
64
|
+
const result = await router.smartRoute('use claude to analyze code');
|
|
65
|
+
console.log(`✓ Simple routing test passed: ${result.tool}`);
|
|
66
|
+
|
|
67
|
+
// Test shouldRoute functionality
|
|
68
|
+
const shouldRoute = router.shouldRoute('help with code');
|
|
69
|
+
console.log(`✓ shouldRoute test passed: ${shouldRoute}`);
|
|
70
|
+
|
|
71
|
+
console.log('All simple tests passed!');
|
|
72
|
+
return true;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error('Simple test failed:', error);
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Run the test
|
|
80
|
+
runSimpleTest().then(success => {
|
|
81
|
+
process.exit(success ? 0 : 1);
|
|
82
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Very simple test without complex mocking
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Simple test to check basic functionality
|
|
8
|
+
async function runVerySimpleTest() {
|
|
9
|
+
console.log('Running very simple test...');
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
// Test basic Node.js functionality
|
|
13
|
+
console.log('✓ Node.js environment is working');
|
|
14
|
+
|
|
15
|
+
// Test basic string operations
|
|
16
|
+
const testString = 'hello world';
|
|
17
|
+
if (testString.toUpperCase() === 'HELLO WORLD') {
|
|
18
|
+
console.log('✓ String operations working');
|
|
19
|
+
} else {
|
|
20
|
+
console.log('✗ String operations failed');
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Test basic math
|
|
25
|
+
if (2 + 2 === 4) {
|
|
26
|
+
console.log('✓ Math operations working');
|
|
27
|
+
} else {
|
|
28
|
+
console.log('✗ Math operations failed');
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Test basic array operations
|
|
33
|
+
const arr = [1, 2, 3];
|
|
34
|
+
arr.push(4);
|
|
35
|
+
if (arr.length === 4 && arr[3] === 4) {
|
|
36
|
+
console.log('✓ Array operations working');
|
|
37
|
+
} else {
|
|
38
|
+
console.log('✗ Array operations failed');
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log('All very simple tests passed!');
|
|
43
|
+
return true;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Very simple test failed:', error);
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Run the test
|
|
51
|
+
runVerySimpleTest().then(success => {
|
|
52
|
+
console.log(`Test completed with success: ${success}`);
|
|
53
|
+
process.exit(success ? 0 : 1);
|
|
54
|
+
});
|