@dikolab/kbdb 0.4.3 → 0.6.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.
Files changed (224) hide show
  1. package/CLA.md +68 -0
  2. package/LICENSE +676 -12
  3. package/LICENSING.md +58 -0
  4. package/README.md +50 -27
  5. package/README.md.bak +320 -0
  6. package/dist/README.md +320 -0
  7. package/dist/{chunk-BJXEVALU.mjs → chunk-QLJ33C74.mjs} +44 -44
  8. package/dist/chunk-QLJ33C74.mjs.map +7 -0
  9. package/dist/cli.cjs +550 -232
  10. package/dist/cli.cjs.map +4 -4
  11. package/dist/cli.d.ts +0 -8
  12. package/dist/cli.mjs +483 -154
  13. package/dist/cli.mjs.map +4 -4
  14. package/dist/kbdb-worker.cjs +36 -5
  15. package/dist/kbdb-worker.cjs.map +3 -3
  16. package/dist/mod.cjs +89 -30
  17. package/dist/mod.cjs.map +4 -4
  18. package/dist/mod.mjs +88 -30
  19. package/dist/mod.mjs.map +4 -4
  20. package/dist/src/cli.d.ts +0 -8
  21. package/dist/src/shared/cli/constants/defaults.constant.d.ts +1 -1
  22. package/dist/src/shared/cli/constants/recfile-command-field-map.constant.d.ts +8 -0
  23. package/dist/src/shared/cli/constants/recfile-field-maps.constant.d.ts +21 -0
  24. package/dist/src/shared/cli/functions/compute-directory-level.function.d.ts +14 -0
  25. package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +2 -28
  26. package/dist/src/shared/cli/functions/format-command-output.function.d.ts +14 -0
  27. package/dist/src/shared/cli/functions/format-db-not-found.function.d.ts +20 -0
  28. package/dist/src/shared/cli/functions/format-output.function.d.ts +1 -0
  29. package/dist/src/shared/cli/functions/format-recfile-output.function.d.ts +11 -0
  30. package/dist/src/shared/cli/functions/render-recfile-value.function.d.ts +11 -0
  31. package/dist/src/shared/cli/functions/resolve-db-dir.function.d.ts +24 -0
  32. package/dist/src/shared/cli/functions/resolve-recfile-key.function.d.ts +9 -0
  33. package/dist/src/shared/cli/functions/run-db-path.function.d.ts +10 -0
  34. package/dist/src/shared/cli/functions/run-export.function.d.ts +8 -4
  35. package/dist/src/shared/cli/functions/run-import.function.d.ts +4 -0
  36. package/dist/src/shared/cli/functions/run-learn.function.d.ts +12 -0
  37. package/dist/src/shared/cli/index.d.ts +4 -1
  38. package/dist/src/shared/cli/typings/cli-options.interface.d.ts +9 -2
  39. package/dist/src/shared/cli/typings/db-resolution.interface.d.ts +9 -0
  40. package/dist/src/shared/cli/typings/recfile-field-map.type.d.ts +10 -0
  41. package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
  42. package/dist/src/shared/wasm-codec/functions/decode-option-u8.function.d.ts +9 -0
  43. package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +4 -0
  44. package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +2 -45
  45. package/dist/src/shared/wasm-codec/functions/encode-update-section-params.function.d.ts +10 -1
  46. package/dist/src/shared/wasm-codec/index.d.ts +1 -1
  47. package/dist/src/shared/wasm-codec/typings/add-section-input.model.d.ts +6 -0
  48. package/dist/src/shared/wasm-codec/typings/section-record-trailing.model.d.ts +5 -0
  49. package/dist/src/shared/wasm-codec/typings/section-record.model.d.ts +5 -0
  50. package/dist/src/shared/worker-client/functions/build-deno-permissions.function.d.ts +11 -0
  51. package/dist/src/shared/worker-client/functions/read-crash-reason.function.d.ts +9 -0
  52. package/dist/src/shared/worker-client/functions/resolve-spawn-script.function.d.ts +6 -0
  53. package/dist/src/shared/worker-client/functions/spawn-daemon.function.d.ts +1 -1
  54. package/dist/src/shared/worker-client/typings/section.model.d.ts +5 -0
  55. package/dist/src/shared/worker-client/typings/worker-client-options.interface.d.ts +0 -6
  56. package/dist/src/shared/worker-daemon/functions/count-files.function.d.ts +12 -0
  57. package/dist/src/shared/worker-daemon/functions/handle-import.function.d.ts +2 -0
  58. package/dist/src/shared/worker-daemon/functions/handle-read-ops.function.d.ts +8 -0
  59. package/dist/src/shared/worker-daemon/functions/validate-daemon-path.function.d.ts +15 -0
  60. package/dist/src/worker.d.ts +0 -7
  61. package/dist/wasm/default-embedding/kbdb_default_embedding_bg.wasm +0 -0
  62. package/dist/wasm/default-embedding/package.json +1 -1
  63. package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
  64. package/dist/wasm/fs-database/package.json +1 -1
  65. package/dist/wasm/fs-migration/kbdb_fs_migration_bg.wasm +0 -0
  66. package/dist/wasm/fs-migration/package.json +1 -1
  67. package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
  68. package/dist/wasm/kb-worker/package.json +1 -1
  69. package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
  70. package/dist/wasm/query-parser/package.json +1 -1
  71. package/dist/worker.d.ts +0 -7
  72. package/dist/worker.mjs +37 -6
  73. package/dist/worker.mjs.map +3 -3
  74. package/package.json +13 -12
  75. package/dist/chunk-BJXEVALU.mjs.map +0 -7
  76. package/dist/src/shared/cli/functions/resolve-raw-db-path.function.d.ts +0 -10
  77. package/docs/details/README.md +0 -30
  78. package/docs/details/agent-tooling.md +0 -132
  79. package/docs/details/cli.md +0 -777
  80. package/docs/details/knowledge-base.md +0 -180
  81. package/docs/details/library-api.md +0 -495
  82. package/docs/details/mcp-server.md +0 -482
  83. package/docs/details/search-and-ranking.md +0 -575
  84. package/docs/details/storage.md +0 -531
  85. package/docs/goals/agents.md +0 -751
  86. package/docs/goals/architecture.svg +0 -198
  87. package/docs/goals/auto-capture.md +0 -378
  88. package/docs/goals/benchmarking.md +0 -296
  89. package/docs/goals/cli.md +0 -2654
  90. package/docs/goals/concurrency.md +0 -259
  91. package/docs/goals/content-composer.md +0 -609
  92. package/docs/goals/content-parser.md +0 -279
  93. package/docs/goals/database.md +0 -1679
  94. package/docs/goals/document.md +0 -368
  95. package/docs/goals/hybrid-search.md +0 -465
  96. package/docs/goals/mcp.md +0 -1541
  97. package/docs/goals/overview.md +0 -124
  98. package/docs/goals/query-parser.md +0 -373
  99. package/docs/goals/query-result.md +0 -860
  100. package/docs/goals/semantic-dedup.md +0 -233
  101. package/docs/goals/skills.md +0 -810
  102. package/docs/goals/sync.md +0 -217
  103. package/docs/goals/worker-client.md +0 -1005
  104. package/docs/goals/worker-daemon.md +0 -1547
  105. package/docs/modules/overview.md +0 -319
  106. package/docs/modules/rust/embedding/module.md +0 -91
  107. package/docs/modules/rust/fs-database/functions/document.md +0 -48
  108. package/docs/modules/rust/fs-database/functions/integrity.md +0 -79
  109. package/docs/modules/rust/fs-database/functions/io.md +0 -87
  110. package/docs/modules/rust/fs-database/functions/module.md +0 -22
  111. package/docs/modules/rust/fs-database/functions/query-exec.md +0 -44
  112. package/docs/modules/rust/fs-database/functions/section.md +0 -76
  113. package/docs/modules/rust/fs-database/indexes/btree.md +0 -35
  114. package/docs/modules/rust/fs-database/indexes/corpus.md +0 -61
  115. package/docs/modules/rust/fs-database/indexes/inverted.md +0 -60
  116. package/docs/modules/rust/fs-database/indexes/module.md +0 -64
  117. package/docs/modules/rust/fs-database/indexes/positional.md +0 -39
  118. package/docs/modules/rust/fs-database/indexes/vectors.md +0 -110
  119. package/docs/modules/rust/fs-database/module.md +0 -150
  120. package/docs/modules/rust/fs-database/types/catalog.md +0 -53
  121. package/docs/modules/rust/fs-database/types/module.md +0 -12
  122. package/docs/modules/rust/fs-database/types/section.md +0 -127
  123. package/docs/modules/rust/kb-worker/functions/compose.md +0 -57
  124. package/docs/modules/rust/kb-worker/functions/module.md +0 -20
  125. package/docs/modules/rust/kb-worker/functions/retrieve.md +0 -194
  126. package/docs/modules/rust/kb-worker/functions/search.md +0 -173
  127. package/docs/modules/rust/kb-worker/functions/write.md +0 -172
  128. package/docs/modules/rust/kb-worker/module.md +0 -171
  129. package/docs/modules/rust/kb-worker/types/cache.md +0 -90
  130. package/docs/modules/rust/kb-worker/types/context.md +0 -26
  131. package/docs/modules/rust/kb-worker/types/module.md +0 -16
  132. package/docs/modules/rust/kb-worker/types/status.md +0 -29
  133. package/docs/modules/rust/kb-worker/types/token.md +0 -50
  134. package/docs/modules/rust/overview.md +0 -531
  135. package/docs/modules/rust/query-parser/functions/extract.md +0 -56
  136. package/docs/modules/rust/query-parser/functions/module.md +0 -18
  137. package/docs/modules/rust/query-parser/functions/parse.md +0 -33
  138. package/docs/modules/rust/query-parser/functions/pipeline.md +0 -9
  139. package/docs/modules/rust/query-parser/functions/rank.md +0 -85
  140. package/docs/modules/rust/query-parser/module.md +0 -131
  141. package/docs/modules/rust/query-parser/types/cache.md +0 -39
  142. package/docs/modules/rust/query-parser/types/keyphrase.md +0 -71
  143. package/docs/modules/rust/query-parser/types/module.md +0 -18
  144. package/docs/modules/rust/query-parser/types/token.md +0 -46
  145. package/docs/modules/rust/shared/content-composer/functions.md +0 -114
  146. package/docs/modules/rust/shared/content-composer/module.md +0 -147
  147. package/docs/modules/rust/shared/content-composer/types.md +0 -93
  148. package/docs/modules/rust/shared/content-parser/functions.md +0 -72
  149. package/docs/modules/rust/shared/content-parser/module.md +0 -99
  150. package/docs/modules/rust/shared/content-parser/types.md +0 -71
  151. package/docs/modules/rust/shared/corpus/module.md +0 -24
  152. package/docs/modules/rust/shared/corpus/types.md +0 -141
  153. package/docs/modules/rust/shared/document/module.md +0 -25
  154. package/docs/modules/rust/shared/document/types.md +0 -154
  155. package/docs/modules/rust/shared/encode/module.md +0 -22
  156. package/docs/modules/rust/shared/encode/traits.md +0 -304
  157. package/docs/modules/rust/shared/error/module.md +0 -28
  158. package/docs/modules/rust/shared/error/types.md +0 -302
  159. package/docs/modules/rust/shared/kbid/module.md +0 -24
  160. package/docs/modules/rust/shared/kbid/types.md +0 -147
  161. package/docs/modules/rust/shared/memory/functions.md +0 -209
  162. package/docs/modules/rust/shared/memory/module.md +0 -24
  163. package/docs/modules/rust/shared/module.md +0 -196
  164. package/docs/modules/rust/shared/pipeline/functions.md +0 -141
  165. package/docs/modules/rust/shared/pipeline/module.md +0 -62
  166. package/docs/modules/rust/shared/pipeline/types.md +0 -43
  167. package/docs/modules/rust/shared/query/module.md +0 -27
  168. package/docs/modules/rust/shared/query/types.md +0 -236
  169. package/docs/modules/rust/shared/section/module.md +0 -25
  170. package/docs/modules/rust/shared/section/types.md +0 -294
  171. package/docs/modules/rust/shared/term/module.md +0 -25
  172. package/docs/modules/rust/shared/term/types.md +0 -139
  173. package/docs/modules/typescript/cli.md +0 -131
  174. package/docs/modules/typescript/kbdb-worker.md +0 -150
  175. package/docs/modules/typescript/overview.md +0 -400
  176. package/docs/modules/typescript/shared/auto-capture/module.md +0 -73
  177. package/docs/modules/typescript/shared/cli/constants.md +0 -23
  178. package/docs/modules/typescript/shared/cli/functions.md +0 -809
  179. package/docs/modules/typescript/shared/cli/module.md +0 -138
  180. package/docs/modules/typescript/shared/cli/typings.md +0 -197
  181. package/docs/modules/typescript/shared/embedding/functions.md +0 -200
  182. package/docs/modules/typescript/shared/embedding/module.md +0 -77
  183. package/docs/modules/typescript/shared/embedding/typings.md +0 -124
  184. package/docs/modules/typescript/shared/hash/functions.md +0 -20
  185. package/docs/modules/typescript/shared/hash/module.md +0 -21
  186. package/docs/modules/typescript/shared/log/constants.md +0 -82
  187. package/docs/modules/typescript/shared/log/functions.md +0 -131
  188. package/docs/modules/typescript/shared/log/module.md +0 -153
  189. package/docs/modules/typescript/shared/log/typings.md +0 -82
  190. package/docs/modules/typescript/shared/mcp/classes.md +0 -179
  191. package/docs/modules/typescript/shared/mcp/functions.md +0 -386
  192. package/docs/modules/typescript/shared/mcp/module.md +0 -160
  193. package/docs/modules/typescript/shared/mcp/typings.md +0 -529
  194. package/docs/modules/typescript/shared/module.md +0 -110
  195. package/docs/modules/typescript/shared/platform/functions.md +0 -42
  196. package/docs/modules/typescript/shared/platform/module.md +0 -25
  197. package/docs/modules/typescript/shared/runtime/functions.md +0 -26
  198. package/docs/modules/typescript/shared/runtime/module.md +0 -27
  199. package/docs/modules/typescript/shared/runtime/typings.md +0 -13
  200. package/docs/modules/typescript/shared/version/module.md +0 -27
  201. package/docs/modules/typescript/shared/wasm-codec/functions.md +0 -391
  202. package/docs/modules/typescript/shared/wasm-codec/module.md +0 -98
  203. package/docs/modules/typescript/shared/worker-client/classes.md +0 -264
  204. package/docs/modules/typescript/shared/worker-client/functions.md +0 -175
  205. package/docs/modules/typescript/shared/worker-client/module.md +0 -92
  206. package/docs/modules/typescript/shared/worker-client/typings.md +0 -511
  207. package/docs/modules/typescript/shared/worker-daemon/classes.md +0 -239
  208. package/docs/modules/typescript/shared/worker-daemon/constants.md +0 -37
  209. package/docs/modules/typescript/shared/worker-daemon/functions.md +0 -234
  210. package/docs/modules/typescript/shared/worker-daemon/module.md +0 -118
  211. package/docs/modules/typescript/shared/worker-daemon/typings.md +0 -132
  212. package/docs/overview.md +0 -191
  213. package/docs/release-notes/0.1.0.md +0 -189
  214. package/docs/release-notes/0.1.1.md +0 -46
  215. package/docs/release-notes/0.1.2.md +0 -38
  216. package/docs/release-notes/0.1.3.md +0 -42
  217. package/docs/release-notes/0.2.0.md +0 -147
  218. package/docs/release-notes/0.3.0.md +0 -89
  219. package/docs/release-notes/0.3.1.md +0 -121
  220. package/docs/release-notes/0.3.2.md +0 -64
  221. package/docs/release-notes/0.4.0.md +0 -80
  222. package/docs/release-notes/0.4.1.md +0 -149
  223. package/docs/release-notes/0.4.3.md +0 -60
  224. package/docs/release-notes/README.md +0 -13
package/LICENSING.md ADDED
@@ -0,0 +1,58 @@
1
+ # Licensing
2
+
3
+ `@dikolab/kbdb` is **dual-licensed**.
4
+
5
+ ## 1. Open source -- AGPL-3.0-only
6
+
7
+ The project is available for free under the
8
+ [GNU Affero General Public License v3.0](./LICENSE) (`AGPL-3.0-only`).
9
+
10
+ You may use, modify, and redistribute it under the terms of that license.
11
+ In short, the AGPL requires that:
12
+
13
+ - if you distribute the software (modified or not), you make the
14
+ corresponding source available under the AGPL, and
15
+ - **if you run a modified version to provide a service over a network**,
16
+ you must offer that service's users the complete source of your
17
+ modified version.
18
+
19
+ The network clause (section 13) is the important one: running kbdb -- or a
20
+ derivative of it -- as part of a hosted or SaaS product triggers the
21
+ source-disclosure obligation.
22
+
23
+ ## 2. Commercial license
24
+
25
+ If the AGPL's obligations don't work for you -- for example, you want to:
26
+
27
+ - embed kbdb in a **closed-source** product,
28
+ - offer it (or a derivative) as a **hosted / managed service** without
29
+ disclosing your source, or
30
+ - receive it under different warranty / support / indemnification terms,
31
+
32
+ you can purchase a **commercial license** that removes the AGPL copyleft
33
+ obligations.
34
+
35
+ **Contact:** Diko <diko316@gmail.com>
36
+ Please include your company, the intended use, and expected scale.
37
+
38
+ ---
39
+
40
+ ## Why dual licensing?
41
+
42
+ The AGPL keeps kbdb open and prevents competitors from taking the code,
43
+ running it as a closed service, and giving nothing back. The commercial
44
+ license is how the project funds continued development. Individuals,
45
+ open-source projects, and internal (non-service) use are fully served by
46
+ the free AGPL edition.
47
+
48
+ ## Contributions
49
+
50
+ By contributing, you agree to the terms in [CLA.md](./CLA.md), which lets
51
+ the maintainer offer the project under both the AGPL and commercial
52
+ licenses. This is required to keep dual licensing possible.
53
+
54
+ ## Note on older versions
55
+
56
+ Versions of `@dikolab/kbdb` published at or before `0.5.0` were released
57
+ under the ISC license and remain available under ISC. The dual-license
58
+ terms above apply from `0.6.0` onward.
package/README.md CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@dikolab/kbdb)](https://www.npmjs.com/package/@dikolab/kbdb)
4
4
  [![JSR](https://jsr.io/badges/@dikolab/kbdb)](https://jsr.io/@dikolab/kbdb)
5
- [![License: ISC](https://img.shields.io/badge/license-ISC-blue.svg)](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/LICENSE)
5
+ [![License: AGPL-3.0](https://img.shields.io/badge/license-AGPL--3.0-blue.svg)](https://gitlab.com/diko316/knowledge-base-db/-/blob/main/LICENSE)
6
6
 
7
7
  A file-based knowledge base database -- no external
8
8
  server to install.
9
9
 
10
- [GitLab](https://gitlab.com/tech-slaves/knowledge-base-db)
10
+ [GitLab](https://gitlab.com/diko316/knowledge-base-db)
11
11
  | [NPM](https://www.npmjs.com/package/@dikolab/kbdb)
12
12
  | [JSR](https://jsr.io/@dikolab/kbdb)
13
- | [License: ISC](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/LICENSE)
13
+ | [License: AGPL-3.0](https://gitlab.com/diko316/knowledge-base-db/-/blob/main/LICENSE)
14
14
 
15
15
  > **Status:** Beta -- actively developed. Core
16
16
  > features (search, recall, MCP) are stable and
@@ -103,8 +103,12 @@ kbdb learn ./docs --db ./my-kb
103
103
  Point it at a folder of Markdown files. kbdb reads
104
104
  them, breaks them into sections, and builds a
105
105
  search index. Add `--tags design,v2` to tag
106
- sections for scoping, or `--replace` to update
107
- existing sections from the same source.
106
+ sections for scoping, `--replace` to update
107
+ existing sections from the same source, or
108
+ `--level 2` to set the hierarchical depth
109
+ (1 = broadest, 6 = narrowest). When learning a
110
+ directory, level is auto-detected from folder
111
+ depth.
108
112
 
109
113
  **3. Search**
110
114
 
@@ -113,8 +117,11 @@ kbdb search "how does auth work" --db ./my-kb
113
117
  ```
114
118
 
115
119
  Results are ranked by relevance with snippets
116
- showing where your terms matched. Use `--offset`
117
- to page through large result sets.
120
+ showing where your terms matched. Output defaults
121
+ to **recfile** format (one `field: value` per
122
+ line) for easy grepping. Use `--format json` for
123
+ machine-readable JSON, or `--offset` to page
124
+ through large result sets.
118
125
 
119
126
  To try hybrid search (keyword + AI similarity):
120
127
 
@@ -128,11 +135,11 @@ kbdb search "how does auth work" --algo hybrid \
128
135
  > omit it. You can also set `KBDB_DB_DIR` as an
129
136
  > environment variable.
130
137
 
131
- > **Scripting:** Use `--non-interactive` or set
138
+ > **Scripting:** Add `--format json` to get
139
+ > structured JSON output for parsing. Use
140
+ > `--non-interactive` or set
132
141
  > `KBDB_NON_INTERACTIVE=1` to suppress prompts in
133
- > scripts and CI pipelines. Commands that need a
134
- > database will return an error instead of waiting
135
- > for user input.
142
+ > CI pipelines.
136
143
 
137
144
  **4. Recall context**
138
145
 
@@ -170,7 +177,7 @@ Build, search, and maintain your knowledge store.
170
177
  - **Rebuild** indexes if anything goes wrong
171
178
 
172
179
  See the
173
- [Knowledge Base Guide](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/details/knowledge-base.md)
180
+ [Knowledge Base Guide](https://diko316.gitlab.io/knowledge-base-db/details/knowledge-base)
174
181
  for the full walkthrough, including export and backup.
175
182
 
176
183
  ---
@@ -192,9 +199,14 @@ Integrate kbdb with AI agents and custom tools.
192
199
  timeout and automatic retry with daemon respawn
193
200
  - **Worker daemon** lifecycle management --
194
201
  stop and restart the background process
202
+ - **Granular Deno permissions** -- the daemon
203
+ runs with scoped permissions instead of
204
+ `--allow-all`
205
+ - **Path confinement** -- the daemon rejects
206
+ path traversal (`..`) in export/import
195
207
 
196
208
  See the
197
- [Agent Tooling Guide](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/details/agent-tooling.md)
209
+ [Agent Tooling Guide](https://diko316.gitlab.io/knowledge-base-db/details/agent-tooling)
198
210
  for MCP setup, skills, agents, and the library API.
199
211
 
200
212
  ---
@@ -230,13 +242,13 @@ or `dbPath` (the parent directory -- kbdb discovers
230
242
  `.kbdb` inside it).
231
243
 
232
244
  See the
233
- [Library API Reference](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/details/library-api.md)
245
+ [Library API Reference](https://diko316.gitlab.io/knowledge-base-db/details/library-api)
234
246
  for the full API.
235
247
 
236
248
  ### Development Setup
237
249
 
238
250
  ```sh
239
- git clone https://gitlab.com/tech-slaves/knowledge-base-db.git
251
+ git clone https://gitlab.com/diko316/knowledge-base-db.git
240
252
  cd knowledge-base-db
241
253
  npm install
242
254
  npm test
@@ -253,10 +265,10 @@ HOST_UMASK=$(umask) docker compose run --rm dev bash
253
265
 
254
266
  Run `make benchmark` to measure search and rebuild
255
267
  latency at scale -- results are written to
256
- [docs/benchmark/benchmark.md](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/benchmark/benchmark.md)
268
+ [docs/benchmark/benchmark.md](https://diko316.gitlab.io/knowledge-base-db/benchmark/benchmark)
257
269
  automatically.
258
270
 
259
- See the [Makefile](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/Makefile) for all available
271
+ See the [Makefile](https://gitlab.com/diko316/knowledge-base-db/-/blob/main/Makefile) for all available
260
272
  build targets.
261
273
 
262
274
  ### Contributing
@@ -271,27 +283,38 @@ build targets.
271
283
 
272
284
  ## Documentation
273
285
 
274
- - [Knowledge Base Guide](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/details/knowledge-base.md)
286
+ - [Knowledge Base Guide](https://diko316.gitlab.io/knowledge-base-db/details/knowledge-base)
275
287
  -- importing, searching, recall, export
276
- - [Agent Tooling Guide](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/details/agent-tooling.md)
288
+ - [Agent Tooling Guide](https://diko316.gitlab.io/knowledge-base-db/details/agent-tooling)
277
289
  -- MCP, skills, agents, library API
278
- - [CLI Reference](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/details/cli.md) -- full command
290
+ - [CLI Reference](https://diko316.gitlab.io/knowledge-base-db/details/cli) -- full command
279
291
  list with examples
280
- - [MCP Server Guide](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/details/mcp-server.md) --
292
+ - [MCP Server Guide](https://diko316.gitlab.io/knowledge-base-db/details/mcp-server) --
281
293
  setup, tools, environment config
282
- - [Search and Ranking](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/details/search-and-ranking.md)
294
+ - [Search and Ranking](https://diko316.gitlab.io/knowledge-base-db/details/search-and-ranking)
283
295
  -- how search works under the hood
284
- - [Storage Architecture](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/details/storage.md) --
296
+ - [Storage Architecture](https://diko316.gitlab.io/knowledge-base-db/details/storage) --
285
297
  file formats and directory layout
286
- - [Benchmark Results](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/benchmark/benchmark.md)
298
+ - [Benchmark Results](https://diko316.gitlab.io/knowledge-base-db/benchmark/benchmark)
287
299
  -- search and rebuild latency at scale
288
- - [Release Notes](https://gitlab.com/tech-slaves/knowledge-base-db/-/tree/main/docs/release-notes)
289
- - [Architecture Overview](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/overview.md)
300
+ - [Release Notes](https://diko316.gitlab.io/knowledge-base-db/release-notes/)
301
+ - [Architecture Overview](https://diko316.gitlab.io/knowledge-base-db/overview)
290
302
 
291
303
  ---
292
304
 
293
305
  ## License
294
306
 
295
- ISC License -- see [LICENSE](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/LICENSE) for details.
307
+ This project is dual-licensed:
308
+
309
+ - **Open source** under the
310
+ [GNU Affero General Public License v3.0](https://gitlab.com/diko316/knowledge-base-db/-/blob/main/LICENSE)
311
+ (`AGPL-3.0-only`)
312
+ - **Commercial license** available for closed-source
313
+ or SaaS use
314
+
315
+ Versions `<= 0.5.0` remain under the ISC license.
316
+
317
+ See [LICENSING.md](./LICENSING.md) for details and
318
+ contact information.
296
319
 
297
320
  ---
package/README.md.bak ADDED
@@ -0,0 +1,320 @@
1
+ # @dikolab/kbdb
2
+
3
+ [![npm](https://img.shields.io/npm/v/@dikolab/kbdb)](https://www.npmjs.com/package/@dikolab/kbdb)
4
+ [![JSR](https://jsr.io/badges/@dikolab/kbdb)](https://jsr.io/@dikolab/kbdb)
5
+ [![License: AGPL-3.0](https://img.shields.io/badge/license-AGPL--3.0-blue.svg)](./LICENSE)
6
+
7
+ A file-based knowledge base database -- no external
8
+ server to install.
9
+
10
+ [GitLab](https://gitlab.com/diko316/knowledge-base-db)
11
+ | [NPM](https://www.npmjs.com/package/@dikolab/kbdb)
12
+ | [JSR](https://jsr.io/@dikolab/kbdb)
13
+ | [License: AGPL-3.0](./LICENSE)
14
+
15
+ > **Status:** Beta -- actively developed. Core
16
+ > features (search, recall, MCP) are stable and
17
+ > tested.
18
+
19
+ ---
20
+
21
+ ## What is kbdb?
22
+
23
+ **kbdb** stores your docs in a plain folder on
24
+ disk and makes them searchable. No external server
25
+ to install. No cloud account. Import your Markdown
26
+ files, and kbdb indexes them automatically.
27
+ Search returns ranked results instantly.
28
+
29
+ It runs anywhere Node.js or Deno runs, and also
30
+ works as an [MCP](https://modelcontextprotocol.io/)
31
+ server -- giving AI agents like Claude a searchable
32
+ second brain that persists between sessions.
33
+
34
+ **How search works:** kbdb uses **keyword search** by
35
+ default -- synonyms are expanded, terms are ranked
36
+ by relevance, and headings carry 2× weight in
37
+ scoring. When an exact query finds nothing, kbdb
38
+ automatically loosens the match so you still get the
39
+ best available results.
40
+
41
+ Want smarter results? Use `--algo hybrid` to blend
42
+ keyword matching with similarity search -- finding
43
+ results even when different words describe the same
44
+ concept. The default **TF-IDF** embedding provider
45
+ works offline with zero setup. Swap it for a
46
+ third-party provider (local ONNX model or remote
47
+ API) in `worker.toml` when you need richer
48
+ embeddings.
49
+
50
+ **Knowledge stays fresh:** Re-learn a file and kbdb
51
+ replaces the old version automatically.
52
+ Near-duplicate detection warns you before content
53
+ drifts. Integrity checks catch contradictions.
54
+ Confidence scores help agents tell strong matches
55
+ from weak ones.
56
+
57
+ ---
58
+
59
+ ## Getting Started
60
+
61
+ ### What You Need
62
+
63
+ One of these (pick whichever you already have):
64
+
65
+ - **Node.js** version 20 or newer --
66
+ [Download](https://nodejs.org/)
67
+ - **Deno** version 2 or newer --
68
+ [Download](https://deno.com/)
69
+
70
+ That's it. No database server. No extra tools.
71
+
72
+ ### Install
73
+
74
+ **Using Node.js:**
75
+
76
+ ```sh
77
+ npm install -g @dikolab/kbdb
78
+ ```
79
+
80
+ **Using Deno:**
81
+
82
+ ```sh
83
+ deno install -Agf jsr:@dikolab/kbdb/cli
84
+ ```
85
+
86
+ ### Try It Out
87
+
88
+ **1. Create a knowledge base**
89
+
90
+ ```sh
91
+ kbdb db init --db ./my-kb
92
+ ```
93
+
94
+ This creates a `.kbdb` folder that holds all your
95
+ data.
96
+
97
+ **2. Feed it your docs**
98
+
99
+ ```sh
100
+ kbdb learn ./docs --db ./my-kb
101
+ ```
102
+
103
+ Point it at a folder of Markdown files. kbdb reads
104
+ them, breaks them into sections, and builds a
105
+ search index. Add `--tags design,v2` to tag
106
+ sections for scoping, `--replace` to update
107
+ existing sections from the same source, or
108
+ `--level 2` to set the hierarchical depth
109
+ (1 = broadest, 6 = narrowest). When learning a
110
+ directory, level is auto-detected from folder
111
+ depth.
112
+
113
+ **3. Search**
114
+
115
+ ```sh
116
+ kbdb search "how does auth work" --db ./my-kb
117
+ ```
118
+
119
+ Results are ranked by relevance with snippets
120
+ showing where your terms matched. Output defaults
121
+ to **recfile** format (one `field: value` per
122
+ line) for easy grepping. Use `--format json` for
123
+ machine-readable JSON, or `--offset` to page
124
+ through large result sets.
125
+
126
+ To try hybrid search (keyword + AI similarity):
127
+
128
+ ```sh
129
+ kbdb search "how does auth work" --algo hybrid \
130
+ --db ./my-kb
131
+ ```
132
+
133
+ > **Tip:** `--db` is optional. If you're already
134
+ > inside a directory with a `.kbdb` folder, just
135
+ > omit it. You can also set `KBDB_DB_DIR` as an
136
+ > environment variable.
137
+
138
+ > **Scripting:** Add `--format json` to get
139
+ > structured JSON output for parsing. Use
140
+ > `--non-interactive` or set
141
+ > `KBDB_NON_INTERACTIVE=1` to suppress prompts in
142
+ > CI pipelines.
143
+
144
+ **4. Recall context**
145
+
146
+ ```sh
147
+ kbdb recall <kbid> --depth 1 --db ./my-kb
148
+ ```
149
+
150
+ Start with a search result's kbid and expand
151
+ context progressively: depth 0 gives the section
152
+ content, depth 1 adds parent documents and
153
+ back-references, depth 2 adds siblings and forward
154
+ references, depth 3 includes full text of
155
+ referenced sections.
156
+
157
+ ---
158
+
159
+ ## Knowledge Base
160
+
161
+ Build, search, and maintain your knowledge store.
162
+
163
+ - **Import** Markdown and plain text files with
164
+ tags and source tracking
165
+ - **Smart updates** -- re-learning a file replaces
166
+ the old version instead of duplicating it
167
+ - **Search** with three algorithms: keyword
168
+ (default), AI similarity, or hybrid (both)
169
+ - **Auto-fallback** -- if your exact query finds
170
+ nothing, kbdb loosens the match automatically
171
+ - **Recall** sections with progressive context --
172
+ from a quick summary to full related content
173
+ - **Export** -- snapshot your knowledge base for
174
+ backup
175
+ - **Verify** database integrity and clean up
176
+ stale data
177
+ - **Rebuild** indexes if anything goes wrong
178
+
179
+ See the
180
+ [Knowledge Base Guide](./docs/details/knowledge-base.md)
181
+ for the full walkthrough, including export and backup.
182
+
183
+ ---
184
+
185
+ ## Agent Tooling
186
+
187
+ Integrate kbdb with AI agents and custom tools.
188
+
189
+ - **MCP server** with 20 tools -- search, recall,
190
+ learn, export, and more
191
+ - **Skills** -- store reusable prompt templates
192
+ with fill-in-the-blank arguments
193
+ - **Agents** -- create AI agent profiles that
194
+ combine a persona with skills
195
+ - **Auto-capture** -- the MCP server can
196
+ proactively suggest knowledge to store from
197
+ your conversations
198
+ - **Daemon resilience** -- configurable request
199
+ timeout and automatic retry with daemon respawn
200
+ - **Worker daemon** lifecycle management --
201
+ stop and restart the background process
202
+ - **Granular Deno permissions** -- the daemon
203
+ runs with scoped permissions instead of
204
+ `--allow-all`
205
+ - **Path confinement** -- the daemon rejects
206
+ path traversal (`..`) in export/import
207
+
208
+ See the
209
+ [Agent Tooling Guide](./docs/details/agent-tooling.md)
210
+ for MCP setup, skills, agents, and the library API.
211
+
212
+ ---
213
+
214
+ ## For Developers
215
+
216
+ ### Library API
217
+
218
+ Use kbdb programmatically in your Node.js or Deno
219
+ project:
220
+
221
+ ```typescript
222
+ import { createWorkerClient } from '@dikolab/kbdb';
223
+
224
+ // Spawns a background worker if not already running
225
+ const client = await createWorkerClient({
226
+ contextPath: '/path/to/.kbdb',
227
+ requestTimeoutMs: 30_000,
228
+ });
229
+
230
+ const results = await client.search({
231
+ query: 'authentication',
232
+ limit: 10,
233
+ offset: 0,
234
+ });
235
+
236
+ console.log(results.items);
237
+ client.disconnect();
238
+ ```
239
+
240
+ Pass `contextPath` (the `.kbdb` directory itself)
241
+ or `dbPath` (the parent directory -- kbdb discovers
242
+ `.kbdb` inside it).
243
+
244
+ See the
245
+ [Library API Reference](./docs/details/library-api.md)
246
+ for the full API.
247
+
248
+ ### Development Setup
249
+
250
+ ```sh
251
+ git clone https://gitlab.com/diko316/knowledge-base-db.git
252
+ cd knowledge-base-db
253
+ npm install
254
+ npm test
255
+ ```
256
+
257
+ ### Docker
258
+
259
+ A Docker setup is included with all build tools
260
+ (Node.js, Deno, Rust, wasm-pack):
261
+
262
+ ```sh
263
+ HOST_UMASK=$(umask) docker compose run --rm dev bash
264
+ ```
265
+
266
+ Run `make benchmark` to measure search and rebuild
267
+ latency at scale -- results are written to
268
+ [docs/benchmark/benchmark.md](./docs/benchmark/benchmark.md)
269
+ automatically.
270
+
271
+ See the [Makefile](./Makefile) for all available
272
+ build targets.
273
+
274
+ ### Contributing
275
+
276
+ 1. Fork the repository
277
+ 2. Create a feature branch
278
+ 3. Make your changes and add tests
279
+ 4. Run `npm test` and `npm run lint`
280
+ 5. Open a merge request
281
+
282
+ ---
283
+
284
+ ## Documentation
285
+
286
+ - [Knowledge Base Guide](./docs/details/knowledge-base.md)
287
+ -- importing, searching, recall, export
288
+ - [Agent Tooling Guide](./docs/details/agent-tooling.md)
289
+ -- MCP, skills, agents, library API
290
+ - [CLI Reference](./docs/details/cli.md) -- full command
291
+ list with examples
292
+ - [MCP Server Guide](./docs/details/mcp-server.md) --
293
+ setup, tools, environment config
294
+ - [Search and Ranking](./docs/details/search-and-ranking.md)
295
+ -- how search works under the hood
296
+ - [Storage Architecture](./docs/details/storage.md) --
297
+ file formats and directory layout
298
+ - [Benchmark Results](./docs/benchmark/benchmark.md)
299
+ -- search and rebuild latency at scale
300
+ - [Release Notes](./docs/release-notes)
301
+ - [Architecture Overview](./docs/overview.md)
302
+
303
+ ---
304
+
305
+ ## License
306
+
307
+ This project is dual-licensed:
308
+
309
+ - **Open source** under the
310
+ [GNU Affero General Public License v3.0](./LICENSE)
311
+ (`AGPL-3.0-only`)
312
+ - **Commercial license** available for closed-source
313
+ or SaaS use
314
+
315
+ Versions `<= 0.5.0` remain under the ISC license.
316
+
317
+ See [LICENSING.md](./LICENSING.md) for details and
318
+ contact information.
319
+
320
+ ---