feat(tools): add read-only "git" toolset for structured repository inspection#3637
feat(tools): add read-only "git" toolset for structured repository inspection#3637dwin-gharibi wants to merge 14 commits into
Conversation
|
Let's just continue. @aheritier @Sayt-0 |
Sayt-0
left a comment
There was a problem hiding this comment.
Summary
Useful addition: structured, read-only git context without the writable shell surface or a git binary, and the implementation follows the builtin-toolset patterns closely (creator + catalog + drift-guard, annotations, instructions, docs page, atomic conventional commits). Two blocking items prevent approval as-is; both are quick fixes. Inline comments follow.
Blocking
| # | Finding | Where | Impact |
|---|---|---|---|
| 1 | golangci-lint fails on the branch: 10x forbidigo (context.Background() in tests is banned, use t.Context()) and 1x modernize (strings.Cut). Note: the linter output shows only 3 of the 10 forbidigo hits because of max-same-issues: 3. |
pkg/tools/builtin/git/git_test.go, pkg/tools/builtin/git/git.go |
The ci / lint job will fail. The green checks currently on the PR are docs-only workflows; the Go CI has not run yet. |
| 2 | agent-schema.json is not updated: the Toolset.type enum does not include "git". |
agent-schema.json (Toolset.type enum, near the scheduler / rag entries) |
Editors validating configs against the schema flag type: git as invalid, and any future docs example using git fails pkg/config/schema_test.go. The catalog drift-guard was handled, but this second registration point was missed. |
Non-blocking suggestions
git_statuson a freshly initialized repository (unborn HEAD) printsOn branch (detached HEAD), andgit_logreturnsError: reading log: reference not found. Friendlier handling ("no commits yet") would help agents on brand-new repos.- Docs: a short caveat on go-git performance would set expectations.
Worktree().Status()rehashes the whole worktree (slow on large repos) andBlamecost grows with history x file size;maxBlameLinestruncates output only after the full computation. - Docs:
DetectDotGitwalks up parent directories. When the working directory is not itself a repository but an ancestor is (for example a dotfiles-tracked home directory),git_show/git_blameexpose the ancestor repository's full history and file contents. Worth an explicit note in the docs page, sincefilesystemconfinement (allow/deny lists) does not apply here. - Test coverage gaps (fast follows):
git_logpathfilter,git_showwith an explicit and an invalidref,git_blamewithrev, the 400-line truncation path, andCreateToolSet.
Verdict
Request changes for items 1 and 2; everything else is optional. With those fixed, the toolset looks good to land as a read-only v1.
…orted on new git tool
…up with latest feedbacks
…into feat/git-tool
|
@Sayt-0 Thank you for the review - the reproduction detail (including the Blocking
Suggestions (all taken)
On Do let me know if any change is required please. |
|
Fixed malformed agent-schema.json @Sayt-0. |
Closes #3636
Summary
Adds a new built-in toolset,
git, giving an agent structured, read-only access to the working repository: status, log, branches, commit details, and blame. Implemented withgo-git(already a direct dependency), so it needs nogitbinary and is fully unit-testable.Tools:
git_status,git_log,git_branches,git_show,git_blame.Motivation
Coding agents constantly need git context. Today the only option is the
shelltool with rawgit, which forces the model to parse free-form porcelain, exposes the full writable shell surface, and depends on agitbinary. A dedicated read-only toolset returns clean structured output, is safe by construction, and works withoutshellor the binary.What changed
pkg/tools/builtin/git/git.gopkg/tools/builtin/git/git_test.gopkg/teamloader/toolsets/toolsets.gogitcreator.pkg/teamloader/toolsets/catalog.gogitcatalog entry (required by the drift-guard test).docs/configuration/tools/index.mdgitto the built-in toolsets table.docs/tools/git/index.mdDesign
add/commit/checkout— write ops are stateful, overlapshell, and raise permission questions; deferred to keep v1 safe.WorkingDirwithDetectDotGit.Example output
Testing
go test ./pkg/tools/builtin/git/ ./pkg/teamloader/toolsets/git_status(changed + clean),git_log(order +limit),git_branches(current marked),git_show(metadata + stats),git_blame(authorship), plus not-a-repo and missing-path error paths, and the tool-count/interface check.TestBuiltinToolsetsCatalogMatchesRegistrypasses withgitin both registry and catalog.All pass;
gofmt -landgo vetclean. (CI runstask lint/task test.)Scope / non-goals
git_showcovers commit-level diffs. Both are noted as possible future work.