diff --git a/src/codegate/pipeline/cli/cli.py b/src/codegate/pipeline/cli/cli.py index 35054339..09628efe 100644 --- a/src/codegate/pipeline/cli/cli.py +++ b/src/codegate/pipeline/cli/cli.py @@ -17,6 +17,7 @@ Available commands: - `version`: Show the version of CodeGate - `workspace`: Perform different operations on workspaces +- `custom-instructions`: Set custom instructions for the workspace """ NOT_FOUND_TEXT = "Command not found. Use `codegate -h` to see available commands." diff --git a/src/codegate/pipeline/cli/commands.py b/src/codegate/pipeline/cli/commands.py index d2c40f87..f6253224 100644 --- a/src/codegate/pipeline/cli/commands.py +++ b/src/codegate/pipeline/cli/commands.py @@ -178,11 +178,11 @@ async def _add_workspace(self, flags: Dict[str, str], args: List[str]) -> str: Add a workspace """ if args is None or len(args) == 0: - return "Please provide a name. Use `codegate workspace add your_workspace_name`" + return "Please provide a name. Use `codegate workspace add `" new_workspace_name = args[0] if not new_workspace_name: - return "Please provide a name. Use `codegate workspace add your_workspace_name`" + return "Please provide a name. Use `codegate workspace add `" try: ws = await self.workspace_crud.add_workspace(new_workspace_name) @@ -204,7 +204,7 @@ async def _rename_workspace(self, flags: Dict[str, str], args: List[str]) -> str if args is None or len(args) < 2: return ( "Please provide a name and a new name. " - "Use `codegate workspace rename workspace_name new_workspace_name`" + "Use `codegate workspace rename `" ) old_workspace_name = args[0] @@ -212,7 +212,7 @@ async def _rename_workspace(self, flags: Dict[str, str], args: List[str]) -> str if not old_workspace_name or not new_workspace_name: return ( "Please provide a name and a new name. " - "Use `codegate workspace rename workspace_name new_workspace_name`" + "Use `codegate workspace rename `" ) try: @@ -233,11 +233,11 @@ async def _activate_workspace(self, flags: Dict[str, str], args: List[str]) -> s Activate a workspace """ if args is None or len(args) == 0: - return "Please provide a name. Use `codegate workspace activate workspace_name`" + return "Please provide a name. Use `codegate workspace activate `" workspace_name = args[0] if not workspace_name: - return "Please provide a name. Use `codegate workspace activate workspace_name`" + return "Please provide a name. Use `codegate workspace activate `" try: await self.workspace_crud.activate_workspace(workspace_name) @@ -254,11 +254,11 @@ async def _archive_workspace(self, flags: Dict[str, str], args: List[str]) -> st Remove a workspace """ if args is None or len(args) == 0: - return "Please provide a name. Use `codegate workspace archive workspace_name`" + return "Please provide a name. Use `codegate workspace archive `" workspace_name = args[0] if not workspace_name: - return "Please provide a name. Use `codegate workspace archive workspace_name`" + return "Please provide a name. Use `codegate workspace archive `" try: await self.workspace_crud.soft_delete_workspace(workspace_name) @@ -285,11 +285,11 @@ async def _restore_workspace(self, flags: Dict[str, str], args: List[str]) -> st Restore an archived workspace """ if args is None or len(args) == 0: - return "Please provide a name. Use `codegate workspace restore workspace_name`" + return "Please provide a name. Use `codegate workspace restore `" workspace_name = args[0] if not workspace_name: - return "Please provide a name. Use `codegate workspace restore workspace_name`" + return "Please provide a name. Use `codegate workspace restore `" try: await self.workspace_crud.recover_workspace(workspace_name) @@ -306,11 +306,15 @@ async def _delete_archived_workspace(self, flags: Dict[str, str], args: List[str Hard delete an archived workspace """ if args is None or len(args) == 0: - return "Please provide a name. Use `codegate workspace delete-archived workspace_name`" + return ( + "Please provide a name. Use `codegate workspace delete-archived `" + ) workspace_name = args[0] if not workspace_name: - return "Please provide a name. Use `codegate workspace delete-archived workspace_name`" + return ( + "Please provide a name. Use `codegate workspace delete-archived `" + ) try: await self.workspace_crud.hard_delete_workspace(workspace_name) @@ -328,30 +332,38 @@ def help(self) -> str: "### CodeGate Workspace\n\n" "Manage workspaces.\n\n" "**Usage**: `codegate workspace [args]`\n\n" - "Available commands:\n\n" - "- `list`: List all workspaces\n\n" - " - *args*: None\n\n" - "- `add`: Add a workspace\n\n" - " - *args*:\n\n" - " - `workspace_name`\n\n" - "- `activate`: Activate a workspace\n\n" - " - *args*:\n\n" - " - `workspace_name`\n\n" - "- `archive`: Archive a workspace\n\n" - " - *args*:\n\n" - " - `workspace_name`\n\n" - "- `rename`: Rename a workspace\n\n" - " - *args*:\n\n" + "Available commands:\n" + "- `list`: List all workspaces\n" + " - *args*: None\n" + " - **Usage**: `codegate workspace list`\n" + "- `add`: Add a workspace\n" + " - *args*:\n" + " - `workspace_name`\n" + " - **Usage**: `codegate workspace add `\n" + "- `activate`: Activate a workspace\n" + " - *args*:\n" + " - `workspace_name`\n" + " - **Usage**: `codegate workspace activate `\n" + "- `archive`: Archive a workspace\n" + " - *args*:\n" + " - `workspace_name`\n" + " - **Usage**: `codegate workspace archive `\n" + "- `rename`: Rename a workspace\n" + " - *args*:\n" + " - `workspace_name`\n" + " - `new_workspace_name`\n" + " - **Usage**: `codegate workspace rename `\n" + "- `list-archived`: List all archived workspaces\n" + " - *args*: None\n" + " - **Usage**: `codegate workspace list-archived`\n" + "- `restore`: Restore an archived workspace\n" + " - *args*:\n" + " - `workspace_name`\n" + " - **Usage**: `codegate workspace restore `\n" + "- `delete-archived`: Hard delete an archived workspace\n" + " - *args*:\n" " - `workspace_name`\n" - " - `new_workspace_name`\n\n" - "- `list-archived`: List all archived workspaces\n\n" - " - *args*: None\n\n" - "- `restore`: Restore an archived workspace\n\n" - " - *args*:\n\n" - " - `workspace_name`\n\n" - "- `delete-archived`: Hard delete an archived workspace\n\n" - " - *args*:\n\n" - " - `workspace_name`\n\n" + " - **Usage**: `codegate workspace delete-archived `\n" ) @@ -403,10 +415,10 @@ async def _set_custom_instructions(self, flags: Dict[str, str], args: List[str]) except crud.WorkspaceDoesNotExistError: return ( f"Workspace custom instructions not updated. " - f"Workspace `{workspace_name}` doesn't exist" + f"Workspace **{workspace_name}** doesn't exist" ) - return f"Workspace `{updated_worksapce.name}` custom instructions updated." + return f"Workspace **{updated_worksapce.name}** custom instructions updated." async def _show_custom_instructions(self, flags: Dict[str, str], args: List[str]) -> str: """ @@ -421,7 +433,7 @@ async def _show_custom_instructions(self, flags: Dict[str, str], args: List[str] try: workspace = await self.workspace_crud.get_workspace_by_name(workspace_name) except crud.WorkspaceDoesNotExistError: - return f"Workspace `{workspace_name}` doesn't exist" + return f"Workspace **{workspace_name}** doesn't exist" sysprompt = workspace.custom_instructions if not sysprompt: @@ -444,9 +456,9 @@ async def _reset_custom_instructions(self, flags: Dict[str, str], args: List[str workspace_name, [""] ) except crud.WorkspaceDoesNotExistError: - return f"Workspace `{workspace_name}` doesn't exist" + return f"Workspace **{workspace_name}** doesn't exist" - return f"Workspace `{updated_worksapce.name}` custom instructions reset." + return f"Workspace **{updated_worksapce.name}** custom instructions reset." @property def help(self) -> str: @@ -455,7 +467,7 @@ def help(self) -> str: "Manage the custom instructionss of workspaces.\n\n" "*Note*: If you want to update the custom instructions using files please go to the " "[dashboard](http://localhost:9090).\n\n" - "**Usage**: `codegate custom-instructions -w `\n\n" + "**Usage**: `codegate custom-instructions -w [args]`\n\n" "*args*:\n" "- `workspace_name`: Optional workspace name. If not specified will use the " "active workspace\n\n" diff --git a/tests/pipeline/workspace/test_workspace.py b/tests/pipeline/workspace/test_workspace.py index 8cadf038..32bf5fc6 100644 --- a/tests/pipeline/workspace/test_workspace.py +++ b/tests/pipeline/workspace/test_workspace.py @@ -55,9 +55,9 @@ async def test_list_workspaces(mock_workspaces, expected_output): "args, existing_workspaces, expected_message", [ # Case 1: No workspace name provided - ([], [], "Please provide a name. Use `codegate workspace add your_workspace_name`"), + ([], [], "Please provide a name. Use `codegate workspace add `"), # Case 2: Workspace name is empty string - ([""], [], "Please provide a name. Use `codegate workspace add your_workspace_name`"), + ([""], [], "Please provide a name. Use `codegate workspace add `"), # Case 3: Successful add (["myworkspace"], [], "Workspace **myworkspace** has been added"), ],