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>
This commit is contained in:
2026-08-17 15:12:31 +08:00
co-authored by Claude Sonnet 5
parent 336878cc04
commit d31aa53fc3
5 changed files with 322 additions and 5 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
"hooks": [
{
"type": "command",
"command": "rel='scripts/worklog/worklog.sh'; own='doc'; plug='jsc-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\" \"$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 \"$s\"; fi; done; done; exit 0",
"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
}
]