Bases: AXMTool
Audit a project's code quality against the AXM standard.
Registered as audit via axm.tools entry point.
Accepted category values (sourced from
axm_audit.models.results.SCORED_CATEGORIES | EXTRA_NONSCORED_CATEGORIES):
{categories}
Source code in packages/axm-audit/src/axm_audit/tools/audit.py
| Python |
|---|
| class AuditTool(AXMTool):
"""Audit a project's code quality against the AXM standard.
Registered as ``audit`` via axm.tools entry point.
Accepted ``category`` values (sourced from
``axm_audit.models.results.SCORED_CATEGORIES | EXTRA_NONSCORED_CATEGORIES``):
{categories}
"""
expose_directly = True
domain = "audit"
tags = frozenset({"quality", "lint", "type", "security"})
@property
def name(self) -> str:
"""Return tool name for registry lookup."""
return "audit"
def execute(
self,
*,
path: str = ".",
category: str | None = None,
**kwargs: object,
) -> ToolResult:
"""Audit a Python project's code quality.
Args:
path: Path to project root.
category: Optional category filter. One of:
{categories}
Returns:
ToolResult with audit scores and details (``data`` dict
and a compact ``text`` summary for LLM consumption).
"""
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_audit.core.auditor import audit_project
from axm_audit.formatters import format_agent, format_agent_text
result = audit_project(project_path, category=category)
data = format_agent(result)
text = format_agent_text(data, category=category)
from axm_audit.code_metrics import collect_code_metrics
from axm_audit.quality_trace import record_quality_snapshot
record_quality_snapshot(path=str(project_path), kind="audit", data=data)
# Also snapshot code metrics (LOC + structural counts) so trends can
# be charted over time; best-effort, never breaks the audit.
record_quality_snapshot(
path=str(project_path),
kind="code",
data=collect_code_metrics(str(project_path)),
)
return ToolResult(success=True, data=data, text=text)
except Exception as exc: # noqa: BLE001
return ToolResult(success=False, error=str(exc))
|
Return tool name for registry lookup.
Audit a Python project's code quality.
Parameters:
| Name |
Type |
Description |
Default |
path
|
str
|
|
'.'
|
category
|
str | None
|
Optional category filter. One of:
|
None
|
Returns:
| Type |
Description |
ToolResult
|
ToolResult with audit scores and details (data dict
|
ToolResult
|
and a compact text summary for LLM consumption).
|
Source code in packages/axm-audit/src/axm_audit/tools/audit.py
| Python |
|---|
| def execute(
self,
*,
path: str = ".",
category: str | None = None,
**kwargs: object,
) -> ToolResult:
"""Audit a Python project's code quality.
Args:
path: Path to project root.
category: Optional category filter. One of:
{categories}
Returns:
ToolResult with audit scores and details (``data`` dict
and a compact ``text`` summary for LLM consumption).
"""
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_audit.core.auditor import audit_project
from axm_audit.formatters import format_agent, format_agent_text
result = audit_project(project_path, category=category)
data = format_agent(result)
text = format_agent_text(data, category=category)
from axm_audit.code_metrics import collect_code_metrics
from axm_audit.quality_trace import record_quality_snapshot
record_quality_snapshot(path=str(project_path), kind="audit", data=data)
# Also snapshot code metrics (LOC + structural counts) so trends can
# be charted over time; best-effort, never breaks the audit.
record_quality_snapshot(
path=str(project_path),
kind="code",
data=collect_code_metrics(str(project_path)),
)
return ToolResult(success=True, data=data, text=text)
except Exception as exc: # noqa: BLE001
return ToolResult(success=False, error=str(exc))
|