@easbot/memory 0.1.11
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/LICENSE +21 -0
- package/README.md +163 -0
- package/dist/assets/txt/assets/jieba_dict.txt +349046 -0
- package/dist/index.cjs +177 -0
- package/dist/index.d.cts +309 -0
- package/dist/index.d.ts +309 -0
- package/dist/index.mjs +177 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 houjallen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# @easbot/memory
|
|
2
|
+
|
|
3
|
+
[English](#english) | [中文](#中文)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<a name="中文"></a>
|
|
8
|
+
|
|
9
|
+
## 中文
|
|
10
|
+
|
|
11
|
+
EASBOT 生态系统的记忆管理库,提供智能化的记忆索引、搜索和管理功能。
|
|
12
|
+
|
|
13
|
+
### 特性
|
|
14
|
+
|
|
15
|
+
- **混合搜索**:支持向量搜索、全文搜索(FTS)和图搜索的混合检索
|
|
16
|
+
- **中英文分词**:基于 jieba-wasm 实现高质量中英文分词
|
|
17
|
+
- **增量索引**:支持增量更新,自动检测文件变化
|
|
18
|
+
- **多源支持**:支持 memory 和 sessions 两种记忆源
|
|
19
|
+
- **XDG 规范**:数据库默认存储在 XDG 数据目录
|
|
20
|
+
|
|
21
|
+
### 安装
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm add @easbot/memory
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 使用示例
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { MemoryIndexManager } from '@easbot/memory';
|
|
31
|
+
|
|
32
|
+
// 获取记忆管理器实例
|
|
33
|
+
const manager = await MemoryIndexManager.get({
|
|
34
|
+
workspaceDir: '/path/to/workspace',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// 搜索记忆
|
|
38
|
+
const results = manager.search('机器学习', {
|
|
39
|
+
maxResults: 10,
|
|
40
|
+
minScore: 0.5,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// 索引文件
|
|
44
|
+
await manager.indexFile('/path/to/file.md');
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### API
|
|
48
|
+
|
|
49
|
+
#### MemoryIndexManager
|
|
50
|
+
|
|
51
|
+
| 方法 | 说明 |
|
|
52
|
+
|------|------|
|
|
53
|
+
| `get(params)` | 获取或创建管理器实例 |
|
|
54
|
+
| `search(query, options)` | 混合搜索 |
|
|
55
|
+
| `indexFile(filePath)` | 索引单个文件 |
|
|
56
|
+
| `indexDirectory(dirPath)` | 索引目录 |
|
|
57
|
+
| `getStatus()` | 获取状态信息 |
|
|
58
|
+
|
|
59
|
+
### 开发
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# 安装依赖
|
|
63
|
+
pnpm install
|
|
64
|
+
|
|
65
|
+
# 构建
|
|
66
|
+
pnpm build
|
|
67
|
+
|
|
68
|
+
# 测试
|
|
69
|
+
pnpm test
|
|
70
|
+
|
|
71
|
+
# 类型检查
|
|
72
|
+
pnpm type-check
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 数据库位置
|
|
76
|
+
|
|
77
|
+
默认存储位置:`$XDG_DATA_HOME/easbot/memory.db`
|
|
78
|
+
|
|
79
|
+
- Linux: `~/.local/share/easbot/memory.db`
|
|
80
|
+
- macOS: `~/Library/Application Support/easbot/memory.db`
|
|
81
|
+
- Windows: `%APPDATA%/easbot/memory.db`
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
<a name="english"></a>
|
|
86
|
+
|
|
87
|
+
## English
|
|
88
|
+
|
|
89
|
+
Memory management library for the EASBOT ecosystem, providing intelligent memory indexing, search, and management capabilities.
|
|
90
|
+
|
|
91
|
+
### Features
|
|
92
|
+
|
|
93
|
+
- **Hybrid Search**: Combines vector search, full-text search (FTS), and graph search
|
|
94
|
+
- **Chinese/English Tokenization**: High-quality tokenization via jieba-wasm
|
|
95
|
+
- **Incremental Indexing**: Supports incremental updates with automatic file change detection
|
|
96
|
+
- **Multi-source Support**: Supports both 'memory' and 'sessions' memory sources
|
|
97
|
+
- **XDG Compliance**: Database stored in XDG data directory by default
|
|
98
|
+
|
|
99
|
+
### Installation
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pnpm add @easbot/memory
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Usage
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { MemoryIndexManager } from '@easbot/memory';
|
|
109
|
+
|
|
110
|
+
// Get memory manager instance
|
|
111
|
+
const manager = await MemoryIndexManager.get({
|
|
112
|
+
workspaceDir: '/path/to/workspace',
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Search memories
|
|
116
|
+
const results = manager.search('machine learning', {
|
|
117
|
+
maxResults: 10,
|
|
118
|
+
minScore: 0.5,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Index a file
|
|
122
|
+
await manager.indexFile('/path/to/file.md');
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### API
|
|
126
|
+
|
|
127
|
+
#### MemoryIndexManager
|
|
128
|
+
|
|
129
|
+
| Method | Description |
|
|
130
|
+
|--------|-------------|
|
|
131
|
+
| `get(params)` | Get or create manager instance |
|
|
132
|
+
| `search(query, options)` | Hybrid search |
|
|
133
|
+
| `indexFile(filePath)` | Index a single file |
|
|
134
|
+
| `indexDirectory(dirPath)` | Index a directory |
|
|
135
|
+
| `getStatus()` | Get status information |
|
|
136
|
+
|
|
137
|
+
### Development
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Install dependencies
|
|
141
|
+
pnpm install
|
|
142
|
+
|
|
143
|
+
# Build
|
|
144
|
+
pnpm build
|
|
145
|
+
|
|
146
|
+
# Test
|
|
147
|
+
pnpm test
|
|
148
|
+
|
|
149
|
+
# Type check
|
|
150
|
+
pnpm type-check
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Database Location
|
|
154
|
+
|
|
155
|
+
Default storage: `$XDG_DATA_HOME/easbot/memory.db`
|
|
156
|
+
|
|
157
|
+
- Linux: `~/.local/share/easbot/memory.db`
|
|
158
|
+
- macOS: `~/Library/Application Support/easbot/memory.db`
|
|
159
|
+
- Windows: `%APPDATA%/easbot/memory.db`
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT
|