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

Method find_intent_path

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

1103 /// falls back to scanning `intents/` for a file whose frontmatter `id`
1104 /// (human key) matches.
1105 fn find_intent_path(&self, full_id: &str) -> Result<Option<String>, RepositoryError> {
1106 // Fast path: check the manifest for a stored vault_path
1107 let manifest = self.vault_manifest()?;
1108 if let Some(summary) = manifest.intents.get(full_id) {
1109 if !summary.vault_path.is_empty() {
1110 // Verify the path still exists
1111 if self.vault_retrieve(&summary.vault_path)?.is_some() {
1112 return Ok(Some(summary.vault_path.clone()));
1113 }
1114 }
1115 }
1116
1117 // Slow path: scan all intents (paths are now flat `intents/<ulid>/`).
1118 let prefixes = ["intents/".to_string(), "intents/manual/".to_string()];
1119 for prefix in &prefixes {
1120 let entries = self.vault_list(prefix, None)?;
1121 for meta in entries {
1122 if !meta.path.ends_with("/intent.md") {
1123 continue;
1124 }
1125 if let Some(entry) = self.vault_retrieve(&meta.path)? {
1126 if let Ok(fm) = serde_json::from_str::<serde_json::Map<String, serde_json::Value>>(
1127 &entry.frontmatter_json,
1128 ) {
1129 if fm.get("id").and_then(|v| v.as_str()) == Some(full_id) {
1130 return Ok(Some(meta.path));
1131 }
1132 }
1133 }
1134 }
1135 }
1136 Ok(None)
1137 }
1138
1139 /// Resolve a user-supplied intent reference to its manifest key (human
1140 /// 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