8000 list-files must include at least the first-level directory contents by qdaxb · Pull Request #5303 · RooCodeInc/Roo-Code · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

list-files must include at least the first-level directory contents #5303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

qdaxb
Copy link
@qdaxb qdaxb commented Jul 1, 2025

Related GitHub Issue

Closes: #5301

Description

When asking the model to “summarize the current project” in projects with a large number of files, it may make inferences based on the content returned by the Current Workspace Directory or the List Files tool.

However, the current List-files tool uses a depth-first search strategy, which can result in returning detailed structures for only part of the project directories, while the model has no awareness of the other directories at all. In some weaker models, instead of requesting the agent to fetch all subfolders, they directly infer based on the partial information available, which can lead to completely incorrect results.

Changes:

  • If the number of files retrieved by list-files reaches the limit, perform an additional retrieval of all directories and files under the top-level folders separately, then merge the results before proceeding with further processing.
  • formatAndCombineResults uses a breadth-first traversal approach.
  • (Note: listFilesWithRipgrep still uses depth-first search, which may lead to incomplete results in some cases, but at least the first-level directory structure will not be missing.)

Test Procedure

When viewing the prompt in human-relay mode, the Current Workspace Directory will include at least all files in the first-level directories.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Documentation Updates

Additional Notes

Get in Touch


Important

Enhance listFiles to include first-level directory contents when file limit is reached, ensuring complete directory awareness.

  • Behavior:
    • listFiles in list-files.ts now performs an additional non-recursive retrieval of top-level directories if the file limit is reached in recursive mode.
    • Ensures at least first-level directory contents are included in results.
  • Functions:
    • formatAndCombineResults updated to sort paths by depth, ensuring directories are listed before files.
  • Misc:
    • listFilesWithRipgrep still uses depth-first search, but first-level directory structure is guaranteed.

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

@qdaxb qdaxb requested review from mrubens, cte and jr as code owners July 1, 2025 06:31
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Jul 1, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 1, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 1, 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 1, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 1, 2025
…it is reached

- Modified list-files to check if limit was reached and ensure all first-level directories are included
- Added helper functions to get first-level directories and adjust results
- Updated tests to properly verify the new behavior
- Removed the breadth-first implementation in favor of a simpler approach that modifies results after the fact
Copy link
Collaborator
@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Thank you @qdaxb for your contribution!

LGTM

@dosubot dosubot bot added the lgtm This PR has been 8000 approved by a maintainer label Jul 1, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: PR [Needs Review]
Development

Successfully merging this pull request may close these issues.

When the agent uses list-files, it may not be able to retrieve the complete project structure
3 participants
0