Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/core/src/core/platform/platform-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,26 @@ function extractPlatformSuffix(absolutePath: string): string | null {
const allFromPatterns = getNonFallbackFromPatterns();
if (allFromPatterns.length === 0) return null;

// Try suffixes from shortest (just filename) to longer, looking for a match
// Prefer suffixes whose first component is a known platform root directory
// (e.g. .claude/, .cursor/). Shorter suffixes may match permissive patterns
// like **/skills/**/* or skills/**/* that lose platform directory context,
// causing incorrect platform selection and path duplication downstream.
const dirLookup = getPlatformDirLookup();
let firstMatch: string | null = null;

for (let i = segments.length - 1; i >= 0; i--) {
const suffix = segments.slice(i).join('/');
for (const pattern of allFromPatterns) {
if (matchesFlowPattern(suffix, pattern)) {
return suffix;
if (!firstMatch) firstMatch = suffix;
if (dirLookup[segments[i]]) {
return suffix;
}
}
}
}

return null;
return firstMatch;
}

/**
Expand Down