···152152 create_manager(dir, cmd.verbose(), cmd.quiet())
153153}
154154155155+/// Resolve a target string (bundle number or path) into a bundle number and canonical path.
156156+/// This utility ensures that file existence checks for bundles are done through the BundleManager.
157157+pub fn resolve_bundle_target(
158158+ manager: &BundleManager,
159159+ target: &str,
160160+ repo_dir: &PathBuf,
161161+) -> Result<(Option<u32>, PathBuf)> {
162162+ // Try to parse as bundle number
163163+ if let Ok(num) = target.parse::<u32>() {
164164+ let path = plcbundle::constants::bundle_path(repo_dir, num);
165165+ // Check if bundle exists via BundleManager's index
166166+ if manager.get_bundle_metadata(num)?.is_some() {
167167+ Ok((Some(num), path))
168168+ } else {
169169+ anyhow::bail!("Bundle {} not found in repository index", num);
170170+ }
171171+ } else {
172172+ // Otherwise treat as file path. For now, this is an error as direct file access is disallowed.
173173+ anyhow::bail!("Loading from arbitrary paths not yet implemented. Please specify a bundle number.");
174174+ }
175175+}
176176+155177/// Get all bundle metadata from the repository
156178/// This is more efficient than iterating through bundle numbers
157179pub fn get_all_bundle_metadata(manager: &BundleManager) -> Vec<plcbundle::index::BundleMetadata> {