You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A local context retrieval library that enables semantic search over your documentation. It loads documents (Markdown, JSON, Text), vectorizes them using [Transformers.js](https://huggingface.co/transformers.js), and stores vectors locally in `.zvec` files for fast semantic querying.
4
4
5
5
> [!TIP]
6
-
> Base it, We provide an official context HTTP server simlar with context7, used to provide AI code generation context services in MCP, Skill, and CLI, for free!
6
+
> Based on this library, we provide an official context HTTP server similar to context7, used to provide AI code generation context services in MCP, Skill, and CLI, for free!
7
7
8
8
9
9
## Features
10
10
11
-
- 📄 **Multi-format Support**: Supports Markdown, JSON, Text, and other file formats
12
-
-📚**Multi-library Support**: Manage documents by library
13
-
-⚡**Auto-indexing**: Automatic vectorization on load
14
-
-🔍**Semantic Retrieval**: Retrieve relevant documents based on vector similarity (file-level)
11
+
- 📄 **Multi-format Support**: Markdown, JSON, Text 文档自动加载与向量化
|`queryExpansion`| `QueryExpansionOptions | false` |`false` (no-op) | Query expansion with user-provided synonym map. `false` disables. Without `synonyms`, expansion is a no-op. |
52
+
|`ftsFields`|`string[]`|`['content']`| Fields to index for Full Text Search in hybrid mode |
53
+
|`ftsFieldWeights`|`Record<string, number>`|`{ content: 1 }`| Per-field boost weights for FTS text path. Higher = more influence. |
54
+
|`rankConstant`|`number`|`60`| RRF rank constant for hybrid search fusion. Lower = "winner-takes-all", higher = more even. |
46
55
47
-
###`ctx.load(library, glob)`
56
+
#### Weight Configuration Example
48
57
49
-
Load files into a specified library with automatic vectorization. Document ID defaults to the file path.
58
+
```typescript
59
+
const ctx =awaitContext.create({
60
+
vectorsDir: './vectors',
61
+
// Boost title matches 3x over content matches
62
+
ftsFieldWeights: { content: 1, title: 3 },
63
+
// More "winner-takes-all" ranking
64
+
rankConstant: 20,
65
+
});
66
+
```
67
+
68
+
#### Query Expansion Configuration Example
69
+
70
+
```typescript
71
+
const ctx =awaitContext.create({
72
+
vectorsDir: './vectors',
73
+
// Define your own CN↔EN synonym bridges (no built-in defaults)
74
+
queryExpansion: {
75
+
synonyms: {
76
+
'折线图': ['line chart', '折线'],
77
+
'雷达图': ['radar chart', '蜘蛛图'],
78
+
'tooltip': ['提示框', 'hover', '悬浮'],
79
+
},
80
+
},
81
+
});
82
+
83
+
// Disable query expansion entirely
84
+
const ctxNoExpand =awaitContext.create({
85
+
vectorsDir: './vectors',
86
+
queryExpansion: false,
87
+
});
88
+
```
89
+
90
+
### `ctx.load(library, pattern)`
91
+
92
+
Load files into a specified library with automatic batch vectorization. Documents are embedded in batches and inserted into the vector store. A content-hash change detection mechanism re-embeds files whose content has changed since the last load.
93
+
94
+
Document IDs are derived from file paths relative to `basePath` for cross-machine consistency.
95
+
96
+
| Parameter | Type | Description |
97
+
|-----------|------|-------------|
98
+
|`library`|`string`| Library name for organizing documents |
Copy file name to clipboardExpand all lines: package.json
+9-2Lines changed: 9 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,12 @@
4
4
"description": "A local context retrieval library that enables semantic search over your documentation. It loads documents (Markdown, JSON, Text), vectorizes them using [Transformers.js](https://huggingface.co/transformers.js), and stores vectors locally in `.zvec` files for fast semantic querying. ",
5
5
"main": "dist/index.js",
6
6
"types": "dist/index.d.ts",
7
-
"type": "module",
8
7
"scripts": {
9
8
"build": "tsc",
10
-
"test": "vitest run --coverage"
9
+
"test": "HF_ENDPOINT=https://hf-mirror.com vitest run --coverage",
0 commit comments