@dikolab/kbdb 0.1.5 → 0.2.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 +30 -9
- package/dist/cli.cjs +181 -50
- package/dist/cli.cjs.map +3 -3
- package/dist/cli.mjs +181 -50
- package/dist/cli.mjs.map +3 -3
- package/dist/kbdb-worker.cjs +283 -29
- package/dist/kbdb-worker.cjs.map +4 -4
- package/dist/mod.cjs +13 -2
- package/dist/mod.cjs.map +2 -2
- package/dist/mod.mjs +13 -2
- package/dist/mod.mjs.map +2 -2
- package/dist/src/shared/cli/functions/format-output.function.d.ts +7 -7
- package/dist/src/shared/cli/functions/run-search.function.d.ts +25 -16
- package/dist/src/shared/cli/index.d.ts +1 -1
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +2 -0
- package/dist/src/shared/cli/typings/search-display.model.d.ts +25 -7
- package/dist/src/shared/mcp/functions/handle-recall.function.d.ts +29 -0
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +30 -11
- package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
- package/dist/src/shared/wasm-codec/functions/decode-recall-result.function.d.ts +28 -0
- package/dist/src/shared/wasm-codec/functions/decode-scored-results.function.d.ts +14 -7
- package/dist/src/shared/wasm-codec/functions/encode-recall-params.function.d.ts +21 -0
- package/dist/src/shared/wasm-codec/functions/encode-search-params.function.d.ts +1 -1
- package/dist/src/shared/wasm-codec/index.d.ts +5 -2
- package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +13 -3
- package/dist/src/shared/worker-client/index.d.ts +2 -1
- package/dist/src/shared/worker-client/typings/recall-result.model.d.ts +94 -0
- package/dist/src/shared/worker-client/typings/search-params.model.d.ts +2 -0
- package/dist/src/shared/worker-client/typings/search-result.model.d.ts +23 -7
- package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +1 -0
- package/dist/wasm/fs-database/kbdb_fs_database.d.ts +18 -0
- package/dist/wasm/fs-database/kbdb_fs_database.js +30 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +2 -0
- package/dist/wasm/kb-worker/kbdb_worker.d.ts +38 -0
- package/dist/wasm/kb-worker/kbdb_worker.js +56 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +3 -0
- package/dist/worker.mjs +283 -29
- package/dist/worker.mjs.map +4 -4
- package/docs/details/README.md +26 -0
- package/docs/details/cli.md +608 -0
- package/docs/details/library-api.md +406 -0
- package/docs/details/mcp-server.md +430 -0
- package/docs/details/search-and-ranking.md +457 -0
- package/docs/details/storage.md +529 -0
- package/docs/goals/agents.md +751 -0
- package/docs/goals/architecture.svg +198 -0
- package/docs/goals/cli.md +2308 -0
- package/docs/goals/content-composer.md +609 -0
- package/docs/goals/content-parser.md +279 -0
- package/docs/goals/database.md +1452 -0
- package/docs/goals/document.md +368 -0
- package/docs/goals/mcp.md +1467 -0
- package/docs/goals/overview.md +124 -0
- package/docs/goals/query-parser.md +271 -0
- package/docs/goals/query-result.md +693 -0
- package/docs/goals/skills.md +738 -0
- package/docs/goals/worker-client.md +944 -0
- package/docs/goals/worker-daemon.md +1447 -0
- package/docs/modules/overview.md +298 -0
- package/docs/modules/rust/fs-database/functions/document.md +48 -0
- package/docs/modules/rust/fs-database/functions/integrity.md +68 -0
- package/docs/modules/rust/fs-database/functions/io.md +87 -0
- package/docs/modules/rust/fs-database/functions/module.md +22 -0
- package/docs/modules/rust/fs-database/functions/query-exec.md +44 -0
- package/docs/modules/rust/fs-database/functions/section.md +59 -0
- package/docs/modules/rust/fs-database/indexes/btree.md +35 -0
- package/docs/modules/rust/fs-database/indexes/corpus.md +61 -0
- package/docs/modules/rust/fs-database/indexes/inverted.md +60 -0
- package/docs/modules/rust/fs-database/indexes/module.md +64 -0
- package/docs/modules/rust/fs-database/indexes/positional.md +39 -0
- package/docs/modules/rust/fs-database/module.md +149 -0
- package/docs/modules/rust/fs-database/types/catalog.md +53 -0
- package/docs/modules/rust/fs-database/types/module.md +12 -0
- package/docs/modules/rust/fs-database/types/section.md +101 -0
- package/docs/modules/rust/kb-worker/functions/compose.md +57 -0
- package/docs/modules/rust/kb-worker/functions/module.md +20 -0
- package/docs/modules/rust/kb-worker/functions/retrieve.md +194 -0
- package/docs/modules/rust/kb-worker/functions/search.md +173 -0
- package/docs/modules/rust/kb-worker/functions/write.md +172 -0
- package/docs/modules/rust/kb-worker/module.md +171 -0
- package/docs/modules/rust/kb-worker/types/cache.md +90 -0
- package/docs/modules/rust/kb-worker/types/context.md +26 -0
- package/docs/modules/rust/kb-worker/types/module.md +16 -0
- package/docs/modules/rust/kb-worker/types/status.md +29 -0
- package/docs/modules/rust/kb-worker/types/token.md +50 -0
- package/docs/modules/rust/overview.md +495 -0
- package/docs/modules/rust/query-parser/functions/extract.md +56 -0
- package/docs/modules/rust/query-parser/functions/module.md +16 -0
- package/docs/modules/rust/query-parser/functions/parse.md +33 -0
- package/docs/modules/rust/query-parser/functions/pipeline.md +103 -0
- package/docs/modules/rust/query-parser/functions/rank.md +85 -0
- package/docs/modules/rust/query-parser/module.md +136 -0
- package/docs/modules/rust/query-parser/types/cache.md +39 -0
- package/docs/modules/rust/query-parser/types/keyphrase.md +60 -0
- package/docs/modules/rust/query-parser/types/module.md +17 -0
- package/docs/modules/rust/query-parser/types/token.md +42 -0
- package/docs/modules/rust/shared/content-composer/functions.md +114 -0
- package/docs/modules/rust/shared/content-composer/module.md +147 -0
- package/docs/modules/rust/shared/content-composer/types.md +93 -0
- package/docs/modules/rust/shared/content-parser/functions.md +72 -0
- package/docs/modules/rust/shared/content-parser/module.md +99 -0
- package/docs/modules/rust/shared/content-parser/types.md +71 -0
- package/docs/modules/rust/shared/corpus/module.md +24 -0
- package/docs/modules/rust/shared/corpus/types.md +141 -0
- package/docs/modules/rust/shared/document/module.md +25 -0
- package/docs/modules/rust/shared/document/types.md +154 -0
- package/docs/modules/rust/shared/encode/module.md +22 -0
- package/docs/modules/rust/shared/encode/traits.md +304 -0
- package/docs/modules/rust/shared/error/module.md +28 -0
- package/docs/modules/rust/shared/error/types.md +302 -0
- package/docs/modules/rust/shared/kbid/module.md +24 -0
- package/docs/modules/rust/shared/kbid/types.md +147 -0
- package/docs/modules/rust/shared/memory/functions.md +209 -0
- package/docs/modules/rust/shared/memory/module.md +24 -0
- package/docs/modules/rust/shared/module.md +168 -0
- package/docs/modules/rust/shared/query/module.md +27 -0
- package/docs/modules/rust/shared/query/types.md +236 -0
- package/docs/modules/rust/shared/section/module.md +25 -0
- package/docs/modules/rust/shared/section/types.md +294 -0
- package/docs/modules/rust/shared/term/module.md +25 -0
- package/docs/modules/rust/shared/term/types.md +139 -0
- package/docs/modules/typescript/cli.md +129 -0
- package/docs/modules/typescript/kbdb-worker.md +135 -0
- package/docs/modules/typescript/overview.md +378 -0
- package/docs/modules/typescript/shared/cli/constants.md +23 -0
- package/docs/modules/typescript/shared/cli/functions.md +630 -0
- package/docs/modules/typescript/shared/cli/module.md +125 -0
- package/docs/modules/typescript/shared/cli/typings.md +172 -0
- package/docs/modules/typescript/shared/hash/functions.md +20 -0
- package/docs/modules/typescript/shared/hash/module.md +21 -0
- package/docs/modules/typescript/shared/mcp/classes.md +179 -0
- package/docs/modules/typescript/shared/mcp/functions.md +386 -0
- package/docs/modules/typescript/shared/mcp/module.md +160 -0
- package/docs/modules/typescript/shared/mcp/typings.md +522 -0
- package/docs/modules/typescript/shared/module.md +94 -0
- package/docs/modules/typescript/shared/platform/functions.md +42 -0
- package/docs/modules/typescript/shared/platform/module.md +25 -0
- package/docs/modules/typescript/shared/runtime/functions.md +26 -0
- package/docs/modules/typescript/shared/runtime/module.md +27 -0
- package/docs/modules/typescript/shared/runtime/typings.md +13 -0
- package/docs/modules/typescript/shared/version/module.md +27 -0
- package/docs/modules/typescript/shared/wasm-codec/functions.md +391 -0
- package/docs/modules/typescript/shared/wasm-codec/module.md +98 -0
- package/docs/modules/typescript/shared/worker-client/classes.md +264 -0
- package/docs/modules/typescript/shared/worker-client/functions.md +175 -0
- package/docs/modules/typescript/shared/worker-client/module.md +84 -0
- package/docs/modules/typescript/shared/worker-client/typings.md +508 -0
- package/docs/modules/typescript/shared/worker-daemon/classes.md +239 -0
- package/docs/modules/typescript/shared/worker-daemon/constants.md +37 -0
- package/docs/modules/typescript/shared/worker-daemon/functions.md +221 -0
- package/docs/modules/typescript/shared/worker-daemon/module.md +112 -0
- package/docs/modules/typescript/shared/worker-daemon/typings.md +126 -0
- package/docs/overview.md +188 -0
- package/docs/release-notes/0.1.0.md +189 -0
- package/docs/release-notes/0.1.1.md +46 -0
- package/docs/release-notes/0.1.2.md +38 -0
- package/docs/release-notes/0.1.3.md +42 -0
- package/docs/release-notes/0.2.0.md +147 -0
- package/docs/release-notes/README.md +9 -0
- package/package.json +8 -2
- package/src/shared/cli/functions/dispatch-command.function.ts +3 -3
- package/src/shared/cli/functions/format-output.function.ts +41 -34
- package/src/shared/cli/functions/parse-args.function.ts +7 -0
- package/src/shared/cli/functions/run-search.function.ts +53 -27
- package/src/shared/cli/index.ts +4 -1
- package/src/shared/cli/typings/cli-options.interface.ts +2 -0
- package/src/shared/cli/typings/search-display.model.ts +26 -7
- package/src/shared/mcp/functions/create-tool-definitions.function.ts +64 -4
- package/src/shared/mcp/functions/handle-recall.function.ts +66 -0
- package/src/shared/mcp/functions/handle-tool-call.function.ts +11 -1
- package/src/shared/mcp/typings/mcp-client.interface.ts +33 -15
- package/src/shared/version/constants/version.constant.ts +1 -1
- package/src/shared/wasm-codec/functions/decode-recall-result.function.ts +267 -0
- package/src/shared/wasm-codec/functions/decode-scored-results.function.ts +81 -27
- package/src/shared/wasm-codec/functions/encode-recall-params.function.ts +68 -0
- package/src/shared/wasm-codec/functions/encode-search-params.function.ts +4 -1
- package/src/shared/wasm-codec/index.ts +11 -3
- package/src/shared/worker-client/classes/worker-client.class.ts +24 -4
- package/src/shared/worker-client/index.ts +11 -1
- package/src/shared/worker-client/typings/recall-result.model.ts +98 -0
- package/src/shared/worker-client/typings/search-params.model.ts +2 -0
- package/src/shared/worker-client/typings/search-result.model.ts +24 -7
- package/src/shared/worker-daemon/classes/worker-daemon.class.ts +25 -4
- package/src/wasm/fs-database/kbdb_fs_database.d.ts +18 -0
- package/src/wasm/fs-database/kbdb_fs_database.js +30 -0
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +2 -0
- package/src/wasm/kb-worker/kbdb_worker.d.ts +38 -0
- package/src/wasm/kb-worker/kbdb_worker.js +56 -0
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +3 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# worker-daemon/typings -- Daemon Type Definitions
|
|
2
|
+
|
|
3
|
+
*Interfaces and type aliases for daemon configuration,
|
|
4
|
+
IPC message shapes, and WASM module references.*
|
|
5
|
+
|
|
6
|
+
## Source
|
|
7
|
+
|
|
8
|
+
`src/shared/worker-daemon/typings/`
|
|
9
|
+
|
|
10
|
+
## Typings
|
|
11
|
+
|
|
12
|
+
### `DaemonConfig`
|
|
13
|
+
|
|
14
|
+
**File:** `daemon-config.interface.ts`
|
|
15
|
+
|
|
16
|
+
Parsed contents of `worker.toml`. Missing keys use
|
|
17
|
+
defaults from
|
|
18
|
+
[daemon-defaults.constant.ts](constants.md).
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
interface DaemonConfig {
|
|
22
|
+
readonly contextPath: string;
|
|
23
|
+
readonly itemLimit: number;
|
|
24
|
+
readonly indexLimit: number;
|
|
25
|
+
readonly timeoutMs: number;
|
|
26
|
+
readonly itemTtlMs: number;
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Property | Type | Default | Description |
|
|
31
|
+
|---------------|----------|----------|-------------------|
|
|
32
|
+
| `contextPath` | `string` | -- | Absolute path to |
|
|
33
|
+
| | | | the context dir |
|
|
34
|
+
| `itemLimit` | `number` | `1000` | Max content items |
|
|
35
|
+
| | | | in cache |
|
|
36
|
+
| `indexLimit` | `number` | `100` | Max index entries |
|
|
37
|
+
| | | | in cache |
|
|
38
|
+
| `timeoutMs` | `number` | `300000` | Daemon idle |
|
|
39
|
+
| | | | timeout (ms) |
|
|
40
|
+
| `itemTtlMs` | `number` | `60000` | Per-item cache |
|
|
41
|
+
| | | | TTL (ms) |
|
|
42
|
+
|
|
43
|
+
### `IpcRequest`
|
|
44
|
+
|
|
45
|
+
**File:** `ipc-handler.interface.ts`
|
|
46
|
+
|
|
47
|
+
A JSON-RPC 2.0 request sent to the daemon over IPC.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
interface IpcRequest {
|
|
51
|
+
readonly jsonrpc: '2.0';
|
|
52
|
+
readonly id: number | string;
|
|
53
|
+
readonly method: string;
|
|
54
|
+
readonly params?: unknown;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### `IpcErrorDetail`
|
|
59
|
+
|
|
60
|
+
**File:** `ipc-handler.interface.ts`
|
|
61
|
+
|
|
62
|
+
Error detail included in a failed JSON-RPC response.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
interface IpcErrorDetail {
|
|
66
|
+
readonly code: number;
|
|
67
|
+
readonly message: string;
|
|
68
|
+
readonly data?: unknown;
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### `IpcResponse`
|
|
73
|
+
|
|
74
|
+
**File:** `ipc-handler.interface.ts`
|
|
75
|
+
|
|
76
|
+
A JSON-RPC 2.0 response returned by the daemon.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
interface IpcResponse {
|
|
80
|
+
readonly jsonrpc: '2.0';
|
|
81
|
+
readonly id: number | string;
|
|
82
|
+
readonly result?: unknown;
|
|
83
|
+
readonly error?: IpcErrorDetail;
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### `IpcHandler`
|
|
88
|
+
|
|
89
|
+
**File:** `ipc-handler.interface.ts`
|
|
90
|
+
|
|
91
|
+
Function type for handling a single IPC request and
|
|
92
|
+
returning a JSON-RPC response.
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
type IpcHandler = (
|
|
96
|
+
request: IpcRequest,
|
|
97
|
+
) => Promise<IpcResponse>;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The `WorkerDaemon.handleRequest` method satisfies this
|
|
101
|
+
type and is passed to `createIpcServer`.
|
|
102
|
+
|
|
103
|
+
### `WasmModules`
|
|
104
|
+
|
|
105
|
+
**File:** `wasm-modules.interface.ts`
|
|
106
|
+
|
|
107
|
+
References to the compiled and instantiated WASM
|
|
108
|
+
module and its exported memory.
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
interface WasmModules {
|
|
112
|
+
readonly memory: WebAssembly.Memory;
|
|
113
|
+
readonly kbWorker: WebAssembly.Instance;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
| Property | Type | Description |
|
|
118
|
+
|------------|------------------------|------------------------|
|
|
119
|
+
| `memory` | `WebAssembly.Memory` | Linear memory exported |
|
|
120
|
+
| | | by `kb-worker.wasm` |
|
|
121
|
+
| `kbWorker` | `WebAssembly.Instance` | Instantiated |
|
|
122
|
+
| | | `kb-worker.wasm` |
|
|
123
|
+
|
|
124
|
+
Returned by `loadWasmModules()`.
|
|
125
|
+
|
|
126
|
+
No spec -- typings are compile-time only.
|
package/docs/overview.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# @dikolab/kbdb -- Knowledge Base Database
|
|
2
|
+
|
|
3
|
+
*A persistent, file-based knowledge store and MCP server purpose-built for AI agents -- your second brain, on disk.*
|
|
4
|
+
|
|
5
|
+
## What Is @dikolab/kbdb?
|
|
6
|
+
|
|
7
|
+
AI agents operate in ephemeral sessions. They lose context between conversations, forget prior research, and have no built-in way to persist or retrieve knowledge across runs. When an agent needs to recall documentation, search a codebase's API surface, or query a corpus of notes, there is no lightweight, local solution optimized for how agents actually retrieve information -- keyword-driven, section-level, ranked.
|
|
8
|
+
|
|
9
|
+
@dikolab/kbdb is a CLI tool and MCP server that imports documents and code documentation, extracts keywords, builds indexes, and enables ranked search -- all backed by a directory-based file database. No database server, no cloud dependency. A folder on disk is your entire knowledge base.
|
|
10
|
+
|
|
11
|
+
The computationally intensive work -- keyword extraction, indexing, ranking -- is offloaded to a Rust engine compiled to WebAssembly, delivering near-native performance inside a Deno or Node.js runtime. The TypeScript CLI provides the developer-facing interface and MCP server; Rust/WASM does the heavy lifting underneath.
|
|
12
|
+
|
|
13
|
+
## Who Is This For?
|
|
14
|
+
|
|
15
|
+
- **AI agent developers** -- Anyone building agentic workflows (with Claude, LangChain, or custom harnesses) who needs persistent, searchable knowledge across sessions.
|
|
16
|
+
- **MCP tool authors** -- Developers creating Model Context Protocol servers who need a local knowledge backend their tools can query.
|
|
17
|
+
- **Knowledge workers using AI assistants** -- Power users who want their AI to have a second brain -- a searchable, structured store of documentation, research, and reference material that survives session boundaries.
|
|
18
|
+
- **CLI-first developers** -- Those who prefer composable command-line tools over GUI applications for managing knowledge.
|
|
19
|
+
|
|
20
|
+
## Core Features
|
|
21
|
+
|
|
22
|
+
### CLI
|
|
23
|
+
|
|
24
|
+
1. **Markdown import and indexing** -- Import `*.md` files, extract keywords and sections, and store them in the file system database.
|
|
25
|
+
2. **Codebase documentation scanning** -- Scan a codebase and import code documentation (TypeDoc, JSDoc, PHPDoc), index it, and store it in the file system database.
|
|
26
|
+
3. **Ranked search** -- Search and display a ranked list of results by section or by whole document, with output in `.md` or `.json` format.
|
|
27
|
+
|
|
28
|
+
### MCP
|
|
29
|
+
|
|
30
|
+
1. **MCP service endpoints** -- Expose the knowledge base as MCP service endpoints for Claude and other AI agents to query, search, and retrieve knowledge programmatically.
|
|
31
|
+
|
|
32
|
+
### Distribution
|
|
33
|
+
|
|
34
|
+
This tool is available via **NPM** for Node.js or **JSR** for Deno.
|
|
35
|
+
|
|
36
|
+
- **Node.js**: `npm install -g @dikolab/kbdb`
|
|
37
|
+
- **Deno**: `deno add @dikolab/kbdb` (via [jsr.io](https://jsr.io))
|
|
38
|
+
|
|
39
|
+
## High-Level Architecture
|
|
40
|
+
|
|
41
|
+
The system is organized in five layers. Data flows
|
|
42
|
+
downward from user commands or agent requests through
|
|
43
|
+
the worker client and daemon into the WASM engine,
|
|
44
|
+
which performs heavy processing and manages the file
|
|
45
|
+
database.
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
**The kbdb Command** -- A single executable with two
|
|
50
|
+
run modes. CLI mode (`kbdb learn`, `kbdb search`,
|
|
51
|
+
`kbdb unlearn`) handles human and script invocation --
|
|
52
|
+
each command is a short-lived process. MCP mode
|
|
53
|
+
(`kbdb mcp`) starts a long-lived MCP server that AI
|
|
54
|
+
agents connect to over stdio.
|
|
55
|
+
|
|
56
|
+
**Worker Client** -- Shared TypeScript module imported
|
|
57
|
+
by both run modes. Discovers or spawns the worker
|
|
58
|
+
daemon and provides a typed async API over IPC.
|
|
59
|
+
|
|
60
|
+
**Worker Daemon** -- A detached background process
|
|
61
|
+
that loads WASM modules, manages an in-memory cache,
|
|
62
|
+
and serves JSON-RPC 2.0 requests over local IPC (Unix
|
|
63
|
+
sockets or Windows named pipes). The daemon has no
|
|
64
|
+
knowledge of its callers.
|
|
65
|
+
|
|
66
|
+
**Rust/WASM Engine** -- Three WASM modules:
|
|
67
|
+
`query-parser.wasm` (tokenization, query parsing,
|
|
68
|
+
ranking), `fs-database.wasm` (file database I/O), and
|
|
69
|
+
`kb-worker.wasm` (imports both, orchestrates). Rust
|
|
70
|
+
provides memory safety and performance; WASM provides
|
|
71
|
+
portability across runtimes.
|
|
72
|
+
|
|
73
|
+
**File Database** -- A structured directory on disk.
|
|
74
|
+
No external database process required. Documents,
|
|
75
|
+
indexes, keywords, and metadata are stored in a
|
|
76
|
+
defined directory layout. The database is portable,
|
|
77
|
+
version-controllable, and human-inspectable.
|
|
78
|
+
|
|
79
|
+
## Technology Stack
|
|
80
|
+
|
|
81
|
+
| Layer | Technology | Role |
|
|
82
|
+
|-------|-----------|------|
|
|
83
|
+
| Runtime | Deno (primary), Node.js (compatible) | Executes the CLI, MCP server, and TypeScript orchestration |
|
|
84
|
+
| Language | TypeScript | CLI, command parsing, MCP protocol, I/O coordination |
|
|
85
|
+
| Engine | Rust compiled to WebAssembly | Keyword processing, indexing, ranking, file DB operations |
|
|
86
|
+
| Protocol | MCP (Model Context Protocol) | AI agent integration interface |
|
|
87
|
+
| Distribution | NPM (Node.js), JSR (Deno) | Package distribution for both ecosystems |
|
|
88
|
+
| Storage | Directory-based file database | Persistent, portable, server-less data storage |
|
|
89
|
+
|
|
90
|
+
## Design Principles
|
|
91
|
+
|
|
92
|
+
1. **Offline-first, server-less** -- No database server, no cloud dependency. A directory on disk is the entire database. Works anywhere a filesystem exists.
|
|
93
|
+
2. **AI-agent-native** -- Designed from the ground up to be invoked by AI agents, not just humans. Commands, output formats, and the MCP interface prioritize machine consumption.
|
|
94
|
+
3. **MCP-first integration** -- The MCP server is a primary interface, not an afterthought. AI agents connect to the knowledge base as naturally as they connect to any other MCP service.
|
|
95
|
+
4. **Performance through Rust/WASM** -- Computationally intensive work runs in compiled Rust via WebAssembly, keeping the TypeScript layer thin and the heavy processing fast.
|
|
96
|
+
5. **Portability** -- Runs on Deno or Node.js. The file database is a plain directory. No platform lock-in at any layer.
|
|
97
|
+
6. **Section-level precision** -- Documents are decomposed into sections. Search returns the specific passage that matters, not an entire document.
|
|
98
|
+
7. **Incremental design** -- The project ships working slices. Storage format and engine capabilities will evolve; the architecture accommodates change without requiring rewrites.
|
|
99
|
+
|
|
100
|
+
## Details
|
|
101
|
+
|
|
102
|
+
The following documents describe the intended behavior and
|
|
103
|
+
design goals for each major subsystem. They serve as
|
|
104
|
+
implementation specifications, not descriptions of current
|
|
105
|
+
functionality.
|
|
106
|
+
|
|
107
|
+
- **[Database](goals/database.md)** -- Filesystem storage
|
|
108
|
+
engine (`fs-database.wasm`). The `.kbdb` directory
|
|
109
|
+
structure, section and document CRUD operations, index
|
|
110
|
+
management, and storage design.
|
|
111
|
+
- **[Query Parser](goals/query-parser.md)** -- Query
|
|
112
|
+
processing and tokenization (`query-parser.wasm`).
|
|
113
|
+
Standalone WASM module for tokenization, query
|
|
114
|
+
parsing, keyword extraction, and ranking.
|
|
115
|
+
- **[Document](goals/document.md)** -- Text content
|
|
116
|
+
format specification. Markdown body text with
|
|
117
|
+
embedding markers and cross-reference link markers.
|
|
118
|
+
- **[Content Parser](goals/content-parser.md)** --
|
|
119
|
+
Marker extraction engine (`kbdb-shared` rlib).
|
|
120
|
+
Scans section content for `$(type: value)` markers
|
|
121
|
+
and returns structured reference lists.
|
|
122
|
+
- **[Content Composer](goals/content-composer.md)** --
|
|
123
|
+
Content composition engine (`kbdb-shared` rlib).
|
|
124
|
+
Resolves sections and markers, produces rendered
|
|
125
|
+
Markdown documents from kbid and docid identifiers.
|
|
126
|
+
- **[CLI](goals/cli.md)** -- The `kbdb` command and its
|
|
127
|
+
two run modes. CLI mode commands (`learn`, `unlearn`,
|
|
128
|
+
`search`), MCP mode dispatch, output formats, and the
|
|
129
|
+
pass-through execution model.
|
|
130
|
+
- **[MCP](goals/mcp.md)** -- MCP server mode
|
|
131
|
+
(`kbdb mcp`). Invocation, database path
|
|
132
|
+
configuration, stdio transport, MCP tools and
|
|
133
|
+
resources, agent wiring examples, and relationship
|
|
134
|
+
to CLI mode.
|
|
135
|
+
- **[Worker Daemon](goals/worker-daemon.md)** -- Cache
|
|
136
|
+
daemon (`kb-worker.wasm` + `src/worker.ts`).
|
|
137
|
+
The detached TypeScript daemon, WASM module loading,
|
|
138
|
+
caching, IPC protocol, lifecycle, and configuration.
|
|
139
|
+
- **[Worker Client](goals/worker-client.md)** -- Shared
|
|
140
|
+
TypeScript client module (`src/shared/worker-client/`).
|
|
141
|
+
Daemon discovery, spawning, IPC connection, typed
|
|
142
|
+
API, and the sole entry point used by `src/cli.ts`.
|
|
143
|
+
|
|
144
|
+
## Project Status
|
|
145
|
+
|
|
146
|
+
@dikolab/kbdb is in active development. The full
|
|
147
|
+
five-layer stack (CLI/MCP -> Worker Client -> Worker
|
|
148
|
+
Daemon -> WASM Engine -> File Database) is wired and
|
|
149
|
+
working end-to-end for all core operations: learn,
|
|
150
|
+
search, recall, content retrieval, skills, agents,
|
|
151
|
+
and maintenance commands.
|
|
152
|
+
|
|
153
|
+
E2E smoke tests run on both Node.js and Deno via
|
|
154
|
+
Docker, covering 380+ assertions across CLI commands,
|
|
155
|
+
18 MCP tools, MCP protocol features, and worker IPC
|
|
156
|
+
methods.
|
|
157
|
+
|
|
158
|
+
### Completed
|
|
159
|
+
|
|
160
|
+
- CLI with 18 commands across 6 groups (tested)
|
|
161
|
+
- MCP server with 18 tools, prompts, resources,
|
|
162
|
+
and completions (tested)
|
|
163
|
+
- Worker client with typed async IPC API (tested)
|
|
164
|
+
- Worker daemon with WASM module loading (tested)
|
|
165
|
+
- Rust/WASM engine: search, recall, indexing,
|
|
166
|
+
reference graph, KWIC snippets, pagination
|
|
167
|
+
- Paginated search with rich metadata (heading,
|
|
168
|
+
type, snippet, matched_terms, docids)
|
|
169
|
+
- Progressive recall at depths 0--3
|
|
170
|
+
- Bidirectional reference graph (references.idx)
|
|
171
|
+
- Skills (template-based prompts) and agents
|
|
172
|
+
(persona + skills compositions)
|
|
173
|
+
- esbuild bundling pipeline (ESM + CJS + .d.ts)
|
|
174
|
+
- Docker build containers (Deno + Node + Rust +
|
|
175
|
+
wasm-pack)
|
|
176
|
+
- npm and JSR packaging with documentation
|
|
177
|
+
|
|
178
|
+
### Remaining
|
|
179
|
+
|
|
180
|
+
- Complete WASM host I/O imports (some operations
|
|
181
|
+
still hit stubs: document removal, agent document
|
|
182
|
+
persistence)
|
|
183
|
+
- Database format versioning and migration
|
|
184
|
+
infrastructure
|
|
185
|
+
|
|
186
|
+
## Links
|
|
187
|
+
|
|
188
|
+
- **Repository**: https://gitlab.com/tech-slaves-internal/knowledge-base-db
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# 0.1.0
|
|
2
|
+
|
|
3
|
+
*Initial release -- 2026-06-19*
|
|
4
|
+
|
|
5
|
+
The first public release of **@dikolab/kbdb**, a
|
|
6
|
+
file-based knowledge base database that stores,
|
|
7
|
+
indexes, and searches documentation without needing
|
|
8
|
+
a database server.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Highlights
|
|
13
|
+
|
|
14
|
+
- Store documentation in a plain folder on disk --
|
|
15
|
+
no server, no cloud account, no infrastructure
|
|
16
|
+
- Ranked search powered by a Rust/WASM engine
|
|
17
|
+
- CLI with 17 commands for managing documents,
|
|
18
|
+
skills, and agents
|
|
19
|
+
- MCP server that gives AI agents a searchable
|
|
20
|
+
second brain
|
|
21
|
+
- Runs on both Node.js (>= 20) and Deno (>= 2)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
# Node.js
|
|
29
|
+
npm install -g @dikolab/kbdb
|
|
30
|
+
|
|
31
|
+
# Deno
|
|
32
|
+
deno install -Agf jsr:@dikolab/kbdb/cli
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## CLI
|
|
38
|
+
|
|
39
|
+
The `kbdb` command organises 17 commands across
|
|
40
|
+
6 groups:
|
|
41
|
+
|
|
42
|
+
| Group | Commands |
|
|
43
|
+
|-------|----------|
|
|
44
|
+
| Knowledge Base | `learn`, `unlearn`, `search`, `content` |
|
|
45
|
+
| Database | `db init`, `db migrate` |
|
|
46
|
+
| Maintenance | `status`, `check`, `gc`, `rebuild` |
|
|
47
|
+
| Skills | `skill learn`, `skill list`, `skill get`, `skill delete` |
|
|
48
|
+
| Agents | `agent create`, `agent list`, `agent get`, `agent delete` |
|
|
49
|
+
| Server | `mcp` |
|
|
50
|
+
|
|
51
|
+
See the [CLI Reference](../details/cli.md) for
|
|
52
|
+
options and examples.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Search and Ranking
|
|
57
|
+
|
|
58
|
+
Search uses **BM25F** field-weighted ranking with
|
|
59
|
+
three indexed fields per section:
|
|
60
|
+
|
|
61
|
+
| Field | Weight | Description |
|
|
62
|
+
|-------|--------|-------------|
|
|
63
|
+
| Heading | 2.0x | Titles and headings |
|
|
64
|
+
| Body | 1.0x | Main text content |
|
|
65
|
+
| Code | 1.5x | Code blocks and inline code |
|
|
66
|
+
|
|
67
|
+
Queries support keywords, exact phrases
|
|
68
|
+
(`"error handling"`), boolean operators
|
|
69
|
+
(`auth AND token`, `cache OR redis`), and term
|
|
70
|
+
exclusions (`auth -oauth`).
|
|
71
|
+
|
|
72
|
+
See [How Search Works](../details/search-and-ranking.md)
|
|
73
|
+
for internals.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## MCP Server
|
|
78
|
+
|
|
79
|
+
The `kbdb mcp` command starts an MCP server over
|
|
80
|
+
stdio using JSON-RPC 2.0 (MCP Protocol 2025-11-25).
|
|
81
|
+
|
|
82
|
+
**17 tools** available to AI agents:
|
|
83
|
+
|
|
84
|
+
- **Knowledge Base**: `search`, `learn`, `unlearn`,
|
|
85
|
+
`retrieve`, `content`
|
|
86
|
+
- **Database**: `status`, `check`, `gc`, `rebuild`
|
|
87
|
+
- **Skills**: `skill-learn`, `skill-list`,
|
|
88
|
+
`skill-get`, `skill-delete`
|
|
89
|
+
- **Agents**: `agent-create`, `agent-list`,
|
|
90
|
+
`agent-get`, `agent-delete`
|
|
91
|
+
|
|
92
|
+
Works with Claude Code, Claude for VS Code,
|
|
93
|
+
Claude Desktop, and any MCP-compatible agent.
|
|
94
|
+
See the [MCP Server Guide](../details/mcp-server.md)
|
|
95
|
+
for setup instructions.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Skills and Agents
|
|
100
|
+
|
|
101
|
+
**Skills** are reusable templates with placeholder
|
|
102
|
+
arguments. Store common prompts or instructions
|
|
103
|
+
once and reference them by name.
|
|
104
|
+
|
|
105
|
+
**Agents** are AI agent profiles that combine a
|
|
106
|
+
persona with a set of skills. Create named agent
|
|
107
|
+
configurations that persist across sessions.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Storage
|
|
112
|
+
|
|
113
|
+
All data lives in a `.kbdb` directory on disk:
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
.kbdb/
|
|
117
|
+
catalog.toml -- version and stats
|
|
118
|
+
corpus.bin -- term frequencies
|
|
119
|
+
sections/ -- indexed content
|
|
120
|
+
documents/ -- document groupings
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Content is identified by **kbid** -- a content-
|
|
124
|
+
addressed ID derived from SHA-256 (128-bit
|
|
125
|
+
truncation, base32-encoded). Identical content
|
|
126
|
+
always produces the same kbid.
|
|
127
|
+
|
|
128
|
+
See [Storage Architecture](../details/storage.md)
|
|
129
|
+
for file formats and design details.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Rust/WASM Engine
|
|
134
|
+
|
|
135
|
+
The search engine is written in Rust and compiled
|
|
136
|
+
to WebAssembly. Four crates handle different
|
|
137
|
+
responsibilities:
|
|
138
|
+
|
|
139
|
+
| Crate | Role |
|
|
140
|
+
|-------|------|
|
|
141
|
+
| `kbdb-shared` | Memory management, encoding, error types |
|
|
142
|
+
| `kbdb-fs-database` | Storage, indexing, search |
|
|
143
|
+
| `kbdb-query-parser` | Query tokenization and parsing |
|
|
144
|
+
| `kbdb-worker` | IPC request dispatch |
|
|
145
|
+
|
|
146
|
+
WASM modules load at runtime -- no native
|
|
147
|
+
compilation needed on the user's machine.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Build Pipeline
|
|
152
|
+
|
|
153
|
+
Development uses a Docker-based build pipeline
|
|
154
|
+
that includes Node.js, Deno, Rust, and wasm-pack:
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
make build # Full pipeline: lint, test, wasm, bundle
|
|
158
|
+
make test-node # E2E smoke tests (Node.js)
|
|
159
|
+
make test-deno # E2E smoke tests (Deno)
|
|
160
|
+
make lint # Rust + TypeScript linting
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
See the [Makefile](../../Makefile) for all targets.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Platforms
|
|
168
|
+
|
|
169
|
+
| Runtime | Minimum version |
|
|
170
|
+
|---------|----------------|
|
|
171
|
+
| Node.js | 20.0.0 |
|
|
172
|
+
| Deno | 2.0.0 |
|
|
173
|
+
|
|
174
|
+
Published to:
|
|
175
|
+
|
|
176
|
+
- [npm](https://www.npmjs.com/package/@dikolab/kbdb)
|
|
177
|
+
as `@dikolab/kbdb`
|
|
178
|
+
- [JSR](https://jsr.io/@dikolab/kbdb) as
|
|
179
|
+
`@dikolab/kbdb`
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Documentation
|
|
184
|
+
|
|
185
|
+
- [CLI Reference](../details/cli.md)
|
|
186
|
+
- [MCP Server Guide](../details/mcp-server.md)
|
|
187
|
+
- [Search and Ranking](../details/search-and-ranking.md)
|
|
188
|
+
- [Storage Architecture](../details/storage.md)
|
|
189
|
+
- [Library API](../details/library-api.md)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# 0.1.1
|
|
2
|
+
|
|
3
|
+
*Patch release -- 2026-06-20*
|
|
4
|
+
|
|
5
|
+
Fixes a Deno type-checking error that blocked
|
|
6
|
+
`deno publish`, and improves the build pipeline.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Fixes
|
|
11
|
+
|
|
12
|
+
- **Deno type error in WASM memory buffer** --
|
|
13
|
+
`WebAssembly.Memory.buffer` returns
|
|
14
|
+
`ArrayBuffer | SharedArrayBuffer` under Deno's
|
|
15
|
+
type system but `ArrayBuffer` under Node.js.
|
|
16
|
+
Added explicit cast to satisfy both type-checkers.
|
|
17
|
+
|
|
18
|
+
## Improvements
|
|
19
|
+
|
|
20
|
+
- **WASM directory resolution** -- `resolveBaseDir`
|
|
21
|
+
now supports three fallback strategies for
|
|
22
|
+
locating WASM files:
|
|
23
|
+
1. `__dirname` (Node.js CJS)
|
|
24
|
+
2. `import.meta.dirname` (Deno local, Node.js
|
|
25
|
+
ESM v21.2+)
|
|
26
|
+
3. URL-based derivation (JSR remote modules)
|
|
27
|
+
|
|
28
|
+
- **Build pipeline cleanup** -- `build-wasm.sh`
|
|
29
|
+
and `build-ts.sh` now remove stale output
|
|
30
|
+
directories (`src/wasm/`, `dist/`) before
|
|
31
|
+
building, ensuring fresh builds every time.
|
|
32
|
+
|
|
33
|
+
- **Rust test stability** -- Added
|
|
34
|
+
`--test-threads=1` to Rust integration tests
|
|
35
|
+
to prevent race conditions on shared WASM
|
|
36
|
+
return-slot globals.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Upgrade
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npm install -g @dikolab/kbdb@0.1.1
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
No breaking changes from 0.1.0.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# 0.1.2
|
|
2
|
+
|
|
3
|
+
*Patch release -- 2026-06-20*
|
|
4
|
+
|
|
5
|
+
Fixes WASM loading failure when installed from JSR
|
|
6
|
+
(`deno install -Agf jsr:@dikolab/kbdb/cli`).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Fixes
|
|
11
|
+
|
|
12
|
+
- **WASM loading from JSR remote URLs** -- When
|
|
13
|
+
installed from JSR, module URLs use `https://`
|
|
14
|
+
instead of filesystem paths. `path.join` mangled
|
|
15
|
+
these URLs by stripping the `//` in `https://`,
|
|
16
|
+
and `readFileSync` cannot open URLs. Added
|
|
17
|
+
URL-aware path joining (`joinPath`) and async
|
|
18
|
+
WASM loading via `fetch()` for remote URLs.
|
|
19
|
+
|
|
20
|
+
- **Worker script resolution for JSR** --
|
|
21
|
+
`resolveWorkerScript` now preserves URL format
|
|
22
|
+
when the script directory is a remote URL, so
|
|
23
|
+
`deno run` receives a valid URL instead of a
|
|
24
|
+
mangled path.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Upgrade
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
# Node.js
|
|
32
|
+
npm install -g @dikolab/kbdb@0.1.2
|
|
33
|
+
|
|
34
|
+
# Deno
|
|
35
|
+
deno install -Agf jsr:@dikolab/kbdb/cli
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
No breaking changes from 0.1.1.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# 0.1.3
|
|
2
|
+
|
|
3
|
+
*Patch release -- 2026-06-20*
|
|
4
|
+
|
|
5
|
+
Fixes WASM binaries missing from JSR package, which
|
|
6
|
+
caused 404 errors when installed via
|
|
7
|
+
`deno install -Agf jsr:@dikolab/kbdb/cli`.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Fixes
|
|
12
|
+
|
|
13
|
+
- **WASM binaries excluded from JSR publish** --
|
|
14
|
+
`deno publish` respects `.gitignore`, which listed
|
|
15
|
+
`src/wasm/`. Additionally, wasm-pack generates
|
|
16
|
+
`.gitignore` files (containing `*`) inside each
|
|
17
|
+
WASM output directory. Both layers prevented WASM
|
|
18
|
+
binaries from being included in the JSR package.
|
|
19
|
+
The build script now removes wasm-pack's nested
|
|
20
|
+
`.gitignore` files, and the publish script
|
|
21
|
+
temporarily un-ignores `src/wasm/` during
|
|
22
|
+
`deno publish`.
|
|
23
|
+
|
|
24
|
+
- **Excluded unnecessary wasm-pack artifacts from
|
|
25
|
+
JSR** -- Added `publish.exclude` patterns for
|
|
26
|
+
`.js`, `.d.ts`, and `package.json` files inside
|
|
27
|
+
`src/wasm/`, so only the `.wasm` binaries are
|
|
28
|
+
published to JSR.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Upgrade
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
# Node.js
|
|
36
|
+
npm install -g @dikolab/kbdb@0.1.3
|
|
37
|
+
|
|
38
|
+
# Deno
|
|
39
|
+
deno install -Agf jsr:@dikolab/kbdb/cli
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
No breaking changes from 0.1.2.
|