forked from kent/consciousness
Remove ContextSource::File — all identity in store now
Identity files migrated to memory nodes: - identity, core-personality, reflections, where-am-i Removed: - ContextSource::File enum variant - File source parsing and handling - load_memory_file helper function Config now only supports Store and Journal sources. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
e8462af505
commit
688e8dbc3e
3 changed files with 1 additions and 32 deletions
|
|
@ -190,13 +190,6 @@ pub async fn get_group_content(group: &crate::config::ContextGroup, cfg: &crate:
|
||||||
}
|
}
|
||||||
results
|
results
|
||||||
}
|
}
|
||||||
crate::config::ContextSource::File => {
|
|
||||||
group.keys.iter().filter_map(|key| {
|
|
||||||
let content = std::fs::read_to_string(cfg.identity_dir.join(key)).ok()?;
|
|
||||||
if content.trim().is_empty() { return None; }
|
|
||||||
Some((key.clone(), content.trim().to_string()))
|
|
||||||
}).collect()
|
|
||||||
}
|
|
||||||
crate::config::ContextSource::Store => {
|
crate::config::ContextSource::Store => {
|
||||||
let mut results = Vec::new();
|
let mut results = Vec::new();
|
||||||
for key in &group.keys {
|
for key in &group.keys {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ pub enum ContextSource {
|
||||||
#[serde(alias = "")]
|
#[serde(alias = "")]
|
||||||
#[default]
|
#[default]
|
||||||
Store,
|
Store,
|
||||||
File,
|
|
||||||
Journal,
|
Journal,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,7 +319,6 @@ impl Config {
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let source = match obj.get("source").and_then(|v| v.as_str()) {
|
let source = match obj.get("source").and_then(|v| v.as_str()) {
|
||||||
Some("file") => ContextSource::File,
|
|
||||||
Some("journal") => ContextSource::Journal,
|
Some("journal") => ContextSource::Journal,
|
||||||
_ => ContextSource::Store,
|
_ => ContextSource::Store,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,6 @@ fn read_nonempty(path: &Path) -> Option<String> {
|
||||||
std::fs::read_to_string(path).ok().filter(|s| !s.trim().is_empty())
|
std::fs::read_to_string(path).ok().filter(|s| !s.trim().is_empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try project dir first, then global.
|
|
||||||
fn load_memory_file(name: &str, project: Option<&Path>, global: &Path) -> Option<String> {
|
|
||||||
project.and_then(|p| read_nonempty(&p.join(name)))
|
|
||||||
.or_else(|| read_nonempty(&global.join(name)))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Walk from cwd to git root collecting instruction files (CLAUDE.md / POC.md).
|
/// Walk from cwd to git root collecting instruction files (CLAUDE.md / POC.md).
|
||||||
///
|
///
|
||||||
/// On Anthropic models, loads CLAUDE.md. On other models, prefers POC.md
|
/// On Anthropic models, loads CLAUDE.md. On other models, prefers POC.md
|
||||||
|
|
@ -67,19 +61,13 @@ fn find_context_files(cwd: &Path, prompt_file: &str) -> Vec<PathBuf> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load memory files from config's context_groups.
|
/// Load memory files from config's context_groups.
|
||||||
/// For file sources, checks:
|
/// Store sources load from the memory graph. Journal source loads recent entries.
|
||||||
/// 1. ~/.consciousness/config/ (primary config dir)
|
|
||||||
/// 2. Project dir (if set)
|
|
||||||
/// 3. Global (~/.consciousness/)
|
|
||||||
/// For journal source, loads recent journal entries.
|
|
||||||
async fn load_memory_files(memory_project: Option<&Path>, context_groups: &[ContextGroup]) -> Vec<(String, String)> {
|
async fn load_memory_files(memory_project: Option<&Path>, context_groups: &[ContextGroup]) -> Vec<(String, String)> {
|
||||||
let home = match dirs::home_dir() {
|
let home = match dirs::home_dir() {
|
||||||
Some(h) => h,
|
Some(h) => h,
|
||||||
None => return Vec::new(),
|
None => return Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Primary config directory
|
|
||||||
let config_dir = home.join(".consciousness/identity");
|
|
||||||
let global = home.join(".consciousness");
|
let global = home.join(".consciousness");
|
||||||
let project = memory_project.map(PathBuf::from);
|
let project = memory_project.map(PathBuf::from);
|
||||||
|
|
||||||
|
|
@ -102,16 +90,6 @@ async fn load_memory_files(memory_project: Option<&Path>, context_groups: &[Cont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ContextSource::File => {
|
|
||||||
for key in &group.keys {
|
|
||||||
let filename = if key.ends_with(".md") { key.clone() } else { format!("{}.md", key) };
|
|
||||||
if let Some(content) = read_nonempty(&config_dir.join(&filename)) {
|
|
||||||
memories.push((key.clone(), content));
|
|
||||||
} else if let Some(content) = load_memory_file(&filename, project.as_deref(), &global) {
|
|
||||||
memories.push((key.clone(), content));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue