@context-engine-bridge/context-engine-mcp-bridge 0.0.71 → 0.0.72
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 +50 -9
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();
|
|
@@ -1882,6 +1878,29 @@ function _getResultsArray(obj) {
|
|
|
1882
1878
|
return null;
|
|
1883
1879
|
}
|
|
1884
1880
|
|
|
1881
|
+
function _parseToonResults(toonStr) {
|
|
1882
|
+
if (typeof toonStr !== "string") return null;
|
|
1883
|
+
try {
|
|
1884
|
+
const lines = toonStr.split("\n");
|
|
1885
|
+
const results = [];
|
|
1886
|
+
for (let i = 1; i < lines.length; i++) {
|
|
1887
|
+
const line = lines[i].trim();
|
|
1888
|
+
if (!line) continue;
|
|
1889
|
+
const parts = line.split(",");
|
|
1890
|
+
if (parts.length < 4) continue;
|
|
1891
|
+
const clean = s => (s || "").replace(/^["'\s]+|["'\s]+$/g, "");
|
|
1892
|
+
results.push({
|
|
1893
|
+
score: parseFloat(parts[0]) || 0,
|
|
1894
|
+
path: clean(parts[1]),
|
|
1895
|
+
symbol: clean(parts[2]),
|
|
1896
|
+
start_line: parseInt(parts[3], 10) || 0,
|
|
1897
|
+
end_line: parseInt(parts[4], 10) || 0,
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
return results.length > 0 ? results : null;
|
|
1901
|
+
} catch (_) { return null; }
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1885
1904
|
function _mergeResults(primaryText, additionalTexts) {
|
|
1886
1905
|
try {
|
|
1887
1906
|
const primary = JSON.parse(primaryText);
|
|
@@ -1929,10 +1948,25 @@ function _mergeResults(primaryText, additionalTexts) {
|
|
|
1929
1948
|
pInner.results_json = pResults;
|
|
1930
1949
|
}
|
|
1931
1950
|
} else if (!pResults && aResults) {
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1951
|
+
const parsedToon = _parseToonResults(pInner.results);
|
|
1952
|
+
if (parsedToon) {
|
|
1953
|
+
primary._merge_branch = "toon_parsed";
|
|
1954
|
+
const existingPaths = new Set(parsedToon.map(r => `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`));
|
|
1955
|
+
let added = 0;
|
|
1956
|
+
for (const r of aResults) {
|
|
1957
|
+
const key = `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`;
|
|
1958
|
+
if (!existingPaths.has(key)) { parsedToon.push(r); existingPaths.add(key); added++; }
|
|
1959
|
+
}
|
|
1960
|
+
parsedToon.sort((a, b) => (b.score || 0) - (a.score || 0));
|
|
1961
|
+
_totalAdded += added;
|
|
1962
|
+
_perCall.push({ ok: true, a_len: aResults.length, added, branch: "toon_parsed", before: parsedToon.length - added, after: parsedToon.length });
|
|
1963
|
+
pInner.results_json = parsedToon;
|
|
1964
|
+
} else {
|
|
1965
|
+
primary._merge_branch = "only_additional";
|
|
1966
|
+
_totalAdded += aResults.length;
|
|
1967
|
+
_perCall.push({ ok: true, a_len: aResults.length, added: aResults.length, branch: "only_additional" });
|
|
1968
|
+
pInner.results_json = [...aResults];
|
|
1969
|
+
}
|
|
1936
1970
|
} else {
|
|
1937
1971
|
primary._merge_branch = "no_merge";
|
|
1938
1972
|
_perCall.push({ ok: true, branch: "no_merge", p_type: pResults ? "array" : typeof pInner.results, a_type: aResults ? "array" : typeof aInner.results });
|
|
@@ -2002,9 +2036,13 @@ function _mergeBatchResults(primaryText, additionalTexts) {
|
|
|
2002
2036
|
const pInner = pItem.result || pItem;
|
|
2003
2037
|
const aInner = aItem.result || aItem;
|
|
2004
2038
|
|
|
2005
|
-
|
|
2039
|
+
let pResults = Array.isArray(pInner.results) ? pInner.results : Array.isArray(pInner.results_json) ? pInner.results_json : null;
|
|
2006
2040
|
const aResults = Array.isArray(aInner.results) ? aInner.results : Array.isArray(aInner.results_json) ? aInner.results_json : null;
|
|
2007
2041
|
|
|
2042
|
+
if (!pResults && typeof pInner.results === "string") {
|
|
2043
|
+
pResults = _parseToonResults(pInner.results);
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2008
2046
|
if (pResults && aResults) {
|
|
2009
2047
|
const existingPaths = new Set(
|
|
2010
2048
|
pResults.map(r => `${r.path || ""}:${r.start_line || 0}:${r.symbol || ""}`)
|
|
@@ -2019,8 +2057,11 @@ function _mergeBatchResults(primaryText, additionalTexts) {
|
|
|
2019
2057
|
if (pResults.length > 1) {
|
|
2020
2058
|
pResults.sort((a, b) => (b.score || 0) - (a.score || 0));
|
|
2021
2059
|
}
|
|
2060
|
+
pInner.results_json = pResults;
|
|
2022
2061
|
if (typeof pInner.total === "number") pInner.total = pResults.length;
|
|
2023
2062
|
if (typeof pInner.count === "number") pInner.count = pResults.length;
|
|
2063
|
+
} else if (!pResults && aResults) {
|
|
2064
|
+
pInner.results_json = [...aResults];
|
|
2024
2065
|
}
|
|
2025
2066
|
}
|
|
2026
2067
|
} catch (_) {}
|