Files
iris-context/internal/scoring/skeleton.go
T
VERSE 6ffb9f83f2 feat(scoring): transition workflow learning and fix history UX (#39)
- add transition scoring engine to learn sequential workflows per
directory using command skeletons
- prioritize current active git branch over older branches in
suggestions
- restore strict chronological order for history navigation and bypass
AI re-ranking
- add in-memory session history for instant access to just-run commands
- fix PTY prompt not syncing when using arrow keys in the history menu
- fix history tie-breaker to properly prioritize newer commands by
assigning larger IDs
- fix potential mutex deadlock between bufferMu and pty write during
history navigation
- fix workspace git detection to remove depth limits and correctly
identify repositories with detached HEADs
- fix SQLite connection leaks in frecency queries
- fix global state leaks in history tests by snapshotting and restoring
registry states
- modernize string prefix checks using strings.CutPrefix
2026-07-26 19:10:56 +07:00

24 lines
608 B
Go

package scoring
import (
"strings"
"github.com/versenilvis/iris/spec"
)
// ExtractSkeleton extracts the subcommand skeleton of a command string for transition tracking.
// If a spec is registered, it walks the subcommand tree.
// If no spec is registered (or fallback occurs), it returns the first token (binary name).
// Never returns empty string unless input has no tokens.
func ExtractSkeleton(buf string) string {
if skeleton, ok := spec.TryExtractSkeleton(buf); ok && skeleton != "" {
return skeleton
}
fields := strings.Fields(buf)
if len(fields) == 0 {
return ""
}
return fields[0]
}