feat(leann-phase2): implement hybrid vector storage and graph-based search

- [x] Add AST-aware code chunking for Go, Python, and TypeScript using tree-sitter
- [x] Implement LEANN-inspired hybrid vector storage with hub detection and selective embedding storage (60-80% savings)
- [x] Add observation relationship graph with CSR format and edge detection (file overlap, semantic similarity, temporal, concept)
- [x] Implement graph-aware search with two-level traversal and relationship-based ranking
- [x] Add auto-tuning system for dynamic hub threshold adjustment based on query performance
- [x] Add comprehensive metrics tracking for vector storage, queries, latency, and graph traversals
- [x] Update configuration system with graph and hybrid storage settings
- [x] Add graph stats and vector metrics endpoints to worker service
- [x] Enhance UI sidebar with advanced metrics display and graph visualization
- [x] Optimize struct field alignment throughout codebase for memory efficiency
- [x] Update documentation with LEANN Phase 2 features and performance benefits
- [x] Add tree-sitter dependency for AST parsing
This commit is contained in:
2026-01-07 20:43:10 +00:00
parent 7ab4b07cf2
commit 74ae8ed4c1
83 changed files with 5190 additions and 603 deletions
+1 -1
View File
@@ -18,12 +18,12 @@ type Input struct {
// Observation represents an observation from the API.
type Observation struct {
ID int64 `json:"id"`
Type string `json:"type"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Narrative string `json:"narrative"`
Facts []string `json:"facts"`
ID int64 `json:"id"`
}
func main() {
+10 -10
View File
@@ -43,21 +43,21 @@ type StatusInput struct {
// WorkerStats is the response from the worker's /api/stats endpoint.
type WorkerStats struct {
Uptime string `json:"uptime"`
ActiveSessions int `json:"activeSessions"`
QueueDepth int `json:"queueDepth"`
IsProcessing bool `json:"isProcessing"`
ConnectedClients int `json:"connectedClients"`
SessionsToday int `json:"sessionsToday"`
Ready bool `json:"ready"`
Project string `json:"project,omitempty"`
ProjectObservations int `json:"projectObservations,omitempty"`
Retrieval struct {
Uptime string `json:"uptime"`
Project string `json:"project,omitempty"`
Retrieval struct {
TotalRequests int64 `json:"TotalRequests"`
ObservationsServed int64 `json:"ObservationsServed"`
SearchRequests int64 `json:"SearchRequests"`
ContextInjections int64 `json:"ContextInjections"`
} `json:"retrieval"`
ActiveSessions int `json:"activeSessions"`
QueueDepth int `json:"queueDepth"`
ConnectedClients int `json:"connectedClients"`
SessionsToday int `json:"sessionsToday"`
ProjectObservations int `json:"projectObservations,omitempty"`
IsProcessing bool `json:"isProcessing"`
Ready bool `json:"ready"`
}
// ANSI color codes
+3 -3
View File
@@ -14,17 +14,17 @@ import (
// Input is the hook input from Claude Code.
type Input struct {
hooks.BaseInput
StopHookActive bool `json:"stop_hook_active"`
TranscriptPath string `json:"transcript_path"`
StopHookActive bool `json:"stop_hook_active"`
}
// TranscriptMessage represents a message in the transcript JSONL file.
type TranscriptMessage struct {
Type string `json:"type"`
Message struct {
Content any `json:"content"`
Role string `json:"role"`
Content any `json:"content"` // Can be string or array
} `json:"message"`
Type string `json:"type"` // Can be string or array
}
// extractTextContent extracts text content from message content (handles both string and array formats).