filetools

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Name string `json:"name"`
	Path string `json:"path"`
	Type string `json:"type"`
}

Entry describes one filesystem item returned by ListDirectory.

type FileChangeResult

type FileChangeResult struct {
	Path      string `json:"path"`
	Operation string `json:"operation"`
	Diff      string `json:"diff"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	Changed   bool   `json:"changed"`
}

FileChangeResult is the structured output of EditFile and WriteFile.

type GlobFilesResult

type GlobFilesResult struct {
	BasePath  string   `json:"base_path"`
	Pattern   string   `json:"pattern"`
	Matches   []string `json:"matches"`
	Count     int      `json:"count"`
	Truncated bool     `json:"truncated"`
}

GlobFilesResult is the structured output of GlobFiles.

type GrepFilesResult

type GrepFilesResult struct {
	BasePath  string      `json:"base_path"`
	Pattern   string      `json:"pattern"`
	Include   string      `json:"include,omitempty"`
	Matches   []GrepMatch `json:"matches"`
	Count     int         `json:"count"`
	Truncated bool        `json:"truncated"`
}

GrepFilesResult is the structured output of GrepFiles.

type GrepMatch

type GrepMatch struct {
	Path string `json:"path"`
	Line int    `json:"line"`
	Text string `json:"text"`
}

GrepMatch describes one grep match.

type ListDirectoryResult

type ListDirectoryResult struct {
	Path      string  `json:"path"`
	Entries   []Entry `json:"entries"`
	Count     int     `json:"count"`
	Truncated bool    `json:"truncated"`
}

ListDirectoryResult is the structured output of ListDirectory.

type ReadFileResult

type ReadFileResult struct {
	Path       string `json:"path"`
	Content    string `json:"content"`
	StartLine  int    `json:"start_line"`
	EndLine    int    `json:"end_line"`
	TotalLines int    `json:"total_lines"`
	Truncated  bool   `json:"truncated"`
}

ReadFileResult is the structured output of ReadFile.

type Service

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

Service exposes workspace-scoped file exploration and editing helpers.

func New

func New(root string) (*Service, error)

New creates a workspace-scoped file service rooted at the supplied directory.

func (*Service) EditFile

func (s *Service) EditFile(path string, oldString string, newString string, replaceAll bool) (*FileChangeResult, error)

EditFile replaces oldString with newString in a workspace file and returns a unified diff.

func (*Service) GlobFiles

func (s *Service) GlobFiles(pattern string, basePath string) (*GlobFilesResult, error)

GlobFiles finds files that match the supplied pattern under the workspace root.

func (*Service) GrepFiles

func (s *Service) GrepFiles(pattern string, basePath string, include string) (*GrepFilesResult, error)

GrepFiles searches text files for matches under the workspace root.

func (*Service) ListDirectory

func (s *Service) ListDirectory(path string) (*ListDirectoryResult, error)

ListDirectory returns directory entries under the workspace root.

func (*Service) ReadFile

func (s *Service) ReadFile(path string, offset int, limit int) (*ReadFileResult, error)

ReadFile reads a text file from the workspace root using 1-indexed line windows.

func (*Service) Root

func (s *Service) Root() string

Root returns the normalized workspace root directory.

func (*Service) WriteFile

func (s *Service) WriteFile(path string, content string) (*FileChangeResult, error)

WriteFile creates or replaces a workspace file and returns a unified diff.

Jump to

Keyboard shortcuts

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