MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / find_transcript

Function find_transcript

eval/hermetic/score.py:65–93  ·  view source on GitHub ↗

Locate the JSONL transcript for this session inside the isolated config.

(config_dir: Path, cwd: str, session_id: str | None)

Source from the content-addressed store, hash-verified

63
64
65def find_transcript(config_dir: Path, cwd: str, session_id: str | None) -> Path | None:
66 """Locate the JSONL transcript for this session inside the isolated config."""
67 projects = config_dir / "projects"
68 candidates: list[Path] = []
69
70 if session_id:
71 # Fast path: <config>/projects/<slug>/<session_id>.jsonl
72 slug_dir = projects / project_slug(cwd)
73 direct = slug_dir / f"{session_id}.jsonl"
74 if direct.exists():
75 return direct
76 candidates.extend(projects.rglob(f"{session_id}.jsonl"))
77 if candidates:
78 return candidates[0]
79
80 # Fallback: newest transcript under the matching project slug.
81 slug_dir = projects / project_slug(cwd)
82 if slug_dir.is_dir():
83 jsonls = sorted(
84 slug_dir.glob("*.jsonl"), key=lambda p: p.stat().st_mtime, reverse=True
85 )
86 if jsonls:
87 return jsonls[0]
88
89 # Last resort: newest transcript anywhere in the isolated config.
90 all_jsonls = sorted(
91 projects.rglob("*.jsonl"), key=lambda p: p.stat().st_mtime, reverse=True
92 ) if projects.is_dir() else []
93 return all_jsonls[0] if all_jsonls else None
94
95
96def is_tracedecay_tool(name: str) -> bool:

Callers 1

mainFunction · 0.85

Calls 2

project_slugFunction · 0.85
existsMethod · 0.80

Tested by

no test coverage detected