diff --git a/core/context/providers/GitHubIssuesContextProvider.ts b/core/context/providers/GitHubIssuesContextProvider.ts index 673455037..f94e10768 100644 --- a/core/context/providers/GitHubIssuesContextProvider.ts +++ b/core/context/providers/GitHubIssuesContextProvider.ts @@ -9,7 +9,7 @@ import { class GitHubIssuesContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { - title: "github", + title: "issue", displayTitle: "GitHub Issues", description: "Reference GitHub issues", type: "submenu", @@ -19,13 +19,75 @@ class GitHubIssuesContextProvider extends BaseContextProvider { query: string, extras: ContextProviderExtras ): Promise { - return []; + const issueId = query; + const { Octokit } = await import("@octokit/rest"); + + const octokit = new Octokit({ + auth: this.options?.githubToken, + }); + + const { owner, repo, issue_number } = JSON.parse(issueId); + + const issue = await octokit.issues.get({ + owner, + repo, + issue_number, + }); + + let content = `# GitHub Issue #${issue.data.number.toString()} in ${owner}/${repo}`; + + const comments = await octokit.issues.listComments({ + owner, + repo, + issue_number, + }); + + const parts = [ + issue.data.body || "No description", + ...comments.data.map((comment) => comment.body), + ]; + content += "\n\n" + parts.join("\n\n---\n\n"); + + return [ + { + name: issue.data.title, + content, + description: `#${issue.data.number.toString()}`, + }, + ]; } async loadSubmenuItems( args: LoadSubmenuItemsArgs ): Promise { - return []; + const { Octokit } = await import("@octokit/rest"); + + const octokit = new Octokit({ + auth: this.options?.githubToken, + }); + + const allIssues = []; + + for (const repo of this.options?.repos) { + const issues = await octokit.issues.listForRepo({ + owner: repo.owner, + repo: repo.repo, + state: repo.type || "open", + }); + allIssues.push( + ...issues.data.map((issue) => ({ + title: issue.title, + description: `#${issue.number.toString()}`, + id: JSON.stringify({ + owner: repo.owner, + repo: repo.repo, + issue_number: issue.number, + }), + })) + ); + } + + return allIssues; } } diff --git a/docs/docs/customization/context-providers.md b/docs/docs/customization/context-providers.md index b8fc1c91f..1b8bfcd98 100644 --- a/docs/docs/customization/context-providers.md +++ b/docs/docs/customization/context-providers.md @@ -82,17 +82,21 @@ Type '@google' to reference the results of a Google search. For example, type "@ Note: You can get an API key for free at [serper.dev](https://serper.dev). -### GitHub +### GitHub Issues -Type '@issue' to reference the title and contents of a GitHub issue. +Type '@issue' to reference the conversation inside of a GitHub issue. ```json { - "name": "github", + "name": "issue", "params": { - // Change to whichever repo you want to use - "repoName": "continuedev/continue", - "authToken": "" + "repos": [ + { + "owner": "continuedev", + "repo": "continue" + } + ], + "githubToken": "" } } ``` diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 82e3f8dc6..0e899a6e6 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1045,13 +1045,13 @@ "type": "string", "description": "The type of issues to search for", "enum": ["open", "closed", "all"] - }, - "required": ["owner", "repo"] - } + } + }, + "required": ["owner", "repo"] } - }, - "required": ["repos"] - } + } + }, + "required": ["repos"] } }, "required": ["params"] diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 89a8f1f41..9b1ecb1a4 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -77,6 +77,7 @@ "version": "1.0.0", "license": "Apache-2.0", "dependencies": { + "@octokit/rest": "^20.0.2", "@xenova/transformers": "^2.14.0", "cheerio": "^1.0.0-rc.12", "dotenv": "^16.3.1", diff --git a/extensions/vscode/yarn.lock b/extensions/vscode/yarn.lock index 8a94e3b24..887d9ee0b 100644 --- a/extensions/vscode/yarn.lock +++ b/extensions/vscode/yarn.lock @@ -2268,6 +2268,7 @@ core-util-is@~1.0.0, core-util-is@1.0.2: version "1.0.0" resolved "file:../../core" dependencies: + "@octokit/rest" "^20.0.2" "@xenova/transformers" "^2.14.0" cheerio "^1.0.0-rc.12" dotenv "^16.3.1" diff --git a/gui/package-lock.json b/gui/package-lock.json index 3b618bfe1..4c266a718 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -65,6 +65,7 @@ "version": "1.0.0", "license": "Apache-2.0", "dependencies": { + "@octokit/rest": "^20.0.2", "@xenova/transformers": "^2.14.0", "cheerio": "^1.0.0-rc.12", "dotenv": "^16.3.1", @@ -7435,6 +7436,7 @@ "core": { "version": "file:../core", "requires": { + "@octokit/rest": "^20.0.2", "@types/handlebars": "^4.1.0", "@types/jest": "^29.5.11", "@types/jquery": "^3.5.29", diff --git a/gui/src/components/mainInput/MentionList.tsx b/gui/src/components/mainInput/MentionList.tsx index 376c3223e..9abfd2d6c 100644 --- a/gui/src/components/mainInput/MentionList.tsx +++ b/gui/src/components/mainInput/MentionList.tsx @@ -56,6 +56,7 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = { problems: ExclamationTriangleIcon, folder: FolderIcon, docs: BookOpenIcon, + issue: ExclamationCircleIcon, "/edit": PaintBrushIcon, "/clear": TrashIcon, "/test": BeakerIcon, @@ -74,18 +75,19 @@ function DropdownIcon(props: { type: ComboBoxItemType; }) { const Icon = ICONS_FOR_DROPDOWN[props.provider]; + const iconClass = `${props.className} flex-shrink-0`; if (!Icon) { return props.type === "contextProvider" ? ( - + ) : ( ); } - return ; + return ; } const ItemsDiv = styled.div` @@ -339,6 +341,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => { float: "right", textAlign: "right", opacity: index !== selectedIndex ? 0 : 1, + minWidth: "30px", }} className="whitespace-nowrap overflow-hidden overflow-ellipsis ml-2 flex items-center" > @@ -346,7 +349,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => { {item.type === "contextProvider" && item.contextProvider?.type === "submenu" && (