CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 56s
CI & Build / integration (push) Successful in 1m4s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / Build & push image (push) Successful in 44s
Step 2 of the Scribe -> Grimoire rename. - src/scribe -> src/grimoire, and every import, patch target, module path, hypercorn entry point and `python -m grimoire.restore` with it; pyproject, uv.lock and the frontend package are named grimoire. - Image git.fabledsword.com/bvandeusen/fabledgrimoire; CI's Postgres service runs as grimoire / grimoire_test. - Compose files default the DB user, database and (prod) volume to grimoire, each overridable from .env, so an install created as Scribe keeps its data by setting POSTGRES_USER, POSTGRES_DB and PGDATA_VOLUME. - Backups are written as grimoire-<ts>.tar with format grimoire-backup-tar. Archives named scribe-* with the scribe-backup-tar manifest still restore and are still counted at the destination (folder and S3), with tests. - Exports, the MCP auth realm, the ASGI scope key and the persistent logger carry the new name. Kept on purpose: the secret-sealing key label stays "scribe.secrets.v1", because every stored secret was derived under it. Plugin identity (plugin name, hooks, env vars, .scribe marker, skills) is step 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
3.2 KiB
Python
79 lines
3.2 KiB
Python
"""Platform MCP tools — what a project is built on or ships as.
|
|
|
|
Thin wrappers over services/platforms.py. The catalog is global; a project's
|
|
platforms decide which family ideas reach it.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from grimoire.mcp._context import current_user_id
|
|
from grimoire.services import platforms as platforms_svc
|
|
|
|
|
|
async def list_platforms(project_id: int = 0) -> dict:
|
|
"""The GLOBAL platform catalog — runtimes, delivery channels and
|
|
toolchains a project can be built on or ship as (Android app, container
|
|
image, Go, …) — and, with a project_id, that project's answer for each.
|
|
|
|
A project's platforms decide which family ideas reach it: an idea is for
|
|
some platforms, and every project that is one of them answers it. Pass
|
|
slugs from here to set_project_platforms and decide_project_inception.
|
|
|
|
Each platform's `markers` are the file patterns that let the coverage
|
|
refresh DETECT it in a bound repo. A project's `state` per platform is
|
|
`declared` (a person said so), `detected` (a marker said so) or `rejected`
|
|
(a person said no — kept so detection cannot add it back). Only declared
|
|
and detected are membership.
|
|
|
|
Args:
|
|
project_id: also return this project's answers. 0 = catalog only.
|
|
"""
|
|
catalog = await platforms_svc.list_platforms()
|
|
out: dict = {"platforms": [p.to_dict() for p in catalog]}
|
|
if project_id:
|
|
rows = await platforms_svc.project_platforms(current_user_id(), project_id)
|
|
if rows is None:
|
|
raise ValueError(f"project {project_id} not found")
|
|
out["project_platforms"] = rows
|
|
return out
|
|
|
|
|
|
async def set_project_platforms(
|
|
project_id: int,
|
|
declared: list[str] | None = None,
|
|
rejected: list[str] | None = None,
|
|
withdrawn: list[str] | None = None,
|
|
) -> dict:
|
|
"""Say which platforms a project is — or is not. Only the platforms named
|
|
change; everything else is left exactly as it is.
|
|
|
|
Use it when the operator corrects what detection found, or when a project
|
|
starts or stops shipping something (it gains an Android client; it drops
|
|
its container image). At project creation, decide_project_inception's
|
|
`platforms` is the place instead — it records the answer with the rest of
|
|
what the project inherits.
|
|
|
|
Args:
|
|
project_id: the project.
|
|
declared: slugs the project IS (list_platforms).
|
|
rejected: slugs it is NOT — recorded as a "no", so the coverage
|
|
refresh never detects it back.
|
|
withdrawn: slugs whose answer to drop entirely, so detection may
|
|
decide again on the next refresh.
|
|
"""
|
|
updates: dict[str, str | None] = {}
|
|
for slug in withdrawn or []:
|
|
updates[slug] = None
|
|
for slug in rejected or []:
|
|
updates[slug] = "rejected"
|
|
for slug in declared or []:
|
|
updates[slug] = "declared"
|
|
if not updates:
|
|
raise ValueError("name at least one platform to declare, reject or withdraw")
|
|
rows = await platforms_svc.set_project_platforms(current_user_id(), project_id, updates)
|
|
return {"project_id": project_id, "project_platforms": rows}
|
|
|
|
|
|
def register(mcp) -> None:
|
|
for fn in (list_platforms, set_project_platforms):
|
|
mcp.tool(name=fn.__name__)(fn)
|