豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Improve promps readability and file read/write behaviour #130

Merged
wonderwhy-er merged 5 commits intomainfrom
file-system-writes
May 22, 2025
Merged

Improve promps readability and file read/write behaviour #130
wonderwhy-er merged 5 commits intomainfrom
file-system-writes

Conversation

@wonderwhy-er
Copy link
Copy Markdown
Owner

@wonderwhy-er wonderwhy-er commented May 22, 2025

Summary by CodeRabbit

  • Improvements

    • Enhanced tool descriptions for improved clarity and readability, now featuring structured formatting and bullet points in tool listings.
    • Improved file reading behavior to provide clearer feedback when requesting lines beyond the end of a file, including specific informational messages.
    • File information now includes line count metadata for supported text files, offering more detailed file insights.
  • Telemetry

    • Expanded telemetry for file writing and text editing actions, capturing more detailed metrics such as content size, line counts, and search/replace statistics.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 22, 2025

Walkthrough

This update improves the clarity and detail of tool descriptions in the server’s tool listing by reformatting them as structured, multi-line template strings. It also enhances telemetry in text editing and filesystem operations to capture more metadata, and adds line count metadata for text files in file information queries. No functional logic or exported interfaces are changed.

Changes

File(s) Change Summary
src/server.ts Reformatted all tool descriptions in the ListToolsRequestSchema handler to use multi-line template strings with bullet points and clearer formatting. No logic or schema changes.
src/tools/edit.ts Enhanced telemetry in performSearchReplace to include search/replace string lengths, line counts, and expected replacements. No changes to logic or signatures.
src/tools/filesystem.ts Improved readFileFromDisk to handle out-of-bounds offsets by returning the last lines with a specific message. Enhanced telemetry in writeFile to include byte size and line count. Updated getFileInfo to add line count metadata for small text files, excluding images. No changes to function signatures.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant FilesystemTool
    participant EditTool

    Client->>Server: Request list of tools
    Server->>Server: Format tool descriptions (multi-line, structured)
    Server-->>Client: Return tool list with detailed descriptions

    Client->>EditTool: Perform search & replace
    EditTool->>EditTool: Capture telemetry (lengths, lines, expected replacements)
    EditTool-->>Client: Return result

    Client->>FilesystemTool: Request file info
    FilesystemTool->>FilesystemTool: If text & <10MB, count lines
    FilesystemTool-->>Client: Return file info with line count
Loading

Possibly related PRs

Suggested reviewers

  • serg33v

Poem

A bunny hopped through lines of code,
Tidying tools with a clearer mode.
With bullet points and details bright,
Telemetry now tracks with insight.
File lines counted, edits in view—
Oh what a spring-cleaning this rabbit can do!
🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efcfcd6 and e711a97.

📒 Files selected for processing (3)
  • src/server.ts (1 hunks)
  • src/tools/edit.ts (1 hunks)
  • src/tools/filesystem.ts (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/tools/edit.ts (1)
src/utils/capture.ts (1)
  • capture (84-199)
src/server.ts (1)
src/tools/schemas.ts (17)
  • GetConfigArgsSchema (6-6)
  • SetConfigValueArgsSchema (8-11)
  • ReadFileArgsSchema (38-43)
  • ReadMultipleFilesArgsSchema (45-47)
  • WriteFileArgsSchema (49-53)
  • CreateDirectoryArgsSchema (55-57)
  • ListDirectoryArgsSchema (59-61)
  • MoveFileArgsSchema (63-66)
  • SearchFilesArgsSchema (68-72)
  • SearchCodeArgsSchema (79-88)
  • GetFileInfoArgsSchema (74-76)
  • EditBlockArgsSchema (91-96)
  • ExecuteCommandArgsSchema (17-21)
  • ReadOutputArgsSchema (23-25)
  • ForceTerminateArgsSchema (27-29)
  • ListSessionsArgsSchema (31-31)
  • ListProcessesArgsSchema (14-14)
🔇 Additional comments (19)
src/tools/edit.ts (1)

109-117: Enhanced telemetry for edit operations - good improvement!

The telemetry data for the edit_block operation has been expanded to include detailed metrics about the search and replace strings. This will provide valuable insights into the types of edits being performed, particularly helping to understand the complexity of edits based on string lengths and line counts.

src/server.ts (14)

84-93: Improved formatting for tool descriptions

The reformatting of tool descriptions as structured multi-line template strings significantly improves readability. The bulleted list of config fields provides clear documentation on what values are available.


98-115: Enhanced documentation with important warnings

Good addition of warning messages and clear labeling of important configuration considerations. The explicit mention of security implications when setting allowedDirectories to an empty array is particularly valuable.


122-139: Comprehensive documentation for read_file

The description now clearly explains all parameters and behavior, including how partial reading works with offset and length. The path guidance inclusion is helpful for ensuring correct usage.


144-155: Clearer description for read_multiple_files

Well-structured explanation that highlights the behavior with failed reads for individual files and the path constraints.


160-188: Critical guidance for write_file operation

Excellent improvement with clear warnings and guidance for chunking large files. The structured format with numbered steps makes the required process easy to follow, which should help prevent truncation issues.


193-200: Concise description for create_directory

Clean, focused description that highlights key capabilities and constraints.


205-213: Improved list_directory documentation

Good recommendation to use this specialized tool instead of generic command execution.


218-225: Clear documentation for move_file

Simple but effective description that covers the key functionality and constraints.


230-240: Enhanced search_files documentation

Good explanation of the search behavior and timeout options.


245-256: Comprehensive search_code documentation

Clear description of capabilities and constraints, with guidance on using this specialized tool instead of general command execution.


261-275: Enhanced get_file_info with new metadata fields

Good documentation that now includes the newly added fields for text files: lineCount, lastLine, and appendPosition. This aligns well with the implementation changes in filesystem.ts.


283-315: Detailed edit_block guidance

Comprehensive documentation that explains the tool behavior, parameters, and best practices. The emphasis on making small, focused edits and handling fuzzy matches is particularly helpful.


322-332: Clear execute_command documentation

Good guidance on preferring specialized tools over generic command execution.


336-340: Consistent formatting for terminal tools

All terminal tool descriptions now follow the same multi-line template format, improving consistency across the documentation.

Also applies to: 344-348, 352-356, 360-366, 370-376

src/tools/filesystem.ts (4)

322-332: Improved handling of offsets beyond file length

Good enhancement to show the last few lines when the requested offset is beyond the file length. This provides a better user experience than returning empty content, while still indicating that the requested offset was beyond the file's size.


340-351: Clearer informational messages for file reading

The improved messaging now distinguishes between normal partial reads and reads with offsets beyond the file length. The condition to avoid adding informational messages when reading the entire file is a nice touch that eliminates unnecessary noise.


399-401: Enhanced telemetry for file writes

Adding byte size and line count metrics to the telemetry provides valuable information about the nature of write operations. This complements the enhanced telemetry in the edit tool and helps build a more complete picture of file system operations.

Also applies to: 406-408


532-565: Added line count metadata for text files

Good enhancement to include line count information for text files. The size limit (10MB) and MIME type check are sensible safeguards to avoid performance issues with large or binary files. The error handling ensures that this enhancement doesn't break functionality for non-text files.

The addition of lineCount, lastLine, and appendPosition properties provides useful metadata for text editing operations, especially when working with partial file reads/writes or appending to files.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@wonderwhy-er wonderwhy-er changed the title File system writes Improve promps readability and file read/write behaviour May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants