MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / cursor_project_slug

Function cursor_project_slug

src/sessions/cursor.rs:550–560  ·  view source on GitHub ↗

Compute the `~/.cursor/projects` directory slug Cursor derives from a workspace path: every normal path component joined with `-`, case preserved (verified against real `~/.cursor/projects` entries). Returns `None` for non-UTF-8, relative, or traversal-containing paths.

(project_root: &Path)

Source from the content-addressed store, hash-verified

548/// preserved (verified against real `~/.cursor/projects` entries).
549/// Returns `None` for non-UTF-8, relative, or traversal-containing paths.
550pub fn cursor_project_slug(project_root: &Path) -> Option<String> {
551 let mut parts = Vec::new();
552 for component in project_root.components() {
553 match component {
554 std::path::Component::Normal(part) => parts.push(part.to_str()?),
555 std::path::Component::RootDir | std::path::Component::Prefix(_) => {}
556 std::path::Component::CurDir | std::path::Component::ParentDir => return None,
557 }
558 }
559 (!parts.is_empty()).then(|| parts.join("-"))
560}
561
562/// Enumerate every *existing* directory that [`cursor_project_slug`] would
563/// encode to `slug`, by walking the filesystem from `project_root`'s root and

Calls 2

pushMethod · 0.80
is_emptyMethod · 0.45