Fix --project flag not working in agent mode

- Add CommonFlags struct to group flags that apply across all modes
- Refactor run_agent_mode() to accept CommonFlags instead of individual params
- Add project loading logic for agent chat mode
- Add integration tests for --project with agent mode

This refactor prevents future bugs where new flags work in one mode
but are forgotten in another.
This commit is contained in:
Dhanji R. Prasanna
2026-01-30 11:28:48 +11:00
parent 51d22b3282
commit 2e21502357
4 changed files with 123 additions and 30 deletions

View File

@@ -305,3 +305,33 @@ fn test_no_auto_memory_in_help_output() {
"Help output should mention --no-auto-memory flag"
);
}
// =============================================================================
// Test: Project option is accepted (including with agent mode)
// =============================================================================
#[test]
fn test_project_option_accepted() {
let output = Command::new(get_g3_binary())
.args(["--project", "/tmp/myproject", "--help"])
.output()
.expect("Failed to execute g3 with project option");
assert!(
output.status.success(),
"--project option should be recognized"
);
}
#[test]
fn test_project_option_with_agent_mode_accepted() {
let output = Command::new(get_g3_binary())
.args(["--agent", "butler", "--chat", "--project", "/tmp/myproject", "--help"])
.output()
.expect("Failed to execute g3 with agent and project options");
assert!(
output.status.success(),
"--project option should work with --agent --chat"
);
}