This file governs the entire visual_interception_event_window/ repository.
Build _cmd (Command Center for AI Agents), a passive terminal agent dashboard — a real-time, high-performance observability surface for monitoring local AI coding agents. _cmd consumes JSON event streams and renders them into a multi-panel TUI and desktop UI without intercepting or interfering with the observed processes.
- Binary name:
_cmd - Primary command:
_cmd(starts the dashboard) - Role: Passive Observer. It consumes JSON event streams and renders them into a multi-panel layout.
- Core Restrictions:
- Non-blocking: The TUI must never block the event processing or input handling.
- Resource Efficient: Must target ~60fps without high CPU usage; uses
tokio::time::interval. - Zero Flicker: Correct use of
ratatuidouble-buffer diffing; avoid manualclear()calls. - Stateless/Passive: It does not modify the state of other agents; it only visualizes observed state.
ratatuifor TUI layout and widgets (cli).egui/eframefor native desktop UI (desktop).axumfor the web API and WebSocket server (web).crosstermfor terminal backend and raw mode handling.tokiofor async runtime and MPSC channels.serdeandserde_jsonfor event parsing.anyhowfor application-level error handling.chronofor precise event timestamping.parking_lotfor low-overheadRwLockacross UI threads.
crates/
├── core/ — domain state, engine, listener, event schemas (no UI deps)
├── cli/ — TUI frontend via ratatui + crossterm
├── desktop/ — desktop frontend via egui/eframe
│ └── src/
│ ├── components/ — reusable UI elements (buttons, badges, dividers)
│ ├── panels/ — major UI regions (terminal, settings, editor)
│ ├── utils/ — pure logic, layout math, search algorithms
│ ├── theme.rs — colors, paddings, and font constants
│ └── desktop_app.rs — the root Orchestrator (state holder)
└── web/ — web API + WebSocket server via axum
Scaling Guidelines (e.g. adding an Editor or new major panels):
- Never bloat
desktop_app.rs: It should only holdAppState, orchestrateaction_tx, and delegate rendering. - Feature Isolation (
panels/): New large features (like an Editor) must live in their ownpanels/editor.rs. - Component Reusability (
components/): Any UI element used in more than one place (buttons, tabs, modals) goes intocomponents/. - Logic Separation (
utils/): Keepeguirendering code separate from math, layout, and search algorithms (utils/).
State access pattern:
state.registry.agents // AgentRegistry — agent data & events
state.terminals.sessions // TerminalManager — PTY sessions
state.ui.selected_* // UiState — ephemeral interaction state- Visual Excellence: The TUI/desktop UI should be extremely premium — modern colors, bold highlights, and clear layouts.
- JSON Compatibility: Internal event schemas must remain compatible with any JSON-streaming agent that follows the snapshot/lifecycle event contract described in
README.md.
- Panic-free: No
unwrap(),expect(), orpanic!macros in production execution paths. Use?,if let, ormatch. - Terminal Hygiene: Use RAII guards (
Dropimplementation) to ensure the terminal is restored (raw mode off, alternate screen left) even on panics or unexpected exits. - Concurrency: UI thread must remain responsive; use
parking_lot::RwLockfor state shared across threads. Never block the egui/ratatui render thread. - IME Disabled (
desktop):ctx.output_mut(|o| o.ime = None)must run every frame to prevent macOS IME interference.
- Treat git history as part of the agent memory for this repo.
- Every meaningful change should be committed with a Conventional Commit style subject:
feat:,fix:,refactor:,test:,docs:,chore:. - For non-trivial commits, include lore-style trailers:
Constraint: ...Rejected: ...Confidence: low|medium|highScope-risk: narrow|moderate|broadDirective: ...Tested: ...Not-tested: ...
- Do not combine unrelated work into one commit; preserve a searchable knowledge trail.
Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment.
Don't assume. Don't hide confusion. Surface tradeoffs.
Before implementing:
- State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them — don't pick silently.
- If a simpler approach exists, say so. Push back when warranted.
- If something is unclear, stop. Name what's confusing. Ask.
Minimum code that solves the problem. Nothing speculative.
- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
Touch only what you must. Clean up only your own mess.
When editing existing code:
- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it — don't delete it.
When your changes create orphans:
- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.
The test: Every changed line should trace directly to the user's request.
Define success criteria. Loop until verified.
Transform tasks into verifiable goals:
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"
For multi-step tasks, state a brief plan:
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]
Always run cargo check --workspace before declaring a task done.
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
These guidelines are working if: fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.