model

package
v0.0.0-...-682de65 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const TopItemsLimit = 10

TopItemsLimit is the maximum number of top entries shown in statistics.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandEntry

type CommandEntry struct {
	Command     string          // The actual command text
	Frequency   int             // Number of times this exact command was executed
	LineNumbers []int           // All line numbers where this command appears
	Hash        uint64          // Fast hash for deduplication
	Order       int             // Insertion order in OrderedList (higher = more recent)
	Shell       Shell           // Which shell/terminal this came from
	TreeNode    *PrefixTreeNode // Back-pointer to the prefix tree node storing this command; set during tree build
}

CommandEntry represents a single unique command with all metadata

func NewCommandEntry

func NewCommandEntry(command string, lineNum int) *CommandEntry

NewCommandEntry creates a new CommandEntry for a command

func (*CommandEntry) Update

func (ce *CommandEntry) Update(lineNum int)

Update increments the frequency and updates metadata for an existing command

type PrefixTreeNode

type PrefixTreeNode struct {
	Word           string                     // Current word/token
	FullPath       string                     // Full command path to this node
	Children       map[string]*PrefixTreeNode // Child nodes (next words)
	SortedChildren []*PrefixTreeNode          // Pre-sorted children for rendering (sorted once at build time)
	Parent         *PrefixTreeNode            // Parent node (nil for root); set during tree build
	CommandCount   int                        // Total commands passing through this node
	TerminalCount  int                        // Commands ending at this node
	Commands       []*CommandEntry            // Commands that end here
	Level          int                        // Depth in tree (0 = root)
}

PrefixTreeNode represents a node in the command hierarchy tree

type RankedEntry

type RankedEntry struct {
	Label       string
	Count       int
	CachedIndex string // Pre-formatted index (e.g., " 1. ")
	CachedCount string // Pre-formatted count (e.g., "    5 uses")
}

RankedEntry represents a ranked item (command or prefix) with its count and pre-formatted display parts

func SortAndFormat

func SortAndFormat(counts map[string]int) []RankedEntry

SortAndFormat sorts aggregated counts descending, truncates to TopItemsLimit, and pre-formats each entry's CachedIndex/CachedCount for rendering.

type Shell

type Shell int

Shell identifies which shell/terminal a command came from.

const (
	UnknownShell Shell = iota
	PowerShell
	GitBash
	WSLBash
	Bash
	Zsh
	Fish
	CustomShell
)

func (Shell) String

func (s Shell) String() string

String returns the human-readable display name for a Shell.

type Tab

type Tab int

Tab represents different view tabs

const (
	TabCommands Tab = iota
	TabTree
	TabTopCommands
	TabSettings
)

type TreeDisplayNode

type TreeDisplayNode struct {
	Node                *PrefixTreeNode
	Path                string // Full path including current word (e.g., "git commit -m")
	PathPrefix          string // Path without current word (e.g., "git commit") - cached for rendering
	PathPrefixWithSpace string // pre-cached to avoid allocation
	Depth               int
	HasChildren         bool
	IsLeaf              bool
	FilteredFrequency   int           // Total frequency considering search + source filters
	MostFrequentCmd     *CommandEntry // Most frequent command among filtered ones
	CachedMetadata      string        // Pre-formatted metadata string (e.g., "Used 5 times · bash")
}

TreeDisplayNode is a flattened tree node for rendering

Jump to

Keyboard shortcuts

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