@kb-labs/mind-core 2.93.0 → 2.96.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/README.md +17 -179
- package/dist/index.d.ts +397 -332
- package/dist/index.js +1340 -515
- package/dist/index.js.map +1 -1
- package/dist/services-CdtgGHNc.d.ts +14 -0
- package/dist/testing.d.ts +68 -0
- package/dist/testing.js +169 -0
- package/dist/testing.js.map +1 -0
- package/package.json +13 -8
package/README.md
CHANGED
|
@@ -1,187 +1,25 @@
|
|
|
1
1
|
# @kb-labs/mind-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The engine for the KB Labs **Mind** (RAG) plugin — all retrieval/answer logic
|
|
4
|
+
behind a single `createMind(services, config)` facade that the CLI and REST
|
|
5
|
+
handlers call identically.
|
|
4
6
|
|
|
5
|
-
##
|
|
7
|
+
## Verbs
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
`index` · `search` · `ask` · `explore` · `reindex` · `sync{Add,Update,Delete,List,Status}` · `status` · `health`
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## Pipeline
|
|
10
12
|
|
|
11
|
-
- **
|
|
12
|
-
-
|
|
13
|
-
- **
|
|
14
|
-
|
|
15
|
-
-
|
|
13
|
+
- **Ingest** — discover (adaptive, language-agnostic) → chunk (AST-aware) →
|
|
14
|
+
token-budget embed → upsert + manifest. Incremental via per-file hash delta.
|
|
15
|
+
- **Retrieve** — hybrid BM25 + vector fused with intent-adaptive RRF; per-result
|
|
16
|
+
provenance (`matchedBy: lexical|semantic|both`) and freshness (`stale`).
|
|
17
|
+
Optional HyDE (vector-side) and query expansion (lexical-side), both flagged.
|
|
18
|
+
- **Answer** — verify/confidence + field-check (anti-hallucination); `ask`
|
|
19
|
+
synthesizes a grounded answer, `explore` returns a task-orientation file map.
|
|
16
20
|
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
- **Version**: 0.1.0
|
|
20
|
-
- **Stage**: Stable
|
|
21
|
-
- **Status**: Production Ready ✅
|
|
22
|
-
|
|
23
|
-
## Architecture
|
|
24
|
-
|
|
25
|
-
### High-Level Overview
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
Mind Core
|
|
29
|
-
│
|
|
30
|
-
├──► Error Handling
|
|
31
|
-
├──► Token Utilities
|
|
32
|
-
├──► Hash Utilities
|
|
33
|
-
├──► Path Utilities
|
|
34
|
-
└──► Defaults
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Key Components
|
|
38
|
-
|
|
39
|
-
1. **Error** (`error/`): Error handling
|
|
40
|
-
2. **Utils** (`utils/`): Utilities (token, hash, paths)
|
|
41
|
-
3. **Defaults** (`defaults.ts`): Default configurations
|
|
42
|
-
|
|
43
|
-
## ✨ Features
|
|
44
|
-
|
|
45
|
-
- **Error Handling**: Unified error handling for Mind
|
|
46
|
-
- **Token Utilities**: Token estimation and truncation utilities
|
|
47
|
-
- **Hash Utilities**: Hashing utilities
|
|
48
|
-
- **Path Utilities**: Path manipulation utilities
|
|
49
|
-
- **Defaults**: Default configurations
|
|
50
|
-
|
|
51
|
-
## 📦 API Reference
|
|
52
|
-
|
|
53
|
-
### Main Exports
|
|
54
|
-
|
|
55
|
-
#### Error Handling
|
|
56
|
-
|
|
57
|
-
- `MindError`: Mind error class
|
|
58
|
-
- `createMindError`: Create Mind error
|
|
59
|
-
|
|
60
|
-
#### Token Utilities
|
|
61
|
-
|
|
62
|
-
- `estimateTokens`: Estimate tokens in text
|
|
63
|
-
- `truncateTokens`: Truncate text by tokens
|
|
64
|
-
|
|
65
|
-
#### Hash Utilities
|
|
66
|
-
|
|
67
|
-
- `hashString`: Hash string
|
|
68
|
-
- `hashFile`: Hash file
|
|
69
|
-
|
|
70
|
-
#### Path Utilities
|
|
71
|
-
|
|
72
|
-
- `normalizePath`: Normalize path
|
|
73
|
-
- `resolvePath`: Resolve path
|
|
74
|
-
|
|
75
|
-
#### Defaults
|
|
76
|
-
|
|
77
|
-
- `DEFAULT_CONFIG`: Default configuration
|
|
78
|
-
|
|
79
|
-
## 🔧 Configuration
|
|
80
|
-
|
|
81
|
-
### Configuration Options
|
|
82
|
-
|
|
83
|
-
All configuration via function parameters.
|
|
84
|
-
|
|
85
|
-
## 🔗 Dependencies
|
|
86
|
-
|
|
87
|
-
### Runtime Dependencies
|
|
88
|
-
|
|
89
|
-
- `@kb-labs/mind-types` (`link:../mind-types`): Mind types
|
|
90
|
-
|
|
91
|
-
### Development Dependencies
|
|
92
|
-
|
|
93
|
-
- `@kb-labs/devkit` (`link:../../../kb-labs-devkit`): DevKit presets
|
|
94
|
-
- `@types/node` (`^24.7.0`): Node.js types
|
|
95
|
-
- `tsup` (`^8.5.0`): TypeScript bundler
|
|
96
|
-
- `typescript` (`^5.6.3`): TypeScript compiler
|
|
97
|
-
- `vitest` (`^3.2.4`): Test runner
|
|
98
|
-
|
|
99
|
-
## 🧪 Testing
|
|
100
|
-
|
|
101
|
-
### Test Structure
|
|
102
|
-
|
|
103
|
-
No tests currently.
|
|
104
|
-
|
|
105
|
-
### Test Coverage
|
|
106
|
-
|
|
107
|
-
- **Current Coverage**: ~50%
|
|
108
|
-
- **Target Coverage**: 90%
|
|
109
|
-
|
|
110
|
-
## 📈 Performance
|
|
111
|
-
|
|
112
|
-
### Performance Characteristics
|
|
113
|
-
|
|
114
|
-
- **Time Complexity**: O(1) for utilities, O(n) for token estimation
|
|
115
|
-
- **Space Complexity**: O(1)
|
|
116
|
-
- **Bottlenecks**: Token estimation for large texts
|
|
117
|
-
|
|
118
|
-
## 🔒 Security
|
|
119
|
-
|
|
120
|
-
### Security Considerations
|
|
121
|
-
|
|
122
|
-
- **Hash Utilities**: Secure hashing utilities
|
|
123
|
-
- **Path Validation**: Path validation for file operations
|
|
124
|
-
|
|
125
|
-
### Known Vulnerabilities
|
|
126
|
-
|
|
127
|
-
- None
|
|
128
|
-
|
|
129
|
-
## 🐛 Known Issues & Limitations
|
|
130
|
-
|
|
131
|
-
### Known Issues
|
|
132
|
-
|
|
133
|
-
- None currently
|
|
134
|
-
|
|
135
|
-
### Limitations
|
|
136
|
-
|
|
137
|
-
- **Token Estimation**: Basic token estimation
|
|
138
|
-
|
|
139
|
-
### Future Improvements
|
|
140
|
-
|
|
141
|
-
- **Better Token Estimation**: More accurate token estimation
|
|
142
|
-
|
|
143
|
-
## 🔄 Migration & Breaking Changes
|
|
144
|
-
|
|
145
|
-
### Migration from Previous Versions
|
|
146
|
-
|
|
147
|
-
No breaking changes in current version (0.1.0).
|
|
148
|
-
|
|
149
|
-
### Breaking Changes in Future Versions
|
|
150
|
-
|
|
151
|
-
- None planned
|
|
152
|
-
|
|
153
|
-
## 📚 Examples
|
|
154
|
-
|
|
155
|
-
### Example 1: Use Error Handling
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
import { createMindError } from '@kb-labs/mind-core';
|
|
159
|
-
|
|
160
|
-
const error = createMindError('MIND_PARSE_ERROR', 'Failed to parse file');
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### Example 2: Use Token Utilities
|
|
164
|
-
|
|
165
|
-
```typescript
|
|
166
|
-
import { estimateTokens, truncateTokens } from '@kb-labs/mind-core';
|
|
167
|
-
|
|
168
|
-
const tokens = estimateTokens('Hello world');
|
|
169
|
-
const truncated = truncateTokens('Long text...', 100);
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Example 3: Use Hash Utilities
|
|
173
|
-
|
|
174
|
-
```typescript
|
|
175
|
-
import { hashString } from '@kb-labs/mind-core';
|
|
176
|
-
|
|
177
|
-
const hash = hashString('Hello world');
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
## 🤝 Contributing
|
|
181
|
-
|
|
182
|
-
See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development guidelines.
|
|
183
|
-
|
|
184
|
-
## 📄 License
|
|
185
|
-
|
|
186
|
-
MIT © KB Labs
|
|
21
|
+
## Boundary
|
|
187
22
|
|
|
23
|
+
Imports only `@kb-labs/sdk` (+ `@kb-labs/mind-contracts`). Platform adapters
|
|
24
|
+
(LLM, embeddings, vector store, storage, cache) arrive via injected
|
|
25
|
+
`MindServices` — never imported directly.
|