feat: 添加DACP服务支持,允许通过命令行调用DACP专业服务,增强AI角色的执行能力,同时更新相关依赖和工具定义。

This commit is contained in:
sean
2025-06-18 15:42:49 +08:00
parent 15b5e607dd
commit 47582c56c9
25 changed files with 3511 additions and 10 deletions

52
scripts/test-dacp-calculator.js Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env node
const { spawn } = require('child_process');
const path = require('path');
// 测试计算器功能
async function testCalculator() {
console.log('🧪 测试DACP计算器服务...\n');
const promptxPath = path.join(__dirname, '..', 'src', 'bin', 'promptx.js');
// 测试案例
const testCases = [
{
name: '简单加法',
command: ['node', promptxPath, 'dacp', 'dacp-promptx-service', 'calculate', '{"user_request": "2加3等于多少"}']
},
{
name: '复杂计算',
command: ['node', promptxPath, 'dacp', 'dacp-promptx-service', 'calculate', '{"user_request": "(10 + 5) * 2 - 8 / 4"}']
},
{
name: '中文运算符',
command: ['node', promptxPath, 'dacp', 'dacp-promptx-service', 'calculate', '{"user_request": "100减去25"}']
}
];
for (const testCase of testCases) {
console.log(`📝 测试: ${testCase.name}`);
console.log(`命令: ${testCase.command.join(' ')}`);
await new Promise((resolve) => {
const child = spawn(testCase.command[0], testCase.command.slice(1), {
stdio: 'inherit'
});
child.on('close', (code) => {
console.log(`\n✅ 测试完成 (退出码: ${code})\n`);
console.log('-'.repeat(60) + '\n');
resolve();
});
});
}
}
// 运行测试
testCalculator().then(() => {
console.log('🎉 所有测试完成!');
}).catch(error => {
console.error('❌ 测试失败:', error);
process.exit(1);
});