Run every claude the loop starts in a Claude home generated outside the clone
CI / tests (pull_request) Successful in 4m45s
CI / tests (pull_request) Successful in 4m45s
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
"""Whether a Read asks for a session transcript under ~/.claude/projects, for the `transcript-read` rule.
|
||||
"""Whether a Read asks for a session transcript, 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."""
|
||||
A transcript is a `.jsonl` file under the `projects` folder of a Claude home, the loop's or the person's own, 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 pathlib
|
||||
import posixpath
|
||||
import typing
|
||||
|
||||
from rule_hook.rules import Breach
|
||||
from rule_hook.call import Call, text
|
||||
from loop_state.paths import CLAUDE_HOME
|
||||
from loop_state.paths import CLAUDE_HOME, claude_home
|
||||
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]:
|
||||
def transcript_breaches(call: Call, home: str, env: typing.Mapping[str, 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_HOME, "projects") + "/"):
|
||||
# The path is only compared: no file of either home is read.
|
||||
homes = (posixpath.join(home, CLAUDE_HOME), str(claude_home(env, pathlib.Path(home))))
|
||||
if path.endswith(".jsonl") and path.startswith(tuple(posixpath.join(each, "projects") + "/" for each in homes)):
|
||||
return [Breach("transcript-read", READS.format(path), call.cwd)]
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user