Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow unknown toolsets to be ignored#1202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
omgitsads merged 4 commits intomainfromignore-not-found-tools
Oct 10, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletioninternal/ghmcp/server.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,7 +142,7 @@ func NewMCPServer(cfg MCPServerConfig) (*server.MCPServer, error) {

// Create default toolsets
tsg := github.DefaultToolsetGroup(cfg.ReadOnly, getClient, getGQLClient, getRawClient, cfg.Translator, cfg.ContentWindowSize)
err = tsg.EnableToolsets(enabledToolsets)
err = tsg.EnableToolsets(enabledToolsets, nil)

if err != nil {
return nil, fmt.Errorf("failed to enable toolsets: %w", err)
Expand Down
16 changes: 13 additions & 3 deletionspkg/toolsets/toolsets.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,23 +203,33 @@ func (tg *ToolsetGroup) IsEnabled(name string) bool {
return feature.Enabled
}

func (tg *ToolsetGroup) EnableToolsets(names []string) error {
type EnableToolsetsOptions struct {
ErrorOnUnknown bool
}

func (tg *ToolsetGroup) EnableToolsets(names []string, options *EnableToolsetsOptions) error {
if options == nil {
options = &EnableToolsetsOptions{
ErrorOnUnknown: false,
}
}

// Special case for "all"
for _, name := range names {
if name == "all" {
tg.everythingOn = true
break
}
err := tg.EnableToolset(name)
if err != nil {
if err != nil&& options.ErrorOnUnknown{
return err
}
}
// Do this after to ensure all toolsets are enabled if "all" is present anywhere in list
if tg.everythingOn {
for name := range tg.Toolsets {
err := tg.EnableToolset(name)
if err != nil {
if err != nil&& options.ErrorOnUnknown{
return err
}
}
Expand Down
28 changes: 20 additions & 8 deletionspkg/toolsets/toolsets_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -134,7 +134,7 @@ func TestEnableToolsets(t *testing.T) {
tsg.AddToolset(toolset2)

// Test enabling multiple toolsets
err := tsg.EnableToolsets([]string{"toolset1", "toolset2"})
err := tsg.EnableToolsets([]string{"toolset1", "toolset2"}, &EnableToolsetsOptions{})
if err != nil {
t.Errorf("Expected no error when enabling toolsets, got: %v", err)
}
Expand All@@ -148,7 +148,19 @@ func TestEnableToolsets(t *testing.T) {
}

// Test with non-existent toolset in the list
err = tsg.EnableToolsets([]string{"toolset1", "non-existent"})
err = tsg.EnableToolsets([]string{"toolset1", "non-existent"}, nil)
if err != nil {
t.Errorf("Expected no error when ignoring unknown toolsets, got: %v", err)
}

err = tsg.EnableToolsets([]string{"toolset1", "non-existent"}, &EnableToolsetsOptions{
ErrorOnUnknown: false,
})
if err != nil {
t.Errorf("Expected no error when ignoring unknown toolsets, got: %v", err)
}

err = tsg.EnableToolsets([]string{"toolset1", "non-existent"}, &EnableToolsetsOptions{ErrorOnUnknown: true})
if err == nil {
t.Error("Expected error when enabling list with non-existent toolset")
}
Expand All@@ -157,14 +169,14 @@ func TestEnableToolsets(t *testing.T) {
}

// Test with empty list
err = tsg.EnableToolsets([]string{})
err = tsg.EnableToolsets([]string{}, &EnableToolsetsOptions{})
if err != nil {
t.Errorf("Expected no error with empty toolset list, got: %v", err)
}

// Test enabling everything through EnableToolsets
tsg = NewToolsetGroup(false)
err = tsg.EnableToolsets([]string{"all"})
err = tsg.EnableToolsets([]string{"all"}, &EnableToolsetsOptions{})
if err != nil {
t.Errorf("Expected no error when enabling 'all', got: %v", err)
}
Expand All@@ -187,14 +199,14 @@ func TestEnableEverything(t *testing.T) {
}

// Enable "all"
err := tsg.EnableToolsets([]string{"all"})
err := tsg.EnableToolsets([]string{"all"}, &EnableToolsetsOptions{})
if err != nil {
t.Errorf("Expected no error when enabling 'eall', got: %v", err)
t.Errorf("Expected no error when enabling 'all', got: %v", err)
}

// Verify everythingOn was set
if !tsg.everythingOn {
t.Error("Expected everythingOn to be true after enabling 'eall'")
t.Error("Expected everythingOn to be true after enabling 'all'")
}

// Verify the previously disabled toolset is now enabled
Expand All@@ -212,7 +224,7 @@ func TestIsEnabledWithEverythingOn(t *testing.T) {
tsg := NewToolsetGroup(false)

// Enable "all"
err := tsg.EnableToolsets([]string{"all"})
err := tsg.EnableToolsets([]string{"all"}, &EnableToolsetsOptions{})
if err != nil {
t.Errorf("Expected no error when enabling 'all', got: %v", err)
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp