mirror of
https://github.com/lukaszraczylo/claude-mnemonic.git
synced 2026-10-17 05:59:36 +00:00
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:
+12
-14
@@ -19,12 +19,9 @@ import (
|
||||
|
||||
// Server is the MCP server that exposes search tools.
|
||||
type Server struct {
|
||||
searchMgr *search.Manager
|
||||
version string
|
||||
stdin io.Reader
|
||||
stdout io.Writer
|
||||
|
||||
// Store dependencies for enhanced tools
|
||||
stdin io.Reader
|
||||
stdout io.Writer
|
||||
searchMgr *search.Manager
|
||||
observationStore *gorm.ObservationStore
|
||||
patternStore *gorm.PatternStore
|
||||
relationStore *gorm.RelationStore
|
||||
@@ -32,6 +29,7 @@ type Server struct {
|
||||
vectorClient *sqlitevec.Client
|
||||
scoreCalculator *scoring.Calculator
|
||||
recalculator *scoring.Recalculator
|
||||
version string
|
||||
}
|
||||
|
||||
// NewServer creates a new MCP server.
|
||||
@@ -71,17 +69,17 @@ type Request struct {
|
||||
|
||||
// Response represents a JSON-RPC response.
|
||||
type Response struct {
|
||||
JSONRPC string `json:"jsonrpc"`
|
||||
ID any `json:"id"`
|
||||
Result any `json:"result,omitempty"`
|
||||
Error *Error `json:"error,omitempty"`
|
||||
JSONRPC string `json:"jsonrpc"`
|
||||
}
|
||||
|
||||
// Error represents a JSON-RPC error.
|
||||
type Error struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data any `json:"data,omitempty"`
|
||||
Message string `json:"message"`
|
||||
Code int `json:"code"`
|
||||
}
|
||||
|
||||
// ToolCallParams represents parameters for tools/call method.
|
||||
@@ -92,9 +90,9 @@ type ToolCallParams struct {
|
||||
|
||||
// Tool represents an MCP tool definition.
|
||||
type Tool struct {
|
||||
InputSchema map[string]any `json:"inputSchema"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
InputSchema map[string]any `json:"inputSchema"`
|
||||
}
|
||||
|
||||
// Run starts the MCP server loop.
|
||||
@@ -489,17 +487,17 @@ func (s *Server) callTool(ctx context.Context, name string, args json.RawMessage
|
||||
|
||||
// TimelineParams represents parameters for timeline operations.
|
||||
type TimelineParams struct {
|
||||
AnchorID int64 `json:"anchor_id"`
|
||||
Query string `json:"query"`
|
||||
Before int `json:"before"`
|
||||
After int `json:"after"`
|
||||
Project string `json:"project"`
|
||||
ObsType string `json:"obs_type"`
|
||||
Concepts string `json:"concepts"`
|
||||
Files string `json:"files"`
|
||||
Format string `json:"format"`
|
||||
AnchorID int64 `json:"anchor_id"`
|
||||
Before int `json:"before"`
|
||||
After int `json:"after"`
|
||||
DateStart int64 `json:"dateStart"`
|
||||
DateEnd int64 `json:"dateEnd"`
|
||||
Format string `json:"format"`
|
||||
}
|
||||
|
||||
// handleTimeline handles timeline requests.
|
||||
|
||||
+10
-10
@@ -34,8 +34,8 @@ func (s *ServerSuite) TestNewServer() {
|
||||
func TestRequest(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
req Request
|
||||
expected string
|
||||
req Request
|
||||
}{
|
||||
{
|
||||
name: "initialize request",
|
||||
@@ -138,9 +138,9 @@ func TestResponse(t *testing.T) {
|
||||
// TestError tests Error struct.
|
||||
func TestError(t *testing.T) {
|
||||
tests := []struct {
|
||||
expected string
|
||||
name string
|
||||
err Error
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "parse error",
|
||||
@@ -365,11 +365,11 @@ func TestHandleRequest(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
req *Request
|
||||
expectError bool
|
||||
errorCode int
|
||||
name string
|
||||
errorMessage string
|
||||
errorCode int
|
||||
expectError bool
|
||||
}{
|
||||
{
|
||||
name: "initialize method",
|
||||
@@ -753,13 +753,13 @@ func TestServerStdinStdoutConfig(t *testing.T) {
|
||||
// TestResponseIDTypes tests that response IDs can be various types.
|
||||
func TestResponseIDTypes(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
id any
|
||||
name string
|
||||
}{
|
||||
{"integer id", 1},
|
||||
{"string id", "abc-123"},
|
||||
{"float id", 1.5},
|
||||
{"null id", nil},
|
||||
{name: "integer id", id: 1},
|
||||
{name: "string id", id: "abc-123"},
|
||||
{name: "float id", id: 1.5},
|
||||
{name: "null id", id: nil},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user