| | | 1 | | using Microsoft.Extensions.DependencyInjection; |
| | | 2 | | using Spectre.Console; |
| | | 3 | | using Spectre.Console.Cli; |
| | | 4 | | using Orchestrator.Commands.Operations.Matchday; |
| | | 5 | | using Orchestrator.Commands.Operations.Bonus; |
| | | 6 | | using Orchestrator.Commands.Operations.CollectContext; |
| | | 7 | | using Orchestrator.Commands.Operations.Verify; |
| | | 8 | | using Orchestrator.Commands.Observability.AnalyzeMatch; |
| | | 9 | | using Orchestrator.Commands.Observability.ContextChanges; |
| | | 10 | | using Orchestrator.Commands.Observability.Cost; |
| | | 11 | | using Orchestrator.Commands.Utility.UploadKpi; |
| | | 12 | | using Orchestrator.Commands.Utility.UploadTransfers; |
| | | 13 | | using Orchestrator.Commands.Utility.ListKpi; |
| | | 14 | | using Orchestrator.Commands.Utility.Snapshots; |
| | | 15 | | using Orchestrator.Infrastructure; |
| | | 16 | | |
| | | 17 | | namespace Orchestrator; |
| | | 18 | | |
| | | 19 | | public class Program |
| | | 20 | | { |
| | | 21 | | public static async Task<int> Main(string[] args) |
| | | 22 | | { |
| | | 23 | | // Load environment variables once at startup |
| | 0 | 24 | | var startupLogger = LoggingConfiguration.CreateLogger<Program>(); |
| | 0 | 25 | | EnvironmentHelper.LoadEnvironmentVariables(startupLogger); |
| | | 26 | | |
| | | 27 | | // Dependency Injection setup follows Spectre.Console.Cli patterns: |
| | | 28 | | // - Tutorial: https://github.com/spectreconsole/website/blob/main/Spectre.Docs/Content/cli/tutorials/dependency |
| | | 29 | | // - Testing: https://github.com/spectreconsole/website/blob/main/Spectre.Docs/Content/cli/how-to/testing-comman |
| | 0 | 30 | | var services = new ServiceCollection(); |
| | | 31 | | |
| | | 32 | | // Register IAnsiConsole for dependency injection into commands |
| | 0 | 33 | | services.AddSingleton<IAnsiConsole>(AnsiConsole.Console); |
| | | 34 | | |
| | | 35 | | // Register all command services (factories and shared infrastructure) |
| | 0 | 36 | | services.AddAllCommandServices(); |
| | | 37 | | |
| | 0 | 38 | | var registrar = new TypeRegistrar(services); |
| | 0 | 39 | | var app = new CommandApp(registrar); |
| | | 40 | | |
| | 0 | 41 | | app.Configure(config => |
| | 0 | 42 | | { |
| | 0 | 43 | | config.SetApplicationName("Orchestrator"); |
| | 0 | 44 | | config.SetApplicationVersion("1.0.0"); |
| | 0 | 45 | | |
| | 0 | 46 | | config.AddCommand<MatchdayCommand>("matchday") |
| | 0 | 47 | | .WithDescription("Generate predictions for the current matchday") |
| | 0 | 48 | | .WithExample("matchday", "gpt-4o-2024-08-06", "--community", "ehonda-test-buli"); |
| | 0 | 49 | | |
| | 0 | 50 | | config.AddBranch("analyze-match", analyzeMatch => |
| | 0 | 51 | | { |
| | 0 | 52 | | analyzeMatch.SetDescription("Analyze prediction distributions for a single match without persisting resu |
| | 0 | 53 | | |
| | 0 | 54 | | analyzeMatch.AddCommand<AnalyzeMatchDetailedCommand>("detailed") |
| | 0 | 55 | | .WithDescription("Detailed analysis with justification output and live estimates") |
| | 0 | 56 | | .WithExample( |
| | 0 | 57 | | "analyze-match", |
| | 0 | 58 | | "detailed", |
| | 0 | 59 | | "gpt-5-nano", |
| | 0 | 60 | | "--community-context", |
| | 0 | 61 | | "ehonda-test-buli", |
| | 0 | 62 | | "--home", |
| | 0 | 63 | | "FC Bayern München", |
| | 0 | 64 | | "--away", |
| | 0 | 65 | | "RB Leipzig", |
| | 0 | 66 | | "--matchday", |
| | 0 | 67 | | "1", |
| | 0 | 68 | | "--runs", |
| | 0 | 69 | | "5"); |
| | 0 | 70 | | |
| | 0 | 71 | | analyzeMatch.AddCommand<AnalyzeMatchComparisonCommand>("comparison") |
| | 0 | 72 | | .WithDescription("Compare predictions generated with and without justification") |
| | 0 | 73 | | .WithExample( |
| | 0 | 74 | | "analyze-match", |
| | 0 | 75 | | "comparison", |
| | 0 | 76 | | "gpt-5-nano", |
| | 0 | 77 | | "--community-context", |
| | 0 | 78 | | "ehonda-test-buli", |
| | 0 | 79 | | "--home", |
| | 0 | 80 | | "FC Bayern München", |
| | 0 | 81 | | "--away", |
| | 0 | 82 | | "RB Leipzig", |
| | 0 | 83 | | "--matchday", |
| | 0 | 84 | | "1", |
| | 0 | 85 | | "--runs", |
| | 0 | 86 | | "5"); |
| | 0 | 87 | | }); |
| | 0 | 88 | | |
| | 0 | 89 | | config.AddCommand<BonusCommand>("bonus") |
| | 0 | 90 | | .WithDescription("Generate bonus predictions") |
| | 0 | 91 | | .WithExample("bonus", "gpt-4o-2024-08-06", "--community", "ehonda-test-buli"); |
| | 0 | 92 | | |
| | 0 | 93 | | config.AddBranch<CollectContextSettings>("collect-context", collectContext => |
| | 0 | 94 | | { |
| | 0 | 95 | | collectContext.SetDescription("Collect context documents and store them in database"); |
| | 0 | 96 | | collectContext.AddCommand<CollectContextKicktippCommand>("kicktipp") |
| | 0 | 97 | | .WithDescription("Collect context from Kicktipp") |
| | 0 | 98 | | .WithExample("collect-context", "kicktipp", "--community", "ehonda-test-buli", "--community-context" |
| | 0 | 99 | | }); |
| | 0 | 100 | | |
| | 0 | 101 | | config.AddCommand<VerifyMatchdayCommand>("verify") |
| | 0 | 102 | | .WithDescription("Verify that database predictions have been successfully posted to Kicktipp") |
| | 0 | 103 | | .WithExample("verify", "--community", "ehonda-test-buli"); |
| | 0 | 104 | | |
| | 0 | 105 | | config.AddCommand<VerifyBonusCommand>("verify-bonus") |
| | 0 | 106 | | .WithDescription("Verify that database bonus predictions are valid and complete") |
| | 0 | 107 | | .WithExample("verify-bonus", "--community", "ehonda-test-buli"); |
| | 0 | 108 | | |
| | 0 | 109 | | config.AddCommand<UploadKpiCommand>("upload-kpi") |
| | 0 | 110 | | .WithDescription("Upload a KPI context document to Firebase") |
| | 0 | 111 | | .WithExample("upload-kpi", "team-data", "--community", "ehonda-test-buli"); |
| | 0 | 112 | | |
| | 0 | 113 | | config.AddCommand<UploadTransfersCommand>("upload-transfers") |
| | 0 | 114 | | .WithDescription("Upload a transfers context document to Firebase (team transfers CSV)") |
| | 0 | 115 | | .WithExample("upload-transfers", "fcb", "--community-context", "ehonda-test-buli"); |
| | 0 | 116 | | |
| | 0 | 117 | | config.AddCommand<ListKpiCommand>("list-kpi") |
| | 0 | 118 | | .WithDescription("List KPI context documents from Firebase") |
| | 0 | 119 | | .WithExample("list-kpi", "--community", "ehonda-test-buli"); |
| | 0 | 120 | | |
| | 0 | 121 | | config.AddCommand<ContextChangesCommand>("context-changes") |
| | 0 | 122 | | .WithDescription("Show changes between latest and previous versions of context documents") |
| | 0 | 123 | | .WithExample("context-changes", "--community-context", "ehonda-test-buli", "--count", "5") |
| | 0 | 124 | | .WithExample("context-changes", "--community-context", "ehonda-test-buli", "--seed", "42"); |
| | 0 | 125 | | |
| | 0 | 126 | | config.AddCommand<CostCommand>("cost") |
| | 0 | 127 | | .WithDescription("Calculate aggregate costs for predictions") |
| | 0 | 128 | | .WithExample("cost", "--all") |
| | 0 | 129 | | .WithExample("cost", "--matchdays", "1,2,3") |
| | 0 | 130 | | .WithExample("cost", "--models", "gpt-4o,o1-mini", "--bonus"); |
| | 0 | 131 | | |
| | 0 | 132 | | config.AddBranch("snapshots", snapshots => |
| | 0 | 133 | | { |
| | 0 | 134 | | snapshots.SetDescription("Generate and encrypt HTML snapshots from Kicktipp for test fixtures"); |
| | 0 | 135 | | |
| | 0 | 136 | | snapshots.AddCommand<SnapshotsFetchCommand>("fetch") |
| | 0 | 137 | | .WithDescription("Fetch HTML snapshots from Kicktipp") |
| | 0 | 138 | | .WithExample("snapshots", "fetch", "--community", "ehonda-test-buli") |
| | 0 | 139 | | .WithExample("snapshots", "fetch", "--community", "ehonda-test-buli", "--output", "my-snapshots"); |
| | 0 | 140 | | |
| | 0 | 141 | | snapshots.AddCommand<SnapshotsEncryptCommand>("encrypt") |
| | 0 | 142 | | .WithDescription("Encrypt HTML snapshots for safe committing") |
| | 0 | 143 | | .WithExample("snapshots", "encrypt") |
| | 0 | 144 | | .WithExample("snapshots", "encrypt", "--input", "my-snapshots", "--output", "tests/KicktippIntegrati |
| | 0 | 145 | | |
| | 0 | 146 | | snapshots.AddCommand<SnapshotsAllCommand>("all") |
| | 0 | 147 | | .WithDescription("Fetch and encrypt snapshots in one step") |
| | 0 | 148 | | .WithExample("snapshots", "all", "--community", "ehonda-test-buli") |
| | 0 | 149 | | .WithExample("snapshots", "all", "--community", "ehonda-test-buli", "--keep-originals"); |
| | 0 | 150 | | }); |
| | 0 | 151 | | }); |
| | | 152 | | |
| | 0 | 153 | | return await app.RunAsync(args); |
| | 0 | 154 | | } |
| | | 155 | | } |