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

Method find_intent_path

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

1126 /// falls back to scanning `intents/` for a file whose frontmatter `id`
1127 /// (human key) matches.
1128 fn find_intent_path(&self, full_id: &str) -> Result<Option<String>, RepositoryError> {
1129 // Fast path: check the manifest for a stored vault_path
1130 let manifest = self.vault_manifest()?;
1131 if let Some(summary) = manifest.intents.get(full_id) {
1132 if !summary.vault_path.is_empty() {
1133 // Verify the path still exists
1134 if self.vault_retrieve(&summary.vault_path)?.is_some() {
1135 return Ok(Some(summary.vault_path.clone()));
1136 }
1137 }
1138 }
1139
1140 // Slow path: scan all intents (paths are now flat `intents/<ulid>/`).
1141 let prefixes = ["intents/".to_string(), "intents/manual/".to_string()];
1142 for prefix in &prefixes {
1143 let entries = self.vault_list(prefix, None)?;
1144 for meta in entries {
1145 if !meta.path.ends_with("/intent.md") {
1146 continue;
1147 }
1148 if let Some(entry) = self.vault_retrieve(&meta.path)? {
1149 if let Ok(fm) = serde_json::from_str::<serde_json::Map<String, serde_json::Value>>(
1150 &entry.frontmatter_json,
1151 ) {
1152 if fm.get("id").and_then(|v| v.as_str()) == Some(full_id) {
1153 return Ok(Some(meta.path));
1154 }
1155 }
1156 }
1157 }
1158 }
1159 Ok(None)
1160 }
1161
1162 /// Resolve a user-supplied intent reference to its manifest key (human
1163 /// 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