MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / memory_write

Function memory_write

atomic-cli/src/commands/rpc.rs:6372–6410  ·  view source on GitHub ↗

`atomic memory write` over UpdateVaultEntity's MemoryWrite arm — the stdin read + frontmatter stay client-side (interactive/file-only); the store + materialize run handler-side and the content hash rides the response.

(args: &super::memory::write::MemoryWrite)

Source from the content-addressed store, hash-verified

6370/// the store + materialize run handler-side and the content hash rides
6371/// the response.
6372pub fn memory_write(args: &super::memory::write::MemoryWrite) -> CliResult<bool> {
6373 // Freeform body from stdin — no lift/gate; this is the raw path.
6374 use std::io::Read;
6375 let mut content = String::new();
6376 std::io::stdin()
6377 .read_to_string(&mut content)
6378 .map_err(CliError::Io)?;
6379 let path = crate::commands::memory::bridge::normalize_memory_path(&args.name);
6380 let frontmatter = serde_json::json!({
6381 "name": args.name.replace(".md", ""),
6382 "type": args.r#type,
6383 })
6384 .to_string();
6385 let Some(session) = Service::open()? else {
6386 return Ok(false);
6387 };
6388 let request = pb::UpdateVaultEntityRequest {
6389 repository: Some(session.reference.clone()),
6390 meta: request_meta(),
6391 kind: Kind::Memory as i32,
6392 id: args.name.clone(),
6393 update: Some(UpdateKind::MemoryWrite(pb::MemoryWriteAction {
6394 path: path.clone(),
6395 content: content.into_bytes(),
6396 frontmatter_json: frontmatter,
6397 })),
6398 expected: None,
6399 view: None,
6400 };
6401 let response = session.update_vault_entity(request)?;
6402 let hash = response
6403 .write_hash
6404 .as_ref()
6405 .and_then(|hash| hash.value.clone().try_into().ok())
6406 .map(|bytes: [u8; 32]| Merkle(bytes).to_base32())
6407 .unwrap_or_default();
6408 println!("Wrote memory: {} ({})", path, &hash[..12]);
6409 Ok(true)
6410}
6411
6412/// `atomic vault goal start` over CreateVaultEntity (kind=GOAL) —
6413/// GoalStartOptions' fields ride the request and the created goal's

Callers 1

runMethod · 0.85

Calls 10

normalize_memory_pathFunction · 0.85
openFunction · 0.85
MemoryWriteClass · 0.85
MerkleClass · 0.85
as_refMethod · 0.80
request_metaFunction · 0.70
cloneMethod · 0.45
update_vault_entityMethod · 0.45
okMethod · 0.45
to_base32Method · 0.45

Tested by

no test coverage detected