Add --project CLI flag for loading projects at startup

Adds a new --project <PATH> flag that loads project files (brief.md,
contacts.yaml, status.md) at startup, similar to the /project command
but WITHOUT auto-executing the project status prompt.

Changes:
- Add --project flag to cli_args.rs
- Add load_and_validate_project() helper in project.rs (shared by both
  --project flag and /project command)
- Modify run_interactive() to accept optional initial_project parameter
- Wire up --project in lib.rs to load project before interactive mode
- Refactor /project command to use shared helper (reduces duplication)
- Add 4 new tests for load_and_validate_project()
This commit is contained in:
Dhanji R. Prasanna
2026-01-29 11:06:08 +11:00
parent 05d253ee2a
commit 5ea43d7b39
7 changed files with 158 additions and 33 deletions

View File

@@ -69,6 +69,7 @@ async fn execute_user_input<W: UiWriter>(
/// Run interactive mode with console output.
/// If `agent_name` is Some, we're in agent+chat mode: skip session resume/verbose welcome,
/// and use the agent name as the prompt (e.g., "butler>").
/// If `initial_project` is Some, the project is pre-loaded (from --project flag).
pub async fn run_interactive<W: UiWriter>(
mut agent: Agent<W>,
show_prompt: bool,
@@ -77,6 +78,7 @@ pub async fn run_interactive<W: UiWriter>(
workspace_path: &Path,
new_session: bool,
agent_name: Option<&str>,
initial_project: Option<Project>,
) -> Result<()> {
let output = SimpleOutput::new();
let from_agent_mode = agent_name.is_some();
@@ -189,8 +191,22 @@ pub async fn run_interactive<W: UiWriter>(
let mut multiline_buffer = String::new();
let mut in_multiline = false;
// Track active project
let mut active_project: Option<Project> = None;
// Track active project (may be pre-loaded from --project flag)
let mut active_project: Option<Project> = initial_project;
// If we have an initial project, display its status
if let Some(ref project) = active_project {
let project_name = project.path
.file_name()
.and_then(|n| n.to_str())
.unwrap_or("project");
G3Status::loading_project(project_name, &project.format_loaded_status());
// Print newline after the loading message (G3Status::loading_project doesn't add one)
use std::io::Write;
println!();
std::io::stdout().flush().ok();
}
loop {
// Display context window progress bar before each prompt