🐛 various fixes for slash commands and context providers
This commit is contained in:
parent
27a668b9cb
commit
446942d09e
7 changed files with 104 additions and 32 deletions
|
|
@ -5,7 +5,7 @@ const CommitMessageCommand: SlashCommand = {
|
|||
description: "Generate a commit message for current changes",
|
||||
run: async function* ({ ide, llm, input }) {
|
||||
const diff = await ide.getDiff();
|
||||
const prompt = `${diff}\n\nGenerate a commit message for the above set of changes. If the changes are easily described in a single concept, then give a single sentence, no more than 80 characters. Otherwise, give a list of short bullet points, each no more than 40 characters. Output nothing except for the commit message.`;
|
||||
const prompt = `${diff}\n\nGenerate a commit message for the above set of changes. First, give a single sentence, no more than 80 characters. Then, after 2 line breaks, give a list of no more than 5 short bullet points, each no more than 40 characters. Output nothing except for the commit message, and don't surround it in quotes.`;
|
||||
for await (const chunk of llm.streamChat([
|
||||
{ role: "user", content: prompt },
|
||||
])) {
|
||||
|
|
|
|||
|
|
@ -46,8 +46,9 @@ const DraftIssueCommand: SlashCommand = {
|
|||
yield chunk.content;
|
||||
}
|
||||
|
||||
// const url = f"{self.repository_url}/issues/new?title={quote(title)}&body={quote(body)}"
|
||||
const url = `${params.repositoryUrl}/issues/new?title={encodeURIComponent(title)}&body={encodeURIComponent(body)}`;
|
||||
const url = `${params.repositoryUrl}/issues/new?title=${encodeURIComponent(
|
||||
title
|
||||
)}&body=${encodeURIComponent(body)}`;
|
||||
yield `\n\n[Link to draft of issue](${url})`;
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,13 +16,20 @@ async function getResults(q: string): Promise<any> {
|
|||
|
||||
const resp = await fetch(`${SERVER_URL}/search`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: payload,
|
||||
});
|
||||
return await resp.json();
|
||||
}
|
||||
|
||||
async function fetchData(url: string): Promise<string | undefined> {
|
||||
const response = await fetch(url);
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
Accept: "text/html",
|
||||
},
|
||||
});
|
||||
const htmlString = await response.text();
|
||||
|
||||
const parser = new DOMParser();
|
||||
|
|
|
|||
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -396,7 +396,6 @@ export interface ContextProviderWithParams {
|
|||
export interface SlashCommandDescription {
|
||||
name: string;
|
||||
description: string;
|
||||
step: StepName | string;
|
||||
params?: { [key: string]: any };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@ function autodetectTemplateType(model: string): TemplateType | undefined {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
if (lower.includes("dolphin")) {
|
||||
return "chatml";
|
||||
}
|
||||
|
||||
if (lower.includes("phind")) {
|
||||
return "phind";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -678,7 +678,22 @@
|
|||
"properties": {
|
||||
"name": {
|
||||
"title": "Name",
|
||||
"type": "string"
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"issue",
|
||||
"share",
|
||||
"so",
|
||||
"cmd",
|
||||
"edit",
|
||||
"comment",
|
||||
"http",
|
||||
"commit"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
{ "type": "string" }
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"title": "Description",
|
||||
|
|
@ -686,19 +701,7 @@
|
|||
},
|
||||
"step": {
|
||||
"title": "Step",
|
||||
"enum": [
|
||||
"AnswerQuestionChroma",
|
||||
"GenerateShellCommandStep",
|
||||
"EditHighlightedCodeStep",
|
||||
"ShareSessionStep",
|
||||
"CommentCodeStep",
|
||||
"ClearHistoryStep",
|
||||
"StackOverflowStep",
|
||||
"OpenConfigStep",
|
||||
"DraftIssueStep",
|
||||
"HttpSlashCommand",
|
||||
"CommitMessageStep"
|
||||
],
|
||||
"description": "This property is no longer required and has no effect. To use a built-in slash command, instead set the 'name' property to one of the pre-configured options.",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
|
|
@ -707,7 +710,32 @@
|
|||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": ["name", "description", "step"]
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"enum": ["issue"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"params": {
|
||||
"properties": {
|
||||
"repositoryUrl": {
|
||||
"type": "string",
|
||||
"description": "Enter the URL of the GitHub repository for which you want to generate the issue."
|
||||
}
|
||||
},
|
||||
"required": ["repositoryUrl"]
|
||||
}
|
||||
},
|
||||
"required": ["params"]
|
||||
}
|
||||
}
|
||||
],
|
||||
"required": ["name", "description"]
|
||||
},
|
||||
"CustomCommand": {
|
||||
"title": "CustomCommand",
|
||||
|
|
@ -734,17 +762,22 @@
|
|||
"properties": {
|
||||
"name": {
|
||||
"title": "Name",
|
||||
"enum": [
|
||||
"diff",
|
||||
"github",
|
||||
"terminal",
|
||||
"open",
|
||||
"google",
|
||||
"search",
|
||||
"url",
|
||||
"http"
|
||||
],
|
||||
"type": "string"
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"diff",
|
||||
"github",
|
||||
"terminal",
|
||||
"open",
|
||||
"google",
|
||||
"search",
|
||||
"url",
|
||||
"http"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
{ "type": "string" }
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"title": "Params",
|
||||
|
|
@ -752,6 +785,31 @@
|
|||
"type": "object"
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"enum": ["google"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"params": {
|
||||
"properties": {
|
||||
"serperApiKey": {
|
||||
"type": "string",
|
||||
"description": "Your API key for https://serper.dev in order to get Google search results"
|
||||
}
|
||||
},
|
||||
"required": ["serperApiKey"]
|
||||
}
|
||||
},
|
||||
"required": ["params"]
|
||||
}
|
||||
}
|
||||
],
|
||||
"required": ["name"]
|
||||
},
|
||||
"RetrievalSettings": {
|
||||
|
|
|
|||
|
|
@ -233,7 +233,10 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
continue;
|
||||
}
|
||||
for (const node of p.content) {
|
||||
if (node.type === "slashcommand" && node.attrs.label === "/edit") {
|
||||
if (
|
||||
node.type === "slashcommand" &&
|
||||
["/edit", "/comment"].includes(node.attrs.label)
|
||||
) {
|
||||
// Update context items
|
||||
dispatch(
|
||||
setEditingContextItemAtIndex({ item: codeBlock.attrs.item })
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue