* 🎨 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
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { streamLines } from "../../diff/util.js";
|
|
import { SlashCommand } from "../../index.js";
|
|
import { removeQuotesAndEscapes } from "../../util/index.js";
|
|
|
|
const GenerateTerminalCommand: SlashCommand = {
|
|
name: "cmd",
|
|
description: "Generate a shell command",
|
|
run: async function* ({ ide, llm, input }) {
|
|
const gen =
|
|
llm.streamComplete(`The user has made a request to run a shell command. Their description of what it should do is:
|
|
|
|
"${input}"
|
|
|
|
Please write a shell command that will do what the user requested. Your output should consist of only the command itself, without any explanation or example output. Do not use any newlines. Only output the command that when inserted into the terminal will do precisely what was requested. Here is the command:`);
|
|
|
|
const lines = streamLines(gen);
|
|
let cmd = "";
|
|
for await (const line of lines) {
|
|
console.log(line);
|
|
if (line.startsWith("```") && line.endsWith("```")) {
|
|
cmd = line.split(" ").slice(1).join(" ").slice(0, -3);
|
|
break;
|
|
}
|
|
|
|
if (
|
|
line.startsWith(">") ||
|
|
line.startsWith("``") ||
|
|
line.startsWith("\\begin{") ||
|
|
line.trim() === ""
|
|
) {
|
|
continue;
|
|
}
|
|
|
|
cmd = removeQuotesAndEscapes(line.trim());
|
|
break;
|
|
}
|
|
|
|
await ide.runCommand(cmd);
|
|
yield `Generated shell command: ${cmd}`;
|
|
},
|
|
};
|
|
|
|
export default GenerateTerminalCommand;
|