commit 4e1688c37e4b547b8eb302550a92e85b1fa0c827 Author: Zhongwei Li Date: Sun Nov 30 08:30:52 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..30395ae --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,11 @@ +{ + "name": "hooks-debugger", + "description": "Logs all hook events to JSONL files for debugging purposes", + "version": "0.2.1", + "author": { + "name": "kawaz" + }, + "hooks": [ + "./hooks" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..62f51e5 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# hooks-debugger + +Logs all hook events to JSONL files for debugging purposes diff --git a/hooks/hooks-debugger.sh b/hooks/hooks-debugger.sh new file mode 100755 index 0000000..e3c1f4d --- /dev/null +++ b/hooks/hooks-debugger.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# hooks-debugger: Logs all hook events to JSONL files + +# ログディレクトリとファイルパスを初期化 +log_dir="${TMPDIR:-/tmp}/claude-hooks-debugger" +log_file="$log_dir/$(date +"%Y-%m-%d").jsonl" + +# 標準入力から JSON を読み取り +input=$(cat) + +# hook_event_name を抽出 +hook_event_name=$(jq -r '.hook_event_name // "unknown"' <<< "$input") + +# SessionStart 時に古いログファイルをクリーンアップ(3日以上前のファイルを削除) +if [[ "$hook_event_name" == "SessionStart" ]]; then + find "$log_dir" -type f -mtime +3 -delete 2>/dev/null +fi + +# タイムスタンプを追加した JSON を作成 +output=$(jq -c '{logged_at: (now | strflocaltime("%Y-%m-%dT%H:%M:%S%z"))}+.' <<< "$input") + +# JSONL ファイルに追記 +echo "$output" >> "$log_file" 2>/dev/null +if [[ $? -ne 0 ]]; then + mkdir -p "$log_dir" + echo "$output" >> "$log_file" +fi + +# 常に正常終了 +exit 0 diff --git a/hooks/hooks.json b/hooks/hooks.json new file mode 100644 index 0000000..5262863 --- /dev/null +++ b/hooks/hooks.json @@ -0,0 +1,103 @@ +{ + "hooks": { + "SessionStart": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/hooks-debugger.sh" + } + ] + } + ], + "SessionEnd": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/hooks-debugger.sh" + } + ] + } + ], + "PreToolUse": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/hooks-debugger.sh" + } + ] + } + ], + "PostToolUse": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/hooks-debugger.sh" + } + ] + } + ], + "PreCompact": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/hooks-debugger.sh" + } + ] + } + ], + "UserPromptSubmit": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/hooks-debugger.sh" + } + ] + } + ], + "Notification": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/hooks-debugger.sh" + } + ] + } + ], + "Stop": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/hooks-debugger.sh" + } + ] + } + ], + "SubagentStop": [ + { + "matcher": "*", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/hooks-debugger.sh" + } + ] + } + ] + } +} diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..d700ccc --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,49 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:kawaz/claude-plugins:plugins/hooks-debugger", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "98880d1ec31aec0de8294825dfede57c0509a1a0", + "treeHash": "831955edb275100fa800cf8bc56170b3b157f38f87aeaa31d3811d40ab053cb3", + "generatedAt": "2025-11-28T10:19:26.789540Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "hooks-debugger", + "description": "Logs all hook events to JSONL files for debugging purposes", + "version": "0.2.1" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "ad4b62a8d7e9ef3a93230ffbd730d93da02eeb5b3e6a0159c4bb01eedb1590b2" + }, + { + "path": "hooks/hooks-debugger.sh", + "sha256": "cb52eb9fada18cd103c1c000d899f5dd92a5a132fcac7bfe0265e171c6abf78a" + }, + { + "path": "hooks/hooks.json", + "sha256": "d8b164c46acb1ce99f6fa1c2ab17ffabc8b3486416686afbfacadd70b9669455" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "6a3aee3931e6ba4be3da8ffe4e92ce6881ef40131c4f3a947f68243e8ca70182" + } + ], + "dirSha256": "831955edb275100fa800cf8bc56170b3b157f38f87aeaa31d3811d40ab053cb3" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file