feat: 划线评论(selection comment)支持#5
Open
onekanyuncoder wants to merge 3 commits into
Open
Conversation
added 3 commits
April 24, 2026 17:27
- client.ts: createComment 支持 quote/targetSelector 参数,新增 buildTargetSelector 从文件内容计算精确偏移 - commands.ts: comment add 新增 --quote/--offset 选项,comment list 展示引用原文 - mcp.ts: docz_add_comment 新增 quote/quote_offset 参数,docz_list_comments 展示引用内容 - client.test.ts: 新增 selection comment 和 buildTargetSelector 测试用例 - smoke-test-remote.sh: 新增划线评论集成测试(创建/列表/删除) Made-with: Cursor
- client.ts: 新增 stripMarkdownToText,将 Markdown 源码转为纯文本(匹配浏览器 DOM textContent),用于精确计算选区偏移 - commands.ts/mcp.ts: .md 文件自动 strip Markdown 标记后再计算 target_selector 偏移 - smoke-test-remote.sh: 集成测试补充 target_selector 完整验证(创建时传入 startOffset/endOffset/prefix/suffix,列表时验证保留) Made-with: Cursor
--offset 基于字符偏移,对 Markdown 文件用户无法正确计算(源码偏移 ≠ DOM 偏移)。 改为 --nth N 表示匹配第 N 次出现,对 Markdown 和纯文本都适用。 Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
createComment支持划线评论:通过--quote引用文件原文,自动计算target_selector(startOffset/endOffset/prefix/suffix),Web UI 可精确高亮--offset参数指定引用文字在文件中的字符偏移,不传则自动匹配第一次出现comment list和 MCPdocz_list_comments输出中展示引用内容(> ...格式)变更文件
src/client.tscreateComment新增quote/targetSelector参数;新增buildTargetSelector方法从文件内容计算精确偏移和上下文src/commands.tscomment add新增--quote/--offset选项;comment list展示target_contentsrc/mcp.tsdocz_add_comment新增quote/quote_offset参数;docz_list_comments展示引用内容src/client.test.tsbuildTargetSelector偏移计算测试(含 explicit offset、first occurrence、not found)scripts/smoke-test-remote.sh使用示例
Test plan
buildTargetSelector偏移计算、prefix/suffix 提取验证Made with Cursor