Normalize an intent ID — accept "PIMO-1", "pimo-1", or just "1".
(&self, id: &str)
| 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 | |
| 775 | fn remove_empty_dirs_up_to( |