@@ -24,12 +24,16 @@ const (
2424 maxQueryGraphLimit = 500
2525)
2626
27+ // largeFunctionItem summarizes one oversized function candidate.
28+ // @intent preserve a stable per-item DTO for findLargeFunctions responses.
2729type largeFunctionItem struct {
2830 Name string `json:"name"`
2931 File string `json:"file"`
3032 Lines int `json:"lines"`
3133}
3234
35+ // annotationTagItem serializes one stored annotation tag.
36+ // @intent expose annotation tags with typed fields for getAnnotation callers.
3337type annotationTagItem struct {
3438 Kind model.TagKind `json:"kind"`
3539 Type string `json:"type"`
@@ -38,18 +42,24 @@ type annotationTagItem struct {
3842 Ordinal int `json:"ordinal"`
3943}
4044
45+ // annotationResponse is the typed wire payload for getAnnotation.
46+ // @intent preserve a stable response envelope for annotation summary, context, and tags.
4147type annotationResponse struct {
4248 Summary string `json:"summary"`
4349 Context string `json:"context"`
4450 Tags []annotationTagItem `json:"tags"`
4551}
4652
53+ // queryGraphEvidence records edge evidence backing one queryGraph result item.
54+ // @intent expose edge location details that justify caller/callee confidence labels.
4755type queryGraphEvidence struct {
4856 FilePath string `json:"file_path"`
4957 Line int `json:"line"`
5058 Fingerprint string `json:"fingerprint"`
5159}
5260
61+ // queryGraphResultItem summarizes one node returned by queryGraph.
62+ // @intent preserve a stable DTO for paged graph traversal results.
5363type queryGraphResultItem struct {
5464 ID uint `json:"id"`
5565 QualifiedName string `json:"qualified_name"`
@@ -61,6 +71,8 @@ type queryGraphResultItem struct {
6171 Evidence * queryGraphEvidence `json:"evidence,omitempty"`
6272}
6373
74+ // queryGraphMetadata records pagination and fallback-call accounting for queryGraph.
75+ // @intent explain result counts, truncation, and strict-versus-tentative composition in queryGraph responses.
6476type queryGraphMetadata struct {
6577 Limit int `json:"limit"`
6678 Offset int `json:"offset"`
@@ -73,14 +85,18 @@ type queryGraphMetadata struct {
7385 IncludeFallbackCalls * bool `json:"include_fallback_calls,omitempty"`
7486}
7587
88+ // queryGraphResponse is the typed wire payload for queryGraph.
89+ // @intent preserve a stable response envelope for predefined graph traversals and their evidence.
7690type queryGraphResponse struct {
77- Pattern string `json:"pattern"`
78- Target string `json:"target"`
91+ Pattern string `json:"pattern"`
92+ Target string `json:"target"`
7993 Results []queryGraphResultItem `json:"results"`
80- Metadata queryGraphMetadata `json:"metadata"`
81- Evidence map [string ]any `json:"evidence"`
94+ Metadata queryGraphMetadata `json:"metadata"`
95+ Evidence map [string ]any `json:"evidence"`
8296}
8397
98+ // searchResultItem summarizes one node hit returned by full-text search.
99+ // @intent preserve a stable per-item DTO for search responses.
84100type searchResultItem struct {
85101 ID uint `json:"id"`
86102 QualifiedName string `json:"qualified_name"`
@@ -89,6 +105,16 @@ type searchResultItem struct {
89105 FilePath string `json:"file_path"`
90106}
91107
108+ // fileSummaryResponse is the typed wire payload for file_summary queryGraph requests.
109+ // @intent preserve a stable response envelope for file-summary graph queries.
110+ type fileSummaryResponse struct {
111+ Pattern string `json:"pattern"`
112+ Target string `json:"target"`
113+ Results * querypkg.FileSummary `json:"results"`
114+ }
115+
116+ // nodeResponse is the typed wire payload for getNode.
117+ // @intent preserve a stable response envelope for node metadata lookups.
92118type nodeResponse struct {
93119 ID uint `json:"id"`
94120 QualifiedName string `json:"qualified_name"`
@@ -337,12 +363,7 @@ func (h *handlers) queryGraph(ctx context.Context, request mcp.CallToolRequest)
337363 if err != nil {
338364 return "" , newToolResultErr (fmt .Sprintf ("file summary error: %v" , err ))
339365 }
340- fsData := map [string ]any {
341- "pattern" : pattern ,
342- "target" : target ,
343- "results" : summary ,
344- }
345- result , err := marshalJSON (fsData )
366+ result , err := marshalJSON (fileSummaryResponse {Pattern : pattern , Target : target , Results : summary })
346367 if err != nil {
347368 return "" , trace .Wrap (err , "marshal result" )
348369 }
@@ -568,6 +589,17 @@ func compactQueryTargetAmbiguity(target string, matches []querypkg.CandidateMatc
568589 return fmt .Sprintf ("query_graph target %q is ambiguous: %s" , target , strings .Join (parts , "; " ))
569590}
570591
592+ // listGraphStatsResponse is the serialized payload for graph statistics.
593+ // @intent preserve a stable typed JSON response for graph statistics without changing the wire format.
594+ type listGraphStatsResponse struct {
595+ TotalNodes int64 `json:"total_nodes"`
596+ TotalEdges int64 `json:"total_edges"`
597+ NodesByKind map [string ]int64 `json:"nodes_by_kind"`
598+ NodesByLanguage map [string ]int64 `json:"nodes_by_language"`
599+ EdgesByKind map [string ]int64 `json:"edges_by_kind"`
600+ Evidence map [string ]any `json:"evidence"`
601+ }
602+
571603// listGraphStats returns aggregate node and edge statistics for the graph.
572604// @intent summarize the current graph load state with kind and language distributions.
573605// @ensures returns total node and edge counts plus kind and language aggregates when the query succeeds.
@@ -634,13 +666,13 @@ func (h *handlers) listGraphStats(ctx context.Context, request mcp.CallToolReque
634666 ebk [k .Kind ] = k .Count
635667 }
636668
637- statsData := map [ string ] any {
638- "total_nodes" : nodeCount ,
639- "total_edges" : edgeCount ,
640- "nodes_by_kind" : nbk ,
641- "nodes_by_language" : nbl ,
642- "edges_by_kind" : ebk ,
643- "evidence" : h .workspaceEvidenceFromContext (ctx ),
669+ statsData := listGraphStatsResponse {
670+ TotalNodes : nodeCount ,
671+ TotalEdges : edgeCount ,
672+ NodesByKind : nbk ,
673+ NodesByLanguage : nbl ,
674+ EdgesByKind : ebk ,
675+ Evidence : h .workspaceEvidenceFromContext (ctx ),
644676 }
645677 result , err := marshalJSON (statsData )
646678 if err != nil {
0 commit comments