{"record":{"id":"df4bb17630192b70","repo":"Hmbown/CodeWhale","slug":"skill-has-multiple-owned-packages-in-the-targ","errorCode":null,"errorMessage":"skill '{}' has multiple owned packages in the target scope; remove or consolidate them before importing","messagePattern":"skill '(.+?)' has multiple owned packages in the target scope; remove or consolidate them before importing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/skills/mutation.rs","lineNumber":701,"sourceCode":"        .skills\n        .iter()\n        .filter(|s| s.id.canonical_name == source_id.canonical_name)\n        .filter(|s| s.root.kind == want_kind)\n        .collect();\n\n    // Prefer the on-disk directory of an existing same-scope package so we\n    // replace/reject against Hello_World rather than creating a parallel\n    // hello-world next to it.\n    let (dest, dest_segment) = match existing_in_target.as_slice() {\n        [] => {\n            let segment = source_id.canonical_name.clone();\n            (skills_dir.join(&segment), segment)\n        }\n        [only] => {\n            let segment = on_disk_package_name(&only.id)?.to_string();\n            (only.root.path.join(&only.id.relative_dir), segment)\n        }\n        _ => bail!(\n            \"skill '{}' has multiple owned packages in the target scope; \\\n             remove or consolidate them before importing\",\n            source_id.canonical_name\n        ),\n    };\n\n    let dest_exists = validate_owned_child(&skills_dir, &dest, false)?;\n    if dest_exists {\n        let existing = package_digest::compute_package_digest(&dest).ok();\n        if existing.as_deref() == Some(expected_digest.as_str()) {\n            return Ok(SkillMutationReceipt {\n                action: SkillActionKind::Import,\n                name: source_id.canonical_name.clone(),\n                scope: target.as_skill_scope(),\n                safe_target_path: safe_display_path(&dest, Some(ctx.workspace), ctx.home),\n                before_digest: before,\n                after_digest: existing,\n                outcome: SkillMutationOutcome::AlreadyPresent,","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/skills/mutation.rs#L683-L719","documentation":"Before copying, `import_external` resolves exactly one owned package matching the source skill's canonical name in the target scope. If the on-disk scan finds more than one owned package for that name, the operation aborts because it cannot determine a unique destination; consolidating ownership is a user decision.","triggerScenarios":"Two or more owned package directories map to the same canonical skill name in the target scope (duplicate dirs whose SKILL.md names collide, or the same name in overlapping owned roots) while calling `import_external`.","commonSituations":"Manually copied skill folders with duplicate SKILL.md `name` fields; a skill imported earlier into both user and project scopes; a renamed directory that left the old copy behind so two dirs claim one name.","solutions":["Delete or consolidate the duplicate owned package directories so only one remains, then retry the import.","Rename one package's SKILL.md name (or directory) so the canonical names no longer collide.","Choose a different `SkillTargetScope` that contains only one package for this name."],"exampleFix":"// before\nskills/my-skill/                (SKILL.md name: my-skill)\n~/.codewhale/skills/my-skill/   (SKILL.md name: my-skill)\n// after\n~/.codewhale/skills/my-skill/   (single owned package; duplicate removed)","handlingStrategy":"validation","validationCode":"let matches: Vec<_> = owned_snap.skills.iter().filter(|s| s.id.canonical_name == source_id.canonical_name).collect();\nif matches.len() > 1 {\n    return Err(anyhow!(\"multiple owned packages for {}; consolidate first\", source_id.canonical_name));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep one owned package per canonical skill name per scope.","Clean up old directories after renaming a skill.","Avoid copying skill folders manually; use import/remove mutations."],"tags":["skills","conflict","import"],"backgroundTag":"file-already-exists","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}