@zuvia-software-solutions/code-mapper 2.2.1 → 2.2.2
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.
|
@@ -115,18 +115,29 @@ export function fetchGraphContext(db, nodes) {
|
|
|
115
115
|
* @returns Enriched text
|
|
116
116
|
*/
|
|
117
117
|
export function enrichTextWithGraphContext(text, ctx) {
|
|
118
|
-
|
|
119
|
-
if (ctx.module)
|
|
120
|
-
parts.push(`Module: ${ctx.module}`);
|
|
121
|
-
if (ctx.callers.length > 0)
|
|
122
|
-
parts.push(`Called by: ${ctx.callers.join(', ')}`);
|
|
123
|
-
if (ctx.callees.length > 0)
|
|
124
|
-
parts.push(`Calls: ${ctx.callees.join(', ')}`);
|
|
125
|
-
if (parts.length === 0)
|
|
118
|
+
if (!ctx.module && ctx.callers.length === 0 && ctx.callees.length === 0)
|
|
126
119
|
return text;
|
|
127
120
|
const lines = text.split('\n');
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
// Append Module to the File: line (matches Python batch format)
|
|
122
|
+
if (ctx.module) {
|
|
123
|
+
const fileIdx = lines.findIndex(l => l.startsWith('File: '));
|
|
124
|
+
if (fileIdx >= 0) {
|
|
125
|
+
lines[fileIdx] += ` | Module: ${ctx.module}`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Insert callers/callees after the File: line
|
|
129
|
+
const insertParts = [];
|
|
130
|
+
if (ctx.callers.length > 0)
|
|
131
|
+
insertParts.push(`Called by: ${ctx.callers.join(', ')}`);
|
|
132
|
+
if (ctx.callees.length > 0)
|
|
133
|
+
insertParts.push(`Calls: ${ctx.callees.join(', ')}`);
|
|
134
|
+
if (insertParts.length > 0) {
|
|
135
|
+
const fileIdx = lines.findIndex(l => l.startsWith('File: '));
|
|
136
|
+
const insertAt = fileIdx >= 0 ? fileIdx + 1 : lines.findIndex(l => l === '') || 2;
|
|
137
|
+
for (let i = insertParts.length - 1; i >= 0; i--) {
|
|
138
|
+
lines.splice(insertAt, 0, insertParts[i] ?? '');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
130
141
|
return lines.join('\n');
|
|
131
142
|
}
|
|
132
143
|
/**
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* The graph context enrichment (callers, callees, module) is applied
|
|
11
11
|
* separately by the embedding pipeline — this module handles the per-node text.
|
|
12
12
|
*/
|
|
13
|
+
import { expandIdentifier } from '../db/adapter.js';
|
|
13
14
|
/** Extract filename from a file path */
|
|
14
15
|
const getFileName = (filePath) => {
|
|
15
16
|
const parts = filePath.split('/');
|
|
@@ -143,8 +144,12 @@ function extractSignature(content, label) {
|
|
|
143
144
|
export const generateEmbeddingText = (node, _config = {}) => {
|
|
144
145
|
const label = node.label;
|
|
145
146
|
const parts = [];
|
|
146
|
-
// 1. Type + name
|
|
147
|
+
// 1. Type + name + expanded name for natural language bridge
|
|
147
148
|
parts.push(`${label}: ${node.name}`);
|
|
149
|
+
const expanded = expandIdentifier(node.name);
|
|
150
|
+
if (expanded && expanded !== node.name.toLowerCase()) {
|
|
151
|
+
parts.push(expanded);
|
|
152
|
+
}
|
|
148
153
|
// 2. First comment as natural language description
|
|
149
154
|
const comment = extractFirstComment(node.content);
|
|
150
155
|
if (comment)
|
|
@@ -6,8 +6,8 @@ import fs from 'node:fs';
|
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
// Max files per postMessage to keep structured-clone memory bounded
|
|
8
8
|
const SUB_BATCH_SIZE = 1500;
|
|
9
|
-
// Per sub-batch timeout
|
|
10
|
-
const SUB_BATCH_TIMEOUT_MS =
|
|
9
|
+
// Per sub-batch timeout — large codebases with big files need more time
|
|
10
|
+
const SUB_BATCH_TIMEOUT_MS = 120_000;
|
|
11
11
|
/** Create a pool of worker threads */
|
|
12
12
|
export const createWorkerPool = (workerUrl, poolSize) => {
|
|
13
13
|
// Validate worker script exists before spawning to prevent MODULE_NOT_FOUND crashes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuvia-software-solutions/code-mapper",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
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",
|