From 6ae66b2afbfe911340fa25e0236c3db83deaa7eb Mon Sep 17 00:00:00 2001 From: Andre Silva Date: Mon, 21 Jul 2025 16:17:57 -0300 Subject: [PATCH] fix(profiles): fix vscode profile generation (#1027) * fix(profiles): fix vscode profile generation - Add .instructions.md extension for VSCode Copilot instructions file. - Add customReplacement to remove unsupported property `alwaysApply` from YAML front-matter in VSCode instructions files. - Add missing property `targetExtension` to the base profile object to support the change to file extension. * chore: run format --------- Co-authored-by: Ralph Khreish <35776126+Crunchyman-ralph@users.noreply.github.com> --- .changeset/swift-otters-argue.md | 5 +++++ package.json | 5 +---- src/profiles/base-profile.js | 1 + src/profiles/vscode.js | 6 +++++- .../integration/profiles/vscode-init-functionality.test.js | 4 ++-- tests/unit/profiles/rule-transformer-vscode.test.js | 7 ++++--- 6 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 .changeset/swift-otters-argue.md diff --git a/.changeset/swift-otters-argue.md b/.changeset/swift-otters-argue.md new file mode 100644 index 00000000..6a6b60a5 --- /dev/null +++ b/.changeset/swift-otters-argue.md @@ -0,0 +1,5 @@ +--- +"task-master-ai": patch +--- + +Fix VSCode profile generation to use correct rule file names (using `.instructions.md` extension instead of `.md`) and front-matter properties (removing the unsupported `alwaysApply` property from instructions files' front-matter). diff --git a/package.json b/package.json index 61db3007..645a04e7 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,7 @@ "task-master-mcp": "mcp-server/server.js", "task-master-ai": "mcp-server/server.js" }, - "workspaces": [ - "apps/*", - "." - ], + "workspaces": ["apps/*", "."], "scripts": { "test": "node --experimental-vm-modules node_modules/.bin/jest", "test:fails": "node --experimental-vm-modules node_modules/.bin/jest --onlyFailures", diff --git a/src/profiles/base-profile.js b/src/profiles/base-profile.js index 6f9c5e56..5c329b5a 100644 --- a/src/profiles/base-profile.js +++ b/src/profiles/base-profile.js @@ -234,6 +234,7 @@ export function createProfile(editorConfig) { globalReplacements: baseGlobalReplacements, conversionConfig, getTargetRuleFilename, + targetExtension, // Optional lifecycle hooks ...(onAdd && { onAddRulesProfile: onAdd }), ...(onRemove && { onRemoveRulesProfile: onRemove }), diff --git a/src/profiles/vscode.js b/src/profiles/vscode.js index 06e28797..df4837b3 100644 --- a/src/profiles/vscode.js +++ b/src/profiles/vscode.js @@ -166,6 +166,7 @@ export const vscodeProfile = createProfile({ rulesDir: '.github/instructions', // VS Code instructions location profileDir: '.vscode', // VS Code configuration directory mcpConfigName: 'mcp.json', // VS Code uses mcp.json in .vscode directory + targetExtension: '.instructions.md', customReplacements: [ // Core VS Code directory structure changes { from: /\.cursor\/rules/g, to: '.github/instructions' }, @@ -177,10 +178,13 @@ export const vscodeProfile = createProfile({ // VS Code custom instructions format - use applyTo with quoted patterns instead of globs { from: /^globs:\s*(.+)$/gm, to: 'applyTo: "$1"' }, + // Remove unsupported property - alwaysApply + { from: /^alwaysApply:\s*(true|false)\s*\n?/gm, to: '' }, + // Essential markdown link transformations for VS Code structure { from: /\[(.+?)\]\(mdc:\.cursor\/rules\/(.+?)\.mdc\)/g, - to: '[$1](.github/instructions/$2.md)' + to: '[$1](.github/instructions/$2.instructions.md)' }, // VS Code specific terminology diff --git a/tests/integration/profiles/vscode-init-functionality.test.js b/tests/integration/profiles/vscode-init-functionality.test.js index 794b673a..f5d69ae9 100644 --- a/tests/integration/profiles/vscode-init-functionality.test.js +++ b/tests/integration/profiles/vscode-init-functionality.test.js @@ -35,10 +35,10 @@ describe('VSCode Profile Initialization Functionality', () => { expect(Array.isArray(vscodeProfile.globalReplacements)).toBe(true); }); - test('vscode.js configures .mdc to .md extension mapping', () => { + test('vscode.js configures .mdc to .instructions.md extension mapping', () => { // Check that the profile object has the correct file mapping behavior (vscode converts to .md) expect(vscodeProfile.fileMap['rules/cursor_rules.mdc']).toBe( - 'vscode_rules.md' + 'vscode_rules.instructions.md' ); }); diff --git a/tests/unit/profiles/rule-transformer-vscode.test.js b/tests/unit/profiles/rule-transformer-vscode.test.js index bcce79ad..ee48c61e 100644 --- a/tests/unit/profiles/rule-transformer-vscode.test.js +++ b/tests/unit/profiles/rule-transformer-vscode.test.js @@ -76,6 +76,7 @@ Also has references to .mdc files and cursor rules.`; expect(transformedContent).not.toContain('cursor.so'); expect(transformedContent).not.toContain('Cursor rule'); expect(transformedContent).not.toContain('globs:'); + expect(transformedContent).not.toContain('alwaysApply:'); }); it('should correctly convert tool references', () => { @@ -132,7 +133,7 @@ Files are in the .cursor/rules directory and we should reference the rules direc // Call the actual function const result = convertRuleToProfileRule( 'source.mdc', - 'target.md', + 'target.instructions.md', vscodeProfile ); @@ -148,10 +149,10 @@ Files are in the .cursor/rules directory and we should reference the rules direc 'applyTo: ".github/instructions/*.md"' ); // globs -> applyTo with path transformation expect(transformedContent).toContain( - '(.github/instructions/dev_workflow.md)' + '(.github/instructions/dev_workflow.instructions.md)' ); // File path transformation - no taskmaster subdirectory for VS Code expect(transformedContent).toContain( - '(.github/instructions/taskmaster.md)' + '(.github/instructions/taskmaster.instructions.md)' ); // File path transformation - no taskmaster subdirectory for VS Code expect(transformedContent).toContain('instructions directory'); // "rules directory" -> "instructions directory" expect(transformedContent).not.toContain('(mdc:.cursor/rules/');