chore: fix claude hooks and add LSP tool env

- bash-guard: block awk (was missing from blocked commands)
- post-compact: replace fragile sed JSON escaping with jq -n --arg
- track-read: deduplicate entries before appending to .read-tracker
- settings: remove redundant Edit→require-read hook (built-in handles it)
- settings: add ENABLE_LSP_TOOL=1 for inline LSP diagnostics
This commit is contained in:
Kevin Turcios 2026-04-23 05:08:37 -05:00
parent d2ec01a0de
commit 5cb0a44cce
4 changed files with 13 additions and 17 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"
}
} }