Lyra Agent hinzugefügt, Multi-Agent Routing, BaseAgent refactoring
This commit is contained in:
@@ -5,3 +5,5 @@ edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nazarick-core = { path = "../nazarick-core" }
|
||||
tracing = "0.1.44"
|
||||
anyhow = "1.0.102"
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
// Nazarick - Explicit sub-skills without generic shell access
|
||||
// crates/skills/src/lib.rs
|
||||
//
|
||||
// Skills — explizite Fähigkeiten für Nazarick-Agenten.
|
||||
// Kein generischer Shell-Zugriff — jeder Skill ist bewusst implementiert.
|
||||
|
||||
pub mod personality;
|
||||
@@ -0,0 +1,59 @@
|
||||
// crates/skills/src/personality.rs
|
||||
//
|
||||
// Personality Skill — implementiert PersonalityWriter Trait.
|
||||
// Schreibt Persönlichkeits-Updates in soul_personality.md.
|
||||
|
||||
use nazarick_core::agent::PersonalityWriter;
|
||||
use tracing::info;
|
||||
|
||||
/// Konkrete Implementierung des PersonalityWriter Traits.
|
||||
/// Wird in main.rs erstellt und via Dependency Injection an SkillExecutor übergeben.
|
||||
pub struct PersonalitySkill {
|
||||
/// Pfad zur soul_personality.md des Agenten
|
||||
path: String,
|
||||
}
|
||||
|
||||
impl PersonalitySkill {
|
||||
/// Erstellt einen neuen PersonalitySkill für einen Agenten.
|
||||
/// `path` → Pfad zur soul_personality.md
|
||||
pub fn new(path: impl Into<String>) -> Self {
|
||||
Self { path: path.into() }
|
||||
}
|
||||
}
|
||||
|
||||
impl PersonalityWriter for PersonalitySkill {
|
||||
/// Aktualisiert ein Feld in soul_personality.md.
|
||||
/// Abschnitt wird ersetzt wenn vorhanden, sonst angehängt.
|
||||
fn update(&self, field: &str, value: &str) -> anyhow::Result<()> {
|
||||
let content = std::fs::read_to_string(&self.path)?;
|
||||
let section_header = format!("## {}", field);
|
||||
let new_section = format!("## {}\n{}", field, value);
|
||||
|
||||
let updated = if content.contains(§ion_header) {
|
||||
let mut result = String::new();
|
||||
let mut in_section = false;
|
||||
|
||||
for line in content.lines() {
|
||||
if line.trim_start().starts_with("## ") && line.contains(field) {
|
||||
result.push_str(&new_section);
|
||||
result.push('\n');
|
||||
in_section = true;
|
||||
} else if line.trim_start().starts_with("## ") && in_section {
|
||||
in_section = false;
|
||||
result.push_str(line);
|
||||
result.push('\n');
|
||||
} else if !in_section {
|
||||
result.push_str(line);
|
||||
result.push('\n');
|
||||
}
|
||||
}
|
||||
result
|
||||
} else {
|
||||
format!("{}\n{}\n", content.trim_end(), new_section)
|
||||
};
|
||||
|
||||
std::fs::write(&self.path, updated)?;
|
||||
info!(path = %self.path, field = %field, "Persönlichkeit aktualisiert");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user