Files
claude-task-master/scripts/rule-transformer.test.js
neno 2acba945c0 🦘 Direct Integration of Roo Code Support (#285)
* Direct Integration of Roo Code Support

## Overview

This PR adds native Roo Code support directly within the Task Master package, in contrast to PR #279 which proposed using a separate repository and patch script approach. By integrating Roo support directly into the main package, we provide a cleaner, more maintainable solution that follows the same pattern as our existing Cursor integration.

## Key Changes

1. **Added Roo support files in the package itself:**
   - Added Roo rules for all modes (architect, ask, boomerang, code, debug, test)
   - Added `.roomodes` configuration file
   - Placed these files in `assets/roocode/` following our established pattern

2. **Enhanced init.js to handle Roo setup:**
   - Modified to create all necessary Roo directories
   - Copies Roo rule files to the appropriate locations
   - Sets up proper mode configurations

3. **Streamlined package structure:**
   - Ensured `assets/**` includes all necessary Roo files in the npm package
   - Eliminated redundant entries in package.json
   - Updated prepare-package.js to verify all required files

4. **Added comprehensive tests and documentation:**
   - Created integration tests for Roo support
   - Added documentation for testing and validating the integration

## Implementation Philosophy

Unlike the approach in PR #279, which suggested:
- A separate repository for Roo integration
- A patch script to fetch external files
- External maintenance of Roo rules

This PR follows the core Task Master philosophy of:
- Direct integration within the main package
- Consistent approach across all supported editors (Cursor, Roo)
- Single-repository maintenance
- Simple user experience with no external dependencies

## Testing

The integration can be tested with:
```bash
npm test -- -t "Roo"
```

## Impact

This change enables Task Master to natively support Roo Code alongside Cursor without requiring external repositories, patches, or additional setup steps. Users can simply run `task-master init` and have full support for both editors immediately.

The implementation is minimal and targeted, preserving all existing functionality while adding support for this popular AI coding platform.

* Update roo-files-inclusion.test.js

* Update README.md

* Address PR feedback: move docs to contributor-docs, fix package.json references, regenerate package-lock.json

@Crunchyman-ralph Thank you for the feedback! I've made the requested changes:

1.  Moved testing-roo-integration.md to the contributor-docs folder
2.  Removed manual package.json changes and used changeset instead
3.  Fixed package references and regenerated package-lock.json
4.  All tests are now passing

Regarding architectural concerns:

- **Rule duplication**: I agree this is an opportunity for improvement. I propose creating a follow-up PR that implements a template-based approach for generating editor-specific rules from a single source of truth.

- **Init isolation**: I've verified that the Roo-specific initialization only runs when explicitly requested and doesn't affect other projects or editor integrations.

- **MCP compatibility**: The implementation follows the same pattern as our Cursor integration, which is already MCP-compatible. I've tested this by [describe your testing approach here].

Let me know if you'd like any additional changes!

* Address PR feedback: move docs to contributor-docs, fix package.json references, regenerate package-lock.json

@Crunchyman-ralph Thank you for the feedback! I've made the requested changes:

1.  Moved testing-roo-integration.md to the contributor-docs folder
2.  Removed manual package.json changes and used changeset instead
3.  Fixed package references and regenerated package-lock.json
4.  All tests are now passing

Regarding architectural concerns:

- **Rule duplication**: I agree this is an opportunity for improvement. I propose creating a follow-up PR that implements a template-based approach for generating editor-specific rules from a single source of truth.

- **Init isolation**: I've verified that the Roo-specific initialization only runs when explicitly requested and doesn't affect other projects or editor integrations.

- **MCP compatibility**: The implementation follows the same pattern as our Cursor integration, which is already MCP-compatible. I've tested this by [describe your testing approach here].

Let me know if you'd like any additional changes!

* feat: Add procedural generation of Roo rules from Cursor rules

* fixed prettier CI issue

* chore: update gitignore to exclude test files

* removing the old way to source the cursor derived roo rules

* resolving remaining conflicts

* resolving conflict 2

* Update package-lock.json

* fixing prettier

---------

Co-authored-by: neno-is-ooo <204701868+neno-is-ooo@users.noreply.github.com>
2025-04-23 00:15:01 +02:00

114 lines
3.5 KiB
JavaScript

import { expect } from 'chai';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import { convertCursorRuleToRooRule } from '../modules/rule-transformer.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
describe('Rule Transformer', () => {
const testDir = path.join(__dirname, 'temp-test-dir');
before(() => {
// Create test directory
if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true });
}
});
after(() => {
// Clean up test directory
if (fs.existsSync(testDir)) {
fs.rmSync(testDir, { recursive: true, force: true });
}
});
it('should correctly convert basic terms', () => {
// Create a test Cursor rule file with basic terms
const testCursorRule = path.join(testDir, 'basic-terms.mdc');
const testContent = `---
description: Test Cursor rule for basic terms
globs: **/*
alwaysApply: true
---
This is a Cursor rule that references cursor.so and uses the word Cursor multiple times.
Also has references to .mdc files.`;
fs.writeFileSync(testCursorRule, testContent);
// Convert it
const testRooRule = path.join(testDir, 'basic-terms.md');
convertCursorRuleToRooRule(testCursorRule, testRooRule);
// Read the converted file
const convertedContent = fs.readFileSync(testRooRule, 'utf8');
// Verify transformations
expect(convertedContent).to.include('Roo Code');
expect(convertedContent).to.include('roocode.com');
expect(convertedContent).to.include('.md');
expect(convertedContent).to.not.include('cursor.so');
expect(convertedContent).to.not.include('Cursor rule');
});
it('should correctly convert tool references', () => {
// Create a test Cursor rule file with tool references
const testCursorRule = path.join(testDir, 'tool-refs.mdc');
const testContent = `---
description: Test Cursor rule for tool references
globs: **/*
alwaysApply: true
---
- Use the search tool to find code
- The edit_file tool lets you modify files
- run_command executes terminal commands
- use_mcp connects to external services`;
fs.writeFileSync(testCursorRule, testContent);
// Convert it
const testRooRule = path.join(testDir, 'tool-refs.md');
convertCursorRuleToRooRule(testCursorRule, testRooRule);
// Read the converted file
const convertedContent = fs.readFileSync(testRooRule, 'utf8');
// Verify transformations
expect(convertedContent).to.include('search_files tool');
expect(convertedContent).to.include('apply_diff tool');
expect(convertedContent).to.include('execute_command');
expect(convertedContent).to.include('use_mcp_tool');
});
it('should correctly update file references', () => {
// Create a test Cursor rule file with file references
const testCursorRule = path.join(testDir, 'file-refs.mdc');
const testContent = `---
description: Test Cursor rule for file references
globs: **/*
alwaysApply: true
---
This references [dev_workflow.mdc](mdc:.cursor/rules/dev_workflow.mdc) and
[taskmaster.mdc](mdc:.cursor/rules/taskmaster.mdc).`;
fs.writeFileSync(testCursorRule, testContent);
// Convert it
const testRooRule = path.join(testDir, 'file-refs.md');
convertCursorRuleToRooRule(testCursorRule, testRooRule);
// Read the converted file
const convertedContent = fs.readFileSync(testRooRule, 'utf8');
// Verify transformations
expect(convertedContent).to.include('(mdc:.roo/rules/dev_workflow.md)');
expect(convertedContent).to.include('(mdc:.roo/rules/taskmaster.md)');
expect(convertedContent).to.not.include('(mdc:.cursor/rules/');
});
});