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
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
"""Tool: check required project artifacts (hybrid DB + repo)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from helpers.tool import Tool, Response
|
||||
from usr.plugins.a0_software_orchestrator.helpers.artifact_rules import check_required_artifacts
|
||||
|
||||
|
||||
def _resolve_name(project_name: str = "", project_root: str = "") -> str:
|
||||
if project_name:
|
||||
return project_name.strip()
|
||||
if project_root:
|
||||
return os.path.basename(project_root.rstrip("/"))
|
||||
return os.path.basename(os.getcwd())
|
||||
|
||||
|
||||
class ArtifactGuard(Tool):
|
||||
"""Prüft alle Pflicht-Artefakte (5 DB + 10 Repo) für ein Projekt.
|
||||
|
||||
Args (kwargs):
|
||||
project_name (str): Projektname (bevorzugt).
|
||||
project_root (str): Legacy – wird zu basename() aufgelöst, bzw. als
|
||||
Wurzel für Repo-File-Checks verwendet.
|
||||
format (str): "summary" (default) oder "json".
|
||||
"""
|
||||
|
||||
async def execute(
|
||||
self,
|
||||
project_name: str = "",
|
||||
project_root: str = "",
|
||||
format: str = "summary",
|
||||
**kwargs,
|
||||
):
|
||||
name = _resolve_name(project_name, project_root)
|
||||
# Falls nur project_name gegeben, project_root auf cwd setzen
|
||||
if not project_root:
|
||||
project_root = os.getcwd()
|
||||
|
||||
result = check_required_artifacts(
|
||||
project_name=name, project_root=project_root
|
||||
)
|
||||
|
||||
n_present = len(result["present"])
|
||||
n_missing = len(result["missing"])
|
||||
n_total = result["total"]
|
||||
|
||||
if format == "json":
|
||||
return Response(
|
||||
message=json.dumps(result, indent=2, ensure_ascii=False),
|
||||
break_loop=False,
|
||||
)
|
||||
|
||||
lines = [
|
||||
f"Required artifacts for project {name!r}: "
|
||||
f"{n_present}/{n_total} present, {n_missing} missing.",
|
||||
]
|
||||
if result["missing"]:
|
||||
lines.append("")
|
||||
lines.append("Missing DB artifacts:")
|
||||
for a in result.get("db", {}):
|
||||
if not result["db"][a]:
|
||||
lines.append(f" - {a}")
|
||||
lines.append("")
|
||||
lines.append("Missing repo artifacts:")
|
||||
for a in result.get("repo", {}):
|
||||
if not result["repo"][a]:
|
||||
lines.append(f" - {a}")
|
||||
return Response(message="\n".join(lines), break_loop=False)
|
||||
Reference in New Issue
Block a user