From bf2006ae438c0a991b49d8e30e1e3b530c75744a Mon Sep 17 00:00:00 2001 From: Garv Date: Wed, 9 Sep 2026 00:31:16 +0530 Subject: [PATCH] fix: hint when --dir points to a file --- agentrace/cli.py | 12 +++++++++++- tests/test_cli.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/agentrace/cli.py b/agentrace/cli.py index fec377b..fa3b31f 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 ba17ee4..ebbb6f1 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -116,3 +116,15 @@ def test_empty_result_names_selected_directory(tmp_path): assert result.returncode == 0 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