ucn 3.7.41 → 3.7.42

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.
Files changed (2) hide show
  1. package/core/project.js +26 -0
  2. package/package.json +1 -1
package/core/project.js CHANGED
@@ -1018,12 +1018,38 @@ class ProjectIndex {
1018
1018
  // Try AST-based detection first (with per-operation cache)
1019
1019
  const astUsages = this._getCachedUsages(filePath, name);
1020
1020
  if (astUsages !== null) {
1021
+ // Pre-compute: does any imported project file define this name?
1022
+ // Used to filter namespace member expressions (e.g., DropdownMenuPrimitive.Separator)
1023
+ // while keeping module access patterns (e.g., output.formatExample())
1024
+ let _importedHasDef = null;
1025
+ const importedFileHasDef = () => {
1026
+ if (_importedHasDef !== null) return _importedHasDef;
1027
+ const importedFiles = this.importGraph.get(filePath) || [];
1028
+ _importedHasDef = importedFiles.some(imp => {
1029
+ const impEntry = this.files.get(imp);
1030
+ return impEntry?.symbols?.some(s => s.name === name);
1031
+ });
1032
+ return _importedHasDef;
1033
+ };
1034
+
1021
1035
  for (const u of astUsages) {
1022
1036
  // Skip if this is a definition line (already added above)
1023
1037
  if (definitions.some(d => d.file === filePath && d.startLine === u.line)) {
1024
1038
  continue;
1025
1039
  }
1026
1040
 
1041
+ // Filter member expressions with unrelated receivers in JS/TS/Python.
1042
+ // Keeps: standalone usages, self/this/cls/super, method calls on known types,
1043
+ // and module access (output.fn()) when the imported file defines the name.
1044
+ // Filters: namespace access to external packages (DropdownMenuPrimitive.Separator).
1045
+ if (u.receiver && !['self', 'this', 'cls', 'super'].includes(u.receiver) &&
1046
+ fileEntry.language !== 'go' && fileEntry.language !== 'java' && fileEntry.language !== 'rust') {
1047
+ const hasMethodDef = allDefinitions.some(d => d.className);
1048
+ if (!hasMethodDef && !importedFileHasDef()) {
1049
+ continue;
1050
+ }
1051
+ }
1052
+
1027
1053
  const lineContent = lines[u.line - 1] || '';
1028
1054
 
1029
1055
  const usage = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ucn",
3
- "version": "3.7.41",
3
+ "version": "3.7.42",
4
4
  "mcpName": "io.github.mleoca/ucn",
5
5
  "description": "Universal Code Navigator — AST-based call graph analysis for AI agents. Find callers, trace impact, detect dead code across JS/TS, Python, Go, Rust, Java, and HTML. CLI, MCP server, and agent skill.",
6
6
  "main": "index.js",