Forge
csharp3407750f
1using AgentForge.Data;
2using AgentForge.Data.Entities;
3using AgentForge.Models;
4using AgentForge.Plugin.Sdk;
5using AgentForge.Services;
6
7namespace AgentForge.Plugin.Org.Web.Services;
8
9internal sealed class ForgePersonalOrgService(ForgeRepository repository, GitRepoService git)
10{
11 internal ForgeOrgEntity EnsurePersonalOrg(ForgeIdentityEntity identity)
12 {
13 var slug = PersonalOrgSlug(identity.Login);
14 var org = repository.GetOrgBySlug(slug);
15 if (org is null)
16 {
17 org = repository.InsertOrg(
18 slug,
19 string.IsNullOrWhiteSpace(identity.DisplayName) ? identity.Login : identity.DisplayName,
20 "Personal catalog — agent-knowledge/canon and other private repos.",
21 RepoVisibility.Private);
22 }
23
24 if (!repository.IsOrgMember(org.Id, identity.Id))
25 repository.InsertOrgMember(org.Id, identity.Id, ForgeOrgRole.Admin);
26
27 new ForgePersonalCatalogBootstrap(repository, git).Ensure(org);
28 return org;
29 }
30
31 internal static string PersonalOrgSlug(string login) =>
32 "u-" + ForgeSlug.Normalize(login.Trim());
33}
34
View only · write via MCP/CIDE