use config for identity node references
Replace hardcoded "identity" lookups with config.core_nodes so experience mining and init work with whatever core nodes are configured, not just a node named "identity". Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
parent
4bc74ca4a2
commit
ba30f5b3e4
2 changed files with 16 additions and 9 deletions
|
|
@ -330,10 +330,12 @@ pub fn experience_mine(
|
|||
let conversation = format_conversation(&messages);
|
||||
println!(" {} messages, {} chars", messages.len(), conversation.len());
|
||||
|
||||
// Load identity
|
||||
let identity = store.nodes.get("identity")
|
||||
.map(|n| n.content.clone())
|
||||
.unwrap_or_default();
|
||||
// Load core identity nodes for context
|
||||
let cfg = crate::config::get();
|
||||
let identity: String = cfg.core_nodes.iter()
|
||||
.filter_map(|k| store.nodes.get(k).map(|n| n.content.as_str()))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n\n");
|
||||
|
||||
// Get recent episodic entries to avoid duplication
|
||||
let mut journal: Vec<_> = store.nodes.values()
|
||||
|
|
|
|||
15
src/main.rs
15
src/main.rs
|
|
@ -359,11 +359,16 @@ fn cmd_init() -> Result<(), String> {
|
|||
// Initialize store and seed default identity node if empty
|
||||
let mut store = store::Store::load()?;
|
||||
let count = store.init_from_markdown()?;
|
||||
if !store.nodes.contains_key("identity") {
|
||||
let default_identity = include_str!("../defaults/identity.md");
|
||||
store.upsert("identity", default_identity)
|
||||
.map_err(|e| format!("seed identity: {}", e))?;
|
||||
println!("Seeded identity in store");
|
||||
// Seed default core nodes if missing
|
||||
for key in &cfg.core_nodes {
|
||||
if !store.nodes.contains_key(key.as_str()) {
|
||||
if key == "identity" {
|
||||
let default = include_str!("../defaults/identity.md");
|
||||
store.upsert(key, default)
|
||||
.map_err(|e| format!("seed {}: {}", key, e))?;
|
||||
println!("Seeded {} in store", key);
|
||||
}
|
||||
}
|
||||
}
|
||||
store.save()?;
|
||||
println!("Indexed {} memory units", count);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue