Skip to content

Conversation

@taisukeoe
Copy link
Contributor

@taisukeoe taisukeoe commented Apr 8, 2025

Context

Fix a bug not to resolve nested .roo/rules directories properly, such as .roo/rules/subdir/file1.txt or .roo/rules/subdir/subdir2/file rule files.
It seems to be intended to support nested directory structures, as recursive option is marked as true in the implementation.

Sub directories are quite helpful to organize multiple custom instructions files. It is nicer to support.

Implementation

Use Dirent#parentPath instead of dirPath to resolve full path of each rule file.

This is because dirPath would be the path of .roo/rules, not sub directory path. So current path misses all subdirectories.

.then((files) => files.map((file) => path.resolve(dirPath, file.name)))

should be

.then((files) => files.map((file) => path.resolve(file.parentPath, file.name)))

Screenshots

before after
スクリーンショット 2025-04-08 22 22 02 スクリーンショット 2025-04-08 22 15 52

How to Test

  1. prepare a rule file under subdir
echo "This was the missed txt." >> .roo/rules/subdir/missed.txt
  1. Go to the Prompts tab
  2. Preview System Prompt and check if .roo/rules/subdir/missed.txt is included.

Get in Touch

I am in the Roo Code Discord server as @taisukeoe. Please feel free to ask if any!

@changeset-bot
Copy link

changeset-bot bot commented Apr 8, 2025

🦋 Changeset detected

Latest commit: e9c7bed

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
roo-cline Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@taisukeoe taisukeoe marked this pull request as ready for review April 8, 2025 13:39
@taisukeoe taisukeoe requested review from cte and mrubens as code owners April 8, 2025 13:39
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 8, 2025
.readdir(dirPath, { withFileTypes: true, recursive: true })
.then((files) => files.filter((file) => file.isFile()))
.then((files) => files.map((file) => path.resolve(dirPath, file.name)))
.then((files) => files.map((file) => path.resolve(file.parentPath, file.name)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using file.parentPath assumes that the Dirent includes a parentPath property, which is non-standard. Consider defaulting to the original dirPath if parentPath is undefined.

Suggested change
.then((files) => files.map((file) => path.resolve(file.parentPath, file.name)))
.then((files) => files.map((file) => path.resolve(file.parentPath || dirPath, file.name)))

Copy link
Contributor Author

@taisukeoe taisukeoe Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed Dirent#parentPath is marked as Stability:1.

https://nodejs.org/docs/latest-v20.x/api/fs.html#direntparentpath

Stability: 1 - Experimental. The feature is not subject to semantic versioning rules. Non-backward compatible changes or removal may occur in any future release. Use of the feature is not recommended in production environments.

Considering Dirent#path was the original function name but deprecated now, the new function name parentPath seems to be still the first option to use.
It might be arguable that we may want to use just parentPath, or prepare some fail-overs.

  • stay file.parentPath
  • file.parentPath || dirPath
  • file.parentPath || file.path
  • or calculate fullpath in a recursive concatenation manner (subdir/ + subdir2/ + file1.txt)

Which pattern do you prefer?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, I'm not sure I have any strong opinions. What do you think is best? cc: @upanume who wrote this originally.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented this! Thank you for the bug fix 😭

IMO: While there are certainly points of discussion, I think either "stay file.parentPath" or "file.parentPath || dirPath" would be good. If the behavior changes due to Node.js modifications, the tests would fail, so we would be able to notice, and I don't think we need to make things unnecessarily complicated.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me!

@dosubot dosubot bot added the bug Something isn't working label Apr 8, 2025
Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good as is. Thank you!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 8, 2025
@mrubens mrubens merged commit dedd655 into RooCodeInc:main Apr 8, 2025
28 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Apr 8, 2025
@taisukeoe
Copy link
Contributor Author

Wow, thank you for your prompt review&merge! 🚀

@mrubens
Copy link
Collaborator

mrubens commented Apr 8, 2025

Thank you for the contribution!

SmartManoj pushed a commit to SmartManoj/Raa-Code that referenced this pull request May 6, 2025
* Create Tailwind DangerButton

* changeset

* remove unused import

* Remove old DangerButton component

* rename DangerButtonTW to DangerButton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants