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

Method new

atomic-repository/src/repository/vault_projection.rs:34–170  ·  view source on GitHub ↗
(
        txn: &impl VaultTxnT,
        project: ProjectId,
        hashes: Vec<Hash>,
    )

Source from the content-addressed store, hash-verified

32
33impl VaultProjection {
34 pub(super) fn new(
35 txn: &impl VaultTxnT,
36 project: ProjectId,
37 hashes: Vec<Hash>,
38 ) -> Result<Self, RepositoryError> {
39 let hashes = hashes
40 .into_iter()
41 .map(|hash| (hash.to_base32(), hash))
42 .collect();
43 let mut context = Self {
44 project,
45 subjects: BTreeMap::new(),
46 aliases: BTreeMap::new(),
47 paths: BTreeMap::new(),
48 hashes,
49 };
50 let manifest = txn.get_vault_manifest()?;
51 for meta in txn.list_vault_entries("", None)? {
52 let Some(entry) = txn.get_vault_entry(&meta.path)? else {
53 continue;
54 };
55 let fm: serde_json::Value =
56 serde_json::from_str(&entry.frontmatter_json).unwrap_or_default();
57 let (subject, class, local_kind, name) = match entry.entry_type {
58 VaultEntryType::Intent => {
59 let uid = fm
60 .get("uid")
61 .and_then(|v| v.as_str())
62 .map(str::to_uppercase)
63 .or_else(|| {
64 manifest
65 .intents
66 .values()
67 .find(|summary| {
68 summary.vault_path == meta.path && !summary.uid.is_empty()
69 })
70 .map(|s| s.uid.to_uppercase())
71 });
72 let Some(uid) = uid else {
73 continue;
74 };
75 let Ok(id) = iri::mint_intent(&project, &uid) else {
76 continue;
77 };
78 (id, C::WorkIntent, "intent", uid)
79 }
80 VaultEntryType::Memory => {
81 let name = stem(&meta.path, "memory/");
82 (iri::mint_memory(&project, &name), C::Memory, "memory", name)
83 }
84 VaultEntryType::Skill => {
85 let name = stem(&meta.path, "skills/");
86 (iri::mint_skill(&project, &name), C::Skill, "skill", name)
87 }
88 VaultEntryType::Session => {
89 let name = meta
90 .path
91 .strip_prefix("goals/")

Callers

nothing calls this directly

Calls 15

mint_intentFunction · 0.85
stemFunction · 0.85
lift_intentFunction · 0.85
mint_childFunction · 0.85
add_aliasMethod · 0.80
extendMethod · 0.80
getMethod · 0.65
collectMethod · 0.45
into_iterMethod · 0.45
to_base32Method · 0.45
get_vault_manifestMethod · 0.45
list_vault_entriesMethod · 0.45

Tested by

no test coverage detected