csharpdeeb25a2 | 1 | using CascadeIDE.Models.AgentChat; |
| 2 | using CascadeIDE.Models.Intercom; |
| 3 | using CascadeIDE.Services.Intercom; |
| 4 | |
| 5 | namespace CascadeIDE.Features.Intercom.Transport; |
| 6 | |
| 7 | /// <summary>Маппинг локальных событий ↔ wire <c>relates_to</c> (ADR 0137, 0146).</summary> |
| 8 | internal static class IntercomRelatesToWire |
| 9 | { |
| 10 | public static IReadOnlyList<IntercomRelatesToLink> FromMessageRangeRelated( |
| 11 | ChatHistoryMessageRangeRelatedPayload payload) |
| 12 | { |
| 13 | var confidence = MapConfidence(payload.Source); |
| 14 | return IntercomMessageRangeRelatedSupport.ResolveSegments(payload) |
| 15 | .Select(segment => new IntercomRelatesToLink( |
| 16 | TargetKind: "code", |
| 17 | Relation: "documents", |
| 18 | CodeRef: payload.CodeRef, |
| 19 | OrdinalRange: new IntercomOrdinalRange(segment.StartOrdinal, segment.EndOrdinal), |
| 20 | Confidence: confidence)) |
| 21 | .ToList(); |
| 22 | } |
| 23 | |
| 24 | public static string MapConfidence(string source) => |
| 25 | source switch |
| 26 | { |
| 27 | "slash" => "explicit", |
| 28 | "explicit" => "explicit", |
| 29 | "inferred" => "inferred", |
| 30 | "agent" => "agent", |
| 31 | _ => "explicit", |
| 32 | }; |
| 33 | } |
| 34 | |
View only · write via MCP/CIDE