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
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package scoring
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/versenilvis/iris/spec"
|
||||
)
|
||||
|
||||
func TestExtractSkeleton(t *testing.T) {
|
||||
spec.ResetRegistry()
|
||||
spec.Register(&spec.Spec{
|
||||
Name: "git",
|
||||
Subcommands: []spec.Subcommand{
|
||||
{Name: "checkout"},
|
||||
{Name: "push"},
|
||||
},
|
||||
})
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
buf string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "spec command with args",
|
||||
buf: "git checkout feature-x",
|
||||
want: "git checkout",
|
||||
},
|
||||
{
|
||||
name: "fallback no spec binary only",
|
||||
buf: "cargo build --release",
|
||||
want: "cargo",
|
||||
},
|
||||
{
|
||||
name: "fallback single command",
|
||||
buf: "ls -la",
|
||||
want: "ls",
|
||||
},
|
||||
{
|
||||
name: "empty input",
|
||||
buf: " ",
|
||||
want: "",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got := ExtractSkeleton(tc.buf)
|
||||
if got != tc.want {
|
||||
t.Errorf("ExtractSkeleton(%q) = %q, want %q", tc.buf, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user