acp/sync/adapters/
continue_dev.rs1use std::path::Path;
4
5use crate::error::Result;
6use crate::sync::adapter::{BootstrapContext, DetectionResult, ToolAdapter};
7use crate::sync::content::generate_bootstrap_json;
8use crate::sync::tool::{MergeStrategy, Tool};
9
10pub struct ContinueAdapter;
12
13impl ToolAdapter for ContinueAdapter {
14 fn tool(&self) -> Tool {
15 Tool::Continue
16 }
17
18 fn detect(&self, project_root: &Path) -> DetectionResult {
19 let continue_dir = project_root.join(".continue");
20 let config_file = continue_dir.join("config.json");
21
22 DetectionResult {
23 tool: Tool::Continue,
24 detected: continue_dir.exists(),
25 reason: if config_file.exists() {
26 ".continue/config.json exists".into()
27 } else if continue_dir.exists() {
28 ".continue/ directory exists".into()
29 } else {
30 "Not detected".into()
31 },
32 existing_file: if config_file.exists() {
33 Some(config_file)
34 } else {
35 None
36 },
37 }
38 }
39
40 fn generate(&self, _context: &BootstrapContext) -> Result<String> {
41 Ok(generate_bootstrap_json(Tool::Continue))
42 }
43
44 fn validate(&self, content: &str) -> Result<()> {
45 serde_json::from_str::<serde_json::Value>(content)
46 .map_err(|e| crate::error::AcpError::Other(format!("Invalid JSON: {}", e)))?;
47 Ok(())
48 }
49
50 fn merge_strategy(&self) -> MergeStrategy {
51 MergeStrategy::Merge
52 }
53
54 fn section_markers(&self) -> (&'static str, &'static str) {
55 ("", "")
57 }
58}