acp/sync/adapters/
cursor.rs

1//! Cursor IDE adapter
2
3use std::path::Path;
4
5use crate::error::Result;
6use crate::sync::adapter::{BootstrapContext, DetectionResult, ToolAdapter};
7use crate::sync::content::generate_bootstrap_markdown;
8use crate::sync::tool::Tool;
9
10/// Cursor IDE adapter - generates .cursorrules
11pub struct CursorAdapter;
12
13impl ToolAdapter for CursorAdapter {
14    fn tool(&self) -> Tool {
15        Tool::Cursor
16    }
17
18    fn detect(&self, project_root: &Path) -> DetectionResult {
19        let cursorrules = project_root.join(".cursorrules");
20        let cursor_dir = project_root.join(".cursor");
21
22        DetectionResult {
23            tool: Tool::Cursor,
24            detected: cursorrules.exists() || cursor_dir.exists(),
25            reason: if cursorrules.exists() {
26                ".cursorrules exists".into()
27            } else if cursor_dir.exists() {
28                ".cursor/ directory exists".into()
29            } else {
30                "Not detected".into()
31            },
32            existing_file: if cursorrules.exists() {
33                Some(cursorrules)
34            } else {
35                None
36            },
37        }
38    }
39
40    fn generate(&self, _context: &BootstrapContext) -> Result<String> {
41        Ok(generate_bootstrap_markdown(Tool::Cursor))
42    }
43}