pub struct WorkspaceManager { /* private fields */ }Expand description
Owns all workspaces and provides the public API for multi-context operations.
§Design
Workspaces and contexts are identified by auto-generated string IDs
("ws-N", "ctx-N"). The manager tracks which workspace is currently
active to serve as a convenient default in CLI/MCP workflows.
Implementations§
Source§impl WorkspaceManager
impl WorkspaceManager
Sourcepub fn create(&mut self, name: &str) -> String
pub fn create(&mut self, name: &str) -> String
Create a new workspace with the given name.
The workspace becomes the active workspace and its generated ID is
returned (e.g., "ws-1").
Sourcepub fn add_context(
&mut self,
workspace_id: &str,
path: &str,
role: ContextRole,
language: Option<String>,
graph: CodeGraph,
) -> Result<String, String>
pub fn add_context( &mut self, workspace_id: &str, path: &str, role: ContextRole, language: Option<String>, graph: CodeGraph, ) -> Result<String, String>
Add a codebase context to an existing workspace.
Returns the generated context ID (e.g., "ctx-2") or an error if the
workspace does not exist.
Sourcepub fn list(&self, workspace_id: &str) -> Result<&Workspace, String>
pub fn list(&self, workspace_id: &str) -> Result<&Workspace, String>
Return a reference to the given workspace.
Sourcepub fn get_active(&self) -> Option<&str>
pub fn get_active(&self) -> Option<&str>
Return the ID of the currently active workspace, if any.
Sourcepub fn query_all(
&self,
workspace_id: &str,
query: &str,
) -> Result<Vec<CrossContextResult>, String>
pub fn query_all( &self, workspace_id: &str, query: &str, ) -> Result<Vec<CrossContextResult>, String>
Search all contexts in a workspace for symbols whose name contains
query (case-insensitive substring match).
Returns one CrossContextResult per context that has at least one
matching symbol.
Sourcepub fn query_context(
&self,
workspace_id: &str,
context_id: &str,
query: &str,
) -> Result<Vec<SymbolMatch>, String>
pub fn query_context( &self, workspace_id: &str, context_id: &str, query: &str, ) -> Result<Vec<SymbolMatch>, String>
Search a single context for symbols whose name contains query
(case-insensitive substring match).
Sourcepub fn compare(
&self,
workspace_id: &str,
symbol: &str,
) -> Result<Comparison, String>
pub fn compare( &self, workspace_id: &str, symbol: &str, ) -> Result<Comparison, String>
Compare a symbol across all contexts in a workspace.
For every context the method records whether the symbol was found and,
if so, its type, signature, and file path. Structural differences
(e.g., different types or signatures) are collected into
Comparison::structural_diff.
Sourcepub fn cross_reference(
&self,
workspace_id: &str,
symbol: &str,
) -> Result<CrossReference, String>
pub fn cross_reference( &self, workspace_id: &str, symbol: &str, ) -> Result<CrossReference, String>
Build a cross-reference report for a symbol across all contexts.
Returns lists of contexts where the symbol was found and where it is
missing (both annotated with their ContextRole).