2026-04-12 10:55:22 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
#
|
|
|
|
|
# deploy/dalidou/batch-extract.sh
|
|
|
|
|
# --------------------------------
|
|
|
|
|
# Host-side LLM batch extraction for Dalidou.
|
|
|
|
|
#
|
|
|
|
|
# The claude CLI is available on the Dalidou HOST but NOT inside the
|
|
|
|
|
# Docker container. This script runs on the host, fetches recent
|
|
|
|
|
# interactions from the AtoCore API, runs the LLM extractor locally
|
|
|
|
|
# (claude -p sonnet), and posts candidates back to the API.
|
|
|
|
|
#
|
|
|
|
|
# Intended to be called from cron-backup.sh after backup/cleanup/rsync,
|
|
|
|
|
# or manually via:
|
|
|
|
|
#
|
|
|
|
|
# bash /srv/storage/atocore/app/deploy/dalidou/batch-extract.sh
|
|
|
|
|
#
|
|
|
|
|
# Environment variables:
|
|
|
|
|
# ATOCORE_URL default http://127.0.0.1:8100
|
|
|
|
|
# ATOCORE_EXTRACT_LIMIT default 50
|
|
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
ATOCORE_URL="${ATOCORE_URL:-http://127.0.0.1:8100}"
|
|
|
|
|
LIMIT="${ATOCORE_EXTRACT_LIMIT:-50}"
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
APP_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
|
|
|
TIMESTAMP="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
|
|
|
|
|
|
|
|
log() { printf '[%s] %s\n' "$TIMESTAMP" "$*"; }
|
|
|
|
|
|
|
|
|
|
# The Python script needs the atocore source on PYTHONPATH
|
|
|
|
|
export PYTHONPATH="$APP_DIR/src:${PYTHONPATH:-}"
|
|
|
|
|
|
2026-04-12 12:30:57 -04:00
|
|
|
log "=== AtoCore batch extraction + triage starting ==="
|
2026-04-12 10:55:22 -04:00
|
|
|
log "URL=$ATOCORE_URL LIMIT=$LIMIT"
|
|
|
|
|
|
2026-04-12 12:30:57 -04:00
|
|
|
# Step A: Extract candidates from recent interactions
|
|
|
|
|
log "Step A: LLM extraction"
|
2026-04-12 10:55:22 -04:00
|
|
|
python3 "$APP_DIR/scripts/batch_llm_extract_live.py" \
|
|
|
|
|
--base-url "$ATOCORE_URL" \
|
|
|
|
|
--limit "$LIMIT" \
|
|
|
|
|
2>&1 || {
|
|
|
|
|
log "WARN: batch extraction failed (non-blocking)"
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-12 12:30:57 -04:00
|
|
|
# Step B: Auto-triage candidates in the queue
|
|
|
|
|
log "Step B: auto-triage"
|
|
|
|
|
python3 "$APP_DIR/scripts/auto_triage.py" \
|
|
|
|
|
--base-url "$ATOCORE_URL" \
|
|
|
|
|
2>&1 || {
|
|
|
|
|
log "WARN: auto-triage failed (non-blocking)"
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-13 21:08:13 -04:00
|
|
|
# Step C: Weekly synthesis (Sundays only)
|
|
|
|
|
if [[ "$(date -u +%u)" == "7" ]]; then
|
|
|
|
|
log "Step C: weekly project synthesis"
|
|
|
|
|
python3 "$APP_DIR/scripts/synthesize_projects.py" \
|
|
|
|
|
--base-url "$ATOCORE_URL" \
|
|
|
|
|
2>&1 || {
|
|
|
|
|
log "WARN: synthesis failed (non-blocking)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log "Step D: weekly lint pass"
|
|
|
|
|
python3 "$APP_DIR/scripts/lint_knowledge_base.py" \
|
|
|
|
|
--base-url "$ATOCORE_URL" \
|
|
|
|
|
2>&1 || true
|
|
|
|
|
fi
|
|
|
|
|
|
2026-04-12 12:30:57 -04:00
|
|
|
log "=== AtoCore batch extraction + triage complete ==="
|