@comfanion/usethis_search 3.0.0-dev.18 → 3.0.0-dev.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comfanion/usethis_search",
3
- "version": "3.0.0-dev.18",
3
+ "version": "3.0.0-dev.19",
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",
@@ -90,13 +90,15 @@ const DEFAULT_GRAPH_CONFIG = {
90
90
  enabled: true,
91
91
  max_related: 4,
92
92
  min_relevance: 0.5,
93
+ semantic_edges: false, // O(n²) post-pass — disabled by default (slow on large repos)
94
+ semantic_edges_max_chunks: 500, // Skip semantic edges if chunk count exceeds this
93
95
  lsp: {
94
96
  enabled: true,
95
97
  timeout_ms: 5000,
96
98
  },
97
99
  read_intercept: true,
98
100
  };
99
- let GRAPH_CONFIG = { ...DEFAULT_GRAPH_CONFIG, lsp: { ...DEFAULT_GRAPH_CONFIG.lsp } };
101
+ let GRAPH_CONFIG = { ...DEFAULT_GRAPH_CONFIG, lsp: { ...DEFAULT_GRAPH_CONFIG.lsp } } as typeof DEFAULT_GRAPH_CONFIG;
100
102
 
101
103
  function defaultVectorizerYaml() {
102
104
  return (
@@ -139,6 +141,8 @@ function defaultVectorizerYaml() {
139
141
  ` enabled: true\n` +
140
142
  ` max_related: 4\n` +
141
143
  ` min_relevance: 0.5\n` +
144
+ ` semantic_edges: false # O(n²) post-pass — enable only for small repos\n` +
145
+ ` semantic_edges_max_chunks: 500 # Skip if chunk count exceeds this\n` +
142
146
  ` lsp:\n` +
143
147
  ` enabled: true\n` +
144
148
  ` timeout_ms: 5000\n` +
@@ -312,6 +316,8 @@ async function loadConfig(projectRoot) {
312
316
  GRAPH_CONFIG.enabled = parseBool(gs, "enabled", DEFAULT_GRAPH_CONFIG.enabled);
313
317
  GRAPH_CONFIG.max_related = parseNumber(gs, "max_related", DEFAULT_GRAPH_CONFIG.max_related);
314
318
  GRAPH_CONFIG.min_relevance = parseNumber(gs, "min_relevance", DEFAULT_GRAPH_CONFIG.min_relevance);
319
+ GRAPH_CONFIG.semantic_edges = parseBool(gs, "semantic_edges", DEFAULT_GRAPH_CONFIG.semantic_edges);
320
+ GRAPH_CONFIG.semantic_edges_max_chunks = parseNumber(gs, "semantic_edges_max_chunks", DEFAULT_GRAPH_CONFIG.semantic_edges_max_chunks);
315
321
  GRAPH_CONFIG.read_intercept = parseBool(gs, "read_intercept", DEFAULT_GRAPH_CONFIG.read_intercept);
316
322
 
317
323
  // Nested lsp: section
@@ -1093,9 +1099,9 @@ class CodebaseIndexer {
1093
1099
  }
1094
1100
 
1095
1101
  // FR-005: Build semantic similarity edges as post-pass
1096
- // Only if we actually indexed new files and have a graph builder
1102
+ // Disabled by default (O(n²) slow on large repos). Enable via graph.semantic_edges: true
1097
1103
  let semanticEdges = 0;
1098
- if (indexed > 0 && this.graphBuilder && this.graphDB) {
1104
+ if (indexed > 0 && this.graphBuilder && this.graphDB && GRAPH_CONFIG.semantic_edges) {
1099
1105
  try {
1100
1106
  const tableName = "chunks";
1101
1107
  const tables = await this.db.tableNames();
@@ -1105,8 +1111,15 @@ class CodebaseIndexer {
1105
1111
  const chunkData = allRows
1106
1112
  .filter(r => r.chunk_id && r.vector)
1107
1113
  .map(r => ({ chunk_id: r.chunk_id, vector: Array.from(r.vector), file: r.file }));
1108
- semanticEdges = await this.graphBuilder.buildSemanticEdges(chunkData, 0.8, 3);
1109
- if (DEBUG) console.log(`[vectorizer] Built ${semanticEdges} semantic similarity edges`);
1114
+
1115
+ // Skip if too many chunks O(n²) becomes prohibitive
1116
+ const maxChunks = GRAPH_CONFIG.semantic_edges_max_chunks ?? 500;
1117
+ if (chunkData.length > maxChunks) {
1118
+ if (DEBUG) console.log(`[vectorizer] Skipping semantic edges: ${chunkData.length} chunks > max ${maxChunks}`);
1119
+ } else {
1120
+ semanticEdges = await this.graphBuilder.buildSemanticEdges(chunkData, 0.8, 3);
1121
+ if (DEBUG) console.log(`[vectorizer] Built ${semanticEdges} semantic similarity edges`);
1122
+ }
1110
1123
  }
1111
1124
  } catch (e) {
1112
1125
  if (DEBUG) console.log(`[vectorizer] Semantic edge building failed:`, e.message);
package/vectorizer.yaml CHANGED
@@ -44,6 +44,8 @@ vectorizer:
44
44
  enabled: true
45
45
  max_related: 4 # How many related chunks to attach
46
46
  min_relevance: 0.5 # Minimum score threshold for related context
47
+ semantic_edges: false # O(n²) post-pass — enable only for small repos (<500 chunks)
48
+ semantic_edges_max_chunks: 500 # Skip semantic edges if chunk count exceeds this
47
49
 
48
50
  # LSP for code analysis
49
51
  lsp: