Repository navigation
Add --json option to --once snapshot for scripts and status bars - #5
Conversation
Adds `--json` to `tracon --once` (or standalone `tracon --json`) to emit a structured JSON array of agent objects with id, description, state, flags, quiet seconds, and judge verdict, sorted by urgency. This enables integrations with status bars (tmux, sketchybar, Waybar) and external scripts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Thanks for picking this up @thanvish21! It's what #1 asked for and it's nicely contained: it builds on assess_all() and only reads cached judge verdicts, so polling it from a status bar every few seconds is free. Tests pass for me.
A few things before I merge, mostly about making the output useful to the status bar it's meant for. Details are inline.
Also, heads up: I have a commit on main I haven't pushed yet (the Ghostty split / session picker). It touches the imports and adds _write right above print_snapshot, so this will conflict in cli.py once it lands. It's an easy conflict; I'll ping you when it's up so you can rebase.
- Require `--once` when using `--json` via parser.error. - Nest flag objects with `code`, `severity`, and `detail` matching web view. - Add `severity` to each agent object for direct status bar styling. - Nest `judge` with `verdict` and `dismissed` flag. - Wrap output in top-level object containing `session`, `lane`, `as_of`, and `agents` list. - Keep `print_snapshot` definition on a single line. - Use `pytest.raises` for JSONDecodeError in tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
All requested changes have been implemented and verified in commit
All 88 unit tests and lint checks pass cleanly. Ready for re-review whenever convenient! |
Resolve conflict in tracon/cli.py by combining ghostty chooser initialization with --json flag parsing, schema serialization, and parser error validation. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Good to go. Thank you @thanvish21 |
Summary
--jsontotracon --onceto emit a structured JSON payload for scripts and status bars.--json needs --onceviaparser.error()to cleanly protect command invariants.{"session": ..., "lane": ..., "as_of": ..., "agents": [...]}.--onceand TUI table ordering.id,description,state,severity,flags(list of{"code", "severity", "detail"}dicts matchingweb.py),quiet_s, andjudge({"verdict": ..., "dismissed": ...}ornull).README.mdandCLAUDE.md) and adds unit tests intests/test_cli.py.Closes #1
Test plan
uv run pytest(88/88 passing, including 7 tests intests/test_cli.py)uv run tracon --demo --once --jsonoutputs valid JSON with schema{"session", "lane", "as_of", "agents"}uv run tracon --demo --once --json | jq '[.agents[] | select(.state=="BLOCKED")] | length'correctly outputs1uv run tracon --demo --jsonexits with code 2 and outputs--json needs --onceuv run tracon --demo --once --json --no-judgesets"judge": nullacross all agentsuv run tracon --demo --oncecontinues to emit standard formatted terminal outputuv run ruff check🤖 Generated with Claude Code