continue-custom/server/continuedev/plugins/steps/cmd.py
Nate Sesti 279593a848
Strong typing (#533)
* refactor: ♻️ get rid of continuedev.src.continuedev structure

* refactor: ♻️ switching back to server folder

* feat: ✨ make config.py imports shorter

* feat: 🔖 publish as pre-release vscode extension

* refactor: ♻️ refactor and add more completion params to ui

* build: 🏗️ download from preview S3
2023-10-04 23:47:59 -07:00

30 lines
1.1 KiB
Python

from textwrap import dedent
from typing import Coroutine
from ...core.main import Step
from ...core.observation import Observation
from ...core.sdk import ContinueSDK
from ...libs.util.strings import remove_quotes_and_escapes
class GenerateShellCommandStep(Step):
user_input: str
async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]:
cmd = await sdk.models.default.complete(
dedent(
f"""\
The user has made a request to run a shell command. Their description of what it should do is:
"{self.user_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 = remove_quotes_and_escapes(cmd.strip()).replace("\n", "").replace("\r", "")
await sdk.ide.runCommand(cmd)
self.description = f"Generated shell command: {cmd}"