@@ -39,6 +39,7 @@ func (d BashDetector) Detect(ctx *detector.Context) *detector.Result {
3939 var edges []* model.CodeEdge
4040 fp := ctx .FilePath
4141 lines := strings .Split (text , "\n " )
42+ seen := map [string ]bool {}
4243
4344 // Shebang → MODULE node for the script
4445 if len (lines ) > 0 {
@@ -69,9 +70,12 @@ func (d BashDetector) Detect(ctx *detector.Context) *detector.Result {
6970 }
7071
7172 // source ./lib.sh / . helpers.sh
73+ // Emit anchor nodes so the imports edge survives GraphBuilder's phantom-drop.
7274 if m := bashSourceRE .FindStringSubmatch (line ); len (m ) >= 2 {
7375 src := m [1 ]
74- e := model .NewCodeEdge (fp + ":sources:" + src , model .EdgeImports , fp , src )
76+ srcID := base .EnsureFileAnchor (ctx , "bash" , "BashDetector" , model .ConfidenceLexical , & nodes , seen )
77+ tgtID := base .EnsureExternalAnchor (src , "bash:external" , "BashDetector" , model .ConfidenceLexical , & nodes , seen )
78+ e := model .NewCodeEdge (srcID + ":sources:" + tgtID , model .EdgeImports , srcID , tgtID )
7579 e .Source = "BashDetector"
7680 edges = append (edges , e )
7781 }
@@ -89,6 +93,7 @@ func (d BashDetector) Detect(ctx *detector.Context) *detector.Result {
8993 }
9094
9195 // Tool calls — dedup across the whole file, skip comments
96+ // Emit anchor nodes so the calls edges survive GraphBuilder's phantom-drop.
9297 toolsSeen := map [string ]bool {}
9398 for _ , line := range lines {
9499 stripped := strings .TrimLeft (line , " \t " )
@@ -101,7 +106,9 @@ func (d BashDetector) Detect(ctx *detector.Context) *detector.Result {
101106 continue
102107 }
103108 toolsSeen [tool ] = true
104- e := model .NewCodeEdge (fp + ":calls:" + tool , model .EdgeCalls , fp , tool )
109+ srcID := base .EnsureFileAnchor (ctx , "bash" , "BashDetector" , model .ConfidenceLexical , & nodes , seen )
110+ tgtID := base .EnsureExternalAnchor (tool , "bash:tool" , "BashDetector" , model .ConfidenceLexical , & nodes , seen )
111+ e := model .NewCodeEdge (srcID + ":calls:" + tgtID , model .EdgeCalls , srcID , tgtID )
105112 e .Source = "BashDetector"
106113 e .Properties ["tool" ] = tool
107114 edges = append (edges , e )
0 commit comments