mirror of
https://github.com/codeflash-ai/codeflash.git
synced 2026-05-04 18:25:17 +00:00
Merge pull request #2108 from codeflash-ai/chore/fix-claude-hooks
chore: fix claude hooks and add LSP tool env
This commit is contained in:
commit
ba56064c72
4 changed files with 13 additions and 17 deletions
|
|
@ -24,6 +24,10 @@ case "$FIRST_CMD" in
|
||||||
echo "BLOCKED: Use the Read tool instead of \`$FIRST_CMD\`. Read provides line numbers and supports images/PDFs." >&2
|
echo "BLOCKED: Use the Read tool instead of \`$FIRST_CMD\`. Read provides line numbers and supports images/PDFs." >&2
|
||||||
exit 2
|
exit 2
|
||||||
;;
|
;;
|
||||||
|
awk)
|
||||||
|
echo "BLOCKED: Use the Grep tool or Read tool instead of \`awk\`." >&2
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
sed)
|
sed)
|
||||||
if echo "$COMMAND" | grep -qE '(^|[[:space:]])sed[[:space:]]+-i'; then
|
if echo "$COMMAND" | grep -qE '(^|[[:space:]])sed[[:space:]]+-i'; then
|
||||||
echo "BLOCKED: Use the Edit tool instead of \`sed -i\`. Edit tracks changes properly." >&2
|
echo "BLOCKED: Use the Edit tool instead of \`sed -i\`. Edit tracks changes properly." >&2
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,8 @@ STATE="${STATE}- libcst for code transforms, ast for read-only analysis\n"
|
||||||
|
|
||||||
[ -z "$STATE" ] && exit 0
|
[ -z "$STATE" ] && exit 0
|
||||||
|
|
||||||
cat <<EOF
|
EXPANDED=$(printf '%b' "$STATE")
|
||||||
{
|
jq -n --arg msg "PRESERVE the following session state through compaction:
|
||||||
"systemMessage": "PRESERVE the following session state through compaction:\n$(echo -e "$STATE" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')"
|
$EXPANDED" '{"systemMessage": $msg}'
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,6 @@ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null |
|
||||||
|
|
||||||
[ -z "$FILE_PATH" ] && exit 0
|
[ -z "$FILE_PATH" ] && exit 0
|
||||||
|
|
||||||
echo "$FILE_PATH" >> "$CLAUDE_PROJECT_DIR/.claude/.read-tracker"
|
TRACKER="$CLAUDE_PROJECT_DIR/.claude/.read-tracker"
|
||||||
|
grep -qxF "$FILE_PATH" "$TRACKER" 2>/dev/null || echo "$FILE_PATH" >> "$TRACKER"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
|
|
@ -42,16 +42,6 @@
|
||||||
"timeout": 5
|
"timeout": 5
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"matcher": "Edit",
|
|
||||||
"hooks": [
|
|
||||||
{
|
|
||||||
"type": "command",
|
|
||||||
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/require-read.sh",
|
|
||||||
"timeout": 5
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"PostToolUse": [
|
"PostToolUse": [
|
||||||
|
|
@ -92,5 +82,8 @@
|
||||||
"type": "command",
|
"type": "command",
|
||||||
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/status-line.sh"
|
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/status-line.sh"
|
||||||
},
|
},
|
||||||
"enableAllProjectMcpServers": true
|
"enableAllProjectMcpServers": true,
|
||||||
|
"env": {
|
||||||
|
"ENABLE_LSP_TOOL": "1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue