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:
+24
-14
@@ -8,16 +8,18 @@ import (
|
||||
)
|
||||
|
||||
type SignalSet struct {
|
||||
Workspace workspace.WorkspaceInfo
|
||||
LocalFrecency []FrecencyEntry
|
||||
GlobalFrecency []FrecencyEntry
|
||||
Query string
|
||||
RootCommand string
|
||||
Cwd string
|
||||
Workspace workspace.WorkspaceInfo
|
||||
LocalFrecency []FrecencyEntry
|
||||
GlobalFrecency []FrecencyEntry
|
||||
TransitionEntries []TransitionEntry
|
||||
TransitionIsLocal bool
|
||||
Query string
|
||||
RootCommand string
|
||||
Cwd string
|
||||
}
|
||||
|
||||
// CollectSignals gathers environment, workspace, and historical frecency signals for the given query and directory
|
||||
func CollectSignals(ctx context.Context, cwd, query, rootCmd string, frecency *FrecencyStore) SignalSet {
|
||||
// CollectSignals gathers environment, workspace, and historical frecency/transition signals for the given query and directory
|
||||
func CollectSignals(ctx context.Context, cwd, query, rootCmd string, frecency *FrecencyStore, prevCmdSkeleton string) SignalSet {
|
||||
ws := workspace.DetectCached(cwd)
|
||||
|
||||
if ctx == nil {
|
||||
@@ -25,17 +27,25 @@ func CollectSignals(ctx context.Context, cwd, query, rootCmd string, frecency *F
|
||||
}
|
||||
|
||||
var local, global []FrecencyEntry
|
||||
var trans []TransitionEntry
|
||||
var transIsLocal bool
|
||||
|
||||
if frecency != nil {
|
||||
local, _ = frecency.QueryLocal(ctx, cwd, query, 50)
|
||||
global, _ = frecency.QueryGlobal(ctx, query, 50)
|
||||
if prevCmdSkeleton != "" {
|
||||
trans, transIsLocal = frecency.QueryTransitionsWithFallback(ctx, prevCmdSkeleton, cwd)
|
||||
}
|
||||
}
|
||||
|
||||
return SignalSet{
|
||||
Workspace: ws,
|
||||
LocalFrecency: local,
|
||||
GlobalFrecency: global,
|
||||
Query: strings.TrimSpace(query),
|
||||
RootCommand: strings.TrimSpace(rootCmd),
|
||||
Cwd: cwd,
|
||||
Workspace: ws,
|
||||
LocalFrecency: local,
|
||||
GlobalFrecency: global,
|
||||
TransitionEntries: trans,
|
||||
TransitionIsLocal: transIsLocal,
|
||||
Query: strings.TrimSpace(query),
|
||||
RootCommand: strings.TrimSpace(rootCmd),
|
||||
Cwd: cwd,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user