@context-engine-bridge/context-engine-mcp-bridge 0.0.70 → 0.0.71
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/package.json +1 -1
- package/src/mcpServer.js +28 -17
package/package.json
CHANGED
package/src/mcpServer.js
CHANGED
|
@@ -1868,8 +1868,10 @@ function _isBatchTool(name) {
|
|
|
1868
1868
|
}
|
|
1869
1869
|
|
|
1870
1870
|
function _unwrapSearchEnvelope(obj) {
|
|
1871
|
-
if (obj && obj.result && typeof obj.result === "object"
|
|
1872
|
-
|
|
1871
|
+
if (obj && obj.result && typeof obj.result === "object") {
|
|
1872
|
+
if (obj.result.ok !== undefined || Array.isArray(obj.result.results) || Array.isArray(obj.result.results_json)) {
|
|
1873
|
+
return obj.result;
|
|
1874
|
+
}
|
|
1873
1875
|
}
|
|
1874
1876
|
return obj;
|
|
1875
1877
|
}
|
|
@@ -1883,7 +1885,8 @@ function _getResultsArray(obj) {
|
|
|
1883
1885
|
function _mergeResults(primaryText, additionalTexts) {
|
|
1884
1886
|
try {
|
|
1885
1887
|
const primary = JSON.parse(primaryText);
|
|
1886
|
-
|
|
1888
|
+
const _primaryHasData = primary && (primary.ok || Array.isArray(primary.results) || (primary.result && Array.isArray(primary.result.results)));
|
|
1889
|
+
if (!_primaryHasData) return primaryText;
|
|
1887
1890
|
|
|
1888
1891
|
const pInner = _unwrapSearchEnvelope(primary);
|
|
1889
1892
|
|
|
@@ -1892,7 +1895,8 @@ function _mergeResults(primaryText, additionalTexts) {
|
|
|
1892
1895
|
for (const addText of additionalTexts) {
|
|
1893
1896
|
try {
|
|
1894
1897
|
const additional = JSON.parse(addText);
|
|
1895
|
-
|
|
1898
|
+
const _addHasData = additional && (additional.ok || Array.isArray(additional.results) || (additional.result && Array.isArray(additional.result.results)));
|
|
1899
|
+
if (!_addHasData) {
|
|
1896
1900
|
_perCall.push({ ok: false, error: additional?.error || "not ok" });
|
|
1897
1901
|
continue;
|
|
1898
1902
|
}
|
|
@@ -1979,37 +1983,44 @@ function _mergeResults(primaryText, additionalTexts) {
|
|
|
1979
1983
|
function _mergeBatchResults(primaryText, additionalTexts) {
|
|
1980
1984
|
try {
|
|
1981
1985
|
const primary = JSON.parse(primaryText);
|
|
1982
|
-
if (!primary || !primary.ok
|
|
1986
|
+
if (!primary || !primary.ok) return primaryText;
|
|
1987
|
+
const pBatch = Array.isArray(primary.results) ? primary.results : Array.isArray(primary.batch_results) ? primary.batch_results : null;
|
|
1988
|
+
if (!pBatch) return primaryText;
|
|
1983
1989
|
|
|
1984
1990
|
for (const addText of additionalTexts) {
|
|
1985
1991
|
try {
|
|
1986
1992
|
const additional = JSON.parse(addText);
|
|
1987
|
-
if (!additional || !additional.ok
|
|
1993
|
+
if (!additional || !additional.ok) continue;
|
|
1994
|
+
const aBatch = Array.isArray(additional.results) ? additional.results : Array.isArray(additional.batch_results) ? additional.batch_results : null;
|
|
1995
|
+
if (!aBatch) continue;
|
|
1988
1996
|
|
|
1989
|
-
for (let i = 0; i <
|
|
1990
|
-
const pItem =
|
|
1991
|
-
const aItem =
|
|
1997
|
+
for (let i = 0; i < pBatch.length && i < aBatch.length; i++) {
|
|
1998
|
+
const pItem = pBatch[i];
|
|
1999
|
+
const aItem = aBatch[i];
|
|
1992
2000
|
if (!pItem || !aItem) continue;
|
|
1993
2001
|
|
|
1994
2002
|
const pInner = pItem.result || pItem;
|
|
1995
2003
|
const aInner = aItem.result || aItem;
|
|
1996
2004
|
|
|
1997
|
-
|
|
2005
|
+
const pResults = Array.isArray(pInner.results) ? pInner.results : Array.isArray(pInner.results_json) ? pInner.results_json : null;
|
|
2006
|
+
const aResults = Array.isArray(aInner.results) ? aInner.results : Array.isArray(aInner.results_json) ? aInner.results_json : null;
|
|
2007
|
+
|
|
2008
|
+
if (pResults && aResults) {
|
|
1998
2009
|
const existingPaths = new Set(
|
|
1999
|
-
|
|
2010
|
+
pResults.map(r => `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`)
|
|
2000
2011
|
);
|
|
2001
|
-
for (const r of
|
|
2012
|
+
for (const r of aResults) {
|
|
2002
2013
|
const key = `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`;
|
|
2003
2014
|
if (!existingPaths.has(key)) {
|
|
2004
|
-
|
|
2015
|
+
pResults.push(r);
|
|
2005
2016
|
existingPaths.add(key);
|
|
2006
2017
|
}
|
|
2007
2018
|
}
|
|
2008
|
-
if (
|
|
2009
|
-
|
|
2019
|
+
if (pResults.length > 1) {
|
|
2020
|
+
pResults.sort((a, b) => (b.score || 0) - (a.score || 0));
|
|
2010
2021
|
}
|
|
2011
|
-
if (typeof pInner.total === "number") pInner.total =
|
|
2012
|
-
if (typeof pInner.count === "number") pInner.count =
|
|
2022
|
+
if (typeof pInner.total === "number") pInner.total = pResults.length;
|
|
2023
|
+
if (typeof pInner.count === "number") pInner.count = pResults.length;
|
|
2013
2024
|
}
|
|
2014
2025
|
}
|
|
2015
2026
|
} catch (_) {}
|