monomind 1.18.8 → 1.18.10
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/packages/@monomind/cli/dist/src/commands/doctor-project-checks.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +17 -1
- package/packages/@monomind/cli/dist/src/commands/doctor.js +15 -1
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.js +1 -2
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.d.ts +1 -2
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.js +2 -117
- package/packages/@monomind/cli/dist/src/commands/hooks.js +1 -2
- package/packages/@monomind/cli/dist/src/commands/index.d.ts +0 -4
- package/packages/@monomind/cli/dist/src/commands/index.js +0 -22
- package/packages/@monomind/cli/dist/src/init/executor.d.ts +3 -0
- package/packages/@monomind/cli/dist/src/init/executor.js +20 -111
- package/packages/@monomind/cli/dist/src/mcp-client.js +0 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/index.d.ts +0 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/index.js +0 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/track-trends.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/test-generation/suggest-tests.d.ts +4 -4
- package/packages/@monomind/cli/package.json +1 -1
- package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.d.ts +0 -134
- package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.js +0 -340
- package/packages/@monomind/cli/dist/src/benchmarks/metric-evaluators.d.ts +0 -36
- package/packages/@monomind/cli/dist/src/benchmarks/metric-evaluators.js +0 -125
- package/packages/@monomind/cli/dist/src/commands/benchmark.d.ts +0 -10
- package/packages/@monomind/cli/dist/src/commands/benchmark.js +0 -586
- package/packages/@monomind/cli/dist/src/commands/migrate.d.ts +0 -8
- package/packages/@monomind/cli/dist/src/commands/migrate.js +0 -789
- package/packages/@monomind/cli/dist/src/commands/monovector/backup.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/monovector/backup.js +0 -752
- package/packages/@monomind/cli/dist/src/commands/monovector/benchmark.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/monovector/benchmark.js +0 -502
- package/packages/@monomind/cli/dist/src/commands/monovector/import.d.ts +0 -18
- package/packages/@monomind/cli/dist/src/commands/monovector/import.js +0 -374
- package/packages/@monomind/cli/dist/src/commands/monovector/index.d.ts +0 -29
- package/packages/@monomind/cli/dist/src/commands/monovector/index.js +0 -129
- package/packages/@monomind/cli/dist/src/commands/monovector/init.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/monovector/init.js +0 -481
- package/packages/@monomind/cli/dist/src/commands/monovector/migrate.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/monovector/migrate.js +0 -500
- package/packages/@monomind/cli/dist/src/commands/monovector/optimize.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/monovector/optimize.js +0 -515
- package/packages/@monomind/cli/dist/src/commands/monovector/setup.d.ts +0 -18
- package/packages/@monomind/cli/dist/src/commands/monovector/setup.js +0 -775
- package/packages/@monomind/cli/dist/src/commands/monovector/status.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/monovector/status.js +0 -491
- package/packages/@monomind/cli/dist/src/commands/progress.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/progress.js +0 -261
- package/packages/@monomind/cli/dist/src/mcp-tools/progress-tools.d.ts +0 -14
- package/packages/@monomind/cli/dist/src/mcp-tools/progress-tools.js +0 -353
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI MonoVector Init Command
|
|
3
|
-
* Initialize MonoVector PostgreSQL Bridge
|
|
4
|
-
*/
|
|
5
|
-
import { output } from '../../output.js';
|
|
6
|
-
import { confirm, input } from '../../prompt.js';
|
|
7
|
-
/**
|
|
8
|
-
* Get PostgreSQL connection config from context flags and environment
|
|
9
|
-
*/
|
|
10
|
-
function getConnectionConfig(ctx) {
|
|
11
|
-
return {
|
|
12
|
-
host: ctx.flags.host || process.env.PGHOST || 'localhost',
|
|
13
|
-
port: parseInt(ctx.flags.port || process.env.PGPORT || '5432', 10),
|
|
14
|
-
database: ctx.flags.database || process.env.PGDATABASE || '',
|
|
15
|
-
user: ctx.flags.user || process.env.PGUSER || 'postgres',
|
|
16
|
-
password: ctx.flags.password || process.env.PGPASSWORD || '',
|
|
17
|
-
ssl: ctx.flags.ssl || process.env.PGSSLMODE === 'require',
|
|
18
|
-
schema: ctx.flags.schema || 'monomind',
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
const IDENTIFIER_RE = /^[a-zA-Z_][a-zA-Z0-9_]{0,63}$/;
|
|
22
|
-
function validateIdentifier(name, label) {
|
|
23
|
-
if (!IDENTIFIER_RE.test(name))
|
|
24
|
-
return `Invalid ${label}: "${name}" (must match [a-zA-Z_][a-zA-Z0-9_]{0,63})`;
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Initialize MonoVector in PostgreSQL
|
|
29
|
-
*/
|
|
30
|
-
export const initCommand = {
|
|
31
|
-
name: 'init',
|
|
32
|
-
description: 'Initialize MonoVector in PostgreSQL',
|
|
33
|
-
options: [
|
|
34
|
-
{
|
|
35
|
-
name: 'host',
|
|
36
|
-
short: 'h',
|
|
37
|
-
description: 'PostgreSQL host',
|
|
38
|
-
type: 'string',
|
|
39
|
-
default: 'localhost',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'port',
|
|
43
|
-
short: 'p',
|
|
44
|
-
description: 'PostgreSQL port',
|
|
45
|
-
type: 'number',
|
|
46
|
-
default: 5432,
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: 'database',
|
|
50
|
-
short: 'd',
|
|
51
|
-
description: 'Database name',
|
|
52
|
-
type: 'string',
|
|
53
|
-
required: true,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'user',
|
|
57
|
-
short: 'u',
|
|
58
|
-
description: 'Database user',
|
|
59
|
-
type: 'string',
|
|
60
|
-
default: 'postgres',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: 'password',
|
|
64
|
-
description: 'Database password (or use PGPASSWORD env)',
|
|
65
|
-
type: 'string',
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: 'ssl',
|
|
69
|
-
description: 'Enable SSL connection',
|
|
70
|
-
type: 'boolean',
|
|
71
|
-
default: false,
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: 'schema',
|
|
75
|
-
short: 's',
|
|
76
|
-
description: 'Schema name for MonoVector tables',
|
|
77
|
-
type: 'string',
|
|
78
|
-
default: 'monomind',
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: 'force',
|
|
82
|
-
short: 'f',
|
|
83
|
-
description: 'Force re-initialization (drops existing schema)',
|
|
84
|
-
type: 'boolean',
|
|
85
|
-
default: false,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: 'dimensions',
|
|
89
|
-
description: 'Default vector dimensions',
|
|
90
|
-
type: 'number',
|
|
91
|
-
default: 1536,
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
name: 'index-type',
|
|
95
|
-
description: 'Default index type (hnsw, ivfflat)',
|
|
96
|
-
type: 'string',
|
|
97
|
-
default: 'hnsw',
|
|
98
|
-
choices: ['hnsw', 'ivfflat'],
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
examples: [
|
|
102
|
-
{ command: 'monomind monovector init -d mydb', description: 'Initialize with database name' },
|
|
103
|
-
{ command: 'monomind monovector init -d mydb -h db.example.com --ssl', description: 'Remote with SSL' },
|
|
104
|
-
{ command: 'monomind monovector init -d mydb --force', description: 'Force re-initialization' },
|
|
105
|
-
{ command: 'monomind monovector init -d mydb --dimensions 768', description: 'Custom vector dimensions' },
|
|
106
|
-
],
|
|
107
|
-
action: async (ctx) => {
|
|
108
|
-
let config = getConnectionConfig(ctx);
|
|
109
|
-
output.writeln();
|
|
110
|
-
output.writeln(output.bold('MonoVector PostgreSQL Initialization'));
|
|
111
|
-
output.writeln(output.dim('='.repeat(60)));
|
|
112
|
-
output.writeln();
|
|
113
|
-
// Interactive mode if database not specified
|
|
114
|
-
if (!config.database && ctx.interactive) {
|
|
115
|
-
config.database = await input({
|
|
116
|
-
message: 'Database name:',
|
|
117
|
-
validate: (v) => v.length > 0 || 'Database name is required',
|
|
118
|
-
});
|
|
119
|
-
const useRemote = await confirm({
|
|
120
|
-
message: 'Connect to remote PostgreSQL?',
|
|
121
|
-
default: false,
|
|
122
|
-
});
|
|
123
|
-
if (useRemote) {
|
|
124
|
-
config.host = await input({
|
|
125
|
-
message: 'PostgreSQL host:',
|
|
126
|
-
default: 'localhost',
|
|
127
|
-
});
|
|
128
|
-
config.port = parseInt(await input({
|
|
129
|
-
message: 'PostgreSQL port:',
|
|
130
|
-
default: '5432',
|
|
131
|
-
}), 10);
|
|
132
|
-
config.ssl = await confirm({
|
|
133
|
-
message: 'Enable SSL?',
|
|
134
|
-
default: true,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
config.user = await input({
|
|
138
|
-
message: 'Database user:',
|
|
139
|
-
default: 'postgres',
|
|
140
|
-
});
|
|
141
|
-
if (!config.password) {
|
|
142
|
-
config.password = await input({
|
|
143
|
-
message: 'Database password (or set PGPASSWORD):',
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (!config.database) {
|
|
148
|
-
output.printError('Database name is required. Use --database or -d flag.');
|
|
149
|
-
return { success: false, exitCode: 1 };
|
|
150
|
-
}
|
|
151
|
-
const schemaErr = validateIdentifier(config.schema, 'schema');
|
|
152
|
-
if (schemaErr) {
|
|
153
|
-
output.printError(schemaErr);
|
|
154
|
-
return { success: false, exitCode: 1 };
|
|
155
|
-
}
|
|
156
|
-
const force = ctx.flags.force;
|
|
157
|
-
const dimensions = parseInt(ctx.flags.dimensions || '1536', 10);
|
|
158
|
-
if (isNaN(dimensions) || dimensions < 1 || dimensions > 65535) {
|
|
159
|
-
output.printError('--dimensions must be a positive integer up to 65535');
|
|
160
|
-
return { success: false, exitCode: 1 };
|
|
161
|
-
}
|
|
162
|
-
const indexType = ctx.flags['index-type'] || 'hnsw';
|
|
163
|
-
// Show configuration
|
|
164
|
-
output.writeln(output.highlight('Connection Configuration:'));
|
|
165
|
-
output.printTable({
|
|
166
|
-
columns: [
|
|
167
|
-
{ key: 'setting', header: 'Setting', width: 20 },
|
|
168
|
-
{ key: 'value', header: 'Value', width: 40 },
|
|
169
|
-
],
|
|
170
|
-
data: [
|
|
171
|
-
{ setting: 'Host', value: config.host },
|
|
172
|
-
{ setting: 'Port', value: String(config.port) },
|
|
173
|
-
{ setting: 'Database', value: config.database },
|
|
174
|
-
{ setting: 'User', value: config.user },
|
|
175
|
-
{ setting: 'SSL', value: config.ssl ? 'Enabled' : 'Disabled' },
|
|
176
|
-
{ setting: 'Schema', value: config.schema },
|
|
177
|
-
{ setting: 'Dimensions', value: String(dimensions) },
|
|
178
|
-
{ setting: 'Index Type', value: indexType.toUpperCase() },
|
|
179
|
-
],
|
|
180
|
-
});
|
|
181
|
-
output.writeln();
|
|
182
|
-
if (force) {
|
|
183
|
-
output.printWarning('Force mode: existing schema will be dropped!');
|
|
184
|
-
if (ctx.interactive) {
|
|
185
|
-
const confirmDrop = await confirm({
|
|
186
|
-
message: `Drop and recreate schema "${config.schema}"?`,
|
|
187
|
-
default: false,
|
|
188
|
-
});
|
|
189
|
-
if (!confirmDrop) {
|
|
190
|
-
output.printInfo('Initialization cancelled');
|
|
191
|
-
return { success: false, exitCode: 0 };
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
const spinner = output.createSpinner({ text: 'Connecting to PostgreSQL...', spinner: 'dots' });
|
|
196
|
-
spinner.start();
|
|
197
|
-
try {
|
|
198
|
-
// Check for pg module
|
|
199
|
-
let pg = null;
|
|
200
|
-
try {
|
|
201
|
-
pg = await import('pg');
|
|
202
|
-
}
|
|
203
|
-
catch {
|
|
204
|
-
spinner.fail('PostgreSQL driver not found');
|
|
205
|
-
output.printError('Install pg package: npm install pg');
|
|
206
|
-
return { success: false, exitCode: 1 };
|
|
207
|
-
}
|
|
208
|
-
// Connect to PostgreSQL
|
|
209
|
-
const client = new pg.Client({
|
|
210
|
-
host: config.host,
|
|
211
|
-
port: config.port,
|
|
212
|
-
database: config.database,
|
|
213
|
-
user: config.user,
|
|
214
|
-
password: config.password,
|
|
215
|
-
ssl: config.ssl ? { rejectUnauthorized: false } : false,
|
|
216
|
-
});
|
|
217
|
-
await client.connect();
|
|
218
|
-
spinner.succeed('Connected to PostgreSQL');
|
|
219
|
-
// Detect vector extension: prefer monovector, fall back to pgvector
|
|
220
|
-
spinner.setText('Detecting vector extension...');
|
|
221
|
-
spinner.start();
|
|
222
|
-
let vectorExtName = 'vector'; // default pgvector type name
|
|
223
|
-
let vectorTypeName = 'vector'; // SQL type used in column definitions
|
|
224
|
-
// Check for monovector extension first (ships with monovector-postgres image)
|
|
225
|
-
const monovectorResult = await client.query(`
|
|
226
|
-
SELECT extname, extversion FROM pg_extension WHERE extname = 'monovector'
|
|
227
|
-
`);
|
|
228
|
-
if (monovectorResult.rows.length > 0) {
|
|
229
|
-
vectorExtName = 'monovector';
|
|
230
|
-
vectorTypeName = 'monovector';
|
|
231
|
-
spinner.succeed(`monovector v${monovectorResult.rows[0].extversion} found`);
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
// Fall back to pgvector
|
|
235
|
-
const pgvectorResult = await client.query(`
|
|
236
|
-
SELECT extname, extversion FROM pg_extension WHERE extname = 'vector'
|
|
237
|
-
`);
|
|
238
|
-
if (pgvectorResult.rows.length > 0) {
|
|
239
|
-
vectorExtName = 'vector';
|
|
240
|
-
vectorTypeName = 'vector';
|
|
241
|
-
spinner.succeed(`pgvector v${pgvectorResult.rows[0].extversion} found`);
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
// Neither installed -- try to create monovector first, then pgvector
|
|
245
|
-
spinner.succeed('No vector extension found, attempting to create...');
|
|
246
|
-
let created = false;
|
|
247
|
-
try {
|
|
248
|
-
await client.query("CREATE EXTENSION IF NOT EXISTS monovector");
|
|
249
|
-
vectorExtName = 'monovector';
|
|
250
|
-
vectorTypeName = 'monovector';
|
|
251
|
-
spinner.succeed('monovector extension created');
|
|
252
|
-
created = true;
|
|
253
|
-
}
|
|
254
|
-
catch {
|
|
255
|
-
// monovector not available, try pgvector
|
|
256
|
-
}
|
|
257
|
-
if (!created) {
|
|
258
|
-
try {
|
|
259
|
-
await client.query("CREATE EXTENSION IF NOT EXISTS vector");
|
|
260
|
-
vectorExtName = 'vector';
|
|
261
|
-
vectorTypeName = 'vector';
|
|
262
|
-
spinner.succeed('pgvector extension created');
|
|
263
|
-
}
|
|
264
|
-
catch {
|
|
265
|
-
spinner.fail('Failed to create vector extension');
|
|
266
|
-
output.printError('Please install monovector or pgvector manually.');
|
|
267
|
-
output.printError(' monovector: https://hub.docker.com/r/nokhodian/monovector-postgres');
|
|
268
|
-
output.printError(' pgvector: https://github.com/pgvector/pgvector');
|
|
269
|
-
await client.end();
|
|
270
|
-
return { success: false, exitCode: 1 };
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
const cosineOps = vectorExtName === 'monovector' ? 'monovector_cosine_ops' : 'vector_cosine_ops';
|
|
276
|
-
// Drop schema if force mode
|
|
277
|
-
if (force) {
|
|
278
|
-
spinner.setText(`Dropping schema "${config.schema}"...`);
|
|
279
|
-
spinner.start();
|
|
280
|
-
await client.query(`DROP SCHEMA IF EXISTS ${config.schema} CASCADE`);
|
|
281
|
-
spinner.succeed(`Schema "${config.schema}" dropped`);
|
|
282
|
-
}
|
|
283
|
-
// Create schema
|
|
284
|
-
spinner.setText(`Creating schema "${config.schema}"...`);
|
|
285
|
-
spinner.start();
|
|
286
|
-
await client.query(`CREATE SCHEMA IF NOT EXISTS ${config.schema}`);
|
|
287
|
-
spinner.succeed(`Schema "${config.schema}" created`);
|
|
288
|
-
// Create tables
|
|
289
|
-
spinner.setText('Creating MonoVector tables...');
|
|
290
|
-
spinner.start();
|
|
291
|
-
// Vector embeddings table
|
|
292
|
-
await client.query(`
|
|
293
|
-
CREATE TABLE IF NOT EXISTS ${config.schema}.embeddings (
|
|
294
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
295
|
-
key VARCHAR(512) NOT NULL,
|
|
296
|
-
namespace VARCHAR(128) NOT NULL DEFAULT 'default',
|
|
297
|
-
content TEXT,
|
|
298
|
-
embedding ${vectorTypeName}(${dimensions}),
|
|
299
|
-
metadata JSONB DEFAULT '{}',
|
|
300
|
-
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
301
|
-
updated_at TIMESTAMPTZ DEFAULT NOW(),
|
|
302
|
-
UNIQUE(key, namespace)
|
|
303
|
-
)
|
|
304
|
-
`);
|
|
305
|
-
// Attention patterns table
|
|
306
|
-
await client.query(`
|
|
307
|
-
CREATE TABLE IF NOT EXISTS ${config.schema}.attention_patterns (
|
|
308
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
309
|
-
pattern_name VARCHAR(256) NOT NULL,
|
|
310
|
-
query_embedding ${vectorTypeName}(${dimensions}),
|
|
311
|
-
key_embedding ${vectorTypeName}(${dimensions}),
|
|
312
|
-
value_embedding ${vectorTypeName}(${dimensions}),
|
|
313
|
-
attention_weights JSONB,
|
|
314
|
-
context TEXT,
|
|
315
|
-
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
316
|
-
)
|
|
317
|
-
`);
|
|
318
|
-
// GNN adjacency table
|
|
319
|
-
await client.query(`
|
|
320
|
-
CREATE TABLE IF NOT EXISTS ${config.schema}.gnn_edges (
|
|
321
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
322
|
-
source_id UUID NOT NULL,
|
|
323
|
-
target_id UUID NOT NULL,
|
|
324
|
-
edge_type VARCHAR(64) NOT NULL DEFAULT 'related',
|
|
325
|
-
weight FLOAT DEFAULT 1.0,
|
|
326
|
-
metadata JSONB DEFAULT '{}',
|
|
327
|
-
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
328
|
-
UNIQUE(source_id, target_id, edge_type)
|
|
329
|
-
)
|
|
330
|
-
`);
|
|
331
|
-
// Hyperbolic embeddings table (Poincare ball)
|
|
332
|
-
await client.query(`
|
|
333
|
-
CREATE TABLE IF NOT EXISTS ${config.schema}.hyperbolic_embeddings (
|
|
334
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
335
|
-
entity_id UUID NOT NULL,
|
|
336
|
-
embedding ${vectorTypeName}(${dimensions}),
|
|
337
|
-
curvature FLOAT DEFAULT -1.0,
|
|
338
|
-
hierarchy_level INTEGER DEFAULT 0,
|
|
339
|
-
parent_id UUID,
|
|
340
|
-
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
341
|
-
)
|
|
342
|
-
`);
|
|
343
|
-
// Migrations tracking table
|
|
344
|
-
await client.query(`
|
|
345
|
-
CREATE TABLE IF NOT EXISTS ${config.schema}.migrations (
|
|
346
|
-
id SERIAL PRIMARY KEY,
|
|
347
|
-
version VARCHAR(64) NOT NULL UNIQUE,
|
|
348
|
-
name VARCHAR(256) NOT NULL,
|
|
349
|
-
applied_at TIMESTAMPTZ DEFAULT NOW(),
|
|
350
|
-
checksum VARCHAR(64)
|
|
351
|
-
)
|
|
352
|
-
`);
|
|
353
|
-
// MonoVector metadata table
|
|
354
|
-
await client.query(`
|
|
355
|
-
CREATE TABLE IF NOT EXISTS ${config.schema}.metadata (
|
|
356
|
-
key VARCHAR(128) PRIMARY KEY,
|
|
357
|
-
value JSONB NOT NULL,
|
|
358
|
-
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
359
|
-
)
|
|
360
|
-
`);
|
|
361
|
-
// Store initialization metadata
|
|
362
|
-
await client.query(`
|
|
363
|
-
INSERT INTO ${config.schema}.metadata (key, value)
|
|
364
|
-
VALUES ('monovector_version', '"1.0.0"')
|
|
365
|
-
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = NOW()
|
|
366
|
-
`);
|
|
367
|
-
await client.query(`
|
|
368
|
-
INSERT INTO ${config.schema}.metadata (key, value)
|
|
369
|
-
VALUES ('dimensions', '${dimensions}')
|
|
370
|
-
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = NOW()
|
|
371
|
-
`);
|
|
372
|
-
await client.query(`
|
|
373
|
-
INSERT INTO ${config.schema}.metadata (key, value)
|
|
374
|
-
VALUES ('initialized_at', '"${new Date().toISOString()}"')
|
|
375
|
-
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = NOW()
|
|
376
|
-
`);
|
|
377
|
-
spinner.succeed('MonoVector tables created');
|
|
378
|
-
// Create indexes
|
|
379
|
-
spinner.setText(`Creating ${indexType.toUpperCase()} indexes...`);
|
|
380
|
-
spinner.start();
|
|
381
|
-
if (indexType === 'hnsw') {
|
|
382
|
-
await client.query(`
|
|
383
|
-
CREATE INDEX IF NOT EXISTS idx_embeddings_vector_hnsw
|
|
384
|
-
ON ${config.schema}.embeddings
|
|
385
|
-
USING hnsw (embedding ${cosineOps})
|
|
386
|
-
WITH (m = 16, ef_construction = 64)
|
|
387
|
-
`);
|
|
388
|
-
await client.query(`
|
|
389
|
-
CREATE INDEX IF NOT EXISTS idx_attention_query_hnsw
|
|
390
|
-
ON ${config.schema}.attention_patterns
|
|
391
|
-
USING hnsw (query_embedding ${cosineOps})
|
|
392
|
-
WITH (m = 16, ef_construction = 64)
|
|
393
|
-
`);
|
|
394
|
-
await client.query(`
|
|
395
|
-
CREATE INDEX IF NOT EXISTS idx_hyperbolic_embedding_hnsw
|
|
396
|
-
ON ${config.schema}.hyperbolic_embeddings
|
|
397
|
-
USING hnsw (embedding ${cosineOps})
|
|
398
|
-
WITH (m = 16, ef_construction = 64)
|
|
399
|
-
`);
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
402
|
-
// IVFFlat indexes
|
|
403
|
-
await client.query(`
|
|
404
|
-
CREATE INDEX IF NOT EXISTS idx_embeddings_vector_ivfflat
|
|
405
|
-
ON ${config.schema}.embeddings
|
|
406
|
-
USING ivfflat (embedding ${cosineOps})
|
|
407
|
-
WITH (lists = 100)
|
|
408
|
-
`);
|
|
409
|
-
await client.query(`
|
|
410
|
-
CREATE INDEX IF NOT EXISTS idx_attention_query_ivfflat
|
|
411
|
-
ON ${config.schema}.attention_patterns
|
|
412
|
-
USING ivfflat (query_embedding ${cosineOps})
|
|
413
|
-
WITH (lists = 100)
|
|
414
|
-
`);
|
|
415
|
-
}
|
|
416
|
-
// Additional standard indexes
|
|
417
|
-
await client.query(`
|
|
418
|
-
CREATE INDEX IF NOT EXISTS idx_embeddings_namespace
|
|
419
|
-
ON ${config.schema}.embeddings (namespace)
|
|
420
|
-
`);
|
|
421
|
-
await client.query(`
|
|
422
|
-
CREATE INDEX IF NOT EXISTS idx_embeddings_key
|
|
423
|
-
ON ${config.schema}.embeddings (key)
|
|
424
|
-
`);
|
|
425
|
-
await client.query(`
|
|
426
|
-
CREATE INDEX IF NOT EXISTS idx_gnn_source
|
|
427
|
-
ON ${config.schema}.gnn_edges (source_id)
|
|
428
|
-
`);
|
|
429
|
-
await client.query(`
|
|
430
|
-
CREATE INDEX IF NOT EXISTS idx_gnn_target
|
|
431
|
-
ON ${config.schema}.gnn_edges (target_id)
|
|
432
|
-
`);
|
|
433
|
-
spinner.succeed(`${indexType.toUpperCase()} indexes created`);
|
|
434
|
-
// Record initial migration
|
|
435
|
-
await client.query(`
|
|
436
|
-
INSERT INTO ${config.schema}.migrations (version, name)
|
|
437
|
-
VALUES ('1.0.0', 'Initial MonoVector setup')
|
|
438
|
-
ON CONFLICT (version) DO NOTHING
|
|
439
|
-
`);
|
|
440
|
-
await client.end();
|
|
441
|
-
output.writeln();
|
|
442
|
-
output.printSuccess('MonoVector PostgreSQL Bridge initialized successfully!');
|
|
443
|
-
output.writeln();
|
|
444
|
-
output.printBox([
|
|
445
|
-
'Created tables:',
|
|
446
|
-
` - ${config.schema}.embeddings (vector storage)`,
|
|
447
|
-
` - ${config.schema}.attention_patterns (attention mechanism)`,
|
|
448
|
-
` - ${config.schema}.gnn_edges (graph neural network)`,
|
|
449
|
-
` - ${config.schema}.hyperbolic_embeddings (Poincare ball)`,
|
|
450
|
-
` - ${config.schema}.migrations (version tracking)`,
|
|
451
|
-
` - ${config.schema}.metadata (configuration)`,
|
|
452
|
-
'',
|
|
453
|
-
'Created indexes:',
|
|
454
|
-
` - ${indexType.toUpperCase()} vector similarity index`,
|
|
455
|
-
' - B-tree indexes on key, namespace',
|
|
456
|
-
' - GNN edge indexes',
|
|
457
|
-
'',
|
|
458
|
-
'Next steps:',
|
|
459
|
-
' 1. Run migrations: monomind monovector migrate --up',
|
|
460
|
-
' 2. Check status: monomind monovector status --verbose',
|
|
461
|
-
' 3. Run benchmark: monomind monovector benchmark',
|
|
462
|
-
].join('\n'), 'Initialization Complete');
|
|
463
|
-
return {
|
|
464
|
-
success: true,
|
|
465
|
-
data: {
|
|
466
|
-
schema: config.schema,
|
|
467
|
-
dimensions,
|
|
468
|
-
indexType,
|
|
469
|
-
tables: ['embeddings', 'attention_patterns', 'gnn_edges', 'hyperbolic_embeddings', 'migrations', 'metadata'],
|
|
470
|
-
},
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
catch (error) {
|
|
474
|
-
spinner.fail('Initialization failed');
|
|
475
|
-
output.printError(error instanceof Error ? error.message : String(error));
|
|
476
|
-
return { success: false, exitCode: 1 };
|
|
477
|
-
}
|
|
478
|
-
},
|
|
479
|
-
};
|
|
480
|
-
export default initCommand;
|
|
481
|
-
//# sourceMappingURL=init.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI MonoVector Migrate Command
|
|
3
|
-
* Database migration management for MonoVector
|
|
4
|
-
*/
|
|
5
|
-
import type { Command } from '../../types.js';
|
|
6
|
-
/**
|
|
7
|
-
* MonoVector migrate command
|
|
8
|
-
*/
|
|
9
|
-
export declare const migrateCommand: Command;
|
|
10
|
-
export default migrateCommand;
|
|
11
|
-
//# sourceMappingURL=migrate.d.ts.map
|