#!/usr/bin/env bash # PreToolUse hook: NO bloquea. Inyecta recordatorio cuando ve sqlite3 sobre registry.db # para que el modelo prefiera el MCP `registry` la proxima vez. input="$(cat)" cmd="$(printf '%s' "$input" | jq -r '.tool_input.command // ""')" # Solo nos importa registry.db (NO operations.db, NO otros .db). if ! printf '%s' "$cmd" | grep -Eq 'sqlite3[^|]*\bregistry\.db\b'; then exit 0 fi # Casos legitimos donde el MCP no aplica: introspeccion de schema, agregaciones, JOINs. if printf '%s' "$cmd" | grep -Eq '(\.schema|\.tables|PRAGMA[[:space:]]+(table_info|index_list))'; then exit 0 fi if printf '%s' "$cmd" | grep -Eqi '(COUNT\(|GROUP[[:space:]]+BY|JOIN[[:space:]])'; then exit 0 fi # Caso a redirigir: emitir nota como additionalContext y dejar pasar el comando. jq -n '{ hookSpecificOutput: { hookEventName: "PreToolUse", additionalContext: "Aviso: sqlite3 directo sobre registry.db detectado. Para futuras consultas usa el MCP registry (mcp__registry__fn_search / fn_show / fn_code / fn_uses / fn_list_domains). Fallback a sqlite3 SOLO para .schema, PRAGMA, COUNT/GROUP BY, JOINs custom." } }' exit 0