acp/sync/adapters/
generic.rs

1//! Generic adapter (AGENTS.md)
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::{MergeStrategy, Tool};
9
10/// Generic adapter - generates AGENTS.md (fallback for any AI tool)
11pub struct GenericAdapter;
12
13impl ToolAdapter for GenericAdapter {
14    fn tool(&self) -> Tool {
15        Tool::Generic
16    }
17
18    fn detect(&self, _project_root: &Path) -> DetectionResult {
19        // Always "detected" - serves as universal fallback
20        DetectionResult {
21            tool: Tool::Generic,
22            detected: true,
23            reason: "Universal fallback".into(),
24            existing_file: None,
25        }
26    }
27
28    fn generate(&self, _context: &BootstrapContext) -> Result<String> {
29        let mut content = String::from(
30            "# AGENTS.md - AI Assistant Context\n\n\
31             This document provides context for AI assistants working with this codebase.\n\
32             Generated by [AI Context Protocol](https://acp-protocol.dev).\n\n\
33             ---\n\n",
34        );
35
36        content.push_str(&generate_bootstrap_markdown(Tool::Generic));
37
38        content.push_str("\n---\n\n## Raw Data Access\n\n");
39        content.push_str("For programmatic access to codebase intelligence:\n\n");
40        content.push_str("| File | Purpose |\n");
41        content.push_str("|------|--------|\n");
42        content.push_str("| `.acp/acp.cache.json` | Complete codebase index |\n");
43        content.push_str("| `.acp/acp.vars.json` | Variable definitions |\n");
44        content.push_str("| `.acp.config.json` | Configuration |\n");
45
46        Ok(content)
47    }
48
49    fn merge_strategy(&self) -> MergeStrategy {
50        MergeStrategy::Replace // Full regeneration for AGENTS.md
51    }
52}