Skip to content

Commit 61be0e1

Browse files
committed
move instructions.go and tests from github package to inventory package
1 parent 1d8019b commit 61be0e1

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package github
1+
package inventory
22

33
import (
44
"os"
55
"slices"
66
"strings"
77
)
88

9-
// GenerateInstructions creates server instructions based on enabled toolsets
10-
func GenerateInstructions(enabledToolsets []string) string {
9+
// generateInstructions creates server instructions based on enabled toolsets
10+
func generateInstructions(enabledToolsets []ToolsetID) string {
1111
// For testing - add a flag to disable instructions
1212
if os.Getenv("DISABLE_INSTRUCTIONS") == "true" {
1313
return "" // Baseline mode
@@ -16,7 +16,7 @@ func GenerateInstructions(enabledToolsets []string) string {
1616
var instructions []string
1717

1818
// Core instruction - always included if context toolset enabled
19-
if slices.Contains(enabledToolsets, "context") {
19+
if slices.Contains(enabledToolsets, ToolsetID("context")) {
2020
instructions = append(instructions, "Always call 'get_me' first to understand current user permissions and context.")
2121
}
2222

@@ -48,27 +48,27 @@ Tool usage guidance:
4848
}
4949

5050
// getToolsetInstructions returns specific instructions for individual toolsets
51-
func getToolsetInstructions(toolset string, enabledToolsets []string) string {
51+
func getToolsetInstructions(toolset ToolsetID, enabledToolsets []ToolsetID) string {
5252
switch toolset {
53-
case "pull_requests":
53+
case ToolsetID("pull_requests"):
5454
pullRequestInstructions := `## Pull Requests
5555
5656
PR review workflow: Always use 'pull_request_review_write' with method 'create' to create a pending review, then 'add_comment_to_pending_review' to add comments, and finally 'pull_request_review_write' with method 'submit_pending' to submit the review for complex reviews with line-specific comments.`
57-
if slices.Contains(enabledToolsets, "repos") {
57+
if slices.Contains(enabledToolsets, ToolsetID("repos")) {
5858
pullRequestInstructions += `
5959
6060
Before creating a pull request, search for pull request templates in the repository. Template files are called pull_request_template.md or they're located in '.github/PULL_REQUEST_TEMPLATE' directory. Use the template content to structure the PR description and then call create_pull_request tool.`
6161
}
6262
return pullRequestInstructions
63-
case "issues":
63+
case ToolsetID("issues"):
6464
return `## Issues
6565
6666
Check 'list_issue_types' first for organizations to use proper issue types. Use 'search_issues' before creating new issues to avoid duplicates. Always set 'state_reason' when closing issues.`
67-
case "discussions":
67+
case ToolsetID("discussions"):
6868
return `## Discussions
6969
7070
Use 'list_discussion_categories' to understand available categories before creating discussions. Filter by category for better organization.`
71-
case "projects":
71+
case ToolsetID("projects"):
7272
return `## Projects
7373
7474
Workflow: 1) list_project_fields (get field IDs), 2) list_project_items (with pagination), 3) optional updates.
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package github
1+
package inventory
22

33
import (
44
"os"
@@ -9,49 +9,49 @@ import (
99
func TestGenerateInstructions(t *testing.T) {
1010
tests := []struct {
1111
name string
12-
enabledToolsets []string
12+
enabledToolsets []ToolsetID
1313
expectedEmpty bool
1414
}{
1515
{
1616
name: "empty toolsets",
17-
enabledToolsets: []string{},
17+
enabledToolsets: []ToolsetID{},
1818
expectedEmpty: false,
1919
},
2020
{
2121
name: "only context toolset",
22-
enabledToolsets: []string{"context"},
22+
enabledToolsets: []ToolsetID{"context"},
2323
expectedEmpty: false,
2424
},
2525
{
2626
name: "pull requests toolset",
27-
enabledToolsets: []string{"pull_requests"},
27+
enabledToolsets: []ToolsetID{"pull_requests"},
2828
expectedEmpty: false,
2929
},
3030
{
3131
name: "issues toolset",
32-
enabledToolsets: []string{"issues"},
32+
enabledToolsets: []ToolsetID{"issues"},
3333
expectedEmpty: false,
3434
},
3535
{
3636
name: "discussions toolset",
37-
enabledToolsets: []string{"discussions"},
37+
enabledToolsets: []ToolsetID{"discussions"},
3838
expectedEmpty: false,
3939
},
4040
{
4141
name: "multiple toolsets (context + pull_requests)",
42-
enabledToolsets: []string{"context", "pull_requests"},
42+
enabledToolsets: []ToolsetID{"context", "pull_requests"},
4343
expectedEmpty: false,
4444
},
4545
{
4646
name: "multiple toolsets (issues + pull_requests)",
47-
enabledToolsets: []string{"issues", "pull_requests"},
47+
enabledToolsets: []ToolsetID{"issues", "pull_requests"},
4848
expectedEmpty: false,
4949
},
5050
}
5151

5252
for _, tt := range tests {
5353
t.Run(tt.name, func(t *testing.T) {
54-
result := GenerateInstructions(tt.enabledToolsets)
54+
result := generateInstructions(tt.enabledToolsets)
5555

5656
if tt.expectedEmpty {
5757
if result != "" {
@@ -70,25 +70,25 @@ func TestGenerateInstructionsWithDisableFlag(t *testing.T) {
7070
tests := []struct {
7171
name string
7272
disableEnvValue string
73-
enabledToolsets []string
73+
enabledToolsets []ToolsetID
7474
expectedEmpty bool
7575
}{
7676
{
7777
name: "DISABLE_INSTRUCTIONS=true returns empty",
7878
disableEnvValue: "true",
79-
enabledToolsets: []string{"context", "issues", "pull_requests"},
79+
enabledToolsets: []ToolsetID{"context", "issues", "pull_requests"},
8080
expectedEmpty: true,
8181
},
8282
{
8383
name: "DISABLE_INSTRUCTIONS=false returns normal instructions",
8484
disableEnvValue: "false",
85-
enabledToolsets: []string{"context"},
85+
enabledToolsets: []ToolsetID{"context"},
8686
expectedEmpty: false,
8787
},
8888
{
8989
name: "DISABLE_INSTRUCTIONS unset returns normal instructions",
9090
disableEnvValue: "",
91-
enabledToolsets: []string{"issues"},
91+
enabledToolsets: []ToolsetID{"issues"},
9292
expectedEmpty: false,
9393
},
9494
}
@@ -112,7 +112,7 @@ func TestGenerateInstructionsWithDisableFlag(t *testing.T) {
112112
os.Setenv("DISABLE_INSTRUCTIONS", tt.disableEnvValue)
113113
}
114114

115-
result := GenerateInstructions(tt.enabledToolsets)
115+
result := generateInstructions(tt.enabledToolsets)
116116

117117
if tt.expectedEmpty {
118118
if result != "" {
@@ -131,20 +131,20 @@ func TestGetToolsetInstructions(t *testing.T) {
131131
tests := []struct {
132132
toolset string
133133
expectedEmpty bool
134-
enabledToolsets []string
134+
enabledToolsets []ToolsetID
135135
expectedToContain string
136136
notExpectedToContain string
137137
}{
138138
{
139139
toolset: "pull_requests",
140140
expectedEmpty: false,
141-
enabledToolsets: []string{"pull_requests", "repos"},
141+
enabledToolsets: []ToolsetID{"pull_requests", "repos"},
142142
expectedToContain: "pull_request_template.md",
143143
},
144144
{
145145
toolset: "pull_requests",
146146
expectedEmpty: false,
147-
enabledToolsets: []string{"pull_requests"},
147+
enabledToolsets: []ToolsetID{"pull_requests"},
148148
notExpectedToContain: "pull_request_template.md",
149149
},
150150
{
@@ -163,7 +163,7 @@ func TestGetToolsetInstructions(t *testing.T) {
163163

164164
for _, tt := range tests {
165165
t.Run(tt.toolset, func(t *testing.T) {
166-
result := getToolsetInstructions(tt.toolset, tt.enabledToolsets)
166+
result := getToolsetInstructions(ToolsetID(tt.toolset), tt.enabledToolsets)
167167
if tt.expectedEmpty {
168168
if result != "" {
169169
t.Errorf("Expected empty result for toolset '%s', but got: %s", tt.toolset, result)

0 commit comments

Comments
 (0)