Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Automatic PR Summary Comment Feature #273

Closed
wants to merge 2 commits into from
Closed

Conversation

homie-gg[bot]
Copy link

@homie-gg homie-gg bot commented Oct 6, 2024

. Three files were modified to implement the automatic PR summary comments feature.

  • A new file src/lib/github/manage-pr-comments.ts was created to handle adding or updating pull request comments.
  • A new file src/queue/jobs/handle-pr-event.ts was created to handle pull request events, generate summaries, and integrate with existing systems.
  • The existing file src/lib/github/create-github-client.ts was modified to export the GithubClient type and ensure compatibility with the newly added functionalities.


const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated:

────────────────────────────────────────────────────────────────────────────────
Newer aider version v0.59.1 is available.

/root/.local/share/pipx/venvs/aider-chat/bin/python -m pip install --upgrade
aider-chat

Installing: /root/.local/share/pipx/venvs/aider-chat/bin/python -m pip install --upgrade aider-chat

Installing... ⠋
Installing...
Installing... ⠙
Installing...
Installing... ⠹
Installing...
Installing... ⠸
Installing...
Installing... ⠼
Installing...

Installation complete.

Aider v0.57.1
Main model: claude-3-5-sonnet-20240620 with diff edit format, infinite output
Weak model: claude-3-haiku-20240307
Git repo: .git with 595 files
Repo-map: using 1024 tokens, auto refresh
Added src/lib/github/manage-pr-comments.ts to the chat.
Use /help for help, run "aider --help" to see cmd line args

Initial repo scan can be slow in larger repos, but only happens once.

Updating repo map ⠴
Updating repo map
Updating repo map ⠦
Updating repo map
Updating repo map ⠧
Updating repo map

I understand that you want to delete the file mentioned in line 5 of the DIFF.
The file in question is src/lib/github/manage-pr-comments.ts. To delete this
file, we don't need to make any changes to its content. Instead, I'll suggest a
shell command to remove the file.

Here's the shell command to delete the file:

rm src/lib/github/manage-pr-comments.ts

This command will remove the file from your file system. Make sure you're in the
root directory of your project when running this command.

After running this command, the file src/lib/github/manage-pr-comments.ts will
be deleted from your project. Be aware that this action is irreversible, so make
sure you have a backup or version control in place if you need to recover the
file later.

Tokens: 3.4k sent, 165 received. Cost: $0.01 message, $0.01 session.

rm src/lib/github/manage-pr-comments.ts

@@ -0,0 +1,39 @@
import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated:

────────────────────────────────────────────────────────────────────────────────
Aider v0.59.1
Main model: claude-3-5-sonnet-20240620 with diff edit format, infinite output
Weak model: claude-3-haiku-20240307
Git repo: .git with 595 files
Repo-map: using 1024 tokens, auto refresh
Added src/lib/github/manage-pr-comments.ts to the chat.
Use /help for help, run "aider --help" to see cmd line args

Initial repo scan can be slow in larger repos, but only happens once.

Updating repo map ⠋
Updating repo map
Updating repo map ⠙
Updating repo map

Certainly! To delete the file src/lib/github/manage-pr-comments.ts, we'll use a
SEARCH/REPLACE block to remove all of its contents, effectively deleting it.
Then, I'll suggest a shell command to actually remove the file from the file
system.

Here's the SEARCH/REPLACE block to remove the file's contents:

src/lib/github/manage-pr-comments.ts

<<<<<<< SEARCH
import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
client: GithubClient,
owner: string,
repo: string,
pullNumber: number,
summary: string,
): Promise {
const existingComments = await client.rest.issues.listComments({
owner,
repo,
issue_number: pullNumber,
})

const homieSummaryComment = existingComments.data.find((comment) =>
comment.body?.includes(HOMIE_SUMMARY_MARKER),
)

const commentBody = ## ${HOMIE_SUMMARY_MARKER}\n\n${summary}

if (homieSummaryComment) {
await client.rest.issues.updateComment({
owner,
repo,
comment_id: homieSummaryComment.id,
body: commentBody,
})
} else {
await client.rest.issues.createComment({
owner,
repo,
issue_number: pullNumber,
body: commentBody,
})
}
}

REPLACE

Now, to actually remove the file from the file system, you can run the following
shell command:

rm src/lib/github/manage-pr-comments.ts

This command will delete the file manage-pr-comments.ts from the src/lib/github/
directory. Make sure to run this command from the root of your project
directory.

After running this command, the file will be completely removed from your
project. Don't forget to update any other files that might be importing or using
the functions from this deleted file to avoid any potential errors in your
project.

Tokens: 3.6k sent, 428 received. Cost: $0.02 message, $0.02 session.
The LLM did not conform to the edit format.
https://aider.chat/docs/troubleshooting/edit-errors.html

1 SEARCH/REPLACE block failed to match!

SearchReplaceNoExactMatch: This SEARCH block failed to exactly match lines in

src/lib/github/manage-pr-comments.ts
<<<<<<< SEARCH
import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
client: GithubClient,
owner: string,
repo: string,
pullNumber: number,
summary: string,
): Promise {
const existingComments = await client.rest.issues.listComments({
owner,
repo,
issue_number: pullNumber,
})

const homieSummaryComment = existingComments.data.find((comment) =>
comment.body?.includes(HOMIE_SUMMARY_MARKER),
)

const commentBody = ## ${HOMIE_SUMMARY_MARKER}\n\n${summary}

if (homieSummaryComment) {
await client.rest.issues.updateComment({
owner,
repo,
comment_id: homieSummaryComment.id,
body: commentBody,
})
} else {
await client.rest.issues.createComment({
owner,
repo,
issue_number: pullNumber,
body: commentBody,
})
}
}

REPLACE

Did you mean to match some of these actual lines from
src/lib/github/manage-pr-comments.ts?

import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
  client: GithubClient,
  owner: string,
  repo: string,
  pullNumber: number,
  summary: string,
): Promise<void> {
  const existingComments = await client.rest.issues.listComments({
    owner,
    repo,
    issue_number: pullNumber,
  })

  const homieSummaryComment = existingComments.data.find((comment) =>
    comment.body?.includes(HOMIE_SUMMARY_MARKER),
  )

  const commentBody = `## ${HOMIE_SUMMARY_MARKER}\n\n${summary}`

  if (homieSummaryComment) {
    await client.rest.issues.updateComment({
      owner,
      repo,
      comment_id: homieSummaryComment.id,
      body: commentBody,
    })
  } else {
    await client.rest.issues.createComment({
      owner,
      repo,
      issue_number: pullNumber,
      body: commentBody,
    })
  }
}

The SEARCH section must exactly match an existing block of lines including all
white space, comments, indentation, docstrings, etc

I apologize for the confusion in my previous response. You're right, and I
appreciate your reminder about the proper format for SEARCH/REPLACE blocks. Let
me correct that and provide the proper SEARCH/REPLACE block to delete the file's
contents:

src/lib/github/manage-pr-comments.ts

<<<<<<< SEARCH
import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
client: GithubClient,
owner: string,
repo: string,
pullNumber: number,
summary: string,
): Promise {
const existingComments = await client.rest.issues.listComments({
owner,
repo,
issue_number: pullNumber,
})

const homieSummaryComment = existingComments.data.find((comment) =>
comment.body?.includes(HOMIE_SUMMARY_MARKER),
)

const commentBody = ## ${HOMIE_SUMMARY_MARKER}\n\n${summary}

if (homieSummaryComment) {
await client.rest.issues.updateComment({
owner,
repo,
comment_id: homieSummaryComment.id,
body: commentBody,
})
} else {
await client.rest.issues.createComment({
owner,
repo,
issue_number: pullNumber,
body: commentBody,
})
}
}

REPLACE

Now, to actually remove the file from the file system, you can run the following
shell command:

rm src/lib/github/manage-pr-comments.ts

This command will delete the file manage-pr-comments.ts from the src/lib/github/
directory. Make sure to run this command from the root of your project
directory.

After running this command, the file will be completely removed from your
project. Don't forget to update any other files that might be importing or using
the functions from this deleted file to avoid any potential errors in your
project.

Tokens: 4.5k sent, 406 received. Cost: $0.02 message, $0.04 session.
The LLM did not conform to the edit format.
https://aider.chat/docs/troubleshooting/edit-errors.html

1 SEARCH/REPLACE block failed to match!

SearchReplaceNoExactMatch: This SEARCH block failed to exactly match lines in

src/lib/github/manage-pr-comments.ts
<<<<<<< SEARCH
import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
client: GithubClient,
owner: string,
repo: string,
pullNumber: number,
summary: string,
): Promise {
const existingComments = await client.rest.issues.listComments({
owner,
repo,
issue_number: pullNumber,
})

const homieSummaryComment = existingComments.data.find((comment) =>
comment.body?.includes(HOMIE_SUMMARY_MARKER),
)

const commentBody = ## ${HOMIE_SUMMARY_MARKER}\n\n${summary}

if (homieSummaryComment) {
await client.rest.issues.updateComment({
owner,
repo,
comment_id: homieSummaryComment.id,
body: commentBody,
})
} else {
await client.rest.issues.createComment({
owner,
repo,
issue_number: pullNumber,
body: commentBody,
})
}
}

REPLACE

Did you mean to match some of these actual lines from
src/lib/github/manage-pr-comments.ts?

import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
  client: GithubClient,
  owner: string,
  repo: string,
  pullNumber: number,
  summary: string,
): Promise<void> {
  const existingComments = await client.rest.issues.listComments({
    owner,
    repo,
    issue_number: pullNumber,
  })

  const homieSummaryComment = existingComments.data.find((comment) =>
    comment.body?.includes(HOMIE_SUMMARY_MARKER),
  )

  const commentBody = `## ${HOMIE_SUMMARY_MARKER}\n\n${summary}`

  if (homieSummaryComment) {
    await client.rest.issues.updateComment({
      owner,
      repo,
      comment_id: homieSummaryComment.id,
      body: commentBody,
    })
  } else {
    await client.rest.issues.createComment({
      owner,
      repo,
      issue_number: pullNumber,
      body: commentBody,
    })
  }
}

The SEARCH section must exactly match an existing block of lines including all
white space, comments, indentation, docstrings, etc

I apologize for the confusion in my previous responses. You're absolutely right,
and I appreciate your patience. Let me provide the correct SEARCH/REPLACE block
to delete the contents of the file:

src/lib/github/manage-pr-comments.ts

<<<<<<< SEARCH
import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
client: GithubClient,
owner: string,
repo: string,
pullNumber: number,
summary: string,
): Promise {
const existingComments = await client.rest.issues.listComments({
owner,
repo,
issue_number: pullNumber,
})

const homieSummaryComment = existingComments.data.find((comment) =>
comment.body?.includes(HOMIE_SUMMARY_MARKER),
)

const commentBody = ## ${HOMIE_SUMMARY_MARKER}\n\n${summary}

if (homieSummaryComment) {
await client.rest.issues.updateComment({
owner,
repo,
comment_id: homieSummaryComment.id,
body: commentBody,
})
} else {
await client.rest.issues.createComment({
owner,
repo,
issue_number: pullNumber,
body: commentBody,
})
}
}

REPLACE

Now, to actually remove the file from the file system, you can run the following
shell command:

rm src/lib/github/manage-pr-comments.ts

This command will delete the file manage-pr-comments.ts from the src/lib/github/
directory. Make sure to run this command from the root of your project
directory.

After running this command, the file will be completely removed from your
project. Don't forget to update any other files that might be importing or using
the functions from this deleted file to avoid any potential errors in your
project.

Tokens: 5.5k sent, 395 received. Cost: $0.02 message, $0.06 session.
The LLM did not conform to the edit format.
https://aider.chat/docs/troubleshooting/edit-errors.html

1 SEARCH/REPLACE block failed to match!

SearchReplaceNoExactMatch: This SEARCH block failed to exactly match lines in

src/lib/github/manage-pr-comments.ts
<<<<<<< SEARCH
import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
client: GithubClient,
owner: string,
repo: string,
pullNumber: number,
summary: string,
): Promise {
const existingComments = await client.rest.issues.listComments({
owner,
repo,
issue_number: pullNumber,
})

const homieSummaryComment = existingComments.data.find((comment) =>
comment.body?.includes(HOMIE_SUMMARY_MARKER),
)

const commentBody = ## ${HOMIE_SUMMARY_MARKER}\n\n${summary}

if (homieSummaryComment) {
await client.rest.issues.updateComment({
owner,
repo,
comment_id: homieSummaryComment.id,
body: commentBody,
})
} else {
await client.rest.issues.createComment({
owner,
repo,
issue_number: pullNumber,
body: commentBody,
})
}
}

REPLACE

Did you mean to match some of these actual lines from
src/lib/github/manage-pr-comments.ts?

import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
  client: GithubClient,
  owner: string,
  repo: string,
  pullNumber: number,
  summary: string,
): Promise<void> {
  const existingComments = await client.rest.issues.listComments({
    owner,
    repo,
    issue_number: pullNumber,
  })

  const homieSummaryComment = existingComments.data.find((comment) =>
    comment.body?.includes(HOMIE_SUMMARY_MARKER),
  )

  const commentBody = `## ${HOMIE_SUMMARY_MARKER}\n\n${summary}`

  if (homieSummaryComment) {
    await client.rest.issues.updateComment({
      owner,
      repo,
      comment_id: homieSummaryComment.id,
      body: commentBody,
    })
  } else {
    await client.rest.issues.createComment({
      owner,
      repo,
      issue_number: pullNumber,
      body: commentBody,
    })
  }
}

The SEARCH section must exactly match an existing block of lines including all
white space, comments, indentation, docstrings, etc

I apologize for the confusion in my previous responses. You're right, and I
appreciate your patience. Let me provide the correct SEARCH/REPLACE block to
delete the contents of the file:

src/lib/github/manage-pr-comments.ts

<<<<<<< SEARCH
import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
client: GithubClient,
owner: string,
repo: string,
pullNumber: number,
summary: string,
): Promise {
const existingComments = await client.rest.issues.listComments({
owner,
repo,
issue_number: pullNumber,
})

const homieSummaryComment = existingComments.data.find((comment) =>
comment.body?.includes(HOMIE_SUMMARY_MARKER),
)

const commentBody = ## ${HOMIE_SUMMARY_MARKER}\n\n${summary}

if (homieSummaryComment) {
await client.rest.issues.updateComment({
owner,
repo,
comment_id: homieSummaryComment.id,
body: commentBody,
})
} else {
await client.rest.issues.createComment({
owner,
repo,
issue_number: pullNumber,
body: commentBody,
})
}
}

REPLACE

Now, to actually remove the file from the file system, you can run the following
shell command:

rm src/lib/github/manage-pr-comments.ts

This command will delete the file manage-pr-comments.ts from the src/lib/github/
directory. Make sure to run this command from the root of your project
directory.

After running this command, the file will be completely removed from your
project. Don't forget to update any other files that might be importing or using
the functions from this deleted file to avoid any potential errors in your
project.

Tokens: 5.7k sent, 394 received. Cost: $0.02 message, $0.08 session.
The LLM did not conform to the edit format.
https://aider.chat/docs/troubleshooting/edit-errors.html

1 SEARCH/REPLACE block failed to match!

SearchReplaceNoExactMatch: This SEARCH block failed to exactly match lines in

src/lib/github/manage-pr-comments.ts
<<<<<<< SEARCH
import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
client: GithubClient,
owner: string,
repo: string,
pullNumber: number,
summary: string,
): Promise {
const existingComments = await client.rest.issues.listComments({
owner,
repo,
issue_number: pullNumber,
})

const homieSummaryComment = existingComments.data.find((comment) =>
comment.body?.includes(HOMIE_SUMMARY_MARKER),
)

const commentBody = ## ${HOMIE_SUMMARY_MARKER}\n\n${summary}

if (homieSummaryComment) {
await client.rest.issues.updateComment({
owner,
repo,
comment_id: homieSummaryComment.id,
body: commentBody,
})
} else {
await client.rest.issues.createComment({
owner,
repo,
issue_number: pullNumber,
body: commentBody,
})
}
}

REPLACE

Did you mean to match some of these actual lines from
src/lib/github/manage-pr-comments.ts?

import { GithubClient } from './create-github-client'

const HOMIE_SUMMARY_MARKER = 'Homie Summary'

export async function addOrUpdatePRComment(
  client: GithubClient,
  owner: string,
  repo: string,
  pullNumber: number,
  summary: string,
): Promise<void> {
  const existingComments = await client.rest.issues.listComments({
    owner,
    repo,
    issue_number: pullNumber,
  })

  const homieSummaryComment = existingComments.data.find((comment) =>
    comment.body?.includes(HOMIE_SUMMARY_MARKER),
  )

  const commentBody = `## ${HOMIE_SUMMARY_MARKER}\n\n${summary}`

  if (homieSummaryComment) {
    await client.rest.issues.updateComment({
      owner,
      repo,
      comment_id: homieSummaryComment.id,
      body: commentBody,
    })
  } else {
    await client.rest.issues.createComment({
      owner,
      repo,
      issue_number: pullNumber,
      body: commentBody,
    })
  }
}

The SEARCH section must exactly match an existing block of lines including all
white space, comments, indentation, docstrings, etc

Only 3 reflections allowed, stopping.

@mikewuu mikewuu closed this Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants