feat: enhance agent personality, tool guidance, and memory hygiene
- Expand communication style presets (professional, expressive, custom) - Enrich SOUL.md with human-like tone and emoji-awareness guidance - Add crash recovery and sub-task scoping guidance to AGENTS.md scaffold - Add 'Use when / Don't use when' guidance to TOOLS.md and runtime prompts - Implement memory hygiene system with configurable archiving and retention - Add MemoryConfig options: hygiene_enabled, archive_after_days, purge_after_days, conversation_retention_days - Archive old daily memory and session files to archive subdirectories - Purge old archives and prune stale SQLite conversation rows - Add comprehensive tests for new features
This commit is contained in:
parent
f4f180ac41
commit
ec2d5cc93d
29 changed files with 3600 additions and 116 deletions
|
|
@ -7,17 +7,21 @@ pub use traits::RuntimeAdapter;
|
|||
use crate::config::RuntimeConfig;
|
||||
|
||||
/// Factory: create the right runtime from config
|
||||
pub fn create_runtime(config: &RuntimeConfig) -> Box<dyn RuntimeAdapter> {
|
||||
pub fn create_runtime(config: &RuntimeConfig) -> anyhow::Result<Box<dyn RuntimeAdapter>> {
|
||||
match config.kind.as_str() {
|
||||
"native" | "docker" => Box::new(NativeRuntime::new()),
|
||||
"cloudflare" => {
|
||||
tracing::warn!("Cloudflare runtime not yet implemented, falling back to native");
|
||||
Box::new(NativeRuntime::new())
|
||||
}
|
||||
_ => {
|
||||
tracing::warn!("Unknown runtime '{}', falling back to native", config.kind);
|
||||
Box::new(NativeRuntime::new())
|
||||
}
|
||||
"native" => Ok(Box::new(NativeRuntime::new())),
|
||||
"docker" => anyhow::bail!(
|
||||
"runtime.kind='docker' is not implemented yet. Use runtime.kind='native' until container runtime support lands."
|
||||
),
|
||||
"cloudflare" => anyhow::bail!(
|
||||
"runtime.kind='cloudflare' is not implemented yet. Use runtime.kind='native' for now."
|
||||
),
|
||||
other if other.trim().is_empty() => anyhow::bail!(
|
||||
"runtime.kind cannot be empty. Supported values: native"
|
||||
),
|
||||
other => anyhow::bail!(
|
||||
"Unknown runtime kind '{other}'. Supported values: native"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -30,44 +34,52 @@ mod tests {
|
|||
let cfg = RuntimeConfig {
|
||||
kind: "native".into(),
|
||||
};
|
||||
let rt = create_runtime(&cfg);
|
||||
let rt = create_runtime(&cfg).unwrap();
|
||||
assert_eq!(rt.name(), "native");
|
||||
assert!(rt.has_shell_access());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn factory_docker_returns_native() {
|
||||
fn factory_docker_errors() {
|
||||
let cfg = RuntimeConfig {
|
||||
kind: "docker".into(),
|
||||
};
|
||||
let rt = create_runtime(&cfg);
|
||||
assert_eq!(rt.name(), "native");
|
||||
match create_runtime(&cfg) {
|
||||
Err(err) => assert!(err.to_string().contains("not implemented")),
|
||||
Ok(_) => panic!("docker runtime should error"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn factory_cloudflare_falls_back() {
|
||||
fn factory_cloudflare_errors() {
|
||||
let cfg = RuntimeConfig {
|
||||
kind: "cloudflare".into(),
|
||||
};
|
||||
let rt = create_runtime(&cfg);
|
||||
assert_eq!(rt.name(), "native");
|
||||
match create_runtime(&cfg) {
|
||||
Err(err) => assert!(err.to_string().contains("not implemented")),
|
||||
Ok(_) => panic!("cloudflare runtime should error"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn factory_unknown_falls_back() {
|
||||
fn factory_unknown_errors() {
|
||||
let cfg = RuntimeConfig {
|
||||
kind: "wasm-edge-unknown".into(),
|
||||
};
|
||||
let rt = create_runtime(&cfg);
|
||||
assert_eq!(rt.name(), "native");
|
||||
match create_runtime(&cfg) {
|
||||
Err(err) => assert!(err.to_string().contains("Unknown runtime kind")),
|
||||
Ok(_) => panic!("unknown runtime should error"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn factory_empty_falls_back() {
|
||||
fn factory_empty_errors() {
|
||||
let cfg = RuntimeConfig {
|
||||
kind: String::new(),
|
||||
};
|
||||
let rt = create_runtime(&cfg);
|
||||
assert_eq!(rt.name(), "native");
|
||||
match create_runtime(&cfg) {
|
||||
Err(err) => assert!(err.to_string().contains("cannot be empty")),
|
||||
Ok(_) => panic!("empty runtime should error"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue