feat(code-search): structural CodeMatch tool; wire CodeSearch + incremental refresh - #238
Merged
Conversation
…mental refresh Two adoptions from the cocoindex-io org mapped against hawk's code intelligence stack. CodeMatch structural search (internal/tool/code_match*.go): - AST-level tree-sitter query search over Go/Python/TypeScript/TSX, using the same smacker/go-tree-sitter grammars codegraph already links. Patterns are S-expressions with @capture nodes; results carry per-file start/end lines, capture names, and line snippets. - Syntax-aware: comments and string literals cannot false-positive (unlike regex Grep). Auto-detects language per file or restricts via language param; gitignore-aware walk with bounded match limit. - CGO-gated with a no-CGO stub so builds stay portable; language-agnostic shared surface (Name/Params/Execute) lives in a cgo-free file. Wire CodeSearch + incremental refresh (internal/engine): - CodeSearchFn and RefreshCodeIndexFn were declared on ToolContext but never bound, so CodeSearchTool reported 'not available' in production and the refresh flag was a silent no-op. Both are now wired in tool_service.go: - CodeSearchFn -> yaad bridge SearchCode (with Language derived from path) - RefreshCodeIndexFn -> repomap.IncrementalReindex, which re-indexes only added/changed files via SHA-256 content-hash staleness and prunes deleted ones (the cocoindex incremental-engine pattern). - Adds a small yaadCodeIndexer adapter implementing repomap.CodeIndexer over the memory bridge (the two packages define identical result types). Registered CodeMatch in chat_tools.go with safety capabilities and permission aliases; both cgo and CGO_ENABLED=0 (linux/windows) builds verified. Verification: new CodeMatch suite (6 tests) green; tool, engine, repomap, memory suites pass; golangci-lint 0 issues; gofmt clean.
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
Two adoptions from the cocoindex-io org mapped against hawk's code-intelligence stack (which already had repomap/codegraph but lacked a structural matcher and had unbound code-search hooks).
1. CodeMatch — structural (AST) search tool
smacker/go-tree-sittergrammarscodegraphalready links. Patterns are S-expressions with@capturenodes.language=restriction; gitignore-aware walk; boundedlimit.CGO_ENABLED=0linux/windows cross-compiles.2. Wire CodeSearch + incremental refresh (the cocoindex "only reprocess what changed" idea)
CodeSearchFn/RefreshCodeIndexFnwere declared but never bound — CodeSearchTool reported "not available" in production and the refresh flag was a silent no-op. Now wired intool_service.go:CodeSearchFn→ yaad bridgeSearchCodeRefreshCodeIndexFn→repomap.IncrementalReindex(SHA-256 content-hash staleness: only added/changed files re-index, deleted ones pruned)yaadCodeIndexeradapter implementsrepomap.CodeIndexerover the memory bridge (identical result types in two packages).Registered
CodeMatchinchat_tools.go+ safety capabilities + permission aliases.Testing
CGO_ENABLED=0builds green