feat(server): add read doc tool
"""
Walkthrough
A new document reading tool named doc_read has been introduced and integrated into the copilot plugin system. This includes its implementation, access control, metadata retrieval, and integration into the tool selection and parsing logic. Relevant interfaces and exports have been updated to support this new tool.
Changes
| File(s) | Change Summary |
|---|---|
| .../copilot/providers/provider.ts | Added support for 'docRead' tool in getTools, including dependency injection and tool creation logic. |
| .../copilot/providers/utils.ts | Integrated doc_read tool into CustomAITools and updated TextStreamParser to handle doc_read. |
| .../copilot/tools/doc-read.ts | New module implementing document reading with access control and metadata, exporting tool builder logic. |
| .../copilot/tools/index.ts | Re-exported all exports from doc-read module. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant CopilotProvider
participant AccessController
participant Models
participant DocReader
User->>CopilotProvider: Request 'doc_read' tool
CopilotProvider->>AccessController: Check read permission for doc_id
AccessController-->>CopilotProvider: Permission result
CopilotProvider->>Models: Fetch document metadata
Models-->>CopilotProvider: Metadata (title, timestamps, user info)
CopilotProvider->>DocReader: Fetch document content
DocReader-->>CopilotProvider: Markdown content
CopilotProvider-->>User: Return document data or error
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Implement a document reading tool per AI SDK conventions (AI-186) | ✅ | |
| Integrate tool with access control and metadata retrieval (AI-186) | ✅ | |
| Expose and handle the tool in copilot provider and parsing logic (AI-186) | ✅ |
Assessment against linked issues: Out-of-scope changes
No out-of-scope changes found.
Possibly related PRs
- #12459: Extended
TextStreamParserto supportdoc_readtool calls, directly related to parsing enhancements for the new document reading tool.
Suggested reviewers
- darkskygit
Poem
A rabbit found a doc to read,
With access checked and metadata freed.
Through code it hopped, with tools anew,
Bringing content safely into view.
Now Copilot’s smarter, thanks to this feat—
Document reading, crisp and neat!
🐇📄✨ """
📜 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 e859451de597b4ca579355758d02dbc0f7518d19 and eb8783f0ff33538c5027bec876660ccbd0b7755d.
📒 Files selected for processing (4)
-
packages/backend/server/src/plugins/copilot/providers/provider.ts(2 hunks) -
packages/backend/server/src/plugins/copilot/providers/utils.ts(3 hunks) -
packages/backend/server/src/plugins/copilot/tools/doc-read.ts(1 hunks) -
packages/backend/server/src/plugins/copilot/tools/index.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- packages/backend/server/src/plugins/copilot/tools/index.ts
- packages/backend/server/src/plugins/copilot/providers/utils.ts
- packages/backend/server/src/plugins/copilot/providers/provider.ts
- packages/backend/server/src/plugins/copilot/tools/doc-read.ts
⏰ Context from checks skipped due to timeout of 90000ms (63)
- GitHub Check: Frontend Copilot E2E Test (7, 8)
- GitHub Check: Frontend Copilot E2E Test (6, 8)
- GitHub Check: Frontend Copilot E2E Test (5, 8)
- GitHub Check: Frontend Copilot E2E Test (8, 8)
- GitHub Check: Server Test (1, 8)
- GitHub Check: Server Test (7, 8)
- GitHub Check: Frontend Copilot E2E Test (1, 8)
- GitHub Check: Server Test (6, 8)
- GitHub Check: Frontend Copilot E2E Test (3, 8)
- GitHub Check: Frontend Copilot E2E Test (2, 8)
- GitHub Check: Server Test with Elasticsearch
- GitHub Check: Server Test (5, 8)
- GitHub Check: Frontend Copilot E2E Test (4, 8)
- GitHub Check: Server Copilot Api Test
- GitHub Check: Server Test (4, 8)
- GitHub Check: Server Test (0, 8)
- GitHub Check: Server E2E Test
- GitHub Check: Server Test (3, 8)
- GitHub Check: Server Test (2, 8)
- GitHub Check: Check Git Status
- GitHub Check: y-octo binding test on aarch64-pc-windows-msvc
- GitHub Check: y-octo binding test on x86_64-pc-windows-msvc
- GitHub Check: y-octo binding test on x86_64-apple-darwin
- GitHub Check: Build AFFiNE native (x86_64-unknown-linux-gnu)
- GitHub Check: E2E Test (1)
- GitHub Check: E2E Test (5)
- GitHub Check: E2E Test (10)
- GitHub Check: E2E Mobile Test (2)
- GitHub Check: E2E BlockSuite Test (9)
- GitHub Check: E2E Test (2)
- GitHub Check: E2E Test (9)
- GitHub Check: Run native tests
- GitHub Check: E2E BlockSuite Test (3)
- GitHub Check: E2E BlockSuite Test (10)
- GitHub Check: Build AFFiNE native (aarch64-pc-windows-msvc)
- GitHub Check: E2E BlockSuite Test (1)
- GitHub Check: E2E Test (6)
- GitHub Check: E2E Test (3)
- GitHub Check: E2E Test (8)
- GitHub Check: E2E BlockSuite Test (7)
- GitHub Check: E2E Mobile Test (5)
- GitHub Check: E2E Test (7)
- GitHub Check: E2E Test (4)
- GitHub Check: Lint
- GitHub Check: E2E BlockSuite Test (8)
- GitHub Check: E2E BlockSuite Cross Browser Test (1, webkit)
- GitHub Check: E2E BlockSuite Test (6)
- GitHub Check: E2E BlockSuite Test (4)
- GitHub Check: E2E BlockSuite Test (2)
- GitHub Check: Build AFFiNE native (x86_64-pc-windows-msvc)
- GitHub Check: E2E Mobile Test (4)
- GitHub Check: E2E Mobile Test (1)
- GitHub Check: E2E BlockSuite Cross Browser Test (2, webkit)
- GitHub Check: fuzzing
- GitHub Check: E2E Mobile Test (3)
- GitHub Check: E2E BlockSuite Test (5)
- GitHub Check: E2E BlockSuite Cross Browser Test (1, chromium)
- GitHub Check: E2E BlockSuite Cross Browser Test (1, firefox)
- GitHub Check: Analyze (typescript, blocksuite)
- GitHub Check: Analyze (typescript, affine)
- GitHub Check: Analyze (javascript, affine)
- GitHub Check: Analyze (javascript, blocksuite)
- GitHub Check: Typecheck
✨ 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.
🪧 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
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai explain this code block. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin 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 pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
Codecov Report
Attention: Patch coverage is 45.28302% with 58 lines in your changes missing coverage. Please review.
Project coverage is 56.71%. Comparing base (
f88e1df) to head (eb8783f). Report is 4 commits behind head on canary.
Additional details and impacted files
@@ Coverage Diff @@
## canary #12811 +/- ##
==========================================
+ Coverage 56.27% 56.71% +0.44%
==========================================
Files 2674 2675 +1
Lines 128571 128677 +106
Branches 20164 20249 +85
==========================================
+ Hits 72352 72979 +627
+ Misses 54589 53532 -1057
- Partials 1630 2166 +536
| Flag | Coverage Δ | |
|---|---|---|
| server-test | 79.76% <45.28%> (+0.98%) |
:arrow_up: |
| unittest | 31.89% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.