ryo_app/lib.rs
1//! RYO App - Application layer
2//!
3//! This crate provides the application layer for RYO:
4//! - **Project**: In-memory collection of AST files with I/O
5//! - **Intent/Goal**: User intention representation
6//! - **Api**: External interface for CLI/UI/Agent
7//! - **Storage trait**: DI for persistent storage
8//!
9//! # Architecture
10//!
11//! ```text
12//! ┌───────────────────────────────────────────────────────────────────┐
13//! │ Layer 3: Application (ryo-app) │
14//! │ ┌───────────────────────────────────────────────────────────────┐│
15//! │ │ Api ││
16//! │ │ • executor: CoreExecutor (直接依存) ││
17//! │ │ • storage: Box<dyn Storage> (DI) ││
18//! │ └───────────────────────────────────────────────────────────────┘│
19//! │ ┌───────────────────────────────────────────────────────────────┐│
20//! │ │ Intent/Goal ││
21//! │ │ • User intention representation ││
22//! │ │ • JSON Schema for LLM integration ││
23//! │ └───────────────────────────────────────────────────────────────┘│
24//! │ ┌───────────────────────────────────────────────────────────────┐│
25//! │ │ Project ││
26//! │ │ • File collection + I/O ││
27//! │ └───────────────────────────────────────────────────────────────┘│
28//! └───────────────────────────────────────────────────────────────────┘
29//! ```
30//!
31//! # Usage
32//!
33//! ```ignore
34//! use ryo_app::{Api, Project, Goal, Intent, InMemoryStorage};
35//!
36//! // Load project
37//! let mut project = Project::from_dir("src/")?;
38//!
39//! // Create API with storage
40//! let storage = Box::new(InMemoryStorage::new());
41//! let mut api = Api::new(storage);
42//!
43//! // Execute a goal
44//! let goal = Goal::new(Intent::RenameIdent {
45//! from: Pattern::exact("old_name"),
46//! to: "new_name".to_string(),
47//! kind: IdentKind::Any,
48//! });
49//!
50//! let result = api.execute(&mut project, goal)?;
51//! ```
52
53pub mod api;
54pub mod codec;
55mod config;
56mod dataflow_v2;
57mod discover;
58mod graph;
59mod intent;
60#[cfg(feature = "fuzzy-parser")]
61mod intent_schema;
62mod planner;
63mod project;
64mod schema;
65pub mod service;
66mod spec;
67pub mod spec_dsl;
68mod storage;
69
70// === Project ===
71pub use project::{Project, ProjectError};
72
73// === Config ===
74pub use config::{
75 ConfigError, ImportConfig, ModuleConfig, MutationConfig, ProjectConfig, RyoConfig,
76};
77
78// === Api (Public Interface) ===
79pub use api::{
80 // Core API
81 Api,
82 ApiError,
83 ApiErrorKind,
84 ApiResult,
85 CascadeRequest,
86 CascadeResponse,
87 DesignChoiceInfo,
88 // Request/Response types (for tarpc transport)
89 DiscoverRequest,
90 DiscoverResponse,
91 ExecuteOptions,
92 ExecutionResult,
93 // Execution Status (HTTP-inspired result codes)
94 ExecutionStatus,
95 GraphSummaryRequest,
96 GraphSummaryResponse,
97 HookResult,
98 LiteralSearchRequest,
99 LiteralSearchResponse,
100 OverviewRequest,
101 OverviewResponse,
102 PostExecutionHook,
103 QueryResponse,
104 RunRequest,
105 RunResponse,
106 RyoqlRequest,
107 SortOrder as ApiSortOrder,
108 StatusCode,
109 StatusDetail,
110 StatusResponse,
111 SuggestApplyRequest,
112 SuggestApplyResponse,
113 SuggestChoicesRequest,
114 SuggestChoicesResponse,
115 SuggestCompareRequest,
116 SuggestCompareResponse,
117 SuggestGenerateRequest,
118 SuggestGenerateResponse,
119 SuggestRequest,
120 SuggestResponse,
121 SuggestVerifyRequest,
122 SuggestVerifyResponse,
123 Suggestion,
124 SuggestionSummary,
125 VerifyLevel,
126 // Re-export from ryo-query-language
127 ViewMode,
128};
129
130// === DataFlow Service V2 (String-free, VarId-based) ===
131pub use dataflow_v2::{
132 BorrowCheckResultV2, DataFlowErrorV2, DataFlowServiceV2, DataFlowStatsV2, FlowInfoV2,
133 LockAnalysisResultV2, VarInfoV2,
134};
135
136// === Discover Service ===
137pub use discover::{CascadeResult, DiscoverError, DiscoverService};
138
139// === Spec Service ===
140// Note: SpecRelation and SpecRelationKind are not re-exported here to avoid conflict with intent module.
141// Use ryo_app::spec::SpecRelation if needed.
142pub use spec::{
143 LintSeverity, SpecError, SpecFlowData, SpecGroupInfo, SpecInfo, SpecLintIssue, SpecLintResult,
144 SpecService, SpecShowResponse, SpecSourceKind, SpecStats,
145};
146// Re-export spec module for qualified access to SpecRelation
147pub mod spec_types {
148 pub use super::spec::{SpecRelation, SpecRelationKind};
149}
150
151// === Storage ===
152pub use storage::{InMemoryStorage, Storage};
153
154// === Intent/Goal ===
155pub use intent::{
156 ConflictStrategy, Constraint, EstimatedScope, ExtractError, Goal, IdentKind, Intent,
157 IntentExtractor, ScopeHint, SpecRelation, SpecRelationKind, StmtInsertPosition,
158 TransformExample, Visibility,
159};
160
161// === Planner ===
162pub use planner::{PlanError, PlanResult, Planner};
163
164// Re-export ItemKind from ryo-source (canonical definition)
165pub use ryo_source::ItemKind;
166
167// === Schema (feature-gated) ===
168#[cfg(feature = "schemars")]
169pub use schema::{generate_goal_schema, generate_goal_schema_json};
170
171// === Graph API ===
172pub use graph::{CodeNode, GraphApi, GraphError, GraphStats, NodeKind, SummaryBuilder};
173
174// === Re-exports for CLI (Layer 4 should only import from ryo-app) ===
175// Analysis context for mutation execution
176pub use ryo_analysis::AnalysisContext;
177
178// Executor types for blueprint execution
179pub use ryo_executor::{
180 BlueprintExecutor, BlueprintResult, Conflict, ConflictKind, MutationSpec, ParallelBlueprint,
181};
182
183// === Re-exports for CLI (from ryo-analysis) ===
184pub use ryo_analysis::query::{VarKind, VarNode};
185pub use ryo_analysis::{
186 CodeGraphV2, DataFlowBuilderWorkspace, DataFlowGraphV2, GraphBuilderV2, QueryBuilder,
187};
188pub use ryo_analysis::{
189 DiscoveredSymbol, DiscoveryEngine, DiscoveryQuery, DiscoveryResult, SortOrder,
190};
191pub use ryo_analysis::{RelationGraph, RelationKind, SymbolRegistry};
192
193// === Check (Borrow/Lock analysis) ===
194pub use ryo_analysis::query::{BorrowTrackerV2, LockTrackerV2};
195pub use ryo_analysis::{LockGranularityAnalyzerV2, LockStatsV2};
196
197// === Cascade Analysis ===
198pub use ryo_analysis::CascadeAnalyzer;
199
200// === Summary (AI-readable output) ===
201pub use ryo_analysis::{SummaryOptions, ToSummary};
202
203// PureFile for project loading
204pub use ryo_source::PureFile;
205
206// Storage types (from ryo-storage)
207pub use ryo_storage::{Format, TxLogMode};
208
209// === Suggest (Enhanced suggestions) ===
210pub use ryo_suggest::{
211 ApplyCommands, ChoiceId, DesignChoice, DesignChoiceSet, EnhancedSuggestion, Rating,
212 SafetyLevel, SuggestCategory, SuggestId, SuggestLocation, SuggestOpportunity, TradeOffs,
213 VerificationStatus, VerifiedCandidate,
214};