codesearch-mcp 0.0.16-alpha → 0.0.17-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 +37 -1
- package/README.md +73 -34
- package/dist/app.d.ts +1 -1
- package/dist/app.js +67 -16
- package/dist/src/commands/BackfillCommand.js +15 -5
- package/dist/src/commands/ConfigCommand.d.ts +12 -0
- package/dist/src/commands/ConfigCommand.js +98 -0
- package/dist/src/commands/IndexCommand.js +1 -1
- package/dist/src/config-store.d.ts +53 -0
- package/dist/src/config-store.js +197 -0
- package/dist/src/config.d.ts +22 -8
- package/dist/src/config.js +103 -58
- package/dist/src/container.d.ts +1 -1
- package/dist/src/container.js +8 -7
- package/dist/src/db/index.d.ts +1 -1
- package/dist/src/db/index.js +2 -1
- package/dist/src/db/schema.d.ts +160 -0
- package/dist/src/db/schema.js +12 -1
- package/dist/src/help.js +28 -12
- package/dist/src/interfaces/IAstParser.d.ts +14 -1
- package/dist/src/interfaces/IEmbedder.d.ts +1 -0
- package/dist/src/project-selector.d.ts +14 -5
- package/dist/src/project-selector.js +74 -60
- package/dist/src/services/AstParserService.d.ts +5 -1
- package/dist/src/services/AstParserService.js +107 -16
- package/dist/src/services/DatabaseService.js +18 -0
- package/dist/src/services/IndexerService.d.ts +7 -0
- package/dist/src/services/IndexerService.js +160 -40
- package/dist/src/services/LoggerService.d.ts +5 -1
- package/dist/src/services/LoggerService.js +8 -5
- package/dist/src/services/McpServer.d.ts +1 -0
- package/dist/src/services/McpServer.js +72 -4
- package/dist/src/services/OllamaEmbedder.d.ts +2 -0
- package/dist/src/services/OllamaEmbedder.js +29 -0
- package/dist/src/services/SearcherService.d.ts +13 -0
- package/dist/src/services/SearcherService.js +118 -22
- package/dist/src/setup.js +57 -62
- package/package.json +3 -3
|
@@ -0,0 +1,197 @@
|
|
|
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.ALL_KEYS = exports.CONFIG_FILE = exports.CONFIG_DIR = void 0;
|
|
37
|
+
exports.readConfigJson = readConfigJson;
|
|
38
|
+
exports.writeConfigJson = writeConfigJson;
|
|
39
|
+
exports.getNestedValue = getNestedValue;
|
|
40
|
+
exports.setNestedValue = setNestedValue;
|
|
41
|
+
exports.deleteNestedValue = deleteNestedValue;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
45
|
+
const zod_1 = require("zod");
|
|
46
|
+
exports.CONFIG_DIR = path.join(os.homedir(), '.config', 'codesearch-mcp');
|
|
47
|
+
exports.CONFIG_FILE = path.join(exports.CONFIG_DIR, 'config.json');
|
|
48
|
+
// All fields optional — defaults live in config.ts. The file stays minimal.
|
|
49
|
+
const jsonSchema = zod_1.z.object({
|
|
50
|
+
db: zod_1.z.object({
|
|
51
|
+
host: zod_1.z.string().optional(),
|
|
52
|
+
port: zod_1.z.number().optional(),
|
|
53
|
+
user: zod_1.z.string().optional(),
|
|
54
|
+
password: zod_1.z.string().optional(),
|
|
55
|
+
name: zod_1.z.string().optional(),
|
|
56
|
+
}).optional(),
|
|
57
|
+
ollama: zod_1.z.object({
|
|
58
|
+
host: zod_1.z.string().optional(),
|
|
59
|
+
model: zod_1.z.string().optional(),
|
|
60
|
+
}).optional(),
|
|
61
|
+
indexing: zod_1.z.object({
|
|
62
|
+
chunkSize: zod_1.z.number().optional(),
|
|
63
|
+
chunkOverlap: zod_1.z.number().optional(),
|
|
64
|
+
embedBatchSize: zod_1.z.number().optional(),
|
|
65
|
+
astBatchSize: zod_1.z.number().optional(),
|
|
66
|
+
}).optional(),
|
|
67
|
+
search: zod_1.z.object({
|
|
68
|
+
similarityThreshold: zod_1.z.number().optional(),
|
|
69
|
+
defaultLimit: zod_1.z.number().optional(),
|
|
70
|
+
maxLimit: zod_1.z.number().optional(),
|
|
71
|
+
autoTranslate: zod_1.z.boolean().optional(),
|
|
72
|
+
translateModel: zod_1.z.string().optional(),
|
|
73
|
+
}).optional(),
|
|
74
|
+
reranker: zod_1.z.object({
|
|
75
|
+
enabled: zod_1.z.boolean().optional(),
|
|
76
|
+
model: zod_1.z.string().optional(),
|
|
77
|
+
url: zod_1.z.string().optional(),
|
|
78
|
+
overfetch: zod_1.z.number().int().min(1).max(20).optional(),
|
|
79
|
+
}).optional(),
|
|
80
|
+
logging: zod_1.z.object({
|
|
81
|
+
level: zod_1.z.enum(['debug', 'info', 'warn', 'error']).optional(),
|
|
82
|
+
dir: zod_1.z.string().optional(),
|
|
83
|
+
}).optional(),
|
|
84
|
+
workspaceRoot: zod_1.z.string().optional(),
|
|
85
|
+
});
|
|
86
|
+
const FIELD_TYPES = {
|
|
87
|
+
'db.host': 'string',
|
|
88
|
+
'db.port': 'number',
|
|
89
|
+
'db.user': 'string',
|
|
90
|
+
'db.password': 'string',
|
|
91
|
+
'db.name': 'string',
|
|
92
|
+
'ollama.host': 'string',
|
|
93
|
+
'ollama.model': 'string',
|
|
94
|
+
'indexing.chunkSize': 'number',
|
|
95
|
+
'indexing.chunkOverlap': 'number',
|
|
96
|
+
'indexing.embedBatchSize': 'number',
|
|
97
|
+
'indexing.astBatchSize': 'number',
|
|
98
|
+
'search.similarityThreshold': 'number',
|
|
99
|
+
'search.defaultLimit': 'number',
|
|
100
|
+
'search.maxLimit': 'number',
|
|
101
|
+
'search.autoTranslate': 'boolean',
|
|
102
|
+
'search.translateModel': 'string',
|
|
103
|
+
'reranker.enabled': 'boolean',
|
|
104
|
+
'reranker.model': 'string',
|
|
105
|
+
'reranker.url': 'string',
|
|
106
|
+
'reranker.overfetch': 'number',
|
|
107
|
+
'logging.level': 'string',
|
|
108
|
+
'logging.dir': 'string',
|
|
109
|
+
'workspaceRoot': 'string',
|
|
110
|
+
};
|
|
111
|
+
exports.ALL_KEYS = Object.keys(FIELD_TYPES);
|
|
112
|
+
function readConfigJson() {
|
|
113
|
+
if (!fs.existsSync(exports.CONFIG_FILE))
|
|
114
|
+
return null;
|
|
115
|
+
let raw;
|
|
116
|
+
try {
|
|
117
|
+
raw = fs.readFileSync(exports.CONFIG_FILE, 'utf-8');
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
throw new Error(`Cannot read ${exports.CONFIG_FILE}: ${e.message}`);
|
|
121
|
+
}
|
|
122
|
+
let parsed;
|
|
123
|
+
try {
|
|
124
|
+
parsed = JSON.parse(raw);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
throw new Error(`Invalid JSON in ${exports.CONFIG_FILE}: ${e.message}\n` +
|
|
128
|
+
`Fix the file manually or delete it and run: rag-setup`);
|
|
129
|
+
}
|
|
130
|
+
const result = jsonSchema.safeParse(parsed);
|
|
131
|
+
if (!result.success) {
|
|
132
|
+
const issues = result.error.issues.map(i => ` ${i.path.join('.')}: ${i.message}`).join('\n');
|
|
133
|
+
throw new Error(`Invalid config in ${exports.CONFIG_FILE}:\n${issues}\n` +
|
|
134
|
+
`Fix with: rag-config set <key> <value>`);
|
|
135
|
+
}
|
|
136
|
+
return result.data;
|
|
137
|
+
}
|
|
138
|
+
function writeConfigJson(data) {
|
|
139
|
+
fs.mkdirSync(exports.CONFIG_DIR, { recursive: true });
|
|
140
|
+
fs.writeFileSync(exports.CONFIG_FILE, JSON.stringify(data, null, 2) + '\n', { mode: 0o600 });
|
|
141
|
+
}
|
|
142
|
+
function getNestedValue(cfg, key) {
|
|
143
|
+
const parts = key.split('.');
|
|
144
|
+
let cur = cfg;
|
|
145
|
+
for (const p of parts) {
|
|
146
|
+
if (cur == null || typeof cur !== 'object')
|
|
147
|
+
return undefined;
|
|
148
|
+
cur = cur[p];
|
|
149
|
+
}
|
|
150
|
+
return cur;
|
|
151
|
+
}
|
|
152
|
+
function coerceValue(key, raw) {
|
|
153
|
+
const type = FIELD_TYPES[key];
|
|
154
|
+
if (type === 'number') {
|
|
155
|
+
const n = Number(raw);
|
|
156
|
+
if (raw.trim() === '' || isNaN(n))
|
|
157
|
+
throw new Error(`${key} must be a number, got: ${raw}`);
|
|
158
|
+
return n;
|
|
159
|
+
}
|
|
160
|
+
if (type === 'boolean') {
|
|
161
|
+
if (raw !== 'true' && raw !== 'false')
|
|
162
|
+
throw new Error(`${key} must be "true" or "false", got: ${raw}`);
|
|
163
|
+
return raw === 'true';
|
|
164
|
+
}
|
|
165
|
+
return raw;
|
|
166
|
+
}
|
|
167
|
+
function setNestedValue(cfg, key, raw) {
|
|
168
|
+
if (!FIELD_TYPES[key])
|
|
169
|
+
throw new Error(`Unknown config key: ${key}\nValid keys: ${exports.ALL_KEYS.join(', ')}`);
|
|
170
|
+
const value = coerceValue(key, raw);
|
|
171
|
+
const parts = key.split('.');
|
|
172
|
+
const clone = JSON.parse(JSON.stringify(cfg));
|
|
173
|
+
if (parts.length === 1) {
|
|
174
|
+
clone[parts[0]] = value;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
if (typeof clone[parts[0]] !== 'object' || !clone[parts[0]])
|
|
178
|
+
clone[parts[0]] = {};
|
|
179
|
+
clone[parts[0]][parts[1]] = value;
|
|
180
|
+
}
|
|
181
|
+
return clone;
|
|
182
|
+
}
|
|
183
|
+
function deleteNestedValue(cfg, key) {
|
|
184
|
+
if (!FIELD_TYPES[key])
|
|
185
|
+
throw new Error(`Unknown config key: ${key}`);
|
|
186
|
+
const parts = key.split('.');
|
|
187
|
+
const clone = JSON.parse(JSON.stringify(cfg));
|
|
188
|
+
if (parts.length === 1) {
|
|
189
|
+
delete clone[parts[0]];
|
|
190
|
+
}
|
|
191
|
+
else if (clone[parts[0]] && typeof clone[parts[0]] === 'object') {
|
|
192
|
+
delete clone[parts[0]][parts[1]];
|
|
193
|
+
if (Object.keys(clone[parts[0]]).length === 0)
|
|
194
|
+
delete clone[parts[0]];
|
|
195
|
+
}
|
|
196
|
+
return clone;
|
|
197
|
+
}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -1,27 +1,41 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
1
|
+
export declare class ConfigError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class Config {
|
|
5
|
+
private readonly data;
|
|
6
|
+
get db(): {
|
|
3
7
|
host: string;
|
|
4
8
|
port: number;
|
|
5
9
|
username: string;
|
|
6
10
|
password: string;
|
|
7
11
|
database: string;
|
|
8
12
|
};
|
|
9
|
-
ollama: {
|
|
13
|
+
get ollama(): {
|
|
10
14
|
host: string;
|
|
11
15
|
model: string;
|
|
16
|
+
rerankerModel: string;
|
|
17
|
+
rerankerUrl: string;
|
|
12
18
|
};
|
|
13
|
-
indexer: {
|
|
19
|
+
get indexer(): {
|
|
14
20
|
chunkSize: number;
|
|
15
21
|
chunkOverlap: number;
|
|
16
22
|
batchSize: number;
|
|
23
|
+
astBatchSize: number;
|
|
17
24
|
};
|
|
18
|
-
search: {
|
|
25
|
+
get search(): {
|
|
19
26
|
similarityThreshold: number;
|
|
20
27
|
defaultLimit: number;
|
|
21
28
|
maxLimit: number;
|
|
22
29
|
autoTranslate: boolean;
|
|
23
30
|
translateModel: string;
|
|
31
|
+
rerankerEnabled: boolean;
|
|
32
|
+
rerankerOverfetch: number;
|
|
24
33
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
get logging(): {
|
|
35
|
+
level: "error" | "debug" | "info" | "warn";
|
|
36
|
+
dir?: string | undefined;
|
|
37
|
+
};
|
|
38
|
+
get workspaceRoot(): string;
|
|
39
|
+
constructor();
|
|
40
|
+
private deriveDbName;
|
|
41
|
+
}
|
package/dist/src/config.js
CHANGED
|
@@ -33,68 +33,113 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.Config = exports.ConfigError = void 0;
|
|
37
37
|
const os = __importStar(require("os"));
|
|
38
38
|
const zod_1 = require("zod");
|
|
39
|
+
const config_store_1 = require("./config-store");
|
|
39
40
|
const constants_1 = require("./constants");
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
class ConfigError extends Error {
|
|
42
|
+
constructor(message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = 'ConfigError';
|
|
45
|
+
}
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
47
|
+
exports.ConfigError = ConfigError;
|
|
48
|
+
const resolvedSchema = zod_1.z.object({
|
|
49
|
+
db: zod_1.z.object({
|
|
50
|
+
host: zod_1.z.string().min(1, 'required — run rag-setup'),
|
|
51
|
+
port: zod_1.z.number().int().positive().default(5433),
|
|
52
|
+
username: zod_1.z.string().min(1, 'required — run rag-setup'),
|
|
53
|
+
password: zod_1.z.string().min(1, 'required — run rag-setup'),
|
|
54
|
+
database: zod_1.z.string().min(1),
|
|
55
|
+
}),
|
|
56
|
+
ollama: zod_1.z.object({
|
|
57
|
+
host: zod_1.z.string().min(1).default('http://localhost:11434'),
|
|
58
|
+
model: zod_1.z.string().min(1).default(constants_1.DEFAULT_EMBED_MODEL),
|
|
59
|
+
rerankerModel: zod_1.z.string().default(''),
|
|
60
|
+
rerankerUrl: zod_1.z.string().min(1),
|
|
61
|
+
}),
|
|
62
|
+
indexer: zod_1.z.object({
|
|
63
|
+
chunkSize: zod_1.z.number().int().positive().default(1500),
|
|
64
|
+
chunkOverlap: zod_1.z.number().int().min(0).default(200),
|
|
65
|
+
batchSize: zod_1.z.number().int().positive().default(5),
|
|
66
|
+
astBatchSize: zod_1.z.number().int().positive().default(3000),
|
|
67
|
+
}),
|
|
68
|
+
search: zod_1.z.object({
|
|
69
|
+
similarityThreshold: zod_1.z.number().min(0).max(1).default(0.6),
|
|
70
|
+
defaultLimit: zod_1.z.number().int().positive().default(5),
|
|
71
|
+
maxLimit: zod_1.z.number().int().positive().default(20),
|
|
72
|
+
autoTranslate: zod_1.z.boolean().default(false),
|
|
73
|
+
translateModel: zod_1.z.string().default('llama3.2'),
|
|
74
|
+
rerankerEnabled: zod_1.z.boolean().default(false),
|
|
75
|
+
rerankerOverfetch: zod_1.z.number().int().min(1).max(20).default(3),
|
|
76
|
+
}),
|
|
77
|
+
logging: zod_1.z.object({
|
|
78
|
+
level: zod_1.z.enum(['debug', 'info', 'warn', 'error']).default('error'),
|
|
79
|
+
dir: zod_1.z.string().optional(),
|
|
80
|
+
}),
|
|
81
|
+
workspaceRoot: zod_1.z.string().default(''),
|
|
65
82
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
83
|
+
class Config {
|
|
84
|
+
data;
|
|
85
|
+
get db() { return this.data.db; }
|
|
86
|
+
get ollama() { return this.data.ollama; }
|
|
87
|
+
get indexer() { return this.data.indexer; }
|
|
88
|
+
get search() { return this.data.search; }
|
|
89
|
+
get logging() { return this.data.logging; }
|
|
90
|
+
get workspaceRoot() { return this.data.workspaceRoot; }
|
|
91
|
+
constructor() {
|
|
92
|
+
const raw = (0, config_store_1.readConfigJson)();
|
|
93
|
+
if (!raw)
|
|
94
|
+
throw new ConfigError('Config not found. Run rag-setup.');
|
|
95
|
+
const ollamaHost = raw.ollama?.host ?? 'http://localhost:11434';
|
|
96
|
+
const result = resolvedSchema.safeParse({
|
|
97
|
+
db: {
|
|
98
|
+
host: raw.db?.host,
|
|
99
|
+
port: raw.db?.port,
|
|
100
|
+
username: raw.db?.user,
|
|
101
|
+
password: raw.db?.password,
|
|
102
|
+
database: raw.db?.name ?? this.deriveDbName(),
|
|
103
|
+
},
|
|
104
|
+
ollama: {
|
|
105
|
+
host: raw.ollama?.host,
|
|
106
|
+
model: raw.ollama?.model,
|
|
107
|
+
rerankerModel: raw.reranker?.model,
|
|
108
|
+
rerankerUrl: raw.reranker?.url ?? `${ollamaHost}/api/rerank`,
|
|
109
|
+
},
|
|
110
|
+
indexer: {
|
|
111
|
+
chunkSize: raw.indexing?.chunkSize,
|
|
112
|
+
chunkOverlap: raw.indexing?.chunkOverlap,
|
|
113
|
+
batchSize: raw.indexing?.embedBatchSize,
|
|
114
|
+
astBatchSize: raw.indexing?.astBatchSize,
|
|
115
|
+
},
|
|
116
|
+
search: {
|
|
117
|
+
similarityThreshold: raw.search?.similarityThreshold,
|
|
118
|
+
defaultLimit: raw.search?.defaultLimit,
|
|
119
|
+
maxLimit: raw.search?.maxLimit,
|
|
120
|
+
autoTranslate: raw.search?.autoTranslate,
|
|
121
|
+
translateModel: raw.search?.translateModel,
|
|
122
|
+
rerankerEnabled: raw.reranker?.enabled,
|
|
123
|
+
rerankerOverfetch: raw.reranker?.overfetch,
|
|
124
|
+
},
|
|
125
|
+
logging: {
|
|
126
|
+
level: raw.logging?.level,
|
|
127
|
+
dir: raw.logging?.dir,
|
|
128
|
+
},
|
|
129
|
+
workspaceRoot: raw.workspaceRoot,
|
|
130
|
+
});
|
|
131
|
+
if (!result.success) {
|
|
132
|
+
const issues = result.error.issues
|
|
133
|
+
.map(i => ` ${i.path.join('.')}: ${i.message}`)
|
|
134
|
+
.join('\n');
|
|
135
|
+
throw new ConfigError(`Invalid config:\n${issues}\nRun rag-setup or: rag-config set <key> <value>`);
|
|
136
|
+
}
|
|
137
|
+
this.data = result.data;
|
|
138
|
+
}
|
|
139
|
+
deriveDbName() {
|
|
140
|
+
const username = os.userInfo().username;
|
|
141
|
+
const sanitized = username.toLowerCase().replace(/[^a-z0-9_]/g, '_');
|
|
142
|
+
return 'rag_' + (sanitized || 'user');
|
|
71
143
|
}
|
|
72
|
-
process.exit(1);
|
|
73
144
|
}
|
|
74
|
-
|
|
75
|
-
exports.config = {
|
|
76
|
-
db: {
|
|
77
|
-
host: env.DB_HOST,
|
|
78
|
-
port: env.DB_PORT,
|
|
79
|
-
username: env.DB_USER,
|
|
80
|
-
password: env.DB_PASS,
|
|
81
|
-
database: env.DB_NAME ?? deriveDbName(),
|
|
82
|
-
},
|
|
83
|
-
ollama: {
|
|
84
|
-
host: env.OLLAMA_HOST,
|
|
85
|
-
model: env.OLLAMA_MODEL,
|
|
86
|
-
},
|
|
87
|
-
indexer: {
|
|
88
|
-
chunkSize: env.CHUNK_SIZE,
|
|
89
|
-
chunkOverlap: env.CHUNK_OVERLAP,
|
|
90
|
-
batchSize: env.EMBED_BATCH_SIZE,
|
|
91
|
-
},
|
|
92
|
-
search: {
|
|
93
|
-
similarityThreshold: env.SIMILARITY_THRESHOLD,
|
|
94
|
-
defaultLimit: env.SEARCH_DEFAULT_LIMIT,
|
|
95
|
-
maxLimit: env.SEARCH_MAX_LIMIT,
|
|
96
|
-
autoTranslate: env.AUTO_TRANSLATE,
|
|
97
|
-
translateModel: env.TRANSLATE_MODEL,
|
|
98
|
-
},
|
|
99
|
-
workspaceRoot: env.WORKSPACE_ROOT ?? '',
|
|
100
|
-
};
|
|
145
|
+
exports.Config = Config;
|
package/dist/src/container.d.ts
CHANGED
package/dist/src/container.js
CHANGED
|
@@ -10,12 +10,13 @@ const SearcherService_1 = require("./services/SearcherService");
|
|
|
10
10
|
const McpServer_1 = require("./services/McpServer");
|
|
11
11
|
const LoggerService_1 = require("./services/LoggerService");
|
|
12
12
|
function createContainer(loggerName) {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
13
|
+
const config = new config_1.Config();
|
|
14
|
+
const logger = LoggerService_1.LoggerService.fromConfig(config.logging, loggerName);
|
|
15
|
+
const db = new DatabaseService_1.DatabaseService(config);
|
|
16
|
+
const embedder = new OllamaEmbedder_1.OllamaEmbedder(config);
|
|
16
17
|
const ast = new AstParserService_1.AstParserService(logger);
|
|
17
|
-
const indexer = new IndexerService_1.IndexerService(db, embedder, ast,
|
|
18
|
-
const searcher = new SearcherService_1.SearcherService(db, embedder,
|
|
19
|
-
const mcp = new McpServer_1.McpServer(searcher,
|
|
20
|
-
return { config
|
|
18
|
+
const indexer = new IndexerService_1.IndexerService(db, embedder, ast, config, logger);
|
|
19
|
+
const searcher = new SearcherService_1.SearcherService(db, embedder, config, logger);
|
|
20
|
+
const mcp = new McpServer_1.McpServer(searcher, config, logger);
|
|
21
|
+
return { config, db, indexer, searcher, mcp, logger };
|
|
21
22
|
}
|
package/dist/src/db/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { codeChunk, codeDependency, codeSymbol } from './schema';
|
|
1
|
+
export { codeChunk, codeDependency, codeSymbol, codeCall } from './schema';
|
|
2
2
|
export type { CodeChunkInsert } from './schema';
|
package/dist/src/db/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.codeSymbol = exports.codeDependency = exports.codeChunk = void 0;
|
|
3
|
+
exports.codeCall = exports.codeSymbol = exports.codeDependency = exports.codeChunk = void 0;
|
|
4
4
|
var schema_1 = require("./schema");
|
|
5
5
|
Object.defineProperty(exports, "codeChunk", { enumerable: true, get: function () { return schema_1.codeChunk; } });
|
|
6
6
|
Object.defineProperty(exports, "codeDependency", { enumerable: true, get: function () { return schema_1.codeDependency; } });
|
|
7
7
|
Object.defineProperty(exports, "codeSymbol", { enumerable: true, get: function () { return schema_1.codeSymbol; } });
|
|
8
|
+
Object.defineProperty(exports, "codeCall", { enumerable: true, get: function () { return schema_1.codeCall; } });
|
package/dist/src/db/schema.d.ts
CHANGED
|
@@ -414,4 +414,164 @@ export declare const codeSymbol: import("drizzle-orm/pg-core").PgTableWithColumn
|
|
|
414
414
|
};
|
|
415
415
|
dialect: "pg";
|
|
416
416
|
}>;
|
|
417
|
+
export declare const codeCall: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
418
|
+
name: "code_call";
|
|
419
|
+
schema: undefined;
|
|
420
|
+
columns: {
|
|
421
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
422
|
+
name: "id";
|
|
423
|
+
tableName: "code_call";
|
|
424
|
+
dataType: "string";
|
|
425
|
+
columnType: "PgUUID";
|
|
426
|
+
data: string;
|
|
427
|
+
driverParam: string;
|
|
428
|
+
notNull: true;
|
|
429
|
+
hasDefault: true;
|
|
430
|
+
isPrimaryKey: true;
|
|
431
|
+
isAutoincrement: false;
|
|
432
|
+
hasRuntimeDefault: false;
|
|
433
|
+
enumValues: undefined;
|
|
434
|
+
baseColumn: never;
|
|
435
|
+
identity: undefined;
|
|
436
|
+
generated: undefined;
|
|
437
|
+
}, {}, {}>;
|
|
438
|
+
project: import("drizzle-orm/pg-core").PgColumn<{
|
|
439
|
+
name: "project";
|
|
440
|
+
tableName: "code_call";
|
|
441
|
+
dataType: "string";
|
|
442
|
+
columnType: "PgText";
|
|
443
|
+
data: string;
|
|
444
|
+
driverParam: string;
|
|
445
|
+
notNull: true;
|
|
446
|
+
hasDefault: false;
|
|
447
|
+
isPrimaryKey: false;
|
|
448
|
+
isAutoincrement: false;
|
|
449
|
+
hasRuntimeDefault: false;
|
|
450
|
+
enumValues: [string, ...string[]];
|
|
451
|
+
baseColumn: never;
|
|
452
|
+
identity: undefined;
|
|
453
|
+
generated: undefined;
|
|
454
|
+
}, {}, {}>;
|
|
455
|
+
fromFile: import("drizzle-orm/pg-core").PgColumn<{
|
|
456
|
+
name: "fromFile";
|
|
457
|
+
tableName: "code_call";
|
|
458
|
+
dataType: "string";
|
|
459
|
+
columnType: "PgText";
|
|
460
|
+
data: string;
|
|
461
|
+
driverParam: string;
|
|
462
|
+
notNull: true;
|
|
463
|
+
hasDefault: false;
|
|
464
|
+
isPrimaryKey: false;
|
|
465
|
+
isAutoincrement: false;
|
|
466
|
+
hasRuntimeDefault: false;
|
|
467
|
+
enumValues: [string, ...string[]];
|
|
468
|
+
baseColumn: never;
|
|
469
|
+
identity: undefined;
|
|
470
|
+
generated: undefined;
|
|
471
|
+
}, {}, {}>;
|
|
472
|
+
fromSymbol: import("drizzle-orm/pg-core").PgColumn<{
|
|
473
|
+
name: "fromSymbol";
|
|
474
|
+
tableName: "code_call";
|
|
475
|
+
dataType: "string";
|
|
476
|
+
columnType: "PgText";
|
|
477
|
+
data: string;
|
|
478
|
+
driverParam: string;
|
|
479
|
+
notNull: false;
|
|
480
|
+
hasDefault: false;
|
|
481
|
+
isPrimaryKey: false;
|
|
482
|
+
isAutoincrement: false;
|
|
483
|
+
hasRuntimeDefault: false;
|
|
484
|
+
enumValues: [string, ...string[]];
|
|
485
|
+
baseColumn: never;
|
|
486
|
+
identity: undefined;
|
|
487
|
+
generated: undefined;
|
|
488
|
+
}, {}, {}>;
|
|
489
|
+
calleeName: import("drizzle-orm/pg-core").PgColumn<{
|
|
490
|
+
name: "calleeName";
|
|
491
|
+
tableName: "code_call";
|
|
492
|
+
dataType: "string";
|
|
493
|
+
columnType: "PgText";
|
|
494
|
+
data: string;
|
|
495
|
+
driverParam: string;
|
|
496
|
+
notNull: true;
|
|
497
|
+
hasDefault: false;
|
|
498
|
+
isPrimaryKey: false;
|
|
499
|
+
isAutoincrement: false;
|
|
500
|
+
hasRuntimeDefault: false;
|
|
501
|
+
enumValues: [string, ...string[]];
|
|
502
|
+
baseColumn: never;
|
|
503
|
+
identity: undefined;
|
|
504
|
+
generated: undefined;
|
|
505
|
+
}, {}, {}>;
|
|
506
|
+
calleeFile: import("drizzle-orm/pg-core").PgColumn<{
|
|
507
|
+
name: "calleeFile";
|
|
508
|
+
tableName: "code_call";
|
|
509
|
+
dataType: "string";
|
|
510
|
+
columnType: "PgText";
|
|
511
|
+
data: string;
|
|
512
|
+
driverParam: string;
|
|
513
|
+
notNull: true;
|
|
514
|
+
hasDefault: false;
|
|
515
|
+
isPrimaryKey: false;
|
|
516
|
+
isAutoincrement: false;
|
|
517
|
+
hasRuntimeDefault: false;
|
|
518
|
+
enumValues: [string, ...string[]];
|
|
519
|
+
baseColumn: never;
|
|
520
|
+
identity: undefined;
|
|
521
|
+
generated: undefined;
|
|
522
|
+
}, {}, {}>;
|
|
523
|
+
calleeSymbol: import("drizzle-orm/pg-core").PgColumn<{
|
|
524
|
+
name: "calleeSymbol";
|
|
525
|
+
tableName: "code_call";
|
|
526
|
+
dataType: "string";
|
|
527
|
+
columnType: "PgText";
|
|
528
|
+
data: string;
|
|
529
|
+
driverParam: string;
|
|
530
|
+
notNull: false;
|
|
531
|
+
hasDefault: false;
|
|
532
|
+
isPrimaryKey: false;
|
|
533
|
+
isAutoincrement: false;
|
|
534
|
+
hasRuntimeDefault: false;
|
|
535
|
+
enumValues: [string, ...string[]];
|
|
536
|
+
baseColumn: never;
|
|
537
|
+
identity: undefined;
|
|
538
|
+
generated: undefined;
|
|
539
|
+
}, {}, {}>;
|
|
540
|
+
line: import("drizzle-orm/pg-core").PgColumn<{
|
|
541
|
+
name: "line";
|
|
542
|
+
tableName: "code_call";
|
|
543
|
+
dataType: "number";
|
|
544
|
+
columnType: "PgInteger";
|
|
545
|
+
data: number;
|
|
546
|
+
driverParam: string | number;
|
|
547
|
+
notNull: false;
|
|
548
|
+
hasDefault: false;
|
|
549
|
+
isPrimaryKey: false;
|
|
550
|
+
isAutoincrement: false;
|
|
551
|
+
hasRuntimeDefault: false;
|
|
552
|
+
enumValues: undefined;
|
|
553
|
+
baseColumn: never;
|
|
554
|
+
identity: undefined;
|
|
555
|
+
generated: undefined;
|
|
556
|
+
}, {}, {}>;
|
|
557
|
+
col: import("drizzle-orm/pg-core").PgColumn<{
|
|
558
|
+
name: "col";
|
|
559
|
+
tableName: "code_call";
|
|
560
|
+
dataType: "number";
|
|
561
|
+
columnType: "PgInteger";
|
|
562
|
+
data: number;
|
|
563
|
+
driverParam: string | number;
|
|
564
|
+
notNull: false;
|
|
565
|
+
hasDefault: false;
|
|
566
|
+
isPrimaryKey: false;
|
|
567
|
+
isAutoincrement: false;
|
|
568
|
+
hasRuntimeDefault: false;
|
|
569
|
+
enumValues: undefined;
|
|
570
|
+
baseColumn: never;
|
|
571
|
+
identity: undefined;
|
|
572
|
+
generated: undefined;
|
|
573
|
+
}, {}, {}>;
|
|
574
|
+
};
|
|
575
|
+
dialect: "pg";
|
|
576
|
+
}>;
|
|
417
577
|
export type CodeChunkInsert = typeof codeChunk.$inferInsert;
|
package/dist/src/db/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.codeSymbol = exports.codeDependency = exports.codeChunk = void 0;
|
|
3
|
+
exports.codeCall = exports.codeSymbol = exports.codeDependency = exports.codeChunk = void 0;
|
|
4
4
|
const pg_core_1 = require("drizzle-orm/pg-core");
|
|
5
5
|
const vector = (0, pg_core_1.customType)({
|
|
6
6
|
dataType(config) { return `vector(${config?.dimensions ?? 1024})`; },
|
|
@@ -34,3 +34,14 @@ exports.codeSymbol = (0, pg_core_1.pgTable)('code_symbol', {
|
|
|
34
34
|
line: (0, pg_core_1.integer)('line'),
|
|
35
35
|
col: (0, pg_core_1.integer)('col'),
|
|
36
36
|
});
|
|
37
|
+
exports.codeCall = (0, pg_core_1.pgTable)('code_call', {
|
|
38
|
+
id: (0, pg_core_1.uuid)('id').primaryKey().defaultRandom(),
|
|
39
|
+
project: (0, pg_core_1.text)('project').notNull(),
|
|
40
|
+
fromFile: (0, pg_core_1.text)('fromFile').notNull(),
|
|
41
|
+
fromSymbol: (0, pg_core_1.text)('fromSymbol'),
|
|
42
|
+
calleeName: (0, pg_core_1.text)('calleeName').notNull(),
|
|
43
|
+
calleeFile: (0, pg_core_1.text)('calleeFile').notNull(),
|
|
44
|
+
calleeSymbol: (0, pg_core_1.text)('calleeSymbol'),
|
|
45
|
+
line: (0, pg_core_1.integer)('line'),
|
|
46
|
+
col: (0, pg_core_1.integer)('col'),
|
|
47
|
+
});
|