cli: convert cmd_edit to use memory_rpc
Add raw parameter to memory_render for getting content without links footer. cmd_edit now uses memory_render(raw=true) to read and memory_write to save. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
366b17163d
commit
4b4271f618
2 changed files with 20 additions and 20 deletions
|
|
@ -228,11 +228,16 @@ pub fn journal_tools() -> [super::Tool; 3] {
|
|||
|
||||
async fn render(args: &serde_json::Value) -> Result<String> {
|
||||
let key = get_str(args, "key")?;
|
||||
let raw = args.get("raw").and_then(|v| v.as_bool()).unwrap_or(false);
|
||||
let arc = cached_store().await?;
|
||||
let store = arc.lock().await;
|
||||
Ok(MemoryNode::from_store(&store, key)
|
||||
.ok_or_else(|| anyhow::anyhow!("node not found: {}", key))?
|
||||
.render())
|
||||
let node = MemoryNode::from_store(&store, key)
|
||||
.ok_or_else(|| anyhow::anyhow!("node not found: {}", key))?;
|
||||
if raw {
|
||||
Ok(node.content)
|
||||
} else {
|
||||
Ok(node.render())
|
||||
}
|
||||
}
|
||||
|
||||
async fn write(agent: &Option<std::sync::Arc<crate::agent::Agent>>, args: &serde_json::Value) -> Result<String> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue