continue-custom/core/commands/slash/cmd.ts
Nate Sesti e1ed7ed0a2 ✨ config.ts
2023-12-14 12:47:01 -08:00

22 lines
906 B
TypeScript

import { SlashCommand } from "../..";
import { removeQuotesAndEscapes } from "../../util";
const GenerateTerminalCommand: SlashCommand = {
name: "cmd",
description: "Generate a shell command",
run: async function* ({ ide, llm, input }) {
let cmd =
await llm.complete(`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.`);
cmd = removeQuotesAndEscapes(cmd.trim())
.replace("\n", "")
.replace("\r", "");
await ide.runCommand(cmd);
yield `Generated shell command: ${cmd}`;
},
};
export default GenerateTerminalCommand;