fsio

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

flow/nodes/fsio/library.go

Index

Constants

This section is empty.

Variables

View Source
var BinaryExtensions = map[string]bool{
	".exe": true, ".dll": true, ".so": true, ".dylib": true,
	".bin": true, ".obj": true, ".o": true, ".a": true,
	".png": true, ".jpg": true, ".jpeg": true, ".gif": true,
	".ico": true, ".webp": true, ".pdf": true,
	".zip": true, ".tar": true, ".gz": true, ".7z": true,
	".db": true, ".sqlite": true, ".sqlite3": true,
	".pyc": true, ".pyo": true, ".wasm": true,
}
View Source
var DefaultSkipDirs = []string{
	".git",
	"node_modules",
	"vendor",
	"target",
	"dist",
	"build",
	"_srcpack",
	".next",
	".turbo",
	".cache",
	".idea",
	".vscode",
}

Functions

func All

func ClipboardOperator

func ClipboardOperator() action.NamedOperator

func ClipboardWrite

func ClipboardWrite[T any](cfg ClipboardConfig) action.StreamOp[T, T]

func FilterOperator

func FilterOperator() action.NamedOperator

func GenerateStatsSummary

func GenerateStatsSummary(entries []StatEntry, maxDepth int) string

func Library

func Library() action.Library

func OutFile

func OutFile[T any](cfg OutFileConfig) action.StreamOp[T, T]

func OutFileOperator

func OutFileOperator() action.NamedOperator

func ReadOperator

func ReadOperator() action.NamedOperator

func RenderMarkdownOperator

func RenderMarkdownOperator() action.NamedOperator

func SortOperator

func SortOperator() action.NamedOperator

func Stdout

func Stdout(up iter.Seq2[FileMeta, error]) iter.Seq2[FileMeta, error]

func StdoutOperator

func StdoutOperator() action.NamedOperator

func WalkSource

func WalkSource() action.AnyStreamAction

WalkSource creates a stream source for file metadata traversal.

Traversal rules, in order:

  1. Hidden entries (name starting with ".") are skipped unless IncludeHidden is true. The rule applies to files and directories alike, so .hidden.go and .hidden/ are treated the same way.
  2. Directories named in DefaultSkipDirs, or in Skip, are skipped unless IncludeAll is true.
  3. Entries at depth >= MaxDepth are not descended into; entries deeper than MaxDepth are not yielded.
  4. Files with an extension in BinaryExtensions are skipped.
  5. When Ext is set, only files matching one of its extensions are yielded.

The source stops cleanly when the downstream yield returns false, when the context is cancelled, or when it has exhausted its target directories.

Types

type ClipboardConfig

type ClipboardConfig struct {
	Enabled bool `json:"enabled"`
}

type FileContent

type FileContent struct {
	FileMeta
	Content []byte
}

type FileMeta

type FileMeta struct {
	Path    string    `json:"path"`
	RelPath string    `json:"rel_path"`
	Size    int64     `json:"size"`
	ModTime time.Time `json:"mod_time"`
	Lang    string    `json:"lang"`
}

FileMeta is the item type that flows through the fsio pipeline.

type FilterConfig

type FilterConfig struct {
	Ext       string `json:"ext"`
	Tests     bool   `json:"tests"`
	Generated bool   `json:"generated"`
	Deps      bool   `json:"deps"`
	Examples  bool   `json:"examples"`
	Exclude   string `json:"exclude"`
}

type OutFileConfig

type OutFileConfig struct {
	Path      string `json:"path" cli:"o,output"`
	Append    bool   `json:"append" cli:"append"`
	FlushEach bool   `json:"flush_each"` // Flushes per item, default false (flush at the end)
}

type ReadConfig

type ReadConfig struct {
	Lines string `json:"lines"`
}

type RenderConfig

type RenderConfig struct {
	Editor   string `json:"editor" cli:"editor,e"`
	NoHeader bool   `json:"no_header" cli:"no_header"`
	Prompt   string `json:"prompt" cli:"prompt"`
}

type SortConfig

type SortConfig struct {
	MaxItems int    `json:"max_items"`
	By       string `json:"by"`
}

type StatEntry

type StatEntry struct {
	RelPath   string
	Size      int64
	FuncCount int
}

type WalkConfig

type WalkConfig struct {
	Dir           string   `json:"dir" cli:"dir,d"`
	Dirs          []string `json:"dirs" cli:"dirs"`
	Files         []string `json:"files" cli:"files,file,f"`
	Skip          []string `json:"skip" cli:"skip"`
	IncludeHidden bool     `json:"include_hidden" cli:"include_hidden"`
	IncludeAll    bool     `json:"include_all" cli:"include_all"`
	Ext           string   `json:"ext" cli:"ext"`
	MaxDepth      int      `json:"max_depth" cli:"max_depth"`
}

WalkConfig contains strongly-typed parameters for filesystem traversal.

IncludeHidden defaults to false, so hidden files and directories are skipped unless the caller explicitly opts in. The zero value is the safe choice: no accidental traversal of .git internals, .env files, editor swap files, or hidden build artefacts. Set IncludeHidden: true to traverse them.

IncludeAll disables the DefaultSkipDirs blacklist. It is independent of IncludeHidden: a caller can include vendor/ without including .git, and vice versa.

type WalkReq

type WalkReq = WalkConfig

WalkReq is an alias to WalkConfig for callers that used the older name. Kept deliberately: a rename with no behavioural difference does not warrant churning every call site.

Jump to

Keyboard shortcuts

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