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

Function cursor_event_candidates

src/hooks/cursor.rs:471–508  ·  view source on GitHub ↗
(event: &Value)

Source from the content-addressed store, hash-verified

469}
470
471fn cursor_event_candidates(event: &Value) -> Vec<PathBuf> {
472 let mut candidates = Vec::new();
473 let mut push_unique = |candidate: PathBuf| {
474 if !candidates.iter().any(|seen| seen == &candidate) {
475 candidates.push(candidate);
476 }
477 };
478 if let Some(cwd) = cursor_event_cwd(event) {
479 push_unique(cwd);
480 }
481 if let Some(project_root) = crate::config::brand_env("PROJECT_ROOT") {
482 push_unique(PathBuf::from(project_root));
483 }
484 if let Some(file_path) = event
485 .get("file_path")
486 .and_then(Value::as_str)
487 .filter(|s| !s.is_empty())
488 {
489 let path = Path::new(file_path);
490 push_unique(path.parent().unwrap_or(path).to_path_buf());
491 }
492 if let Some(transcript_path) = event
493 .get("transcript_path")
494 .and_then(Value::as_str)
495 .filter(|s| !s.is_empty())
496 {
497 let path = Path::new(transcript_path);
498 push_unique(path.parent().unwrap_or(path).to_path_buf());
499 }
500 if let Some(roots) = event.get("workspace_roots").and_then(Value::as_array) {
501 for root in roots {
502 if let Some(path) = root.as_str().filter(|s| !s.is_empty()) {
503 push_unique(PathBuf::from(path));
504 }
505 }
506 }
507 candidates
508}
509
510fn cursor_event_cwd(event: &Value) -> Option<PathBuf> {
511 event

Calls 5

cursor_event_cwdFunction · 0.85
brand_envFunction · 0.85
pushMethod · 0.80
is_emptyMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected