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

Method run

atomic-cli/src/commands/memory/show.rs:26–76  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

24
25impl Command for MemoryShow {
26 fn run(&self) -> CliResult<()> {
27 let root = find_repository_root()?;
28 let repo = Repository::open(&root).map_err(CliError::Repository)?;
29
30 // Pure read-time projection: lift then render. No gate, no proof
31 // requirement — this must work on a plain (un-attested) memory. If a
32 // FRESH attestation exists we project that (so `show` reflects the
33 // attested author/proof); a stale one warns and falls back to the raw
34 // node.
35 let inputs = bridge::read_memory(&repo, &self.id)?;
36 if bridge::is_freeform_memory(&inputs) {
37 if self.json {
38 println!(
39 "{}",
40 serde_json::to_string_pretty(&serde_json::json!({
41 "path": bridge::normalize_memory_path(&self.id),
42 "content": inputs.body,
43 "frontmatter": inputs.frontmatter,
44 }))
45 .unwrap()
46 );
47 } else {
48 print!("{}", inputs.body);
49 }
50 return Ok(());
51 }
52
53 let node = match bridge::load_attestation(&repo, &self.id, &inputs)? {
54 bridge::Attestation::Fresh(node) => *node,
55 bridge::Attestation::Stale(_) => {
56 eprintln!(
57 "warning: the attestation for {} is stale; showing the current \
58 (un-attested) memory.",
59 self.id
60 );
61 bridge::lift(&inputs)?
62 }
63 bridge::Attestation::None => bridge::lift(&inputs)?,
64 };
65
66 if self.json {
67 println!(
68 "{}",
69 serde_json::to_string_pretty(&node.to_value()).unwrap()
70 );
71 } else {
72 print!("{}", render_memory(&node, Target::Cli));
73 }
74
75 Ok(())
76 }
77}

Callers

nothing calls this directly

Calls 5

find_repository_rootFunction · 0.85
read_memoryFunction · 0.85
is_freeform_memoryFunction · 0.85
load_attestationFunction · 0.70
liftFunction · 0.70

Tested by

no test coverage detected