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

filesystem

package
v1.152.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ToolNameReadFile           = types.ToolNameReadFile
	ToolNameReadMultipleFiles  = types.ToolNameReadMultipleFiles
	ToolNameEditFile           = types.ToolNameEditFile
	ToolNameWriteFile          = types.ToolNameWriteFile
	ToolNameDirectoryTree      = types.ToolNameDirectoryTree
	ToolNameListDirectory      = types.ToolNameListDirectory
	ToolNameSearchFilesContent = types.ToolNameSearchFilesContent
	ToolNameMkdir              = types.ToolNameMkdir
	ToolNameRmdir              = types.ToolNameRmdir
)

Variables

This section is empty.

Functions

func CreateToolSet added in v1.60.0

func CreateToolSet(toolset latest.Toolset, runConfig *config.RuntimeConfig) (tools.ToolSet, error)

CreateToolSet is used by the tools registry.

func Creator added in v1.132.0

func Creator(_ context.Context, toolset latest.Toolset, _ string, runConfig *config.RuntimeConfig, _ string) (tools.ToolSet, error)

Creator builds this toolset from its YAML declaration. It matches teamloader.ToolsetCreator so it can be registered directly:

teamloader.NewToolsetRegistry(map[string]teamloader.ToolsetCreator{"filesystem": filesystem.Creator})

func ValidateReadFileRange added in v1.121.0

func ValidateReadFileRange(line, limit *int) error

ValidateReadFileRange rejects explicitly supplied non-positive range values; nil means "not provided" and is always valid. It is exported so alternative read_file implementations (e.g. the ACP override) apply the same contract before doing any I/O.

Types

type CreateDirectoryArgs

type CreateDirectoryArgs struct {
	Paths []string `json:"paths" jsonschema:"Directories to create"`
}

type DirectoryTreeArgs

type DirectoryTreeArgs = types.DirectoryTreeArgs

type DirectoryTreeMeta

type DirectoryTreeMeta = types.DirectoryTreeMeta

type Edit

type Edit = types.Edit

type EditFileArgs

type EditFileArgs = types.EditFileArgs

func ParseEditFileArgs

func ParseEditFileArgs(data []byte) (EditFileArgs, error)

ParseEditFileArgs parses edit_file arguments, including common LLM JSON malformations.

type ListDirectoryArgs

type ListDirectoryArgs = types.ListDirectoryArgs

type ListDirectoryMeta

type ListDirectoryMeta = types.ListDirectoryMeta

type Opt

type Opt func(*ToolSet)

func WithAgentsIgnore added in v1.112.0

func WithAgentsIgnore(m *fsx.AgentsIgnoreMatcher) Opt

func WithAllowList

func WithAllowList(roots []string) Opt

WithAllowList restricts every filesystem operation to paths that resolve under one of the supplied roots. Each entry may be:

  • "." — the agent's working directory
  • "~" or "~/..." — the user's home directory
  • "$VAR" / "${VAR}" — an environment variable
  • any absolute or relative path (relative paths are anchored at the working directory)

Symlinks are resolved before the containment check, so a symlink inside an allowed root cannot be used to escape it. An empty or nil slice disables the allow-list and preserves the default behaviour (any path is allowed).

Invalid entries (e.g. an empty string) are logged and the allow-list is silently dropped, mirroring how WithIgnoreVCS handles construction errors.

func WithDenyList

func WithDenyList(roots []string) Opt

WithDenyList forbids every filesystem operation on paths that resolve under one of the supplied roots. Tokens follow the same expansion rules as WithAllowList. The deny-list takes precedence over the allow-list: a path that matches both is rejected. An empty or nil slice disables the deny-list.

func WithIgnoreVCS

func WithIgnoreVCS(ignoreVCS bool) Opt

func WithPostEditCommands

func WithPostEditCommands(postEditCommands []PostEditConfig) Opt

type PostEditConfig

type PostEditConfig struct {
	Path string // File path pattern (glob-style)
	Cmd  string // Command to execute (with $path placeholder)
}

PostEditConfig represents a post-edit command configuration

type ReadFileArgs

type ReadFileArgs = types.ReadFileArgs

type ReadFileMeta

type ReadFileMeta = types.ReadFileMeta

type ReadMultipleFilesArgs

type ReadMultipleFilesArgs = types.ReadMultipleFilesArgs

type ReadMultipleFilesMeta

type ReadMultipleFilesMeta = types.ReadMultipleFilesMeta

type RemoveDirectoryArgs

type RemoveDirectoryArgs struct {
	Paths []string `json:"paths" jsonschema:"Directories to remove"`
}

type SearchFilesContentArgs

type SearchFilesContentArgs = types.SearchFilesContentArgs

type SearchFilesContentMeta

type SearchFilesContentMeta = types.SearchFilesContentMeta

type ToolSet added in v1.60.0

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

func New added in v1.60.0

func New(workingDir string, opts ...Opt) *ToolSet

func NewFromConfig added in v1.143.0

func NewFromConfig(toolset latest.Toolset, runConfig *config.RuntimeConfig) (*ToolSet, error)

NewFromConfig builds a filesystem toolset with its configured policies and hooks.

func (*ToolSet) Close added in v1.60.0

func (t *ToolSet) Close() error

Close releases any *os.Root file descriptors held by the allow/deny lists. It is safe to call Close multiple times.

func (*ToolSet) ExecutePostEditCommands added in v1.143.0

func (t *ToolSet) ExecutePostEditCommands(ctx context.Context, path string) error

ExecutePostEditCommands runs hooks after a transport writes a checked, canonical path.

func (*ToolSet) HasPostEditCommands added in v1.143.0

func (t *ToolSet) HasPostEditCommands() bool

HasPostEditCommands reports whether writes may be changed by configured commands.

func (*ToolSet) Instructions added in v1.60.0

func (t *ToolSet) Instructions() string

func (*ToolSet) ResolveAndCheckPath added in v1.143.0

func (t *ToolSet) ResolveAndCheckPath(path string) (string, error)

ResolveAndCheckPath applies filesystem policy without reading or writing file contents. Transport adapters must also enforce containment when they access the path.

func (*ToolSet) Tools added in v1.60.0

func (t *ToolSet) Tools(context.Context) ([]tools.Tool, error)

type WriteFileArgs

type WriteFileArgs = types.WriteFileArgs

Directories

Path Synopsis
Package types defines the shared wire contracts for the filesystem tools.
Package types defines the shared wire contracts for the filesystem tools.

Jump to

Keyboard shortcuts

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