codesearch-mcp 0.2.1-alpha → 0.2.3-alpha
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/CHANGELOG.md +40 -0
- package/README.md +15 -8
- package/dist/app.js +45 -7
- package/dist/src/commands/EvalCommand.d.ts +10 -0
- package/dist/src/commands/EvalCommand.js +231 -0
- package/dist/src/commands/IndexCommand.js +79 -53
- package/dist/src/db/index.d.ts +1 -1
- package/dist/src/db/index.js +1 -2
- package/dist/src/db/schema.d.ts +5 -29
- package/dist/src/db/schema.js +2 -8
- package/dist/src/dependency-traversal.d.ts +16 -0
- package/dist/src/dependency-traversal.js +45 -0
- package/dist/src/enriched-prompt.d.ts +3 -2
- package/dist/src/enriched-prompt.js +3 -2
- package/dist/src/eval-results.d.ts +12 -0
- package/dist/src/eval-results.js +114 -0
- package/dist/src/file-utils.d.ts +15 -0
- package/dist/src/file-utils.js +24 -1
- package/dist/src/help.js +4 -1
- package/dist/src/interfaces/IAstParser.d.ts +13 -1
- package/dist/src/interfaces/IDatabase.d.ts +0 -14
- package/dist/src/interfaces/IRetrievalEvaluator.d.ts +94 -0
- package/dist/src/interfaces/IRetrievalEvaluator.js +2 -0
- package/dist/src/interfaces/ISearcher.d.ts +11 -16
- package/dist/src/interfaces/index.d.ts +1 -0
- package/dist/src/project-scope.d.ts +19 -0
- package/dist/src/project-scope.js +49 -0
- package/dist/src/project-selector.d.ts +6 -0
- package/dist/src/project-selector.js +18 -0
- package/dist/src/retrieval-eval.d.ts +16 -0
- package/dist/src/retrieval-eval.js +214 -0
- package/dist/src/services/AstParserService.d.ts +66 -1
- package/dist/src/services/AstParserService.js +432 -28
- package/dist/src/services/DatabaseService.d.ts +0 -12
- package/dist/src/services/DatabaseService.js +2 -52
- package/dist/src/services/IndexerService.d.ts +8 -0
- package/dist/src/services/IndexerService.js +24 -11
- package/dist/src/services/McpServer.d.ts +7 -0
- package/dist/src/services/McpServer.js +42 -38
- package/dist/src/services/OpenAICompatibleEmbedder.js +2 -1
- package/dist/src/services/SearcherService.d.ts +189 -25
- package/dist/src/services/SearcherService.js +505 -203
- package/dist/src/symbol-rows.d.ts +14 -9
- package/dist/src/symbol-rows.js +17 -11
- package/dist/src/tools/FindSymbolTool.js +14 -5
- package/dist/src/tools/GetCallersTool.d.ts +3 -1
- package/dist/src/tools/GetCallersTool.js +16 -6
- package/dist/src/tools/GetDependenciesTool.d.ts +3 -1
- package/dist/src/tools/GetDependenciesTool.js +15 -8
- package/dist/src/tools/GetDependentsTool.d.ts +3 -1
- package/dist/src/tools/GetDependentsTool.js +31 -16
- package/dist/src/tools/ListFilesTool.d.ts +3 -1
- package/dist/src/tools/ListFilesTool.js +14 -12
- package/dist/src/tools/ListProjectsTool.js +5 -1
- package/dist/src/tools/ReadFileRangeTool.d.ts +3 -1
- package/dist/src/tools/ReadFileRangeTool.js +12 -11
- package/dist/src/tools/ReadFileTool.d.ts +3 -1
- package/dist/src/tools/ReadFileTool.js +12 -10
- package/dist/src/tools/SearchCodebaseTool.js +3 -1
- package/dist/src/tools/format-helpers.d.ts +16 -1
- package/dist/src/tools/format-helpers.js +64 -0
- package/package.json +9 -8
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PATH_EXAMPLE = void 0;
|
|
3
4
|
exports.textResponse = textResponse;
|
|
4
5
|
exports.errorResponse = errorResponse;
|
|
5
6
|
exports.formatChunk = formatChunk;
|
|
6
7
|
exports.formatGraphContext = formatGraphContext;
|
|
7
8
|
exports.formatDependencies = formatDependencies;
|
|
8
9
|
exports.formatDependents = formatDependents;
|
|
10
|
+
exports.pathArgDescription = pathArgDescription;
|
|
11
|
+
exports.pathErrorText = pathErrorText;
|
|
12
|
+
exports.pathErrorResponse = pathErrorResponse;
|
|
9
13
|
function textResponse(text) {
|
|
10
14
|
return { content: [{ type: 'text', text }] };
|
|
11
15
|
}
|
|
@@ -56,3 +60,63 @@ function formatDependents(filePath, rows, transitive) {
|
|
|
56
60
|
}
|
|
57
61
|
return lines.join('\n');
|
|
58
62
|
}
|
|
63
|
+
exports.PATH_EXAMPLE = { file: 'my-app/src/index.ts', directory: 'my-app/src' };
|
|
64
|
+
/** Description of a path argument; `kind` names what the path points at. */
|
|
65
|
+
function pathArgDescription(kind = 'file') {
|
|
66
|
+
const root = kind === 'directory' ? ', "." for the workspace root' : '';
|
|
67
|
+
const noun = kind === 'directory' ? 'directory' : 'path';
|
|
68
|
+
return `Workspace-relative ${noun}, as printed by search_codebase (e.g. ${exports.PATH_EXAMPLE[kind]})${root}`;
|
|
69
|
+
}
|
|
70
|
+
function acceptedForm(example) {
|
|
71
|
+
return `Paths are workspace-relative, as printed by search_codebase — e.g. ${example}.`;
|
|
72
|
+
}
|
|
73
|
+
function notIndexedExplanation(e) {
|
|
74
|
+
const excluded = (why) => `This file is not indexed (${why}), so the graph has no data for it. Use read_file or Grep instead.`;
|
|
75
|
+
switch (e.kind) {
|
|
76
|
+
case 'no_project': return excluded('it is outside every project');
|
|
77
|
+
case 'type': return excluded('files of this type are not indexed');
|
|
78
|
+
case 'ignored_dir': return excluded(`${e.segment}/ is an ignored directory`);
|
|
79
|
+
case 'ragignore': return excluded('it matches .ragignore');
|
|
80
|
+
case 'project_not_indexed': return `Project ${e.project} is not in the index. If it is not selected, select it with rag-index --select; then run rag-index.`;
|
|
81
|
+
case 'unknown':
|
|
82
|
+
return 'The file exists on disk but the index has no data for it: either it was added after the last index run ' +
|
|
83
|
+
'(run rag-index), or it has no indexable content (empty, comments only, or imports of external packages only).';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Text of a path error. `input` is the raw argument (echoed by refusals);
|
|
88
|
+
* `relPath` its canonical form, printed by every other message.
|
|
89
|
+
*/
|
|
90
|
+
function pathErrorText(argName, input, relPath, err, kind = 'file') {
|
|
91
|
+
const example = exports.PATH_EXAMPLE[kind];
|
|
92
|
+
switch (err.reason) {
|
|
93
|
+
case 'invalid':
|
|
94
|
+
return err.missing
|
|
95
|
+
? `Missing ${argName}\n${acceptedForm(example)}`
|
|
96
|
+
: `Invalid path (\\ is not a separator): ${input}\n${acceptedForm(example)}`;
|
|
97
|
+
case 'absolute':
|
|
98
|
+
return `Absolute path: ${input} — use ${err.relative}\n${acceptedForm(err.relative)}`;
|
|
99
|
+
case 'outside_workspace':
|
|
100
|
+
return `${input} is outside the workspace\n${acceptedForm(example)}`;
|
|
101
|
+
case 'not_found': {
|
|
102
|
+
const lines = [`Not found: ${relPath}`, acceptedForm(err.candidates[0] ?? example)];
|
|
103
|
+
if (err.candidates.length > 0)
|
|
104
|
+
lines.push('Did you mean:', ...err.candidates.map(c => `- ${c}`));
|
|
105
|
+
return lines.join('\n');
|
|
106
|
+
}
|
|
107
|
+
case 'deleted':
|
|
108
|
+
return `Deleted from disk: ${relPath}\nThe index still holds this file, but it no longer exists on disk. Run rag-index to update the index.`;
|
|
109
|
+
case 'not_indexed':
|
|
110
|
+
return `Not indexed: ${relPath}\n${notIndexedExplanation(err.explanation)}`;
|
|
111
|
+
case 'not_a_file': return `Not a file: ${relPath}`;
|
|
112
|
+
case 'not_a_directory': return `Not a directory: ${relPath}`;
|
|
113
|
+
case 'unreadable': return `Cannot read: ${relPath} (${err.code})`;
|
|
114
|
+
case 'past_end': return `${relPath} has ${err.lineCount} lines; start_line ${err.startLine} is past the end`;
|
|
115
|
+
case 'bad_range': return `end_line ${err.endLine} is before start_line ${err.startLine}`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** Error response for a path error, logged at `warn` — a caller or index-freshness problem, not a server fault. */
|
|
119
|
+
function pathErrorResponse(logger, tool, argName, input, relPath, err, kind = 'file') {
|
|
120
|
+
logger.warn('Tool path error', { tool, input, reason: err.reason });
|
|
121
|
+
return errorResponse(pathErrorText(argName, input, relPath, err, kind));
|
|
122
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codesearch-mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3-alpha",
|
|
4
4
|
"description": "Local semantic codebase search via MCP — indexes projects into pgvector, exposes search to Claude",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -42,23 +42,24 @@
|
|
|
42
42
|
"start:web": "ts-node app.ts web",
|
|
43
43
|
"index:workspace": "ts-node app.ts index",
|
|
44
44
|
"index:reindex": "ts-node app.ts index --reindex",
|
|
45
|
+
"index:project": "ts-node app.ts index --project",
|
|
45
46
|
"typecheck": "tsc --noEmit",
|
|
46
47
|
"test": "vitest run",
|
|
47
48
|
"test:watch": "vitest",
|
|
48
49
|
"verify": "tsc --noEmit && vitest run"
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
|
-
"@inquirer/prompts": "^8.
|
|
52
|
-
"@langchain/textsplitters": "^1.0.
|
|
53
|
-
"@modelcontextprotocol/sdk": "
|
|
52
|
+
"@inquirer/prompts": "^8.7.3",
|
|
53
|
+
"@langchain/textsplitters": "^1.0.2",
|
|
54
|
+
"@modelcontextprotocol/sdk": "1.32.0",
|
|
54
55
|
"cli-progress": "^3.12.0",
|
|
55
56
|
"drizzle-orm": "^0.45.2",
|
|
56
57
|
"ignore": "^7.0.5",
|
|
57
|
-
"pg": "^8.
|
|
58
|
-
"pino": "^10.
|
|
58
|
+
"pg": "^8.23.1",
|
|
59
|
+
"pino": "^10.4.0",
|
|
59
60
|
"pino-roll": "^4.0.0",
|
|
60
61
|
"ts-morph": "^28.0.0",
|
|
61
|
-
"zod": "^4.
|
|
62
|
+
"zod": "^4.6.7"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@types/cli-progress": "^3.11.6",
|
|
@@ -66,6 +67,6 @@
|
|
|
66
67
|
"@types/pg": "^8.20.0",
|
|
67
68
|
"ts-node": "^10.9.2",
|
|
68
69
|
"typescript": "^5.6.0",
|
|
69
|
-
"vitest": "^
|
|
70
|
+
"vitest": "^5.0.5"
|
|
70
71
|
}
|
|
71
72
|
}
|