feat: implement MACP phase 1 core protocol

This commit is contained in:
Jarvis
2026-03-27 18:39:57 -05:00
parent 24496cea01
commit 7ef49a33d8
19 changed files with 1546 additions and 48 deletions

View File

@@ -78,9 +78,11 @@ def map_status(raw: str) -> str:
"pending": "pending",
"in-progress": "pending",
"needs-qa": "pending",
"gated": "gated",
"done": "completed",
"completed": "completed",
"failed": "failed",
"escalated": "escalated",
}
return mapping.get(value, "pending")
@@ -92,6 +94,7 @@ def parse_depends(raw: str) -> list[str]:
def build_task(
row: dict[str, str],
existing: dict[str, Any],
macp_defaults: dict[str, str],
runtime_default: str,
source_path: str,
) -> dict[str, Any]:
@@ -100,6 +103,9 @@ def build_task(
issue = row.get("issue", "").strip()
repo = row.get("repo", "").strip()
branch = row.get("branch", "").strip()
task_type = row.get("type", "").strip()
dispatch = row.get("dispatch", "").strip()
runtime = row.get("runtime", "").strip()
depends_on = parse_depends(row.get("depends_on", ""))
task = dict(existing)
@@ -108,7 +114,11 @@ def build_task(
task["description"] = description
task["status"] = map_status(row.get("status", "pending"))
task["depends_on"] = depends_on
task["runtime"] = str(task.get("runtime") or runtime_default or "codex")
task["type"] = task_type or str(task.get("type") or macp_defaults.get("type") or "coding")
task["dispatch"] = dispatch or str(task.get("dispatch") or macp_defaults.get("dispatch") or "")
task["runtime"] = runtime or str(task.get("runtime") or macp_defaults.get("runtime") or runtime_default or "codex")
task["branch"] = branch or str(task.get("branch") or macp_defaults.get("branch") or "")
task["issue"] = issue or str(task.get("issue") or "")
task["command"] = str(task.get("command") or "")
task["quality_gates"] = task.get("quality_gates") or []
metadata = dict(task.get("metadata") or {})
@@ -147,7 +157,14 @@ def main() -> int:
tasks_path = (repo / args.tasks_json).resolve()
config_path = repo / ".mosaic" / "orchestrator" / "config.json"
config = load_json(config_path, {})
runtime_default = str(config.get("worker", {}).get("runtime") or "codex")
macp_config = dict(config.get("macp") or {})
runtime_default = str(config.get("worker", {}).get("runtime") or macp_config.get("default_runtime") or "codex")
macp_defaults = {
"type": "coding",
"dispatch": str(macp_config.get("default_dispatch") or ""),
"runtime": str(macp_config.get("default_runtime") or runtime_default or "codex"),
"branch": "",
}
rows = parse_tasks_markdown(docs_path)
try:
@@ -171,6 +188,7 @@ def main() -> int:
build_task(
row,
existing_by_id.get(task_id, {}),
macp_defaults,
runtime_default,
source_path,
)