Fix out-of-workspace platform file mapping in add command#50
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed
extractPlatformSuffixreturning the wrong path suffix for out-of-workspace files, causing incorrect platform selection and doubled path segments.Root Cause
When adding an external file like
/tmp/ext/.claude/skills/commits/SKILL.md,extractPlatformSuffixwalks path suffixes shortest-to-longest:SKILL.md→ no matchcommits/SKILL.md→ no matchskills/commits/SKILL.md→ matches**/skills/**/*(claude-plugin) ANDskills/**/*(openclaw). Returned immediately — never reaches step 4..claude/skills/commits/SKILL.md→ would match.claude/skills/**/*(claude) ← correct match, never reachedThe short suffix
skills/commits/SKILL.mdcaused:claude-plugininstead ofclaude)mapPathUsingFlowPatternwith emptyfromBasereturnedskills/commits/SKILL.mdasrelPathsubdir = "skills"→skills/skills/commits/SKILL.md(doubled)Fix
Modified
extractPlatformSuffixto prefer suffixes whose first component is a known platform root directory (.claude,.cursor,.cline, etc.) via the existinggetPlatformDirLookup(). Shorter matches without a platform dir prefix are saved as fallback.For the example above:
skills/commits/SKILL.mdmatches butskillsis not a platform dir → saved as fallback.claude/skills/commits/SKILL.mdmatches and.claudeIS a platform dir → returned immediatelyDownstream, the correct claude platform is selected,
fromBase = '.claude/skills'properly strips the prefix, producingrelPath = 'commits/SKILL.md', and the final path isskills/commits/SKILL.md(correct).Test Results
tests/core/add/add-flow-based-mapping.test.ts— all 12 tests pass (2 previously failing)source-resolution.test.tsfailure from separate path→base migration issue, fixed in Fix path→base migration gaps in dependency resolution and validation #49)