Files
GLM-Tools-Skills-Agents/hooks/community/jat/log-tool-activity.sh
uroma b60638f0a3 Add community skills, agents, system prompts from 22+ sources
Community Skills (32):
- jat: jat-start, jat-verify, jat-complete
- pi-mono: codex-cli, codex-5.3-prompting, interactive-shell
- picoclaw: github, weather, tmux, summarize, skill-creator
- dyad: 18 skills (swarm-to-plan, multi-pr-review, fix-issue, lint, etc.)
- dexter: dcf valuation skill

Agents (23):
- pi-mono subagents: scout, planner, reviewer, worker
- toad: 19 agent configs (Claude, Codex, Gemini, Copilot, OpenCode, etc.)

System Prompts (91):
- Anthropic: 15 Claude prompts (opus-4.6, code, cowork, etc.)
- OpenAI: 49 GPT prompts (gpt-5 series, o3, o4-mini, tools)
- Google: 13 Gemini prompts (2.5-pro, 3-pro, workspace, cli)
- xAI: 5 Grok prompts
- Other: 9 misc prompts (Notion, Raycast, Warp, Kagi, etc.)

Hooks (9):
- JAT hooks for session management, signal tracking, activity logging

Prompts (6):
- pi-mono templates for PR review, issue analysis, changelog audit

Sources analyzed: jat, ralph-desktop, toad, pi-mono, cmux, pi-interactive-shell,
craft-agents-oss, dexter, picoclaw, dyad, system_prompts_leaks, Prometheus,
zed, clawdbot, OS-Copilot, and more
2026-02-13 10:58:17 +00:00

114 lines
4.1 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# log-tool-activity.sh - Claude hook to log tool usage
#
# This hook is called after any tool use by Claude
# Hook receives tool info via stdin (JSON format)
set -euo pipefail
# Read tool info from stdin
TOOL_INFO=$(cat)
# Extract session ID from hook data (preferred - always available in hooks)
SESSION_ID=$(echo "$TOOL_INFO" | jq -r '.session_id // ""' 2>/dev/null || echo "")
if [[ -z "$SESSION_ID" ]]; then
# Fallback to PPID-based file if session_id not in JSON (shouldn't happen with hooks)
# Note: PPID here is the hook's parent, which may not be correct
SESSION_ID=$(cat /tmp/claude-session-${PPID}.txt 2>/dev/null | tr -d '\n' || echo "")
fi
if [[ -z "$SESSION_ID" ]]; then
exit 0 # Can't determine session, skip logging
fi
# Parse tool name and parameters (correct JSON paths)
TOOL_NAME=$(echo "$TOOL_INFO" | jq -r '.tool_name // "Unknown"' 2>/dev/null || echo "Unknown")
# Build preview based on tool type
case "$TOOL_NAME" in
Read)
FILE_PATH=$(echo "$TOOL_INFO" | jq -r '.tool_input.file_path // ""' 2>/dev/null || echo "")
PREVIEW="Reading $(basename "$FILE_PATH")"
log-agent-activity \
--session "$SESSION_ID" \
--type tool \
--tool "Read" \
--file "$FILE_PATH" \
--preview "$PREVIEW" \
--content "Read file: $FILE_PATH"
;;
Write)
FILE_PATH=$(echo "$TOOL_INFO" | jq -r '.tool_input.file_path // ""' 2>/dev/null || echo "")
PREVIEW="Writing $(basename "$FILE_PATH")"
log-agent-activity \
--session "$SESSION_ID" \
--type tool \
--tool "Write" \
--file "$FILE_PATH" \
--preview "$PREVIEW" \
--content "Write file: $FILE_PATH"
;;
Edit)
FILE_PATH=$(echo "$TOOL_INFO" | jq -r '.tool_input.file_path // ""' 2>/dev/null || echo "")
PREVIEW="Editing $(basename "$FILE_PATH")"
log-agent-activity \
--session "$SESSION_ID" \
--type tool \
--tool "Edit" \
--file "$FILE_PATH" \
--preview "$PREVIEW" \
--content "Edit file: $FILE_PATH"
;;
Bash)
COMMAND=$(echo "$TOOL_INFO" | jq -r '.tool_input.command // ""' 2>/dev/null || echo "")
# Truncate long commands
SHORT_CMD=$(echo "$COMMAND" | head -c 50)
[[ ${#COMMAND} -gt 50 ]] && SHORT_CMD="${SHORT_CMD}..."
PREVIEW="Running: $SHORT_CMD"
log-agent-activity \
--session "$SESSION_ID" \
--type tool \
--tool "Bash" \
--preview "$PREVIEW" \
--content "Bash: $COMMAND"
;;
Grep|Glob)
PATTERN=$(echo "$TOOL_INFO" | jq -r '.tool_input.pattern // ""' 2>/dev/null || echo "")
PREVIEW="Searching: $PATTERN"
log-agent-activity \
--session "$SESSION_ID" \
--type tool \
--tool "$TOOL_NAME" \
--preview "$PREVIEW" \
--content "$TOOL_NAME: $PATTERN"
;;
AskUserQuestion)
# Note: Question file writing is handled by pre-ask-user-question.sh (PreToolUse hook)
# This PostToolUse hook only logs the activity
QUESTIONS_JSON=$(echo "$TOOL_INFO" | jq -c '.tool_input.questions // []' 2>/dev/null || echo "[]")
FIRST_QUESTION=$(echo "$QUESTIONS_JSON" | jq -r '.[0].question // "Question"' 2>/dev/null || echo "Question")
SHORT_Q=$(echo "$FIRST_QUESTION" | head -c 40)
[[ ${#FIRST_QUESTION} -gt 40 ]] && SHORT_Q="${SHORT_Q}..."
PREVIEW="Asking: $SHORT_Q"
log-agent-activity \
--session "$SESSION_ID" \
--type tool \
--tool "AskUserQuestion" \
--preview "$PREVIEW" \
--content "Question: $FIRST_QUESTION"
;;
*)
# Generic tool logging
PREVIEW="Using tool: $TOOL_NAME"
log-agent-activity \
--session "$SESSION_ID" \
--type tool \
--tool "$TOOL_NAME" \
--preview "$PREVIEW" \
--content "Tool: $TOOL_NAME"
;;
esac
exit 0