From 4577d218d357557163507b7a522ae5bef7805e14 Mon Sep 17 00:00:00 2001 From: Ed Zynda Date: Fri, 6 Mar 2026 18:50:32 +0300 Subject: [PATCH] feat: add /model slash command with interactive fuzzy-finding selector Add /model command that allows switching LLM models mid-session. When invoked without arguments, opens a full-screen selector overlay showing only models with configured API keys, with inline fuzzy search, cursor navigation, and current model indicator. When invoked with an argument (e.g. /model anthropic/claude-haiku-4-5), switches directly. Also upgrades all Go dependencies to latest versions. --- cmd/root.go | 30 ++- go.mod | 78 +++---- go.sum | 148 ++++++------ internal/ui/commands.go | 6 + internal/ui/model.go | 137 ++++++++++- internal/ui/model_selector.go | 413 ++++++++++++++++++++++++++++++++++ 6 files changed, 689 insertions(+), 123 deletions(-) create mode 100644 internal/ui/model_selector.go diff --git a/cmd/root.go b/cmd/root.go index 0422376a..c4216cd0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -962,9 +962,27 @@ func runNormalMode(ctx context.Context) error { return extensionCommandsForUI(kitInstance) } + // Build model switching callbacks for the /model command. + setModelForUI := func(modelString string) error { + err := kitInstance.SetModel(context.Background(), modelString) + if err != nil { + return err + } + // Update the extension context's Model field so handlers see it. + kitInstance.UpdateExtensionContextModel(modelString) + // NOTE: We do NOT call appInstance.NotifyModelChanged() here because + // this callback runs synchronously inside BubbleTea's Update(), and + // NotifyModelChanged calls prog.Send() which deadlocks. The UI layer + // updates m.providerName and m.modelName directly after setModel returns. + return nil + } + emitModelChangeForUI := func(newModel, previousModel, source string) { + kitInstance.EmitModelChange(newModel, previousModel, source) + } + // Check if running in non-interactive mode if positionalPrompt != "" { - return runNonInteractiveModeApp(ctx, appInstance, cli, positionalPrompt, quietFlag, jsonFlag, noExitFlag, modelName, parsedProvider, kitInstance.GetLoadingMessage(), serverNames, toolNames, mcpToolCount, extensionToolCount, usageTracker, extCommands, contextPaths, skillItems, getWidgets, getHeader, getFooter, getToolRenderer, getEditorInterceptor, getUIVisibility, getStatusBarEntries, emitBeforeFork, emitBeforeSessionSwitch, getGlobalShortcuts, getExtensionCommands) + return runNonInteractiveModeApp(ctx, appInstance, cli, positionalPrompt, quietFlag, jsonFlag, noExitFlag, modelName, parsedProvider, kitInstance.GetLoadingMessage(), serverNames, toolNames, mcpToolCount, extensionToolCount, usageTracker, extCommands, contextPaths, skillItems, getWidgets, getHeader, getFooter, getToolRenderer, getEditorInterceptor, getUIVisibility, getStatusBarEntries, emitBeforeFork, emitBeforeSessionSwitch, getGlobalShortcuts, getExtensionCommands, setModelForUI, emitModelChangeForUI) } // Quiet mode is not allowed in interactive mode @@ -972,7 +990,7 @@ func runNormalMode(ctx context.Context) error { return fmt.Errorf("--quiet requires a prompt") } - return runInteractiveModeBubbleTea(ctx, appInstance, modelName, parsedProvider, kitInstance.GetLoadingMessage(), serverNames, toolNames, mcpToolCount, extensionToolCount, usageTracker, extCommands, contextPaths, skillItems, getWidgets, getHeader, getFooter, getToolRenderer, getEditorInterceptor, getUIVisibility, getStatusBarEntries, emitBeforeFork, emitBeforeSessionSwitch, getGlobalShortcuts, getExtensionCommands) + return runInteractiveModeBubbleTea(ctx, appInstance, modelName, parsedProvider, kitInstance.GetLoadingMessage(), serverNames, toolNames, mcpToolCount, extensionToolCount, usageTracker, extCommands, contextPaths, skillItems, getWidgets, getHeader, getFooter, getToolRenderer, getEditorInterceptor, getUIVisibility, getStatusBarEntries, emitBeforeFork, emitBeforeSessionSwitch, getGlobalShortcuts, getExtensionCommands, setModelForUI, emitModelChangeForUI) } // runNonInteractiveModeApp executes a single prompt via the app layer and exits, @@ -985,7 +1003,7 @@ func runNormalMode(ctx context.Context) error { // // When --no-exit is set, after the prompt completes the interactive BubbleTea // TUI is started so the user can continue the conversation. -func runNonInteractiveModeApp(ctx context.Context, appInstance *app.App, cli *ui.CLI, prompt string, quiet, jsonOutput, noExit bool, modelName, providerName, loadingMessage string, serverNames, toolNames []string, mcpToolCount, extensionToolCount int, usageTracker *ui.UsageTracker, extCommands []ui.ExtensionCommand, contextPaths []string, skillItems []ui.SkillItem, getWidgets func(string) []ui.WidgetData, getHeader, getFooter func() *ui.WidgetData, getToolRenderer func(string) *ui.ToolRendererData, getEditorInterceptor func() *ui.EditorInterceptor, getUIVisibility func() *ui.UIVisibility, getStatusBarEntries func() []ui.StatusBarEntryData, emitBeforeFork func(string, bool, string) (bool, string), emitBeforeSessionSwitch func(string) (bool, string), getGlobalShortcuts func() map[string]func(), getExtensionCommands func() []ui.ExtensionCommand) error { +func runNonInteractiveModeApp(ctx context.Context, appInstance *app.App, cli *ui.CLI, prompt string, quiet, jsonOutput, noExit bool, modelName, providerName, loadingMessage string, serverNames, toolNames []string, mcpToolCount, extensionToolCount int, usageTracker *ui.UsageTracker, extCommands []ui.ExtensionCommand, contextPaths []string, skillItems []ui.SkillItem, getWidgets func(string) []ui.WidgetData, getHeader, getFooter func() *ui.WidgetData, getToolRenderer func(string) *ui.ToolRendererData, getEditorInterceptor func() *ui.EditorInterceptor, getUIVisibility func() *ui.UIVisibility, getStatusBarEntries func() []ui.StatusBarEntryData, emitBeforeFork func(string, bool, string) (bool, string), emitBeforeSessionSwitch func(string) (bool, string), getGlobalShortcuts func() map[string]func(), getExtensionCommands func() []ui.ExtensionCommand, setModel func(string) error, emitModelChange func(string, string, string)) error { // Expand @file references in the prompt before sending to the agent. if cwd, err := os.Getwd(); err == nil { prompt = ui.ProcessFileAttachments(prompt, cwd) @@ -1028,7 +1046,7 @@ func runNonInteractiveModeApp(ctx context.Context, appInstance *app.App, cli *ui // If --no-exit was requested, hand off to the interactive TUI. if noExit { - return runInteractiveModeBubbleTea(ctx, appInstance, modelName, providerName, loadingMessage, serverNames, toolNames, mcpToolCount, extensionToolCount, usageTracker, extCommands, contextPaths, skillItems, getWidgets, getHeader, getFooter, getToolRenderer, getEditorInterceptor, getUIVisibility, getStatusBarEntries, emitBeforeFork, emitBeforeSessionSwitch, getGlobalShortcuts, getExtensionCommands) + return runInteractiveModeBubbleTea(ctx, appInstance, modelName, providerName, loadingMessage, serverNames, toolNames, mcpToolCount, extensionToolCount, usageTracker, extCommands, contextPaths, skillItems, getWidgets, getHeader, getFooter, getToolRenderer, getEditorInterceptor, getUIVisibility, getStatusBarEntries, emitBeforeFork, emitBeforeSessionSwitch, getGlobalShortcuts, getExtensionCommands, setModel, emitModelChange) } return nil @@ -1122,7 +1140,7 @@ func writeJSONError(err error) { // 4. Calls program.Run() which blocks until the user quits (Ctrl+C or /quit). // // SetupCLI is not used for interactive mode; the TUI (AppModel) handles its own rendering. -func runInteractiveModeBubbleTea(_ context.Context, appInstance *app.App, modelName, providerName, loadingMessage string, serverNames, toolNames []string, mcpToolCount, extensionToolCount int, usageTracker *ui.UsageTracker, extCommands []ui.ExtensionCommand, contextPaths []string, skillItems []ui.SkillItem, getWidgets func(string) []ui.WidgetData, getHeader, getFooter func() *ui.WidgetData, getToolRenderer func(string) *ui.ToolRendererData, getEditorInterceptor func() *ui.EditorInterceptor, getUIVisibility func() *ui.UIVisibility, getStatusBarEntries func() []ui.StatusBarEntryData, emitBeforeFork func(string, bool, string) (bool, string), emitBeforeSessionSwitch func(string) (bool, string), getGlobalShortcuts func() map[string]func(), getExtensionCommands func() []ui.ExtensionCommand) error { +func runInteractiveModeBubbleTea(_ context.Context, appInstance *app.App, modelName, providerName, loadingMessage string, serverNames, toolNames []string, mcpToolCount, extensionToolCount int, usageTracker *ui.UsageTracker, extCommands []ui.ExtensionCommand, contextPaths []string, skillItems []ui.SkillItem, getWidgets func(string) []ui.WidgetData, getHeader, getFooter func() *ui.WidgetData, getToolRenderer func(string) *ui.ToolRendererData, getEditorInterceptor func() *ui.EditorInterceptor, getUIVisibility func() *ui.UIVisibility, getStatusBarEntries func() []ui.StatusBarEntryData, emitBeforeFork func(string, bool, string) (bool, string), emitBeforeSessionSwitch func(string) (bool, string), getGlobalShortcuts func() map[string]func(), getExtensionCommands func() []ui.ExtensionCommand, setModel func(string) error, emitModelChange func(string, string, string)) error { // Determine terminal size; fall back gracefully. termWidth, termHeight, err := term.GetSize(int(os.Stdout.Fd())) if err != nil || termWidth == 0 { @@ -1158,6 +1176,8 @@ func runInteractiveModeBubbleTea(_ context.Context, appInstance *app.App, modelN EmitBeforeSessionSwitch: emitBeforeSessionSwitch, GetGlobalShortcuts: getGlobalShortcuts, GetExtensionCommands: getExtensionCommands, + SetModel: setModel, + EmitModelChange: emitModelChange, }) // Print startup info to stdout before Bubble Tea takes over the screen. diff --git a/go.mod b/go.mod index e84f9825..d0754e55 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,17 @@ go 1.26.0 require ( charm.land/bubbles/v2 v2.0.0 - charm.land/bubbletea/v2 v2.0.0 - charm.land/fantasy v0.10.0 + charm.land/bubbletea/v2 v2.0.1 + charm.land/fantasy v0.11.1 charm.land/lipgloss/v2 v2.0.0 + github.com/alecthomas/chroma/v2 v2.23.1 + github.com/aymanbagabas/go-udiff v0.4.0 github.com/charmbracelet/fang v0.4.4 - github.com/mark3labs/mcp-go v0.44.0 + github.com/charmbracelet/log v0.4.2 + github.com/mark3labs/mcp-go v0.44.1 github.com/spf13/cobra v1.10.2 github.com/spf13/viper v1.21.0 + github.com/traefik/yaegi v0.16.1 golang.org/x/term v0.40.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -22,24 +26,22 @@ require ( cloud.google.com/go/compute/metadata v0.9.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect - github.com/alecthomas/chroma/v2 v2.23.1 // indirect github.com/atotto/clipboard v0.1.4 // indirect - github.com/aws/aws-sdk-go-v2 v1.41.2 // indirect - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.5 // indirect - github.com/aws/aws-sdk-go-v2/config v1.32.10 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.19.10 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.18 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.18 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.18 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.5 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.18 // indirect - github.com/aws/aws-sdk-go-v2/service/signin v1.0.6 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.30.11 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.15 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.41.7 // indirect - github.com/aws/smithy-go v1.24.1 // indirect - github.com/aymanbagabas/go-udiff v0.4.0 // indirect + github.com/aws/aws-sdk-go-v2 v1.41.3 // indirect + github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.6 // indirect + github.com/aws/aws-sdk-go-v2/config v1.32.11 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.19.11 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.19 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.19 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.19 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.8.5 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.6 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.19 // indirect + github.com/aws/aws-sdk-go-v2/service/signin v1.0.7 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.30.12 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.16 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.41.8 // indirect + github.com/aws/smithy-go v1.24.2 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/buger/jsonparser v1.1.1 // indirect @@ -48,11 +50,10 @@ require ( github.com/charmbracelet/colorprofile v0.4.2 // indirect github.com/charmbracelet/harmonica v0.2.0 // indirect github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 // indirect - github.com/charmbracelet/log v0.4.2 // indirect - github.com/charmbracelet/ultraviolet v0.0.0-20260223171050-89c142e4aa73 // indirect + github.com/charmbracelet/ultraviolet v0.0.0-20260303162955-0b88c25f3fff // indirect github.com/charmbracelet/x/cellbuf v0.0.15 // indirect - github.com/charmbracelet/x/exp/charmtone v0.0.0-20260223200540-d6a276319c45 // indirect - github.com/charmbracelet/x/exp/slice v0.0.0-20260223200540-d6a276319c45 // indirect + github.com/charmbracelet/x/exp/charmtone v0.0.0-20260305213658-fe36e8c10185 // indirect + github.com/charmbracelet/x/exp/slice v0.0.0-20260305213658-fe36e8c10185 // indirect github.com/charmbracelet/x/json v0.2.0 // indirect github.com/charmbracelet/x/termios v0.1.1 // indirect github.com/charmbracelet/x/windows v0.2.2 // indirect @@ -62,7 +63,7 @@ require ( github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 // indirect - github.com/go-logfmt/logfmt v0.6.0 // indirect + github.com/go-logfmt/logfmt v0.6.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 // indirect @@ -71,14 +72,14 @@ require ( github.com/google/go-cmp v0.7.0 // indirect github.com/google/s2a-go v0.1.9 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.3.12 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.14 // indirect github.com/googleapis/gax-go/v2 v2.17.0 // indirect github.com/gorilla/css v1.0.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/invopop/jsonschema v0.13.0 // indirect - github.com/kaptinlin/go-i18n v0.2.11 // indirect - github.com/kaptinlin/jsonpointer v0.4.16 // indirect - github.com/kaptinlin/jsonschema v0.7.3 // indirect + github.com/kaptinlin/go-i18n v0.2.12 // indirect + github.com/kaptinlin/jsonpointer v0.4.17 // indirect + github.com/kaptinlin/jsonschema v0.7.5 // indirect github.com/kaptinlin/messageformat-go v0.4.18 // indirect github.com/mailru/easyjson v0.9.1 // indirect github.com/microcosm-cc/bluemonday v1.0.27 // indirect @@ -97,28 +98,27 @@ require ( github.com/tidwall/match v1.2.0 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect - github.com/traefik/yaegi v0.16.1 // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yosida95/uritemplate/v3 v3.0.2 // indirect github.com/yuin/goldmark v1.7.16 // indirect github.com/yuin/goldmark-emoji v1.0.6 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.65.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0 // indirect - go.opentelemetry.io/otel v1.40.0 // indirect - go.opentelemetry.io/otel/metric v1.40.0 // indirect - go.opentelemetry.io/otel/trace v1.40.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.66.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.66.0 // indirect + go.opentelemetry.io/otel v1.41.0 // indirect + go.opentelemetry.io/otel/metric v1.41.0 // indirect + go.opentelemetry.io/otel/trace v1.41.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/crypto v0.48.0 // indirect golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa // indirect - golang.org/x/net v0.50.0 // indirect + golang.org/x/net v0.51.0 // indirect golang.org/x/oauth2 v0.35.0 // indirect golang.org/x/time v0.14.0 // indirect google.golang.org/api v0.269.0 // indirect - google.golang.org/genai v1.47.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260223185530-2f722ef697dc // indirect - google.golang.org/grpc v1.79.1 // indirect + google.golang.org/genai v1.49.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 // indirect + google.golang.org/grpc v1.79.2 // indirect google.golang.org/protobuf v1.36.11 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index ec2c42a3..4eed97f2 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,9 @@ charm.land/bubbles/v2 v2.0.0 h1:tE3eK/pHjmtrDiRdoC9uGNLgpopOd8fjhEe31B/ai5s= charm.land/bubbles/v2 v2.0.0/go.mod h1:rCHoleP2XhU8um45NTuOWBPNVHxnkXKTiZqcclL/qOI= -charm.land/bubbletea/v2 v2.0.0 h1:p0d6CtWyJXJ9GfzMpUUqbP/XUUhhlk06+vCKWmox1wQ= -charm.land/bubbletea/v2 v2.0.0/go.mod h1:3LRff2U4WIYXy7MTxfbAQ+AdfM3D8Xuvz2wbsOD9OHQ= -charm.land/fantasy v0.10.0 h1:6PD+1rrsCgLIG1n+PAZp/gHiC0dltU0cvb7c8zUKyu8= -charm.land/fantasy v0.10.0/go.mod h1:KIeNQUpJTswwpY0P6HJsr3LBFgfTDb8FDpOdVQMsKqY= +charm.land/bubbletea/v2 v2.0.1 h1:B8e9zzK7x9JJ+XvHGF4xnYu9Xa0E0y0MyggY6dbaCfQ= +charm.land/bubbletea/v2 v2.0.1/go.mod h1:3LRff2U4WIYXy7MTxfbAQ+AdfM3D8Xuvz2wbsOD9OHQ= +charm.land/fantasy v0.11.1 h1:G1dRqkzEQ0RJN1Ls5mte8HOi0wFKxYd5bfnRAmeYvDk= +charm.land/fantasy v0.11.1/go.mod h1:C8wNxWlw+b2z54zsTor9r1tG2GE2C4QotvAlgXh9KF8= charm.land/lipgloss/v2 v2.0.0 h1:sd8N/B3x892oiOjFfBQdXBQp3cAkvjGaU5TvVZC3ivo= charm.land/lipgloss/v2 v2.0.0/go.mod h1:w6SnmsBFBmEFBodiEDurGS/sdUY/u1+v72DqUzc6J14= cloud.google.com/go v0.123.0 h1:2NAUJwPR47q+E35uaJeYoNhuNEM9kM8SjgRgdeOJUSE= @@ -32,36 +32,36 @@ github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= -github.com/aws/aws-sdk-go-v2 v1.41.2 h1:LuT2rzqNQsauaGkPK/7813XxcZ3o3yePY0Iy891T2ls= -github.com/aws/aws-sdk-go-v2 v1.41.2/go.mod h1:IvvlAZQXvTXznUPfRVfryiG1fbzE2NGK6m9u39YQ+S4= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.5 h1:zWFmPmgw4sveAYi1mRqG+E/g0461cJ5M4bJ8/nc6d3Q= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.5/go.mod h1:nVUlMLVV8ycXSb7mSkcNu9e3v/1TJq2RTlrPwhYWr5c= -github.com/aws/aws-sdk-go-v2/config v1.32.10 h1:9DMthfO6XWZYLfzZglAgW5Fyou2nRI5CuV44sTedKBI= -github.com/aws/aws-sdk-go-v2/config v1.32.10/go.mod h1:2rUIOnA2JaiqYmSKYmRJlcMWy6qTj1vuRFscppSBMcw= -github.com/aws/aws-sdk-go-v2/credentials v1.19.10 h1:EEhmEUFCE1Yhl7vDhNOI5OCL/iKMdkkYFTRpZXNw7m8= -github.com/aws/aws-sdk-go-v2/credentials v1.19.10/go.mod h1:RnnlFCAlxQCkN2Q379B67USkBMu1PipEEiibzYN5UTE= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.18 h1:Ii4s+Sq3yDfaMLpjrJsqD6SmG/Wq/P5L/hw2qa78UAY= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.18/go.mod h1:6x81qnY++ovptLE6nWQeWrpXxbnlIex+4H4eYYGcqfc= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.18 h1:F43zk1vemYIqPAwhjTjYIz0irU2EY7sOb/F5eJ3HuyM= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.18/go.mod h1:w1jdlZXrGKaJcNoL+Nnrj+k5wlpGXqnNrKoP22HvAug= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.18 h1:xCeWVjj0ki0l3nruoyP2slHsGArMxeiiaoPN5QZH6YQ= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.18/go.mod h1:r/eLGuGCBw6l36ZRWiw6PaZwPXb6YOj+i/7MizNl5/k= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 h1:WKuaxf++XKWlHWu9ECbMlha8WOEGm0OUEZqm4K/Gcfk= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4/go.mod h1:ZWy7j6v1vWGmPReu0iSGvRiise4YI5SkR3OHKTZ6Wuc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.5 h1:CeY9LUdur+Dxoeldqoun6y4WtJ3RQtzk0JMP2gfUay0= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.5/go.mod h1:AZLZf2fMaahW5s/wMRciu1sYbdsikT/UHwbUjOdEVTc= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.18 h1:LTRCYFlnnKFlKsyIQxKhJuDuA3ZkrDQMRYm6rXiHlLY= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.18/go.mod h1:XhwkgGG6bHSd00nO/mexWTcTjgd6PjuvWQMqSn2UaEk= -github.com/aws/aws-sdk-go-v2/service/signin v1.0.6 h1:MzORe+J94I+hYu2a6XmV5yC9huoTv8NRcCrUNedDypQ= -github.com/aws/aws-sdk-go-v2/service/signin v1.0.6/go.mod h1:hXzcHLARD7GeWnifd8j9RWqtfIgxj4/cAtIVIK7hg8g= -github.com/aws/aws-sdk-go-v2/service/sso v1.30.11 h1:7oGD8KPfBOJGXiCoRKrrrQkbvCp8N++u36hrLMPey6o= -github.com/aws/aws-sdk-go-v2/service/sso v1.30.11/go.mod h1:0DO9B5EUJQlIDif+XJRWCljZRKsAFKh3gpFz7UnDtOo= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.15 h1:edCcNp9eGIUDUCrzoCu1jWAXLGFIizeqkdkKgRlJwWc= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.15/go.mod h1:lyRQKED9xWfgkYC/wmmYfv7iVIM68Z5OQ88ZdcV1QbU= -github.com/aws/aws-sdk-go-v2/service/sts v1.41.7 h1:NITQpgo9A5NrDZ57uOWj+abvXSb83BbyggcUBVksN7c= -github.com/aws/aws-sdk-go-v2/service/sts v1.41.7/go.mod h1:sks5UWBhEuWYDPdwlnRFn1w7xWdH29Jcpe+/PJQefEs= -github.com/aws/smithy-go v1.24.1 h1:VbyeNfmYkWoxMVpGUAbQumkODcYmfMRfZ8yQiH30SK0= -github.com/aws/smithy-go v1.24.1/go.mod h1:LEj2LM3rBRQJxPZTB4KuzZkaZYnZPnvgIhb4pu07mx0= +github.com/aws/aws-sdk-go-v2 v1.41.3 h1:4kQ/fa22KjDt13QCy1+bYADvdgcxpfH18f0zP542kZA= +github.com/aws/aws-sdk-go-v2 v1.41.3/go.mod h1:mwsPRE8ceUUpiTgF7QmQIJ7lgsKUPQOUl3o72QBrE1o= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.6 h1:N4lRUXZpZ1KVEUn6hxtco/1d2lgYhNn1fHkkl8WhlyQ= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.6/go.mod h1:lyw7GFp3qENLh7kwzf7iMzAxDn+NzjXEAGjKS2UOKqI= +github.com/aws/aws-sdk-go-v2/config v1.32.11 h1:ftxI5sgz8jZkckuUHXfC/wMUc8u3fG1vQS0plr2F2Zs= +github.com/aws/aws-sdk-go-v2/config v1.32.11/go.mod h1:twF11+6ps9aNRKEDimksp923o44w/Thk9+8YIlzWMmo= +github.com/aws/aws-sdk-go-v2/credentials v1.19.11 h1:NdV8cwCcAXrCWyxArt58BrvZJ9pZ9Fhf9w6Uh5W3Uyc= +github.com/aws/aws-sdk-go-v2/credentials v1.19.11/go.mod h1:30yY2zqkMPdrvxBqzI9xQCM+WrlrZKSOpSJEsylVU+8= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.19 h1:INUvJxmhdEbVulJYHI061k4TVuS3jzzthNvjqvVvTKM= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.19/go.mod h1:FpZN2QISLdEBWkayloda+sZjVJL+e9Gl0k1SyTgcswU= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.19 h1:/sECfyq2JTifMI2JPyZ4bdRN77zJmr6SrS1eL3augIA= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.19/go.mod h1:dMf8A5oAqr9/oxOfLkC/c2LU/uMcALP0Rgn2BD5LWn0= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.19 h1:AWeJMk33GTBf6J20XJe6qZoRSJo0WfUhsMdUKhoODXE= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.19/go.mod h1:+GWrYoaAsV7/4pNHpwh1kiNLXkKaSoppxQq9lbH8Ejw= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.5 h1:clHU5fm//kWS1C2HgtgWxfQbFbx4b6rx+5jzhgX9HrI= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.5/go.mod h1:O3h0IK87yXci+kg6flUKzJnWeziQUKciKrLjcatSNcY= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.6 h1:XAq62tBTJP/85lFD5oqOOe7YYgWxY9LvWq8plyDvDVg= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.6/go.mod h1:x0nZssQ3qZSnIcePWLvcoFisRXJzcTVvYpAAdYX8+GI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.19 h1:X1Tow7suZk9UCJHE1Iw9GMZJJl0dAnKXXP1NaSDHwmw= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.19/go.mod h1:/rARO8psX+4sfjUQXp5LLifjUt8DuATZ31WptNJTyQA= +github.com/aws/aws-sdk-go-v2/service/signin v1.0.7 h1:Y2cAXlClHsXkkOvWZFXATr34b0hxxloeQu/pAZz2row= +github.com/aws/aws-sdk-go-v2/service/signin v1.0.7/go.mod h1:idzZ7gmDeqeNrSPkdbtMp9qWMgcBwykA7P7Rzh5DXVU= +github.com/aws/aws-sdk-go-v2/service/sso v1.30.12 h1:iSsvB9EtQ09YrsmIc44Heqlx5ByGErqhPK1ZQLppias= +github.com/aws/aws-sdk-go-v2/service/sso v1.30.12/go.mod h1:fEWYKTRGoZNl8tZ77i61/ccwOMJdGxwOhWCkp6TXAr0= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.16 h1:EnUdUqRP1CNzt2DkV67tJx6XDN4xlfBFm+bzeNOQVb0= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.16/go.mod h1:Jic/xv0Rq/pFNCh3WwpH4BEqdbSAl+IyHro8LbibHD8= +github.com/aws/aws-sdk-go-v2/service/sts v1.41.8 h1:XQTQTF75vnug2TXS8m7CVJfC2nniYPZnO1D4Np761Oo= +github.com/aws/aws-sdk-go-v2/service/sts v1.41.8/go.mod h1:Xgx+PR1NUOjNmQY+tRMnouRp83JRM8pRMw/vCaVhPkI= +github.com/aws/smithy-go v1.24.2 h1:FzA3bu/nt/vDvmnkg+R8Xl46gmzEDam6mZ1hzmwXFng= +github.com/aws/smithy-go v1.24.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.4.0 h1:TKnLPh7IbnizJIBKFWa9mKayRUBQ9Kh1BPCk6w2PnYM= @@ -88,18 +88,18 @@ github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834 h1:ZR7e0r github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834/go.mod h1:aKC/t2arECF6rNOnaKaVU6y4t4ZeHQzqfxedE/VkVhA= github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig= github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw= -github.com/charmbracelet/ultraviolet v0.0.0-20260223171050-89c142e4aa73 h1:Af/L28Xh+pddhouT/6lJ7IAIYfu5tWJOB0iqt+mXsYM= -github.com/charmbracelet/ultraviolet v0.0.0-20260223171050-89c142e4aa73/go.mod h1:E6/0abq9uG2SnM8IbLB9Y5SW09uIgfaFETk8aRzgXUQ= +github.com/charmbracelet/ultraviolet v0.0.0-20260303162955-0b88c25f3fff h1:uY7A6hTokHPJBHfq7rj9Y/wm+IAjOghZTxKfVW6QLvw= +github.com/charmbracelet/ultraviolet v0.0.0-20260303162955-0b88c25f3fff/go.mod h1:E6/0abq9uG2SnM8IbLB9Y5SW09uIgfaFETk8aRzgXUQ= github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8= github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ= github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI= github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q= -github.com/charmbracelet/x/exp/charmtone v0.0.0-20260223200540-d6a276319c45 h1:t/EWU3ZOrVxmr2d19f+1wnWr92p1O82oOTm7ASxodsA= -github.com/charmbracelet/x/exp/charmtone v0.0.0-20260223200540-d6a276319c45/go.mod h1:nsExn0DGyX0lh9LwLHTn2Gg+hafdzfSXnC+QmEJTZFY= +github.com/charmbracelet/x/exp/charmtone v0.0.0-20260305213658-fe36e8c10185 h1:/192monmpmRICpSPrFRzkIO+xfhioV6/nwrQdkDTj10= +github.com/charmbracelet/x/exp/charmtone v0.0.0-20260305213658-fe36e8c10185/go.mod h1:nsExn0DGyX0lh9LwLHTn2Gg+hafdzfSXnC+QmEJTZFY= github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA= github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I= -github.com/charmbracelet/x/exp/slice v0.0.0-20260223200540-d6a276319c45 h1:jgQlAnMmwbjtvd91AzjWWFtwpIZ2P/Nspx5zyrhmPec= -github.com/charmbracelet/x/exp/slice v0.0.0-20260223200540-d6a276319c45/go.mod h1:vqEfX6xzqW1pKKZUUiFOKg0OQ7bCh54Q2vR/tserrRA= +github.com/charmbracelet/x/exp/slice v0.0.0-20260305213658-fe36e8c10185 h1:bloHJLweYZeIkBVgi8AF94DrTdx3eoEB57VOpFuFi3U= +github.com/charmbracelet/x/exp/slice v0.0.0-20260305213658-fe36e8c10185/go.mod h1:vqEfX6xzqW1pKKZUUiFOKg0OQ7bCh54Q2vR/tserrRA= github.com/charmbracelet/x/json v0.2.0 h1:DqB+ZGx2h+Z+1s98HOuOyli+i97wsFQIxP2ZQANTPrQ= github.com/charmbracelet/x/json v0.2.0/go.mod h1:opFIflx2YgXgi49xVUu8gEQ21teFAxyMwvOiZhIvWNM= github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk= @@ -134,8 +134,8 @@ github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433 h1:vymEbVwYFP/L05h5TKQxvkXoKxNvTpjxYKdF1Nlwuao= github.com/go-json-experiment/json v0.0.0-20260214004413-d219187c3433/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg= -github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= -github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logfmt/logfmt v0.6.1 h1:4hvbpePJKnIzH1B+8OR/JPbTx37NktoI9LE2QZBBkvE= +github.com/go-logfmt/logfmt v0.6.1/go.mod h1:EV2pOAQoZaT1ZXZbqDl5hrymndi4SY9ED9/z6CO0XAk= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -155,8 +155,8 @@ github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0= github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.3.12 h1:Fg+zsqzYEs1ZnvmcztTYxhgCBsx3eEhEwQ1W/lHq/sQ= -github.com/googleapis/enterprise-certificate-proxy v0.3.12/go.mod h1:vqVt9yG9480NtzREnTlmGSBmFrA+bzb0yl0TxoBQXOg= +github.com/googleapis/enterprise-certificate-proxy v0.3.14 h1:yh8ncqsbUY4shRD5dA6RlzjJaT4hi3kII+zYw8wmLb8= +github.com/googleapis/enterprise-certificate-proxy v0.3.14/go.mod h1:vqVt9yG9480NtzREnTlmGSBmFrA+bzb0yl0TxoBQXOg= github.com/googleapis/gax-go/v2 v2.17.0 h1:RksgfBpxqff0EZkDWYuz9q/uWsTVz+kf43LsZ1J6SMc= github.com/googleapis/gax-go/v2 v2.17.0/go.mod h1:mzaqghpQp4JDh3HvADwrat+6M3MOIDp5YKHhb9PAgDY= github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= @@ -169,12 +169,12 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E= github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= -github.com/kaptinlin/go-i18n v0.2.11 h1:OayNt8mWt8nDaqAOp09/C1VG9Y5u8LpQnnxbyGARDV4= -github.com/kaptinlin/go-i18n v0.2.11/go.mod h1:pVcu9qsW5pOIOoZFJXesRYmLos1vMQrby70JPAoWmJU= -github.com/kaptinlin/jsonpointer v0.4.16 h1:Ux4w4FY+uLv+K+TxaCJtM/TpPv+1+eS6gH4Z9/uhOuA= -github.com/kaptinlin/jsonpointer v0.4.16/go.mod h1:SsfsjqnHG5zuKo1DTBzk1VknaHlL4osHw+X9kZKukpU= -github.com/kaptinlin/jsonschema v0.7.3 h1:kyIydij76ORiSxmfy0xFYy0cOx8MwG6pyyaSoQshsK4= -github.com/kaptinlin/jsonschema v0.7.3/go.mod h1:Ys6zr+W6/1330FzZEouFrAYImK+AmYt5HQVTHQQXQo8= +github.com/kaptinlin/go-i18n v0.2.12 h1:ywDsvb4KDFddMC2dpI/rrIzGU2mWUSvHmWUm9BMsdl4= +github.com/kaptinlin/go-i18n v0.2.12/go.mod h1:pVcu9qsW5pOIOoZFJXesRYmLos1vMQrby70JPAoWmJU= +github.com/kaptinlin/jsonpointer v0.4.17 h1:mY9k8ciWncxbsECyaxKnR0MdmxamNdp2tLQkAKVrtSk= +github.com/kaptinlin/jsonpointer v0.4.17/go.mod h1:SsfsjqnHG5zuKo1DTBzk1VknaHlL4osHw+X9kZKukpU= +github.com/kaptinlin/jsonschema v0.7.5 h1:jkK4a3NyzNoGlvu12CsL3IcqNMVa5sL51HPVa0nWcPY= +github.com/kaptinlin/jsonschema v0.7.5/go.mod h1:3gIWnptl+SWMyfMR2r4TXXd0xsQZ1m50AKrwmcUONSg= github.com/kaptinlin/messageformat-go v0.4.18 h1:RBlHVWgZyoxTcUgGWBsl2AcyScq/urqbLZvzgryTmSI= github.com/kaptinlin/messageformat-go v0.4.18/go.mod h1:ntI3154RnqJgr7GaC+vZBnIExl2V3sv9selvRNNEM24= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -187,8 +187,8 @@ github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQ github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mailru/easyjson v0.9.1 h1:LbtsOm5WAswyWbvTEOqhypdPeZzHavpZx96/n553mR8= github.com/mailru/easyjson v0.9.1/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= -github.com/mark3labs/mcp-go v0.44.0 h1:OlYfcVviAnwNN40QZUrrzU0QZjq3En7rCU5X09a/B7I= -github.com/mark3labs/mcp-go v0.44.0/go.mod h1:YnJfOL382MIWDx1kMY+2zsRHU/q78dBg9aFb8W6Thdw= +github.com/mark3labs/mcp-go v0.44.1 h1:2PKppYlT9X2fXnE8SNYQLAX4hNjfPB0oNLqQVcN6mE8= +github.com/mark3labs/mcp-go v0.44.1/go.mod h1:YnJfOL382MIWDx1kMY+2zsRHU/q78dBg9aFb8W6Thdw= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= @@ -269,28 +269,28 @@ github.com/yuin/goldmark-emoji v1.0.6 h1:QWfF2FYaXwL74tfGOW5izeiZepUDroDJfWubQI9 github.com/yuin/goldmark-emoji v1.0.6/go.mod h1:ukxJDKFpdFb5x0a5HqbdlcKtebh086iJpI31LTKmWuA= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.65.0 h1:XmiuHzgJt067+a6kwyAzkhXooYVv3/TOw9cM2VfJgUM= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.65.0/go.mod h1:KDgtbWKTQs4bM+VPUr6WlL9m/WXcmkCcBlIzqxPGzmI= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0 h1:7iP2uCb7sGddAr30RRS6xjKy7AZ2JtTOPA3oolgVSw8= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0/go.mod h1:c7hN3ddxs/z6q9xwvfLPk+UHlWRQyaeR1LdgfL/66l0= -go.opentelemetry.io/otel v1.40.0 h1:oA5YeOcpRTXq6NN7frwmwFR0Cn3RhTVZvXsP4duvCms= -go.opentelemetry.io/otel v1.40.0/go.mod h1:IMb+uXZUKkMXdPddhwAHm6UfOwJyh4ct1ybIlV14J0g= -go.opentelemetry.io/otel/metric v1.40.0 h1:rcZe317KPftE2rstWIBitCdVp89A2HqjkxR3c11+p9g= -go.opentelemetry.io/otel/metric v1.40.0/go.mod h1:ib/crwQH7N3r5kfiBZQbwrTge743UDc7DTFVZrrXnqc= -go.opentelemetry.io/otel/sdk v1.40.0 h1:KHW/jUzgo6wsPh9At46+h4upjtccTmuZCFAc9OJ71f8= -go.opentelemetry.io/otel/sdk v1.40.0/go.mod h1:Ph7EFdYvxq72Y8Li9q8KebuYUr2KoeyHx0DRMKrYBUE= -go.opentelemetry.io/otel/sdk/metric v1.40.0 h1:mtmdVqgQkeRxHgRv4qhyJduP3fYJRMX4AtAlbuWdCYw= -go.opentelemetry.io/otel/sdk/metric v1.40.0/go.mod h1:4Z2bGMf0KSK3uRjlczMOeMhKU2rhUqdWNoKcYrtcBPg= -go.opentelemetry.io/otel/trace v1.40.0 h1:WA4etStDttCSYuhwvEa8OP8I5EWu24lkOzp+ZYblVjw= -go.opentelemetry.io/otel/trace v1.40.0/go.mod h1:zeAhriXecNGP/s2SEG3+Y8X9ujcJOTqQ5RgdEJcawiA= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.66.0 h1:w/o339tDd6Qtu3+ytwt+/jon2yjAs3Ot8Xq8pelfhSo= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.66.0/go.mod h1:pdhNtM9C4H5fRdrnwO7NjxzQWhKSSxCHk/KluVqDVC0= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.66.0 h1:PnV4kVnw0zOmwwFkAzCN5O07fw1YOIQor120zrh0AVo= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.66.0/go.mod h1:ofAwF4uinaf8SXdVzzbL4OsxJ3VfeEg3f/F6CeF49/Y= +go.opentelemetry.io/otel v1.41.0 h1:YlEwVsGAlCvczDILpUXpIpPSL/VPugt7zHThEMLce1c= +go.opentelemetry.io/otel v1.41.0/go.mod h1:Yt4UwgEKeT05QbLwbyHXEwhnjxNO6D8L5PQP51/46dE= +go.opentelemetry.io/otel/metric v1.41.0 h1:rFnDcs4gRzBcsO9tS8LCpgR0dxg4aaxWlJxCno7JlTQ= +go.opentelemetry.io/otel/metric v1.41.0/go.mod h1:xPvCwd9pU0VN8tPZYzDZV/BMj9CM9vs00GuBjeKhJps= +go.opentelemetry.io/otel/sdk v1.41.0 h1:YPIEXKmiAwkGl3Gu1huk1aYWwtpRLeskpV+wPisxBp8= +go.opentelemetry.io/otel/sdk v1.41.0/go.mod h1:ahFdU0G5y8IxglBf0QBJXgSe7agzjE4GiTJ6HT9ud90= +go.opentelemetry.io/otel/sdk/metric v1.41.0 h1:siZQIYBAUd1rlIWQT2uCxWJxcCO7q3TriaMlf08rXw8= +go.opentelemetry.io/otel/sdk/metric v1.41.0/go.mod h1:HNBuSvT7ROaGtGI50ArdRLUnvRTRGniSUZbxiWxSO8Y= +go.opentelemetry.io/otel/trace v1.41.0 h1:Vbk2co6bhj8L59ZJ6/xFTskY+tGAbOnCtQGVVa9TIN0= +go.opentelemetry.io/otel/trace v1.41.0/go.mod h1:U1NU4ULCoxeDKc09yCWdWe+3QoyweJcISEVa1RBzOis= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts= golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos= golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa h1:Zt3DZoOFFYkKhDT3v7Lm9FDMEV06GpzjG2jrqW+QTE0= golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa/go.mod h1:K79w1Vqn7PoiZn+TkNpx3BUWUQksGO3JcVX6qIjytmA= -golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60= -golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM= +golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo= +golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y= golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ= golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= @@ -308,12 +308,12 @@ gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/api v0.269.0 h1:qDrTOxKUQ/P0MveH6a7vZ+DNHxJQjtGm/uvdbdGXCQg= google.golang.org/api v0.269.0/go.mod h1:N8Wpcu23Tlccl0zSHEkcAZQKDLdquxK+l9r2LkwAauE= -google.golang.org/genai v1.47.0 h1:iWCS7gEdO6rctOqfCYLOrZGKu2D+N42aTnCEcBvB1jo= -google.golang.org/genai v1.47.0/go.mod h1:A3kkl0nyBjyFlNjgxIwKq70julKbIxpSxqKO5gw/gmk= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260223185530-2f722ef697dc h1:51Wupg8spF+5FC6D+iMKbOddFjMckETnNnEiZ+HX37s= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260223185530-2f722ef697dc/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= -google.golang.org/grpc v1.79.1 h1:zGhSi45ODB9/p3VAawt9a+O/MULLl9dpizzNNpq7flY= -google.golang.org/grpc v1.79.1/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ= +google.golang.org/genai v1.49.0 h1:Se+QJaH2GYK1aaR1o5S38mlU2GD5FnVvP76nfkV7LH0= +google.golang.org/genai v1.49.0/go.mod h1:A3kkl0nyBjyFlNjgxIwKq70julKbIxpSxqKO5gw/gmk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 h1:ggcbiqK8WWh6l1dnltU4BgWGIGo+EVYxCaAPih/zQXQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= +google.golang.org/grpc v1.79.2 h1:fRMD94s2tITpyJGtBBn7MkMseNpOZU8ZxgC3MMBaXRU= +google.golang.org/grpc v1.79.2/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/ui/commands.go b/internal/ui/commands.go index 09d8923b..5137f790 100644 --- a/internal/ui/commands.go +++ b/internal/ui/commands.go @@ -66,6 +66,12 @@ var SlashCommands = []SlashCommand{ Category: "System", Aliases: []string{"/co"}, }, + { + Name: "/model", + Description: "Switch to a different model", + Category: "System", + Aliases: []string{"/m"}, + }, { Name: "/quit", Description: "Exit the application", diff --git a/internal/ui/model.go b/internal/ui/model.go index 6057771d..19ca9f81 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -38,6 +38,9 @@ const ( // stateOverlay means an extension-triggered modal overlay dialog is active. // The overlay takes over the full view until the user completes or cancels. stateOverlay + + // stateModelSelector means the /model selector overlay is active. + stateModelSelector ) // AppController is the interface the parent TUI model uses to interact with the @@ -307,6 +310,17 @@ type AppModelOptions struct { // commands. Called on WidgetUpdateEvent to refresh the command list // after an extension hot-reload. May be nil if no extensions loaded. GetExtensionCommands func() []ExtensionCommand + + // SetModel changes the active model at runtime. The model string uses + // "provider/model" format (e.g. "anthropic/claude-sonnet-4-5-20250929"). + // Returns an error if the model string is invalid or the provider cannot + // be created. May be nil if model switching is not supported. + SetModel func(modelString string) error + + // EmitModelChange fires the OnModelChange extension event after a + // successful model switch. Parameters are (newModel, previousModel, source). + // May be nil if extensions are not loaded. + EmitModelChange func(newModel, previousModel, source string) } // AppModel is the root Bubble Tea model for the interactive TUI. It owns the @@ -436,6 +450,16 @@ type AppModel struct { // to refresh the command list after an extension hot-reload. May be nil. getExtensionCommands func() []ExtensionCommand + // setModel changes the active model at runtime. Wired from cmd/root.go. + // May be nil if model switching is not supported. + setModel func(modelString string) error + + // emitModelChange fires the OnModelChange extension event. May be nil. + emitModelChange func(newModel, previousModel, source string) + + // modelSelector is the model selection overlay, active in stateModelSelector. + modelSelector *ModelSelectorComponent + // prompt holds the state of an active interactive prompt overlay. Nil // when no prompt is active. Managed by updatePromptState(). prompt *promptOverlay @@ -559,6 +583,8 @@ func NewAppModel(appCtrl AppController, opts AppModelOptions) *AppModel { m.emitBeforeSessionSwitch = opts.EmitBeforeSessionSwitch m.getGlobalShortcuts = opts.GetGlobalShortcuts m.getExtensionCommands = opts.GetExtensionCommands + m.setModel = opts.SetModel + m.emitModelChange = opts.EmitModelChange // Store context/skills metadata and tool counts for startup display. m.contextPaths = opts.ContextPaths @@ -762,6 +788,39 @@ func (m *AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.state = stateInput return m, nil + // ── Model selector events ──────────────────────────────────────────────── + case ModelSelectedMsg: + m.modelSelector = nil + m.state = stateInput + if m.setModel != nil { + previousModel := m.providerName + "/" + m.modelName + if err := m.setModel(msg.ModelString); err != nil { + cmds = append(cmds, m.printSystemMessage(fmt.Sprintf("Failed to switch model: %v", err))) + } else { + // Update display state directly — we cannot use + // NotifyModelChanged (prog.Send) from inside Update() + // without deadlocking BubbleTea. + parts := strings.SplitN(msg.ModelString, "/", 2) + if len(parts) == 2 { + m.providerName = parts[0] + m.modelName = parts[1] + } + cmds = append(cmds, m.printSystemMessage(fmt.Sprintf("Switched to %s", msg.ModelString))) + if m.emitModelChange != nil { + emit := m.emitModelChange + newModel := msg.ModelString + prev := previousModel + go emit(newModel, prev, "user") + } + } + } + return m, tea.Batch(cmds...) + + case ModelSelectorCancelledMsg: + m.modelSelector = nil + m.state = stateInput + return m, nil + // ── Window resize ──────────────────────────────────────────────────────── case tea.WindowSizeMsg: m.width = msg.Width @@ -820,6 +879,14 @@ func (m *AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Batch(cmds...) } + // Route to model selector when active. + if m.state == stateModelSelector && m.modelSelector != nil { + updated, cmd := m.modelSelector.Update(msg) + m.modelSelector = updated.(*ModelSelectorComponent) + cmds = append(cmds, cmd) + return m, tea.Batch(cmds...) + } + switch msg.String() { case "esc": if m.state == stateWorking { @@ -901,14 +968,23 @@ func (m *AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Batch(cmds...) } - // /compact supports optional args: "/compact Focus on API decisions". + // /compact and /model support optional args (e.g. "/compact Focus on API", + // "/model anthropic/claude-haiku-3-5-20241022"). // GetCommandByName won't match the full text, so check the prefix. if name, args, ok := strings.Cut(msg.Text, " "); ok { - if sc := GetCommandByName(name); sc != nil && sc.Name == "/compact" { - if cmd := m.handleCompactCommand(strings.TrimSpace(args)); cmd != nil { - cmds = append(cmds, cmd) + if sc := GetCommandByName(name); sc != nil { + switch sc.Name { + case "/compact": + if cmd := m.handleCompactCommand(strings.TrimSpace(args)); cmd != nil { + cmds = append(cmds, cmd) + } + return m, tea.Batch(cmds...) + case "/model": + if cmd := m.handleModelCommand(strings.TrimSpace(args)); cmd != nil { + cmds = append(cmds, cmd) + } + return m, tea.Batch(cmds...) } - return m, tea.Batch(cmds...) } } @@ -1256,6 +1332,11 @@ func (m *AppModel) View() tea.View { return m.treeSelector.View() } + // Model selector overlay replaces the normal layout. + if m.state == stateModelSelector && m.modelSelector != nil { + return m.modelSelector.View() + } + // Overlay dialog replaces the normal layout. if m.state == stateOverlay && m.overlay != nil { return tea.NewView(m.overlay.Render()) @@ -1595,6 +1676,8 @@ func (m *AppModel) handleSlashCommand(sc *SlashCommand) tea.Cmd { return m.printUsageMessage() case "/reset-usage": return m.printResetUsage() + case "/model": + return m.handleModelCommand("") case "/compact": return m.handleCompactCommand("") case "/clear": @@ -2023,6 +2106,50 @@ func remapKey(name string) (tea.KeyPressMsg, bool) { } } +// -------------------------------------------------------------------------- +// Model command handler +// -------------------------------------------------------------------------- + +// handleModelCommand handles the /model slash command. With no arguments, it +// opens an interactive model selector overlay with fuzzy finding. With an +// argument (e.g. "/model anthropic/claude-haiku-3-5-20241022"), it switches +// to that model directly. +func (m *AppModel) handleModelCommand(args string) tea.Cmd { + if m.setModel == nil { + return m.printSystemMessage("Model switching is not available.") + } + + if args == "" { + // Open the interactive model selector. + currentModel := m.providerName + "/" + m.modelName + m.modelSelector = NewModelSelector(currentModel, m.width, m.height) + m.state = stateModelSelector + return nil + } + + // Direct model switch with the provided model string. + previousModel := m.providerName + "/" + m.modelName + if err := m.setModel(args); err != nil { + return m.printSystemMessage(fmt.Sprintf("Failed to switch model: %v", err)) + } + + // Update display state directly (cannot use prog.Send from Update). + parts := strings.SplitN(args, "/", 2) + if len(parts) == 2 { + m.providerName = parts[0] + m.modelName = parts[1] + } + + if m.emitModelChange != nil { + emit := m.emitModelChange + prev := previousModel + newModel := args + go emit(newModel, prev, "user") + } + + return m.printSystemMessage(fmt.Sprintf("Switched to %s", args)) +} + // -------------------------------------------------------------------------- // Tree session command handlers // -------------------------------------------------------------------------- diff --git a/internal/ui/model_selector.go b/internal/ui/model_selector.go new file mode 100644 index 00000000..78cf6dd9 --- /dev/null +++ b/internal/ui/model_selector.go @@ -0,0 +1,413 @@ +package ui + +import ( + "fmt" + "sort" + "strings" + + "charm.land/bubbles/v2/key" + tea "charm.land/bubbletea/v2" + "charm.land/lipgloss/v2" + + "github.com/mark3labs/kit/internal/models" +) + +// ModelEntry holds display metadata for a single model in the selector. +type ModelEntry struct { + Provider string + ModelID string + Name string // human-friendly name (e.g. "Claude Haiku 4.5") + ContextLimit int + Reasoning bool +} + +// ModelSelectedMsg is sent when the user selects a model from the selector. +type ModelSelectedMsg struct { + ModelString string // "provider/model-id" +} + +// ModelSelectorCancelledMsg is sent when the user cancels the selector. +type ModelSelectorCancelledMsg struct{} + +// ModelSelectorComponent is a full-screen Bubble Tea component that displays +// a filterable list of available models. It follows the same pattern as +// TreeSelectorComponent: inline text search, scrolling list, and custom +// messages for result delivery. +type ModelSelectorComponent struct { + allModels []ModelEntry // all available models (pre-sorted) + filtered []ModelEntry // subset matching the current search + cursor int + search string + currentModel string // "provider/model" of the active model (for checkmark) + width int + height int + active bool +} + +// NewModelSelector creates a model selector populated from the global registry, +// filtered to only providers with configured API keys. +func NewModelSelector(currentModel string, width, height int) *ModelSelectorComponent { + registry := models.GetGlobalRegistry() + var allModels []ModelEntry + + for _, providerID := range registry.GetFantasyProviders() { + // Only include providers with valid API keys configured. + if err := registry.ValidateEnvironment(providerID, ""); err != nil { + continue + } + + modelsMap, err := registry.GetModelsForProvider(providerID) + if err != nil { + continue + } + + for modelID, info := range modelsMap { + allModels = append(allModels, ModelEntry{ + Provider: providerID, + ModelID: modelID, + Name: info.Name, + ContextLimit: info.Limit.Context, + Reasoning: info.Reasoning, + }) + } + } + + // Sort: alphabetically by model ID, grouped by provider. + sort.Slice(allModels, func(i, j int) bool { + if allModels[i].Provider != allModels[j].Provider { + return allModels[i].Provider < allModels[j].Provider + } + return allModels[i].ModelID < allModels[j].ModelID + }) + + ms := &ModelSelectorComponent{ + allModels: allModels, + filtered: allModels, + currentModel: currentModel, + width: width, + height: height, + active: true, + } + + // Position cursor on the current model if found. + for i, m := range ms.filtered { + if m.Provider+"/"+m.ModelID == currentModel { + ms.cursor = i + break + } + } + + return ms +} + +// Init implements tea.Model. +func (ms *ModelSelectorComponent) Init() tea.Cmd { + return nil +} + +// Update implements tea.Model. +func (ms *ModelSelectorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case tea.WindowSizeMsg: + ms.width = msg.Width + ms.height = msg.Height + return ms, nil + + case tea.KeyPressMsg: + switch { + case key.Matches(msg, key.NewBinding(key.WithKeys("up", "k"))): + if ms.cursor > 0 { + ms.cursor-- + } + + case key.Matches(msg, key.NewBinding(key.WithKeys("down", "j"))): + if ms.cursor < len(ms.filtered)-1 { + ms.cursor++ + } + + case key.Matches(msg, key.NewBinding(key.WithKeys("pgup"))): + ms.cursor -= ms.visibleHeight() + if ms.cursor < 0 { + ms.cursor = 0 + } + + case key.Matches(msg, key.NewBinding(key.WithKeys("pgdown"))): + ms.cursor += ms.visibleHeight() + if ms.cursor >= len(ms.filtered) { + ms.cursor = len(ms.filtered) - 1 + } + if ms.cursor < 0 { + ms.cursor = 0 + } + + case key.Matches(msg, key.NewBinding(key.WithKeys("home"))): + ms.cursor = 0 + + case key.Matches(msg, key.NewBinding(key.WithKeys("end"))): + ms.cursor = max(len(ms.filtered)-1, 0) + + case key.Matches(msg, key.NewBinding(key.WithKeys("enter"))): + if ms.cursor < len(ms.filtered) { + entry := ms.filtered[ms.cursor] + ms.active = false + return ms, func() tea.Msg { + return ModelSelectedMsg{ + ModelString: entry.Provider + "/" + entry.ModelID, + } + } + } + + case key.Matches(msg, key.NewBinding(key.WithKeys("esc"))): + if ms.search != "" { + ms.search = "" + ms.rebuildFiltered() + } else { + ms.active = false + return ms, func() tea.Msg { + return ModelSelectorCancelledMsg{} + } + } + + default: + // Inline text search. + if msg.Text != "" && len(msg.Text) == 1 { + ch := msg.Text[0] + if ch >= 32 && ch < 127 { + ms.search += string(ch) + ms.rebuildFiltered() + } + } + if key.Matches(msg, key.NewBinding(key.WithKeys("backspace"))) && len(ms.search) > 0 { + ms.search = ms.search[:len(ms.search)-1] + ms.rebuildFiltered() + } + } + } + return ms, nil +} + +// View implements tea.Model. +func (ms *ModelSelectorComponent) View() tea.View { + theme := GetTheme() + + headerStyle := lipgloss.NewStyle(). + Bold(true). + Foreground(theme.Accent). + PaddingLeft(2) + + helpStyle := lipgloss.NewStyle(). + Foreground(theme.Muted). + PaddingLeft(2) + + infoStyle := lipgloss.NewStyle(). + Foreground(theme.Warning). + PaddingLeft(2) + + var b strings.Builder + + // Header. + b.WriteString(headerStyle.Render("Model Selector")) + b.WriteString("\n") + b.WriteString(helpStyle.Render("↑/↓: move enter: select esc: cancel type to filter")) + b.WriteString("\n") + b.WriteString(infoStyle.Render("Only showing models with configured API keys")) + b.WriteString("\n") + + // Search input. + searchStyle := lipgloss.NewStyle().Foreground(theme.Info).PaddingLeft(2) + if ms.search != "" { + b.WriteString(searchStyle.Render(fmt.Sprintf("> %s", ms.search))) + } else { + b.WriteString(searchStyle.Render("> ")) + } + b.WriteString("\n") + + b.WriteString(lipgloss.NewStyle().Foreground(theme.Muted).Render(strings.Repeat("─", ms.width))) + b.WriteString("\n") + + if len(ms.filtered) == 0 { + emptyStyle := lipgloss.NewStyle().Foreground(theme.Muted).PaddingLeft(2) + if ms.search != "" { + b.WriteString(emptyStyle.Render("No models matching \"" + ms.search + "\"")) + } else { + b.WriteString(emptyStyle.Render("No models available (check API keys)")) + } + b.WriteString("\n") + } else { + // Visible window. + visH := ms.visibleHeight() + startIdx := 0 + if ms.cursor >= visH { + startIdx = ms.cursor - visH + 1 + } + endIdx := min(startIdx+visH, len(ms.filtered)) + + for i := startIdx; i < endIdx; i++ { + entry := ms.filtered[i] + line := ms.renderEntry(entry, i == ms.cursor) + b.WriteString(line) + b.WriteString("\n") + } + } + + // Footer. + b.WriteString(lipgloss.NewStyle().Foreground(theme.Muted).Render(strings.Repeat("─", ms.width))) + b.WriteString("\n") + + footerParts := []string{ + fmt.Sprintf("(%d/%d)", ms.cursor+1, len(ms.filtered)), + } + if ms.cursor < len(ms.filtered) { + entry := ms.filtered[ms.cursor] + if entry.Name != "" { + footerParts = append(footerParts, fmt.Sprintf("Model Name: %s", entry.Name)) + } + if entry.ContextLimit > 0 { + footerParts = append(footerParts, fmt.Sprintf("Context: %dK", entry.ContextLimit/1000)) + } + } + + footerStyle := lipgloss.NewStyle().Foreground(theme.Muted).PaddingLeft(2) + b.WriteString(footerStyle.Render(strings.Join(footerParts, " "))) + + return tea.NewView(b.String()) +} + +// IsActive returns whether the selector is still accepting input. +func (ms *ModelSelectorComponent) IsActive() bool { + return ms.active +} + +// --- Internal helpers --- + +func (ms *ModelSelectorComponent) visibleHeight() int { + // Reserve: header(1) + help(1) + info(1) + search(1) + separator(1) + footer(2) = 7 + h := max(ms.height-7, 5) + return h +} + +func (ms *ModelSelectorComponent) rebuildFiltered() { + if ms.search == "" { + ms.filtered = ms.allModels + } else { + query := strings.ToLower(ms.search) + ms.filtered = ms.filtered[:0] + + type scored struct { + entry ModelEntry + score int + } + var matches []scored + + for _, entry := range ms.allModels { + s := ms.fuzzyScoreModel(query, entry) + if s > 0 { + matches = append(matches, scored{entry: entry, score: s}) + } + } + + // Sort by score descending, then alphabetically. + sort.Slice(matches, func(i, j int) bool { + if matches[i].score != matches[j].score { + return matches[i].score > matches[j].score + } + return matches[i].entry.ModelID < matches[j].entry.ModelID + }) + + ms.filtered = make([]ModelEntry, len(matches)) + for i, m := range matches { + ms.filtered[i] = m.entry + } + } + + // Clamp cursor. + if ms.cursor >= len(ms.filtered) { + ms.cursor = max(len(ms.filtered)-1, 0) + } +} + +// fuzzyScoreModel scores a model entry against the search query. +func (ms *ModelSelectorComponent) fuzzyScoreModel(query string, entry ModelEntry) int { + modelID := strings.ToLower(entry.ModelID) + provider := strings.ToLower(entry.Provider) + name := strings.ToLower(entry.Name) + combined := provider + "/" + modelID + + // Exact match on combined provider/model. + if combined == query { + return 1000 + } + + // Exact match on model ID. + if modelID == query { + return 950 + } + + // Prefix match on model ID. + if strings.HasPrefix(modelID, query) { + return 800 - len(modelID) + len(query) + } + + // Prefix match on combined. + if strings.HasPrefix(combined, query) { + return 750 - len(combined) + len(query) + } + + // Contains match on model ID. + if strings.Contains(modelID, query) { + return 600 + } + + // Contains match on combined. + if strings.Contains(combined, query) { + return 550 + } + + // Contains match on name. + if strings.Contains(name, query) { + return 400 + } + + // Character-by-character fuzzy match on model ID. + if s := fuzzyCharacterMatch(query, modelID); s > 0 { + return s + } + + // Fuzzy match on combined. + if s := fuzzyCharacterMatch(query, combined); s > 0 { + return s - 20 + } + + return 0 +} + +func (ms *ModelSelectorComponent) renderEntry(entry ModelEntry, isCursor bool) string { + theme := GetTheme() + modelStr := entry.ModelID + providerStr := fmt.Sprintf("[%s]", entry.Provider) + + // Cursor indicator. + var cursor string + if isCursor { + cursor = lipgloss.NewStyle().Foreground(theme.Accent).Render("-> ") + } else { + cursor = " " + } + + // Active model checkmark. + var active string + if entry.Provider+"/"+entry.ModelID == ms.currentModel { + active = lipgloss.NewStyle().Foreground(theme.Success).Render(" \u2713") + } + + // Style the model ID. + modelStyle := lipgloss.NewStyle().Foreground(theme.Text) + if isCursor { + modelStyle = modelStyle.Bold(true).Foreground(theme.Accent) + } + + // Style the provider tag. + providerStyle := lipgloss.NewStyle().Foreground(theme.Muted) + + return cursor + modelStyle.Render(modelStr) + " " + providerStyle.Render(providerStr) + active +}