- 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
24 lines
608 B
Go
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]
|
|
}
|