@matperez/coderag 0.1.24
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/README.md +154 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/ast-chunking.d.ts +40 -0
- package/dist/ast-chunking.d.ts.map +1 -0
- package/dist/ast-chunking.js +88 -0
- package/dist/ast-chunking.js.map +1 -0
- package/dist/ast-chunking.test.d.ts +5 -0
- package/dist/ast-chunking.test.d.ts.map +1 -0
- package/dist/ast-chunking.test.js +173 -0
- package/dist/ast-chunking.test.js.map +1 -0
- package/dist/code-tokenizer.d.ts +62 -0
- package/dist/code-tokenizer.d.ts.map +1 -0
- package/dist/code-tokenizer.js +129 -0
- package/dist/code-tokenizer.js.map +1 -0
- package/dist/code-tokenizer.test.d.ts +5 -0
- package/dist/code-tokenizer.test.d.ts.map +1 -0
- package/dist/code-tokenizer.test.js +96 -0
- package/dist/code-tokenizer.test.js.map +1 -0
- package/dist/db/client-pg.d.ts +16 -0
- package/dist/db/client-pg.d.ts.map +1 -0
- package/dist/db/client-pg.js +38 -0
- package/dist/db/client-pg.js.map +1 -0
- package/dist/db/client.d.ts +36 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +81 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/migrations-pg.d.ts +6 -0
- package/dist/db/migrations-pg.d.ts.map +1 -0
- package/dist/db/migrations-pg.js +88 -0
- package/dist/db/migrations-pg.js.map +1 -0
- package/dist/db/migrations.d.ts +9 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +164 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/schema-pg.d.ts +611 -0
- package/dist/db/schema-pg.d.ts.map +1 -0
- package/dist/db/schema-pg.js +66 -0
- package/dist/db/schema-pg.js.map +1 -0
- package/dist/db/schema.d.ts +630 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +85 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/embeddings.d.ts +92 -0
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/embeddings.js +275 -0
- package/dist/embeddings.js.map +1 -0
- package/dist/embeddings.test.d.ts +5 -0
- package/dist/embeddings.test.d.ts.map +1 -0
- package/dist/embeddings.test.js +255 -0
- package/dist/embeddings.test.js.map +1 -0
- package/dist/hybrid-search.d.ts +47 -0
- package/dist/hybrid-search.d.ts.map +1 -0
- package/dist/hybrid-search.js +215 -0
- package/dist/hybrid-search.js.map +1 -0
- package/dist/hybrid-search.test.d.ts +5 -0
- package/dist/hybrid-search.test.d.ts.map +1 -0
- package/dist/hybrid-search.test.js +252 -0
- package/dist/hybrid-search.test.js.map +1 -0
- package/dist/incremental-tfidf.d.ts +77 -0
- package/dist/incremental-tfidf.d.ts.map +1 -0
- package/dist/incremental-tfidf.js +248 -0
- package/dist/incremental-tfidf.js.map +1 -0
- package/dist/incremental-tfidf.test.d.ts +5 -0
- package/dist/incremental-tfidf.test.d.ts.map +1 -0
- package/dist/incremental-tfidf.test.js +276 -0
- package/dist/incremental-tfidf.test.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer.d.ts +205 -0
- package/dist/indexer.d.ts.map +1 -0
- package/dist/indexer.js +1331 -0
- package/dist/indexer.js.map +1 -0
- package/dist/indexer.test.d.ts +12 -0
- package/dist/indexer.test.d.ts.map +1 -0
- package/dist/indexer.test.js +471 -0
- package/dist/indexer.test.js.map +1 -0
- package/dist/language-config.d.ts +54 -0
- package/dist/language-config.d.ts.map +1 -0
- package/dist/language-config.js +75 -0
- package/dist/language-config.js.map +1 -0
- package/dist/search-cache.d.ts +63 -0
- package/dist/search-cache.d.ts.map +1 -0
- package/dist/search-cache.js +118 -0
- package/dist/search-cache.js.map +1 -0
- package/dist/search-cache.test.d.ts +5 -0
- package/dist/search-cache.test.d.ts.map +1 -0
- package/dist/search-cache.test.js +194 -0
- package/dist/search-cache.test.js.map +1 -0
- package/dist/storage-factory.d.ts +11 -0
- package/dist/storage-factory.d.ts.map +1 -0
- package/dist/storage-factory.js +17 -0
- package/dist/storage-factory.js.map +1 -0
- package/dist/storage-persistent-pg.d.ts +75 -0
- package/dist/storage-persistent-pg.d.ts.map +1 -0
- package/dist/storage-persistent-pg.js +579 -0
- package/dist/storage-persistent-pg.js.map +1 -0
- package/dist/storage-persistent-pg.test.d.ts +7 -0
- package/dist/storage-persistent-pg.test.d.ts.map +1 -0
- package/dist/storage-persistent-pg.test.js +90 -0
- package/dist/storage-persistent-pg.test.js.map +1 -0
- package/dist/storage-persistent-types.d.ts +110 -0
- package/dist/storage-persistent-types.d.ts.map +1 -0
- package/dist/storage-persistent-types.js +5 -0
- package/dist/storage-persistent-types.js.map +1 -0
- package/dist/storage-persistent.d.ts +231 -0
- package/dist/storage-persistent.d.ts.map +1 -0
- package/dist/storage-persistent.js +897 -0
- package/dist/storage-persistent.js.map +1 -0
- package/dist/storage-persistent.test.d.ts +5 -0
- package/dist/storage-persistent.test.d.ts.map +1 -0
- package/dist/storage-persistent.test.js +325 -0
- package/dist/storage-persistent.test.js.map +1 -0
- package/dist/storage.d.ts +63 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +67 -0
- package/dist/storage.js.map +1 -0
- package/dist/storage.test.d.ts +5 -0
- package/dist/storage.test.d.ts.map +1 -0
- package/dist/storage.test.js +157 -0
- package/dist/storage.test.js.map +1 -0
- package/dist/tfidf.d.ts +97 -0
- package/dist/tfidf.d.ts.map +1 -0
- package/dist/tfidf.js +308 -0
- package/dist/tfidf.js.map +1 -0
- package/dist/tfidf.test.d.ts +5 -0
- package/dist/tfidf.test.d.ts.map +1 -0
- package/dist/tfidf.test.js +181 -0
- package/dist/tfidf.test.js.map +1 -0
- package/dist/utils.d.ts +61 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +264 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.test.d.ts +5 -0
- package/dist/utils.test.d.ts.map +1 -0
- package/dist/utils.test.js +94 -0
- package/dist/utils.test.js.map +1 -0
- package/dist/vector-storage.d.ts +120 -0
- package/dist/vector-storage.d.ts.map +1 -0
- package/dist/vector-storage.js +264 -0
- package/dist/vector-storage.js.map +1 -0
- package/dist/vector-storage.test.d.ts +5 -0
- package/dist/vector-storage.test.d.ts.map +1 -0
- package/dist/vector-storage.test.js +345 -0
- package/dist/vector-storage.test.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language configuration (extension to language mapping).
|
|
3
|
+
* AST chunking is done by code-chunk for typescript, javascript, python, rust, go, java.
|
|
4
|
+
* Other extensions are used for display and fallback chunking.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Embedded language configuration (kept for API compatibility; unused after Synth removal)
|
|
8
|
+
*/
|
|
9
|
+
export interface EmbeddedLanguageConfig {
|
|
10
|
+
readonly nodeType: string;
|
|
11
|
+
readonly langAttr?: string;
|
|
12
|
+
readonly defaultLanguage?: string;
|
|
13
|
+
readonly recursive?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Minimal language config (extensions only)
|
|
17
|
+
*/
|
|
18
|
+
export interface LanguageConfig {
|
|
19
|
+
readonly extensions: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Language Registry
|
|
23
|
+
* Maps language identifiers to extensions. Used for getLanguageFromPath and display.
|
|
24
|
+
*/
|
|
25
|
+
export declare const LANGUAGE_REGISTRY: Record<string, LanguageConfig>;
|
|
26
|
+
/**
|
|
27
|
+
* Extension to language mapping
|
|
28
|
+
*/
|
|
29
|
+
export declare const EXTENSION_TO_LANGUAGE: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Get language config by language name
|
|
32
|
+
*/
|
|
33
|
+
export declare function getLanguageConfig(language: string): LanguageConfig | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Get language config by file extension
|
|
36
|
+
*/
|
|
37
|
+
export declare function getLanguageConfigByExtension(extension: string): LanguageConfig | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Get language name from file path
|
|
40
|
+
*/
|
|
41
|
+
export declare function getLanguageFromPath(filePath: string): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a language is supported (has extension mapping)
|
|
44
|
+
*/
|
|
45
|
+
export declare function isLanguageSupported(language: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get all supported languages (registry keys)
|
|
48
|
+
*/
|
|
49
|
+
export declare function getSupportedLanguages(): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Get all supported extensions
|
|
52
|
+
*/
|
|
53
|
+
export declare function getSupportedExtensions(): string[];
|
|
54
|
+
//# sourceMappingURL=language-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-config.d.ts","sourceRoot":"","sources":["../src/language-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CACtC;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAgB5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAUxD,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAE9E;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAI1F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGxE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAEjD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language configuration (extension to language mapping).
|
|
3
|
+
* AST chunking is done by code-chunk for typescript, javascript, python, rust, go, java.
|
|
4
|
+
* Other extensions are used for display and fallback chunking.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Language Registry
|
|
8
|
+
* Maps language identifiers to extensions. Used for getLanguageFromPath and display.
|
|
9
|
+
*/
|
|
10
|
+
export const LANGUAGE_REGISTRY = {
|
|
11
|
+
typescript: { extensions: ['.ts', '.tsx', '.mts', '.cts'] },
|
|
12
|
+
javascript: { extensions: ['.js', '.jsx', '.mjs', '.cjs'] },
|
|
13
|
+
python: { extensions: ['.py', '.pyi', '.pyw'] },
|
|
14
|
+
rust: { extensions: ['.rs'] },
|
|
15
|
+
go: { extensions: ['.go'] },
|
|
16
|
+
java: { extensions: ['.java'] },
|
|
17
|
+
markdown: { extensions: ['.md', '.markdown', '.mdx'] },
|
|
18
|
+
html: { extensions: ['.html', '.htm'] },
|
|
19
|
+
json: { extensions: ['.json', '.jsonc', '.json5'] },
|
|
20
|
+
yaml: { extensions: ['.yaml', '.yml'] },
|
|
21
|
+
toml: { extensions: ['.toml'] },
|
|
22
|
+
xml: { extensions: ['.xml', '.xsl', '.xslt', '.xsd', '.svg'] },
|
|
23
|
+
ini: { extensions: ['.ini', '.cfg', '.conf', '.gitconfig', '.editorconfig'] },
|
|
24
|
+
c: { extensions: ['.c', '.h'] },
|
|
25
|
+
protobuf: { extensions: ['.proto'] },
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Extension to language mapping
|
|
29
|
+
*/
|
|
30
|
+
export const EXTENSION_TO_LANGUAGE = Object.entries(LANGUAGE_REGISTRY).reduce((acc, [lang, config]) => {
|
|
31
|
+
for (const ext of config.extensions) {
|
|
32
|
+
acc[ext] = lang;
|
|
33
|
+
}
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
/**
|
|
37
|
+
* Get language config by language name
|
|
38
|
+
*/
|
|
39
|
+
export function getLanguageConfig(language) {
|
|
40
|
+
return LANGUAGE_REGISTRY[language.toLowerCase()];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get language config by file extension
|
|
44
|
+
*/
|
|
45
|
+
export function getLanguageConfigByExtension(extension) {
|
|
46
|
+
const ext = extension.startsWith('.') ? extension : `.${extension}`;
|
|
47
|
+
const language = EXTENSION_TO_LANGUAGE[ext.toLowerCase()];
|
|
48
|
+
return language ? LANGUAGE_REGISTRY[language] : undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get language name from file path
|
|
52
|
+
*/
|
|
53
|
+
export function getLanguageFromPath(filePath) {
|
|
54
|
+
const ext = filePath.slice(filePath.lastIndexOf('.')).toLowerCase();
|
|
55
|
+
return EXTENSION_TO_LANGUAGE[ext];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Check if a language is supported (has extension mapping)
|
|
59
|
+
*/
|
|
60
|
+
export function isLanguageSupported(language) {
|
|
61
|
+
return language.toLowerCase() in LANGUAGE_REGISTRY;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get all supported languages (registry keys)
|
|
65
|
+
*/
|
|
66
|
+
export function getSupportedLanguages() {
|
|
67
|
+
return Object.keys(LANGUAGE_REGISTRY);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get all supported extensions
|
|
71
|
+
*/
|
|
72
|
+
export function getSupportedExtensions() {
|
|
73
|
+
return Object.keys(EXTENSION_TO_LANGUAGE);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=language-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-config.js","sourceRoot":"","sources":["../src/language-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmBH;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAmC;IAChE,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;IAC3D,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;IAC3D,MAAM,EAAE,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;IAC/C,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE;IAC7B,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE;IAC3B,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE;IAC/B,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE;IACtD,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;IACvC,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE;IACnD,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;IACvC,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE;IAC/B,GAAG,EAAE,EAAE,UAAU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AM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IACnE,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAA;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IACnD,OAAO,QAAQ,CAAC,WAAW,EAAE,IAAI,iBAAiB,CAAA;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACpC,OAAO,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRU Cache for search results
|
|
3
|
+
* Improves search performance by caching common queries
|
|
4
|
+
*/
|
|
5
|
+
export interface CacheEntry<T> {
|
|
6
|
+
value: T;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
hits: number;
|
|
9
|
+
}
|
|
10
|
+
export interface CacheStats {
|
|
11
|
+
size: number;
|
|
12
|
+
maxSize: number;
|
|
13
|
+
hits: number;
|
|
14
|
+
misses: number;
|
|
15
|
+
hitRate: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* LRU (Least Recently Used) Cache
|
|
19
|
+
* Automatically evicts least recently used entries when full
|
|
20
|
+
*/
|
|
21
|
+
export declare class LRUCache<T> {
|
|
22
|
+
private cache;
|
|
23
|
+
private maxSize;
|
|
24
|
+
private ttl;
|
|
25
|
+
private hits;
|
|
26
|
+
private misses;
|
|
27
|
+
constructor(maxSize?: number, ttlMinutes?: number);
|
|
28
|
+
/**
|
|
29
|
+
* Get value from cache
|
|
30
|
+
*/
|
|
31
|
+
get(key: string): T | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Set value in cache
|
|
34
|
+
*/
|
|
35
|
+
set(key: string, value: T): void;
|
|
36
|
+
/**
|
|
37
|
+
* Clear all cache entries
|
|
38
|
+
*/
|
|
39
|
+
clear(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Invalidate cache (clear all entries)
|
|
42
|
+
* Call this when the index is updated
|
|
43
|
+
*/
|
|
44
|
+
invalidate(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Get cache statistics
|
|
47
|
+
*/
|
|
48
|
+
stats(): CacheStats;
|
|
49
|
+
/**
|
|
50
|
+
* Remove expired entries
|
|
51
|
+
*/
|
|
52
|
+
cleanup(): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a cache key from search parameters
|
|
56
|
+
*/
|
|
57
|
+
export declare function createCacheKey(query: string, options?: {
|
|
58
|
+
limit?: number;
|
|
59
|
+
fileExtensions?: string[];
|
|
60
|
+
pathFilter?: string;
|
|
61
|
+
excludePaths?: string[];
|
|
62
|
+
}): string;
|
|
63
|
+
//# sourceMappingURL=search-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-cache.d.ts","sourceRoot":"","sources":["../src/search-cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC5B,KAAK,EAAE,CAAC,CAAA;IACR,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,qBAAa,QAAQ,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,GAAG,CAAQ;IACnB,OAAO,CAAC,IAAI,CAAI;IAChB,OAAO,CAAC,MAAM,CAAI;gBAEN,OAAO,SAAM,EAAE,UAAU,SAAI;IAMzC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAyB/B;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAsBhC;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;;OAGG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,KAAK,IAAI,UAAU;IAWnB;;OAEG;IACH,OAAO,IAAI,IAAI;CAQf;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB,GACJ,MAAM,CAUR"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRU Cache for search results
|
|
3
|
+
* Improves search performance by caching common queries
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* LRU (Least Recently Used) Cache
|
|
7
|
+
* Automatically evicts least recently used entries when full
|
|
8
|
+
*/
|
|
9
|
+
export class LRUCache {
|
|
10
|
+
cache;
|
|
11
|
+
maxSize;
|
|
12
|
+
ttl; // Time to live in milliseconds
|
|
13
|
+
hits = 0;
|
|
14
|
+
misses = 0;
|
|
15
|
+
constructor(maxSize = 100, ttlMinutes = 5) {
|
|
16
|
+
this.cache = new Map();
|
|
17
|
+
this.maxSize = maxSize;
|
|
18
|
+
this.ttl = ttlMinutes * 60 * 1000;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get value from cache
|
|
22
|
+
*/
|
|
23
|
+
get(key) {
|
|
24
|
+
const entry = this.cache.get(key);
|
|
25
|
+
if (!entry) {
|
|
26
|
+
this.misses++;
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
// Check if entry expired
|
|
30
|
+
if (Date.now() - entry.timestamp > this.ttl) {
|
|
31
|
+
this.cache.delete(key);
|
|
32
|
+
this.misses++;
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
// Update entry (move to end = most recently used)
|
|
36
|
+
entry.hits++;
|
|
37
|
+
entry.timestamp = Date.now();
|
|
38
|
+
this.cache.delete(key);
|
|
39
|
+
this.cache.set(key, entry);
|
|
40
|
+
this.hits++;
|
|
41
|
+
return entry.value;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Set value in cache
|
|
45
|
+
*/
|
|
46
|
+
set(key, value) {
|
|
47
|
+
// Remove old entry if exists
|
|
48
|
+
if (this.cache.has(key)) {
|
|
49
|
+
this.cache.delete(key);
|
|
50
|
+
}
|
|
51
|
+
// Evict least recently used if cache is full
|
|
52
|
+
if (this.cache.size >= this.maxSize) {
|
|
53
|
+
const firstKey = this.cache.keys().next().value;
|
|
54
|
+
if (firstKey !== undefined) {
|
|
55
|
+
this.cache.delete(firstKey);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Add new entry (at end = most recently used)
|
|
59
|
+
this.cache.set(key, {
|
|
60
|
+
value,
|
|
61
|
+
timestamp: Date.now(),
|
|
62
|
+
hits: 0,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Clear all cache entries
|
|
67
|
+
*/
|
|
68
|
+
clear() {
|
|
69
|
+
this.cache.clear();
|
|
70
|
+
this.hits = 0;
|
|
71
|
+
this.misses = 0;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Invalidate cache (clear all entries)
|
|
75
|
+
* Call this when the index is updated
|
|
76
|
+
*/
|
|
77
|
+
invalidate() {
|
|
78
|
+
this.clear();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get cache statistics
|
|
82
|
+
*/
|
|
83
|
+
stats() {
|
|
84
|
+
const total = this.hits + this.misses;
|
|
85
|
+
return {
|
|
86
|
+
size: this.cache.size,
|
|
87
|
+
maxSize: this.maxSize,
|
|
88
|
+
hits: this.hits,
|
|
89
|
+
misses: this.misses,
|
|
90
|
+
hitRate: total > 0 ? this.hits / total : 0,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Remove expired entries
|
|
95
|
+
*/
|
|
96
|
+
cleanup() {
|
|
97
|
+
const now = Date.now();
|
|
98
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
99
|
+
if (now - entry.timestamp > this.ttl) {
|
|
100
|
+
this.cache.delete(key);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Create a cache key from search parameters
|
|
107
|
+
*/
|
|
108
|
+
export function createCacheKey(query, options = {}) {
|
|
109
|
+
const parts = [
|
|
110
|
+
query.toLowerCase().trim(),
|
|
111
|
+
options.limit?.toString() || '10',
|
|
112
|
+
options.fileExtensions?.sort().join(',') || '',
|
|
113
|
+
options.pathFilter || '',
|
|
114
|
+
options.excludePaths?.sort().join(',') || '',
|
|
115
|
+
];
|
|
116
|
+
return parts.join('|');
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=search-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-cache.js","sourceRoot":"","sources":["../src/search-cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACZ,KAAK,CAA4B;IACjC,OAAO,CAAQ;IACf,GAAG,CAAQ,CAAC,+BAA+B;IAC3C,IAAI,GAAG,CAAC,CAAA;IACR,MAAM,GAAG,CAAC,CAAA;IAElB,YAAY,OAAO,GAAG,GAAG,EAAE,UAAU,GAAG,CAAC;QACxC,IAAI,CAAC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IAAI,GAAG,GAAG,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACvB,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC7B,KAAa,EACb,UAKI,EAAE;IAEN,MAAM,KAAK,GAAG;QACb,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE;QAC1B,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI;QACjC,OAAO,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;QAC9C,OAAO,CAAC,UAAU,IAAI,EAAE;QACxB,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;KAC5C,CAAA;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-cache.test.d.ts","sourceRoot":"","sources":["../src/search-cache.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for LRU Cache implementation
|
|
3
|
+
*/
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { createCacheKey, LRUCache } from './search-cache.js';
|
|
6
|
+
describe('LRUCache', () => {
|
|
7
|
+
let cache;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
cache = new LRUCache(3, 1); // 3 entries, 1 minute TTL
|
|
10
|
+
});
|
|
11
|
+
describe('get and set', () => {
|
|
12
|
+
it('should store and retrieve values', () => {
|
|
13
|
+
cache.set('key1', 'value1');
|
|
14
|
+
expect(cache.get('key1')).toBe('value1');
|
|
15
|
+
});
|
|
16
|
+
it('should return undefined for non-existent keys', () => {
|
|
17
|
+
expect(cache.get('nonexistent')).toBeUndefined();
|
|
18
|
+
});
|
|
19
|
+
it('should update existing keys', () => {
|
|
20
|
+
cache.set('key1', 'value1');
|
|
21
|
+
cache.set('key1', 'value2');
|
|
22
|
+
expect(cache.get('key1')).toBe('value2');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('LRU eviction', () => {
|
|
26
|
+
it('should evict least recently used entry when cache is full', () => {
|
|
27
|
+
cache.set('key1', 'value1');
|
|
28
|
+
cache.set('key2', 'value2');
|
|
29
|
+
cache.set('key3', 'value3');
|
|
30
|
+
// Cache is now full (size 3)
|
|
31
|
+
// key1 is least recently used
|
|
32
|
+
cache.set('key4', 'value4'); // Should evict key1
|
|
33
|
+
expect(cache.get('key1')).toBeUndefined();
|
|
34
|
+
expect(cache.get('key2')).toBe('value2');
|
|
35
|
+
expect(cache.get('key3')).toBe('value3');
|
|
36
|
+
expect(cache.get('key4')).toBe('value4');
|
|
37
|
+
});
|
|
38
|
+
it('should update LRU order on get', () => {
|
|
39
|
+
cache.set('key1', 'value1');
|
|
40
|
+
cache.set('key2', 'value2');
|
|
41
|
+
cache.set('key3', 'value3');
|
|
42
|
+
// Access key1 to make it most recently used
|
|
43
|
+
cache.get('key1');
|
|
44
|
+
// Now key2 is least recently used
|
|
45
|
+
cache.set('key4', 'value4'); // Should evict key2
|
|
46
|
+
expect(cache.get('key1')).toBe('value1');
|
|
47
|
+
expect(cache.get('key2')).toBeUndefined();
|
|
48
|
+
expect(cache.get('key3')).toBe('value3');
|
|
49
|
+
expect(cache.get('key4')).toBe('value4');
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe('TTL expiration', () => {
|
|
53
|
+
it('should expire entries after TTL', async () => {
|
|
54
|
+
vi.useFakeTimers();
|
|
55
|
+
const shortCache = new LRUCache(10, 0.01); // 0.01 minutes = 600ms
|
|
56
|
+
shortCache.set('key1', 'value1');
|
|
57
|
+
expect(shortCache.get('key1')).toBe('value1');
|
|
58
|
+
// Advance time by 1 second (beyond TTL)
|
|
59
|
+
vi.advanceTimersByTime(1000);
|
|
60
|
+
expect(shortCache.get('key1')).toBeUndefined();
|
|
61
|
+
vi.useRealTimers();
|
|
62
|
+
});
|
|
63
|
+
it('should refresh TTL on access', async () => {
|
|
64
|
+
vi.useFakeTimers();
|
|
65
|
+
const shortCache = new LRUCache(10, 0.01); // 0.01 minutes = 600ms
|
|
66
|
+
shortCache.set('key1', 'value1');
|
|
67
|
+
// Advance time by 500ms
|
|
68
|
+
vi.advanceTimersByTime(500);
|
|
69
|
+
// Access entry (should refresh TTL)
|
|
70
|
+
expect(shortCache.get('key1')).toBe('value1');
|
|
71
|
+
// Advance time by another 500ms (total 1000ms, but entry was refreshed at 500ms)
|
|
72
|
+
vi.advanceTimersByTime(500);
|
|
73
|
+
// Entry should still be valid (only 500ms since last access)
|
|
74
|
+
expect(shortCache.get('key1')).toBe('value1');
|
|
75
|
+
vi.useRealTimers();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
describe('stats', () => {
|
|
79
|
+
it('should track hits and misses', () => {
|
|
80
|
+
cache.set('key1', 'value1');
|
|
81
|
+
cache.get('key1'); // hit
|
|
82
|
+
cache.get('key1'); // hit
|
|
83
|
+
cache.get('key2'); // miss
|
|
84
|
+
cache.get('key3'); // miss
|
|
85
|
+
const stats = cache.stats();
|
|
86
|
+
expect(stats.hits).toBe(2);
|
|
87
|
+
expect(stats.misses).toBe(2);
|
|
88
|
+
expect(stats.hitRate).toBe(0.5);
|
|
89
|
+
});
|
|
90
|
+
it('should report cache size', () => {
|
|
91
|
+
cache.set('key1', 'value1');
|
|
92
|
+
cache.set('key2', 'value2');
|
|
93
|
+
const stats = cache.stats();
|
|
94
|
+
expect(stats.size).toBe(2);
|
|
95
|
+
expect(stats.maxSize).toBe(3);
|
|
96
|
+
});
|
|
97
|
+
it('should handle hit rate when no accesses', () => {
|
|
98
|
+
const stats = cache.stats();
|
|
99
|
+
expect(stats.hitRate).toBe(0);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
describe('clear', () => {
|
|
103
|
+
it('should remove all entries', () => {
|
|
104
|
+
cache.set('key1', 'value1');
|
|
105
|
+
cache.set('key2', 'value2');
|
|
106
|
+
cache.set('key3', 'value3');
|
|
107
|
+
cache.clear();
|
|
108
|
+
expect(cache.get('key1')).toBeUndefined();
|
|
109
|
+
expect(cache.get('key2')).toBeUndefined();
|
|
110
|
+
expect(cache.get('key3')).toBeUndefined();
|
|
111
|
+
expect(cache.stats().size).toBe(0);
|
|
112
|
+
});
|
|
113
|
+
it('should reset stats', () => {
|
|
114
|
+
cache.set('key1', 'value1');
|
|
115
|
+
cache.get('key1'); // hit
|
|
116
|
+
cache.get('key2'); // miss
|
|
117
|
+
cache.clear();
|
|
118
|
+
const stats = cache.stats();
|
|
119
|
+
expect(stats.hits).toBe(0);
|
|
120
|
+
expect(stats.misses).toBe(0);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe('invalidate', () => {
|
|
124
|
+
it('should clear all entries', () => {
|
|
125
|
+
cache.set('key1', 'value1');
|
|
126
|
+
cache.set('key2', 'value2');
|
|
127
|
+
cache.invalidate();
|
|
128
|
+
expect(cache.get('key1')).toBeUndefined();
|
|
129
|
+
expect(cache.get('key2')).toBeUndefined();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
describe('cleanup', () => {
|
|
133
|
+
it('should remove expired entries', async () => {
|
|
134
|
+
vi.useFakeTimers();
|
|
135
|
+
const shortCache = new LRUCache(10, 0.01); // 0.01 minutes = 600ms
|
|
136
|
+
shortCache.set('key1', 'value1');
|
|
137
|
+
shortCache.set('key2', 'value2');
|
|
138
|
+
// Advance time by 1 second
|
|
139
|
+
vi.advanceTimersByTime(1000);
|
|
140
|
+
// Add a new entry (not expired)
|
|
141
|
+
shortCache.set('key3', 'value3');
|
|
142
|
+
// Cleanup expired entries
|
|
143
|
+
shortCache.cleanup();
|
|
144
|
+
// key1 and key2 should be removed, key3 should remain
|
|
145
|
+
expect(shortCache.get('key1')).toBeUndefined();
|
|
146
|
+
expect(shortCache.get('key2')).toBeUndefined();
|
|
147
|
+
expect(shortCache.get('key3')).toBe('value3');
|
|
148
|
+
vi.useRealTimers();
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
describe('createCacheKey', () => {
|
|
153
|
+
it('should create consistent keys for same parameters', () => {
|
|
154
|
+
const key1 = createCacheKey('test query', { limit: 10 });
|
|
155
|
+
const key2 = createCacheKey('test query', { limit: 10 });
|
|
156
|
+
expect(key1).toBe(key2);
|
|
157
|
+
});
|
|
158
|
+
it('should create different keys for different queries', () => {
|
|
159
|
+
const key1 = createCacheKey('query1', { limit: 10 });
|
|
160
|
+
const key2 = createCacheKey('query2', { limit: 10 });
|
|
161
|
+
expect(key1).not.toBe(key2);
|
|
162
|
+
});
|
|
163
|
+
it('should create different keys for different limits', () => {
|
|
164
|
+
const key1 = createCacheKey('test', { limit: 10 });
|
|
165
|
+
const key2 = createCacheKey('test', { limit: 20 });
|
|
166
|
+
expect(key1).not.toBe(key2);
|
|
167
|
+
});
|
|
168
|
+
it('should normalize query case', () => {
|
|
169
|
+
const key1 = createCacheKey('Test Query', {});
|
|
170
|
+
const key2 = createCacheKey('test query', {});
|
|
171
|
+
expect(key1).toBe(key2);
|
|
172
|
+
});
|
|
173
|
+
it('should handle file extensions', () => {
|
|
174
|
+
const key1 = createCacheKey('test', { fileExtensions: ['.ts', '.js'] });
|
|
175
|
+
const key2 = createCacheKey('test', { fileExtensions: ['.js', '.ts'] }); // Different order
|
|
176
|
+
expect(key1).toBe(key2); // Should be same (sorted)
|
|
177
|
+
});
|
|
178
|
+
it('should handle path filter', () => {
|
|
179
|
+
const key1 = createCacheKey('test', { pathFilter: 'src/' });
|
|
180
|
+
const key2 = createCacheKey('test', { pathFilter: 'lib/' });
|
|
181
|
+
expect(key1).not.toBe(key2);
|
|
182
|
+
});
|
|
183
|
+
it('should handle exclude paths', () => {
|
|
184
|
+
const key1 = createCacheKey('test', { excludePaths: ['node_modules', 'dist'] });
|
|
185
|
+
const key2 = createCacheKey('test', { excludePaths: ['dist', 'node_modules'] }); // Different order
|
|
186
|
+
expect(key1).toBe(key2); // Should be same (sorted)
|
|
187
|
+
});
|
|
188
|
+
it('should handle default values', () => {
|
|
189
|
+
const key1 = createCacheKey('test', {});
|
|
190
|
+
const key2 = createCacheKey('test', { limit: 10 });
|
|
191
|
+
expect(key1).toBe(key2); // Default limit is 10
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
//# sourceMappingURL=search-cache.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-cache.test.js","sourceRoot":"","sources":["../src/search-cache.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5D,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACzB,IAAI,KAAuB,CAAA;IAE3B,UAAU,CAAC,GAAG,EAAE;QACf,KAAK,GAAG,IAAI,QAAQ,CAAS,CAAC,EAAE,CAAC,CAAC,CAAA,CAAC,0BAA0B;IAC9D,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;YAC3C,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;YAC3B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACxD,MAAM,CAAC,KAAK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AAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,sBAAsB;IAC/C,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory for persistent storage (SQLite or Postgres)
|
|
3
|
+
*/
|
|
4
|
+
import type { PersistentChunkStorage, PersistentStorageConfig } from './storage-persistent-types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Create persistent storage by backend type.
|
|
7
|
+
* SQLite: use dbPath/codebaseRoot (default ~/.coderag/projects/<hash>/index.db).
|
|
8
|
+
* Postgres: use connectionString or host/port/database/user/password (env fallback in implementation).
|
|
9
|
+
*/
|
|
10
|
+
export declare function createPersistentStorage(config: PersistentStorageConfig): PersistentChunkStorage;
|
|
11
|
+
//# sourceMappingURL=storage-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-factory.d.ts","sourceRoot":"","sources":["../src/storage-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AAIpG;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,uBAAuB,GAAG,sBAAsB,CAK/F"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory for persistent storage (SQLite or Postgres)
|
|
3
|
+
*/
|
|
4
|
+
import { PersistentStorage } from './storage-persistent.js';
|
|
5
|
+
import { createPostgresPersistentStorage } from './storage-persistent-pg.js';
|
|
6
|
+
/**
|
|
7
|
+
* Create persistent storage by backend type.
|
|
8
|
+
* SQLite: use dbPath/codebaseRoot (default ~/.coderag/projects/<hash>/index.db).
|
|
9
|
+
* Postgres: use connectionString or host/port/database/user/password (env fallback in implementation).
|
|
10
|
+
*/
|
|
11
|
+
export function createPersistentStorage(config) {
|
|
12
|
+
if (config.backend === 'postgres') {
|
|
13
|
+
return createPostgresPersistentStorage(config);
|
|
14
|
+
}
|
|
15
|
+
return new PersistentStorage(config);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=storage-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-factory.js","sourceRoot":"","sources":["../src/storage-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAA;AAE5E;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAA+B;IACtE,IAAI,MAAM,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,+BAA+B,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC;IACD,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAA;AACrC,CAAC"}
|