refactor(g3-cli): eliminate code-path aliasing in config and project content loading
Consolidate duplicated logic into canonical shared functions: - Extract load_config_with_cli_overrides() to utils.rs - Was duplicated in lib.rs and accumulative.rs with subtle differences - lib.rs version had Chrome diagnostics + provider validation - accumulative.rs version was missing both - Now all callers use the complete canonical implementation - Extract combine_project_content() to project_files.rs - Was duplicated inline in lib.rs and agent_mode.rs - Simplified implementation using iterator flatten - Added unit tests for all cases This eliminates drift risk where the duplicated implementations could diverge over time (accumulative.rs was already missing Chrome diagnostics and provider validation). Agent: fowler
This commit is contained in:
@@ -7,7 +7,7 @@ use tracing::debug;
|
||||
use g3_core::ui_writer::UiWriter;
|
||||
use g3_core::Agent;
|
||||
|
||||
use crate::project_files::{read_agents_config, read_project_memory, read_project_readme};
|
||||
use crate::project_files::{combine_project_content, read_agents_config, read_project_memory, read_project_readme};
|
||||
use crate::simple_output::SimpleOutput;
|
||||
use crate::ui_writer_impl::ConsoleUiWriter;
|
||||
|
||||
@@ -177,23 +177,11 @@ pub async fn run_agent_mode(
|
||||
));
|
||||
|
||||
// Combine all content for the agent's context
|
||||
let combined_content = {
|
||||
let mut parts = Vec::new();
|
||||
if let Some(agents) = agents_content_opt {
|
||||
parts.push(agents);
|
||||
}
|
||||
if let Some(readme) = readme_content_opt {
|
||||
parts.push(readme);
|
||||
}
|
||||
if let Some(memory) = memory_content_opt {
|
||||
parts.push(memory);
|
||||
}
|
||||
if parts.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(parts.join("\n\n"))
|
||||
}
|
||||
};
|
||||
let combined_content = combine_project_content(
|
||||
agents_content_opt,
|
||||
readme_content_opt,
|
||||
memory_content_opt,
|
||||
);
|
||||
|
||||
// Create agent with custom system prompt
|
||||
let ui_writer = ConsoleUiWriter::new();
|
||||
|
||||
Reference in New Issue
Block a user