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>
This commit is contained in:
Andre Silva
2025-07-21 16:17:57 -03:00
committed by GitHub
parent 8781794c56
commit 6ae66b2afb
6 changed files with 18 additions and 10 deletions

View File

@@ -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).

View File

@@ -9,10 +9,7 @@
"task-master-mcp": "mcp-server/server.js", "task-master-mcp": "mcp-server/server.js",
"task-master-ai": "mcp-server/server.js" "task-master-ai": "mcp-server/server.js"
}, },
"workspaces": [ "workspaces": ["apps/*", "."],
"apps/*",
"."
],
"scripts": { "scripts": {
"test": "node --experimental-vm-modules node_modules/.bin/jest", "test": "node --experimental-vm-modules node_modules/.bin/jest",
"test:fails": "node --experimental-vm-modules node_modules/.bin/jest --onlyFailures", "test:fails": "node --experimental-vm-modules node_modules/.bin/jest --onlyFailures",

View File

@@ -234,6 +234,7 @@ export function createProfile(editorConfig) {
globalReplacements: baseGlobalReplacements, globalReplacements: baseGlobalReplacements,
conversionConfig, conversionConfig,
getTargetRuleFilename, getTargetRuleFilename,
targetExtension,
// Optional lifecycle hooks // Optional lifecycle hooks
...(onAdd && { onAddRulesProfile: onAdd }), ...(onAdd && { onAddRulesProfile: onAdd }),
...(onRemove && { onRemoveRulesProfile: onRemove }), ...(onRemove && { onRemoveRulesProfile: onRemove }),

View File

@@ -166,6 +166,7 @@ export const vscodeProfile = createProfile({
rulesDir: '.github/instructions', // VS Code instructions location rulesDir: '.github/instructions', // VS Code instructions location
profileDir: '.vscode', // VS Code configuration directory profileDir: '.vscode', // VS Code configuration directory
mcpConfigName: 'mcp.json', // VS Code uses mcp.json in .vscode directory mcpConfigName: 'mcp.json', // VS Code uses mcp.json in .vscode directory
targetExtension: '.instructions.md',
customReplacements: [ customReplacements: [
// Core VS Code directory structure changes // Core VS Code directory structure changes
{ from: /\.cursor\/rules/g, to: '.github/instructions' }, { 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 // VS Code custom instructions format - use applyTo with quoted patterns instead of globs
{ from: /^globs:\s*(.+)$/gm, to: 'applyTo: "$1"' }, { 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 // Essential markdown link transformations for VS Code structure
{ {
from: /\[(.+?)\]\(mdc:\.cursor\/rules\/(.+?)\.mdc\)/g, from: /\[(.+?)\]\(mdc:\.cursor\/rules\/(.+?)\.mdc\)/g,
to: '[$1](.github/instructions/$2.md)' to: '[$1](.github/instructions/$2.instructions.md)'
}, },
// VS Code specific terminology // VS Code specific terminology

View File

@@ -35,10 +35,10 @@ describe('VSCode Profile Initialization Functionality', () => {
expect(Array.isArray(vscodeProfile.globalReplacements)).toBe(true); 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) // Check that the profile object has the correct file mapping behavior (vscode converts to .md)
expect(vscodeProfile.fileMap['rules/cursor_rules.mdc']).toBe( expect(vscodeProfile.fileMap['rules/cursor_rules.mdc']).toBe(
'vscode_rules.md' 'vscode_rules.instructions.md'
); );
}); });

View File

@@ -76,6 +76,7 @@ Also has references to .mdc files and cursor rules.`;
expect(transformedContent).not.toContain('cursor.so'); expect(transformedContent).not.toContain('cursor.so');
expect(transformedContent).not.toContain('Cursor rule'); expect(transformedContent).not.toContain('Cursor rule');
expect(transformedContent).not.toContain('globs:'); expect(transformedContent).not.toContain('globs:');
expect(transformedContent).not.toContain('alwaysApply:');
}); });
it('should correctly convert tool references', () => { 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 // Call the actual function
const result = convertRuleToProfileRule( const result = convertRuleToProfileRule(
'source.mdc', 'source.mdc',
'target.md', 'target.instructions.md',
vscodeProfile vscodeProfile
); );
@@ -148,10 +149,10 @@ Files are in the .cursor/rules directory and we should reference the rules direc
'applyTo: ".github/instructions/*.md"' 'applyTo: ".github/instructions/*.md"'
); // globs -> applyTo with path transformation ); // globs -> applyTo with path transformation
expect(transformedContent).toContain( expect(transformedContent).toContain(
'(.github/instructions/dev_workflow.md)' '(.github/instructions/dev_workflow.instructions.md)'
); // File path transformation - no taskmaster subdirectory for VS Code ); // File path transformation - no taskmaster subdirectory for VS Code
expect(transformedContent).toContain( expect(transformedContent).toContain(
'(.github/instructions/taskmaster.md)' '(.github/instructions/taskmaster.instructions.md)'
); // File path transformation - no taskmaster subdirectory for VS Code ); // File path transformation - no taskmaster subdirectory for VS Code
expect(transformedContent).toContain('instructions directory'); // "rules directory" -> "instructions directory" expect(transformedContent).toContain('instructions directory'); // "rules directory" -> "instructions directory"
expect(transformedContent).not.toContain('(mdc:.cursor/rules/'); expect(transformedContent).not.toContain('(mdc:.cursor/rules/');