Skip to content

feat(tools/gocode): Implement Go code analysis tools #41

@TobiasGleiter

Description

@TobiasGleiter

Summary

Implement a set of Go code analysis tools for the agent to understand
a codebase. Each tool must be a scalpel — small, focused, and answering
exactly one question. No tool should do more than its name implies.

Rules

  • One concern per tool, no exceptions
  • Return JSON only
  • No tool should wrap or call another tool
  • Prefer go/ast and go/packages over shelling out
  • If a tool needs more than ~50 lines, it is doing too much

Tools

Orientation

  • ListPackages — all packages with import paths
  • ListFiles — files in a package with line counts
  • GetFileContent — file content with line numbers

Declarations

  • ListDeclarations — top-level funcs, types, vars in a file or package
  • GetFunctionSignature — signature and doc comment for a named function
  • GetStructFields — fields, types, and struct tags for a named type
  • GetInterfaceMethods — method set of a named interface

Semantics

  • FindImplementors — all types implementing a given interface
  • FindUsages — all references to a named symbol
  • GetCallGraph — direct callees of a named function, one level deep
  • ResolveType — resolved type of a named expression

Documentation

  • GetDocComment — doc comment for any named symbol
  • RunGoDoc — output of go doc pkg.Symbol

Diagnostics

  • RunGoVet — vet output scoped to a package
  • RunStaticcheck — staticcheck findings for a package

Navigation

  • FindDefinition — definition site of a named symbol
  • FindByPattern — regex search scoped to a package or file

Start Here

Implement ListDeclarations, GetFunctionSignature, GetStructFields,
and FindUsages first. These four cover the majority of what an agent
needs to orient itself in an unfamiliar codebase.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions