gitnexus 1.6.6-rc.86 → 1.6.6-rc.87

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.
@@ -101,9 +101,26 @@ export const processCobol = (graph, files, allPathSet) => {
101
101
  const entry = copybookMap.get(name.toUpperCase());
102
102
  return entry ? entry.path : null;
103
103
  };
104
+ // Memoize preprocessed copybook content for the duration of this
105
+ // processCobol call. A single copybook is COPYed by many programs (and at
106
+ // many COPY sites within a program); without this cache
107
+ // preprocessCobolSource would re-run once per COPY site —
108
+ // O(programs × copybooks) preprocessing passes over the same content.
109
+ // Keyed by the resolved copybook path. REPLACING is applied later by the
110
+ // expander on the returned (pre-REPLACING) content (see
111
+ // cobol-copy-expander.ts readFile→applyReplacing), so caching the
112
+ // pre-REPLACING preprocessed text here is safe and per-call-scoped.
113
+ const preprocessedCopyCache = new Map();
104
114
  const readCopy = (copyPath) => {
115
+ const cached = preprocessedCopyCache.get(copyPath);
116
+ if (cached !== undefined)
117
+ return cached;
105
118
  const content = copybookByPath.get(copyPath);
106
- return content ? preprocessCobolSource(content) : null;
119
+ if (!content)
120
+ return null; // preserves original falsy→null (missing/empty)
121
+ const preprocessed = preprocessCobolSource(content);
122
+ preprocessedCopyCache.set(copyPath, preprocessed);
123
+ return preprocessed;
107
124
  };
108
125
  // Track module names for cross-program CALL resolution
109
126
  const moduleNodeIds = new Map(); // uppercase program name -> node id
@@ -59,7 +59,7 @@ export function emitCobolScopeCaptures(sourceText, _filePath, _cachedTree) {
59
59
  ? rangeOf(progIdLine, 7, progIdLine, lines[progIdLine - 1]?.length ?? endCol)
60
60
  : rangeOf(startLine, startCol, endLine, endCol);
61
61
  const grouped = {
62
- '@scope.module': capture('@scope.module', nameRange, name),
62
+ '@scope.module': capture('@scope.module', rangeOf(startLine, startCol, endLine, endCol), name),
63
63
  '@declaration.program': capture('@declaration.program', rangeOf(startLine, startCol, endLine, endCol), name),
64
64
  '@declaration.name': capture('@declaration.name', nameRange, name),
65
65
  };
@@ -83,7 +83,7 @@ export function emitCobolScopeCaptures(sourceText, _filePath, _cachedTree) {
83
83
  ? rangeOf(progIdLine, 7, progIdLine, lines[progIdLine - 1]?.length ?? endCol)
84
84
  : rangeOf(startLine, startCol, endLine, endCol);
85
85
  const grouped = {
86
- '@scope.module': capture('@scope.module', nameRange, prog.name),
86
+ '@scope.module': capture('@scope.module', rangeOf(startLine, startCol, endLine, endCol), prog.name),
87
87
  '@declaration.program': capture('@declaration.program', rangeOf(startLine, startCol, endLine, endCol), prog.name),
88
88
  '@declaration.name': capture('@declaration.name', nameRange, prog.name),
89
89
  };
@@ -79,6 +79,7 @@ export const MIGRATED_LANGUAGES = new Set([
79
79
  SupportedLanguages.Java,
80
80
  SupportedLanguages.Rust,
81
81
  SupportedLanguages.Ruby,
82
+ SupportedLanguages.Cobol,
82
83
  ]);
83
84
  /**
84
85
  * Return the env-var name that controls a given language's registry-
@@ -81,6 +81,20 @@ export const scopeResolutionPhase = {
81
81
  for (const pf of workerParsedFiles) {
82
82
  preExtractedByPath.set(pf.filePath, pf);
83
83
  }
84
+ // Drop pre-extracted entries for standalone providers — these
85
+ // languages are skipped by the canonical guard below (line 164)
86
+ // and never consume preExtractedByPath, so holding onto their
87
+ // entries leaks memory until the cleanup loop at 262-264 which
88
+ // also never runs for skipped providers.
89
+ for (const [path] of preExtractedByPath) {
90
+ const lang = getLanguageFromFilename(path);
91
+ if (lang === null)
92
+ continue;
93
+ const provider = SCOPE_RESOLVERS.get(lang);
94
+ if (provider?.languageProvider.parseStrategy === 'standalone') {
95
+ preExtractedByPath.delete(path);
96
+ }
97
+ }
84
98
  let totalFiles = 0;
85
99
  let totalImports = 0;
86
100
  let totalRefs = 0;
@@ -114,6 +128,14 @@ export const scopeResolutionPhase = {
114
128
  for (const [lang, provider] of SCOPE_RESOLVERS) {
115
129
  if (!isRegistryPrimary(lang))
116
130
  continue;
131
+ // Standalone providers (COBOL, JCL) don't emit graph edges yet
132
+ // through the scope-resolution path. This is the canonical guard:
133
+ // runScopeResolution is never called for standalone providers, which
134
+ // keeps cobolPhase as the sole IMPORTS edge producer. Keep this guard
135
+ // in sync with any additional standalone providers added to
136
+ // SCOPE_RESOLVERS.
137
+ if (provider.languageProvider.parseStrategy === 'standalone')
138
+ continue;
117
139
  const langFiles = scannedFiles.filter((f) => getLanguageFromFilename(f.path) === lang);
118
140
  if (langFiles.length === 0)
119
141
  continue;
@@ -473,9 +473,29 @@ const processBatch = (files, onProgress) => {
473
473
  for (const [language, langFiles] of byLanguage) {
474
474
  const provider = getProvider(language);
475
475
  const queryString = provider.treeSitterQueries;
476
- if (!queryString)
476
+ if (!queryString) {
477
+ // Standalone providers (regex-based, no tree-sitter) that implement
478
+ // emitScopeCaptures feed into the scope-resolution pipeline via
479
+ // extractParsedFile directly — no tree-sitter involved.
480
+ if (provider.emitScopeCaptures) {
481
+ for (const file of langFiles) {
482
+ const parsedFile = extractParsedFile(provider, file.content, file.path, (message) => {
483
+ if (parentPort) {
484
+ parentPort.postMessage({ type: 'warning', message });
485
+ }
486
+ else {
487
+ logger.warn(message);
488
+ }
489
+ }, undefined);
490
+ if (parsedFile !== undefined) {
491
+ result.parsedFiles.push(parsedFile);
492
+ result.fileCount++;
493
+ onFileProcessed?.();
494
+ }
495
+ }
496
+ }
477
497
  continue;
478
- // Track if we need to handle tsx separately
498
+ }
479
499
  const tsxFiles = [];
480
500
  const regularFiles = [];
481
501
  if (language === SupportedLanguages.TypeScript) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.6-rc.86",
3
+ "version": "1.6.6-rc.87",
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",