Skip to content

fix: strip 'skills/' prefix in _collect_bare_skill to prevent double nesting#734

Closed
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/719-skills-double-nesting
Closed

fix: strip 'skills/' prefix in _collect_bare_skill to prevent double nesting#734
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/719-skills-double-nesting

Conversation

@Jah-yee
Copy link
Copy Markdown
Contributor

@Jah-yee Jah-yee commented Apr 16, 2026

Summary

When a dependency has virtual_path='skills/javascript-typescript-jest', the bare skill collector in _collect_bare_skill was producing output paths like skills/skills/javascript-typescript-jest/SKILL.md instead of skills/javascript-typescript-jest/SKILL.md.

This happens because the slug (derived from virtual_path) already contains the skills/ prefix, and the code unconditionally prepends another skills/ to the output path.

Fix

Strip the skills/ prefix from the slug before prepending skills/ in the output path:

# Strip "skills/" prefix to avoid double nesting like "skills/skills/..."
if slug.startswith("skills/"):
    slug = slug[len("skills/"):]

Test added

test_virtual_path_with_skills_prefix_no_double_nesting in tests/unit/test_plugin_exporter.py covers this exact bug scenario.

Fixes #719.

…nesting

When a dependency has virtual_path='skills/javascript-typescript-jest', the
bare skill collector was producing 'skills/skills/javascript-typescript-jest/'
instead of 'skills/javascript-typescript-jest/'.

Fixes microsoft#719.
@sergio-sisternes-epam
Copy link
Copy Markdown
Collaborator

Thank you for this contribution @Jah-yee! Your fix correctly identifies the root cause and the test is well-written.

We received two independent fixes for #719 -- yours and #738. After comparing both, we're going with #738 because it adds cross-platform path normalization (backslash handling) and includes an additional end-to-end integration test alongside the unit test.

Your effort is appreciated -- hope to see you on future issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] apm pack --format plugin produces duplicated skills/ directory nesting

2 participants