{
  "version": 1,
  "hooks": {
    "sessionStart": [
      {
        "type": "command",
        "bash": "echo \"branch: $(git branch --show-current 2>/dev/null)\"; gh pr view --json number,title,state -q '\"open PR: #\\(.number) \\(.title) (\\(.state))\"' 2>/dev/null; [ -f log.md ] && echo '--- last log entry ---' && tail -n 12 log.md; exit 0",
        "powershell": "Write-Output \"branch: $(git branch --show-current 2>$null)\"; gh pr view --json number,title,state -q '\"open PR: #\\(.number) \\(.title) (\\(.state))\"' 2>$null; if (Test-Path log.md) { Write-Output '--- last log entry ---'; Get-Content log.md -Tail 12 }; exit 0",
        "cwd": ".",
        "timeoutSec": 15
      }
    ],
    "preToolUse": [
      {
        "type": "command",
        "bash": "cmd=$(cat | jq -r '.tool_input.command // empty' 2>/dev/null); case \"$cmd\" in *'push --force'*|*'push -f'*|*'reset --hard'*|*'clean -fd'*|*'rm -rf /'*) echo \"refused by hook: $cmd\" >&2; exit 2;; esac; exit 0",
        "powershell": "$in = [Console]::In.ReadToEnd(); try { $cmd = ($in | ConvertFrom-Json).tool_input.command } catch { $cmd = '' }; if ($cmd -match 'push --force|push -f\\b|reset --hard|clean -fd|Remove-Item .* -Recurse .* -Force .*\\\\$') { [Console]::Error.WriteLine(\"refused by hook: $cmd\"); exit 2 }; exit 0",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "postToolUse": [
      {
        "type": "command",
        "bash": "f=$(cat | jq -r '.tool_input.file_path // .tool_input.path // empty' 2>/dev/null); [ -n \"$f\" ] || exit 0; case \"$f\" in *.cs) command -v dotnet >/dev/null && dotnet format whitespace --include \"$f\" --no-restore >/dev/null 2>&1;; *.ts|*.tsx|*.js|*.json|*.md|*.yml|*.yaml) command -v prettier >/dev/null && prettier --write --log-level silent \"$f\";; *.py) command -v ruff >/dev/null && ruff format -q \"$f\";; esac; exit 0",
        "powershell": "$in = [Console]::In.ReadToEnd(); try { $j = $in | ConvertFrom-Json; $f = $j.tool_input.file_path; if (-not $f) { $f = $j.tool_input.path } } catch { $f = '' }; if (-not $f) { exit 0 }; switch -Wildcard ($f) { '*.cs' { if (Get-Command dotnet -EA SilentlyContinue) { dotnet format whitespace --include $f --no-restore *> $null } } '*.ts' { if (Get-Command prettier -EA SilentlyContinue) { prettier --write --log-level silent $f } } '*.tsx' { if (Get-Command prettier -EA SilentlyContinue) { prettier --write --log-level silent $f } } '*.js' { if (Get-Command prettier -EA SilentlyContinue) { prettier --write --log-level silent $f } } '*.json' { if (Get-Command prettier -EA SilentlyContinue) { prettier --write --log-level silent $f } } '*.md' { if (Get-Command prettier -EA SilentlyContinue) { prettier --write --log-level silent $f } } '*.py' { if (Get-Command ruff -EA SilentlyContinue) { ruff format -q $f } } }; exit 0",
        "cwd": ".",
        "timeoutSec": 30
      }
    ],
    "agentStop": [
      {
        "type": "command",
        "bash": "if [ -f package.json ]; then npm test --silent; elif ls *.sln *.csproj >/dev/null 2>&1; then dotnet test --nologo -v q; elif [ -f pyproject.toml ]; then uv run pytest -q; else echo 'agentStop: no test runner detected'; fi",
        "powershell": "if (Test-Path package.json) { npm test --silent } elseif (Get-ChildItem -Filter *.sln,*.csproj -EA SilentlyContinue) { dotnet test --nologo -v q } elseif (Test-Path pyproject.toml) { uv run pytest -q } else { Write-Output 'agentStop: no test runner detected' }",
        "cwd": ".",
        "timeoutSec": 600
      }
    ]
  }
}
