Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 26, 2025

Summary

This PR fixes issue #6229 where rules files were written to the wrong directory when users changed the slug in exported YAML files before importing.

Problem

When exporting a mode, the relativePath for rule files included the rules-<slug> prefix (e.g., rules-old-slug/rule.xml). If a user changed the slug in the exported YAML file before importing, the rules were written to a directory based on the old slug instead of the new one.

Solution

  1. Export function: Changed to calculate relative paths from the mode's rules directory, making them slug-independent (e.g., rule.md instead of rules-slug/rule.md)
  2. Import function: Added backwards compatibility to strip old format prefixes when found, ensuring existing exports continue to work

Changes

  • Modified exportModeWithRules in CustomModesManager.ts to use path.relative(modeRulesDir, filePath)
  • Modified importRulesFiles in CustomModesManager.ts to detect and strip rules-<slug>/ prefixes for backwards compatibility
  • Added comprehensive tests for slug renaming scenarios
  • Updated existing export tests to verify the new path format

Testing

  • All existing tests pass ✅
  • Added new tests specifically for slug renaming scenarios
  • Added tests for backwards compatibility with old export format
  • Added tests for new export format

Impact

Users can now:

  • Rename modes by editing the slug in exported YAML files
  • Share modes with different names
  • Create variations of existing modes with new slugs

This change is backwards compatible - existing exports will continue to work correctly.

Fixes #6229


Important

Fixes slug-dependent paths in mode export/import, allowing slug renaming and ensuring backward compatibility.

  • Behavior:
    • exportModeWithRules in CustomModesManager.ts now calculates relative paths from the mode's rules directory, making them slug-independent.
    • importRulesFiles in CustomModesManager.ts strips rules-<slug>/ prefixes for backward compatibility.
  • Testing:
    • Added tests for slug renaming scenarios and backward compatibility in CustomModesManager.spec.ts.
    • Updated existing export tests to verify new path format.
  • Impact:
    • Users can rename modes by editing the slug in exported YAML files.
    • Backward compatibility ensures existing exports continue to work.

This description was created by Ellipsis for a2f09b0. You can customize this summary. It will automatically update as commits are pushed.

- Export now creates relative paths from the rules directory (e.g., "rule.md" instead of "rules-slug/rule.md")
- Import strips old format prefixes for backwards compatibility
- Users can now rename modes by editing the slug in exported YAML files
- Added comprehensive tests for slug renaming scenarios

Fixes #6229
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 26, 2025 02:04
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jul 26, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 26, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 28, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 28, 2025
@daniel-lxs
Copy link
Member

Closed by #6186

@daniel-lxs daniel-lxs closed this Jul 29, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Jul 29, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Preliminary Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Mode export/import: Rules files are written to wrong directory when slug is changed

4 participants