Skip to content

Commit

Permalink
fix: previou issue/pr custom message
Browse files Browse the repository at this point in the history
  • Loading branch information
snobbee committed Jan 17, 2025
1 parent 4359d74 commit 248ceda
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
6 changes: 4 additions & 2 deletions packages/client-github/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ export class GitHubClient extends EventEmitter {
this.state.repo as string,
this.state.branch as string,
this.apiToken,
issuesLimit
issuesLimit,
true
);
await savePullRequestsToMemory(
this.runtime,
Expand All @@ -260,7 +261,8 @@ export class GitHubClient extends EventEmitter {
this.state.repo as string,
this.state.branch as string,
this.apiToken,
pullRequestsLimit
pullRequestsLimit,
true
);

const callback: HandlerCallback = async (content: Content) => {
Expand Down
30 changes: 22 additions & 8 deletions packages/plugin-github/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ export const getPullRequestFromMemories = async (
export async function saveIssueToMemory(
runtime: IAgentRuntime,
message: Memory,
issue: RestEndpointMethodTypes["issues"]["create"]["response"]["data"]
issue: RestEndpointMethodTypes["issues"]["create"]["response"]["data"],
previousIssue: boolean = false
): Promise<Memory> {
const issueId = stringToUuid(
`${message.roomId}-${runtime.agentId}-issue-${issue.number}`
Expand All @@ -335,7 +336,9 @@ export async function saveIssueToMemory(
agentId: runtime.agentId,
roomId: message.roomId,
content: {
text: `Previously created issue: ${issue.title} ${issue.html_url}`,
text: previousIssue
? `Previously created issue: ${issue.title} ${issue.html_url}`
: `Created issue: ${issue.title} ${issue.html_url}`,
action: "CREATE_ISSUE",
source: "github",
metadata: {
Expand Down Expand Up @@ -366,7 +369,8 @@ export const saveIssuesToMemory = async (
repository: string,
branch: string,
apiToken: string,
limit: number = 999999
limit: number = 999999,
previousIssue: boolean = false
): Promise<Memory[]> => {
const githubService = new GitHubService({
owner: owner,
Expand All @@ -389,7 +393,12 @@ export const saveIssuesToMemory = async (
// )
// );
// if (!issueMemory) {
const newIssueMemory = await saveIssueToMemory(runtime, message, issue);
const newIssueMemory = await saveIssueToMemory(
runtime,
message,
issue,
previousIssue
);

issuesMemories.push(newIssueMemory);
// } else {
Expand Down Expand Up @@ -487,7 +496,8 @@ export async function savePullRequestToMemory(
owner: string,
repo: string,
branch: string,
apiToken: string
apiToken: string,
previousPullRequest: boolean = false
): Promise<Memory> {
const githubService = new GitHubService({
owner,
Expand All @@ -503,7 +513,9 @@ export async function savePullRequestToMemory(
agentId: runtime.agentId,
roomId: message.roomId,
content: {
text: `Previously created pull request: ${pullRequest.title} ${pullRequest.html_url}`,
text: previousPullRequest
? `Previously created pull request: ${pullRequest.title} ${pullRequest.html_url}`
: `Created pull request: ${pullRequest.title} ${pullRequest.html_url}`,
metadata: await getPullRequestMetadata(pullRequest, githubService),
},
};
Expand Down Expand Up @@ -555,7 +567,8 @@ export const savePullRequestsToMemory = async (
repository: string,
branch: string,
apiToken: string,
limit: number = 999999
limit: number = 999999,
previousPullRequest: boolean = false
): Promise<Memory[]> => {
const memories = await runtime.messageManager.getMemories({
roomId: message.roomId,
Expand Down Expand Up @@ -586,7 +599,8 @@ export const savePullRequestsToMemory = async (
owner,
repository,
branch,
apiToken
apiToken,
previousPullRequest
);
pullRequestsMemories.push(newPrMemory);
} else {
Expand Down

0 comments on commit 248ceda

Please sign in to comment.