-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtri_utils.zig
More file actions
2127 lines (1913 loc) · 112 KB
/
tri_utils.zig
File metadata and controls
2127 lines (1913 loc) · 112 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ═══════════════════════════════════════════════════════════════════════════════
// TRI CLI - Utility Functions
// ═══════════════════════════════════════════════════════════════════════════════
//
// Banner, help, info, version, REPL, parseCommand, and input processing.
// Extracted from main.zig for faster compilation.
//
// phi^2 + 1/phi^2 = 3 = TRINITY | KOSCHEI IS IMMORTAL
// ═══════════════════════════════════════════════════════════════════════════════
const std = @import("std");
const colors = @import("tri_colors.zig");
const trinity_swe = @import("trinity_swe");
const igla_hybrid_chat = @import("igla_hybrid_chat");
const igla_coder = @import("igla_coder");
const tvc = @import("tvc_corpus");
const streaming = @import("streaming.zig");
const multilingual = @import("multilingual.zig");
const tri_context = @import("tri_context.zig");
const sacred_formula = @import("math/formula.zig");
// Sacred Intelligence is enabled by default
const SACRED_INTELLIGENCE_DEFAULT = true;
const GREEN = colors.GREEN;
const GOLDEN = colors.GOLDEN;
const WHITE = colors.WHITE;
const GRAY = colors.GRAY;
const RED = colors.RED;
const CYAN = colors.CYAN;
const RESET = colors.RESET;
const VERSION = colors.VERSION;
pub const Command = enum {
none, // Interactive REPL
chat,
code,
gen,
fix,
explain,
test_cmd,
doc,
refactor,
reason,
convert,
serve,
bench,
evolve,
// Git commands
commit,
diff,
status,
log,
// Golden Chain Pipeline
pipeline,
decompose,
plan,
verify,
verdict,
// Test REPL (Cycle 101)
test_repl,
// Spec & Loop (v8.27)
spec_create,
loop_decide,
// TVC (Distributed Learning)
tvc_demo,
tvc_stats,
// Multi-Agent System
agents_demo,
agents_bench,
// Long Context
context_demo,
context_bench,
// RAG (Retrieval-Augmented Generation)
rag_demo,
rag_bench,
// Voice I/O (TTS + STT)
voice_demo,
voice_bench,
// Code Execution Sandbox
sandbox_demo,
sandbox_bench,
// Streaming Output
stream_demo,
stream_bench,
// Local Vision
vision_demo,
vision_bench,
// Fine-Tuning Engine
finetune_demo,
finetune_bench,
// Batched Stealing
batched_demo,
batched_bench,
// Priority Queue
priority_demo,
priority_bench,
// Deadline Scheduling
deadline_demo,
deadline_bench,
// Multi-Modal Unified (Cycle 26)
multimodal_demo,
multimodal_bench,
// Multi-Modal Tool Use (Cycle 27)
tooluse_demo,
tooluse_bench,
// Unified Multi-Modal Agent (Cycle 30)
unified_demo,
unified_bench,
// Autonomous Agent (Cycle 31)
autonomous_demo,
autonomous_bench,
// Multi-Agent Orchestration (Cycle 32)
orchestration_demo,
orchestration_bench,
// MM Multi-Agent Orchestration (Cycle 33)
mm_orch_demo,
mm_orch_bench,
// Agent Memory & Cross-Modal Learning (Cycle 34)
memory_demo,
memory_bench,
// Persistent Memory & Disk Serialization (Cycle 35)
persist_demo,
persist_bench,
// Dynamic Agent Spawning & Load Balancing (Cycle 36)
spawn_demo,
spawn_bench,
// Distributed Multi-Node Agents (Cycle 37)
cluster_demo,
cluster_bench,
// Adaptive Work-Stealing Scheduler (Cycle 39)
worksteal_demo,
worksteal_bench,
// Plugin & Extension System (Cycle 40)
plugin_demo,
plugin_bench,
// Agent Communication Protocol (Cycle 41)
comms_demo,
comms_bench,
// Observability & Tracing System (Cycle 42)
observe_demo,
observe_bench,
// Consensus & Coordination Protocol (Cycle 43)
consensus_demo,
consensus_bench,
// Speculative Execution Engine (Cycle 44)
specexec_demo,
specexec_bench,
// Adaptive Resource Governor (Cycle 45)
governor_demo,
governor_bench,
// Federated Learning Protocol (Cycle 46)
fedlearn_demo,
fedlearn_bench,
// Event Sourcing & CQRS Engine (Cycle 47)
eventsrc_demo,
eventsrc_bench,
// Capability-Based Security Model (Cycle 48)
capsec_demo,
capsec_bench,
// Distributed Transaction Coordinator (Cycle 49)
dtxn_demo,
dtxn_bench,
// Adaptive Caching & Memoization (Cycle 50)
cache_demo,
cache_bench,
// Contract-Based Agent Negotiation (Cycle 51)
contract_demo,
contract_bench,
// Temporal Workflow Engine (Cycle 52)
workflow_demo,
workflow_bench,
// Distributed Inference
distributed,
// Multi-Cluster (Cycle #97)
multi_cluster,
// Sacred Mathematics (v3.6)
math,
constants_cmd,
phi,
fib,
lucas,
spiral,
gematria,
formula_cmd,
sacred,
// Biology (v14.0)
bio,
// Cosmology (v15.0)
cosmos,
// Neuroscience (v16.0)
neuro,
// Chemistry (v6.0)
chem,
// Intelligence System
intelligence,
// Dev Utilities
doctor,
clean,
fmt_cmd,
stats_cmd,
igla,
// Cycle 98: Sacred Intelligence
identity,
swarm,
mu,
govern,
dashboard,
omega,
math_agent,
// Code Analysis
analyze,
search_cmd,
deps,
// Codebase Context (Cycle 92)
context_info,
// Temporal Engine v1.2 (Order #030)
time,
install,
build_cmd,
// Temporal Engine v1.3 (Order #031)
deck_generate,
fpga_demo,
fpga,
train,
// Cloud deployment (Railway integration)
cloud,
sacred_const,
sacred_full_cycle,
// Quantum Trinity v1.4 (Order #032)
quantum,
release_cosmic,
// Omega Phase v2.0 (Order #033)
omega_cmd,
all_cmd,
holo_cmd,
release_absolute,
omega_evolve,
// TRINITY OS v1.0 (Order #034)
launch,
// P0.3: Job Runtime (Async Long-Running Commands)
job_start,
job_status,
job_logs,
job_artifacts,
job_cancel,
job_list,
// Info
info,
version,
help,
// NEEDLE - Structural Editor Core
needle,
needle_search,
needle_check,
// P1.6: CLI Tools
commands,
mcp,
// Spec Linter (Issue #68)
lint,
// Spec Enricher (Issue #69)
enrich,
// Spec ↔ Code Sync Checker (Issue #71)
sync_check,
// GitHub Integration (Protocol v2)
github,
// Zenodo DOI Publishing
zenodo,
// Faculty Board (A2A Dashboard)
faculty,
research,
};
pub const CLIState = struct {
allocator: std.mem.Allocator,
agent: trinity_swe.TrinitySWEAgent,
chat_agent: igla_hybrid_chat.IglaHybridChat,
coder: igla_coder.IglaLocalCoder,
mode: trinity_swe.SWETaskType,
language: trinity_swe.Language,
verbose: bool,
running: bool,
stream_enabled: bool,
// UX Flags (v1.1)
dry_run: bool = false,
yes: bool = false,
output_format: OutputFormat = .text,
// TVC Corpus for self-learning (heap-allocated, ~26MB)
tvc_corpus: ?*tvc.TVCCorpus,
// Codebase Context Manager (Cycle 92)
context_mgr: ?*tri_context.ContextManager,
const Self = @This();
/// Output format for command results
pub const OutputFormat = enum {
text,
json,
yaml,
};
/// Default model path for auto-detection
const DEFAULT_MODEL_PATH = "models/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf";
/// Default TVC corpus save path
const TVC_CORPUS_PATH = "trinity_chat.tvc";
pub fn init(allocator: std.mem.Allocator) !Self {
// Auto-detect model path
const model_path: ?[]const u8 = blk: {
std.fs.cwd().access(DEFAULT_MODEL_PATH, .{}) catch break :blk null;
break :blk DEFAULT_MODEL_PATH;
};
// Heap-allocate TVC corpus for self-learning (~26MB, must be on heap)
const corpus = try allocator.create(tvc.TVCCorpus);
corpus.initInPlace();
// Try loading existing corpus from disk (load into heap-allocated struct)
corpus.loadInto(TVC_CORPUS_PATH) catch |err| {
std.log.debug("corpus load: {s}", .{@errorName(err)});
};
// Codebase Context Manager (Cycle 92)
const ctx_mgr = try allocator.create(tri_context.ContextManager);
ctx_mgr.* = tri_context.ContextManager.init(allocator);
ctx_mgr.loadIndex() catch |err| {
std.log.debug("context index load: {s}", .{@errorName(err)});
};
// Read API keys from environment
const groq_key = std.process.getEnvVarOwned(allocator, "GROQ_API_KEY") catch null;
const claude_key = std.process.getEnvVarOwned(allocator, "ANTHROPIC_API_KEY") catch null;
const openai_key = std.process.getEnvVarOwned(allocator, "OPENAI_API_KEY") catch null;
// Build hybrid config with TVC + multi-provider + multi-modal (v2.1)
const config = igla_hybrid_chat.HybridConfig{
.tvc_corpus_path = TVC_CORPUS_PATH,
.groq_api_key = groq_key,
.claude_api_key = claude_key,
.openai_api_key = openai_key,
};
// Initialize hybrid chat with TVC corpus
var chat = try igla_hybrid_chat.IglaHybridChat.initWithConfig(allocator, model_path, config);
chat.corpus = corpus;
return Self{
.allocator = allocator,
.agent = try trinity_swe.TrinitySWEAgent.init(allocator),
.chat_agent = chat,
.coder = igla_coder.IglaLocalCoder.init(allocator),
.mode = .Explain,
.language = .Zig,
.verbose = true,
.running = true,
.stream_enabled = false,
.tvc_corpus = corpus,
.context_mgr = ctx_mgr,
};
}
pub fn deinit(self: *Self) void {
// Save context index before exit (Cycle 92)
if (self.context_mgr) |mgr| {
if (mgr.is_dirty) {
mgr.saveIndex() catch |err| {
std.log.debug("context index save: {s}", .{@errorName(err)});
};
}
mgr.deinit();
self.allocator.destroy(mgr);
self.context_mgr = null;
}
// Save TVC corpus to disk before exit
if (self.tvc_corpus) |corpus| {
corpus.save(TVC_CORPUS_PATH) catch |err| {
std.log.debug("corpus save: {s}", .{@errorName(err)});
};
self.allocator.destroy(corpus);
self.tvc_corpus = null;
}
// Free API key strings (allocated by getEnvVarOwned)
if (self.chat_agent.config.groq_api_key) |key| {
self.allocator.free(key);
}
if (self.chat_agent.config.claude_api_key) |key| {
self.allocator.free(key);
}
if (self.chat_agent.config.openai_api_key) |key| {
self.allocator.free(key);
}
self.chat_agent.deinit();
self.agent.deinit();
}
};
pub fn printBanner() void {
std.debug.print("\n", .{});
std.debug.print("{s}TRINITY v{s}{s}\n", .{ GOLDEN, VERSION, RESET });
std.debug.print("100% Local AI | Code | Chat | SWE Agent\n", .{});
std.debug.print("\n", .{});
}
pub fn printHelp() void {
std.debug.print("\n{s}TRI CLI - Trinity Unified Command Line{s}\n", .{ GOLDEN, RESET });
std.debug.print("{s}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{s}\n\n", .{ GRAY, RESET });
std.debug.print("{s}USAGE:{s}\n", .{ CYAN, RESET });
std.debug.print(" tri Interactive REPL (default)\n", .{});
std.debug.print(" tri <command> [args.] Run specific command\n\n", .{});
std.debug.print("{s}COMMANDS:{s}\n", .{ CYAN, RESET });
std.debug.print(" {s}chat{s} [--stream] [--image <path>] [--voice <path>] <msg>\n", .{ GREEN, RESET });
std.debug.print(" Interactive chat (v2.1: vision + voice + tools)\n", .{});
std.debug.print(" {s}code{s} [--stream] <prompt> Generate code (--stream for typing effect)\n", .{ GREEN, RESET });
std.debug.print(" {s}gen{s} <spec.tri> Compile VIBEE spec to Zig/Verilog\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}SWE AGENT:{s}\n", .{ CYAN, RESET });
std.debug.print(" {s}fix{s} <file> Detect and fix bugs\n", .{ GREEN, RESET });
std.debug.print(" {s}explain{s} <file|prompt> Explain code or concept\n", .{ GREEN, RESET });
std.debug.print(" {s}test{s} <file> Generate tests\n", .{ GREEN, RESET });
std.debug.print(" {s}doc{s} <file> Generate documentation\n", .{ GREEN, RESET });
std.debug.print(" {s}refactor{s} <file> Suggest refactoring\n", .{ GREEN, RESET });
std.debug.print(" {s}reason{s} <prompt> Chain-of-thought reasoning\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}TOOLS:{s}\n", .{ CYAN, RESET });
std.debug.print(" {s}gen{s} <spec.tri> VIBEE → Zig/Verilog compiler\n", .{ GREEN, RESET });
std.debug.print(" {s}convert{s} <file> Convert WASM/Binary → Ternary\n", .{ GREEN, RESET });
std.debug.print(" {s}serve{s} --model <path> Start HTTP API server\n", .{ GREEN, RESET });
std.debug.print(" {s}bench{s} Run performance benchmarks\n", .{ GREEN, RESET });
std.debug.print(" {s}evolve{s} [--dim N] Evolve fingerprint (Firebird)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}GIT:{s}\n", .{ CYAN, RESET });
std.debug.print(" {s}status{s} Git status --short\n", .{ GREEN, RESET });
std.debug.print(" {s}diff{s} Git diff\n", .{ GREEN, RESET });
std.debug.print(" {s}log{s} Git log --oneline -10\n", .{ GREEN, RESET });
std.debug.print(" {s}commit{s} <message> Git add -A && commit\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}GOLDEN CHAIN:{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}pipeline run{s} <task> Execute 17-link development cycle (incl TVC)\n", .{ GREEN, RESET });
std.debug.print(" {s}pipeline status{s} Show pipeline state\n", .{ GREEN, RESET });
std.debug.print(" {s}decompose{s} <task> Break task into sub-tasks\n", .{ GREEN, RESET });
std.debug.print(" {s}verify{s} Run tests + benchmarks (Links 7-11)\n", .{ GREEN, RESET });
std.debug.print(" {s}verdict{s} Generate toxic verdict (Link 14)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}TVC (DISTRIBUTED):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}tvc-demo{s} Run TVC chat demo (distributed learning)\n", .{ GREEN, RESET });
std.debug.print(" {s}tvc-stats{s} Show TVC corpus statistics\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}MULTI-AGENT:{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}agents-demo{s} Run multi-agent coordination demo\n", .{ GREEN, RESET });
std.debug.print(" {s}agents-bench{s} Run multi-agent benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}LONG CONTEXT:{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}context-demo{s} Run long context demo (sliding window)\n", .{ GREEN, RESET });
std.debug.print(" {s}context-bench{s} Run context benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}RAG (RETRIEVAL):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}rag-demo{s} Run RAG demo (local retrieval)\n", .{ GREEN, RESET });
std.debug.print(" {s}rag-bench{s} Run RAG benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}VOICE I/O MULTI-MODAL (Cycle 29):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}voice-demo{s} Run voice I/O multi-modal demo (STT+TTS+cross-modal)\n", .{ GREEN, RESET });
std.debug.print(" {s}voice-bench{s} Run voice I/O benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}CODE SANDBOX:{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}sandbox-demo{s} Run code sandbox demo (safe execution)\n", .{ GREEN, RESET });
std.debug.print(" {s}sandbox-bench{s} Run sandbox benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}STREAMING MULTI-MODAL PIPELINE (Cycle 38):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}stream-demo, pipeline{s} Run streaming multi-modal pipeline demo\n", .{ GREEN, RESET });
std.debug.print(" {s}stream-bench{s} Run streaming pipeline benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}VISION UNDERSTANDING (Cycle 28):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}vision-demo{s} Run vision understanding demo (image analysis)\n", .{ GREEN, RESET });
std.debug.print(" {s}vision-bench{s} Run vision understanding benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}FINE-TUNING:{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}finetune-demo{s} Run fine-tuning demo (custom model adaptation)\n", .{ GREEN, RESET });
std.debug.print(" {s}finetune-bench{s} Run fine-tuning benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}MULTI-MODAL UNIFIED (Cycle 26):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}multimodal-demo{s} Run multi-modal unified demo (text+vision+voice+code)\n", .{ GREEN, RESET });
std.debug.print(" {s}multimodal-bench{s} Run multi-modal benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}MULTI-MODAL TOOL USE (Cycle 27):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}tooluse-demo{s} Run tool use demo (file/code/system from any modality)\n", .{ GREEN, RESET });
std.debug.print(" {s}tooluse-bench{s} Run tool use benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}UNIFIED MULTI-MODAL AGENT (Cycle 30):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}unified-demo{s} Run unified agent demo (text+vision+voice+code+tools)\n", .{ GREEN, RESET });
std.debug.print(" {s}unified-bench{s} Run unified agent benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}AUTONOMOUS AGENT (Cycle 31):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}auto-demo{s} Run autonomous agent demo (self-directed task execution)\n", .{ GREEN, RESET });
std.debug.print(" {s}auto-bench{s} Run autonomous agent benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}MULTI-AGENT ORCHESTRATION (Cycle 32):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}orch-demo{s} Run multi-agent orchestration demo (coordinator+specialists)\n", .{ GREEN, RESET });
std.debug.print(" {s}orch-bench{s} Run multi-agent orchestration benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}MM MULTI-AGENT ORCHESTRATION (Cycle 33):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}mmo-demo{s} Run multi-modal multi-agent demo (all modalities+agents)\n", .{ GREEN, RESET });
std.debug.print(" {s}mmo-bench{s} Run multi-modal multi-agent benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}AGENT MEMORY & CROSS-MODAL LEARNING (Cycle 34):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}memory-demo{s} Run agent memory & learning demo\n", .{ GREEN, RESET });
std.debug.print(" {s}memory-bench{s} Run agent memory benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}PERSISTENT MEMORY & DISK SERIALIZATION (Cycle 35):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}persist-demo{s} Run persistent memory demo (save/load TRMM)\n", .{ GREEN, RESET });
std.debug.print(" {s}persist-bench{s} Run persistent memory benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}DYNAMIC AGENT SPAWNING & LOAD BALANCING (Cycle 36):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}spawn-demo{s} Run dynamic agent spawning demo\n", .{ GREEN, RESET });
std.debug.print(" {s}spawn-bench{s} Run dynamic spawning benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}DISTRIBUTED MULTI-NODE AGENTS (Cycle 37):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}cluster-demo{s} Run distributed multi-node agents demo\n", .{ GREEN, RESET });
std.debug.print(" {s}cluster-bench{s} Run distributed agents benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}ADAPTIVE WORK-STEALING SCHEDULER (Cycle 39):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}worksteal-demo, steal{s} Run adaptive work-stealing scheduler demo\n", .{ GREEN, RESET });
std.debug.print(" {s}worksteal-bench{s} Run work-stealing benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}PLUGIN & EXTENSION SYSTEM (Cycle 40):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}plugin-demo, plugin, ext{s} Run plugin & extension system demo\n", .{ GREEN, RESET });
std.debug.print(" {s}plugin-bench{s} Run plugin system benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}AGENT COMMUNICATION PROTOCOL (Cycle 41):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}comms-demo, comms, msg{s} Run agent communication protocol demo\n", .{ GREEN, RESET });
std.debug.print(" {s}comms-bench{s} Run communication benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}OBSERVABILITY & TRACING SYSTEM (Cycle 42):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}observe-demo, observe, otel{s} Run observability & tracing demo\n", .{ GREEN, RESET });
std.debug.print(" {s}observe-bench{s} Run observability benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}CONSENSUS & COORDINATION PROTOCOL (Cycle 43):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}consensus-demo, consensus, raft{s} Run consensus & coordination demo\n", .{ GREEN, RESET });
std.debug.print(" {s}consensus-bench{s} Run consensus benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}SPECULATIVE EXECUTION ENGINE (Cycle 44):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}specexec-demo, specexec, spec{s} Run speculative execution demo\n", .{ GREEN, RESET });
std.debug.print(" {s}specexec-bench{s} Run speculative execution benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}ADAPTIVE RESOURCE GOVERNOR (Cycle 45):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}governor-demo, governor, gov{s} Run adaptive resource governor demo\n", .{ GREEN, RESET });
std.debug.print(" {s}governor-bench{s} Run resource governor benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}FEDERATED LEARNING PROTOCOL (Cycle 46):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}fedlearn-demo, fedlearn, fl{s} Run federated learning demo\n", .{ GREEN, RESET });
std.debug.print(" {s}fedlearn-bench{s} Run federated learning benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}EVENT SOURCING & CQRS ENGINE (Cycle 47):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}eventsrc-demo, eventsrc, es{s} Run event sourcing & CQRS demo\n", .{ GREEN, RESET });
std.debug.print(" {s}eventsrc-bench{s} Run event sourcing benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}CAPABILITY-BASED SECURITY MODEL (Cycle 48):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}capsec-demo, capsec, sec{s} Run capability security demo\n", .{ GREEN, RESET });
std.debug.print(" {s}capsec-bench{s} Run capability security benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}DISTRIBUTED TRANSACTION COORDINATOR (Cycle 49):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}dtxn-demo, dtxn, txn{s} Run distributed transaction demo\n", .{ GREEN, RESET });
std.debug.print(" {s}dtxn-bench{s} Run distributed transaction benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}ADAPTIVE CACHING & MEMOIZATION (Cycle 50):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}cache-demo, cache, memo{s} Run adaptive caching demo\n", .{ GREEN, RESET });
std.debug.print(" {s}cache-bench{s} Run adaptive caching benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}CONTRACT-BASED AGENT NEGOTIATION (Cycle 51):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}contract-demo, contract, sla{s} Run contract negotiation demo\n", .{ GREEN, RESET });
std.debug.print(" {s}contract-bench{s} Run contract negotiation benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}TEMPORAL WORKFLOW ENGINE (Cycle 52):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}workflow-demo, workflow, wf{s} Run temporal workflow demo\n", .{ GREEN, RESET });
std.debug.print(" {s}workflow-bench{s} Run temporal workflow benchmark (Needle check)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}SACRED MATHEMATICS (v3.6):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}math{s} Sacred math dispatcher\n", .{ GREEN, RESET });
std.debug.print(" {s}constants{s} Show all sacred constants\n", .{ GREEN, RESET });
std.debug.print(" {s}phi{s} <n> Compute phi^n\n", .{ GREEN, RESET });
std.debug.print(" {s}fib{s} <n> Fibonacci F(n) with BigInt\n", .{ GREEN, RESET });
std.debug.print(" {s}lucas{s} <n> Lucas L(n)\n", .{ GREEN, RESET });
std.debug.print(" {s}spiral{s} <n> phi-spiral coordinates\n", .{ GREEN, RESET });
std.debug.print(" {s}gematria{s} <number|text> Coptic gematria + sacred formula\n", .{ GREEN, RESET });
std.debug.print(" {s}formula{s} <value> Sacred formula decomposition\n", .{ GREEN, RESET });
std.debug.print(" {s}sacred{s} 32 constants + 9 predictions table\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}SACRED BIOLOGY (v14.0):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}bio{s} dna <sequence> DNA analysis with sacred mathematics\n", .{ GREEN, RESET });
std.debug.print(" {s}bio{s} rna <sequence> RNA analysis with sacred mathematics\n", .{ GREEN, RESET });
std.debug.print(" {s}bio{s} protein <sequence> Protein analysis (1-letter codes)\n", .{ GREEN, RESET });
std.debug.print(" {s}bio{s} phi-genome Sacred genome patterns\n", .{ GREEN, RESET });
std.debug.print(" {s}bio{s} codon <codon> Codon → amino acid lookup\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}SACRED COSMOLOGY (v15.0):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}cosmos{s} hubble Resolve Hubble tension via Sacred Formula\n", .{ GREEN, RESET });
std.debug.print(" {s}cosmos{s} dark Dark energy/matter as φ-patterns\n", .{ GREEN, RESET });
std.debug.print(" {s}cosmos{s} predict Predict new constants and stability islands\n", .{ GREEN, RESET });
std.debug.print(" {s}cosmos{s} expand Universe expansion timeline\n", .{ GREEN, RESET });
std.debug.print(" {s}cosmos{s} big-bang Big Bang through sacred lens\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}SACRED NEUROSCIENCE (v16.0):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}neuro{s} waves [freq] Brain waves (φ-patterned frequencies)\n", .{ GREEN, RESET });
std.debug.print(" {s}neuro{s} consciousness [C t E] Compute consciousness level Ψ\n", .{ GREEN, RESET });
std.debug.print(" {s}neuro{s} regions Sacred brain regions (φ-index)\n", .{ GREEN, RESET });
std.debug.print(" {s}neuro{s} network [layers...] Analyze neural network sacredness\n", .{ GREEN, RESET });
std.debug.print(" {s}neuro{s} synapse Synaptic transmission timing\n", .{ GREEN, RESET });
std.debug.print(" {s}neuro{s} neurons Brain statistics & sacred constants\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}SACRED INTELLIGENCE:{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}intelligence{s} [<symbol>.] Sacred formula + gematria analysis\n", .{ GREEN, RESET });
std.debug.print(" {s}intel{s} [<symbol>.] Alias for intelligence\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}SACRED AGENTS (Cycle 98):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}identity{s} Show Sacred Intelligence identity\n", .{ GREEN, RESET });
std.debug.print(" {s}swarm{s} Multi-agent Sacred Swarm status\n", .{ GREEN, RESET });
std.debug.print(" {s}govern{s} Sacred Governance rules (φ-Rules)\n", .{ GREEN, RESET });
std.debug.print(" {s}dashboard{s} [--stream] 3-column Sacred Dashboard (RAZUM/MATERIYA/DUKH)\n", .{ GREEN, RESET });
std.debug.print(" {s}omega{s} [status|validate] Master coordinator - all agents\n", .{ GREEN, RESET });
std.debug.print(" {s}math-agent{s} [phi|fib|...] Sacred Math Agent - self-aware\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}AUTONOMOUS EVOLUTION (Cycle 97):{s}\n", .{ GOLDEN, RESET });
std.debug.print(" {s}auto-commit{s} [--dry-run] [--approve] [--max N]\n", .{ GREEN, RESET });
std.debug.print(" Autonomous sacred patch commits (φ-guided)\n", .{});
std.debug.print(" {s}ml-optimize{s} <file> ML-based patch optimization\n", .{ GREEN, RESET });
std.debug.print(" {s}deploy-dashboard{s} [--target] Deploy production dashboard\n", .{ GREEN, RESET });
std.debug.print(" {s}self-host{s} Self-hosting loop (IMPROVE YOURSELF!)\n", .{ GREEN, RESET });
std.debug.print(" {s}safeguards{s} show Show safeguard status\n", .{ GREEN, RESET });
std.debug.print(" {s}safeguards-disable{s} <feature> Disable a safeguard\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}DEV UTILITIES:{s}\n", .{ CYAN, RESET });
std.debug.print(" {s}doctor{s} Project health check (build, test, zig version)\n", .{ GREEN, RESET });
std.debug.print(" {s}clean{s} Clean build artifacts (.zig-cache, zig-out)\n", .{ GREEN, RESET });
std.debug.print(" {s}fmt{s} Format Zig source (zig fmt src/)\n", .{ GREEN, RESET });
std.debug.print(" {s}stats{s} Project statistics (files, LOC, specs, tests)\n", .{ GREEN, RESET });
std.debug.print(" {s}igla{s} IGLA initiative status (parser coverage)\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}INFO:{s}\n", .{ CYAN, RESET });
std.debug.print(" {s}info{s} System information\n", .{ GREEN, RESET });
std.debug.print(" {s}version{s} Show version\n", .{ GREEN, RESET });
std.debug.print(" {s}help{s} This help message\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}TESTING (Cycle 100):{s}\n", .{ CYAN, RESET });
std.debug.print(" {s}test --repl{s} Run REPL test suite\n", .{ GREEN, RESET });
std.debug.print(" {s}test -r{s} Short form\n", .{ GREEN, RESET });
std.debug.print("\n", .{});
std.debug.print("{s}REPL COMMANDS:{s} (in interactive mode)\n", .{ CYAN, RESET });
std.debug.print(" /chat /code /fix /explain /test /doc /reason\n", .{});
std.debug.print(" /zig /python /rust /js Set language\n", .{});
std.debug.print(" /stats /verbose /help /quit\n", .{});
std.debug.print("\n", .{});
std.debug.print("{s}MULTILINGUAL:{s}\n", .{ GOLDEN, RESET });
std.debug.print(" Auto-detects: Russian, Chinese, English\n", .{});
std.debug.print(" Examples:\n", .{});
std.debug.print(" tri code \"optimize fibonacci function\" [RU]\n", .{});
std.debug.print(" tri code \"写一个斐波那契函数\" [ZH]\n", .{});
std.debug.print(" tri code \"write fibonacci function\" \n", .{});
std.debug.print("\n{s}phi^2 + 1/phi^2 = 3 = TRINITY{s}\n\n", .{ GOLDEN, RESET });
}
pub fn printVersion() void {
std.debug.print("{s}TRI CLI{s} v{s}\n", .{ GREEN, RESET, VERSION });
std.debug.print("Trinity Unified Command Line Interface\n", .{});
std.debug.print("phi^2 + 1/phi^2 = 3 = TRINITY\n", .{});
}
pub fn printInfo() void {
std.debug.print("\n{s}═══ System Information ═══{s}\n", .{ GOLDEN, RESET });
std.debug.print(" TRI CLI Version: {s}\n", .{VERSION});
std.debug.print(" Platform: {s}\n", .{@tagName(@import("builtin").os.tag)});
std.debug.print(" Architecture: {s}\n", .{@tagName(@import("builtin").cpu.arch)});
std.debug.print(" Mode: 100%% LOCAL\n", .{});
std.debug.print(" Vocabulary: 50000 words\n", .{});
std.debug.print(" Code Templates: 50+\n", .{});
std.debug.print(" Chat Patterns: 60+\n", .{});
std.debug.print("\n{s}phi^2 + 1/phi^2 = 3 = TRINITY{s}\n\n", .{ GOLDEN, RESET });
}
pub fn parseCommand(arg: []const u8) Command {
if (std.mem.eql(u8, arg, "chat")) return .chat;
if (std.mem.eql(u8, arg, "code")) return .code;
if (std.mem.eql(u8, arg, "gen")) return .gen;
if (std.mem.eql(u8, arg, "fix")) return .fix;
if (std.mem.eql(u8, arg, "explain")) return .explain;
if (std.mem.eql(u8, arg, "test")) return .test_cmd;
if (std.mem.eql(u8, arg, "doc")) return .doc;
if (std.mem.eql(u8, arg, "refactor")) return .refactor;
if (std.mem.eql(u8, arg, "reason")) return .reason;
if (std.mem.eql(u8, arg, "convert")) return .convert;
if (std.mem.eql(u8, arg, "serve")) return .serve;
if (std.mem.eql(u8, arg, "bench")) return .bench;
if (std.mem.eql(u8, arg, "evolve")) return .evolve;
// Git commands
if (std.mem.eql(u8, arg, "commit")) return .commit;
if (std.mem.eql(u8, arg, "diff")) return .diff;
if (std.mem.eql(u8, arg, "status")) return .status;
if (std.mem.eql(u8, arg, "log")) return .log;
// Golden Chain Pipeline
if (std.mem.eql(u8, arg, "pipeline") or std.mem.eql(u8, arg, "chain")) return .pipeline;
if (std.mem.eql(u8, arg, "decompose")) return .decompose;
if (std.mem.eql(u8, arg, "plan")) return .plan;
if (std.mem.eql(u8, arg, "verify")) return .verify;
if (std.mem.eql(u8, arg, "verdict")) return .verdict;
// Test REPL (Cycle 101)
if (std.mem.eql(u8, arg, "test-repl") or std.mem.eql(u8, arg, "test_repl")) return .test_repl;
// Spec & Loop (v8.27)
if (std.mem.eql(u8, arg, "spec-create") or std.mem.eql(u8, arg, "spec_create")) return .spec_create;
if (std.mem.eql(u8, arg, "loop-decide") or std.mem.eql(u8, arg, "loop_decide")) return .loop_decide;
// TVC (Distributed Learning)
if (std.mem.eql(u8, arg, "tvc-demo") or std.mem.eql(u8, arg, "tvc")) return .tvc_demo;
if (std.mem.eql(u8, arg, "tvc-stats")) return .tvc_stats;
// Multi-Agent System
if (std.mem.eql(u8, arg, "agents-demo") or std.mem.eql(u8, arg, "agents")) return .agents_demo;
if (std.mem.eql(u8, arg, "agents-bench")) return .agents_bench;
// Long Context
if (std.mem.eql(u8, arg, "context-demo")) return .context_demo;
if (std.mem.eql(u8, arg, "context-bench")) return .context_bench;
// RAG
if (std.mem.eql(u8, arg, "rag-demo") or std.mem.eql(u8, arg, "rag")) return .rag_demo;
if (std.mem.eql(u8, arg, "rag-bench")) return .rag_bench;
// Voice I/O
if (std.mem.eql(u8, arg, "voice-demo") or std.mem.eql(u8, arg, "voice") or std.mem.eql(u8, arg, "mic")) return .voice_demo;
if (std.mem.eql(u8, arg, "voice-bench") or std.mem.eql(u8, arg, "mic-bench")) return .voice_bench;
// Code Sandbox
if (std.mem.eql(u8, arg, "sandbox-demo") or std.mem.eql(u8, arg, "sandbox")) return .sandbox_demo;
if (std.mem.eql(u8, arg, "sandbox-bench")) return .sandbox_bench;
// Streaming Multi-Modal Pipeline (Cycle 38)
if (std.mem.eql(u8, arg, "stream-demo") or std.mem.eql(u8, arg, "stream") or std.mem.eql(u8, arg, "pipeline")) return .stream_demo;
if (std.mem.eql(u8, arg, "stream-bench") or std.mem.eql(u8, arg, "pipeline-bench")) return .stream_bench;
// Local Vision
if (std.mem.eql(u8, arg, "vision-demo") or std.mem.eql(u8, arg, "vision") or std.mem.eql(u8, arg, "eye")) return .vision_demo;
if (std.mem.eql(u8, arg, "vision-bench") or std.mem.eql(u8, arg, "eye-bench")) return .vision_bench;
// Fine-Tuning Engine
if (std.mem.eql(u8, arg, "finetune-demo") or std.mem.eql(u8, arg, "finetune")) return .finetune_demo;
if (std.mem.eql(u8, arg, "finetune-bench")) return .finetune_bench;
// Batched Stealing
if (std.mem.eql(u8, arg, "batched-demo") or std.mem.eql(u8, arg, "batched")) return .batched_demo;
if (std.mem.eql(u8, arg, "batched-bench")) return .batched_bench;
// Priority Queue
if (std.mem.eql(u8, arg, "priority-demo") or std.mem.eql(u8, arg, "priority")) return .priority_demo;
if (std.mem.eql(u8, arg, "priority-bench")) return .priority_bench;
// Deadline Scheduling
if (std.mem.eql(u8, arg, "deadline-demo") or std.mem.eql(u8, arg, "deadline")) return .deadline_demo;
if (std.mem.eql(u8, arg, "deadline-bench")) return .deadline_bench;
// Multi-Modal Unified (Cycle 26)
if (std.mem.eql(u8, arg, "multimodal-demo") or std.mem.eql(u8, arg, "multimodal") or std.mem.eql(u8, arg, "mm")) return .multimodal_demo;
if (std.mem.eql(u8, arg, "multimodal-bench") or std.mem.eql(u8, arg, "mm-bench")) return .multimodal_bench;
// Multi-Modal Tool Use (Cycle 27)
if (std.mem.eql(u8, arg, "tooluse-demo") or std.mem.eql(u8, arg, "tooluse") or std.mem.eql(u8, arg, "tools")) return .tooluse_demo;
if (std.mem.eql(u8, arg, "tooluse-bench") or std.mem.eql(u8, arg, "tools-bench")) return .tooluse_bench;
// Unified Multi-Modal Agent (Cycle 30)
if (std.mem.eql(u8, arg, "unified-demo") or std.mem.eql(u8, arg, "unified") or std.mem.eql(u8, arg, "agent")) return .unified_demo;
if (std.mem.eql(u8, arg, "unified-bench") or std.mem.eql(u8, arg, "agent-bench")) return .unified_bench;
// Autonomous Agent (Cycle 31)
if (std.mem.eql(u8, arg, "auto-demo") or std.mem.eql(u8, arg, "auto") or std.mem.eql(u8, arg, "autonomous")) return .autonomous_demo;
if (std.mem.eql(u8, arg, "auto-bench") or std.mem.eql(u8, arg, "autonomous-bench")) return .autonomous_bench;
// Multi-Agent Orchestration (Cycle 32)
if (std.mem.eql(u8, arg, "orch-demo") or std.mem.eql(u8, arg, "orch") or std.mem.eql(u8, arg, "orchestrate")) return .orchestration_demo;
if (std.mem.eql(u8, arg, "orch-bench") or std.mem.eql(u8, arg, "orchestrate-bench")) return .orchestration_bench;
// MM Multi-Agent Orchestration (Cycle 33)
if (std.mem.eql(u8, arg, "mmo-demo") or std.mem.eql(u8, arg, "mmo") or std.mem.eql(u8, arg, "mm-orch")) return .mm_orch_demo;
if (std.mem.eql(u8, arg, "mmo-bench") or std.mem.eql(u8, arg, "mm-orch-bench")) return .mm_orch_bench;
// Agent Memory & Cross-Modal Learning (Cycle 34)
if (std.mem.eql(u8, arg, "memory-demo") or std.mem.eql(u8, arg, "memory") or std.mem.eql(u8, arg, "mem")) return .memory_demo;
if (std.mem.eql(u8, arg, "memory-bench") or std.mem.eql(u8, arg, "mem-bench")) return .memory_bench;
// Persistent Memory & Disk Serialization (Cycle 35)
if (std.mem.eql(u8, arg, "persist-demo") or std.mem.eql(u8, arg, "persist") or std.mem.eql(u8, arg, "save")) return .persist_demo;
if (std.mem.eql(u8, arg, "persist-bench") or std.mem.eql(u8, arg, "persist-bench") or std.mem.eql(u8, arg, "save-bench")) return .persist_bench;
// Dynamic Agent Spawning & Load Balancing (Cycle 36)
if (std.mem.eql(u8, arg, "spawn-demo") or std.mem.eql(u8, arg, "spawn") or std.mem.eql(u8, arg, "pool")) return .spawn_demo;
if (std.mem.eql(u8, arg, "spawn-bench") or std.mem.eql(u8, arg, "pool-bench")) return .spawn_bench;
// Distributed Multi-Node Agents (Cycle 37)
if (std.mem.eql(u8, arg, "cluster-demo") or std.mem.eql(u8, arg, "cluster") or std.mem.eql(u8, arg, "nodes")) return .cluster_demo;
if (std.mem.eql(u8, arg, "cluster-bench") or std.mem.eql(u8, arg, "nodes-bench")) return .cluster_bench;
// Adaptive Work-Stealing Scheduler (Cycle 39)
if (std.mem.eql(u8, arg, "worksteal-demo") or std.mem.eql(u8, arg, "worksteal") or std.mem.eql(u8, arg, "steal")) return .worksteal_demo;
if (std.mem.eql(u8, arg, "worksteal-bench") or std.mem.eql(u8, arg, "steal-bench")) return .worksteal_bench;
// Plugin & Extension System (Cycle 40)
if (std.mem.eql(u8, arg, "plugin-demo") or std.mem.eql(u8, arg, "plugin") or std.mem.eql(u8, arg, "ext")) return .plugin_demo;
if (std.mem.eql(u8, arg, "plugin-bench") or std.mem.eql(u8, arg, "ext-bench")) return .plugin_bench;
// Agent Communication Protocol (Cycle 41)
if (std.mem.eql(u8, arg, "comms-demo") or std.mem.eql(u8, arg, "comms") or std.mem.eql(u8, arg, "msg")) return .comms_demo;
if (std.mem.eql(u8, arg, "comms-bench") or std.mem.eql(u8, arg, "msg-bench")) return .comms_bench;
// Observability & Tracing System (Cycle 42)
if (std.mem.eql(u8, arg, "observe-demo") or std.mem.eql(u8, arg, "observe") or std.mem.eql(u8, arg, "otel")) return .observe_demo;
if (std.mem.eql(u8, arg, "observe-bench") or std.mem.eql(u8, arg, "otel-bench")) return .observe_bench;
// Consensus & Coordination Protocol (Cycle 43)
if (std.mem.eql(u8, arg, "consensus-demo") or std.mem.eql(u8, arg, "consensus") or std.mem.eql(u8, arg, "raft")) return .consensus_demo;
if (std.mem.eql(u8, arg, "consensus-bench") or std.mem.eql(u8, arg, "raft-bench")) return .consensus_bench;
// Speculative Execution Engine (Cycle 44)
if (std.mem.eql(u8, arg, "specexec-demo") or std.mem.eql(u8, arg, "specexec") or std.mem.eql(u8, arg, "spec")) return .specexec_demo;
if (std.mem.eql(u8, arg, "specexec-bench") or std.mem.eql(u8, arg, "spec-bench")) return .specexec_bench;
// Adaptive Resource Governor (Cycle 45)
if (std.mem.eql(u8, arg, "governor-demo") or std.mem.eql(u8, arg, "governor") or std.mem.eql(u8, arg, "gov")) return .governor_demo;
if (std.mem.eql(u8, arg, "governor-bench") or std.mem.eql(u8, arg, "gov-bench")) return .governor_bench;
// Federated Learning Protocol (Cycle 46)
if (std.mem.eql(u8, arg, "fedlearn-demo") or std.mem.eql(u8, arg, "fedlearn") or std.mem.eql(u8, arg, "fl")) return .fedlearn_demo;
if (std.mem.eql(u8, arg, "fedlearn-bench") or std.mem.eql(u8, arg, "fl-bench")) return .fedlearn_bench;
// Event Sourcing & CQRS Engine (Cycle 47)
if (std.mem.eql(u8, arg, "eventsrc-demo") or std.mem.eql(u8, arg, "eventsrc") or std.mem.eql(u8, arg, "es")) return .eventsrc_demo;
if (std.mem.eql(u8, arg, "eventsrc-bench") or std.mem.eql(u8, arg, "es-bench")) return .eventsrc_bench;
// Capability-Based Security Model (Cycle 48)
if (std.mem.eql(u8, arg, "capsec-demo") or std.mem.eql(u8, arg, "capsec") or std.mem.eql(u8, arg, "sec")) return .capsec_demo;
if (std.mem.eql(u8, arg, "capsec-bench") or std.mem.eql(u8, arg, "sec-bench")) return .capsec_bench;
// Distributed Transaction Coordinator (Cycle 49)
if (std.mem.eql(u8, arg, "dtxn-demo") or std.mem.eql(u8, arg, "dtxn") or std.mem.eql(u8, arg, "txn")) return .dtxn_demo;
if (std.mem.eql(u8, arg, "dtxn-bench") or std.mem.eql(u8, arg, "txn-bench")) return .dtxn_bench;
// Adaptive Caching & Memoization (Cycle 50)
if (std.mem.eql(u8, arg, "cache-demo") or std.mem.eql(u8, arg, "cache") or std.mem.eql(u8, arg, "memo")) return .cache_demo;
if (std.mem.eql(u8, arg, "cache-bench") or std.mem.eql(u8, arg, "memo-bench")) return .cache_bench;
// Contract-Based Agent Negotiation (Cycle 51)
if (std.mem.eql(u8, arg, "contract-demo") or std.mem.eql(u8, arg, "contract") or std.mem.eql(u8, arg, "sla")) return .contract_demo;
if (std.mem.eql(u8, arg, "contract-bench") or std.mem.eql(u8, arg, "sla-bench")) return .contract_bench;
// Temporal Workflow Engine (Cycle 52)
if (std.mem.eql(u8, arg, "workflow-demo") or std.mem.eql(u8, arg, "workflow") or std.mem.eql(u8, arg, "wf")) return .workflow_demo;
if (std.mem.eql(u8, arg, "workflow-bench") or std.mem.eql(u8, arg, "wf-bench")) return .workflow_bench;
if (std.mem.eql(u8, arg, "distributed") or std.mem.eql(u8, arg, "dist")) return .distributed;
// Multi-Cluster (Cycle #97)
if (std.mem.eql(u8, arg, "multi-cluster") or std.mem.eql(u8, arg, "mc")) return .multi_cluster;
// Sacred Mathematics (v3.6)
if (std.mem.eql(u8, arg, "math")) return .math;
if (std.mem.eql(u8, arg, "constants")) return .constants_cmd;
if (std.mem.eql(u8, arg, "phi")) return .phi;
if (std.mem.eql(u8, arg, "fib")) return .fib;
if (std.mem.eql(u8, arg, "lucas")) return .lucas;
if (std.mem.eql(u8, arg, "spiral")) return .spiral;
if (std.mem.eql(u8, arg, "gematria") or std.mem.eql(u8, arg, "gem")) return .gematria;
if (std.mem.eql(u8, arg, "formula")) return .formula_cmd;
if (std.mem.eql(u8, arg, "sacred")) return .sacred;
// Biology (v14.0)
if (std.mem.eql(u8, arg, "bio") or std.mem.eql(u8, arg, "biology")) return .bio;
// Cosmology (v15.0)
if (std.mem.eql(u8, arg, "cosmos") or std.mem.eql(u8, arg, "cosmology")) return .cosmos;
// Neuroscience (v16.0)
if (std.mem.eql(u8, arg, "neuro") or std.mem.eql(u8, arg, "neuroscience")) return .neuro;
// Chemistry (v6.0)
if (std.mem.eql(u8, arg, "chem") or std.mem.eql(u8, arg, "chemistry")) return .chem;
// Intelligence System
if (std.mem.eql(u8, arg, "intelligence") or std.mem.eql(u8, arg, "intel")) return .intelligence;
// Dev Utilities
if (std.mem.eql(u8, arg, "doctor") or std.mem.eql(u8, arg, "dr")) return .doctor;
if (std.mem.eql(u8, arg, "clean")) return .clean;
if (std.mem.eql(u8, arg, "fmt") or std.mem.eql(u8, arg, "format")) return .fmt_cmd;
if (std.mem.eql(u8, arg, "stats")) return .stats_cmd;
if (std.mem.eql(u8, arg, "igla")) return .igla;
// Cycle 98: Sacred Intelligence
if (std.mem.eql(u8, arg, "identity")) return .identity;
if (std.mem.eql(u8, arg, "swarm")) return .swarm;
if (std.mem.eql(u8, arg, "mu")) return .mu;
if (std.mem.eql(u8, arg, "govern")) return .govern;
if (std.mem.eql(u8, arg, "dashboard") or std.mem.eql(u8, arg, "dash")) return .dashboard;
if (std.mem.eql(u8, arg, "omega")) return .omega;
if (std.mem.eql(u8, arg, "math-agent") or std.mem.eql(u8, arg, "mathagent")) return .math_agent;
// Code Analysis & Context (Cycle 92)
if (std.mem.eql(u8, arg, "analyze") or std.mem.eql(u8, arg, "scan")) return .analyze;
if (std.mem.eql(u8, arg, "search")) return .search_cmd;
if (std.mem.eql(u8, arg, "context") or std.mem.eql(u8, arg, "ctx")) return .context_info;
// Sacred Intelligence (Cycle 94)
if (std.mem.eql(u8, arg, "intelligence")) return .intelligence;
// Temporal Engine v1.2 (Order #030)
if (std.mem.eql(u8, arg, "time") or std.mem.eql(u8, arg, "temporal")) return .time;
if (std.mem.eql(u8, arg, "install") or std.mem.eql(u8, arg, "self-update")) return .install;
if (std.mem.eql(u8, arg, "build")) return .build_cmd;
// Temporal Engine v1.3 (Order #031)
if (std.mem.eql(u8, arg, "deck") or std.mem.eql(u8, arg, "deck-generate")) return .deck_generate;
if (std.mem.eql(u8, arg, "fpga")) return .fpga;
if (std.mem.eql(u8, arg, "train")) return .train;
if (std.mem.eql(u8, arg, "cloud")) return .cloud;
if (std.mem.eql(u8, arg, "fpga-demo")) return .fpga_demo;
if (std.mem.eql(u8, arg, "sacred-const") or std.mem.eql(u8, arg, "sacred_const") or std.mem.eql(u8, arg, "sacred-constants")) return .sacred_const;
if (std.mem.eql(u8, arg, "full-cycle") or std.mem.eql(u8, arg, "sacred-full-cycle")) return .sacred_full_cycle;
// Quantum Trinity v1.4 (Order #032)
if (std.mem.eql(u8, arg, "quantum")) return .quantum;
if (std.mem.eql(u8, arg, "release-cosmic")) return .release_cosmic;
// Omega Phase v2.0 (Order #033)
if (std.mem.eql(u8, arg, "omega") or std.mem.eql(u8, arg, "omega-phase")) return .omega_cmd;
if (std.mem.eql(u8, arg, "all")) return .all_cmd;
if (std.mem.eql(u8, arg, "holo") or std.mem.eql(u8, arg, "holographic")) return .holo_cmd;
if (std.mem.eql(u8, arg, "release") or std.mem.eql(u8, arg, "release-absolute")) return .release_absolute;
if (std.mem.eql(u8, arg, "omega-evolve") or std.mem.eql(u8, arg, "evolve-omega")) return .omega_evolve;
// TRINITY OS v1.0 (Order #034)
if (std.mem.eql(u8, arg, "launch")) return .launch;
// Info
if (std.mem.eql(u8, arg, "info")) return .info;
if (std.mem.eql(u8, arg, "version") or std.mem.eql(u8, arg, "--version") or std.mem.eql(u8, arg, "-v")) return .version;
if (std.mem.eql(u8, arg, "help") or std.mem.eql(u8, arg, "--help") or std.mem.eql(u8, arg, "-h")) return .help;
// NEEDLE - Structural Editor Core
if (std.mem.eql(u8, arg, "needle") or std.mem.eql(u8, arg, "nedl")) return .needle;
if (std.mem.eql(u8, arg, "needle-search") or std.mem.eql(u8, arg, "needle-search") or std.mem.eql(u8, arg, "ns")) return .needle_search;
if (std.mem.eql(u8, arg, "needle-check") or std.mem.eql(u8, arg, "nc")) return .needle_check;
// P0.3: Job Runtime commands
if (std.mem.eql(u8, arg, "job")) return .job_start; // Default to start
if (std.mem.eql(u8, arg, "job-start")) return .job_start;
if (std.mem.eql(u8, arg, "job-status")) return .job_status;
if (std.mem.eql(u8, arg, "job-logs")) return .job_logs;
if (std.mem.eql(u8, arg, "job-artifacts")) return .job_artifacts;
if (std.mem.eql(u8, arg, "job-cancel")) return .job_cancel;
if (std.mem.eql(u8, arg, "job-list")) return .job_list;
// P1.6: CLI Tools
if (std.mem.eql(u8, arg, "commands")) return .commands;
if (std.mem.eql(u8, arg, "mcp")) return .mcp;
// Spec Linter
if (std.mem.eql(u8, arg, "lint") or std.mem.eql(u8, arg, "validate")) return .lint;
// Spec Enricher (Issue #69)
if (std.mem.eql(u8, arg, "enrich") or std.mem.eql(u8, arg, "spec-enrich") or std.mem.eql(u8, arg, "spec_enrich")) return .enrich;
// Spec ↔ Code Sync Checker (Issue #71)
if (std.mem.eql(u8, arg, "sync-check") or std.mem.eql(u8, arg, "sync_check") or std.mem.eql(u8, arg, "synccheck")) return .sync_check;
// GitHub Integration (Protocol v2)
if (std.mem.eql(u8, arg, "issue")) return .github;
if (std.mem.eql(u8, arg, "board")) return .github;
if (std.mem.eql(u8, arg, "protocol")) return .github;
if (std.mem.eql(u8, arg, "github")) return .github;
if (std.mem.eql(u8, arg, "zenodo")) return .zenodo;
// Faculty Board (A2A Dashboard)
if (std.mem.eql(u8, arg, "faculty") or std.mem.eql(u8, arg, "a2a")) return .faculty;
if (std.mem.eql(u8, arg, "research")) return .research;
return .none;
}
pub fn printPrompt(state: *CLIState) void {
const mode_name = state.mode.getName();
const lang_ext = state.language.getExtension();
std.debug.print("{s}[{s}]{s} {s}[{s}]{s} > ", .{ GREEN, mode_name, RESET, GOLDEN, lang_ext, RESET });
}
pub fn processREPLCommand(state: *CLIState, cmd: []const u8) void {
if (std.mem.eql(u8, cmd, "/chat")) {
state.mode = .Chat;
std.debug.print("{s}Mode: Chat{s}\n", .{ GREEN, RESET });
} else if (std.mem.eql(u8, cmd, "/code")) {
state.mode = .CodeGen;
std.debug.print("{s}Mode: Code Generation{s}\n", .{ GREEN, RESET });
} else if (std.mem.eql(u8, cmd, "/fix")) {
state.mode = .BugFix;
std.debug.print("{s}Mode: Bug Fix{s}\n", .{ GREEN, RESET });
} else if (std.mem.eql(u8, cmd, "/explain")) {
state.mode = .Explain;
std.debug.print("{s}Mode: Explain{s}\n", .{ GREEN, RESET });
} else if (std.mem.eql(u8, cmd, "/test")) {
state.mode = .Test;
std.debug.print("{s}Mode: Test Generation{s}\n", .{ GREEN, RESET });
} else if (std.mem.eql(u8, cmd, "/doc")) {
state.mode = .Document;
std.debug.print("{s}Mode: Documentation{s}\n", .{ GREEN, RESET });
} else if (std.mem.eql(u8, cmd, "/refactor")) {
state.mode = .Refactor;
std.debug.print("{s}Mode: Refactor{s}\n", .{ GREEN, RESET });