20 lines
1.0 KiB
Python
20 lines
1.0 KiB
Python
"""Whether a Read asks for a session transcript under ~/.claude/projects, for the `transcript-read` rule.
|
|
|
|
A transcript is a `.jsonl` file there, a session's own or a subagent's. It holds every tool result of its session, so reading one costs far more than the lines a task needs. The files Claude Code saves a long Bash result to, under the session's `tool-results/` folder, are `.txt` files and pass: the model is handed their path to read."""
|
|
import posixpath
|
|
|
|
from rule_hook.rules import Breach
|
|
from rule_hook.call import Call, text
|
|
from command_lines.shell_command import resolved
|
|
|
|
READS = "the call reads {}, a session transcript that holds every tool result of its session; print only the lines you need with grep or jq"
|
|
|
|
|
|
def transcript_breaches(call: Call, home: str) -> list[Breach]:
|
|
if call.tool != "Read":
|
|
return []
|
|
path = resolved(call.cwd, text(call.given, "file_path"), home)
|
|
if path.endswith(".jsonl") and path.startswith(posixpath.join(home, ".claude", "projects") + "/"):
|
|
return [Breach("transcript-read", READS.format(path), call.cwd)]
|
|
return []
|