Skip to content

Commit 4a3b7d6

Browse files
committed
add initial server instruction scenarios support
1 parent bbfc44c commit 4a3b7d6

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

pkg/github/instructions.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package github
22

33
import (
4+
"fmt"
45
"os"
56
"slices"
67
"strings"
@@ -20,6 +21,11 @@ func GenerateInstructions(enabledToolsets []string) string {
2021
instructions = append(instructions, "Always call 'get_me' first to understand current user permissions and context.")
2122
}
2223

24+
generalInstructions := getGeneralInstructions(enabledToolsets)
25+
if generalInstructions != "" {
26+
instructions = append(instructions, "Here are common scenarios you may encounter followed by name and description of the steps to follow:", generalInstructions)
27+
}
28+
2329
// Individual toolset instructions
2430
for _, toolset := range enabledToolsets {
2531
if inst := getToolsetInstructions(toolset); inst != "" {
@@ -47,6 +53,52 @@ Tool usage guidance:
4753
return strings.Join(allInstructions, " ")
4854
}
4955

56+
// scenarioDefinition defines a scenario with its instruction text and required toolsets
57+
type scenarioDefinition struct {
58+
instruction string
59+
requiredToolsets []string
60+
}
61+
62+
// getGeneralInstructions returns scenario-based guidance for common development tasks
63+
func getGeneralInstructions(enabledToolsets []string) string {
64+
enabledSet := make(map[string]bool)
65+
for _, ts := range enabledToolsets {
66+
enabledSet[ts] = true
67+
}
68+
69+
scenarios := map[string]scenarioDefinition{
70+
"Reviewing Pull Requests": {
71+
instruction: "Use get_pull_request to fetch PR details and get_pull_request_files to see changes. Use create_pending_pull_request_review to start a review, add_comment_to_pending_review for line-specific feedback, then submit_pending_pull_request_review to publish. Check get_pull_request_status to verify CI/CD checks before approving.",
72+
requiredToolsets: []string{"pull_requests"},
73+
},
74+
}
75+
76+
var parts []string
77+
parts = append(parts, "When helping with development tasks, consider these common scenarios and appropriate tool choices:")
78+
79+
// Filter scenarios based on enabled toolsets
80+
for scenarioName, scenario := range scenarios {
81+
if len(scenario.requiredToolsets) == 0 {
82+
parts = append(parts, fmt.Sprintf("%s: %s", scenarioName, scenario.instruction))
83+
continue
84+
}
85+
86+
hasAllRequiredToolsets := true
87+
for _, required := range scenario.requiredToolsets {
88+
if !enabledSet[required] {
89+
hasAllRequiredToolsets = false
90+
break
91+
}
92+
}
93+
94+
if hasAllRequiredToolsets {
95+
parts = append(parts, fmt.Sprintf("%s: %s", scenarioName, scenario.instruction))
96+
}
97+
}
98+
99+
return strings.Join(parts, " ")
100+
}
101+
50102
// getToolsetInstructions returns specific instructions for individual toolsets
51103
func getToolsetInstructions(toolset string) string {
52104
switch toolset {

0 commit comments

Comments
 (0)