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