@dikolab/kbdb 0.2.2 → 0.3.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 +50 -15
- package/dist/cli.cjs +461 -72
- package/dist/cli.cjs.map +4 -4
- package/dist/cli.mjs +453 -64
- package/dist/cli.mjs.map +4 -4
- package/dist/kbdb-worker.cjs +395 -60
- package/dist/kbdb-worker.cjs.map +4 -4
- package/dist/mod.cjs +17 -0
- package/dist/mod.cjs.map +2 -2
- package/dist/mod.mjs +17 -0
- package/dist/mod.mjs.map +2 -2
- package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +3 -1
- package/dist/src/shared/cli/functions/install-default-skills.function.d.ts +12 -0
- package/dist/src/shared/cli/functions/run-check.function.d.ts +47 -5
- package/dist/src/shared/cli/functions/run-export.function.d.ts +34 -0
- package/dist/src/shared/cli/functions/run-gc.function.d.ts +6 -0
- package/dist/src/shared/cli/functions/run-learn.function.d.ts +35 -6
- package/dist/src/shared/cli/functions/run-recall.function.d.ts +45 -0
- package/dist/src/shared/cli/functions/run-search.function.d.ts +52 -15
- package/dist/src/shared/cli/index.d.ts +4 -0
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +13 -0
- package/dist/src/shared/cli/typings/learn-result.model.d.ts +19 -0
- package/dist/src/shared/cli/typings/search-display.model.d.ts +18 -0
- package/dist/src/shared/mcp/classes/mcp-server.class.d.ts +8 -0
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +43 -0
- package/dist/src/shared/wasm-codec/functions/decode-add-section-result.function.d.ts +48 -0
- package/dist/src/shared/wasm-codec/functions/decode-scored-results.function.d.ts +58 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +33 -0
- package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +52 -0
- package/dist/src/shared/wasm-codec/index.d.ts +2 -0
- package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +16 -0
- package/dist/src/shared/worker-client/index.d.ts +1 -1
- package/dist/src/shared/worker-client/typings/add-section-result.model.d.ts +29 -15
- package/dist/src/shared/worker-client/typings/export-result.model.d.ts +14 -0
- package/dist/src/shared/worker-client/typings/gc-result.model.d.ts +6 -0
- package/dist/src/shared/worker-client/typings/search-result.model.d.ts +12 -0
- package/dist/src/shared/worker-client/typings/section.model.d.ts +16 -0
- package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +35 -0
- package/dist/wasm/fs-database/kbdb_fs_database.d.ts +22 -1
- package/dist/wasm/fs-database/kbdb_fs_database.js +28 -1
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +1 -0
- package/dist/wasm/kb-worker/kbdb_worker.d.ts +48 -1
- package/dist/wasm/kb-worker/kbdb_worker.js +60 -1
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +2 -0
- package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
- package/dist/worker.mjs +396 -60
- package/dist/worker.mjs.map +4 -4
- package/docs/details/cli.md +102 -15
- package/docs/details/library-api.md +55 -6
- package/docs/details/mcp-server.md +8 -4
- package/docs/details/search-and-ranking.md +63 -5
- package/docs/details/storage.md +2 -0
- package/docs/goals/cli.md +255 -14
- package/docs/goals/database.md +244 -17
- package/docs/goals/document.md +1 -1
- package/docs/goals/mcp.md +83 -14
- package/docs/goals/query-parser.md +98 -4
- package/docs/goals/query-result.md +177 -10
- package/docs/goals/skills.md +72 -0
- package/docs/goals/worker-daemon.md +54 -7
- package/docs/modules/rust/fs-database/functions/integrity.md +11 -0
- package/docs/modules/rust/fs-database/functions/section.md +23 -6
- package/docs/modules/rust/fs-database/module.md +1 -0
- package/docs/modules/rust/fs-database/types/section.md +27 -1
- package/docs/modules/rust/overview.md +2 -1
- package/docs/modules/rust/query-parser/functions/module.md +2 -2
- package/docs/modules/rust/query-parser/functions/pipeline.md +44 -6
- package/docs/modules/rust/query-parser/module.md +5 -4
- package/docs/modules/rust/query-parser/types/keyphrase.md +11 -0
- package/docs/modules/rust/query-parser/types/module.md +3 -3
- package/docs/modules/typescript/shared/cli/functions.md +68 -3
- package/package.json +1 -1
- package/src/shared/cli/functions/dispatch-command.function.ts +53 -1
- package/src/shared/cli/functions/format-output.function.ts +36 -12
- package/src/shared/cli/functions/generate-help.function.ts +56 -1
- package/src/shared/cli/functions/install-default-skills.function.ts +296 -0
- package/src/shared/cli/functions/parse-args.function.ts +13 -0
- package/src/shared/cli/functions/run-check.function.ts +87 -6
- package/src/shared/cli/functions/run-export.function.ts +40 -0
- package/src/shared/cli/functions/run-gc.function.ts +6 -0
- package/src/shared/cli/functions/run-init.function.ts +2 -0
- package/src/shared/cli/functions/run-learn.function.ts +68 -16
- package/src/shared/cli/functions/run-recall.function.ts +66 -0
- package/src/shared/cli/functions/run-search.function.ts +58 -15
- package/src/shared/cli/index.ts +4 -0
- package/src/shared/cli/typings/cli-options.interface.ts +13 -0
- package/src/shared/cli/typings/learn-result.model.ts +16 -0
- package/src/shared/cli/typings/search-display.model.ts +18 -0
- package/src/shared/mcp/classes/mcp-server.class.ts +30 -1
- package/src/shared/mcp/functions/create-tool-definitions.function.ts +46 -5
- package/src/shared/mcp/functions/handle-tool-call.function.ts +70 -2
- package/src/shared/mcp/typings/mcp-client.interface.ts +45 -0
- package/src/shared/wasm-codec/functions/decode-add-section-result.function.ts +112 -0
- package/src/shared/wasm-codec/functions/decode-scored-results.function.ts +86 -0
- package/src/shared/wasm-codec/functions/decode-section-records.function.ts +87 -0
- package/src/shared/wasm-codec/functions/encode-add-section-params.function.ts +68 -0
- package/src/shared/wasm-codec/index.ts +5 -0
- package/src/shared/worker-client/classes/worker-client.class.ts +19 -0
- package/src/shared/worker-client/index.ts +4 -1
- package/src/shared/worker-client/typings/add-section-result.model.ts +30 -15
- package/src/shared/worker-client/typings/export-result.model.ts +14 -0
- package/src/shared/worker-client/typings/gc-result.model.ts +6 -0
- package/src/shared/worker-client/typings/search-result.model.ts +12 -0
- package/src/shared/worker-client/typings/section.model.ts +16 -0
- package/src/shared/worker-daemon/classes/worker-daemon.class.ts +315 -46
- package/src/shared/worker-daemon/functions/create-host-imports.function.ts +19 -4
- package/src/shared/worker-daemon/functions/create-ipc-server.function.ts +5 -1
- package/src/wasm/fs-database/kbdb_fs_database.d.ts +22 -1
- package/src/wasm/fs-database/kbdb_fs_database.js +28 -1
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +1 -0
- package/src/wasm/kb-worker/kbdb_worker.d.ts +48 -1
- package/src/wasm/kb-worker/kbdb_worker.js +60 -1
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +2 -0
- package/src/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -26,11 +26,36 @@ It runs anywhere Node.js or Deno runs. Import your
|
|
|
26
26
|
Markdown files, and kbdb indexes them automatically.
|
|
27
27
|
Search returns ranked results instantly.
|
|
28
28
|
|
|
29
|
+
kbdb uses **lexical search** (keyword matching with
|
|
30
|
+
stemming and synonym expansion), not semantic
|
|
31
|
+
embeddings. This is a deliberate tradeoff: fast,
|
|
32
|
+
offline, deterministic, and zero embedding cost.
|
|
33
|
+
When AI agents are the primary consumers, lexical
|
|
34
|
+
search works well -- agents can issue multiple
|
|
35
|
+
keyword queries, use boolean/phrase syntax, and
|
|
36
|
+
expand vocabulary themselves. When an exact-match
|
|
37
|
+
query returns nothing, kbdb automatically retries
|
|
38
|
+
with relaxed OR matching so you always get the
|
|
39
|
+
best available results. Write clear headings
|
|
40
|
+
(they carry 2x ranking weight) and use specific
|
|
41
|
+
terms for best recall.
|
|
42
|
+
|
|
43
|
+
kbdb tracks **knowledge freshness** automatically.
|
|
44
|
+
Re-learn a file and supersession replaces the old
|
|
45
|
+
version instead of duplicating it. Near-duplicate
|
|
46
|
+
detection warns you before content drifts.
|
|
47
|
+
Integrity checks catch contradictions between
|
|
48
|
+
versions of the same source. Confidence scores
|
|
49
|
+
let agents tell strong matches from weak tail
|
|
50
|
+
results.
|
|
51
|
+
|
|
29
52
|
As a bonus, kbdb also works as an MCP server --
|
|
30
53
|
giving AI agents like Claude a searchable second
|
|
31
54
|
brain. Store skills, agent profiles, and
|
|
32
55
|
documentation that your AI can query across
|
|
33
|
-
sessions.
|
|
56
|
+
sessions. Default skills (`query-guidance` and
|
|
57
|
+
`memory-protocol`) teach agents how to search
|
|
58
|
+
effectively and what to store.
|
|
34
59
|
|
|
35
60
|
---
|
|
36
61
|
|
|
@@ -80,7 +105,9 @@ kbdb learn ./docs --db ./my-kb
|
|
|
80
105
|
|
|
81
106
|
Point it at a folder of Markdown files. kbdb reads
|
|
82
107
|
them, breaks them into sections, and builds a
|
|
83
|
-
search index.
|
|
108
|
+
search index. Add `--tags design,v2` to tag
|
|
109
|
+
sections for scoping, or `--replace` to supersede
|
|
110
|
+
existing sections from the same source.
|
|
84
111
|
|
|
85
112
|
**3. Search**
|
|
86
113
|
|
|
@@ -88,9 +115,11 @@ search index.
|
|
|
88
115
|
kbdb search "how does auth work" --db ./my-kb
|
|
89
116
|
```
|
|
90
117
|
|
|
91
|
-
Results are ranked by relevance with
|
|
92
|
-
showing matched terms in
|
|
93
|
-
|
|
118
|
+
Results are ranked by relevance with confidence
|
|
119
|
+
scores and snippets showing matched terms in
|
|
120
|
+
context. Each result includes `matched_fields`
|
|
121
|
+
(heading, body, code) and `created_at` timestamps.
|
|
122
|
+
Use `--offset` to page through large result sets.
|
|
94
123
|
|
|
95
124
|
**4. Recall context**
|
|
96
125
|
|
|
@@ -109,18 +138,24 @@ referenced sections.
|
|
|
109
138
|
|
|
110
139
|
## What Can It Do?
|
|
111
140
|
|
|
112
|
-
- **Import** Markdown files and other documents
|
|
113
|
-
|
|
114
|
-
|
|
141
|
+
- **Import** Markdown files and other documents,
|
|
142
|
+
with tags and source tracking
|
|
143
|
+
- **Supersede** outdated sections automatically
|
|
144
|
+
when re-learning from the same source
|
|
145
|
+
- **Search** with ranked results, confidence
|
|
146
|
+
scores, snippets, and paginated output
|
|
147
|
+
- **Relaxed fallback** -- automatic OR retry when
|
|
148
|
+
exact AND queries return nothing
|
|
115
149
|
- **Recall** sections with progressive context --
|
|
116
150
|
from a quick summary to full related content
|
|
151
|
+
- **Export** the database as a portable snapshot
|
|
117
152
|
- **Skills** -- store reusable prompt templates
|
|
118
153
|
with placeholder arguments
|
|
119
154
|
- **Agents** -- create AI agent profiles that
|
|
120
155
|
combine a persona with skills
|
|
121
156
|
- **Manage** documents, sections, and metadata
|
|
122
|
-
- **Verify** database integrity
|
|
123
|
-
|
|
157
|
+
- **Verify** database integrity, detect
|
|
158
|
+
contradictions, and clean up superseded data
|
|
124
159
|
- **Rebuild** indexes if anything goes wrong
|
|
125
160
|
|
|
126
161
|
See the [CLI Reference](https://gitlab.com/tech-slaves/knowledge-base-db/-/blob/main/docs/details/cli.md)
|
|
@@ -132,10 +167,10 @@ for the full command list and examples.
|
|
|
132
167
|
|
|
133
168
|
kbdb runs as an
|
|
134
169
|
[MCP](https://modelcontextprotocol.io/) server
|
|
135
|
-
with
|
|
136
|
-
recall context progressively,
|
|
137
|
-
skills, and build agent profiles --
|
|
138
|
-
that persists between sessions.
|
|
170
|
+
with 19 tools, so AI agents can search your docs,
|
|
171
|
+
recall context progressively, export snapshots,
|
|
172
|
+
store reusable skills, and build agent profiles --
|
|
173
|
+
a second brain that persists between sessions.
|
|
139
174
|
|
|
140
175
|
### Claude Code (CLI)
|
|
141
176
|
|
|
@@ -230,7 +265,7 @@ const results = await client.search({
|
|
|
230
265
|
offset: 0,
|
|
231
266
|
});
|
|
232
267
|
|
|
233
|
-
// results = { items, total, offset, limit, has_more }
|
|
268
|
+
// results = { items, total, offset, limit, has_more, relaxed }
|
|
234
269
|
console.log(results.items);
|
|
235
270
|
client.disconnect();
|
|
236
271
|
```
|