The cli_engineer tool features a flexible and informative user interface and logging system designed to provide insight into the agent's operations. It offers two primary UI modes and a robust logging mechanism that can operate in tandem.
The application provides two distinct user experiences: a real-time Dashboard UI (default) and an Enhanced Text UI for simpler, script-friendly output.
The Dashboard is the default, recommended interface for interactive use. It provides a rich, in-place updating view of the agent's status without scrolling.
Key Features:
- Real-Time Metrics: Displays API calls, total cost, artifacts created, and context usage.
- Live Progress: Shows the current phase, task description, and overall progress.
- In-Place Updates: Uses
crosstermto control the terminal, rendering a static layout that updates its content dynamically. - Dual Log Panes:
- Session Logs: A top pane shows formatted and colored log output (
INFO,WARN,ERROR). - Model Reasoning: A bottom pane streams the LLM's "thoughts" or reasoning process in real-time, offering a look into how it makes decisions.
- Session Logs: A top pane shows formatted and colored log output (
- Event-Driven: The UI listens to events from the
EventBusto update its state, decoupling it from the core application logic.
This UI is managed by the DashboardUI struct and is initialized in main.rs when the --no-dashboard flag is absent.
// From src/main.rs (simplified)
if !args.no_dashboard {
// Use dashboard UI
let mut ui = DashboardUI::new(false);
ui.set_event_bus(event_bus.clone());
ui.start()?;
// ... run agent ...
ui.finish()?;
}When the --no-dashboard flag is used, the application falls back to a more traditional, scrolling terminal output, managed by the EnhancedUI struct.
Key Features:
- Progress Bars: Uses the
indicatifcrate to display multi-line progress bars for the main task and metrics. - Colored Output: Provides clear, color-coded status messages for different events (e.g., task start, artifact creation, errors).
- Session Summary: Prints a final summary of metrics upon completion.
- Script-Friendly: The linear, scrolling output is suitable for CI/CD pipelines or logging to a file.
The src/ui.rs file contains a basic, legacy UI handler (UIHandler) that shows a simple spinning character (|, /, -, \). It serves as a minimal fallback but is largely superseded by the DashboardUI and EnhancedUI.
The logging system is designed to work seamlessly with both UI modes and provide persistent records of agent sessions.
This is the primary logger used with the Dashboard UI. It's a custom implementation of the log::Log trait.
How it Works:
- It's initialized in
main.rswhen in dashboard mode. - It captures all log records generated by the application (using the
logcrate macros likeinfo!,warn!, etc.). - Instead of printing directly to the console, it creates an
Event::LogLineand emits it to theEventBus. - The
DashboardUIsubscribes to theEventBusand displays theseLogLineevents in its log pane. - If file logging is enabled (
-vflag), it simultaneously writes the formatted log message to a timestamped file (e.g.,cli_engineer_20240915_183000.log).
This architecture decouples the logging source from the display, allowing the UI to handle rendering without interfering with the application's execution flow.
This logger is used in --no-dashboard mode. It's a straightforward setup using the simplelog crate.
How it Works:
- It initializes a
SimpleLoggerthat writes directly to the standard error stream. - The log level is determined by the
-vflag (Infoif verbose,Warnotherwise). - The
init_with_file_loggingfunction configures a file writer to save all session logs to a timestamped file when-vis active.
The choice of UI and logger is determined at startup in main.rs:
-
Default Mode (No flags):
DashboardUIis created.DashboardLoggeris initialized.DashboardLoggercaptures logs ->EventBus.DashboardUIlistens toEventBusand renders logs, metrics, and progress.
-
Simple Mode (
--no-dashboard):EnhancedUIis created.logger::init()orlogger::init_with_file_logging()is called.SimpleLoggerwrites logs directly to the console and/or a file.EnhancedUIlistens to theEventBusfor progress and status events to update its progress bars.