Merge branch 'main' into preview

This commit is contained in:
Nate Sesti 2024-02-21 14:49:15 -08:00
commit 136e56d98c
13 changed files with 357 additions and 42 deletions

View file

@ -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<JiraComment>;
};
};
}
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<AxiosInstance> {
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<ContextItem[]> {
const issueId = query;
const api = await this.createApi();
const issue = await api
.get<JiraIssue>(`/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<ContextSubmenuItem[]> {
const api = await this.createApi();
try {
const results = await api.get<QueryResults>("/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;

View file

@ -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(

3
core/index.d.ts vendored
View file

@ -414,7 +414,8 @@ type ContextProviderName =
| "http"
| "codebase"
| "problems"
| "folder";
| "folder"
| "jira";
type TemplateType =
| "llama2"

13
core/package-lock.json generated
View file

@ -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",

View file

@ -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",

View file

@ -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"

View file

@ -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'

View file

@ -1121,6 +1121,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": {

View file

@ -76,8 +76,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": {
@ -376,7 +383,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)."
@ -462,7 +471,9 @@
"AUTODETECT"
]
},
{ "type": "string" }
{
"type": "string"
}
]
}
}
@ -481,8 +492,12 @@
"properties": {
"model": {
"anyOf": [
{ "enum": ["claude-2", "claude-instant-1"] },
{ "type": "string" }
{
"enum": ["claude-2", "claude-instant-1"]
},
{
"type": "string"
}
]
}
}
@ -531,7 +546,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)."
}
@ -599,7 +616,9 @@
"starcoder-3b"
]
},
{ "type": "string" }
{
"type": "string"
}
]
}
}
@ -644,7 +663,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)."
}
@ -827,7 +848,9 @@
"starcoder-3b"
]
},
{ "type": "string" }
{
"type": "string"
}
]
}
}
@ -892,7 +915,9 @@
"Generate a commit message for the current changes"
]
},
{ "type": "string" }
{
"type": "string"
}
]
},
"description": {
@ -1025,7 +1050,9 @@
],
"type": "string"
},
{ "type": "string" }
{
"type": "string"
}
]
},
"params": {
@ -1126,6 +1153,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": {

View file

@ -1287,6 +1287,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": {

View file

@ -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",

View file

@ -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"
@ -2315,6 +2315,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"
@ -3348,11 +3350,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"

2
gui/package-lock.json generated
View file

@ -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",