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 权限规则
This commit is contained in:
2025-12-11 11:21:08 +08:00
parent c6f8ba95ec
commit 82f0a0ccde
22 changed files with 1600 additions and 2 deletions
+9 -1
View File
@@ -4,9 +4,10 @@ import { Command } from 'commander';
import { Agent } from './core/agent.js';
import { TerminalUI } from './ui/terminal.js';
import { loadConfig, initConfig } from './utils/config.js';
import { toolRegistry, todoManager } from './tools/index.js';
import { toolRegistry, todoManager, initTaskContext, updateTaskDescription } from './tools/index.js';
import { getPermissionManager, promptPermission } from './permission/index.js';
import { SessionManager } from './session/index.js';
import { agentRegistry } from './agent/index.js';
import { initLSP, shutdownLSP } from './lsp/index.js';
import {
printServerList,
@@ -119,6 +120,13 @@ program.action(async () => {
// 初始化 todoManager(让 todo 工具可以访问会话)
todoManager.setSessionManager(sessionManager);
// 初始化 Agent 注册表(加载预设和用户配置)
await agentRegistry.init(process.cwd());
// 初始化 Task 工具上下文
initTaskContext(config, sessionManager);
updateTaskDescription();
// 显示会话恢复信息
const session = sessionManager.getSession();
if (session && session.messages.length > 0) {