Parse each transcript entry once into a typed value naming its kind, and have every consumer read those types

This commit is contained in:
2026-11-09 00:12:13 +01:00
parent bc2d7d6d5e
commit b83c1ddf19
20 changed files with 408 additions and 254 deletions
+3 -4
View File
@@ -3,7 +3,6 @@ import typing
from rule_hook.rules import Breach
from rule_hook.call import Call, text
from claude_code.entries import content
from failure import Failure
from git_cli import git_repo
from rule_hook.git import guarded_git
@@ -11,6 +10,7 @@ from model_routing.worker_rungs import handed
from model_routing.ladder import position, review_rung, ReviewKind, Rung
from review_rules.review_passes import prose, REVIEWERS
from claude_code.transcript import read_transcript
from claude_code.entries import UserText
# The pass each agent under agents/ reviews.
PASS_OF = {agent: kind for kind, agent in REVIEWERS.items()}
@@ -57,9 +57,8 @@ def skill_breaches(call: Call, environ: typing.Mapping[str, str]) -> list[Breach
def opening_prompt(transcript: str) -> str:
"""The prompt a transcript opens with, such as a subagent's from its Agent call; empty where it cannot be read."""
entries = read_transcript(transcript) if transcript else []
first = entries[0] if isinstance(entries, list) and entries else {}
prompt = content(first) if first.get("type") == "user" else None
return prompt.lstrip() if isinstance(prompt, str) else ""
first = entries[0] if isinstance(entries, list) and entries else None
return first.text.lstrip() if isinstance(first, UserText) else ""
def review_kind(given: dict[str, typing.Any]) -> ReviewKind | None: