Lyra Agent hinzugefügt, Multi-Agent Routing, BaseAgent refactoring

This commit is contained in:
Sithies
2026-03-16 23:30:42 +01:00
parent 6fc1648939
commit 750fe1f5f6
22 changed files with 454 additions and 111 deletions
+6 -1
View File
@@ -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;
+59
View File
@@ -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(&section_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(())
}
}