1pub mod audit;
24pub mod code_graph;
25pub mod concurrent;
26pub mod dependency_validation;
27pub mod execution_lifecycle;
28pub mod execution_proof;
29pub mod executor;
30pub mod incremental_cache;
31#[allow(dead_code)]
32pub mod lifecycle_hooks;
33pub mod marketplace_integration;
34pub mod merge;
35pub mod pipeline;
36pub mod proof_archive;
37pub mod swarm_execution;
38pub mod swarm_executor_bridge;
39pub mod typescript;
40pub mod watch;
41pub mod watch_cache_integration;
42pub mod watch_mode;
43
44pub use audit::{AuditOutput, AuditStep, AuditTrail, AuditTrailBuilder};
46pub use code_graph::{
47 CodeEnum, CodeField, CodeGraphBuilder, CodeImpl, CodeImport, CodeItem, CodeMethod, CodeModule,
48 CodeParam, CodeStruct, CodeTrait, CodeVariant,
49};
50pub use concurrent::ConcurrentRuleExecutor;
51pub use dependency_validation::{DependencyCheck, DependencyValidationReport, DependencyValidator};
52pub use execution_lifecycle::{ExecutionLifecycle, PostSyncContext, PreSyncContext};
53pub use execution_proof::{ExecutionProof, ProofCarrier, RuleExecution};
54pub use executor::{SyncExecutor, SyncResult, SyncedFileInfo, ValidationCheck};
55pub use incremental_cache::{CacheInvalidation, IncrementalCache};
56pub use marketplace_integration::{MarketplaceValidator, PackageValidation, PreFlightReport};
57pub use merge::{merge_sections, parse_merge_markers, MergeMarkers, MergedSections};
58pub use pipeline::{
59 ExecutedRule, GeneratedFile, GenerationPipeline, PipelineState, RuleType, ValidationResult,
60 ValidationSeverity,
61};
62pub use proof_archive::{ChainVerification, ProofArchive};
63pub use swarm_execution::{Agent, SwarmCoordinator, SwarmSummary};
64pub use swarm_executor_bridge::{ExecutionStrategy, SwarmExecutorBridge};
65pub use typescript::TypeScriptGenerator;
66pub use watch::{collect_watch_paths, FileWatcher, WatchEvent};
67pub use watch_cache_integration::{AffectedRulesAnalysis, WatchCacheIntegration};
68pub use watch_mode::{WatchConfig, WatchMode};
69
70#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
76pub enum OutputFormat {
77 #[default]
79 Text,
80 Json,
82}
83
84impl std::str::FromStr for OutputFormat {
85 type Err = String;
86
87 fn from_str(s: &str) -> Result<Self, Self::Err> {
88 match s.to_lowercase().as_str() {
89 "text" => Ok(OutputFormat::Text),
90 "json" => Ok(OutputFormat::Json),
91 _ => Err(format!(
92 "Invalid output format: '{}'. Expected 'text' or 'json'",
93 s
94 )),
95 }
96 }
97}
98
99impl std::fmt::Display for OutputFormat {
100 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
101 match self {
102 OutputFormat::Text => write!(f, "text"),
103 OutputFormat::Json => write!(f, "json"),
104 }
105 }
106}
107
108#[derive(Debug, Clone)]
113pub struct SyncOptions {
114 pub manifest_path: std::path::PathBuf,
116
117 pub output_dir: Option<std::path::PathBuf>,
119
120 pub dry_run: bool,
122
123 pub force: bool,
125
126 pub audit: bool,
128
129 pub selected_rules: Option<Vec<String>>,
131
132 pub verbose: bool,
134
135 pub watch: bool,
137
138 pub validate_only: bool,
140
141 pub output_format: OutputFormat,
143
144 pub timeout_ms: u64,
146
147 pub use_cache: bool,
149
150 pub cache_dir: Option<std::path::PathBuf>,
152
153 pub max_parallelism: Option<usize>,
155}
156
157impl Default for SyncOptions {
158 fn default() -> Self {
159 Self {
160 manifest_path: std::path::PathBuf::from("ggen.toml"),
161 output_dir: None,
162 dry_run: false,
163 force: false,
164 audit: false,
165 selected_rules: None,
166 verbose: false,
167 watch: false,
168 validate_only: false,
169 output_format: OutputFormat::default(),
170 timeout_ms: 30000, use_cache: true, cache_dir: None,
173 max_parallelism: None, }
175 }
176}
177
178impl SyncOptions {
179 pub fn new() -> Self {
181 Self::default()
182 }
183
184 pub fn from_manifest<P: AsRef<std::path::Path>>(path: P) -> Self {
186 Self {
187 manifest_path: path.as_ref().to_path_buf(),
188 ..Self::default()
189 }
190 }
191
192 pub fn with_dry_run(mut self, dry_run: bool) -> Self {
194 self.dry_run = dry_run;
195 self
196 }
197
198 pub fn with_verbose(mut self, verbose: bool) -> Self {
200 self.verbose = verbose;
201 self
202 }
203
204 pub fn with_audit(mut self, audit: bool) -> Self {
206 self.audit = audit;
207 self
208 }
209
210 pub fn with_validate_only(mut self, validate_only: bool) -> Self {
212 self.validate_only = validate_only;
213 self
214 }
215
216 pub fn with_output_format(mut self, format: OutputFormat) -> Self {
218 self.output_format = format;
219 self
220 }
221
222 pub fn with_timeout_ms(mut self, timeout_ms: u64) -> Self {
224 self.timeout_ms = timeout_ms;
225 self
226 }
227
228 pub fn with_rules(mut self, rules: Vec<String>) -> Self {
230 self.selected_rules = Some(rules);
231 self
232 }
233
234 pub fn with_force(mut self, force: bool) -> Self {
236 self.force = force;
237 self
238 }
239
240 pub fn with_output_dir<P: AsRef<std::path::Path>>(mut self, dir: P) -> Self {
242 self.output_dir = Some(dir.as_ref().to_path_buf());
243 self
244 }
245
246 pub fn with_cache(mut self, use_cache: bool) -> Self {
248 self.use_cache = use_cache;
249 self
250 }
251
252 pub fn with_cache_dir<P: AsRef<std::path::Path>>(mut self, dir: P) -> Self {
254 self.cache_dir = Some(dir.as_ref().to_path_buf());
255 self
256 }
257
258 pub fn with_max_parallelism(mut self, max_parallelism: usize) -> Self {
260 self.max_parallelism = Some(max_parallelism);
261 self
262 }
263}