Skip to content

Commit 80a3237

Browse files
committed
move label tools
1 parent 3c32559 commit 80a3237

File tree

1 file changed

+68
-70
lines changed

1 file changed

+68
-70
lines changed

pkg/github/issues.go

Lines changed: 68 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,74 @@ func AssignCopilotToIssue(getGQLClient GetGQLClientFn, t translations.Translatio
17001700
}
17011701
}
17021702

1703+
type ReplaceActorsForAssignableInput struct {
1704+
AssignableID githubv4.ID `json:"assignableId"`
1705+
ActorIDs []githubv4.ID `json:"actorIds"`
1706+
}
1707+
1708+
// parseISOTimestamp parses an ISO 8601 timestamp string into a time.Time object.
1709+
// Returns the parsed time or an error if parsing fails.
1710+
// Example formats supported: "2023-01-15T14:30:00Z", "2023-01-15"
1711+
func parseISOTimestamp(timestamp string) (time.Time, error) {
1712+
if timestamp == "" {
1713+
return time.Time{}, fmt.Errorf("empty timestamp")
1714+
}
1715+
1716+
// Try RFC3339 format (standard ISO 8601 with time)
1717+
t, err := time.Parse(time.RFC3339, timestamp)
1718+
if err == nil {
1719+
return t, nil
1720+
}
1721+
1722+
// Try simple date format (YYYY-MM-DD)
1723+
t, err = time.Parse("2006-01-02", timestamp)
1724+
if err == nil {
1725+
return t, nil
1726+
}
1727+
1728+
// Return error with supported formats
1729+
return time.Time{}, fmt.Errorf("invalid ISO 8601 timestamp: %s (supported formats: YYYY-MM-DDThh:mm:ssZ or YYYY-MM-DD)", timestamp)
1730+
}
1731+
1732+
func AssignCodingAgentPrompt(t translations.TranslationHelperFunc) (tool mcp.Prompt, handler server.PromptHandlerFunc) {
1733+
return mcp.NewPrompt("AssignCodingAgent",
1734+
mcp.WithPromptDescription(t("PROMPT_ASSIGN_CODING_AGENT_DESCRIPTION", "Assign GitHub Coding Agent to multiple tasks in a GitHub repository.")),
1735+
mcp.WithArgument("repo", mcp.ArgumentDescription("The repository to assign tasks in (owner/repo)."), mcp.RequiredArgument()),
1736+
), func(_ context.Context, request mcp.GetPromptRequest) (*mcp.GetPromptResult, error) {
1737+
repo := request.Params.Arguments["repo"]
1738+
1739+
messages := []mcp.PromptMessage{
1740+
{
1741+
Role: "user",
1742+
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."),
1743+
},
1744+
{
1745+
Role: "user",
1746+
Content: mcp.NewTextContent(fmt.Sprintf("Please go and get a list of the most recent 10 issues from the %s GitHub repository", repo)),
1747+
},
1748+
{
1749+
Role: "assistant",
1750+
Content: mcp.NewTextContent(fmt.Sprintf("Sure! I will get a list of the 10 most recent issues for the repo %s.", repo)),
1751+
},
1752+
{
1753+
Role: "user",
1754+
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."),
1755+
},
1756+
{
1757+
Role: "assistant",
1758+
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."),
1759+
},
1760+
{
1761+
Role: "user",
1762+
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."),
1763+
},
1764+
}
1765+
return &mcp.GetPromptResult{
1766+
Messages: messages,
1767+
}, nil
1768+
}
1769+
}
1770+
17031771
// Label Management
17041772

17051773
// Create label
@@ -2088,73 +2156,3 @@ func DeleteLabel(getGQLClient GetGQLClientFn, t translations.TranslationHelperFu
20882156
return mcp.NewToolResultText(fmt.Sprintf("label %s deleted successfully", name)), nil
20892157
}
20902158
}
2091-
2092-
// ReplaceActorsForAssignableInput represents the input for replacing actors for an assignable entity.
2093-
// Used in the AssignCopilotToIssue tool to assign Copilot to an issue.
2094-
type ReplaceActorsForAssignableInput struct {
2095-
AssignableID githubv4.ID `json:"assignableId"`
2096-
ActorIDs []githubv4.ID `json:"actorIds"`
2097-
}
2098-
2099-
func AssignCodingAgentPrompt(t translations.TranslationHelperFunc) (tool mcp.Prompt, handler server.PromptHandlerFunc) {
2100-
return mcp.NewPrompt("AssignCodingAgent",
2101-
mcp.WithPromptDescription(t("PROMPT_ASSIGN_CODING_AGENT_DESCRIPTION", "Assign GitHub Coding Agent to multiple tasks in a GitHub repository.")),
2102-
mcp.WithArgument("repo", mcp.ArgumentDescription("The repository to assign tasks in (owner/repo)."), mcp.RequiredArgument()),
2103-
), func(_ context.Context, request mcp.GetPromptRequest) (*mcp.GetPromptResult, error) {
2104-
repo := request.Params.Arguments["repo"]
2105-
2106-
messages := []mcp.PromptMessage{
2107-
{
2108-
Role: "user",
2109-
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."),
2110-
},
2111-
{
2112-
Role: "user",
2113-
Content: mcp.NewTextContent(fmt.Sprintf("Please go and get a list of the most recent 10 issues from the %s GitHub repository", repo)),
2114-
},
2115-
{
2116-
Role: "assistant",
2117-
Content: mcp.NewTextContent(fmt.Sprintf("Sure! I will get a list of the 10 most recent issues for the repo %s.", repo)),
2118-
},
2119-
{
2120-
Role: "user",
2121-
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."),
2122-
},
2123-
{
2124-
Role: "assistant",
2125-
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."),
2126-
},
2127-
{
2128-
Role: "user",
2129-
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."),
2130-
},
2131-
}
2132-
return &mcp.GetPromptResult{
2133-
Messages: messages,
2134-
}, nil
2135-
}
2136-
}
2137-
2138-
// parseISOTimestamp parses an ISO 8601 timestamp string into a time.Time object.
2139-
// Returns the parsed time or an error if parsing fails.
2140-
// Example formats supported: "2023-01-15T14:30:00Z", "2023-01-15"
2141-
func parseISOTimestamp(timestamp string) (time.Time, error) {
2142-
if timestamp == "" {
2143-
return time.Time{}, fmt.Errorf("empty timestamp")
2144-
}
2145-
2146-
// Try RFC3339 format (standard ISO 8601 with time)
2147-
t, err := time.Parse(time.RFC3339, timestamp)
2148-
if err == nil {
2149-
return t, nil
2150-
}
2151-
2152-
// Try simple date format (YYYY-MM-DD)
2153-
t, err = time.Parse("2006-01-02", timestamp)
2154-
if err == nil {
2155-
return t, nil
2156-
}
2157-
2158-
// Return error with supported formats
2159-
return time.Time{}, fmt.Errorf("invalid ISO 8601 timestamp: %s (supported formats: YYYY-MM-DDThh:mm:ssZ or YYYY-MM-DD)", timestamp)
2160-
}

0 commit comments

Comments
 (0)