open-codebase-index 0.22.4 → 0.22.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.
@@ -10,7 +10,7 @@
10
10
  "name": "codebase-index",
11
11
  "description": "Semantic code search and codebase graph tools for Claude Code",
12
12
  "source": "./",
13
- "version": "0.22.4"
13
+ "version": "0.22.5"
14
14
  }
15
15
  ]
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-index",
3
- "version": "0.22.4",
3
+ "version": "0.22.5",
4
4
  "description": "Semantic code search and codebase graph tools for Claude Code",
5
5
  "displayName": "Codebase Index",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebase-index",
3
- "version": "0.22.4",
3
+ "version": "0.22.5",
4
4
  "description": "Semantic code search and codebase graph tools for Codex",
5
5
  "author": {
6
6
  "name": "Kenneth",
package/dist/cli.cjs CHANGED
@@ -7067,6 +7067,29 @@ function extractPrimaryIdentifierQueryHint(query) {
7067
7067
  const best = codeTerms.find((term) => term.length >= 6);
7068
7068
  return best ?? null;
7069
7069
  }
7070
+ function pathSegmentsForAffinityMatch(filePath) {
7071
+ const normalizedPath3 = normalizeRankingText(filePath).replace(/\\/g, "/");
7072
+ const segments = normalizedPath3.split("/").filter((segment) => segment.length > 0);
7073
+ if (segments.length === 0) {
7074
+ return [];
7075
+ }
7076
+ const basename8 = segments[segments.length - 1] ?? "";
7077
+ const basenameWithoutExt = basename8.replace(/\.[^/.]+$/u, "");
7078
+ const normalizedSegments = segments.map((segment) => segment.toLowerCase());
7079
+ return Array.from(/* @__PURE__ */ new Set([
7080
+ ...normalizedSegments,
7081
+ basenameWithoutExt.toLowerCase()
7082
+ ]));
7083
+ }
7084
+ function hasModuleAffinity(filePath, exactIdentifierVariants) {
7085
+ const haystack = pathSegmentsForAffinityMatch(filePath);
7086
+ return exactIdentifierVariants.some((variant) => {
7087
+ if (!variant || variant.length < 2) {
7088
+ return false;
7089
+ }
7090
+ return haystack.includes(variant);
7091
+ });
7092
+ }
7070
7093
  var FILE_PATH_HINT_EXTENSIONS = [
7071
7094
  "ts",
7072
7095
  "tsx",
@@ -7142,10 +7165,13 @@ function buildDeterministicIdentifierPass(query, candidates, limit, prioritizeSo
7142
7165
  ).map((candidate) => {
7143
7166
  const nameLower = (candidate.metadata.name ?? "").toLowerCase();
7144
7167
  const pathLower = candidate.metadata.filePath.toLowerCase();
7145
- let maxMatch = 0;
7146
- const nameMatchesPrimary = primaryVariants.some(
7168
+ const exactIdentifierVariants = primaryVariants.filter((value) => value.length >= 2);
7169
+ const exactMatch = exactIdentifierVariants.some(
7147
7170
  (variant) => nameLower === variant || nameLower.replace(/[^a-z0-9]/g, "") === variant.replace(/[^a-z0-9]/g, "")
7148
7171
  );
7172
+ let maxMatch = 0;
7173
+ const nameMatchesPrimary = exactMatch;
7174
+ const pathAffinity = exactMatch ? hasModuleAffinity(candidate.metadata.filePath, exactIdentifierVariants) : false;
7149
7175
  const pathMatchesFileHint = filePathHint ? pathMatchesHint(candidate.metadata.filePath, filePathHint) : false;
7150
7176
  for (const hint of hints) {
7151
7177
  const variants = normalizeIdentifierVariants(hint);
@@ -7166,12 +7192,17 @@ function buildDeterministicIdentifierPass(query, candidates, limit, prioritizeSo
7166
7192
  candidate,
7167
7193
  maxMatch,
7168
7194
  pathMatchesFileHint,
7169
- nameMatchesPrimary
7195
+ nameMatchesPrimary,
7196
+ pathAffinity
7170
7197
  };
7171
7198
  }).filter((entry) => entry.maxMatch >= 0.7).sort((a, b) => {
7172
7199
  const aAnchored = a.pathMatchesFileHint && a.nameMatchesPrimary ? 1 : 0;
7173
7200
  const bAnchored = b.pathMatchesFileHint && b.nameMatchesPrimary ? 1 : 0;
7174
7201
  if (aAnchored !== bAnchored) return bAnchored - aAnchored;
7202
+ if (a.nameMatchesPrimary !== b.nameMatchesPrimary) {
7203
+ return b.nameMatchesPrimary ? 1 : -1;
7204
+ }
7205
+ if (a.pathAffinity !== b.pathAffinity) return b.pathAffinity ? 1 : -1;
7175
7206
  if (b.maxMatch !== a.maxMatch) return b.maxMatch - a.maxMatch;
7176
7207
  if (b.candidate.score !== a.candidate.score) return b.candidate.score - a.candidate.score;
7177
7208
  return a.candidate.id.localeCompare(b.candidate.id);