stigmergy 1.1.2 → 1.1.4
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 +2 -3
- package/scripts/build.js +2 -2
- package/scripts/publish.js +267 -267
- package/scripts/simple-publish.js +58 -58
- package/src/cli/router.js +49 -11
- package/src/core/coordination/nodejs/HookDeploymentManager.js +1 -1
- package/test/fibonacci.test.js +178 -0
- package/test/hook-system-integration-test.js +306 -306
- package/test/system-compatibility-test.js +1 -1
- package/test/tool-selection-integration-test.js +1 -1
- package/src/main.js +0 -1338
|
@@ -1,307 +1,307 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* TDD Test Suite for Hook System Integration
|
|
5
|
-
* Tests real integration between hooks and AI CLI tools
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const assert = require('assert');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
|
|
12
|
-
// Test 1: Hook Installation Verification
|
|
13
|
-
function testHookInstallation() {
|
|
14
|
-
console.log('TEST 1: Hook Installation Verification');
|
|
15
|
-
console.log('---------------------------------------');
|
|
16
|
-
|
|
17
|
-
const hookDirectories = [
|
|
18
|
-
'.claude/hooks',
|
|
19
|
-
'.gemini/hooks',
|
|
20
|
-
'.qwen/hooks',
|
|
21
|
-
'.iflow/hooks',
|
|
22
|
-
'.codebuddy/hooks'
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const results = [];
|
|
26
|
-
for (const hookDir of hookDirectories) {
|
|
27
|
-
const exists = fs.existsSync(hookDir);
|
|
28
|
-
results.push({ directory: hookDir, exists });
|
|
29
|
-
console.log(`${exists ? '✅' : '❌'} ${hookDir}: ${exists ? 'Found' : 'Missing'}`);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const installedCount = results.filter(r => r.exists).length;
|
|
33
|
-
console.log(`\nHook directories installed: ${installedCount}/${hookDirectories.length}`);
|
|
34
|
-
|
|
35
|
-
return installedCount === hookDirectories.length;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Test 2: Hook Content Verification
|
|
39
|
-
function testHookContentVerification() {
|
|
40
|
-
console.log('TEST 2: Hook Content Verification');
|
|
41
|
-
console.log('-----------------------------------');
|
|
42
|
-
|
|
43
|
-
const hookFiles = [
|
|
44
|
-
{ path: '.claude/hooks/skill-forced-eval-hook.sh', expectedContent: ['skill', 'natural', 'language'] },
|
|
45
|
-
{ path: '.gemini/hooks/skill-forced-eval-hook.js', expectedContent: ['skill', 'parse', 'detect'] },
|
|
46
|
-
{ path: '.qwen/hooks/skill-forced-eval-hook.py', expectedContent: ['skill', 'analysis', 'translate'] }
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
let validHooks = 0;
|
|
50
|
-
for (const hookFile of hookFiles) {
|
|
51
|
-
if (fs.existsSync(hookFile.path)) {
|
|
52
|
-
const content = fs.readFileSync(hookFile.path, 'utf8');
|
|
53
|
-
const hasRequiredContent = hookFile.expectedContent.every(keyword =>
|
|
54
|
-
content.toLowerCase().includes(keyword.toLowerCase())
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
console.log(`${hasRequiredContent ? '✅' : '❌'} ${hookFile.path}: ${hasRequiredContent ? 'Valid' : 'Invalid content'}`);
|
|
58
|
-
if (hasRequiredContent) validHooks++;
|
|
59
|
-
} else {
|
|
60
|
-
console.log(`❌ ${hookFile.path}: File not found`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.log(`\nValid hooks: ${validHooks}/${hookFiles.length}`);
|
|
65
|
-
return validHooks > 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Test 3: Hook Execution Simulation
|
|
69
|
-
function testHookExecution() {
|
|
70
|
-
console.log('TEST 3: Hook Execution Simulation');
|
|
71
|
-
console.log('------------------------------------');
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
// This will fail initially since we haven't implemented real hook integration
|
|
75
|
-
const HookIntegrationManager = require('../package/src/hooks/hook-integration-manager.cjs');
|
|
76
|
-
const hookManager = new HookIntegrationManager();
|
|
77
|
-
|
|
78
|
-
const testScenarios = [
|
|
79
|
-
{
|
|
80
|
-
tool: 'claude',
|
|
81
|
-
input: '请分析这个React组件的安全性',
|
|
82
|
-
expectedSkill: 'code-analysis'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
tool: 'gemini',
|
|
86
|
-
input: 'Translate this comment to English',
|
|
87
|
-
expectedSkill: 'translation'
|
|
88
|
-
}
|
|
89
|
-
];
|
|
90
|
-
|
|
91
|
-
let passed = 0;
|
|
92
|
-
for (const scenario of testScenarios) {
|
|
93
|
-
console.log(`Testing ${scenario.tool} hook with: "${scenario.input}"`);
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
const result = hookManager.processHookInput(scenario.tool, scenario.input);
|
|
97
|
-
|
|
98
|
-
if (result.detected && result.skill === scenario.expectedSkill) {
|
|
99
|
-
console.log(`✅ Hook correctly detected ${result.skill}`);
|
|
100
|
-
passed++;
|
|
101
|
-
} else {
|
|
102
|
-
console.log(`❌ Hook failed to detect skill (expected: ${scenario.expectedSkill})`);
|
|
103
|
-
}
|
|
104
|
-
} catch (error) {
|
|
105
|
-
console.log(`❌ Hook execution error: ${error.message}`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
console.log(`\nHook execution tests: ${passed}/${testScenarios.length} passed`);
|
|
110
|
-
return passed === testScenarios.length;
|
|
111
|
-
|
|
112
|
-
} catch (error) {
|
|
113
|
-
console.log(`❌ Hook execution test failed: ${error.message}`);
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Test 4: Character Encoding Verification
|
|
119
|
-
function testCharacterEncoding() {
|
|
120
|
-
console.log('TEST 4: Character Encoding Verification');
|
|
121
|
-
console.log('----------------------------------------');
|
|
122
|
-
|
|
123
|
-
const filesToCheck = [
|
|
124
|
-
'package/src/
|
|
125
|
-
'package/src/skills/skills-manager.js',
|
|
126
|
-
'package/src/natural-language/nl-parser.cjs',
|
|
127
|
-
'hooks/install-hooks.js'
|
|
128
|
-
];
|
|
129
|
-
|
|
130
|
-
let pureAnsiFiles = 0;
|
|
131
|
-
let problematicFiles = [];
|
|
132
|
-
|
|
133
|
-
for (const file of filesToCheck) {
|
|
134
|
-
if (fs.existsSync(file)) {
|
|
135
|
-
const content = fs.readFileSync(file, 'utf8');
|
|
136
|
-
|
|
137
|
-
// Check for non-ANSI characters (simplified check)
|
|
138
|
-
const hasNonAnsi = /[^\x00-\x7F]/.test(content);
|
|
139
|
-
|
|
140
|
-
if (!hasNonAnsi) {
|
|
141
|
-
console.log(`✅ ${file}: Pure ANSI encoding`);
|
|
142
|
-
pureAnsiFiles++;
|
|
143
|
-
} else {
|
|
144
|
-
console.log(`❌ ${file}: Contains non-ANSI characters`);
|
|
145
|
-
problematicFiles.push(file);
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
console.log(`⚠️ ${file}: File not found`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
console.log(`\nPure ANSI files: ${pureAnsiFiles}/${filesToCheck.length}`);
|
|
153
|
-
if (problematicFiles.length > 0) {
|
|
154
|
-
console.log(`Files needing encoding fixes: ${problematicFiles.join(', ')}`);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return pureAnsiFiles === filesToCheck.length;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Test 5: Real AI Tool Calling
|
|
161
|
-
async function testRealAIToolCalling() {
|
|
162
|
-
console.log('TEST 5: Real AI Tool Calling');
|
|
163
|
-
console.log('-------------------------------');
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
// This will fail initially since we haven't implemented real AI calling
|
|
167
|
-
const RealAIExecutor = require('../package/src/ai/real-executor.cjs');
|
|
168
|
-
const executor = new RealAIExecutor();
|
|
169
|
-
|
|
170
|
-
const testCalls = [
|
|
171
|
-
{
|
|
172
|
-
tool: 'claude',
|
|
173
|
-
command: '请将以下文本翻译成英文:Hello World',
|
|
174
|
-
expectedSuccess: true
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
tool: 'gemini',
|
|
178
|
-
command: '分析这个函数的复杂度',
|
|
179
|
-
expectedSuccess: true
|
|
180
|
-
}
|
|
181
|
-
];
|
|
182
|
-
|
|
183
|
-
let successful = 0;
|
|
184
|
-
for (const test of testCalls) {
|
|
185
|
-
console.log(`Testing ${test.tool} real execution...`);
|
|
186
|
-
|
|
187
|
-
try {
|
|
188
|
-
const result = await executor.executeCommand(test.tool, test.command);
|
|
189
|
-
|
|
190
|
-
if (result.success === test.expectedSuccess) {
|
|
191
|
-
console.log(`✅ ${test.tool} execution successful`);
|
|
192
|
-
successful++;
|
|
193
|
-
} else {
|
|
194
|
-
console.log(`❌ ${test.tool} execution failed (expected: ${test.expectedSuccess})`);
|
|
195
|
-
}
|
|
196
|
-
} catch (error) {
|
|
197
|
-
console.log(`❌ ${test.tool} execution error: ${error.message}`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
console.log(`\nReal AI tool calls: ${successful}/${testCalls.length} successful`);
|
|
202
|
-
return successful === testCalls.length;
|
|
203
|
-
|
|
204
|
-
} catch (error) {
|
|
205
|
-
console.log(`❌ Real AI tool calling test failed: ${error.message}`);
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Test 6: Cross-Platform Compatibility
|
|
211
|
-
function testCrossPlatformCompatibility() {
|
|
212
|
-
console.log('TEST 6: Cross-Platform Compatibility');
|
|
213
|
-
console.log('--------------------------------------');
|
|
214
|
-
|
|
215
|
-
const platform = process.platform;
|
|
216
|
-
console.log(`Current platform: ${platform}`);
|
|
217
|
-
|
|
218
|
-
// Test file paths work on current platform
|
|
219
|
-
const testPaths = [
|
|
220
|
-
'package/src/
|
|
221
|
-
'package/src/skills/skills-manager.cjs',
|
|
222
|
-
'.claude/settings.json'
|
|
223
|
-
];
|
|
224
|
-
|
|
225
|
-
let validPaths = 0;
|
|
226
|
-
for (const testPath of testPaths) {
|
|
227
|
-
const normalizedPath = path.normalize(testPath);
|
|
228
|
-
const works = fs.existsSync(normalizedPath) || !fs.existsSync(testPath);
|
|
229
|
-
|
|
230
|
-
console.log(`${works ? '✅' : '❌'} ${testPath}: ${works ? 'Valid' : 'Invalid path'}`);
|
|
231
|
-
if (works) validPaths++;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
console.log(`\nValid paths: ${validPaths}/${testPaths.length}`);
|
|
235
|
-
return validPaths === testPaths.length;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Main test runner
|
|
239
|
-
async function runTests() {
|
|
240
|
-
console.log('==============================================');
|
|
241
|
-
console.log('TDD: HOOK SYSTEM & ENCODING & REAL AI');
|
|
242
|
-
console.log('==============================================');
|
|
243
|
-
console.log('');
|
|
244
|
-
|
|
245
|
-
const results = [];
|
|
246
|
-
|
|
247
|
-
// Test 1: Hook installation
|
|
248
|
-
results.push(testHookInstallation());
|
|
249
|
-
console.log('');
|
|
250
|
-
|
|
251
|
-
// Test 2: Hook content
|
|
252
|
-
results.push(testHookContentVerification());
|
|
253
|
-
console.log('');
|
|
254
|
-
|
|
255
|
-
// Test 3: Hook execution (will fail initially)
|
|
256
|
-
results.push(testHookExecution());
|
|
257
|
-
console.log('');
|
|
258
|
-
|
|
259
|
-
// Test 4: Character encoding
|
|
260
|
-
results.push(testCharacterEncoding());
|
|
261
|
-
console.log('');
|
|
262
|
-
|
|
263
|
-
// Test 5: Real AI tool calling (will fail initially)
|
|
264
|
-
results.push(await testRealAIToolCalling());
|
|
265
|
-
console.log('');
|
|
266
|
-
|
|
267
|
-
// Test 6: Cross-platform compatibility
|
|
268
|
-
results.push(testCrossPlatformCompatibility());
|
|
269
|
-
console.log('');
|
|
270
|
-
|
|
271
|
-
// Summary
|
|
272
|
-
const passed = results.filter(r => r === true).length;
|
|
273
|
-
const total = results.length;
|
|
274
|
-
|
|
275
|
-
console.log('==============================================');
|
|
276
|
-
console.log('TDD COMPREHENSIVE TEST SUMMARY');
|
|
277
|
-
console.log('==============================================');
|
|
278
|
-
console.log(`Tests passed: ${passed}/${total}`);
|
|
279
|
-
|
|
280
|
-
if (passed === total) {
|
|
281
|
-
console.log('🎉 All tests passed! System is fully integrated and production-ready!');
|
|
282
|
-
} else {
|
|
283
|
-
console.log('⚠️ Some tests failed. Implementation needed for:');
|
|
284
|
-
console.log(' • Hook System Integration (Medium Priority)');
|
|
285
|
-
console.log(' • Character Encoding Internationalization (Low Priority)');
|
|
286
|
-
console.log(' • Real AI Tool Calling (Medium Priority)');
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return passed === total;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// Run tests if called directly
|
|
293
|
-
if (require.main === module) {
|
|
294
|
-
runTests().then(success => {
|
|
295
|
-
process.exit(success ? 0 : 1);
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
module.exports = {
|
|
300
|
-
testHookInstallation,
|
|
301
|
-
testHookContentVerification,
|
|
302
|
-
testHookExecution,
|
|
303
|
-
testCharacterEncoding,
|
|
304
|
-
testRealAIToolCalling,
|
|
305
|
-
testCrossPlatformCompatibility,
|
|
306
|
-
runTests
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TDD Test Suite for Hook System Integration
|
|
5
|
+
* Tests real integration between hooks and AI CLI tools
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const assert = require('assert');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
// Test 1: Hook Installation Verification
|
|
13
|
+
function testHookInstallation() {
|
|
14
|
+
console.log('TEST 1: Hook Installation Verification');
|
|
15
|
+
console.log('---------------------------------------');
|
|
16
|
+
|
|
17
|
+
const hookDirectories = [
|
|
18
|
+
'.claude/hooks',
|
|
19
|
+
'.gemini/hooks',
|
|
20
|
+
'.qwen/hooks',
|
|
21
|
+
'.iflow/hooks',
|
|
22
|
+
'.codebuddy/hooks'
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const results = [];
|
|
26
|
+
for (const hookDir of hookDirectories) {
|
|
27
|
+
const exists = fs.existsSync(hookDir);
|
|
28
|
+
results.push({ directory: hookDir, exists });
|
|
29
|
+
console.log(`${exists ? '✅' : '❌'} ${hookDir}: ${exists ? 'Found' : 'Missing'}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const installedCount = results.filter(r => r.exists).length;
|
|
33
|
+
console.log(`\nHook directories installed: ${installedCount}/${hookDirectories.length}`);
|
|
34
|
+
|
|
35
|
+
return installedCount === hookDirectories.length;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Test 2: Hook Content Verification
|
|
39
|
+
function testHookContentVerification() {
|
|
40
|
+
console.log('TEST 2: Hook Content Verification');
|
|
41
|
+
console.log('-----------------------------------');
|
|
42
|
+
|
|
43
|
+
const hookFiles = [
|
|
44
|
+
{ path: '.claude/hooks/skill-forced-eval-hook.sh', expectedContent: ['skill', 'natural', 'language'] },
|
|
45
|
+
{ path: '.gemini/hooks/skill-forced-eval-hook.js', expectedContent: ['skill', 'parse', 'detect'] },
|
|
46
|
+
{ path: '.qwen/hooks/skill-forced-eval-hook.py', expectedContent: ['skill', 'analysis', 'translate'] }
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
let validHooks = 0;
|
|
50
|
+
for (const hookFile of hookFiles) {
|
|
51
|
+
if (fs.existsSync(hookFile.path)) {
|
|
52
|
+
const content = fs.readFileSync(hookFile.path, 'utf8');
|
|
53
|
+
const hasRequiredContent = hookFile.expectedContent.every(keyword =>
|
|
54
|
+
content.toLowerCase().includes(keyword.toLowerCase())
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
console.log(`${hasRequiredContent ? '✅' : '❌'} ${hookFile.path}: ${hasRequiredContent ? 'Valid' : 'Invalid content'}`);
|
|
58
|
+
if (hasRequiredContent) validHooks++;
|
|
59
|
+
} else {
|
|
60
|
+
console.log(`❌ ${hookFile.path}: File not found`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log(`\nValid hooks: ${validHooks}/${hookFiles.length}`);
|
|
65
|
+
return validHooks > 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Test 3: Hook Execution Simulation
|
|
69
|
+
function testHookExecution() {
|
|
70
|
+
console.log('TEST 3: Hook Execution Simulation');
|
|
71
|
+
console.log('------------------------------------');
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
// This will fail initially since we haven't implemented real hook integration
|
|
75
|
+
const HookIntegrationManager = require('../package/src/hooks/hook-integration-manager.cjs');
|
|
76
|
+
const hookManager = new HookIntegrationManager();
|
|
77
|
+
|
|
78
|
+
const testScenarios = [
|
|
79
|
+
{
|
|
80
|
+
tool: 'claude',
|
|
81
|
+
input: '请分析这个React组件的安全性',
|
|
82
|
+
expectedSkill: 'code-analysis'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
tool: 'gemini',
|
|
86
|
+
input: 'Translate this comment to English',
|
|
87
|
+
expectedSkill: 'translation'
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
let passed = 0;
|
|
92
|
+
for (const scenario of testScenarios) {
|
|
93
|
+
console.log(`Testing ${scenario.tool} hook with: "${scenario.input}"`);
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
const result = hookManager.processHookInput(scenario.tool, scenario.input);
|
|
97
|
+
|
|
98
|
+
if (result.detected && result.skill === scenario.expectedSkill) {
|
|
99
|
+
console.log(`✅ Hook correctly detected ${result.skill}`);
|
|
100
|
+
passed++;
|
|
101
|
+
} else {
|
|
102
|
+
console.log(`❌ Hook failed to detect skill (expected: ${scenario.expectedSkill})`);
|
|
103
|
+
}
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.log(`❌ Hook execution error: ${error.message}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
console.log(`\nHook execution tests: ${passed}/${testScenarios.length} passed`);
|
|
110
|
+
return passed === testScenarios.length;
|
|
111
|
+
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.log(`❌ Hook execution test failed: ${error.message}`);
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Test 4: Character Encoding Verification
|
|
119
|
+
function testCharacterEncoding() {
|
|
120
|
+
console.log('TEST 4: Character Encoding Verification');
|
|
121
|
+
console.log('----------------------------------------');
|
|
122
|
+
|
|
123
|
+
const filesToCheck = [
|
|
124
|
+
'package/src/index.js',
|
|
125
|
+
'package/src/skills/skills-manager.js',
|
|
126
|
+
'package/src/natural-language/nl-parser.cjs',
|
|
127
|
+
'hooks/install-hooks.js'
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
let pureAnsiFiles = 0;
|
|
131
|
+
let problematicFiles = [];
|
|
132
|
+
|
|
133
|
+
for (const file of filesToCheck) {
|
|
134
|
+
if (fs.existsSync(file)) {
|
|
135
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
136
|
+
|
|
137
|
+
// Check for non-ANSI characters (simplified check)
|
|
138
|
+
const hasNonAnsi = /[^\x00-\x7F]/.test(content);
|
|
139
|
+
|
|
140
|
+
if (!hasNonAnsi) {
|
|
141
|
+
console.log(`✅ ${file}: Pure ANSI encoding`);
|
|
142
|
+
pureAnsiFiles++;
|
|
143
|
+
} else {
|
|
144
|
+
console.log(`❌ ${file}: Contains non-ANSI characters`);
|
|
145
|
+
problematicFiles.push(file);
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
console.log(`⚠️ ${file}: File not found`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
console.log(`\nPure ANSI files: ${pureAnsiFiles}/${filesToCheck.length}`);
|
|
153
|
+
if (problematicFiles.length > 0) {
|
|
154
|
+
console.log(`Files needing encoding fixes: ${problematicFiles.join(', ')}`);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return pureAnsiFiles === filesToCheck.length;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Test 5: Real AI Tool Calling
|
|
161
|
+
async function testRealAIToolCalling() {
|
|
162
|
+
console.log('TEST 5: Real AI Tool Calling');
|
|
163
|
+
console.log('-------------------------------');
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
// This will fail initially since we haven't implemented real AI calling
|
|
167
|
+
const RealAIExecutor = require('../package/src/ai/real-executor.cjs');
|
|
168
|
+
const executor = new RealAIExecutor();
|
|
169
|
+
|
|
170
|
+
const testCalls = [
|
|
171
|
+
{
|
|
172
|
+
tool: 'claude',
|
|
173
|
+
command: '请将以下文本翻译成英文:Hello World',
|
|
174
|
+
expectedSuccess: true
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
tool: 'gemini',
|
|
178
|
+
command: '分析这个函数的复杂度',
|
|
179
|
+
expectedSuccess: true
|
|
180
|
+
}
|
|
181
|
+
];
|
|
182
|
+
|
|
183
|
+
let successful = 0;
|
|
184
|
+
for (const test of testCalls) {
|
|
185
|
+
console.log(`Testing ${test.tool} real execution...`);
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
const result = await executor.executeCommand(test.tool, test.command);
|
|
189
|
+
|
|
190
|
+
if (result.success === test.expectedSuccess) {
|
|
191
|
+
console.log(`✅ ${test.tool} execution successful`);
|
|
192
|
+
successful++;
|
|
193
|
+
} else {
|
|
194
|
+
console.log(`❌ ${test.tool} execution failed (expected: ${test.expectedSuccess})`);
|
|
195
|
+
}
|
|
196
|
+
} catch (error) {
|
|
197
|
+
console.log(`❌ ${test.tool} execution error: ${error.message}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
console.log(`\nReal AI tool calls: ${successful}/${testCalls.length} successful`);
|
|
202
|
+
return successful === testCalls.length;
|
|
203
|
+
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.log(`❌ Real AI tool calling test failed: ${error.message}`);
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Test 6: Cross-Platform Compatibility
|
|
211
|
+
function testCrossPlatformCompatibility() {
|
|
212
|
+
console.log('TEST 6: Cross-Platform Compatibility');
|
|
213
|
+
console.log('--------------------------------------');
|
|
214
|
+
|
|
215
|
+
const platform = process.platform;
|
|
216
|
+
console.log(`Current platform: ${platform}`);
|
|
217
|
+
|
|
218
|
+
// Test file paths work on current platform
|
|
219
|
+
const testPaths = [
|
|
220
|
+
'package/src/index.js',
|
|
221
|
+
'package/src/skills/skills-manager.cjs',
|
|
222
|
+
'.claude/settings.json'
|
|
223
|
+
];
|
|
224
|
+
|
|
225
|
+
let validPaths = 0;
|
|
226
|
+
for (const testPath of testPaths) {
|
|
227
|
+
const normalizedPath = path.normalize(testPath);
|
|
228
|
+
const works = fs.existsSync(normalizedPath) || !fs.existsSync(testPath);
|
|
229
|
+
|
|
230
|
+
console.log(`${works ? '✅' : '❌'} ${testPath}: ${works ? 'Valid' : 'Invalid path'}`);
|
|
231
|
+
if (works) validPaths++;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
console.log(`\nValid paths: ${validPaths}/${testPaths.length}`);
|
|
235
|
+
return validPaths === testPaths.length;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Main test runner
|
|
239
|
+
async function runTests() {
|
|
240
|
+
console.log('==============================================');
|
|
241
|
+
console.log('TDD: HOOK SYSTEM & ENCODING & REAL AI');
|
|
242
|
+
console.log('==============================================');
|
|
243
|
+
console.log('');
|
|
244
|
+
|
|
245
|
+
const results = [];
|
|
246
|
+
|
|
247
|
+
// Test 1: Hook installation
|
|
248
|
+
results.push(testHookInstallation());
|
|
249
|
+
console.log('');
|
|
250
|
+
|
|
251
|
+
// Test 2: Hook content
|
|
252
|
+
results.push(testHookContentVerification());
|
|
253
|
+
console.log('');
|
|
254
|
+
|
|
255
|
+
// Test 3: Hook execution (will fail initially)
|
|
256
|
+
results.push(testHookExecution());
|
|
257
|
+
console.log('');
|
|
258
|
+
|
|
259
|
+
// Test 4: Character encoding
|
|
260
|
+
results.push(testCharacterEncoding());
|
|
261
|
+
console.log('');
|
|
262
|
+
|
|
263
|
+
// Test 5: Real AI tool calling (will fail initially)
|
|
264
|
+
results.push(await testRealAIToolCalling());
|
|
265
|
+
console.log('');
|
|
266
|
+
|
|
267
|
+
// Test 6: Cross-platform compatibility
|
|
268
|
+
results.push(testCrossPlatformCompatibility());
|
|
269
|
+
console.log('');
|
|
270
|
+
|
|
271
|
+
// Summary
|
|
272
|
+
const passed = results.filter(r => r === true).length;
|
|
273
|
+
const total = results.length;
|
|
274
|
+
|
|
275
|
+
console.log('==============================================');
|
|
276
|
+
console.log('TDD COMPREHENSIVE TEST SUMMARY');
|
|
277
|
+
console.log('==============================================');
|
|
278
|
+
console.log(`Tests passed: ${passed}/${total}`);
|
|
279
|
+
|
|
280
|
+
if (passed === total) {
|
|
281
|
+
console.log('🎉 All tests passed! System is fully integrated and production-ready!');
|
|
282
|
+
} else {
|
|
283
|
+
console.log('⚠️ Some tests failed. Implementation needed for:');
|
|
284
|
+
console.log(' • Hook System Integration (Medium Priority)');
|
|
285
|
+
console.log(' • Character Encoding Internationalization (Low Priority)');
|
|
286
|
+
console.log(' • Real AI Tool Calling (Medium Priority)');
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return passed === total;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Run tests if called directly
|
|
293
|
+
if (require.main === module) {
|
|
294
|
+
runTests().then(success => {
|
|
295
|
+
process.exit(success ? 0 : 1);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
module.exports = {
|
|
300
|
+
testHookInstallation,
|
|
301
|
+
testHookContentVerification,
|
|
302
|
+
testHookExecution,
|
|
303
|
+
testCharacterEncoding,
|
|
304
|
+
testRealAIToolCalling,
|
|
305
|
+
testCrossPlatformCompatibility,
|
|
306
|
+
runTests
|
|
307
307
|
};
|
|
@@ -77,7 +77,7 @@ async function testToolSelectionIntegration() {
|
|
|
77
77
|
|
|
78
78
|
for (const testCase of testCases) {
|
|
79
79
|
console.log(`${testCase.name}`);
|
|
80
|
-
console.log(`Command: node package/src/
|
|
80
|
+
console.log(`Command: node package/src/index.js ${testCase.args.join(' ')}`);
|
|
81
81
|
|
|
82
82
|
try {
|
|
83
83
|
const result = await runCommand(testCase.args);
|