Files
ai-terminal-assistant/src/tools/index.ts
T
kurihada 82f0a0ccde feat: 添加多代理系统和 Task 子任务功能
Agent 模块:
- types.ts: Agent 类型定义 (AgentInfo, AgentPermission 等)
- permission-merger.ts: 三级权限合并逻辑 (系统->全局->Agent)
- config-loader.ts: 支持 YAML/JSON 配置文件加载
- registry.ts: Agent 注册表,管理预设和自定义 Agent
- executor.ts: Agent 执行器,支持工具过滤和权限控制
- presets/: 预设 Agent (general, explore, code-reviewer, build, plan)

Task 工具:
- task.ts: 执行子任务,委派给指定 Agent 处理
- 支持子会话创建和管理

会话扩展:
- 支持父子会话关系 (parentId, agentName)
- 新增 createChildSession, saveChildSession 方法

配置:
- 支持 .ai-assist/agents.yaml 用户自定义 Agent
- 支持通配符模式的 Bash 权限规则
2025-12-11 11:21:08 +08:00

97 lines
2.1 KiB
TypeScript

import type { ToolWithMetadata } from './types.js';
import { toolRegistry } from './registry.js';
// Shell 工具
import { bashTool } from './shell/index.js';
// 核心工具
import { toolSearchTool } from './tool-search.js';
import { todoReadTool, todoWriteTool } from './todo/index.js';
// Task 工具(Agent 子任务)
import { taskTool } from './task/index.js';
// 文件系统工具
import {
readFileTool,
writeFileTool,
editFileTool,
listDirTool,
createDirectoryTool,
searchFilesTool,
grepContentTool,
getFileInfoTool,
moveFileTool,
copyFileTool,
deleteFileTool,
} from './filesystem/index.js';
// Web 工具
import { webSearchTool, webExtractTool } from './web/index.js';
// Git 工具
import {
gitStatusTool,
gitDiffTool,
gitLogTool,
gitBranchTool,
gitAddTool,
gitCommitTool,
gitPushTool,
gitPullTool,
gitCheckoutTool,
gitStashTool,
} from './git/index.js';
// 所有工具列表(用于注册)
const allToolsWithMetadata: ToolWithMetadata[] = [
// 核心工具 (deferLoading: false)
toolSearchTool,
bashTool,
todoReadTool,
todoWriteTool,
taskTool,
// 文件系统工具 (deferLoading: true)
readFileTool,
writeFileTool,
editFileTool,
listDirTool,
createDirectoryTool,
searchFilesTool,
grepContentTool,
getFileInfoTool,
moveFileTool,
copyFileTool,
deleteFileTool,
// Web 工具 (deferLoading: false)
webSearchTool,
webExtractTool,
// Git 工具 (deferLoading: false)
gitStatusTool,
gitDiffTool,
gitLogTool,
gitBranchTool,
gitAddTool,
gitCommitTool,
gitPushTool,
gitPullTool,
gitCheckoutTool,
gitStashTool,
];
// 注册所有工具到 registry
toolRegistry.registerAll(allToolsWithMetadata);
// 导出
export { toolRegistry } from './registry.js';
export { toolSearchTool } from './tool-search.js';
export { todoManager } from './todo/index.js';
export { initTaskContext, updateTaskDescription } from './task/index.js';
export type { ToolWithMetadata, ToolMetadata, ToolCategory, ToolSearchResult } from './types.js';
// 兼容旧代码:导出所有工具数组(基础 Tool 类型)
export const allTools = toolRegistry.getAllTools();