From 7b04cc6be67ac2e0f044d4d1a3e392e2a0f674b2 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Tue, 28 Jul 2026 14:21:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(hooks):=20hooks.json=20=E7=B5=B1=E4=B8=80?= =?UTF-8?q?=E7=82=BA=E5=90=88=E4=BD=B5=E8=B6=85=E9=9B=86=E4=B8=A6=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E8=B7=A8=20cache=20=E8=A7=A3=E6=9E=90=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同名 plugin(三個 repo 都叫 jsc)只有一份 hooks.json 會生效,無法預期哪一 份會贏,因此三家必須同步為同一份超集。本次補上 role 的 SessionStart 與 Stop hook,避免 doc 贏得註冊時角色載入與記憶記錄靜默消失。 worklog 的 Stop 指令同步改用新解析器:先驗證 CLAUDE_PLUGIN_ROOT 下腳本存 在,再依「擁有者 marketplace 優先 → 全 cache 後援」搜尋 ~/.claude 與 ~/.codex 快取。舊版在 CLAUDE_PLUGIN_ROOT 為空時只搜 ~/.codex,非 Claude Code 的 CLI 會找不到腳本。 Co-Authored-By: Claude Opus 5 (1M context) --- hooks/hooks.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/hooks/hooks.json b/hooks/hooks.json index 3eed275..6eab4fe 100644 --- a/hooks/hooks.json +++ b/hooks/hooks.json @@ -1,11 +1,27 @@ { "hooks": { + "SessionStart": [ + { + "hooks": [ + { + "type": "command", + "command": "rel='scripts/role/role_load.sh'; own='generic'; root=\"${CLAUDE_PLUGIN_ROOT:-}\"; if [ -n \"$root\" ] && [ -f \"$root/$rel\" ]; then exec \"$root/$rel\"; fi; for base in \"$HOME/.claude/plugins/cache\" \"$HOME/.codex/plugins/cache\"; do for dir in \"$base/$own/jsc\" \"$base\"; do s=$(find \"$dir\" -path \"*/jsc/*/$rel\" -type f 2>/dev/null | sort -V | tail -n 1); if [ -n \"$s\" ]; then exec \"$s\"; fi; done; done; exit 0", + "timeout": 20 + } + ] + } + ], "Stop": [ { "hooks": [ { "type": "command", - "command": "root=\"${CLAUDE_PLUGIN_ROOT:-}\"; if [ -z \"$root\" ]; then script=$(find \"$HOME/.codex/plugins/cache/doc/jsc\" -path '*/scripts/worklog/worklog.sh' -type f 2>/dev/null | sort -V | tail -n 1); [ -n \"$script\" ] && exec \"$script\"; else exec \"$root/scripts/worklog/worklog.sh\"; fi", + "command": "rel='scripts/worklog/worklog.sh'; own='doc'; root=\"${CLAUDE_PLUGIN_ROOT:-}\"; if [ -n \"$root\" ] && [ -f \"$root/$rel\" ]; then exec \"$root/$rel\"; fi; for base in \"$HOME/.claude/plugins/cache\" \"$HOME/.codex/plugins/cache\"; do for dir in \"$base/$own/jsc\" \"$base\"; do s=$(find \"$dir\" -path \"*/jsc/*/$rel\" -type f 2>/dev/null | sort -V | tail -n 1); if [ -n \"$s\" ]; then exec \"$s\"; fi; done; done; exit 0", + "timeout": 60 + }, + { + "type": "command", + "command": "rel='scripts/role/role_capture.sh'; own='generic'; root=\"${CLAUDE_PLUGIN_ROOT:-}\"; if [ -n \"$root\" ] && [ -f \"$root/$rel\" ]; then exec \"$root/$rel\"; fi; for base in \"$HOME/.claude/plugins/cache\" \"$HOME/.codex/plugins/cache\"; do for dir in \"$base/$own/jsc\" \"$base\"; do s=$(find \"$dir\" -path \"*/jsc/*/$rel\" -type f 2>/dev/null | sort -V | tail -n 1); if [ -n \"$s\" ]; then exec \"$s\"; fi; done; done; exit 0", "timeout": 60 } ]