Files
iris-context/spec/spec.go
T
VERSE 94c8af7b1d feat: AI suggestion (#34)
## Feat
* feat(ai): add AI suggestion engine, context gathering, and ghost text
overlay (`v0.3.0`)

## Security & Perf
* fix(ai): restrict background `--help` execution to a hardcoded command
allowlist to prevent RCE
* fix(root): defer context cancellation in goroutine to prevent resource
leaks
* perf(ai): implement LRU eviction and maximum size limit for
`ProviderCache`
* perf(ai): truncate command context output
(`CommandContextProvider.Gather`) to 1000 characters to save tokens

## Bug Fixes
* fix(ai): add mutex synchronization and thread-safe snapshotting to
`AIEngine.RegisterProvider` and `GatherDynamicContext`
* fix(ai): return a copy of fresh `Suggestion` in `AIEngine.Suggest` to
prevent cache mutation
* fix(ai): use length-prefixed encoding in `EnvSnapshot.Hash` to prevent
delimiter collisions
* fix(ai): skip variable assignment lines containing `=` when extracting
Makefile targets
* fix(runner): check `scanner.Err()` and return `nil` on scan errors in
justfile generator
* test(ci): rename `git commit` to `git checkout` in overlay test to
resolve CI `typos` false positive
2026-07-11 15:17:14 +07:00

56 lines
1.2 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
}
// Option represents a command flag or option
type Option struct {
Name string
Description string
}
// 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
}
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)
}