Documentation
¶
Index ¶
- Constants
- func DataURL(mime string, raw []byte) string
- func DetectMimeType(path string) string
- func FormatContentWithLineNumbers(content string, startLine int) string
- func FormatLinesWithLineNumbers(lines []string, startLine int) string
- func IsImageFile(mimeType string) bool
- func IsTextFile(mimeType string) bool
- func PathToResourceURI(path string) string
- func ReadLines(reader io.Reader, number bool, offset int, limit int) (string, error)
- func Search(path string, o *SearchOptions) (string, error)
- type EditOptions
- type FileInfo
- type FileNode
- type FileStat
- type FileStore
- type FileSystem
- type LocalFS
- func (s *LocalFS) CopyFile(source string, destination string) error
- func (s *LocalFS) CreateDirectory(path string) error
- func (s *LocalFS) DeleteFile(path string, recursive bool) error
- func (s *LocalFS) EditFile(path string, o *EditOptions) (int, error)
- func (s *LocalFS) GetFileInfo(path string) (*FileInfo, error)
- func (s *LocalFS) ListDirectory(path string) ([]string, error)
- func (s *LocalFS) ListRoots() ([]string, error)
- func (s *LocalFS) Locator(path string) (string, error)
- func (s *LocalFS) Lstat(path string) (fs.FileInfo, error)
- func (s *LocalFS) MoveFile(source, destination string) error
- func (s *LocalFS) OpenFile(path string, flag int, perm fs.FileMode) (*os.File, error)
- func (s *LocalFS) ReadDir(path string) ([]fs.DirEntry, error)
- func (s *LocalFS) ReadFile(path string, o *ReadOptions) ([]byte, error)
- func (s *LocalFS) ReadMultipleFiles(pathsSlice []string) ([]string, error)
- func (s *LocalFS) SearchFiles(path string, options *SearchOptions) (string, error)
- func (s *LocalFS) Stat(path string) (fs.FileInfo, error)
- func (s *LocalFS) Tree(path string, depth int, follow bool) (string, error)
- func (s *LocalFS) WriteFile(path string, content []byte) error
- type ReadOptions
- type SearchOptions
- type Workspace
Constants ¶
const ( // Maximum size for inline content (5MB) MAX_INLINE_SIZE = 5 * 1024 * 1024 // Maximum size for base64 encoding (1MB) MAX_BASE64_SIZE = 1 * 1024 * 1024 // Maximum number of search results to return (prevent excessive output) MAX_SEARCH_RESULTS = 1000 // Maximum file size in bytes to search within (10MB) MAX_SEARCHABLE_SIZE = 10 * 1024 * 1024 )
Variables ¶
This section is empty.
Functions ¶
func DataURL ¶ added in v0.1.3
https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data data:[<media-type>][;base64],<data>
func DetectMimeType ¶ added in v0.0.9
DetectMimeType tries to determine the MIME type of a file
func FormatContentWithLineNumbers ¶ added in v0.0.9
FormatContentWithLineNumbers formats content with line numbers (cat -n style).
func FormatLinesWithLineNumbers ¶ added in v0.0.9
func IsImageFile ¶ added in v0.0.9
IsImageFile determines if a file is an image based on MIME type
func IsTextFile ¶ added in v0.0.9
IsTextFile determines if a file is likely a text file based on MIME type
func PathToResourceURI ¶ added in v0.1.4
PathToResourceURI converts a file path to a resource URI
Types ¶
type EditOptions ¶ added in v0.0.8
type FileInfo ¶
type FileInfo struct {
Filename string `json:"filename"`
IsDirectory bool `json:"isDirectory"`
IsFile bool `json:"isFile"`
IsLink bool `json:"isLink"`
Permissions string `json:"permissions"`
Length int64 `json:"size"`
Created time.Time `json:"created"`
Modified time.Time `json:"modified"`
Accessed time.Time `json:"accessed"`
Mime string `json:"mime"`
// original info for local fs
Info fs.FileInfo `json:"-"`
}
type FileNode ¶ added in v0.0.8
type FileNode struct {
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"` // "file" or "directory"
Size int64 `json:"size,omitempty"`
Modified time.Time `json:"modified,omitempty"`
Children []*FileNode `json:"children,omitempty"`
}
FileNode represents a node in the file tree
type FileSystem ¶
type FileSystem interface {
FileStore
ListRoots() ([]string, error)
ListDirectory(string) ([]string, error)
CreateDirectory(string) error
MoveFile(string, string) error
GetFileInfo(string) (*FileInfo, error)
DeleteFile(string, bool) error
CopyFile(string, string) error
EditFile(string, *EditOptions) (int, error)
Tree(string, int, bool) (string, error)
SearchFiles(string, *SearchOptions) (string, error)
}
FileSystem is a virtual file system that provides a set of operations to interact with the file system in a controlled manner.
type LocalFS ¶
type LocalFS struct {
// contains filtered or unexported fields
}
Local fs is a workspace
func (*LocalFS) CopyFile ¶ added in v0.0.8
Copy files and directories Parameters: source (required): Source path of the file or directory, destination (required): Destination path
func (*LocalFS) CreateDirectory ¶
func (*LocalFS) DeleteFile ¶ added in v0.0.8
Delete a file or directory from the file system Parameters: path (required): Path to the file or directory to delete, recursive (optional): Whether to recursively delete directories (default: false)
func (*LocalFS) EditFile ¶ added in v0.0.8
func (s *LocalFS) EditFile( path string, o *EditOptions, ) (int, error)
Update file by finding and replacing text using string matching or regex Parameters: path (required): Path to the file to modify, find (required): Text to search for, replace (required): Text to replace with, all_occurrences (optional): Replace all occurrences (default: true), regex (optional): Treat find pattern as regex (default: false) Return replacement count.
func (*LocalFS) GetFileInfo ¶ added in v0.1.3
func (*LocalFS) ReadFile ¶
func (s *LocalFS) ReadFile(path string, o *ReadOptions) ([]byte, error)
ReadFile read raw bytes or content with line numbers if option is provided. path: Absolute or relative file path offset: Line offset to start reading from (0-indexed) limit: Maximum number of lines to read Returns: Formatted file content with line numbers.
func (*LocalFS) ReadMultipleFiles ¶ added in v0.1.3
func (*LocalFS) SearchFiles ¶
func (s *LocalFS) SearchFiles(path string, options *SearchOptions) (string, error)
Recursively search for files and directories matching a pattern Parameters: path (required): Starting path for the search, pattern (required): Search pattern to match against file names
func (*LocalFS) Tree ¶ added in v0.0.8
Returns a hierarchical JSON representation of a directory structure Parameters: path (required): Path of the directory to traverse, depth (optional): Maximum depth to traverse (default: 3), follow_symlinks (optional): Whether to follow symbolic links (default: false)
type ReadOptions ¶ added in v0.0.9
type SearchOptions ¶
type SearchOptions struct {
Pattern string
// Parse PATTERN as a regular expression
// Accepted syntax is the same
// as https://github.com/google/re2/wiki/Syntax
Regexp bool
// Match case insensitively
IgnoreCase bool
// Only match whole words
WordRegexp bool
// Ignore files/directories matching pattern
Exclude []string
// Limit search to filenames matching PATTERN
FileSearchRegexp string
// Search up to 'Depth' directories deep (default: 25)
Depth int
// Follow symlinks
Follow bool
// Search hidden files and directories
Hidden bool
}