@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
|
@@ -5,7 +5,10 @@ declare namespace wasm_bindgen {
|
|
|
5
5
|
/**
|
|
6
6
|
* Adds a section. `ptr`/`len` point to an encoded `AddSectionParams`.
|
|
7
7
|
*
|
|
8
|
-
* On success: writes encoded
|
|
8
|
+
* On success: writes an encoded `AddSectionResult` to the return slot and
|
|
9
|
+
* returns 0. When `params.replace` is true and a section with the same
|
|
10
|
+
* `source_key` exists, the superseded section's index entries are removed
|
|
11
|
+
* and the returned `AddSectionResult.superseded` is set to its kbid.
|
|
9
12
|
* On error: writes error message to return slot, returns -1.
|
|
10
13
|
*/
|
|
11
14
|
export function db_add_section(ptr: number, len: number): number;
|
|
@@ -42,6 +45,23 @@ declare namespace wasm_bindgen {
|
|
|
42
45
|
*/
|
|
43
46
|
export function db_check_version(ptr: number, len: number): number;
|
|
44
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Exports the database to a target directory.
|
|
50
|
+
*
|
|
51
|
+
* `ptr`/`len` point to a UTF-8 string containing the target path.
|
|
52
|
+
*
|
|
53
|
+
* Copies `sections/`, `documents/`, and `catalog.toml` to the target.
|
|
54
|
+
* Indexes are not copied because they can be rebuilt from the data.
|
|
55
|
+
*
|
|
56
|
+
* The target path may be absolute or relative. It is an external output
|
|
57
|
+
* destination, not a database-internal path, so no path validation is
|
|
58
|
+
* applied to it.
|
|
59
|
+
*
|
|
60
|
+
* On success a summary string is placed in the return slot:
|
|
61
|
+
* `path={target}\nsections_exported={N}\ndocuments_exported={M}`
|
|
62
|
+
*/
|
|
63
|
+
export function db_export(ptr: number, len: number): number;
|
|
64
|
+
|
|
45
65
|
/**
|
|
46
66
|
* Runs garbage collection. Returns 0 on success.
|
|
47
67
|
* On success a summary string is placed in the return slot.
|
|
@@ -344,6 +364,10 @@ declare namespace wasm_bindgen {
|
|
|
344
364
|
|
|
345
365
|
/**
|
|
346
366
|
* Adds a section. Returns 0 on success, -1 on error.
|
|
367
|
+
*
|
|
368
|
+
* On success the return slot holds the binary-encoded `AddSectionResult`
|
|
369
|
+
* (kbid + indexed_terms_count + elapsed_ms + superseded + warnings +
|
|
370
|
+
* near_duplicates) using the `Encode` trait wire format.
|
|
347
371
|
*/
|
|
348
372
|
export function worker_add_section(ptr: number, len: number): number;
|
|
349
373
|
|
|
@@ -365,6 +389,19 @@ declare namespace wasm_bindgen {
|
|
|
365
389
|
*/
|
|
366
390
|
export function worker_compose(ptr: number, len: number): number;
|
|
367
391
|
|
|
392
|
+
/**
|
|
393
|
+
* Exports the database to a target directory.
|
|
394
|
+
*
|
|
395
|
+
* `ptr`/`len` point to a UTF-8 string containing the target path.
|
|
396
|
+
*
|
|
397
|
+
* Delegates directly to `db_export` in `kbdb-fs-database`. Does not require
|
|
398
|
+
* the worker to have been initialised because the target path is given
|
|
399
|
+
* explicitly by the caller.
|
|
400
|
+
*
|
|
401
|
+
* Returns 0 on success, -1 on error (message in return slot).
|
|
402
|
+
*/
|
|
403
|
+
export function worker_export(ptr: number, len: number): number;
|
|
404
|
+
|
|
368
405
|
/**
|
|
369
406
|
* Runs garbage collection and invalidates all cache entries.
|
|
370
407
|
*
|
|
@@ -444,6 +481,14 @@ declare namespace wasm_bindgen {
|
|
|
444
481
|
|
|
445
482
|
/**
|
|
446
483
|
* Rebuilds all database indexes.
|
|
484
|
+
*
|
|
485
|
+
* First clears the existing inverted, positional, and reference indexes via
|
|
486
|
+
* `db_rebuild_index`. Then re-tokenizes every stored section and re-populates
|
|
487
|
+
* the indexes via `rebuild_all_section_indexes`.
|
|
488
|
+
*
|
|
489
|
+
* On success the return slot holds the number of reindexed sections as a
|
|
490
|
+
* little-endian `u32`, and 0 is returned. On error -1 is returned and an
|
|
491
|
+
* error message is in the return slot.
|
|
447
492
|
*/
|
|
448
493
|
export function worker_rebuild_indexes(): number;
|
|
449
494
|
|
|
@@ -525,6 +570,7 @@ declare interface InitOutput {
|
|
|
525
570
|
readonly worker_add_section: (a: number, b: number) => number;
|
|
526
571
|
readonly worker_check_integrity: () => number;
|
|
527
572
|
readonly worker_compose: (a: number, b: number) => number;
|
|
573
|
+
readonly worker_export: (a: number, b: number) => number;
|
|
528
574
|
readonly worker_garbage_collect: () => number;
|
|
529
575
|
readonly worker_get_result: (a: number) => number;
|
|
530
576
|
readonly worker_group_sections: (a: number, b: number) => number;
|
|
@@ -565,6 +611,7 @@ declare interface InitOutput {
|
|
|
565
611
|
readonly db_add_to_index: (a: number, b: number) => number;
|
|
566
612
|
readonly db_check_integrity: (a: number, b: number) => number;
|
|
567
613
|
readonly db_check_version: (a: number, b: number) => number;
|
|
614
|
+
readonly db_export: (a: number, b: number) => number;
|
|
568
615
|
readonly db_gc: (a: number, b: number) => number;
|
|
569
616
|
readonly db_get_back_refs: (a: number, b: number) => number;
|
|
570
617
|
readonly db_get_forward_refs: (a: number, b: number) => number;
|
|
@@ -7,7 +7,10 @@ let wasm_bindgen = (function(exports) {
|
|
|
7
7
|
/**
|
|
8
8
|
* Adds a section. `ptr`/`len` point to an encoded `AddSectionParams`.
|
|
9
9
|
*
|
|
10
|
-
* On success: writes encoded
|
|
10
|
+
* On success: writes an encoded `AddSectionResult` to the return slot and
|
|
11
|
+
* returns 0. When `params.replace` is true and a section with the same
|
|
12
|
+
* `source_key` exists, the superseded section's index entries are removed
|
|
13
|
+
* and the returned `AddSectionResult.superseded` is set to its kbid.
|
|
11
14
|
* On error: writes error message to return slot, returns -1.
|
|
12
15
|
* @param {number} ptr
|
|
13
16
|
* @param {number} len
|
|
@@ -72,6 +75,30 @@ let wasm_bindgen = (function(exports) {
|
|
|
72
75
|
}
|
|
73
76
|
exports.db_check_version = db_check_version;
|
|
74
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Exports the database to a target directory.
|
|
80
|
+
*
|
|
81
|
+
* `ptr`/`len` point to a UTF-8 string containing the target path.
|
|
82
|
+
*
|
|
83
|
+
* Copies `sections/`, `documents/`, and `catalog.toml` to the target.
|
|
84
|
+
* Indexes are not copied because they can be rebuilt from the data.
|
|
85
|
+
*
|
|
86
|
+
* The target path may be absolute or relative. It is an external output
|
|
87
|
+
* destination, not a database-internal path, so no path validation is
|
|
88
|
+
* applied to it.
|
|
89
|
+
*
|
|
90
|
+
* On success a summary string is placed in the return slot:
|
|
91
|
+
* `path={target}\nsections_exported={N}\ndocuments_exported={M}`
|
|
92
|
+
* @param {number} ptr
|
|
93
|
+
* @param {number} len
|
|
94
|
+
* @returns {number}
|
|
95
|
+
*/
|
|
96
|
+
function db_export(ptr, len) {
|
|
97
|
+
const ret = wasm.db_export(ptr, len);
|
|
98
|
+
return ret;
|
|
99
|
+
}
|
|
100
|
+
exports.db_export = db_export;
|
|
101
|
+
|
|
75
102
|
/**
|
|
76
103
|
* Runs garbage collection. Returns 0 on success.
|
|
77
104
|
* On success a summary string is placed in the return slot.
|
|
@@ -644,6 +671,10 @@ let wasm_bindgen = (function(exports) {
|
|
|
644
671
|
|
|
645
672
|
/**
|
|
646
673
|
* Adds a section. Returns 0 on success, -1 on error.
|
|
674
|
+
*
|
|
675
|
+
* On success the return slot holds the binary-encoded `AddSectionResult`
|
|
676
|
+
* (kbid + indexed_terms_count + elapsed_ms + superseded + warnings +
|
|
677
|
+
* near_duplicates) using the `Encode` trait wire format.
|
|
647
678
|
* @param {number} ptr
|
|
648
679
|
* @param {number} len
|
|
649
680
|
* @returns {number}
|
|
@@ -684,6 +715,26 @@ let wasm_bindgen = (function(exports) {
|
|
|
684
715
|
}
|
|
685
716
|
exports.worker_compose = worker_compose;
|
|
686
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Exports the database to a target directory.
|
|
720
|
+
*
|
|
721
|
+
* `ptr`/`len` point to a UTF-8 string containing the target path.
|
|
722
|
+
*
|
|
723
|
+
* Delegates directly to `db_export` in `kbdb-fs-database`. Does not require
|
|
724
|
+
* the worker to have been initialised because the target path is given
|
|
725
|
+
* explicitly by the caller.
|
|
726
|
+
*
|
|
727
|
+
* Returns 0 on success, -1 on error (message in return slot).
|
|
728
|
+
* @param {number} ptr
|
|
729
|
+
* @param {number} len
|
|
730
|
+
* @returns {number}
|
|
731
|
+
*/
|
|
732
|
+
function worker_export(ptr, len) {
|
|
733
|
+
const ret = wasm.worker_export(ptr, len);
|
|
734
|
+
return ret;
|
|
735
|
+
}
|
|
736
|
+
exports.worker_export = worker_export;
|
|
737
|
+
|
|
687
738
|
/**
|
|
688
739
|
* Runs garbage collection and invalidates all cache entries.
|
|
689
740
|
*
|
|
@@ -835,6 +886,14 @@ let wasm_bindgen = (function(exports) {
|
|
|
835
886
|
|
|
836
887
|
/**
|
|
837
888
|
* Rebuilds all database indexes.
|
|
889
|
+
*
|
|
890
|
+
* First clears the existing inverted, positional, and reference indexes via
|
|
891
|
+
* `db_rebuild_index`. Then re-tokenizes every stored section and re-populates
|
|
892
|
+
* the indexes via `rebuild_all_section_indexes`.
|
|
893
|
+
*
|
|
894
|
+
* On success the return slot holds the number of reindexed sections as a
|
|
895
|
+
* little-endian `u32`, and 0 is returned. On error -1 is returned and an
|
|
896
|
+
* error message is in the return slot.
|
|
838
897
|
* @returns {number}
|
|
839
898
|
*/
|
|
840
899
|
function worker_rebuild_indexes() {
|
|
Binary file
|
|
@@ -8,6 +8,7 @@ export const set_return: (a: number, b: number) => void;
|
|
|
8
8
|
export const worker_add_section: (a: number, b: number) => number;
|
|
9
9
|
export const worker_check_integrity: () => number;
|
|
10
10
|
export const worker_compose: (a: number, b: number) => number;
|
|
11
|
+
export const worker_export: (a: number, b: number) => number;
|
|
11
12
|
export const worker_garbage_collect: () => number;
|
|
12
13
|
export const worker_get_result: (a: number) => number;
|
|
13
14
|
export const worker_group_sections: (a: number, b: number) => number;
|
|
@@ -48,6 +49,7 @@ export const db_add_section: (a: number, b: number) => number;
|
|
|
48
49
|
export const db_add_to_index: (a: number, b: number) => number;
|
|
49
50
|
export const db_check_integrity: (a: number, b: number) => number;
|
|
50
51
|
export const db_check_version: (a: number, b: number) => number;
|
|
52
|
+
export const db_export: (a: number, b: number) => number;
|
|
51
53
|
export const db_gc: (a: number, b: number) => number;
|
|
52
54
|
export const db_get_back_refs: (a: number, b: number) => number;
|
|
53
55
|
export const db_get_forward_refs: (a: number, b: number) => number;
|
|
Binary file
|