summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--continuedev/src/continuedev/core/config.py84
-rw-r--r--continuedev/src/continuedev/steps/open_config.py14
-rw-r--r--extension/react-app/src/components/UserInputContainer.tsx39
3 files changed, 72 insertions, 65 deletions
diff --git a/continuedev/src/continuedev/core/config.py b/continuedev/src/continuedev/core/config.py
index 3208e63d..9e8541dc 100644
--- a/continuedev/src/continuedev/core/config.py
+++ b/continuedev/src/continuedev/core/config.py
@@ -22,6 +22,45 @@ class OnTracebackSteps(BaseModel):
params: Optional[Dict] = {}
+DEFAULT_SLASH_COMMANDS = [
+ # SlashCommand(
+ # name="pytest",
+ # description="Write pytest unit tests for the current file",
+ # step_name="WritePytestsRecipe",
+ # params=??)
+ SlashCommand(
+ name="edit",
+ description="Edit code in the current file or the highlighted code",
+ step_name="EditHighlightedCodeStep",
+ ),
+ SlashCommand(
+ name="explain",
+ description="Reply to instructions or a question with previous steps and the highlighted code or current file as context",
+ step_name="SimpleChatStep",
+ ),
+ SlashCommand(
+ name="config",
+ description="Open the config file to create new and edit existing slash commands",
+ step_name="OpenConfigStep",
+ ),
+ SlashCommand(
+ name="comment",
+ description="Write comments for the current file or highlighted code",
+ step_name="CommentCodeStep",
+ ),
+ SlashCommand(
+ name="feedback",
+ description="Send feedback to improve Continue",
+ step_name="FeedbackStep",
+ ),
+ SlashCommand(
+ name="clear",
+ description="Clear step history",
+ step_name="ClearHistoryStep",
+ )
+]
+
+
class ContinueConfig(BaseModel):
"""
A pydantic class for the continue config file.
@@ -33,46 +72,15 @@ class ContinueConfig(BaseModel):
default_model: Literal["gpt-3.5-turbo", "gpt-3.5-turbo-16k",
"gpt-4"] = 'gpt-4'
custom_commands: Optional[List[CustomCommand]] = []
- slash_commands: Optional[List[SlashCommand]] = [
- # SlashCommand(
- # name="pytest",
- # description="Write pytest unit tests for the current file",
- # step_name="WritePytestsRecipe",
- # params=??)
- SlashCommand(
- name="edit",
- description="Edit code in the current file or the highlighted code",
- step_name="EditHighlightedCodeStep",
- ),
- SlashCommand(
- name="explain",
- description="Reply to instructions or a question with previous steps and the highlighted code or current file as context",
- step_name="SimpleChatStep",
- ),
- SlashCommand(
- name="config",
- description="Open the config file to create new and edit existing slash commands",
- step_name="OpenConfigStep",
- ),
- SlashCommand(
- name="comment",
- description="Write comments for the current file or highlighted code",
- step_name="CommentCodeStep",
- ),
- SlashCommand(
- name="feedback",
- description="Send feedback to improve Continue",
- step_name="FeedbackStep",
- ),
- SlashCommand(
- name="clear",
- description="Clear step history",
- step_name="ClearHistoryStep",
- )
- ]
+ slash_commands: Optional[List[SlashCommand]] = DEFAULT_SLASH_COMMANDS
on_traceback: Optional[List[OnTracebackSteps]] = [
OnTracebackSteps(step_name="DefaultOnTracebackStep")]
+ # Want to force these to be the slash commands for now
+ @validator('slash_commands', pre=True)
+ def default_slash_commands_validator(cls, v):
+ return DEFAULT_SLASH_COMMANDS
+
def load_config(config_file: str) -> ContinueConfig:
"""
@@ -142,4 +150,4 @@ def update_global_config(config: ContinueConfig):
else:
config_path = os.path.join(global_dir, 'config.json')
with open(config_path, 'w') as f:
- json.dump(config.dict(), f)
+ json.dump(config.dict(exclude_unset=False), f, indent=4)
diff --git a/continuedev/src/continuedev/steps/open_config.py b/continuedev/src/continuedev/steps/open_config.py
index 9cffdb3a..91459113 100644
--- a/continuedev/src/continuedev/steps/open_config.py
+++ b/continuedev/src/continuedev/steps/open_config.py
@@ -1,3 +1,4 @@
+from textwrap import dedent
from ..core.main import Step
from ..core.sdk import ContinueSDK
import os
@@ -7,9 +8,18 @@ class OpenConfigStep(Step):
name: str = "Open config"
async def describe(self, models):
- return "Config.json is now open. Create a new or edit an existing slash command here. Here is an example: { custom_commands : [ { 'name;: 'test', 'prompt': 'write me a unit test' } ] }"
+ return dedent("""\
+ Config.json is now open. You can add a custom slash command in the `\"custom_commands\"` section, like in this example:
+ ```json
+ "custom_commands": [
+ {
+ "name": "test",
+ "prompt": "write me a comprehensive unit test for this function, that covers all edge cases. Use pytest."
+ }
+ ],
+ ```""")
async def run(self, sdk: ContinueSDK):
global_dir = os.path.expanduser('~/.continue')
config_path = os.path.join(global_dir, 'config.json')
- await sdk.ide.setFileOpen(config_path) \ No newline at end of file
+ await sdk.ide.setFileOpen(config_path)
diff --git a/extension/react-app/src/components/UserInputContainer.tsx b/extension/react-app/src/components/UserInputContainer.tsx
index 7d6f0d4e..59453169 100644
--- a/extension/react-app/src/components/UserInputContainer.tsx
+++ b/extension/react-app/src/components/UserInputContainer.tsx
@@ -16,40 +16,29 @@ const StyledDiv = styled.div`
background-color: rgb(50 50 50);
padding: 8px;
padding-left: 16px;
+ padding-right: 16px;
border-bottom: 1px solid white;
border-top: 1px solid white;
font-size: 13px;
display: flex;
align-items: center;
- gap: 2px;
`;
-const DeleteButton = styled.button`
- position: absolute;
- top: 0;
- right: 0;
- background: none;
- border: none;
- cursor: pointer;
- margin-left: auto;
-`;
-
-const UserInputContainer: React.FC<UserInputContainerProps> = ({
- children,
- onDelete,
-}) => {
+const UserInputContainer = (props: UserInputContainerProps) => {
return (
<StyledDiv>
- {children}
- <HeaderButtonWithText
- onClick={(e) => {
- e.stopPropagation();
- onDelete();
- }}
- text="Delete"
- >
- <XMark size="1.6em" onClick={onDelete} />
- </HeaderButtonWithText>
+ {props.children}
+ <div style={{ marginLeft: "auto" }}>
+ <HeaderButtonWithText
+ onClick={(e) => {
+ props.onDelete();
+ e.stopPropagation();
+ }}
+ text="Delete"
+ >
+ <XMark size="1.6em" onClick={props.onDelete} />
+ </HeaderButtonWithText>
+ </div>
</StyledDiv>
);
};