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

Method run

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

Source from the content-addressed store, hash-verified

37
38impl Command for MemoryWrite {
39 fn run(&self) -> CliResult<()> {
40 let root = find_repository_root()?;
41 let repo = Repository::open(&root).map_err(CliError::Repository)?;
42
43 // Freeform body from stdin — no lift/gate; this is the raw path.
44 use std::io::Read;
45 let mut content = String::new();
46 std::io::stdin()
47 .read_to_string(&mut content)
48 .map_err(CliError::Io)?;
49
50 let path = bridge::normalize_memory_path(&self.name);
51 let frontmatter = serde_json::json!({
52 "name": self.name.replace(".md", ""),
53 "type": self.r#type,
54 })
55 .to_string();
56
57 let hash = repo
58 .vault_store(
59 &path,
60 VaultEntryType::Memory,
61 content.into_bytes(),
62 frontmatter,
63 )
64 .map_err(CliError::Repository)?;
65 repo.vault_materialize(&path)
66 .map_err(CliError::Repository)?;
67
68 println!("Wrote memory: {} ({})", path, &hash.to_string()[..12]);
69 Ok(())
70 }
71}

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected