diff --git a/.claude/hooks/format-backend.sh b/.claude/hooks/format-backend.sh new file mode 100755 index 0000000000..d6077d7482 --- /dev/null +++ b/.claude/hooks/format-backend.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Format backend Rust files with rustfmt after Claude edits them + +# Get the file path from the tool result (passed via stdin as JSON) +INPUT=$(cat) +FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty') + +# Exit if no file path +if [ -z "$FILE_PATH" ]; then + exit 0 +fi + +# Check if the file is in the backend directory and is a Rust file +if [[ "$FILE_PATH" == *"/backend/"* ]] && [[ "$FILE_PATH" =~ \.rs$ ]]; then + cd "$CLAUDE_PROJECT_DIR/backend" || exit 0 + # Run rustfmt with config from rustfmt.toml (edition=2021) + rustfmt --config-path rustfmt.toml "$FILE_PATH" 2>/dev/null || true +fi + +exit 0 diff --git a/.claude/hooks/format-frontend.sh b/.claude/hooks/format-frontend.sh new file mode 100755 index 0000000000..d0b4f0559b --- /dev/null +++ b/.claude/hooks/format-frontend.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Format frontend files with prettier after Claude edits them + +# Get the file path from the tool result (passed via stdin as JSON) +INPUT=$(cat) +FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty') + +# Exit if no file path +if [ -z "$FILE_PATH" ]; then + exit 0 +fi + +# Check if the file is in the frontend directory +if [[ "$FILE_PATH" == *"/frontend/"* ]]; then + # Check if it's a formattable file type + if [[ "$FILE_PATH" =~ \.(ts|js|svelte|json|css|html|md)$ ]]; then + cd "$CLAUDE_PROJECT_DIR/frontend" || exit 0 + # Run prettier silently, don't fail the hook if prettier fails + npx prettier --write "$FILE_PATH" 2>/dev/null || true + fi +fi + +exit 0 diff --git a/.claude/hooks/notify-user.sh b/.claude/hooks/notify-user.sh new file mode 100755 index 0000000000..086b55c6c2 --- /dev/null +++ b/.claude/hooks/notify-user.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Notify user when Claude requires input (works on macOS and Linux) + +# Check if we're in an SSH session +if [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" || -n "$SSH_CONNECTION" ]]; then + # SSH session - use terminal bell + # If using VSCode, enable audible terminal bell for SSH sessions: + # Add the following to .vscode/settings.json: + # "accessibility.signals.terminalBell": { + # "sound": "on" + # }, + # "terminal.integrated.enableVisualBell": true + printf '\a' +else + # Local session - use native notifications + if [[ "$OSTYPE" == "darwin"* ]]; then + osascript -e 'display notification "Claude is waiting for your input" with title "Claude Code" sound name "Glass"' 2>/dev/null || printf '\a' + elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + notify-send "Claude Code" "Claude is waiting for your input" 2>/dev/null || printf '\a' + else + printf '\a' + fi +fi + +exit 0 diff --git a/.claude/settings.json b/.claude/settings.json index 5fd636bdf1..eac00f2227 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -23,7 +23,11 @@ "Bash(git log:*)", "Bash(git branch:*)", "Bash(git show:*)", - "Bash(git blame:*)" + "Bash(git blame:*)", + "Bash(cargo check:*)", + "mcp__ide__getDiagnostics", + "Bash(npm run generate-backend-client:*)", + "Bash(npm run check:*)" ], "deny": [ "Read(.env)", @@ -91,6 +95,34 @@ } ] } + ], + "PostToolUse": [ + { + "matcher": "Edit|Write", + "hooks": [ + { + "type": "command", + "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/format-frontend.sh", + "timeout": 30 + }, + { + "type": "command", + "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/format-backend.sh", + "timeout": 30 + } + ] + } + ], + "Notification": [ + { + "hooks": [ + { + "type": "command", + "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/notify-user.sh", + "timeout": 10 + } + ] + } ] }, "enabledPlugins": { diff --git a/.gitignore b/.gitignore index 7b93b49807..471fe31b59 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,9 @@ backend/.minio-data .aider* !.aiderignore rust-client/Cargo.toml + +# Symlinked cache directories (for git worktrees) +backend/target +frontend/node_modules +typescript-client/node_modules +frontend/.svelte-kit diff --git a/backend/rustfmt.toml b/backend/rustfmt.toml index 4aa3caaffa..912ee9d237 100644 --- a/backend/rustfmt.toml +++ b/backend/rustfmt.toml @@ -1,3 +1,4 @@ +edition = "2021" max_width = 100 use_small_heuristics = "Default" match_arm_leading_pipes="Preserve"