@@ -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,52 +67,63 @@ 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
was_activated = await self .workspace_crud .activate_workspace (workspace_name )
98
99
if not was_activated :
99
100
return (
100
- f"Workspace ** { workspace_name } ** does not exist or was already active. "
101
+ f"Workspace ` { workspace_name } ` does not exist or was already active. "
101
102
f"Use `codegate workspace add { workspace_name } ` to add it"
102
103
)
103
- return f"Workspace ** { workspace_name } ** has been activated"
104
+ return f"Workspace ` { workspace_name } ` has been activated"
104
105
105
- async def _add_system_prompt (self , workspace_name : str , sys_prompt_lst : List [str ]):
106
- updated_worksapce = await self .workspace_crud .update_workspace_system_prompt (workspace_name , sys_prompt_lst )
106
+ async def _add_system_prompt (self , args : List [str ]):
107
+ if len (args ) < 2 :
108
+ return (
109
+ "Please provide a workspace name and a system prompt. "
110
+ "Use `codegate workspace system-prompt <workspace_name> <system_prompt>`"
111
+ )
112
+
113
+ workspace_name = args [0 ]
114
+ sys_prompt_lst = args [1 :]
115
+
116
+ updated_worksapce = await self .workspace_crud .update_workspace_system_prompt (
117
+ workspace_name , sys_prompt_lst
118
+ )
107
119
if not updated_worksapce :
108
120
return (
109
121
f"Workspace system prompt not updated. "
110
- f"Check if the workspace ** { workspace_name } ** exists"
122
+ f"Check if the workspace ` { workspace_name } ` exists"
111
123
)
112
124
return (
113
- f"Workspace ** { updated_worksapce .name } ** system prompt "
114
- f"updated to:\n \n ```{ updated_worksapce .system_prompt } ```"
125
+ f"Workspace ` { updated_worksapce .name } ` system prompt "
126
+ f"updated to:\n ```\n { updated_worksapce .system_prompt } \n ```"
115
127
)
116
128
117
129
async def run (self , args : List [str ]) -> str :
@@ -122,23 +134,29 @@ async def run(self, args: List[str]) -> str:
122
134
if command_to_execute is not None :
123
135
return await command_to_execute (args [1 :])
124
136
else :
125
- if len (args ) >= 2 and args [1 ] == "system-prompt" :
126
- return await self ._add_system_prompt (args [0 ], args [2 :])
127
137
return "Command not found. Use `codegate workspace -h` to see available commands"
128
138
129
139
@property
130
140
def help (self ) -> str :
131
141
return (
132
- "### CodeGate Workspace\n \n "
142
+ "### CodeGate Workspace\n "
133
143
"Manage workspaces.\n \n "
134
144
"**Usage**: `codegate workspace <command> [args]`\n \n "
135
- "Available commands:\n \n "
136
- "- `list`: List all workspaces\n \n "
137
- " - *args*: None\n \n "
138
- "- `add`: Add a workspace\n \n "
139
- " - *args*:\n \n "
140
- " - `workspace_name`\n \n "
141
- "- `activate`: Activate a workspace\n \n "
142
- " - *args*:\n \n "
143
- " - `workspace_name`"
145
+ "Available commands:\n "
146
+ "- `list`: List all workspaces\n "
147
+ " - *args*: None\n "
148
+ " - **Usage**: `codegate workspace list`\n "
149
+ "- `add`: Add a workspace\n "
150
+ " - *args*:\n "
151
+ " - `workspace_name`\n "
152
+ " - **Usage**: `codegate workspace add <workspace_name>`\n "
153
+ "- `activate`: Activate a workspace\n "
154
+ " - *args*:\n "
155
+ " - `workspace_name`\n "
156
+ " - **Usage**: `codegate workspace activate <workspace_name>`\n "
157
+ "- `system-prompt`: Modify the system-prompt of a workspace\n "
158
+ " - *args*:\n "
159
+ " - `workspace_name`\n "
160
+ " - `system_prompt`\n "
161
+ " - **Usage**: `codegate workspace system-prompt <workspace_name> <system_prompt>`\n "
144
162
)
0 commit comments