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

file

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolReadFile   = "read_file"
	ToolListDir    = "list_dir"
	ToolSearchText = "search_text"
	ToolFileEdit   = "file_edit"
)
View Source
const (
	MaxTextOutputBytes = 4 << 20
)

Variables

This section is empty.

Functions

func AddRuntimeOutputProperties

func AddRuntimeOutputProperties(_ map[string]any)

func AddRuntimeProperties

func AddRuntimeProperties(_ map[string]any)

func EditDescription

func EditDescription(base string) string

func InputSchema added in v0.8.2

func InputSchema(name string) (map[string]any, bool)

func OutputSchema added in v0.8.2

func OutputSchema(name string) (map[string]any, bool)

func PatchDescription

func PatchDescription(base string) string

func PathDescription

func PathDescription(hostDescription string) string

func ToolDescription

func ToolDescription(base string) string

Types

type CommandEnv

type CommandEnv func(skillName string, extra map[string]string) ([]string, error)

type EditRequest added in v0.8.2

type EditRequest struct {
	RuntimeOptions
	Action          string `json:"action"`
	Path            string `json:"path,omitempty"`
	Old             string `json:"old,omitempty"`
	New             string `json:"new,omitempty"`
	ReplaceAll      bool   `json:"replace_all,omitempty"`
	ExpectedMatches *int   `json:"expected_matches,omitempty"`
	Content         string `json:"content,omitempty"`
	NewPath         string `json:"new_path,omitempty"`
	Overwrite       bool   `json:"overwrite,omitempty"`
	Recursive       bool   `json:"recursive,omitempty"`
	Patch           string `json:"patch,omitempty"`
	Workdir         string `json:"workdir,omitempty"`
	DryRun          bool   `json:"dry_run,omitempty"`
	MaxDiffBytes    *int   `json:"max_diff_bytes,omitempty"`
}

EditRequest 统一承载 file_edit 五种 action 的输入,避免为每个 action 再制造一层类型。 action 对字段组合的业务约束仍由文件服务在对应主流程中校验。

type ListRequest added in v0.8.2

type ListRequest struct {
	RuntimeOptions
	Path            string   `json:"path,omitempty"`
	MaxDepth        *int     `json:"max_depth,omitempty"`
	MaxEntries      *int     `json:"max_entries,omitempty"`
	Patterns        []string `json:"patterns,omitempty"`
	ExcludePatterns []string `json:"exclude_patterns,omitempty"`
	EntryType       string   `json:"entry_type,omitempty"`
	IncludeHidden   bool     `json:"include_hidden,omitempty"`
	IncludeIgnored  bool     `json:"include_ignored,omitempty"`
}

ListRequest 是 list_dir 进入文件核心后的稳定输入契约。

type ReadRequest added in v0.8.2

type ReadRequest struct {
	RuntimeOptions
	Path      string `json:"path"`
	StartLine *int   `json:"start_line,omitempty"`
	EndLine   *int   `json:"end_line,omitempty"`
	MaxBytes  *int   `json:"max_bytes,omitempty"`
}

ReadRequest 是 read_file 进入文件核心后的稳定输入契约。

type Result

type Result = toolcore.Result

type RuntimeOptions added in v0.8.2

type RuntimeOptions struct {
	Runtime         string `json:"runtime,omitempty"`
	WSLDistribution string `json:"wsl_distribution,omitempty"`
}

RuntimeOptions 描述文件工具的实际文件系统运行环境。非 Windows 主机只接受零值。

type SearchOptions

type SearchOptions struct {
	Query          string
	CaseSensitive  bool
	Regex          bool
	IncludeIgnored bool
	IncludeHidden  bool
	IncludeGlobs   []string
	ExcludeGlobs   []string
	MaxResults     int
	ContextLines   int
}

type SearchRequest added in v0.8.2

type SearchRequest struct {
	RuntimeOptions
	Path           string   `json:"path,omitempty"`
	Query          string   `json:"query"`
	Regex          bool     `json:"regex,omitempty"`
	CaseSensitive  bool     `json:"case_sensitive,omitempty"`
	IncludeHidden  bool     `json:"include_hidden,omitempty"`
	IncludeIgnored bool     `json:"include_ignored,omitempty"`
	IncludeGlobs   []string `json:"include_globs,omitempty"`
	Glob           string   `json:"glob,omitempty"`
	ExcludeGlobs   []string `json:"exclude_globs,omitempty"`
	ContextLines   *int     `json:"context_lines,omitempty"`
	MaxResults     *int     `json:"max_results,omitempty"`
}

SearchRequest 是 search_text 进入文件核心后的稳定输入契约。

type Service

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

func New

func New(ws *workspace.Workspace, resolveSkillResource SkillResourceResolver, commandEnv CommandEnv) *Service

func (*Service) Edit

func (svc *Service) Edit(ctx context.Context, request EditRequest) (Result, error)

func (*Service) ListDir

func (svc *Service) ListDir(ctx context.Context, request ListRequest) (Result, error)

func (*Service) ReadFile

func (svc *Service) ReadFile(ctx context.Context, request ReadRequest) (Result, error)

func (*Service) SearchText

func (svc *Service) SearchText(ctx context.Context, request SearchRequest) (Result, error)

type SkillResourceResolver

type SkillResourceResolver func(ctx context.Context, raw string) (absolutePath, displayPath string, release func(), err error)

type ToolError

type ToolError = toolcore.ToolError

Jump to

Keyboard shortcuts

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