Skip to content

Commit 6c883fd

Browse files
olaservoalmaleksia
authored andcommitted
Simplify changes for now
1 parent c614cfa commit 6c883fd

2 files changed

Lines changed: 4 additions & 81 deletions

File tree

pkg/github/instructions.go

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,14 @@ func GenerateInstructions(enabledToolsets []string) string {
1919
}
2020

2121
// Cross-toolset conditional instructions
22-
if contains(enabledToolsets, "pull_requests") && contains(enabledToolsets, "context") {
23-
instructions = append(instructions, "For team workflows: Use 'get_teams' and 'get_team_members' before assigning PR reviewers.")
24-
}
25-
26-
if hasAnySecurityToolset(enabledToolsets) {
27-
instructions = append(instructions, "Security alert priority: secret_scanning → dependabot → code_scanning alerts.")
28-
}
29-
3022
if contains(enabledToolsets, "issues") && contains(enabledToolsets, "pull_requests") {
3123
instructions = append(instructions, "Link issues to PRs using 'closes #123' or 'fixes #123' in PR descriptions.")
3224
}
3325

34-
if contains(enabledToolsets, "repos") && contains(enabledToolsets, "actions") {
35-
instructions = append(instructions, "For repository operations: Check workflow status before major changes using 'list_workflow_runs'.")
36-
}
37-
38-
baseInstruction := "The GitHub MCP Server provides GitHub API tools."
26+
// Base instruction with context management
27+
baseInstruction := "The GitHub MCP Server provides GitHub API tools. GitHub API responses can overflow context windows. Strategy: 1) Always prefer 'search_*' tools over 'list_*' tools when possible - search tools return filtered results, 2) Process large datasets in batches rather than all at once, 3) For summarization tasks, fetch minimal data first, then drill down into specifics, 4) When analyzing multiple items (issues, PRs, etc), process in groups of 5-10 to manage context."
3928

40-
// Add context management instruction for all configurations
41-
contextInstruction := " GitHub API responses can overflow context windows. Strategy: 1) Always prefer 'search_*' tools over 'list_*' tools when possible - search tools return filtered results, 2) Process large datasets in batches rather than all at once, 3) For summarization tasks, fetch minimal data first, then drill down into specifics, 4) When analyzing multiple items (issues, PRs, etc), process in groups of 5-10 to manage context."
42-
43-
allInstructions := []string{baseInstruction, contextInstruction}
29+
allInstructions := []string{baseInstruction}
4430
allInstructions = append(allInstructions, instructions...)
4531

4632
return strings.Join(allInstructions, " ")
@@ -68,16 +54,6 @@ func getToolsetInstructions(toolset string) string {
6854
}
6955
}
7056

71-
// hasAnySecurityToolset checks if any security-related toolsets are enabled
72-
func hasAnySecurityToolset(toolsets []string) bool {
73-
securityToolsets := []string{"code_security", "secret_protection", "dependabot"}
74-
for _, security := range securityToolsets {
75-
if contains(toolsets, security) {
76-
return true
77-
}
78-
}
79-
return false
80-
}
8157

8258
// contains checks if a slice contains a specific string
8359
func contains(slice []string, item string) bool {

pkg/github/instructions_test.go

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,12 @@ func TestGenerateInstructions(t *testing.T) {
4747
"rerun_failed_jobs",
4848
},
4949
},
50-
{
51-
name: "security toolsets",
52-
enabledToolsets: []string{"code_security", "secret_protection", "dependabot"},
53-
expectedContains: []string{
54-
"Security alert priority",
55-
"secret_scanning",
56-
"dependabot",
57-
"code_scanning",
58-
},
59-
},
6050
{
6151
name: "cross-toolset instructions",
6252
enabledToolsets: []string{"context", "pull_requests"},
6353
expectedContains: []string{
6454
"get_me",
65-
"get_teams",
66-
"get_team_members",
55+
"create_pending_pull_request_review",
6756
},
6857
},
6958
{
@@ -141,45 +130,3 @@ func TestGetToolsetInstructions(t *testing.T) {
141130
}
142131
}
143132

144-
func TestHasAnySecurityToolset(t *testing.T) {
145-
tests := []struct {
146-
name string
147-
toolsets []string
148-
expected bool
149-
}{
150-
{
151-
name: "no security toolsets",
152-
toolsets: []string{"repos", "issues"},
153-
expected: false,
154-
},
155-
{
156-
name: "has code_security",
157-
toolsets: []string{"repos", "code_security"},
158-
expected: true,
159-
},
160-
{
161-
name: "has secret_protection",
162-
toolsets: []string{"secret_protection", "issues"},
163-
expected: true,
164-
},
165-
{
166-
name: "has dependabot",
167-
toolsets: []string{"dependabot"},
168-
expected: true,
169-
},
170-
{
171-
name: "has all security toolsets",
172-
toolsets: []string{"code_security", "secret_protection", "dependabot"},
173-
expected: true,
174-
},
175-
}
176-
177-
for _, tt := range tests {
178-
t.Run(tt.name, func(t *testing.T) {
179-
result := hasAnySecurityToolset(tt.toolsets)
180-
if result != tt.expected {
181-
t.Errorf("Expected %v for toolsets %v, but got %v", tt.expected, tt.toolsets, result)
182-
}
183-
})
184-
}
185-
}

0 commit comments

Comments
 (0)