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);
|
let conversation = format_conversation(&messages);
|
||||||
println!(" {} messages, {} chars", messages.len(), conversation.len());
|
println!(" {} messages, {} chars", messages.len(), conversation.len());
|
||||||
|
|
||||||
// Load identity
|
// Load core identity nodes for context
|
||||||
let identity = store.nodes.get("identity")
|
let cfg = crate::config::get();
|
||||||
.map(|n| n.content.clone())
|
let identity: String = cfg.core_nodes.iter()
|
||||||
.unwrap_or_default();
|
.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
|
// Get recent episodic entries to avoid duplication
|
||||||
let mut journal: Vec<_> = store.nodes.values()
|
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
|
// Initialize store and seed default identity node if empty
|
||||||
let mut store = store::Store::load()?;
|
let mut store = store::Store::load()?;
|
||||||
let count = store.init_from_markdown()?;
|
let count = store.init_from_markdown()?;
|
||||||
if !store.nodes.contains_key("identity") {
|
// Seed default core nodes if missing
|
||||||
let default_identity = include_str!("../defaults/identity.md");
|
for key in &cfg.core_nodes {
|
||||||
store.upsert("identity", default_identity)
|
if !store.nodes.contains_key(key.as_str()) {
|
||||||
.map_err(|e| format!("seed identity: {}", e))?;
|
if key == "identity" {
|
||||||
println!("Seeded identity in store");
|
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()?;
|
store.save()?;
|
||||||
println!("Indexed {} memory units", count);
|
println!("Indexed {} memory units", count);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue