| 1 | #nullable enable |
| 2 | |
| 3 | namespace CascadeIDE.Features.Chat; |
| 4 | |
| 5 | /// <summary>Канонические slash-пути и нормализация args (alias table).</summary> |
| 6 | internal static class SlashPathAliases |
| 7 | { |
| 8 | public const string AnchorPeekPath = "/anchor peek"; |
| 9 | |
| 10 | private const string IntercomAnchorPeekPath = "/intercom anchor peek"; |
| 11 | private const string IntercomAnchorPeekBody = "intercom anchor peek"; |
| 12 | private const string AnchorPeekBody = "anchor peek"; |
| 13 | |
| 14 | public static bool IsAnchorPeekPath(string canonicalPath) => |
| 15 | string.Equals(canonicalPath, AnchorPeekPath, StringComparison.OrdinalIgnoreCase) |
| 16 | || string.Equals(canonicalPath, IntercomAnchorPeekPath, StringComparison.OrdinalIgnoreCase); |
| 17 | |
| 18 | public static string? ExtractPeekArgs(string canonicalPath, string? argTail) |
| 19 | { |
| 20 | if (!IsAnchorPeekPath(canonicalPath)) |
| 21 | return null; |
| 22 | |
| 23 | return string.IsNullOrWhiteSpace(argTail) ? "" : argTail.Trim(); |
| 24 | } |
| 25 | |
| 26 | public static string NormalizeCompletionBody(string body) |
| 27 | { |
| 28 | if (body.Equals(IntercomAnchorPeekBody, StringComparison.OrdinalIgnoreCase)) |
| 29 | return AnchorPeekBody; |
| 30 | |
| 31 | var prefix = IntercomAnchorPeekBody + " "; |
| 32 | if (body.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) |
| 33 | return AnchorPeekBody + " " + body[prefix.Length..]; |
| 34 | |
| 35 | return body; |
| 36 | } |
| 37 | |
| 38 | public static bool IsAnchorPeekCompletionBody(string body) |
| 39 | { |
| 40 | var normalized = NormalizeCompletionBody(body); |
| 41 | return normalized.Equals(AnchorPeekBody, StringComparison.OrdinalIgnoreCase) |
| 42 | || normalized.StartsWith(AnchorPeekBody + " ", StringComparison.OrdinalIgnoreCase); |
| 43 | } |
| 44 | } |
| 45 | |