@@ -18,6 +18,9 @@ const spec_improver = @import("spec_improver.zig");
1818// V10.3: Self-Feeding Loop + Rewards
1919const vibe_rewards = @import ("vibe_rewards.zig" );
2020
21+ // V10.5: Golden Seed Factory
22+ const synthetic_seed_gen = @import ("synthetic_seed_gen.zig" );
23+
2124pub fn main () ! void {
2225 const allocator = std .heap .page_allocator ;
2326
@@ -146,6 +149,37 @@ pub fn main() !void {
146149
147150 const dir = args [2 ];
148151 try importSeeds (allocator , dir );
152+ } else if (std .mem .eql (u8 , command , "generate-seeds" )) {
153+ // V10.5: Generate synthetic seeds
154+ var spec_files : []const []const u8 = &[_ ][]const u8 {};
155+ var min_quality : f32 = 0.6 ;
156+ var import_to_db : bool = false ;
157+
158+ // Parse flags
159+ var i : usize = 2 ;
160+ while (i < args .len ) : (i += 1 ) {
161+ if (std .mem .eql (u8 , args [i ], "--min-quality" ) and i + 1 < args .len ) {
162+ min_quality = std .fmt .parseFloat (f32 , args [i + 1 ]) catch 0.6 ;
163+ i += 1 ;
164+ } else if (std .mem .eql (u8 , args [i ], "--import" )) {
165+ import_to_db = true ;
166+ } else if (! std .mem .eql (u8 , args [i ][0.. 2], "--" )) {
167+ // Not a flag, treat as spec file
168+ const new_list = try allocator .alloc ([]const u8 , spec_files .len + 1 );
169+ @memcpy (new_list [0.. spec_files .len ], spec_files );
170+ new_list [spec_files .len ] = args [i ];
171+ if (spec_files .len > 0 ) allocator .free (spec_files );
172+ spec_files = new_list ;
173+ }
174+ }
175+
176+ if (spec_files .len == 0 ) {
177+ std .debug .print ("Error: No spec files provided\n " , .{});
178+ std .debug .print ("Usage: vibeec generate-seeds <spec.vibee...> [--min-quality F] [--import]\n " , .{});
179+ return ;
180+ }
181+
182+ try generateSyntheticSeeds (allocator , spec_files , min_quality , import_to_db );
149183 } else if (std .mem .eql (u8 , command , "show-rewards" )) {
150184 // V10.3: Show reward system info
151185 var agent_id : []const u8 = "vibee-v10.3" ;
@@ -167,7 +201,7 @@ fn printUsage() void {
167201 std .debug .print (
168202 \\
169203 \\═══════════════════════════════════════════════════════════════════════════════
170- \\ VIBEEC - VIBEE Compiler v10.3
204+ \\ VIBEEC - VIBEE Compiler v10.5
171205 \\ φ² + 1/φ² = 3
172206 \\═══════════════════════════════════════════════════════════════════════════════
173207 \\
@@ -177,6 +211,9 @@ fn printUsage() void {
177211 \\ --dry-run Show what would be filled without writing
178212 \\ --min-confidence F Minimum confidence threshold (default: 0.7)
179213 \\ vibeec import-seeds <dir> Import seeds from generated/*.zig files
214+ \\ vibeec generate-seeds <specs...> [options] V10.5: Generate synthetic seeds
215+ \\ --min-quality F Minimum quality threshold (default: 0.6)
216+ \\ --import Auto-import to Golden DB
180217 \\ vibeec show-rewards [--agent <id>] Show $TRI reward info (V10.3)
181218 \\ vibeec chat --model <path.gguf> [options] Chat with GGUF model (SIMD optimized)
182219 \\ --prompt "text" Initial prompt
@@ -447,3 +484,114 @@ fn showRewards(allocator: std.mem.Allocator, agent_id: []const u8) !void {
447484 std .debug .print (" Daily Earnings Cap: {d:.0} $TRI\n " , .{vibe_rewards .VibeRewardSystem .DAILY_CAP });
448485 std .debug .print ("\n " , .{});
449486}
487+
488+ /// V10.5: Generate synthetic seeds from spec files
489+ fn generateSyntheticSeeds (
490+ allocator : std.mem.Allocator ,
491+ spec_files : []const []const u8 ,
492+ min_quality : f32 ,
493+ import_to_db : bool ,
494+ ) ! void {
495+ std .debug .print ("╔════════════════════════════════════════════════════════════════╗\n " , .{});
496+ std .debug .print ("║ VIBEE v10.5: Synthetic Seed Generator ║\n " , .{});
497+ std .debug .print ("╚════════════════════════════════════════════════════════════════╝\n\n " , .{});
498+
499+ std .debug .print (" Spec files: {d}\n " , .{spec_files .len });
500+ std .debug .print (" Min quality: {d:.2}\n " , .{min_quality });
501+ std .debug .print (" Import to DB: {any}\n\n " , .{import_to_db });
502+
503+ // Initialize Golden DB
504+ var db = try golden_db .GoldenDB .init (allocator );
505+ defer db .deinit ();
506+
507+ // Initialize synthetic generator
508+ var generator = synthetic_seed_gen .SyntheticSeedGenerator .init (allocator , & db );
509+
510+ // Collect all behavior names from specs
511+ var behavior_names = std .ArrayList ([]const u8 ).initCapacity (allocator , 256 ) catch | err | {
512+ std .debug .print (" [Error] Cannot allocate behavior list: {}\n " , .{err });
513+ return err ;
514+ };
515+ defer behavior_names .deinit (allocator );
516+
517+ for (spec_files ) | spec_path | {
518+ std .debug .print (" Reading: {s}\n " , .{spec_path });
519+
520+ const file = std .fs .cwd ().openFile (spec_path , .{}) catch | err | {
521+ std .debug .print (" [Error] Cannot open: {}\n " , .{err });
522+ continue ;
523+ };
524+ defer file .close ();
525+
526+ const source = try file .readToEndAlloc (allocator , 1024 * 1024 );
527+ // Note: Don't free source - VibeeParser takes ownership
528+
529+ var parser = vibee_parser .VibeeParser .init (allocator , source );
530+ var spec = try parser .parse ();
531+ defer spec .deinit (); // This will free source_content
532+
533+ for (spec .behaviors .items ) | b | {
534+ const name_copy = try allocator .dupe (u8 , b .name );
535+ try behavior_names .append (allocator , name_copy );
536+ }
537+
538+ std .debug .print (" Found {d} behaviors\n " , .{spec .behaviors .items .len });
539+ }
540+
541+ std .debug .print ("\n Total behaviors: {d}\n " , .{behavior_names .items .len });
542+ std .debug .print (" Generating synthetic seeds...\n\n " , .{});
543+
544+ // Generate seeds
545+ var result = try generator .generateForBehaviors (behavior_names .items , min_quality );
546+ defer result .deinit (allocator );
547+
548+ // Report results
549+ std .debug .print (" Results:\n " , .{});
550+ std .debug .print (" Generated: {d} seeds\n " , .{result .generated .items .len });
551+ std .debug .print (" High quality (≥0.9): {d}\n " , .{result .high_quality_count });
552+ std .debug .print (" Avg quality: {d:.2}\n " , .{
553+ if (result .generated .items .len > 0 )
554+ result .total_quality / @as (f32 , @floatFromInt (result .generated .items .len ))
555+ else
556+ 0.0
557+ });
558+
559+ // Import to DB if requested
560+ if (import_to_db ) {
561+ std .debug .print ("\n Importing to Golden DB...\n " , .{});
562+ var imported : usize = 0 ;
563+ for (result .generated .items ) | seed | {
564+ if (seed .quality_score >= min_quality ) {
565+ db .addNewSeed (
566+ seed .name ,
567+ seed .signature ,
568+ seed .body ,
569+ seed .category ,
570+ ) catch | err | {
571+ std .debug .print (" [Error] Failed to add '{s}': {}\n " , .{seed .name , err });
572+ continue ;
573+ };
574+ imported += 1 ;
575+ }
576+ }
577+ std .debug .print (" Imported: {d} seeds\n " , .{imported });
578+ std .debug .print (" DB size: {d}\n " , .{db .implementations .items .len });
579+ }
580+
581+ // Show sample of generated seeds
582+ if (result .generated .items .len > 0 ) {
583+ std .debug .print ("\n Sample (first 3):\n " , .{});
584+ const sample_count = @min (3 , result .generated .items .len );
585+ for (result .generated .items [0.. sample_count ], 0.. ) | seed , i | {
586+ std .debug .print (" {d}. {s} (quality: {d:.2}, category: {s})\n " , .{
587+ i + 1 ,
588+ seed .name ,
589+ seed .quality_score ,
590+ @tagName (seed .category ),
591+ });
592+ }
593+ }
594+
595+ std .debug .print ("\n " , .{});
596+ }
597+ //
0 commit comments