engine

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package engine wires the scan → rules passes into a single ordered item list, shared by the TUI and the JSON serve mode. No terminal dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoSafeSelection

func AutoSafeSelection(items []rules.Item) []rules.Item

AutoSafeSelection picks regenerable SAFE path items (no REVIEW/KEEP, no tool-commands) — the set `--yes` and the GUI's default selection clean.

func FindProjects added in v0.2.1

func FindProjects(root string, onItem func(Project), cancel <-chan struct{}, excludes []string)

FindProjects walks root depth-first for directories named "node_modules" without recursing into a found one, streaming each via onItem. It stays on a single filesystem, skips symlinked dirs, tolerates permission errors, and stops early when cancel is closed (nil = never).

func ScanAll

func ScanAll(goos, home string, system bool, onItem func(rules.Item), cancel <-chan struct{}, excludes []string) []rules.Item

ScanAll runs the catalog pass then the heuristic pass, de-duped and sorted. onItem (may be nil) is called for each item as it is discovered, so a UI can stream rows in. Catalog items stream as they are measured; heuristic (top-N) items stream after. cancel (may be nil) aborts the scan early, returning whatever was collected so far.

Types

type Disk

type Disk struct {
	Used  int64 `json:"used"`
	Free  int64 `json:"free"`
	Total int64 `json:"total"`
}

Disk reports capacity for the filesystem holding a path.

func DiskUsage

func DiskUsage(path string) (Disk, error)

DiskUsage stats the filesystem at path. Works on darwin and linux (both expose Bsize/Blocks/Bavail on Statfs_t).

type Node added in v0.5.0

type Node struct {
	Name     string  `json:"name"`
	Path     string  `json:"path"`
	Bytes    int64   `json:"bytes"`
	Dir      bool    `json:"dir"`
	Children []*Node `json:"children,omitempty"`
}

Node is a directory or file in the disk-map size tree. Aggregate ("+N small") nodes have an empty Path and Dir=false.

func BuildSizeTree added in v0.5.0

func BuildSizeTree(root string, excludes []string, onProgress func(scanned int, bytes int64, path string), cancel <-chan struct{}) *Node

BuildSizeTree walks root once and returns a pruned size tree for a treemap. Excluded subtrees, symlinks, and other devices are skipped; unreadable entries are skipped best-effort; the walk stops when cancel is closed.

type Project added in v0.2.1

type Project struct {
	Path     string // absolute path to the artifact dir (removed when cleaned)
	Dir      string // absolute path to the parent project dir (for the label)
	Kind     string // node_modules | .next | dist | build | target | __pycache__ | ...
	Bytes    int64
	Modified int64 // unix secs: newest mtime among the project dir's non-artifact children
}

Project is one regenerable artifact directory found under a root.

Jump to

Keyboard shortcuts

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