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:
VERSE
2026-07-26 19:10:56 +07:00
committed by GitHub
parent 85ac76e85a
commit 6ffb9f83f2
20 changed files with 1004 additions and 72 deletions
+29 -1
View File
@@ -20,7 +20,6 @@ func TestMergeResults(t *testing.T) {
}
})
t.Run("Limit 100", func(t *testing.T) {
res := MergeResults("a", "history")
if len(res) > 100 {
@@ -50,3 +49,32 @@ func TestMergeResults(t *testing.T) {
}
})
}
func TestPrevRecordedCommandState(t *testing.T) {
origRegistry := spec.Registry
t.Cleanup(func() {
spec.Registry = origRegistry
})
spec.ResetRegistry()
spec.Register(&spec.Spec{
Name: "git",
Subcommands: []spec.Subcommand{
{Name: "checkout"},
},
})
setPrevRecordedInfo("git checkout feature-abc", "/repo/dir")
skel, cwd := getPrevRecordedInfo()
if skel != "git checkout" || cwd != "/repo/dir" {
t.Errorf("expected skel='git checkout' and cwd='/repo/dir', got skel=%q, cwd=%q", skel, cwd)
}
if gotSkel := getPrevSkeleton(); gotSkel != "git checkout" {
t.Errorf("expected getPrevSkeleton()='git checkout', got %q", gotSkel)
}
setPrevRecordedInfo("", "")
if gotSkel := getPrevSkeleton(); gotSkel != "" {
t.Errorf("expected empty getPrevSkeleton() after reset, got %q", gotSkel)
}
}