general improvements (#17)

* refactor(hooks): simplify hook execution with shared context

- [x] Extract BaseInput struct to eliminate duplicate fields across hooks
- [x] Create RunHook handler pattern for session-start and user-prompt
- [x] Create RunStatuslineHook for fast statusline rendering without worker startup
- [x] Add HookContext struct to pass port, project, CWD, SessionID to handlers
- [x] Add db/interface.go with ObservationReader/Writer interfaces
- [x] Add comprehensive conflict management tests in sqlite/conflict_test.go
- [x] Add vector client tests for Count, ModelVersion, NeedsRebuild, GetStaleVectors
- [x] Add FilterByThreshold helper tests for query result filtering
- [x] Make handlers_test more robust for network-dependent update checks
- [x] Update package versions in UI

* Move to GORM + general cleanup

* feat(mcp): add observation relations discovery and scoring integration

- [x] Add find_related_observations MCP tool for discovering related observations by confidence
- [x] Integrate scoring calculator and recalculator into MCP server initialization
- [x] Add pattern, relation, and session stores to MCP server dependencies
- [x] Register MCP server in Claude Code settings during plugin installation
- [x] Update install scripts (bash, PowerShell) to configure MCP server settings
- [x] Switch plugin manifest files to template-based versioning (plugin.json.tpl, marketplace.json.tpl)
- [x] Update all MCP server tests to pass new dependency parameters
This commit is contained in:
2026-01-07 00:26:20 +00:00
committed by GitHub
parent 92a99c7615
commit 7a061c85eb
85 changed files with 8445 additions and 8202 deletions
+116
View File
@@ -572,3 +572,119 @@ func TestExtractedIDs_Empty(t *testing.T) {
assert.Nil(t, ids.SummaryIDs)
assert.Nil(t, ids.PromptIDs)
}
func TestFilterByThreshold(t *testing.T) {
tests := []struct {
name string
results []QueryResult
threshold float64
maxResults int
expectedLen int
expectedIDs []string
}{
{
name: "empty_results",
results: []QueryResult{},
threshold: 0.5,
maxResults: 0,
expectedLen: 0,
},
{
name: "all_above_threshold",
results: []QueryResult{
{ID: "doc-1", Similarity: 0.9},
{ID: "doc-2", Similarity: 0.8},
{ID: "doc-3", Similarity: 0.7},
},
threshold: 0.5,
maxResults: 0,
expectedLen: 3,
expectedIDs: []string{"doc-1", "doc-2", "doc-3"},
},
{
name: "some_below_threshold",
results: []QueryResult{
{ID: "doc-1", Similarity: 0.9},
{ID: "doc-2", Similarity: 0.4},
{ID: "doc-3", Similarity: 0.7},
{ID: "doc-4", Similarity: 0.3},
},
threshold: 0.5,
maxResults: 0,
expectedLen: 2,
expectedIDs: []string{"doc-1", "doc-3"},
},
{
name: "all_below_threshold",
results: []QueryResult{
{ID: "doc-1", Similarity: 0.3},
{ID: "doc-2", Similarity: 0.2},
},
threshold: 0.5,
maxResults: 0,
expectedLen: 0,
},
{
name: "max_results_limit",
results: []QueryResult{
{ID: "doc-1", Similarity: 0.9},
{ID: "doc-2", Similarity: 0.8},
{ID: "doc-3", Similarity: 0.7},
{ID: "doc-4", Similarity: 0.6},
},
threshold: 0.5,
maxResults: 2,
expectedLen: 2,
expectedIDs: []string{"doc-1", "doc-2"},
},
{
name: "max_results_with_threshold",
results: []QueryResult{
{ID: "doc-1", Similarity: 0.9},
{ID: "doc-2", Similarity: 0.3},
{ID: "doc-3", Similarity: 0.8},
{ID: "doc-4", Similarity: 0.2},
{ID: "doc-5", Similarity: 0.7},
},
threshold: 0.5,
maxResults: 2,
expectedLen: 2,
expectedIDs: []string{"doc-1", "doc-3"},
},
{
name: "exact_threshold_included",
results: []QueryResult{
{ID: "doc-1", Similarity: 0.5},
{ID: "doc-2", Similarity: 0.4},
},
threshold: 0.5,
maxResults: 0,
expectedLen: 1,
expectedIDs: []string{"doc-1"},
},
{
name: "zero_threshold",
results: []QueryResult{
{ID: "doc-1", Similarity: 0.1},
{ID: "doc-2", Similarity: 0.0},
},
threshold: 0.0,
maxResults: 0,
expectedLen: 2,
expectedIDs: []string{"doc-1", "doc-2"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
filtered := FilterByThreshold(tt.results, tt.threshold, tt.maxResults)
assert.Len(t, filtered, tt.expectedLen)
if tt.expectedLen > 0 {
for i, id := range tt.expectedIDs {
assert.Equal(t, id, filtered[i].ID)
}
}
})
}
}