builtin

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompileTool

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

CompileTool 在工作目录运行 `go build ./...`。 关键语义:编译失败**不是工具错误**——Success 始终为 true(只要命令跑起来了), 把 compiled(bool) 与 output(编译器报错) 放进结果,供 planner 看到报错后去修复。 这正是 control loop 的反馈来源。

func NewCompileTool

func NewCompileTool(baseDir string) *CompileTool

func (CompileTool) Description

func (CompileTool) Description() string

func (CompileTool) Execute

func (t CompileTool) Execute(ctx context.Context, _ map[string]any, _ tool.ToolEmitter) (*tool.Result, error)

func (CompileTool) InputSchema

func (CompileTool) InputSchema() tool.DataSchema

func (CompileTool) Mode

func (CompileTool) Name

func (CompileTool) Name() string

func (CompileTool) OutputSchema

func (CompileTool) OutputSchema() tool.DataSchema

type GrepTool

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

GrepTool 在工作目录用 `grep -rn` 按内容搜索文件(代码 agent 必备)

func NewGrepTool

func NewGrepTool(baseDir string) *GrepTool

func (GrepTool) Description

func (GrepTool) Description() string

func (GrepTool) Execute

func (t GrepTool) Execute(ctx context.Context, input map[string]any, _ tool.ToolEmitter) (*tool.Result, error)

func (GrepTool) InputSchema

func (GrepTool) InputSchema() tool.DataSchema

func (GrepTool) Mode

func (GrepTool) Mode() tool.ExecutionMode

func (GrepTool) Name

func (GrepTool) Name() string

func (GrepTool) OutputSchema

func (GrepTool) OutputSchema() tool.DataSchema

type MergeResultTool

type MergeResultTool struct {
}

func NewMergeResultTool

func NewMergeResultTool() *MergeResultTool

func (MergeResultTool) Description

func (m MergeResultTool) Description() string

func (MergeResultTool) Execute

func (m MergeResultTool) Execute(ctx context.Context, input map[string]any, emitter tool.ToolEmitter) (*tool.Result, error)

func (MergeResultTool) InputSchema

func (m MergeResultTool) InputSchema() tool.DataSchema

func (MergeResultTool) Mode

func (MergeResultTool) Name

func (m MergeResultTool) Name() string

func (MergeResultTool) OutputSchema

func (m MergeResultTool) OutputSchema() tool.DataSchema

type ReadFileTool

type ReadFileTool struct {
	MaxBytes int64
	// contains filtered or unexported fields
}

ReadFileTool 读取工作目录下的 UTF-8 文本文件。每行带行号前缀,支持 offset/limit 窗口读取。 大型文件拒绝全读并提示用 offset/limit —— 专为 LLM 设计。

这是对标 MCP read_text_file 的本地工具,保留了原作者的全部核心设计:行号右对齐、 大文件预算拒绝、窗口截断提示、路径穿越防御、UTF-8 校验。

func NewReadFileTool

func NewReadFileTool(baseDir string) *ReadFileTool

func (ReadFileTool) Description

func (ReadFileTool) Description() string

func (ReadFileTool) Execute

func (r ReadFileTool) Execute(_ context.Context, input map[string]any, _ tool.ToolEmitter) (*tool.Result, error)

func (ReadFileTool) InputSchema

func (ReadFileTool) InputSchema() tool.DataSchema

func (ReadFileTool) Mode

func (ReadFileTool) Name

func (ReadFileTool) Name() string

func (ReadFileTool) OutputSchema

func (ReadFileTool) OutputSchema() tool.DataSchema

type ShellTool

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

ShellTool 在工作目录运行一条 shell 命令(sh -c),让代码 agent 能跑测试/构建/运行程序。

与 compile 工具同样的反馈语义:命令非零退出/超时**不是工具错误**——Success 仍为 true, 把 stdout/stderr/exit_code/timed_out 放进结果供 planner 据此决定下一步。

超时与进程树击杀(被真实任务赚来的修复):命令跑在**独立进程组**里;超时(或 ctx 取消)时 击杀**整个进程组**——否则像 `sh -c "go test"` 这种,超时只杀 sh、杀不掉 go test 孙子进程, 孙子继承 stdout 管道会让读取无限阻塞,把整个 agent 拖死。

安全边界(本版):命令受限在 baseDir + 超时。生产级沙箱(白名单/容器/资源限额)尚未做。

func NewShellTool

func NewShellTool(baseDir string) *ShellTool

func (ShellTool) Description

func (ShellTool) Description() string

func (ShellTool) Execute

func (t ShellTool) Execute(ctx context.Context, input map[string]any, _ tool.ToolEmitter) (*tool.Result, error)

func (ShellTool) InputSchema

func (ShellTool) InputSchema() tool.DataSchema

func (ShellTool) Mode

func (ShellTool) Mode() tool.ExecutionMode

func (ShellTool) Name

func (ShellTool) Name() string

func (ShellTool) OutputSchema

func (ShellTool) OutputSchema() tool.DataSchema

type WriteFileTool

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

WriteFileTool 把内容写入工作目录下的文件。M1 用于让 planner 生成/修改代码。

func NewWriteFileTool

func NewWriteFileTool(baseDir string) *WriteFileTool

func (WriteFileTool) Description

func (WriteFileTool) Description() string

func (WriteFileTool) Execute

func (t WriteFileTool) Execute(_ context.Context, input map[string]any, _ tool.ToolEmitter) (*tool.Result, error)

func (WriteFileTool) InputSchema

func (WriteFileTool) InputSchema() tool.DataSchema

func (WriteFileTool) Mode

func (WriteFileTool) Name

func (WriteFileTool) Name() string

func (WriteFileTool) OutputSchema

func (WriteFileTool) OutputSchema() tool.DataSchema

Jump to

Keyboard shortcuts

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