Implement ANN index using HNSW algorithm and update related tests

- Added ANNIndex class for approximate nearest neighbor search using HNSW.
- Integrated ANN index with VectorStore for enhanced search capabilities.
- Updated test suite for ANN index, including tests for adding, searching, saving, and loading vectors.
- Modified existing tests to accommodate changes in search performance expectations.
- Improved error handling for file operations in tests to ensure compatibility with Windows file locks.
- Adjusted hybrid search performance assertions for increased stability in CI environments.
This commit is contained in:
catlog22
2025-12-19 10:35:29 +08:00
parent 9f6e6852da
commit 5e91ba6c60
15 changed files with 1463 additions and 172 deletions

View File

@@ -315,7 +315,10 @@ async function contextAction(options: CommandOptions): Promise<void> {
const { SessionClusteringService } = await import('../core/session-clustering-service.js');
const service = new SessionClusteringService(getProjectPath());
const index = await service.getProgressiveIndex();
// Default to session-start for CLI usage
const index = await service.getProgressiveIndex({
type: 'session-start'
});
if (options.format === 'json') {
console.log(JSON.stringify({ index }, null, 2));

View File

@@ -1068,13 +1068,17 @@ export async function handleMcpRoutes(ctx: RouteContext): Promise<boolean> {
}
// Generate CCW MCP server config
// Use cmd /c to inherit Claude Code's working directory
const ccwMcpConfig = {
command: "ccw-mcp",
args: []
command: "cmd",
args: ["/c", "npx", "-y", "ccw-mcp"],
env: {
CCW_ENABLED_TOOLS: "all"
}
};
// Use existing addMcpServerToProject to install CCW MCP
return addMcpServerToProject(projectPath, 'ccw-mcp', ccwMcpConfig);
return addMcpServerToProject(projectPath, 'ccw-tools', ccwMcpConfig);
});
return true;
}

View File

@@ -522,7 +522,7 @@ export class SessionClusteringService {
const sortedSessions = sessions
.filter(s => s.created_at)
.sort((a, b) => (b.created_at || '').localeCompare(a.created_at || ''))
.slice(0, 10); // Top 10 recent sessions
.slice(0, 5); // Top 5 recent sessions
if (sortedSessions.length === 0) {
return `<ccw-session-context>
@@ -634,7 +634,7 @@ Parameters: { "action": "search", "query": "<keyword>" }
let output = `<ccw-session-context>
## 📋 Intent-Matched Sessions
**Detected Intent**: ${promptSession.keywords.slice(0, 5).join(', ') || 'General'}
**Detected Intent**: ${(promptSession.keywords || []).slice(0, 5).join(', ') || 'General'}
`;

View File

@@ -453,10 +453,10 @@ async function generateMemorySummary(memoryId) {
try {
showNotification(t('coreMemory.generatingSummary'), 'info');
const response = await fetch(`/api/core-memory/memories/${memoryId}/summary?path=${encodeURIComponent(projectPath)}`, {
const response = await fetch(`/api/core-memory/memories/${memoryId}/summary`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ tool: 'gemini' })
body: JSON.stringify({ tool: 'gemini', path: projectPath })
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);