Skip to content

feat(grokbuild): hashline anchor editing; fuzzy file search - #244

Merged
Patel230 merged 2 commits into
mainfrom
feat/grokbuild-hashline-fuzzysearch
Aug 23, 2026
Merged

feat(grokbuild): hashline anchor editing; fuzzy file search#244
Patel230 merged 2 commits into
mainfrom
feat/grokbuild-hashline-fuzzysearch

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Summary

Two final adoptions from grok-build's tool implementations.

Hashline anchor-based editing — internal/tool/hashline.go

  • Every line carries a content-derived SHA-256 hash anchor
  • ReadAnchored outputs L{line}:{hash}|{content} for agent reference
  • ApplyEdits validates ALL anchors against current content before applying anything: a bad hash rejects the entire batch atomically (no partial writes)
  • Shifted-anchor recovery finds drifted content within ±5 lines so insertion/deletion above the edit point doesn't force re-read
  • Bottom-up application prevents earlier edits from shifting later line numbers

Fuzzy file search — internal/fuzzyfind + FuzzyFind tool

  • Scored path matching: exact basename > basename prefix > contains > multi-word segments > camelCase/abbrev, path-length tiebreak
  • Gitignore-aware walk excluding vendor/node_modules/build dirs
  • FuzzyFind tool registered in chat_tools.go + safety capabilities

Testing

  • hashline suite (8): read, replace, insert/delete, atomic rejection, shifted-anchor recovery, beyond-window failure, bottom-up ordering, validation
  • fuzzyfind suite (7): exact/partial scoring, multi-word, skip dirs, k limit, abbrev, empty query, non-dir root
  • FuzzyFindTool suite (3)
  • Full cmd/tool/safety/testaudit suites pass; golangci-lint 0 issues

Two final adoptions from grok-build's tool implementations.

Hashline anchor-based editing (internal/tool/hashline.go):
- Every line carries a content-derived SHA-256 hash anchor; ReadAnchored
  outputs L{line}:{hash}|{content} for the agent to reference.
- ApplyEdits validates ALL anchors against current content before
  applying anything: a bad hash rejects the entire batch atomically with
  no partial writes. Shifted-anchor recovery finds drifted content within
  a bounded window so insertion/deletion above the edit point does not
  force the agent to re-read the file. Bottom-up application prevents
  earlier edits from shifting later line numbers.

Fuzzy file search (internal/fuzzyfind + FuzzyFind tool):
- Scored path matching: exact basename > basename prefix > basename
  contains > multi-word segments > path contains > camelCase/abbrev,
  with path-length tiebreak. Gitignore-aware walk.
- FuzzyFind tool registered in chat_tools.go with safety capabilities +
  permission aliases. Complements Glob/Grep for approximate lookups.

Verification: new suites green (hashline 8, fuzzyfind 7, FuzzyFindTool 3);
tool, cmd, safety, testaudit suites pass; golangci-lint 0 issues;
gofmt clean; go build ./... clean.
The previous commit missed internal/fuzzyfind/ (the package implementing
scored path matching) and the chat_tools/capabilities/permission
registrations for both CodeMatch and FuzzyFind, because the initial
git add failed on the missing test file and the retry only staged
internal/tool/.
@Patel230
Patel230 merged commit 8dbe5a7 into main Aug 23, 2026
26 checks passed
@Patel230
Patel230 deleted the feat/grokbuild-hashline-fuzzysearch branch August 23, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant