pub struct PathResolver { /* private fields */ }Expand description
Builder-style resolver over Cursor’s data directories.
Implementations§
Source§impl PathResolver
impl PathResolver
pub fn new() -> Self
pub fn with_home<P: Into<PathBuf>>(self, home: P) -> Self
Sourcepub fn with_anysphere_dir<P: Into<PathBuf>>(self, dir: P) -> Self
pub fn with_anysphere_dir<P: Into<PathBuf>>(self, dir: P) -> Self
Override ~/.cursor/ directly.
Sourcepub fn with_user_data_dir<P: Into<PathBuf>>(self, dir: P) -> Self
pub fn with_user_data_dir<P: Into<PathBuf>>(self, dir: P) -> Self
Override the Electron user-data root. On macOS this defaults
to <home>/Library/Application Support/Cursor.
pub fn home_dir(&self) -> Result<&Path>
Sourcepub fn anysphere_dir(&self) -> Result<PathBuf>
pub fn anysphere_dir(&self) -> Result<PathBuf>
Path to ~/.cursor/.
Sourcepub fn projects_dir(&self) -> Result<PathBuf>
pub fn projects_dir(&self) -> Result<PathBuf>
Path to ~/.cursor/projects/.
Sourcepub fn project_transcripts_dir(&self, slug: &str) -> Result<PathBuf>
pub fn project_transcripts_dir(&self, slug: &str) -> Result<PathBuf>
Path to the agent-transcripts folder for a project slug.
Sourcepub fn transcript_path(&self, slug: &str, composer_id: &str) -> Result<PathBuf>
pub fn transcript_path(&self, slug: &str, composer_id: &str) -> Result<PathBuf>
Path to the JSONL transcript file for a composer in a project.
Sourcepub fn user_data_dir(&self) -> Result<PathBuf>
pub fn user_data_dir(&self) -> Result<PathBuf>
Path to the Electron user-data root.
Sourcepub fn global_storage_dir(&self) -> Result<PathBuf>
pub fn global_storage_dir(&self) -> Result<PathBuf>
Path to <user-data>/User/globalStorage/.
Sourcepub fn db_path(&self) -> Result<PathBuf>
pub fn db_path(&self) -> Result<PathBuf>
Path to the primary cross-workspace SQLite database
(<user-data>/User/globalStorage/state.vscdb).
Sourcepub fn workspace_storage_dir(&self) -> Result<PathBuf>
pub fn workspace_storage_dir(&self) -> Result<PathBuf>
Path to <user-data>/User/workspaceStorage/. Cursor stores
one subdirectory per workspace folder it’s been opened
against, named by the workspace id (an opaque 32-hex-char
hash Cursor computes from the folder URI). Each subdir
contains a workspace.json with the canonical folder URI
that subdir is bound to.
Sourcepub fn find_workspace_id(&self, folder: &Path) -> Result<Option<String>>
pub fn find_workspace_id(&self, folder: &Path) -> Result<Option<String>>
Look up Cursor’s workspace id for a given folder, if it has
been opened in Cursor.app before. Scans every
workspaceStorage/<id>/workspace.json, returning the <id>
whose recorded folder URI canonicalizes to folder.
Returns Ok(None) when the folder hasn’t been opened yet —
the caller can decide whether to synthesize one via
Self::ensure_workspace_storage_entry.
Sourcepub fn ensure_workspace_storage_entry(
&self,
folder: &Path,
synthesize_id: impl FnOnce(&Path) -> String,
) -> Result<EnsuredWorkspaceId>
pub fn ensure_workspace_storage_entry( &self, folder: &Path, synthesize_id: impl FnOnce(&Path) -> String, ) -> Result<EnsuredWorkspaceId>
Look up the workspace id for folder; if none exists, create
workspaceStorage/<synthesized-id>/workspace.json recording
the folder URI and return the synthesized id. The next time
Cursor.app opens that folder it’ll scan workspaceStorage,
match by URI, and adopt our id — so any composer we projected
with workspaceIdentifier.id = <our-id> lights up in the
sidebar.
synthesize_id decides what id to assign for new folders.
Production callers should pass a stable hash (e.g. the
first 32 hex chars of SHA-256 of the folder path) so re-runs
don’t accumulate orphaned workspaceStorage entries.
Trait Implementations§
Source§impl Clone for PathResolver
impl Clone for PathResolver
Source§fn clone(&self) -> PathResolver
fn clone(&self) -> PathResolver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more