observation agent rewrite, edit command, daemon fixes
- observation.agent: rewritten to navigate graph and prefer refining existing nodes over creating new ones. Identity-framed prompt, goals over rules. - poc-memory edit: opens node in $EDITOR, writes back on save, no-op if unchanged - daemon: remove extra_workers (jobkit tokio migration dropped it), remove sequential chaining of same-type agents (in-flight exclusion is sufficient) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3b30a6abae
commit
869a2fbc38
6 changed files with 97 additions and 70 deletions
|
|
@ -399,6 +399,60 @@ pub fn cmd_write(key: &[String]) -> Result<(), String> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmd_edit(key: &[String]) -> Result<(), String> {
|
||||
if key.is_empty() {
|
||||
return Err("edit requires a key".into());
|
||||
}
|
||||
let raw_key = key.join(" ");
|
||||
let store = store::Store::load()?;
|
||||
let key = store.resolve_key(&raw_key).unwrap_or(raw_key.clone());
|
||||
|
||||
let content = store.nodes.get(&key)
|
||||
.map(|n| n.content.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
let tmp = std::env::temp_dir().join(format!("poc-memory-edit-{}.md", key.replace('/', "_")));
|
||||
std::fs::write(&tmp, &content)
|
||||
.map_err(|e| format!("write temp file: {}", e))?;
|
||||
|
||||
let editor = std::env::var("EDITOR").unwrap_or_else(|_| "vi".into());
|
||||
let status = std::process::Command::new(&editor)
|
||||
.arg(&tmp)
|
||||
.status()
|
||||
.map_err(|e| format!("spawn {}: {}", editor, e))?;
|
||||
|
||||
if !status.success() {
|
||||
let _ = std::fs::remove_file(&tmp);
|
||||
return Err(format!("{} exited with {}", editor, status));
|
||||
}
|
||||
|
||||
let new_content = std::fs::read_to_string(&tmp)
|
||||
.map_err(|e| format!("read temp file: {}", e))?;
|
||||
let _ = std::fs::remove_file(&tmp);
|
||||
|
||||
if new_content == content {
|
||||
println!("No change: '{}'", key);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if new_content.trim().is_empty() {
|
||||
return Err("Content is empty, aborting".into());
|
||||
}
|
||||
|
||||
drop(store);
|
||||
let mut store = store::Store::load()?;
|
||||
let result = store.upsert(&key, &new_content)?;
|
||||
match result {
|
||||
"unchanged" => println!("No change: '{}'", key),
|
||||
"updated" => println!("Updated '{}' (v{})", key, store.nodes[&key].version),
|
||||
_ => println!("Created '{}'", key),
|
||||
}
|
||||
if result != "unchanged" {
|
||||
store.save()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmd_lookup_bump(keys: &[String]) -> Result<(), String> {
|
||||
if keys.is_empty() {
|
||||
return Err("lookup-bump requires at least one key".into());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue