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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/dist/cli.cjs +34 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +34 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +34 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -3
- package/dist/index.js.map +1 -1
- package/dist/pi-extension.cjs +34 -3
- package/dist/pi-extension.cjs.map +1 -1
- package/dist/pi-extension.js +34 -3
- package/dist/pi-extension.js.map +1 -1
- package/native/codebase-index-native.darwin-arm64.node +0 -0
- package/native/codebase-index-native.darwin-x64.node +0 -0
- package/native/codebase-index-native.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9043,6 +9043,29 @@ function extractPrimaryIdentifierQueryHint(query) {
|
|
|
9043
9043
|
const best = codeTerms.find((term) => term.length >= 6);
|
|
9044
9044
|
return best ?? null;
|
|
9045
9045
|
}
|
|
9046
|
+
function pathSegmentsForAffinityMatch(filePath) {
|
|
9047
|
+
const normalizedPath2 = normalizeRankingText(filePath).replace(/\\/g, "/");
|
|
9048
|
+
const segments = normalizedPath2.split("/").filter((segment) => segment.length > 0);
|
|
9049
|
+
if (segments.length === 0) {
|
|
9050
|
+
return [];
|
|
9051
|
+
}
|
|
9052
|
+
const basename9 = segments[segments.length - 1] ?? "";
|
|
9053
|
+
const basenameWithoutExt = basename9.replace(/\.[^/.]+$/u, "");
|
|
9054
|
+
const normalizedSegments = segments.map((segment) => segment.toLowerCase());
|
|
9055
|
+
return Array.from(/* @__PURE__ */ new Set([
|
|
9056
|
+
...normalizedSegments,
|
|
9057
|
+
basenameWithoutExt.toLowerCase()
|
|
9058
|
+
]));
|
|
9059
|
+
}
|
|
9060
|
+
function hasModuleAffinity(filePath, exactIdentifierVariants) {
|
|
9061
|
+
const haystack = pathSegmentsForAffinityMatch(filePath);
|
|
9062
|
+
return exactIdentifierVariants.some((variant) => {
|
|
9063
|
+
if (!variant || variant.length < 2) {
|
|
9064
|
+
return false;
|
|
9065
|
+
}
|
|
9066
|
+
return haystack.includes(variant);
|
|
9067
|
+
});
|
|
9068
|
+
}
|
|
9046
9069
|
var FILE_PATH_HINT_EXTENSIONS = [
|
|
9047
9070
|
"ts",
|
|
9048
9071
|
"tsx",
|
|
@@ -9118,10 +9141,13 @@ function buildDeterministicIdentifierPass(query, candidates, limit, prioritizeSo
|
|
|
9118
9141
|
).map((candidate) => {
|
|
9119
9142
|
const nameLower = (candidate.metadata.name ?? "").toLowerCase();
|
|
9120
9143
|
const pathLower = candidate.metadata.filePath.toLowerCase();
|
|
9121
|
-
|
|
9122
|
-
const
|
|
9144
|
+
const exactIdentifierVariants = primaryVariants.filter((value) => value.length >= 2);
|
|
9145
|
+
const exactMatch = exactIdentifierVariants.some(
|
|
9123
9146
|
(variant) => nameLower === variant || nameLower.replace(/[^a-z0-9]/g, "") === variant.replace(/[^a-z0-9]/g, "")
|
|
9124
9147
|
);
|
|
9148
|
+
let maxMatch = 0;
|
|
9149
|
+
const nameMatchesPrimary = exactMatch;
|
|
9150
|
+
const pathAffinity = exactMatch ? hasModuleAffinity(candidate.metadata.filePath, exactIdentifierVariants) : false;
|
|
9125
9151
|
const pathMatchesFileHint = filePathHint ? pathMatchesHint(candidate.metadata.filePath, filePathHint) : false;
|
|
9126
9152
|
for (const hint of hints) {
|
|
9127
9153
|
const variants = normalizeIdentifierVariants(hint);
|
|
@@ -9142,12 +9168,17 @@ function buildDeterministicIdentifierPass(query, candidates, limit, prioritizeSo
|
|
|
9142
9168
|
candidate,
|
|
9143
9169
|
maxMatch,
|
|
9144
9170
|
pathMatchesFileHint,
|
|
9145
|
-
nameMatchesPrimary
|
|
9171
|
+
nameMatchesPrimary,
|
|
9172
|
+
pathAffinity
|
|
9146
9173
|
};
|
|
9147
9174
|
}).filter((entry) => entry.maxMatch >= 0.7).sort((a, b) => {
|
|
9148
9175
|
const aAnchored = a.pathMatchesFileHint && a.nameMatchesPrimary ? 1 : 0;
|
|
9149
9176
|
const bAnchored = b.pathMatchesFileHint && b.nameMatchesPrimary ? 1 : 0;
|
|
9150
9177
|
if (aAnchored !== bAnchored) return bAnchored - aAnchored;
|
|
9178
|
+
if (a.nameMatchesPrimary !== b.nameMatchesPrimary) {
|
|
9179
|
+
return b.nameMatchesPrimary ? 1 : -1;
|
|
9180
|
+
}
|
|
9181
|
+
if (a.pathAffinity !== b.pathAffinity) return b.pathAffinity ? 1 : -1;
|
|
9151
9182
|
if (b.maxMatch !== a.maxMatch) return b.maxMatch - a.maxMatch;
|
|
9152
9183
|
if (b.candidate.score !== a.candidate.score) return b.candidate.score - a.candidate.score;
|
|
9153
9184
|
return a.candidate.id.localeCompare(b.candidate.id);
|