@esankhan3/code-search-mcp 0.4.9 → 0.4.11
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/dist/backends/in-process.js +1 -3
- package/dist/server.js +5 -1
- package/dist/tools/search.js +5 -0
- package/package.json +1 -1
|
@@ -22,9 +22,8 @@ class InProcessBackend {
|
|
|
22
22
|
async search(query, opts) {
|
|
23
23
|
const started = Date.now();
|
|
24
24
|
let outcome = "ok";
|
|
25
|
-
let retriever;
|
|
26
25
|
try {
|
|
27
|
-
retriever = await getRetriever(this.project, this.knowledge);
|
|
26
|
+
const retriever = await getRetriever(this.project, this.knowledge);
|
|
28
27
|
const modeMap = {
|
|
29
28
|
hybrid: "vector+bm25+graph",
|
|
30
29
|
vector: "vector",
|
|
@@ -54,7 +53,6 @@ class InProcessBackend {
|
|
|
54
53
|
metrics.errors.inc({ kind: "search" });
|
|
55
54
|
throw err;
|
|
56
55
|
} finally {
|
|
57
|
-
retriever?.close?.();
|
|
58
56
|
const elapsed = (Date.now() - started) / 1e3;
|
|
59
57
|
metrics.queriesTotal.inc({ mode: opts.mode, outcome });
|
|
60
58
|
metrics.queryDuration.observe(elapsed, { mode: opts.mode });
|
package/dist/server.js
CHANGED
|
@@ -14,7 +14,7 @@ import { registerProfileTools, handleProfileTool } from "./tools/profile.js";
|
|
|
14
14
|
import { registerIndexTools, handleIndexTool } from "./tools/index-tools.js";
|
|
15
15
|
import { registerResources, handleResource } from "./resources/resources.js";
|
|
16
16
|
import { getKnowledgeBasePath } from "@esankhan3/anvil-knowledge-core";
|
|
17
|
-
import { indexFromPath } from "@esankhan3/anvil-knowledge-core";
|
|
17
|
+
import { indexFromPath, invalidateRetriever } from "@esankhan3/anvil-knowledge-core";
|
|
18
18
|
import { loadServerConfig } from "./core/env-config.js";
|
|
19
19
|
import { toKnowledgeConfig } from "./core/config.js";
|
|
20
20
|
import { startHttpTransport } from "./transports/http-transport.js";
|
|
@@ -202,6 +202,10 @@ async function trackedIndex(ctx, project, dirPath, opts) {
|
|
|
202
202
|
ctx.indexing.message = p.message;
|
|
203
203
|
}
|
|
204
204
|
});
|
|
205
|
+
try {
|
|
206
|
+
await invalidateRetriever(project);
|
|
207
|
+
} catch {
|
|
208
|
+
}
|
|
205
209
|
ctx.indexReady = true;
|
|
206
210
|
ctx.indexing.status = "idle";
|
|
207
211
|
ctx.indexing.phase = null;
|
package/dist/tools/search.js
CHANGED
|
@@ -73,6 +73,11 @@ async function handleSearchTool(name, args, ctx) {
|
|
|
73
73
|
};
|
|
74
74
|
const result = await retriever.retrieve(query, {
|
|
75
75
|
maxChunks: maxResults,
|
|
76
|
+
// A search tool returns a fixed COUNT of results; the config token budget
|
|
77
|
+
// is for LLM-context packing and would truncate below maxResults (the
|
|
78
|
+
// benchmark saw ~6.6 of 10 returned). Give maxChunks room to bind while
|
|
79
|
+
// still bounding a pathological all-huge-chunks payload.
|
|
80
|
+
maxTokens: maxResults * 4e3,
|
|
76
81
|
repoFilter: repos,
|
|
77
82
|
mode: modeMap[name]
|
|
78
83
|
});
|