diff --git a/core/context/providers/JiraIssuesContextProvider.ts b/core/context/providers/JiraIssuesContextProvider.ts new file mode 100644 index 000000000..a6cf4fc59 --- /dev/null +++ b/core/context/providers/JiraIssuesContextProvider.ts @@ -0,0 +1,136 @@ +import { BaseContextProvider } from ".."; +import { + ContextItem, + ContextProviderDescription, + ContextProviderExtras, + ContextSubmenuItem, + LoadSubmenuItemsArgs, +} from "../.."; +import type { AxiosInstance } from "axios"; + +interface JiraComment { + id: string; + created: string; + updated: string; + author: { + emailAddress: string; + displayName: string; + }; + body: object; +} + +interface JiraIssue { + id: string; + key: string; + fields: { + summary: string; + description: object; + comment: { + total: number; + comments: Array; + }; + }; +} + +interface QueryResults { + issues: JiraIssue[]; +} + +class JiraIssuesContextProvider extends BaseContextProvider { + static description: ContextProviderDescription = { + title: "jira", + displayTitle: "Jira Issues", + description: "Reference Jira issues", + type: "submenu", + }; + + private async createApi(): Promise { + const { default: Axios } = await import("axios"); + + return Axios.create({ + baseURL: `https://${this.options.domain}/rest/api/3/`, + auth: { + username: this.options.email, + password: this.options.token, + }, + }); + } + + async getContextItems( + query: string, + extras: ContextProviderExtras + ): Promise { + const issueId = query; + + const api = await this.createApi(); + + const issue = await api + .get(`/issue/${issueId}`, { + params: { + fields: "description,comment,summary", + }, + }) + .then((result) => result.data); + + // @ts-ignore + const adf2md = await import("adf2md/dist/adf2md.min.js"); + + const parts = [ + `# Jira Issue ${issue.key}: ${issue.fields.summary}`, + "## Description", + issue.fields.description + ? adf2md.convert(issue.fields.description).result + : "No description", + ]; + + if (issue.fields.comment.comments.length > 0) { + parts.push("## Comments"); + + parts.push( + ...issue.fields.comment.comments.map((comment) => { + const commentText = adf2md.convert(comment.body).result; + + return `### ${comment.author.displayName} on ${comment.created}\n\n${commentText}`; + }) + ); + } + + const content = parts.join("\n\n"); + + return [ + { + name: `${issue.key}: ${issue.fields.summary}`, + content, + description: issue.key, + }, + ]; + } + + async loadSubmenuItems( + args: LoadSubmenuItemsArgs + ): Promise { + const api = await this.createApi(); + + try { + const results = await api.get("/search", { + params: { + jql: + this.options.issueQuery ?? + `assignee = currentUser() AND resolution = Unresolved order by updated DESC`, + fields: "summary", + }, + }); + + return results.data.issues.map((issue) => ({ + id: issue.id, + title: `${issue.key}: ${issue.fields.summary}`, + description: "", + })); + } catch (ex) { + console.error(`Unable to get jira tickets: ${ex}`); + return []; + } + } +} + +export default JiraIssuesContextProvider; diff --git a/core/context/providers/index.ts b/core/context/providers/index.ts index e335a8363..2017e1738 100644 --- a/core/context/providers/index.ts +++ b/core/context/providers/index.ts @@ -15,6 +15,7 @@ import ProblemsContextProvider from "./ProblemsContextProvider"; import SearchContextProvider from "./SearchContextProvider"; import TerminalContextProvider from "./TerminalContextProvider"; import URLContextProvider from "./URLContextProvider"; +import JiraIssuesContextProvider from "./JiraIssuesContextProvider"; const Providers: (typeof BaseContextProvider)[] = [ DiffContextProvider, @@ -32,6 +33,7 @@ const Providers: (typeof BaseContextProvider)[] = [ DocsContextProvider, CodeHighlightsContextProvider, CodeOutlineContextProvider, + JiraIssuesContextProvider, ]; export function contextProviderClassFromName( diff --git a/core/index.d.ts b/core/index.d.ts index 77599c13c..f66df8b47 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -414,7 +414,8 @@ type ContextProviderName = | "http" | "codebase" | "problems" - | "folder"; + | "folder" + | "jira"; type TemplateType = | "llama2" diff --git a/core/package-lock.json b/core/package-lock.json index 6ea8b6f89..61bc32c9d 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -12,6 +12,8 @@ "@octokit/rest": "^20.0.2", "@types/node-fetch": "^2.6.11", "@xenova/transformers": "^2.14.0", + "adf2md": "^2.0.0", + "axios": "^1.6.7", "cheerio": "^1.0.0-rc.12", "dotenv": "^16.3.1", "fastest-levenshtein": "^1.0.16", @@ -2029,6 +2031,11 @@ "node": ">=6.5" } }, + "node_modules/adf2md": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/adf2md/-/adf2md-2.0.0.tgz", + "integrity": "sha512-QZvKkozgbIu3QfU1CtAEhAdgJ9h5q61pz6txOEqgjktjEsjer+EnFJ+Prhi+94+5Jl+50OD8eo7m/ardxYe00Q==" + }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -2188,9 +2195,9 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.5.tgz", - "integrity": "sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==", + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", + "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", "dependencies": { "follow-redirects": "^1.15.4", "form-data": "^4.0.0", diff --git a/core/package.json b/core/package.json index dfb3e6f34..79e08f8c4 100644 --- a/core/package.json +++ b/core/package.json @@ -21,6 +21,8 @@ "@octokit/rest": "^20.0.2", "@types/node-fetch": "^2.6.11", "@xenova/transformers": "^2.14.0", + "adf2md": "^2.0.0", + "axios": "^1.6.7", "cheerio": "^1.0.0-rc.12", "dotenv": "^16.3.1", "fastest-levenshtein": "^1.0.16", diff --git a/core/yarn.lock b/core/yarn.lock index 295c042b7..dfbe639cb 100644 --- a/core/yarn.lock +++ b/core/yarn.lock @@ -321,10 +321,10 @@ resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@esbuild/darwin-arm64@0.19.11": +"@esbuild/linux-x64@0.19.11": version "0.19.11" - resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.11.tgz" - integrity sha512-ETp87DRWuSt9KdDVkqSoKoLFHYTrkyz2+65fj9nfXsaV3bMhTCjtQfw3y+um88vGRKRiF7erPrh/ZuIdLUIVxQ== + resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.11.tgz" + integrity sha512-grbyMlVCvJSfxFQUndw5mCtWs5LO1gUlwP4CDi4iJBbVpZcqLVT29FxgGuBJGSzyOxotFG4LoO5X+M1350zmPA== "@gar/promisify@^1.0.1": version "1.1.3" @@ -576,10 +576,10 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" -"@lancedb/vectordb-darwin-arm64@0.4.3": +"@lancedb/vectordb-linux-x64-gnu@0.4.3": version "0.4.3" - resolved "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.3.tgz" - integrity sha512-47CvvSaV1EdUsFEpXUJApTk+hMzAhCxVizipCFUlXCgcmzpCDL86wNgJij/X9a+j6zADhIX//Lsu0qd/an/Bpw== + resolved "https://registry.npmjs.org/@lancedb/vectordb-linux-x64-gnu/-/vectordb-linux-x64-gnu-0.4.3.tgz" + integrity sha512-OBx3WF3pK0xNfFJeErmuD9R2QWLa3XdeZspyTsIrQmBDeKj3HKh8y7Scpx4NH5Y09+9JNqRRKRZN7OqWTYhITg== "@neon-rs/load@^0.0.74": version "0.0.74" @@ -967,6 +967,11 @@ abort-controller@^3.0.0: dependencies: event-target-shim "^5.0.0" +adf2md@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/adf2md/-/adf2md-2.0.0.tgz" + integrity sha512-QZvKkozgbIu3QfU1CtAEhAdgJ9h5q61pz6txOEqgjktjEsjer+EnFJ+Prhi+94+5Jl+50OD8eo7m/ardxYe00Q== + agent-base@^6.0.2, agent-base@6: version "6.0.2" resolved "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz" @@ -1079,10 +1084,10 @@ asynckit@^0.4.0: resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== -axios@^1.4.0, axios@^1.6.2: - version "1.6.5" - resolved "https://registry.npmjs.org/axios/-/axios-1.6.5.tgz" - integrity sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg== +axios@^1.4.0, axios@^1.6.2, axios@^1.6.7: + version "1.6.7" + resolved "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz" + integrity sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA== dependencies: follow-redirects "^1.15.4" form-data "^4.0.0" @@ -1918,11 +1923,6 @@ fs.realpath@^1.0.0: resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@^2.3.2: - version "2.3.3" - resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" - integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== - function-bind@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz" diff --git a/docs/docs/customization/context-providers.md b/docs/docs/customization/context-providers.md index d976eac8e..77c54fb97 100644 --- a/docs/docs/customization/context-providers.md +++ b/docs/docs/customization/context-providers.md @@ -112,6 +112,32 @@ Type '@issue' to reference the conversation in a GitHub issue. Make sure to incl } ``` +### Jira Issues + +Type '@jira' to reference the conversation in a Jira issue. Make sure to include your own [Atlassian API Token](https://id.atlassian.com/manage-profile/security/api-tokens). + +```json +{ + "name": "issue", + "params": { + "domain": "company.atlassian.net", + "email": "someone@somewhere.com", + "token ": "ATATT..." + } +} +``` + +#### Issue Query + +By default, the following query will be used to find issues: + +```jql +assignee = currentUser() AND resolution = Unresolved order by updated DESC +``` + +You can override this query by setting the `issueQuery` parameter. + + ### Code Outline Type '@outline' to reference the outline of all currently open files. The outline of a files consists of only the function and class definitions in the file. Supported file extensions are '.js', '.mjs', '.go', '.c', '.cc', '.cs', '.cpp', '.el', '.ex', '.elm', '.java', '.ml', '.php', '.ql', '.rb', '.rs', '.ts' diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 746737b6a..51686f00b 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1112,6 +1112,41 @@ "required": ["params"] } }, + { + "if": { + "properties": { + "name": { + "enum": ["jira"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "domain": { + "type": "string", + "description": "Your Jira domain, for example company.atlassian.net." + }, + "email": { + "type": "string", + "description": "The email that you log into Jira with" + }, + "token": { + "type": "string", + "description": "Your atlassian API token from https://id.atlassian.com/manage-profile/security/api-tokens" + }, + "issueQuery": { + "type": "string", + "description": "Customize the query used to find Jira issues" + } + }, + "required": ["domain", "email", "token"] + } + }, + "required": ["params"] + } + }, { "if": { "properties": { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 746737b6a..4275f00f4 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -71,8 +71,15 @@ "title": "Ca Bundle Path", "description": "Path to a custom CA bundle to use when making the HTTP request", "anyOf": [ - { "type": "string" }, - { "type": "array", "items": { "type": "string" } } + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } ] }, "proxy": { @@ -365,7 +372,9 @@ "llama2-13b" ] }, - { "type": "string" } + { + "type": "string" + } ] }, "markdownDescription": "Select a pre-defined option, or find an exact model ID from Replicate [here](https://replicate.com/collections/streaming-language-models)." @@ -448,7 +457,9 @@ "AUTODETECT" ] }, - { "type": "string" } + { + "type": "string" + } ] } } @@ -467,8 +478,12 @@ "properties": { "model": { "anyOf": [ - { "enum": ["claude-2", "claude-instant-1"] }, - { "type": "string" } + { + "enum": ["claude-2", "claude-instant-1"] + }, + { + "type": "string" + } ] } } @@ -517,7 +532,9 @@ "phind-codellama-34b" ] }, - { "type": "string" } + { + "type": "string" + } ], "markdownDescription": "Select a pre-defined option, or find an exact model string from Together AI [here](https://docs.together.ai/docs/inference-models)." } @@ -585,7 +602,9 @@ "starcoder-3b" ] }, - { "type": "string" } + { + "type": "string" + } ] } } @@ -630,7 +649,9 @@ "AUTODETECT" ] }, - { "type": "string" } + { + "type": "string" + } ], "markdownDescription": "Select a pre-defined option, or find the exact model tag for an Ollama model [here](https://ollama.ai/library)." } @@ -813,7 +834,9 @@ "starcoder-3b" ] }, - { "type": "string" } + { + "type": "string" + } ] } } @@ -878,7 +901,9 @@ "Generate a commit message for the current changes" ] }, - { "type": "string" } + { + "type": "string" + } ] }, "description": { @@ -1011,7 +1036,9 @@ ], "type": "string" }, - { "type": "string" } + { + "type": "string" + } ] }, "params": { @@ -1112,6 +1139,41 @@ "required": ["params"] } }, + { + "if": { + "properties": { + "name": { + "enum": ["jira"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "domain": { + "type": "string", + "description": "Your Jira domain, for example company.atlassian.net." + }, + "email": { + "type": "string", + "description": "The email that you log into Jira with" + }, + "token": { + "type": "string", + "description": "Your atlassian API token from https://id.atlassian.com/manage-profile/security/api-tokens" + }, + "issueQuery": { + "type": "string", + "description": "Customize the query used to find Jira issues" + } + }, + "required": ["domain", "email", "token"] + } + }, + "required": ["params"] + } + }, { "if": { "properties": { diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index ea2a834e5..6df5626e4 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1278,6 +1278,49 @@ ] } }, + { + "if": { + "properties": { + "name": { + "enum": [ + "jira" + ] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "domain": { + "type": "string", + "description": "Your Jira domain, for example company.atlassian.net." + }, + "email": { + "type": "string", + "description": "The email that you log into Jira with" + }, + "token": { + "type": "string", + "description": "Your atlassian API token from https://id.atlassian.com/manage-profile/security/api-tokens" + }, + "issueQuery": { + "type": "string", + "description": "Customize the query used to find Jira issues" + } + }, + "required": [ + "domain", + "email", + "token" + ] + } + }, + "required": [ + "params" + ] + } + }, { "if": { "properties": { diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index bbf07f092..17dc171be 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.8.13", + "version": "0.8.14", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.8.13", + "version": "0.8.14", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", @@ -88,6 +88,8 @@ "@octokit/rest": "^20.0.2", "@types/node-fetch": "^2.6.11", "@xenova/transformers": "^2.14.0", + "adf2md": "^2.0.0", + "axios": "^1.6.7", "cheerio": "^1.0.0-rc.12", "dotenv": "^16.3.1", "fastest-levenshtein": "^1.0.16", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index daf4b09e1..7e77e273b 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -1,7 +1,7 @@ { "name": "continue", "icon": "media/icon.png", - "version": "0.8.13", + "version": "0.8.14", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" diff --git a/extensions/vscode/yarn.lock b/extensions/vscode/yarn.lock index 4d470fefc..56084924f 100644 --- a/extensions/vscode/yarn.lock +++ b/extensions/vscode/yarn.lock @@ -368,15 +368,15 @@ tar "^6.0.5" yargs "^17.0.1" -"@esbuild/darwin-arm64@0.17.19": +"@esbuild/linux-x64@0.17.19": version "0.17.19" - resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz" - integrity sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg== + resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz" + integrity sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw== -"@esbuild/darwin-arm64@0.18.20": +"@esbuild/linux-x64@0.18.20": version "0.18.20" - resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz" - integrity sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA== + resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.18.20.tgz" + integrity sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w== "@eslint-community/eslint-utils@^4.2.0": version "4.4.0" @@ -696,10 +696,10 @@ resolved "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz" integrity sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg== -"@lancedb/vectordb-darwin-arm64@*", "@lancedb/vectordb-darwin-arm64@0.4.9": +"@lancedb/vectordb-linux-x64-gnu@0.4.9": version "0.4.9" - resolved "https://registry.npmjs.org/@lancedb/vectordb-darwin-arm64/-/vectordb-darwin-arm64-0.4.9.tgz" - integrity sha512-u56TXU0hvdLbknGwC7Ebza3/CUFeCTkoCy/sC6h0FtOGya+NV7jraAeXEwDzoZbfW08VYYxnp3TsCcpNU9lpTA== + resolved "https://registry.npmjs.org/@lancedb/vectordb-linux-x64-gnu/-/vectordb-linux-x64-gnu-0.4.9.tgz" + integrity sha512-HbvSym1WXgTTDb+gfEaD9R/x+NbI6PWM8PrqFaAXkhm2Zzi/eL9eHBl2vgTyYFbzUvucTYnHZzT8a8FzCuvW0A== "@lukeed/csprng@^1.0.0": version "1.1.0" @@ -2314,6 +2314,8 @@ core-util-is@1.0.2: "@octokit/rest" "^20.0.2" "@types/node-fetch" "^2.6.11" "@xenova/transformers" "^2.14.0" + adf2md "^2.0.0" + axios "^1.6.7" cheerio "^1.0.0-rc.12" dotenv "^16.3.1" fastest-levenshtein "^1.0.16" @@ -3341,11 +3343,6 @@ fs.realpath@^1.0.0: resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@^2.3.2, fsevents@~2.3.2: - version "2.3.3" - resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" - integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== - function-bind@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz" diff --git a/gui/package-lock.json b/gui/package-lock.json index f1f681629..4449f7aba 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -76,6 +76,8 @@ "@octokit/rest": "^20.0.2", "@types/node-fetch": "^2.6.11", "@xenova/transformers": "^2.14.0", + "adf2md": "^2.0.0", + "axios": "^1.6.7", "cheerio": "^1.0.0-rc.12", "dotenv": "^16.3.1", "fastest-levenshtein": "^1.0.16",