stigmergy 1.2.0 → 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.
- package/LICENSE +18 -18
- package/README.md +28 -223
- package/STIGMERGY.md +61 -61
- package/docs/PROJECT_CONSTITUTION.md +433 -433
- package/docs/PROJECT_STRUCTURE_CURRENT.md +80 -80
- package/examples/calculator-example.js +72 -72
- package/examples/cline_usage_examples.md +364 -364
- package/examples/encryption-example.js +67 -67
- package/examples/json-parser-example.js +120 -120
- package/examples/json-validation-example.js +64 -64
- package/examples/rest-client-example.js +52 -52
- package/examples/rest_client_example.js +54 -54
- package/package.json +36 -15
- package/scripts/build.js +74 -74
- package/scripts/post-deployment-config.js +296 -296
- package/scripts/preinstall-check.js +173 -173
- package/scripts/publish.js +58 -268
- package/scripts/run-layered-tests.js +247 -0
- package/scripts/safe-install.js +139 -139
- package/scripts/simple-publish.js +57 -59
- package/src/adapters/claude/install_claude_integration.js +292 -0
- package/src/adapters/codebuddy/install_codebuddy_integration.js +349 -0
- package/src/adapters/codex/install_codex_integration.js +395 -0
- package/src/adapters/copilot/install_copilot_integration.js +716 -0
- package/src/adapters/gemini/install_gemini_integration.js +304 -0
- package/src/adapters/iflow/install_iflow_integration.js +304 -0
- package/src/adapters/qoder/install_qoder_integration.js +1090 -0
- package/src/adapters/qwen/install_qwen_integration.js +285 -0
- package/src/auth.js +173 -173
- package/src/auth_command.js +208 -208
- package/src/calculator.js +313 -313
- package/src/cli/router.js +417 -38
- package/src/core/cache_cleaner.js +767 -744
- package/src/core/cli_help_analyzer.js +680 -674
- package/src/core/cli_parameter_handler.js +132 -127
- package/src/core/cli_tools.js +89 -89
- package/src/core/coordination/index.js +16 -16
- package/src/core/coordination/nodejs/AdapterManager.js +102 -89
- package/src/core/coordination/nodejs/CLCommunication.js +132 -124
- package/src/core/coordination/nodejs/CLIIntegrationManager.js +272 -236
- package/src/core/coordination/nodejs/HealthChecker.js +76 -77
- package/src/core/coordination/nodejs/HookDeploymentManager.js +263 -190
- package/src/core/coordination/nodejs/StatisticsCollector.js +71 -71
- package/src/core/coordination/nodejs/index.js +90 -72
- package/src/core/coordination/nodejs/utils/Logger.js +29 -29
- package/src/core/enhanced_installer.js +479 -456
- package/src/core/enhanced_uninstaller.js +638 -618
- package/src/core/error_handler.js +406 -406
- package/src/core/installer.js +815 -294
- package/src/core/memory_manager.js +83 -83
- package/src/core/rest_client.js +160 -160
- package/src/core/smart_router.js +249 -146
- package/src/core/upgrade_manager.js +76 -59
- package/src/data_encryption.js +143 -143
- package/src/data_structures.js +440 -440
- package/src/deploy.js +55 -55
- package/src/index.js +30 -30
- package/src/test/cli-availability-checker.js +194 -0
- package/src/test/test-environment.js +289 -0
- package/src/utils/helpers.js +35 -35
- package/src/utils.js +921 -915
- package/src/weatherProcessor.js +228 -228
- package/test/cache-cleaner-implemented.test.js +0 -328
- package/test/cache-cleaner.test.js +0 -390
- package/test/calculator.test.js +0 -215
- package/test/collision-test.js +0 -26
- package/test/comprehensive-enhanced-features.test.js +0 -252
- package/test/comprehensive-execution-test.js +0 -428
- package/test/conflict-prevention-test.js +0 -95
- package/test/cross-cli-detection-test.js +0 -33
- package/test/csv-processing-test.js +0 -36
- package/test/deploy-hooks-test.js +0 -250
- package/test/e2e/claude-cli-test.js +0 -128
- package/test/e2e/collaboration-test.js +0 -75
- package/test/e2e/comprehensive-test.js +0 -431
- package/test/e2e/error-handling-test.js +0 -90
- package/test/e2e/individual-tool-test.js +0 -143
- package/test/e2e/other-cli-test.js +0 -130
- package/test/e2e/qoder-cli-test.js +0 -128
- package/test/e2e/run-e2e-tests.js +0 -73
- package/test/e2e/test-data.js +0 -88
- package/test/e2e/test-utils.js +0 -222
- package/test/encryption-simple-test.js +0 -110
- package/test/encryption.test.js +0 -129
- package/test/enhanced-main-alignment.test.js +0 -298
- package/test/enhanced-uninstaller-implemented.test.js +0 -271
- package/test/enhanced-uninstaller.test.js +0 -284
- package/test/error-handling-test.js +0 -341
- package/test/fibonacci.test.js +0 -178
- package/test/final-deploy-test.js +0 -221
- package/test/final-install-test.js +0 -226
- package/test/hash-table-demo.js +0 -33
- package/test/hash-table-test.js +0 -26
- package/test/hash_table_test.js +0 -114
- package/test/hook-system-integration-test.js +0 -307
- package/test/iflow-integration-test.js +0 -292
- package/test/improved-install-test.js +0 -362
- package/test/install-command-test.js +0 -370
- package/test/json-parser-test.js +0 -161
- package/test/json-validation-test.js +0 -164
- package/test/natural-language-skills-test.js +0 -320
- package/test/nl-integration-test.js +0 -179
- package/test/parameter-parsing-test.js +0 -143
- package/test/plugin-deployment-test.js +0 -316
- package/test/postinstall-test.js +0 -269
- package/test/python-plugins-test.js +0 -259
- package/test/real-test.js +0 -435
- package/test/remaining-adapters-test.js +0 -256
- package/test/rest-client-test.js +0 -56
- package/test/rest_client.test.js +0 -85
- package/test/safe-installation-cleaner.test.js +0 -343
- package/test/simple-iflow-hook-test.js +0 -137
- package/test/stigmergy-upgrade-test.js +0 -243
- package/test/system-compatibility-test.js +0 -467
- package/test/tdd-deploy-fix-test.js +0 -324
- package/test/tdd-fixes-test.js +0 -211
- package/test/third-party-skills-test.js +0 -321
- package/test/tool-selection-integration-test.js +0 -158
- package/test/unit/calculator-full.test.js +0 -191
- package/test/unit/calculator-simple.test.js +0 -96
- package/test/unit/calculator.test.js +0 -97
- package/test/unit/cli-scanner.test.js +0 -291
- package/test/unit/cli_parameter_handler.test.js +0 -116
- package/test/unit/cross-cli-executor.test.js +0 -399
- package/test/weather-processor.test.js +0 -104
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* TDD Implementation Test for deployHooks Fix
|
|
5
|
-
* This test verifies the implementation of automatic CLI tool installation and configuration
|
|
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 TDDDeployFixTester {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.testResults = [];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Mock CLI tools configuration for testing
|
|
19
|
-
getMockCLITools() {
|
|
20
|
-
return {
|
|
21
|
-
iflow: {
|
|
22
|
-
name: 'iFlow CLI',
|
|
23
|
-
install: 'npm install -g iflow-cli',
|
|
24
|
-
hooksDir: path.join(os.homedir(), '.config', 'iflow', 'hooks'),
|
|
25
|
-
config: path.join(os.homedir(), '.config', 'iflow', 'hooks.yml'),
|
|
26
|
-
installScript: 'install_iflow_integration.py'
|
|
27
|
-
},
|
|
28
|
-
claude: {
|
|
29
|
-
name: 'Claude CLI',
|
|
30
|
-
install: 'npm install -g claude-cli',
|
|
31
|
-
hooksDir: path.join(os.homedir(), '.config', 'claude', 'hooks'),
|
|
32
|
-
config: path.join(os.homedir(), '.config', 'claude', 'hooks.json'),
|
|
33
|
-
installScript: 'install_claude_integration.py'
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Test 1: Verify directory creation functionality
|
|
39
|
-
async testDirectoryCreation() {
|
|
40
|
-
console.log('[TEST 1] Verifying directory creation functionality...');
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
// Create a temporary test directory
|
|
44
|
-
const testDir = path.join(os.tmpdir(), 'stigmergy-test-' + Date.now());
|
|
45
|
-
await fs.mkdir(testDir, { recursive: true });
|
|
46
|
-
|
|
47
|
-
// Test creating subdirectories
|
|
48
|
-
const subDir = path.join(testDir, 'subdir', 'nested');
|
|
49
|
-
await fs.mkdir(subDir, { recursive: true });
|
|
50
|
-
|
|
51
|
-
// Verify directories exist
|
|
52
|
-
await fs.access(testDir);
|
|
53
|
-
await fs.access(subDir);
|
|
54
|
-
|
|
55
|
-
// Clean up
|
|
56
|
-
await fs.rm(testDir, { recursive: true, force: true });
|
|
57
|
-
|
|
58
|
-
console.log(' ✓ Directory creation works correctly');
|
|
59
|
-
|
|
60
|
-
this.testResults.push({
|
|
61
|
-
name: 'Directory Creation',
|
|
62
|
-
passed: true,
|
|
63
|
-
details: 'Successfully created and verified directories'
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
return true;
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.log(` ✗ Directory creation failed: ${error.message}`);
|
|
69
|
-
|
|
70
|
-
this.testResults.push({
|
|
71
|
-
name: 'Directory Creation',
|
|
72
|
-
passed: false,
|
|
73
|
-
details: `Failed: ${error.message}`
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Test 2: Verify file copying functionality
|
|
81
|
-
async testFileCopying() {
|
|
82
|
-
console.log('\n[TEST 2] Verifying file copying functionality...');
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
// Create source and destination directories
|
|
86
|
-
const srcDir = path.join(os.tmpdir(), 'stigmergy-src-' + Date.now());
|
|
87
|
-
const dstDir = path.join(os.tmpdir(), 'stigmergy-dst-' + Date.now());
|
|
88
|
-
|
|
89
|
-
await fs.mkdir(srcDir, { recursive: true });
|
|
90
|
-
await fs.mkdir(dstDir, { recursive: true });
|
|
91
|
-
|
|
92
|
-
// Create test files
|
|
93
|
-
const testFiles = ['file1.txt', 'file2.py', 'config.json'];
|
|
94
|
-
for (const fileName of testFiles) {
|
|
95
|
-
const filePath = path.join(srcDir, fileName);
|
|
96
|
-
await fs.writeFile(filePath, `Test content for ${fileName}`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Create subdirectory with files
|
|
100
|
-
const subDir = path.join(srcDir, 'subdir');
|
|
101
|
-
await fs.mkdir(subDir, { recursive: true });
|
|
102
|
-
await fs.writeFile(path.join(subDir, 'subfile.txt'), 'Subdirectory file content');
|
|
103
|
-
|
|
104
|
-
// Test copyDirectory function (mock implementation)
|
|
105
|
-
async function copyDirectory(src, dst) {
|
|
106
|
-
await fs.mkdir(dst, { recursive: true });
|
|
107
|
-
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
108
|
-
|
|
109
|
-
for (const entry of entries) {
|
|
110
|
-
const srcPath = path.join(src, entry.name);
|
|
111
|
-
const dstPath = path.join(dst, entry.name);
|
|
112
|
-
|
|
113
|
-
if (entry.isDirectory()) {
|
|
114
|
-
await copyDirectory(srcPath, dstPath);
|
|
115
|
-
} else {
|
|
116
|
-
await fs.copyFile(srcPath, dstPath);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Copy files
|
|
122
|
-
await copyDirectory(srcDir, dstDir);
|
|
123
|
-
|
|
124
|
-
// Verify files were copied
|
|
125
|
-
const dstFiles = await fs.readdir(dstDir);
|
|
126
|
-
const expectedFiles = ['file1.txt', 'file2.py', 'config.json', 'subdir'];
|
|
127
|
-
|
|
128
|
-
let allFilesCopied = true;
|
|
129
|
-
for (const expectedFile of expectedFiles) {
|
|
130
|
-
if (!dstFiles.includes(expectedFile)) {
|
|
131
|
-
console.log(` ✗ Missing file: ${expectedFile}`);
|
|
132
|
-
allFilesCopied = false;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Check subdirectory contents
|
|
137
|
-
const subDirFiles = await fs.readdir(path.join(dstDir, 'subdir'));
|
|
138
|
-
if (!subDirFiles.includes('subfile.txt')) {
|
|
139
|
-
console.log(' ✗ Subdirectory file not copied');
|
|
140
|
-
allFilesCopied = false;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Clean up
|
|
144
|
-
await fs.rm(srcDir, { recursive: true, force: true });
|
|
145
|
-
await fs.rm(dstDir, { recursive: true, force: true });
|
|
146
|
-
|
|
147
|
-
if (allFilesCopied) {
|
|
148
|
-
console.log(' ✓ File copying works correctly');
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
this.testResults.push({
|
|
152
|
-
name: 'File Copying',
|
|
153
|
-
passed: allFilesCopied,
|
|
154
|
-
details: allFilesCopied ? 'Successfully copied all files and directories' : 'Some files not copied'
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
return allFilesCopied;
|
|
158
|
-
} catch (error) {
|
|
159
|
-
console.log(` ✗ File copying failed: ${error.message}`);
|
|
160
|
-
|
|
161
|
-
this.testResults.push({
|
|
162
|
-
name: 'File Copying',
|
|
163
|
-
passed: false,
|
|
164
|
-
details: `Failed: ${error.message}`
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Test 3: Verify installation script execution
|
|
172
|
-
async testInstallationScriptExecution() {
|
|
173
|
-
console.log('\n[TEST 3] Verifying installation script execution...');
|
|
174
|
-
|
|
175
|
-
try {
|
|
176
|
-
// Check if Python is available
|
|
177
|
-
const pythonCheck = spawn('python', ['--version']);
|
|
178
|
-
|
|
179
|
-
const pythonAvailable = await new Promise((resolve) => {
|
|
180
|
-
pythonCheck.on('close', (code) => {
|
|
181
|
-
resolve(code === 0);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
pythonCheck.on('error', () => {
|
|
185
|
-
resolve(false);
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
// Timeout after 5 seconds
|
|
189
|
-
setTimeout(() => {
|
|
190
|
-
resolve(false);
|
|
191
|
-
}, 5000);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
console.log(` Python available: ${pythonAvailable ? '✓' : '✗'}`);
|
|
195
|
-
|
|
196
|
-
this.testResults.push({
|
|
197
|
-
name: 'Installation Script Execution',
|
|
198
|
-
passed: pythonAvailable,
|
|
199
|
-
details: pythonAvailable ? 'Python is available for script execution' : 'Python not available'
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
return pythonAvailable;
|
|
203
|
-
} catch (error) {
|
|
204
|
-
console.log(` ✗ Installation script execution check failed: ${error.message}`);
|
|
205
|
-
|
|
206
|
-
this.testResults.push({
|
|
207
|
-
name: 'Installation Script Execution',
|
|
208
|
-
passed: false,
|
|
209
|
-
details: `Failed: ${error.message}`
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Test 4: Verify configuration file creation
|
|
217
|
-
async testConfigurationFileCreation() {
|
|
218
|
-
console.log('\n[TEST 4] Verifying configuration file creation...');
|
|
219
|
-
|
|
220
|
-
try {
|
|
221
|
-
// Create a temporary config file
|
|
222
|
-
const tempConfigDir = path.join(os.tmpdir(), 'stigmergy-config-test-' + Date.now());
|
|
223
|
-
await fs.mkdir(tempConfigDir, { recursive: true });
|
|
224
|
-
|
|
225
|
-
const configPath = path.join(tempConfigDir, 'test-config.yml');
|
|
226
|
-
const configContent = `
|
|
227
|
-
plugins:
|
|
228
|
-
- name: "TestPlugin"
|
|
229
|
-
enabled: true
|
|
230
|
-
config:
|
|
231
|
-
test_setting: "value"
|
|
232
|
-
`;
|
|
233
|
-
|
|
234
|
-
await fs.writeFile(configPath, configContent);
|
|
235
|
-
|
|
236
|
-
// Verify file was created and has content
|
|
237
|
-
const content = await fs.readFile(configPath, 'utf8');
|
|
238
|
-
const fileExists = content.includes('TestPlugin');
|
|
239
|
-
|
|
240
|
-
// Clean up
|
|
241
|
-
await fs.rm(tempConfigDir, { recursive: true, force: true });
|
|
242
|
-
|
|
243
|
-
if (fileExists) {
|
|
244
|
-
console.log(' ✓ Configuration file creation works correctly');
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
this.testResults.push({
|
|
248
|
-
name: 'Configuration File Creation',
|
|
249
|
-
passed: fileExists,
|
|
250
|
-
details: fileExists ? 'Successfully created configuration file' : 'Failed to create configuration file'
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
return fileExists;
|
|
254
|
-
} catch (error) {
|
|
255
|
-
console.log(` ✗ Configuration file creation failed: ${error.message}`);
|
|
256
|
-
|
|
257
|
-
this.testResults.push({
|
|
258
|
-
name: 'Configuration File Creation',
|
|
259
|
-
passed: false,
|
|
260
|
-
details: `Failed: ${error.message}`
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Run all tests
|
|
268
|
-
async runAllTests() {
|
|
269
|
-
console.log('TDD Implementation Test for deployHooks Fix');
|
|
270
|
-
console.log('='.repeat(50));
|
|
271
|
-
|
|
272
|
-
await this.testDirectoryCreation();
|
|
273
|
-
await this.testFileCopying();
|
|
274
|
-
await this.testInstallationScriptExecution();
|
|
275
|
-
await this.testConfigurationFileCreation();
|
|
276
|
-
|
|
277
|
-
// Summary
|
|
278
|
-
console.log('\n' + '='.repeat(50));
|
|
279
|
-
console.log('Implementation Test Summary:');
|
|
280
|
-
console.log('='.repeat(50));
|
|
281
|
-
|
|
282
|
-
let passedTests = 0;
|
|
283
|
-
this.testResults.forEach(result => {
|
|
284
|
-
console.log(`${result.name}: ${result.passed ? '✓ PASS' : '✗ FAIL'} - ${result.details}`);
|
|
285
|
-
if (result.passed) passedTests++;
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
console.log(`\nOverall Result: ${passedTests}/${this.testResults.length} tests passed`);
|
|
289
|
-
|
|
290
|
-
if (passedTests === this.testResults.length) {
|
|
291
|
-
console.log('✓ All implementation tests passed! Ready to implement deployHooks fix.');
|
|
292
|
-
} else if (passedTests > 0) {
|
|
293
|
-
console.log('⚠ Some implementation tests failed. Implementation may need adjustments.');
|
|
294
|
-
} else {
|
|
295
|
-
console.log('✗ All implementation tests failed. Implementation not ready.');
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return {
|
|
299
|
-
totalTests: this.testResults.length,
|
|
300
|
-
passedTests: passedTests,
|
|
301
|
-
results: this.testResults
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Run the tests
|
|
307
|
-
async function runTDDDeployFixTests() {
|
|
308
|
-
const tester = new TDDDeployFixTester();
|
|
309
|
-
const results = await tester.runAllTests();
|
|
310
|
-
return results;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// Export for use in other modules
|
|
314
|
-
module.exports = { TDDDeployFixTester };
|
|
315
|
-
|
|
316
|
-
// Run if called directly
|
|
317
|
-
if (require.main === module) {
|
|
318
|
-
runTDDDeployFixTests().then(results => {
|
|
319
|
-
process.exit(results.passedTests === results.totalTests ? 0 : 1);
|
|
320
|
-
}).catch(error => {
|
|
321
|
-
console.error('[Test Failed]:', error.message);
|
|
322
|
-
process.exit(1);
|
|
323
|
-
});
|
|
324
|
-
}
|
package/test/tdd-fixes-test.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* TDD Test Suite for Critical Issues
|
|
5
|
-
* Tests that will initially fail, then drive fixes
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const assert = require('assert');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
|
|
11
|
-
// Test 1: Tool Selection Logic
|
|
12
|
-
function testToolSelection() {
|
|
13
|
-
console.log('TEST 1: Tool Selection Logic');
|
|
14
|
-
console.log('-------------------------------');
|
|
15
|
-
|
|
16
|
-
// This test will fail initially because tool selection is broken
|
|
17
|
-
const testCases = [
|
|
18
|
-
{
|
|
19
|
-
args: ['skills', 'execute', 'translation', '--text=hello', '--to=zh', '--tool=claude'],
|
|
20
|
-
expectedTool: 'claude',
|
|
21
|
-
description: 'Should parse --tool=claude parameter'
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
args: ['skills', 'execute', 'code-analysis', '--file=app.js', '--tool=gemini'],
|
|
25
|
-
expectedTool: 'gemini',
|
|
26
|
-
description: 'Should parse --tool=gemini parameter'
|
|
27
|
-
}
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
return testCases;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Test 2: Module Import
|
|
34
|
-
function testModuleImport() {
|
|
35
|
-
console.log('TEST 2: Module Import');
|
|
36
|
-
console.log('------------------------');
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
// Use CommonJS version to fix ES6 module issues
|
|
40
|
-
const SkillsManager = require('../package/src/skills/skills-manager.cjs');
|
|
41
|
-
const manager = new SkillsManager();
|
|
42
|
-
|
|
43
|
-
assert(typeof manager.init === 'function', 'Manager should have init method');
|
|
44
|
-
assert(typeof manager.listSkills === 'function', 'Manager should have listSkills method');
|
|
45
|
-
assert(typeof manager.executeSkill === 'function', 'Manager should have executeSkill method');
|
|
46
|
-
assert(typeof manager.buildCommand === 'function', 'Manager should have buildCommand method');
|
|
47
|
-
|
|
48
|
-
console.log('✅ Module import test passed');
|
|
49
|
-
return true;
|
|
50
|
-
} catch (error) {
|
|
51
|
-
console.log(`❌ Module import test failed: ${error.message}`);
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Test 3: Skills Registry Loading
|
|
57
|
-
function testSkillsRegistryLoading() {
|
|
58
|
-
console.log('TEST 3: Skills Registry Loading');
|
|
59
|
-
console.log('---------------------------------');
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
const fs = require('fs');
|
|
63
|
-
const registryPath = path.join(__dirname, '../package/src/skills/skills/skills-registry.json');
|
|
64
|
-
|
|
65
|
-
if (!fs.existsSync(registryPath)) {
|
|
66
|
-
throw new Error(`Skills registry not found at ${registryPath}`);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
|
|
70
|
-
|
|
71
|
-
// Validate registry structure
|
|
72
|
-
assert(typeof registry === 'object', 'Registry should be an object');
|
|
73
|
-
assert(Object.keys(registry).length > 0, 'Registry should contain skills');
|
|
74
|
-
|
|
75
|
-
// Validate each skill structure
|
|
76
|
-
for (const [skillId, skill] of Object.entries(registry)) {
|
|
77
|
-
assert(skill.name, `Skill ${skillId} should have a name`);
|
|
78
|
-
assert(skill.description, `Skill ${skillId} should have a description`);
|
|
79
|
-
assert(skill.category, `Skill ${skillId} should have a category`);
|
|
80
|
-
assert(Array.isArray(skill.tools), `Skill ${skillId} should have tools array`);
|
|
81
|
-
assert(skill.template, `Skill ${skillId} should have a template`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
console.log(`✅ Skills registry test passed - ${Object.keys(registry).length} skills loaded`);
|
|
85
|
-
return true;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.log(`❌ Skills registry test failed: ${error.message}`);
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Test 4: Skills Execution
|
|
93
|
-
async function testSkillsExecution() {
|
|
94
|
-
console.log('TEST 4: Skills Execution');
|
|
95
|
-
console.log('-------------------------');
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
const SkillsManager = require('../package/src/skills/skills-manager.cjs');
|
|
99
|
-
const manager = new SkillsManager();
|
|
100
|
-
|
|
101
|
-
// Initialize manager
|
|
102
|
-
await manager.init();
|
|
103
|
-
|
|
104
|
-
// Test skill execution
|
|
105
|
-
const result = await manager.executeSkill('translation', {
|
|
106
|
-
text: 'hello world',
|
|
107
|
-
to: 'zh'
|
|
108
|
-
}, 'claude');
|
|
109
|
-
|
|
110
|
-
assert(result.skillId === 'translation', 'Should execute translation skill');
|
|
111
|
-
assert(result.tool === 'claude', 'Should use specified tool');
|
|
112
|
-
assert(result.command.includes('claude'), 'Command should include tool name');
|
|
113
|
-
assert(result.result.success, 'Execution should succeed');
|
|
114
|
-
|
|
115
|
-
console.log('✅ Skills execution test passed');
|
|
116
|
-
return true;
|
|
117
|
-
} catch (error) {
|
|
118
|
-
console.log(`❌ Skills execution test failed: ${error.message}`);
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Test 5: Parameter Parsing
|
|
124
|
-
function testParameterParsing() {
|
|
125
|
-
console.log('TEST 5: Parameter Parsing');
|
|
126
|
-
console.log('---------------------------');
|
|
127
|
-
|
|
128
|
-
const testCases = [
|
|
129
|
-
{
|
|
130
|
-
args: ['--text=hello', '--to=zh', '--tool=claude'],
|
|
131
|
-
expected: {
|
|
132
|
-
text: 'hello',
|
|
133
|
-
to: 'zh',
|
|
134
|
-
tool: 'claude'
|
|
135
|
-
},
|
|
136
|
-
description: 'Should parse key=value parameters'
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
args: ['--file', 'app.js', '--line', '10'],
|
|
140
|
-
expected: {
|
|
141
|
-
file: 'app.js',
|
|
142
|
-
line: '10'
|
|
143
|
-
},
|
|
144
|
-
description: 'Should handle space-separated parameters'
|
|
145
|
-
}
|
|
146
|
-
];
|
|
147
|
-
|
|
148
|
-
return testCases;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Main test runner
|
|
152
|
-
async function runTests() {
|
|
153
|
-
console.log('==============================================');
|
|
154
|
-
console.log('TDD DRIVEN DEVELOPMENT - CRITICAL ISSUES');
|
|
155
|
-
console.log('==============================================');
|
|
156
|
-
console.log('');
|
|
157
|
-
|
|
158
|
-
const results = [];
|
|
159
|
-
|
|
160
|
-
// Test 1: Tool selection (will be implemented in main.js)
|
|
161
|
-
console.log('Test 1: Tool Selection Logic');
|
|
162
|
-
console.log('⚠️ TODO: This test drives handleSkillsCommand fixes');
|
|
163
|
-
console.log('');
|
|
164
|
-
|
|
165
|
-
// Test 2: Module import
|
|
166
|
-
results.push(testModuleImport());
|
|
167
|
-
console.log('');
|
|
168
|
-
|
|
169
|
-
// Test 3: Skills registry
|
|
170
|
-
results.push(testSkillsRegistryLoading());
|
|
171
|
-
console.log('');
|
|
172
|
-
|
|
173
|
-
// Test 4: Skills execution
|
|
174
|
-
results.push(await testSkillsExecution());
|
|
175
|
-
console.log('');
|
|
176
|
-
|
|
177
|
-
// Test 5: Parameter parsing
|
|
178
|
-
console.log('Test 5: Parameter Parsing');
|
|
179
|
-
console.log('⚠️ TODO: This test drives parameter parsing fixes');
|
|
180
|
-
console.log('');
|
|
181
|
-
|
|
182
|
-
// Summary
|
|
183
|
-
const passed = results.filter(r => r === true).length;
|
|
184
|
-
const total = results.length;
|
|
185
|
-
|
|
186
|
-
console.log('==============================================');
|
|
187
|
-
console.log('TDD TEST SUMMARY');
|
|
188
|
-
console.log('==============================================');
|
|
189
|
-
console.log(`Tests passed: ${passed}/${total}`);
|
|
190
|
-
|
|
191
|
-
if (passed === total) {
|
|
192
|
-
console.log('🎉 All tests passed! Critical issues are fixed.');
|
|
193
|
-
} else {
|
|
194
|
-
console.log('⚠️ Some tests failed. Time to implement fixes!');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return passed === total;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Run tests if called directly
|
|
201
|
-
if (require.main === module) {
|
|
202
|
-
runTests();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
module.exports = {
|
|
206
|
-
testToolSelection,
|
|
207
|
-
testModuleImport,
|
|
208
|
-
testSkillsRegistryLoading,
|
|
209
|
-
testParameterParsing,
|
|
210
|
-
runTests
|
|
211
|
-
};
|