mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-21 15:55:50 +00:00
docs: 审校 Agent 文档术语与架构描述准确性(docs/agent) (#231)
基于源码验证和官方文档对照,修正三份 Agent 文档的内容准确性: coordinator-and-swarm.mdx: - 对齐官方术语:Leader→Team Lead, teammate→Teammate, 引入 Mailbox 消息系统 - 修正 Swarm 门控为 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1(原文"默认启用"不准确) - 拓扑描述改为"星型+P2P混合"(官方有 Team Lead 角色,非纯网状) - 新增架构组件表、Mailbox 消息系统、Hook 事件(TeammateIdle/TaskCreated/TaskCompleted)、限制说明 - 新增持久化存储路径(~/.claude/teams/, ~/.claude/tasks/) - 移除虚构的"高水位标记"(claimTask 仅使用文件锁) - 修正 Scratchpad 描述(Workers 获得,非 Coordinator 拥有) - 修复引号不匹配 sub-agents.mdx: - 修正为三路径路由(命名 Agent / Fork / GP 回退),原文仅两种 - 补充 isForkSubagentEnabled() 三前提(feature flag + 非Coordinator + 非非交互式) - 新增模型解析优先级(4级链 + inherit 运行时解析) - 新增内置 Agent 表(Explore/Plan/GP/statusline-setup/claude-code-guide) - 新增 Hook 事件表(frontmatter + settings.json 双级别) - 补充异步生命周期完整链路(finalizeAgentTool → getWorktreeResult) - 补充 transcript 存储路径和结果格式细节 worktree-isolation.mdx: - 区分 createWorktreeForSession vs createAgentWorktree 两种函数 - 修正清理机制为 cleanupWorktreeIfNeeded(非 ExitWorktreeTool 手动操作) - 补充 usedSparsePaths 字段
This commit is contained in:
@@ -143,14 +143,18 @@ call() — 实际执行
|
||||
|
||||
## 与 Agent 工具的联动
|
||||
|
||||
Agent 工具(`AgentTool`)的 `isolation` 参数决定子 Agent 是否在 worktree 中运行:
|
||||
Agent 工具(`AgentTool`)的 `isolation` 参数决定子 Agent 是否在 worktree 中运行。注意 Agent 工具使用**专用的** `createAgentWorktree()`(`src/utils/worktree.ts`),而非用户会话用的 `createWorktreeForSession()`,两者有关键差异:
|
||||
|
||||
- `isolation: "worktree"` → 调用 `createWorktreeForSession()`,子 Agent 在独立 worktree 中执行
|
||||
- 无 isolation → 子 Agent 共享主工作目录
|
||||
| 维度 | `createWorktreeForSession`(用户会话) | `createAgentWorktree`(子 Agent) |
|
||||
|------|---------------------------------------|----------------------------------|
|
||||
| 调用者 | EnterWorktreeTool | AgentTool |
|
||||
| Session 管理 | 设置 `currentWorktreeSession` | **不设置** `currentWorktreeSession` |
|
||||
| 恢复已有 worktree | 直接复用 | 复用并 bump mtime(防止被周期性清理误删) |
|
||||
|
||||
子 Agent 结束时的处理:
|
||||
- **成功**:主 Agent 通过 `ExitWorktreeTool(action: "keep")` 保留 worktree,然后手动合并
|
||||
- **失败/放弃**:主 Agent 通过 `ExitWorktreeTool(action: "remove", discard_changes: true)` 清理
|
||||
子 Agent 结束时的处理由 `cleanupWorktreeIfNeeded()` 自动完成——它不走 `ExitWorktreeTool`(因为 Agent worktree 没有会话状态,`ExitWorktreeTool` 的 `validateInput` 会拒绝):
|
||||
- **有变更** → 保留 worktree,返回 `worktreePath` 供主 Agent 后续合并
|
||||
- **无变更** → 自动删除
|
||||
- **Hook-based** → 始终保留
|
||||
|
||||
## Session 状态持久化
|
||||
|
||||
@@ -168,6 +172,7 @@ Agent 工具(`AgentTool`)的 `isolation` 参数决定子 Agent 是否在 wor
|
||||
tmuxSessionName?: string, // 关联的 tmux session
|
||||
hookBased?: boolean, // 是否由 hook 创建
|
||||
creationDurationMs?: number, // 创建耗时(分析用)
|
||||
usedSparsePaths?: boolean, // 是否使用了 sparse checkout
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user