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

Method normalize_intent_id

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

Normalize an intent ID — accept "PIMO-1", "pimo-1", or just "1".

(&self, id: &str)

Source from the content-addressed store, hash-verified

746
747 /// Normalize an intent ID — accept "PIMO-1", "pimo-1", or just "1".
748 fn normalize_intent_id(&self, id: &str) -> Result<String, RepositoryError> {
749 // If it already looks like PREFIX-N, uppercase it
750 if id.contains('-') {
751 return Ok(id.to_uppercase());
752 }
753
754 // Just a number — prepend the prefix
755 if id.parse::<u32>().is_ok() {
756 let manifest = self.vault_manifest()?;
757 let prefix = if manifest.intent_prefix.is_empty() {
758 "VAULT".to_string()
759 } else {
760 manifest.intent_prefix.clone()
761 };
762 return Ok(format!("{}-{}", prefix, id));
763 }
764
765 // Unknown format
766 Err(RepositoryError::InvalidOperation {
767 message: format!(
768 "Invalid intent ID: '{}'. Expected format: PREFIX-N or N",
769 id
770 ),
771 })
772 }
773}
774
775fn remove_empty_dirs_up_to(

Callers 7

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
test_normalize_intent_idFunction · 0.80

Calls 4

vault_manifestMethod · 0.80
containsMethod · 0.45
is_emptyMethod · 0.45
cloneMethod · 0.45

Tested by 2

test_normalize_intent_idFunction · 0.64