feat(docs,hooks): enforce rgai-first search policy#125
Open
heAdz0r wants to merge 3 commits intortk-ai:masterfrom
Open
feat(docs,hooks): enforce rgai-first search policy#125heAdz0r wants to merge 3 commits intortk-ai:masterfrom
heAdz0r wants to merge 3 commits intortk-ai:masterfrom
Conversation
Rust-native semantic search that scores files and lines by term relevance, symbol definitions, and path matching. No external dependencies (no grepai/embeddings required). Features: - Natural-language multi-word queries: rtk rgai "auth token refresh" - File scoring with symbol definition boost (+2.5) and comment penalty - Stop word removal + basic stemming for better recall - Compact and JSON output modes - File type filtering (--file-type ts/py/rust/etc.) - gitignore-aware traversal via `ignore` crate - Binary and large file skipping - Backward-compat: trailing path token auto-detection Includes 8 unit tests (5 in rgai_cmd, 3 for arg normalization).
Replace naive append-or-skip logic in run_claude_md_mode with upsert_rtk_block() that handles all 4 cases: - Added: no existing block → append - Updated: stale block → replace in-place - Unchanged: current block → no-op - Malformed: opening marker without closing → warn safely Includes 4 unit tests covering each case.
Search priority (mandatory): rgai > rg > grep. Hook changes: - Add rewrite rules: grepai/rgai search -> rtk rgai (Tier 1) - Split rg and grep into separate rules (Tier 2/3) - Source-of-truth comment for hook sync - Test infrastructure: HOOK env override, script-relative path Doc updates (README, INSTALL, TROUBLESHOOTING, awareness template): - Add search priority section - Update command tables with rtk rgai examples - Add search ladder (rgai -> grep -> proxy) - Remove unverifiable benchmark table Template updates (init.rs): - RTK_INSTRUCTIONS: add rtk rgai to Files & Search section - show_config: display search priority hint - Tests: assert rtk rgai in top-level commands list Test fixes: - Fix pre-existing find/tree/wget test expectations (hook already rewrites them on master, tests incorrectly expected no rewrite) - Add 7 new hook tests for rgai/grepai rewrite rules
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
Extracted from #118 per reviewer feedback. This PR adds the search policy documentation and hook rewrites that depend on #123 (upsert refactor) and #124 (rtk rgai command).
Depends on: #123, #124
What changed
Hook rewrite rules (
hooks/rtk-rewrite.sh,.claude/hooks/rtk-rewrite.sh):grepai search <query>/rgai search <query>→rtk rgai <query>rgai <query>→rtk rgai <query>rg <pattern>→rtk grep <pattern>(split from combined rule)grep <pattern>→rtk grep <pattern>(split from combined rule)Documentation (README, INSTALL, TROUBLESHOOTING, awareness template):
rgai > rg > greprtk rgai→rtk grep→rtk proxyrtk rgaiexamplesTemplates (
src/init.rs):rtk rgaito Files & Search sectionshow_config(): displays search priority hintTest fixes:
Benchmark table removal
The benchmark table from #118 cited "internal migration benchmark artifacts (private repository)" — not verifiable by contributors. Removed entirely. A follow-up PR will add a reproducible benchmark using a public dataset or synthetic test set.
Test plan
cargo test— 325 tests passcargo fmt --all --check— cleanbash hooks/test-rtk-rewrite.sh— 57/57 pass (was 54/57 on master)