feat(docs,hooks): enforce rgai-first search policy#125
feat(docs,hooks): enforce rgai-first search policy#125heAdz0r 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
|
Hi! I noticed the The PR currently has no merge conflicts and all tests pass locally. It does depend on #123 and #124 — is the label related to waiting for those to merge first, or are there specific changes you'd like to see? Thanks! |
|
We're still reviewing #124. We cannot force the use of a tool — # Search priority (mandatory): rgai > rg > grep is not acceptable. rtk is a proxy, not a policy enforcer. If rtk rgai is to exist, it should follow the same pattern as every other rtk command: proxy an existing external command (grepai/rgai) if installed, compress its output, and that's it. Please remove all the hook rewrites, documentation changes, and init template modifications from this PR. Otherwise, please close PRs #124, #125, #127, and #136. we are open for discussion if you want. |
|
Closing — agreed with maintainers to keep grepai/rgai activity in my fork (heAdz0r/rtk) and not mix it into upstream for now. |
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)