* 🎨 refactor out react context * 🎨 refactor local storage * 🎨 refactor IdeMessenger * 🔥 removing unused files * 🚚 move scripts * ✅ setup VSCode integration testing * 🎨 fix test-related stuff * 🚧 testing * 🎨 tweak terminal cmd+L * 🧑💻 install biome in core * 🎨 run biome check on core * 🎨 run biome check in vscode * 🎨 run biome check in binary * 🧑💻 global biome config * 🎨 run biome check on core * 🎨 run biome check in vscode * 🎨 fix a few biome warnings * 🚧 WIP on protocols * 🚧 progress, organizing, about to remove webviewCore protocol * 🚧 now running * 🚧 move indexing code to core * 🚧 WIP on JetBrains indexing implementation * 🎨 finish listDir * 🚧 gui fixes * 🏷️ update IMessenger.on return type * 🐛 fix jetbrains types + IDE detection * 🧑💻 set up debugging for binary with TcpMessenger * 👷 fix prepackage.js * 🧑💻 turn off debug mode for intellij * 🐛 merge fixes * 🐛 fixes after refactor * 🐛 merge fixes * 💄 increase font size in JB * 🔀 merge changes * 🩹 small fixes * 🐛 fix jetbrains build * 🩹 more jetbrains fixes * 🎨 jetbrains improvements * 🐛 fix lancedb prob in jetbrains build * 👷 update jetbrains build process * ✨ intellij problems context provider * 👷 add script utils file * 💚 fix jetbrains build regression * 🎨 dynamic import transformers.js * 🩹 small jetbrains updates * ✨ folder context provider in jetbrains * 🎨 many more jetbrains improvements * 🔀 merge fixes * ⚡️ small improvements * 🎨 tell users transformers.js not supported * 🎨 trial updates * 📝 update jetbrains readmej * ⚡️ only use smaller context for local autocomplete models * ⚡️ improve bracket filter * ✨ global .continue/.prompts folder * 💄 improved model setup process * 🥅 display VSCode req errs
58 lines
2 KiB
TypeScript
58 lines
2 KiB
TypeScript
import { ChatMessage, SlashCommand } from "../../index.js";
|
|
import { stripImages } from "../../llm/countTokens.js";
|
|
import { removeQuotesAndEscapes } from "../../util/index.js";
|
|
|
|
const PROMPT = (
|
|
input: string,
|
|
title: string,
|
|
) => `You will be asked to generate the body of a GitHub issue given a user request. You should follow these rules:
|
|
- Be descriptive but do not make up details
|
|
- If the the user request includes any code snippets that are relevant, reference them in code blocks
|
|
- Describe step by step how to reproduce the problem
|
|
- Describe the ideal solution to the problem
|
|
- Describe the expected behavior after the issue has been resolved
|
|
- This issue will be read by a team member
|
|
- Use markdown formatting, but you do not need to surround the entire body with triple backticks
|
|
{additional_instructions}
|
|
|
|
Here is the user request: '${input}'
|
|
|
|
Title: ${title}
|
|
|
|
Body:\n\n`;
|
|
|
|
const DraftIssueCommand: SlashCommand = {
|
|
name: "issue",
|
|
description: "Draft a GitHub issue",
|
|
run: async function* ({ input, llm, history, params }) {
|
|
if (params?.repositoryUrl === undefined) {
|
|
yield "This command requires a repository URL to be set in the config file.";
|
|
return;
|
|
}
|
|
let title = await llm.complete(
|
|
`Generate a title for the GitHub issue requested in this user input: '${input}'. Use no more than 20 words and output nothing other than the title. Do not surround it with quotes. The title is: `,
|
|
{ maxTokens: 20 },
|
|
);
|
|
|
|
title = `${removeQuotesAndEscapes(title.trim())}\n\n`;
|
|
yield title;
|
|
|
|
let body = "";
|
|
const messages: ChatMessage[] = [
|
|
...history,
|
|
{ role: "user", content: PROMPT(input, title) },
|
|
];
|
|
|
|
for await (const chunk of llm.streamChat(messages)) {
|
|
body += chunk.content;
|
|
yield stripImages(chunk.content);
|
|
}
|
|
|
|
const url = `${params.repositoryUrl}/issues/new?title=${encodeURIComponent(
|
|
title,
|
|
)}&body=${encodeURIComponent(body)}`;
|
|
yield `\n\n[Link to draft of issue](${url})`;
|
|
},
|
|
};
|
|
|
|
export default DraftIssueCommand;
|