@zuvia-software-solutions/code-mapper 2.0.2 → 2.1.0

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.
@@ -159,24 +159,34 @@ export const embedBatch = async (texts) => {
159
159
  return [];
160
160
  if (!ready)
161
161
  await initEmbedder();
162
- // Send all texts to Python in one call — Python does optimal length-tiered
163
- // batching internally for Metal GPU. No need to double-batch at the Node level.
164
- console.error(`Code Mapper: embedBatch sending ${texts.length} texts to MLX...`);
162
+ // Batch at Node level to keep stdin/stdout JSON messages manageable.
163
+ // Python does internal length-tiered batching within each chunk.
164
+ // 500 texts per chunk balances IPC overhead vs pipe buffer limits.
165
+ const CHUNK_SIZE = 500;
166
+ const allResults = [];
167
+ const totalChunks = Math.ceil(texts.length / CHUNK_SIZE);
165
168
  const t0 = Date.now();
166
- const result = await sendAndReceive({
167
- texts,
168
- task: 'nl2code',
169
- type: 'passage',
170
- dims: DEFAULT_EMBEDDING_CONFIG.dimensions,
171
- });
172
- if (result.error)
173
- throw new Error(`Batch embedding failed: ${result.error}`);
174
- if (!result.embeddings || !Array.isArray(result.embeddings)) {
175
- throw new Error(`Batch embedding returned invalid response: ${JSON.stringify(result).slice(0, 200)}`);
169
+ console.error(`Code Mapper: embedBatch ${texts.length} texts in ${totalChunks} chunk(s)...`);
170
+ for (let i = 0; i < texts.length; i += CHUNK_SIZE) {
171
+ const chunk = texts.slice(i, i + CHUNK_SIZE);
172
+ const result = await sendAndReceive({
173
+ texts: chunk,
174
+ task: 'nl2code',
175
+ type: 'passage',
176
+ dims: DEFAULT_EMBEDDING_CONFIG.dimensions,
177
+ });
178
+ if (result.error)
179
+ throw new Error(`Batch embedding failed: ${result.error}`);
180
+ if (!result.embeddings || !Array.isArray(result.embeddings)) {
181
+ throw new Error(`Batch embedding returned invalid response: ${JSON.stringify(result).slice(0, 200)}`);
182
+ }
183
+ for (const e of result.embeddings) {
184
+ allResults.push(new Float32Array(e));
185
+ }
176
186
  }
177
187
  const elapsed = Date.now() - t0;
178
- console.error(`Code Mapper: embedBatch complete — ${result.embeddings.length} embeddings in ${elapsed}ms (${result.ms ?? '?'}ms inference)`);
179
- return result.embeddings.map((e) => new Float32Array(e));
188
+ console.error(`Code Mapper: embedBatch complete — ${allResults.length} embeddings in ${elapsed}ms`);
189
+ return allResults;
180
190
  };
181
191
  /**
182
192
  * Embed a query text for semantic search (cached, uses "query" prompt type)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuvia-software-solutions/code-mapper",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",