mirror of
				https://github.com/charmbracelet/crush.git
				synced 2025-08-02 05:20:46 +03:00 
			
		
		
		
	Merge remote-tracking branch 'origin/main' into list
This commit is contained in:
		@@ -116,9 +116,9 @@ Crush supports Model Context Protocol (MCP) servers through three transport type
 | 
			
		||||
    },
 | 
			
		||||
    "github": {
 | 
			
		||||
      "type": "http",
 | 
			
		||||
      "url": "https://api.githubcopilot.com/mcp/",
 | 
			
		||||
      "url": "https://example.com/mcp/",
 | 
			
		||||
      "headers": {
 | 
			
		||||
        "Authorization": "$(echo Bearer $GH_MCP_TOKEN)"
 | 
			
		||||
        "Authorization": "$(echo Bearer $EXAMPLE_MCP_TOKEN)"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "streaming-service": {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.mod
									
									
									
									
									
								
							@@ -16,7 +16,7 @@ require (
 | 
			
		||||
	github.com/charmbracelet/catwalk v0.3.1
 | 
			
		||||
	github.com/charmbracelet/fang v0.3.1-0.20250711140230-d5ebb8c1d674
 | 
			
		||||
	github.com/charmbracelet/glamour/v2 v2.0.0-20250516160903-6f1e2c8f9ebe
 | 
			
		||||
	github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.3.0.20250716211347-10c048e36112
 | 
			
		||||
	github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.3.0.20250721205738-ea66aa652ee0
 | 
			
		||||
	github.com/charmbracelet/log/v2 v2.0.0-20250226163916-c379e29ff706
 | 
			
		||||
	github.com/charmbracelet/x/ansi v0.9.3
 | 
			
		||||
	github.com/charmbracelet/x/exp/charmtone v0.0.0-20250708181618-a60a724ba6c3
 | 
			
		||||
@@ -40,7 +40,7 @@ require (
 | 
			
		||||
	github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef
 | 
			
		||||
	github.com/stretchr/testify v1.10.0
 | 
			
		||||
	github.com/tidwall/sjson v1.2.5
 | 
			
		||||
	github.com/u-root/u-root v0.14.1-0.20250722142936-bf4e78a90dfc
 | 
			
		||||
	github.com/u-root/u-root v0.14.1-0.20250724181933-b01901710169
 | 
			
		||||
	github.com/zeebo/xxh3 v1.0.2
 | 
			
		||||
	gopkg.in/natefinch/lumberjack.v2 v2.2.1
 | 
			
		||||
	mvdan.cc/sh/v3 v3.11.0
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								go.sum
									
									
									
									
									
								
							@@ -80,8 +80,8 @@ github.com/charmbracelet/fang v0.3.1-0.20250711140230-d5ebb8c1d674 h1:+Cz+VfxD5D
 | 
			
		||||
github.com/charmbracelet/fang v0.3.1-0.20250711140230-d5ebb8c1d674/go.mod h1:9gCUAHmVx5BwSafeyNr3GI0GgvlB1WYjL21SkPp1jyU=
 | 
			
		||||
github.com/charmbracelet/glamour/v2 v2.0.0-20250516160903-6f1e2c8f9ebe h1:i6ce4CcAlPpTj2ER69m1DBeLZ3RRcHnKExuwhKa3GfY=
 | 
			
		||||
github.com/charmbracelet/glamour/v2 v2.0.0-20250516160903-6f1e2c8f9ebe/go.mod h1:p3Q+aN4eQKeM5jhrmXPMgPrlKbmc59rWSnMsSA3udhk=
 | 
			
		||||
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.3.0.20250716211347-10c048e36112 h1:SyZEoqRe2oiKZI+h93lgJYXtcBgcS/OsJIOYC7KbR7s=
 | 
			
		||||
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.3.0.20250716211347-10c048e36112/go.mod h1:BXY7j7rZgAprFwzNcO698++5KTd6GKI6lU83Pr4o0r0=
 | 
			
		||||
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.3.0.20250721205738-ea66aa652ee0 h1:sWRGoSw/JsO2S4t2+fmmEkRbkOxphI0AxZkQPQVKWbs=
 | 
			
		||||
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.3.0.20250721205738-ea66aa652ee0/go.mod h1:XIuqKpZTUXtVyeyiN1k9Tc/U7EzfaDnVc34feFHfBws=
 | 
			
		||||
github.com/charmbracelet/log/v2 v2.0.0-20250226163916-c379e29ff706 h1:WkwO6Ks3mSIGnGuSdKl9qDSyfbYK50z2wc2gGMggegE=
 | 
			
		||||
github.com/charmbracelet/log/v2 v2.0.0-20250226163916-c379e29ff706/go.mod h1:mjJGp00cxcfvD5xdCa+bso251Jt4owrQvuimJtVmEmM=
 | 
			
		||||
github.com/charmbracelet/ultraviolet v0.0.0-20250723145313-809e6f5b43a1 h1:tsw1mOuIEIKlmm614bXctvJ3aavaFhyPG+y+wrKtuKQ=
 | 
			
		||||
@@ -261,8 +261,8 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
 | 
			
		||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
 | 
			
		||||
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
 | 
			
		||||
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
 | 
			
		||||
github.com/u-root/u-root v0.14.1-0.20250722142936-bf4e78a90dfc h1:HjI/UCF4dRyzizePQrhGUSQvuU7z4tOqMqz6GRGlFCM=
 | 
			
		||||
github.com/u-root/u-root v0.14.1-0.20250722142936-bf4e78a90dfc/go.mod h1:/0Qr7qJeDwWxoKku2xKQ4Szc+SwBE3g9VE8jNiamsmc=
 | 
			
		||||
github.com/u-root/u-root v0.14.1-0.20250724181933-b01901710169 h1:f4cp2yGKkMuGpCwAyNEjzcw8szgVXmemK/wfOu4l5gc=
 | 
			
		||||
github.com/u-root/u-root v0.14.1-0.20250724181933-b01901710169/go.mod h1:/0Qr7qJeDwWxoKku2xKQ4Szc+SwBE3g9VE8jNiamsmc=
 | 
			
		||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
 | 
			
		||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
 | 
			
		||||
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,6 @@ import (
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"slices"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"sync"
 | 
			
		||||
 | 
			
		||||
	"github.com/charmbracelet/catwalk/pkg/catwalk"
 | 
			
		||||
	"github.com/charmbracelet/crush/internal/csync"
 | 
			
		||||
@@ -78,8 +77,6 @@ func Load(workingDir string, debug bool) (*Config, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to configure providers: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	go cfg.removeUnresponsiveProviders()
 | 
			
		||||
 | 
			
		||||
	if !cfg.IsConfigured() {
 | 
			
		||||
		slog.Warn("No providers configured")
 | 
			
		||||
		return cfg, nil
 | 
			
		||||
@@ -92,37 +89,6 @@ func Load(workingDir string, debug bool) (*Config, error) {
 | 
			
		||||
	return cfg, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Config) removeUnresponsiveProviders() {
 | 
			
		||||
	slog.Info("Testing provider connections")
 | 
			
		||||
	defer slog.Info("Provider connection tests completed")
 | 
			
		||||
 | 
			
		||||
	// Test provider connections in parallel
 | 
			
		||||
	var wg sync.WaitGroup
 | 
			
		||||
	testResults := csync.NewMap[string, bool]()
 | 
			
		||||
	for _, p := range c.Providers.Seq2() {
 | 
			
		||||
		if p.Type != catwalk.TypeOpenAI && p.Type != catwalk.TypeAnthropic {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		wg.Add(1)
 | 
			
		||||
		go func(provider ProviderConfig) {
 | 
			
		||||
			defer wg.Done()
 | 
			
		||||
			err := provider.TestConnection(c.resolver)
 | 
			
		||||
			testResults.Set(provider.ID, err == nil)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				slog.Error("Provider connection test failed", "provider", provider.ID, "error", err)
 | 
			
		||||
			}
 | 
			
		||||
		}(p)
 | 
			
		||||
	}
 | 
			
		||||
	wg.Wait()
 | 
			
		||||
 | 
			
		||||
	// Remove failed providers
 | 
			
		||||
	for providerID, passed := range testResults.Seq2() {
 | 
			
		||||
		if !passed {
 | 
			
		||||
			c.Providers.Del(providerID)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *Config) configureProviders(env env.Env, resolver VariableResolver, knownProviders []catwalk.Provider) error {
 | 
			
		||||
	knownProviderNames := make(map[string]bool)
 | 
			
		||||
	for _, p := range knownProviders {
 | 
			
		||||
 
 | 
			
		||||
@@ -495,9 +495,7 @@ func (s *splashCmp) View() string {
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
		buttons := lipgloss.JoinHorizontal(lipgloss.Left, yesButton, "  ", noButton)
 | 
			
		||||
		infoSection := s.infoSection()
 | 
			
		||||
 | 
			
		||||
		remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2) - lipgloss.Height(infoSection)
 | 
			
		||||
		remainingHeight := s.height - lipgloss.Height(s.logoRendered) - (SplashScreenPaddingY * 2)
 | 
			
		||||
 | 
			
		||||
		initContent := t.S().Base.AlignVertical(lipgloss.Bottom).PaddingLeft(1).Height(remainingHeight).Render(
 | 
			
		||||
			lipgloss.JoinVertical(
 | 
			
		||||
@@ -511,7 +509,7 @@ func (s *splashCmp) View() string {
 | 
			
		||||
		content = lipgloss.JoinVertical(
 | 
			
		||||
			lipgloss.Left,
 | 
			
		||||
			s.logoRendered,
 | 
			
		||||
			infoSection,
 | 
			
		||||
			"",
 | 
			
		||||
			initContent,
 | 
			
		||||
		)
 | 
			
		||||
	} else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user