codesearch-mcp 0.0.18-alpha → 0.2.0-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 +47 -1
- package/README.md +194 -23
- package/dist/app.js +38 -2
- package/dist/src/commands/IndexCommand.js +55 -1
- package/dist/src/commands/McpCommand.js +6 -2
- package/dist/src/config-error.d.ts +7 -0
- package/dist/src/config-error.js +14 -0
- package/dist/src/config-store.d.ts +73 -17
- package/dist/src/config-store.js +142 -27
- package/dist/src/config.d.ts +36 -11
- package/dist/src/config.js +89 -27
- package/dist/src/constants.d.ts +42 -2
- package/dist/src/constants.js +61 -7
- package/dist/src/container.js +5 -3
- package/dist/src/db/index.d.ts +1 -1
- package/dist/src/db/index.js +2 -1
- package/dist/src/db/schema.d.ts +111 -0
- package/dist/src/db/schema.js +15 -1
- package/dist/src/help.js +6 -5
- package/dist/src/interfaces/IAstParser.d.ts +14 -0
- package/dist/src/interfaces/IChunker.d.ts +24 -0
- package/dist/src/interfaces/IChunker.js +2 -0
- package/dist/src/interfaces/IDatabase.d.ts +31 -0
- package/dist/src/interfaces/IEmbedder.d.ts +14 -2
- package/dist/src/interfaces/ILogger.d.ts +7 -0
- package/dist/src/interfaces/ISearcher.d.ts +1 -0
- package/dist/src/interfaces/index.d.ts +2 -1
- package/dist/src/owner-path.d.ts +10 -0
- package/dist/src/owner-path.js +27 -0
- package/dist/src/services/AstChunker.d.ts +42 -0
- package/dist/src/services/AstChunker.js +158 -0
- package/dist/src/services/AstParserService.d.ts +6 -0
- package/dist/src/services/AstParserService.js +31 -2
- package/dist/src/services/DatabaseService.d.ts +17 -1
- package/dist/src/services/DatabaseService.js +116 -25
- package/dist/src/services/EmbedderFactory.d.ts +9 -0
- package/dist/src/services/EmbedderFactory.js +26 -0
- package/dist/src/services/IndexerService.d.ts +21 -5
- package/dist/src/services/IndexerService.js +127 -44
- package/dist/src/services/InfinityEmbedder.d.ts +38 -0
- package/dist/src/services/InfinityEmbedder.js +88 -0
- package/dist/src/services/LoggerService.d.ts +3 -1
- package/dist/src/services/LoggerService.js +17 -3
- package/dist/src/services/OpenAICompatibleEmbedder.d.ts +25 -0
- package/dist/src/services/OpenAICompatibleEmbedder.js +75 -0
- package/dist/src/services/SearcherService.d.ts +21 -1
- package/dist/src/services/SearcherService.js +129 -28
- package/dist/src/services/VoyageEmbedder.d.ts +22 -0
- package/dist/src/services/VoyageEmbedder.js +72 -0
- package/dist/src/services/WebServerService.d.ts +57 -14
- package/dist/src/services/WebServerService.js +134 -26
- package/dist/src/services/http-retry.d.ts +19 -0
- package/dist/src/services/http-retry.js +54 -0
- package/dist/src/services/infinity-provisioning.d.ts +115 -0
- package/dist/src/services/infinity-provisioning.js +516 -0
- package/dist/src/services/legacy-ollama-index.d.ts +24 -0
- package/dist/src/services/legacy-ollama-index.js +61 -0
- package/dist/src/services/reranker.d.ts +15 -0
- package/dist/src/services/reranker.js +44 -0
- package/dist/src/setup.d.ts +43 -0
- package/dist/src/setup.js +227 -55
- package/dist/src/tools/SearchCodebaseTool.js +1 -1
- package/dist/src/tools/format-helpers.js +2 -1
- package/dist/src/web/dashboard.js +5 -0
- package/docker/docker-compose.infinity-gpu.yml +19 -0
- package/docker/docker-compose.yml +20 -5
- package/docs/web-dashboard.md +36 -17
- package/package.json +18 -3
- package/dist/src/ast.d.ts +0 -2
- package/dist/src/ast.js +0 -110
- package/dist/src/commands/SetupCommand.d.ts +0 -7
- package/dist/src/commands/SetupCommand.js +0 -14
- package/dist/src/db/data-source.d.ts +0 -2
- package/dist/src/db/data-source.js +0 -13
- package/dist/src/db/entities/code-chunk.entity.d.ts +0 -9
- package/dist/src/db/entities/code-chunk.entity.js +0 -54
- package/dist/src/db/entities/code-dependency.entity.d.ts +0 -9
- package/dist/src/db/entities/code-dependency.entity.js +0 -54
- package/dist/src/db/entities/code-symbol.entity.d.ts +0 -10
- package/dist/src/db/entities/code-symbol.entity.js +0 -59
- package/dist/src/db/init.d.ts +0 -2
- package/dist/src/db/init.js +0 -62
- package/dist/src/env-loader.d.ts +0 -1
- package/dist/src/env-loader.js +0 -41
- package/dist/src/indexer.d.ts +0 -17
- package/dist/src/indexer.js +0 -242
- package/dist/src/mcp.d.ts +0 -1
- package/dist/src/mcp.js +0 -403
- package/dist/src/ollama.d.ts +0 -2
- package/dist/src/ollama.js +0 -6
- package/dist/src/searcher.d.ts +0 -74
- package/dist/src/searcher.js +0 -446
- package/dist/src/services/OllamaEmbedder.d.ts +0 -14
- package/dist/src/services/OllamaEmbedder.js +0 -63
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -9
package/package.json
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codesearch-mcp",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0-alpha",
|
|
4
4
|
"description": "Local semantic codebase search via MCP — indexes projects into pgvector, exposes search to Claude",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"mcp",
|
|
8
|
+
"model-context-protocol",
|
|
9
|
+
"rag",
|
|
10
|
+
"semantic-search",
|
|
11
|
+
"code-search",
|
|
12
|
+
"pgvector",
|
|
13
|
+
"embeddings",
|
|
14
|
+
"claude",
|
|
15
|
+
"ollama",
|
|
16
|
+
"infinity"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
6
21
|
"main": "dist/app.js",
|
|
7
22
|
"bin": {
|
|
8
23
|
"rag-index": "dist/app.js",
|
|
@@ -19,9 +34,10 @@
|
|
|
19
34
|
"CHANGELOG.md"
|
|
20
35
|
],
|
|
21
36
|
"scripts": {
|
|
37
|
+
"prebuild": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
22
38
|
"build": "tsc",
|
|
23
39
|
"postbuild": "node -e \"const fs=require('fs');const f='dist/app.js';fs.writeFileSync(f,'#!/usr/bin/env node\\n'+fs.readFileSync(f,'utf8'));fs.chmodSync(f,0o755);\"",
|
|
24
|
-
"prepublishOnly": "npm run build && npm run typecheck",
|
|
40
|
+
"prepublishOnly": "npm run build && npm run typecheck && npm test",
|
|
25
41
|
"start:mcp": "ts-node app.ts mcp",
|
|
26
42
|
"start:web": "ts-node app.ts web",
|
|
27
43
|
"index:workspace": "ts-node app.ts index",
|
|
@@ -39,7 +55,6 @@
|
|
|
39
55
|
"cli-progress": "^3.12.0",
|
|
40
56
|
"drizzle-orm": "^0.45.2",
|
|
41
57
|
"ignore": "^7.0.5",
|
|
42
|
-
"ollama": "^0.5.0",
|
|
43
58
|
"pg": "^8.13.0",
|
|
44
59
|
"pino": "^10.3.1",
|
|
45
60
|
"pino-roll": "^4.0.0",
|
package/dist/src/ast.d.ts
DELETED
package/dist/src/ast.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.extractImportEdges = extractImportEdges;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
const ts_morph_1 = require("ts-morph");
|
|
40
|
-
// Per-project ts-morph instances keyed by projectRoot. Each project gets its own instance so that
|
|
41
|
-
// projects without a tsconfig (key previously shared as '') don't leak files into each other.
|
|
42
|
-
// Loading the tsconfig gives ts-morph the compilerOptions.paths needed to resolve aliases like @core/*.
|
|
43
|
-
const morphProjects = new Map();
|
|
44
|
-
const FALLBACK_OPTS = { skipAddingFilesFromTsConfig: true, skipFileDependencyResolution: false, compilerOptions: { allowJs: true, noEmit: true } };
|
|
45
|
-
function getMorphProject(projectRoot) {
|
|
46
|
-
if (!morphProjects.has(projectRoot)) {
|
|
47
|
-
const tsconfigPath = path.join(projectRoot, 'tsconfig.json');
|
|
48
|
-
const hasTsconfig = fs.existsSync(tsconfigPath);
|
|
49
|
-
let project;
|
|
50
|
-
try {
|
|
51
|
-
const opts = hasTsconfig
|
|
52
|
-
? { tsConfigFilePath: tsconfigPath, skipAddingFilesFromTsConfig: true, skipFileDependencyResolution: false }
|
|
53
|
-
: FALLBACK_OPTS;
|
|
54
|
-
project = new ts_morph_1.Project(opts);
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
// tsconfig is invalid — fall back so other files in the project can still be processed
|
|
58
|
-
project = new ts_morph_1.Project(FALLBACK_OPTS);
|
|
59
|
-
}
|
|
60
|
-
morphProjects.set(projectRoot, project);
|
|
61
|
-
}
|
|
62
|
-
return morphProjects.get(projectRoot);
|
|
63
|
-
}
|
|
64
|
-
// Extract import edges from a TS/JS file using ts-morph.
|
|
65
|
-
// projectRoot must be the project root (where tsconfig.json lives) for alias resolution to work.
|
|
66
|
-
// Defaults to the file's directory — callers that need alias resolution must pass the project root explicitly.
|
|
67
|
-
// Removes the source file from the morph project after parsing to prevent memory accumulation.
|
|
68
|
-
async function extractImportEdges(filePath, serviceName, projectRoot = path.dirname(filePath)) {
|
|
69
|
-
// Only process JS/TS files; skip declaration files
|
|
70
|
-
if (!/\.(ts|tsx|js|jsx)$/.test(filePath) || /\.d\.ts$/.test(filePath))
|
|
71
|
-
return [];
|
|
72
|
-
const morphProject = getMorphProject(projectRoot);
|
|
73
|
-
// Remove stale cached version before re-adding
|
|
74
|
-
const existing = morphProject.getSourceFile(filePath);
|
|
75
|
-
if (existing)
|
|
76
|
-
morphProject.removeSourceFile(existing);
|
|
77
|
-
let sourceFile;
|
|
78
|
-
try {
|
|
79
|
-
sourceFile = morphProject.addSourceFileAtPath(filePath);
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
return []; // file disappeared between stat and parse
|
|
83
|
-
}
|
|
84
|
-
const edges = [];
|
|
85
|
-
for (const decl of sourceFile.getImportDeclarations()) {
|
|
86
|
-
const resolved = decl.getModuleSpecifierSourceFile();
|
|
87
|
-
if (!resolved)
|
|
88
|
-
continue; // external package or unresolvable
|
|
89
|
-
const toFile = resolved.getFilePath();
|
|
90
|
-
if (toFile.includes('/node_modules/'))
|
|
91
|
-
continue; // skip package type declarations
|
|
92
|
-
const namedImports = decl.getNamedImports();
|
|
93
|
-
const defaultImport = decl.getDefaultImport();
|
|
94
|
-
const namespaceImport = decl.getNamespaceImport();
|
|
95
|
-
if (namedImports.length > 0) {
|
|
96
|
-
for (const named of namedImports) {
|
|
97
|
-
edges.push({ project: serviceName, fromFile: filePath, fromSymbol: null, toFile, toSymbol: named.getName(), depType: 'import' });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else if (defaultImport) {
|
|
101
|
-
edges.push({ project: serviceName, fromFile: filePath, fromSymbol: null, toFile, toSymbol: null, depType: 'import-default' });
|
|
102
|
-
}
|
|
103
|
-
else if (namespaceImport) {
|
|
104
|
-
edges.push({ project: serviceName, fromFile: filePath, fromSymbol: null, toFile, toSymbol: null, depType: 'import-namespace' });
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// Remove from memory — prevents accumulation across large workspaces
|
|
108
|
-
morphProject.removeSourceFile(sourceFile);
|
|
109
|
-
return edges;
|
|
110
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SetupCommand = void 0;
|
|
4
|
-
const setup_1 = require("../setup");
|
|
5
|
-
class SetupCommand {
|
|
6
|
-
container;
|
|
7
|
-
constructor(container) {
|
|
8
|
-
this.container = container;
|
|
9
|
-
}
|
|
10
|
-
async execute() {
|
|
11
|
-
await (0, setup_1.runSetup)(this.container.logger);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.SetupCommand = SetupCommand;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.db = void 0;
|
|
4
|
-
const typeorm_1 = require("typeorm");
|
|
5
|
-
const config_1 = require("../config");
|
|
6
|
-
const code_chunk_entity_1 = require("./entities/code-chunk.entity");
|
|
7
|
-
const code_dependency_entity_1 = require("./entities/code-dependency.entity");
|
|
8
|
-
exports.db = new typeorm_1.DataSource({
|
|
9
|
-
type: 'postgres',
|
|
10
|
-
...config_1.config.db,
|
|
11
|
-
entities: [code_chunk_entity_1.CodeChunk, code_dependency_entity_1.CodeDependency],
|
|
12
|
-
synchronize: false,
|
|
13
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CodeChunk = void 0;
|
|
13
|
-
const typeorm_1 = require("typeorm");
|
|
14
|
-
let CodeChunk = class CodeChunk {
|
|
15
|
-
id;
|
|
16
|
-
serviceName;
|
|
17
|
-
filePath;
|
|
18
|
-
startLine;
|
|
19
|
-
content;
|
|
20
|
-
embedding;
|
|
21
|
-
lastModified;
|
|
22
|
-
};
|
|
23
|
-
exports.CodeChunk = CodeChunk;
|
|
24
|
-
__decorate([
|
|
25
|
-
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
26
|
-
__metadata("design:type", String)
|
|
27
|
-
], CodeChunk.prototype, "id", void 0);
|
|
28
|
-
__decorate([
|
|
29
|
-
(0, typeorm_1.Column)(),
|
|
30
|
-
__metadata("design:type", String)
|
|
31
|
-
], CodeChunk.prototype, "serviceName", void 0);
|
|
32
|
-
__decorate([
|
|
33
|
-
(0, typeorm_1.Column)(),
|
|
34
|
-
__metadata("design:type", String)
|
|
35
|
-
], CodeChunk.prototype, "filePath", void 0);
|
|
36
|
-
__decorate([
|
|
37
|
-
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
38
|
-
__metadata("design:type", Object)
|
|
39
|
-
], CodeChunk.prototype, "startLine", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
(0, typeorm_1.Column)('text'),
|
|
42
|
-
__metadata("design:type", String)
|
|
43
|
-
], CodeChunk.prototype, "content", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
(0, typeorm_1.Column)({ type: 'vector', length: 1024 }),
|
|
46
|
-
__metadata("design:type", String)
|
|
47
|
-
], CodeChunk.prototype, "embedding", void 0);
|
|
48
|
-
__decorate([
|
|
49
|
-
(0, typeorm_1.Column)({ type: 'double precision', nullable: true }),
|
|
50
|
-
__metadata("design:type", Number)
|
|
51
|
-
], CodeChunk.prototype, "lastModified", void 0);
|
|
52
|
-
exports.CodeChunk = CodeChunk = __decorate([
|
|
53
|
-
(0, typeorm_1.Entity)()
|
|
54
|
-
], CodeChunk);
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CodeDependency = void 0;
|
|
13
|
-
const typeorm_1 = require("typeorm");
|
|
14
|
-
let CodeDependency = class CodeDependency {
|
|
15
|
-
id;
|
|
16
|
-
project;
|
|
17
|
-
fromFile;
|
|
18
|
-
fromSymbol;
|
|
19
|
-
toFile;
|
|
20
|
-
toSymbol;
|
|
21
|
-
depType; // 'import' | 'import-default' | 'import-namespace'
|
|
22
|
-
};
|
|
23
|
-
exports.CodeDependency = CodeDependency;
|
|
24
|
-
__decorate([
|
|
25
|
-
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
26
|
-
__metadata("design:type", String)
|
|
27
|
-
], CodeDependency.prototype, "id", void 0);
|
|
28
|
-
__decorate([
|
|
29
|
-
(0, typeorm_1.Column)(),
|
|
30
|
-
__metadata("design:type", String)
|
|
31
|
-
], CodeDependency.prototype, "project", void 0);
|
|
32
|
-
__decorate([
|
|
33
|
-
(0, typeorm_1.Column)(),
|
|
34
|
-
__metadata("design:type", String)
|
|
35
|
-
], CodeDependency.prototype, "fromFile", void 0);
|
|
36
|
-
__decorate([
|
|
37
|
-
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
38
|
-
__metadata("design:type", Object)
|
|
39
|
-
], CodeDependency.prototype, "fromSymbol", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
(0, typeorm_1.Column)(),
|
|
42
|
-
__metadata("design:type", String)
|
|
43
|
-
], CodeDependency.prototype, "toFile", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
46
|
-
__metadata("design:type", Object)
|
|
47
|
-
], CodeDependency.prototype, "toSymbol", void 0);
|
|
48
|
-
__decorate([
|
|
49
|
-
(0, typeorm_1.Column)(),
|
|
50
|
-
__metadata("design:type", String)
|
|
51
|
-
], CodeDependency.prototype, "depType", void 0);
|
|
52
|
-
exports.CodeDependency = CodeDependency = __decorate([
|
|
53
|
-
(0, typeorm_1.Entity)()
|
|
54
|
-
], CodeDependency);
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CodeSymbol = void 0;
|
|
13
|
-
const typeorm_1 = require("typeorm");
|
|
14
|
-
let CodeSymbol = class CodeSymbol {
|
|
15
|
-
id;
|
|
16
|
-
project;
|
|
17
|
-
filePath;
|
|
18
|
-
name;
|
|
19
|
-
kind;
|
|
20
|
-
signature;
|
|
21
|
-
line;
|
|
22
|
-
col;
|
|
23
|
-
};
|
|
24
|
-
exports.CodeSymbol = CodeSymbol;
|
|
25
|
-
__decorate([
|
|
26
|
-
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
27
|
-
__metadata("design:type", String)
|
|
28
|
-
], CodeSymbol.prototype, "id", void 0);
|
|
29
|
-
__decorate([
|
|
30
|
-
(0, typeorm_1.Column)(),
|
|
31
|
-
__metadata("design:type", String)
|
|
32
|
-
], CodeSymbol.prototype, "project", void 0);
|
|
33
|
-
__decorate([
|
|
34
|
-
(0, typeorm_1.Column)(),
|
|
35
|
-
__metadata("design:type", String)
|
|
36
|
-
], CodeSymbol.prototype, "filePath", void 0);
|
|
37
|
-
__decorate([
|
|
38
|
-
(0, typeorm_1.Column)(),
|
|
39
|
-
__metadata("design:type", String)
|
|
40
|
-
], CodeSymbol.prototype, "name", void 0);
|
|
41
|
-
__decorate([
|
|
42
|
-
(0, typeorm_1.Column)(),
|
|
43
|
-
__metadata("design:type", String)
|
|
44
|
-
], CodeSymbol.prototype, "kind", void 0);
|
|
45
|
-
__decorate([
|
|
46
|
-
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
47
|
-
__metadata("design:type", Object)
|
|
48
|
-
], CodeSymbol.prototype, "signature", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
51
|
-
__metadata("design:type", Object)
|
|
52
|
-
], CodeSymbol.prototype, "line", void 0);
|
|
53
|
-
__decorate([
|
|
54
|
-
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
55
|
-
__metadata("design:type", Object)
|
|
56
|
-
], CodeSymbol.prototype, "col", void 0);
|
|
57
|
-
exports.CodeSymbol = CodeSymbol = __decorate([
|
|
58
|
-
(0, typeorm_1.Entity)()
|
|
59
|
-
], CodeSymbol);
|
package/dist/src/db/init.d.ts
DELETED
package/dist/src/db/init.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initDb = initDb;
|
|
4
|
-
exports.initDbWithSchema = initDbWithSchema;
|
|
5
|
-
const data_source_1 = require("./data-source");
|
|
6
|
-
// For MCP server — just connect, no schema changes
|
|
7
|
-
async function initDb() {
|
|
8
|
-
await data_source_1.db.initialize();
|
|
9
|
-
}
|
|
10
|
-
// For indexer — connect + create schema only if tables don't exist yet.
|
|
11
|
-
// All secondary indexes use IF NOT EXISTS so existing installs pick up new indexes on re-run.
|
|
12
|
-
async function initDbWithSchema() {
|
|
13
|
-
await data_source_1.db.initialize();
|
|
14
|
-
// code_chunk table
|
|
15
|
-
const [{ exists }] = await data_source_1.db.query(`
|
|
16
|
-
SELECT EXISTS (
|
|
17
|
-
SELECT 1 FROM information_schema.tables
|
|
18
|
-
WHERE table_schema = 'public' AND table_name = 'code_chunk'
|
|
19
|
-
)
|
|
20
|
-
`);
|
|
21
|
-
if (!exists) {
|
|
22
|
-
await data_source_1.db.synchronize();
|
|
23
|
-
await data_source_1.db.query(`
|
|
24
|
-
CREATE INDEX idx_code_chunk_embedding
|
|
25
|
-
ON code_chunk USING hnsw (embedding vector_cosine_ops)
|
|
26
|
-
`);
|
|
27
|
-
}
|
|
28
|
-
// Composite btree for all per-service lookups (scanAndIndex stale-sweep, ingest upsert, search filter).
|
|
29
|
-
// Applied idempotently so existing installs pick it up on next indexing run.
|
|
30
|
-
await data_source_1.db.query(`CREATE INDEX IF NOT EXISTS idx_code_chunk_service_file ON code_chunk ("serviceName", "filePath")`);
|
|
31
|
-
// code_dependency table
|
|
32
|
-
const [{ existsDep }] = await data_source_1.db.query(`
|
|
33
|
-
SELECT EXISTS (
|
|
34
|
-
SELECT 1 FROM information_schema.tables
|
|
35
|
-
WHERE table_schema = 'public' AND table_name = 'code_dependency'
|
|
36
|
-
) AS "existsDep"
|
|
37
|
-
`);
|
|
38
|
-
if (!existsDep) {
|
|
39
|
-
await data_source_1.db.query(`
|
|
40
|
-
CREATE TABLE code_dependency (
|
|
41
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
42
|
-
project TEXT NOT NULL,
|
|
43
|
-
"fromFile" TEXT NOT NULL,
|
|
44
|
-
"fromSymbol" TEXT,
|
|
45
|
-
"toFile" TEXT NOT NULL,
|
|
46
|
-
"toSymbol" TEXT,
|
|
47
|
-
"depType" TEXT NOT NULL
|
|
48
|
-
)
|
|
49
|
-
`);
|
|
50
|
-
}
|
|
51
|
-
// Composite indexes for the two query shapes used everywhere:
|
|
52
|
-
// WHERE project = $1 AND "fromFile" = $2 (get_dependencies, ingest delete-by-from)
|
|
53
|
-
// WHERE project = $1 AND "toFile" = $2 (get_dependents, stale-file sweep)
|
|
54
|
-
// IF NOT EXISTS lets existing installs upgrade without a manual migration.
|
|
55
|
-
await data_source_1.db.query(`CREATE INDEX IF NOT EXISTS idx_dep_project_from ON code_dependency (project, "fromFile")`);
|
|
56
|
-
await data_source_1.db.query(`CREATE INDEX IF NOT EXISTS idx_dep_project_to ON code_dependency (project, "toFile")`);
|
|
57
|
-
// Drop redundant legacy single-column indexes (covered by the composites above).
|
|
58
|
-
// Safe on fresh installs too — DROP IF EXISTS is a no-op when absent.
|
|
59
|
-
await data_source_1.db.query(`DROP INDEX IF EXISTS idx_dep_from`);
|
|
60
|
-
await data_source_1.db.query(`DROP INDEX IF EXISTS idx_dep_to`);
|
|
61
|
-
await data_source_1.db.query(`DROP INDEX IF EXISTS idx_dep_project`);
|
|
62
|
-
}
|
package/dist/src/env-loader.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/src/env-loader.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const dotenv = __importStar(require("dotenv"));
|
|
37
|
-
const path = __importStar(require("path"));
|
|
38
|
-
const os = __importStar(require("os"));
|
|
39
|
-
// Global config first, then local .env overrides (for development)
|
|
40
|
-
dotenv.config({ path: path.join(os.homedir(), '.config', 'codesearch-mcp', '.env') });
|
|
41
|
-
dotenv.config();
|
package/dist/src/indexer.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CodeDependency } from './db';
|
|
2
|
-
export interface IndexStats {
|
|
3
|
-
serviceName: string;
|
|
4
|
-
indexed: number;
|
|
5
|
-
skipped: number;
|
|
6
|
-
failed: number;
|
|
7
|
-
chunks: number;
|
|
8
|
-
elapsedSec: number;
|
|
9
|
-
warnings: string[];
|
|
10
|
-
}
|
|
11
|
-
export declare function discoverProjects(rootDir: string): {
|
|
12
|
-
name: string;
|
|
13
|
-
path: string;
|
|
14
|
-
}[];
|
|
15
|
-
export declare function collectDepEdges(absFilePath: string, serviceName: string, projectRoot: string): Promise<Omit<CodeDependency, 'id'>[]>;
|
|
16
|
-
export declare function writeDepEdges(serviceName: string, relFilePath: string, edges: Omit<CodeDependency, 'id'>[], manager?: import('typeorm').EntityManager): Promise<void>;
|
|
17
|
-
export declare function scanAndIndex(dir: string, serviceName: string, force?: boolean, signal?: AbortSignal, preCollectedFiles?: string[]): Promise<IndexStats>;
|