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

Method find_intent_path

atomic-repository/src/repository/vault_intent.rs:794–826  ·  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

792 /// falls back to scanning `intents/` for a file whose frontmatter `id`
793 /// (human key) matches.
794 fn find_intent_path(&self, full_id: &str) -> Result<Option<String>, RepositoryError> {
795 // Fast path: check the manifest for a stored vault_path
796 let manifest = self.vault_manifest()?;
797 if let Some(summary) = manifest.intents.get(full_id) {
798 if !summary.vault_path.is_empty() {
799 // Verify the path still exists
800 if self.vault_retrieve(&summary.vault_path)?.is_some() {
801 return Ok(Some(summary.vault_path.clone()));
802 }
803 }
804 }
805
806 // Slow path: scan all intents (paths are now flat `intents/<ulid>/`).
807 let prefixes = ["intents/".to_string(), "intents/manual/".to_string()];
808 for prefix in &prefixes {
809 let entries = self.vault_list(prefix, None)?;
810 for meta in entries {
811 if !meta.path.ends_with("/intent.md") {
812 continue;
813 }
814 if let Some(entry) = self.vault_retrieve(&meta.path)? {
815 if let Ok(fm) = serde_json::from_str::<serde_json::Map<String, serde_json::Value>>(
816 &entry.frontmatter_json,
817 ) {
818 if fm.get("id").and_then(|v| v.as_str()) == Some(full_id) {
819 return Ok(Some(meta.path));
820 }
821 }
822 }
823 }
824 }
825 Ok(None)
826 }
827
828 /// Resolve a user-supplied intent reference to its manifest key (human
829 /// 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