diff options
Diffstat (limited to 'continuedev')
| -rw-r--r-- | continuedev/src/continuedev/core/config.py | 84 | ||||
| -rw-r--r-- | continuedev/src/continuedev/steps/open_config.py | 14 | 
2 files changed, 58 insertions, 40 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)  | 
