Skip to content

Branch text

branch_text

Text renderers for GitBranchTool dual-format ToolResult.

Transform the structured data dict produced by :class:axm_git.tools.branch.GitBranchTool into a compact, token-efficient text representation, following the AXM header convention::

Text Only
git_branch | ✓ | {branch}
git_branch | ✗ | {error}

render_failure_text(*, error, data)

Render the failure-path text representation.

Appends a child-repo hint line when data carries suggestions (the not-a-repo enrichment from :func:not_a_repo_error).

Source code in packages/axm-git/src/axm_git/tools/branch_text.py
Python
def render_failure_text(*, error: str, data: dict[str, object] | None) -> str:
    """Render the failure-path text representation.

    Appends a child-repo hint line when *data* carries ``suggestions``
    (the not-a-repo enrichment from :func:`not_a_repo_error`).
    """
    header = f"git_branch | ✗ | {error}"
    suggestions = _as_str_list(data.get("suggestions")) if data else []
    if suggestions:
        return f"{header}\nhint: pass one as path: {', '.join(suggestions)}"
    return header

render_text(data)

Render the success-path data dict ({"branch": ...}).

Source code in packages/axm-git/src/axm_git/tools/branch_text.py
Python
def render_text(data: dict[str, object]) -> str:
    """Render the success-path ``data`` dict (``{"branch": ...}``)."""
    return f"git_branch | ✓ | {_as_str(data.get('branch'))}"