# `grokkit agent` Go tools integration ## Priority: 4 of 12 **Description**: Wrappers for `go` subcommands: mod tidy, generate, vet, fmt. Ensures hygiene post-agent edits. ## Problem It Solves Agent changes may break deps/fmt/vet—manual fixes. Auto-run + fix loops. ## Benefits - **Hygiene auto**: Tidy deps, fmt code, vet issues. - **Generate**: Run go:generate for boilerplate. - **Safe mutations**: Preview changes (git diff). - **Workflow**: Edit → gotools tidy → test. ## Agent Tool Examples ``` grokkit agent "Add new import, tidy mods, vet all" # Grok: edits → go mod tidy → go vet → reports clean ``` ## High-Level Implementation 1. **Detect**: `go version`. 2. **Tool schemas**: - `tidy() → changes` - `vet(path?) → issues` - `generate() → output` - `fmt_diff() → diff` 3. **Wrappers** in `internal/tools/gotools.go`: ```go func Tidy(ctx context.Context, args map[string]any) (string, error) ``` 4. **Agent integration**: Post-edit hygiene step. 5. **Safety**: - Dry-run where possible (go fmt -d). - Whitelist subcmds. - Config: `[tools.gotools.enabled]`. ## Flags / Config | Key | Description | |-----|-------------| | `tools.gotools.enabled` | Enable Go tools | ## Implementation Notes - **Commands**: `go mod tidy`, `go vet ./...`, `go generate ./...`. - **Parsing**: Diff output, error lists. - **Errors**: GoToolError. - **Tests**: Mock, table-driven. - **Effort**: Low (~130 LOC). - **Prereq**: Go workspace. ## ROI **High**. Go-specific polish: | Stage | Covered | |-------|---------| | Hygiene | **gotools** ← new | | Search | rg (sibling) | | Build | make (sibling) |