-
Notifications
You must be signed in to change notification settings - Fork 412
feat(tools): add read-only "git" toolset for structured repository inspection #3637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dwin-gharibi
wants to merge
14
commits into
docker:main
Choose a base branch
from
dwin-gharibi:feat/git-tool
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+730
−2
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8bb6e82
feat(pkg/tools/builtin/git/git.go): add read-only git toolset
dwin-gharibi bfd39cb
test(pkg/tools/builtin/git/git_test.go): add unit tests for git toolset
dwin-gharibi e9873dc
feat(pkg/teamloader/toolsets/toolsets.go): register git built-in toolset
dwin-gharibi f5d2b84
feat(pkg/teamloader/toolsets/catalog.go): add git toolset catalog entry
dwin-gharibi 4f94485
docs(docs/configuration/tools/index.md): document git built-in toolset
dwin-gharibi 715aa27
docs(docs/tools/git/index.md): add git toolset documentation
dwin-gharibi d7579c9
Merge branch 'docker:main' into feat/git-tool
dwin-gharibi a91b70e
fix(pkg/tools/builtin/git/git.go): fixing up all review feedbacks rep…
dwin-gharibi 9e86792
fix(pkg/tools/builtin/git/git_test.go): fixing up the git tool tests …
dwin-gharibi 3295c65
fix(docs/tools/git/index.md): updating up the docs with latest changes
dwin-gharibi 1068287
fix(agent-schema.json): adding up the git tool into toolsets
dwin-gharibi 302e96c
Merge branch 'main' of github.com:dwin-gharibi/docker-agent into feat…
dwin-gharibi 08e3d2c
Merge branch 'feat/git-tool' of github.com:dwin-gharibi/docker-agent …
dwin-gharibi 085e39f
fix(agent-schema.json): fixing the malformed agent-schema.json causin…
dwin-gharibi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| --- | ||
| title: "Git Tool" | ||
| description: "Read-only inspection of the working git repository." | ||
| keywords: docker agent, ai agents, tools, toolsets, git tool | ||
| linkTitle: "Git" | ||
| weight: 125 | ||
| canonical: https://docs.docker.com/ai/docker-agent/tools/git/ | ||
| --- | ||
|
|
||
| _Read-only inspection of the working git repository._ | ||
|
|
||
| ## Overview | ||
|
|
||
| The git toolset gives an agent structured, **read-only** access to the working repository — status, history, branches, a commit's changes, and line-level authorship. It is implemented with go-git, so it needs **no `git` binary**. | ||
|
|
||
| Compared with running `git` through the `shell` tool, the git toolset returns clean, structured output the model can read reliably, is **safe by construction** (no command can modify the repository), and works even when `shell` is disabled or no `git` binary is installed. | ||
|
|
||
| > [!NOTE] | ||
| > The git toolset is read-only. To stage, commit, or check out, use the [`shell`](../shell/index.md) tool. | ||
|
|
||
| ## Configuration | ||
|
|
||
| ```yaml | ||
| toolsets: | ||
| - type: git | ||
| ``` | ||
|
|
||
| No configuration options. The repository is opened at the agent's working directory; a subdirectory still resolves to the repository root. | ||
|
|
||
| > [!WARNING] | ||
| > **The repository is discovered by walking up parent directories.** If the working | ||
| > directory is not itself a repository but an ancestor is (for example a | ||
| > home directory tracked as dotfiles), the toolset resolves to that ancestor and | ||
| > `git_show` / `git_blame` can expose its full history and file contents. The | ||
| > filesystem toolset's allow/deny lists do **not** apply here. Only enable this | ||
| > toolset where the surrounding repository is safe to read. | ||
|
|
||
| > [!NOTE] | ||
| > **Performance.** go-git is pure Go, which costs speed on large repositories: | ||
| > `git_status` rehashes the whole worktree, and `git_blame` scales with history | ||
| > depth times file size — its 400-line output cap is applied *after* the full | ||
| > computation, so it does not make blaming a large file cheaper. | ||
|
|
||
| ## Tools | ||
|
|
||
| | Tool | Description | | ||
| | --- | --- | | ||
| | `git_status` | Current branch and changed files (staged / unstaged / untracked). | | ||
| | `git_log` | Recent commits (hash, date, author, subject). | | ||
| | `git_branches` | Local branches, current one marked with `*`. | | ||
| | `git_show` | A commit's metadata, message, and changed files with +/- counts. | | ||
| | `git_blame` | Line-by-line authorship for a file. | | ||
|
|
||
| ### `git_log` | ||
|
|
||
| | Parameter | Required | Description | | ||
| | --- | --- | --- | | ||
| | `limit` | No | Maximum number of commits to return (default 20). | | ||
| | `path` | No | Only show commits that touch this path. | | ||
|
|
||
| ### `git_show` | ||
|
|
||
| | Parameter | Required | Description | | ||
| | --- | --- | --- | | ||
| | `ref` | No | Commit hash or revision to show (default HEAD). | | ||
|
|
||
| ### `git_blame` | ||
|
|
||
| | Parameter | Required | Description | | ||
| | --- | --- | --- | | ||
| | `path` | Yes | File path to blame, relative to the repository root. | | ||
| | `rev` | No | Commit or revision to blame at (default HEAD). | | ||
|
|
||
| ## Example | ||
|
|
||
| ```yaml | ||
| agents: | ||
| root: | ||
| model: openai/gpt-5-mini | ||
| description: A code review assistant | ||
| instruction: | | ||
| Review the working changes: check git_status, then git_show the latest | ||
| commit, and summarize what changed. | ||
| toolsets: | ||
| - type: git | ||
| - type: filesystem | ||
| ``` | ||
|
|
||
| Example `git_status` output: | ||
|
|
||
| ```text | ||
| On branch master | ||
| 1 changed file(s) [XY = staged/worktree; M=modified A=added D=deleted R=renamed ?=untracked]: | ||
| M main.go | ||
| ``` | ||
|
|
||
| > [!TIP] | ||
| > **When to use** | ||
| > | ||
| > Use the git toolset whenever the agent needs repository context — before editing, to review recent history, or to find who last touched a line — without exposing the writable `shell` surface. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.