mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Add Cursor hooks
This commit is contained in:
parent
8240af7f51
commit
0197b4bced
16
.cursor/hooks.json
Normal file
16
.cursor/hooks.json
Normal 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
18
.cursor/hooks/lint-file.sh
Executable 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
21
.cursor/hooks/stop-check.sh
Executable 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
3
.gitignore
vendored
@ -56,9 +56,6 @@ dist
|
||||
# Jetbrains
|
||||
.idea
|
||||
|
||||
# Cursor
|
||||
.cursor
|
||||
|
||||
# GitHub Actions runner
|
||||
/actions-runner
|
||||
/_work
|
||||
|
||||
7
examples/lovable-react-18-example/.cursor/mcp.json
Normal file
7
examples/lovable-react-18-example/.cursor/mcp.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"stack-auth": {
|
||||
"url": "https://mcp.stack-auth.com/"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user