mirror of
https://github.com/cocoindex-io/cocoindex-code.git
synced 2026-09-14 16:39:38 +08:00
2e96b45636
* feat: add `ccc grep` structural code search Add a `ccc grep "PATTERN" [DIR/FILE]` subcommand backed by cocoindex's structural `code_match` API. It compiles the pattern once per language, walks the project (honoring configured include/exclude globs and nested .gitignore, or the enclosing git repo when run outside a cocoindex project), and matches files in parallel on a thread pool, streaming each file's results as soon as it completes. Supports `--lang` and `--path` filters like `ccc search`, and renders matches with colorized line numbers and paths under a TTY. Extract the shared source-file walking logic (the include/exclude + nested-gitignore matcher and the os.walk-based file iteration) into a new `file_walk` module, now the single source of truth used by the indexer, the daemon's doctor file-walk, and grep. Bump cocoindex to >=1.0.13 for the locked symmetric pattern syntax used by `code_match`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(grep): normalize display paths to posix and strip CRLF in output On Windows the directory walk rendered paths with backslashes (e.g. `sub\b.py`) and CRLF files left a trailing `\r` on every rendered code line, which broke two tests. Normalize all display paths via `Path.as_posix()` — matching the indexer and `ccc search` — and strip the trailing `\r` when splitting source into lines. Add a CRLF rendering regression test that runs on all platforms. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test(grep): assert posix display path in path_glob test Completes the Windows path fix: test_grep_path_glob compared fm.path (now normalized to posix) against a str()-built path, which renders with backslashes on Windows. Use as_posix() so the assertion is platform independent, matching the other display-path assertions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>