@comfanion/usethis_search 3.0.0-dev.6 → 3.0.0-dev.8
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/api.ts +2 -2
- package/index.ts +6 -0
- package/package.json +1 -1
- package/tools/codeindex.ts +22 -5
package/api.ts
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import { GraphDB } from "./vectorizer/graph-db"
|
|
9
9
|
|
|
10
|
-
// Global GraphDB instance (shared across
|
|
10
|
+
// Global GraphDB instance (shared across plugins)
|
|
11
11
|
let graphDBInstance: GraphDB | null = null
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Initialize
|
|
14
|
+
* Initialize API with GraphDB instance
|
|
15
15
|
*/
|
|
16
16
|
export function initGraphAPI(db: GraphDB): void {
|
|
17
17
|
graphDBInstance = db
|
package/index.ts
CHANGED
|
@@ -4,6 +4,12 @@ import search from "./tools/search"
|
|
|
4
4
|
import codeindex from "./tools/codeindex"
|
|
5
5
|
import FileIndexerPlugin from "./file-indexer"
|
|
6
6
|
|
|
7
|
+
// Export API for plugin-to-plugin communication
|
|
8
|
+
export * from "./api"
|
|
9
|
+
|
|
10
|
+
// Export CodebaseIndexer for other plugins (e.g., mind)
|
|
11
|
+
export { CodebaseIndexer } from "./vectorizer/index.js"
|
|
12
|
+
|
|
7
13
|
const UsethisSearchPlugin: Plugin = async ({ directory, client }) => {
|
|
8
14
|
// Start file indexer (background indexing + event handling)
|
|
9
15
|
let fileIndexerEvent: ((args: any) => Promise<void>) | null = null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comfanion/usethis_search",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.8",
|
|
4
4
|
"description": "OpenCode plugin: semantic search with graph-based context (v3: graph relations, 1-hop context, LSP + regex analyzers)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
package/tools/codeindex.ts
CHANGED
|
@@ -313,16 +313,27 @@ Available indexes:
|
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
// 1. Get all triples from graph
|
|
316
|
-
|
|
316
|
+
let allTriples: any[] = []
|
|
317
|
+
try {
|
|
318
|
+
allTriples = await graphDB.getAllTriples()
|
|
319
|
+
} catch (e: any) {
|
|
320
|
+
await indexer.unloadModel()
|
|
321
|
+
return `## Graph Validation: "${indexName}"\n\n**Error:** Failed to read graph database: ${e.message || String(e)}\n\nThe graph database may be corrupted. Run: codeindex({ action: "reindex", index: "${indexName}" })`
|
|
322
|
+
}
|
|
317
323
|
|
|
318
324
|
// 2. Get all chunk IDs from vector DB
|
|
319
325
|
const knownChunkIds = new Set<string>()
|
|
320
326
|
const tables = await db.tableNames()
|
|
321
327
|
if (tables.includes("chunks")) {
|
|
322
328
|
const table = await db.openTable("chunks")
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
329
|
+
try {
|
|
330
|
+
const rows = await table.search([0]).limit(100000).execute()
|
|
331
|
+
for (const row of rows) {
|
|
332
|
+
if (row.chunk_id) knownChunkIds.add(row.chunk_id)
|
|
333
|
+
}
|
|
334
|
+
} catch (e: any) {
|
|
335
|
+
await indexer.unloadModel()
|
|
336
|
+
return `## Graph Validation: "${indexName}"\n\n**Error:** Failed to read vector database: ${e.message || String(e)}\n\nThe vector database may be corrupted. Run: codeindex({ action: "reindex", index: "${indexName}" })`
|
|
326
337
|
}
|
|
327
338
|
}
|
|
328
339
|
|
|
@@ -357,7 +368,13 @@ Available indexes:
|
|
|
357
368
|
}
|
|
358
369
|
|
|
359
370
|
// 4. Get file metadata stats
|
|
360
|
-
|
|
371
|
+
let fileMeta: Array<{ filePath: string; hash: string; timestamp: number }> = []
|
|
372
|
+
try {
|
|
373
|
+
fileMeta = await graphDB.getAllFileMeta()
|
|
374
|
+
} catch (e: any) {
|
|
375
|
+
// Non-fatal - continue validation without metadata
|
|
376
|
+
console.warn(`Warning: Failed to get file metadata: ${e.message || String(e)}`)
|
|
377
|
+
}
|
|
361
378
|
|
|
362
379
|
await indexer.unloadModel()
|
|
363
380
|
|