main.py (5146 lines, 106 routes) becomes an assembly only: one package per domain — core, files, settings, dashboards, conversations, diff, notifications, forms, runs, accounts, workers, models, cron, agents, projects, services, goals, memories, plans, templates — each exposing an APIRouter; the flat domain modules move into their package behind a barrel that keeps the old `import conversations` / `import projects` spellings. The shared singletons (store, meta_store, hub, indexer, …) are built once by core.state.build_state() and attached to app.state.ai; routes take them as the `deps: State` dependency and helpers as an explicit `deps: AppState`. conversations/pricing.py carries the per-model rates out of the parser. Verified: route table and OpenAPI byte-identical; 90 read endpoints golden-diffed against the monolith on a copy of the live data (identical); write routes smoke-tested; 66 backend tests pass. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""Project scaffolding templates routes."""
|
|
|
|
|
|
from fastapi import APIRouter
|
|
from fastapi.responses import PlainTextResponse
|
|
|
|
import schemas
|
|
import templates as templates_mod
|
|
from core.http import _r
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
# ── project scaffolding templates (projects/templates/) ──────────────────────
|
|
@router.get("/api/templates", responses=_r(schemas.TemplatesResponse))
|
|
def templates_list():
|
|
"""List every scaffold under projects/templates/ with stack tags + stats."""
|
|
return {"templates": templates_mod.list_templates()}
|
|
|
|
|
|
@router.get("/api/template", responses=_r(schemas.TemplateDetail))
|
|
def template_detail(name: str):
|
|
"""One template: README, npm scripts, deps and a nested file tree."""
|
|
return templates_mod.template_detail(name)
|
|
|
|
|
|
@router.get("/api/template-file")
|
|
def template_file(name: str, path: str):
|
|
"""A single text file's contents from within a template (512 KB cap)."""
|
|
return PlainTextResponse(templates_mod.template_file(name, path))
|