From 5d19ba6781ddbae3dad26706ef0580b59b8ab973 Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Sun, 27 Oct 2024 09:11:04 -0400 Subject: [PATCH 1/8] fix: ignore file path and diffs --- package.json | 3 + src/adapters/openai/helpers/completions.ts | 13 +- src/handlers/ask-llm.ts | 17 +- src/helpers/format-chat-history.ts | 6 +- src/helpers/issue-fetching.ts | 37 +- tests/main.test.ts | 8 +- yarn.lock | 422 ++++++++++++++++++++- 7 files changed, 481 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 71bee04..3984bfe 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,8 @@ "@supabase/supabase-js": "^2.45.4", "@ubiquity-dao/ubiquibot-logger": "^1.3.0", "dotenv": "^16.4.5", + "github-diff-tool": "^1.0.3", + "gpt-tokenizer": "^2.5.1", "openai": "^4.63.0", "typebox-validators": "0.3.5", "voyageai": "^0.0.1-5" @@ -48,6 +50,7 @@ "@cspell/dict-typescript": "3.1.5", "@eslint/js": "9.5.0", "@jest/globals": "29.7.0", + "@types/diff": "^5.2.3", "@types/jest": "^29.5.12", "@types/node": "20.14.5", "cspell": "8.9.0", diff --git a/src/adapters/openai/helpers/completions.ts b/src/adapters/openai/helpers/completions.ts index 1d282b5..a2e2ee3 100644 --- a/src/adapters/openai/helpers/completions.ts +++ b/src/adapters/openai/helpers/completions.ts @@ -2,6 +2,7 @@ import OpenAI from "openai"; import { Context } from "../../../types"; import { SuperOpenAi } from "./openai"; import { CompletionsModelHelper, ModelApplications } from "../../../types/llm"; +import { encode } from "gpt-tokenizer"; const MAX_TOKENS = 7000; export interface CompletionsType { @@ -46,10 +47,10 @@ export class Completions extends SuperOpenAi { "Your name is : " + botName + "\n" + - "Primary Context: " + - additionalContext.join("\n") + - "\nLocal Context: " + - localContext.join("\n"), + "Main Context (Provide additional precedence in terms of information): " + + localContext.join("\n") + + "Secondary Context: " + + additionalContext.join("\n"), }, ], }, @@ -117,4 +118,8 @@ export class Completions extends SuperOpenAi { return res.choices[0].message.content; } + + async findTokenLength(prompt: string, additionalContext: string[], localContext: string[], groundTruths: string[]): Promise { + return encode(prompt + additionalContext.join("\n") + localContext.join("\n") + groundTruths.join("\n")).length; + } } diff --git a/src/handlers/ask-llm.ts b/src/handlers/ask-llm.ts index 7f3a7b3..4e34048 100644 --- a/src/handlers/ask-llm.ts +++ b/src/handlers/ask-llm.ts @@ -4,7 +4,6 @@ import { CommentSimilaritySearchResult } from "../adapters/supabase/helpers/comm import { IssueSimilaritySearchResult } from "../adapters/supabase/helpers/issues"; import { recursivelyFetchLinkedIssues } from "../helpers/issue-fetching"; import { formatChatHistory } from "../helpers/format-chat-history"; -import { optimizeContext } from "../helpers/issue"; import { fetchRepoDependencies, fetchRepoLanguageStats } from "./ground-truths/chat-bot"; import { findGroundTruths } from "./ground-truths/find-ground-truths"; @@ -58,12 +57,20 @@ export async function askGpt(context: Context, question: string, formattedChat: // Remove Null Results (Private Comments) similarText = similarText.filter((text) => text !== null); formattedChat = formattedChat.filter((text) => text !== null); - // Optimize the context - formattedChat = optimizeContext(formattedChat); - // ReRank the results based on the question - // const reRankedChat = formattedChat.length > 0 ? await context.adapters.voyage.reranker.reRankResults(formattedChat.filter(text => text !== ""), question, 300) : []; similarText = similarText.filter((text) => text !== ""); const rerankedText = similarText.length > 0 ? await context.adapters.voyage.reranker.reRankResults(similarText, question) : []; + //Calculate the current context size in tokens + const numTokens = await context.adapters.openai.completions.findTokenLength(question, rerankedText, formattedChat, [ + "typescript", + "github", + "cloudflare worker", + "actions", + "jest", + "supabase", + "openai", + ]); + // TODO: If numTokens exceed limit then limit the context size + context.logger.info(`Number of tokens: ${numTokens}`); const languages = await fetchRepoLanguageStats(context); const { dependencies, devDependencies } = await fetchRepoDependencies(context); diff --git a/src/helpers/format-chat-history.ts b/src/helpers/format-chat-history.ts index b1b5ecb..edbc289 100644 --- a/src/helpers/format-chat-history.ts +++ b/src/helpers/format-chat-history.ts @@ -1,7 +1,7 @@ import { Context } from "../types"; import { StreamlinedComment, StreamlinedComments } from "../types/llm"; import { createKey, streamlineComments } from "../handlers/comments"; -import { fetchPullRequestDiff, fetchIssue, fetchIssueComments } from "./issue-fetching"; +import { fetchPullRequestDiff, fetchIssue, fetchIssueComments, fetchLinkedPrFromIssue } from "./issue-fetching"; import { splitKey } from "./issue"; /** @@ -83,7 +83,9 @@ async function createContextBlockSection( if (!issueNumber || isNaN(issueNumber)) { throw context.logger.error("Issue number is not valid"); } - const prDiff = await fetchPullRequestDiff(context, org, repo, issueNumber); + const pulls = await fetchLinkedPrFromIssue(org, repo, issueNumber, context); + const prDiffs = await Promise.all(pulls.map(async (pull) => await fetchPullRequestDiff(context, org, repo, pull.number))); + const prDiff = prDiffs.join("\n"); const specHeader = getCorrectHeaderString(prDiff, issueNumber, isCurrentIssue, false); let specOrBody = specAndBodies[key]; if (!specOrBody) { diff --git a/src/helpers/issue-fetching.ts b/src/helpers/issue-fetching.ts index fc1df5a..62721d3 100644 --- a/src/helpers/issue-fetching.ts +++ b/src/helpers/issue-fetching.ts @@ -1,3 +1,4 @@ +import { GithubDiff } from "github-diff-tool"; import { createKey, getAllStreamlinedComments } from "../handlers/comments"; import { Context } from "../types"; import { IssueWithUser, SimplifiedComment, User } from "../types/github-types"; @@ -167,15 +168,18 @@ export async function mergeCommentsAndFetchSpec( export async function fetchPullRequestDiff(context: Context, org: string, repo: string, issue: number): Promise { const { octokit, logger } = context; try { - const { data } = await octokit.pulls.get({ - owner: org, - repo, - pull_number: issue, - mediaType: { - format: "diff", - }, + const githubDiff = new GithubDiff(octokit); + //Fetch the statistics of the pull request + const stats = await githubDiff.getPullRequestStats(org, repo, issue); + //Find the filenames which do not have more than 200 changes + let files = stats.filter((file) => file.changes < 500).map((file) => file.filename); + //Ignore files like in dist or build or .lock files + const ignoredFiles = ["dist/*", "build/*", ".lock", "index.js"]; + files = files.filter((file) => !ignoredFiles.some((pattern) => file.match(pattern))); + //Fetch the diff of the files + return await githubDiff.getPullRequestDiffsFiltered(org, repo, issue, { + includeFiles: files, }); - return data as unknown as string; } catch (error) { logger.error(`Error fetching pull request diff`, { error: error as Error, @@ -188,10 +192,9 @@ export async function fetchPullRequestDiff(context: Context, org: string, repo: } /** - * Fetches the details of a pull request. - * - * @param params - The parameters required to fetch the pull request, including context and other details. - * @returns A promise that resolves to the pull request details or null if an error occurs. + * Fetches an issue from the GitHub API. + * @param params - Context + * @returns A promise that resolves to an issue object or null if an error occurs. */ export async function fetchIssue(params: FetchParams): Promise { const { octokit, payload, logger } = params.context; @@ -296,3 +299,13 @@ function castCommentsToSimplifiedComments(comments: Comments, params: FetchParam url: comment.html_url, })); } + +export async function fetchLinkedPrFromIssue(owner: string, repo: string, issueNumber: number, context: Context) { + const prs = await context.octokit.rest.pulls.list({ + owner: owner, + repo: repo, + state: "all", + }); + //Filter the PRs which are linked to the issue using the body of the PR + return prs.data.filter((pr) => pr.body?.includes(`#${issueNumber}`)); +} diff --git a/tests/main.test.ts b/tests/main.test.ts index 30e76b6..d61fdfb 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -107,8 +107,9 @@ describe("Ask plugin tests", () => { createComments([transformCommentTemplate(1, 1, TEST_QUESTION, "ubiquity", "test-repo", true)]); await runPlugin(ctx); + expect(infoSpy).toHaveBeenCalledTimes(4); expect(infoSpy).toHaveBeenNthCalledWith(1, `Asking question: @UbiquityOS ${TEST_QUESTION}`); - expect(infoSpy).toHaveBeenNthCalledWith(3, "Answer: This is a mock answer for the chat", { + expect(infoSpy).toHaveBeenNthCalledWith(4, "Answer: This is a mock answer for the chat", { caller: LOG_CALLER, tokenUsage: { input: 1000, @@ -130,6 +131,8 @@ describe("Ask plugin tests", () => { await runPlugin(ctx); + expect(infoSpy).toHaveBeenCalledTimes(4); + expect(infoSpy).toHaveBeenNthCalledWith(1, `Asking question: @UbiquityOS ${TEST_QUESTION}`); const prompt = `=== Current Issue #1 Specification === ubiquity/test-repo/1 === @@ -402,6 +405,9 @@ function createContext(body = TEST_SLASH_COMMAND) { }, }; }, + findTokenLength: async () => { + return 1000; + }, createGroundTruthCompletion: async (): Promise => { return `["${MOCK_ANSWER}"]`; }, diff --git a/yarn.lock b/yarn.lock index bb77c02..71910e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -979,6 +979,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz#c7184a326533fcdf1b8ee0733e21c713b975575f" integrity sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ== +"@esbuild/aix-ppc64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz#b57697945b50e99007b4c2521507dc613d4a648c" + integrity sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw== + "@esbuild/android-arm64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz#bafb75234a5d3d1b690e7c2956a599345e84a2fd" @@ -989,6 +994,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz#09d9b4357780da9ea3a7dfb833a1f1ff439b4052" integrity sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A== +"@esbuild/android-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.24.0.tgz#1add7e0af67acefd556e407f8497e81fddad79c0" + integrity sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w== + "@esbuild/android-arm@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.17.19.tgz#5898f7832c2298bc7d0ab53701c57beb74d78b4d" @@ -999,6 +1009,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz#9b04384fb771926dfa6d7ad04324ecb2ab9b2e28" integrity sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg== +"@esbuild/android-arm@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.24.0.tgz#ab7263045fa8e090833a8e3c393b60d59a789810" + integrity sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew== + "@esbuild/android-x64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.17.19.tgz#658368ef92067866d95fb268719f98f363d13ae1" @@ -1009,6 +1024,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz#29918ec2db754cedcb6c1b04de8cd6547af6461e" integrity sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA== +"@esbuild/android-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.24.0.tgz#e8f8b196cfdfdd5aeaebbdb0110983460440e705" + integrity sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ== + "@esbuild/darwin-arm64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz#584c34c5991b95d4d48d333300b1a4e2ff7be276" @@ -1019,6 +1039,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz#e495b539660e51690f3928af50a76fb0a6ccff2a" integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ== +"@esbuild/darwin-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.24.0.tgz#2d0d9414f2acbffd2d86e98253914fca603a53dd" + integrity sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw== + "@esbuild/darwin-x64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz#7751d236dfe6ce136cce343dce69f52d76b7f6cb" @@ -1029,6 +1054,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz#c13838fa57372839abdddc91d71542ceea2e1e22" integrity sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw== +"@esbuild/darwin-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.24.0.tgz#33087aab31a1eb64c89daf3d2cf8ce1775656107" + integrity sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA== + "@esbuild/freebsd-arm64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz#cacd171665dd1d500f45c167d50c6b7e539d5fd2" @@ -1039,6 +1069,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz#646b989aa20bf89fd071dd5dbfad69a3542e550e" integrity sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g== +"@esbuild/freebsd-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.0.tgz#bb76e5ea9e97fa3c753472f19421075d3a33e8a7" + integrity sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA== + "@esbuild/freebsd-x64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz#0769456eee2a08b8d925d7c00b79e861cb3162e4" @@ -1049,6 +1084,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz#aa615cfc80af954d3458906e38ca22c18cf5c261" integrity sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ== +"@esbuild/freebsd-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.24.0.tgz#e0e2ce9249fdf6ee29e5dc3d420c7007fa579b93" + integrity sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ== + "@esbuild/linux-arm64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz#38e162ecb723862c6be1c27d6389f48960b68edb" @@ -1059,6 +1099,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz#70ac6fa14f5cb7e1f7f887bcffb680ad09922b5b" integrity sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q== +"@esbuild/linux-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.24.0.tgz#d1b2aa58085f73ecf45533c07c82d81235388e75" + integrity sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g== + "@esbuild/linux-arm@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz#1a2cd399c50040184a805174a6d89097d9d1559a" @@ -1069,6 +1114,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz#fc6fd11a8aca56c1f6f3894f2bea0479f8f626b9" integrity sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA== +"@esbuild/linux-arm@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.24.0.tgz#8e4915df8ea3e12b690a057e77a47b1d5935ef6d" + integrity sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw== + "@esbuild/linux-ia32@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz#e28c25266b036ce1cabca3c30155222841dc035a" @@ -1079,6 +1129,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz#3271f53b3f93e3d093d518d1649d6d68d346ede2" integrity sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg== +"@esbuild/linux-ia32@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.24.0.tgz#8200b1110666c39ab316572324b7af63d82013fb" + integrity sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA== + "@esbuild/linux-loong64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz#0f887b8bb3f90658d1a0117283e55dbd4c9dcf72" @@ -1089,6 +1144,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz#ed62e04238c57026aea831c5a130b73c0f9f26df" integrity sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg== +"@esbuild/linux-loong64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.24.0.tgz#6ff0c99cf647504df321d0640f0d32e557da745c" + integrity sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g== + "@esbuild/linux-mips64el@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz#f5d2a0b8047ea9a5d9f592a178ea054053a70289" @@ -1099,6 +1159,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz#e79b8eb48bf3b106fadec1ac8240fb97b4e64cbe" integrity sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg== +"@esbuild/linux-mips64el@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.24.0.tgz#3f720ccd4d59bfeb4c2ce276a46b77ad380fa1f3" + integrity sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA== + "@esbuild/linux-ppc64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz#876590e3acbd9fa7f57a2c7d86f83717dbbac8c7" @@ -1109,6 +1174,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz#5f2203860a143b9919d383ef7573521fb154c3e4" integrity sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w== +"@esbuild/linux-ppc64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.24.0.tgz#9d6b188b15c25afd2e213474bf5f31e42e3aa09e" + integrity sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ== + "@esbuild/linux-riscv64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz#7f49373df463cd9f41dc34f9b2262d771688bf09" @@ -1119,6 +1189,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz#07bcafd99322d5af62f618cb9e6a9b7f4bb825dc" integrity sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA== +"@esbuild/linux-riscv64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.24.0.tgz#f989fdc9752dfda286c9cd87c46248e4dfecbc25" + integrity sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw== + "@esbuild/linux-s390x@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz#e2afd1afcaf63afe2c7d9ceacd28ec57c77f8829" @@ -1129,6 +1204,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz#b7ccf686751d6a3e44b8627ababc8be3ef62d8de" integrity sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A== +"@esbuild/linux-s390x@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.24.0.tgz#29ebf87e4132ea659c1489fce63cd8509d1c7319" + integrity sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g== + "@esbuild/linux-x64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz#8a0e9738b1635f0c53389e515ae83826dec22aa4" @@ -1139,6 +1219,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz#6d8f0c768e070e64309af8004bb94e68ab2bb3b0" integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ== +"@esbuild/linux-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.24.0.tgz#4af48c5c0479569b1f359ffbce22d15f261c0cef" + integrity sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA== + "@esbuild/netbsd-x64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz#c29fb2453c6b7ddef9a35e2c18b37bda1ae5c462" @@ -1149,6 +1234,16 @@ resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz#bbe430f60d378ecb88decb219c602667387a6047" integrity sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg== +"@esbuild/netbsd-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.24.0.tgz#1ae73d23cc044a0ebd4f198334416fb26c31366c" + integrity sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg== + +"@esbuild/openbsd-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.0.tgz#5d904a4f5158c89859fd902c427f96d6a9e632e2" + integrity sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg== + "@esbuild/openbsd-x64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz#95e75a391403cb10297280d524d66ce04c920691" @@ -1159,6 +1254,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz#99d1cf2937279560d2104821f5ccce220cb2af70" integrity sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow== +"@esbuild/openbsd-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.24.0.tgz#4c8aa88c49187c601bae2971e71c6dc5e0ad1cdf" + integrity sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q== + "@esbuild/sunos-x64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz#722eaf057b83c2575937d3ffe5aeb16540da7273" @@ -1169,6 +1269,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz#08741512c10d529566baba837b4fe052c8f3487b" integrity sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg== +"@esbuild/sunos-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.24.0.tgz#8ddc35a0ea38575fa44eda30a5ee01ae2fa54dd4" + integrity sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA== + "@esbuild/win32-arm64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz#9aa9dc074399288bdcdd283443e9aeb6b9552b6f" @@ -1179,6 +1284,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz#675b7385398411240735016144ab2e99a60fc75d" integrity sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A== +"@esbuild/win32-arm64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.24.0.tgz#6e79c8543f282c4539db684a207ae0e174a9007b" + integrity sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA== + "@esbuild/win32-ia32@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz#95ad43c62ad62485e210f6299c7b2571e48d2b03" @@ -1189,6 +1299,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz#1bfc3ce98aa6ca9a0969e4d2af72144c59c1193b" integrity sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA== +"@esbuild/win32-ia32@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.24.0.tgz#057af345da256b7192d18b676a02e95d0fa39103" + integrity sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw== + "@esbuild/win32-x64@0.17.19": version "0.17.19" resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz#8cfaf2ff603e9aabb910e9c0558c26cf32744061" @@ -1199,6 +1314,11 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz#acad351d582d157bb145535db2a6ff53dd514b5c" integrity sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw== +"@esbuild/win32-x64@0.24.0": + version "0.24.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz#168ab1c7e1c318b922637fad8f339d48b01e1244" + integrity sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA== + "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" @@ -1628,11 +1748,83 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@octokit/app@^15.0.0": + version "15.1.0" + resolved "https://registry.yarnpkg.com/@octokit/app/-/app-15.1.0.tgz#b330d8826be088ec8d1d43a59dc27ef57d1232b2" + integrity sha512-TkBr7QgOmE6ORxvIAhDbZsqPkF7RSqTY4pLTtUQCvr6dTXqvi2fFo46q3h1lxlk/sGMQjqyZ0kEahkD/NyzOHg== + dependencies: + "@octokit/auth-app" "^7.0.0" + "@octokit/auth-unauthenticated" "^6.0.0" + "@octokit/core" "^6.1.2" + "@octokit/oauth-app" "^7.0.0" + "@octokit/plugin-paginate-rest" "^11.0.0" + "@octokit/types" "^13.0.0" + "@octokit/webhooks" "^13.0.0" + +"@octokit/auth-app@^7.0.0": + version "7.1.1" + resolved "https://registry.yarnpkg.com/@octokit/auth-app/-/auth-app-7.1.1.tgz#d8916ad01e6ffb0a0a50507aa613e91fe7a49b93" + integrity sha512-kRAd6yelV9OgvlEJE88H0VLlQdZcag9UlLr7dV0YYP37X8PPDvhgiTy66QVhDXdyoT0AleFN2w/qXkPdrSzINg== + dependencies: + "@octokit/auth-oauth-app" "^8.1.0" + "@octokit/auth-oauth-user" "^5.1.0" + "@octokit/request" "^9.1.1" + "@octokit/request-error" "^6.1.1" + "@octokit/types" "^13.4.1" + lru-cache "^10.0.0" + universal-github-app-jwt "^2.2.0" + universal-user-agent "^7.0.0" + +"@octokit/auth-oauth-app@^8.0.0", "@octokit/auth-oauth-app@^8.1.0": + version "8.1.1" + resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-app/-/auth-oauth-app-8.1.1.tgz#6204affa6e86f535016799cadf2af9befe5e893c" + integrity sha512-5UtmxXAvU2wfcHIPPDWzVSAWXVJzG3NWsxb7zCFplCWEmMCArSZV0UQu5jw5goLQXbFyOr5onzEH37UJB3zQQg== + dependencies: + "@octokit/auth-oauth-device" "^7.0.0" + "@octokit/auth-oauth-user" "^5.0.1" + "@octokit/request" "^9.0.0" + "@octokit/types" "^13.0.0" + universal-user-agent "^7.0.0" + +"@octokit/auth-oauth-device@^7.0.0", "@octokit/auth-oauth-device@^7.0.1": + version "7.1.1" + resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-device/-/auth-oauth-device-7.1.1.tgz#7b4f8f97cbcadbe9894d48cde4406dbdef39875a" + integrity sha512-HWl8lYueHonuyjrKKIup/1tiy0xcmQCdq5ikvMO1YwkNNkxb6DXfrPjrMYItNLyCP/o2H87WuijuE+SlBTT8eg== + dependencies: + "@octokit/oauth-methods" "^5.0.0" + "@octokit/request" "^9.0.0" + "@octokit/types" "^13.0.0" + universal-user-agent "^7.0.0" + +"@octokit/auth-oauth-user@^5.0.1", "@octokit/auth-oauth-user@^5.1.0": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-user/-/auth-oauth-user-5.1.1.tgz#4f1570c6ee15bb9ddc3dcca83308dcaa159e3848" + integrity sha512-rRkMz0ErOppdvEfnemHJXgZ9vTPhBuC6yASeFaB7I2yLMd7QpjfrL1mnvRPlyKo+M6eeLxrKanXJ9Qte29SRsw== + dependencies: + "@octokit/auth-oauth-device" "^7.0.1" + "@octokit/oauth-methods" "^5.0.0" + "@octokit/request" "^9.0.1" + "@octokit/types" "^13.0.0" + universal-user-agent "^7.0.0" + "@octokit/auth-token@^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-4.0.0.tgz#40d203ea827b9f17f42a29c6afb93b7745ef80c7" integrity sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA== +"@octokit/auth-token@^5.0.0": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-5.1.1.tgz#3bbfe905111332a17f72d80bd0b51a3e2fa2cf07" + integrity sha512-rh3G3wDO8J9wSjfI436JUKzHIxq8NaiL0tVeB2aXmG6p/9859aUOAjA9pmSPNGGZxfwmaJ9ozOJImuNVJdpvbA== + +"@octokit/auth-unauthenticated@^6.0.0", "@octokit/auth-unauthenticated@^6.0.0-beta.1": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@octokit/auth-unauthenticated/-/auth-unauthenticated-6.1.0.tgz#de0fe923bb06ed93aea526ab99972a98c546d0bf" + integrity sha512-zPSmfrUAcspZH/lOFQnVnvjQZsIvmfApQH6GzJrkIunDooU1Su2qt2FfMTSVPRp7WLTQyC20Kd55lF+mIYaohQ== + dependencies: + "@octokit/request-error" "^6.0.1" + "@octokit/types" "^13.0.0" + "@octokit/core@^5.0.1", "@octokit/core@^5.0.2": version "5.2.0" resolved "https://registry.yarnpkg.com/@octokit/core/-/core-5.2.0.tgz#ddbeaefc6b44a39834e1bb2e58a49a117672a7ea" @@ -1646,6 +1838,27 @@ before-after-hook "^2.2.0" universal-user-agent "^6.0.0" +"@octokit/core@^6.0.0", "@octokit/core@^6.1.2": + version "6.1.2" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-6.1.2.tgz#20442d0a97c411612da206411e356014d1d1bd17" + integrity sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg== + dependencies: + "@octokit/auth-token" "^5.0.0" + "@octokit/graphql" "^8.0.0" + "@octokit/request" "^9.0.0" + "@octokit/request-error" "^6.0.1" + "@octokit/types" "^13.0.0" + before-after-hook "^3.0.2" + universal-user-agent "^7.0.0" + +"@octokit/endpoint@^10.0.0": + version "10.1.1" + resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-10.1.1.tgz#1a9694e7aef6aa9d854dc78dd062945945869bcc" + integrity sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q== + dependencies: + "@octokit/types" "^13.0.0" + universal-user-agent "^7.0.2" + "@octokit/endpoint@^9.0.1": version "9.0.5" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-9.0.5.tgz#e6c0ee684e307614c02fc6ac12274c50da465c44" @@ -1663,6 +1876,44 @@ "@octokit/types" "^13.0.0" universal-user-agent "^6.0.0" +"@octokit/graphql@^8.0.0": + version "8.1.1" + resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-8.1.1.tgz#3cacab5f2e55d91c733e3bf481d3a3f8a5f639c4" + integrity sha512-ukiRmuHTi6ebQx/HFRCXKbDlOh/7xEV6QUXaE7MJEKGNAncGI/STSbOkl12qVXZrfZdpXctx5O9X1AIaebiDBg== + dependencies: + "@octokit/request" "^9.0.0" + "@octokit/types" "^13.0.0" + universal-user-agent "^7.0.0" + +"@octokit/oauth-app@^7.0.0": + version "7.1.3" + resolved "https://registry.yarnpkg.com/@octokit/oauth-app/-/oauth-app-7.1.3.tgz#a0f256dd185e7c00bfbc3e6bc3c5aad66e42c609" + integrity sha512-EHXbOpBkSGVVGF1W+NLMmsnSsJRkcrnVmDKt0TQYRBb6xWfWzoi9sBD4DIqZ8jGhOWO/V8t4fqFyJ4vDQDn9bg== + dependencies: + "@octokit/auth-oauth-app" "^8.0.0" + "@octokit/auth-oauth-user" "^5.0.1" + "@octokit/auth-unauthenticated" "^6.0.0-beta.1" + "@octokit/core" "^6.0.0" + "@octokit/oauth-authorization-url" "^7.0.0" + "@octokit/oauth-methods" "^5.0.0" + "@types/aws-lambda" "^8.10.83" + universal-user-agent "^7.0.0" + +"@octokit/oauth-authorization-url@^7.0.0": + version "7.1.1" + resolved "https://registry.yarnpkg.com/@octokit/oauth-authorization-url/-/oauth-authorization-url-7.1.1.tgz#0e17c2225eb66b58ec902d02b6f1315ffe9ff04b" + integrity sha512-ooXV8GBSabSWyhLUowlMIVd9l1s2nsOGQdlP2SQ4LnkEsGXzeCvbSbCPdZThXhEFzleGPwbapT0Sb+YhXRyjCA== + +"@octokit/oauth-methods@^5.0.0": + version "5.1.2" + resolved "https://registry.yarnpkg.com/@octokit/oauth-methods/-/oauth-methods-5.1.2.tgz#fd31d2a69f4c91d1abc1ed1814dda5252c697e02" + integrity sha512-C5lglRD+sBlbrhCUTxgJAFjWgJlmTx5bQ7Ch0+2uqRjYv7Cfb5xpX4WuSC9UgQna3sqRGBL9EImX9PvTpMaQ7g== + dependencies: + "@octokit/oauth-authorization-url" "^7.0.0" + "@octokit/request" "^9.1.0" + "@octokit/request-error" "^6.1.0" + "@octokit/types" "^13.0.0" + "@octokit/openapi-types@^20.0.0": version "20.0.0" resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-20.0.0.tgz#9ec2daa0090eeb865ee147636e0c00f73790c6e5" @@ -1678,6 +1929,16 @@ resolved "https://registry.yarnpkg.com/@octokit/openapi-webhooks-types/-/openapi-webhooks-types-8.2.1.tgz#08b974f1e83a75c4d3ce23f798c7667b433bf4cd" integrity sha512-msAU1oTSm0ZmvAE0xDemuF4tVs5i0xNnNGtNmr4EuATi+1Rn8cZDetj6NXioSf5LwnxEc209COa/WOSbjuhLUA== +"@octokit/openapi-webhooks-types@8.3.0": + version "8.3.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-webhooks-types/-/openapi-webhooks-types-8.3.0.tgz#a7a4da00c0f27f7f5708eb3fcebefa08f8d51125" + integrity sha512-vKLsoR4xQxg4Z+6rU/F65ItTUz/EXbD+j/d4mlq2GW8TsA4Tc8Kdma2JTAAJ5hrKWUQzkR/Esn2fjsqiVRYaQg== + +"@octokit/plugin-paginate-graphql@^5.0.0": + version "5.2.4" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-graphql/-/plugin-paginate-graphql-5.2.4.tgz#b6afda7b3f24cb93d2ab822ec8eac664a5d325d0" + integrity sha512-pLZES1jWaOynXKHOqdnwZ5ULeVR6tVVCMm+AUbp0htdcyXDU95WbkYdU4R2ej1wKj5Tu94Mee2Ne0PjPO9cCyA== + "@octokit/plugin-paginate-rest@11.3.1": version "11.3.1" resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.3.1.tgz#fe92d04b49f134165d6fbb716e765c2f313ad364" @@ -1685,6 +1946,13 @@ dependencies: "@octokit/types" "^13.5.0" +"@octokit/plugin-paginate-rest@^11.0.0": + version "11.3.5" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.3.5.tgz#a1929b3ba3dc7b63bc73bb6d3c7a3faf2a9c7649" + integrity sha512-cgwIRtKrpwhLoBi0CUNuY83DPGRMaWVjqVI/bGKsLJ4PzyWZNaEmhHroI2xlrVXkk6nFv0IsZpOp+ZWSWUS2AQ== + dependencies: + "@octokit/types" "^13.6.0" + "@octokit/plugin-paginate-rest@^9.0.0": version "9.2.1" resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.2.1.tgz#2e2a2f0f52c9a4b1da1a3aa17dabe3c459b9e401" @@ -1711,6 +1979,30 @@ dependencies: "@octokit/types" "^12.6.0" +"@octokit/plugin-rest-endpoint-methods@^13.0.0": + version "13.2.6" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-13.2.6.tgz#b9d343dbe88a6cb70cc7fa16faa98f0a29ffe654" + integrity sha512-wMsdyHMjSfKjGINkdGKki06VEkgdEldIGstIEyGX0wbYHGByOwN/KiM+hAAlUwAtPkP3gvXtVQA9L3ITdV2tVw== + dependencies: + "@octokit/types" "^13.6.1" + +"@octokit/plugin-retry@^7.0.0": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-retry/-/plugin-retry-7.1.2.tgz#242e2d19a72a50b5113bb25d7d2c622ce0373fa0" + integrity sha512-XOWnPpH2kJ5VTwozsxGurw+svB2e61aWlmk5EVIYZPwFK5F9h4cyPyj9CIKRyMXMHSwpIsI3mPOdpMmrRhe7UQ== + dependencies: + "@octokit/request-error" "^6.0.0" + "@octokit/types" "^13.0.0" + bottleneck "^2.15.3" + +"@octokit/plugin-throttling@^9.0.0": + version "9.3.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-throttling/-/plugin-throttling-9.3.2.tgz#cc05180e45e769d6726c5faed157e9ad3b6ab8c0" + integrity sha512-FqpvcTpIWFpMMwIeSoypoJXysSAQ3R+ALJhXXSG1HTP3YZOIeLmcNcimKaXxTcws+Sh6yoRl13SJ5r8sXc1Fhw== + dependencies: + "@octokit/types" "^13.0.0" + bottleneck "^2.15.3" + "@octokit/request-error@^5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-5.1.0.tgz#ee4138538d08c81a60be3f320cd71063064a3b30" @@ -1720,6 +2012,13 @@ deprecation "^2.0.0" once "^1.4.0" +"@octokit/request-error@^6.0.0", "@octokit/request-error@^6.1.0", "@octokit/request-error@^6.1.1": + version "6.1.5" + resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-6.1.5.tgz#907099e341c4e6179db623a0328d678024f54653" + integrity sha512-IlBTfGX8Yn/oFPMwSfvugfncK2EwRLjzbrpifNaMY8o/HTEAFqCA1FZxjD9cWvSKBHgrIhc4CSBIzMxiLsbzFQ== + dependencies: + "@octokit/types" "^13.0.0" + "@octokit/request-error@^6.0.1": version "6.1.1" resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-6.1.1.tgz#bed1b5f52ce7fefb1077a92bf42124ff36f73f2c" @@ -1737,6 +2036,16 @@ "@octokit/types" "^13.1.0" universal-user-agent "^6.0.0" +"@octokit/request@^9.0.0", "@octokit/request@^9.0.1", "@octokit/request@^9.1.0", "@octokit/request@^9.1.1": + version "9.1.3" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-9.1.3.tgz#42b693bc06238f43af3c037ebfd35621c6457838" + integrity sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA== + dependencies: + "@octokit/endpoint" "^10.0.0" + "@octokit/request-error" "^6.0.1" + "@octokit/types" "^13.1.0" + universal-user-agent "^7.0.2" + "@octokit/rest@20.1.1": version "20.1.1" resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-20.1.1.tgz#ec775864f53fb42037a954b9a40d4f5275b3dc95" @@ -1761,6 +2070,13 @@ dependencies: "@octokit/openapi-types" "^22.2.0" +"@octokit/types@^13.4.1", "@octokit/types@^13.6.0", "@octokit/types@^13.6.1": + version "13.6.1" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-13.6.1.tgz#432fc6c0aaae54318e5b2d3e15c22ac97fc9b15f" + integrity sha512-PHZE9Z+kWXb23Ndik8MKPirBPziOc0D2/3KH1P+6jK5nGWe96kadZuE4jev2/Jq7FvIfTlT2Ltg8Fv2x1v0a5g== + dependencies: + "@octokit/openapi-types" "^22.2.0" + "@octokit/webhooks-methods@^5.0.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@octokit/webhooks-methods/-/webhooks-methods-5.1.0.tgz#13b6c08f89902c1ab0ddf31c6eeeec9c2772cfe6" @@ -1776,6 +2092,15 @@ "@octokit/webhooks-methods" "^5.0.0" aggregate-error "^5.0.0" +"@octokit/webhooks@^13.0.0": + version "13.3.0" + resolved "https://registry.yarnpkg.com/@octokit/webhooks/-/webhooks-13.3.0.tgz#fd5d54d47c789c75d60a00eb04e982152d7c654a" + integrity sha512-TUkJLtI163Bz5+JK0O+zDkQpn4gKwN+BovclUvCj6pI/6RXrFqQvUMRS2M+Rt8Rv0qR3wjoMoOPmpJKeOh0nBg== + dependencies: + "@octokit/openapi-webhooks-types" "8.3.0" + "@octokit/request-error" "^6.0.1" + "@octokit/webhooks-methods" "^5.0.0" + "@open-draft/deferred-promise@^2.2.0": version "2.2.0" resolved "https://registry.yarnpkg.com/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz#4a822d10f6f0e316be4d67b4d4f8c9a124b073bd" @@ -1889,6 +2214,11 @@ "@supabase/realtime-js" "2.10.2" "@supabase/storage-js" "2.7.0" +"@types/aws-lambda@^8.10.83": + version "8.10.145" + resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.145.tgz#b2d31a987f4888e5553ff1819f57cafa475594d9" + integrity sha512-dtByW6WiFk5W5Jfgz1VM+YPA21xMXTuSFoLYIDY0L44jDLLflVPtZkYuu3/YxpGcvjzKFBZLU+GyKjR0HOYtyw== + "@types/babel__core@^7.1.14": version "7.20.5" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017" @@ -1934,6 +2264,11 @@ resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.6.0.tgz#eac397f28bf1d6ae0ae081363eca2f425bedf0d5" integrity sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA== +"@types/diff@^5.2.3": + version "5.2.3" + resolved "https://registry.yarnpkg.com/@types/diff/-/diff-5.2.3.tgz#dcdcfa40df9f011f9465180e0196dfbd921971d9" + integrity sha512-K0Oqlrq3kQMaO2RhfrNQX5trmt+XLyom88zS0u84nnIcLvFnRUMRRHmrGny5GSM+kNO9IZLARsdQHDzkhAgmrQ== + "@types/graceful-fs@^4.1.3": version "4.1.9" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" @@ -2465,6 +2800,11 @@ before-after-hook@^2.2.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ== +before-after-hook@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-3.0.2.tgz#d5665a5fa8b62294a5aa0a499f933f4a1016195d" + integrity sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A== + binary-extensions@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" @@ -2475,6 +2815,11 @@ blake3-wasm@^2.1.5: resolved "https://registry.yarnpkg.com/blake3-wasm/-/blake3-wasm-2.1.5.tgz#b22dbb84bc9419ed0159caa76af4b1b132e6ba52" integrity sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g== +bottleneck@^2.15.3: + version "2.19.5" + resolved "https://registry.yarnpkg.com/bottleneck/-/bottleneck-2.19.5.tgz#5df0b90f59fd47656ebe63c78a98419205cadd91" + integrity sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -3137,7 +3482,7 @@ dot-prop@^5.1.0: dependencies: is-obj "^2.0.0" -dotenv@^16.4.5: +dotenv@^16.3.1, dotenv@^16.4.5: version "16.4.5" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== @@ -3305,6 +3650,36 @@ esbuild@0.17.19: "@esbuild/win32-ia32" "0.17.19" "@esbuild/win32-x64" "0.17.19" +esbuild@^0.24.0: + version "0.24.0" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.24.0.tgz#f2d470596885fcb2e91c21eb3da3b3c89c0b55e7" + integrity sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ== + optionalDependencies: + "@esbuild/aix-ppc64" "0.24.0" + "@esbuild/android-arm" "0.24.0" + "@esbuild/android-arm64" "0.24.0" + "@esbuild/android-x64" "0.24.0" + "@esbuild/darwin-arm64" "0.24.0" + "@esbuild/darwin-x64" "0.24.0" + "@esbuild/freebsd-arm64" "0.24.0" + "@esbuild/freebsd-x64" "0.24.0" + "@esbuild/linux-arm" "0.24.0" + "@esbuild/linux-arm64" "0.24.0" + "@esbuild/linux-ia32" "0.24.0" + "@esbuild/linux-loong64" "0.24.0" + "@esbuild/linux-mips64el" "0.24.0" + "@esbuild/linux-ppc64" "0.24.0" + "@esbuild/linux-riscv64" "0.24.0" + "@esbuild/linux-s390x" "0.24.0" + "@esbuild/linux-x64" "0.24.0" + "@esbuild/netbsd-x64" "0.24.0" + "@esbuild/openbsd-arm64" "0.24.0" + "@esbuild/openbsd-x64" "0.24.0" + "@esbuild/sunos-x64" "0.24.0" + "@esbuild/win32-arm64" "0.24.0" + "@esbuild/win32-ia32" "0.24.0" + "@esbuild/win32-x64" "0.24.0" + esbuild@~0.21.4: version "0.21.5" resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.21.5.tgz#9ca301b120922959b766360d8ac830da0d02997d" @@ -3812,6 +4187,15 @@ git-raw-commits@^4.0.0: meow "^12.0.1" split2 "^4.0.0" +github-diff-tool@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/github-diff-tool/-/github-diff-tool-1.0.3.tgz#6845765b36b9f86ea0160f6c90e8a5774c274799" + integrity sha512-h+0XfJwzMwp6V5SwLZp/HANGgCMx3a+ulYe1V9rQ/HM5nvvDNtuUCAkdTv6Aa6qGxoX3BpATTQLJmFEnjmk94A== + dependencies: + dotenv "^16.3.1" + esbuild "^0.24.0" + octokit "^4.0.2" + glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -3887,6 +4271,11 @@ gopd@^1.0.1: dependencies: get-intrinsic "^1.1.3" +gpt-tokenizer@^2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/gpt-tokenizer/-/gpt-tokenizer-2.5.1.tgz#ff1175b9ae1325f0f5281e9797af078cb29295dc" + integrity sha512-26zNjvGrIf+a6yWg5l2DvNT4LXAmotHyx7IomHVhXiUs62BwKVFLv/l8yRQQrkUDc2XDtzCdjcNuJqzOjxxiPA== + graceful-fs@^4.1.2, graceful-fs@^4.2.9: version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" @@ -5005,6 +5394,11 @@ log-update@^6.0.0: strip-ansi "^7.1.0" wrap-ansi "^9.0.0" +lru-cache@^10.0.0: + version "10.4.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" + integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -5327,6 +5721,22 @@ object.assign@^4.1.5: has-symbols "^1.0.3" object-keys "^1.1.1" +octokit@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/octokit/-/octokit-4.0.2.tgz#775d68d363cdaec69d7b73d3dc82ae909d30f59b" + integrity sha512-wbqF4uc1YbcldtiBFfkSnquHtECEIpYD78YUXI6ri1Im5OO2NLo6ZVpRdbJpdnpZ05zMrVPssNiEo6JQtea+Qg== + dependencies: + "@octokit/app" "^15.0.0" + "@octokit/core" "^6.0.0" + "@octokit/oauth-app" "^7.0.0" + "@octokit/plugin-paginate-graphql" "^5.0.0" + "@octokit/plugin-paginate-rest" "^11.0.0" + "@octokit/plugin-rest-endpoint-methods" "^13.0.0" + "@octokit/plugin-retry" "^7.0.0" + "@octokit/plugin-throttling" "^9.0.0" + "@octokit/request-error" "^6.0.0" + "@octokit/types" "^13.0.0" + ohash@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/ohash/-/ohash-1.1.4.tgz#ae8d83014ab81157d2c285abf7792e2995fadd72" @@ -6527,11 +6937,21 @@ unicorn-magic@^0.1.0: resolved "https://registry.yarnpkg.com/unicorn-magic/-/unicorn-magic-0.1.0.tgz#1bb9a51c823aaf9d73a8bfcd3d1a23dde94b0ce4" integrity sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ== +universal-github-app-jwt@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/universal-github-app-jwt/-/universal-github-app-jwt-2.2.0.tgz#dc6c8929e76f1996a766ba2a08fb420f73365d77" + integrity sha512-G5o6f95b5BggDGuUfKDApKaCgNYy2x7OdHY0zSMF081O0EJobw+1130VONhrA7ezGSV2FNOGyM+KQpQZAr9bIQ== + universal-user-agent@^6.0.0: version "6.0.1" resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.1.tgz#15f20f55da3c930c57bddbf1734c6654d5fd35aa" integrity sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ== +universal-user-agent@^7.0.0, universal-user-agent@^7.0.2: + version "7.0.2" + resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-7.0.2.tgz#52e7d0e9b3dc4df06cc33cb2b9fd79041a54827e" + integrity sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q== + universalify@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.2.0.tgz#6451760566fa857534745ab1dde952d1b1761be0" From 312bede0f3a7c6e59617cece4c41ceaf080f6234 Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Sun, 27 Oct 2024 12:14:33 -0400 Subject: [PATCH 2/8] fix: adds sorting diff size and then adds diffs size wise add --- package.json | 2 +- src/adapters/openai/helpers/completions.ts | 2 +- src/handlers/ask-llm.ts | 1 - src/helpers/format-chat-history.ts | 32 ++++++++--- src/helpers/issue-fetching.ts | 63 +++++++++++++++++++--- yarn.lock | 8 +-- 6 files changed, 85 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 3984bfe..bcf7074 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@supabase/supabase-js": "^2.45.4", "@ubiquity-dao/ubiquibot-logger": "^1.3.0", "dotenv": "^16.4.5", - "github-diff-tool": "^1.0.3", + "github-diff-tool": "^1.0.6", "gpt-tokenizer": "^2.5.1", "openai": "^4.63.0", "typebox-validators": "0.3.5", diff --git a/src/adapters/openai/helpers/completions.ts b/src/adapters/openai/helpers/completions.ts index a2e2ee3..77592b5 100644 --- a/src/adapters/openai/helpers/completions.ts +++ b/src/adapters/openai/helpers/completions.ts @@ -119,7 +119,7 @@ export class Completions extends SuperOpenAi { return res.choices[0].message.content; } - async findTokenLength(prompt: string, additionalContext: string[], localContext: string[], groundTruths: string[]): Promise { + async findTokenLength(prompt: string, additionalContext: string[] = [], localContext: string[] = [], groundTruths: string[] = []): Promise { return encode(prompt + additionalContext.join("\n") + localContext.join("\n") + groundTruths.join("\n")).length; } } diff --git a/src/handlers/ask-llm.ts b/src/handlers/ask-llm.ts index 4e34048..33562c5 100644 --- a/src/handlers/ask-llm.ts +++ b/src/handlers/ask-llm.ts @@ -69,7 +69,6 @@ export async function askGpt(context: Context, question: string, formattedChat: "supabase", "openai", ]); - // TODO: If numTokens exceed limit then limit the context size context.logger.info(`Number of tokens: ${numTokens}`); const languages = await fetchRepoLanguageStats(context); diff --git a/src/helpers/format-chat-history.ts b/src/helpers/format-chat-history.ts index edbc289..588dc0d 100644 --- a/src/helpers/format-chat-history.ts +++ b/src/helpers/format-chat-history.ts @@ -3,6 +3,7 @@ import { StreamlinedComment, StreamlinedComments } from "../types/llm"; import { createKey, streamlineComments } from "../handlers/comments"; import { fetchPullRequestDiff, fetchIssue, fetchIssueComments, fetchLinkedPrFromIssue } from "./issue-fetching"; import { splitKey } from "./issue"; +const MAX_TOKENS_ALLOWED = 7000; /** * Formats the chat history by combining streamlined comments and specifications or bodies for issues and pull requests. @@ -18,10 +19,13 @@ export async function formatChatHistory( specAndBodies: Record ): Promise { const keys = new Set([...Object.keys(streamlined), ...Object.keys(specAndBodies), createKey(context.payload.issue.html_url)]); + let runningTokenCount = 0; const chatHistory = await Promise.all( Array.from(keys).map(async (key) => { const isCurrentIssue = key === createKey(context.payload.issue.html_url); - return createContextBlockSection(context, key, streamlined, specAndBodies, isCurrentIssue); + const [currentTokenCount, result] = await createContextBlockSection(context, key, streamlined, specAndBodies, isCurrentIssue, runningTokenCount); + runningTokenCount += currentTokenCount; + return result; }) ); return Array.from(new Set(chatHistory)); @@ -65,8 +69,9 @@ async function createContextBlockSection( key: string, streamlined: Record, specAndBodies: Record, - isCurrentIssue: boolean -) { + isCurrentIssue: boolean, + currentContextTokenCount: number = 0 +): Promise<[number, string]> { let comments = streamlined[key]; if (!comments || comments.length === 0) { const [owner, repo, number] = splitKey(key); @@ -84,8 +89,17 @@ async function createContextBlockSection( throw context.logger.error("Issue number is not valid"); } const pulls = await fetchLinkedPrFromIssue(org, repo, issueNumber, context); - const prDiffs = await Promise.all(pulls.map(async (pull) => await fetchPullRequestDiff(context, org, repo, pull.number))); - const prDiff = prDiffs.join("\n"); + const prDiffs = await Promise.all(pulls.map((pull) => fetchPullRequestDiff(context, org, repo, pull.number))); + let prDiff: string | null = null; + for (const pullDiff of prDiffs.flat()) { + if (currentContextTokenCount > MAX_TOKENS_ALLOWED) break; + if (pullDiff) { + const tokenLength = await context.adapters.openai.completions.findTokenLength(pullDiff.diff); + if (currentContextTokenCount + tokenLength > MAX_TOKENS_ALLOWED) break; + currentContextTokenCount += tokenLength; + prDiff = (prDiff ? prDiff + "\n" : "") + pullDiff.diff; + } + } const specHeader = getCorrectHeaderString(prDiff, issueNumber, isCurrentIssue, false); let specOrBody = specAndBodies[key]; if (!specOrBody) { @@ -100,14 +114,16 @@ async function createContextBlockSection( )?.body || "No specification or body available"; } const specOrBodyBlock = [createHeader(specHeader, key), createSpecOrBody(specOrBody), createFooter(specHeader)]; + currentContextTokenCount += await context.adapters.openai.completions.findTokenLength(specOrBody); const header = getCorrectHeaderString(prDiff, issueNumber, isCurrentIssue, true); const repoString = `${org}/${repo} #${issueNumber}`; const block = [specOrBodyBlock.join(""), createHeader(header, repoString), createComment({ issueNumber, repo, org, comments }), createFooter(header)]; + currentContextTokenCount += await context.adapters.openai.completions.findTokenLength(block.join(" ")); if (!prDiff) { - return block.join(""); + return [currentContextTokenCount, block.join("")]; } - const diffBlock = [createHeader("Linked Pull Request Code Diff", repoString), prDiff, createFooter("Linked Pull Request Code Diff")]; - return block.concat(diffBlock).join(""); + const diffBlock = [createHeader("Linked Pull Request Code Diff", repoString), prDiff, createFooter("\nLinked Pull Request Code Diff")]; + return [currentContextTokenCount, block.join("") + diffBlock.join("")]; } /** diff --git a/src/helpers/issue-fetching.ts b/src/helpers/issue-fetching.ts index 62721d3..edce620 100644 --- a/src/helpers/issue-fetching.ts +++ b/src/helpers/issue-fetching.ts @@ -165,21 +165,40 @@ export async function mergeCommentsAndFetchSpec( * @param issue - The pull request number. * @returns A promise that resolves to the diff of the pull request as a string, or null if an error occurs. */ -export async function fetchPullRequestDiff(context: Context, org: string, repo: string, issue: number): Promise { +export async function fetchPullRequestDiff(context: Context, org: string, repo: string, issue: number): Promise<{ diff: string; diffSize: number }[] | null> { const { octokit, logger } = context; try { const githubDiff = new GithubDiff(octokit); //Fetch the statistics of the pull request const stats = await githubDiff.getPullRequestStats(org, repo, issue); - //Find the filenames which do not have more than 200 changes - let files = stats.filter((file) => file.changes < 500).map((file) => file.filename); //Ignore files like in dist or build or .lock files - const ignoredFiles = ["dist/*", "build/*", ".lock", "index.js"]; - files = files.filter((file) => !ignoredFiles.some((pattern) => file.match(pattern))); + const ignoredFiles = (await buildIgnoreFilesFromGitIgnore(context, org, repo)) || []; + const files = stats + .filter((file) => !ignoredFiles.some((pattern) => file.filename.includes(pattern))) + .map((file) => ({ filename: file.filename, diffSizeInBytes: file.diffSizeInBytes })); //Fetch the diff of the files - return await githubDiff.getPullRequestDiffsFiltered(org, repo, issue, { - includeFiles: files, - }); + const prDiffs = await Promise.all( + files.map(async (file) => { + let diff = null; + try { + diff = await githubDiff.getPullRequestDiff({ + owner: org, + repo, + pullNumber: issue, + filePath: file.filename, + }); + } catch { + logger.error(`Error fetching pull request diff for the file`, { + owner: org, + repo, + pull_number: issue, + file: file.filename, + }); + } + return diff ? { diff: file.filename + diff, diffSize: file.diffSizeInBytes } : null; + }) + ); + return prDiffs.filter((diff): diff is { diff: string; diffSize: number } => diff !== null).sort((a, b) => a.diffSize - b.diffSize); } catch (error) { logger.error(`Error fetching pull request diff`, { error: error as Error, @@ -309,3 +328,31 @@ export async function fetchLinkedPrFromIssue(owner: string, repo: string, issueN //Filter the PRs which are linked to the issue using the body of the PR return prs.data.filter((pr) => pr.body?.includes(`#${issueNumber}`)); } + +async function buildIgnoreFilesFromGitIgnore(context: Context, owner: string, repo: string): Promise { + try { + const gitignore = await context.octokit.rest.repos.getContent({ + owner, + repo, + path: ".gitignore", + }); + // Build an array of files to ignore + const ignoreFiles: string[] = []; + if ("content" in gitignore.data) { + const content = Buffer.from(gitignore.data.content, "base64").toString(); + content.split("\n").forEach((line) => { + if (line && !line.startsWith("#")) { + ignoreFiles.push(line); + } + }); + } + return ignoreFiles; + } catch (error) { + context.logger.error(`Error fetching .gitignore file`, { + error: error as Error, + owner, + repo, + }); + return null; + } +} diff --git a/yarn.lock b/yarn.lock index 71910e2..01d3a78 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4187,10 +4187,10 @@ git-raw-commits@^4.0.0: meow "^12.0.1" split2 "^4.0.0" -github-diff-tool@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/github-diff-tool/-/github-diff-tool-1.0.3.tgz#6845765b36b9f86ea0160f6c90e8a5774c274799" - integrity sha512-h+0XfJwzMwp6V5SwLZp/HANGgCMx3a+ulYe1V9rQ/HM5nvvDNtuUCAkdTv6Aa6qGxoX3BpATTQLJmFEnjmk94A== +github-diff-tool@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/github-diff-tool/-/github-diff-tool-1.0.6.tgz#e633b46397db850ad3dc0d500450357cb7ee26f9" + integrity sha512-DOqKck+WUj3HsfOwef5cjS32qqOkKWFncIl4erBtp2+dfccrkSi6Ee14mKGnrQaAhMrx/9LWFh8X5KGivZVY8A== dependencies: dotenv "^16.3.1" esbuild "^0.24.0" From 4e928df4cc85b1aee0a7fa1acd9af946d9ff28f1 Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Sun, 27 Oct 2024 12:18:28 -0400 Subject: [PATCH 3/8] fix: removed context optimizer --- src/helpers/issue.ts | 55 -------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/src/helpers/issue.ts b/src/helpers/issue.ts index 68fcda7..d52405d 100644 --- a/src/helpers/issue.ts +++ b/src/helpers/issue.ts @@ -166,61 +166,6 @@ export async function fetchCodeLinkedFromIssue( })); } -/** - * Optimizes the context strings by removing duplicates and sorting by information density. - * Removes exact duplicates and sorts by information density and length. - * - * @param strings - The array of context strings to optimize. - * @returns The optimized array of context strings. - */ -export function optimizeContext(strings: string[]): string[] { - // Helper function to clean strings while preserving links - function cleanString(inputString: string): string { - // Preserve links by temporarily replacing them - const links: string[] = []; - inputString = inputString.replace(/https?:\/\/\S+/g, (match) => { - links.push(match); - return `__LINK${links.length - 1}__`; - }); - // Clean the string - inputString = inputString - .replace(/[^\w\s-/]|_/g, "") // Remove punctuation except '-' and '/' - .replace(/\s+/g, " ") - .trim() - .toLowerCase(); - // Restore links - inputString = inputString.replace(/__LINK(\d+)__/g, (i) => links[parseInt(i)]); - - return inputString; - } - // Helper function to calculate information density - function informationDensity(s: string): number { - const words = s.split(/\s+/); - const uniqueWords = new Set(words); - return uniqueWords.size / words.length; - } - // Clean and remove empty strings - const cleanedStrings = strings.map(cleanString).filter((s) => s.length > 0); - // Remove exact duplicates - const uniqueStrings = Array.from(new Set(cleanedStrings)); - // Sort strings by information density and length - uniqueStrings.sort((a, b) => { - const densityDiff = informationDensity(b) - informationDensity(a); - return densityDiff !== 0 ? densityDiff : b.length - a.length; - }); - const result: string[] = []; - const wordSet = new Set(); - for (const str of uniqueStrings) { - const words = str.split(/\s+/); - const newWords = words.filter((word) => !wordSet.has(word) && !word.startsWith("http")); - if (newWords.length > 0 || str.includes("http")) { - result.push(str); - newWords.forEach((word) => wordSet.add(word)); - } - } - return result; -} - /** * Extracts and returns the README content from the repository associated with the given issue. * From e0b252a211998ca10ffd42d3f31e47b503f53aeb Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Sun, 27 Oct 2024 12:19:22 -0400 Subject: [PATCH 4/8] fix: knip --- package.json | 1 - yarn.lock | 5 ----- 2 files changed, 6 deletions(-) diff --git a/package.json b/package.json index bcf7074..92e3a93 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "@cspell/dict-typescript": "3.1.5", "@eslint/js": "9.5.0", "@jest/globals": "29.7.0", - "@types/diff": "^5.2.3", "@types/jest": "^29.5.12", "@types/node": "20.14.5", "cspell": "8.9.0", diff --git a/yarn.lock b/yarn.lock index 01d3a78..6c98d95 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2264,11 +2264,6 @@ resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.6.0.tgz#eac397f28bf1d6ae0ae081363eca2f425bedf0d5" integrity sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA== -"@types/diff@^5.2.3": - version "5.2.3" - resolved "https://registry.yarnpkg.com/@types/diff/-/diff-5.2.3.tgz#dcdcfa40df9f011f9465180e0196dfbd921971d9" - integrity sha512-K0Oqlrq3kQMaO2RhfrNQX5trmt+XLyom88zS0u84nnIcLvFnRUMRRHmrGny5GSM+kNO9IZLARsdQHDzkhAgmrQ== - "@types/graceful-fs@^4.1.3": version "4.1.9" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" From 9efaf5342c27ac3ed0c58a5457471c8e658d9178 Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Sun, 27 Oct 2024 12:41:04 -0400 Subject: [PATCH 5/8] fix: conflicts --- package.json | 2 +- src/handlers/ask-llm.ts | 16 +++------------- tests/main.test.ts | 4 ++-- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 92e3a93..2d2aca5 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "knip-ci": "knip --no-exit-code --reporter json --config .github/knip.ts", "prepare": "husky install", "test": "jest --setupFiles dotenv/config --coverage", - "worker": "wrangler dev --env dev --port 4000" + "worker": "wrangler dev --env dev --port 5000" }, "keywords": [ "typescript", diff --git a/src/handlers/ask-llm.ts b/src/handlers/ask-llm.ts index 33562c5..962bb7e 100644 --- a/src/handlers/ask-llm.ts +++ b/src/handlers/ask-llm.ts @@ -59,18 +59,6 @@ export async function askGpt(context: Context, question: string, formattedChat: formattedChat = formattedChat.filter((text) => text !== null); similarText = similarText.filter((text) => text !== ""); const rerankedText = similarText.length > 0 ? await context.adapters.voyage.reranker.reRankResults(similarText, question) : []; - //Calculate the current context size in tokens - const numTokens = await context.adapters.openai.completions.findTokenLength(question, rerankedText, formattedChat, [ - "typescript", - "github", - "cloudflare worker", - "actions", - "jest", - "supabase", - "openai", - ]); - context.logger.info(`Number of tokens: ${numTokens}`); - const languages = await fetchRepoLanguageStats(context); const { dependencies, devDependencies } = await fetchRepoDependencies(context); const groundTruths = await findGroundTruths(context, "chat-bot", { @@ -78,6 +66,8 @@ export async function askGpt(context: Context, question: string, formattedChat: dependencies, devDependencies, }); - + //Calculate the current context size in tokens + const numTokens = await context.adapters.openai.completions.findTokenLength(question, rerankedText, formattedChat, groundTruths); + context.logger.info(`Number of tokens: ${numTokens}`); return context.adapters.openai.completions.createCompletion(question, model, rerankedText, formattedChat, groundTruths, UBIQUITY_OS_APP_NAME); } diff --git a/tests/main.test.ts b/tests/main.test.ts index d61fdfb..361f7e3 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -107,7 +107,7 @@ describe("Ask plugin tests", () => { createComments([transformCommentTemplate(1, 1, TEST_QUESTION, "ubiquity", "test-repo", true)]); await runPlugin(ctx); - expect(infoSpy).toHaveBeenCalledTimes(4); + expect(infoSpy).toHaveBeenCalledTimes(5); expect(infoSpy).toHaveBeenNthCalledWith(1, `Asking question: @UbiquityOS ${TEST_QUESTION}`); expect(infoSpy).toHaveBeenNthCalledWith(4, "Answer: This is a mock answer for the chat", { caller: LOG_CALLER, @@ -131,7 +131,7 @@ describe("Ask plugin tests", () => { await runPlugin(ctx); - expect(infoSpy).toHaveBeenCalledTimes(4); + expect(infoSpy).toHaveBeenCalledTimes(5); expect(infoSpy).toHaveBeenNthCalledWith(1, `Asking question: @UbiquityOS ${TEST_QUESTION}`); From c4b43d7ae9e109e807bdc7f41c1aae989f260b6b Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Sun, 27 Oct 2024 13:39:12 -0400 Subject: [PATCH 6/8] fix: updated logic for fetching linked pr --- src/adapters/openai/helpers/completions.ts | 6 +-- src/handlers/ask-llm.ts | 4 +- src/helpers/format-chat-history.ts | 10 ++--- src/helpers/issue-fetching.ts | 45 +++++++++++++++++----- src/types/github-types.d.ts | 18 +++++++++ src/types/plugin-inputs.ts | 1 + 6 files changed, 65 insertions(+), 19 deletions(-) diff --git a/src/adapters/openai/helpers/completions.ts b/src/adapters/openai/helpers/completions.ts index 77592b5..3a5f24a 100644 --- a/src/adapters/openai/helpers/completions.ts +++ b/src/adapters/openai/helpers/completions.ts @@ -3,7 +3,6 @@ import { Context } from "../../../types"; import { SuperOpenAi } from "./openai"; import { CompletionsModelHelper, ModelApplications } from "../../../types/llm"; import { encode } from "gpt-tokenizer"; -const MAX_TOKENS = 7000; export interface CompletionsType { answer: string; @@ -29,7 +28,8 @@ export class Completions extends SuperOpenAi { additionalContext: string[], localContext: string[], groundTruths: string[], - botName: string + botName: string, + maxTokens: number ): Promise { const res: OpenAI.Chat.Completions.ChatCompletion = await this.client.chat.completions.create({ model: model, @@ -65,7 +65,7 @@ export class Completions extends SuperOpenAi { }, ], temperature: 0.2, - max_tokens: MAX_TOKENS, + max_tokens: maxTokens, top_p: 0.5, frequency_penalty: 0, presence_penalty: 0, diff --git a/src/handlers/ask-llm.ts b/src/handlers/ask-llm.ts index 962bb7e..f58b3aa 100644 --- a/src/handlers/ask-llm.ts +++ b/src/handlers/ask-llm.ts @@ -38,7 +38,7 @@ export async function askQuestion(context: Context, question: string) { export async function askGpt(context: Context, question: string, formattedChat: string[]): Promise { const { env: { UBIQUITY_OS_APP_NAME }, - config: { model, similarityThreshold }, + config: { model, similarityThreshold, maxTokens }, } = context; let similarComments: CommentSimilaritySearchResult[] = []; let similarIssues: IssueSimilaritySearchResult[] = []; @@ -69,5 +69,5 @@ export async function askGpt(context: Context, question: string, formattedChat: //Calculate the current context size in tokens const numTokens = await context.adapters.openai.completions.findTokenLength(question, rerankedText, formattedChat, groundTruths); context.logger.info(`Number of tokens: ${numTokens}`); - return context.adapters.openai.completions.createCompletion(question, model, rerankedText, formattedChat, groundTruths, UBIQUITY_OS_APP_NAME); + return context.adapters.openai.completions.createCompletion(question, model, rerankedText, formattedChat, groundTruths, UBIQUITY_OS_APP_NAME, maxTokens); } diff --git a/src/helpers/format-chat-history.ts b/src/helpers/format-chat-history.ts index 588dc0d..ecb2b38 100644 --- a/src/helpers/format-chat-history.ts +++ b/src/helpers/format-chat-history.ts @@ -1,9 +1,8 @@ import { Context } from "../types"; import { StreamlinedComment, StreamlinedComments } from "../types/llm"; import { createKey, streamlineComments } from "../handlers/comments"; -import { fetchPullRequestDiff, fetchIssue, fetchIssueComments, fetchLinkedPrFromIssue } from "./issue-fetching"; +import { fetchPullRequestDiff, fetchIssue, fetchIssueComments, fetchLinkedPullRequests } from "./issue-fetching"; import { splitKey } from "./issue"; -const MAX_TOKENS_ALLOWED = 7000; /** * Formats the chat history by combining streamlined comments and specifications or bodies for issues and pull requests. @@ -72,6 +71,7 @@ async function createContextBlockSection( isCurrentIssue: boolean, currentContextTokenCount: number = 0 ): Promise<[number, string]> { + const maxTokens = context.config.maxTokens; let comments = streamlined[key]; if (!comments || comments.length === 0) { const [owner, repo, number] = splitKey(key); @@ -88,14 +88,14 @@ async function createContextBlockSection( if (!issueNumber || isNaN(issueNumber)) { throw context.logger.error("Issue number is not valid"); } - const pulls = await fetchLinkedPrFromIssue(org, repo, issueNumber, context); + const pulls = (await fetchLinkedPullRequests(org, repo, issueNumber, context)) || []; const prDiffs = await Promise.all(pulls.map((pull) => fetchPullRequestDiff(context, org, repo, pull.number))); let prDiff: string | null = null; for (const pullDiff of prDiffs.flat()) { - if (currentContextTokenCount > MAX_TOKENS_ALLOWED) break; + if (currentContextTokenCount > maxTokens) break; if (pullDiff) { const tokenLength = await context.adapters.openai.completions.findTokenLength(pullDiff.diff); - if (currentContextTokenCount + tokenLength > MAX_TOKENS_ALLOWED) break; + if (currentContextTokenCount + tokenLength > maxTokens) break; currentContextTokenCount += tokenLength; prDiff = (prDiff ? prDiff + "\n" : "") + pullDiff.diff; } diff --git a/src/helpers/issue-fetching.ts b/src/helpers/issue-fetching.ts index edce620..e8399b8 100644 --- a/src/helpers/issue-fetching.ts +++ b/src/helpers/issue-fetching.ts @@ -1,7 +1,7 @@ import { GithubDiff } from "github-diff-tool"; import { createKey, getAllStreamlinedComments } from "../handlers/comments"; import { Context } from "../types"; -import { IssueWithUser, SimplifiedComment, User } from "../types/github-types"; +import { IssueWithUser, LinkedPullsToIssue, SimplifiedComment, User } from "../types/github-types"; import { FetchParams, Issue, Comments, LinkedIssues } from "../types/github-types"; import { StreamlinedComment } from "../types/llm"; import { @@ -319,14 +319,41 @@ function castCommentsToSimplifiedComments(comments: Comments, params: FetchParam })); } -export async function fetchLinkedPrFromIssue(owner: string, repo: string, issueNumber: number, context: Context) { - const prs = await context.octokit.rest.pulls.list({ - owner: owner, - repo: repo, - state: "all", - }); - //Filter the PRs which are linked to the issue using the body of the PR - return prs.data.filter((pr) => pr.body?.includes(`#${issueNumber}`)); +export async function fetchLinkedPullRequests(owner: string, repo: string, issueNumber: number, context: Context) { + const query = ` + query($owner: String!, $repo: String!, $issueNumber: Int!) { + repository(owner: $owner, name: $repo) { + issue(number: $issueNumber) { + closedByPullRequestsReferences(first: 100) { + nodes { + number + title + state + merged + url + } + } + } + } + } + `; + + try { + const { repository } = await context.octokit.graphql(query, { + owner, + repo, + issueNumber, + }); + return repository.issue.closedByPullRequestsReferences.nodes; + } catch (error) { + context.logger.error(`Error fetching linked PRs from issue`, { + error: error as Error, + owner, + repo, + issueNumber, + }); + return null; + } } async function buildIgnoreFilesFromGitIgnore(context: Context, owner: string, repo: string): Promise { diff --git a/src/types/github-types.d.ts b/src/types/github-types.d.ts index 23a0b18..7f72549 100644 --- a/src/types/github-types.d.ts +++ b/src/types/github-types.d.ts @@ -44,3 +44,21 @@ export type FetchedCodes = { repo: string; issueNumber: number; }; + +export type FetchedPulls = { + number: number; + title: string; + state: string; + merged: boolean; + url: string; +}; + +export type LinkedPullsToIssue = { + repository: { + issue: { + closedByPullRequestsReferences: { + nodes: FetchedPulls[]; + }; + }; + }; +}; diff --git a/src/types/plugin-inputs.ts b/src/types/plugin-inputs.ts index a98f0be..086578c 100644 --- a/src/types/plugin-inputs.ts +++ b/src/types/plugin-inputs.ts @@ -23,6 +23,7 @@ export const pluginSettingsSchema = T.Object({ model: T.String({ default: "o1-mini" }), openAiBaseUrl: T.Optional(T.String()), similarityThreshold: T.Number({ default: 0.9 }), + maxTokens: T.Number({ default: 10000 }), }); export const pluginSettingsValidator = new StandardValidator(pluginSettingsSchema); From 195e8e818d7215fee62d1c9f734c5a47be2d696a Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Sun, 27 Oct 2024 21:35:02 -0400 Subject: [PATCH 7/8] fix: remove file ignores --- src/helpers/issue-fetching.ts | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/src/helpers/issue-fetching.ts b/src/helpers/issue-fetching.ts index e8399b8..aa953ad 100644 --- a/src/helpers/issue-fetching.ts +++ b/src/helpers/issue-fetching.ts @@ -171,11 +171,7 @@ export async function fetchPullRequestDiff(context: Context, org: string, repo: const githubDiff = new GithubDiff(octokit); //Fetch the statistics of the pull request const stats = await githubDiff.getPullRequestStats(org, repo, issue); - //Ignore files like in dist or build or .lock files - const ignoredFiles = (await buildIgnoreFilesFromGitIgnore(context, org, repo)) || []; - const files = stats - .filter((file) => !ignoredFiles.some((pattern) => file.filename.includes(pattern))) - .map((file) => ({ filename: file.filename, diffSizeInBytes: file.diffSizeInBytes })); + const files = stats.map((file) => ({ filename: file.filename, diffSizeInBytes: file.diffSizeInBytes })); //Fetch the diff of the files const prDiffs = await Promise.all( files.map(async (file) => { @@ -355,31 +351,3 @@ export async function fetchLinkedPullRequests(owner: string, repo: string, issue return null; } } - -async function buildIgnoreFilesFromGitIgnore(context: Context, owner: string, repo: string): Promise { - try { - const gitignore = await context.octokit.rest.repos.getContent({ - owner, - repo, - path: ".gitignore", - }); - // Build an array of files to ignore - const ignoreFiles: string[] = []; - if ("content" in gitignore.data) { - const content = Buffer.from(gitignore.data.content, "base64").toString(); - content.split("\n").forEach((line) => { - if (line && !line.startsWith("#")) { - ignoreFiles.push(line); - } - }); - } - return ignoreFiles; - } catch (error) { - context.logger.error(`Error fetching .gitignore file`, { - error: error as Error, - owner, - repo, - }); - return null; - } -} From 30f876ca3925ef15e9e094af38bb44f64de302af Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Sun, 27 Oct 2024 21:39:39 -0400 Subject: [PATCH 8/8] fix: package.json missing issue --- src/handlers/ask-llm.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/handlers/ask-llm.ts b/src/handlers/ask-llm.ts index f58b3aa..f07e154 100644 --- a/src/handlers/ask-llm.ts +++ b/src/handlers/ask-llm.ts @@ -60,7 +60,15 @@ export async function askGpt(context: Context, question: string, formattedChat: similarText = similarText.filter((text) => text !== ""); const rerankedText = similarText.length > 0 ? await context.adapters.voyage.reranker.reRankResults(similarText, question) : []; const languages = await fetchRepoLanguageStats(context); - const { dependencies, devDependencies } = await fetchRepoDependencies(context); + let dependencies = {}; + let devDependencies = {}; + try { + const deps = await fetchRepoDependencies(context); + dependencies = deps.dependencies; + devDependencies = deps.devDependencies; + } catch (error) { + context.logger.error(`Unable to Fetch Dependencies: ${(error as Error).message}`); + } const groundTruths = await findGroundTruths(context, "chat-bot", { languages, dependencies,