Files
a0_software_orchestrator/api/project_state_get.py
T
Software Orchestrator 5769c1cd22 Initial commit: a0_software_orchestrator v1.0
- Auto-Registration-Bug behoben (register_project/get_project_id/resolve_project Trennung)
- 25 Tests gruen (Pytest)
- block_compactor-Tool refactored (Option B: Soft-Check statt Hard-Block)
- 4 Restbaustellen gefixt
- DB-Schema: plugin_settings-Tabelle hinzugefuegt
- 3 Schattenprojekte aus DB geloescht
- Plan v3 + Refactor-Plan + Worklog dokumentiert
2026-06-16 22:13:06 +00:00

30 lines
1.3 KiB
Python

"""API: Read DB-backed project state."""
from __future__ import annotations
import os
from helpers.api import ApiHandler, Request, Response
from usr.plugins.a0_software_orchestrator.helpers.db_state_store import (
get_project_id,
collect_full_state,
)
from usr.plugins.a0_software_orchestrator.helpers.state_store import read_json
class ProjectStateGet(ApiHandler):
async def process(self, input: dict, request: Request) -> dict | Response:
project_root = input.get("project_root", os.getcwd())
# Bug 4 Fix: basename-Fallback entfernt. project_name ist Pflicht.
project_name = input.get("project_name")
if not project_name:
return {"ok": False, "error": "project_name is required (basename fallback removed)"}
try:
pid = get_project_id(project_name)
if pid is None:
raise LookupError("project is not registered")
return {"ok": True, "source": "db", "project_id": pid, "state": collect_full_state(pid)}
except Exception as exc:
# Legacy fallback for existing .a0 projects.
state_file = os.path.join(project_root, ".a0", "project_state.json")
state = read_json(state_file, {})
return {"ok": False, "source": "file-fallback", "error": str(exc), "state": state}