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