@dikolab/kbdb 0.3.1 → 0.4.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 +108 -126
- package/dist/chunk-BJPSPNGX.mjs +223 -0
- package/dist/chunk-BJPSPNGX.mjs.map +7 -0
- package/dist/cli.cjs +956 -319
- package/dist/cli.cjs.map +4 -4
- package/dist/cli.d.ts +9 -0
- package/dist/cli.mjs +840 -321
- package/dist/cli.mjs.map +4 -4
- package/dist/kbdb-worker.cjs +714 -94
- package/dist/kbdb-worker.cjs.map +4 -4
- package/dist/mod.cjs +122 -16
- package/dist/mod.cjs.map +3 -3
- package/dist/mod.d.ts +23 -2
- package/dist/mod.mjs +121 -16
- package/dist/mod.mjs.map +3 -3
- package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +2 -1
- package/dist/src/shared/cli/functions/find-db.function.d.ts +7 -8
- package/dist/src/shared/cli/functions/handle-mcp.function.d.ts +1 -1
- package/dist/src/shared/cli/functions/parse-args.function.d.ts +4 -3
- package/dist/src/shared/cli/functions/resolve-kbid-prefix.function.d.ts +27 -0
- package/dist/src/shared/cli/functions/resolve-raw-db-path.function.d.ts +10 -0
- package/dist/src/shared/cli/functions/run-cli.function.d.ts +3 -1
- package/dist/src/shared/cli/functions/run-content.function.d.ts +8 -3
- package/dist/src/shared/cli/functions/run-import.function.d.ts +27 -0
- package/dist/src/shared/cli/functions/run-recall.function.d.ts +10 -4
- package/dist/src/shared/cli/functions/run-search.function.d.ts +7 -0
- package/dist/src/shared/cli/functions/run-unlearn.function.d.ts +9 -4
- package/dist/src/shared/cli/functions/run-worker-restart.function.d.ts +11 -0
- package/dist/src/shared/cli/functions/run-worker-stop.function.d.ts +11 -0
- package/dist/src/shared/cli/index.d.ts +2 -0
- package/dist/src/shared/cli/typings/cli-deps.interface.d.ts +4 -1
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +17 -0
- package/dist/src/shared/cli/typings/dispatch-client.type.d.ts +2 -1
- package/dist/src/shared/cli/typings/search-display.model.d.ts +6 -0
- package/dist/src/shared/embedding/classes/api-embedding-provider.class.d.ts +33 -0
- package/dist/src/shared/embedding/classes/onnx-embedding-provider.class.d.ts +33 -0
- package/dist/src/shared/embedding/functions/append-vector-entry.function.d.ts +14 -0
- package/dist/src/shared/embedding/functions/create-embedding-provider.function.d.ts +12 -0
- package/dist/src/shared/embedding/functions/detect-stale-vectors.function.d.ts +16 -0
- package/dist/src/shared/embedding/functions/parse-api-embedding-response.function.d.ts +11 -0
- package/dist/src/shared/embedding/functions/rebuild-vectors.function.d.ts +15 -0
- package/dist/src/shared/embedding/functions/scan-semantic-contradictions.function.d.ts +13 -0
- package/dist/src/shared/embedding/index.d.ts +7 -0
- package/dist/src/shared/embedding/typings/semantic-contradiction.model.d.ts +21 -0
- package/dist/src/shared/embedding/typings/stale-vectors-report.model.d.ts +16 -0
- package/dist/src/shared/mcp/classes/mcp-server.class.d.ts +22 -2
- package/dist/src/shared/mcp/functions/create-mcp-server.function.d.ts +6 -1
- package/dist/src/shared/mcp/functions/has-sampling-capability.function.d.ts +8 -0
- package/dist/src/shared/mcp/functions/run-auto-capture.function.d.ts +26 -0
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +2 -0
- package/dist/src/shared/mcp/typings/mcp-integrity-check-result.model.d.ts +24 -0
- package/dist/src/shared/mcp/typings/mcp-worker-client.interface.d.ts +3 -1
- package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
- package/dist/src/shared/wasm-codec/typings/paged-search-result.model.d.ts +2 -0
- package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +31 -1
- package/dist/src/shared/worker-client/constants/request-timeout.constant.d.ts +2 -0
- package/dist/src/shared/worker-client/constants/retry-defaults.constant.d.ts +2 -0
- package/dist/src/shared/worker-client/functions/get-or-create-client.function.d.ts +20 -0
- package/dist/src/shared/worker-client/functions/retry-on-timeout.function.d.ts +17 -0
- package/dist/src/shared/worker-client/index.d.ts +4 -1
- package/dist/src/shared/worker-client/typings/import-result.model.d.ts +16 -0
- package/dist/src/shared/worker-client/typings/integrity-check-result.model.d.ts +24 -0
- package/dist/src/shared/worker-client/typings/search-params.model.d.ts +4 -0
- package/dist/src/shared/worker-client/typings/search-result.model.d.ts +6 -0
- package/dist/src/shared/worker-client/typings/worker-client-options.interface.d.ts +7 -0
- package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +5 -0
- package/dist/src/shared/worker-daemon/functions/create-ipc-server.function.d.ts +11 -11
- package/dist/src/shared/worker-daemon/functions/embed-after-learn.function.d.ts +13 -0
- package/dist/src/shared/worker-daemon/functions/handle-hybrid-search.function.d.ts +44 -0
- package/dist/src/shared/worker-daemon/functions/handle-import.function.d.ts +14 -0
- package/dist/src/shared/worker-daemon/functions/handle-read-ops.function.d.ts +7 -1
- package/dist/src/shared/worker-daemon/functions/handle-write-ops.function.d.ts +9 -4
- package/dist/src/shared/worker-daemon/typings/handler-context.interface.d.ts +3 -0
- package/dist/wasm/fs-database/kbdb_fs_database.d.ts +16 -85
- package/dist/wasm/fs-database/kbdb_fs_database.js +16 -85
- package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/dist/wasm/kb-worker/kbdb_worker.d.ts +20 -115
- package/dist/wasm/kb-worker/kbdb_worker.js +20 -115
- package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
- package/dist/worker.d.ts +8 -0
- package/dist/worker.mjs +606 -102
- package/dist/worker.mjs.map +4 -4
- package/docs/details/README.md +4 -0
- package/docs/details/agent-tooling.md +122 -0
- package/docs/details/cli.md +78 -12
- package/docs/details/knowledge-base.md +173 -0
- package/docs/details/library-api.md +42 -2
- package/docs/details/mcp-server.md +39 -8
- package/docs/details/search-and-ranking.md +56 -0
- package/docs/goals/cli.md +110 -34
- package/docs/goals/mcp.md +22 -19
- package/docs/goals/query-parser.md +8 -0
- package/docs/goals/worker-client.md +62 -1
- package/docs/goals/worker-daemon.md +52 -10
- package/docs/modules/typescript/cli.md +1 -1
- package/docs/modules/typescript/shared/cli/functions.md +116 -13
- package/docs/modules/typescript/shared/cli/module.md +33 -20
- package/docs/modules/typescript/shared/cli/typings.md +4 -0
- package/docs/modules/typescript/shared/embedding/functions.md +104 -25
- package/docs/modules/typescript/shared/mcp/module.md +1 -1
- package/docs/modules/typescript/shared/mcp/typings.md +8 -1
- package/docs/modules/typescript/shared/worker-client/module.md +9 -1
- package/docs/modules/typescript/shared/worker-client/typings.md +3 -0
- package/docs/modules/typescript/shared/worker-daemon/module.md +6 -3
- package/docs/overview.md +43 -22
- package/docs/release-notes/0.3.1.md +10 -0
- package/docs/release-notes/0.3.2.md +64 -0
- package/docs/release-notes/0.4.0.md +80 -0
- package/docs/release-notes/README.md +2 -0
- package/mod.ts +33 -15
- package/package.json +11 -10
- package/dist/chunk-JG2UCKLI.mjs +0 -95
- package/dist/chunk-JG2UCKLI.mjs.map +0 -7
- package/src/cli.ts +0 -71
- package/src/shared/auto-capture/classes/auto-capture-controller.class.ts +0 -62
- package/src/shared/auto-capture/constants/auto-capture-defaults.constant.ts +0 -15
- package/src/shared/auto-capture/functions/build-capture-prompt.function.ts +0 -27
- package/src/shared/auto-capture/functions/evaluate-trigger.function.ts +0 -50
- package/src/shared/auto-capture/index.ts +0 -7
- package/src/shared/auto-capture/typings/auto-capture-config.interface.ts +0 -13
- package/src/shared/auto-capture/typings/auto-capture-state.interface.ts +0 -13
- package/src/shared/auto-capture/typings/auto-capture-trigger.interface.ts +0 -7
- package/src/shared/cli/constants/defaults.constant.ts +0 -19
- package/src/shared/cli/constants/global-help.constant.ts +0 -73
- package/src/shared/cli/constants/help-text.constant.ts +0 -4
- package/src/shared/cli/constants/leaf-help.constant.ts +0 -219
- package/src/shared/cli/constants/memory-protocol-body.constant.ts +0 -39
- package/src/shared/cli/constants/query-guidance-body.constant.ts +0 -37
- package/src/shared/cli/constants/subcommand-help.constant.ts +0 -195
- package/src/shared/cli/functions/collect-files.function.ts +0 -55
- package/src/shared/cli/functions/compute-section-kbid.function.ts +0 -49
- package/src/shared/cli/functions/dispatch-command.function.ts +0 -390
- package/src/shared/cli/functions/ensure-db.function.ts +0 -21
- package/src/shared/cli/functions/error-to-message.function.ts +0 -9
- package/src/shared/cli/functions/find-db.function.ts +0 -20
- package/src/shared/cli/functions/format-mcp-output.function.ts +0 -41
- package/src/shared/cli/functions/format-output.function.ts +0 -95
- package/src/shared/cli/functions/format-text-output.function.ts +0 -42
- package/src/shared/cli/functions/generate-group-help.function.ts +0 -41
- package/src/shared/cli/functions/generate-help.function.ts +0 -654
- package/src/shared/cli/functions/handle-data-command.function.ts +0 -67
- package/src/shared/cli/functions/handle-mcp.function.ts +0 -56
- package/src/shared/cli/functions/handle-migrate.function.ts +0 -64
- package/src/shared/cli/functions/hydrate-search-previews.function.ts +0 -29
- package/src/shared/cli/functions/install-default-skills.function.ts +0 -296
- package/src/shared/cli/functions/is-stdin-tty.function.ts +0 -12
- package/src/shared/cli/functions/parse-args.function.ts +0 -156
- package/src/shared/cli/functions/prompt-user.function.ts +0 -36
- package/src/shared/cli/functions/resolve-skill-names.function.ts +0 -43
- package/src/shared/cli/functions/run-agent-create.function.ts +0 -114
- package/src/shared/cli/functions/run-agent-delete.function.ts +0 -47
- package/src/shared/cli/functions/run-agent-get.function.ts +0 -166
- package/src/shared/cli/functions/run-agent-list.function.ts +0 -58
- package/src/shared/cli/functions/run-check.function.ts +0 -159
- package/src/shared/cli/functions/run-cli.function.ts +0 -299
- package/src/shared/cli/functions/run-content.function.ts +0 -47
- package/src/shared/cli/functions/run-db-init.function.ts +0 -44
- package/src/shared/cli/functions/run-db-migrate.function.ts +0 -40
- package/src/shared/cli/functions/run-export.function.ts +0 -40
- package/src/shared/cli/functions/run-gc.function.ts +0 -51
- package/src/shared/cli/functions/run-init.function.ts +0 -93
- package/src/shared/cli/functions/run-learn.function.ts +0 -223
- package/src/shared/cli/functions/run-migrate.function.ts +0 -85
- package/src/shared/cli/functions/run-rebuild.function.ts +0 -47
- package/src/shared/cli/functions/run-recall.function.ts +0 -66
- package/src/shared/cli/functions/run-search.function.ts +0 -133
- package/src/shared/cli/functions/run-skill-delete.function.ts +0 -47
- package/src/shared/cli/functions/run-skill-get.function.ts +0 -90
- package/src/shared/cli/functions/run-skill-learn.function.ts +0 -70
- package/src/shared/cli/functions/run-skill-list.function.ts +0 -74
- package/src/shared/cli/functions/run-status.function.ts +0 -29
- package/src/shared/cli/functions/run-unlearn.function.ts +0 -58
- package/src/shared/cli/functions/version-gate.function.ts +0 -44
- package/src/shared/cli/functions/wrap-command.function.ts +0 -34
- package/src/shared/cli/index.ts +0 -55
- package/src/shared/cli/typings/agent-create-client.interface.ts +0 -47
- package/src/shared/cli/typings/agent-get-client.interface.ts +0 -39
- package/src/shared/cli/typings/check-client.interface.ts +0 -66
- package/src/shared/cli/typings/cli-deps.interface.ts +0 -54
- package/src/shared/cli/typings/cli-options.interface.ts +0 -72
- package/src/shared/cli/typings/command-result.model.ts +0 -15
- package/src/shared/cli/typings/disconnectable-client.interface.ts +0 -29
- package/src/shared/cli/typings/dispatch-client.type.ts +0 -46
- package/src/shared/cli/typings/learn-client.interface.ts +0 -53
- package/src/shared/cli/typings/learn-io.interface.ts +0 -5
- package/src/shared/cli/typings/learn-result.model.ts +0 -27
- package/src/shared/cli/typings/search-client.interface.ts +0 -73
- package/src/shared/cli/typings/search-display.model.ts +0 -54
- package/src/shared/dir-resolver/functions/join-path.function.ts +0 -13
- package/src/shared/dir-resolver/functions/resolve-base-dir.function.ts +0 -25
- package/src/shared/dir-resolver/functions/resolve-wasm-dir.function.ts +0 -5
- package/src/shared/dir-resolver/functions/resolve-worker-script.function.ts +0 -13
- package/src/shared/dir-resolver/index.ts +0 -11
- package/src/shared/dir-resolver/typings/base-dir.interface.ts +0 -4
- package/src/shared/embedding/classes/null-embedding-provider.class.ts +0 -29
- package/src/shared/embedding/constants/near-duplicate-thresholds.constant.ts +0 -17
- package/src/shared/embedding/functions/build-vector-index.function.ts +0 -79
- package/src/shared/embedding/functions/cosine-similarity.function.ts +0 -31
- package/src/shared/embedding/functions/detect-near-duplicates.function.ts +0 -69
- package/src/shared/embedding/functions/jaccard-coefficient.function.ts +0 -26
- package/src/shared/embedding/functions/read-vector-index-meta.function.ts +0 -44
- package/src/shared/embedding/functions/rrf-fuse.function.ts +0 -33
- package/src/shared/embedding/functions/search-vectors.function.ts +0 -59
- package/src/shared/embedding/index.ts +0 -20
- package/src/shared/embedding/typings/embedding-config.interface.ts +0 -23
- package/src/shared/embedding/typings/embedding-provider.interface.ts +0 -25
- package/src/shared/embedding/typings/near-duplicate-candidate.model.ts +0 -25
- package/src/shared/embedding/typings/near-duplicate-result.model.ts +0 -26
- package/src/shared/embedding/typings/vector-index-entry.model.ts +0 -13
- package/src/shared/embedding/typings/vector-index-meta.model.ts +0 -14
- package/src/shared/embedding/typings/vector-search-result.model.ts +0 -8
- package/src/shared/hash/functions/compute-sha256.ts +0 -17
- package/src/shared/hash/index.ts +0 -1
- package/src/shared/mcp/classes/mcp-server.class.ts +0 -480
- package/src/shared/mcp/constants/mcp-error-codes.constant.ts +0 -30
- package/src/shared/mcp/constants/tool-agent-create.constant.ts +0 -39
- package/src/shared/mcp/constants/tool-agent-delete.constant.ts +0 -26
- package/src/shared/mcp/constants/tool-agent-get.constant.ts +0 -24
- package/src/shared/mcp/constants/tool-agent-list.constant.ts +0 -18
- package/src/shared/mcp/constants/tool-auto-capture-review.constant.ts +0 -32
- package/src/shared/mcp/constants/tool-check.constant.ts +0 -21
- package/src/shared/mcp/constants/tool-content.constant.ts +0 -29
- package/src/shared/mcp/constants/tool-export.constant.ts +0 -27
- package/src/shared/mcp/constants/tool-gc.constant.ts +0 -21
- package/src/shared/mcp/constants/tool-learn.constant.ts +0 -58
- package/src/shared/mcp/constants/tool-rebuild.constant.ts +0 -21
- package/src/shared/mcp/constants/tool-recall.constant.ts +0 -36
- package/src/shared/mcp/constants/tool-retrieve.constant.ts +0 -31
- package/src/shared/mcp/constants/tool-search.constant.ts +0 -51
- package/src/shared/mcp/constants/tool-skill-delete.constant.ts +0 -24
- package/src/shared/mcp/constants/tool-skill-get.constant.ts +0 -27
- package/src/shared/mcp/constants/tool-skill-learn.constant.ts +0 -37
- package/src/shared/mcp/constants/tool-skill-list.constant.ts +0 -18
- package/src/shared/mcp/constants/tool-status.constant.ts +0 -20
- package/src/shared/mcp/constants/tool-unlearn.constant.ts +0 -25
- package/src/shared/mcp/functions/as-boolean-or-undefined.function.ts +0 -11
- package/src/shared/mcp/functions/as-string-array-or-undefined.function.ts +0 -17
- package/src/shared/mcp/functions/as-string-array.function.ts +0 -15
- package/src/shared/mcp/functions/as-string.function.ts +0 -10
- package/src/shared/mcp/functions/build-skills-text.function.ts +0 -43
- package/src/shared/mcp/functions/create-mcp-server.function.ts +0 -14
- package/src/shared/mcp/functions/create-prompt-definitions.function.ts +0 -102
- package/src/shared/mcp/functions/create-resource-templates.function.ts +0 -23
- package/src/shared/mcp/functions/create-tool-definitions.function.ts +0 -530
- package/src/shared/mcp/functions/extract-skill-arguments.function.ts +0 -27
- package/src/shared/mcp/functions/handle-agent-create.function.ts +0 -116
- package/src/shared/mcp/functions/handle-agent-delete.function.ts +0 -50
- package/src/shared/mcp/functions/handle-agent-get.function.ts +0 -160
- package/src/shared/mcp/functions/handle-agent-list.function.ts +0 -50
- package/src/shared/mcp/functions/handle-agent-prompt.function.ts +0 -68
- package/src/shared/mcp/functions/handle-completion.function.ts +0 -114
- package/src/shared/mcp/functions/handle-mcp-request.function.ts +0 -202
- package/src/shared/mcp/functions/handle-prompt-get.function.ts +0 -220
- package/src/shared/mcp/functions/handle-recall.function.ts +0 -66
- package/src/shared/mcp/functions/handle-resource-read.function.ts +0 -56
- package/src/shared/mcp/functions/handle-roots-list.function.ts +0 -29
- package/src/shared/mcp/functions/handle-skill-prompt.function.ts +0 -44
- package/src/shared/mcp/functions/handle-tool-auto-capture-review.function.ts +0 -24
- package/src/shared/mcp/functions/handle-tool-call.function.ts +0 -560
- package/src/shared/mcp/functions/handle-tool-check.function.ts +0 -21
- package/src/shared/mcp/functions/handle-tool-content.function.ts +0 -23
- package/src/shared/mcp/functions/handle-tool-export.function.ts +0 -25
- package/src/shared/mcp/functions/handle-tool-gc.function.ts +0 -21
- package/src/shared/mcp/functions/handle-tool-learn.function.ts +0 -69
- package/src/shared/mcp/functions/handle-tool-rebuild.function.ts +0 -21
- package/src/shared/mcp/functions/handle-tool-retrieve.function.ts +0 -40
- package/src/shared/mcp/functions/handle-tool-search.function.ts +0 -47
- package/src/shared/mcp/functions/handle-tool-skill-delete.function.ts +0 -34
- package/src/shared/mcp/functions/handle-tool-skill-get.function.ts +0 -59
- package/src/shared/mcp/functions/handle-tool-skill-learn.function.ts +0 -61
- package/src/shared/mcp/functions/handle-tool-skill-list.function.ts +0 -39
- package/src/shared/mcp/functions/handle-tool-status.function.ts +0 -21
- package/src/shared/mcp/functions/handle-tool-unlearn.function.ts +0 -24
- package/src/shared/mcp/functions/parse-agent-meta.function.ts +0 -27
- package/src/shared/mcp/functions/parse-skill-arguments.function.ts +0 -36
- package/src/shared/mcp/functions/parse-skill-content.function.ts +0 -38
- package/src/shared/mcp/functions/read-agent-meta.function.ts +0 -41
- package/src/shared/mcp/functions/resolve-skill-refs.function.ts +0 -50
- package/src/shared/mcp/functions/run-startup-health-check.function.ts +0 -34
- package/src/shared/mcp/functions/serialize-skill-content.function.ts +0 -12
- package/src/shared/mcp/functions/should-emit-log.function.ts +0 -38
- package/src/shared/mcp/index.ts +0 -28
- package/src/shared/mcp/typings/agent-types.interface.ts +0 -39
- package/src/shared/mcp/typings/log-types.interface.ts +0 -26
- package/src/shared/mcp/typings/mcp-capabilities.interface.ts +0 -16
- package/src/shared/mcp/typings/mcp-client.interface.ts +0 -317
- package/src/shared/mcp/typings/mcp-completion.interface.ts +0 -45
- package/src/shared/mcp/typings/mcp-content-result.model.ts +0 -9
- package/src/shared/mcp/typings/mcp-export-result.model.ts +0 -11
- package/src/shared/mcp/typings/mcp-gc-result.model.ts +0 -15
- package/src/shared/mcp/typings/mcp-integrity-check-result.model.ts +0 -17
- package/src/shared/mcp/typings/mcp-integrity-error.model.ts +0 -15
- package/src/shared/mcp/typings/mcp-notification.interface.ts +0 -9
- package/src/shared/mcp/typings/mcp-rebuild-result.model.ts +0 -9
- package/src/shared/mcp/typings/mcp-request.interface.ts +0 -11
- package/src/shared/mcp/typings/mcp-resource-result.interface.ts +0 -12
- package/src/shared/mcp/typings/mcp-resource-template.interface.ts +0 -11
- package/src/shared/mcp/typings/mcp-response.interface.ts +0 -18
- package/src/shared/mcp/typings/mcp-server-info.interface.ts +0 -7
- package/src/shared/mcp/typings/mcp-server-state.interface.ts +0 -17
- package/src/shared/mcp/typings/mcp-tool-annotations.interface.ts +0 -32
- package/src/shared/mcp/typings/mcp-tool-definition.interface.ts +0 -16
- package/src/shared/mcp/typings/mcp-tool-result.interface.ts +0 -19
- package/src/shared/mcp/typings/mcp-types.interface.ts +0 -158
- package/src/shared/mcp/typings/mcp-worker-client.interface.ts +0 -243
- package/src/shared/mcp/typings/prompt-types.interface.ts +0 -39
- package/src/shared/mcp/typings/remove-section-result.model.ts +0 -10
- package/src/shared/mcp/typings/sampling-types.interface.ts +0 -48
- package/src/shared/mcp/typings/skill-types.interface.ts +0 -29
- package/src/shared/mcp/typings/tool-call-result.model.ts +0 -18
- package/src/shared/mod.ts +0 -1
- package/src/shared/platform/functions/get-ipc-path.function.ts +0 -19
- package/src/shared/platform/functions/get-tmpdir.function.ts +0 -8
- package/src/shared/platform/functions/is-process-alive.function.ts +0 -17
- package/src/shared/platform/index.ts +0 -3
- package/src/shared/runtime/functions/detect-runtime.ts +0 -14
- package/src/shared/runtime/functions/get-args.ts +0 -16
- package/src/shared/runtime/index.ts +0 -3
- package/src/shared/runtime/typings/runtime.ts +0 -2
- package/src/shared/sync/functions/build-import-report.function.ts +0 -40
- package/src/shared/sync/functions/parse-export-entry.function.ts +0 -45
- package/src/shared/sync/functions/resolve-conflict.function.ts +0 -31
- package/src/shared/sync/functions/serialize-export-entry.function.ts +0 -18
- package/src/shared/sync/index.ts +0 -9
- package/src/shared/sync/typings/conflict-resolution.type.ts +0 -8
- package/src/shared/sync/typings/export-entry.interface.ts +0 -13
- package/src/shared/sync/typings/export-options.interface.ts +0 -9
- package/src/shared/sync/typings/import-options.interface.ts +0 -7
- package/src/shared/sync/typings/import-report.interface.ts +0 -15
- package/src/shared/version/constants/version.constant.ts +0 -2
- package/src/shared/version/index.ts +0 -1
- package/src/shared/wasm-codec/functions/decode-add-section-result.function.ts +0 -112
- package/src/shared/wasm-codec/functions/decode-compose-output.function.ts +0 -16
- package/src/shared/wasm-codec/functions/decode-document-manifest-list.function.ts +0 -70
- package/src/shared/wasm-codec/functions/decode-document-manifest.function.ts +0 -87
- package/src/shared/wasm-codec/functions/decode-f32.function.ts +0 -16
- package/src/shared/wasm-codec/functions/decode-key-value-text.function.ts +0 -15
- package/src/shared/wasm-codec/functions/decode-one-recall-result.function.ts +0 -86
- package/src/shared/wasm-codec/functions/decode-option-string.function.ts +0 -24
- package/src/shared/wasm-codec/functions/decode-recall-document.function.ts +0 -59
- package/src/shared/wasm-codec/functions/decode-recall-reference.function.ts +0 -52
- package/src/shared/wasm-codec/functions/decode-recall-result.function.ts +0 -267
- package/src/shared/wasm-codec/functions/decode-recall-sibling.function.ts +0 -43
- package/src/shared/wasm-codec/functions/decode-remove-flag.function.ts +0 -3
- package/src/shared/wasm-codec/functions/decode-scored-results.function.ts +0 -194
- package/src/shared/wasm-codec/functions/decode-section-match.function.ts +0 -80
- package/src/shared/wasm-codec/functions/decode-section-record-list.function.ts +0 -20
- package/src/shared/wasm-codec/functions/decode-section-record-trailing.function.ts +0 -75
- package/src/shared/wasm-codec/functions/decode-section-record.function.ts +0 -85
- package/src/shared/wasm-codec/functions/decode-section-records.function.ts +0 -249
- package/src/shared/wasm-codec/functions/decode-section-type.function.ts +0 -30
- package/src/shared/wasm-codec/functions/decode-string.function.ts +0 -22
- package/src/shared/wasm-codec/functions/decode-u32.function.ts +0 -16
- package/src/shared/wasm-codec/functions/decode-u64.function.ts +0 -16
- package/src/shared/wasm-codec/functions/decode-wasm-list.function.ts +0 -31
- package/src/shared/wasm-codec/functions/encode-add-section-params.function.ts +0 -102
- package/src/shared/wasm-codec/functions/encode-group-params.function.ts +0 -28
- package/src/shared/wasm-codec/functions/encode-identifier-list.function.ts +0 -17
- package/src/shared/wasm-codec/functions/encode-kbid-list.function.ts +0 -17
- package/src/shared/wasm-codec/functions/encode-option-string.function.ts +0 -14
- package/src/shared/wasm-codec/functions/encode-recall-params.function.ts +0 -68
- package/src/shared/wasm-codec/functions/encode-search-params.function.ts +0 -12
- package/src/shared/wasm-codec/functions/encode-section-type.function.ts +0 -18
- package/src/shared/wasm-codec/functions/encode-string.function.ts +0 -9
- package/src/shared/wasm-codec/functions/encode-type-filter-param.function.ts +0 -13
- package/src/shared/wasm-codec/functions/encode-u32.function.ts +0 -5
- package/src/shared/wasm-codec/functions/encode-update-section-params.function.ts +0 -16
- package/src/shared/wasm-codec/index.ts +0 -49
- package/src/shared/wasm-codec/typings/add-section-input.model.ts +0 -45
- package/src/shared/wasm-codec/typings/add-section-result.model.ts +0 -28
- package/src/shared/wasm-codec/typings/document-manifest.model.ts +0 -20
- package/src/shared/wasm-codec/typings/document-section.model.ts +0 -12
- package/src/shared/wasm-codec/typings/item-decoder.type.ts +0 -10
- package/src/shared/wasm-codec/typings/near-duplicate.model.ts +0 -16
- package/src/shared/wasm-codec/typings/paged-search-result.model.ts +0 -22
- package/src/shared/wasm-codec/typings/section-match.model.ts +0 -31
- package/src/shared/wasm-codec/typings/section-record-trailing.model.ts +0 -38
- package/src/shared/wasm-codec/typings/section-record.model.ts +0 -66
- package/src/shared/wasm-codec/typings/section-type-result.model.ts +0 -12
- package/src/shared/worker-client/classes/worker-client.class.ts +0 -466
- package/src/shared/worker-client/functions/compute-context-id.function.ts +0 -18
- package/src/shared/worker-client/functions/create-worker-client.function.ts +0 -70
- package/src/shared/worker-client/functions/discover-daemon.function.ts +0 -47
- package/src/shared/worker-client/functions/handle-ipc-data.function.ts +0 -49
- package/src/shared/worker-client/functions/resolve-db-path.function.ts +0 -21
- package/src/shared/worker-client/functions/send-ipc-request.function.ts +0 -39
- package/src/shared/worker-client/functions/spawn-daemon.function.ts +0 -35
- package/src/shared/worker-client/functions/wait-for-daemon.function.ts +0 -34
- package/src/shared/worker-client/index.ts +0 -44
- package/src/shared/worker-client/typings/add-section-result.model.ts +0 -39
- package/src/shared/worker-client/typings/content-result.model.ts +0 -12
- package/src/shared/worker-client/typings/daemon-info.model.ts +0 -7
- package/src/shared/worker-client/typings/export-result.model.ts +0 -14
- package/src/shared/worker-client/typings/gc-result.model.ts +0 -18
- package/src/shared/worker-client/typings/integrity-check-result.model.ts +0 -43
- package/src/shared/worker-client/typings/json-rpc-response.interface.ts +0 -17
- package/src/shared/worker-client/typings/migrate-result.model.ts +0 -11
- package/src/shared/worker-client/typings/pending-call.interface.ts +0 -7
- package/src/shared/worker-client/typings/rebuild-result.model.ts +0 -12
- package/src/shared/worker-client/typings/recall-document.model.ts +0 -16
- package/src/shared/worker-client/typings/recall-params.model.ts +0 -15
- package/src/shared/worker-client/typings/recall-reference.model.ts +0 -32
- package/src/shared/worker-client/typings/recall-result.model.ts +0 -98
- package/src/shared/worker-client/typings/recall-sibling.model.ts +0 -11
- package/src/shared/worker-client/typings/recall-single-result.model.ts +0 -41
- package/src/shared/worker-client/typings/remove-section-result.model.ts +0 -7
- package/src/shared/worker-client/typings/search-params.model.ts +0 -14
- package/src/shared/worker-client/typings/search-result.model.ts +0 -43
- package/src/shared/worker-client/typings/section.model.ts +0 -43
- package/src/shared/worker-client/typings/status-result.model.ts +0 -14
- package/src/shared/worker-client/typings/version-status.model.ts +0 -28
- package/src/shared/worker-client/typings/worker-client-error.interface.ts +0 -8
- package/src/shared/worker-client/typings/worker-client-options.interface.ts +0 -30
- package/src/shared/worker-daemon/classes/ipc-error.class.ts +0 -22
- package/src/shared/worker-daemon/classes/worker-daemon.class.ts +0 -1291
- package/src/shared/worker-daemon/constants/daemon-defaults.constant.ts +0 -29
- package/src/shared/worker-daemon/constants/wasm-method-map.constant.ts +0 -69
- package/src/shared/worker-daemon/functions/build-ipc-error-response.function.ts +0 -16
- package/src/shared/worker-daemon/functions/check-catalog-version.function.ts +0 -54
- package/src/shared/worker-daemon/functions/check-preconditions.function.ts +0 -28
- package/src/shared/worker-daemon/functions/create-host-imports.function.ts +0 -328
- package/src/shared/worker-daemon/functions/create-ipc-server.function.ts +0 -87
- package/src/shared/worker-daemon/functions/detect-stale-pid.function.ts +0 -33
- package/src/shared/worker-daemon/functions/dispatch-request.function.ts +0 -190
- package/src/shared/worker-daemon/functions/handle-check-version.function.ts +0 -74
- package/src/shared/worker-daemon/functions/handle-config-method.function.ts +0 -27
- package/src/shared/worker-daemon/functions/handle-read-ops.function.ts +0 -236
- package/src/shared/worker-daemon/functions/handle-write-ops.function.ts +0 -257
- package/src/shared/worker-daemon/functions/load-wasm-modules.function.ts +0 -95
- package/src/shared/worker-daemon/functions/parse-auto-capture-section.function.ts +0 -51
- package/src/shared/worker-daemon/functions/parse-catalog-version.function.ts +0 -20
- package/src/shared/worker-daemon/functions/parse-embedding-section.function.ts +0 -38
- package/src/shared/worker-daemon/functions/parse-worker-toml.function.ts +0 -104
- package/src/shared/worker-daemon/functions/read-config.function.ts +0 -83
- package/src/shared/worker-daemon/functions/run-startup-integrity-check.function.ts +0 -55
- package/src/shared/worker-daemon/functions/run-worker.function.ts +0 -57
- package/src/shared/worker-daemon/functions/scan-near-duplicates.function.ts +0 -92
- package/src/shared/worker-daemon/functions/start-daemon.function.ts +0 -74
- package/src/shared/worker-daemon/functions/wasm-bridge.function.ts +0 -144
- package/src/shared/worker-daemon/functions/wasm-memory-helpers.function.ts +0 -41
- package/src/shared/worker-daemon/functions/write-lock.function.ts +0 -49
- package/src/shared/worker-daemon/index.ts +0 -16
- package/src/shared/worker-daemon/typings/allocator-ref.interface.ts +0 -16
- package/src/shared/worker-daemon/typings/daemon-config.interface.ts +0 -20
- package/src/shared/worker-daemon/typings/fs-adapter.interface.ts +0 -22
- package/src/shared/worker-daemon/typings/handler-context.interface.ts +0 -19
- package/src/shared/worker-daemon/typings/ipc-handler.interface.ts +0 -39
- package/src/shared/worker-daemon/typings/memory-ref.interface.ts +0 -13
- package/src/shared/worker-daemon/typings/wasm-fn.type.ts +0 -2
- package/src/shared/worker-daemon/typings/wasm-modules.interface.ts +0 -7
- package/src/shared/worker-daemon/typings/write-lock.interface.ts +0 -13
- package/src/wasm/fs-database/kbdb_fs_database.d.ts +0 -259
- package/src/wasm/fs-database/kbdb_fs_database.js +0 -515
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
- package/src/wasm/fs-database/kbdb_fs_database_bg.wasm.d.ts +0 -35
- package/src/wasm/fs-database/package.json +0 -13
- package/src/wasm/kb-worker/kbdb_worker.d.ts +0 -650
- package/src/wasm/kb-worker/kbdb_worker.js +0 -1181
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
- package/src/wasm/kb-worker/kbdb_worker_bg.wasm.d.ts +0 -77
- package/src/wasm/kb-worker/package.json +0 -13
- package/src/wasm/query-parser/kbdb_query_parser.d.ts +0 -195
- package/src/wasm/query-parser/kbdb_query_parser.js +0 -403
- package/src/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
- package/src/wasm/query-parser/kbdb_query_parser_bg.wasm.d.ts +0 -25
- package/src/wasm/query-parser/package.json +0 -13
- package/src/worker.ts +0 -42
package/README.md
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
# @dikolab/kbdb
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@dikolab/kbdb)
|
|
4
|
+
[](https://jsr.io/@dikolab/kbdb)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
A file-based knowledge base database -- no external
|
|
8
|
+
server to install.
|
|
5
9
|
|
|
6
10
|
[GitLab](https://gitlab.com/tech-slaves/knowledge-base-db)
|
|
7
11
|
| [NPM](https://www.npmjs.com/package/@dikolab/kbdb)
|
|
8
12
|
| [JSR](https://jsr.io/@dikolab/kbdb)
|
|
9
|
-
| [License: ISC](
|
|
13
|
+
| [License: ISC](LICENSE)
|
|
14
|
+
|
|
15
|
+
> **Status:** Beta -- actively developed. Core
|
|
16
|
+
> features (search, recall, MCP) are stable and
|
|
17
|
+
> tested.
|
|
10
18
|
|
|
11
19
|
---
|
|
12
20
|
|
|
13
21
|
## What is kbdb?
|
|
14
22
|
|
|
15
23
|
**kbdb** stores your docs in a plain folder on
|
|
16
|
-
disk and makes them searchable. No server
|
|
17
|
-
install. No cloud account. Import your Markdown
|
|
24
|
+
disk and makes them searchable. No external server
|
|
25
|
+
to install. No cloud account. Import your Markdown
|
|
18
26
|
files, and kbdb indexes them automatically.
|
|
19
27
|
Search returns ranked results instantly.
|
|
20
28
|
|
|
@@ -23,13 +31,19 @@ works as an [MCP](https://modelcontextprotocol.io/)
|
|
|
23
31
|
server -- giving AI agents like Claude a searchable
|
|
24
32
|
second brain that persists between sessions.
|
|
25
33
|
|
|
26
|
-
**How search works:** kbdb uses keyword
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
**How search works:** kbdb uses **keyword search** by
|
|
35
|
+
default -- synonyms are expanded, terms are ranked
|
|
36
|
+
by relevance, and headings carry 2× weight in
|
|
37
|
+
scoring. When an exact query finds nothing, kbdb
|
|
38
|
+
automatically loosens the match so you still get the
|
|
39
|
+
best available results.
|
|
40
|
+
|
|
41
|
+
Want smarter results? Use `--algo hybrid` to blend
|
|
42
|
+
keyword matching with AI-powered similarity --
|
|
43
|
+
finding results even when different words describe
|
|
44
|
+
the same concept. Hybrid mode needs an embedding
|
|
45
|
+
provider; without one, use the default keyword-only
|
|
46
|
+
search for fast, offline matching.
|
|
33
47
|
|
|
34
48
|
**Knowledge stays fresh:** Re-learn a file and kbdb
|
|
35
49
|
replaces the old version automatically.
|
|
@@ -87,7 +101,7 @@ kbdb learn ./docs --db ./my-kb
|
|
|
87
101
|
Point it at a folder of Markdown files. kbdb reads
|
|
88
102
|
them, breaks them into sections, and builds a
|
|
89
103
|
search index. Add `--tags design,v2` to tag
|
|
90
|
-
sections for scoping, or `--replace` to
|
|
104
|
+
sections for scoping, or `--replace` to update
|
|
91
105
|
existing sections from the same source.
|
|
92
106
|
|
|
93
107
|
**3. Search**
|
|
@@ -96,11 +110,21 @@ existing sections from the same source.
|
|
|
96
110
|
kbdb search "how does auth work" --db ./my-kb
|
|
97
111
|
```
|
|
98
112
|
|
|
99
|
-
Results are ranked by relevance with
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
113
|
+
Results are ranked by relevance with snippets
|
|
114
|
+
showing where your terms matched. Use `--offset`
|
|
115
|
+
to page through large result sets.
|
|
116
|
+
|
|
117
|
+
To try hybrid search (keyword + AI similarity):
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
kbdb search "how does auth work" --algo hybrid \
|
|
121
|
+
--db ./my-kb
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
> **Tip:** `--db` is optional. If you're already
|
|
125
|
+
> inside a directory with a `.kbdb` folder, just
|
|
126
|
+
> omit it. You can also set `KBDB_DB_DIR` as an
|
|
127
|
+
> environment variable.
|
|
104
128
|
|
|
105
129
|
**4. Recall context**
|
|
106
130
|
|
|
@@ -117,112 +141,53 @@ referenced sections.
|
|
|
117
141
|
|
|
118
142
|
---
|
|
119
143
|
|
|
120
|
-
##
|
|
144
|
+
## Knowledge Base
|
|
145
|
+
|
|
146
|
+
Build, search, and maintain your knowledge store.
|
|
121
147
|
|
|
122
|
-
- **Import** Markdown
|
|
123
|
-
|
|
124
|
-
- **
|
|
125
|
-
|
|
126
|
-
- **Search** with
|
|
127
|
-
|
|
128
|
-
- **
|
|
129
|
-
|
|
148
|
+
- **Import** Markdown and plain text files with
|
|
149
|
+
tags and source tracking
|
|
150
|
+
- **Smart updates** -- re-learning a file replaces
|
|
151
|
+
the old version instead of duplicating it
|
|
152
|
+
- **Search** with three algorithms: keyword
|
|
153
|
+
(default), AI similarity, or hybrid (both)
|
|
154
|
+
- **Auto-fallback** -- if your exact query finds
|
|
155
|
+
nothing, kbdb loosens the match automatically
|
|
130
156
|
- **Recall** sections with progressive context --
|
|
131
157
|
from a quick summary to full related content
|
|
132
|
-
- **Export**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
combine a persona with skills
|
|
137
|
-
- **Manage** documents, sections, and metadata
|
|
138
|
-
- **Verify** database integrity, detect
|
|
139
|
-
contradictions, and clean up superseded data
|
|
158
|
+
- **Export** -- snapshot your knowledge base for
|
|
159
|
+
backup
|
|
160
|
+
- **Verify** database integrity and clean up
|
|
161
|
+
stale data
|
|
140
162
|
- **Rebuild** indexes if anything goes wrong
|
|
141
163
|
|
|
142
|
-
See the
|
|
143
|
-
|
|
164
|
+
See the
|
|
165
|
+
[Knowledge Base Guide](docs/details/knowledge-base.md)
|
|
166
|
+
for the full walkthrough, including export and backup.
|
|
144
167
|
|
|
145
168
|
---
|
|
146
169
|
|
|
147
|
-
##
|
|
148
|
-
|
|
149
|
-
kbdb runs as an
|
|
150
|
-
[MCP](https://modelcontextprotocol.io/) server
|
|
151
|
-
with 20 tools, so AI agents can search your docs,
|
|
152
|
-
recall context progressively, export snapshots,
|
|
153
|
-
store reusable skills, and build agent profiles --
|
|
154
|
-
a second brain that persists between sessions.
|
|
155
|
-
|
|
156
|
-
### Claude Code (CLI)
|
|
157
|
-
|
|
158
|
-
Create `.mcp.json` in your project root:
|
|
159
|
-
|
|
160
|
-
```json
|
|
161
|
-
{
|
|
162
|
-
"mcpServers": {
|
|
163
|
-
"kbdb": {
|
|
164
|
-
"command": "npx",
|
|
165
|
-
"args": [
|
|
166
|
-
"-y",
|
|
167
|
-
"@dikolab/kbdb",
|
|
168
|
-
"mcp",
|
|
169
|
-
"--db",
|
|
170
|
-
"/path/to/.kbdb"
|
|
171
|
-
]
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
```
|
|
170
|
+
## Agent Tooling
|
|
176
171
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
Create `.vscode/mcp.json` in your project:
|
|
180
|
-
|
|
181
|
-
```json
|
|
182
|
-
{
|
|
183
|
-
"servers": {
|
|
184
|
-
"kbdb": {
|
|
185
|
-
"command": "npx",
|
|
186
|
-
"args": [
|
|
187
|
-
"-y",
|
|
188
|
-
"@dikolab/kbdb",
|
|
189
|
-
"mcp",
|
|
190
|
-
"--db",
|
|
191
|
-
"${workspaceFolder}/.kbdb"
|
|
192
|
-
]
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### Claude Desktop
|
|
199
|
-
|
|
200
|
-
Add to your `claude_desktop_config.json`:
|
|
201
|
-
|
|
202
|
-
```json
|
|
203
|
-
{
|
|
204
|
-
"mcpServers": {
|
|
205
|
-
"kbdb": {
|
|
206
|
-
"command": "npx",
|
|
207
|
-
"args": [
|
|
208
|
-
"-y",
|
|
209
|
-
"@dikolab/kbdb",
|
|
210
|
-
"mcp",
|
|
211
|
-
"--db",
|
|
212
|
-
"/path/to/.kbdb"
|
|
213
|
-
]
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
```
|
|
172
|
+
Integrate kbdb with AI agents and custom tools.
|
|
218
173
|
|
|
219
|
-
|
|
174
|
+
- **MCP server** with 20 tools -- search, recall,
|
|
175
|
+
learn, export, and more
|
|
176
|
+
- **Skills** -- store reusable prompt templates
|
|
177
|
+
with fill-in-the-blank arguments
|
|
178
|
+
- **Agents** -- create AI agent profiles that
|
|
179
|
+
combine a persona with skills
|
|
180
|
+
- **Auto-capture** -- the MCP server can
|
|
181
|
+
proactively suggest knowledge to store from
|
|
182
|
+
your conversations
|
|
183
|
+
- **Daemon resilience** -- configurable request
|
|
184
|
+
timeout and automatic retry with daemon respawn
|
|
185
|
+
- **Worker daemon** lifecycle management --
|
|
186
|
+
stop and restart the background process
|
|
220
187
|
|
|
221
|
-
|
|
222
|
-
[
|
|
223
|
-
setup
|
|
224
|
-
variable configuration, and the full list of
|
|
225
|
-
available tools.
|
|
188
|
+
See the
|
|
189
|
+
[Agent Tooling Guide](docs/details/agent-tooling.md)
|
|
190
|
+
for MCP setup, skills, agents, and the library API.
|
|
226
191
|
|
|
227
192
|
---
|
|
228
193
|
|
|
@@ -236,8 +201,10 @@ project:
|
|
|
236
201
|
```typescript
|
|
237
202
|
import { createWorkerClient } from '@dikolab/kbdb';
|
|
238
203
|
|
|
204
|
+
// Spawns a background worker if not already running
|
|
239
205
|
const client = await createWorkerClient({
|
|
240
206
|
contextPath: '/path/to/.kbdb',
|
|
207
|
+
requestTimeoutMs: 30_000,
|
|
241
208
|
});
|
|
242
209
|
|
|
243
210
|
const results = await client.search({
|
|
@@ -246,13 +213,16 @@ const results = await client.search({
|
|
|
246
213
|
offset: 0,
|
|
247
214
|
});
|
|
248
215
|
|
|
249
|
-
// results = { items, total, offset, limit, has_more, relaxed }
|
|
250
216
|
console.log(results.items);
|
|
251
217
|
client.disconnect();
|
|
252
218
|
```
|
|
253
219
|
|
|
220
|
+
Pass `contextPath` (the `.kbdb` directory itself)
|
|
221
|
+
or `dbPath` (the parent directory -- kbdb discovers
|
|
222
|
+
`.kbdb` inside it).
|
|
223
|
+
|
|
254
224
|
See the
|
|
255
|
-
[Library API Reference](
|
|
225
|
+
[Library API Reference](docs/details/library-api.md)
|
|
256
226
|
for the full API.
|
|
257
227
|
|
|
258
228
|
### Development Setup
|
|
@@ -273,7 +243,12 @@ A Docker setup is included with all build tools
|
|
|
273
243
|
HOST_UMASK=$(umask) docker compose run --rm dev bash
|
|
274
244
|
```
|
|
275
245
|
|
|
276
|
-
|
|
246
|
+
Run `make benchmark` to measure search and rebuild
|
|
247
|
+
latency at scale -- results are written to
|
|
248
|
+
[docs/benchmark/benchmark.md](docs/benchmark/benchmark.md)
|
|
249
|
+
automatically.
|
|
250
|
+
|
|
251
|
+
See the [Makefile](Makefile) for all available
|
|
277
252
|
build targets.
|
|
278
253
|
|
|
279
254
|
### Contributing
|
|
@@ -288,20 +263,27 @@ build targets.
|
|
|
288
263
|
|
|
289
264
|
## Documentation
|
|
290
265
|
|
|
291
|
-
- [
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
- [
|
|
266
|
+
- [Knowledge Base Guide](docs/details/knowledge-base.md)
|
|
267
|
+
-- importing, searching, recall, export
|
|
268
|
+
- [Agent Tooling Guide](docs/details/agent-tooling.md)
|
|
269
|
+
-- MCP, skills, agents, library API
|
|
270
|
+
- [CLI Reference](docs/details/cli.md) -- full command
|
|
271
|
+
list with examples
|
|
272
|
+
- [MCP Server Guide](docs/details/mcp-server.md) --
|
|
273
|
+
setup, tools, environment config
|
|
274
|
+
- [Search and Ranking](docs/details/search-and-ranking.md)
|
|
275
|
+
-- how search works under the hood
|
|
276
|
+
- [Storage Architecture](docs/details/storage.md) --
|
|
277
|
+
file formats and directory layout
|
|
278
|
+
- [Benchmark Results](docs/benchmark/benchmark.md)
|
|
279
|
+
-- search and rebuild latency at scale
|
|
280
|
+
- [Release Notes](docs/release-notes/)
|
|
281
|
+
- [Architecture Overview](docs/overview.md)
|
|
296
282
|
|
|
297
283
|
---
|
|
298
284
|
|
|
299
285
|
## License
|
|
300
286
|
|
|
301
|
-
ISC License -- see [LICENSE](
|
|
287
|
+
ISC License -- see [LICENSE](LICENSE) for details.
|
|
302
288
|
|
|
303
289
|
---
|
|
304
|
-
|
|
305
|
-
[GitLab](https://gitlab.com/tech-slaves/knowledge-base-db)
|
|
306
|
-
| [NPM](https://www.npmjs.com/package/@dikolab/kbdb)
|
|
307
|
-
| [JSR](https://jsr.io/@dikolab/kbdb)
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// src/shared/runtime/functions/detect-runtime.ts
|
|
2
|
+
function detectRuntime() {
|
|
3
|
+
if (typeof globalThis !== "undefined" && "Deno" in globalThis) {
|
|
4
|
+
return "deno";
|
|
5
|
+
}
|
|
6
|
+
return "node";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// src/shared/runtime/functions/get-args.ts
|
|
10
|
+
function getArgs() {
|
|
11
|
+
if (detectRuntime() === "deno") {
|
|
12
|
+
const g = globalThis;
|
|
13
|
+
const deno = g["Deno"];
|
|
14
|
+
return deno?.args ?? [];
|
|
15
|
+
}
|
|
16
|
+
return process.argv.slice(2);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/shared/dir-resolver/functions/resolve-base-dir.function.ts
|
|
20
|
+
import { dirname } from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
function resolveScriptDir(entryUrl, entryDirname) {
|
|
23
|
+
if (entryDirname) return entryDirname;
|
|
24
|
+
if (entryUrl.startsWith("file:"))
|
|
25
|
+
return dirname(fileURLToPath(entryUrl));
|
|
26
|
+
return dirname(entryUrl);
|
|
27
|
+
}
|
|
28
|
+
function resolveBaseDir(entryUrl, entryDirname) {
|
|
29
|
+
const scriptDir = typeof __dirname !== "undefined" ? __dirname : resolveScriptDir(entryUrl, entryDirname);
|
|
30
|
+
return { scriptDir, cwd: process.cwd() };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/shared/dir-resolver/functions/join-path.function.ts
|
|
34
|
+
import { join } from "node:path";
|
|
35
|
+
function isRemoteUrl(path) {
|
|
36
|
+
return path.startsWith("http://") || path.startsWith("https://");
|
|
37
|
+
}
|
|
38
|
+
function joinPath(base, ...segments) {
|
|
39
|
+
if (isRemoteUrl(base)) {
|
|
40
|
+
const trailing = base.endsWith("/") ? "" : "/";
|
|
41
|
+
return base + trailing + segments.join("/");
|
|
42
|
+
}
|
|
43
|
+
return join(base, ...segments);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/shared/dir-resolver/functions/resolve-worker-script.function.ts
|
|
47
|
+
function resolveWorkerScript(scriptDir, runtime) {
|
|
48
|
+
if (runtime === "deno") {
|
|
49
|
+
return joinPath(scriptDir, "worker.ts");
|
|
50
|
+
}
|
|
51
|
+
return joinPath(scriptDir, "kbdb-worker.cjs");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/shared/dir-resolver/functions/resolve-wasm-dir.function.ts
|
|
55
|
+
function resolveWasmDir(scriptDir) {
|
|
56
|
+
return joinPath(scriptDir, "wasm");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/shared/worker-daemon/constants/daemon-defaults.constant.ts
|
|
60
|
+
var DEFAULT_ITEM_LIMIT = 1e3;
|
|
61
|
+
var DEFAULT_INDEX_LIMIT = 100;
|
|
62
|
+
var DEFAULT_TIMEOUT_MS = 3e5;
|
|
63
|
+
var DEFAULT_ITEM_TTL_MS = 6e4;
|
|
64
|
+
var WORKER_TOML_FILENAME = "worker.toml";
|
|
65
|
+
var DB_FORMAT_VERSION = 1;
|
|
66
|
+
|
|
67
|
+
// src/shared/worker-daemon/functions/parse-embedding-section.function.ts
|
|
68
|
+
function parseEmbeddingSection(entries) {
|
|
69
|
+
const provider = entries.get("provider");
|
|
70
|
+
if (!provider) {
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
const model = entries.get("model");
|
|
74
|
+
const endpoint = entries.get("endpoint");
|
|
75
|
+
const dimensionsRaw = entries.get("dimensions");
|
|
76
|
+
const dimensions = dimensionsRaw ? parseInt(dimensionsRaw, 10) || void 0 : void 0;
|
|
77
|
+
return {
|
|
78
|
+
provider,
|
|
79
|
+
...model !== void 0 ? { model } : {},
|
|
80
|
+
...endpoint !== void 0 ? { endpoint } : {},
|
|
81
|
+
...dimensions !== void 0 ? { dimensions } : {}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/shared/auto-capture/constants/auto-capture-defaults.constant.ts
|
|
86
|
+
var AUTO_CAPTURE_DEFAULTS = {
|
|
87
|
+
enabled: false,
|
|
88
|
+
triggerAfterToolCalls: 5,
|
|
89
|
+
minIntervalMs: 6e4,
|
|
90
|
+
maxCapturesPerSession: 10,
|
|
91
|
+
dryRun: false
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/shared/worker-daemon/functions/parse-auto-capture-section.function.ts
|
|
95
|
+
function parseAutoCaptureSection(entries) {
|
|
96
|
+
const enabled = entries.has("enabled") ? entries.get("enabled") === "true" : AUTO_CAPTURE_DEFAULTS.enabled;
|
|
97
|
+
const dryRun = entries.has("dry_run") ? entries.get("dry_run") === "true" : AUTO_CAPTURE_DEFAULTS.dryRun;
|
|
98
|
+
const triggerRaw = entries.get("trigger_after_tool_calls");
|
|
99
|
+
const triggerAfterToolCalls = triggerRaw ? parseInt(triggerRaw, 10) || AUTO_CAPTURE_DEFAULTS.triggerAfterToolCalls : AUTO_CAPTURE_DEFAULTS.triggerAfterToolCalls;
|
|
100
|
+
const intervalRaw = entries.get("min_interval_ms");
|
|
101
|
+
const minIntervalMs = intervalRaw ? parseInt(intervalRaw, 10) || AUTO_CAPTURE_DEFAULTS.minIntervalMs : AUTO_CAPTURE_DEFAULTS.minIntervalMs;
|
|
102
|
+
const capRaw = entries.get("max_captures_per_session");
|
|
103
|
+
const maxCapturesPerSession = capRaw ? parseInt(capRaw, 10) || AUTO_CAPTURE_DEFAULTS.maxCapturesPerSession : AUTO_CAPTURE_DEFAULTS.maxCapturesPerSession;
|
|
104
|
+
return {
|
|
105
|
+
enabled,
|
|
106
|
+
triggerAfterToolCalls,
|
|
107
|
+
minIntervalMs,
|
|
108
|
+
maxCapturesPerSession,
|
|
109
|
+
dryRun
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/shared/worker-daemon/functions/parse-worker-toml.function.ts
|
|
114
|
+
function applyRootKey(acc, key, value) {
|
|
115
|
+
switch (key) {
|
|
116
|
+
case "item_limit":
|
|
117
|
+
acc.itemLimit = parseInt(value, 10) || DEFAULT_ITEM_LIMIT;
|
|
118
|
+
break;
|
|
119
|
+
case "index_limit":
|
|
120
|
+
acc.indexLimit = parseInt(value, 10) || DEFAULT_INDEX_LIMIT;
|
|
121
|
+
break;
|
|
122
|
+
case "timeout_ms":
|
|
123
|
+
acc.timeoutMs = parseInt(value, 10) || DEFAULT_TIMEOUT_MS;
|
|
124
|
+
break;
|
|
125
|
+
case "item_ttl_ms":
|
|
126
|
+
acc.itemTtlMs = parseInt(value, 10) || DEFAULT_ITEM_TTL_MS;
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function parseWorkerToml(text, contextPath) {
|
|
133
|
+
let section = "";
|
|
134
|
+
const embeddingEntries = /* @__PURE__ */ new Map();
|
|
135
|
+
const autoCaptureEntries = /* @__PURE__ */ new Map();
|
|
136
|
+
const acc = {
|
|
137
|
+
itemLimit: DEFAULT_ITEM_LIMIT,
|
|
138
|
+
indexLimit: DEFAULT_INDEX_LIMIT,
|
|
139
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
140
|
+
itemTtlMs: DEFAULT_ITEM_TTL_MS
|
|
141
|
+
};
|
|
142
|
+
for (const line of text.split("\n")) {
|
|
143
|
+
const trimmed = line.trim();
|
|
144
|
+
if (trimmed === "[embedding]") {
|
|
145
|
+
section = "embedding";
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (trimmed === "[auto_capture]") {
|
|
149
|
+
section = "auto_capture";
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (trimmed.startsWith("[")) {
|
|
153
|
+
section = "";
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (trimmed.startsWith("#") || !trimmed.includes("=")) continue;
|
|
157
|
+
const eqIdx = trimmed.indexOf("=");
|
|
158
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
159
|
+
const value = trimmed.slice(eqIdx + 1).trim();
|
|
160
|
+
if (section === "embedding") {
|
|
161
|
+
embeddingEntries.set(key, value);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (section === "auto_capture") {
|
|
165
|
+
autoCaptureEntries.set(key, value);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
applyRootKey(acc, key, value);
|
|
169
|
+
}
|
|
170
|
+
const embedding = parseEmbeddingSection(embeddingEntries);
|
|
171
|
+
const autoCapture = autoCaptureEntries.size > 0 ? parseAutoCaptureSection(autoCaptureEntries) : void 0;
|
|
172
|
+
return {
|
|
173
|
+
contextPath,
|
|
174
|
+
...acc,
|
|
175
|
+
...embedding !== void 0 ? { embedding } : {},
|
|
176
|
+
...autoCapture !== void 0 ? { autoCapture } : {}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/shared/hash/functions/compute-sha256.ts
|
|
181
|
+
async function computeSha256(input) {
|
|
182
|
+
const data = new TextEncoder().encode(input);
|
|
183
|
+
const hash = await crypto.subtle.digest("SHA-256", data);
|
|
184
|
+
const bytes = new Uint8Array(hash);
|
|
185
|
+
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/shared/platform/functions/get-ipc-path.function.ts
|
|
189
|
+
import { join as join2 } from "node:path";
|
|
190
|
+
|
|
191
|
+
// src/shared/platform/functions/get-tmpdir.function.ts
|
|
192
|
+
import { tmpdir } from "node:os";
|
|
193
|
+
function getTmpdir() {
|
|
194
|
+
return tmpdir();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/shared/platform/functions/get-ipc-path.function.ts
|
|
198
|
+
function getIpcPath(ctx) {
|
|
199
|
+
if (process.platform === "win32") {
|
|
200
|
+
return `\\\\.\\pipe\\kbdb-${ctx}`;
|
|
201
|
+
}
|
|
202
|
+
return join2(getTmpdir(), `kbdb-${ctx}.sock`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export {
|
|
206
|
+
detectRuntime,
|
|
207
|
+
getArgs,
|
|
208
|
+
resolveBaseDir,
|
|
209
|
+
isRemoteUrl,
|
|
210
|
+
joinPath,
|
|
211
|
+
resolveWorkerScript,
|
|
212
|
+
resolveWasmDir,
|
|
213
|
+
computeSha256,
|
|
214
|
+
getIpcPath,
|
|
215
|
+
DEFAULT_ITEM_LIMIT,
|
|
216
|
+
DEFAULT_INDEX_LIMIT,
|
|
217
|
+
DEFAULT_TIMEOUT_MS,
|
|
218
|
+
DEFAULT_ITEM_TTL_MS,
|
|
219
|
+
WORKER_TOML_FILENAME,
|
|
220
|
+
DB_FORMAT_VERSION,
|
|
221
|
+
parseWorkerToml
|
|
222
|
+
};
|
|
223
|
+
//# sourceMappingURL=chunk-BJPSPNGX.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/shared/runtime/functions/detect-runtime.ts", "../src/shared/runtime/functions/get-args.ts", "../src/shared/dir-resolver/functions/resolve-base-dir.function.ts", "../src/shared/dir-resolver/functions/join-path.function.ts", "../src/shared/dir-resolver/functions/resolve-worker-script.function.ts", "../src/shared/dir-resolver/functions/resolve-wasm-dir.function.ts", "../src/shared/worker-daemon/constants/daemon-defaults.constant.ts", "../src/shared/worker-daemon/functions/parse-embedding-section.function.ts", "../src/shared/auto-capture/constants/auto-capture-defaults.constant.ts", "../src/shared/worker-daemon/functions/parse-auto-capture-section.function.ts", "../src/shared/worker-daemon/functions/parse-worker-toml.function.ts", "../src/shared/hash/functions/compute-sha256.ts", "../src/shared/platform/functions/get-ipc-path.function.ts", "../src/shared/platform/functions/get-tmpdir.function.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Runtime } from '../typings/runtime.ts';\n\n/**\n * Detects the current JavaScript runtime environment.\n *\n * Returns `'deno'` when the global `Deno` object is present,\n * otherwise returns `'node'`.\n */\nexport function detectRuntime(): Runtime {\n if (typeof globalThis !== 'undefined' && 'Deno' in globalThis) {\n return 'deno';\n }\n return 'node';\n}\n", "import { detectRuntime } from './detect-runtime.ts';\n\n/**\n * Returns the command-line arguments for the current runtime.\n *\n * In Deno, reads `Deno.args`; in Node.js, slices `process.argv`\n * past the interpreter and script entries.\n */\nexport function getArgs(): string[] {\n if (detectRuntime() === 'deno') {\n const g = globalThis as Record<string, unknown>;\n const deno = g['Deno'] as { args: string[] } | undefined;\n return deno?.args ?? [];\n }\n return process.argv.slice(2);\n}\n", "import { dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { BaseDir } from '../typings/base-dir.interface.ts';\n\nexport function resolveScriptDir(\n entryUrl: string,\n entryDirname?: string,\n): string {\n if (entryDirname) return entryDirname;\n if (entryUrl.startsWith('file:'))\n return dirname(fileURLToPath(entryUrl));\n return dirname(entryUrl);\n}\n\nexport function resolveBaseDir(\n entryUrl: string,\n entryDirname?: string,\n): BaseDir {\n const scriptDir =\n typeof __dirname !== 'undefined'\n ? __dirname\n : resolveScriptDir(entryUrl, entryDirname);\n return { scriptDir, cwd: process.cwd() };\n}\n", "import { join } from 'node:path';\n\nexport function isRemoteUrl(path: string): boolean {\n return path.startsWith('http://') || path.startsWith('https://');\n}\n\nexport function joinPath(base: string, ...segments: string[]): string {\n if (isRemoteUrl(base)) {\n const trailing = base.endsWith('/') ? '' : '/';\n return base + trailing + segments.join('/');\n }\n return join(base, ...segments);\n}\n", "import { joinPath } from './join-path.function.ts';\n\nimport type { Runtime } from '../../runtime/typings/runtime.ts';\n\nexport function resolveWorkerScript(\n scriptDir: string,\n runtime: Runtime,\n): string {\n if (runtime === 'deno') {\n return joinPath(scriptDir, 'worker.ts');\n }\n return joinPath(scriptDir, 'kbdb-worker.cjs');\n}\n", "import { joinPath } from './join-path.function.ts';\n\nexport function resolveWasmDir(scriptDir: string): string {\n return joinPath(scriptDir, 'wasm');\n}\n", "/** Default maximum number of items held in daemon memory. */\nexport const DEFAULT_ITEM_LIMIT = 1000;\n\n/** Default maximum number of index entries held in daemon memory. */\nexport const DEFAULT_INDEX_LIMIT = 100;\n\n/**\n * Default idle timeout in milliseconds before the daemon shuts\n * down automatically (5 minutes).\n */\nexport const DEFAULT_TIMEOUT_MS = 300_000;\n\n/**\n * Default time-to-live in milliseconds for each cached item\n * (1 minute).\n */\nexport const DEFAULT_ITEM_TTL_MS = 60_000;\n\n/** Filename of the daemon configuration file inside `.kbdb/`. */\nexport const WORKER_TOML_FILENAME = 'worker.toml';\n\n/**\n * Database format version the daemon supports.\n *\n * Read from `catalog.toml` at startup. If the catalog version\n * differs, the daemon prints a structured error to stderr and\n * exits with code 1 before loading any WASM modules.\n */\nexport const DB_FORMAT_VERSION = 1;\n", "import type { EmbeddingConfig } from '../../embedding/typings/embedding-config.interface.ts';\n\n/**\n * Parses key-value pairs from a `[embedding]` TOML section into an\n * `EmbeddingConfig`.\n *\n * Recognises: `provider`, `model`, `endpoint`, `dimensions`.\n * Unknown keys are silently ignored. Returns `undefined` when the\n * `provider` key is absent from the supplied entries.\n *\n * @param entries - key-value pairs from inside the `[embedding]`\n * section\n */\nexport function parseEmbeddingSection(\n entries: ReadonlyMap<string, string>,\n): EmbeddingConfig | undefined {\n const provider = entries.get('provider') as\n | EmbeddingConfig['provider']\n | undefined;\n\n if (!provider) {\n return undefined;\n }\n\n const model = entries.get('model');\n const endpoint = entries.get('endpoint');\n const dimensionsRaw = entries.get('dimensions');\n const dimensions = dimensionsRaw\n ? parseInt(dimensionsRaw, 10) || undefined\n : undefined;\n\n return {\n provider,\n ...(model !== undefined ? { model } : {}),\n ...(endpoint !== undefined ? { endpoint } : {}),\n ...(dimensions !== undefined ? { dimensions } : {}),\n };\n}\n", "import type { AutoCaptureConfig } from '../typings/auto-capture-config.interface.ts';\n\n/**\n * Default configuration for the auto-capture feature.\n *\n * Auto-capture is disabled by default. Enable it in\n * `worker.toml` under `[auto_capture]`.\n */\nexport const AUTO_CAPTURE_DEFAULTS: AutoCaptureConfig = {\n enabled: false,\n triggerAfterToolCalls: 5,\n minIntervalMs: 60_000,\n maxCapturesPerSession: 10,\n dryRun: false,\n};\n", "import type { AutoCaptureConfig } from '../../auto-capture/typings/auto-capture-config.interface.ts';\nimport { AUTO_CAPTURE_DEFAULTS } from '../../auto-capture/constants/auto-capture-defaults.constant.ts';\n\n/**\n * Parses key-value pairs from an `[auto_capture]` TOML section\n * into an `AutoCaptureConfig`.\n *\n * Recognised keys: `enabled`, `trigger_after_tool_calls`,\n * `min_interval_ms`, `max_captures_per_session`, `dry_run`.\n * Unknown keys are silently ignored. Falls back to\n * `AUTO_CAPTURE_DEFAULTS` for any absent key.\n *\n * @param entries - key-value pairs from inside the\n * `[auto_capture]` section\n */\nexport function parseAutoCaptureSection(\n entries: ReadonlyMap<string, string>,\n): AutoCaptureConfig {\n const enabled = entries.has('enabled')\n ? entries.get('enabled') === 'true'\n : AUTO_CAPTURE_DEFAULTS.enabled;\n\n const dryRun = entries.has('dry_run')\n ? entries.get('dry_run') === 'true'\n : AUTO_CAPTURE_DEFAULTS.dryRun;\n\n const triggerRaw = entries.get('trigger_after_tool_calls');\n const triggerAfterToolCalls = triggerRaw\n ? parseInt(triggerRaw, 10) ||\n AUTO_CAPTURE_DEFAULTS.triggerAfterToolCalls\n : AUTO_CAPTURE_DEFAULTS.triggerAfterToolCalls;\n\n const intervalRaw = entries.get('min_interval_ms');\n const minIntervalMs = intervalRaw\n ? parseInt(intervalRaw, 10) || AUTO_CAPTURE_DEFAULTS.minIntervalMs\n : AUTO_CAPTURE_DEFAULTS.minIntervalMs;\n\n const capRaw = entries.get('max_captures_per_session');\n const maxCapturesPerSession = capRaw\n ? parseInt(capRaw, 10) ||\n AUTO_CAPTURE_DEFAULTS.maxCapturesPerSession\n : AUTO_CAPTURE_DEFAULTS.maxCapturesPerSession;\n\n return {\n enabled,\n triggerAfterToolCalls,\n minIntervalMs,\n maxCapturesPerSession,\n dryRun,\n };\n}\n", "import type { DaemonConfig } from '../typings/daemon-config.interface.ts';\nimport {\n DEFAULT_ITEM_LIMIT,\n DEFAULT_INDEX_LIMIT,\n DEFAULT_TIMEOUT_MS,\n DEFAULT_ITEM_TTL_MS,\n} from '../constants/daemon-defaults.constant.ts';\nimport { parseEmbeddingSection } from './parse-embedding-section.function.ts';\nimport { parseAutoCaptureSection } from './parse-auto-capture-section.function.ts';\n\ninterface RootAccum {\n itemLimit: number;\n indexLimit: number;\n timeoutMs: number;\n itemTtlMs: number;\n}\n\nfunction applyRootKey(\n acc: RootAccum,\n key: string,\n value: string,\n): void {\n switch (key) {\n case 'item_limit':\n acc.itemLimit = parseInt(value, 10) || DEFAULT_ITEM_LIMIT;\n break;\n case 'index_limit':\n acc.indexLimit = parseInt(value, 10) || DEFAULT_INDEX_LIMIT;\n break;\n case 'timeout_ms':\n acc.timeoutMs = parseInt(value, 10) || DEFAULT_TIMEOUT_MS;\n break;\n case 'item_ttl_ms':\n acc.itemTtlMs = parseInt(value, 10) || DEFAULT_ITEM_TTL_MS;\n break;\n default:\n break;\n }\n}\n\n/**\n * Parses a `worker.toml` file body into a partial `DaemonConfig`.\n *\n * Handles `[embedding]` sub-sections and root key-value pairs.\n * Unknown keys are silently ignored.\n *\n * @param text - raw content of `worker.toml`\n * @param contextPath - daemon context directory path\n */\nexport function parseWorkerToml(\n text: string,\n contextPath: string,\n): DaemonConfig {\n let section = '';\n const embeddingEntries = new Map<string, string>();\n const autoCaptureEntries = new Map<string, string>();\n const acc: RootAccum = {\n itemLimit: DEFAULT_ITEM_LIMIT,\n indexLimit: DEFAULT_INDEX_LIMIT,\n timeoutMs: DEFAULT_TIMEOUT_MS,\n itemTtlMs: DEFAULT_ITEM_TTL_MS,\n };\n\n for (const line of text.split('\\n')) {\n const trimmed = line.trim();\n if (trimmed === '[embedding]') {\n section = 'embedding';\n continue;\n }\n if (trimmed === '[auto_capture]') {\n section = 'auto_capture';\n continue;\n }\n if (trimmed.startsWith('[')) {\n section = '';\n continue;\n }\n if (trimmed.startsWith('#') || !trimmed.includes('=')) continue;\n const eqIdx = trimmed.indexOf('=');\n const key = trimmed.slice(0, eqIdx).trim();\n const value = trimmed.slice(eqIdx + 1).trim();\n if (section === 'embedding') {\n embeddingEntries.set(key, value);\n continue;\n }\n if (section === 'auto_capture') {\n autoCaptureEntries.set(key, value);\n continue;\n }\n applyRootKey(acc, key, value);\n }\n\n const embedding = parseEmbeddingSection(embeddingEntries);\n const autoCapture =\n autoCaptureEntries.size > 0\n ? parseAutoCaptureSection(autoCaptureEntries)\n : undefined;\n return {\n contextPath,\n ...acc,\n ...(embedding !== undefined ? { embedding } : {}),\n ...(autoCapture !== undefined ? { autoCapture } : {}),\n };\n}\n", "/**\n * Computes the SHA-256 hash of a UTF-8 string.\n *\n * Uses the Web Crypto API (`crypto.subtle`), which is available\n * in both Deno and Node.js >= 20 without additional imports.\n *\n * @param input - the string to hash\n * @returns lowercase hex-encoded SHA-256 digest (64 characters)\n */\nexport async function computeSha256(input: string): Promise<string> {\n const data = new TextEncoder().encode(input);\n const hash = await crypto.subtle.digest('SHA-256', data);\n const bytes = new Uint8Array(hash);\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n}\n", "import { join } from 'node:path';\nimport { getTmpdir } from './get-tmpdir.function.ts';\n\n/**\n * Returns the platform-appropriate IPC socket path for a given\n * context identifier.\n *\n * On Windows, returns a named pipe path (`\\\\.\\pipe\\kbdb-<ctx>`).\n * On POSIX systems, returns a Unix domain socket path under the\n * system temp directory (`<tmpdir>/kbdb-<ctx>.sock`).\n *\n * @param ctx - unique context identifier embedded in the path\n */\nexport function getIpcPath(ctx: string): string {\n if (process.platform === 'win32') {\n return `\\\\\\\\.\\\\pipe\\\\kbdb-${ctx}`;\n }\n return join(getTmpdir(), `kbdb-${ctx}.sock`);\n}\n", "import { tmpdir } from 'node:os';\n\n/**\n * Returns the operating system's default temporary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