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

Method normalize_intent_id

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

700
701 /// Normalize an intent ID — accept "PIMO-1", "pimo-1", or just "1".
702 fn normalize_intent_id(&self, id: &str) -> Result<String, RepositoryError> {
703 // If it already looks like PREFIX-N, uppercase it
704 if id.contains('-') {
705 return Ok(id.to_uppercase());
706 }
707
708 // Just a number — prepend the prefix
709 if id.parse::<u32>().is_ok() {
710 let manifest = self.vault_manifest()?;
711 let prefix = if manifest.intent_prefix.is_empty() {
712 "VAULT".to_string()
713 } else {
714 manifest.intent_prefix.clone()
715 };
716 return Ok(format!("{}-{}", prefix, id));
717 }
718
719 // Unknown format
720 Err(RepositoryError::InvalidOperation {
721 message: format!(
722 "Invalid intent ID: '{}'. Expected format: PREFIX-N or N",
723 id
724 ),
725 })
726 }
727}
728
729fn remove_empty_dirs_up_to(

Callers 6

vault_intent_showMethod · 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