@dikolab/kbdb 0.5.0 → 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.
- package/CLA.md +68 -0
- package/LICENSE +676 -12
- package/LICENSING.md +58 -0
- package/README.md +47 -24
- package/README.md.bak +320 -0
- package/dist/README.md +320 -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 +10 -9
- 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
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg"
|
|
2
|
-
width="780" height="770" viewBox="0 0 780 770"
|
|
3
|
-
font-family="system-ui, -apple-system, sans-serif">
|
|
4
|
-
|
|
5
|
-
<defs>
|
|
6
|
-
<marker id="arrowhead" viewBox="0 0 10 7"
|
|
7
|
-
refX="10" refY="3.5"
|
|
8
|
-
markerWidth="8" markerHeight="6" orient="auto">
|
|
9
|
-
<path d="M0,0 L10,3.5 L0,7 z" fill="#6b7280"/>
|
|
10
|
-
</marker>
|
|
11
|
-
<marker id="arrowhead-red" viewBox="0 0 10 7"
|
|
12
|
-
refX="10" refY="3.5"
|
|
13
|
-
markerWidth="8" markerHeight="6" orient="auto">
|
|
14
|
-
<path d="M0,0 L10,3.5 L0,7 z" fill="#dc2626"/>
|
|
15
|
-
</marker>
|
|
16
|
-
</defs>
|
|
17
|
-
|
|
18
|
-
<!-- Background -->
|
|
19
|
-
<rect width="780" height="770" fill="#ffffff"/>
|
|
20
|
-
|
|
21
|
-
<!-- =========================================== -->
|
|
22
|
-
<!-- Process boundary: kbdb executable -->
|
|
23
|
-
<!-- =========================================== -->
|
|
24
|
-
<rect x="35" y="90" width="710" height="200" rx="12"
|
|
25
|
-
fill="none" stroke="#d1d5db" stroke-width="1.5"
|
|
26
|
-
stroke-dasharray="8,4"/>
|
|
27
|
-
<text x="50" y="105" font-size="11" fill="#9ca3af"
|
|
28
|
-
font-weight="500">kbdb executable</text>
|
|
29
|
-
|
|
30
|
-
<!-- =========================================== -->
|
|
31
|
-
<!-- Process boundary: worker daemon -->
|
|
32
|
-
<!-- =========================================== -->
|
|
33
|
-
<rect x="35" y="355" width="710" height="285" rx="12"
|
|
34
|
-
fill="none" stroke="#d1d5db" stroke-width="1.5"
|
|
35
|
-
stroke-dasharray="8,4"/>
|
|
36
|
-
<text x="50" y="370" font-size="11" fill="#9ca3af"
|
|
37
|
-
font-weight="500">worker daemon (detached process)</text>
|
|
38
|
-
|
|
39
|
-
<!-- =========================================== -->
|
|
40
|
-
<!-- External: User / Script -->
|
|
41
|
-
<!-- =========================================== -->
|
|
42
|
-
<rect x="85" y="20" width="200" height="44" rx="8"
|
|
43
|
-
fill="#f8f9fa" stroke="#9ca3af" stroke-width="1.5"
|
|
44
|
-
stroke-dasharray="6,3"/>
|
|
45
|
-
<text x="185" y="47" text-anchor="middle"
|
|
46
|
-
font-size="13" font-weight="600" fill="#495057">User / Script</text>
|
|
47
|
-
|
|
48
|
-
<!-- =========================================== -->
|
|
49
|
-
<!-- External: AI Agent Host -->
|
|
50
|
-
<!-- =========================================== -->
|
|
51
|
-
<rect x="495" y="20" width="200" height="44" rx="8"
|
|
52
|
-
fill="#f8f9fa" stroke="#9ca3af" stroke-width="1.5"
|
|
53
|
-
stroke-dasharray="6,3"/>
|
|
54
|
-
<text x="595" y="47" text-anchor="middle"
|
|
55
|
-
font-size="13" font-weight="600" fill="#495057">AI Agent Host</text>
|
|
56
|
-
|
|
57
|
-
<!-- =========================================== -->
|
|
58
|
-
<!-- CLI Mode -->
|
|
59
|
-
<!-- =========================================== -->
|
|
60
|
-
<rect x="85" y="110" width="200" height="52" rx="8"
|
|
61
|
-
fill="#dbeafe" stroke="#3b82f6" stroke-width="1.5"/>
|
|
62
|
-
<text x="185" y="134" text-anchor="middle"
|
|
63
|
-
font-size="13" font-weight="600" fill="#1e40af">CLI Mode</text>
|
|
64
|
-
<text x="185" y="150" text-anchor="middle"
|
|
65
|
-
font-size="11" fill="#6b7280">cli.ts</text>
|
|
66
|
-
|
|
67
|
-
<!-- =========================================== -->
|
|
68
|
-
<!-- MCP Mode -->
|
|
69
|
-
<!-- =========================================== -->
|
|
70
|
-
<rect x="495" y="110" width="200" height="52" rx="8"
|
|
71
|
-
fill="#dbeafe" stroke="#3b82f6" stroke-width="1.5"/>
|
|
72
|
-
<text x="595" y="134" text-anchor="middle"
|
|
73
|
-
font-size="13" font-weight="600" fill="#1e40af">MCP Mode</text>
|
|
74
|
-
<text x="595" y="150" text-anchor="middle"
|
|
75
|
-
font-size="11" fill="#6b7280">mcp.ts (stdio)</text>
|
|
76
|
-
|
|
77
|
-
<!-- =========================================== -->
|
|
78
|
-
<!-- Worker Client -->
|
|
79
|
-
<!-- =========================================== -->
|
|
80
|
-
<rect x="240" y="220" width="300" height="52" rx="8"
|
|
81
|
-
fill="#d1fae5" stroke="#10b981" stroke-width="1.5"/>
|
|
82
|
-
<text x="390" y="244" text-anchor="middle"
|
|
83
|
-
font-size="13" font-weight="600" fill="#065f46">Worker Client</text>
|
|
84
|
-
<text x="390" y="260" text-anchor="middle"
|
|
85
|
-
font-size="11" fill="#6b7280">src/shared/worker-client/</text>
|
|
86
|
-
|
|
87
|
-
<!-- =========================================== -->
|
|
88
|
-
<!-- Worker Daemon -->
|
|
89
|
-
<!-- =========================================== -->
|
|
90
|
-
<rect x="240" y="375" width="300" height="52" rx="8"
|
|
91
|
-
fill="#fed7aa" stroke="#f97316" stroke-width="1.5"/>
|
|
92
|
-
<text x="390" y="399" text-anchor="middle"
|
|
93
|
-
font-size="13" font-weight="600" fill="#9a3412">Worker Daemon</text>
|
|
94
|
-
<text x="390" y="415" text-anchor="middle"
|
|
95
|
-
font-size="11" fill="#6b7280">kbdb-worker.ts</text>
|
|
96
|
-
|
|
97
|
-
<!-- =========================================== -->
|
|
98
|
-
<!-- kb-worker.wasm -->
|
|
99
|
-
<!-- =========================================== -->
|
|
100
|
-
<rect x="265" y="475" width="250" height="46" rx="8"
|
|
101
|
-
fill="#ede9fe" stroke="#8b5cf6" stroke-width="1.5"/>
|
|
102
|
-
<text x="390" y="503" text-anchor="middle"
|
|
103
|
-
font-size="13" font-weight="600" fill="#5b21b6">kb-worker.wasm</text>
|
|
104
|
-
|
|
105
|
-
<!-- =========================================== -->
|
|
106
|
-
<!-- query-parser.wasm -->
|
|
107
|
-
<!-- =========================================== -->
|
|
108
|
-
<rect x="55" y="575" width="220" height="46" rx="8"
|
|
109
|
-
fill="#ede9fe" stroke="#8b5cf6" stroke-width="1.5"/>
|
|
110
|
-
<text x="165" y="603" text-anchor="middle"
|
|
111
|
-
font-size="13" font-weight="600" fill="#5b21b6">query-parser.wasm</text>
|
|
112
|
-
|
|
113
|
-
<!-- =========================================== -->
|
|
114
|
-
<!-- fs-database.wasm -->
|
|
115
|
-
<!-- =========================================== -->
|
|
116
|
-
<rect x="505" y="575" width="220" height="46" rx="8"
|
|
117
|
-
fill="#ede9fe" stroke="#8b5cf6" stroke-width="1.5"/>
|
|
118
|
-
<text x="615" y="603" text-anchor="middle"
|
|
119
|
-
font-size="13" font-weight="600" fill="#5b21b6">fs-database.wasm</text>
|
|
120
|
-
|
|
121
|
-
<!-- =========================================== -->
|
|
122
|
-
<!-- .kbdb/ directory -->
|
|
123
|
-
<!-- =========================================== -->
|
|
124
|
-
<rect x="505" y="700" width="220" height="50" rx="8"
|
|
125
|
-
fill="#f3f4f6" stroke="#6b7280" stroke-width="1.5"/>
|
|
126
|
-
<text x="615" y="722" text-anchor="middle"
|
|
127
|
-
font-size="13" font-weight="600" fill="#374151">.kbdb/</text>
|
|
128
|
-
<text x="615" y="738" text-anchor="middle"
|
|
129
|
-
font-size="11" fill="#6b7280">directory on disk</text>
|
|
130
|
-
|
|
131
|
-
<!-- =========================================== -->
|
|
132
|
-
<!-- Arrows -->
|
|
133
|
-
<!-- =========================================== -->
|
|
134
|
-
|
|
135
|
-
<!-- User → CLI -->
|
|
136
|
-
<line x1="185" y1="64" x2="185" y2="108"
|
|
137
|
-
stroke="#6b7280" stroke-width="1.5"
|
|
138
|
-
marker-end="url(#arrowhead)"/>
|
|
139
|
-
<text x="195" y="91" font-size="10" fill="#6b7280"
|
|
140
|
-
font-style="italic">args / stdout</text>
|
|
141
|
-
|
|
142
|
-
<!-- AI Agent → MCP -->
|
|
143
|
-
<line x1="595" y1="64" x2="595" y2="108"
|
|
144
|
-
stroke="#6b7280" stroke-width="1.5"
|
|
145
|
-
marker-end="url(#arrowhead)"/>
|
|
146
|
-
<text x="605" y="84" font-size="10" fill="#6b7280"
|
|
147
|
-
font-style="italic">stdio</text>
|
|
148
|
-
<text x="605" y="96" font-size="10" fill="#6b7280"
|
|
149
|
-
font-style="italic">(JSON-RPC 2.0)</text>
|
|
150
|
-
|
|
151
|
-
<!-- CLI → Worker Client -->
|
|
152
|
-
<line x1="215" y1="162" x2="320" y2="218"
|
|
153
|
-
stroke="#6b7280" stroke-width="1.5"
|
|
154
|
-
marker-end="url(#arrowhead)"/>
|
|
155
|
-
|
|
156
|
-
<!-- MCP → Worker Client -->
|
|
157
|
-
<line x1="565" y1="162" x2="460" y2="218"
|
|
158
|
-
stroke="#6b7280" stroke-width="1.5"
|
|
159
|
-
marker-end="url(#arrowhead)"/>
|
|
160
|
-
|
|
161
|
-
<!-- Worker Client → Worker Daemon (IPC boundary) -->
|
|
162
|
-
<line x1="390" y1="272" x2="390" y2="373"
|
|
163
|
-
stroke="#dc2626" stroke-width="2"
|
|
164
|
-
marker-end="url(#arrowhead-red)"/>
|
|
165
|
-
<text x="400" y="318" font-size="11" fill="#dc2626"
|
|
166
|
-
font-weight="600">IPC (JSON-RPC 2.0)</text>
|
|
167
|
-
<text x="400" y="333" font-size="10" fill="#dc2626"
|
|
168
|
-
font-style="italic">Unix socket / named pipe</text>
|
|
169
|
-
|
|
170
|
-
<!-- Worker Daemon → kb-worker.wasm -->
|
|
171
|
-
<line x1="390" y1="427" x2="390" y2="473"
|
|
172
|
-
stroke="#6b7280" stroke-width="1.5"
|
|
173
|
-
marker-end="url(#arrowhead)"/>
|
|
174
|
-
<text x="400" y="455" font-size="10" fill="#6b7280"
|
|
175
|
-
font-style="italic">loads</text>
|
|
176
|
-
|
|
177
|
-
<!-- kb-worker.wasm → query-parser.wasm -->
|
|
178
|
-
<line x1="315" y1="521" x2="210" y2="573"
|
|
179
|
-
stroke="#6b7280" stroke-width="1.5"
|
|
180
|
-
marker-end="url(#arrowhead)"/>
|
|
181
|
-
<text x="232" y="543" font-size="10" fill="#6b7280"
|
|
182
|
-
font-style="italic">imports</text>
|
|
183
|
-
|
|
184
|
-
<!-- kb-worker.wasm → fs-database.wasm -->
|
|
185
|
-
<line x1="465" y1="521" x2="570" y2="573"
|
|
186
|
-
stroke="#6b7280" stroke-width="1.5"
|
|
187
|
-
marker-end="url(#arrowhead)"/>
|
|
188
|
-
<text x="508" y="543" font-size="10" fill="#6b7280"
|
|
189
|
-
font-style="italic">imports</text>
|
|
190
|
-
|
|
191
|
-
<!-- fs-database.wasm → .kbdb/ -->
|
|
192
|
-
<line x1="615" y1="621" x2="615" y2="698"
|
|
193
|
-
stroke="#6b7280" stroke-width="1.5"
|
|
194
|
-
marker-end="url(#arrowhead)"/>
|
|
195
|
-
<text x="625" y="665" font-size="10" fill="#6b7280"
|
|
196
|
-
font-style="italic">host file I/O</text>
|
|
197
|
-
|
|
198
|
-
</svg>
|
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
# Auto-Capture -- Proactive Knowledge Capture Hooks
|
|
2
|
-
|
|
3
|
-
*Server-side enforcement of knowledge capture that
|
|
4
|
-
closes the gap between agent intent and reliable
|
|
5
|
-
storage -- without requiring the agent to remember
|
|
6
|
-
to act.*
|
|
7
|
-
|
|
8
|
-
## Goal
|
|
9
|
-
|
|
10
|
-
The `memory-protocol` skill (see [Skills](skills.md))
|
|
11
|
-
teaches an agent what to store, but enforcement
|
|
12
|
-
depends entirely on the agent choosing to act.
|
|
13
|
-
Agents are unreliable at remembering to call `learn`
|
|
14
|
-
after every significant exchange. Auto-capture closes
|
|
15
|
-
this gap by having the MCP server proactively issue
|
|
16
|
-
a sampling request to the host LLM, asking it to
|
|
17
|
-
review recent context and identify storable knowledge.
|
|
18
|
-
|
|
19
|
-
This is gap #2 from the
|
|
20
|
-
[Opus 4.8 second brain review](../issues/2026-06-23-opus-48-second-brain-review.md):
|
|
21
|
-
|
|
22
|
-
> A memory-protocol *skill* is intent, not
|
|
23
|
-
> enforcement -- agents are unreliable at remembering
|
|
24
|
-
> to write. Real second brains lean on auto-capture
|
|
25
|
-
> hooks.
|
|
26
|
-
|
|
27
|
-
Auto-capture is opt-in and default-disabled. It never
|
|
28
|
-
writes to the database without the host LLM's
|
|
29
|
-
explicit response identifying items to store.
|
|
30
|
-
|
|
31
|
-
## MCP Sampling Approach
|
|
32
|
-
|
|
33
|
-
Auto-capture uses the MCP `sampling/createMessage`
|
|
34
|
-
capability. When a trigger fires, the kbdb MCP server
|
|
35
|
-
sends a `sampling/createMessage` request to the host
|
|
36
|
-
asking it to identify storable knowledge from the
|
|
37
|
-
current conversation context.
|
|
38
|
-
|
|
39
|
-
If the host's `initialize` response does not include
|
|
40
|
-
a `sampling` capability entry, auto-capture is
|
|
41
|
-
silently disabled for that session regardless of
|
|
42
|
-
configuration.
|
|
43
|
-
|
|
44
|
-
### Sampling Prompt Template
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
Review the recent conversation context. Identify any
|
|
48
|
-
durable facts, decisions, corrections, architecture
|
|
49
|
-
choices, or configuration details that should be
|
|
50
|
-
stored in the knowledge base for future sessions.
|
|
51
|
-
|
|
52
|
-
For each item, provide:
|
|
53
|
-
- title: short heading
|
|
54
|
-
- content: the fact or decision
|
|
55
|
-
- tags: relevant topic tags
|
|
56
|
-
|
|
57
|
-
Respond with JSON: {"items": [...]} or {"items": []}
|
|
58
|
-
if nothing is worth storing. Apply the same criteria
|
|
59
|
-
as the memory-protocol skill: store durable facts,
|
|
60
|
-
not transient context.
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
The server sets `maxTokens` to a fixed ceiling (e.g.
|
|
64
|
-
2048) to bound cost. The sampling request carries no
|
|
65
|
-
`systemPrompt` -- context comes from the host's own
|
|
66
|
-
conversation window.
|
|
67
|
-
|
|
68
|
-
### Sampling Response Schema
|
|
69
|
-
|
|
70
|
-
The host LLM must respond with a JSON object at the
|
|
71
|
-
top level. The server parses the text content of the
|
|
72
|
-
sampling response and extracts:
|
|
73
|
-
|
|
74
|
-
```json
|
|
75
|
-
{
|
|
76
|
-
"items": [
|
|
77
|
-
{
|
|
78
|
-
"title": "Postgres chosen for JSONB support",
|
|
79
|
-
"content": "We chose Postgres because JSONB
|
|
80
|
-
support simplifies document storage.",
|
|
81
|
-
"tags": ["architecture", "database"]
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
When `items` is empty or the response cannot be parsed
|
|
88
|
-
as valid JSON, the server takes no action and logs a
|
|
89
|
-
`debug`-level notification.
|
|
90
|
-
|
|
91
|
-
Each item in `items` is stored via `addSection` with
|
|
92
|
-
`sectionType: 'text/markdown'` and the
|
|
93
|
-
`auto-capture` tag appended to `tags`.
|
|
94
|
-
|
|
95
|
-
## Trigger Points
|
|
96
|
-
|
|
97
|
-
Three independent trigger mechanisms fire a capture
|
|
98
|
-
review. All three can be active simultaneously.
|
|
99
|
-
|
|
100
|
-
### 1. Tool-Call Count Trigger
|
|
101
|
-
|
|
102
|
-
The MCP server maintains a per-session counter of
|
|
103
|
-
tool invocations. When the count reaches a multiple
|
|
104
|
-
of `trigger_interval`, a capture review fires.
|
|
105
|
-
|
|
106
|
-
- The counter increments on every `tools/call`
|
|
107
|
-
dispatch, including read-only tools.
|
|
108
|
-
- The counter does not increment during the capture
|
|
109
|
-
review itself (no recursion).
|
|
110
|
-
- The review fires after the triggering tool call
|
|
111
|
-
returns its result to the agent, not before.
|
|
112
|
-
|
|
113
|
-
Default: every 10 tool calls.
|
|
114
|
-
|
|
115
|
-
### 2. Explicit Tool Trigger
|
|
116
|
-
|
|
117
|
-
The `auto-capture-review` tool is always registered,
|
|
118
|
-
regardless of whether auto-capture is enabled in
|
|
119
|
-
`worker.toml`. Agents or users can call it at any
|
|
120
|
-
time to request an immediate capture review.
|
|
121
|
-
|
|
122
|
-
When `dry_run: true` is passed, the review runs but
|
|
123
|
-
no sections are written. See [MCP Surface](#mcp-surface).
|
|
124
|
-
|
|
125
|
-
### 3. Session-End Trigger
|
|
126
|
-
|
|
127
|
-
When the MCP connection closes gracefully (stdin EOF
|
|
128
|
-
or explicit disconnect), one final capture review
|
|
129
|
-
runs before the server exits.
|
|
130
|
-
|
|
131
|
-
The session-end trigger fires only when
|
|
132
|
-
`auto_capture.enabled` is `true`. It does not fire
|
|
133
|
-
when the connection is lost abruptly (SIGKILL, socket
|
|
134
|
-
drop).
|
|
135
|
-
|
|
136
|
-
## Configuration
|
|
137
|
-
|
|
138
|
-
Auto-capture is configured in `worker.toml` under the
|
|
139
|
-
`[auto_capture]` table:
|
|
140
|
-
|
|
141
|
-
```toml
|
|
142
|
-
[auto_capture]
|
|
143
|
-
enabled = false # opt-in, default off
|
|
144
|
-
trigger_interval = 10 # tool calls between reviews
|
|
145
|
-
max_captures_per_session = 20 # rate limit
|
|
146
|
-
dry_run = false # log without writing
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
| Field | Type | Default | Description |
|
|
150
|
-
|-------|------|---------|-------------|
|
|
151
|
-
| `enabled` | bool | `false` | Enable auto-capture for all MCP sessions |
|
|
152
|
-
| `trigger_interval` | integer | `10` | Tool calls between automatic reviews |
|
|
153
|
-
| `max_captures_per_session` | integer | `20` | Maximum sections stored per session |
|
|
154
|
-
| `dry_run` | bool | `false` | Log what would be stored; write nothing |
|
|
155
|
-
|
|
156
|
-
When `enabled` is `false`, only the `auto-capture-review`
|
|
157
|
-
tool remains active. The tool-call count and
|
|
158
|
-
session-end triggers are suppressed.
|
|
159
|
-
|
|
160
|
-
## Guard Rails
|
|
161
|
-
|
|
162
|
-
### Rate Limiting
|
|
163
|
-
|
|
164
|
-
The server tracks the number of sections stored
|
|
165
|
-
during the current MCP session. When
|
|
166
|
-
`max_captures_per_session` is reached, further
|
|
167
|
-
automatic reviews are skipped. The
|
|
168
|
-
`auto-capture-review` tool still runs but returns a
|
|
169
|
-
rate-limit message instead of executing the review.
|
|
170
|
-
|
|
171
|
-
The counter resets when the MCP session ends. It is
|
|
172
|
-
not persisted across sessions.
|
|
173
|
-
|
|
174
|
-
### Dry-Run Mode
|
|
175
|
-
|
|
176
|
-
When `dry_run` is `true` (either from `worker.toml`
|
|
177
|
-
or the `auto-capture-review` tool parameter), the
|
|
178
|
-
server executes the full review -- sends the sampling
|
|
179
|
-
request, parses the response, and evaluates items --
|
|
180
|
-
but does not call `addSection`. Instead, it emits a
|
|
181
|
-
`notifications/message` at `info` level describing
|
|
182
|
-
what would have been stored.
|
|
183
|
-
|
|
184
|
-
Dry-run mode is useful for tuning `trigger_interval`
|
|
185
|
-
and verifying that the sampling prompt produces
|
|
186
|
-
reasonable output before enabling writes.
|
|
187
|
-
|
|
188
|
-
### Deduplication
|
|
189
|
-
|
|
190
|
-
Before storing each item from the sampling response,
|
|
191
|
-
the server searches the database for existing sections
|
|
192
|
-
with similar content. If any existing section has a
|
|
193
|
-
Jaccard similarity >= 0.85 to the candidate item, the
|
|
194
|
-
item is skipped and logged at `debug` level.
|
|
195
|
-
|
|
196
|
-
This uses the same near-duplicate detection that the
|
|
197
|
-
`learn` tool uses, reflected in the `near_duplicates`
|
|
198
|
-
field of `AddSectionResult`.
|
|
199
|
-
|
|
200
|
-
### No Recursion
|
|
201
|
-
|
|
202
|
-
The tool-call counter does not increment during an
|
|
203
|
-
active capture review. The `addSection` calls made
|
|
204
|
-
by auto-capture do not trigger a nested review.
|
|
205
|
-
|
|
206
|
-
### Agent Override
|
|
207
|
-
|
|
208
|
-
Auto-capture never overrides an agent's explicit
|
|
209
|
-
decision not to store something. If an agent
|
|
210
|
-
calls `unlearn` to remove a section, auto-capture
|
|
211
|
-
will not re-add it in the same session (the content's
|
|
212
|
-
kbid is added to a per-session exclusion set after
|
|
213
|
-
removal).
|
|
214
|
-
|
|
215
|
-
## Interaction with the memory-protocol Skill
|
|
216
|
-
|
|
217
|
-
| Aspect | memory-protocol | Auto-capture |
|
|
218
|
-
|--------|-----------------|--------------|
|
|
219
|
-
| Audience | Agent (reads skill text) | MCP server (server-side) |
|
|
220
|
-
| Mechanism | Teaches filtering criteria | Sends sampling request |
|
|
221
|
-
| Enforcement | Agent must choose to act | Server acts automatically |
|
|
222
|
-
| Criteria | Defined in skill body | Sampling prompt mirrors skill |
|
|
223
|
-
| Override | Agent decides | Agent's `unlearn` is respected |
|
|
224
|
-
|
|
225
|
-
Both mechanisms apply the same filtering criteria --
|
|
226
|
-
store durable facts, skip transient context. They are
|
|
227
|
-
complementary: `memory-protocol` is agent-facing
|
|
228
|
-
intent; auto-capture is server-side enforcement.
|
|
229
|
-
|
|
230
|
-
## CLI Surface
|
|
231
|
-
|
|
232
|
-
The `--auto-capture` flag on `kbdb mcp` enables
|
|
233
|
-
auto-capture for the current session, overriding the
|
|
234
|
-
`enabled` value in `worker.toml`:
|
|
235
|
-
|
|
236
|
-
```
|
|
237
|
-
kbdb mcp --db <path> [--auto-capture]
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
The flag does not accept a value -- its presence sets
|
|
241
|
-
`enabled: true`. It does not override other fields
|
|
242
|
-
(`trigger_interval`, `max_captures_per_session`,
|
|
243
|
-
`dry_run`), which continue to come from `worker.toml`
|
|
244
|
-
or their defaults.
|
|
245
|
-
|
|
246
|
-
## MCP Surface
|
|
247
|
-
|
|
248
|
-
### auto-capture-review Tool
|
|
249
|
-
|
|
250
|
-
Triggers an immediate capture review regardless of
|
|
251
|
-
whether auto-capture is enabled in configuration.
|
|
252
|
-
|
|
253
|
-
**Parameters:**
|
|
254
|
-
|
|
255
|
-
| Name | Type | Required | Description |
|
|
256
|
-
|------|------|----------|-------------|
|
|
257
|
-
| `dry_run` | boolean | no | When `true`, evaluate but do not write (default: `false`) |
|
|
258
|
-
|
|
259
|
-
**Returns:**
|
|
260
|
-
|
|
261
|
-
```json
|
|
262
|
-
{
|
|
263
|
-
"captured": 2,
|
|
264
|
-
"items": [
|
|
265
|
-
{
|
|
266
|
-
"title": "Postgres chosen for JSONB support",
|
|
267
|
-
"kbid": "a1b2c3d4e5f6g7h8j9k0l1m2n3"
|
|
268
|
-
}
|
|
269
|
-
],
|
|
270
|
-
"skipped": 1,
|
|
271
|
-
"dry_run": false
|
|
272
|
-
}
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
| Field | Description |
|
|
276
|
-
|-------|-------------|
|
|
277
|
-
| `captured` | Number of sections written (0 when `dry_run: true`) |
|
|
278
|
-
| `items` | Array of `{ title, kbid }` for each section stored |
|
|
279
|
-
| `skipped` | Items returned by LLM but not stored (duplicates, parse errors, rate limit) |
|
|
280
|
-
| `dry_run` | Reflects the effective dry-run mode used |
|
|
281
|
-
|
|
282
|
-
When sampling is not supported by the host, the tool
|
|
283
|
-
returns `isError: true` with message:
|
|
284
|
-
`"Host does not support sampling; auto-capture-review
|
|
285
|
-
unavailable"`.
|
|
286
|
-
|
|
287
|
-
**Tool annotation:**
|
|
288
|
-
|
|
289
|
-
| Attribute | Value |
|
|
290
|
-
|-----------|-------|
|
|
291
|
-
| `readOnlyHint` | `false` |
|
|
292
|
-
| `destructiveHint` | `false` |
|
|
293
|
-
| `idempotentHint` | `false` |
|
|
294
|
-
| `openWorldHint` | `false` |
|
|
295
|
-
|
|
296
|
-
### Capability Advertisement
|
|
297
|
-
|
|
298
|
-
When `sampling` is present in the host's `initialize`
|
|
299
|
-
capabilities, the server advertises the `sampling`
|
|
300
|
-
capability in its own `initialize` response. When
|
|
301
|
-
`sampling` is absent, the capability is omitted from
|
|
302
|
-
the response and auto-capture is silently disabled.
|
|
303
|
-
|
|
304
|
-
## Response Flow
|
|
305
|
-
|
|
306
|
-
```
|
|
307
|
-
Agent uses kbdb tools
|
|
308
|
-
|
|
|
309
|
-
v
|
|
310
|
-
Tool call count reaches N
|
|
311
|
-
|
|
|
312
|
-
v
|
|
313
|
-
Server sends sampling/createMessage
|
|
314
|
-
|
|
|
315
|
-
v
|
|
316
|
-
Host LLM reviews conversation context
|
|
317
|
-
|
|
|
318
|
-
v
|
|
319
|
-
Returns {"items": [...]} or {"items": []}
|
|
320
|
-
|
|
|
321
|
-
v
|
|
322
|
-
Server deduplicates against existing sections
|
|
323
|
-
|
|
|
324
|
-
v
|
|
325
|
-
Server stores each new item via addSection
|
|
326
|
-
(with "auto-capture" tag appended)
|
|
327
|
-
|
|
|
328
|
-
v
|
|
329
|
-
notifications/message logged (info level)
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
When the host does not support sampling, or when
|
|
333
|
-
`enabled` is `false` and the trigger is automatic
|
|
334
|
-
(not the explicit tool), the flow terminates after
|
|
335
|
-
the trigger fires with a `debug`-level log and no
|
|
336
|
-
sampling request is sent.
|
|
337
|
-
|
|
338
|
-
## Tagging
|
|
339
|
-
|
|
340
|
-
Every section stored by auto-capture receives the
|
|
341
|
-
`auto-capture` tag appended to any tags the sampling
|
|
342
|
-
response supplied. This makes auto-captured sections
|
|
343
|
-
filterable and identifiable in search results and
|
|
344
|
-
integrity checks.
|
|
345
|
-
|
|
346
|
-
Example stored section tags when the sampling
|
|
347
|
-
response supplies `["architecture", "database"]`:
|
|
348
|
-
|
|
349
|
-
```
|
|
350
|
-
["architecture", "database", "auto-capture"]
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
## Design Constraints
|
|
354
|
-
|
|
355
|
-
- **Opt-in by default.** `enabled` is `false` in
|
|
356
|
-
`worker.toml` until explicitly set. No sections are
|
|
357
|
-
written without explicit configuration or the
|
|
358
|
-
`--auto-capture` flag.
|
|
359
|
-
- **Sampling required.** Auto-capture cannot function
|
|
360
|
-
without MCP sampling support. It is silently
|
|
361
|
-
disabled when the host omits the `sampling`
|
|
362
|
-
capability, with no error and no user-visible
|
|
363
|
-
change to other tools.
|
|
364
|
-
- **No recursion.** Auto-capture calls do not
|
|
365
|
-
increment the tool-call counter and do not trigger
|
|
366
|
-
nested reviews.
|
|
367
|
-
- **Agent override respected.** Sections removed by
|
|
368
|
-
an explicit `unlearn` call are not re-added by
|
|
369
|
-
auto-capture within the same session.
|
|
370
|
-
- **Rate-limited.** `max_captures_per_session`
|
|
371
|
-
prevents runaway storage from a misconfigured
|
|
372
|
-
trigger interval or a verbose LLM response.
|
|
373
|
-
- **Traceability.** Auto-captured sections always
|
|
374
|
-
carry the `auto-capture` tag so they can be
|
|
375
|
-
distinguished from manually learned content.
|
|
376
|
-
- **Dry-run available.** `dry_run` mode allows
|
|
377
|
-
operators to verify sampling output and tune
|
|
378
|
-
configuration before enabling writes.
|