selection

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package selection resolves user-provided skill selectors (by name, the "all" wildcard, or a name@path disambiguator) against the skills discovered in a source. Resolution is a pure function of its inputs: it prefers exact matches, refuses to guess between duplicates in non-interactive use, and surfaces close matches when a name does not resolve.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAmbiguousSelection is returned when a selector cannot be resolved
	// without guessing — a duplicated id with no disambiguating path, or a
	// wildcard over a source that still contains duplicates.
	ErrAmbiguousSelection = errors.New("ambiguous skill selection")
	// ErrInvalidSelection is returned when an explicitly selected skill is invalid.
	ErrInvalidSelection = errors.New("selected skill is invalid")
)

Sentinel selection errors. Callers map these to exit codes at the CLI boundary (ErrAmbiguousSelection/NoMatchError → usage/2, ErrInvalidSelection → 3).

Functions

func Closest

func Closest(target string, candidates []string, limit int) []string

Closest returns up to limit candidate names within a small edit distance of target, ordered by (distance, name) for determinism. It is used to suggest near-misses when a skill selector does not resolve (FR-017).

func Resolve

func Resolve(res discovery.Result, sels []Selector, interactive bool) ([]discovery.DiscoveredSkill, error)

Resolve maps selectors onto discovered skills, preferring exact matches and refusing to guess between duplicates non-interactively. The returned skills are de-duplicated and returned in deterministic (RepoPath, ID) order.

Types

type NoMatchError

type NoMatchError struct {
	Name        string
	Suggestions []string
}

NoMatchError is returned when a name selector matches no discovered skill; it carries the closest candidate names as suggestions (FR-017).

func (*NoMatchError) Error

func (e *NoMatchError) Error() string

type Selector

type Selector interface {
	// contains filtered or unexported methods
}

Selector is a parsed user selection. Implementations: allSelector, nameSelector, pathSelector.

func Parse

func Parse(skillFlags []string, all bool, path string) ([]Selector, error)

Parse turns raw --skill values, the --all flag, and a --path disambiguator into selectors. A "*" --skill value or all=true yields the wildcard selector; a "name@path" value yields a path-qualified selector.

Jump to

Keyboard shortcuts

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