34 lines
1004 B
Bash
Executable File
34 lines
1004 B
Bash
Executable File
#!/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
|