- 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
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package scoring
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/versenilvis/iris/internal/workspace"
|
|
)
|
|
|
|
type SignalSet struct {
|
|
Workspace workspace.WorkspaceInfo
|
|
LocalFrecency []FrecencyEntry
|
|
GlobalFrecency []FrecencyEntry
|
|
TransitionEntries []TransitionEntry
|
|
TransitionIsLocal bool
|
|
Query string
|
|
RootCommand string
|
|
Cwd string
|
|
}
|
|
|
|
// 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 {
|
|
ctx = context.Background()
|
|
}
|
|
|
|
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,
|
|
TransitionEntries: trans,
|
|
TransitionIsLocal: transIsLocal,
|
|
Query: strings.TrimSpace(query),
|
|
RootCommand: strings.TrimSpace(rootCmd),
|
|
Cwd: cwd,
|
|
}
|
|
}
|