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

Commit21389a4

Browse files
Add in an assign copilot prompt (#572)
* add in an assign copilot prompt* Update pkg/github/issues.goCo-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>---------Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parentf631ff5 commit21389a4

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

‎pkg/github/issues.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,3 +931,42 @@ func parseISOTimestamp(timestamp string) (time.Time, error) {
931931
// Return error with supported formats
932932
return time.Time{},fmt.Errorf("invalid ISO 8601 timestamp: %s (supported formats: YYYY-MM-DDThh:mm:ssZ or YYYY-MM-DD)",timestamp)
933933
}
934+
935+
funcAssignCodingAgentPrompt(t translations.TranslationHelperFunc) (tool mcp.Prompt,handler server.PromptHandlerFunc) {
936+
returnmcp.NewPrompt("AssignCodingAgent",
937+
mcp.WithPromptDescription(t("PROMPT_ASSIGN_CODING_AGENT_DESCRIPTION","Assign GitHub Coding Agent to multiple tasks in a GitHub repository.")),
938+
mcp.WithArgument("repo",mcp.ArgumentDescription("The repository to assign tasks in (owner/repo)."),mcp.RequiredArgument()),
939+
),func(ctx context.Context,request mcp.GetPromptRequest) (*mcp.GetPromptResult,error) {
940+
repo:=request.Params.Arguments["repo"]
941+
942+
messages:= []mcp.PromptMessage{
943+
{
944+
Role:"system",
945+
Content:mcp.NewTextContent("You are a personal assistant for GitHub the Copilot GitHub Coding Agent. Your task is to help the user assign tasks to the Coding Agent based on their open GitHub issues. You can use `assign_copilot_to_issue` tool to assign the Coding Agent to issues that are suitable for autonomous work, and `search_issues` tool to find issues that match the user's criteria. You can also use `list_issues` to get a list of issues in the repository."),
946+
},
947+
{
948+
Role:"user",
949+
Content:mcp.NewTextContent(fmt.Sprintf("Please go and get a list of the most recent 10 issues from the %s GitHub repository",repo)),
950+
},
951+
{
952+
Role:"assistant",
953+
Content:mcp.NewTextContent(fmt.Sprintf("Sure! I will get a list of the 10 most recent issues for the repo %s.",repo)),
954+
},
955+
{
956+
Role:"user",
957+
Content:mcp.NewTextContent("For each issue, please check if it is a clearly defined coding task with acceptance criteria and a low to medium complexity to identify issues that are suitable for an AI Coding Agent to work on. Then assign each of the identified issues to Copilot."),
958+
},
959+
{
960+
Role:"assistant",
961+
Content:mcp.NewTextContent("Certainly! Let me carefully check which ones are clearly scoped issues that are good to assign to the coding agent, and I will summarize and assign them now."),
962+
},
963+
{
964+
Role:"user",
965+
Content:mcp.NewTextContent("Great, if you are unsure if an issue is good to assign, ask me first, rather than assigning copilot. If you are certain the issue is clear and suitable you can assign it to Copilot without asking."),
966+
},
967+
}
968+
return&mcp.GetPromptResult{
969+
Messages:messages,
970+
},nil
971+
}
972+
}

‎pkg/github/tools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func DefaultToolsetGroup(readOnly bool, getClient GetClientFn, getGQLClient GetG
5959
toolsets.NewServerTool(AddIssueComment(getClient,t)),
6060
toolsets.NewServerTool(UpdateIssue(getClient,t)),
6161
toolsets.NewServerTool(AssignCopilotToIssue(getGQLClient,t)),
62-
)
62+
).AddPrompts(toolsets.NewServerPrompt(AssignCodingAgentPrompt(t)))
6363
users:=toolsets.NewToolset("users","GitHub User related tools").
6464
AddReadTools(
6565
toolsets.NewServerTool(SearchUsers(getClient,t)),

‎pkg/toolsets/toolsets.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,25 @@ func NewServerResourceTemplate(resourceTemplate mcp.ResourceTemplate, handler se
4040
}
4141
}
4242

43+
funcNewServerPrompt(prompt mcp.Prompt,handler server.PromptHandlerFunc)ServerPrompt {
44+
returnServerPrompt{
45+
Prompt:prompt,
46+
Handler:handler,
47+
}
48+
}
49+
4350
// ServerResourceTemplate represents a resource template that can be registered with the MCP server.
4451
typeServerResourceTemplatestruct {
4552
resourceTemplate mcp.ResourceTemplate
4653
handler server.ResourceTemplateHandlerFunc
4754
}
4855

56+
// ServerPrompt represents a prompt that can be registered with the MCP server.
57+
typeServerPromptstruct {
58+
Prompt mcp.Prompt
59+
Handler server.PromptHandlerFunc
60+
}
61+
4962
// Toolset represents a collection of MCP functionality that can be enabled or disabled as a group.
5063
typeToolsetstruct {
5164
Namestring
@@ -57,6 +70,8 @@ type Toolset struct {
5770
// resources are not tools, but the community seems to be moving towards namespaces as a broader concept
5871
// and in order to have multiple servers running concurrently, we want to avoid overlapping resources too.
5972
resourceTemplates []ServerResourceTemplate
73+
// prompts are also not tools but are namespaced similarly
74+
prompts []ServerPrompt
6075
}
6176

6277
func (t*Toolset)GetActiveTools() []server.ServerTool {
@@ -95,6 +110,11 @@ func (t *Toolset) AddResourceTemplates(templates ...ServerResourceTemplate) *Too
95110
returnt
96111
}
97112

113+
func (t*Toolset)AddPrompts(prompts...ServerPrompt)*Toolset {
114+
t.prompts=append(t.prompts,prompts...)
115+
returnt
116+
}
117+
98118
func (t*Toolset)GetActiveResourceTemplates() []ServerResourceTemplate {
99119
if!t.Enabled {
100120
returnnil
@@ -115,6 +135,15 @@ func (t *Toolset) RegisterResourcesTemplates(s *server.MCPServer) {
115135
}
116136
}
117137

138+
func (t*Toolset)RegisterPrompts(s*server.MCPServer) {
139+
if!t.Enabled {
140+
return
141+
}
142+
for_,prompt:=ranget.prompts {
143+
s.AddPrompt(prompt.Prompt,prompt.Handler)
144+
}
145+
}
146+
118147
func (t*Toolset)SetReadOnly() {
119148
// Set the toolset to read-only
120149
t.readOnly=true
@@ -225,6 +254,7 @@ func (tg *ToolsetGroup) RegisterAll(s *server.MCPServer) {
225254
for_,toolset:=rangetg.Toolsets {
226255
toolset.RegisterTools(s)
227256
toolset.RegisterResourcesTemplates(s)
257+
toolset.RegisterPrompts(s)
228258
}
229259
}
230260

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp