@@ -12,6 +12,24 @@ import (
1212 "github.com/tae2089/code-context-graph/internal/model"
1313)
1414
15+ // graphFlowInfo represents a summarized flow response entry.
16+ // @intent serialize listFlows results with the legacy response shape.
17+ type graphFlowInfo struct {
18+ ID uint `json:"id"`
19+ Name string `json:"name"`
20+ Description string `json:"description"`
21+ NodeCount int `json:"node_count"`
22+ }
23+
24+ // graphCommInfo represents a summarized community response entry.
25+ // @intent serialize listCommunities results with the legacy response shape.
26+ type graphCommInfo struct {
27+ ID uint `json:"id"`
28+ Label string `json:"label"`
29+ NodeCount int `json:"node_count"`
30+ Cohesion float64 `json:"cohesion"`
31+ }
32+
1533// listFlows lists stored flows with optional sorting and truncation.
1634// @intent 저장된 호출 흐름을 요약 형태로 노출해 탐색과 우선순위 판단을 돕는다.
1735// @param request sort_by와 limit로 정렬 방식과 최대 개수를 제어한다.
@@ -29,13 +47,6 @@ func (h *handlers) listFlows(ctx context.Context, request mcp.CallToolRequest) (
2947
3048 log .Info ("list_flows called" , "sort_by" , sortBy , "limit" , limit )
3149
32- // flowCount stores aggregated membership counts per flow.
33- // @intent flow_id별 멤버 수 집계 결과를 스캔하기 위한 임시 구조체다.
34- type flowCount struct {
35- FlowID uint
36- Count int
37- }
38-
3950 return finalizeToolResult (h .cachedExecute (ctx , "list_flows:" , map [string ]any {"sort_by" : sortBy , "limit" : limit , "namespace" : requestNamespace (request )}, func () (string , error ) {
4051 ns := ctxns .FromContext (ctx )
4152 var fcRows []flowCount
@@ -60,18 +71,9 @@ func (h *handlers) listFlows(ctx context.Context, request mcp.CallToolRequest) (
6071 return "" , trace .Wrap (err , "find flows" )
6172 }
6273
63- // flowInfo represents a summarized flow response entry.
64- // @intent MCP 응답에서 각 flow의 핵심 정보만 직렬화한다.
65- type flowInfo struct {
66- ID uint `json:"id"`
67- Name string `json:"name"`
68- Description string `json:"description"`
69- NodeCount int `json:"node_count"`
70- }
71-
72- infos := make ([]flowInfo , len (flowList ))
74+ infos := make ([]graphFlowInfo , len (flowList ))
7375 for i , f := range flowList {
74- infos [i ] = flowInfo {
76+ infos [i ] = graphFlowInfo {
7577 ID : f .ID ,
7678 Name : f .Name ,
7779 Description : f .Description ,
@@ -119,13 +121,6 @@ func (h *handlers) listCommunities(ctx context.Context, request mcp.CallToolRequ
119121
120122 log .Info ("list_communities called" , "sort_by" , sortBy , "min_size" , minSize )
121123
122- // commCount stores aggregated membership counts per community.
123- // @intent community_id별 멤버 수 집계 결과를 스캔하기 위한 임시 구조체다.
124- type commCount struct {
125- CommunityID uint
126- Count int
127- }
128-
129124 return finalizeToolResult (h .cachedExecute (ctx , "list_communities:" , map [string ]any {"sort_by" : sortBy , "min_size" : minSize , "namespace" : requestNamespace (request )}, func () (string , error ) {
130125 ns := ctxns .FromContext (ctx )
131126 var ccRows []commCount
@@ -151,22 +146,13 @@ func (h *handlers) listCommunities(ctx context.Context, request mcp.CallToolRequ
151146 return "" , trace .Wrap (err , "find communities" )
152147 }
153148
154- // commInfo represents a summarized community response entry.
155- // @intent MCP 응답에서 커뮤니티의 핵심 메타데이터만 직렬화한다.
156- type commInfo struct {
157- ID uint `json:"id"`
158- Label string `json:"label"`
159- NodeCount int `json:"node_count"`
160- Cohesion float64 `json:"cohesion"`
161- }
162-
163- infos := make ([]commInfo , 0 , len (communities ))
149+ infos := make ([]graphCommInfo , 0 , len (communities ))
164150 for _ , c := range communities {
165151 cnt := ccMap [c .ID ]
166152 if cnt < minSize {
167153 continue
168154 }
169- infos = append (infos , commInfo {
155+ infos = append (infos , graphCommInfo {
170156 ID : c .ID ,
171157 Label : c .Label ,
172158 NodeCount : cnt ,
@@ -228,9 +214,9 @@ func (h *handlers) getCommunity(ctx context.Context, request mcp.CallToolRequest
228214 }
229215
230216 gcData := map [string ]any {
231- "id" : comm .ID ,
232- "label" : comm .Label ,
233- "node_count" : memberCount ,
217+ "id" : comm .ID ,
218+ "label" : comm .Label ,
219+ "node_count" : memberCount ,
234220 "derived_state" : derivedStateCommunities (),
235221 }
236222
@@ -299,9 +285,9 @@ func (h *handlers) getArchitectureOverview(ctx context.Context, request mcp.Call
299285
300286 if len (communities ) == 0 {
301287 result , err := marshalJSON (map [string ]any {
302- "communities" : []any {},
303- "coupling" : []any {},
304- "warnings" : []string {"No communities found. Run community rebuild first." },
288+ "communities" : []any {},
289+ "coupling" : []any {},
290+ "warnings" : []string {"No communities found. Run community rebuild first." },
305291 "derived_state" : derivedStateSummary (),
306292 })
307293 if err != nil {
@@ -363,9 +349,9 @@ func (h *handlers) getArchitectureOverview(ctx context.Context, request mcp.Call
363349 }
364350
365351 result , err := marshalJSON (map [string ]any {
366- "communities" : commInfos ,
367- "coupling" : couplingPairs ,
368- "warnings" : warnings ,
352+ "communities" : commInfos ,
353+ "coupling" : couplingPairs ,
354+ "warnings" : warnings ,
369355 "derived_state" : derivedStateSummary (),
370356 })
371357 if err != nil {
@@ -375,6 +361,7 @@ func (h *handlers) getArchitectureOverview(ctx context.Context, request mcp.Call
375361 }))
376362}
377363
364+ // @intent describe community-membership freshness so callers know when to re-run postprocess.
378365func derivedStateCommunities () map [string ]any {
379366 return map [string ]any {
380367 "communities" : map [string ]any {
@@ -385,6 +372,7 @@ func derivedStateCommunities() map[string]any {
385372 }
386373}
387374
375+ // @intent describe flow-membership freshness so callers know when to re-run postprocess.
388376func derivedStateFlows () map [string ]any {
389377 return map [string ]any {
390378 "flows" : map [string ]any {
@@ -395,6 +383,7 @@ func derivedStateFlows() map[string]any {
395383 }
396384}
397385
386+ // @intent merge community and flow freshness hints into a single derived-state map for status responses.
398387func derivedStateSummary () map [string ]any {
399388 state := derivedStateCommunities ()
400389 for k , v := range derivedStateFlows () {
0 commit comments