directory-indexer 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +37 -572
- package/dist/cli.js.map +1 -1
- package/dist/config.js +0 -7
- package/dist/config.js.map +1 -1
- package/dist/indexing.js +22 -2
- package/dist/indexing.js.map +1 -1
- package/dist/mcp-handlers.js +152 -0
- package/dist/mcp-handlers.js.map +1 -0
- package/dist/mcp.js +298 -0
- package/dist/mcp.js.map +1 -0
- package/dist/prerequisites.js +154 -0
- package/dist/prerequisites.js.map +1 -0
- package/dist/search.js +22 -43
- package/dist/search.js.map +1 -1
- package/dist/storage.js +176 -31
- package/dist/storage.js.map +1 -1
- package/package.json +1 -1
package/dist/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sources":["../src/search.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { generateEmbedding } from './embedding.js';\nimport { initializeStorage } from './storage.js';\nimport { fileExists } from './utils.js';\n\nexport interface SearchOptions {\n limit?: number;\n threshold?: number;\n directoryPath?: string;\n workspace?: string;\n}\n\nexport interface ChunkMatch {\n chunkId: string;\n score: number;\n}\n\nexport interface SearchResult {\n filePath: string;\n score: number;\n fileSizeBytes: number;\n matchingChunks: number;\n chunks: ChunkMatch[];\n}\n\nexport interface SimilarFile {\n filePath: string;\n score: number;\n fileSizeBytes: number;\n}\n\nexport class SearchError extends Error {\n constructor(message: string, public override cause?: Error) {\n super(message);\n this.name = 'SearchError';\n }\n}\n\nexport async function searchContent(query: string, options: SearchOptions = {}): Promise<SearchResult[]> {\n const { limit = 10, threshold = 0.0, workspace } = options;\n \n try {\n const config = (await import('./config.js')).loadConfig();\n const { getWorkspacePaths, isFileInWorkspace } = await import('./config.js');\n const { sqlite, qdrant } = await initializeStorage(config);\n \n const queryEmbedding = await generateEmbedding(query, config);\n \n // Get workspace paths if workspace is specified\n const workspacePaths = workspace ? getWorkspacePaths(config, workspace) : [];\n \n // Get more points initially since we'll group by file and potentially filter by workspace\n const searchLimit = workspace ? limit * 10 : limit * 5;\n const points = await qdrant.searchPoints(queryEmbedding, searchLimit);\n \n // Group points by file path, filtering by workspace if specified\n const fileGroups = new Map<string, Array<{ score: number; chunkId: string }>>();\n \n for (const point of points) {\n const score = point.score ?? 0;\n if (score < threshold) continue;\n \n const filePath = point.payload.filePath;\n \n // Filter by workspace if specified\n if (workspace && workspacePaths.length > 0) {\n if (!isFileInWorkspace(filePath, workspacePaths)) {\n continue;\n }\n }\n \n if (!fileGroups.has(filePath)) {\n fileGroups.set(filePath, []);\n }\n \n fileGroups.get(filePath)!.push({\n score,\n chunkId: point.payload.chunkId\n });\n }\n \n // Calculate average score per file and sort\n const results: SearchResult[] = [];\n for (const [filePath, chunks] of fileGroups.entries()) {\n const avgScore = chunks.reduce((sum, chunk) => sum + chunk.score, 0) / chunks.length;\n \n // Sort chunks by score (best first) and create chunk matches\n const sortedChunks = chunks.sort((a, b) => b.score - a.score);\n const chunkMatches: ChunkMatch[] = sortedChunks.map(chunk => ({\n chunkId: chunk.chunkId,\n score: chunk.score\n }));\n \n // Get file size from SQLite database\n const fileRecord = await sqlite.getFile(filePath);\n const fileSizeBytes = fileRecord?.size ?? 0;\n \n results.push({\n filePath,\n score: avgScore,\n fileSizeBytes,\n matchingChunks: chunks.length,\n chunks: chunkMatches\n });\n }\n \n // Sort by average score and return top results\n return results\n .sort((a, b) => b.score - a.score)\n .slice(0, limit);\n } catch (error) {\n throw new SearchError(`Failed to search content`, error as Error);\n }\n}\n\nexport async function findSimilarFiles(filePath: string, limit: number = 5, workspace?: string): Promise<SimilarFile[]> {\n try {\n if (!await fileExists(filePath)) {\n throw new Error(`File not found: ${filePath}`);\n }\n \n const config = (await import('./config.js')).loadConfig();\n const { getWorkspacePaths, isFileInWorkspace } = await import('./config.js');\n const { sqlite, qdrant } = await initializeStorage(config);\n \n // Get workspace paths if workspace is specified\n const workspacePaths = workspace ? getWorkspacePaths(config, workspace) : [];\n \n const fileRecord = await sqlite.getFile(filePath);\n if (!fileRecord || fileRecord.chunks.length === 0) {\n const content = await fs.readFile(filePath, 'utf-8');\n const embedding = await generateEmbedding(content, config);\n const searchLimit = workspace ? (limit + 1) * 5 : limit + 1;\n const points = await qdrant.searchPoints(embedding, searchLimit);\n \n const filteredPoints = points\n .filter(point => {\n const pointFilePath = point.payload.filePath;\n // Exclude the reference file itself\n if (pointFilePath === filePath) return false;\n \n // Filter by workspace if specified\n if (workspace && workspacePaths.length > 0) {\n return isFileInWorkspace(pointFilePath, workspacePaths);\n }\n \n return true;\n })\n .slice(0, limit);\n \n const results: SimilarFile[] = [];\n for (const point of filteredPoints) {\n const pointFileRecord = await sqlite.getFile(point.payload.filePath);\n const fileSizeBytes = pointFileRecord?.size ?? 0;\n \n results.push({\n filePath: point.payload.filePath,\n score: point.score ?? 0,\n fileSizeBytes\n });\n }\n \n return results;\n }\n \n const firstChunkEmbedding = await generateEmbedding(fileRecord.chunks[0].content, config);\n const searchLimit = workspace ? (limit + 1) * 5 : limit + 1;\n const points = await qdrant.searchPoints(firstChunkEmbedding, searchLimit);\n \n const filteredPoints = points\n .filter(point => {\n const pointFilePath = point.payload.filePath;\n // Exclude the reference file itself\n if (pointFilePath === filePath) return false;\n \n // Filter by workspace if specified\n if (workspace && workspacePaths.length > 0) {\n return isFileInWorkspace(pointFilePath, workspacePaths);\n }\n \n return true;\n })\n .slice(0, limit);\n \n const results: SimilarFile[] = [];\n for (const point of filteredPoints) {\n const pointFileRecord = await sqlite.getFile(point.payload.filePath);\n const fileSizeBytes = pointFileRecord?.size ?? 0;\n \n results.push({\n filePath: point.payload.filePath,\n score: point.score ?? 0,\n fileSizeBytes\n });\n }\n \n return results;\n } catch (error) {\n throw new SearchError(`Failed to find similar files`, error as Error);\n }\n}\n\nexport async function getChunkContent(filePath: string, chunkId: string): Promise<string> {\n try {\n if (!await fileExists(filePath)) {\n throw new Error(`File not found: ${filePath}`);\n }\n \n const config = (await import('./config.js')).loadConfig();\n const { sqlite } = await initializeStorage(config);\n \n const fileRecord = await sqlite.getFile(filePath);\n if (!fileRecord || fileRecord.chunks.length === 0) {\n throw new Error(`File not indexed: ${filePath}`);\n }\n \n const chunk = fileRecord.chunks.find(c => c.id === chunkId);\n if (!chunk) {\n throw new Error(`Chunk ${chunkId} not found in file: ${filePath}`);\n }\n \n return chunk.content;\n } catch (error) {\n throw new SearchError(`Failed to get chunk content`, error as Error);\n }\n}\n\nexport async function getFileContent(filePath: string, chunks?: string): Promise<string> {\n try {\n if (!await fileExists(filePath)) {\n throw new Error(`File not found: ${filePath}`);\n }\n \n const config = (await import('./config.js')).loadConfig();\n const { sqlite } = await initializeStorage(config);\n \n const fileRecord = await sqlite.getFile(filePath);\n \n if (!chunks) {\n return await fs.readFile(filePath, 'utf-8');\n }\n \n if (!fileRecord || fileRecord.chunks.length === 0) {\n return await fs.readFile(filePath, 'utf-8');\n }\n \n const chunkRange = parseChunkRange(chunks);\n const selectedChunks = fileRecord.chunks.filter(chunk => {\n const chunkNum = parseInt(chunk.id);\n return chunkNum >= chunkRange.start && chunkNum <= chunkRange.end;\n });\n \n return selectedChunks.map(chunk => chunk.content).join('');\n } catch (error) {\n throw new SearchError(`Failed to get file content`, error as Error);\n }\n}\n\nfunction parseChunkRange(chunks: string): { start: number; end: number } {\n if (chunks.includes('-')) {\n const [start, end] = chunks.split('-').map(num => parseInt(num.trim()));\n return { start: start || 0, end: end || start || 0 };\n }\n \n const num = parseInt(chunks);\n return { start: num, end: num };\n}"],"names":["fs","searchLimit","points","filteredPoints","results","num"],"mappings":";;;;AA+BO,MAAM,oBAAoB,MAAM;AAAA,EACrC,YAAY,SAAiC,OAAe;AAC1D,UAAM,OAAO;AAD8B,SAAA,QAAA;AAE3C,SAAK,OAAO;AAAA,EACd;AACF;AAEA,eAAsB,cAAc,OAAe,UAAyB,IAA6B;AACvG,QAAM,EAAE,QAAQ,IAAI,YAAY,GAAK,cAAc;AAEnD,MA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,EAAE;AAAA,EAC3D,SAAS,OAAO;AACd,UAAM,IAAI,YAAY,8BAA8B,KAAc;AAAA,EACpE;AACF;AAEA,SAAS,gBAAgB,QAAgD;AACvE,MAAI,OAAO,SAAS,GAAG,GAAG;AACxB,UAAM,CAAC,OAAO,GAAG,IAAI,OAAO,MAAM,GAAG,EAAE,IAAI,CAAAK,SAAO,SAASA,KAAI,KAAA,CAAM,CAAC;AACtE,WAAO,EAAE,OAAO,SAAS,GAAG,KAAK,OAAO,SAAS,EAAA;AAAA,EACnD;AAEA,QAAM,MAAM,SAAS,MAAM;AAC3B,SAAO,EAAE,OAAO,KAAK,KAAK,IAAA;AAC5B;"}
|
|
1
|
+
{"version":3,"file":"search.js","sources":["../src/search.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { generateEmbedding } from './embedding.js';\nimport { initializeStorage } from './storage.js';\nimport { fileExists } from './utils.js';\n\nexport interface SearchOptions {\n limit?: number;\n threshold?: number;\n workspace?: string;\n}\n\nexport interface ChunkMatch {\n chunkId: string;\n score: number;\n}\n\nexport interface SearchResult {\n filePath: string;\n score: number;\n fileSizeBytes: number;\n matchingChunks: number;\n chunks: ChunkMatch[];\n}\n\nexport interface SimilarFile {\n filePath: string;\n score: number;\n fileSizeBytes: number;\n}\n\nexport class SearchError extends Error {\n constructor(message: string, public override cause?: Error) {\n super(message);\n this.name = 'SearchError';\n }\n}\n\n\nfunction buildWorkspaceFilter(workspacePaths: string[]): Record<string, unknown> {\n return {\n must: [\n {\n key: \"parentDirectories\",\n match: { any: workspacePaths }\n }\n ]\n };\n}\n\nexport async function searchContent(query: string, options: SearchOptions = {}): Promise<SearchResult[]> {\n const { limit = 10, threshold = 0.0, workspace } = options;\n \n try {\n const config = (await import('./config.js')).loadConfig();\n const { getWorkspacePaths } = await import('./config.js');\n const { sqlite, qdrant } = await initializeStorage(config);\n \n const queryEmbedding = await generateEmbedding(query, config);\n \n // Get workspace paths if workspace is specified\n const workspacePaths = workspace ? getWorkspacePaths(config, workspace) : [];\n \n // Use Qdrant filtering for workspace searches\n const filter = workspace && workspacePaths.length > 0 ? buildWorkspaceFilter(workspacePaths) : undefined;\n const points = await qdrant.searchPoints(queryEmbedding, limit, filter);\n \n // Group points by file path\n const fileGroups = new Map<string, Array<{ score: number; chunkId: string }>>();\n \n for (const point of points) {\n const score = point.score ?? 0;\n if (score < threshold) continue;\n \n const filePath = point.payload.filePath;\n \n if (!fileGroups.has(filePath)) {\n fileGroups.set(filePath, []);\n }\n \n fileGroups.get(filePath)!.push({\n score,\n chunkId: point.payload.chunkId\n });\n }\n \n // Calculate average score per file and sort\n const results: SearchResult[] = [];\n for (const [filePath, chunks] of fileGroups.entries()) {\n const avgScore = chunks.reduce((sum, chunk) => sum + chunk.score, 0) / chunks.length;\n \n // Sort chunks by score (best first) and create chunk matches\n const sortedChunks = chunks.sort((a, b) => b.score - a.score);\n const chunkMatches: ChunkMatch[] = sortedChunks.map(chunk => ({\n chunkId: chunk.chunkId,\n score: chunk.score\n }));\n \n // Get file size from SQLite database\n const fileRecord = await sqlite.getFile(filePath);\n const fileSizeBytes = fileRecord?.size ?? 0;\n \n results.push({\n filePath,\n score: avgScore,\n fileSizeBytes,\n matchingChunks: chunks.length,\n chunks: chunkMatches\n });\n }\n \n // Sort by average score and return top results\n return results\n .sort((a, b) => b.score - a.score)\n .slice(0, limit);\n } catch (error) {\n throw new SearchError(`Failed to search content`, error as Error);\n }\n}\n\nexport async function findSimilarFiles(filePath: string, limit: number = 5, workspace?: string): Promise<SimilarFile[]> {\n try {\n if (!await fileExists(filePath)) {\n throw new Error(`File not found: ${filePath}`);\n }\n \n const config = (await import('./config.js')).loadConfig();\n const { getWorkspacePaths } = await import('./config.js');\n const { sqlite, qdrant } = await initializeStorage(config);\n \n // Get workspace paths if workspace is specified\n const workspacePaths = workspace ? getWorkspacePaths(config, workspace) : [];\n const filter = workspace && workspacePaths.length > 0 ? buildWorkspaceFilter(workspacePaths) : undefined;\n \n // Get embedding from file record or read file directly\n let embedding: number[];\n const fileRecord = await sqlite.getFile(filePath);\n if (fileRecord && fileRecord.chunks.length > 0) {\n embedding = await generateEmbedding(fileRecord.chunks[0].content, config);\n } else {\n const content = await fs.readFile(filePath, 'utf-8');\n embedding = await generateEmbedding(content, config);\n }\n \n const points = await qdrant.searchPoints(embedding, limit + 1, filter);\n \n const filteredPoints = points\n .filter(point => point.payload.filePath !== filePath)\n .slice(0, limit);\n \n const results: SimilarFile[] = [];\n for (const point of filteredPoints) {\n const pointFileRecord = await sqlite.getFile(point.payload.filePath);\n const fileSizeBytes = pointFileRecord?.size ?? 0;\n \n results.push({\n filePath: point.payload.filePath,\n score: point.score ?? 0,\n fileSizeBytes\n });\n }\n \n return results;\n } catch (error) {\n throw new SearchError(`Failed to find similar files`, error as Error);\n }\n}\n\nexport async function getChunkContent(filePath: string, chunkId: string): Promise<string> {\n try {\n if (!await fileExists(filePath)) {\n throw new Error(`File not found: ${filePath}`);\n }\n \n const config = (await import('./config.js')).loadConfig();\n const { sqlite } = await initializeStorage(config);\n \n const fileRecord = await sqlite.getFile(filePath);\n if (!fileRecord || fileRecord.chunks.length === 0) {\n throw new Error(`File not indexed: ${filePath}`);\n }\n \n const chunk = fileRecord.chunks.find(c => c.id === chunkId);\n if (!chunk) {\n throw new Error(`Chunk ${chunkId} not found in file: ${filePath}`);\n }\n \n return chunk.content;\n } catch (error) {\n throw new SearchError(`Failed to get chunk content`, error as Error);\n }\n}\n\nexport async function getFileContent(filePath: string, chunks?: string): Promise<string> {\n try {\n if (!await fileExists(filePath)) {\n throw new Error(`File not found: ${filePath}`);\n }\n \n const config = (await import('./config.js')).loadConfig();\n const { sqlite } = await initializeStorage(config);\n \n const fileRecord = await sqlite.getFile(filePath);\n \n if (!chunks) {\n return await fs.readFile(filePath, 'utf-8');\n }\n \n if (!fileRecord || fileRecord.chunks.length === 0) {\n return await fs.readFile(filePath, 'utf-8');\n }\n \n const chunkRange = parseChunkRange(chunks);\n const selectedChunks = fileRecord.chunks.filter(chunk => {\n const chunkNum = parseInt(chunk.id);\n return chunkNum >= chunkRange.start && chunkNum <= chunkRange.end;\n });\n \n return selectedChunks.map(chunk => chunk.content).join('');\n } catch (error) {\n throw new SearchError(`Failed to get file content`, error as Error);\n }\n}\n\nfunction parseChunkRange(chunks: string): { start: number; end: number } {\n if (chunks.includes('-')) {\n const [start, end] = chunks.split('-').map(num => parseInt(num.trim()));\n return { start: start || 0, end: end || start || 0 };\n }\n \n const num = parseInt(chunks);\n return { start: num, end: num };\n}"],"names":["fs","num"],"mappings":";;;;AA8BO,MAAM,oBAAoB,MAAM;AAAA,EACrC,YAAY,SAAiC,OAAe;AAC1D,UAAM,OAAO;AAD8B,SAAA,QAAA;AAE3C,SAAK,OAAO;AAAA,EACd;AACF;AAGA,SAAS,qBAAqB,gBAAmD;AAC/E,SAAO;AAAA,IACL,MAAM;AAAA,MACJ;AAAA,QACE,KAAK;AAAA,QACL,OAAO,EAAE,KAAK,eAAA;AAAA,MAAe;AAAA,IAC/B;AAAA,EACF;AAEJ;AAEA,eAAsB,cAAc,OAAe,UAAyB,IAA6B;AACvG,QAAM,EAAE,QAAQ,IAAI,YAAY,GAAK,cAAc;AAEnD,MAAI;AACF,UAAM,UAAU,MAAM,OAAO,aAAa,GAAG,WAAA;AAC7C,UAAM,EAAE,kBAAA,IAAsB,MAAM,OAAO,aAAa;AACxD,UAAM,EAAE,QAAQ,OAAA,IAAW,MAAM,kBAAkB,MAAM;AAEzD,UAAM,iBAAiB,MAAM,kBAAkB,OAAO,MAAM;AAG5D,UAAM,iBAAiB,YAAY,kBAAkB,QAAQ,SAAS,IAAI,CAAA;AAG1E,UAAM,SAAS,aAAa,eAAe,SAAS,IAAI,qBAAqB,cAAc,IAAI;AAC/F,UAAM,SAAS,MAAM,OAAO,aAAa,gBAAgB,OAAO,MAAM;AAGtE,UAAM,iCAAiB,IAAA;AAEvB,eAAW,SAAS,QAAQ;AAC1B,YAAM,QAAQ,MAAM,SAAS;AAC7B,UAAI,QAAQ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D;AACvE,MAAI,OAAO,SAAS,GAAG,GAAG;AACxB,UAAM,CAAC,OAAO,GAAG,IAAI,OAAO,MAAM,GAAG,EAAE,IAAI,CAAAC,SAAO,SAASA,KAAI,KAAA,CAAM,CAAC;AACtE,WAAO,EAAE,OAAO,SAAS,GAAG,KAAK,OAAO,SAAS,EAAA;AAAA,EACnD;AAEA,QAAM,MAAM,SAAS,MAAM;AAC3B,SAAO,EAAE,OAAO,KAAK,KAAK,IAAA;AAC5B;"}
|
package/dist/storage.js
CHANGED
|
@@ -60,20 +60,25 @@ class QdrantClient {
|
|
|
60
60
|
throw new StorageError(`Failed to upsert points to Qdrant`, error);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
async searchPoints(vector, limit = 10) {
|
|
63
|
+
async searchPoints(vector, limit = 10, filter) {
|
|
64
64
|
const collectionName = this.config.storage.qdrantCollection;
|
|
65
65
|
try {
|
|
66
|
+
const searchBody = {
|
|
67
|
+
vector,
|
|
68
|
+
limit,
|
|
69
|
+
with_payload: true
|
|
70
|
+
};
|
|
71
|
+
if (filter) {
|
|
72
|
+
searchBody.filter = filter;
|
|
73
|
+
}
|
|
66
74
|
const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/search`, {
|
|
67
75
|
method: "POST",
|
|
68
76
|
headers: { "Content-Type": "application/json" },
|
|
69
|
-
body: JSON.stringify(
|
|
70
|
-
vector,
|
|
71
|
-
limit,
|
|
72
|
-
with_payload: true
|
|
73
|
-
})
|
|
77
|
+
body: JSON.stringify(searchBody)
|
|
74
78
|
});
|
|
75
79
|
if (!response.ok) {
|
|
76
|
-
|
|
80
|
+
const errorBody = await response.text();
|
|
81
|
+
throw new Error(`Failed to search points: ${response.statusText} - ${errorBody}`);
|
|
77
82
|
}
|
|
78
83
|
const data = await response.json();
|
|
79
84
|
return data.result.map((item) => ({
|
|
@@ -101,7 +106,7 @@ class QdrantClient {
|
|
|
101
106
|
throw new StorageError(`Failed to delete points from Qdrant`, error);
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
|
-
async
|
|
109
|
+
async deletePointsByFilePath(filePath) {
|
|
105
110
|
const collectionName = this.config.storage.qdrantCollection;
|
|
106
111
|
try {
|
|
107
112
|
const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/delete`, {
|
|
@@ -111,8 +116,8 @@ class QdrantClient {
|
|
|
111
116
|
filter: {
|
|
112
117
|
must: [
|
|
113
118
|
{
|
|
114
|
-
key: "
|
|
115
|
-
match: { value:
|
|
119
|
+
key: "filePath",
|
|
120
|
+
match: { value: filePath }
|
|
116
121
|
}
|
|
117
122
|
]
|
|
118
123
|
}
|
|
@@ -120,10 +125,61 @@ class QdrantClient {
|
|
|
120
125
|
});
|
|
121
126
|
if (!response.ok) {
|
|
122
127
|
const errorText = await response.text();
|
|
123
|
-
throw new Error(`Failed to delete points by file
|
|
128
|
+
throw new Error(`Failed to delete points by file path: ${response.status} ${response.statusText} - ${errorText}`);
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
throw new StorageError(`Failed to delete points by file path from Qdrant`, error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async countPoints(filter) {
|
|
135
|
+
const collectionName = this.config.storage.qdrantCollection;
|
|
136
|
+
try {
|
|
137
|
+
const countBody = { exact: true };
|
|
138
|
+
if (filter) {
|
|
139
|
+
countBody.filter = filter;
|
|
140
|
+
}
|
|
141
|
+
const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/count`, {
|
|
142
|
+
method: "POST",
|
|
143
|
+
headers: { "Content-Type": "application/json" },
|
|
144
|
+
body: JSON.stringify(countBody)
|
|
145
|
+
});
|
|
146
|
+
if (!response.ok) {
|
|
147
|
+
throw new Error(`Failed to count points: ${response.statusText}`);
|
|
124
148
|
}
|
|
149
|
+
const data = await response.json();
|
|
150
|
+
return data.result.count;
|
|
125
151
|
} catch (error) {
|
|
126
|
-
throw new StorageError(`Failed to
|
|
152
|
+
throw new StorageError(`Failed to count points in Qdrant`, error);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async scrollPoints(filter, limit = 1e3) {
|
|
156
|
+
const collectionName = this.config.storage.qdrantCollection;
|
|
157
|
+
try {
|
|
158
|
+
const scrollBody = {
|
|
159
|
+
limit,
|
|
160
|
+
with_payload: true,
|
|
161
|
+
with_vector: false
|
|
162
|
+
};
|
|
163
|
+
if (filter) {
|
|
164
|
+
scrollBody.filter = filter;
|
|
165
|
+
}
|
|
166
|
+
const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/scroll`, {
|
|
167
|
+
method: "POST",
|
|
168
|
+
headers: { "Content-Type": "application/json" },
|
|
169
|
+
body: JSON.stringify(scrollBody)
|
|
170
|
+
});
|
|
171
|
+
if (!response.ok) {
|
|
172
|
+
throw new Error(`Failed to scroll points: ${response.statusText}`);
|
|
173
|
+
}
|
|
174
|
+
const data = await response.json();
|
|
175
|
+
return data.result.points.map((item) => ({
|
|
176
|
+
id: item.id,
|
|
177
|
+
vector: [],
|
|
178
|
+
payload: item.payload,
|
|
179
|
+
score: 0
|
|
180
|
+
}));
|
|
181
|
+
} catch (error) {
|
|
182
|
+
throw new StorageError(`Failed to scroll points in Qdrant`, error);
|
|
127
183
|
}
|
|
128
184
|
}
|
|
129
185
|
}
|
|
@@ -269,37 +325,126 @@ async function initDatabase(dbPath) {
|
|
|
269
325
|
return new Database(dbPath);
|
|
270
326
|
}
|
|
271
327
|
async function calculateWorkspaceStatistics(sqlite, config) {
|
|
272
|
-
const { getAvailableWorkspaces, getWorkspacePaths
|
|
328
|
+
const { getAvailableWorkspaces, getWorkspacePaths } = await import("./config.js");
|
|
273
329
|
const workspaces = [];
|
|
330
|
+
const directoriesStmt = sqlite.db.prepare("SELECT path, status FROM directories");
|
|
331
|
+
const indexedDirectories = directoriesStmt.all();
|
|
332
|
+
const indexedDirectoryPaths = indexedDirectories.map((d) => d.path);
|
|
333
|
+
const qdrant = new QdrantClient(config);
|
|
274
334
|
for (const workspaceName of getAvailableWorkspaces(config)) {
|
|
275
335
|
const workspacePaths = getWorkspacePaths(config, workspaceName);
|
|
276
336
|
const workspaceConfig = config.workspaces[workspaceName];
|
|
277
|
-
const filesStmt = sqlite.db.prepare("SELECT path, chunks_json FROM files");
|
|
278
|
-
const allFiles = filesStmt.all();
|
|
279
337
|
let filesCount = 0;
|
|
280
338
|
let chunksCount = 0;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
339
|
+
if (workspacePaths.length > 0) {
|
|
340
|
+
try {
|
|
341
|
+
const workspaceFilter = {
|
|
342
|
+
must: [
|
|
343
|
+
{
|
|
344
|
+
key: "parentDirectories",
|
|
345
|
+
match: { any: workspacePaths }
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
};
|
|
349
|
+
chunksCount = await qdrant.countPoints(workspaceFilter);
|
|
350
|
+
const points = await qdrant.scrollPoints(workspaceFilter, 1e4);
|
|
351
|
+
const uniqueFilePaths = new Set(points.map((p) => p.payload.filePath));
|
|
352
|
+
filesCount = uniqueFilePaths.size;
|
|
353
|
+
} catch {
|
|
354
|
+
filesCount = 0;
|
|
355
|
+
chunksCount = 0;
|
|
291
356
|
}
|
|
292
357
|
}
|
|
358
|
+
const health = analyzeWorkspaceHealth(workspacePaths, workspaceConfig.isValid, filesCount, indexedDirectoryPaths);
|
|
293
359
|
workspaces.push({
|
|
294
360
|
name: workspaceName,
|
|
295
361
|
paths: workspacePaths,
|
|
296
362
|
isValid: workspaceConfig.isValid,
|
|
297
363
|
filesCount,
|
|
298
|
-
chunksCount
|
|
364
|
+
chunksCount,
|
|
365
|
+
health
|
|
299
366
|
});
|
|
300
367
|
}
|
|
301
368
|
return workspaces;
|
|
302
369
|
}
|
|
370
|
+
function analyzeWorkspaceHealth(workspacePaths, isValid, filesCount, indexedDirectoryPaths) {
|
|
371
|
+
const issues = [];
|
|
372
|
+
const recommendations = [];
|
|
373
|
+
if (!isValid) {
|
|
374
|
+
issues.push("One or more workspace directories do not exist on the filesystem");
|
|
375
|
+
recommendations.push("Verify workspace directory paths exist and are accessible");
|
|
376
|
+
}
|
|
377
|
+
const unindexedPaths = [];
|
|
378
|
+
const partiallyIndexedPaths = [];
|
|
379
|
+
for (const workspacePath of workspacePaths) {
|
|
380
|
+
const exactMatch = indexedDirectoryPaths.includes(workspacePath);
|
|
381
|
+
if (exactMatch) {
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
const isChildOfIndexed = indexedDirectoryPaths.some((indexedPath) => {
|
|
385
|
+
return workspacePath.startsWith(indexedPath + "/") || workspacePath.startsWith(indexedPath + "\\");
|
|
386
|
+
});
|
|
387
|
+
if (isChildOfIndexed) {
|
|
388
|
+
partiallyIndexedPaths.push(workspacePath);
|
|
389
|
+
} else {
|
|
390
|
+
unindexedPaths.push(workspacePath);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (unindexedPaths.length > 0) {
|
|
394
|
+
issues.push(`Workspace directories not indexed: ${unindexedPaths.join(", ")}`);
|
|
395
|
+
recommendations.push(`Run indexing on these directories: ${unindexedPaths.join(", ")}`);
|
|
396
|
+
}
|
|
397
|
+
if (partiallyIndexedPaths.length > 0) {
|
|
398
|
+
issues.push(`Workspace directories indexed as part of parent directory: ${partiallyIndexedPaths.join(", ")}`);
|
|
399
|
+
recommendations.push("Consider indexing workspace directories directly for better organization");
|
|
400
|
+
}
|
|
401
|
+
if (isValid && filesCount === 0 && unindexedPaths.length === 0) {
|
|
402
|
+
issues.push("Workspace contains no indexed files");
|
|
403
|
+
recommendations.push("Verify the workspace directory contains files and re-index if necessary");
|
|
404
|
+
}
|
|
405
|
+
let status;
|
|
406
|
+
if (!isValid || unindexedPaths.length > 0) {
|
|
407
|
+
status = "error";
|
|
408
|
+
} else if (issues.length > 0) {
|
|
409
|
+
status = "warning";
|
|
410
|
+
} else {
|
|
411
|
+
status = "healthy";
|
|
412
|
+
}
|
|
413
|
+
return { status, issues, recommendations };
|
|
414
|
+
}
|
|
415
|
+
function calculateWorkspaceHealthSummary(workspaces) {
|
|
416
|
+
let healthy = 0;
|
|
417
|
+
let warnings = 0;
|
|
418
|
+
let errors = 0;
|
|
419
|
+
const criticalIssues = [];
|
|
420
|
+
const recommendations = [];
|
|
421
|
+
for (const workspace of workspaces) {
|
|
422
|
+
switch (workspace.health.status) {
|
|
423
|
+
case "healthy":
|
|
424
|
+
healthy++;
|
|
425
|
+
break;
|
|
426
|
+
case "warning":
|
|
427
|
+
warnings++;
|
|
428
|
+
break;
|
|
429
|
+
case "error":
|
|
430
|
+
errors++;
|
|
431
|
+
criticalIssues.push(`${workspace.name}: ${workspace.health.issues.join(", ")}`);
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
for (const rec of workspace.health.recommendations) {
|
|
435
|
+
if (!recommendations.includes(rec)) {
|
|
436
|
+
recommendations.push(rec);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
healthy,
|
|
442
|
+
warnings,
|
|
443
|
+
errors,
|
|
444
|
+
criticalIssues,
|
|
445
|
+
recommendations
|
|
446
|
+
};
|
|
447
|
+
}
|
|
303
448
|
async function checkQdrantConsistency(sqlite, config) {
|
|
304
449
|
const issues = [];
|
|
305
450
|
try {
|
|
@@ -372,18 +517,16 @@ async function getIndexStatus() {
|
|
|
372
517
|
d.path,
|
|
373
518
|
d.status,
|
|
374
519
|
d.indexed_at,
|
|
375
|
-
COUNT(f.
|
|
376
|
-
COALESCE(SUM(json_array_length(f.chunks_json)), 0) as chunks_count
|
|
520
|
+
(SELECT COUNT(*) FROM files f WHERE f.path LIKE d.path || '%') as files_count,
|
|
521
|
+
(SELECT COALESCE(SUM(json_array_length(f.chunks_json)), 0) FROM files f WHERE f.path LIKE d.path || '%' AND f.chunks_json IS NOT NULL) as chunks_count
|
|
377
522
|
FROM directories d
|
|
378
|
-
LEFT JOIN files f ON f.parent_dirs LIKE '%"' || d.path || '"%'
|
|
379
|
-
GROUP BY d.id, d.path, d.status, d.indexed_at
|
|
380
523
|
ORDER BY d.indexed_at DESC
|
|
381
524
|
`);
|
|
382
525
|
const directoryDetails = directoriesDetailStmt.all();
|
|
383
526
|
const directories = directoryDetails.map((row) => {
|
|
384
527
|
const errorsByDirStmt = sqlite.db.prepare(`
|
|
385
528
|
SELECT errors_json FROM files
|
|
386
|
-
WHERE
|
|
529
|
+
WHERE path LIKE ? || '%' AND errors_json IS NOT NULL
|
|
387
530
|
`);
|
|
388
531
|
const dirErrors = errorsByDirStmt.all(row.path);
|
|
389
532
|
const dirErrorsList = [];
|
|
@@ -406,6 +549,7 @@ async function getIndexStatus() {
|
|
|
406
549
|
});
|
|
407
550
|
const qdrantConsistency = await checkQdrantConsistency(sqlite, config);
|
|
408
551
|
const workspaces = await calculateWorkspaceStatistics(sqlite, config);
|
|
552
|
+
const workspaceHealth = calculateWorkspaceHealthSummary(workspaces);
|
|
409
553
|
const fs = await import("fs");
|
|
410
554
|
let databaseSize = "0 KB";
|
|
411
555
|
try {
|
|
@@ -430,6 +574,7 @@ async function getIndexStatus() {
|
|
|
430
574
|
errors: allErrors,
|
|
431
575
|
directories,
|
|
432
576
|
workspaces,
|
|
577
|
+
workspaceHealth,
|
|
433
578
|
qdrantConsistency
|
|
434
579
|
};
|
|
435
580
|
} finally {
|
package/dist/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sources":["../src/storage.ts"],"sourcesContent":["import Database from 'better-sqlite3';\nimport { Config } from './config.js';\nimport { FileInfo, ChunkInfo, ensureDirectory } from './utils.js';\nimport { dirname } from 'path';\n\nexport interface DirectoryRecord {\n id: number;\n path: string;\n status: 'pending' | 'indexing' | 'completed' | 'failed';\n indexedAt: Date;\n}\n\nexport interface FileRecord {\n id: number;\n path: string;\n size: number;\n modifiedTime: Date;\n hash: string;\n parentDirs: string[];\n chunks: ChunkInfo[];\n errors?: string[];\n}\n\nexport interface QdrantPoint {\n id: string | number;\n vector: number[];\n payload: {\n filePath: string;\n chunkId: string;\n parentDirectories: string[];\n };\n score?: number;\n}\n\nexport class StorageError extends Error {\n constructor(message: string, public override cause?: Error) {\n super(message);\n this.name = 'StorageError';\n }\n}\n\nexport class QdrantClient {\n constructor(private config: Config) {}\n\n async healthCheck(): Promise<boolean> {\n try {\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/healthz`);\n return response.ok;\n } catch {\n return false;\n }\n }\n\n async createCollection(): Promise<void> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const checkResponse = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}`);\n if (checkResponse.ok) {\n return;\n }\n\n const createResponse = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n vectors: {\n size: 768,\n distance: 'Cosine'\n }\n })\n });\n\n if (!createResponse.ok) {\n throw new Error(`Failed to create collection: ${createResponse.statusText}`);\n }\n } catch (error) {\n throw new StorageError(`Failed to create Qdrant collection`, error as Error);\n }\n }\n\n async upsertPoints(points: QdrantPoint[]): Promise<void> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ points })\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Failed to upsert points: ${response.status} ${response.statusText} - ${errorText}`);\n }\n } catch (error) {\n throw new StorageError(`Failed to upsert points to Qdrant`, error as Error);\n }\n }\n\n async searchPoints(vector: number[], limit: number = 10): Promise<QdrantPoint[]> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/search`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n vector,\n limit,\n with_payload: true\n })\n });\n\n if (!response.ok) {\n throw new Error(`Failed to search points: ${response.statusText}`);\n }\n\n const data = await response.json();\n return data.result.map((item: { id: string | number; vector: number[]; payload: Record<string, unknown>; score: number }) => ({\n id: item.id,\n vector: item.vector,\n payload: item.payload,\n score: item.score\n }));\n } catch (error) {\n throw new StorageError(`Failed to search points in Qdrant`, error as Error);\n }\n }\n\n async deletePoints(ids: (string | number)[]): Promise<void> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/delete`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ points: ids })\n });\n\n if (!response.ok) {\n throw new Error(`Failed to delete points: ${response.statusText}`);\n }\n } catch (error) {\n throw new StorageError(`Failed to delete points from Qdrant`, error as Error);\n }\n }\n\n async deletePointsByFileHash(fileHash: string): Promise<void> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/delete`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n filter: {\n must: [\n {\n key: 'fileHash',\n match: { value: fileHash }\n }\n ]\n }\n })\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Failed to delete points by file hash: ${response.status} ${response.statusText} - ${errorText}`);\n }\n } catch (error) {\n throw new StorageError(`Failed to delete points by file hash from Qdrant`, error as Error);\n }\n }\n}\n\nexport class SQLiteStorage {\n public db: Database.Database;\n\n constructor(private config: Config) {\n this.db = this.initializeDatabase();\n }\n\n private initializeDatabase(): Database.Database {\n try {\n ensureDirectory(dirname(this.config.storage.sqlitePath));\n \n const db = new Database(this.config.storage.sqlitePath);\n \n db.exec(`\n CREATE TABLE IF NOT EXISTS directories (\n id INTEGER PRIMARY KEY,\n path TEXT UNIQUE NOT NULL,\n status TEXT DEFAULT 'pending',\n indexed_at INTEGER DEFAULT 0\n );\n\n CREATE TABLE IF NOT EXISTS files (\n id INTEGER PRIMARY KEY,\n path TEXT UNIQUE NOT NULL,\n size INTEGER NOT NULL,\n modified_time INTEGER NOT NULL,\n hash TEXT NOT NULL,\n parent_dirs TEXT NOT NULL,\n chunks_json TEXT,\n errors_json TEXT\n );\n\n CREATE INDEX IF NOT EXISTS idx_files_path ON files(path);\n CREATE INDEX IF NOT EXISTS idx_files_hash ON files(hash);\n CREATE INDEX IF NOT EXISTS idx_directories_path ON directories(path);\n `);\n\n return db;\n } catch (error) {\n throw new StorageError(`Failed to initialize SQLite database`, error as Error);\n }\n }\n\n async getDirectory(path: string): Promise<DirectoryRecord | null> {\n try {\n const stmt = this.db.prepare('SELECT * FROM directories WHERE path = ?');\n const row = stmt.get(path) as { id: number; path: string; status: 'pending' | 'indexing' | 'completed' | 'failed'; indexed_at: number } | undefined;\n \n if (!row) return null;\n \n return {\n id: row.id,\n path: row.path,\n status: row.status,\n indexedAt: new Date(row.indexed_at)\n };\n } catch (error) {\n throw new StorageError(`Failed to get directory record`, error as Error);\n }\n }\n\n async upsertDirectory(path: string, status: DirectoryRecord['status']): Promise<void> {\n try {\n const stmt = this.db.prepare(`\n INSERT OR REPLACE INTO directories (path, status, indexed_at)\n VALUES (?, ?, ?)\n `);\n \n stmt.run(path, status, Date.now());\n } catch (error) {\n throw new StorageError(`Failed to upsert directory record`, error as Error);\n }\n }\n\n async getFile(path: string): Promise<FileRecord | null> {\n try {\n const stmt = this.db.prepare('SELECT * FROM files WHERE path = ?');\n const row = stmt.get(path) as { id: number; path: string; size: number; modified_time: number; hash: string; parent_dirs: string; chunks_json: string | null; errors_json: string | null } | undefined;\n \n if (!row) return null;\n \n return {\n id: row.id,\n path: row.path,\n size: row.size,\n modifiedTime: new Date(row.modified_time * 1000),\n hash: row.hash,\n parentDirs: JSON.parse(row.parent_dirs),\n chunks: row.chunks_json ? JSON.parse(row.chunks_json) : [],\n errors: row.errors_json ? JSON.parse(row.errors_json) : undefined\n };\n } catch (error) {\n throw new StorageError(`Failed to get file record`, error as Error);\n }\n }\n\n async upsertFile(fileInfo: FileInfo, chunks: ChunkInfo[] = [], errors: string[] = []): Promise<void> {\n try {\n const stmt = this.db.prepare(`\n INSERT OR REPLACE INTO files (path, size, modified_time, hash, parent_dirs, chunks_json, errors_json)\n VALUES (?, ?, ?, ?, ?, ?, ?)\n `);\n \n stmt.run(\n fileInfo.path,\n fileInfo.size,\n fileInfo.modifiedTime.getTime(),\n fileInfo.hash,\n JSON.stringify(fileInfo.parentDirs),\n chunks.length > 0 ? JSON.stringify(chunks) : null,\n errors.length > 0 ? JSON.stringify(errors) : null\n );\n } catch (error) {\n throw new StorageError(`Failed to upsert file record`, error as Error);\n }\n }\n\n async deleteFile(path: string): Promise<void> {\n try {\n const stmt = this.db.prepare('DELETE FROM files WHERE path = ?');\n stmt.run(path);\n } catch (error) {\n throw new StorageError(`Failed to delete file record`, error as Error);\n }\n }\n\n async getFilesByDirectory(directoryPath: string): Promise<FileRecord[]> {\n try {\n const stmt = this.db.prepare('SELECT * FROM files WHERE path LIKE ?');\n const rows = stmt.all(`${directoryPath}%`) as { id: number; path: string; size: number; modified_time: number; hash: string; parent_dirs: string; chunks_json: string | null; errors_json: string | null }[];\n \n return rows.map(row => ({\n id: row.id,\n path: row.path,\n size: row.size,\n modifiedTime: new Date(row.modified_time * 1000),\n hash: row.hash,\n parentDirs: JSON.parse(row.parent_dirs),\n chunks: row.chunks_json ? JSON.parse(row.chunks_json) : [],\n errors: row.errors_json ? JSON.parse(row.errors_json) : undefined\n }));\n } catch (error) {\n throw new StorageError(`Failed to get files by directory`, error as Error);\n }\n }\n\n close(): void {\n this.db.close();\n }\n}\n\nexport async function initializeStorage(config: Config): Promise<{ sqlite: SQLiteStorage; qdrant: QdrantClient }> {\n const sqlite = new SQLiteStorage(config);\n const qdrant = new QdrantClient(config);\n \n await qdrant.createCollection();\n \n return { sqlite, qdrant };\n}\n\nexport async function initDatabase(dbPath: string): Promise<Database.Database> {\n return new Database(dbPath);\n}\n\nexport interface DirectoryStatus {\n path: string;\n status: string;\n filesCount: number;\n chunksCount: number;\n lastIndexed: string | null;\n errors: string[];\n}\n\nexport interface WorkspaceStatus {\n name: string;\n paths: string[];\n isValid: boolean;\n filesCount: number;\n chunksCount: number;\n}\n\nexport interface IndexStatus {\n directoriesIndexed: number;\n filesIndexed: number;\n chunksIndexed: number;\n databaseSize: string;\n lastIndexed: string | null;\n errors: string[];\n directories: DirectoryStatus[];\n workspaces: WorkspaceStatus[];\n qdrantConsistency: {\n isConsistent: boolean;\n issues: string[];\n };\n}\n\nasync function calculateWorkspaceStatistics(sqlite: SQLiteStorage, config: Config): Promise<WorkspaceStatus[]> {\n const { getAvailableWorkspaces, getWorkspacePaths, isFileInWorkspace } = await import('./config.js');\n const workspaces: WorkspaceStatus[] = [];\n \n for (const workspaceName of getAvailableWorkspaces(config)) {\n const workspacePaths = getWorkspacePaths(config, workspaceName);\n const workspaceConfig = config.workspaces[workspaceName];\n \n // Get all files and count those in this workspace\n const filesStmt = sqlite.db.prepare('SELECT path, chunks_json FROM files');\n const allFiles = filesStmt.all() as { path: string; chunks_json: string | null }[];\n \n let filesCount = 0;\n let chunksCount = 0;\n \n for (const file of allFiles) {\n if (isFileInWorkspace(file.path, workspacePaths)) {\n filesCount++;\n if (file.chunks_json) {\n try {\n const chunks = JSON.parse(file.chunks_json);\n chunksCount += chunks.length;\n } catch {\n // Skip malformed JSON\n }\n }\n }\n }\n \n workspaces.push({\n name: workspaceName,\n paths: workspacePaths,\n isValid: workspaceConfig.isValid,\n filesCount,\n chunksCount\n });\n }\n \n return workspaces;\n}\n\nasync function checkQdrantConsistency(sqlite: SQLiteStorage, config: Config): Promise<{ isConsistent: boolean; issues: string[] }> {\n const issues: string[] = [];\n \n try {\n const qdrant = new QdrantClient(config);\n const isHealthy = await qdrant.healthCheck();\n \n if (!isHealthy) {\n issues.push('Qdrant vector database is not running or accessible');\n return { isConsistent: false, issues };\n }\n \n const filesWithChunksStmt = sqlite.db.prepare('SELECT COUNT(*) as count FROM files WHERE chunks_json IS NOT NULL');\n const filesWithChunks = filesWithChunksStmt.get() as { count: number };\n \n const totalChunksStmt = sqlite.db.prepare('SELECT SUM(json_array_length(chunks_json)) as count FROM files WHERE chunks_json IS NOT NULL');\n const totalChunks = totalChunksStmt.get() as { count: number | null };\n \n if (filesWithChunks.count > 0 && (totalChunks.count || 0) === 0) {\n issues.push('Files exist but no chunks found - possible data corruption');\n }\n \n const collectionName = config.storage.qdrantCollection;\n try {\n const response = await fetch(`${config.storage.qdrantEndpoint}/collections/${collectionName}`);\n if (!response.ok) {\n issues.push(`Vector collection '${collectionName}' not found (normal during first-time setup)`);\n return { isConsistent: false, issues };\n }\n \n const collectionInfo = await response.json();\n const qdrantPointCount = collectionInfo.result?.points_count || 0;\n const sqliteChunkCount = totalChunks.count || 0;\n \n if (Math.abs(qdrantPointCount - sqliteChunkCount) > 0) {\n if (qdrantPointCount > sqliteChunkCount) {\n issues.push(`Extra vectors in database: ${qdrantPointCount} vectors vs ${sqliteChunkCount} indexed chunks (normal during cleanup)`);\n } else {\n issues.push(`Missing vectors: ${sqliteChunkCount} indexed chunks vs ${qdrantPointCount} vectors (normal during indexing)`);\n }\n }\n } catch (error) {\n issues.push(`Cannot verify vector database status: ${error}`);\n }\n \n } catch (error) {\n issues.push(`Database status check failed: ${error}`);\n }\n \n return {\n isConsistent: issues.length === 0,\n issues\n };\n}\n\nexport async function getIndexStatus(): Promise<IndexStatus> {\n const config = await import('./config.js').then(m => m.loadConfig());\n const sqlite = new SQLiteStorage(config);\n \n try {\n const directoriesStmt = sqlite.db.prepare('SELECT COUNT(*) as count FROM directories WHERE status = ?');\n const directoriesCount = directoriesStmt.get('completed') as { count: number };\n \n const filesStmt = sqlite.db.prepare('SELECT COUNT(*) as count FROM files');\n const filesCount = filesStmt.get() as { count: number };\n \n const chunksStmt = sqlite.db.prepare('SELECT SUM(json_array_length(chunks_json)) as count FROM files WHERE chunks_json IS NOT NULL');\n const chunksCount = chunksStmt.get() as { count: number | null };\n \n const lastIndexedStmt = sqlite.db.prepare('SELECT MAX(indexed_at) as last_indexed FROM directories WHERE indexed_at > 0');\n const lastIndexedResult = lastIndexedStmt.get() as { last_indexed: number | null };\n \n const errorsStmt = sqlite.db.prepare('SELECT errors_json FROM files WHERE errors_json IS NOT NULL');\n const errorRows = errorsStmt.all() as { errors_json: string }[];\n \n const allErrors: string[] = [];\n errorRows.forEach(row => {\n try {\n const errors = JSON.parse(row.errors_json);\n allErrors.push(...errors);\n } catch {\n allErrors.push('Failed to parse error JSON');\n }\n });\n \n const directoriesDetailStmt = sqlite.db.prepare(`\n SELECT \n d.path,\n d.status,\n d.indexed_at,\n COUNT(f.id) as files_count,\n COALESCE(SUM(json_array_length(f.chunks_json)), 0) as chunks_count\n FROM directories d\n LEFT JOIN files f ON f.parent_dirs LIKE '%\"' || d.path || '\"%'\n GROUP BY d.id, d.path, d.status, d.indexed_at\n ORDER BY d.indexed_at DESC\n `);\n const directoryDetails = directoriesDetailStmt.all() as { id: number; path: string; status: 'pending' | 'indexing' | 'completed' | 'failed'; indexed_at: number; files_count: number; chunks_count: number }[];\n \n const directories: DirectoryStatus[] = directoryDetails.map(row => {\n const errorsByDirStmt = sqlite.db.prepare(`\n SELECT errors_json FROM files \n WHERE parent_dirs LIKE '%\"' || ? || '\"%' AND errors_json IS NOT NULL\n `);\n const dirErrors = errorsByDirStmt.all(row.path) as { errors_json: string }[];\n \n const dirErrorsList: string[] = [];\n dirErrors.forEach(errorRow => {\n try {\n const errors = JSON.parse(errorRow.errors_json);\n dirErrorsList.push(...errors);\n } catch {\n dirErrorsList.push('Failed to parse error JSON');\n }\n });\n \n return {\n path: row.path,\n status: row.status,\n filesCount: row.files_count,\n chunksCount: row.chunks_count,\n lastIndexed: row.indexed_at && row.indexed_at > 0 ? new Date(row.indexed_at).toISOString() : null,\n errors: dirErrorsList\n };\n });\n \n const qdrantConsistency = await checkQdrantConsistency(sqlite, config);\n const workspaces = await calculateWorkspaceStatistics(sqlite, config);\n \n const fs = await import('fs');\n let databaseSize = '0 KB';\n try {\n const stats = fs.statSync(config.storage.sqlitePath);\n const sizeInBytes = stats.size;\n if (sizeInBytes > 1024 * 1024) {\n databaseSize = `${(sizeInBytes / (1024 * 1024)).toFixed(2)} MB`;\n } else if (sizeInBytes > 1024) {\n databaseSize = `${(sizeInBytes / 1024).toFixed(2)} KB`;\n } else {\n databaseSize = `${sizeInBytes} bytes`;\n }\n } catch {\n databaseSize = 'Unknown';\n }\n \n return {\n directoriesIndexed: directoriesCount.count,\n filesIndexed: filesCount.count,\n chunksIndexed: chunksCount.count || 0,\n databaseSize,\n lastIndexed: lastIndexedResult.last_indexed ? new Date(lastIndexedResult.last_indexed).toISOString() : null,\n errors: allErrors,\n directories,\n workspaces,\n qdrantConsistency\n };\n } finally {\n sqlite.close();\n }\n}"],"names":[],"mappings":";;;AAkCO,MAAM,qBAAqB,MAAM;AAAA,EACtC,YAAY,SAAiC,OAAe;AAC1D,UAAM,OAAO;AAD8B,SAAA,QAAA;AAE3C,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,aAAa;AAAA,EACxB,YAAoB,QAAgB;AAAhB,SAAA,SAAA;AAAA,EAAiB;AAAA,EAErC,MAAM,cAAgC;AACpC,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,GAAG,KAAK,OAAO,QAAQ,cAAc,UAAU;AAC5E,aAAO,SAAS;AAAA,IAClB,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,mBAAkC;AACtC,UAAM,iBAAiB,KAAK,OAAO,QAAQ;AAE3C,QAAI;AACF,YAAM,gBAAgB,MAAM,MAAM,GAAG,KAAK,OAAO,QAAQ,cAAc,gBAAgB,cAAc,EAAE;AACvG,UAAI,cAAc,IAAI;AACpB;AAAA,MACF;AAEA,YAAM,iBAAiB,MAA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;AACF,YAAM,QAAQ,GAAG,SAAS,OAAO,QAAQ,UAAU;AACnD,YAAM,cAAc,MAAM;AAC1B,UAAI,cAAc,OAAO,MAAM;AAC7B,uBAAe,IAAI,eAAe,OAAO,OAAO,QAAQ,CAAC,CAAC;AAAA,MAC5D,WAAW,cAAc,MAAM;AAC7B,uBAAe,IAAI,cAAc,MAAM,QAAQ,CAAC,CAAC;AAAA,MACnD,OAAO;AACL,uBAAe,GAAG,WAAW;AAAA,MAC/B;AAAA,IACF,QAAQ;AACN,qBAAe;AAAA,IACjB;AAEA,WAAO;AAAA,MACL,oBAAoB,iBAAiB;AAAA,MACrC,cAAc,WAAW;AAAA,MACzB,eAAe,YAAY,SAAS;AAAA,MACpC;AAAA,MACA,aAAa,kBAAkB,eAAe,IAAI,KAAK,kBAAkB,YAAY,EAAE,YAAA,IAAgB;AAAA,MACvG,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ,UAAA;AACE,WAAO,MAAA;AAAA,EACT;AACF;"}
|
|
1
|
+
{"version":3,"file":"storage.js","sources":["../src/storage.ts"],"sourcesContent":["import Database from 'better-sqlite3';\nimport { Config } from './config.js';\nimport { FileInfo, ChunkInfo, ensureDirectory } from './utils.js';\nimport { dirname } from 'path';\n\nexport interface DirectoryRecord {\n id: number;\n path: string;\n status: 'pending' | 'indexing' | 'completed' | 'failed';\n indexedAt: Date;\n}\n\nexport interface FileRecord {\n id: number;\n path: string;\n size: number;\n modifiedTime: Date;\n hash: string;\n parentDirs: string[];\n chunks: ChunkInfo[];\n errors?: string[];\n}\n\nexport interface QdrantPoint {\n id: string | number;\n vector: number[];\n payload: {\n filePath: string;\n chunkId: string;\n fileHash: string;\n content: string;\n parentDirectories: string[];\n };\n score?: number;\n}\n\nexport class StorageError extends Error {\n constructor(message: string, public override cause?: Error) {\n super(message);\n this.name = 'StorageError';\n }\n}\n\nexport class QdrantClient {\n constructor(private config: Config) {}\n\n async healthCheck(): Promise<boolean> {\n try {\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/healthz`);\n return response.ok;\n } catch {\n return false;\n }\n }\n\n async createCollection(): Promise<void> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const checkResponse = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}`);\n if (checkResponse.ok) {\n return;\n }\n\n const createResponse = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n vectors: {\n size: 768,\n distance: 'Cosine'\n }\n })\n });\n\n if (!createResponse.ok) {\n throw new Error(`Failed to create collection: ${createResponse.statusText}`);\n }\n } catch (error) {\n throw new StorageError(`Failed to create Qdrant collection`, error as Error);\n }\n }\n\n async upsertPoints(points: QdrantPoint[]): Promise<void> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ points })\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Failed to upsert points: ${response.status} ${response.statusText} - ${errorText}`);\n }\n } catch (error) {\n throw new StorageError(`Failed to upsert points to Qdrant`, error as Error);\n }\n }\n\n async searchPoints(vector: number[], limit: number = 10, filter?: Record<string, unknown>): Promise<QdrantPoint[]> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const searchBody: Record<string, unknown> = {\n vector,\n limit,\n with_payload: true\n };\n \n if (filter) {\n searchBody.filter = filter;\n }\n \n const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/search`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(searchBody)\n });\n\n if (!response.ok) {\n const errorBody = await response.text();\n throw new Error(`Failed to search points: ${response.statusText} - ${errorBody}`);\n }\n\n const data = await response.json();\n return data.result.map((item: { id: string | number; vector: number[]; payload: Record<string, unknown>; score: number }) => ({\n id: item.id,\n vector: item.vector,\n payload: item.payload,\n score: item.score\n }));\n } catch (error) {\n throw new StorageError(`Failed to search points in Qdrant`, error as Error);\n }\n }\n\n async deletePoints(ids: (string | number)[]): Promise<void> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/delete`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ points: ids })\n });\n\n if (!response.ok) {\n throw new Error(`Failed to delete points: ${response.statusText}`);\n }\n } catch (error) {\n throw new StorageError(`Failed to delete points from Qdrant`, error as Error);\n }\n }\n\n async deletePointsByFilePath(filePath: string): Promise<void> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/delete`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n filter: {\n must: [\n {\n key: 'filePath',\n match: { value: filePath }\n }\n ]\n }\n })\n });\n\n if (!response.ok) {\n const errorText = await response.text();\n throw new Error(`Failed to delete points by file path: ${response.status} ${response.statusText} - ${errorText}`);\n }\n } catch (error) {\n throw new StorageError(`Failed to delete points by file path from Qdrant`, error as Error);\n }\n }\n\n async countPoints(filter?: Record<string, unknown>): Promise<number> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const countBody: Record<string, unknown> = { exact: true };\n if (filter) {\n countBody.filter = filter;\n }\n\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/count`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(countBody)\n });\n\n if (!response.ok) {\n throw new Error(`Failed to count points: ${response.statusText}`);\n }\n\n const data = await response.json();\n return data.result.count;\n } catch (error) {\n throw new StorageError(`Failed to count points in Qdrant`, error as Error);\n }\n }\n\n async scrollPoints(filter?: Record<string, unknown>, limit: number = 1000): Promise<QdrantPoint[]> {\n const collectionName = this.config.storage.qdrantCollection;\n \n try {\n const scrollBody: Record<string, unknown> = {\n limit,\n with_payload: true,\n with_vector: false\n };\n if (filter) {\n scrollBody.filter = filter;\n }\n\n const response = await fetch(`${this.config.storage.qdrantEndpoint}/collections/${collectionName}/points/scroll`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(scrollBody)\n });\n\n if (!response.ok) {\n throw new Error(`Failed to scroll points: ${response.statusText}`);\n }\n\n const data = await response.json();\n return data.result.points.map((item: { id: string | number; payload: Record<string, unknown> }) => ({\n id: item.id,\n vector: [],\n payload: item.payload,\n score: 0\n }));\n } catch (error) {\n throw new StorageError(`Failed to scroll points in Qdrant`, error as Error);\n }\n }\n}\n\nexport class SQLiteStorage {\n public db: Database.Database;\n\n constructor(private config: Config) {\n this.db = this.initializeDatabase();\n }\n\n private initializeDatabase(): Database.Database {\n try {\n ensureDirectory(dirname(this.config.storage.sqlitePath));\n \n const db = new Database(this.config.storage.sqlitePath);\n \n db.exec(`\n CREATE TABLE IF NOT EXISTS directories (\n id INTEGER PRIMARY KEY,\n path TEXT UNIQUE NOT NULL,\n status TEXT DEFAULT 'pending',\n indexed_at INTEGER DEFAULT 0\n );\n\n CREATE TABLE IF NOT EXISTS files (\n id INTEGER PRIMARY KEY,\n path TEXT UNIQUE NOT NULL,\n size INTEGER NOT NULL,\n modified_time INTEGER NOT NULL,\n hash TEXT NOT NULL,\n parent_dirs TEXT NOT NULL,\n chunks_json TEXT,\n errors_json TEXT\n );\n\n CREATE INDEX IF NOT EXISTS idx_files_path ON files(path);\n CREATE INDEX IF NOT EXISTS idx_files_hash ON files(hash);\n CREATE INDEX IF NOT EXISTS idx_directories_path ON directories(path);\n `);\n\n return db;\n } catch (error) {\n throw new StorageError(`Failed to initialize SQLite database`, error as Error);\n }\n }\n\n async getDirectory(path: string): Promise<DirectoryRecord | null> {\n try {\n const stmt = this.db.prepare('SELECT * FROM directories WHERE path = ?');\n const row = stmt.get(path) as { id: number; path: string; status: 'pending' | 'indexing' | 'completed' | 'failed'; indexed_at: number } | undefined;\n \n if (!row) return null;\n \n return {\n id: row.id,\n path: row.path,\n status: row.status,\n indexedAt: new Date(row.indexed_at)\n };\n } catch (error) {\n throw new StorageError(`Failed to get directory record`, error as Error);\n }\n }\n\n async upsertDirectory(path: string, status: DirectoryRecord['status']): Promise<void> {\n try {\n const stmt = this.db.prepare(`\n INSERT OR REPLACE INTO directories (path, status, indexed_at)\n VALUES (?, ?, ?)\n `);\n \n stmt.run(path, status, Date.now());\n } catch (error) {\n throw new StorageError(`Failed to upsert directory record`, error as Error);\n }\n }\n\n async getFile(path: string): Promise<FileRecord | null> {\n try {\n const stmt = this.db.prepare('SELECT * FROM files WHERE path = ?');\n const row = stmt.get(path) as { id: number; path: string; size: number; modified_time: number; hash: string; parent_dirs: string; chunks_json: string | null; errors_json: string | null } | undefined;\n \n if (!row) return null;\n \n return {\n id: row.id,\n path: row.path,\n size: row.size,\n modifiedTime: new Date(row.modified_time * 1000),\n hash: row.hash,\n parentDirs: JSON.parse(row.parent_dirs),\n chunks: row.chunks_json ? JSON.parse(row.chunks_json) : [],\n errors: row.errors_json ? JSON.parse(row.errors_json) : undefined\n };\n } catch (error) {\n throw new StorageError(`Failed to get file record`, error as Error);\n }\n }\n\n async upsertFile(fileInfo: FileInfo, chunks: ChunkInfo[] = [], errors: string[] = []): Promise<void> {\n try {\n const stmt = this.db.prepare(`\n INSERT OR REPLACE INTO files (path, size, modified_time, hash, parent_dirs, chunks_json, errors_json)\n VALUES (?, ?, ?, ?, ?, ?, ?)\n `);\n \n stmt.run(\n fileInfo.path,\n fileInfo.size,\n fileInfo.modifiedTime.getTime(),\n fileInfo.hash,\n JSON.stringify(fileInfo.parentDirs),\n chunks.length > 0 ? JSON.stringify(chunks) : null,\n errors.length > 0 ? JSON.stringify(errors) : null\n );\n } catch (error) {\n throw new StorageError(`Failed to upsert file record`, error as Error);\n }\n }\n\n async deleteFile(path: string): Promise<void> {\n try {\n const stmt = this.db.prepare('DELETE FROM files WHERE path = ?');\n stmt.run(path);\n } catch (error) {\n throw new StorageError(`Failed to delete file record`, error as Error);\n }\n }\n\n async getFilesByDirectory(directoryPath: string): Promise<FileRecord[]> {\n try {\n const stmt = this.db.prepare('SELECT * FROM files WHERE path LIKE ?');\n const rows = stmt.all(`${directoryPath}%`) as { id: number; path: string; size: number; modified_time: number; hash: string; parent_dirs: string; chunks_json: string | null; errors_json: string | null }[];\n \n return rows.map(row => ({\n id: row.id,\n path: row.path,\n size: row.size,\n modifiedTime: new Date(row.modified_time * 1000),\n hash: row.hash,\n parentDirs: JSON.parse(row.parent_dirs),\n chunks: row.chunks_json ? JSON.parse(row.chunks_json) : [],\n errors: row.errors_json ? JSON.parse(row.errors_json) : undefined\n }));\n } catch (error) {\n throw new StorageError(`Failed to get files by directory`, error as Error);\n }\n }\n\n close(): void {\n this.db.close();\n }\n}\n\nexport async function initializeStorage(config: Config): Promise<{ sqlite: SQLiteStorage; qdrant: QdrantClient }> {\n const sqlite = new SQLiteStorage(config);\n const qdrant = new QdrantClient(config);\n \n await qdrant.createCollection();\n \n return { sqlite, qdrant };\n}\n\nexport async function initDatabase(dbPath: string): Promise<Database.Database> {\n return new Database(dbPath);\n}\n\nexport interface DirectoryStatus {\n path: string;\n status: string;\n filesCount: number;\n chunksCount: number;\n lastIndexed: string | null;\n errors: string[];\n}\n\nexport interface WorkspaceStatus {\n name: string;\n paths: string[];\n isValid: boolean;\n filesCount: number;\n chunksCount: number;\n health: {\n status: 'healthy' | 'warning' | 'error';\n issues: string[];\n recommendations: string[];\n };\n}\n\nexport interface IndexStatus {\n directoriesIndexed: number;\n filesIndexed: number;\n chunksIndexed: number;\n databaseSize: string;\n lastIndexed: string | null;\n errors: string[];\n directories: DirectoryStatus[];\n workspaces: WorkspaceStatus[];\n workspaceHealth: {\n healthy: number;\n warnings: number;\n errors: number;\n criticalIssues: string[];\n recommendations: string[];\n };\n qdrantConsistency: {\n isConsistent: boolean;\n issues: string[];\n };\n}\n\nasync function calculateWorkspaceStatistics(sqlite: SQLiteStorage, config: Config): Promise<WorkspaceStatus[]> {\n const { getAvailableWorkspaces, getWorkspacePaths } = await import('./config.js');\n const workspaces: WorkspaceStatus[] = [];\n \n // Get all indexed directories for comparison\n const directoriesStmt = sqlite.db.prepare('SELECT path, status FROM directories');\n const indexedDirectories = directoriesStmt.all() as { path: string; status: string }[];\n const indexedDirectoryPaths = indexedDirectories.map(d => d.path);\n \n // Get Qdrant client for efficient workspace filtering\n const qdrant = new QdrantClient(config);\n \n for (const workspaceName of getAvailableWorkspaces(config)) {\n const workspacePaths = getWorkspacePaths(config, workspaceName);\n const workspaceConfig = config.workspaces[workspaceName];\n \n let filesCount = 0;\n let chunksCount = 0;\n \n if (workspacePaths.length > 0) {\n try {\n // Build workspace filter using same logic as search\n const workspaceFilter = {\n must: [\n {\n key: \"parentDirectories\",\n match: { any: workspacePaths }\n }\n ]\n };\n \n // Get chunk count efficiently using Qdrant\n chunksCount = await qdrant.countPoints(workspaceFilter);\n \n // Get unique file paths using Qdrant scroll\n const points = await qdrant.scrollPoints(workspaceFilter, 10000);\n const uniqueFilePaths = new Set(points.map(p => p.payload.filePath));\n filesCount = uniqueFilePaths.size;\n \n } catch {\n // Fallback to 0 if Qdrant is unavailable\n filesCount = 0;\n chunksCount = 0;\n }\n }\n \n // Check workspace health\n const health = analyzeWorkspaceHealth(workspacePaths, workspaceConfig.isValid, filesCount, indexedDirectoryPaths);\n \n workspaces.push({\n name: workspaceName,\n paths: workspacePaths,\n isValid: workspaceConfig.isValid,\n filesCount,\n chunksCount,\n health\n });\n }\n \n return workspaces;\n}\n\nfunction analyzeWorkspaceHealth(\n workspacePaths: string[], \n isValid: boolean, \n filesCount: number, \n indexedDirectoryPaths: string[]\n): { status: 'healthy' | 'warning' | 'error'; issues: string[]; recommendations: string[] } {\n const issues: string[] = [];\n const recommendations: string[] = [];\n \n // Check if workspace paths exist and are valid\n if (!isValid) {\n issues.push('One or more workspace directories do not exist on the filesystem');\n recommendations.push('Verify workspace directory paths exist and are accessible');\n }\n \n // Check if workspace paths are indexed\n const unindexedPaths: string[] = [];\n const partiallyIndexedPaths: string[] = [];\n \n for (const workspacePath of workspacePaths) {\n // Check if this exact path is indexed\n const exactMatch = indexedDirectoryPaths.includes(workspacePath);\n \n if (exactMatch) {\n // Perfect match - workspace directory is directly indexed\n continue;\n }\n \n // Check if workspace path is covered by a parent directory that is indexed\n const isChildOfIndexed = indexedDirectoryPaths.some(indexedPath => {\n // Workspace path must start with indexed path and be a subdirectory\n return workspacePath.startsWith(indexedPath + '/') || workspacePath.startsWith(indexedPath + '\\\\');\n });\n \n if (isChildOfIndexed) {\n partiallyIndexedPaths.push(workspacePath);\n } else {\n unindexedPaths.push(workspacePath);\n }\n }\n \n // Report unindexed paths\n if (unindexedPaths.length > 0) {\n issues.push(`Workspace directories not indexed: ${unindexedPaths.join(', ')}`);\n recommendations.push(`Run indexing on these directories: ${unindexedPaths.join(', ')}`);\n }\n \n // Report partially indexed paths (where parent directory is indexed)\n if (partiallyIndexedPaths.length > 0) {\n issues.push(`Workspace directories indexed as part of parent directory: ${partiallyIndexedPaths.join(', ')}`);\n recommendations.push('Consider indexing workspace directories directly for better organization');\n }\n \n // Check if workspace is empty (no files found)\n if (isValid && filesCount === 0 && unindexedPaths.length === 0) {\n issues.push('Workspace contains no indexed files');\n recommendations.push('Verify the workspace directory contains files and re-index if necessary');\n }\n \n // Determine overall health status\n let status: 'healthy' | 'warning' | 'error';\n if (!isValid || unindexedPaths.length > 0) {\n status = 'error';\n } else if (issues.length > 0) {\n status = 'warning';\n } else {\n status = 'healthy';\n }\n \n return { status, issues, recommendations };\n}\n\nfunction calculateWorkspaceHealthSummary(workspaces: WorkspaceStatus[]): {\n healthy: number;\n warnings: number; \n errors: number;\n criticalIssues: string[];\n recommendations: string[];\n} {\n let healthy = 0;\n let warnings = 0;\n let errors = 0;\n const criticalIssues: string[] = [];\n const recommendations: string[] = [];\n \n for (const workspace of workspaces) {\n switch (workspace.health.status) {\n case 'healthy':\n healthy++;\n break;\n case 'warning':\n warnings++;\n break;\n case 'error':\n errors++;\n criticalIssues.push(`${workspace.name}: ${workspace.health.issues.join(', ')}`);\n break;\n }\n \n // Collect unique recommendations\n for (const rec of workspace.health.recommendations) {\n if (!recommendations.includes(rec)) {\n recommendations.push(rec);\n }\n }\n }\n \n return {\n healthy,\n warnings,\n errors,\n criticalIssues,\n recommendations\n };\n}\n\nasync function checkQdrantConsistency(sqlite: SQLiteStorage, config: Config): Promise<{ isConsistent: boolean; issues: string[] }> {\n const issues: string[] = [];\n \n try {\n const qdrant = new QdrantClient(config);\n const isHealthy = await qdrant.healthCheck();\n \n if (!isHealthy) {\n issues.push('Qdrant vector database is not running or accessible');\n return { isConsistent: false, issues };\n }\n \n const filesWithChunksStmt = sqlite.db.prepare('SELECT COUNT(*) as count FROM files WHERE chunks_json IS NOT NULL');\n const filesWithChunks = filesWithChunksStmt.get() as { count: number };\n \n const totalChunksStmt = sqlite.db.prepare('SELECT SUM(json_array_length(chunks_json)) as count FROM files WHERE chunks_json IS NOT NULL');\n const totalChunks = totalChunksStmt.get() as { count: number | null };\n \n if (filesWithChunks.count > 0 && (totalChunks.count || 0) === 0) {\n issues.push('Files exist but no chunks found - possible data corruption');\n }\n \n const collectionName = config.storage.qdrantCollection;\n try {\n const response = await fetch(`${config.storage.qdrantEndpoint}/collections/${collectionName}`);\n if (!response.ok) {\n issues.push(`Vector collection '${collectionName}' not found (normal during first-time setup)`);\n return { isConsistent: false, issues };\n }\n \n const collectionInfo = await response.json();\n const qdrantPointCount = collectionInfo.result?.points_count || 0;\n const sqliteChunkCount = totalChunks.count || 0;\n \n if (Math.abs(qdrantPointCount - sqliteChunkCount) > 0) {\n if (qdrantPointCount > sqliteChunkCount) {\n issues.push(`Extra vectors in database: ${qdrantPointCount} vectors vs ${sqliteChunkCount} indexed chunks (normal during cleanup)`);\n } else {\n issues.push(`Missing vectors: ${sqliteChunkCount} indexed chunks vs ${qdrantPointCount} vectors (normal during indexing)`);\n }\n }\n } catch (error) {\n issues.push(`Cannot verify vector database status: ${error}`);\n }\n \n } catch (error) {\n issues.push(`Database status check failed: ${error}`);\n }\n \n return {\n isConsistent: issues.length === 0,\n issues\n };\n}\n\nexport async function getIndexStatus(): Promise<IndexStatus> {\n const config = await import('./config.js').then(m => m.loadConfig());\n const sqlite = new SQLiteStorage(config);\n \n try {\n const directoriesStmt = sqlite.db.prepare('SELECT COUNT(*) as count FROM directories WHERE status = ?');\n const directoriesCount = directoriesStmt.get('completed') as { count: number };\n \n const filesStmt = sqlite.db.prepare('SELECT COUNT(*) as count FROM files');\n const filesCount = filesStmt.get() as { count: number };\n \n const chunksStmt = sqlite.db.prepare('SELECT SUM(json_array_length(chunks_json)) as count FROM files WHERE chunks_json IS NOT NULL');\n const chunksCount = chunksStmt.get() as { count: number | null };\n \n const lastIndexedStmt = sqlite.db.prepare('SELECT MAX(indexed_at) as last_indexed FROM directories WHERE indexed_at > 0');\n const lastIndexedResult = lastIndexedStmt.get() as { last_indexed: number | null };\n \n const errorsStmt = sqlite.db.prepare('SELECT errors_json FROM files WHERE errors_json IS NOT NULL');\n const errorRows = errorsStmt.all() as { errors_json: string }[];\n \n const allErrors: string[] = [];\n errorRows.forEach(row => {\n try {\n const errors = JSON.parse(row.errors_json);\n allErrors.push(...errors);\n } catch {\n allErrors.push('Failed to parse error JSON');\n }\n });\n \n const directoriesDetailStmt = sqlite.db.prepare(`\n SELECT \n d.path,\n d.status,\n d.indexed_at,\n (SELECT COUNT(*) FROM files f WHERE f.path LIKE d.path || '%') as files_count,\n (SELECT COALESCE(SUM(json_array_length(f.chunks_json)), 0) FROM files f WHERE f.path LIKE d.path || '%' AND f.chunks_json IS NOT NULL) as chunks_count\n FROM directories d\n ORDER BY d.indexed_at DESC\n `);\n const directoryDetails = directoriesDetailStmt.all() as { id: number; path: string; status: 'pending' | 'indexing' | 'completed' | 'failed'; indexed_at: number; files_count: number; chunks_count: number }[];\n \n const directories: DirectoryStatus[] = directoryDetails.map(row => {\n const errorsByDirStmt = sqlite.db.prepare(`\n SELECT errors_json FROM files \n WHERE path LIKE ? || '%' AND errors_json IS NOT NULL\n `);\n const dirErrors = errorsByDirStmt.all(row.path) as { errors_json: string }[];\n \n const dirErrorsList: string[] = [];\n dirErrors.forEach(errorRow => {\n try {\n const errors = JSON.parse(errorRow.errors_json);\n dirErrorsList.push(...errors);\n } catch {\n dirErrorsList.push('Failed to parse error JSON');\n }\n });\n \n return {\n path: row.path,\n status: row.status,\n filesCount: row.files_count,\n chunksCount: row.chunks_count,\n lastIndexed: row.indexed_at && row.indexed_at > 0 ? new Date(row.indexed_at).toISOString() : null,\n errors: dirErrorsList\n };\n });\n \n const qdrantConsistency = await checkQdrantConsistency(sqlite, config);\n const workspaces = await calculateWorkspaceStatistics(sqlite, config);\n \n // Calculate workspace health summary\n const workspaceHealth = calculateWorkspaceHealthSummary(workspaces);\n \n const fs = await import('fs');\n let databaseSize = '0 KB';\n try {\n const stats = fs.statSync(config.storage.sqlitePath);\n const sizeInBytes = stats.size;\n if (sizeInBytes > 1024 * 1024) {\n databaseSize = `${(sizeInBytes / (1024 * 1024)).toFixed(2)} MB`;\n } else if (sizeInBytes > 1024) {\n databaseSize = `${(sizeInBytes / 1024).toFixed(2)} KB`;\n } else {\n databaseSize = `${sizeInBytes} bytes`;\n }\n } catch {\n databaseSize = 'Unknown';\n }\n \n return {\n directoriesIndexed: directoriesCount.count,\n filesIndexed: filesCount.count,\n chunksIndexed: chunksCount.count || 0,\n databaseSize,\n lastIndexed: lastIndexedResult.last_indexed ? new Date(lastIndexedResult.last_indexed).toISOString() : null,\n errors: allErrors,\n directories,\n workspaces,\n workspaceHealth,\n qdrantConsistency\n };\n } finally {\n sqlite.close();\n }\n}"],"names":[],"mappings":";;;AAoCO,MAAM,qBAAqB,MAAM;AAAA,EACtC,YAAY,SAAiC,OAAe;AAC1D,UAAM,OAAO;AAD8B,SAAA,QAAA;AAE3C,SAAK,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