fstool

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteFileTool added in v0.6.0

func DeleteFileTool() spec.Tool

func ListDirectoryTool

func ListDirectoryTool() spec.Tool

func MIMEForExtensionTool added in v0.4.0

func MIMEForExtensionTool() spec.Tool

func MIMEForPathTool added in v0.4.0

func MIMEForPathTool() spec.Tool

func ReadFile

func ReadFile(ctx context.Context, args ReadFileArgs) ([]spec.ToolStoreOutputUnion, error)

ReadFile reads a file from disk and returns its contents. If Encoding == "binary" the output is base64-encoded.

func ReadFileTool

func ReadFileTool() spec.Tool

func SearchFilesTool

func SearchFilesTool() spec.Tool

func StatPathTool

func StatPathTool() spec.Tool

func WriteFileTool added in v0.6.0

func WriteFileTool() spec.Tool

Types

type DeleteFileArgs added in v0.6.0

type DeleteFileArgs struct {
	Path     string `json:"path"`
	TrashDir string `json:"trashDir,omitempty"` // "auto" default
}

type DeleteFileMethod added in v0.6.0

type DeleteFileMethod string
const (
	DeleteFileMethodRename        DeleteFileMethod = "rename"
	DeleteFileMethodCopyAndRemove DeleteFileMethod = "copyAndRemove"
	DeleteFileMethodSymlinkRehome DeleteFileMethod = "symlinkRehome"
)

type DeleteFileOut added in v0.6.0

type DeleteFileOut struct {
	OriginalPath string           `json:"originalPath"`
	TrashedPath  string           `json:"trashedPath"`
	Method       DeleteFileMethod `json:"method"`
}

func DeleteFile added in v0.6.0

func DeleteFile(ctx context.Context, args DeleteFileArgs) (*DeleteFileOut, error)

type ListDirectoryArgs

type ListDirectoryArgs struct {
	Path    string `json:"path,omitempty"`    // default "."
	Pattern string `json:"pattern,omitempty"` // Optional glob
}

type ListDirectoryOut

type ListDirectoryOut struct {
	Entries []string `json:"entries"`
}

func ListDirectory

func ListDirectory(ctx context.Context, args ListDirectoryArgs) (*ListDirectoryOut, error)

ListDirectory lists files / dirs in Path. If Pattern is supplied, the results are filtered via filepath.Match.

type MIMEDetectMethod added in v0.4.0

type MIMEDetectMethod string
const (
	MIMEDetectMethodExtension MIMEDetectMethod = "extension"
	MIMEDetectMethodSniff     MIMEDetectMethod = "sniff"
)

type MIMEForExtensionArgs added in v0.4.0

type MIMEForExtensionArgs struct {
	Extension string `json:"extension"`
}

type MIMEForExtensionOut added in v0.4.0

type MIMEForExtensionOut struct {
	Extension           string   `json:"extension"`
	NormalizedExtension string   `json:"normalizedExtension"`
	MIMEType            string   `json:"mimeType"`
	BaseMIMEType        string   `json:"baseMimeType"`
	Mode                MIMEMode `json:"mode"`
	Known               bool     `json:"known"`
}

func MIMEForExtension added in v0.4.0

func MIMEForExtension(ctx context.Context, args MIMEForExtensionArgs) (*MIMEForExtensionOut, error)

MIMEForExtension returns the best-known MIME type for an extension.

If the extension is unknown, this tool returns: - mimeType: "application/octet-stream" - known: false and does NOT error (so calling code can continue).

type MIMEForPathArgs added in v0.4.0

type MIMEForPathArgs struct {
	Path string `json:"path"`
}

type MIMEForPathOut added in v0.4.0

type MIMEForPathOut struct {
	Path                string           `json:"path"`
	Extension           string           `json:"extension,omitempty"`
	NormalizedExtension string           `json:"normalizedExtension,omitempty"`
	MIMEType            string           `json:"mimeType"`
	BaseMIMEType        string           `json:"baseMimeType"`
	Mode                MIMEMode         `json:"mode"`
	Method              MIMEDetectMethod `json:"method"`
}

func MIMEForPath added in v0.4.0

func MIMEForPath(ctx context.Context, args MIMEForPathArgs) (*MIMEForPathOut, error)

MIMEForPath returns a best-effort MIME type for a filesystem path.

Notes: - If the extension maps to a non-generic MIME type, it may succeed even if the file does not exist. - If the extension is unknown/generic, it tries to open and sniff the file (can error if unreadable).

type MIMEMode added in v0.4.0

type MIMEMode string
const (
	MIMEModeText     MIMEMode = "text"
	MIMEModeImage    MIMEMode = "image"
	MIMEModeDocument MIMEMode = "document"
	MIMEModeDefault  MIMEMode = "default"
)

type ReadFileArgs

type ReadFileArgs struct {
	Path     string `json:"path"`               // required
	Encoding string `json:"encoding,omitempty"` // "text" (default) | "binary"
}

type SearchFilesArgs

type SearchFilesArgs struct {
	Root       string `json:"root,omitempty"` // default "."
	Pattern    string `json:"pattern"`        // required (RE2)
	MaxResults int    `json:"maxResults,omitempty"`
}

type SearchFilesOut

type SearchFilesOut struct {
	MatchCount        int      `json:"matchCount"`
	ReachedMaxResults bool     `json:"reachedMaxResults"`
	Matches           []string `json:"matches"`
}

func SearchFiles

func SearchFiles(ctx context.Context, args SearchFilesArgs) (*SearchFilesOut, error)

SearchFiles walks Root (recursively) and returns up to MaxResults files whose *path* or *UTF-8 text content* match the supplied regexp.

type StatPathArgs

type StatPathArgs struct {
	Path string `json:"path"`
}

type StatPathOut

type StatPathOut struct {
	Path      string     `json:"path"`
	Name      string     `json:"name"`
	Exists    bool       `json:"exists"`
	IsDir     bool       `json:"isDir"`
	SizeBytes int64      `json:"sizeBytes,omitempty"`
	ModTime   *time.Time `json:"modTime,omitempty"`
}

func StatPath

func StatPath(ctx context.Context, args StatPathArgs) (*StatPathOut, error)

StatPath returns basic metadata for the supplied path without mutating the file system.

type WriteFileArgs added in v0.6.0

type WriteFileArgs struct {
	Path          string `json:"path"`
	Encoding      string `json:"encoding,omitempty"` // "text"(default) | "binary"
	Content       string `json:"content"`
	Overwrite     bool   `json:"overwrite,omitempty"`
	CreateParents bool   `json:"createParents,omitempty"`
}

type WriteFileOut added in v0.6.0

type WriteFileOut struct {
	Path         string `json:"path"`
	BytesWritten int64  `json:"bytesWritten"`
}

func WriteFile added in v0.6.0

func WriteFile(ctx context.Context, args WriteFileArgs) (*WriteFileOut, error)

Jump to

Keyboard shortcuts

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