@@ -4,9 +4,13 @@ const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
44const GITHUB_REPO_OWNER = process . env . GITHUB_REPO_OWNER ;
55const GITHUB_REPO_NAME = process . env . GITHUB_REPO_NAME ;
66
7+ // Known Copilot Coding Agent bot identity
8+ const COPILOT_BOT_LOGIN = 'Copilot' ;
9+ const COPILOT_BOT_NODE_ID = 'BOT_kgDOC9w8XQ' ;
10+
711/**
8- * Creates a GitHub issue from the provided description and assigns it to @copilot-swe-agent if available .
9- * Uses GraphQL for efficient repo/actor queries and issue creation with assignment .
12+ * Creates a GitHub issue and assigns it to the Copilot Coding Agent (@Copilot) .
13+ * Uses GraphQL to create the issue with the bot's known node ID as assignee .
1014 * Returns the issue URL on success, null on failure.
1115 */
1216export async function createIssueWithCopilot ( description : string ) : Promise < string | null > {
@@ -21,23 +25,12 @@ export async function createIssueWithCopilot(description: string): Promise<strin
2125 const octokit = new Octokit ( { auth : GITHUB_TOKEN } ) ;
2226
2327 try {
24- // Fetch repo ID and check for @copilot -swe-agent
25- const repoInfoQuery = `
28+ // Fetch repo node ID
29+ const repoInfo : any = await octokit . graphql ( `
2630 query($owner: String!, $name: String!) {
27- repository(owner: $owner, name: $name) {
28- id
29- suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) {
30- nodes {
31- login
32- ... on User { id }
33- ... on Bot { id }
34- }
35- }
36- }
31+ repository(owner: $owner, name: $name) { id }
3732 }
38- ` ;
39-
40- const repoInfo : any = await octokit . graphql ( repoInfoQuery , {
33+ ` , {
4134 owner : GITHUB_REPO_OWNER ,
4235 name : GITHUB_REPO_NAME ,
4336 } ) ;
@@ -47,26 +40,10 @@ export async function createIssueWithCopilot(description: string): Promise<strin
4740 return null ;
4841 }
4942
50- const copilotBot = repoInfo . repository . suggestedActors . nodes . find (
51- ( node : any ) => node . login === 'copilot-swe-agent'
52- ) ;
53-
5443 const title = description . split ( '\n' ) [ 0 ] . slice ( 0 , 100 ) ;
5544
56- if ( ! copilotBot ) {
57- // Fallback: Create issue without assignment via REST
58- const issue = await octokit . issues . create ( {
59- owner : GITHUB_REPO_OWNER ,
60- repo : GITHUB_REPO_NAME ,
61- title,
62- body : description ,
63- } ) ;
64-
65- return issue . data . html_url ;
66- }
67-
68- // Create issue with assignment via GraphQL
69- const createIssueMutation = `
45+ // Create issue with Copilot bot assigned via known node ID
46+ const response : any = await octokit . graphql ( `
7047 mutation($repoId: ID!, $title: String!, $body: String!, $assigneeIds: [ID!]) {
7148 createIssue(input: { repositoryId: $repoId, title: $title, body: $body, assigneeIds: $assigneeIds }) {
7249 issue {
@@ -77,20 +54,19 @@ export async function createIssueWithCopilot(description: string): Promise<strin
7754 }
7855 }
7956 }
80- ` ;
81-
82- const response : any = await octokit . graphql ( createIssueMutation , {
57+ ` , {
8358 repoId,
8459 title,
8560 body : description ,
86- assigneeIds : [ copilotBot . id ] ,
61+ assigneeIds : [ COPILOT_BOT_NODE_ID ] ,
8762 } ) ;
8863
8964 const issue = response ?. createIssue ?. issue ;
9065 if ( ! issue ) {
9166 return null ;
9267 }
9368
69+ console . log ( `Assigned to: ${ issue . assignees . nodes . map ( ( a : any ) => a . login ) . join ( ', ' ) } ` ) ;
9470 return issue . url ;
9571 } catch ( error ) {
9672 console . error ( 'Error creating issue:' , error ) ;
0 commit comments