f55bd8f526
- 删除 agent_output.ts,新增 task_output.ts - 更新工具导出、注册和描述映射 - 更新 build/plan agent 预设的工具列表 - 更新 task 工具中的相关引用
64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
// 工具名到子目录的映射
|
|
const TOOL_CATEGORY_MAP: Record<string, string> = {
|
|
// shell
|
|
bash: 'shell',
|
|
// filesystem
|
|
read_file: 'filesystem',
|
|
write_file: 'filesystem',
|
|
edit_file: 'filesystem',
|
|
multi_edit: 'filesystem',
|
|
glob: 'filesystem',
|
|
grep: 'filesystem',
|
|
// web
|
|
web_search: 'web',
|
|
web_extract: 'web',
|
|
// git
|
|
git_status: 'git',
|
|
git_diff: 'git',
|
|
git_log: 'git',
|
|
git_branch: 'git',
|
|
git_add: 'git',
|
|
git_commit: 'git',
|
|
git_push: 'git',
|
|
git_pull: 'git',
|
|
git_checkout: 'git',
|
|
git_stash: 'git',
|
|
// todo
|
|
todo_write: 'todo',
|
|
// plan
|
|
ask_user_question: 'plan',
|
|
enter_plan_mode: 'plan',
|
|
exit_plan_mode: 'plan',
|
|
// task
|
|
task: 'task',
|
|
task_output: 'task',
|
|
// checkpoint
|
|
checkpoint_create: 'checkpoint',
|
|
checkpoint_list: 'checkpoint',
|
|
checkpoint_diff: 'checkpoint',
|
|
checkpoint_restore: 'checkpoint',
|
|
undo: 'checkpoint',
|
|
// repomap
|
|
repo_map: 'repomap',
|
|
};
|
|
|
|
export function loadDescription(toolName: string): string {
|
|
const category = TOOL_CATEGORY_MAP[toolName];
|
|
const filePath = category
|
|
? path.join(__dirname, 'descriptions', category, `${toolName}.txt`)
|
|
: path.join(__dirname, 'descriptions', `${toolName}.txt`);
|
|
|
|
try {
|
|
return fs.readFileSync(filePath, 'utf-8').trim();
|
|
} catch {
|
|
throw new Error(`无法加载工具描述文件: ${filePath}`);
|
|
}
|
|
}
|