- Added priority markers (e.g., "Priority: X of 12") to existing queued TODOs like audit, changelog, profile, scaffold. - Introduced new detailed TODO markdowns for agent integrations: cnotes, git-chglog, gotools, make, pprof, rg, tea. - Enhances planning for grokkit agent tooling ecosystem.
2.1 KiB
2.1 KiB
grokkit agent ripgrep (rg) integration
Priority: 4 of 12
Description: Fast search wrapper for ripgrep (rg). Enables agent to grep project for symbols/patterns/context before edits.
Problem It Solves
Agent lacks quick codebase search—relies on full file scans or manual grep. rg is 10x faster, regex-aware.
Benefits
- Lightning search: Multi-line, git-ignored, type-aware (
--type=go). - Context gathering: "rg 'err handling' → snippets for prompt".
- Safe: Read-only, project-only, no filespecs.
- Stats: Count matches, paths.
- Workflow: "Search todos → prioritize → edit".
Agent Tool Examples
grokkit agent "Find all error returns in cmd/, improve handling"
# Grok: rg 'return err' cmd/ → analyzes → targeted edits
grokkit agent "Count test coverage gaps: rg 't.Skip' or untested funcs"
# Grok: rg --type=go '_test\.go' → stats → testgen suggestions
High-Level Implementation
- Detect:
rg --version. - Tool schemas:
search(pattern: string, path?: string) → matches[]count(pattern: string) → int
- Wrappers in
internal/tools/rg.go:func Search(ctx context.Context, args map[string]any) (string, error) - Agent integration: Pre-plan search → richer context.
- Safety:
- Args whitelist: --type, --no-heading, project root.
- Max 100 matches.
- Config:
[tools.rg.enabled].
- Parsing: JSON output (
--json), or lines → structured.
Flags / Config
| Key | Description |
|---|---|
tools.rg.enabled |
Enable rg tools |
tools.rg.max_matches |
Limit results |
Implementation Notes
- Commands:
rg PATTERN [PATH] --no-heading --colors=never. - Extend agent: Optional search phase in planning.
- Errors: RgError.
- Tests: Mock, table-driven patterns.
- Effort: Low (~100 LOC).
- Prereq: rg installed (
apt install ripgrep).
ROI
High. Search is dev superpower:
| Stage | Covered |
|---|---|
| Search | rg ← new |
| Edit | agent ✓ |
| Verify | make (sibling) |
Agent plans smarter with instant intel.