import { spawnSync } from "child_process" import path from "path" import { tool } from "@opencode-ai/plugin" export default tool({ description: "Project status oracle. Read-only check of repo architecture conformance. Auto-detects project type (frontend→fullstack, fastapi→backend, typer→cli, aiogram→bot, prefect→worker) and runs 7 check groups: Структура, Тонкие роуты (AST ≤50 lines), Качество кода (mypy/ruff/pytest), Тесты (conftest, stub-detector, no @pytest.mark.asyncio), README (12 delimiter tags), Infra (branch protection, ci.yml, dependabot, LICENSE, pre-commit), Coverage (non-blocking). Non-blocking default (exit 0); pass check=true for strict (exit 1 on FAIL); pass fast=true to skip slow/remote checks (branch protection).", args: { check: tool.schema.boolean().optional().describe("If true, strict mode — exit 1 on any FAIL"), fast: tool.schema.boolean().optional().describe("If true, skip slow/remote checks (branch protection via gh)"), }, async execute(args, context) { const script = path.join(import.meta.dir, "..", "scripts", "project-status.py") const cmdArgs: string[] = [] if (args.check) cmdArgs.push("--check") if (args.fast) cmdArgs.push("--fast") const r = spawnSync("python3", [script, ...cmdArgs], { encoding: "utf-8", cwd: context.worktree, }) if (r.status === null) { return `⚠️ project_status failed (no exit): ${r.stderr || r.stdout}` } if (r.status !== 0 && !args.check) { return `⚠️ project_status failed (exit ${r.status}): ${r.stderr}` } return r.stdout.trim() }, })