Files
ai-agent/backend/services/routes.py
gabrielvidalandClaude Opus 5.5 ea29553d8b feat(services): the Services catalogue moves to the services live plugin
The core keeps the services index (names, README line, GOAL.md, last commit)
that service: tags, goals, artefacts and file chips need, and the service
page's shell (README, CLAUDE.md, commits, conversations, memories). Compose /
Traefik parsing, containers, URLs, auth chain, env keys and the file browser
(/api/service-file) leave services/catalog.py (667 → 186 lines) for the
services plugin in ai-agent-plugins.

Two plugin extension points make it work: provides.service.cards (the host
runs the plugin's action and merges whitelisted card fields into
/api/services and /api/service, services/enrich.py) and the services.read
capability (AIA_SERVICES_DIR for the owner's handler runs). ui.slots now
render (PluginSlots, service.detail with {slug}), and every plugin frame gets
the app's theme tokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:41:37 +01:00

32 lines
1.2 KiB
Python

"""Services index routes (the catalogue itself is the ``services`` plugin)."""
from fastapi import APIRouter, HTTPException
import schemas
from core.http import _json_in_worker, _r
from core.state import State
from services import catalog as svc_mod
from services import enrich
router = APIRouter()
# ── services index (the repo's services/ dir — read-only, no Docker) ──────────
@router.get("/api/services", responses=_r(schemas.ServicesResponse))
@_json_in_worker
def services_list(deps: State):
"""Every service dir (newest commit first): name, README line, goal, last
commit — plus containers / URLs / auth when the services plugin is on."""
return {"services": enrich.enrich(deps, svc_mod.list_services())}
@router.get("/api/service", responses=_r(schemas.ServiceDetail))
def service_detail(deps: State, slug: str):
"""One service's page shell: the card + README, CLAUDE.md, GOAL.md and
recent commits (the services plugin's slot draws the rest)."""
detail = svc_mod.service_detail(slug)
if detail is None:
raise HTTPException(404, "service not found")
return enrich.apply(detail, enrich.card_fields(deps).get(detail["dir"]))