From 9d25178d1245cdda2e8de84c2e460a23d7874272 Mon Sep 17 00:00:00 2001 From: Joe Danziger Date: Tue, 27 May 2025 10:05:26 -0400 Subject: [PATCH] fix for filepath at bottom of rule --- scripts/profiles/base-profile.js | 11 +++++++++-- src/utils/rule-transformer.js | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/profiles/base-profile.js b/scripts/profiles/base-profile.js index b39dd38a..abae3c8c 100644 --- a/scripts/profiles/base-profile.js +++ b/scripts/profiles/base-profile.js @@ -67,7 +67,7 @@ export function createProfile(editorConfig) { ...(targetExtension !== fileExtension ? [ { - from: new RegExp(`\\${fileExtension}\\b`, 'g'), + from: new RegExp(`\\${fileExtension}(?!\\])\\b`, 'g'), to: targetExtension } ] @@ -168,7 +168,14 @@ export function createProfile(editorConfig) { const baseName = path.basename(filePath, '.mdc'); const newFileName = fileMap[`${baseName}.mdc`] || `${baseName}${targetExtension}`; - return `[${text}](mdc:${rulesDir}/${newFileName})`; + // Update the link text to match the new filename + const newLinkText = newFileName; + // For Cursor, keep the mdc: protocol; for others, use standard relative paths + if (name.toLowerCase() === 'cursor') { + return `[${newLinkText}](mdc:${rulesDir}/${newFileName})`; + } else { + return `[${newLinkText}](${rulesDir}/${newFileName})`; + } } } }; diff --git a/src/utils/rule-transformer.js b/src/utils/rule-transformer.js index 95bb6200..daab8ef0 100644 --- a/src/utils/rule-transformer.js +++ b/src/utils/rule-transformer.js @@ -136,12 +136,12 @@ function transformCursorToProfileRules( conversionConfig, globalReplacements = [] ) { - // Apply all transformations in appropriate order let result = content; + // Apply all transformations in appropriate order + result = updateFileReferences(result, conversionConfig); result = replaceBasicTerms(result, conversionConfig); result = replaceToolReferences(result, conversionConfig); result = updateDocReferences(result, conversionConfig); - result = updateFileReferences(result, conversionConfig); // Apply any global/catch-all replacements from the profile // Super aggressive failsafe pass to catch any variations we might have missed