diff options
-rw-r--r-- | continuedev/src/continuedev/core/policy.py | 64 | ||||
-rw-r--r-- | extension/package-lock.json | 4 | ||||
-rw-r--r-- | extension/package.json | 2 | ||||
-rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 2 | ||||
-rw-r--r-- | extension/react-app/src/components/StepContainer.tsx | 12 | ||||
-rw-r--r-- | extension/react-app/src/components/UserInputContainer.tsx | 10 | ||||
-rw-r--r-- | extension/react-app/src/tabs/gui.tsx | 18 |
7 files changed, 61 insertions, 51 deletions
diff --git a/continuedev/src/continuedev/core/policy.py b/continuedev/src/continuedev/core/policy.py index b0853380..ef753ee4 100644 --- a/continuedev/src/continuedev/core/policy.py +++ b/continuedev/src/continuedev/core/policy.py @@ -1,5 +1,5 @@ from textwrap import dedent -from typing import List, Tuple, Type +from typing import List, Tuple, Type, Union from ..steps.welcome import WelcomeStep from .config import ContinueConfig @@ -22,6 +22,34 @@ from ..libs.util.step_name_to_steps import get_step_from_name from ..steps.custom_command import CustomCommandStep +def parse_slash_command(inp: str, config: ContinueConfig) -> Union[None, Step]: + """ + Parses a slash command, returning the command name and the rest of the input. + """ + if inp.startswith("/"): + command_name = inp.split(" ")[0] + after_command = " ".join(inp.split(" ")[1:]) + + for slash_command in config.slash_commands: + if slash_command.name == command_name[1:]: + params = slash_command.params + params["user_input"] = after_command + return get_step_from_name(slash_command.step_name, params) + return None + + +def parse_custom_command(inp: str, config: ContinueConfig) -> Union[None, Step]: + command_name = inp.split(" ")[0] + after_command = " ".join(inp.split(" ")[1:]) + for custom_cmd in config.custom_commands: + if custom_cmd.name == command_name[1:]: + slash_command = parse_slash_command(custom_cmd.prompt, config) + if slash_command is not None: + return slash_command + return CustomCommandStep(name=custom_cmd.name, prompt=custom_cmd.prompt, user_input=after_command) + return None + + class DemoPolicy(Policy): ran_code_last: bool = False @@ -46,34 +74,14 @@ class DemoPolicy(Policy): # This could be defined with ObservationTypePolicy. Ergonomics not right though. user_input = observation.user_input - if user_input.startswith("/"): - command_name = user_input.split(" ")[0] - after_command = " ".join(user_input.split(" ")[1:]) - for slash_command in config.slash_commands: - if slash_command.name == command_name[1:]: - params = slash_command.params - params["user_input"] = after_command - return get_step_from_name(slash_command.step_name, params) + slash_command = parse_slash_command(user_input) + if slash_command is not None: + return slash_command - for custom_cmd in config.custom_commands: - if custom_cmd.name == command_name[1:]: - return CustomCommandStep(name=custom_cmd.name, prompt=custom_cmd.prompt, user_input=after_command) + custom_command = parse_custom_command(user_input) + if custom_command is not None: + return custom_command - # return EditHighlightedCodeStep(user_input=user_input) return ChatWithFunctions(user_input=user_input) - return NLDecisionStep(user_input=user_input, steps=[ - (EditHighlightedCodeStep(user_input=user_input), - "Edit the highlighted code"), - # AnswerQuestionChroma(question=user_input), - # EditFileChroma(request=user_input), - (SimpleChatStep(user_input=user_input), - "Respond to the user with a chat message. Can answer questions about code or anything else."), - ], default_step=EditHighlightedCodeStep(user_input=user_input)) - - state = history.get_current() - if observation is not None and isinstance(observation, TracebackObservation): - self.ran_code_last = False - return SolveTracebackStep(traceback=observation.traceback) - else: - return None + return None diff --git a/extension/package-lock.json b/extension/package-lock.json index 82c28a90..ce1a42ee 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.0.109", + "version": "0.0.110", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.0.109", + "version": "0.0.110", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extension/package.json b/extension/package.json index 001a696e..607c2ca6 100644 --- a/extension/package.json +++ b/extension/package.json @@ -14,7 +14,7 @@ "displayName": "Continue", "pricing": "Free", "description": "The open-source coding autopilot", - "version": "0.0.109", + "version": "0.0.110", "publisher": "Continue", "engines": { "vscode": "^1.67.0" diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index 97f5b57e..73b7cc2d 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -324,7 +324,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { /> ))} - <span className="text-trueGray-400 ml-auto mr-4 text-xs"> + <span className="text-trueGray-400 ml-auto mr-4 text-xs text-right"> Highlight code to include as context. Currently open file included by default. {highlightedCodeSections.length === 0 && ""} </span> diff --git a/extension/react-app/src/components/StepContainer.tsx b/extension/react-app/src/components/StepContainer.tsx index 183ffeef..2aed2e72 100644 --- a/extension/react-app/src/components/StepContainer.tsx +++ b/extension/react-app/src/components/StepContainer.tsx @@ -11,11 +11,9 @@ import { ChevronDown, ChevronRight, ArrowPath, - XMark + XMark, } from "@styled-icons/heroicons-outline"; -import { - Stop, -} from "@styled-icons/heroicons-solid"; +import { Stop } from "@styled-icons/heroicons-solid"; import { HistoryNode } from "../../../schema/HistoryNode"; import ReactMarkdown from "react-markdown"; import HeaderButtonWithText from "./HeaderButtonWithText"; @@ -213,7 +211,11 @@ function StepContainer(props: StepContainerProps) { text={props.historyNode.active ? "Stop" : "Delete"} active={props.historyNode.active} > - {props.historyNode.active ? <Stop size="1.6em" onClick={props.onDelete} /> :<XMark size="1.6em" onClick={props.onDelete} />} + {props.historyNode.active ? ( + <Stop size="1.2em" onClick={props.onDelete} /> + ) : ( + <XMark size="1.6em" onClick={props.onDelete} /> + )} </HeaderButtonWithText> {props.historyNode.observation?.error ? ( <HeaderButtonWithText diff --git a/extension/react-app/src/components/UserInputContainer.tsx b/extension/react-app/src/components/UserInputContainer.tsx index a72f6098..28437d35 100644 --- a/extension/react-app/src/components/UserInputContainer.tsx +++ b/extension/react-app/src/components/UserInputContainer.tsx @@ -14,8 +14,8 @@ interface UserInputContainerProps { historyNode: HistoryNode; } -const StyledDiv = styled.div<{ hidden: boolean }>` - background-color: rgb(50 50 50); +const StyledDiv = styled.div` + background-color: rgb(45 45 45); padding: 8px; padding-left: 16px; padding-right: 16px; @@ -24,14 +24,12 @@ const StyledDiv = styled.div<{ hidden: boolean }>` font-size: 13px; display: flex; align-items: center; - visibility: ${(props) => (props.hidden ? "hidden" : "visible")}; - height: ${(props) => (props.hidden ? "0px" : "auto")}; `; const UserInputContainer = (props: UserInputContainerProps) => { return ( - <StyledDiv hidden={props.historyNode.step.hide as any}> - {props.children} + <StyledDiv> + <b>{props.children}</b> <div style={{ marginLeft: "auto" }}> <HeaderButtonWithText onClick={(e) => { diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx index 851045d5..e5320c6a 100644 --- a/extension/react-app/src/tabs/gui.tsx +++ b/extension/react-app/src/tabs/gui.tsx @@ -295,14 +295,16 @@ function GUI(props: GUIProps) { )} {history?.timeline.map((node: HistoryNode, index: number) => { return node.step.name === "User Input" ? ( - <UserInputContainer - onDelete={() => { - client?.deleteAtIndex(index); - }} - historyNode={node} - > - {node.step.description as string} - </UserInputContainer> + node.step.hide || ( + <UserInputContainer + onDelete={() => { + client?.deleteAtIndex(index); + }} + historyNode={node} + > + {node.step.description as string} + </UserInputContainer> + ) ) : ( <StepContainer isLast={index === history.timeline.length - 1} |