Add Cursor hooks

This commit is contained in:
Konstantin Wohlwend 2025-12-03 17:05:41 -08:00
parent 8240af7f51
commit 0197b4bced
5 changed files with 62 additions and 3 deletions

16
.cursor/hooks.json Normal file
View File

@ -0,0 +1,16 @@
{
"version": 1,
"hooks": {
"afterFileEdit": [
{
"command": "./hooks/lint-file.sh"
}
],
"stop": [
{
"command": "./hooks/stop-check.sh"
}
]
}
}

18
.cursor/hooks/lint-file.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# Cursor hook: afterFileEdit
# Runs lint --fix on JS/TS files after they are edited by the agent
# Read JSON input from stdin
input=$(cat)
# Extract file_path from the input
file_path=$(echo "$input" | jq -r '.file_path')
# If file is a JS/TS file, run lint --fix on it
if [[ "$file_path" =~ \.(js|jsx|ts|tsx)$ ]]; then
pnpm run lint --fix "$file_path" || true
fi
exit 0

21
.cursor/hooks/stop-check.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
# Cursor hook: stop
# Runs typecheck and lint when the agent loop ends
# Read JSON input from stdin (contains status and loop_count)
input=$(cat)
# Check if this is a repeated stop hook call (loop_count > 0)
# to prevent infinite loops
loop_count=$(echo "$input" | jq -r '.loop_count // 0')
if [[ "$loop_count" -gt 0 ]]; then
exit 0
fi
# Run typecheck and lint
pnpm run typecheck 1>&2 || exit 2
pnpm run lint 1>&2 || exit 2
exit 0

3
.gitignore vendored
View File

@ -56,9 +56,6 @@ dist
# Jetbrains
.idea
# Cursor
.cursor
# GitHub Actions runner
/actions-runner
/_work

View File

@ -0,0 +1,7 @@
{
"mcpServers": {
"stack-auth": {
"url": "https://mcp.stack-auth.com/"
}
}
}