Files
claude-config/bin/review_passes.py
T

29 lines
2.1 KiB
Python

"""The passes of larv-review, as skills/larv-review/SKILL.md → "Passes" lists them, and the Markdown that counts as config for them."""
import pathlib
import typing
# A pass an agent under agents/ reviews, in lower case. A Literal cannot be built from `PASS_AGENTS`, so test_review_passes holds the two together.
ReviewedPass = typing.Literal["architecture", "principles", "overrides", "stability", "product-owner", "prose"]
# Each pass in the order of SKILL.md's pass table, and the agent under agents/ that reviews it; None where a skill or plugin does. The auto-reviewer is left out: larv-review counts its rounds from its reviews on the PR, not from commit titles.
PASS_AGENTS: dict[str, str | None] = {"architecture": "systems-architect", "principles": "principles-auditor", "full scan": None, "security": None, "overrides": "override-reviewer", "stability": "stability-reviewer", "product-owner": "product-owner-reviewer", "prose": "prose-reviewer"}
PASSES = tuple(PASS_AGENTS)
def _reviewed(name: str) -> typing.TypeGuard[ReviewedPass]:
return name in typing.get_args(ReviewedPass)
# The passes that have an agent. A pass missing from `ReviewedPass` drops out of it, which test_review_passes fails on.
REVIEWERS: dict[ReviewedPass, str] = {name: agent for name, agent in PASS_AGENTS.items() if agent and _reviewed(name)}
# Markdown an agent follows, which counts as config: Claude Code's memory files, the bench's prompts, and the folders that hold Claude Code's skills, agents and rules and this repo's principles. skills/larv-review/SKILL.md → "Passes" and docs/decisions.md state the same lists for the agents that read them.
INSTRUCTION_FILES = ("CLAUDE.md", "AGENTS.md", "workflow-bench/*-prompt.md")
INSTRUCTION_FOLDERS = ("agents", "principles", "rules", "skills")
def prose(path: str) -> bool:
"""Whether path names Markdown that no agent follows: a branch changing only such files reviews on the project's rung, skills/larv-review/SKILL.md → "Markdown only"."""
named = pathlib.PurePosixPath(path)
return path.endswith(".md") and not any(named.match(pattern) for pattern in INSTRUCTION_FILES) and not set(INSTRUCTION_FOLDERS) & set(named.parts[:-1])