filesystem

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxReadSize  int64    // maximum file size to read
	AllowedPaths []string // allowed base paths (empty = all)
	BlockedPaths []string // paths that are always denied
}

Config holds filesystem tool configuration

type FileInfo

type FileInfo struct {
	Path    string `json:"path"`
	Name    string `json:"name"`
	Size    int64  `json:"size"`
	IsDir   bool   `json:"isDir"`
	ModTime int64  `json:"modTime"`
	Mode    string `json:"mode"`
}

FileInfo represents file metadata

type ReadResult added in v0.6.0

type ReadResult struct {
	Content    string `json:"content"`
	TotalLines int    `json:"totalLines"`
	Size       int64  `json:"size"`
	Offset     int    `json:"offset,omitempty"`
	Limit      int    `json:"limit,omitempty"`
}

ReadResult holds file content with metadata.

type StatResult added in v0.6.0

type StatResult struct {
	Path       string `json:"path"`
	Size       int64  `json:"size"`
	Lines      int    `json:"lines"`
	ModTime    int64  `json:"modTime"`
	IsDir      bool   `json:"isDir"`
	Permission string `json:"permission"`
}

StatResult holds file metadata without reading content.

type Tool

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

Tool provides filesystem operations

func New

func New(cfg Config) *Tool

New creates a new filesystem tool

func (*Tool) Copy

func (t *Tool) Copy(src, dst string) error

Copy copies a file

func (*Tool) Delete

func (t *Tool) Delete(path string) error

Delete removes a file or directory

func (*Tool) Edit

func (t *Tool) Edit(path string, startLine, endLine int, newContent string) error

Edit replaces content in a file between specified lines

func (*Tool) Exists

func (t *Tool) Exists(path string) (bool, error)

Exists checks if a path exists

func (*Tool) ListDir

func (t *Tool) ListDir(path string) ([]FileInfo, error)

ListDir lists contents of a directory

func (*Tool) Mkdir

func (t *Tool) Mkdir(path string) error

Mkdir creates a directory

func (*Tool) Read

func (t *Tool) Read(path string) (string, error)

Read reads a file and returns its contents

func (*Tool) ReadLines

func (t *Tool) ReadLines(path string, startLine, endLine int) (string, error)

ReadLines reads specific lines from a file

func (*Tool) ReadWithMeta added in v0.6.0

func (t *Tool) ReadWithMeta(path string, offset, limit int) (*ReadResult, error)

ReadWithMeta reads a file with offset/limit support and returns content + metadata. offset is 1-indexed line number (0 or 1 = start from beginning). limit is max lines to return (0 = all lines).

func (*Tool) Stat added in v0.6.0

func (t *Tool) Stat(path string) (*StatResult, error)

Stat returns file metadata without reading the full content. Line count is computed by scanning newlines (efficient, doesn't load full file into memory).

func (*Tool) Write

func (t *Tool) Write(path, content string) error

Write writes content to a file (atomic write)

Jump to

Keyboard shortcuts

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