diff --git a/.claude/scripts/compile-on-save.sh b/.claude/scripts/compile-on-save.sh new file mode 100755 index 0000000..396ab68 --- /dev/null +++ b/.claude/scripts/compile-on-save.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Hook PostToolUse: compila index-base.tpl cuando Claude lo edita +# Recibe JSON por stdin con info del tool use + +INPUT=$(cat) + +# Extraer file_path del tool input +FILE_PATH=$(echo "$INPUT" | node -e " + const d = JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')); + process.stdout.write(d?.tool_input?.file_path || ''); +" 2>/dev/null) + +# Solo compilar si es index-base.tpl +if [[ "$FILE_PATH" != *"index-base.tpl" ]]; then + exit 0 +fi + +# Leer el puerto del server Python del .docker/.env +ENV_FILE="${CLAUDE_PROJECT_DIR}/.docker/.env" +if [ ! -f "$ENV_FILE" ]; then exit 0; fi + +SERVER_PORT=$(grep "^ACAI_HOST_PORT=" "$ENV_FILE" | cut -d= -f2 | tr -d '[:space:]') +if [ -z "$SERVER_PORT" ]; then + SERVER_PORT="9091" +fi + +# Llamar al server Python para compilar +curl -s -X POST "http://localhost:${SERVER_PORT}/api/compile-module" \ + -H "Content-Type: application/json" \ + -d "{\"file_path\": \"${FILE_PATH}\", \"project_dir\": \"${CLAUDE_PROJECT_DIR}\"}" \ + > /dev/null 2>&1 & + +exit 0 diff --git a/.claude/settings.json b/.claude/settings.json index b52031e..a77309c 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -1,15 +1,15 @@ { - "mcpServers": { - "playwright": { - "command": "npx", - "args": ["@anthropic-ai/mcp-playwright@latest"] - }, - "fetch": { - "command": "npx", - "args": ["@anthropic-ai/mcp-fetch@latest"] - } - }, "permissions": { - "allow": ["Bash(docker exec:*)"] + "allow": ["Bash(docker exec:*)", "mcp__acai-code__*"] + }, + "hooks": { + "PostToolUse": [ + { + "type": "command", + "matcher": "Write|Edit", + "command": "bash ${CLAUDE_PROJECT_DIR}/.claude/scripts/compile-on-save.sh", + "timeout": 30 + } + ] } }