## 动机 来源: `architecture/fusion-code-enhance-0819.md` Part A Tier 1。 深度洞察 CC 2.1.196→2.1.234 后发现 fusion-code 已移植完整 27-event settings.json hook 系统 (`src/utils/hooks.ts` + `src/entrypoints/sdk/coreTypes.ts:55-83` HOOK_EVENTS), 但仍有 2 处覆盖度缺口: 1. **DirectoryAdded** (CC 2.1.219): 注册新工作目录后触发。fusion-code 有 `/add-dir` 命令但无对应 hook 事件, 目录变更静默发生。 2. **Notification agent_completed/agent_needs_input** (CC 2.1.198): 后台子代理完成/需输入通知。fusion-code Notification hook 存在但 `notification_type` matcher 仅含 permission_prompt/idle_prompt/auth_success/elicitation_*, 缺后台代理 2 类。 > 注: 文档原列 PreCompact hook 为缺口, 调查发现**已存在** (`executePreCompactHooks` hooks.ts:4018, 4 处 fire site, block 经 exit-2/decision:block/continue:false)。此 issue 不含 PreCompact。 ## 现状 (调查定位) ### DirectoryAdded — 缺 - `src/commands/add-dir/add-dir.tsx:92` — `setAdditionalDirectoriesForClaudeMd([...currentDirs, path])` 目录添加点, 无 hook fire - `src/entrypoints/sdk/coreTypes.ts:55-83` HOOK_EVENTS 27 事件无 DirectoryAdded - 最近事件 `CwdChanged` (hooks.ts:4335) 仅 `cd` 触发, 不覆盖 /add-dir (cwd 不变) ### Notification agent 类型 — 缺 - `src/utils/hooks/hooksConfigManager.ts:71-78` notification_type matcher: permission_prompt, idle_prompt, auth_success, elicitation_dialog, elicitation_complete, elicitation_response (无 agent_*) - `src/services/notifier.ts:18-36` sendNotification 调 executeNotificationHooks, Notification hook fire 点 - `src/tasks/LocalMainSessionTask.ts:168-219` completeMainSessionTask 后台任务完成, L:200-206 仅 enqueue XML 消息未直接 sendNotification ## 方案 ### 1. DirectoryAdded - `coreTypes.ts` HOOK_EVENTS 加 `'DirectoryAdded'` - `src/types/hooks.ts` + `src/entrypoints/sdk/types.ts` 加 `DirectoryAddedHookInput` {hook_event_name, directory, source} - `src/utils/hooks.ts` 加 `executeDirectoryAddedHooks` (仿 executeCwdChangedHooks:4335) - `src/commands/add-dir/add-dir.tsx:92` 后 fire (setAdditionalDirectoriesForClaudeMd 成功后) - `src/main.tsx:2638` CLI --add-dir 路径同步 fire - zod schema `src/schemas/hooks.ts` 更新 ### 2. Notification agent 类型 - `hooksConfigManager.ts:71-78` matcher 加 `agent_completed`, `agent_needs_input` - `LocalMainSessionTask.ts:200-206` 后台任务完成 fire sendNotification (notification_type:'agent_completed') - needs_input 状态转换处 fire (notification_type:'agent_needs_input') — 定位 `src/tasks/LocalShellTask/LocalShellTask.tsx` shell 任务 input-wanted 转换 ## 验收 - typecheck 0 / build + build:dev:full / 514 tests - 单测: DirectoryAdded hook fire + Notification agent 类型 matcher - CI + lint 绿 - doc 更新 (docs/ + enhance-0819.md 状态)
Activity
feat(hooks): WS1 补齐 DirectoryAdded hook + Notification agent_* 类型 (#73)
refactor(screens): extract resume standalone agent context (audit 1.1…