filesystem

package
v0.0.0-...-4b2b8ef Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPathExists

func CheckPathExists(path string) (exists bool, isDir bool, err error)

CheckPathExists checks if a path exists and returns info about it

func EnsureParentDirs

func EnsureParentDirs(path string) error

EnsureParentDirs creates parent directories if they don't exist

func FormatFileSize

func FormatFileSize(size int64) string

FormatFileSize formats a file size in bytes to a human-readable string

func SanitizePath

func SanitizePath(path string) string

SanitizePath cleans and normalizes a file path

func ValidateAbsolutePath

func ValidateAbsolutePath(path string) error

ValidateAbsolutePath checks if the given path is absolute

func WalkDirectoryTree

func WalkDirectoryTree(rootPath string) (string, error)

WalkDirectoryTree walks a directory tree and returns a string representation

Types

type ConflictWarning

type ConflictWarning struct {
	Edit1Index   int    `json:"edit1_index"`
	Edit2Index   int    `json:"edit2_index"`
	ConflictType string `json:"conflict_type"`
	Message      string `json:"message"`
}

type CreateFileInput

type CreateFileInput struct {
	Path    string
	Content string
}

type CreateFileResult

type CreateFileResult struct {
	Overwritten bool `json:"overwritten"`
}

func CreateFile

func CreateFile(fsys afero.Fs, input *CreateFileInput) (*CreateFileResult, error)

type DiffPair

type DiffPair struct {
	Old string `json:"old"`
	New string `json:"new"`
}

type DiffValidationError

type DiffValidationError struct {
	DiffIndex    int    `json:"diff_index"`
	ErrorType    string `json:"error_type"`
	ErrorMessage string `json:"error_message"`
	SuggestedFix string `json:"suggested_fix,omitempty"`
}

func (*DiffValidationError) Error

func (e *DiffValidationError) Error() string

type DirectoryEntry

type DirectoryEntry struct {
	Name string `json:"n"`
	Type string `json:"t"`
	Size int64  `json:"s"`
}

type EditFileInput

type EditFileInput struct {
	Path  string     `json:"path"`
	Diffs []DiffPair `json:"diffs"`
}

type EditFileResult

type EditFileResult struct {
	Success              bool                  `json:"success"`
	Path                 string                `json:"path"`
	ReplacementsMade     int                   `json:"replacements_made"`
	ExpectedReplacements int                   `json:"expected_replacements"`
	FailureReason        string                `json:"failure_reason,omitempty"`
	ValidationErrors     []DiffValidationError `json:"validation_errors,omitempty"`
	ConflictWarnings     []ConflictWarning     `json:"conflict_warnings,omitempty"`
	PatchInfo            PatchInfo             `json:"patch_info,omitempty"`
}

func EditFile

func EditFile(fsys afero.Fs, input *EditFileInput) (*EditFileResult, error)

type FindFileInput

type FindFileInput struct {
	Pattern        string `json:"pattern"`
	Path           string `json:"path"`
	ExcludePattern string `json:"exclude_pattern"`
	MaxResults     int    `json:"max_results"`
}

type FindFileResult

type FindFileResult struct {
	Files          []string `json:"files"`
	TotalFiles     int      `json:"total_files"`
	TruncatedCount int      `json:"truncated_count"`
}

func FindFile

func FindFile(fsys afero.Fs, input *FindFileInput) (*FindFileResult, error)

type GrepInput

type GrepInput struct {
	Query          string `json:"query"`
	Path           string `json:"path"`
	IncludePattern string `json:"include_pattern"`
	ExcludePattern string `json:"exclude_pattern"`
	CaseSensitive  bool   `json:"case_sensitive"`
	MaxResults     int    `json:"max_results"`
	Context        int    `json:"context"`
}

type GrepMatch

type GrepMatch struct {
	FilePath string `json:"file_path"`
	Value    string `json:"value"`
}

type GrepResult

type GrepResult struct {
	Matches          []GrepMatch `json:"matches"`
	TotalMatches     int         `json:"total_matches"`
	TruncatedMatches int         `json:"truncated_matches"`
	SearchedFiles    int         `json:"searched_files"`
}

func Grep

func Grep(ctx context.Context, input *GrepInput, cmdRunner shared.CommandRunner) (*GrepResult, error)

type ListFilesInput

type ListFilesInput struct {
	Path      string
	Recursive bool
}

type ListFilesResult

type ListFilesResult struct {
	Path    string           `json:"path"`
	Entries []DirectoryEntry `json:"entries"`
}

func ListFiles

func ListFiles(fsys afero.Fs, input *ListFilesInput) (*ListFilesResult, error)

type PatchInfo

type PatchInfo struct {
	Patch        string `json:"patch"`
	LinesAdded   int    `json:"lines_added"`
	LinesRemoved int    `json:"lines_removed"`
}

type ReadFileInput

type ReadFileInput struct {
	Path      string `json:"path"`
	StartLine *int   `json:"start_line,omitempty"` // 1-based, inclusive
	EndLine   *int   `json:"end_line,omitempty"`   // 1-based, inclusive
}

func (*ReadFileInput) Validate

func (input *ReadFileInput) Validate() error

type ReadFileResult

type ReadFileResult struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

func ReadFile

func ReadFile(fsys afero.Fs, input *ReadFileInput) (*ReadFileResult, error)

Jump to

Keyboard shortcuts

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