Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:30:52 +08:00
commit 4e1688c37e
5 changed files with 196 additions and 0 deletions

View File

@@ -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"
]
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# hooks-debugger
Logs all hook events to JSONL files for debugging purposes

30
hooks/hooks-debugger.sh Executable file
View File

@@ -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

103
hooks/hooks.json Normal file
View File

@@ -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"
}
]
}
]
}
}

49
plugin.lock.json Normal file
View File

@@ -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": []
}
}