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

tool

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolListRepos           = "list_repos"
	DescListRepos           = "list all repositories"
	ToolGetRepoStructure    = "get_repo_structure"
	DescGetRepoStructure    = "get the repository structure, including package list and file list"
	ToolGetPackageStructure = "get_package_structure"
	DescGetPackageStructure = "get the package (NameSpace) structure, including file list and node-id list"
	ToolGetFileStructure    = "get_file_structure"
	DescGetFileStructure    = "get the file structure, including node (id,signature,type) list"
	ToolGetASTNode          = "get_ast_node"
	DescGetASTNode          = "" /* 152-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"`
	NodeIDs  []NodeID `json:"node_ids" jsonschema:"description=the identities of the ast node"`
}

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"`
	FilePath string `json:"file_paths" jsonschema:"description=the file paths"`
}

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"`
	ModPath  uniast.ModPath `json:"mod_path" jsonschema:"description=the module path"`
	PkgPath  uniast.PkgPath `json:"package_path" jsonschema:"description=the package path"`
}

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"`
}

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
	Comand 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=the mod path of the node"`
	PkgPath uniast.PkgPath `json:"pkg_path" jsonschema:"description=the package path of the node"`
	Name    string         `json:"name" jsonschema:"description=the name of the node"`
}

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