Move the code and terraform audits into the reviews plugin

Copy the standalone code-review and terraform-review skills into
plugins/reviews as audit-code and audit-terraform. The rename separates the
automated, linter-driven audits from the guided review-pr walkthrough that
already lived here.

Resolve bundled script paths through ${SKILL_DIR}, exported in a new step 0.
CLAUDE_PLUGIN_ROOT is not set in the Bash tool environment, so the obvious
substitution would have expanded to nothing and broken every collection
script invocation.

Replace the PLAN and DESIGN docs with READMEs written from the current
SKILL.md and scripts. The old docs had drifted badly: they named semgrep
where the code calls opengrep, scoped five review agents where there are
now eight, and predated Lua, PowerShell, and GitHub Actions support.

Add CONSISTENCY_NORMS to the audit-terraform agent inputs. The collection
script writes consistency_norms.json and the agent prompt declares it, but
SKILL.md never listed it, leaving the variable unsubstituted.

Drop the --ingest-verdicts instruction from both skills. review_stats.py
parses no arguments, so the ref-mode verdict template it told users to feed
back could never be read.

Point audit-terraform's smoke test at README.md and resolve its fixture
paths relative to the test file rather than an absolute home directory.

Tests: 197 passing (audit-code), 106 passing (audit-terraform).
This commit is contained in:
2026-07-21 11:11:05 -05:00
parent 600c1fef86
commit f5934181ec
179 changed files with 20779 additions and 3 deletions
@@ -0,0 +1,146 @@
"""Manifest dataclasses for collect-findings.py output.
The manifest is the contract between the script and the review subagents.
Schema mirrors DESIGN.md.
"""
from __future__ import annotations
import json
from dataclasses import dataclass, field, asdict
from typing import Literal
Mode = Literal["local", "ref"]
Severity = Literal["critical", "high", "medium", "low", "info"]
Language = Literal[
"python", "javascript", "typescript", "csharp", "lua", "powershell",
"github-actions",
]
@dataclass
class Finding:
tool: str
rule_id: str
severity: Severity
file: str
line: int
end_line: int
message: str
cwe: str | None = None
fix_suggestion: str | None = None
def to_dict(self) -> dict:
return asdict(self)
@dataclass
class ChangedFile:
path: str
language: str
added_lines: list[tuple[int, int]]
def to_dict(self) -> dict:
return {
"path": self.path,
"language": self.language,
"added_lines": [list(r) for r in self.added_lines],
}
@dataclass
class LanguageBreakdown:
python: int = 0
javascript: int = 0
typescript: int = 0
csharp: int = 0
lua: int = 0
powershell: int = 0
github_actions: int = 0
skipped_files: list[str] = field(default_factory=list)
def to_dict(self) -> dict:
return asdict(self)
@dataclass
class PackageEntry:
name: str
version: str
def to_dict(self) -> dict:
return asdict(self)
@dataclass
class PackageUpgrade:
name: str
from_version: str
to_version: str
def to_dict(self) -> dict:
return {"name": self.name, "from": self.from_version, "to": self.to_version}
@dataclass
class PackageDiff:
added: list[PackageEntry] = field(default_factory=list)
removed: list[PackageEntry] = field(default_factory=list)
upgraded: list[PackageUpgrade] = field(default_factory=list)
def to_dict(self) -> dict:
return {
"added": [p.to_dict() for p in self.added],
"removed": [p.to_dict() for p in self.removed],
"upgraded": [u.to_dict() for u in self.upgraded],
}
@dataclass
class ToolStat:
ran: bool
pre_filter: int = 0
post_filter: int = 0
reason: str | None = None
def to_dict(self) -> dict:
d: dict = {"ran": self.ran}
if self.ran:
d["pre_filter"] = self.pre_filter
d["post_filter"] = self.post_filter
else:
d["reason"] = self.reason or ""
return d
@dataclass
class Manifest:
mode: Mode
base_ref: str
head_ref: str
default_branch: str
language_breakdown: LanguageBreakdown
changed_files: list[ChangedFile]
findings: list[Finding]
package_diffs: dict[str, PackageDiff]
tool_stats: dict[str, ToolStat]
tools_unavailable: list[str]
errors: list[str]
def to_dict(self) -> dict:
return {
"mode": self.mode,
"base_ref": self.base_ref,
"head_ref": self.head_ref,
"default_branch": self.default_branch,
"language_breakdown": self.language_breakdown.to_dict(),
"changed_files": [c.to_dict() for c in self.changed_files],
"findings": [f.to_dict() for f in self.findings],
"package_diffs": {k: v.to_dict() for k, v in self.package_diffs.items()},
"tool_stats": {k: v.to_dict() for k, v in self.tool_stats.items()},
"tools_unavailable": list(self.tools_unavailable),
"errors": list(self.errors),
}
def to_json(self, indent: int = 2) -> str:
return json.dumps(self.to_dict(), indent=indent, sort_keys=False)