Forge
csharpdeeb25a2
1#nullable enable
2
3using CascadeIDE.Contracts;
4
5namespace CascadeIDE.Cockpit.ComputingUnits.Launch;
6
7/// <summary>
8/// CCU formatter для ошибок MCP-запуска отладки: единый формат "# Error: ...".
9/// </summary>
10[ComputingUnit]
11public sealed class LaunchMcpErrorFormatUnit : ICockpitComputeUnit
12{
13 public static LaunchMcpErrorFormatUnit Default { get; } = new();
14
15 private LaunchMcpErrorFormatUnit()
16 {
17 }
18
19 public string FormatResolveFailure(
20 LaunchReadinessSnapshot readiness,
21 string? explicitProfileName,
22 string solutionDirectory)
23 {
24 if (!readiness.CanAttemptResolve)
25 {
26 return "# Error: " + (explicitProfileName is { Length: > 0 }
27 ? "profile_not_found: " + explicitProfileName
28 : "active_profile_missing");
29 }
30
31 if (!string.IsNullOrWhiteSpace(explicitProfileName) && !string.IsNullOrWhiteSpace(readiness.ProfileProjectRelative))
32 {
33 var candidate = CanonicalFilePath.Normalize(Path.Combine(solutionDirectory, readiness.ProfileProjectRelative));
34 return "# Error: project_not_found: " + candidate;
35 }
36
37 return "# Error: active_profile_missing";
38 }
39}
40
View only · write via MCP/CIDE