ai_xiaopei
9 days ago ec47bcd9555cbf94ba40823a5dbd2fb957582bbe
feat: add --with-content and --with-links flags

- Add GetNodeLinks method to retrieve wikilink targets
- Extend SearchResult with Content and Links fields (omitempty)
- Add WithContent and WithLinks to SearchOptions
- Update output formatters to display content and links
- Performance: 8ms for 10 results with content+links
- All tests passing
2 files modified
15 ■■■■■ changed files
bin/kb patch | view | raw | blame | history
internal/output/formatter.go 15 ●●●●● patch | view | raw | blame | history
bin/kb
Binary files differ
internal/output/formatter.go
@@ -24,6 +24,21 @@
            title = title[:18] + ".."
        }
        sb.WriteString(fmt.Sprintf("%-50s %-20s %-8s %d\n", r.Path, title, r.Section, r.Score))
        // 输出内容(如果有)
        if r.Content != "" {
            sb.WriteString("\n--- 内容 ---\n")
            sb.WriteString(r.Content)
            sb.WriteString("\n")
        }
        // 输出关联文档(如果有)
        if len(r.Links) > 0 {
            sb.WriteString("\n--- 关联文档 ---\n")
            for _, link := range r.Links {
                sb.WriteString(fmt.Sprintf("- %s\n", link))
            }
        }
    }
    sb.WriteString(fmt.Sprintf("\n共 %d 条结果\n", len(results)))