ggen-domain 3.2.0

Domain logic layer for ggen - pure business logic without CLI dependencies
Documentation
//! AI-powered code analysis
//!
//! This module provides AI-powered analysis capabilities for code and project
//! structures. It can analyze code snippets and entire project directories to
//! provide insights and recommendations.
//!
//! ## Features
//!
//! - **Code Analysis**: Analyze code snippets for patterns and issues
//! - **Project Analysis**: Analyze entire project structures
//! - **Insights Generation**: Generate actionable insights from analysis
//!
//! ## Examples
//!
//! ### Analyzing Code
//!
//! ```rust,no_run
//! use ggen_domain::ai::analyze::analyze_code;
//!
//! # async fn example() -> anyhow::Result<()> {
//! let code = r#"
//! fn main() {
//!     println!("Hello, world!");
//! }
//! "#;
//! let analysis = analyze_code(code).await?;
//! println!("{}", analysis);
//! # Ok(())
//! # }
//! ```
//!
//! ### Analyzing a Project
//!
//! ```rust,no_run
//! use ggen_domain::ai::analyze::analyze_project;
//! use std::path::Path;
//!
//! # async fn example() -> anyhow::Result<()> {
//! let analysis = analyze_project(Path::new("my-project")).await?;
//! println!("{}", analysis);
//! # Ok(())
//! # }
//! ```

use ggen_utils::{bail, error::Result};

/// Analyze code and provide insights
pub async fn analyze_code(code: &str) -> Result<String> {
    if code.is_empty() {
        bail!("Code cannot be empty");
    }

    Ok(format!("Analysis of {} characters of code", code.len()))
}

/// Analyze project structure
pub async fn analyze_project(path: &std::path::Path) -> Result<String> {
    if !path.exists() {
        bail!("Path does not exist: {}", path.display());
    }

    Ok(format!("Project analysis for: {}", path.display()))
}