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

Method find_intent_path

atomic-repository/src/repository/vault_intent.rs:921–953  ·  view source on GitHub ↗

Find the vault path for an intent by its resolved manifest key. First checks the manifest's `vault_path` field (fast path), then falls back to scanning `intents/` for a file whose frontmatter `id` (human key) matches.

(&self, full_id: &str)

Source from the content-addressed store, hash-verified

919 /// falls back to scanning `intents/` for a file whose frontmatter `id`
920 /// (human key) matches.
921 fn find_intent_path(&self, full_id: &str) -> Result<Option<String>, RepositoryError> {
922 // Fast path: check the manifest for a stored vault_path
923 let manifest = self.vault_manifest()?;
924 if let Some(summary) = manifest.intents.get(full_id) {
925 if !summary.vault_path.is_empty() {
926 // Verify the path still exists
927 if self.vault_retrieve(&summary.vault_path)?.is_some() {
928 return Ok(Some(summary.vault_path.clone()));
929 }
930 }
931 }
932
933 // Slow path: scan all intents (paths are now flat `intents/<ulid>/`).
934 let prefixes = ["intents/".to_string(), "intents/manual/".to_string()];
935 for prefix in &prefixes {
936 let entries = self.vault_list(prefix, None)?;
937 for meta in entries {
938 if !meta.path.ends_with("/intent.md") {
939 continue;
940 }
941 if let Some(entry) = self.vault_retrieve(&meta.path)? {
942 if let Ok(fm) = serde_json::from_str::<serde_json::Map<String, serde_json::Value>>(
943 &entry.frontmatter_json,
944 ) {
945 if fm.get("id").and_then(|v| v.as_str()) == Some(full_id) {
946 return Ok(Some(meta.path));
947 }
948 }
949 }
950 }
951 }
952 Ok(None)
953 }
954
955 /// Resolve a user-supplied intent reference to its manifest key (human
956 /// key). Public entry point so callers outside the repository (e.g. the

Callers 6

vault_intent_listMethod · 0.80
vault_intent_showMethod · 0.80
vault_intent_pathMethod · 0.80
vault_intent_deleteMethod · 0.80
vault_intent_updateMethod · 0.80
vault_intent_linkMethod · 0.80

Calls 7

vault_manifestMethod · 0.80
vault_retrieveMethod · 0.80
vault_listMethod · 0.80
getMethod · 0.65
is_emptyMethod · 0.45
cloneMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected