poc-agent: read context_groups from config instead of hardcoded list
- Remove MEMORY_FILES constant from identity.rs - Add ContextGroup struct for deserializing from config - Load context_groups from ~/.config/poc-agent/config.json5 - Check ~/.config/poc-agent/ first for identity files, then project/global - Debug screen now shows what's actually configured This eliminates the hardcoded duplication and makes the debug output match what's in the config file.
This commit is contained in:
parent
966219720a
commit
aa46b1d5a6
9 changed files with 346 additions and 654 deletions
|
|
@ -843,11 +843,34 @@ impl Session {
|
|||
self.send_context_info();
|
||||
}
|
||||
|
||||
/// Load context_groups from the shared config file.
|
||||
fn load_context_groups(&self) -> Vec<identity::ContextGroup> {
|
||||
let config_path = dirs::home_dir()
|
||||
.unwrap_or_else(|| PathBuf::from("."))
|
||||
.join(".config/poc-agent/config.json5");
|
||||
|
||||
if let Ok(content) = std::fs::read_to_string(&config_path) {
|
||||
let config: Result<serde_json::Value, _> = json5::from_str(&content);
|
||||
if let Ok(config) = config {
|
||||
if let Some(memory) = config.get("memory") {
|
||||
if let Some(groups) = memory.get("context_groups") {
|
||||
if let Ok(context_groups) = serde_json::from_value(groups.clone()) {
|
||||
return context_groups;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// Send context loading info to the TUI debug screen.
|
||||
fn send_context_info(&self) {
|
||||
let context_groups = self.load_context_groups();
|
||||
let (instruction_files, memory_files) = identity::context_file_info(
|
||||
&self.config.prompt_file,
|
||||
self.config.app.memory_project.as_deref(),
|
||||
&context_groups,
|
||||
);
|
||||
let _ = self.ui_tx.send(UiMessage::ContextInfoUpdate(ContextInfo {
|
||||
model: self.config.model.clone(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue