Skip to content

Check

check

InitCheckTool — project conformity check as an AXMTool.

InitCheckTool

Check a project against the AXM gold standard.

Registered as init_check via axm.tools entry point.

Source code in packages/axm-init/src/axm_init/tools/check.py
Python
class InitCheckTool:
    """Check a project against the AXM gold standard.

    Registered as ``init_check`` via axm.tools entry point.
    """

    @property
    def name(self) -> str:
        """Tool name used for MCP registration."""
        return "init_check"

    def execute(
        self,
        path: str = ".",
        *,
        category: str | None = None,
        json_output: bool = False,
        agent: bool = False,
        verbose: bool = False,
    ) -> ToolResult:
        """Check a project against the AXM gold standard.

        Args:
            path: Path to project root.
            category: Optional category filter.
            json_output: If True, render the structured report.
            agent: If True, render the structured report for agents.
            verbose: If True, include per-check detail in the rendered text.

        Returns:
            ToolResult with check scores and details.
        """
        try:
            project_path = Path(path).resolve()
            if not project_path.is_dir():
                return ToolResult(
                    success=False, error=f"Not a directory: {project_path}"
                )

            from axm_init.core.checker import (
                CheckEngine,
                format_agent,
                protocol_status,
            )
            from axm_init.models.check import ProjectResult

            engine = CheckEngine(project_path, category=category)
            result = engine.run()
            data = format_agent(result)
            if category == "protocols" and isinstance(result, ProjectResult):
                data["protocols"] = protocol_status(result)

            from axm_init.quality_trace import record_quality_snapshot

            record_quality_snapshot(
                path=str(project_path), kind="governance", data=data
            )
            success = _resolve_success(result)
            return ToolResult(
                success=success,
                data=data,
                text=_render_text(
                    result, structured=json_output or agent, verbose=verbose
                ),
                error=None if success else "Gold-standard checks failed",
            )
        except Exception as exc:
            return ToolResult(success=False, error=str(exc))
name property

Tool name used for MCP registration.

execute(path='.', *, category=None, json_output=False, agent=False, verbose=False)

Check a project against the AXM gold standard.

Parameters:

Name Type Description Default
path str

Path to project root.

'.'
category str | None

Optional category filter.

None
json_output bool

If True, render the structured report.

False
agent bool

If True, render the structured report for agents.

False
verbose bool

If True, include per-check detail in the rendered text.

False

Returns:

Type Description
ToolResult

ToolResult with check scores and details.

Source code in packages/axm-init/src/axm_init/tools/check.py
Python
def execute(
    self,
    path: str = ".",
    *,
    category: str | None = None,
    json_output: bool = False,
    agent: bool = False,
    verbose: bool = False,
) -> ToolResult:
    """Check a project against the AXM gold standard.

    Args:
        path: Path to project root.
        category: Optional category filter.
        json_output: If True, render the structured report.
        agent: If True, render the structured report for agents.
        verbose: If True, include per-check detail in the rendered text.

    Returns:
        ToolResult with check scores and details.
    """
    try:
        project_path = Path(path).resolve()
        if not project_path.is_dir():
            return ToolResult(
                success=False, error=f"Not a directory: {project_path}"
            )

        from axm_init.core.checker import (
            CheckEngine,
            format_agent,
            protocol_status,
        )
        from axm_init.models.check import ProjectResult

        engine = CheckEngine(project_path, category=category)
        result = engine.run()
        data = format_agent(result)
        if category == "protocols" and isinstance(result, ProjectResult):
            data["protocols"] = protocol_status(result)

        from axm_init.quality_trace import record_quality_snapshot

        record_quality_snapshot(
            path=str(project_path), kind="governance", data=data
        )
        success = _resolve_success(result)
        return ToolResult(
            success=success,
            data=data,
            text=_render_text(
                result, structured=json_output or agent, verbose=verbose
            ),
            error=None if success else "Gold-standard checks failed",
        )
    except Exception as exc:
        return ToolResult(success=False, error=str(exc))