Documentation
¶
Overview ¶
Local semantic search over the workdir's source code (code_search).
Substring search fails exactly when memory does: you remember the *concept* ("that clustering IP problem") but not the keyword (RegisterAllProvidersIP). With an embedding model loaded in LM Studio and "embed_model" set in config, code_search finds code by meaning.
Design: source files are chunked (line-aware), embedded via the standard /v1/embeddings endpoint in batches, and cached in a gob file under ~/.agent/index/ keyed by workdir. The index is INCREMENTAL: each search rescans the tree by (path, mtime, size) and embeds only new or changed chunks — a stable tree costs one query embedding per search, nothing more. No vector database; at personal-project scale a linear cosine scan over a few thousand chunks is microseconds.
Degrades gracefully: no embed_model configured → code_search is not registered. Embedding server errors → one dim note, no crash.
Semantic git tools — structured, read-only access to repository history so the model can understand code provenance without shelling out through run_command and parsing raw `git` text itself.
Three tools:
git_log — recent commits (hash, author, date, subject), optionally for a path git_blame — who last changed each line of a file (or a line range) git_show — a single commit's message + diff
All are read-only (no working-tree mutation), so they're marked read-only: available in plan mode and safe to batch. They use `git --no-pager` with stable formatting and confine any path argument to the workspace via the sandbox, matching the file tools' safety model.
Structured & atomic editing — the "safe refactor" toolset.
Three capabilities the plain edit_file loop couldn't give a small model:
edit_files — N edits across M files applied ATOMICALLY: every edit
validates first, then all apply, or none do. The DI
refactor failed repeatedly because the model changed
todo.go, broke the build, and couldn't change cmd/*.go
in the same breath — the tree was red between turns.
This makes "change the signature and every caller" one
indivisible step.
rename_symbol— a REAL rename via gopls, not text substitution: renames
the declaration and every reference across packages,
respecting scope (won't touch a same-named field on an
unrelated type). Falls back with a clear message when
gopls isn't installed.
go_diagnostics—type errors and vet findings from gopls WITHOUT a build,
so the model can check its work cheaply mid-turn.
Plus parseTestFailures (used by the verify loop): turns a wall of `go test` output into just the failing tests and their file:line assertions, so the model gets a target instead of a haystack.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterEmbedTools ¶
func RegisterEmbedTools()
RegisterEmbedTools adds code_search when an embedding model is configured.
func RegisterGitTools ¶ added in v0.2.0
func RegisterGitTools()
RegisterGitTools adds the read-only semantic git tools to the engine.
func RegisterStructuredTools ¶
func RegisterStructuredTools()
RegisterStructuredTools adds the atomic/gopls tools. gopls tools are registered even when gopls is absent — they return an install hint rather than vanishing, so the model learns the capability exists.
Types ¶
This section is empty.