| 1 | using AgentForge.Abstractions; |
| 2 | using AgentForge.Plugin.Ci.Data; |
| 3 | using AgentForge.Plugin.Ci.Execution; |
| 4 | using AgentForge.Plugin.Ci.Endpoints; |
| 5 | using AgentForge.Plugin.Ci.Pages; |
| 6 | using AgentForge.Plugin.View; |
| 7 | using Microsoft.Extensions.Configuration; |
| 8 | using Microsoft.Extensions.DependencyInjection; |
| 9 | |
| 10 | namespace AgentForge.Plugin.Ci; |
| 11 | |
| 12 | public sealed class CiForgePlugin : IForgePlugin |
| 13 | { |
| 14 | public string Id => "ci-visual"; |
| 15 | |
| 16 | public string DisplayName => "Forge Visual CI"; |
| 17 | |
| 18 | public void ConfigureServices(IServiceCollection services, IConfiguration configuration) |
| 19 | { |
| 20 | services.AddScoped<ForgeCiDefinitionStore>(); |
| 21 | services.AddScoped<ForgeCiRunStore>(); |
| 22 | services.AddSingleton<ForgeCiRunExecutor>(); |
| 23 | services.AddScoped<ForgeCiRunQueueService>(); |
| 24 | } |
| 25 | |
| 26 | public void MapEndpoints(WebApplication app) |
| 27 | { |
| 28 | var api = app.MapGroup("/api/v1"); |
| 29 | api.MapCiEndpoints(); |
| 30 | ForgeCiViewEndpoints.Map(app); |
| 31 | } |
| 32 | |
| 33 | public void RegisterFeatures(ForgeFeatureRegistry registry) => registry.Add("forge_ci"); |
| 34 | |
| 35 | public void RegisterMcpTools(ForgeMcpToolRegistry registry) => ForgeCiMcpTools.Register(registry); |
| 36 | |
| 37 | public void RegisterCommands(ForgeCommandRegistry registry) => ForgeCiCommandRegistration.Register(registry); |
| 38 | |
| 39 | public void RegisterViewContributors(ForgeViewContributorRegistry registry) |
| 40 | { |
| 41 | registry.Add(new ForgeViewContributor |
| 42 | { |
| 43 | TabId = "ci", |
| 44 | Label = "CI", |
| 45 | RoutePrefix = $"/view/repos/{{name}}/ci", |
| 46 | Order = 35, |
| 47 | PluginId = Id, |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | public void RegisterRepoTabBodies(ForgeRepoTabBodyRegistry registry) => |
| 52 | registry.Add("ci", ctx => ForgeCiRepoTabPage.RenderHome(ctx.RepoName, ctx.Services)); |
| 53 | |
| 54 | public void ApplyMigrations(IForgeMigrationContext context) => |
| 55 | ForgeCiSchemaBootstrap.Apply(context); |
| 56 | } |
| 57 | |