- Execute all 6 migrations on Desk CRM production database - Create missing tables: cr_lsps, cr_agent_lsps, cr_lsp_usage - Create archive tables: cr_*_usage_archive (4 tables) - Create system tables: cr_migrations, cr_maintenance_log - Make all scripts executable (chmod +x) - Total cr_* tables: 38 Migration files: - 001_initial_schema.sql - 002_add_lsps.sql - 003_add_relationships.sql - 004_add_telemetry.sql - 005_add_archive_tables.sql - 006_add_maintenance_log.sql Scripts: - session-init.sh, session-end.sh - inject-context.sh, inject-agent-context.sh - record-usage.sh, db-backup.sh, sync-to-mysql.sh Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
47 lines
1.7 KiB
Bash
Executable File
47 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# session-end.sh - Finaliza sessão e regista métricas
|
|
# Chamado pelo hook Stop
|
|
# Author: Descomplicar®
|
|
|
|
set -e
|
|
|
|
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-/home/ealmeida/mcp-servers/descomplicar-meta-plugin}"
|
|
SESSION_FILE="$PLUGIN_ROOT/.current_session"
|
|
|
|
# Verificar se existe sessão activa
|
|
if [[ ! -f "$SESSION_FILE" ]]; then
|
|
echo "No active session found"
|
|
exit 0
|
|
fi
|
|
|
|
# Ler dados da sessão
|
|
SESSION_DATA=$(cat "$SESSION_FILE")
|
|
SESSION_ID=$(echo "$SESSION_DATA" | jq -r '.session_id // "unknown"')
|
|
STARTED_AT=$(echo "$SESSION_DATA" | jq -r '.started_at // ""')
|
|
TOOL_CALLS=$(echo "$SESSION_DATA" | jq -r '.tool_calls // 0')
|
|
|
|
# Calcular duração
|
|
if [[ -n "$STARTED_AT" ]]; then
|
|
START_EPOCH=$(date -d "$STARTED_AT" +%s 2>/dev/null || echo 0)
|
|
NOW_EPOCH=$(date +%s)
|
|
DURATION=$((NOW_EPOCH - START_EPOCH))
|
|
else
|
|
DURATION=0
|
|
fi
|
|
|
|
# Output resumo
|
|
cat << EOF
|
|
╔══════════════════════════════════════════════════════════════════════╗
|
|
║ SESSION ENDED ║
|
|
╠══════════════════════════════════════════════════════════════════════╣
|
|
║ Session ID: $SESSION_ID
|
|
║ Duration: ${DURATION}s
|
|
║ Tool Calls: $TOOL_CALLS
|
|
╚══════════════════════════════════════════════════════════════════════╝
|
|
EOF
|
|
|
|
# Limpar ficheiro de sessão
|
|
rm -f "$SESSION_FILE"
|
|
|
|
exit 0
|