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