Forge
csharp4405de34
1namespace CascadeIDE.Services.Intercom;
2
3/// <summary>Содержимое <c>.cascade-ide/intercom-team.toml</c> (ADR 0144 §2.1).</summary>
4public sealed class IntercomTeamManifest
5{
6 public IntercomTeamManifestSection Team { get; set; } = new();
7
8 public string TeamId => Team.TeamId;
9
10 public string DisplayName => string.IsNullOrWhiteSpace(Team.DisplayName) ? Team.TeamId : Team.DisplayName;
11}
12
13public sealed class IntercomTeamManifestSection
14{
15 public string TeamId { get; set; } = "";
16
17 public string DisplayName { get; set; } = "";
18}
19
20/// <summary>Поиск manifest от workspace root вверх к git root.</summary>
21public static class IntercomTeamManifestResolver
22{
23 public const string RelativeManifestPath = ".cascade-ide/intercom-team.toml";
24
25 public static IntercomTeamManifest? TryResolve(string? workspaceRoot)
26 {
27 if (string.IsNullOrWhiteSpace(workspaceRoot))
28 return null;
29
30 var dir = new DirectoryInfo(Path.GetFullPath(workspaceRoot));
31 while (dir is not null)
32 {
33 var path = Path.Combine(dir.FullName, RelativeManifestPath);
34 if (File.Exists(path))
35 return TryParseFile(path);
36
37 var git = Path.Combine(dir.FullName, ".git");
38 if (Directory.Exists(git) || File.Exists(git))
39 break;
40
41 dir = dir.Parent;
42 }
43
44 return null;
45 }
46
47 public static IntercomTeamManifest? TryParseFile(string path)
48 {
49 try
50 {
51 var toml = File.ReadAllText(path);
52 var manifest = CascadeTomlSerializer.Deserialize<IntercomTeamManifest>(toml);
53 if (manifest is null || string.IsNullOrWhiteSpace(manifest.TeamId))
54 return null;
55 return manifest;
56 }
57 catch
58 {
59 return null;
60 }
61 }
62}
63
View only · write via MCP/CIDE