@liendev/core 0.21.0 → 0.23.0
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/config/global-config.d.ts +8 -0
- package/dist/config/global-config.d.ts.map +1 -1
- package/dist/config/global-config.js +90 -22
- package/dist/config/global-config.js.map +1 -1
- package/dist/indexer/types.d.ts +10 -0
- package/dist/indexer/types.d.ts.map +1 -1
- package/dist/vectordb/factory.d.ts.map +1 -1
- package/dist/vectordb/factory.js +93 -41
- package/dist/vectordb/factory.js.map +1 -1
- package/dist/vectordb/qdrant-payload-mapper.d.ts +34 -1
- package/dist/vectordb/qdrant-payload-mapper.d.ts.map +1 -1
- package/dist/vectordb/qdrant-payload-mapper.js +92 -41
- package/dist/vectordb/qdrant-payload-mapper.js.map +1 -1
- package/dist/vectordb/qdrant.d.ts +119 -5
- package/dist/vectordb/qdrant.d.ts.map +1 -1
- package/dist/vectordb/qdrant.js +333 -136
- package/dist/vectordb/qdrant.js.map +1 -1
- package/dist/vectordb/types.d.ts +15 -0
- package/dist/vectordb/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when config file exists but has invalid syntax or structure.
|
|
3
|
+
* This is separate from "file not found" which is expected behavior.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConfigValidationError extends Error {
|
|
6
|
+
readonly configPath: string;
|
|
7
|
+
constructor(message: string, configPath: string);
|
|
8
|
+
}
|
|
1
9
|
/**
|
|
2
10
|
* Global configuration for Lien.
|
|
3
11
|
* Only contains what truly needs configuration: storage backend choice.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../../src/config/global-config.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC/B,MAAM,CAAC,EAAE;QACP,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,MAAM,CAAC;KAEjB,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../../src/config/global-config.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;aACD,UAAU,EAAE,MAAM;gBAAnD,OAAO,EAAE,MAAM,EAAkB,UAAU,EAAE,MAAM;CAIhE;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC/B,MAAM,CAAC,EAAE;QACP,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,MAAM,CAAC;KAEjB,CAAC;CACH;AAoGD;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC,CAuB9D;AA0ED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAsBjF"}
|
|
@@ -4,6 +4,89 @@ import os from 'os';
|
|
|
4
4
|
import { exec } from 'child_process';
|
|
5
5
|
import { promisify } from 'util';
|
|
6
6
|
const execAsync = promisify(exec);
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when config file exists but has invalid syntax or structure.
|
|
9
|
+
* This is separate from "file not found" which is expected behavior.
|
|
10
|
+
*/
|
|
11
|
+
export class ConfigValidationError extends Error {
|
|
12
|
+
configPath;
|
|
13
|
+
constructor(message, configPath) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.configPath = configPath;
|
|
16
|
+
this.name = 'ConfigValidationError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Load configuration from environment variables if present.
|
|
21
|
+
*/
|
|
22
|
+
function loadConfigFromEnv() {
|
|
23
|
+
const backendEnv = process.env.LIEN_BACKEND;
|
|
24
|
+
if (!backendEnv) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
// Validate backend value
|
|
28
|
+
const validBackends = ['lancedb', 'qdrant'];
|
|
29
|
+
if (!validBackends.includes(backendEnv)) {
|
|
30
|
+
throw new ConfigValidationError(`Invalid LIEN_BACKEND environment variable: "${backendEnv}"\n` +
|
|
31
|
+
`Valid values: 'lancedb' or 'qdrant'`, '<environment>');
|
|
32
|
+
}
|
|
33
|
+
const backend = backendEnv;
|
|
34
|
+
if (backend === 'qdrant') {
|
|
35
|
+
const url = process.env.LIEN_QDRANT_URL;
|
|
36
|
+
if (!url) {
|
|
37
|
+
// Fail fast with clear error instead of returning incomplete config
|
|
38
|
+
throw new ConfigValidationError('Qdrant backend requires LIEN_QDRANT_URL environment variable.\n' +
|
|
39
|
+
'Set it with: export LIEN_QDRANT_URL=http://localhost:6333', '<environment>');
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
backend: 'qdrant',
|
|
43
|
+
qdrant: {
|
|
44
|
+
url,
|
|
45
|
+
apiKey: process.env.LIEN_QDRANT_API_KEY,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return { backend };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parse and validate a config object.
|
|
53
|
+
*/
|
|
54
|
+
function validateConfig(config, configPath) {
|
|
55
|
+
// Validate backend value
|
|
56
|
+
if (config.backend && !['lancedb', 'qdrant'].includes(config.backend)) {
|
|
57
|
+
throw new ConfigValidationError(`Invalid backend in global config: "${config.backend}"\n` +
|
|
58
|
+
`Config file: ${configPath}\n` +
|
|
59
|
+
`Valid values: 'lancedb' or 'qdrant'`, configPath);
|
|
60
|
+
}
|
|
61
|
+
// Validate Qdrant configuration
|
|
62
|
+
if (config.backend === 'qdrant') {
|
|
63
|
+
if (!config.qdrant) {
|
|
64
|
+
throw new ConfigValidationError(`Qdrant backend requires a "qdrant" configuration section\n` +
|
|
65
|
+
`Config file: ${configPath}\n` +
|
|
66
|
+
`Add: { "qdrant": { "url": "http://localhost:6333" } }`, configPath);
|
|
67
|
+
}
|
|
68
|
+
if (!config.qdrant.url) {
|
|
69
|
+
throw new ConfigValidationError(`Qdrant backend requires qdrant.url in config\n` +
|
|
70
|
+
`Config file: ${configPath}\n` +
|
|
71
|
+
`Add: { "qdrant": { "url": "http://localhost:6333" } }`, configPath);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Parse JSON config file with helpful error messages.
|
|
77
|
+
*/
|
|
78
|
+
function parseConfigFile(content, configPath) {
|
|
79
|
+
try {
|
|
80
|
+
return JSON.parse(content);
|
|
81
|
+
}
|
|
82
|
+
catch (parseError) {
|
|
83
|
+
const errorMsg = parseError instanceof Error ? parseError.message : String(parseError);
|
|
84
|
+
throw new ConfigValidationError(`Failed to parse global config file.\n` +
|
|
85
|
+
`Config file: ${configPath}\n` +
|
|
86
|
+
`Syntax error: ${errorMsg}\n\n` +
|
|
87
|
+
`Please fix the JSON syntax errors in your config file.`, configPath);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
7
90
|
/**
|
|
8
91
|
* Load global configuration from environment variables or config file.
|
|
9
92
|
*
|
|
@@ -16,39 +99,24 @@ const execAsync = promisify(exec);
|
|
|
16
99
|
*/
|
|
17
100
|
export async function loadGlobalConfig() {
|
|
18
101
|
// 1. Check environment variables first
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
backend: 'qdrant',
|
|
24
|
-
qdrant: {
|
|
25
|
-
url: process.env.LIEN_QDRANT_URL,
|
|
26
|
-
apiKey: process.env.LIEN_QDRANT_API_KEY,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
return { backend };
|
|
102
|
+
const envConfig = loadConfigFromEnv();
|
|
103
|
+
if (envConfig) {
|
|
104
|
+
return envConfig;
|
|
31
105
|
}
|
|
32
106
|
// 2. Check global config file
|
|
33
107
|
const configPath = path.join(os.homedir(), '.lien', 'config.json');
|
|
34
108
|
try {
|
|
35
109
|
const content = await fs.readFile(configPath, 'utf-8');
|
|
36
|
-
const config =
|
|
37
|
-
|
|
38
|
-
if (config.backend && !['lancedb', 'qdrant'].includes(config.backend)) {
|
|
39
|
-
throw new Error(`Invalid backend: ${config.backend}. Must be 'lancedb' or 'qdrant'`);
|
|
40
|
-
}
|
|
41
|
-
if (config.backend === 'qdrant' && config.qdrant && !config.qdrant.url) {
|
|
42
|
-
throw new Error('Qdrant backend requires qdrant.url in config');
|
|
43
|
-
}
|
|
110
|
+
const config = parseConfigFile(content, configPath);
|
|
111
|
+
validateConfig(config, configPath);
|
|
44
112
|
return config;
|
|
45
113
|
}
|
|
46
114
|
catch (error) {
|
|
47
115
|
if (error.code === 'ENOENT') {
|
|
48
|
-
// File doesn't exist - use defaults
|
|
116
|
+
// File doesn't exist - use defaults (this is normal)
|
|
49
117
|
return { backend: 'lancedb' };
|
|
50
118
|
}
|
|
51
|
-
// Re-throw validation errors
|
|
119
|
+
// Re-throw all other errors (validation errors, JSON parse errors, etc.)
|
|
52
120
|
throw error;
|
|
53
121
|
}
|
|
54
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-config.js","sourceRoot":"","sources":["../../src/config/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"global-config.js","sourceRoot":"","sources":["../../src/config/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AA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AM,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,IAAI,CAAC,UAAU;gBAAE,OAAO,IAAI,CAAC;YAE7B,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,sBAAsB,UAAU,EAAE,EAAE;gBACrE,GAAG,EAAE,OAAO;gBACZ,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC,CAAC,wBAAwB;QACvC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAe;IACvD,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QAE5B,sCAAsC;QACtC,MAAM,OAAO,GAAG;YACd,gBAAgB;YAChB,cAAc;YACd,mBAAmB;YACnB,kBAAkB;SACnB,CAAC;QAEF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;YAChC,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAC;QAC1B,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC,CAAC,mCAAmC;IAClD,CAAC;AACH,CAAC"}
|
package/dist/indexer/types.d.ts
CHANGED
|
@@ -37,6 +37,16 @@ export interface ChunkMetadata {
|
|
|
37
37
|
* Set from config.storage.qdrant.orgId when using Qdrant backend.
|
|
38
38
|
*/
|
|
39
39
|
orgId?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Git branch name for branch/commit tracking in Qdrant backend.
|
|
42
|
+
* Used to isolate indexes by branch (e.g., main vs PR branches).
|
|
43
|
+
*/
|
|
44
|
+
branch?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Git commit SHA for branch/commit tracking in Qdrant backend.
|
|
47
|
+
* Used to isolate indexes by commit (e.g., for PR analysis).
|
|
48
|
+
*/
|
|
49
|
+
commitSha?: string;
|
|
40
50
|
}
|
|
41
51
|
export interface ScanOptions {
|
|
42
52
|
rootDir: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/indexer/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IAClD,QAAQ,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,EAAE;QACR,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,UAAU,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;IAGF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,UAAU,CAAC;IAC5G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAGnB,cAAc,CAAC,E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,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/vectordb/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/vectordb/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAwF/C;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,iBAAiB,CAAC,CA2C5B"}
|
package/dist/vectordb/factory.js
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
import { VectorDB } from './lancedb.js';
|
|
2
2
|
import { QdrantDB } from './qdrant.js';
|
|
3
|
-
import { loadGlobalConfig, extractOrgIdFromGit } from '../config/global-config.js';
|
|
3
|
+
import { loadGlobalConfig, extractOrgIdFromGit, ConfigValidationError } from '../config/global-config.js';
|
|
4
|
+
import { getCurrentBranch, getCurrentCommit } from '../git/utils.js';
|
|
5
|
+
/**
|
|
6
|
+
* Validate that a VectorDB instance has the required methods.
|
|
7
|
+
*/
|
|
8
|
+
function validateVectorDBInterface(db) {
|
|
9
|
+
if (typeof db.initialize !== 'function') {
|
|
10
|
+
throw new Error('VectorDB instance missing initialize method');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a LanceDB instance.
|
|
15
|
+
*/
|
|
16
|
+
async function createLanceDB(projectRoot) {
|
|
17
|
+
const db = new VectorDB(projectRoot);
|
|
18
|
+
validateVectorDBInterface(db);
|
|
19
|
+
return db;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a QdrantDB instance.
|
|
23
|
+
* Extracts orgId, branch, and commit from git repository.
|
|
24
|
+
*/
|
|
25
|
+
async function createQdrantDB(projectRoot, config) {
|
|
26
|
+
if (!config.url) {
|
|
27
|
+
throw new Error('Qdrant backend requires qdrant.url in global config');
|
|
28
|
+
}
|
|
29
|
+
// Auto-detect orgId from git remote
|
|
30
|
+
const orgId = await extractOrgIdFromGit(projectRoot);
|
|
31
|
+
if (!orgId) {
|
|
32
|
+
throw new Error('Qdrant backend requires a git repository with a remote URL. ' +
|
|
33
|
+
'Could not extract organization ID from git remote. ' +
|
|
34
|
+
'Make sure your project is a git repo with a remote configured (e.g., origin).');
|
|
35
|
+
}
|
|
36
|
+
// Extract branch and commit from git (both are required for Qdrant isolation)
|
|
37
|
+
// Fail fast if git commands fail - branch/commit tracking is essential for data isolation
|
|
38
|
+
let branch;
|
|
39
|
+
let commitSha;
|
|
40
|
+
try {
|
|
41
|
+
[branch, commitSha] = await Promise.all([
|
|
42
|
+
getCurrentBranch(projectRoot),
|
|
43
|
+
getCurrentCommit(projectRoot),
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw new Error('Qdrant backend requires a valid git branch and commit SHA for proper data isolation. ' +
|
|
48
|
+
'Failed to detect current branch and/or commit from git. ' +
|
|
49
|
+
'Ensure the repository is initialized, has at least one commit, and HEAD is not detached. ' +
|
|
50
|
+
`Original error: ${error instanceof Error ? error.message : String(error)}`);
|
|
51
|
+
}
|
|
52
|
+
// Validate that branch and commitSha are non-empty (fail-fast for invalid git state)
|
|
53
|
+
if (!branch || branch.trim().length === 0) {
|
|
54
|
+
throw new Error('Qdrant backend requires a valid git branch for proper data isolation. ' +
|
|
55
|
+
'Current branch is empty or whitespace. ' +
|
|
56
|
+
'Ensure the repository is on a valid branch (not in detached HEAD state).');
|
|
57
|
+
}
|
|
58
|
+
if (!commitSha || commitSha.trim().length === 0) {
|
|
59
|
+
throw new Error('Qdrant backend requires a valid git commit SHA for proper data isolation. ' +
|
|
60
|
+
'Current commit SHA is empty or whitespace. ' +
|
|
61
|
+
'Ensure the repository has at least one commit.');
|
|
62
|
+
}
|
|
63
|
+
const db = new QdrantDB(config.url, config.apiKey, orgId, projectRoot, branch, commitSha);
|
|
64
|
+
validateVectorDBInterface(db);
|
|
65
|
+
return db;
|
|
66
|
+
}
|
|
4
67
|
/**
|
|
5
68
|
* Factory function to create a VectorDB instance based on global configuration.
|
|
6
69
|
*
|
|
@@ -14,51 +77,40 @@ import { loadGlobalConfig, extractOrgIdFromGit } from '../config/global-config.j
|
|
|
14
77
|
* @throws Error if Qdrant config is invalid or orgId cannot be detected
|
|
15
78
|
*/
|
|
16
79
|
export async function createVectorDB(projectRoot) {
|
|
80
|
+
let globalConfig = null;
|
|
17
81
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
return db;
|
|
82
|
+
globalConfig = await loadGlobalConfig();
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
// ConfigValidationError: Config file exists but has syntax/validation errors
|
|
86
|
+
// This should fail hard with a clear error message
|
|
87
|
+
if (error instanceof ConfigValidationError) {
|
|
88
|
+
throw error; // Error message already has helpful details
|
|
27
89
|
}
|
|
28
|
-
//
|
|
29
|
-
if (
|
|
90
|
+
// Check if this is a "file not found" error (expected)
|
|
91
|
+
if (error.code === 'ENOENT') {
|
|
92
|
+
// Expected: No config file exists, use default LanceDB (normal for CLI usage)
|
|
93
|
+
return await createLanceDB(projectRoot);
|
|
94
|
+
}
|
|
95
|
+
// Any other error: fail hard with details
|
|
96
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
97
|
+
throw new Error('Failed to load global config file. Please check your config file for errors.\n' +
|
|
98
|
+
`Error: ${errorMessage}`);
|
|
99
|
+
}
|
|
100
|
+
// Config loaded successfully - respect the backend choice
|
|
101
|
+
switch (globalConfig.backend) {
|
|
102
|
+
case 'qdrant':
|
|
30
103
|
if (!globalConfig.qdrant) {
|
|
31
104
|
throw new Error('Qdrant backend requires qdrant configuration in global config');
|
|
32
105
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
'Could not extract organization ID from git remote. ' +
|
|
42
|
-
'Make sure your project is a git repo with a remote configured (e.g., origin).');
|
|
43
|
-
}
|
|
44
|
-
const db = new QdrantDB(url, apiKey, orgId, projectRoot);
|
|
45
|
-
// Verify it has the required methods
|
|
46
|
-
if (typeof db.initialize !== 'function') {
|
|
47
|
-
throw new Error('QdrantDB instance missing initialize method');
|
|
48
|
-
}
|
|
49
|
-
return db;
|
|
50
|
-
}
|
|
51
|
-
// Unknown backend - fallback to LanceDB
|
|
52
|
-
throw new Error(`Unknown storage backend: ${globalConfig.backend}. Supported backends: 'lancedb', 'qdrant'`);
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
// If anything goes wrong, fall back to LanceDB
|
|
56
|
-
console.warn(`[Lien] Error creating vector DB, falling back to LanceDB: ${error}`);
|
|
57
|
-
const db = new VectorDB(projectRoot);
|
|
58
|
-
if (typeof db.initialize !== 'function') {
|
|
59
|
-
throw new Error(`Failed to create VectorDB: ${error instanceof Error ? error.message : String(error)}`);
|
|
60
|
-
}
|
|
61
|
-
return db;
|
|
106
|
+
// Don't catch errors here - let Qdrant-specific errors propagate
|
|
107
|
+
// User explicitly configured Qdrant, so they should see configuration errors
|
|
108
|
+
return await createQdrantDB(projectRoot, globalConfig.qdrant);
|
|
109
|
+
case 'lancedb':
|
|
110
|
+
case undefined:
|
|
111
|
+
return await createLanceDB(projectRoot);
|
|
112
|
+
default:
|
|
113
|
+
throw new Error(`Unknown storage backend: ${globalConfig.backend}. Supported backends: 'lancedb', 'qdrant'`);
|
|
62
114
|
}
|
|
63
115
|
}
|
|
64
116
|
//# sourceMappingURL=factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/vectordb/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/vectordb/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAgB,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAErE;;GAEG;AACH,SAAS,yBAAyB,CAAC,EAAqB;IACtD,IAAI,OAAO,EAAE,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;AACH,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,aAAa,CAAC,WAAmB;IAC9C,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC;IACrC,yBAAyB,CAAC,EAAE,CAA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7E,OAAO,MAAM,cAAc,CAAC,WAAW,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;QAEhE,KAAK,SAAS,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,MAAM,aAAa,CAAC,WAAW,CAAC,CAAC;QAE1C;YACE,MAAM,IAAI,KAAK,CAAC,4BAA4B,YAAY,CAAC,OAAO,2CAA2C,CAAC,CAAC;IACjH,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ChunkMetadata } from '../indexer/types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Qdrant payload structure for storing chunk metadata.
|
|
4
|
+
*
|
|
5
|
+
* Note: Metrics (complexity, halstead) are always present as numbers.
|
|
6
|
+
* If missing in source metadata, they are stored as 0.
|
|
4
7
|
*/
|
|
5
8
|
export interface QdrantPayload {
|
|
6
9
|
content: string;
|
|
@@ -26,6 +29,8 @@ export interface QdrantPayload {
|
|
|
26
29
|
halsteadBugs: number;
|
|
27
30
|
orgId: string;
|
|
28
31
|
repoId: string;
|
|
32
|
+
branch: string;
|
|
33
|
+
commitSha: string;
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
31
36
|
* Maps between ChunkMetadata and Qdrant payload format.
|
|
@@ -34,11 +39,39 @@ export interface QdrantPayload {
|
|
|
34
39
|
export declare class QdrantPayloadMapper {
|
|
35
40
|
private orgId;
|
|
36
41
|
private repoId;
|
|
37
|
-
|
|
42
|
+
private branch;
|
|
43
|
+
private commitSha;
|
|
44
|
+
constructor(orgId: string, repoId: string, branch: string, commitSha: string);
|
|
45
|
+
/**
|
|
46
|
+
* Map metrics from metadata to payload format.
|
|
47
|
+
*/
|
|
48
|
+
private mapMetrics;
|
|
49
|
+
/**
|
|
50
|
+
* Map symbols from metadata to payload format.
|
|
51
|
+
*/
|
|
52
|
+
private mapSymbols;
|
|
38
53
|
/**
|
|
39
54
|
* Transform chunk metadata to Qdrant payload format.
|
|
40
55
|
*/
|
|
41
56
|
toPayload(metadata: ChunkMetadata, content?: string): QdrantPayload;
|
|
57
|
+
/**
|
|
58
|
+
* Extract symbols from payload.
|
|
59
|
+
*/
|
|
60
|
+
private extractSymbols;
|
|
61
|
+
/**
|
|
62
|
+
* Extract metrics from payload.
|
|
63
|
+
*/
|
|
64
|
+
private extractMetrics;
|
|
65
|
+
/**
|
|
66
|
+
* Extract tracking info from payload.
|
|
67
|
+
*
|
|
68
|
+
* For legacy points indexed before branch/commit tracking was added, these
|
|
69
|
+
* fields may be missing. In that case they are returned as undefined and
|
|
70
|
+
* the points will not match branch/commitSha-based filters. Such data
|
|
71
|
+
* effectively becomes \"orphaned\" until it is re-indexed with tracking
|
|
72
|
+
* metadata, which is the expected migration path for old Qdrant data.
|
|
73
|
+
*/
|
|
74
|
+
private extractTrackingInfo;
|
|
42
75
|
/**
|
|
43
76
|
* Transform Qdrant payload back to ChunkMetadata.
|
|
44
77
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qdrant-payload-mapper.d.ts","sourceRoot":"","sources":["../../src/vectordb/qdrant-payload-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD
|
|
1
|
+
{"version":3,"file":"qdrant-payload-mapper.d.ts","sourceRoot":"","sources":["../../src/vectordb/qdrant-payload-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IAEjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IAEz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
9
|
+
commitSha;
|
|
10
|
+
constructor(orgId, repoId, branch, commitSha) {
|
|
9
11
|
this.orgId = orgId;
|
|
10
12
|
this.repoId = repoId;
|
|
13
|
+
this.branch = branch;
|
|
14
|
+
this.commitSha = commitSha;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Map metrics from metadata to payload format.
|
|
18
|
+
*/
|
|
19
|
+
mapMetrics(metadata) {
|
|
20
|
+
return {
|
|
21
|
+
complexity: metadata.complexity ?? 0,
|
|
22
|
+
cognitiveComplexity: metadata.cognitiveComplexity ?? 0,
|
|
23
|
+
halsteadVolume: metadata.halsteadVolume ?? 0,
|
|
24
|
+
halsteadDifficulty: metadata.halsteadDifficulty ?? 0,
|
|
25
|
+
halsteadEffort: metadata.halsteadEffort ?? 0,
|
|
26
|
+
halsteadBugs: metadata.halsteadBugs ?? 0,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Map symbols from metadata to payload format.
|
|
31
|
+
*/
|
|
32
|
+
mapSymbols(metadata) {
|
|
33
|
+
return {
|
|
34
|
+
functionNames: metadata.symbols?.functions ?? [],
|
|
35
|
+
classNames: metadata.symbols?.classes ?? [],
|
|
36
|
+
interfaceNames: metadata.symbols?.interfaces ?? [],
|
|
37
|
+
symbolName: metadata.symbolName ?? '',
|
|
38
|
+
symbolType: metadata.symbolType ?? '',
|
|
39
|
+
parentClass: metadata.parentClass ?? '',
|
|
40
|
+
parameters: metadata.parameters ?? [],
|
|
41
|
+
signature: metadata.signature ?? '',
|
|
42
|
+
imports: metadata.imports ?? [],
|
|
43
|
+
};
|
|
11
44
|
}
|
|
12
45
|
/**
|
|
13
46
|
* Transform chunk metadata to Qdrant payload format.
|
|
14
47
|
*/
|
|
15
48
|
toPayload(metadata, content = '') {
|
|
49
|
+
const trackingInfo = {
|
|
50
|
+
orgId: this.orgId,
|
|
51
|
+
repoId: this.repoId,
|
|
52
|
+
branch: this.branch,
|
|
53
|
+
commitSha: this.commitSha,
|
|
54
|
+
};
|
|
16
55
|
return {
|
|
17
56
|
content,
|
|
18
57
|
file: metadata.file,
|
|
@@ -20,27 +59,49 @@ export class QdrantPayloadMapper {
|
|
|
20
59
|
endLine: metadata.endLine,
|
|
21
60
|
type: metadata.type,
|
|
22
61
|
language: metadata.language,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
...this.mapSymbols(metadata),
|
|
63
|
+
...this.mapMetrics(metadata),
|
|
64
|
+
...trackingInfo,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Extract symbols from payload.
|
|
69
|
+
*/
|
|
70
|
+
extractSymbols(payload) {
|
|
71
|
+
return {
|
|
72
|
+
functions: payload.functionNames ?? [],
|
|
73
|
+
classes: payload.classNames ?? [],
|
|
74
|
+
interfaces: payload.interfaceNames ?? [],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Extract metrics from payload.
|
|
79
|
+
*/
|
|
80
|
+
extractMetrics(payload) {
|
|
81
|
+
return {
|
|
82
|
+
complexity: payload.complexity ?? undefined,
|
|
83
|
+
cognitiveComplexity: payload.cognitiveComplexity ?? undefined,
|
|
84
|
+
halsteadVolume: payload.halsteadVolume ?? undefined,
|
|
85
|
+
halsteadDifficulty: payload.halsteadDifficulty ?? undefined,
|
|
86
|
+
halsteadEffort: payload.halsteadEffort ?? undefined,
|
|
87
|
+
halsteadBugs: payload.halsteadBugs ?? undefined,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Extract tracking info from payload.
|
|
92
|
+
*
|
|
93
|
+
* For legacy points indexed before branch/commit tracking was added, these
|
|
94
|
+
* fields may be missing. In that case they are returned as undefined and
|
|
95
|
+
* the points will not match branch/commitSha-based filters. Such data
|
|
96
|
+
* effectively becomes \"orphaned\" until it is re-indexed with tracking
|
|
97
|
+
* metadata, which is the expected migration path for old Qdrant data.
|
|
98
|
+
*/
|
|
99
|
+
extractTrackingInfo(payload) {
|
|
100
|
+
return {
|
|
101
|
+
repoId: payload.repoId ?? undefined,
|
|
102
|
+
orgId: payload.orgId ?? undefined,
|
|
103
|
+
branch: payload.branch ?? undefined,
|
|
104
|
+
commitSha: payload.commitSha ?? undefined,
|
|
44
105
|
};
|
|
45
106
|
}
|
|
46
107
|
/**
|
|
@@ -53,25 +114,15 @@ export class QdrantPayloadMapper {
|
|
|
53
114
|
endLine: payload.endLine,
|
|
54
115
|
type: payload.type,
|
|
55
116
|
language: payload.language,
|
|
56
|
-
symbols:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
cognitiveComplexity: payload.cognitiveComplexity || undefined,
|
|
66
|
-
parameters: payload.parameters || undefined,
|
|
67
|
-
signature: payload.signature || undefined,
|
|
68
|
-
imports: payload.imports || undefined,
|
|
69
|
-
halsteadVolume: payload.halsteadVolume || undefined,
|
|
70
|
-
halsteadDifficulty: payload.halsteadDifficulty || undefined,
|
|
71
|
-
halsteadEffort: payload.halsteadEffort || undefined,
|
|
72
|
-
halsteadBugs: payload.halsteadBugs || undefined,
|
|
73
|
-
repoId: payload.repoId || undefined,
|
|
74
|
-
orgId: payload.orgId || undefined,
|
|
117
|
+
symbols: this.extractSymbols(payload),
|
|
118
|
+
symbolName: payload.symbolName ?? undefined,
|
|
119
|
+
symbolType: payload.symbolType ?? undefined,
|
|
120
|
+
parentClass: payload.parentClass ?? undefined,
|
|
121
|
+
parameters: payload.parameters ?? undefined,
|
|
122
|
+
signature: payload.signature ?? undefined,
|
|
123
|
+
imports: payload.imports ?? undefined,
|
|
124
|
+
...this.extractMetrics(payload),
|
|
125
|
+
...this.extractTrackingInfo(payload),
|
|
75
126
|
};
|
|
76
127
|
}
|
|
77
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qdrant-payload-mapper.js","sourceRoot":"","sources":["../../src/vectordb/qdrant-payload-mapper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"qdrant-payload-mapper.js","sourceRoot":"","sources":["../../src/vectordb/qdrant-payload-mapper.ts"],"names":[],"mappings":"AAyCA;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAEpB;IACA;IACA;IACA;IAJV,YACU,KAAa,EACb,MAAc,EACd,MAAc,EACd,SAAiB;QAHjB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAQ;IACxB,CAAC;IAEJ;;OAEG;IACK,UAAU,CAAC,QAAuB;QACxC,OAAO;YACL,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,CAAC;YACpC,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB,IAAI,CAAC;YACtD,cAAc,EAAE,QAAQ,CAAC,cAAc,IAAI,CAAC;YAC5C,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB,IAAI,CAAC;YACpD,cAAc,EAAE,QAAQ,CAAC,cAAc,IAAI,CAAC;YAC5C,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,CAAC;SACzC,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,QAAuB;QACxC,OAAO;YACL,aAAa,EAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,IAAI,EAAE;YAChD,UAAU,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE;YAC3C,cAAc,EAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,IAAI,EAAE;YACl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