stigmergy 1.0.68 → 1.0.70
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/README.en.md +306 -300
- package/README.md +469 -301
- package/package.json +97 -81
- package/scripts/publish.js +268 -0
- package/scripts/simple-publish.js +59 -0
- package/src/index.js +12 -0
- package/test/enhanced-main-alignment.test.js +298 -0
- package/test/hook-system-integration-test.js +307 -0
- package/test/natural-language-skills-test.js +320 -0
- package/test/nl-integration-test.js +179 -0
- package/test/parameter-parsing-test.js +143 -0
- package/test/real-test.js +435 -0
- package/test/system-compatibility-test.js +447 -0
- package/test/tdd-fixes-test.js +211 -0
- package/test/third-party-skills-test.js +321 -0
- package/test/tool-selection-integration-test.js +157 -0
- package/test/unit/cli-scanner.test.js +291 -0
- package/test/unit/cross-cli-executor.test.js +399 -0
- package/src/adapters/claude/__init__.py +0 -13
- package/src/adapters/claude/claude_skills_integration.py +0 -609
- package/src/adapters/claude/hook_adapter.py +0 -663
- package/src/adapters/claude/install_claude_integration.py +0 -265
- package/src/adapters/claude/skills_hook_adapter.py +0 -841
- package/src/adapters/claude/standalone_claude_adapter.py +0 -384
- package/src/adapters/cline/__init__.py +0 -20
- package/src/adapters/cline/config.py +0 -108
- package/src/adapters/cline/install_cline_integration.py +0 -617
- package/src/adapters/cline/mcp_server.py +0 -713
- package/src/adapters/cline/standalone_cline_adapter.py +0 -459
- package/src/adapters/codebuddy/__init__.py +0 -13
- package/src/adapters/codebuddy/buddy_adapter.py +0 -1125
- package/src/adapters/codebuddy/install_codebuddy_integration.py +0 -279
- package/src/adapters/codebuddy/skills_hook_adapter.py +0 -672
- package/src/adapters/codebuddy/skills_integration.py +0 -395
- package/src/adapters/codebuddy/standalone_codebuddy_adapter.py +0 -403
- package/src/adapters/codex/__init__.py +0 -11
- package/src/adapters/codex/base.py +0 -46
- package/src/adapters/codex/install_codex_integration.py +0 -311
- package/src/adapters/codex/mcp_server.py +0 -493
- package/src/adapters/codex/natural_language_parser.py +0 -82
- package/src/adapters/codex/slash_command_adapter.py +0 -326
- package/src/adapters/codex/standalone_codex_adapter.py +0 -362
- package/src/adapters/copilot/__init__.py +0 -13
- package/src/adapters/copilot/install_copilot_integration.py +0 -564
- package/src/adapters/copilot/mcp_adapter.py +0 -772
- package/src/adapters/copilot/mcp_server.py +0 -168
- package/src/adapters/copilot/standalone_copilot_adapter.py +0 -114
- package/src/adapters/gemini/__init__.py +0 -13
- package/src/adapters/gemini/extension_adapter.py +0 -690
- package/src/adapters/gemini/install_gemini_integration.py +0 -257
- package/src/adapters/gemini/standalone_gemini_adapter.py +0 -366
- package/src/adapters/iflow/__init__.py +0 -7
- package/src/adapters/iflow/hook_adapter.py +0 -1038
- package/src/adapters/iflow/hook_installer.py +0 -536
- package/src/adapters/iflow/install_iflow_integration.py +0 -271
- package/src/adapters/iflow/official_hook_adapter.py +0 -1272
- package/src/adapters/iflow/standalone_iflow_adapter.py +0 -48
- package/src/adapters/iflow/workflow_adapter.py +0 -793
- package/src/adapters/qoder/hook_installer.py +0 -732
- package/src/adapters/qoder/install_qoder_integration.py +0 -265
- package/src/adapters/qoder/notification_hook_adapter.py +0 -863
- package/src/adapters/qoder/standalone_qoder_adapter.py +0 -48
- package/src/adapters/qwen/__init__.py +0 -17
- package/src/adapters/qwencode/__init__.py +0 -13
- package/src/adapters/qwencode/inheritance_adapter.py +0 -818
- package/src/adapters/qwencode/install_qwencode_integration.py +0 -276
- package/src/adapters/qwencode/standalone_qwencode_adapter.py +0 -399
- package/src/atomic_collaboration_handler.py +0 -461
- package/src/cli_collaboration_agent.py +0 -697
- package/src/collaboration/hooks.py +0 -315
- package/src/core/__init__.py +0 -21
- package/src/core/ai_environment_scanner.py +0 -331
- package/src/core/base_adapter.py +0 -220
- package/src/core/cli_hook_integration.py +0 -406
- package/src/core/cross_cli_executor.py +0 -713
- package/src/core/cross_cli_mapping.py +0 -1165
- package/src/core/cross_platform_encoding.py +0 -365
- package/src/core/cross_platform_safe_cli.py +0 -894
- package/src/core/direct_cli_executor.py +0 -805
- package/src/core/direct_cli_hook_system.py +0 -958
- package/src/core/enhanced_init_processor.py +0 -467
- package/src/core/graceful_cli_executor.py +0 -912
- package/src/core/md_enhancer.py +0 -342
- package/src/core/md_generator.py +0 -619
- package/src/core/models.py +0 -218
- package/src/core/parser.py +0 -108
- package/src/core/real_cli_hook_system.py +0 -852
- package/src/core/real_cross_cli_system.py +0 -925
- package/src/core/verified_cross_cli_system.py +0 -961
- package/src/deploy.js +0 -737
- package/src/enhanced-main.js +0 -626
- package/src/enhanced_deploy.js +0 -303
- package/src/enhanced_universal_cli_setup.py +0 -930
- package/src/kimi_wrapper.py +0 -104
- package/src/main.js +0 -1309
- package/src/shell_integration.py +0 -398
- package/src/simple-main.js +0 -315
- package/src/smart_router_creator.py +0 -323
- package/src/universal_cli_setup.py +0 -1289
- package/src/utils/__init__.py +0 -12
- package/src/utils/cli_detector.py +0 -445
- package/src/utils/file_utils.py +0 -246
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TDD Test Suite for Natural Language Skills Calling
|
|
5
|
+
* Tests natural language parsing and skill mapping functionality
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const assert = require('assert');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Test scenarios for natural language to skills mapping
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// Test 1: Translation skill detection patterns
|
|
15
|
+
function testTranslationSkillDetection() {
|
|
16
|
+
console.log('TEST 1: Translation Skill Detection');
|
|
17
|
+
console.log('-----------------------------------');
|
|
18
|
+
|
|
19
|
+
const testCases = [
|
|
20
|
+
{
|
|
21
|
+
input: "请帮我把这段中文翻译成英文",
|
|
22
|
+
expectedSkill: 'translation',
|
|
23
|
+
expectedParams: { to: 'en', text: '这段中文' },
|
|
24
|
+
description: 'Chinese to English translation'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
input: "Translate this code comment to Spanish",
|
|
28
|
+
expectedSkill: 'translation',
|
|
29
|
+
expectedParams: { to: 'es', text: 'this code comment' },
|
|
30
|
+
description: 'English to Spanish translation'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
input: "能把这段说明翻译成日语吗?",
|
|
34
|
+
expectedSkill: 'translation',
|
|
35
|
+
expectedParams: { to: 'ja', text: '这段说明' },
|
|
36
|
+
description: 'Chinese to Japanese translation'
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
return testCases;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Test 2: Code analysis skill detection patterns
|
|
44
|
+
function testCodeAnalysisSkillDetection() {
|
|
45
|
+
console.log('TEST 2: Code Analysis Skill Detection');
|
|
46
|
+
console.log('--------------------------------------');
|
|
47
|
+
|
|
48
|
+
const testCases = [
|
|
49
|
+
{
|
|
50
|
+
input: "请分析这个React组件的安全性",
|
|
51
|
+
expectedSkill: 'code-analysis',
|
|
52
|
+
expectedParams: { focus: 'security', file: 'React组件' },
|
|
53
|
+
description: 'React component security analysis'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
input: "Can you analyze the performance of this algorithm?",
|
|
57
|
+
expectedSkill: 'code-analysis',
|
|
58
|
+
expectedParams: { focus: 'performance', file: 'this algorithm' },
|
|
59
|
+
description: 'Algorithm performance analysis'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
input: "检查一下这段代码有没有bug",
|
|
63
|
+
expectedSkill: 'code-analysis',
|
|
64
|
+
expectedParams: { focus: 'bugs', file: '这段代码' },
|
|
65
|
+
description: 'Bug detection in code'
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
return testCases;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Test 3: Code generation skill detection patterns
|
|
73
|
+
function testCodeGenerationSkillDetection() {
|
|
74
|
+
console.log('TEST 3: Code Generation Skill Detection');
|
|
75
|
+
console.log('----------------------------------------');
|
|
76
|
+
|
|
77
|
+
const testCases = [
|
|
78
|
+
{
|
|
79
|
+
input: "请生成一个用户登录的Python代码",
|
|
80
|
+
expectedSkill: 'code-generation',
|
|
81
|
+
expectedParams: { requirement: '用户登录', language: 'python' },
|
|
82
|
+
description: 'Python login code generation'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
input: "帮我写一个React的用户认证组件",
|
|
86
|
+
expectedSkill: 'code-generation',
|
|
87
|
+
expectedParams: { requirement: '用户认证组件', framework: 'react' },
|
|
88
|
+
description: 'React authentication component'
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
return testCases;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Test 4: Documentation skill detection patterns
|
|
96
|
+
function testDocumentationSkillDetection() {
|
|
97
|
+
console.log('TEST 4: Documentation Skill Detection');
|
|
98
|
+
console.log('-------------------------------------');
|
|
99
|
+
|
|
100
|
+
const testCases = [
|
|
101
|
+
{
|
|
102
|
+
input: "请为这个API生成文档",
|
|
103
|
+
expectedSkill: 'documentation',
|
|
104
|
+
expectedParams: { target: 'API', format: 'markdown' },
|
|
105
|
+
description: 'API documentation generation'
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
input: "帮我把这个函数写个注释",
|
|
109
|
+
expectedSkill: 'documentation',
|
|
110
|
+
expectedParams: { target: '函数', format: 'comments' },
|
|
111
|
+
description: 'Function comments generation'
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
return testCases;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Test 5: Natural Language Parser Implementation (will fail initially)
|
|
119
|
+
function testNaturalLanguageParser() {
|
|
120
|
+
console.log('TEST 5: Natural Language Parser');
|
|
121
|
+
console.log('---------------------------------');
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
// This will fail initially since we haven't implemented it yet
|
|
125
|
+
const NaturalLanguageParser = require('../package/src/natural-language/nl-parser.cjs');
|
|
126
|
+
const parser = new NaturalLanguageParser();
|
|
127
|
+
|
|
128
|
+
const testInput = "请帮我把这段代码翻译成英文";
|
|
129
|
+
const result = parser.parse(testInput);
|
|
130
|
+
|
|
131
|
+
assert(result.skill === 'translation', 'Should detect translation skill');
|
|
132
|
+
assert(result.parameters.to === 'en', 'Should detect target language');
|
|
133
|
+
assert(result.parameters.text, 'Should extract text to translate');
|
|
134
|
+
|
|
135
|
+
console.log('✅ Natural language parser test passed');
|
|
136
|
+
return true;
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.log(`❌ Natural language parser test failed: ${error.message}`);
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Test 6: Skill mapping accuracy
|
|
144
|
+
function testSkillMappingAccuracy() {
|
|
145
|
+
console.log('TEST 6: Skill Mapping Accuracy');
|
|
146
|
+
console.log('--------------------------------');
|
|
147
|
+
|
|
148
|
+
const accuracyTests = [
|
|
149
|
+
{
|
|
150
|
+
inputs: [
|
|
151
|
+
"翻译这段文字",
|
|
152
|
+
"translate this text",
|
|
153
|
+
"把这个翻译成英文",
|
|
154
|
+
"Can you translate this to French?"
|
|
155
|
+
],
|
|
156
|
+
expectedSkill: 'translation',
|
|
157
|
+
description: 'Translation keyword variations'
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
inputs: [
|
|
161
|
+
"分析这个代码",
|
|
162
|
+
"analyze this security issue",
|
|
163
|
+
"检查性能",
|
|
164
|
+
"review this code"
|
|
165
|
+
],
|
|
166
|
+
expectedSkill: 'code-analysis',
|
|
167
|
+
description: 'Analysis keyword variations'
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
inputs: [
|
|
171
|
+
"生成代码",
|
|
172
|
+
"write a function",
|
|
173
|
+
"create a component",
|
|
174
|
+
"实现一个功能"
|
|
175
|
+
],
|
|
176
|
+
expectedSkill: 'code-generation',
|
|
177
|
+
description: 'Generation keyword variations'
|
|
178
|
+
}
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
return accuracyTests;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Test 7: Context-aware parameter extraction
|
|
185
|
+
function testContextAwareParameterExtraction() {
|
|
186
|
+
console.log('TEST 7: Context-Aware Parameter Extraction');
|
|
187
|
+
console.log('--------------------------------------------');
|
|
188
|
+
|
|
189
|
+
const extractionTests = [
|
|
190
|
+
{
|
|
191
|
+
input: "把这个React组件的性能优化一下",
|
|
192
|
+
expectedParams: {
|
|
193
|
+
framework: 'react',
|
|
194
|
+
focus: 'performance',
|
|
195
|
+
target: '组件'
|
|
196
|
+
},
|
|
197
|
+
description: 'React performance optimization parameters'
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
input: "请为这个Python API生成安全文档",
|
|
201
|
+
expectedParams: {
|
|
202
|
+
language: 'python',
|
|
203
|
+
target: 'API',
|
|
204
|
+
focus: 'security',
|
|
205
|
+
type: 'documentation'
|
|
206
|
+
},
|
|
207
|
+
description: 'Python API security documentation'
|
|
208
|
+
}
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
return extractionTests;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Test runner
|
|
215
|
+
function runTests() {
|
|
216
|
+
console.log('==============================================');
|
|
217
|
+
console.log('TDD: NATURAL LANGUAGE SKILLS CALLING');
|
|
218
|
+
console.log('==============================================');
|
|
219
|
+
console.log('');
|
|
220
|
+
|
|
221
|
+
const results = [];
|
|
222
|
+
|
|
223
|
+
// Show test scenarios (will drive implementation)
|
|
224
|
+
console.log('📝 TEST SCENARIOS TO IMPLEMENT:');
|
|
225
|
+
console.log('');
|
|
226
|
+
|
|
227
|
+
// Test 1: Translation patterns
|
|
228
|
+
const translationTests = testTranslationSkillDetection();
|
|
229
|
+
console.log('1. Translation Skill Detection:');
|
|
230
|
+
translationTests.forEach(test => {
|
|
231
|
+
console.log(` Input: "${test.input}"`);
|
|
232
|
+
console.log(` Expected: ${test.expectedSkill} with params ${JSON.stringify(test.expectedParams)}`);
|
|
233
|
+
console.log('');
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// Test 2: Analysis patterns
|
|
237
|
+
const analysisTests = testCodeAnalysisSkillDetection();
|
|
238
|
+
console.log('2. Code Analysis Skill Detection:');
|
|
239
|
+
analysisTests.forEach(test => {
|
|
240
|
+
console.log(` Input: "${test.input}"`);
|
|
241
|
+
console.log(` Expected: ${test.expectedSkill} with params ${JSON.stringify(test.expectedParams)}`);
|
|
242
|
+
console.log('');
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// Test 3: Generation patterns
|
|
246
|
+
const generationTests = testCodeGenerationSkillDetection();
|
|
247
|
+
console.log('3. Code Generation Skill Detection:');
|
|
248
|
+
generationTests.forEach(test => {
|
|
249
|
+
console.log(` Input: "${test.input}"`);
|
|
250
|
+
console.log(` Expected: ${test.expectedSkill} with params ${JSON.stringify(test.expectedParams)}`);
|
|
251
|
+
console.log('');
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// Test 4: Documentation patterns
|
|
255
|
+
const documentationTests = testDocumentationSkillDetection();
|
|
256
|
+
console.log('4. Documentation Skill Detection:');
|
|
257
|
+
documentationTests.forEach(test => {
|
|
258
|
+
console.log(` Input: "${test.input}"`);
|
|
259
|
+
console.log(` Expected: ${test.expectedSkill} with params ${JSON.stringify(test.expectedParams)}`);
|
|
260
|
+
console.log('');
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// Test 5: Parser implementation (will fail initially)
|
|
264
|
+
results.push(testNaturalLanguageParser());
|
|
265
|
+
console.log('');
|
|
266
|
+
|
|
267
|
+
// Test 6: Accuracy tests
|
|
268
|
+
const accuracyTests = testSkillMappingAccuracy();
|
|
269
|
+
console.log('6. Skill Mapping Accuracy Tests:');
|
|
270
|
+
accuracyTests.forEach(test => {
|
|
271
|
+
console.log(` ${test.description}:`);
|
|
272
|
+
test.inputs.forEach(input => {
|
|
273
|
+
console.log(` - "${input}" → should map to ${test.expectedSkill}`);
|
|
274
|
+
});
|
|
275
|
+
console.log('');
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// Test 7: Context extraction
|
|
279
|
+
const extractionTests = testContextAwareParameterExtraction();
|
|
280
|
+
console.log('7. Context-Aware Parameter Extraction:');
|
|
281
|
+
extractionTests.forEach(test => {
|
|
282
|
+
console.log(` Input: "${test.input}"`);
|
|
283
|
+
console.log(` Expected params: ${JSON.stringify(test.expectedParams)}`);
|
|
284
|
+
console.log('');
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// Summary
|
|
288
|
+
const passed = results.filter(r => r === true).length;
|
|
289
|
+
const total = results.length;
|
|
290
|
+
|
|
291
|
+
console.log('==============================================');
|
|
292
|
+
console.log('TDD TEST SUMMARY');
|
|
293
|
+
console.log('==============================================');
|
|
294
|
+
console.log(`Parser tests passed: ${passed}/${total}`);
|
|
295
|
+
console.log('');
|
|
296
|
+
|
|
297
|
+
if (passed === total) {
|
|
298
|
+
console.log('🎉 All tests passed! Natural language skills calling is ready.');
|
|
299
|
+
} else {
|
|
300
|
+
console.log('⚠️ Parser implementation needed. Time to implement based on these test scenarios!');
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return passed === total;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Run tests if called directly
|
|
307
|
+
if (require.main === module) {
|
|
308
|
+
runTests();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
module.exports = {
|
|
312
|
+
testTranslationSkillDetection,
|
|
313
|
+
testCodeAnalysisSkillDetection,
|
|
314
|
+
testCodeGenerationSkillDetection,
|
|
315
|
+
testDocumentationSkillDetection,
|
|
316
|
+
testNaturalLanguageParser,
|
|
317
|
+
testSkillMappingAccuracy,
|
|
318
|
+
testContextAwareParameterExtraction,
|
|
319
|
+
runTests
|
|
320
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TDD Test for Natural Language Integration
|
|
5
|
+
* Tests the integration between natural language parsing and CLI tools
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const assert = require('assert');
|
|
9
|
+
|
|
10
|
+
async function testNaturalLanguageIntegration() {
|
|
11
|
+
console.log('TEST: Natural Language Integration');
|
|
12
|
+
console.log('----------------------------------');
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const NaturalLanguageIntegration = require('../package/src/natural-language/nl-integration.cjs');
|
|
16
|
+
const integration = new NaturalLanguageIntegration();
|
|
17
|
+
|
|
18
|
+
// Test 1: Basic natural language processing
|
|
19
|
+
console.log('Test 1: Basic natural language processing');
|
|
20
|
+
const result1 = await integration.processNaturalLanguageInput("请帮我把这段中文翻译成英文", "claude");
|
|
21
|
+
|
|
22
|
+
assert(result1.success === true, 'Should successfully process translation request');
|
|
23
|
+
assert(result1.skill === 'translation', 'Should detect translation skill');
|
|
24
|
+
assert(result1.parameters.to === 'en', 'Should detect target language');
|
|
25
|
+
console.log('✅ Basic natural language processing test passed');
|
|
26
|
+
|
|
27
|
+
// Test 2: Multi-language support
|
|
28
|
+
console.log('Test 2: Multi-language support');
|
|
29
|
+
const result2 = await integration.processNaturalLanguageInput("Analyze the security of this React component", "gemini");
|
|
30
|
+
|
|
31
|
+
assert(result2.success === true, 'Should process English input');
|
|
32
|
+
assert(result2.skill === 'code-analysis', 'Should detect code analysis skill');
|
|
33
|
+
assert(result2.parameters.focus === 'security', 'Should detect security focus');
|
|
34
|
+
console.log('✅ Multi-language support test passed');
|
|
35
|
+
|
|
36
|
+
// Test 3: Skill detection confidence
|
|
37
|
+
console.log('Test 3: Skill detection confidence');
|
|
38
|
+
const result3 = await integration.processNaturalLanguageInput("Generate Python code for user login", "qwen");
|
|
39
|
+
|
|
40
|
+
assert(result3.confidence > 5, 'Should have high confidence for clear patterns');
|
|
41
|
+
assert(result3.parameters.language === 'python', 'Should extract programming language');
|
|
42
|
+
console.log('✅ Skill detection confidence test passed');
|
|
43
|
+
|
|
44
|
+
// Test 4: Hook response creation
|
|
45
|
+
console.log('Test 4: Hook response creation');
|
|
46
|
+
const hookResponse = integration.createHookResponse("translate this to Spanish", "claude");
|
|
47
|
+
|
|
48
|
+
assert(hookResponse.shouldIntercept === true, 'Should intercept skill requests');
|
|
49
|
+
assert(hookResponse.skill === 'translation', 'Should identify correct skill');
|
|
50
|
+
assert(hookResponse.options.includes('execute_skill'), 'Should provide execution option');
|
|
51
|
+
console.log('✅ Hook response creation test passed');
|
|
52
|
+
|
|
53
|
+
// Test 5: CLI command processing
|
|
54
|
+
console.log('Test 5: CLI command processing');
|
|
55
|
+
const cliResult = await integration.processCliCommand(['analyze', 'this', 'code', 'for', 'security'], 'gemini');
|
|
56
|
+
|
|
57
|
+
assert(cliResult.success === true, 'Should process CLI command successfully');
|
|
58
|
+
assert(cliResult.skill === 'code-analysis', 'Should detect skill from CLI args');
|
|
59
|
+
console.log('✅ CLI command processing test passed');
|
|
60
|
+
|
|
61
|
+
// Test 6: Help message generation
|
|
62
|
+
console.log('Test 6: Help message generation');
|
|
63
|
+
const helpMessage = integration.createEnhancedHelp('claude');
|
|
64
|
+
|
|
65
|
+
assert(helpMessage.includes('Natural Language Skills'), 'Should include integration info');
|
|
66
|
+
assert(helpMessage.includes('translate'), 'Should include translation examples');
|
|
67
|
+
console.log('✅ Help message generation test passed');
|
|
68
|
+
|
|
69
|
+
console.log('✅ Natural language integration test passed');
|
|
70
|
+
return true;
|
|
71
|
+
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.log(`❌ Natural language integration test failed: ${error.message}`);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function testEndToEndScenarios() {
|
|
79
|
+
console.log('TEST: End-to-End Natural Language Scenarios');
|
|
80
|
+
console.log('---------------------------------------------');
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
const NaturalLanguageIntegration = require('../package/src/natural-language/nl-integration.cjs');
|
|
84
|
+
const integration = new NaturalLanguageIntegration();
|
|
85
|
+
|
|
86
|
+
const scenarios = [
|
|
87
|
+
{
|
|
88
|
+
name: 'Chinese to English Translation',
|
|
89
|
+
input: '请帮我把这段API文档翻译成英文',
|
|
90
|
+
expectedSkill: 'translation',
|
|
91
|
+
expectedParams: { to: 'en', text: '这段API文档' }
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'React Component Analysis',
|
|
95
|
+
input: '分析这个React组件的性能问题',
|
|
96
|
+
expectedSkill: 'code-analysis',
|
|
97
|
+
expectedParams: { focus: 'performance', file: 'React组件' }
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'Python Code Generation',
|
|
101
|
+
input: '生成一个用户认证的Python函数',
|
|
102
|
+
expectedSkill: 'code-generation',
|
|
103
|
+
expectedParams: { requirement: '用户认证函数', language: 'python' }
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
let passed = 0;
|
|
108
|
+
for (const scenario of scenarios) {
|
|
109
|
+
console.log(`\nTesting scenario: ${scenario.name}`);
|
|
110
|
+
console.log(`Input: "${scenario.input}"`);
|
|
111
|
+
|
|
112
|
+
const result = await integration.processNaturalLanguageInput(scenario.input, 'claude');
|
|
113
|
+
|
|
114
|
+
if (result.success &&
|
|
115
|
+
result.skill === scenario.expectedSkill) {
|
|
116
|
+
console.log(`✅ Passed: Detected ${result.skill} with confidence ${result.confidence}`);
|
|
117
|
+
passed++;
|
|
118
|
+
} else {
|
|
119
|
+
console.log(`❌ Failed: Expected ${scenario.expectedSkill}, got ${result.skill || 'none'}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
console.log(`\nEnd-to-end scenarios: ${passed}/${scenarios.length} passed`);
|
|
124
|
+
return passed === scenarios.length;
|
|
125
|
+
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.log(`❌ End-to-end scenarios test failed: ${error.message}`);
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Main test runner
|
|
133
|
+
async function runTests() {
|
|
134
|
+
console.log('==============================================');
|
|
135
|
+
console.log('TDD: NATURAL LANGUAGE INTEGRATION');
|
|
136
|
+
console.log('==============================================');
|
|
137
|
+
console.log('');
|
|
138
|
+
|
|
139
|
+
const results = [];
|
|
140
|
+
|
|
141
|
+
// Test 1: Natural language integration
|
|
142
|
+
results.push(await testNaturalLanguageIntegration());
|
|
143
|
+
console.log('');
|
|
144
|
+
|
|
145
|
+
// Test 2: End-to-end scenarios
|
|
146
|
+
results.push(await testEndToEndScenarios());
|
|
147
|
+
console.log('');
|
|
148
|
+
|
|
149
|
+
// Summary
|
|
150
|
+
const passed = results.filter(r => r === true).length;
|
|
151
|
+
const total = results.length;
|
|
152
|
+
|
|
153
|
+
console.log('==============================================');
|
|
154
|
+
console.log('TDD INTEGRATION TEST SUMMARY');
|
|
155
|
+
console.log('==============================================');
|
|
156
|
+
console.log(`Integration tests passed: ${passed}/${total}`);
|
|
157
|
+
|
|
158
|
+
if (passed === total) {
|
|
159
|
+
console.log('🎉 All integration tests passed!');
|
|
160
|
+
console.log('✅ Natural language skills integration is ready for CLI tools!');
|
|
161
|
+
} else {
|
|
162
|
+
console.log('⚠️ Some integration tests failed. Review implementation.');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return passed === total;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Run tests if called directly
|
|
169
|
+
if (require.main === module) {
|
|
170
|
+
runTests().then(success => {
|
|
171
|
+
process.exit(success ? 0 : 1);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
module.exports = {
|
|
176
|
+
testNaturalLanguageIntegration,
|
|
177
|
+
testEndToEndScenarios,
|
|
178
|
+
runTests
|
|
179
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TDD Test for Parameter Parsing Function
|
|
5
|
+
* Tests that will drive the implementation of proper parameter parsing
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const assert = require('assert');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Parse command line arguments into parameters and tool selection
|
|
12
|
+
* @param {string[]} args - Array of command line arguments
|
|
13
|
+
* @returns {Object} - { parameters: {}, tool: string|null }
|
|
14
|
+
*/
|
|
15
|
+
function parseArguments(args) {
|
|
16
|
+
const parameters = {};
|
|
17
|
+
let tool = null;
|
|
18
|
+
|
|
19
|
+
for (let i = 0; i < args.length; i++) {
|
|
20
|
+
const arg = args[i];
|
|
21
|
+
|
|
22
|
+
if (arg.startsWith('--')) {
|
|
23
|
+
if (arg.includes('=')) {
|
|
24
|
+
// Format: --key=value
|
|
25
|
+
const [key, value] = arg.substring(2).split('=', 2);
|
|
26
|
+
if (key === 'tool') {
|
|
27
|
+
tool = value;
|
|
28
|
+
} else {
|
|
29
|
+
parameters[key] = value;
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
// Format: --key value
|
|
33
|
+
const key = arg.substring(2);
|
|
34
|
+
if (key === 'tool') {
|
|
35
|
+
tool = args[i + 1];
|
|
36
|
+
i++; // Skip next argument as it's the value
|
|
37
|
+
} else if (i + 1 < args.length && !args[i + 1].startsWith('--')) {
|
|
38
|
+
parameters[key] = args[i + 1];
|
|
39
|
+
i++; // Skip next argument as it's the value
|
|
40
|
+
} else {
|
|
41
|
+
parameters[key] = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return { parameters, tool };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function testParameterParsing() {
|
|
51
|
+
console.log('TEST: Parameter Parsing Function');
|
|
52
|
+
console.log('--------------------------------');
|
|
53
|
+
|
|
54
|
+
const testCases = [
|
|
55
|
+
{
|
|
56
|
+
name: 'Key=value format with tool',
|
|
57
|
+
args: ['--text=hello', '--to=zh', '--tool=claude'],
|
|
58
|
+
expected: {
|
|
59
|
+
parameters: { text: 'hello', to: 'zh' },
|
|
60
|
+
tool: 'claude'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'Space-separated format with tool',
|
|
65
|
+
args: ['--text', 'hello', '--to', 'zh', '--tool', 'gemini'],
|
|
66
|
+
expected: {
|
|
67
|
+
parameters: { text: 'hello', to: 'zh' },
|
|
68
|
+
tool: 'gemini'
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Mixed format',
|
|
73
|
+
args: ['--text=hello', '--to', 'zh', '--file=app.js', '--tool=qwen'],
|
|
74
|
+
expected: {
|
|
75
|
+
parameters: { text: 'hello', to: 'zh', file: 'app.js' },
|
|
76
|
+
tool: 'qwen'
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'No tool specified',
|
|
81
|
+
args: ['--text=hello', '--to=zh'],
|
|
82
|
+
expected: {
|
|
83
|
+
parameters: { text: 'hello', to: 'zh' },
|
|
84
|
+
tool: null
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'Boolean flags',
|
|
89
|
+
args: ['--verbose', '--debug=true', '--tool=claude'],
|
|
90
|
+
expected: {
|
|
91
|
+
parameters: { verbose: true, debug: 'true' },
|
|
92
|
+
tool: 'claude'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
let passed = 0;
|
|
98
|
+
let total = testCases.length;
|
|
99
|
+
|
|
100
|
+
for (const testCase of testCases) {
|
|
101
|
+
console.log(`\nTesting: ${testCase.name}`);
|
|
102
|
+
console.log(`Input: ${JSON.stringify(testCase.args)}`);
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const result = parseArguments(testCase.args);
|
|
106
|
+
|
|
107
|
+
// Deep comparison of results
|
|
108
|
+
const paramsMatch = JSON.stringify(result.parameters) === JSON.stringify(testCase.expected.parameters);
|
|
109
|
+
const toolMatch = result.tool === testCase.expected.tool;
|
|
110
|
+
|
|
111
|
+
if (paramsMatch && toolMatch) {
|
|
112
|
+
console.log(`✅ PASSED`);
|
|
113
|
+
console.log(` Parameters: ${JSON.stringify(result.parameters)}`);
|
|
114
|
+
console.log(` Tool: ${result.tool}`);
|
|
115
|
+
passed++;
|
|
116
|
+
} else {
|
|
117
|
+
console.log(`❌ FAILED`);
|
|
118
|
+
console.log(` Expected: ${JSON.stringify(testCase.expected)}`);
|
|
119
|
+
console.log(` Got: ${JSON.stringify(result)}`);
|
|
120
|
+
|
|
121
|
+
if (!paramsMatch) {
|
|
122
|
+
console.log(` Parameters mismatch`);
|
|
123
|
+
}
|
|
124
|
+
if (!toolMatch) {
|
|
125
|
+
console.log(` Tool mismatch`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.log(`❌ ERROR: ${error.message}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log(`\nParameter Parsing Tests: ${passed}/${total} passed`);
|
|
134
|
+
return passed === total;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Run tests if called directly
|
|
138
|
+
if (require.main === module) {
|
|
139
|
+
const success = testParameterParsing();
|
|
140
|
+
process.exit(success ? 0 : 1);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = { parseArguments, testParameterParsing };
|