scryer-engine 0.2.0

Tree-sitter and stack-graphs AST indexing engine for Scryer code intelligence
use std::path::{Path, PathBuf};

use anyhow::Result;
use async_trait::async_trait;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DependencySourceType {
    CratesIo,
    Git,
    Path,
    Unknown(String),
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DiscoveredDependency {
    pub name: String,
    pub version: String,
    pub source_type: DependencySourceType,
    pub manifest_path: PathBuf,
    pub root_path: PathBuf,
    pub package_hash: Option<String>,
    pub is_direct: bool,
    pub features: Vec<String>,
}

#[async_trait]
pub trait DependencyProvider: Send + Sync {
    /// Ecosystem identifier, e.g. "cargo", "npm", "pip"
    fn ecosystem(&self) -> &'static str;

    /// Discover all direct and transitive dependencies from a workspace root
    async fn discover_dependencies(&self, root: &Path) -> Result<Vec<DiscoveredDependency>>;

    /// Resolve the root source directory for an unpacked dependency
    fn resolve_source_directory(&self, dep: &DiscoveredDependency) -> Result<PathBuf>;
}