pub struct Workspace { /* private fields */ }Expand description
Workspace runtime state. Shared across MCP request clones via Arc.
Implementations§
Source§impl Workspace
impl Workspace
Sourcepub fn open(
workspace_dir: PathBuf,
stale_after_days: u32,
post_activate: Option<PostActivateHook>,
) -> Result<Self>
pub fn open( workspace_dir: PathBuf, stale_after_days: u32, post_activate: Option<PostActivateHook>, ) -> Result<Self>
Open a github-flavoured workspace (clone + track flow).
Sourcepub fn open_local(
root: PathBuf,
post_activate: Option<PostActivateHook>,
) -> Result<Self>
pub fn open_local( root: PathBuf, post_activate: Option<PostActivateHook>, ) -> Result<Self>
Open a local-directory workspace.
Binds root as the active source root immediately and fires the
post-activate hook (subject to last-built-sha gating). inventory.json
is kept under <root>/.mcp-workspace/ so the local mode mirrors
the same gating / fingerprinting infra without polluting the
user’s tree with a repos/ directory.
pub fn kind(&self) -> WorkspaceKind
pub fn workspace_dir(&self) -> &Path
pub fn repos_dir(&self) -> PathBuf
Sourcepub fn active_repo_name(&self) -> Option<String>
pub fn active_repo_name(&self) -> Option<String>
Active repo’s full org/repo name, or None if nothing is active.
Sourcepub fn active_repo_path(&self) -> Option<PathBuf>
pub fn active_repo_path(&self) -> Option<PathBuf>
Active repo’s filesystem path, or None.
Sourcepub fn last_built_sha(&self, name: &str) -> Option<String>
pub fn last_built_sha(&self, name: &str) -> Option<String>
Read the SHA recorded after the last successful post-activate hook
for the named repo. None if the repo was never built (or the
hook last failed). Useful for downstream consumers gating
“is the active graph up to date with the repo HEAD?” checks.
Sourcepub fn repo_management(
&self,
name: Option<&str>,
delete: bool,
update: bool,
force_rebuild: bool,
) -> String
pub fn repo_management( &self, name: Option<&str>, delete: bool, update: bool, force_rebuild: bool, ) -> String
Public entry for the repo_management MCP tool.
name:org/repoto activate (None = list / refresh mode).delete: remove the named repo + inventory entry. Github only.update: refresh the active repo (auto-rebuild gated).force_rebuild: withupdate=true(or initial activation), re-run the post-activate hook even when the HEAD SHA matcheslast_built_sha. Useful after the builder itself has been upgraded.
Local mode behaviour: name and delete are rejected; pass
update=true (or no args after the initial activation) to
re-fingerprint the root and rebuild if anything changed.
Sourcepub fn set_root_dir(&self, new_root: &Path) -> String
pub fn set_root_dir(&self, new_root: &Path) -> String
Swap the active root (local mode only). Re-fires the post-activate hook against the new root. Errors if the workspace is github-flavoured.