- 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>
49 lines
1.7 KiB
Bash
Executable File
49 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# inject-agent-context.sh - Injecção de contexto para subagentes
|
|
# Hook: SubagentStart
|
|
# Autor: Descomplicar
|
|
# Data: 2026-02-04
|
|
|
|
# Este script é chamado quando um subagente inicia
|
|
# Recebe o tipo de agente via variável de ambiente CLAUDE_SUBAGENT_TYPE
|
|
|
|
PLUGIN_ROOT="$(dirname "$(dirname "$(readlink -f "$0")")")"
|
|
AGENT_TYPE="${CLAUDE_SUBAGENT_TYPE:-unknown}"
|
|
CONFIG_FILE="$HOME/.claude/agents/agent-knowledge-config.json"
|
|
CACHE_DIR="${PLUGIN_ROOT}/.cache"
|
|
|
|
mkdir -p "$CACHE_DIR"
|
|
|
|
# Verificar se temos configuração para este agente
|
|
if [[ ! -f "$CONFIG_FILE" ]]; then
|
|
echo "META-PLUGIN: No agent-knowledge-config.json found"
|
|
exit 0
|
|
fi
|
|
|
|
# Tentar extrair configuração do agente (usando jq se disponível)
|
|
if command -v jq &> /dev/null; then
|
|
AGENT_CONFIG=$(jq -r ".\"$AGENT_TYPE\" // empty" "$CONFIG_FILE" 2>/dev/null)
|
|
|
|
if [[ -n "$AGENT_CONFIG" && "$AGENT_CONFIG" != "null" ]]; then
|
|
# Extrair datasets
|
|
DATASETS=$(echo "$AGENT_CONFIG" | jq -r '.datasets // [] | join(", ")' 2>/dev/null)
|
|
AUTO_CONSULT=$(echo "$AGENT_CONFIG" | jq -r '.auto_consult // false' 2>/dev/null)
|
|
QUERY_TEMPLATE=$(echo "$AGENT_CONFIG" | jq -r '.query_template // ""' 2>/dev/null)
|
|
|
|
if [[ -n "$DATASETS" && "$DATASETS" != "null" ]]; then
|
|
echo "META-PLUGIN: Agent context for $AGENT_TYPE"
|
|
echo " Datasets: $DATASETS"
|
|
echo " Auto-consult: $AUTO_CONSULT"
|
|
if [[ -n "$QUERY_TEMPLATE" && "$QUERY_TEMPLATE" != "null" ]]; then
|
|
echo " Query template: $QUERY_TEMPLATE"
|
|
fi
|
|
fi
|
|
else
|
|
echo "META-PLUGIN: No specific config for agent '$AGENT_TYPE'"
|
|
fi
|
|
else
|
|
echo "META-PLUGIN: jq not installed, skipping advanced context injection"
|
|
fi
|
|
|
|
exit 0
|