Skip to content

feat(server): add read doc tool #12811

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 1 commit into
base: ai-editable-markdown-format
Choose a base branch
from

Conversation

fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Jun 13, 2025

Copy link

coderabbitai bot commented Jun 13, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

Copy link

codecov bot commented Jun 13, 2025

Codecov Report

Attention: Patch coverage is 47.05882% with 54 lines in your changes missing coverage. Please review.

Project coverage is 55.88%. Comparing base (f23adb5) to head (4a34a09).

Files with missing lines Patch % Lines
...ckend/server/src/plugins/copilot/tools/doc-read.ts 39.75% 50 Missing ⚠️
...kend/server/src/plugins/copilot/providers/utils.ts 33.33% 4 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                       @@
##           ai-editable-markdown-format   #12811      +/-   ##
===============================================================
+ Coverage                        55.67%   55.88%   +0.21%     
===============================================================
  Files                             2658     2659       +1     
  Lines                           126088   126190     +102     
  Branches                         19973    20032      +59     
===============================================================
+ Hits                             70197    70521     +324     
+ Misses                           53630    53321     -309     
- Partials                          2261     2348      +87     
Flag Coverage Δ
server-test 79.32% <47.05%> (+0.44%) ⬆️
unittest 31.76% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fengmk2 fengmk2 changed the base branch from fengmk2/read-doc-markdown to read-doc-markdown June 13, 2025 03:52
@fengmk2 fengmk2 force-pushed the read-doc-markdown branch from 03e15d8 to dd21429 Compare June 13, 2025 04:25
@fengmk2 fengmk2 force-pushed the fengmk2/ai-read-doc-tool branch 3 times, most recently from d1416e6 to 6c7ec97 Compare June 13, 2025 05:24
@fengmk2 fengmk2 force-pushed the read-doc-markdown branch from e9acb88 to 416d507 Compare June 13, 2025 10:38
@fengmk2 fengmk2 force-pushed the fengmk2/ai-read-doc-tool branch from 6c7ec97 to 729c8e8 Compare June 13, 2025 10:38
@fengmk2 fengmk2 force-pushed the read-doc-markdown branch from 416d507 to 4dd7854 Compare June 17, 2025 07:23
@fengmk2 fengmk2 force-pushed the fengmk2/ai-read-doc-tool branch from 729c8e8 to a5f73b9 Compare June 17, 2025 07:23
@fengmk2 fengmk2 force-pushed the read-doc-markdown branch from 4dd7854 to 9d6ee14 Compare June 17, 2025 08:58
@fengmk2 fengmk2 force-pushed the fengmk2/ai-read-doc-tool branch from a5f73b9 to 9541597 Compare June 17, 2025 08:58
@fengmk2 fengmk2 force-pushed the read-doc-markdown branch from 9d6ee14 to 016adc0 Compare June 18, 2025 02:02
@fengmk2 fengmk2 force-pushed the fengmk2/ai-read-doc-tool branch from 9541597 to 1ba4569 Compare June 18, 2025 02:02
@fengmk2 fengmk2 force-pushed the read-doc-markdown branch from 016adc0 to a9e4dd0 Compare June 18, 2025 02:03
@fengmk2 fengmk2 force-pushed the fengmk2/ai-read-doc-tool branch from 1ba4569 to a186b28 Compare June 18, 2025 02:03
@fengmk2 fengmk2 force-pushed the read-doc-markdown branch 2 times, most recently from e4d26eb to 541a2cc Compare June 18, 2025 06:03
@fengmk2 fengmk2 force-pushed the fengmk2/ai-read-doc-tool branch 2 times, most recently from df48490 to 3893e0e Compare June 18, 2025 06:17
@fengmk2 fengmk2 changed the base branch from read-doc-markdown to ai-editable-markdown-format June 18, 2025 06:17
@fengmk2 fengmk2 force-pushed the fengmk2/ai-read-doc-tool branch from 3893e0e to 4a34a09 Compare June 18, 2025 08:08
@fengmk2 fengmk2 marked this pull request as ready for review June 18, 2025 08:08
@fengmk2 fengmk2 requested review from Copilot, darkskygit and akumatus and removed request for Copilot and darkskygit June 18, 2025 08:08
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new Copilot tool for reading document content directly within the workspace.

  • Introduces doc-read tool implementation in tools/doc-read.ts
  • Integrates the new tool into Copilot’s utilities and provider setup
  • Exposes the tool in the tools index for discovery

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/backend/server/src/plugins/copilot/tools/index.ts Export new doc-read tool
packages/backend/server/src/plugins/copilot/tools/doc-read.ts Add buildDocContentGetter and createDocReadTool
packages/backend/server/src/plugins/copilot/providers/utils.ts Import and register doc_read in CustomAITools
packages/backend/server/src/plugins/copilot/providers/provider.ts Wire up docRead in provider switch
Comments suppressed due to low confidence (2)

packages/backend/server/src/plugins/copilot/tools/doc-read.ts:1

  • No tests were added for the new doc-read tool. Consider adding unit tests for both buildDocContentGetter (authorized, unauthorized, missing doc) and createDocReadTool (successful read, error handling).
import { Logger } from '@nestjs/common';

packages/backend/server/src/plugins/copilot/tools/doc-read.ts:12

  • Add JSDoc or comments to explain buildDocContentGetter parameters and return value so future maintainers understand its contract and side effects.
export const buildDocContentGetter = (

Comment on lines +55 to +63
...content,
...docMeta,
};
};
return getDoc;
};

export const createDocReadTool = (
getDoc: (targetId?: string) => Promise<object | undefined>
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

The tool's return type is currently object | undefined. Defining a specific interface for the doc payload (e.g. DocReadResult) will improve type safety and clarity.

Suggested change
...content,
...docMeta,
};
};
return getDoc;
};
export const createDocReadTool = (
getDoc: (targetId?: string) => Promise<object | undefined>
createdAt: docMeta.createdAt,
updatedAt: docMeta.updatedAt,
createdByUser: docMeta.createdByUser,
updatedByUser: docMeta.updatedByUser,
markdownContent: content,
};
};
return getDoc;
};
export const createDocReadTool = (
getDoc: (targetId?: string) => Promise<DocReadResult | undefined>

Copilot uses AI. Check for mistakes.

@@ -10,6 +10,7 @@ import {
import { ZodType } from 'zod';

import {
createDocReadTool,
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider grouping and ordering imports alphabetically (or per project style) to keep the import block organized as more tools are added.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant