cc-haha/docs/agent/index.md
程序员阿江(Relakkes) 007b8abab8 docs: add VitePress documentation site with i18n and GitHub Pages deployment
- Set up VitePress with bilingual support (Chinese root + English /en/)
- Create unified sidebar navigation with all doc sections
- Add custom Anthropic brand theme (#D97757)
- Create Quick Start pages (zh/en) from README content
- Migrate 7 .en.md files to docs/en/ directory structure
- Translate memory/agent/skills docs to English (9 files)
- Generate English-only architecture diagrams (11 images via PicTactic)
- Copy English-ready images for agent/skills sections (21 images)
- Configure custom domain (claudecodehaha.relakkesyang.org)
- Localize Chinese UI labels (sidebar, outline, footer)
- Add documentation site badge to READMEs
- Fix dead links and update cross-references for VitePress

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 22:21:45 +08:00

4.5 KiB
Raw Blame History

Claude Code 多 Agent 系统文档

完整的多 Agent 编排使用指南和实现原理文档


📚 文档目录

01-usage-guide.md — 使用指南

面向用户的完整使用手册,涵盖:

  • Agent 工具:参数详解、生成方式、后台运行
  • 六种内置 Agentgeneral-purpose、Explore、Plan、verification、claude-code-guide、statusline-setup
  • 后台任务:异步执行、进度追踪、完成通知
  • Agent Teams:团队创建、成员协作、消息通信
  • Worktree 隔离:独立环境、分支管理、安全上下文
  • 自定义 Agent:定义格式、工具池配置、系统提示词

适合人群:所有 Claude Code 用户


02-implementation.md — 实现原理

面向开发者的技术深度解析,涵盖:

  • 架构总览5 大 Agent 类别、4 条生成路径
  • Agent 生成流程:同步/异步/Fork/Teammate 四种路径详解
  • 工具池系统:三层过滤、常量定义、权限映射
  • 上下文传递CacheSafeParams、系统提示词构建、Fork 缓存优化
  • Teams 内部机制TeamFile 结构、邮箱系统、收件箱轮询、消息路由
  • 后台任务引擎LocalAgentTask 生命周期、进度追踪、通知队列
  • 权限同步团队级权限、模式传播、bubble 模式
  • 完整数据流:从 Agent Tool 调用到结果回传

适合人群:贡献者、架构师、想深入了解实现的开发者


🖼️ 配图说明

所有配图采用深色背景(#1a1a2e+ Anthropic 品牌橙铜色(#D97757风格与 Claude Code 官方文档一致。

图片 说明 所属文档
01-agent-overview.png 多 Agent 系统概览 — 架构全景 使用指南
02-agent-types.png 六种内置 Agent — 类型对比矩阵 使用指南
03-spawn-flow.png Agent 生成流程 — 四条路径决策树 使用指南
04-agent-teams.png Agent Teams 协作 — 团队通信拓扑 使用指南
05-architecture.png 实现架构总览 — 核心模块关系 实现原理
06-context-passing.png 上下文传递 — CacheSafeParams 数据流 实现原理
07-tool-pool.png 工具池系统 — 三层过滤流程 实现原理
08-background-task.png 后台任务引擎 — 生命周期状态机 实现原理
09-teams-mailbox.png Teams 邮箱系统 — 消息路由拓扑 实现原理
10-fork-cache.png Fork 缓存优化 — 字节级一致共享 实现原理

🚀 快速开始

用户

  1. 阅读 使用指南
  2. 了解六种内置 Agent 及其适用场景
  3. 尝试在对话中使用 Agent 工具生成子代理
  4. 探索 Agent Teams 多代理协作

开发者

  1. 阅读 实现原理
  2. 查看源码位置:
    • src/tools/AgentTool/ — Agent 工具实现
    • src/tools/TeamCreateTool/ — 团队创建
    • src/tools/SendMessageTool/ — 代理间通信
    • src/utils/swarm/ — Swarm 协作基础设施
    • src/utils/forkedAgent.ts — Fork 代理上下文
    • src/tasks/ — 任务管理系统
  3. 理解四条生成路径和上下文传递机制

📝 核心概念速查

概念 说明
Agent Tool 主入口工具,接受 prompt + subagent_type 生成子代理
Subagent 独立执行任务的子代理,有自己的工具池和权限
Fork Agent 继承父代理完整上下文的分叉代理,共享 prompt cache
Teammate Agent Teams 中的协作成员,通过邮箱通信
Worktree Git worktree 隔离模式,独立文件环境
LocalAgentTask 本地代理任务状态,追踪 running/completed/failed
DreamTask 自动记忆整合任务,定期后台运行
CacheSafeParams 缓存安全参数,确保 API 请求前缀字节级一致
TeamFile 团队配置文件,存储成员列表和权限
Mailbox 基于文件的消息队列,支持队友间异步通信

🔗 相关资源