Skip to content

feat(hooks): WS1 补齐 DirectoryAdded hook + Notification agent_* 类型 - #73

Merged
dahai80 merged 1 commit into
mainfrom
feat/hook-coverage-directory-added-notification-agent
Aug 20, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/hook-coverage-directory-added-notification-agent

Conversation

@dahai80

@dahai80 dahai80 commented Aug 19, 2026

Copy link
Copy Markdown
Owner

概要

对齐 Claude Code 2.1.196→2.1.234 Tier-1 hook 覆盖。Closes #71。

本 PR 落地 WS1 (issue #71 的第一工作流): DirectoryAdded hook + Notification agent_completed/agent_needs_input 类型。WS2 (stacked slash-skills, issue #72) 单独 PR。

改动

DirectoryAdded (CC 2.1.219)

  • HookEvent union / HOOK_EVENTS const 加 DirectoryAdded (types.ts / coreTypes.ts / coreSchemas.ts)
  • DirectoryAddedHookInput + Schema: directory + source: 'repl_add_dir' | 'cli_add_dir'
  • DirectoryAddedHookSpecificOutputSchema: watchPaths 注册 FileChanged watcher (与 CwdChanged/FileChanged 一致)
  • getHookEventMetadata / groupHooksByEventAndMatcher / loadPluginHooks 补 DirectoryAdded 键
  • executeDirectoryAddedHooks dispatcher: fire-and-forget, 返回 {results, watchPaths, systemMessages} (镜像 executeFileChangedHooks)
  • /add-dir REPL 触发点: SandboxManager.refreshConfig() 后触发 source='repl_add_dir'
  • CLI --add-dir 触发点 (main.tsx) 未加 — 发生在 session bootstrap 前, hook 系统未就绪; cli_add_dir source 类型保留供未来使用

Notification agent_completed/agent_needs_input (CC 2.1.198)

  • Notification matcher values 加 agent_completed + agent_needs_input
  • LocalAgentTask / LocalMainSessionTask 后台任务完成触发 agent_completed/agent_failed (与既有 enqueuePendingNotification 并行, 不同 matchQuery 不重复触发)
  • useInboxPoller worker 权限请求 + 沙箱网络请求触发 agent_needs_input (与既有 worker_permission_prompt 桌面通知并行)

验证

  • bun run typecheck: 0 错误
  • bun run build + bun run build:dev:full: 通过
  • bun test src/__tests__/ tests/: 453 pass / 0 fail (含 13 新 WS1 单测 tests/hooks/directory-added-notification.test.ts)
  • diff 纯增量 257+/1-, 零格式 churn (Rule 3 surgical)

测试

新增 tests/hooks/directory-added-notification.test.ts (13 用例):

  • HOOK_EVENTS const / Schema 含 DirectoryAdded
  • DirectoryAddedHookInputSchema 接受 repl_add_dir/cli_add_dir, 拒绝非法 source
  • DirectoryAddedHookSpecificOutputSchema 接受 watchPaths, 拒绝错误 hookEventName
  • executeDirectoryAddedHooks / executeNotificationHooks 导出为函数
  • getHookEventMetadata 返回 DirectoryAdded metadata
  • groupHooksByEventAndMatcher 含 DirectoryAdded 组
  • Notification matcher values 含 agent_completed/agent_needs_input, field 为 notification_type

Co-Authored-By: Claude Fable 5 [email protected]

对齐 Claude Code 2.1.196→2.1.234 Tier-1 hook 覆盖 (issue #71):

DirectoryAdded (CC 2.1.219):
- HookEvent union / HOOK_EVENTS const 加 DirectoryAdded (types.ts/coreTypes.ts/coreSchemas.ts)
- DirectoryAddedHookInput + Schema (directory + source: repl_add_dir|cli_add_dir)
- DirectoryAddedHookSpecificOutputSchema (watchPaths 注册 FileChanged watcher)
- getHookEventMetadata / groupHooksByEventAndMatcher / loadPluginHooks 补 DirectoryAdded 键
- executeDirectoryAddedHooks dispatcher (fire-and-forget, 返回 watchPaths/systemMessages)
- /add-dir REPL 触发点: SandboxManager.refreshConfig() 后触发 source=repl_add_dir

Notification agent_completed/agent_needs_input (CC 2.1.198):
- Notification matcher values 加 agent_completed + agent_needs_input
- LocalAgentTask / LocalMainSessionTask 后台任务完成触发 agent_completed/agent_failed
- useInboxPoller worker 权限 + 沙箱网络请求触发 agent_needs_input

验证: typecheck 0 错误 / build + build:dev:full 通过 / 453 测试通过 (含 13 新 WS1 单测)
diff 纯增量 257+/1-, 零格式 churn (Rule 3 surgical)

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 4cef7c6 into main Aug 20, 2026
1 check passed
@dahai80
dahai80 deleted the feat/hook-coverage-directory-added-notification-agent branch August 20, 2026 12:00
dahai80 added a commit that referenced this pull request Aug 20, 2026
CC 2.1.217 对齐: Agent 工具 spawn 前强制三类上限, 阻断失控子代理递归。
- FUSION_MAX_CONCURRENT_SUBAGENTS 默认 20: 运行中 local_agent 数上限
- FUSION_MAX_SUBAGENTS_PER_SESSION 默认 200: 会话累计 spawn 数上限, /clear 重置
- FUSION_MAX_SUBAGENT_SPAWN_DEPTH 默认 3: 嵌套 spawn 深度上限

新增 src/tools/AgentTool/subagentGuardrails.ts 封装三限 (parseCap fail-open:
非数/0/负值回退默认, 非静默阻断)。AgentTool.call() 解析 agent 后、sync/async
分发前插入校验, 超限 throw (与 fork/MCP guard 同路径)。AppState 增
subagentSpawnCount 字段, spawn 时 rootSetAppState 递增, clearConversation 重置。

维度 4 (budget cap --max-budget-tokens) + 维度 5 背景默认 + per-agent-budget-stop
延后单独 item。worktree 隔离 + agent_completed 通知已在 PR #73 落地。

15 单测 (env 解析/默认/无效回退/十进制截断, 计数, 三限拒绝/放行, 深度优先序,
运行时降限)。typecheck 0, 全测 455 pass, build + build:dev:full pass。

Closes #81

Co-authored-by: Claude Fable 5 <[email protected]>
dahai80 added a commit that referenced this pull request Aug 20, 2026
追 CC 2.1.196→2.1.234 Tier-1 特性批量落地 (13 PR):

变更自 v0.4.22:
- WS1 DirectoryAdded hook + Notification agent_* 类型 (#73)
- WS2 堆叠 slash-skill 调用, 最多 5 前导 (#74)
- LSP+filecache 内存泄漏 cap, 对齐 CC 2.1.208 (#76)
- skill body-defer 懒加载, item 9 (#78)
- SessionStart source "fork" 区分 fork 与 resume (#80)
- P2.1 子代理护栏 — 并发/会话/深度三限 (#82)
- P1.1 大输出 tool_result tail 预览 (#84)
- P4.1 --ax-screen-reader 入口点对齐 — env 别名 + settings key (#86)
- item 13 WebSearch per-session 搜索次数上限 (#88)
- P4.2 §6 /doctor FUSION_* vs ANTHROPIC_* 环境变量冲突检测 (#90)
- P4.2 #1+#3 /doctor MLX 网关连通 + 模型加载探测 (#92)
- item 4 MCP 工具自动后台化 FUSION_MCP_AUTO_BACKGROUND_MS (#94)
- item 22 审计日志凭证脱敏 (#96)

- package.json: version 0.4.22 → 0.4.23

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(hooks): 补齐 hook 覆盖度 — DirectoryAdded 事件 + Notification agent_completed/agent_needs_input 类型

1 participant