- Added configuration options for requiring human approval before applying LLM-generated MCP patches. - Updated Docker setup to include skills directory. - Integrated skills management into the backend, allowing for procedural guides and skill matching. - Refactored database initialization to apply Alembic migrations. - Enhanced task approval process to handle MCP patch applications with optional approval. - Introduced new schemas for skills and updated existing APIs to support skills functionality. This commit lays the groundwork for improved agent capabilities and better management of MCP development processes.
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
"""Database schema migrations via Alembic."""
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import logging
|
|
from collections.abc import AsyncGenerator
|
|
from pathlib import Path
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
|
from sqlalchemy.orm import DeclarativeBase
|
|
|
|
from app.config import settings
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
engine = create_async_engine(settings.database_url, echo=False, pool_pre_ping=True)
|
|
SessionLocal = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
pass
|
|
|
|
|
|
async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
async with SessionLocal() as session:
|
|
yield session
|
|
|
|
|
|
def _run_alembic_upgrade() -> None:
|
|
from alembic import command
|
|
from alembic.config import Config
|
|
|
|
ini = Path(__file__).resolve().parent.parent / "alembic.ini"
|
|
cfg = Config(str(ini))
|
|
command.upgrade(cfg, "head")
|
|
|
|
|
|
async def init_db() -> None:
|
|
"""Apply Alembic migrations to head."""
|
|
try:
|
|
await asyncio.to_thread(_run_alembic_upgrade)
|
|
except Exception as exc: # noqa: BLE001
|
|
logger.exception("Database migration failed")
|
|
raise RuntimeError("Database migration failed") from exc
|