Help us shape the future of Go! Take the 2026 Go Developer Survey

tool

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolListRepos           = "list_repos"
	DescListRepos           = "[DISCOVERY] level1/4: List all repositories. No parameters required. Always the first step in any analysis workflow."
	ToolGetRepoStructure    = "get_repo_structure"
	DescGetRepoStructure    = "" /* 129-byte string literal not displayed */
	ToolGetPackageStructure = "get_package_structure"
	DescGetPackageStructure = "" /* 156-byte string literal not displayed */
	ToolGetFileStructure    = "get_file_structure"
	DescGetFileStructure    = "" /* 147-byte string literal not displayed */
	ToolGetASTNode          = "get_ast_node"
	DescGetASTNode          = "" /* 154-byte string literal not displayed */

)
View Source
const (
	ToolWriteASTNode = "write_ast_node"
)

Variables

View Source
var (
	SchemaListRepos           = GetJSONSchema(ListReposReq{})
	SchemaGetRepoStructure    = GetJSONSchema(GetRepoStructReq{})
	SchemaGetPackageStructure = GetJSONSchema(GetPackageStructReq{})
	SchemaGetFileStructure    = GetJSONSchema(GetFileStructReq{})
	SchemaGetASTNode          = GetJSONSchema(GetASTNodeReq{})
)

Functions

func GetJSONSchema

func GetJSONSchema(sch any) json.RawMessage

Types

type ASTReadTools

type ASTReadTools struct {
	// contains filtered or unexported fields
}

func NewASTReadTools

func NewASTReadTools(opts ASTReadToolsOptions) *ASTReadTools

func (*ASTReadTools) GetASTNode

func (t *ASTReadTools) GetASTNode(_ context.Context, params GetASTNodeReq) (*GetASTNodeResp, error)

func (*ASTReadTools) GetFileStructure

func (t *ASTReadTools) GetFileStructure(_ context.Context, req GetFileStructReq) (*GetFileStructResp, error)

GetFileStruct get node list, each node only includes ID\Type\Signature

func (*ASTReadTools) GetPackageStructure

func (t *ASTReadTools) GetPackageStructure(ctx context.Context, req GetPackageStructReq) (*GetPackageStructResp, error)

GetPackageStruct get package structure

func (*ASTReadTools) GetRepoStructure

func (t *ASTReadTools) GetRepoStructure(_ context.Context, req GetRepoStructReq) (*GetRepoStructResp, error)

GetRepoStructure list the packages and file-paths

func (*ASTReadTools) GetTool

func (t *ASTReadTools) GetTool(name string) Tool

func (*ASTReadTools) GetTools

func (t *ASTReadTools) GetTools() []Tool

func (*ASTReadTools) ListRepos

func (t *ASTReadTools) ListRepos(ctx context.Context, req ListReposReq) (*ListReposResp, error)

type ASTReadToolsOptions

type ASTReadToolsOptions struct {
	// PatchOptions patch.Options
	RepoASTsDir string
}

type ASTWriteTools

type ASTWriteTools struct {
	// contains filtered or unexported fields
}

func NewASTWriteTools

func NewASTWriteTools(repo *uniast.Repository, opts ASTWriteToolsOptions) *ASTWriteTools

func (ASTWriteTools) GetTool

func (t ASTWriteTools) GetTool(name string) Tool

func (ASTWriteTools) GetTools

func (t ASTWriteTools) GetTools() []Tool

func (ASTWriteTools) WriteASTNode

type ASTWriteToolsOptions

type ASTWriteToolsOptions struct {
	PatchOptions patch.Options
}

type FileStruct

type FileStruct struct {
	FilePath string          `json:"file_path" jsonschema:"description=the path of the file"`
	Imports  []uniast.Import `json:"imports,omitempty" jsonschema:"description=the imports of the file"`
	Nodes    []NodeStruct    `json:"nodes,omitempty" jsonschema:"description=the node structs of the file"`
}

type FuncType

type FuncType string
const (
	FuncTypeBuiltin FuncType = "builtin"
	FuncTypeStdio   FuncType = "stdio"
)

type FunctionConfig

type FunctionConfig struct {
	Type    FuncType        `json:"type"`    // plugin type includes builtin, stdio
	URI     string          `json:"uri"`     // exec-path for stdio, func-URI for func
	Options json.RawMessage `json:"options"` // raw config for specific plugin
}

FunctionConfig is the config for function It can be either builtin function or stdio-plugin or MCP (TODO)

type GetASTNodeReq

type GetASTNodeReq struct {
	RepoName string   `json:"repo_name" jsonschema:"description=the name of the repository (output of list_repos tool)"`
	NodeIDs  []NodeID `` /* 132-byte string literal not displayed */
}

type GetASTNodeResp

type GetASTNodeResp struct {
	Nodes []NodeStruct `json:"nodes" jsonschema:"description=the ast nodes"`
	Error string       `json:"error,omitempty" jsonschema:"description=the error message"`
}

type GetFileStructReq

type GetFileStructReq struct {
	RepoName string `json:"repo_name" jsonschema:"description=the name of the repository (output of list_repos tool)"`
	FilePath string `json:"file_path" jsonschema:"description=relative file path (output of get_repo_structure tool, e.g., 'src/main.go')"`
}

type GetFileStructResp

type GetFileStructResp struct {
	FileStruct
	Error string `json:"error,omitempty" jsonschema:"description=the error message"`
}

type GetPackageStructReq

type GetPackageStructReq struct {
	RepoName string         `json:"repo_name" jsonschema:"description=the name of the repository (output of list_repos tool)"`
	ModPath  uniast.ModPath `json:"mod_path" jsonschema:"description=the module path (output of get_repo_structure tool)"`
	PkgPath  uniast.PkgPath `json:"package_path" jsonschema:"description=the package path (output of get_repo_structure tool)"`
}

type GetPackageStructResp

type GetPackageStructResp struct {
	Files []FileStruct `json:"files" jsonschema:"description=the file structures"`
	Error string       `json:"error,omitempty" jsonschema:"description=the error message"`
}

type GetRepoStructReq

type GetRepoStructReq struct {
	RepoName string `json:"repo_name" jsonschema:"description=the name of the repository (output of list_repos tool)"`
}

type GetRepoStructResp

type GetRepoStructResp struct {
	Modules []ModuleStruct `json:"modules" jsonschema:"description=the module structure of the repository"`
	Error   string         `json:"error,omitempty" jsonschema:"description=the error message"`
}

type ListReposReq

type ListReposReq struct{}

type ListReposResp

type ListReposResp struct {
	RepoNames []string `json:"repo_names" jsonschema:"description=the names of the repositories"`
}

type MCPClient

type MCPClient struct {
	// contains filtered or unexported fields
}

func NewMCPClient

func NewMCPClient(opts MCPConfig) (*MCPClient, error)

func (*MCPClient) GetTools

func (c *MCPClient) GetTools(ctx context.Context) ([]Tool, error)

func (*MCPClient) Start

func (c *MCPClient) Start(ctx context.Context) error

type MCPConfig

type MCPConfig struct {
	Type    MCPType
	Command string
	Args    []string
	Envs    []string
	SSEURL  string
}

type MCPType

type MCPType string
const (
	MCPTypeStdio MCPType = "stdio"
	MCPTypeSSE   MCPType = "sse"
)

type ModuleStruct

type ModuleStruct struct {
	uniast.ModPath `json:"mod_path" jsonschema:"description=the mod path of the module"`
	Packages       []PackageStruct `json:"packages,omitempty" jsonschema:"description=the package structures of the module"`
}

type NodeID

type NodeID struct {
	ModPath uniast.ModPath `json:"mod_path" jsonschema:"description=module path of the node (from get_repo_structure)"`
	PkgPath uniast.PkgPath `json:"pkg_path" jsonschema:"description=package path of the node (from get_repo_structure)"`
	Name    string         `json:"name" jsonschema:"description=name of the node (from get_package_structure or get_file_structure)"`
}

func NewNodeID

func NewNodeID(id uniast.Identity) NodeID

func (NodeID) Identity

func (n NodeID) Identity() uniast.Identity

type NodeStruct

type NodeStruct struct {
	ModPath      uniast.ModPath `json:"mod_path,omitempty" jsonschema:"description=the module path"`
	PkgPath      uniast.PkgPath `json:"pkg_path,omitempty" jsonschema:"description=the package path"`
	Name         string         `json:"name" jsonschema:"description=the name of the node"`
	Type         string         `json:"type,omitempty" jsonschema:"description=the type of the node"`
	Signature    string         `json:"signature,omitempty" jsonschema:"description=the func signature of the node"`
	File         string         `json:"file,omitempty" jsonschema:"description=the file path of the node"`
	Line         int            `json:"line,omitempty" jsonschema:"description=the line of the node"`
	Codes        string         `json:"codes,omitempty" jsonschema:"description=the codes of the node"`
	Dependencies []NodeID       `json:"dependencies,omitempty" jsonschema:"description=the dependencies of the node"`
	References   []NodeID       `json:"references,omitempty" jsonschema:"description=the references of the node"`
	Implements   []NodeID       `json:"implements,omitempty" jsonschema:"description=the implements of the node"`
	Groups       []NodeID       `json:"groups,omitempty" jsonschema:"description=the groups of the node"`
	Inherits     []NodeID       `json:"inherits,omitempty" jsonschema:"description=the inherits of the node"`
}

type PackageStruct

type PackageStruct struct {
	uniast.PkgPath `json:"pkg_path" jsonschema:"description=the path of the package"`
	Files          []FileStruct `json:"files,omitempty" jsonschema:"description=the file structures of the package"`
}

type Tool

type Tool interface {
	tool.BaseTool
}

Tool is the interface for LLM-calling tools.

func GetGitTools

func GetGitTools(ctx context.Context) ([]Tool, error)

func GetSequentialThinkingTools

func GetSequentialThinkingTools(ctx context.Context) ([]Tool, error)

type ToolConfig

type ToolConfig struct {
	Name string `json:"name"` // name of the tool
	FunctionConfig
}

ToolConfig is the config for LLM-calling tools.

type WriteASTNodeReq

type WriteASTNodeReq struct {
	ID        uniast.Identity   `json:"id" jsonschema:"description=the id of the ast node"`
	Codes     string            `json:"codes" jsonschema:"description=the codes of the ast node"`
	Type      string            `json:"type" jsonschema:"description=the type of the ast node, must be enum of 'FUNC'|'TYPE'|'VAR'"`
	File      string            `json:"file,omitempty" jsonschema:"description=the file path for newly-added ast node"`
	AddedDeps []uniast.Identity `json:"added_deps" jsonschema:"description=the added dependencies of the ast node"`
}

type WriteASTNodeResp

type WriteASTNodeResp struct {
	Success    bool              `json:"success" jsonschema:"description=whether the ast node is written successfully"`
	Message    string            `json:"message" jsonschema:"description=the feedback message"`
	References []uniast.Identity `json:"references,omitempty" jsonschema:"description=the references of the ast node"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL