interactive

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package interactive provides project scoring and session-state persistence for the magus x shorthand command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emit

func Emit(w io.Writer, msg string)

Emit writes "hint: <msg>\n" to w when hints are enabled, once per distinct msg - see emitted.

func HintsEnabled added in v0.4.0

func HintsEnabled() bool

HintsEnabled reports whether actionable hints are active.

func LastTarget added in v0.4.1

func LastTarget(dir string) string

LastTarget returns the target last run for the project rooted at dir, "" when there is none. Every failure yields "" rather than an error: the value only pre-highlights a picker row, so an unreadable file must not stop x opening.

func LeafScore

func LeafScore(path, query string) int

LeafScore returns a leaf-anchored match score for path against query. Higher is better. Returns 0 when query does not appear in path.

func SaveLastTarget added in v0.4.1

func SaveLastTarget(dir, target string) error

SaveLastTarget records target as the last one run for the project rooted at dir. Atomic despite the file holding one short line: two pickers finishing in the same project race for it, and a plain write truncates before it fills, so the shorter name lands inside the longer one ("ci\nerage-badge-...", measured).

func SetHintsEnabled added in v0.4.0

func SetHintsEnabled(on bool)

SetHintsEnabled sets whether actionable hints are emitted.

Types

type ScoredFile

type ScoredFile struct {
	Path  string
	Score int // higher is better; only meaningful relative to other results from the same call
}

ScoredFile pairs a workspace-relative file path with its leaf-anchored match score. Path uses forward slashes.

func SearchFiles

func SearchFiles(ctx context.Context, wsRoot string, filters []string, matchFn func(absPath string) bool) ([]ScoredFile, error)

SearchFiles walks wsRoot and returns regular files matching all filter tokens (AND, case-insensitive) and matchFn, ranked by LeafScore. Returns nil,nil when filters is empty and matchFn is nil.

type ScoredProject

type ScoredProject struct {
	P     *types.Project
	Score int
}

ScoredProject pairs a project with its ranking score from ScoreProjects.

func ScoreProjects

func ScoreProjects(all []*types.Project, filters []string) []ScoredProject

ScoreProjects keeps every project that contains every filter token as a substring (AND), then ranks by leaf-anchored longest match against the first token. With no filters every project is kept and ranked alphabetically.

Directories

Path Synopsis
Package difftui is the terminal client of the shared diff session: the same changeset the console's Diff surface renders and an agent joins over MCP, read with a keyboard.
Package difftui is the terminal client of the shared diff session: the same changeset the console's Diff surface renders and an agent joins over MCP, read with a keyboard.
Package screen is a terminal emulator: it consumes an escape stream and reconstructs the grid a reader would be looking at.
Package screen is a terminal emulator: it consumes an escape stream and reconstructs the grid a reader would be looking at.
Package tty provides terminal-agnostic primitives: scroll regions, file-descriptor classification (TTY vs pipe vs regular file), and the picker.
Package tty provides terminal-agnostic primitives: scroll regions, file-descriptor classification (TTY vs pipe vs regular file), and the picker.

Jump to

Keyboard shortcuts

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