Skip to content

--file and --dir are not mutually exclusive, so --dir is silently ignored #8

Description

@royalpinto007

Desired outcome

Passing both --file and --dir is rejected instead of silently ignoring one of them.

Why it matters

_load() in agentrace/cli.py:

if args.file:
    sessions = [parse_session(Path(args.file))]
else:
    sessions = parse_all(Path(args.dir) if args.dir else None)

--file wins and --dir is discarded without a word. Both are defined as plain top-level options in main(), so nothing stops a user from writing:

agentrace check --dir ./transcripts --file ./transcripts/session.jsonl

and this is a natural thing to type when narrowing down from a directory run to a single file: you add --file and leave the --dir you already had in your shell history. The output then describes one file while the user believes it covers the directory. For a tool whose whole purpose is telling you which agent results not to trust, quietly analysing a different input than the one requested is a bad failure mode.

The empty-result message compounds it: _load prints "Looked in ~/.claude/projects unless --dir was given" even on the --file path, so a typo'd filename reports the wrong location.

Steps

  1. In main(), put --file and --dir in a mutually exclusive group:

    src = p.add_mutually_exclusive_group()
    src.add_argument("--dir", ...)
    src.add_argument("--file", ...)

    argparse then errors out with a clear message and no code in _load needs to change.

  2. Make the "no runs found" message name the actual source: the file path when --file was used, the directory otherwise.

  3. Consider erroring when --file points at something that does not exist, rather than letting it surface from parse_session.

Claiming this

Comment below to claim it. A reply usually comes within a day.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions