diff --git a/agentrace/cli.py b/agentrace/cli.py index 9c7a5b9..eedb373 100644 --- a/agentrace/cli.py +++ b/agentrace/cli.py @@ -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" diff --git a/tests/test_cli.py b/tests/test_cli.py index c346408..28b0de3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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 \ No newline at end of file + assert "0.1.0" in result.stdout