ko-qmd 2.8.3-ko.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/CHANGELOG.md +1937 -0
- package/LICENSE +21 -0
- package/README.en.md +184 -0
- package/README.md +292 -0
- package/bin/qmd +192 -0
- package/dist/ast.d.ts +65 -0
- package/dist/ast.js +51 -0
- package/dist/bench/bench.d.ts +41 -0
- package/dist/bench/bench.js +12 -0
- package/dist/bench/score.d.ts +33 -0
- package/dist/bench/score.js +1 -0
- package/dist/bench/types.d.ts +101 -0
- package/dist/bench/types.js +1 -0
- package/dist/cli/build-info.json +4 -0
- package/dist/cli/embed-lock.d.ts +24 -0
- package/dist/cli/embed-lock.js +2 -0
- package/dist/cli/formatter.d.ts +120 -0
- package/dist/cli/formatter.js +60 -0
- package/dist/cli/mcp-pid.d.ts +33 -0
- package/dist/cli/mcp-pid.js +1 -0
- package/dist/cli/qmd.d.ts +101 -0
- package/dist/cli/qmd.js +165 -0
- package/dist/cli/version.d.ts +42 -0
- package/dist/cli/version.js +1 -0
- package/dist/collections.d.ts +162 -0
- package/dist/collections.js +1 -0
- package/dist/db.d.ts +63 -0
- package/dist/db.js +2 -0
- package/dist/filters.d.ts +46 -0
- package/dist/filters.js +1 -0
- package/dist/grep.d.ts +85 -0
- package/dist/grep.js +9 -0
- package/dist/hangul.d.ts +102 -0
- package/dist/hangul.js +1 -0
- package/dist/index.d.ts +270 -0
- package/dist/index.js +1 -0
- package/dist/llm.d.ts +584 -0
- package/dist/llm.js +40 -0
- package/dist/maintenance.d.ts +33 -0
- package/dist/maintenance.js +1 -0
- package/dist/mcp/daemon-health.d.ts +17 -0
- package/dist/mcp/daemon-health.js +1 -0
- package/dist/mcp/origin-guard.d.ts +67 -0
- package/dist/mcp/origin-guard.js +1 -0
- package/dist/mcp/server.d.ts +131 -0
- package/dist/mcp/server.js +35 -0
- package/dist/memory.d.ts +74 -0
- package/dist/memory.js +13 -0
- package/dist/metadata-filter.d.ts +74 -0
- package/dist/metadata-filter.js +1 -0
- package/dist/metadata-store.d.ts +45 -0
- package/dist/metadata-store.js +68 -0
- package/dist/metadata.d.ts +61 -0
- package/dist/metadata.js +1 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.js +1 -0
- package/dist/query-log.d.ts +156 -0
- package/dist/query-log.js +2 -0
- package/dist/refresh.d.ts +60 -0
- package/dist/refresh.js +1 -0
- package/dist/rerank-input.d.ts +46 -0
- package/dist/rerank-input.js +5 -0
- package/dist/store.d.ts +1267 -0
- package/dist/store.js +421 -0
- package/dist/trust.d.ts +152 -0
- package/dist/trust.js +2 -0
- package/package.json +124 -0
- package/scripts/build.mjs +130 -0
- package/scripts/check-package-grammars.mjs +29 -0
- package/scripts/package-smoke.mjs +65 -0
- package/scripts/test-all.mjs +42 -0
- package/skills/qmd/SKILL.md +333 -0
- package/skills/qmd/references/mcp-setup.md +122 -0
- package/skills/release/SKILL.md +141 -0
- package/skills/release/scripts/install-hooks.sh +38 -0
- package/skills/release/scripts/release-context.sh +129 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QMD SDK - Library mode for programmatic access to QMD search and indexing.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { createStore } from '@tobilu/qmd'
|
|
6
|
+
*
|
|
7
|
+
* const store = await createStore({
|
|
8
|
+
* dbPath: './my-index.sqlite',
|
|
9
|
+
* config: {
|
|
10
|
+
* collections: {
|
|
11
|
+
* docs: { path: '/path/to/docs', pattern: '**\/*.md' }
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* })
|
|
15
|
+
*
|
|
16
|
+
* const results = await store.search({ query: "how does auth work?" })
|
|
17
|
+
* await store.close()
|
|
18
|
+
*/
|
|
19
|
+
import { extractSnippet, addLineNumbers, DEFAULT_MULTI_GET_MAX_BYTES, type Store as InternalStore, type DocumentResult, type DocumentNotFound, type DocumentExcludedByIgnore, type DocumentLookupError, type SearchResult, type HybridQueryResult, type HybridQueryOptions, type HybridQueryExplain, type ExpandedQuery, type StructuredSearchOptions, type MultiGetResult, type IndexStatus, type IndexHealthInfo, type SearchHooks, type ReindexProgress, type ReindexResult, type EmbedProgress, type EmbedResult, type ChunkStrategy } from "./store.js";
|
|
20
|
+
import type { DocumentFilter } from "./filters.js";
|
|
21
|
+
import type { DocumentMetadata, MetadataScalar, MetadataScalarArray, MetadataValue } from "./metadata.js";
|
|
22
|
+
import { parseMetadataFilter, MetadataFilterError, type MetadataFilter, type MetadataFilterGroup, type MetadataFilterNegation, type MetadataCondition } from "./metadata-filter.js";
|
|
23
|
+
import { type Collection, type CollectionConfig, type NamedCollection, type ContextMap } from "./collections.js";
|
|
24
|
+
export type { DocumentResult, DocumentNotFound, DocumentExcludedByIgnore, DocumentLookupError, SearchResult, HybridQueryResult, HybridQueryOptions, HybridQueryExplain, ExpandedQuery, StructuredSearchOptions, MultiGetResult, IndexStatus, IndexHealthInfo, SearchHooks, ReindexProgress, ReindexResult, EmbedProgress, EmbedResult, Collection, CollectionConfig, NamedCollection, ContextMap, };
|
|
25
|
+
export type { DocumentMetadata, MetadataScalar, MetadataScalarArray, MetadataValue, MetadataFilter, MetadataFilterGroup, MetadataFilterNegation, MetadataCondition, };
|
|
26
|
+
export { parseMetadataFilter, MetadataFilterError };
|
|
27
|
+
export type { InternalStore };
|
|
28
|
+
export type { StoreRerankOptions } from "./store.js";
|
|
29
|
+
export { extractSnippet, addLineNumbers, DEFAULT_MULTI_GET_MAX_BYTES };
|
|
30
|
+
export type { ChunkStrategy } from "./store.js";
|
|
31
|
+
export type { DocumentFilter } from "./filters.js";
|
|
32
|
+
export { buildDocumentFilter, describeFilter, parseTimeSpec } from "./filters.js";
|
|
33
|
+
export { getDefaultDbPath } from "./store.js";
|
|
34
|
+
export { Maintenance } from "./maintenance.js";
|
|
35
|
+
/**
|
|
36
|
+
* Progress info emitted during update() for each file processed.
|
|
37
|
+
*/
|
|
38
|
+
export type UpdateProgress = {
|
|
39
|
+
collection: string;
|
|
40
|
+
file: string;
|
|
41
|
+
current: number;
|
|
42
|
+
total: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Aggregated result from update() across all collections.
|
|
46
|
+
*/
|
|
47
|
+
export type UpdateResult = {
|
|
48
|
+
collections: number;
|
|
49
|
+
indexed: number;
|
|
50
|
+
updated: number;
|
|
51
|
+
unchanged: number;
|
|
52
|
+
removed: number;
|
|
53
|
+
skipped: number;
|
|
54
|
+
needsEmbedding: number;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Options for the unified search() method.
|
|
58
|
+
*/
|
|
59
|
+
export interface SearchOptions {
|
|
60
|
+
/** Simple query string — auto-expanded via LLM, unless it contains Hangul */
|
|
61
|
+
query?: string;
|
|
62
|
+
/** Pre-expanded queries (from expandQuery) — skips auto-expansion */
|
|
63
|
+
queries?: ExpandedQuery[];
|
|
64
|
+
/** Domain intent hint — steers reranking and snippet/chunk selection */
|
|
65
|
+
intent?: string;
|
|
66
|
+
/** Rerank results using LLM (default: true) */
|
|
67
|
+
rerank?: boolean;
|
|
68
|
+
/** Filter to a specific collection */
|
|
69
|
+
collection?: string;
|
|
70
|
+
/** Filter to specific collections */
|
|
71
|
+
collections?: string[];
|
|
72
|
+
/** Metadata filter — every returned result satisfies it */
|
|
73
|
+
filter?: MetadataFilter;
|
|
74
|
+
/** Max results (default: 10) */
|
|
75
|
+
limit?: number;
|
|
76
|
+
/** Max candidates to rerank (default: 40) */
|
|
77
|
+
candidateLimit?: number;
|
|
78
|
+
/** Per-request rerank doc token cap; overrides QMD_RERANK_MAX_DOC_TOKENS */
|
|
79
|
+
rerankMaxDocTokens?: number;
|
|
80
|
+
/** Minimum score threshold */
|
|
81
|
+
minScore?: number;
|
|
82
|
+
/** Include explain traces */
|
|
83
|
+
explain?: boolean;
|
|
84
|
+
/** Chunk strategy: "auto" (default, uses AST for code files) or "regex" (legacy) */
|
|
85
|
+
chunkStrategy?: ChunkStrategy;
|
|
86
|
+
/**
|
|
87
|
+
* Narrow the corpus before anything is ranked: path globs against
|
|
88
|
+
* `collection/path`, and a `modified_at` range. Build one with
|
|
89
|
+
* `buildDocumentFilter` so `--since 7d` and a bad span both behave.
|
|
90
|
+
* ANDed with `filter`.
|
|
91
|
+
*/
|
|
92
|
+
scope?: DocumentFilter;
|
|
93
|
+
/** Past this many ms, answer in RRF order instead of waiting for the reranker (unset or 0 = wait) */
|
|
94
|
+
rerankDeadlineMs?: number;
|
|
95
|
+
/** Past this many ms, search the original query only instead of waiting for expansion (unset or 0 = wait) */
|
|
96
|
+
expandDeadlineMs?: number;
|
|
97
|
+
/** Progress callbacks for expansion, embedding and reranking */
|
|
98
|
+
hooks?: SearchHooks;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Options for searchLex() — BM25 keyword search.
|
|
102
|
+
*/
|
|
103
|
+
export interface LexSearchOptions {
|
|
104
|
+
limit?: number;
|
|
105
|
+
collection?: string | string[];
|
|
106
|
+
/** Metadata filter — every returned result satisfies it */
|
|
107
|
+
filter?: MetadataFilter;
|
|
108
|
+
/** Narrow the corpus by path glob and `modified_at` before ranking (see `buildDocumentFilter`) */
|
|
109
|
+
scope?: DocumentFilter;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Options for searchVector() — vector similarity search.
|
|
113
|
+
*/
|
|
114
|
+
export interface VectorSearchOptions {
|
|
115
|
+
limit?: number;
|
|
116
|
+
collection?: string | string[];
|
|
117
|
+
/** Metadata filter — every returned result satisfies it */
|
|
118
|
+
filter?: MetadataFilter;
|
|
119
|
+
/** Narrow the corpus by path glob and `modified_at` before ranking (see `buildDocumentFilter`) */
|
|
120
|
+
scope?: DocumentFilter;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Options for expandQuery() — manual query expansion.
|
|
124
|
+
*/
|
|
125
|
+
export interface ExpandQueryOptions {
|
|
126
|
+
/**
|
|
127
|
+
* @deprecated Ignored. Intent no longer feeds the expansion model — caller
|
|
128
|
+
* intent is meta-language the model reproduced verbatim as sub-queries.
|
|
129
|
+
* Pass intent via SearchOptions instead, where it shapes reranking and
|
|
130
|
+
* snippet selection.
|
|
131
|
+
*/
|
|
132
|
+
intent?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Options for creating a QMD store.
|
|
136
|
+
*
|
|
137
|
+
* Provide `dbPath` and optionally `configPath` (YAML file) or `config` (inline).
|
|
138
|
+
* If neither configPath nor config is provided, the store reads from existing
|
|
139
|
+
* DB state (useful for reopening a previously-configured store).
|
|
140
|
+
*/
|
|
141
|
+
export interface StoreOptions {
|
|
142
|
+
/** Path to the SQLite database file */
|
|
143
|
+
dbPath: string;
|
|
144
|
+
/** Path to a YAML config file (mutually exclusive with `config`) */
|
|
145
|
+
configPath?: string;
|
|
146
|
+
/** Inline collection config (mutually exclusive with `configPath`) */
|
|
147
|
+
config?: CollectionConfig;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The QMD SDK store — provides search, retrieval, collection management,
|
|
151
|
+
* context management, and indexing operations.
|
|
152
|
+
*
|
|
153
|
+
* All methods are async. The store manages its own LlamaCpp instance
|
|
154
|
+
* (lazy-loaded, auto-unloaded after inactivity) — no global singletons.
|
|
155
|
+
*/
|
|
156
|
+
export interface QMDStore {
|
|
157
|
+
/** The underlying internal store (for advanced use) */
|
|
158
|
+
readonly internal: InternalStore;
|
|
159
|
+
/** Path to the SQLite database */
|
|
160
|
+
readonly dbPath: string;
|
|
161
|
+
/** Full search: query expansion + multi-signal retrieval + LLM reranking */
|
|
162
|
+
search(options: SearchOptions): Promise<HybridQueryResult[]>;
|
|
163
|
+
/** BM25 keyword search (fast, no LLM) */
|
|
164
|
+
searchLex(query: string, options?: LexSearchOptions): Promise<SearchResult[]>;
|
|
165
|
+
/** Vector similarity search (embedding model, no reranking) */
|
|
166
|
+
searchVector(query: string, options?: VectorSearchOptions): Promise<SearchResult[]>;
|
|
167
|
+
/** Expand a query into typed sub-searches (lex/vec/hyde) for manual control */
|
|
168
|
+
expandQuery(query: string, options?: ExpandQueryOptions): Promise<ExpandedQuery[]>;
|
|
169
|
+
/** Get a single document by path or docid */
|
|
170
|
+
get(pathOrDocid: string, options?: {
|
|
171
|
+
includeBody?: boolean;
|
|
172
|
+
}): Promise<DocumentResult | DocumentLookupError>;
|
|
173
|
+
/** Get the body content of a document, optionally sliced by line range */
|
|
174
|
+
getDocumentBody(pathOrDocid: string, opts?: {
|
|
175
|
+
fromLine?: number;
|
|
176
|
+
maxLines?: number;
|
|
177
|
+
}): Promise<string | null>;
|
|
178
|
+
/** Get multiple documents by glob pattern or comma-separated list */
|
|
179
|
+
multiGet(pattern: string, options?: {
|
|
180
|
+
includeBody?: boolean;
|
|
181
|
+
maxBytes?: number;
|
|
182
|
+
}): Promise<{
|
|
183
|
+
docs: MultiGetResult[];
|
|
184
|
+
errors: string[];
|
|
185
|
+
}>;
|
|
186
|
+
/** Add or update a collection */
|
|
187
|
+
addCollection(name: string, opts: {
|
|
188
|
+
path: string;
|
|
189
|
+
pattern?: string;
|
|
190
|
+
ignore?: string[];
|
|
191
|
+
}): Promise<void>;
|
|
192
|
+
/** Remove a collection */
|
|
193
|
+
removeCollection(name: string): Promise<boolean>;
|
|
194
|
+
/** Rename a collection */
|
|
195
|
+
renameCollection(oldName: string, newName: string): Promise<boolean>;
|
|
196
|
+
/** List all collections with document stats */
|
|
197
|
+
listCollections(): Promise<{
|
|
198
|
+
name: string;
|
|
199
|
+
pwd: string;
|
|
200
|
+
glob_pattern: string;
|
|
201
|
+
doc_count: number;
|
|
202
|
+
active_count: number;
|
|
203
|
+
last_modified: string | null;
|
|
204
|
+
includeByDefault: boolean;
|
|
205
|
+
}[]>;
|
|
206
|
+
/** Get names of collections included by default in queries */
|
|
207
|
+
getDefaultCollectionNames(): Promise<string[]>;
|
|
208
|
+
/** Add context for a path within a collection */
|
|
209
|
+
addContext(collectionName: string, pathPrefix: string, contextText: string): Promise<boolean>;
|
|
210
|
+
/** Remove context from a collection path */
|
|
211
|
+
removeContext(collectionName: string, pathPrefix: string): Promise<boolean>;
|
|
212
|
+
/** Set global context (applies to all collections) */
|
|
213
|
+
setGlobalContext(context: string | undefined): Promise<void>;
|
|
214
|
+
/** Get global context */
|
|
215
|
+
getGlobalContext(): Promise<string | undefined>;
|
|
216
|
+
/** List all contexts across all collections */
|
|
217
|
+
listContexts(): Promise<Array<{
|
|
218
|
+
collection: string;
|
|
219
|
+
path: string;
|
|
220
|
+
context: string;
|
|
221
|
+
}>>;
|
|
222
|
+
/** Re-index collections by scanning the filesystem */
|
|
223
|
+
update(options?: {
|
|
224
|
+
collections?: string[];
|
|
225
|
+
onProgress?: (info: UpdateProgress) => void;
|
|
226
|
+
}): Promise<UpdateResult>;
|
|
227
|
+
/** Generate vector embeddings for documents that need them */
|
|
228
|
+
embed(options?: {
|
|
229
|
+
force?: boolean;
|
|
230
|
+
model?: string;
|
|
231
|
+
/** Restrict embedding to documents in one collection. */
|
|
232
|
+
collection?: string;
|
|
233
|
+
maxDocsPerBatch?: number;
|
|
234
|
+
maxBatchBytes?: number;
|
|
235
|
+
chunkStrategy?: ChunkStrategy;
|
|
236
|
+
onProgress?: (info: EmbedProgress) => void;
|
|
237
|
+
}): Promise<EmbedResult>;
|
|
238
|
+
/** Get index status (document counts, collections, embedding state) */
|
|
239
|
+
getStatus(): Promise<IndexStatus>;
|
|
240
|
+
/** Get index health info (stale embeddings, etc.) */
|
|
241
|
+
getIndexHealth(): Promise<IndexHealthInfo>;
|
|
242
|
+
/** Close the store and release all resources (LLM models, DB connection) */
|
|
243
|
+
close(): Promise<void>;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Create a QMD store for programmatic access to search and indexing.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* // With a YAML config file
|
|
251
|
+
* const store = await createStore({
|
|
252
|
+
* dbPath: './index.sqlite',
|
|
253
|
+
* configPath: './qmd.yml',
|
|
254
|
+
* })
|
|
255
|
+
*
|
|
256
|
+
* // With inline config (no files needed besides the DB)
|
|
257
|
+
* const store = await createStore({
|
|
258
|
+
* dbPath: './index.sqlite',
|
|
259
|
+
* config: {
|
|
260
|
+
* collections: {
|
|
261
|
+
* docs: { path: '/path/to/docs', pattern: '**\/*.md' }
|
|
262
|
+
* }
|
|
263
|
+
* }
|
|
264
|
+
* })
|
|
265
|
+
*
|
|
266
|
+
* const results = await store.search({ query: "authentication flow" })
|
|
267
|
+
* await store.close()
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export declare function createStore(options: StoreOptions): Promise<QMDStore>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var M=Object.defineProperty;var t=(i,r)=>M(i,"name",{value:r,configurable:!0});import{createStore as P,hybridQuery as w,structuredSearch as v,extractSnippet as L,addLineNumbers as B,DEFAULT_MULTI_GET_MAX_BYTES as E,reindexCollection as T,generateEmbeddings as q,listCollections as D,syncConfigToDb as b,getStoreCollections as G,getStoreGlobalContext as F,getStoreContexts as I,upsertStoreCollection as R,deleteStoreCollection as U,renameStoreCollection as A,updateStoreContext as _,removeStoreContext as H,setStoreGlobalContext as Q}from"./store.js";import{LlamaCpp as V}from"./llm.js";import{parseMetadataFilter as g,MetadataFilterError as Y}from"./metadata-filter.js";import{setConfigSource as h,loadConfig as j,addCollection as X,removeCollection as $,renameCollection as z,addContext as J,removeContext as K,setGlobalContext as N}from"./collections.js";import{buildDocumentFilter as ie,describeFilter as ce,parseTimeSpec as ae}from"./filters.js";import{getDefaultDbPath as de}from"./store.js";import{Maintenance as fe}from"./maintenance.js";async function te(i){if(!i.dbPath)throw new Error("dbPath is required");if(i.configPath&&i.config)throw new Error("Provide either configPath or config, not both");const r=P(i.dbPath),c=r.db,d=!!i.configPath;let s;i.configPath?(h({configPath:i.configPath}),s=j(),b(c,s)):i.config&&(h({config:i.config}),s=i.config,b(c,s));const m=new V({embedModel:s?.models?.embed,generateModel:s?.models?.generate,rerankModel:s?.models?.rerank,inactivityTimeoutMs:300*1e3,disposeModelsOnInactivity:!0});return r.llm=m,{internal:r,dbPath:r.dbPath,search:t(async e=>{if(!e.query&&!e.queries)throw new Error("search() requires either 'query' or 'queries'");const n=[...e.collection?[e.collection]:[],...e.collections??[]],o=e.rerank===!1,f=e.filter===void 0?void 0:g(e.filter);return e.queries?v(r,e.queries,{collections:n.length>0?n:void 0,filter:f,limit:e.limit,minScore:e.minScore,explain:e.explain,intent:e.intent,candidateLimit:e.candidateLimit,rerankMaxDocTokens:e.rerankMaxDocTokens,skipRerank:o,chunkStrategy:e.chunkStrategy,scope:e.scope,rerankDeadlineMs:e.rerankDeadlineMs,hooks:e.hooks}):w(r,e.query,{collection:n.length>0?n:void 0,filter:f,limit:e.limit,minScore:e.minScore,explain:e.explain,intent:e.intent,candidateLimit:e.candidateLimit,rerankMaxDocTokens:e.rerankMaxDocTokens,skipRerank:o,chunkStrategy:e.chunkStrategy,scope:e.scope,rerankDeadlineMs:e.rerankDeadlineMs,expandDeadlineMs:e.expandDeadlineMs,hooks:e.hooks})},"search"),searchLex:t(async(e,n)=>{const o=n?.filter===void 0?void 0:g(n.filter);return r.searchFTS(e,n?.limit,n?.collection,o,n?.scope)},"searchLex"),searchVector:t(async(e,n)=>{const o=n?.filter===void 0?void 0:g(n.filter);return r.searchVec(e,m.embedModelName,n?.limit,n?.collection,void 0,void 0,o,n?.scope)},"searchVector"),expandQuery:t(async e=>r.expandQuery(e),"expandQuery"),get:t(async(e,n)=>r.findDocument(e,n),"get"),getDocumentBody:t(async(e,n)=>{const o=r.findDocument(e,{includeBody:!1});return"error"in o?null:r.getDocumentBody(o,n?.fromLine,n?.maxLines)},"getDocumentBody"),multiGet:t(async(e,n)=>r.findDocuments(e,n),"multiGet"),addCollection:t(async(e,n)=>{R(c,e,{path:n.path,pattern:n.pattern,ignore:n.ignore}),(d||i.config)&&X(e,n.path,n.pattern,{ignore:n.ignore})},"addCollection"),removeCollection:t(async e=>{const n=U(c,e);return(d||i.config)&&$(e),n},"removeCollection"),renameCollection:t(async(e,n)=>{const o=A(c,e,n);return(d||i.config)&&z(e,n),o},"renameCollection"),listCollections:t(async()=>D(c),"listCollections"),getDefaultCollectionNames:t(async()=>D(c).filter(n=>n.includeByDefault).map(n=>n.name),"getDefaultCollectionNames"),addContext:t(async(e,n,o)=>{const f=_(c,e,n,o);return(d||i.config)&&J(e,n,o),f},"addContext"),removeContext:t(async(e,n)=>{const o=H(c,e,n);return(d||i.config)&&K(e,n),o},"removeContext"),setGlobalContext:t(async e=>{Q(c,e),(d||i.config)&&N(e)},"setGlobalContext"),getGlobalContext:t(async()=>F(c),"getGlobalContext"),listContexts:t(async()=>I(c),"listContexts"),update:t(async e=>{const n=G(c),o=e?.collections;if(o){const a=new Set(n.map(u=>u.name)),l=o.filter(u=>!a.has(u));if(l.length>0)throw new Error(`Unknown collection(s): ${l.join(", ")}`)}const f=o?n.filter(a=>o.includes(a.name)):n;r.clearCache();let y=0,x=0,C=0,k=0,S=0;for(const a of f){const l=await T(r,a.path,a.pattern||"**/*.md",a.name,{ignorePatterns:a.ignore,onProgress:e?.onProgress?u=>e.onProgress({collection:a.name,...u}):void 0});y+=l.indexed,x+=l.updated,C+=l.unchanged,k+=l.removed,S+=l.skipped}return{collections:f.length,indexed:y,updated:x,unchanged:C,removed:k,skipped:S,needsEmbedding:r.getHashesNeedingEmbedding()}},"update"),embed:t(async e=>q(r,{force:e?.force,model:e?.model,collection:e?.collection,maxDocsPerBatch:e?.maxDocsPerBatch,maxBatchBytes:e?.maxBatchBytes,chunkStrategy:e?.chunkStrategy,onProgress:e?.onProgress}),"embed"),getStatus:t(async()=>r.getStatus(),"getStatus"),getIndexHealth:t(async()=>r.getIndexHealth(),"getIndexHealth"),close:t(async()=>{await m.dispose(),r.close(),(d||i.config)&&h(void 0)},"close")}}t(te,"createStore");export{E as DEFAULT_MULTI_GET_MAX_BYTES,fe as Maintenance,Y as MetadataFilterError,B as addLineNumbers,ie as buildDocumentFilter,te as createStore,ce as describeFilter,L as extractSnippet,de as getDefaultDbPath,g as parseMetadataFilter,ae as parseTimeSpec};
|