config: unify memory and agent config into single module
Both hippocampus/config.rs and agent/config.rs read from the same config file (~/.config/poc-agent/config.json5). Having two separate implementations was a footgun — load_context_groups() was duplicated three times across the codebase. Merged into src/config.rs: - Config (memory settings, global get()/reload()) - AppConfig (agent backend/model settings, figment-based loading) - SessionConfig (resolved agent session, renamed from agent's Config) - Single ContextGroup/ContextSource definition used everywhere Eliminated: duplicate load_context_groups(), duplicate ContextGroup definition in identity.rs, duplicate config file path constants. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
2f3fbb3353
commit
228815d807
7 changed files with 393 additions and 467 deletions
|
|
@ -5,17 +5,9 @@
|
|||
// from the shared config file.
|
||||
|
||||
use anyhow::Result;
|
||||
use serde::Deserialize;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct ContextGroup {
|
||||
pub label: String,
|
||||
#[serde(default)]
|
||||
pub keys: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub source: Option<String>, // "file" or "journal"
|
||||
}
|
||||
use crate::config::{ContextGroup, ContextSource};
|
||||
|
||||
/// Read a file if it exists and is non-empty.
|
||||
fn read_nonempty(path: &Path) -> Option<String> {
|
||||
|
|
@ -96,12 +88,12 @@ fn load_memory_files(cwd: &Path, memory_project: Option<&Path>, context_groups:
|
|||
|
||||
// Load from context_groups
|
||||
for group in context_groups {
|
||||
match group.source.as_deref() {
|
||||
Some("journal") => {
|
||||
match group.source {
|
||||
ContextSource::Journal => {
|
||||
// Journal loading handled separately
|
||||
continue;
|
||||
}
|
||||
Some("file") | None => {
|
||||
ContextSource::File | ContextSource::Store => {
|
||||
// File source - load each key as a file
|
||||
for key in &group.keys {
|
||||
let filename = format!("{}.md", key);
|
||||
|
|
@ -113,9 +105,7 @@ fn load_memory_files(cwd: &Path, memory_project: Option<&Path>, context_groups:
|
|||
}
|
||||
}
|
||||
}
|
||||
Some(other) => {
|
||||
eprintln!("Unknown context group source: {}", other);
|
||||
}
|
||||
// All variants covered
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue