@context-engine-bridge/context-engine-mcp-bridge 0.0.71 → 0.0.73
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 +51 -12
package/package.json
CHANGED
package/src/mcpServer.js
CHANGED
|
@@ -1262,10 +1262,6 @@ async function createBridgeServer(options) {
|
|
|
1262
1262
|
debugLog(`[ctxce] Fan-out: ${name} across ${additionalCollections.length} additional collection(s): ${additionalCollections.join(", ")}`);
|
|
1263
1263
|
}
|
|
1264
1264
|
|
|
1265
|
-
if (shouldFanOut && args && typeof args === "object") {
|
|
1266
|
-
args = { ...args, output_format: "json", compact: false };
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
1265
|
const timeoutMs = getBridgeToolTimeoutMs();
|
|
1270
1266
|
const maxAttempts = getBridgeRetryAttempts();
|
|
1271
1267
|
const retryDelayMs = getBridgeRetryDelayMs();
|
|
@@ -1336,9 +1332,7 @@ async function createBridgeServer(options) {
|
|
|
1336
1332
|
}
|
|
1337
1333
|
const mergeFn = _isBatchTool(name) ? _mergeBatchResults : _mergeResults;
|
|
1338
1334
|
primaryTb.text = mergeFn(primaryTb.text, additionalTexts);
|
|
1339
|
-
|
|
1340
|
-
try { result.structuredContent = JSON.parse(primaryTb.text); } catch (_) {}
|
|
1341
|
-
}
|
|
1335
|
+
delete result.structuredContent;
|
|
1342
1336
|
}
|
|
1343
1337
|
}
|
|
1344
1338
|
}
|
|
@@ -1882,6 +1876,29 @@ function _getResultsArray(obj) {
|
|
|
1882
1876
|
return null;
|
|
1883
1877
|
}
|
|
1884
1878
|
|
|
1879
|
+
function _parseToonResults(toonStr) {
|
|
1880
|
+
if (typeof toonStr !== "string") return null;
|
|
1881
|
+
try {
|
|
1882
|
+
const lines = toonStr.split("\n");
|
|
1883
|
+
const results = [];
|
|
1884
|
+
for (let i = 1; i < lines.length; i++) {
|
|
1885
|
+
const line = lines[i].trim();
|
|
1886
|
+
if (!line) continue;
|
|
1887
|
+
const parts = line.split(",");
|
|
1888
|
+
if (parts.length < 4) continue;
|
|
1889
|
+
const clean = s => (s || "").replace(/^["'\s]+|["'\s]+$/g, "");
|
|
1890
|
+
results.push({
|
|
1891
|
+
score: parseFloat(parts[0]) || 0,
|
|
1892
|
+
path: clean(parts[1]),
|
|
1893
|
+
symbol: clean(parts[2]),
|
|
1894
|
+
start_line: parseInt(parts[3], 10) || 0,
|
|
1895
|
+
end_line: parseInt(parts[4], 10) || 0,
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
return results.length > 0 ? results : null;
|
|
1899
|
+
} catch (_) { return null; }
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1885
1902
|
function _mergeResults(primaryText, additionalTexts) {
|
|
1886
1903
|
try {
|
|
1887
1904
|
const primary = JSON.parse(primaryText);
|
|
@@ -1929,10 +1946,25 @@ function _mergeResults(primaryText, additionalTexts) {
|
|
|
1929
1946
|
pInner.results_json = pResults;
|
|
1930
1947
|
}
|
|
1931
1948
|
} else if (!pResults && aResults) {
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1949
|
+
const parsedToon = _parseToonResults(pInner.results);
|
|
1950
|
+
if (parsedToon) {
|
|
1951
|
+
primary._merge_branch = "toon_parsed";
|
|
1952
|
+
const existingPaths = new Set(parsedToon.map(r => `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`));
|
|
1953
|
+
let added = 0;
|
|
1954
|
+
for (const r of aResults) {
|
|
1955
|
+
const key = `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`;
|
|
1956
|
+
if (!existingPaths.has(key)) { parsedToon.push(r); existingPaths.add(key); added++; }
|
|
1957
|
+
}
|
|
1958
|
+
parsedToon.sort((a, b) => (b.score || 0) - (a.score || 0));
|
|
1959
|
+
_totalAdded += added;
|
|
1960
|
+
_perCall.push({ ok: true, a_len: aResults.length, added, branch: "toon_parsed", before: parsedToon.length - added, after: parsedToon.length });
|
|
1961
|
+
pInner.results_json = parsedToon;
|
|
1962
|
+
} else {
|
|
1963
|
+
primary._merge_branch = "only_additional";
|
|
1964
|
+
_totalAdded += aResults.length;
|
|
1965
|
+
_perCall.push({ ok: true, a_len: aResults.length, added: aResults.length, branch: "only_additional" });
|
|
1966
|
+
pInner.results_json = [...aResults];
|
|
1967
|
+
}
|
|
1936
1968
|
} else {
|
|
1937
1969
|
primary._merge_branch = "no_merge";
|
|
1938
1970
|
_perCall.push({ ok: true, branch: "no_merge", p_type: pResults ? "array" : typeof pInner.results, a_type: aResults ? "array" : typeof aInner.results });
|
|
@@ -2002,9 +2034,13 @@ function _mergeBatchResults(primaryText, additionalTexts) {
|
|
|
2002
2034
|
const pInner = pItem.result || pItem;
|
|
2003
2035
|
const aInner = aItem.result || aItem;
|
|
2004
2036
|
|
|
2005
|
-
|
|
2037
|
+
let pResults = Array.isArray(pInner.results) ? pInner.results : Array.isArray(pInner.results_json) ? pInner.results_json : null;
|
|
2006
2038
|
const aResults = Array.isArray(aInner.results) ? aInner.results : Array.isArray(aInner.results_json) ? aInner.results_json : null;
|
|
2007
2039
|
|
|
2040
|
+
if (!pResults && typeof pInner.results === "string") {
|
|
2041
|
+
pResults = _parseToonResults(pInner.results);
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2008
2044
|
if (pResults && aResults) {
|
|
2009
2045
|
const existingPaths = new Set(
|
|
2010
2046
|
pResults.map(r => `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`)
|
|
@@ -2019,8 +2055,11 @@ function _mergeBatchResults(primaryText, additionalTexts) {
|
|
|
2019
2055
|
if (pResults.length > 1) {
|
|
2020
2056
|
pResults.sort((a, b) => (b.score || 0) - (a.score || 0));
|
|
2021
2057
|
}
|
|
2058
|
+
pInner.results_json = pResults;
|
|
2022
2059
|
if (typeof pInner.total === "number") pInner.total = pResults.length;
|
|
2023
2060
|
if (typeof pInner.count === "number") pInner.count = pResults.length;
|
|
2061
|
+
} else if (!pResults && aResults) {
|
|
2062
|
+
pInner.results_json = [...aResults];
|
|
2024
2063
|
}
|
|
2025
2064
|
}
|
|
2026
2065
|
} catch (_) {}
|