Skip to content

Fix out-of-workspace platform file mapping in add command#50

Merged
hyericlee merged 2 commits into
mainfrom
fix-extract-platform-suffix
Apr 4, 2026
Merged

Fix out-of-workspace platform file mapping in add command#50
hyericlee merged 2 commits into
mainfrom
fix-extract-platform-suffix

Conversation

@hyericlee

Copy link
Copy Markdown
Contributor

Summary

Fixed extractPlatformSuffix returning 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, extractPlatformSuffix walks path suffixes shortest-to-longest:

  1. SKILL.md → no match
  2. commits/SKILL.md → no match
  3. skills/commits/SKILL.md → matches **/skills/**/* (claude-plugin) AND skills/**/* (openclaw). Returned immediately — never reaches step 4.
  4. .claude/skills/commits/SKILL.md → would match .claude/skills/**/* (claude) ← correct match, never reached

The short suffix skills/commits/SKILL.md caused:

  • Wrong platform selected (claude-plugin instead of claude)
  • mapPathUsingFlowPattern with empty fromBase returned skills/commits/SKILL.md as relPath
  • Combined with subdir = "skills"skills/skills/commits/SKILL.md (doubled)
  • File placed at wrong location; test assertions failed

Fix

Modified extractPlatformSuffix to prefer suffixes whose first component is a known platform root directory (.claude, .cursor, .cline, etc.) via the existing getPlatformDirLookup(). Shorter matches without a platform dir prefix are saved as fallback.

For the example above:

  • skills/commits/SKILL.md matches but skills is not a platform dir → saved as fallback
  • .claude/skills/commits/SKILL.md matches and .claude IS a platform dir → returned immediately

Downstream, the correct claude platform is selected, fromBase = '.claude/skills' properly strips the prefix, producing relPath = 'commits/SKILL.md', and the final path is skills/commits/SKILL.md (correct).

Test Results

@hyericlee hyericlee merged commit b3f1b6a into main Apr 4, 2026
@hyericlee hyericlee deleted the fix-extract-platform-suffix branch April 4, 2026 12:30
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.

1 participant