1.3 KiB
1.3 KiB
Hook 自动同步机制
Hook 机制可在特定事件发生时自动触发同步,无需手动执行。
支持的 Hook 事件
| 事件 | 触发条件 | 自动执行操作 |
|---|---|---|
requirement.created |
创建新需求 | 同步需求到远程 |
requirement.submitted |
提交评审 | 发送评审通知 |
requirement.approved |
需求评审通过 | 同步需求 + 关联任务到远程 |
requirement.archived |
需求归档 | 最终同步 + 同步到思源笔记 + 发送通知 |
task.completed |
任务完成 | 同步任务状态到远程 |
配置 Hook
在 .claude/settings.local.json 中配置:
{
"hooks": {
"requirement.approved": {
"enabled": true,
"actions": ["sync_requirement_to_remote", "sync_tasks_to_remote"]
},
"requirement.archived": {
"enabled": true,
"actions": ["sync_requirement_to_remote", "sync_to_siyuan", "send_notification"]
},
"task.completed": {
"enabled": true,
"actions": ["sync_task_to_remote"]
}
}
}
手动触发 Hook
/req hook trigger requirement.approved REQ-2026-0010
查看 Hook 执行历史
/req hook history REQ-2026-0010
禁用/启用 Hook
/req hook disable REQ-2026-0010
/req hook enable REQ-2026-0010