code-graph-context 2.12.7 → 2.12.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/README.md CHANGED
@@ -190,7 +190,7 @@ If you prefer to edit the config files directly:
190
190
  | `NEO4J_USER` | No | `neo4j` | Neo4j username |
191
191
  | `NEO4J_PASSWORD` | No | `PASSWORD` | Neo4j password |
192
192
  | `EMBEDDING_MODEL` | No | `codesage/codesage-base-v2` | Local embedding model (see [Embedding Configuration](#embedding-configuration)) |
193
- | `EMBEDDING_BATCH_SIZE` | No | `16` | Texts per embedding batch (lower = less memory, higher = faster) |
193
+ | `EMBEDDING_BATCH_SIZE` | No | `8` | Texts per embedding batch (lower = less memory, higher = faster) |
194
194
  | `EMBEDDING_SIDECAR_PORT` | No | `8787` | Port for local embedding server |
195
195
  | `EMBEDDING_DEVICE` | No | auto (`mps`/`cpu`) | Device for embeddings. Auto-detects MPS on Apple Silicon |
196
196
  | `EMBEDDING_HALF_PRECISION` | No | `false` | Set `true` for float16 (uses ~0.5x memory) |
@@ -175,7 +175,9 @@ export class EmbeddingSidecar {
175
175
  }
176
176
  return false;
177
177
  }
178
- catch {
178
+ catch (err) {
179
+ const msg = err instanceof Error ? err.message : String(err);
180
+ console.error(`[embedding-sidecar] Health check failed: ${msg}`);
179
181
  return false;
180
182
  }
181
183
  }
@@ -186,6 +188,7 @@ export class EmbeddingSidecar {
186
188
  await this.start();
187
189
  const controller = new AbortController();
188
190
  const timeout = setTimeout(() => controller.abort(), this.config.requestTimeoutMs);
191
+ const startTime = Date.now();
189
192
  try {
190
193
  const res = await fetch(`${this.baseUrl}/embed`, {
191
194
  method: 'POST',
@@ -202,21 +205,24 @@ export class EmbeddingSidecar {
202
205
  console.error('[embedding-sidecar] OOM detected, restarting sidecar to reclaim GPU memory');
203
206
  await this.stop();
204
207
  }
208
+ console.error(`[embedding-sidecar] Embed failed after ${Date.now() - startTime}ms: status=${res.status}, texts=${texts.length}, oom=${isOOM}, detail=${detail}`);
205
209
  throw new Error(`Sidecar embed failed (${res.status}): ${detail}`);
206
210
  }
207
211
  const data = (await res.json());
208
212
  if (data.dimensions)
209
213
  this._dimensions = data.dimensions;
214
+ console.error(`[embedding-sidecar] Embedded ${texts.length} texts in ${Date.now() - startTime}ms (dims=${data.dimensions})`);
210
215
  this.resetIdleTimer();
211
216
  return data.embeddings;
212
217
  }
213
218
  catch (err) {
214
219
  if (err instanceof Error && err.name === 'AbortError') {
215
- // Timeout likely means the sidecar is stuck kill it
216
- console.error('[embedding-sidecar] Request timed out, restarting sidecar');
220
+ console.error(`[embedding-sidecar] Request timed out after ${Date.now() - startTime}ms (limit=${this.config.requestTimeoutMs}ms, texts=${texts.length}), restarting sidecar`);
217
221
  await this.stop();
218
222
  throw new Error(`Embedding request timed out after ${this.config.requestTimeoutMs}ms`);
219
223
  }
224
+ const msg = err instanceof Error ? err.message : String(err);
225
+ console.error(`[embedding-sidecar] Embed error after ${Date.now() - startTime}ms: ${msg} (url=${this.baseUrl}, running=${this.isRunning}, texts=${texts.length})`);
220
226
  throw err;
221
227
  }
222
228
  finally {
@@ -6,7 +6,7 @@
6
6
  import { debugLog } from '../../mcp/utils.js';
7
7
  import { getEmbeddingSidecar } from './embedding-sidecar.js';
8
8
  const BATCH_CONFIG = {
9
- maxBatchSize: parseInt(process.env.EMBEDDING_BATCH_SIZE ?? '', 10) || 16,
9
+ maxBatchSize: parseInt(process.env.EMBEDDING_BATCH_SIZE ?? '', 10) || 8,
10
10
  };
11
11
  export class LocalEmbeddingsService {
12
12
  async embedText(text) {
@@ -42,7 +42,7 @@ export class LocalEmbeddingsService {
42
42
  }
43
43
  catch (error) {
44
44
  const msg = error instanceof Error ? error.message : String(error);
45
- console.error(`[embedding] Batch ${batchIndex}/${totalBatches} FAILED: ${msg}`);
45
+ console.error(`[embedding] Batch ${batchIndex}/${totalBatches} FAILED (${batch.length} texts, batchSize=${safeBatchSize}): ${msg}`);
46
46
  throw error;
47
47
  }
48
48
  }
@@ -132,8 +132,9 @@ export class GraphGeneratorHandler {
132
132
  // Batch embed all texts that need it
133
133
  if (nodesNeedingEmbedding.length > 0) {
134
134
  const texts = nodesNeedingEmbedding.map((n) => n.text);
135
- const totalBatches = Math.ceil(texts.length / EMBEDDING_BATCH_CONFIG.maxBatchSize);
136
- console.error(`[embedding] Starting ${texts.length} texts in ${totalBatches} batches (batch_size=${EMBEDDING_BATCH_CONFIG.maxBatchSize})`);
135
+ const effectiveBatchSize = parseInt(process.env.EMBEDDING_BATCH_SIZE ?? '', 10) || EMBEDDING_BATCH_CONFIG.maxBatchSize;
136
+ const totalBatches = Math.ceil(texts.length / effectiveBatchSize);
137
+ console.error(`[embedding] Starting ${texts.length} texts in ~${totalBatches} batches (effective_batch_size=${effectiveBatchSize}, config_max=${EMBEDDING_BATCH_CONFIG.maxBatchSize})`);
137
138
  try {
138
139
  const embeddings = await this.embeddingsService.embedTextsInBatches(texts, EMBEDDING_BATCH_CONFIG.maxBatchSize);
139
140
  // Map embeddings back to their nodes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-graph-context",
3
- "version": "2.12.7",
3
+ "version": "2.12.8",
4
4
  "description": "MCP server that builds code graphs to provide rich context to LLMs",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/drewdrewH/code-graph-context#readme",