Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions .claude/hooks/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,15 @@ def main():
# Read JSON input from stdin
input_data = json.loads(sys.stdin.read())

# Ensure log directory exists
import os
log_dir = os.path.join(os.getcwd(), 'logs')
os.makedirs(log_dir, exist_ok=True)
log_file = os.path.join(log_dir, 'notification.json')
# Ensure logs directory exists
log_dir = Path("logs")
log_dir.mkdir(parents=True, exist_ok=True)
log_file = log_dir / 'notification.jsonl'

# Read existing log data or initialize empty list
if os.path.exists(log_file):
with open(log_file, 'r') as f:
try:
log_data = json.load(f)
except (json.JSONDecodeError, ValueError):
log_data = []
else:
log_data = []

# Append new data
log_data.append(input_data)

# Write back to file with formatting
with open(log_file, 'w') as f:
json.dump(log_data, f, indent=2)
# Append new data as a single line to JSONL file
with open(log_file, 'a') as f:
json.dump(input_data, f)
f.write('\n')

# Announce notification via TTS only if --notify flag is set
# Skip TTS for the generic "Claude is waiting for your input" message
Expand Down
26 changes: 7 additions & 19 deletions .claude/hooks/post_tool_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,15 @@ def main():
# Read JSON input from stdin
input_data = json.load(sys.stdin)

# Ensure log directory exists
log_dir = Path.cwd() / 'logs'
# Ensure logs directory exists
log_dir = Path("logs")
log_dir.mkdir(parents=True, exist_ok=True)
log_path = log_dir / 'post_tool_use.json'
log_file = log_dir / 'post_tool_use.jsonl'

# Read existing log data or initialize empty list
if log_path.exists():
with open(log_path, 'r') as f:
try:
log_data = json.load(f)
except (json.JSONDecodeError, ValueError):
log_data = []
else:
log_data = []

# Append new data
log_data.append(input_data)

# Write back to file with formatting
with open(log_path, 'w') as f:
json.dump(log_data, f, indent=2)
# Append new data as a single line to JSONL file
with open(log_file, 'a') as f:
json.dump(input_data, f)
f.write('\n')

sys.exit(0)

Expand Down
22 changes: 5 additions & 17 deletions .claude/hooks/pre_compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,12 @@ def log_pre_compact(input_data):
# Ensure logs directory exists
log_dir = Path("logs")
log_dir.mkdir(parents=True, exist_ok=True)
log_file = log_dir / 'pre_compact.json'
log_file = log_dir / 'pre_compact.jsonl'

# Read existing log data or initialize empty list
if log_file.exists():
with open(log_file, 'r') as f:
try:
log_data = json.load(f)
except (json.JSONDecodeError, ValueError):
log_data = []
else:
log_data = []

# Append the entire input data
log_data.append(input_data)

# Write back to file with formatting
with open(log_file, 'w') as f:
json.dump(log_data, f, indent=2)
# Append new data as a single line to JSONL file
with open(log_file, 'a') as f:
json.dump(input_data, f)
f.write('\n')


def backup_transcript(transcript_path, trigger):
Expand Down
26 changes: 7 additions & 19 deletions .claude/hooks/pre_tool_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,27 +104,15 @@ def main():
print("BLOCKED: Dangerous rm command detected and prevented", file=sys.stderr)
sys.exit(2) # Exit code 2 blocks tool call and shows error to Claude

# Ensure log directory exists
log_dir = Path.cwd() / 'logs'
# Ensure logs directory exists
log_dir = Path("logs")
log_dir.mkdir(parents=True, exist_ok=True)
log_path = log_dir / 'pre_tool_use.json'
log_file = log_dir / 'pre_tool_use.jsonl'

# Read existing log data or initialize empty list
if log_path.exists():
with open(log_path, 'r') as f:
try:
log_data = json.load(f)
except (json.JSONDecodeError, ValueError):
log_data = []
else:
log_data = []

# Append new data
log_data.append(input_data)

# Write back to file with formatting
with open(log_path, 'w') as f:
json.dump(log_data, f, indent=2)
# Append new data as a single line to JSONL file
with open(log_file, 'a') as f:
json.dump(input_data, f)
f.write('\n')

sys.exit(0)

Expand Down
22 changes: 5 additions & 17 deletions .claude/hooks/session_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,12 @@ def log_session_start(input_data):
# Ensure logs directory exists
log_dir = Path("logs")
log_dir.mkdir(parents=True, exist_ok=True)
log_file = log_dir / 'session_start.json'
log_file = log_dir / 'session_start.jsonl'

# Read existing log data or initialize empty list
if log_file.exists():
with open(log_file, 'r') as f:
try:
log_data = json.load(f)
except (json.JSONDecodeError, ValueError):
log_data = []
else:
log_data = []

# Append the entire input data
log_data.append(input_data)

# Write back to file with formatting
with open(log_file, 'w') as f:
json.dump(log_data, f, indent=2)
# Append new data as a single line to JSONL file
with open(log_file, 'a') as f:
json.dump(input_data, f)
f.write('\n')


def get_git_status():
Expand Down
30 changes: 9 additions & 21 deletions .claude/hooks/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,15 @@ def main():
session_id = input_data.get("session_id", "")
stop_hook_active = input_data.get("stop_hook_active", False)

# Ensure log directory exists
log_dir = os.path.join(os.getcwd(), "logs")
os.makedirs(log_dir, exist_ok=True)
log_path = os.path.join(log_dir, "stop.json")

# Read existing log data or initialize empty list
if os.path.exists(log_path):
with open(log_path, 'r') as f:
try:
log_data = json.load(f)
except (json.JSONDecodeError, ValueError):
log_data = []
else:
log_data = []

# Append new data
log_data.append(input_data)

# Write back to file with formatting
with open(log_path, 'w') as f:
json.dump(log_data, f, indent=2)
# Ensure logs directory exists
log_dir = Path("logs")
log_dir.mkdir(parents=True, exist_ok=True)
log_file = log_dir / 'stop.jsonl'

# Append new data as a single line to JSONL file
with open(log_file, 'a') as f:
json.dump(input_data, f)
f.write('\n')

# Handle --chat switch
if args.chat and 'transcript_path' in input_data:
Expand Down
30 changes: 9 additions & 21 deletions .claude/hooks/subagent_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,15 @@ def main():
session_id = input_data.get("session_id", "")
stop_hook_active = input_data.get("stop_hook_active", False)

# Ensure log directory exists
log_dir = os.path.join(os.getcwd(), "logs")
os.makedirs(log_dir, exist_ok=True)
log_path = os.path.join(log_dir, "subagent_stop.json")

# Read existing log data or initialize empty list
if os.path.exists(log_path):
with open(log_path, 'r') as f:
try:
log_data = json.load(f)
except (json.JSONDecodeError, ValueError):
log_data = []
else:
log_data = []

# Append new data
log_data.append(input_data)

# Write back to file with formatting
with open(log_path, 'w') as f:
json.dump(log_data, f, indent=2)
# Ensure logs directory exists
log_dir = Path("logs")
log_dir.mkdir(parents=True, exist_ok=True)
log_file = log_dir / 'subagent_stop.jsonl'

# Append new data as a single line to JSONL file
with open(log_file, 'a') as f:
json.dump(input_data, f)
f.write('\n')

# Handle --chat switch (same as stop.py)
if args.chat and 'transcript_path' in input_data:
Expand Down
22 changes: 5 additions & 17 deletions .claude/hooks/user_prompt_submit.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,12 @@ def log_user_prompt(session_id, input_data):
# Ensure logs directory exists
log_dir = Path("logs")
log_dir.mkdir(parents=True, exist_ok=True)
log_file = log_dir / 'user_prompt_submit.json'
log_file = log_dir / 'user_prompt_submit.jsonl'

# Read existing log data or initialize empty list
if log_file.exists():
with open(log_file, 'r') as f:
try:
log_data = json.load(f)
except (json.JSONDecodeError, ValueError):
log_data = []
else:
log_data = []

# Append the entire input data
log_data.append(input_data)

# Write back to file with formatting
with open(log_file, 'w') as f:
json.dump(log_data, f, indent=2)
# Append new data as a single line to JSONL file
with open(log_file, 'a') as f:
json.dump(input_data, f)
f.write('\n')


def validate_prompt(prompt):
Expand Down