Skip to content

Commit 58efc01

Browse files
author
SqlRush
committed
Add Grep context separators
1 parent ff3d652 commit 58efc01

4 files changed

Lines changed: 166 additions & 5 deletions

File tree

docs/claude-code-go-rewrite-plan.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ test/parity/ # golden tests against TS/official behavior
173173
- Read/Edit/Write 初版已落地,覆盖文本 Read、PDF text/page-selection 初版(含常见 Page/Contents 间接对象、Pages/Kids 页序、FlateDecode 文本流和 UTF-16 BOM 字符串)、PNG/JPEG/GIF/WebP image Read、Jupyter notebook cell 渲染初版、Read 大文本 tool-result budget 截断/落盘、read-before-write、mtime stale guard、唯一匹配、`replace_all`、Write/Edit structured diff hunks、`.claude/settings.json`/`settings.local.json` 写前 JSON/语义校验、team-memory secret guard、Read 去重和跨 tool round read-state。
174174
- NotebookEdit 初版已落地,按官方 `notebook_path`/`cell_id`/`new_source`/`cell_type`/`edit_mode` schema 支持 replace/insert/delete 主路径、真实 cell id 和 `cell-N` 索引、code cell 修改后清空 outputs/execution_count、read-before-edit/stale guard、read-state 刷新、`notebook_path` 权限路径识别、结构化结果和 cell-level diff/hunks;完整 notebook UI/file-history/golden parity 仍需继续补。
175175
- Bash 初版已落地,覆盖 command/timeout/description 输入校验、`/bin/sh -c` 执行、stdout/stderr/exit code/timeout 结构化结果、动态 read-only/concurrency-safe/destructive 分类、Git diff/log/show/status/ls-files/grep/rev-parse/branch/tag/ls-remote safe-flag 校验,Git remote/push/reflog/stash/worktree/merge-base/describe/cat-file/for-each-ref/rev-list/blame/shortlog/config-get 参数级安全分类、`git remote show/get-url` 参数收紧、`git ls-remote` URL/SSH/server-option guard、branch/tag 裸 positional 创建防护、`git reflog expire/delete`、`git stash drop/pop/clear` 和 `git worktree remove/prune` 破坏性分类、`find -delete/-exec rm` 与 `xargs rm` 破坏性分类、safe wrapper/env 前缀归一化(`time`/`nohup`/`timeout`/`nice`/`stdbuf`/`env`)后的只读/破坏性分类、临时环境赋值前缀后的破坏性命令识别、权限规则接入、后台启动、同会话 `BashOutput` 输出读取和 `KillBash` 取消;完整 shell parser、真实 sandbox、interrupt、后台任务完整生命周期和官方 golden 仍需继续补。
176-
- Glob/Grep 纯 Go 初版已落地,覆盖 `**` 递归 glob、Glob 绝对 pattern base-dir 提取、Glob 官方 pattern/path-only strict schema、Glob/Grep 输出工作目录相对路径、Glob 默认 no-ignore/hidden 搜索及 `CLAUDE_CODE_GLOB_NO_IGNORE`/`CLAUDE_CODE_GLOB_HIDDEN` env 切换、Grep 官方 VCS metadata 目录排除(`.git`/`.svn`/`.hg`/`.bzr`/`.jj`/`.sl`)、Grep 层级 `.gitignore`/`.ignore`、Glob oldest-first modified/path 排序、Glob 截断 tool-result 提示、Grep regex/fixed string (`fixed_strings`/`-F`)、multiline 跨行 dotall 搜索、glob/type 过滤、Grep glob 空白/逗号多 pattern 与 brace alternation、Glob/Grep path 存在性校验和 Glob directory-only path 校验、`output_mode`/`outputMode` 的 `files_with_matches`/`content`/`count` 输出模式、Grep files_with_matches file-count summary、Grep count-mode occurrence/file summary、Grep `--max-columns 500` 长匹配/上下文行省略占位、`context`/`before_context`/`after_context` 及 `-C`/`-B`/`-A` 上下文行和官方 precedence(非 content 模式忽略)、`line_numbers`/`lineNumbers`/`-n` line-number 控制、`path_separator`/`--path-separator`、`null`/`--null`/`-0` 和 `field_match_separator`/`--field-match-separator`、`field_context_separator`/`--field-context-separator` 输出分隔符控制、`max_count`/`maxCount`/`-m` per-file match limiting、`offset`/`head_limit` 分页和 content-mode pagination tool-result 提示、默认 250 条 Grep head limit、`head_limit=0` unlimited、`ignore_case`/`case_insensitive`/`caseInsensitive`/`-i` 大小写不敏感搜索,以及 Grep 数字/布尔参数的 quoted semantic string 兼容;完整 ripgrep parity 和剩余输出参数仍需继续补。
176+
- Glob/Grep 纯 Go 初版已落地,覆盖 `**` 递归 glob、Glob 绝对 pattern base-dir 提取、Glob 官方 pattern/path-only strict schema、Glob/Grep 输出工作目录相对路径、Glob 默认 no-ignore/hidden 搜索及 `CLAUDE_CODE_GLOB_NO_IGNORE`/`CLAUDE_CODE_GLOB_HIDDEN` env 切换、Grep 官方 VCS metadata 目录排除(`.git`/`.svn`/`.hg`/`.bzr`/`.jj`/`.sl`)、Grep 层级 `.gitignore`/`.ignore`、Glob oldest-first modified/path 排序、Glob 截断 tool-result 提示、Grep regex/fixed string (`fixed_strings`/`-F`)、multiline 跨行 dotall 搜索、glob/type 过滤、Grep glob 空白/逗号多 pattern 与 brace alternation、Glob/Grep path 存在性校验和 Glob directory-only path 校验、`output_mode`/`outputMode` 的 `files_with_matches`/`content`/`count` 输出模式、Grep files_with_matches file-count summary、Grep count-mode occurrence/file summary、Grep `--max-columns 500` 长匹配/上下文行省略占位、`context`/`before_context`/`after_context` 及 `-C`/`-B`/`-A` 上下文行和官方 precedence(非 content 模式忽略)、`line_numbers`/`lineNumbers`/`-n` line-number 控制、`path_separator`/`--path-separator`、`null`/`--null`/`-0`、`field_match_separator`/`--field-match-separator`、`field_context_separator`/`--field-context-separator`、`context_separator`/`--context-separator` 和 `no_context_separator`/`--no-context-separator` 输出分隔符控制、`max_count`/`maxCount`/`-m` per-file match limiting、`offset`/`head_limit` 分页和 content-mode pagination tool-result 提示、默认 250 条 Grep head limit、`head_limit=0` unlimited、`ignore_case`/`case_insensitive`/`caseInsensitive`/`-i` 大小写不敏感搜索,以及 Grep 数字/布尔参数的 quoted semantic string 兼容;完整 ripgrep parity 和剩余输出参数仍需继续补。
177177
- TodoWrite 初版已落地,覆盖完整 todo list 写入、状态/优先级校验、重复 id 拒绝、单个 `in_progress` 约束、结构化结果、tool metadata 状态保存和 session-scoped 本地持久化/恢复;TUI 同步和官方 golden 仍需继续补。
178178
- WebFetch 初版已落地,覆盖 URL/timeout/max_bytes 输入校验、HTTP GET、HEAD preflight、metadata/raw `skipWebFetchPreflight` skip-preflight、二进制 preflight 跳过 GET、文本/二进制判定、截断、非 2xx error 标记、结构化结果、HTML-to-text rendering、prompt-focused excerpt、prompt phrase scoring/metadata 和 `WebFetch(domain:...)` 权限规则适配;browser 渲染、完整 prompt-aware summarization 和官方 golden 仍需继续补。
179179
- WebSearch HTML/JSON 搜索适配初版已落地,覆盖 query/max_results/timeout/domain filters 输入校验、可注入搜索 endpoint、DuckDuckGo HTML 链接解析、DuckDuckGo subdomain redirect unwrap、常见 JSON result shapes、DuckDuckGo result snippet 抽取、domain allow/block 过滤、结构化结果和 query 权限规则匹配;官方搜索后端、ranking parity 和 golden 仍需继续补。
@@ -220,6 +220,7 @@ test/parity/ # golden tests against TS/official behavior
220220
- 本轮补充:Grep 带路径的输出现在支持 ripgrep 风格 `path_separator`/`--path-separator`,可替换 content/count/file-list/heading 可见路径中的 `/`,并按官方约束拒绝多字节分隔符。
221221
- 本轮补充:Grep 带路径的输出现在支持 ripgrep 风格 `null`/`--null`/`-0`,文件列表路径使用 NUL 终止,content/count/heading 输出把路径字段后的分隔符替换为 NUL;`--no-filename` 时不会额外产生 NUL。
222222
- 本轮补充:Grep content 输出现在支持 ripgrep 风格 `field_match_separator`/`fieldMatchSeparator`/`field-match-separator`/`--field-match-separator``field_context_separator`/`fieldContextSeparator`/`field-context-separator`/`--field-context-separator`,匹配行与上下文行可分别使用自定义字段分隔符,并兼容空字符串分隔符与 `--null` 路径字段分隔。
223+
- 本轮补充:Grep content 上下文输出现在支持 ripgrep 风格 `context_separator`/`contextSeparator`/`context-separator`/`--context-separator``no_context_separator`/`noContextSeparator`/`no-context-separator`/`--no-context-separator`,会在同文件不连续上下文块和非 heading 跨文件块之间插入默认 `--` 或自定义分隔行,heading 模式仅在同一文件内部插入。
223224
- 本轮补充:Grep 常用布尔参数继续补齐 ripgrep 长参数 aliases,覆盖 `--line-number``--ignore-case``--fixed-strings``--word-regexp``--invert-match``--only-matching`,并兼容 quoted semantic boolean。
224225
- 本轮补充:Grep multiline 搜索现在支持 ripgrep 风格 `-U``--multiline``multiline-dotall``--multiline-dotall` aliases,统一映射到既有跨行 dotall 匹配逻辑并兼容 quoted semantic boolean。
225226
- 本轮补充:Grep 搜索现在支持 `no_ignore`/`noIgnore`/`no-ignore`/`--no-ignore`,可跳过 `.gitignore`/`.ignore` 规则,同时继续排除 VCS metadata 目录并保留 Read deny 额外 ignore 保护;`--no-ignore` 兼容 quoted boolean。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ Covered behavior:
145145
- `Grep` path-bearing output now accepts `path_separator`/`--path-separator`, replacing visible `/` separators in content, count, file-list, and heading output while validating one-byte separators.
146146
- `Grep` path-bearing output now accepts `null`/`--null`/`-0`, using NUL after path fields for content/count/heading and NUL-terminated paths in file-list modes.
147147
- `Grep` content output now accepts `field_match_separator`/`fieldMatchSeparator`/`field-match-separator`/`--field-match-separator` plus `field_context_separator`/`fieldContextSeparator`/`field-context-separator`/`--field-context-separator`, preserving separate match/context field separators including empty values and `--null` path-field output.
148+
- `Grep` content context output now accepts `context_separator`/`contextSeparator`/`context-separator`/`--context-separator` plus `no_context_separator`/`noContextSeparator`/`no-context-separator`/`--no-context-separator`, inserting the default `--` or a custom group separator between disjoint context groups and suppressing it when requested.
148149
- `Grep` content output now accepts `trim`/`--trim` plus `no_trim`/`--no-trim`, trimming leading ASCII whitespace from printed line text while preserving original match columns.
149150
- `Grep` long-line output now accepts `max_columns_preview`/`--max-columns-preview` plus `no_max_columns_preview`/`--no-max-columns-preview`, showing a ripgrep-style truncated preview when `max_columns` is exceeded.
150151
- `Glob`/`Grep` traversal now applies `Read(...)` deny rules from the permission context as extra search ignore rules, hiding denied basename, path, and directory patterns from search results.

0 commit comments

Comments
 (0)