@dikolab/kbdb 0.6.1 → 0.6.2
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 +33 -6
- package/README.md.bak +33 -6
- package/dist/README.md +33 -6
- package/dist/cli.cjs +662 -217
- package/dist/cli.cjs.map +3 -3
- package/dist/cli.mjs +662 -217
- package/dist/cli.mjs.map +3 -3
- package/dist/kbdb-worker.cjs +71 -12
- package/dist/kbdb-worker.cjs.map +3 -3
- package/dist/src/shared/cli/constants/recfile-field-maps.constant.d.ts +3 -1
- package/dist/src/shared/cli/functions/format-command-output.function.d.ts +0 -4
- package/dist/src/shared/cli/functions/format-command-text.function.d.ts +1 -0
- package/dist/src/shared/cli/functions/format-mcp-output.function.d.ts +5 -4
- package/dist/src/shared/cli/functions/format-output.function.d.ts +3 -7
- package/dist/src/shared/cli/functions/format-text-output.function.d.ts +3 -2
- package/dist/src/shared/cli/functions/run-agent-search.function.d.ts +13 -0
- package/dist/src/shared/cli/functions/run-check.function.d.ts +1 -1
- package/dist/src/shared/cli/functions/run-content.function.d.ts +18 -14
- package/dist/src/shared/cli/functions/run-learn.function.d.ts +6 -11
- package/dist/src/shared/cli/functions/run-skill-search.function.d.ts +13 -0
- package/dist/src/shared/cli/functions/wrap-mcp-envelope.function.d.ts +8 -0
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +6 -0
- package/dist/src/shared/cli/typings/learn-client.interface.d.ts +6 -2
- package/dist/src/shared/cli/typings/learn-result.model.d.ts +4 -0
- package/dist/src/shared/cli/typings/search-display.model.d.ts +2 -2
- package/dist/src/shared/mcp/constants/tool-agent-search.constant.d.ts +3 -0
- package/dist/src/shared/mcp/constants/tool-skill-search.constant.d.ts +3 -0
- package/dist/src/shared/mcp/functions/format-search-results.function.d.ts +25 -0
- package/dist/src/shared/mcp/functions/handle-agent-get.function.d.ts +4 -4
- package/dist/src/shared/mcp/functions/handle-agent-list.function.d.ts +3 -7
- package/dist/src/shared/mcp/functions/handle-agent-search.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-recall.function.d.ts +1 -1
- package/dist/src/shared/mcp/functions/handle-skill-search.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/handle-tool-search.function.d.ts +3 -3
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +2 -2
- package/dist/src/shared/mcp/typings/mcp-worker-client.interface.d.ts +2 -2
- package/dist/src/shared/worker-client/typings/add-section-result.model.d.ts +6 -12
- package/dist/src/shared/worker-client/typings/status-result.model.d.ts +2 -2
- package/dist/src/shared/worker-daemon/functions/strip-recall-by-depth.function.d.ts +22 -0
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/worker.mjs +71 -12
- package/dist/worker.mjs.map +3 -3
- package/package.json +1 -1
package/dist/kbdb-worker.cjs
CHANGED
|
@@ -1974,6 +1974,33 @@ function decodeAddSectionResult(bytes) {
|
|
|
1974
1974
|
};
|
|
1975
1975
|
}
|
|
1976
1976
|
|
|
1977
|
+
// src/shared/worker-daemon/functions/strip-recall-by-depth.function.ts
|
|
1978
|
+
function stripRecallByDepth(result, depth) {
|
|
1979
|
+
const base = {
|
|
1980
|
+
kbid: result.kbid,
|
|
1981
|
+
heading: result.heading,
|
|
1982
|
+
type: result.type,
|
|
1983
|
+
content: result.content,
|
|
1984
|
+
docids: result.docids
|
|
1985
|
+
};
|
|
1986
|
+
if (depth >= 1) {
|
|
1987
|
+
base["documents"] = result.documents;
|
|
1988
|
+
base["back_references"] = result.back_references;
|
|
1989
|
+
}
|
|
1990
|
+
if (depth >= 2) {
|
|
1991
|
+
base["siblings"] = result.siblings;
|
|
1992
|
+
base["references"] = result.references;
|
|
1993
|
+
}
|
|
1994
|
+
return base;
|
|
1995
|
+
}
|
|
1996
|
+
function applyRecallDepth(decoded, depth) {
|
|
1997
|
+
if (Array.isArray(decoded)) {
|
|
1998
|
+
const items = decoded.map((r) => stripRecallByDepth(r, depth));
|
|
1999
|
+
return items.length === 1 ? items[0] : items;
|
|
2000
|
+
}
|
|
2001
|
+
return stripRecallByDepth(decoded, depth);
|
|
2002
|
+
}
|
|
2003
|
+
|
|
1977
2004
|
// src/shared/worker-daemon/classes/worker-daemon.class.ts
|
|
1978
2005
|
var WASM_METHOD_MAP = {
|
|
1979
2006
|
search: "worker_search",
|
|
@@ -2561,13 +2588,16 @@ var WorkerDaemon = class {
|
|
|
2561
2588
|
const semanticType = sectionType === "text" || sectionType === "code" || sectionType === "image" ? sectionType : "text";
|
|
2562
2589
|
const typeName = sectionType !== semanticType ? sectionType : null;
|
|
2563
2590
|
const tags = Array.isArray(params["tags"]) ? params["tags"] : [];
|
|
2591
|
+
const title = params["title"] ?? null;
|
|
2592
|
+
const explicitDocid = params["docid"] ?? null;
|
|
2593
|
+
const docid = explicitDocid ?? (typeName && title ? `${typeName}:${title}` : null);
|
|
2564
2594
|
const input = {
|
|
2565
2595
|
sectionType: semanticType,
|
|
2566
2596
|
mimeType: params["mimeType"],
|
|
2567
2597
|
content: params["content"] ?? "",
|
|
2568
|
-
title
|
|
2598
|
+
title,
|
|
2569
2599
|
description: params["description"] ?? null,
|
|
2570
|
-
docid
|
|
2600
|
+
docid,
|
|
2571
2601
|
typeName,
|
|
2572
2602
|
sourcePath: typeof params["sourcePath"] === "string" ? params["sourcePath"] : void 0,
|
|
2573
2603
|
sourceMtime: typeof params["sourceMtime"] === "string" ? params["sourceMtime"] : void 0,
|
|
@@ -2584,9 +2614,9 @@ var WorkerDaemon = class {
|
|
|
2584
2614
|
(d) => ({ ...d, method: "jaccard" })
|
|
2585
2615
|
);
|
|
2586
2616
|
return {
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2617
|
+
items: [decoded.kbid],
|
|
2618
|
+
total: 1,
|
|
2619
|
+
offset: 0,
|
|
2590
2620
|
superseded: decoded.superseded,
|
|
2591
2621
|
warnings: decoded.warnings,
|
|
2592
2622
|
near_duplicates: nearDups
|
|
@@ -2633,6 +2663,7 @@ var WorkerDaemon = class {
|
|
|
2633
2663
|
const bytes = this.callWasmSync("worker_compose", encoded);
|
|
2634
2664
|
const output = decodeComposeOutput(bytes);
|
|
2635
2665
|
return {
|
|
2666
|
+
type: "text/markdown",
|
|
2636
2667
|
data: output.markdown,
|
|
2637
2668
|
total: Number(output.totalChars)
|
|
2638
2669
|
};
|
|
@@ -2700,7 +2731,8 @@ var WorkerDaemon = class {
|
|
|
2700
2731
|
const depth = Number(params["depth"] ?? 0);
|
|
2701
2732
|
const encoded = encodeRecallParams({ kbid, kbids, depth });
|
|
2702
2733
|
const bytes = this.callWasmSync("worker_recall", encoded);
|
|
2703
|
-
|
|
2734
|
+
const decoded = decodeRecallResult(bytes);
|
|
2735
|
+
return applyRecallDepth(decoded, depth);
|
|
2704
2736
|
}
|
|
2705
2737
|
// -- Zero-arg methods --
|
|
2706
2738
|
handleInvalidateAll() {
|
|
@@ -2712,17 +2744,44 @@ var WorkerDaemon = class {
|
|
|
2712
2744
|
const bytes = this.readReturnSlot();
|
|
2713
2745
|
const text = new TextDecoder().decode(bytes);
|
|
2714
2746
|
const kv = decodeKeyValueText(text);
|
|
2715
|
-
const
|
|
2716
|
-
|
|
2717
|
-
kv["
|
|
2718
|
-
|
|
2719
|
-
|
|
2747
|
+
const ctxPath = kv["ctx_path"] || kv["context_path"] || "";
|
|
2748
|
+
return {
|
|
2749
|
+
initialized: kv["initialized"] === "true",
|
|
2750
|
+
context_path: ctxPath,
|
|
2751
|
+
contextPath: ctxPath,
|
|
2752
|
+
document_count: Number(
|
|
2753
|
+
kv["document_count"] || kv["documents"] || 0
|
|
2754
|
+
),
|
|
2755
|
+
section_count: Number(
|
|
2756
|
+
kv["section_count"] || kv["sections"] || 0
|
|
2757
|
+
),
|
|
2758
|
+
wasm_memory_bytes: this._wasmModules?.memory.buffer.byteLength ?? 0
|
|
2759
|
+
};
|
|
2720
2760
|
}
|
|
2721
2761
|
handleIntegrityCheck() {
|
|
2722
2762
|
this.callWasmZeroArg("worker_check_integrity");
|
|
2723
2763
|
const bytes = this.readReturnSlot();
|
|
2724
2764
|
const text = new TextDecoder().decode(bytes);
|
|
2725
|
-
|
|
2765
|
+
const kv = decodeKeyValueText(text);
|
|
2766
|
+
const divContent = kv["divergent_content"] || "";
|
|
2767
|
+
const errors = [];
|
|
2768
|
+
if (divContent) {
|
|
2769
|
+
errors.push({
|
|
2770
|
+
type: "divergent_content",
|
|
2771
|
+
entity: divContent,
|
|
2772
|
+
detail: "sections share source key with different content"
|
|
2773
|
+
});
|
|
2774
|
+
}
|
|
2775
|
+
return {
|
|
2776
|
+
type: "integrity",
|
|
2777
|
+
ok: kv["ok"] === "true",
|
|
2778
|
+
sections_checked: Number(kv["sections_checked"] || 0),
|
|
2779
|
+
documents_checked: Number(kv["documents_checked"] || 0),
|
|
2780
|
+
references_checked: Number(kv["references_checked"] || 0),
|
|
2781
|
+
elapsed_ms: Number(kv["elapsed_ms"] || 0),
|
|
2782
|
+
errors,
|
|
2783
|
+
divergent_content: divContent
|
|
2784
|
+
};
|
|
2726
2785
|
}
|
|
2727
2786
|
handleGc() {
|
|
2728
2787
|
const start = Date.now();
|