Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 3cd60e8

Browse files
Added show system-prompt command
1 parent f854816 commit 3cd60e8

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/codegate/pipeline/cli/commands.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ def flags(self) -> List[str]:
230230
def subcommands(self) -> Dict[str, Callable[[List[str]], Awaitable[str]]]:
231231
return {
232232
"set": self._set_system_prompt,
233+
"show": self._show_system_prompt,
233234
}
234235

235236
async def _set_system_prompt(self, flags: Dict[str, str], args: List[str]) -> str:
@@ -253,10 +254,22 @@ async def _set_system_prompt(self, flags: Dict[str, str], args: List[str]) -> st
253254
f"Workspace system prompt not updated. Workspace `{workspace_name}` doesn't exist"
254255
)
255256

256-
return (
257-
f"Workspace `{updated_worksapce.name}` system prompt "
258-
f"updated to:\n```\n{updated_worksapce.system_prompt}\n```"
259-
)
257+
return f"Workspace `{updated_worksapce.name}` system prompt updated."
258+
259+
async def _show_system_prompt(self, flags: Dict[str, str], args: List[str]) -> str:
260+
workspace_name = flags.get("-w")
261+
if not workspace_name:
262+
active_workspace = await self.workspace_crud.get_active_workspace()
263+
workspace_name = active_workspace.name
264+
265+
try:
266+
workspace = await self.workspace_crud.get_workspace_by_name(workspace_name)
267+
except crud.WorkspaceDoesNotExistError:
268+
return (
269+
f"Workspace `{workspace_name}` doesn't exist"
270+
)
271+
272+
return f"Workspace **{workspace.name}** system prompt:\n\n{workspace.system_prompt}."
260273

261274
@property
262275
def help(self) -> str:

src/codegate/workspaces/crud.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,9 @@ async def update_workspace_system_prompt(
9999
db_recorder = DbRecorder()
100100
updated_workspace = await db_recorder.update_workspace(workspace_update)
101101
return updated_workspace
102+
103+
async def get_workspace_by_name(self, workspace_name: str) -> Workspace:
104+
workspace = await self._db_reader.get_workspace_by_name(workspace_name)
105+
if not workspace:
106+
raise WorkspaceDoesNotExistError(f"Workspace {workspace_name} does not exist.")
107+
return workspace

0 commit comments

Comments
 (0)