From 7ba0de7dc75ec9b09bb662d59068b1ed6dbdc0a7 Mon Sep 17 00:00:00 2001
From: ai_xiaopei <xiaopei@aisim.cn>
Date: Fri, 21 Aug 2026 20:11:20 +0800
Subject: [PATCH] fix(llm): getDefaultConfig 默认路径经 expandPath 展开(修复无配置文件时在 cwd 下创建字面 ~ 目录)

---
 internal/graph/builder_test.go |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/internal/graph/builder_test.go b/internal/graph/builder_test.go
index 8b66be5..a966c86 100644
--- a/internal/graph/builder_test.go
+++ b/internal/graph/builder_test.go
@@ -1,6 +1,7 @@
 package graph
 
 import (
+	"strings"
 	"testing"
 
 	"github.com/aisim/kb-cli/internal/vault"
@@ -30,8 +31,33 @@
 
 	g := BuildGraph(files)
 
-	if len(g.Nodes) != 2 {
-		t.Errorf("node count = %d, want 2", len(g.Nodes))
+	// 2 个文件节点 + 2 个 tag 虚拟节点(充装、智能枪)+ 1 个 entity 虚拟节点
+	if len(g.Nodes) != 5 {
+		t.Errorf("node count = %d, want 5", len(g.Nodes))
+	}
+
+	// 验证虚拟节点 path 命名空间与 NodeType
+	tagCount, entityCount, fileCount := 0, 0, 0
+	for _, n := range g.Nodes {
+		switch n.NodeType {
+		case "tag":
+			tagCount++
+			if !strings.HasPrefix(n.Path, "tag:") {
+				t.Errorf("tag node path = %q, want prefix tag:", n.Path)
+			}
+		case "entity":
+			entityCount++
+			if !strings.HasPrefix(n.Path, "entity:") {
+				t.Errorf("entity node path = %q, want prefix entity:", n.Path)
+			}
+		case "file":
+			fileCount++
+		default:
+			t.Errorf("unexpected node_type %q for %s", n.NodeType, n.Path)
+		}
+	}
+	if tagCount != 2 || entityCount != 1 || fileCount != 2 {
+		t.Errorf("file/tag/entity = %d/%d/%d, want 2/2/1", fileCount, tagCount, entityCount)
 	}
 
 	// 应该有 3 条边:2条 tag + 1条 entity

--
Gitblit v1.10.0