@@ -31,10 +31,10 @@ async def run(self, args: List[str]) -> str:
31
31
@property
32
32
def help (self ) -> str :
33
33
return (
34
- "### CodeGate Version\n \n "
34
+ "### CodeGate Version\n "
35
35
"Prints the version of CodeGate.\n \n "
36
+ "*args*: None\n \n "
36
37
"**Usage**: `codegate version`\n \n "
37
- "*args*: None"
38
38
)
39
39
40
40
@@ -46,6 +46,7 @@ def __init__(self):
46
46
"list" : self ._list_workspaces ,
47
47
"add" : self ._add_workspace ,
48
48
"activate" : self ._activate_workspace ,
49
+ "system-prompt" : self ._add_system_prompt ,
49
50
}
50
51
51
52
async def _list_workspaces (self , * args : List [str ]) -> str :
@@ -66,33 +67,33 @@ async def _add_workspace(self, args: List[str]) -> str:
66
67
Add a workspace
67
68
"""
68
69
if args is None or len (args ) == 0 :
69
- return "Please provide a name. Use `codegate workspace add your_workspace_name `"
70
+ return "Please provide a name. Use `codegate workspace add <workspace_name> `"
70
71
71
72
new_workspace_name = args [0 ]
72
73
if not new_workspace_name :
73
- return "Please provide a name. Use `codegate workspace add your_workspace_name `"
74
+ return "Please provide a name. Use `codegate workspace add <workspace_name> `"
74
75
75
76
try :
76
77
_ = await self .workspace_crud .add_workspace (new_workspace_name )
77
78
except ValidationError :
78
79
return "Invalid workspace name: It should be alphanumeric and dashes"
79
80
except AlreadyExistsError :
80
- return f"Workspace ** { new_workspace_name } ** already exists"
81
+ return f"Workspace ` { new_workspace_name } ` already exists"
81
82
except Exception :
82
83
return "An error occurred while adding the workspace"
83
84
84
- return f"Workspace ** { new_workspace_name } ** has been added"
85
+ return f"Workspace ` { new_workspace_name } ` has been added"
85
86
86
87
async def _activate_workspace (self , args : List [str ]) -> str :
87
88
"""
88
89
Activate a workspace
89
90
"""
90
91
if args is None or len (args ) == 0 :
91
- return "Please provide a name. Use `codegate workspace activate workspace_name`"
92
+ return "Please provide a name. Use `codegate workspace activate < workspace_name> `"
92
93
93
94
workspace_name = args [0 ]
94
95
if not workspace_name :
95
- return "Please provide a name. Use `codegate workspace activate workspace_name`"
96
+ return "Please provide a name. Use `codegate workspace activate < workspace_name> `"
96
97
97
98
try :
98
99
await self .workspace_crud .activate_workspace (workspace_name )
@@ -104,16 +105,27 @@ async def _activate_workspace(self, args: List[str]) -> str:
104
105
return "An error occurred while activating the workspace"
105
106
return f"Workspace **{ workspace_name } ** has been activated"
106
107
107
- async def _add_system_prompt (self , workspace_name : str , sys_prompt_lst : List [str ]):
108
- updated_worksapce = await self .workspace_crud .update_workspace_system_prompt (workspace_name , sys_prompt_lst )
108
+ async def _add_system_prompt (self , args : List [str ]):
109
+ if len (args ) < 2 :
110
+ return (
111
+ "Please provide a workspace name and a system prompt. "
112
+ "Use `codegate workspace system-prompt <workspace_name> <system_prompt>`"
113
+ )
114
+
115
+ workspace_name = args [0 ]
116
+ sys_prompt_lst = args [1 :]
117
+
118
+ updated_worksapce = await self .workspace_crud .update_workspace_system_prompt (
119
+ workspace_name , sys_prompt_lst
120
+ )
109
121
if not updated_worksapce :
110
122
return (
111
123
f"Workspace system prompt not updated. "
112
- f"Check if the workspace ** { workspace_name } ** exists"
124
+ f"Check if the workspace ` { workspace_name } ` exists"
113
125
)
114
126
return (
115
- f"Workspace ** { updated_worksapce .name } ** system prompt "
116
- f"updated to:\n \n ```{ updated_worksapce .system_prompt } ```"
127
+ f"Workspace ` { updated_worksapce .name } ` system prompt "
128
+ f"updated to:\n ```\n { updated_worksapce .system_prompt } \n ```"
117
129
)
118
130
119
131
async def run (self , args : List [str ]) -> str :
@@ -124,23 +136,29 @@ async def run(self, args: List[str]) -> str:
124
136
if command_to_execute is not None :
125
137
return await command_to_execute (args [1 :])
126
138
else :
127
- if len (args ) >= 2 and args [1 ] == "system-prompt" :
128
- return await self ._add_system_prompt (args [0 ], args [2 :])
129
139
return "Command not found. Use `codegate workspace -h` to see available commands"
130
140
131
141
@property
132
142
def help (self ) -> str :
133
143
return (
134
- "### CodeGate Workspace\n \n "
144
+ "### CodeGate Workspace\n "
135
145
"Manage workspaces.\n \n "
136
146
"**Usage**: `codegate workspace <command> [args]`\n \n "
137
- "Available commands:\n \n "
138
- "- `list`: List all workspaces\n \n "
139
- " - *args*: None\n \n "
140
- "- `add`: Add a workspace\n \n "
141
- " - *args*:\n \n "
142
- " - `workspace_name`\n \n "
143
- "- `activate`: Activate a workspace\n \n "
144
- " - *args*:\n \n "
145
- " - `workspace_name`"
147
+ "Available commands:\n "
148
+ "- `list`: List all workspaces\n "
149
+ " - *args*: None\n "
150
+ " - **Usage**: `codegate workspace list`\n "
151
+ "- `add`: Add a workspace\n "
152
+ " - *args*:\n "
153
+ " - `workspace_name`\n "
154
+ " - **Usage**: `codegate workspace add <workspace_name>`\n "
155
+ "- `activate`: Activate a workspace\n "
156
+ " - *args*:\n "
157
+ " - `workspace_name`\n "
158
+ " - **Usage**: `codegate workspace activate <workspace_name>`\n "
159
+ "- `system-prompt`: Modify the system-prompt of a workspace\n "
160
+ " - *args*:\n "
161
+ " - `workspace_name`\n "
162
+ " - `system_prompt`\n "
163
+ " - **Usage**: `codegate workspace system-prompt <workspace_name> <system_prompt>`\n "
146
164
)
0 commit comments