blob: a38f6323d240b9e2581c26b5158806b216a44581 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
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}"
|