Forge
csharp3407750f
1using AgentForge.Data;
2using AgentForge.Data.Entities;
3using AgentForge.Models;
4using AgentForge.Services;
5
6namespace AgentForge.Plugin.Org.Web.Services;
7
8internal sealed class ForgePersonalCatalogBootstrap(ForgeRepository repository, GitRepoService git)
9{
10 internal void Ensure(ForgeOrgEntity personalOrg)
11 {
12 repository.EnsureRepoGroupPath(personalOrg.Id, ForgeAgentKnowledgeCatalog.PersonalCanonGroup);
13
14 var fullName = $"{personalOrg.Slug}/{ForgeAgentKnowledgeCatalog.PersonalCanonRepoSlug}";
15 if (repository.RepoNameExists(fullName))
16 return;
17
18 var groupId = repository.ResolveRepoGroupIdByPath(
19 personalOrg.Id,
20 ForgeAgentKnowledgeCatalog.PersonalCanonGroup);
21
22 git.CreateBareRepository(fullName);
23 try
24 {
25 repository.InsertRepo(
26 fullName,
27 "Personal knowledge canon (agent-notes contour).",
28 DriveMode.HumanDriven,
29 groupId,
30 personalOrg.Id,
31 RepoVisibility.Private);
32 }
33 catch
34 {
35 var path = git.GetBareRepoPath(fullName);
36 if (Directory.Exists(path))
37 Directory.Delete(path, recursive: true);
38 throw;
39 }
40 }
41}
42
View only · write via MCP/CIDE