acp/sync/adapters/
copilot.rs

1//! GitHub Copilot 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/// GitHub Copilot adapter - generates .github/copilot-instructions.md
11pub struct CopilotAdapter;
12
13impl ToolAdapter for CopilotAdapter {
14    fn tool(&self) -> Tool {
15        Tool::Copilot
16    }
17
18    fn detect(&self, project_root: &Path) -> DetectionResult {
19        let github_dir = project_root.join(".github");
20        let copilot_instructions = github_dir.join("copilot-instructions.md");
21
22        DetectionResult {
23            tool: Tool::Copilot,
24            detected: github_dir.exists(),
25            reason: if copilot_instructions.exists() {
26                "copilot-instructions.md exists".into()
27            } else if github_dir.exists() {
28                ".github/ directory exists".into()
29            } else {
30                "Not detected".into()
31            },
32            existing_file: if copilot_instructions.exists() {
33                Some(copilot_instructions)
34            } else {
35                None
36            },
37        }
38    }
39
40    fn generate(&self, _context: &BootstrapContext) -> Result<String> {
41        Ok(generate_bootstrap_markdown(Tool::Copilot))
42    }
43}