ryo-app 0.1.0

[preview] Application layer for RYO - Project management, Intent handling, API
Documentation
//! RYO App - Application layer
//!
//! This crate provides the application layer for RYO:
//! - **Project**: In-memory collection of AST files with I/O
//! - **Intent/Goal**: User intention representation
//! - **Api**: External interface for CLI/UI/Agent
//! - **Storage trait**: DI for persistent storage
//!
//! # Architecture
//!
//! ```text
//! ┌───────────────────────────────────────────────────────────────────┐
//! │ Layer 3: Application (ryo-app)                                    │
//! │ ┌───────────────────────────────────────────────────────────────┐│
//! │ │ Api                                                           ││
//! │ │ • executor: CoreExecutor (直接依存)                           ││
//! │ │ • storage: Box<dyn Storage> (DI)                              ││
//! │ └───────────────────────────────────────────────────────────────┘│
//! │ ┌───────────────────────────────────────────────────────────────┐│
//! │ │ Intent/Goal                                                   ││
//! │ │ • User intention representation                               ││
//! │ │ • JSON Schema for LLM integration                             ││
//! │ └───────────────────────────────────────────────────────────────┘│
//! │ ┌───────────────────────────────────────────────────────────────┐│
//! │ │ Project                                                       ││
//! │ │ • File collection + I/O                                       ││
//! │ └───────────────────────────────────────────────────────────────┘│
//! └───────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Usage
//!
//! ```ignore
//! use ryo_app::{Api, Project, Goal, Intent, InMemoryStorage};
//!
//! // Load project
//! let mut project = Project::from_dir("src/")?;
//!
//! // Create API with storage
//! let storage = Box::new(InMemoryStorage::new());
//! let mut api = Api::new(storage);
//!
//! // Execute a goal
//! let goal = Goal::new(Intent::RenameIdent {
//!     from: Pattern::exact("old_name"),
//!     to: "new_name".to_string(),
//!     kind: IdentKind::Any,
//! });
//!
//! let result = api.execute(&mut project, goal)?;
//! ```

pub mod api;
pub mod codec;
mod config;
mod dataflow_v2;
mod discover;
mod graph;
mod intent;
#[cfg(feature = "fuzzy-parser")]
mod intent_schema;
mod planner;
mod project;
mod schema;
pub mod service;
mod spec;
pub mod spec_dsl;
mod storage;

// === Project ===
pub use project::{Project, ProjectError};

// === Config ===
pub use config::{
    ConfigError, ImportConfig, ModuleConfig, MutationConfig, ProjectConfig, RyoConfig,
};

// === Api (Public Interface) ===
pub use api::{
    // Core API
    Api,
    ApiError,
    ApiErrorKind,
    ApiResult,
    CascadeRequest,
    CascadeResponse,
    DesignChoiceInfo,
    // Request/Response types (for tarpc transport)
    DiscoverRequest,
    DiscoverResponse,
    ExecuteOptions,
    ExecutionResult,
    // Execution Status (HTTP-inspired result codes)
    ExecutionStatus,
    GraphSummaryRequest,
    GraphSummaryResponse,
    HookResult,
    LiteralSearchRequest,
    LiteralSearchResponse,
    OverviewRequest,
    OverviewResponse,
    PostExecutionHook,
    QueryResponse,
    RunRequest,
    RunResponse,
    RyoqlRequest,
    SortOrder as ApiSortOrder,
    StatusCode,
    StatusDetail,
    StatusResponse,
    SuggestApplyRequest,
    SuggestApplyResponse,
    SuggestChoicesRequest,
    SuggestChoicesResponse,
    SuggestCompareRequest,
    SuggestCompareResponse,
    SuggestGenerateRequest,
    SuggestGenerateResponse,
    SuggestRequest,
    SuggestResponse,
    SuggestVerifyRequest,
    SuggestVerifyResponse,
    Suggestion,
    SuggestionSummary,
    VerifyLevel,
    // Re-export from ryo-query-language
    ViewMode,
};

// === DataFlow Service V2 (String-free, VarId-based) ===
pub use dataflow_v2::{
    BorrowCheckResultV2, DataFlowErrorV2, DataFlowServiceV2, DataFlowStatsV2, FlowInfoV2,
    LockAnalysisResultV2, VarInfoV2,
};

// === Discover Service ===
pub use discover::{CascadeResult, DiscoverError, DiscoverService};

// === Spec Service ===
// Note: SpecRelation and SpecRelationKind are not re-exported here to avoid conflict with intent module.
// Use ryo_app::spec::SpecRelation if needed.
pub use spec::{
    LintSeverity, SpecError, SpecFlowData, SpecGroupInfo, SpecInfo, SpecLintIssue, SpecLintResult,
    SpecService, SpecShowResponse, SpecSourceKind, SpecStats,
};
// Re-export spec module for qualified access to SpecRelation
pub mod spec_types {
    pub use super::spec::{SpecRelation, SpecRelationKind};
}

// === Storage ===
pub use storage::{InMemoryStorage, Storage};

// === Intent/Goal ===
pub use intent::{
    ConflictStrategy, Constraint, EstimatedScope, ExtractError, Goal, IdentKind, Intent,
    IntentExtractor, ScopeHint, SpecRelation, SpecRelationKind, StmtInsertPosition,
    TransformExample, Visibility,
};

// === Planner ===
pub use planner::{PlanError, PlanResult, Planner};

// Re-export ItemKind from ryo-source (canonical definition)
pub use ryo_source::ItemKind;

// === Schema (feature-gated) ===
#[cfg(feature = "schemars")]
pub use schema::{generate_goal_schema, generate_goal_schema_json};

// === Graph API ===
pub use graph::{CodeNode, GraphApi, GraphError, GraphStats, NodeKind, SummaryBuilder};

// === Re-exports for CLI (Layer 4 should only import from ryo-app) ===
// Analysis context for mutation execution
pub use ryo_analysis::AnalysisContext;

// Executor types for blueprint execution
pub use ryo_executor::{
    BlueprintExecutor, BlueprintResult, Conflict, ConflictKind, MutationSpec, ParallelBlueprint,
};

// === Re-exports for CLI (from ryo-analysis) ===
pub use ryo_analysis::query::{VarKind, VarNode};
pub use ryo_analysis::{
    CodeGraphV2, DataFlowBuilderWorkspace, DataFlowGraphV2, GraphBuilderV2, QueryBuilder,
};
pub use ryo_analysis::{
    DiscoveredSymbol, DiscoveryEngine, DiscoveryQuery, DiscoveryResult, SortOrder,
};
pub use ryo_analysis::{RelationGraph, RelationKind, SymbolRegistry};

// === Check (Borrow/Lock analysis) ===
pub use ryo_analysis::query::{BorrowTrackerV2, LockTrackerV2};
pub use ryo_analysis::{LockGranularityAnalyzerV2, LockStatsV2};

// === Cascade Analysis ===
pub use ryo_analysis::CascadeAnalyzer;

// === Summary (AI-readable output) ===
pub use ryo_analysis::{SummaryOptions, ToSummary};

// PureFile for project loading
pub use ryo_source::PureFile;

// Storage types (from ryo-storage)
pub use ryo_storage::{Format, TxLogMode};

// === Suggest (Enhanced suggestions) ===
pub use ryo_suggest::{
    ApplyCommands, ChoiceId, DesignChoice, DesignChoiceSet, EnhancedSuggestion, Rating,
    SafetyLevel, SuggestCategory, SuggestId, SuggestLocation, SuggestOpportunity, TradeOffs,
    VerificationStatus, VerifiedCandidate,
};