Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

fix: make mode export/import paths slug-independent to support renaming - #6231

Closed
ghost wants to merge 1 commit into
mainfrom
fix/mode-export-import-slug-renaming
Closed

fix: make mode export/import paths slug-independent to support renaming#6231
ghost wants to merge 1 commit into
mainfrom
fix/mode-export-import-slug-renaming

Conversation

@ghost

@ghostghost commented Jul 26, 2025

Copy link
Copy Markdown

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
@ghost
ghost requested review from cte, jr and mrubens as code ownersJuly 26, 2025 02:04
@dosubotdosubotBot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jul 26, 2025
@hannesrudolphhannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 26, 2025
@daniel-lxsdaniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code RoadmapJul 28, 2025
@hannesrudolphhannesrudolph 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
Copy Markdown
Member

Closed by #6186

@github-project-automationgithub-project-automationBot moved this from PR [Needs Prelim Review] to Done in Roo Code RoadmapJul 29, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugSomething isn't workingPR - Needs Preliminary Reviewsize:LThis PR changes 100-499 lines, ignoring generated files.

Projects

No open 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

3 participants

@daniel-lxs@hannesrudolph@roomote