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

Function project

atomic-cli/src/commands/memory/show.rs:32–76  ·  view source on GitHub ↗

The pure read-time projection: lift then render. No gate, no proof requirement — this must work on a plain (un-attested) memory; a freeform memory renders its stored body. If a FRESH attestation exists we project that (so `show` reflects the attested author/proof); a stale one warns and falls back to the raw node. Shared by the local body (repo-read inputs) and the routed hook (wire-carried inputs

(
    id: &str,
    inputs: &bridge::MemLiftInputs,
    attestation: &bridge::Attestation,
    json: bool,
)

Source from the content-addressed store, hash-verified

30/// Shared by the local body (repo-read inputs) and the routed hook
31/// (wire-carried inputs) — one render, two data sources.
32pub(crate) fn project(
33 id: &str,
34 inputs: &bridge::MemLiftInputs,
35 attestation: &bridge::Attestation,
36 json: bool,
37) -> CliResult<()> {
38 if bridge::is_freeform_memory(inputs) {
39 if json {
40 println!(
41 "{}",
42 serde_json::to_string_pretty(&serde_json::json!({
43 "path": bridge::normalize_memory_path(id),
44 "content": inputs.body,
45 "frontmatter": inputs.frontmatter,
46 }))
47 .unwrap()
48 );
49 } else {
50 print!("{}", inputs.body);
51 }
52 return Ok(());
53 }
54
55 let node = match attestation {
56 bridge::Attestation::Fresh(node) => (**node).clone(),
57 bridge::Attestation::Stale(_) => {
58 eprintln!(
59 "warning: the attestation for {id} is stale; showing the current \
60 (un-attested) memory."
61 );
62 bridge::lift(inputs)?
63 }
64 bridge::Attestation::None => bridge::lift(inputs)?,
65 };
66
67 if json {
68 println!(
69 "{}",
70 serde_json::to_string_pretty(&node.to_value()).unwrap()
71 );
72 } else {
73 print!("{}", render_memory(&node, Target::Cli));
74 }
75 Ok(())
76}
77
78impl Command for MemoryShow {
79 fn run(&self) -> CliResult<()> {

Callers 1

runMethod · 0.70

Calls 3

is_freeform_memoryFunction · 0.85
liftFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected