@zuvia-software-solutions/code-mapper 2.6.4 → 2.6.5

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.
@@ -440,3 +440,4 @@ export async function buildNlEmbeddings(db, onProgress) {
440
440
  }
441
441
  return { embedded, skipped, durationMs: Date.now() - t0 };
442
442
  }
443
+ // touch
@@ -311,6 +311,99 @@ export async function refreshFiles(db, repoPath, dirtyFiles) {
311
311
  }
312
312
  }
313
313
  // FTS5 auto-updates via triggers — no manual rebuild needed
314
+ // Phase 5: Rebuild graph-level analyses (communities, processes, interface dispatch)
315
+ // These are cheap (<300ms) but critical — stale communities/processes mislead agents.
316
+ // Load full graph from SQLite, re-run analyses, write results back.
317
+ try {
318
+ const { createKnowledgeGraph } = await import('../graph/graph.js');
319
+ const { processCommunities } = await import('../ingestion/community-processor.js');
320
+ const { processProcesses } = await import('../ingestion/process-processor.js');
321
+ const { insertNodesBatch, insertEdgesBatch } = await import('../db/adapter.js');
322
+ const { toNodeId, toEdgeId } = await import('../db/schema.js');
323
+ const graph = createKnowledgeGraph();
324
+ // Load all non-community/process nodes and edges into in-memory graph
325
+ const allNodes = db.prepare('SELECT * FROM nodes WHERE label NOT IN (\'Community\', \'Process\')').all();
326
+ const allEdges = db.prepare('SELECT * FROM edges WHERE type NOT IN (\'MEMBER_OF\', \'STEP_IN_PROCESS\')').all();
327
+ for (const row of allNodes) {
328
+ graph.addNode({
329
+ id: toNodeId(row.id),
330
+ label: row.label,
331
+ properties: {
332
+ name: row.name ?? '', filePath: row.filePath ?? '',
333
+ startLine: row.startLine ?? undefined, endLine: row.endLine ?? undefined,
334
+ isExported: Boolean(row.isExported),
335
+ description: row.description ?? undefined,
336
+ parameterCount: row.parameterCount ?? undefined,
337
+ returnType: row.returnType ?? undefined,
338
+ },
339
+ });
340
+ }
341
+ for (const row of allEdges) {
342
+ graph.addRelationship({
343
+ id: toEdgeId(row.id),
344
+ sourceId: toNodeId(row.sourceId),
345
+ targetId: toNodeId(row.targetId),
346
+ type: row.type,
347
+ confidence: row.confidence ?? 1.0,
348
+ reason: row.reason ?? '',
349
+ });
350
+ }
351
+ // Delete old community/process data from SQLite
352
+ db.exec('BEGIN');
353
+ db.prepare("DELETE FROM edges WHERE type IN ('MEMBER_OF', 'STEP_IN_PROCESS')").run();
354
+ db.prepare("DELETE FROM nodes WHERE label IN ('Community', 'Process')").run();
355
+ // Re-run community detection + process detection
356
+ const communityResult = await processCommunities(graph, () => { });
357
+ const processResult = await processProcesses(graph, communityResult.memberships, () => { });
358
+ // Write new community/process nodes + edges back to SQLite
359
+ const newNodes = [];
360
+ const newEdges = [];
361
+ for (const node of graph.iterNodes()) {
362
+ if (node.label === 'Community' || node.label === 'Process') {
363
+ newNodes.push({
364
+ id: node.id,
365
+ label: node.label,
366
+ name: node.properties.name ?? '',
367
+ filePath: node.properties.filePath ?? '',
368
+ heuristicLabel: node.properties.heuristicLabel ?? null,
369
+ cohesion: node.properties.cohesion ?? null,
370
+ symbolCount: node.properties.symbolCount ?? null,
371
+ keywords: Array.isArray(node.properties.keywords) ? node.properties.keywords.join(', ') : node.properties.keywords ?? null,
372
+ processType: node.properties.processType ?? null,
373
+ stepCount: node.properties.stepCount ?? null,
374
+ communities: node.properties.communities ?? null,
375
+ entryPointId: node.properties.entryPointId ?? null,
376
+ terminalId: node.properties.terminalId ?? null,
377
+ });
378
+ }
379
+ }
380
+ for (const rel of graph.iterRelationships()) {
381
+ if (rel.type === 'MEMBER_OF' || rel.type === 'STEP_IN_PROCESS') {
382
+ newEdges.push({
383
+ id: rel.id,
384
+ sourceId: rel.sourceId,
385
+ targetId: rel.targetId,
386
+ type: rel.type,
387
+ confidence: rel.confidence,
388
+ reason: rel.reason,
389
+ step: rel.step,
390
+ });
391
+ }
392
+ }
393
+ if (newNodes.length > 0)
394
+ insertNodesBatch(db, newNodes);
395
+ if (newEdges.length > 0)
396
+ insertEdgesBatch(db, newEdges);
397
+ db.exec('COMMIT');
398
+ console.error(`Code Mapper: refresh Phase 5 — ${communityResult.communities.length} communities, ${processResult.stats.totalProcesses} processes rebuilt`);
399
+ }
400
+ catch (err) {
401
+ try {
402
+ db.exec('ROLLBACK');
403
+ }
404
+ catch { }
405
+ console.error(`Code Mapper: Phase 5 graph rebuild failed: ${err instanceof Error ? err.message : err}`);
406
+ }
314
407
  return {
315
408
  filesProcessed: filesToProcess.length, filesSkipped,
316
409
  nodesDeleted, nodesInserted, edgesInserted,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuvia-software-solutions/code-mapper",
3
- "version": "2.6.4",
3
+ "version": "2.6.5",
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",