textfs

package
v0.0.0-...-6c5c7c9 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatTypeFile = "file"
	StatTypeDir  = "dir"
)
View Source
const (
	DefaultMaxLines   = 2000
	DefaultMaxBytes   = 50 * 1024
	GrepMaxLineLength = 500
)

Variables

This section is empty.

Functions

func AllowedNoteExtensions

func AllowedNoteExtensions() []string

AllowedNoteExtensions returns the hardcoded list of indexable "note" file extensions. Extensions are lowercase and include a leading dot.

func ClassifySource

func ClassifySource(path string) string

ClassifySource returns the default source label for a path.

func FormatSize

func FormatSize(bytes int) string

func IsAllowedTextNotePath

func IsAllowedTextNotePath(relPath string) (ok bool, ext string, reason string)

IsAllowedTextNotePath checks whether a virtual path is allowed for note indexing/reading. It requires an explicit file extension in the allowlist.

func IsMemoryPath

func IsMemoryPath(relPath string) bool

IsMemoryPath returns true for MEMORY.md or memory/*.md.

func IsVirtualDir

func IsVirtualDir(relDir string) bool

IsVirtualDir returns true for virtual directories that should exist even when empty.

func NormalizeDir

func NormalizeDir(raw string) (string, error)

NormalizeDir normalizes a directory path; empty means root.

func NormalizePath

func NormalizePath(raw string) (string, error)

NormalizePath normalizes a virtual file path and prevents escaping the root.

func NoteMaxBytesDefault

func NoteMaxBytesDefault() int

NoteMaxBytesDefault is the default per-file size cap for note indexing and reads.

func VirtualRootEntries

func VirtualRootEntries() []string

VirtualRootEntries returns the virtual root directories.

Types

type ApplyPatchResult

type ApplyPatchResult struct {
	Summary ApplyPatchSummary
	Text    string
}

func ApplyPatch

func ApplyPatch(ctx context.Context, store *Store, input string) (*ApplyPatchResult, error)

type ApplyPatchSummary

type ApplyPatchSummary struct {
	Added    []string
	Modified []string
	Deleted  []string
}

type FileEntry

type FileEntry struct {
	Path      string
	Content   string
	Hash      string
	Source    string
	UpdatedAt int64
}

type StatEntry

type StatEntry struct {
	Path      string
	Type      string
	Size      int
	Hash      string
	Source    string
	UpdatedAt int64
	Entries   int
}

type Store

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

func NewStore

func NewStore(db *dbutil.Database, bridgeID, loginID, agentID string) *Store

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, relPath string) error

func (*Store) DirEntries

func (s *Store) DirEntries(entries []FileEntry, dir string) ([]string, bool)

func (*Store) List

func (s *Store) List(ctx context.Context) ([]FileEntry, error)

func (*Store) ListWithPrefix

func (s *Store) ListWithPrefix(ctx context.Context, dir string) ([]FileEntry, error)

func (*Store) Read

func (s *Store) Read(ctx context.Context, relPath string) (*FileEntry, bool, error)

func (*Store) Stat

func (s *Store) Stat(ctx context.Context, relPath string) (*StatEntry, error)

func (*Store) Write

func (s *Store) Write(ctx context.Context, relPath, content string) (*FileEntry, error)

func (*Store) WriteIfMissing

func (s *Store) WriteIfMissing(ctx context.Context, relPath, content string) (bool, error)

WriteIfMissing writes a file only if it does not already exist. Returns true if a new entry was created.

type Truncation

type Truncation struct {
	Content               string
	Truncated             bool
	TruncatedBy           string
	TotalLines            int
	TotalBytes            int
	OutputLines           int
	OutputBytes           int
	FirstLineExceedsLimit bool
	MaxLines              int
	MaxBytes              int
}

func TruncateHead

func TruncateHead(content string, maxLines, maxBytes int) Truncation

TruncateHead keeps the first maxLines/maxBytes of content.

Jump to

Keyboard shortcuts

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