Files
VERSE 860b475b53 feat: scoring and frecency (#37)
Enhance lookup mechanics and priority propagation (`spec/lookup.go`)
Remove the requirement of typing a leading `-` when searching for
options, allowing flag suggestions to surface naturally during input
Accurately forward the `Priority` field from registry specs into the
`Suggestion` struct so the scoring engine evaluates relevance properly

Integrate scoring into the main suggestion pipeline
(`root/suggestions.go`)
Collect context signals using `scoring.CollectSignals(cwd, query,
rootCmd, store)` with the live working directory retrieved from
`spec.GetCWD()`
Pass the entire deduplicated list across spec, history and AI items
through `scoring.Score(deduped, signals)` to compute scores and sort by
descending order before rendering on screen

Record execution history in Frecency Store (`root/wrapper.go`)
Save the last executed command to `lastSubmittedCommand` whenever Enter
is pressed or a suggestion is selected
Trigger `store.Record(...)` asynchronously within the `IRIS_CMD_STOP`
hook using a dedicated goroutine guarded by panic recovery and timeout
limits, preventing blocks on the main shell thread

Optimize workspace identification for AI
(`internal/ai/context_provider.go`)
Use `workspace.DetectCached(cwd)` to instantly fetch ecosystem context
across Git, Node, Go, Rust, Python and Docker alongside active git
branch state
This caching mechanism avoids redundant subprocess execution when
outside git repositories, significantly speeding up prompt context
generation
2026-07-13 17:56:29 +07:00

59 lines
1.3 KiB
Go

package spec
type GeneratorFunc func(tokens []string, prefix string, partial string) []Suggestion
// Spec defines a top-level command structure
type Spec struct {
Name string
Aliases []string
Description string
Icon string
Subcommands []Subcommand
Options []Option
Generator GeneratorFunc
MaxArgs int
}
// Subcommand defines nested command logic
type Subcommand struct {
Name string
Aliases []string
Description string
Icon string
Subcommands []Subcommand
Options []Option
Generator GeneratorFunc
MaxArgs int
Priority int
}
// Option represents a command flag or option
type Option struct {
Name string
Description string
Priority int
}
// Suggestion represents an item in the suggestion menu
type Suggestion struct {
Cmd string
Desc string
Icon string
Source string // "history", "spec", "ai"
Confidence int // 0-100
Priority int // static author priority
}
var Registry = map[string]*Spec{}
// Register adds a new spec to the global Registry
// example: Register(&Spec{Name: "git"})
func Register(s *Spec) {
Registry[s.Name] = s
}
// ResetRegistry clears all registered specs - use in tests only
func ResetRegistry() {
Registry = make(map[string]*Spec)
}