8f02318542
YNAB has no event feed, so keep a local copy in ynab_* tables synced via server_knowledge delta requests: full download on first run, deltas every YNAB_SYNC_INTERVAL seconds and on demand before each tool call, full resync daily. Each sync diffs against the mirror and appends real edits (transactions, assignments, renames) to ynab_changes, the edit history YNAB doesn't keep. Agent YNAB tools now answer from the mirror: budget summary (spending computed from transactions, since YNAB's month activity nets in credit card payment categories), account balances, transaction search with splits expanded, spending reports by category/payee/account/month, category budget, and recent changes. Adds an admin-only read-only ynab_sql tool guarded by a sqlglot allowlist (scope-resolved tables, no dangerous functions), a READ ONLY transaction, a timeout, and a row cap. Replaces utils/ynab_service.py and drops the unused ynab SDK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
2.1 KiB
Makefile
80 lines
2.1 KiB
Makefile
.PHONY: deploy redeploy build up down restart logs migrate migrate-new migrate-history frontend test test-cov reindex reindex-obsidian ynab-sync ynab-resync
|
|
|
|
# Blue-green: detect the running color (default blue when nothing is running)
|
|
ACTIVE_COLOR := $(shell docker compose ps --status running --services 2>/dev/null | grep -oE 'raggr-(blue|green)' | head -1 | cut -d- -f2)
|
|
ifeq ($(ACTIVE_COLOR),)
|
|
ACTIVE_COLOR := blue
|
|
endif
|
|
RAGGR := raggr-$(ACTIVE_COLOR)
|
|
# Both profiles enabled for commands that only touch existing containers
|
|
# (never use this with `up`, which would start both colors)
|
|
COMPOSE := docker compose --profile blue --profile green
|
|
|
|
# Build and deploy
|
|
deploy: build up
|
|
|
|
# Zero-downtime blue-green swap (see scripts/deploy.sh)
|
|
redeploy:
|
|
git pull && ./scripts/deploy.sh
|
|
|
|
build:
|
|
docker compose --profile $(ACTIVE_COLOR) build $(RAGGR)
|
|
|
|
up:
|
|
docker compose --profile $(ACTIVE_COLOR) up -d
|
|
|
|
down:
|
|
$(COMPOSE) down
|
|
|
|
restart:
|
|
$(COMPOSE) restart $(RAGGR)
|
|
|
|
logs:
|
|
$(COMPOSE) logs -f $(RAGGR)
|
|
|
|
# Vector store reindexing
|
|
reindex:
|
|
$(COMPOSE) exec $(RAGGR) python -c "\
|
|
import asyncio; \
|
|
from blueprints.rag.logic import delete_all_documents, index_documents, index_obsidian_documents; \
|
|
delete_all_documents(); \
|
|
asyncio.run(index_documents()); \
|
|
asyncio.run(index_obsidian_documents()); \
|
|
print('Reindex complete')"
|
|
|
|
reindex-obsidian:
|
|
$(COMPOSE) exec $(RAGGR) python -c "\
|
|
import asyncio; \
|
|
from blueprints.rag.logic import delete_documents_by_metadata, index_obsidian_documents; \
|
|
delete_documents_by_metadata('source', 'obsidian'); \
|
|
asyncio.run(index_obsidian_documents()); \
|
|
print('Obsidian reindex complete')"
|
|
|
|
# YNAB mirror: delta sync, or full re-download
|
|
ynab-sync:
|
|
$(COMPOSE) exec $(RAGGR) python -m blueprints.ynab
|
|
|
|
ynab-resync:
|
|
$(COMPOSE) exec $(RAGGR) python -m blueprints.ynab --full
|
|
|
|
# Database migrations
|
|
migrate:
|
|
$(COMPOSE) exec $(RAGGR) aerich upgrade
|
|
|
|
migrate-new:
|
|
@./scripts/migrate-new.sh
|
|
|
|
migrate-history:
|
|
$(COMPOSE) exec $(RAGGR) aerich history
|
|
|
|
# Tests
|
|
test:
|
|
pytest tests/ -v
|
|
|
|
test-cov:
|
|
pytest tests/ -v --cov
|
|
|
|
# Frontend
|
|
frontend:
|
|
cd raggr-frontend && yarn install && yarn build
|