66
77from basic_memory .cli .commands .command_utils import run_with_cleanup
88from basic_memory .config import ConfigManager
9- from basic_memory .mcp .project_context import (
10- _workspace_choices ,
11- _workspace_matches_identifier ,
12- get_available_workspaces ,
9+ from basic_memory .mcp .project_context import get_available_workspaces
10+ from basic_memory .schemas .cloud import (
11+ format_workspace_choices ,
12+ format_workspace_selection_choices ,
13+ workspace_matches_identifier ,
1314)
1415
1516console = Console ()
@@ -62,7 +63,10 @@ async def _list():
6263
6364@workspace_app .command ("set-default" )
6465def set_default_workspace (
65- identifier : str = typer .Argument (..., help = "Workspace name or tenant_id to set as default" ),
66+ identifier : str = typer .Argument (
67+ ...,
68+ help = "Workspace name, slug, type, or tenant_id to set as default" ,
69+ ),
6670) -> None :
6771 """Set the default cloud workspace.
6872
@@ -71,6 +75,7 @@ def set_default_workspace(
7175
7276 Examples:
7377 bm cloud workspace set-default Personal
78+ bm cloud workspace set-default organization
7479 bm cloud workspace set-default 11111111-1111-1111-1111-111111111111
7580 """
7681
@@ -87,19 +92,21 @@ async def _list():
8792 console .print ("[yellow]No accessible workspaces found.[/yellow]" )
8893 raise typer .Exit (1 )
8994
90- matches = [ws for ws in workspaces if _workspace_matches_identifier (ws , identifier )]
95+ matches = [ws for ws in workspaces if workspace_matches_identifier (ws , identifier )]
9196
9297 if not matches :
9398 console .print (f"[red]Error: Workspace '{ identifier } ' not found[/red]" )
94- console .print (f"[dim]Available:\n { _workspace_choices (workspaces )} [/dim]" )
99+ console .print (f"[dim]Available:\n { format_workspace_choices (workspaces )} [/dim]" )
95100 raise typer .Exit (1 )
96101
97102 if len (matches ) > 1 :
98103 console .print (
99- f"[red]Error: Workspace name '{ identifier } ' matches multiple workspaces. "
100- f"Use tenant_id instead.[/red]"
104+ f"[red]Error: Workspace '{ identifier } ' matches multiple workspaces.[/red]"
105+ )
106+ console .print (
107+ "[dim]Choose one of these matching workspaces by slug:\n "
108+ f"{ format_workspace_selection_choices (matches )} [/dim]"
101109 )
102- console .print (f"[dim]Available:\n { _workspace_choices (workspaces )} [/dim]" )
103110 raise typer .Exit (1 )
104111
105112 selected = matches [0 ]
0 commit comments