Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion agentrace/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ def _load(args) -> list[AgentRun]:
if args.file:
sessions = [parse_session(Path(args.file))]
else:
sessions = parse_all(Path(args.dir) if args.dir else None)
path = Path(args.dir) if args.dir else None

if path and path.is_file():
console.print(
f"[yellow]Hint:[/] {escape(str(path))} is a file. "
"Use [bold]--file[/] instead of [bold]--dir[/]."
)
return []

sessions = parse_all(path)

runs = [r for s in sessions for r in s.runs]
if not runs:
source = args.file or args.dir or "~/.claude/projects"
Expand Down
9 changes: 8 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,14 @@ def test_empty_result_names_selected_directory(tmp_path):
assert "No subagent runs found." in result.stdout
assert f"Looked in {tmp_path}." in result.stdout

def test_dir_given_file_hints_to_use_file(tmp_path):
transcript = tmp_path / "session.jsonl"
transcript.write_text("")
result = run_cli("--dir", str(transcript), "list")
assert "--file" in result.stdout


def test_version():
result = run_cli("--version")
assert result.returncode == 0
assert "0.1.0" in result.stdout
assert "0.1.0" in result.stdout
Loading