Files
doc/hooks/hooks.json
T
jiantw83andClaude Sonnet 5 d31aa53fc3 feat(worklog): worklog.sh 改寫為 worklog.mjs(node 全面模組化)
新增 scripts/worklog/worklog.mjs,逐段對應改寫 worklog.sh:log/nowStr 改
import 自 wiki_api.mjs,extractTurn/turnDuration/turnTokens/redact 改
import 自 transcript.mjs,appendEntry/resolveToken/weekPageName/
weekPageHeader 改 import 自 wiki_api.mjs,取代原本各自開子行程呼叫;
stdin JSON 解析、遞迴防護、啟用檢查、Codex transcript fallback、
WORKLOG_SCOPE 過濾、專案判定、模型決定與快取過期、濃縮 prompt 九條規則
逐字保留,退出碼一律 0。hooks/hooks.json 的 Stop hook 改用 node 執行;
README/worklog SKILL.md/wiki_api.mjs 檔頭註解同步更新指向 worklog.mjs。

舊 worklog.sh 暫未刪除:依規劃需先在 WORKLOG_ENABLED=1 的環境實測 hook
真的會觸發並成功寫入週頁,這個環境目前未設定,留待後續驗證後再處理。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-17 15:12:31 +08:00

29 lines
1.7 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"hooks": {
"PreToolUse": [
{
"matcher": "Read|Write|Edit|MultiEdit|NotebookEdit|Glob|Grep|LS|Bash",
"hooks": [
{
"type": "command",
"command": "own='shared'; plug='jsc-shared'; rel='scripts/version-guard.mjs'; for base in \"$HOME/.claude/plugins/cache\" \"$HOME/.codex/plugins/cache\" \"$HOME/.copilot/installed-plugins\"; do for dir in \"$base/$own/$plug\" \"$base\"; do s=$(find \"$dir\" -path \"*/$plug/*/$rel\" -type f 2>/dev/null | sort -V | tail -n 1); if [ -n \"$s\" ]; then exec node --use-system-ca \"$s\"; fi; done; done; ts=$(TZ='Asia/Taipei' date +'%Y/%m/%d %H:%M:%S'); echo \"[$ts][版本檢查][ERR]: 找不到 jsc-shared 的 version-guard.mjs,fail-closed 阻擋。\" >&2; printf '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"deny\",\"permissionDecisionReason\":\"找不到 jsc-shared 的 version-guard.mjs,fail-closed 阻擋\"}}\\n'; exit 0",
"timeout": 15,
"statusMessage": "檢查 jsc-doc 版本…"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "rel='scripts/worklog/worklog.mjs'; own='doc'; plug='jsc-doc'; root=\"${CLAUDE_PLUGIN_ROOT:-}\"; if [ -n \"$root\" ] && [ -f \"$root/$rel\" ]; then exec node \"$root/$rel\"; fi; for base in \"$HOME/.claude/plugins/cache\" \"$HOME/.codex/plugins/cache\" \"$HOME/.copilot/installed-plugins\"; do for dir in \"$base/$own/$plug\" \"$base\"; do s=$(find \"$dir\" -path \"*/$plug/*/$rel\" -type f 2>/dev/null | sort -V | tail -n 1); if [ -n \"$s\" ]; then exec node \"$s\"; fi; done; done; exit 0",
"timeout": 60
}
]
}
]
}
}