Skip to content

Commit 4ac2981

Browse files
author
SqlRush
committed
Add Grep negative type filters
1 parent 886b9ed commit 4ac2981

4 files changed

Lines changed: 99 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`、Grep `hidden`/`--hidden` 和 `no_hidden`/`--no-hidden` 隐藏文件遍历控制、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 控制、`byte_offset`/`--byte-offset`/`-b`、`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 和剩余输出参数仍需继续补。
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`、Grep `hidden`/`--hidden` 和 `no_hidden`/`--no-hidden` 隐藏文件遍历控制、Glob oldest-first modified/path 排序、Glob 截断 tool-result 提示、Grep regex/fixed string (`fixed_strings`/`-F`)、multiline 跨行 dotall 搜索、glob/type/type-not 过滤、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 控制、`byte_offset`/`--byte-offset`/`-b`、`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 仍需继续补。
@@ -206,6 +206,7 @@ test/parity/ # golden tests against TS/official behavior
206206
- 本轮补充:Grep 文件列表输出现在支持 `files_without_match`/`filesWithoutMatch`/`files-without-match`/`--files-without-match`/`-L`,也接受 `output_mode``files_without_match(es)`,用于列出不含匹配的文件并兼容 quoted boolean。
207207
- 本轮补充:Grep 文件列表输出现在显式支持 `files_with_match(es)`/`filesWithMatch(es)`/`files-with-match(es)`/`--files-with-match(es)`/`-l`,并接受 `output_mode``files_with_match` alias,统一归一为 `files_with_matches`
208208
- 本轮补充:Grep 路径过滤现在支持 ripgrep 风格 `--glob`/`-g``--type`/`-t` aliases,执行和 structured content 都统一使用归一化后的 glob/type 过滤值。
209+
- 本轮补充:Grep 路径过滤现在支持 ripgrep 风格 `type_not`/`typeNot`/`type-not`/`--type-not`/`-T`,可在 `type` 限定后排除指定文件类型,structured content 会回传归一化后的排除类型。
209210
- 本轮补充:Grep `glob`/`--glob`/`-g` 路径过滤现在支持 ripgrep 风格 `!pattern` 排除规则,可与正向 glob、逗号/空白多 pattern 和 brace alternation 组合;只有排除规则时默认包含未被排除的路径。
210211
- 本轮补充:Grep 搜索现在支持 ripgrep 风格 `text`/`--text`/`-a`,可显式把二进制扩展名文件按文本读取参与匹配,structured content 会回传 `text` 状态;`-a` 同样兼容 quoted semantic boolean。
211212
- 本轮补充:Grep content 输出现在支持 ripgrep 风格 `passthru`/`passthrough`/`--passthru`/`--passthrough`,可输出被搜索文件的全部行并保留匹配行标记;启用后按官方语义覆盖 context 行数,quoted semantic boolean 同样兼容。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ Covered behavior:
133133
- `Grep` content output now accepts `column`/`column_numbers`/`columnNumbers`/`column-number`/`--column`, emitting `path:line:column:text` for matching lines while preserving context-line formatting and structured column metadata.
134134
- `Grep` files-with-matches output now mirrors the official modified-time sort: newest files first, path tie-breaker, and pagination applied after sorting.
135135
- `Grep` now accepts ripgrep-style result ordering through `sort`/`--sort` and `sortr`/`--sortr`, covering path, modified-time, and none ordering for files/content/count modes with structured sort metadata.
136+
- `Grep` now accepts ripgrep-style negative type filtering through `type_not`/`typeNot`/`type-not`/`--type-not`/`-T`, applying it after any positive `type` filter and preserving structured filter metadata.
136137
- `Grep` glob filtering now accepts ripgrep-style negated `!pattern` rules, including combinations with positive patterns, comma/whitespace splitting, and brace-expanded globs.
137138
- `Grep` now accepts `text`/`--text`/`-a` to search binary-extension files as text while preserving the default binary-extension skip behavior.
138139
- `Grep` now accepts `line_regexp`/`line-regexp`/`--line-regexp`/`-x` to require whole-line matches, with fixed-string and word-regexp precedence covered.

0 commit comments

Comments
 (0)