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

Method run

atomic-cli/src/commands/memory/write.rs:39–77  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

37
38impl Command for MemoryWrite {
39 fn run(&self) -> CliResult<()> {
40 // Route every form through the service layer: stdin + frontmatter
41 // stay client-side (interactive/file-only); the store + materialize
42 // run handler-side with the hash riding the response.
43 if crate::commands::rpc::memory_write(self)? {
44 return Ok(());
45 }
46
47 let root = find_repository_root()?;
48 let repo = crate::commands::open_repository_with_vault(&root)?;
49
50 // Freeform body from stdin — no lift/gate; this is the raw path.
51 use std::io::Read;
52 let mut content = String::new();
53 std::io::stdin()
54 .read_to_string(&mut content)
55 .map_err(CliError::Io)?;
56
57 let path = bridge::normalize_memory_path(&self.name);
58 let frontmatter = serde_json::json!({
59 "name": self.name.replace(".md", ""),
60 "type": self.r#type,
61 })
62 .to_string();
63
64 let hash = repo
65 .vault_store(
66 &path,
67 VaultEntryType::Memory,
68 content.into_bytes(),
69 frontmatter,
70 )
71 .map_err(CliError::Repository)?;
72 repo.vault_materialize(&path)
73 .map_err(CliError::Repository)?;
74
75 println!("Wrote memory: {} ({})", path, &hash.to_string()[..12]);
76 Ok(())
77 }
78}

Callers

nothing calls this directly

Calls 6

memory_writeFunction · 0.85
find_repository_rootFunction · 0.85
normalize_memory_pathFunction · 0.85
vault_storeMethod · 0.80
vault_materializeMethod · 0.80

Tested by

no test coverage detected