@dikolab/kbdb 0.3.2 → 0.4.1
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 +92 -90
- package/dist/chunk-BJXEVALU.mjs +337 -0
- package/dist/chunk-BJXEVALU.mjs.map +7 -0
- package/dist/cli.cjs +1398 -378
- package/dist/cli.cjs.map +4 -4
- package/dist/cli.d.ts +9 -0
- package/dist/cli.mjs +1138 -342
- package/dist/cli.mjs.map +4 -4
- package/dist/kbdb-worker.cjs +1115 -135
- package/dist/kbdb-worker.cjs.map +4 -4
- package/dist/mod.cjs +351 -69
- package/dist/mod.cjs.map +4 -4
- package/dist/mod.d.ts +23 -2
- package/dist/mod.mjs +349 -68
- package/dist/mod.mjs.map +4 -4
- 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 +22 -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/classes/tfidf-embedding-provider.class.d.ts +28 -0
- package/dist/src/shared/embedding/constants/tfidf-defaults.constant.d.ts +4 -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 +15 -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 +9 -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/log/constants/log-colors.constant.d.ts +5 -0
- package/dist/src/shared/log/constants/log-defaults.constant.d.ts +3 -0
- package/dist/src/shared/log/constants/log-icons.constant.d.ts +3 -0
- package/dist/src/shared/log/functions/configure-log.function.d.ts +12 -0
- package/dist/src/shared/log/functions/log.function.d.ts +28 -0
- package/dist/src/shared/log/functions/parse-log-level.function.d.ts +10 -0
- package/dist/src/shared/log/functions/resolve-log-level.function.d.ts +12 -0
- package/dist/src/shared/log/functions/write-stderr.function.d.ts +10 -0
- package/dist/src/shared/log/index.d.ts +10 -0
- package/dist/src/shared/log/typings/log-config.interface.d.ts +7 -0
- package/dist/src/shared/log/typings/log-level.type.d.ts +7 -0
- package/dist/src/shared/log/typings/log-output.interface.d.ts +4 -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 +38 -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 +18 -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 +6 -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/functions/run-worker.function.d.ts +6 -1
- package/dist/src/shared/worker-daemon/typings/handler-context.interface.d.ts +3 -0
- package/dist/src/shared/worker-daemon/typings/wasm-modules.interface.d.ts +5 -0
- package/dist/wasm/default-embedding/kbdb_default_embedding.d.ts +55 -0
- package/dist/wasm/default-embedding/kbdb_default_embedding.js +156 -0
- package/{src/wasm/query-parser/kbdb_query_parser_bg.wasm → dist/wasm/default-embedding/kbdb_default_embedding_bg.wasm} +0 -0
- package/dist/wasm/default-embedding/kbdb_default_embedding_bg.wasm.d.ts +12 -0
- package/dist/wasm/default-embedding/package.json +13 -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/fs-migration/kbdb_fs_migration.d.ts +38 -0
- package/dist/wasm/fs-migration/kbdb_fs_migration.js +130 -0
- package/dist/wasm/fs-migration/kbdb_fs_migration_bg.wasm +0 -0
- package/dist/wasm/fs-migration/kbdb_fs_migration_bg.wasm.d.ts +9 -0
- package/dist/wasm/fs-migration/package.json +13 -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 +899 -143
- package/dist/worker.mjs.map +4 -4
- package/docs/details/README.md +4 -0
- package/docs/details/agent-tooling.md +132 -0
- package/docs/details/cli.md +91 -18
- package/docs/details/knowledge-base.md +180 -0
- package/docs/details/library-api.md +42 -2
- package/docs/details/mcp-server.md +53 -7
- package/docs/details/search-and-ranking.md +16 -11
- package/docs/goals/cli.md +142 -37
- package/docs/goals/content-parser.md +1 -1
- package/docs/goals/hybrid-search.md +71 -42
- package/docs/goals/mcp.md +24 -19
- package/docs/goals/overview.md +1 -1
- package/docs/goals/query-parser.md +8 -0
- package/docs/goals/semantic-dedup.md +7 -3
- package/docs/goals/worker-client.md +62 -1
- package/docs/goals/worker-daemon.md +83 -30
- package/docs/modules/overview.md +43 -22
- package/docs/modules/rust/embedding/module.md +91 -0
- package/docs/modules/rust/overview.md +56 -21
- package/docs/modules/rust/query-parser/functions/module.md +7 -5
- package/docs/modules/rust/query-parser/functions/pipeline.md +6 -138
- package/docs/modules/rust/query-parser/module.md +16 -22
- package/docs/modules/rust/query-parser/types/module.md +5 -4
- package/docs/modules/rust/query-parser/types/token.md +5 -1
- package/docs/modules/rust/shared/content-parser/functions.md +1 -1
- package/docs/modules/rust/shared/memory/module.md +1 -1
- package/docs/modules/rust/shared/module.md +33 -5
- package/docs/modules/rust/shared/pipeline/functions.md +141 -0
- package/docs/modules/rust/shared/pipeline/module.md +62 -0
- package/docs/modules/rust/shared/pipeline/types.md +43 -0
- package/docs/modules/rust/shared/section/module.md +1 -1
- package/docs/modules/rust/shared/section/types.md +1 -1
- package/docs/modules/typescript/cli.md +5 -3
- package/docs/modules/typescript/kbdb-worker.md +20 -5
- package/docs/modules/typescript/overview.md +28 -6
- package/docs/modules/typescript/shared/cli/functions.md +131 -17
- package/docs/modules/typescript/shared/cli/module.md +33 -20
- package/docs/modules/typescript/shared/cli/typings.md +25 -0
- package/docs/modules/typescript/shared/embedding/functions.md +125 -19
- package/docs/modules/typescript/shared/embedding/module.md +10 -4
- package/docs/modules/typescript/shared/embedding/typings.md +7 -5
- package/docs/modules/typescript/shared/log/constants.md +82 -0
- package/docs/modules/typescript/shared/log/functions.md +131 -0
- package/docs/modules/typescript/shared/log/module.md +153 -0
- package/docs/modules/typescript/shared/log/typings.md +82 -0
- 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/module.md +22 -6
- 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/functions.md +19 -6
- package/docs/modules/typescript/shared/worker-daemon/module.md +11 -5
- package/docs/modules/typescript/shared/worker-daemon/typings.md +13 -7
- package/docs/overview.md +1 -2
- package/docs/release-notes/0.4.0.md +80 -0
- package/docs/release-notes/0.4.1.md +149 -0
- package/docs/release-notes/README.md +1 -0
- package/mod.ts +33 -15
- package/package.json +12 -11
- 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.d.ts +0 -25
- package/src/wasm/query-parser/package.json +0 -13
- package/src/worker.ts +0 -42
package/docs/modules/overview.md
CHANGED
|
@@ -12,9 +12,10 @@ final `dist/` output.*
|
|
|
12
12
|
|
|
13
13
|
engine/crates/ src/shared/
|
|
14
14
|
├── shared (rlib) ├── worker-daemon/
|
|
15
|
-
├── fs-database (cdylib) │ ├── wasm/ ←
|
|
15
|
+
├── fs-database (cdylib) │ ├── wasm/ ← 4 WASM modules
|
|
16
16
|
├── query-parser (cdylib) │ │ ├── fs-database.*
|
|
17
|
-
|
|
17
|
+
├── default-embedding (cdylib)│ │ ├── query-parser.*
|
|
18
|
+
└── kb-worker (cdylib) │ │ ├── default-embedding.*
|
|
18
19
|
│ │ │ └── kb-worker.*
|
|
19
20
|
│ wasm-pack build │ └── functions/
|
|
20
21
|
└─────────────────────┘ └── load-wasm-modules
|
|
@@ -31,7 +32,7 @@ final `dist/` output.*
|
|
|
31
32
|
|
|
32
33
|
## Phase 1 -- Build Rust to WASM
|
|
33
34
|
|
|
34
|
-
The Rust engine compiles to
|
|
35
|
+
The Rust engine compiles to four standalone `.wasm`
|
|
35
36
|
files. The `kbdb-shared` crate is an `rlib` -- it
|
|
36
37
|
produces no artifact, compiled **into** each consumer
|
|
37
38
|
via dead code elimination.
|
|
@@ -43,15 +44,17 @@ via dead code elimination.
|
|
|
43
44
|
| `kbdb-shared` | `rlib` | none (compiled into consumers) |
|
|
44
45
|
| `kbdb-fs-database` | `cdylib` | `fs-database.wasm` |
|
|
45
46
|
| `kbdb-query-parser`| `cdylib` | `query-parser.wasm` |
|
|
47
|
+
| `kbdb-default-embedding` | `cdylib` | `default-embedding.wasm` |
|
|
46
48
|
| `kbdb-worker` | `cdylib` | `kb-worker.wasm` |
|
|
47
49
|
|
|
48
50
|
### Build Order
|
|
49
51
|
|
|
50
52
|
```
|
|
51
|
-
1. kbdb-shared
|
|
52
|
-
2. kbdb-fs-database
|
|
53
|
-
kbdb-query-parser
|
|
54
|
-
|
|
53
|
+
1. kbdb-shared (leaf, no deps)
|
|
54
|
+
2. kbdb-fs-database ┐ (all depend on shared,
|
|
55
|
+
kbdb-query-parser │ built in parallel)
|
|
56
|
+
kbdb-default-embedding ┘
|
|
57
|
+
3. kbdb-worker (depends on all above)
|
|
55
58
|
```
|
|
56
59
|
|
|
57
60
|
### Build Command
|
|
@@ -62,20 +65,24 @@ npm run build:wasm
|
|
|
62
65
|
|
|
63
66
|
This runs `wasm-pack build` for each cdylib crate.
|
|
64
67
|
Output lands in the TypeScript source tree at
|
|
65
|
-
`src/
|
|
68
|
+
`src/wasm/`:
|
|
66
69
|
|
|
67
70
|
```sh
|
|
68
71
|
wasm-pack build crates/fs-database \
|
|
69
72
|
--target no-modules \
|
|
70
|
-
--out-dir
|
|
73
|
+
--out-dir ../../../src/wasm/fs-database
|
|
71
74
|
|
|
72
75
|
wasm-pack build crates/query-parser \
|
|
73
76
|
--target no-modules \
|
|
74
|
-
--out-dir
|
|
77
|
+
--out-dir ../../../src/wasm/query-parser
|
|
78
|
+
|
|
79
|
+
wasm-pack build crates/default-embedding \
|
|
80
|
+
--target no-modules \
|
|
81
|
+
--out-dir ../../../src/wasm/default-embedding
|
|
75
82
|
|
|
76
83
|
wasm-pack build crates/kb-worker \
|
|
77
84
|
--target no-modules \
|
|
78
|
-
--out-dir
|
|
85
|
+
--out-dir ../../../src/wasm/kb-worker
|
|
79
86
|
```
|
|
80
87
|
|
|
81
88
|
### Size Optimization
|
|
@@ -115,6 +122,10 @@ src/shared/worker-daemon/
|
|
|
115
122
|
│ │ ├── query-parser.wasm
|
|
116
123
|
│ │ ├── query-parser.js
|
|
117
124
|
│ │ └── query-parser.d.ts
|
|
125
|
+
│ ├── default-embedding/
|
|
126
|
+
│ │ ├── default-embedding.wasm
|
|
127
|
+
│ │ ├── default-embedding.js
|
|
128
|
+
│ │ └── default-embedding.d.ts
|
|
118
129
|
│ └── kb-worker/
|
|
119
130
|
│ ├── kb-worker.wasm
|
|
120
131
|
│ ├── kb-worker.js
|
|
@@ -145,11 +156,14 @@ loadWasmModules(config)
|
|
|
145
156
|
│ (standalone, shared memory + host I/O)
|
|
146
157
|
│ ↑ steps 2 and 3 run in parallel
|
|
147
158
|
│
|
|
148
|
-
|
|
159
|
+
├─ 4. Compile + instantiate default-embedding.wasm
|
|
160
|
+
│ (standalone, no host imports -- pure computation)
|
|
161
|
+
│
|
|
162
|
+
└─ 5. Compile + instantiate kb-worker.wasm
|
|
149
163
|
(imports query-parser + fs-database exports)
|
|
150
164
|
```
|
|
151
165
|
|
|
152
|
-
All
|
|
166
|
+
All four WASM modules share one `WebAssembly.Memory`
|
|
153
167
|
instance. Data crosses module boundaries via
|
|
154
168
|
`(pointer, length)` pairs encoded with the `Encode`
|
|
155
169
|
trait from `kbdb-shared`.
|
|
@@ -163,7 +177,7 @@ TypeScript module directly accesses WASM files or the
|
|
|
163
177
|
## Phase 3 -- TypeScript Modules
|
|
164
178
|
|
|
165
179
|
All TypeScript logic lives under `src/shared/` in
|
|
166
|
-
|
|
180
|
+
9 sub-modules. Two thin entry points at the project
|
|
167
181
|
root dispatch into them.
|
|
168
182
|
|
|
169
183
|
### Entry Points
|
|
@@ -186,24 +200,31 @@ root dispatch into them.
|
|
|
186
200
|
| `runtime/` | Deno / Node.js detection |
|
|
187
201
|
| `platform/` | OS abstractions (tmpdir, PID, IPC paths) |
|
|
188
202
|
| `hash/` | SHA-256 via Web Crypto API |
|
|
203
|
+
| `log/` | Structured logging with configurable levels and ANSI formatting |
|
|
189
204
|
|
|
190
205
|
### Module Dependencies
|
|
191
206
|
|
|
192
207
|
```
|
|
193
208
|
src/cli.ts
|
|
194
209
|
├── shared/cli/ ──→ shared/worker-client/
|
|
210
|
+
│ └── shared/log/
|
|
195
211
|
└── shared/mcp/ ──→ shared/worker-client/
|
|
196
|
-
|
|
197
|
-
|
|
212
|
+
│ ├── shared/platform/
|
|
213
|
+
│ ├── shared/hash/
|
|
214
|
+
│ └── shared/log/
|
|
215
|
+
└── shared/log/
|
|
198
216
|
|
|
199
217
|
src/worker.ts
|
|
200
218
|
└── shared/worker-daemon/
|
|
201
219
|
├── shared/platform/
|
|
220
|
+
├── shared/log/
|
|
202
221
|
└── wasm/ (fs-database, query-parser,
|
|
203
|
-
kb-worker)
|
|
222
|
+
default-embedding, kb-worker)
|
|
204
223
|
|
|
205
224
|
mod.ts
|
|
206
225
|
└── shared/version/
|
|
226
|
+
|
|
227
|
+
shared/log/ (no dependencies -- standalone)
|
|
207
228
|
```
|
|
208
229
|
|
|
209
230
|
**Full TypeScript architecture:**
|
|
@@ -266,7 +287,7 @@ are loaded at runtime by the daemon via
|
|
|
266
287
|
## Full Build Sequence
|
|
267
288
|
|
|
268
289
|
```sh
|
|
269
|
-
# 1. Build WASM (Rust → .wasm → src/
|
|
290
|
+
# 1. Build WASM (Rust → .wasm → src/wasm/)
|
|
270
291
|
npm run build:wasm
|
|
271
292
|
|
|
272
293
|
# 2. Build TypeScript (src/ → dist/)
|
|
@@ -282,8 +303,8 @@ npm run build:all
|
|
|
282
303
|
build:all
|
|
283
304
|
│
|
|
284
305
|
├─ build:wasm
|
|
285
|
-
│ ├─ cargo build (
|
|
286
|
-
│ └─ wasm-pack build (
|
|
306
|
+
│ ├─ cargo build (5 crates)
|
|
307
|
+
│ └─ wasm-pack build (4 cdylib → wasm/)
|
|
287
308
|
│
|
|
288
309
|
└─ build
|
|
289
310
|
├─ esbuild (2 entry points → dist/)
|
|
@@ -294,5 +315,5 @@ build:all
|
|
|
294
315
|
|
|
295
316
|
| Layer | Overview | Modules |
|
|
296
317
|
|------------|-----------------------------------|---------|
|
|
297
|
-
| Rust/WASM | [rust/overview.md](rust/overview.md) |
|
|
298
|
-
| TypeScript | [typescript/overview.md](typescript/overview.md) | 2 entry points,
|
|
318
|
+
| Rust/WASM | [rust/overview.md](rust/overview.md) | 5 crates, 9 shared namespaces |
|
|
319
|
+
| TypeScript | [typescript/overview.md](typescript/overview.md) | 2 entry points, 9 shared modules |
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# default-embedding -- TF-IDF Vector Computation
|
|
2
|
+
|
|
3
|
+
**Source:** `engine/crates/default-embedding/`
|
|
4
|
+
**Crate type:** `cdylib` + `rlib`
|
|
5
|
+
**Output:** `default-embedding.wasm`
|
|
6
|
+
|
|
7
|
+
## Responsibility
|
|
8
|
+
|
|
9
|
+
Computes feature-hashed sublinear TF vectors for the
|
|
10
|
+
default embedding provider. Reuses kbdb-shared's
|
|
11
|
+
9-stage tokenization pipeline (NFC normalization,
|
|
12
|
+
Unicode segmentation, camelCase splitting, stop-word
|
|
13
|
+
removal, synonym expansion, Snowball stemming) so
|
|
14
|
+
that TF-IDF vectors are token-consistent with the
|
|
15
|
+
lexical index.
|
|
16
|
+
|
|
17
|
+
No host imports -- pure computation with no file I/O.
|
|
18
|
+
The WASM module is instantiated without an import
|
|
19
|
+
object.
|
|
20
|
+
|
|
21
|
+
## Algorithm
|
|
22
|
+
|
|
23
|
+
1. Tokenize text via `kbdb_shared::pipeline::tokenize`
|
|
24
|
+
2. Count term frequencies on stemmed tokens
|
|
25
|
+
3. Hash each stemmed token to a bucket using FNV-1a:
|
|
26
|
+
`bucket = fnv1a(token) % 256`
|
|
27
|
+
4. Apply sign trick to reduce collision bias:
|
|
28
|
+
`sign = if fnv1a(token + "_s") % 2 == 0 { 1 } else { -1 }`
|
|
29
|
+
5. Accumulate `sign * (1.0 + tf.ln())` per bucket
|
|
30
|
+
(sublinear TF provides diminishing returns for
|
|
31
|
+
repeated terms)
|
|
32
|
+
6. L2-normalize the vector
|
|
33
|
+
|
|
34
|
+
Output: 256-dimensional `Float32Array`, suitable for
|
|
35
|
+
cosine similarity via `cosineSimilarity()` in the
|
|
36
|
+
TypeScript embedding module.
|
|
37
|
+
|
|
38
|
+
## Directory Layout
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
engine/crates/default-embedding/
|
|
42
|
+
├── Cargo.toml
|
|
43
|
+
└── src/
|
|
44
|
+
├── lib.rs ← WASM exports
|
|
45
|
+
├── mem.rs ← shared-memory helpers
|
|
46
|
+
├── fnv1a.rs ← FNV-1a hash function
|
|
47
|
+
└── feature_hash.rs ← feature hashing + L2 norm
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## WASM Exports
|
|
51
|
+
|
|
52
|
+
| Export | Signature | Description |
|
|
53
|
+
|-------------------------------|------------------------|-------------|
|
|
54
|
+
| `embedding_tfidf` | `(ptr, len) -> u32` | Single text → 256×f32 vector |
|
|
55
|
+
| `embedding_tfidf_batch` | `(ptr, len) -> u32` | Newline-delimited texts → count + count×256 f32s |
|
|
56
|
+
| `embedding_dimensions` | `() -> u32` | Returns 256 |
|
|
57
|
+
| `embedding_model_name` | `(ptr, len) -> u32` | Writes `tfidf-v1` to return slot |
|
|
58
|
+
|
|
59
|
+
All exports use the standard return-slot protocol:
|
|
60
|
+
result data is written via `mem::set_return(ptr, len)`
|
|
61
|
+
and read by TypeScript via `get_return_ptr` /
|
|
62
|
+
`get_return_len`.
|
|
63
|
+
|
|
64
|
+
## Dependencies
|
|
65
|
+
|
|
66
|
+
```toml
|
|
67
|
+
[dependencies]
|
|
68
|
+
kbdb-shared = { path = "../shared" }
|
|
69
|
+
wasm-bindgen = "0.2"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- **kbdb-shared** -- memory management (`kbdb_alloc`,
|
|
73
|
+
`kbdb_free`, `set_return`, `read_str`) and
|
|
74
|
+
tokenization pipeline (`pipeline::tokenize`,
|
|
75
|
+
`pipeline::TokenResult`)
|
|
76
|
+
|
|
77
|
+
## Dependency Direction
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
kbdb-shared (rlib)
|
|
81
|
+
│ provides: memory, pipeline::tokenize
|
|
82
|
+
│
|
|
83
|
+
└──→ kbdb-default-embedding (cdylib)
|
|
84
|
+
uses: shared memory + shared tokenization
|
|
85
|
+
consumed by: TypeScript TfidfEmbeddingProvider
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The embedding crate is a leaf in the dependency graph.
|
|
89
|
+
No other Rust crate depends on it. It is loaded as a
|
|
90
|
+
standalone WASM instance by the TypeScript worker
|
|
91
|
+
daemon.
|
|
@@ -27,7 +27,7 @@ other file. Code sharing requires a crate dependency.
|
|
|
27
27
|
## Workspace
|
|
28
28
|
|
|
29
29
|
All Rust code lives in `engine/`. The workspace
|
|
30
|
-
contains
|
|
30
|
+
contains six crates under `engine/crates/`:
|
|
31
31
|
|
|
32
32
|
```
|
|
33
33
|
engine/
|
|
@@ -38,6 +38,8 @@ engine/
|
|
|
38
38
|
└── crates/
|
|
39
39
|
├── shared/ ← rlib (library)
|
|
40
40
|
├── fs-database/ ← cdylib (→ .wasm)
|
|
41
|
+
├── fs-migration/ ← cdylib (→ .wasm)
|
|
42
|
+
├── default-embedding/ ← cdylib (→ .wasm)
|
|
41
43
|
├── query-parser/ ← cdylib (→ .wasm)
|
|
42
44
|
└── kb-worker/ ← cdylib (→ .wasm)
|
|
43
45
|
```
|
|
@@ -61,6 +63,7 @@ WASM binary.
|
|
|
61
63
|
|
|
62
64
|
- **`kbdb-fs-database`** → `fs-database.wasm`
|
|
63
65
|
- **`kbdb-query-parser`** → `query-parser.wasm`
|
|
66
|
+
- **`kbdb-default-embedding`** → `default-embedding.wasm`
|
|
64
67
|
- **`kbdb-worker`** → `kb-worker.wasm`
|
|
65
68
|
|
|
66
69
|
## Crate Dependency Graph
|
|
@@ -74,6 +77,9 @@ kbdb-shared (rlib)
|
|
|
74
77
|
├──→ kbdb-query-parser (cdylib)
|
|
75
78
|
│ produces: query-parser.wasm
|
|
76
79
|
│
|
|
80
|
+
├──→ kbdb-default-embedding (cdylib)
|
|
81
|
+
│ produces: default-embedding.wasm
|
|
82
|
+
│
|
|
77
83
|
└──→ kbdb-worker (cdylib)
|
|
78
84
|
produces: kb-worker.wasm
|
|
79
85
|
also depends on:
|
|
@@ -102,11 +108,11 @@ have **no dependency** on each other or on `kb-worker`.
|
|
|
102
108
|
## Build Order
|
|
103
109
|
|
|
104
110
|
```
|
|
105
|
-
1. kbdb-shared
|
|
106
|
-
2. kbdb-fs-database
|
|
107
|
-
kbdb-query-parser
|
|
108
|
-
|
|
109
|
-
3. kbdb-worker
|
|
111
|
+
1. kbdb-shared (no deps, builds first)
|
|
112
|
+
2. kbdb-fs-database ┐ (all depend on shared,
|
|
113
|
+
kbdb-query-parser │ built in parallel)
|
|
114
|
+
kbdb-default-embedding┘
|
|
115
|
+
3. kbdb-worker (depends on all above)
|
|
110
116
|
```
|
|
111
117
|
|
|
112
118
|
## WASM Output
|
|
@@ -119,12 +125,15 @@ dist/wasm/
|
|
|
119
125
|
├── query-parser/
|
|
120
126
|
│ ├── query-parser.wasm
|
|
121
127
|
│ └── query-parser.js
|
|
128
|
+
├── embedding/
|
|
129
|
+
│ ├── default-embedding.wasm
|
|
130
|
+
│ └── default-embedding.js
|
|
122
131
|
└── kb-worker/
|
|
123
132
|
├── kb-worker.wasm
|
|
124
133
|
└── kb-worker.js
|
|
125
134
|
```
|
|
126
135
|
|
|
127
|
-
All
|
|
136
|
+
All modules share one `WebAssembly.Memory`
|
|
128
137
|
instance at runtime. Data crosses module boundaries
|
|
129
138
|
via `(pointer, length)` pairs encoded with the
|
|
130
139
|
`Encode` trait from `kbdb-shared`.
|
|
@@ -209,6 +218,19 @@ engine/crates/shared/
|
|
|
209
218
|
│ ├── compose.rs
|
|
210
219
|
│ └── render.rs
|
|
211
220
|
│
|
|
221
|
+
├── pipeline/ ← 9-stage tokenizer
|
|
222
|
+
│ ├── mod.rs
|
|
223
|
+
│ ├── markers.rs
|
|
224
|
+
│ ├── unicode.rs
|
|
225
|
+
│ ├── segment.rs
|
|
226
|
+
│ ├── identifiers.rs
|
|
227
|
+
│ ├── case.rs
|
|
228
|
+
│ ├── stopwords.rs
|
|
229
|
+
│ ├── synonyms.rs
|
|
230
|
+
│ ├── stem.rs
|
|
231
|
+
│ ├── ngram.rs
|
|
232
|
+
│ └── token_result.rs
|
|
233
|
+
│
|
|
212
234
|
└── error/ ← error hierarchy
|
|
213
235
|
├── mod.rs
|
|
214
236
|
└── error.rs
|
|
@@ -256,8 +278,9 @@ Detailed docs:
|
|
|
256
278
|
|
|
257
279
|
### kbdb-query-parser (cdylib → .wasm)
|
|
258
280
|
|
|
259
|
-
|
|
260
|
-
|
|
281
|
+
Query parsing, keyword extraction, and ranking.
|
|
282
|
+
Tokenization is imported from `kbdb-shared`'s
|
|
283
|
+
`pipeline` module.
|
|
261
284
|
|
|
262
285
|
```
|
|
263
286
|
engine/crates/query-parser/
|
|
@@ -266,18 +289,6 @@ engine/crates/query-parser/
|
|
|
266
289
|
├── lib.rs ← WASM exports
|
|
267
290
|
├── mem.rs ← shared-memory helpers
|
|
268
291
|
│
|
|
269
|
-
├── pipeline/ ← 9-stage tokenizer
|
|
270
|
-
│ ├── mod.rs
|
|
271
|
-
│ ├── markers.rs
|
|
272
|
-
│ ├── unicode.rs
|
|
273
|
-
│ ├── segment.rs
|
|
274
|
-
│ ├── identifiers.rs
|
|
275
|
-
│ ├── case.rs
|
|
276
|
-
│ ├── stopwords.rs
|
|
277
|
-
│ ├── synonyms.rs
|
|
278
|
-
│ ├── stem.rs
|
|
279
|
-
│ └── ngram.rs
|
|
280
|
-
│
|
|
281
292
|
├── parse.rs ← query → QueryPlan
|
|
282
293
|
│
|
|
283
294
|
├── extract/ ← keyword extraction
|
|
@@ -298,6 +309,27 @@ engine/crates/query-parser/
|
|
|
298
309
|
Detailed docs:
|
|
299
310
|
[query-parser/module.md](query-parser/module.md)
|
|
300
311
|
|
|
312
|
+
### kbdb-default-embedding (cdylib → .wasm)
|
|
313
|
+
|
|
314
|
+
TF-IDF embedding computation. Reuses kbdb-shared's
|
|
315
|
+
tokenization pipeline to produce feature-hashed
|
|
316
|
+
sublinear TF vectors (256 dimensions, L2-normalized).
|
|
317
|
+
Depends only on `kbdb-shared`. No host imports --
|
|
318
|
+
pure computation with no file I/O.
|
|
319
|
+
|
|
320
|
+
```
|
|
321
|
+
engine/crates/default-embedding/
|
|
322
|
+
├── Cargo.toml
|
|
323
|
+
└── src/
|
|
324
|
+
├── lib.rs ← WASM exports
|
|
325
|
+
├── mem.rs ← shared-memory helpers
|
|
326
|
+
├── fnv1a.rs ← FNV-1a hash function
|
|
327
|
+
└── feature_hash.rs ← feature hashing + L2 norm
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Detailed docs:
|
|
331
|
+
[embedding/module.md](embedding/module.md)
|
|
332
|
+
|
|
301
333
|
### kbdb-worker (cdylib → .wasm)
|
|
302
334
|
|
|
303
335
|
Orchestration layer. Imports the other two WASM
|
|
@@ -483,6 +515,9 @@ docs/modules/rust/
|
|
|
483
515
|
│ ├── functions/
|
|
484
516
|
│ └── ...
|
|
485
517
|
│
|
|
518
|
+
├── embedding/ ← kbdb-default-embedding crate
|
|
519
|
+
│ └── module.md
|
|
520
|
+
│
|
|
486
521
|
└── kb-worker/ ← kbdb-worker crate
|
|
487
522
|
├── module.md
|
|
488
523
|
├── types/
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# query-parser/functions -- Operations
|
|
2
2
|
|
|
3
|
-
*Functions for
|
|
4
|
-
|
|
3
|
+
*Functions for query parsing, keyword extraction,
|
|
4
|
+
and ranking.*
|
|
5
5
|
|
|
6
6
|
## Modules
|
|
7
7
|
|
|
8
|
-
- **[pipeline](pipeline.md)** -- 9-stage tokenization
|
|
9
|
-
pipeline. Converts raw text into normalized, stemmed
|
|
10
|
-
tokens with synonym expansion and n-grams.
|
|
11
8
|
- **[parse](parse.md)** -- Query string parsing into
|
|
12
9
|
structured `QueryPlan`.
|
|
13
10
|
- **[extract](extract.md)** -- RAKE keyphrase
|
|
14
11
|
extraction and TF-IDF term weighting.
|
|
15
12
|
- **[rank](rank.md)** -- BM25F, proximity, zone, and
|
|
16
13
|
freshness scoring functions.
|
|
14
|
+
|
|
15
|
+
Tokenization is provided by
|
|
16
|
+
[kbdb-shared pipeline](../../shared/pipeline/functions.md).
|
|
17
|
+
This crate re-exports it via the `qp_tokenize`
|
|
18
|
+
WASM export.
|
|
@@ -1,141 +1,9 @@
|
|
|
1
|
-
# functions::pipeline --
|
|
1
|
+
# functions::pipeline -- Moved to kbdb-shared
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
normalized, stemmed tokens with synonym expansion.
|
|
5
|
-
Used for both indexing and query processing.*
|
|
3
|
+
The tokenization pipeline has moved to `kbdb-shared`.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
See [shared/pipeline/functions.md](../../shared/pipeline/functions.md)
|
|
6
|
+
for the full documentation.
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Entry Point
|
|
12
|
-
|
|
13
|
-
```rust
|
|
14
|
-
pub fn tokenize(input: &str) -> TokenStream;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Runs all nine stages in sequence. Each stage is a
|
|
18
|
-
pure function.
|
|
19
|
-
|
|
20
|
-
## Stages
|
|
21
|
-
|
|
22
|
-
### 1. Content Marker Stripping
|
|
23
|
-
|
|
24
|
-
```rust
|
|
25
|
-
use kbdb_shared::content_parser::strip_content_markers;
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Removes all six content marker types from the input
|
|
29
|
-
text before tokenization:
|
|
30
|
-
`$(image:)`, `$(code:)`, `$(text:)`, `$(document:)`,
|
|
31
|
-
`$(link:)`, `$(doc-link:)`.
|
|
32
|
-
|
|
33
|
-
Delegates to `strip_content_markers()` imported from
|
|
34
|
-
`kbdb_shared::content_parser` (see
|
|
35
|
-
[Content Parser](../../shared/content-parser/module.md)).
|
|
36
|
-
These are structural references, not searchable
|
|
37
|
-
content.
|
|
38
|
-
|
|
39
|
-
### 2. Unicode Normalization (`unicode.rs`)
|
|
40
|
-
|
|
41
|
-
```rust
|
|
42
|
-
pub fn normalize_nfc(input: &str) -> String;
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
NFC normalization for consistent codepoints.
|
|
46
|
-
|
|
47
|
-
### 3. Word Boundary Detection (`segment.rs`)
|
|
48
|
-
|
|
49
|
-
```rust
|
|
50
|
-
pub fn segment_words(input: &str) -> Vec<&str>;
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Unicode Segmentation (UAX #29).
|
|
54
|
-
|
|
55
|
-
### 4. Identifier Splitting (`identifiers.rs`)
|
|
56
|
-
|
|
57
|
-
```rust
|
|
58
|
-
pub fn split_identifiers(word: &str) -> Vec<String>;
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
- `camelCase` → `["camel", "case"]`
|
|
62
|
-
- `snake_case` → `["snake", "case"]`
|
|
63
|
-
- `PascalCase` → `["pascal", "case"]`
|
|
64
|
-
- `HTMLParser` → `["html", "parser"]`
|
|
65
|
-
|
|
66
|
-
### 5. Case Folding (`case.rs`)
|
|
67
|
-
|
|
68
|
-
```rust
|
|
69
|
-
pub fn fold_case(word: &str) -> String;
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Unicode case folding (lowercase).
|
|
73
|
-
|
|
74
|
-
### 6. Stop Word Removal (`stopwords.rs`)
|
|
75
|
-
|
|
76
|
-
```rust
|
|
77
|
-
pub fn is_stop_word(word: &str) -> bool;
|
|
78
|
-
pub fn remove_stop_words(
|
|
79
|
-
words: &[String],
|
|
80
|
-
) -> Vec<String>;
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
Filters common function words. Single-character
|
|
84
|
-
tokens also removed.
|
|
85
|
-
|
|
86
|
-
### 7. Synonym Expansion (`synonyms.rs`)
|
|
87
|
-
|
|
88
|
-
```rust
|
|
89
|
-
pub fn expand_synonyms(
|
|
90
|
-
word: &str,
|
|
91
|
-
map: &SynonymMap,
|
|
92
|
-
) -> Vec<String>;
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Looks up the lowercased word in the built-in synonym
|
|
96
|
-
map. Returns a vector containing the original word
|
|
97
|
-
plus any synonyms. When no synonyms exist, returns a
|
|
98
|
-
single-element vector containing only the original.
|
|
99
|
-
|
|
100
|
-
The synonym map is a bidirectional
|
|
101
|
-
`HashMap<String, Vec<String>>` built at compile time.
|
|
102
|
-
Expansion is applied after stop-word removal and
|
|
103
|
-
before stemming, so both original and synonym tokens
|
|
104
|
-
are stemmed consistently.
|
|
105
|
-
|
|
106
|
-
The map is small (~30-50 entries) and focused on
|
|
107
|
-
common IT/development vocabulary mismatches:
|
|
108
|
-
login/sign-in, auth/authentication, remove/delete,
|
|
109
|
-
config/configuration, credential/password, etc.
|
|
110
|
-
|
|
111
|
-
### 8. Stemming (`stem.rs`)
|
|
112
|
-
|
|
113
|
-
```rust
|
|
114
|
-
pub fn stem_word(word: &str) -> StemResult;
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Snowball / Porter2. Preserves both original and
|
|
118
|
-
stemmed forms.
|
|
119
|
-
|
|
120
|
-
### 9. N-gram Extraction (`ngram.rs`)
|
|
121
|
-
|
|
122
|
-
```rust
|
|
123
|
-
pub fn extract_ngrams(
|
|
124
|
-
tokens: &[Token],
|
|
125
|
-
) -> Vec<Ngram>;
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
Bigrams and trigrams for phrase indexing.
|
|
129
|
-
|
|
130
|
-
## Relaxed Query Mode
|
|
131
|
-
|
|
132
|
-
The tokenization pipeline is used for both the
|
|
133
|
-
primary AND-mode query plan and the relaxed OR-mode
|
|
134
|
-
fallback plan. `qp_parse_query` produces a
|
|
135
|
-
`QueryPlan` with a `match_mode` field (`All` | `Any`).
|
|
136
|
-
When the AND plan returns zero matches,
|
|
137
|
-
`kb-worker.wasm` retries with the OR plan using the
|
|
138
|
-
same tokenized terms. No additional pipeline stage or
|
|
139
|
-
WASM export is needed. See
|
|
140
|
-
[Query Parser -- Relaxed Query
|
|
141
|
-
Mode](../../../goals/query-parser.md).
|
|
8
|
+
This crate re-exports the pipeline via the
|
|
9
|
+
`qp_tokenize` WASM FFI export.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# query-parser -- Query Processing and Tokenization
|
|
2
2
|
|
|
3
|
-
*Rust crate that provides
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
*Rust crate that provides query parsing, keyword
|
|
4
|
+
extraction, and ranking functions. Tokenization is
|
|
5
|
+
imported from `kbdb-shared`'s `pipeline` module.
|
|
6
|
+
Compiles to `query-parser.wasm`.*
|
|
6
7
|
|
|
7
8
|
## Crate
|
|
8
9
|
|
|
@@ -41,17 +42,6 @@ engine/crates/query-parser/
|
|
|
41
42
|
└── src/
|
|
42
43
|
├── lib.rs # crate root, WASM exports
|
|
43
44
|
├── mem.rs # shared-memory helpers
|
|
44
|
-
├── pipeline/
|
|
45
|
-
│ ├── mod.rs # pipeline orchestrator
|
|
46
|
-
│ ├── markers.rs # stage 1: strip markers
|
|
47
|
-
│ ├── unicode.rs # stage 2: NFC normalize
|
|
48
|
-
│ ├── segment.rs # stage 3: word boundaries
|
|
49
|
-
│ ├── identifiers.rs # stage 4: camelCase split
|
|
50
|
-
│ ├── case.rs # stage 5: case folding
|
|
51
|
-
│ ├── stopwords.rs # stage 6: stop words
|
|
52
|
-
│ ├── synonyms.rs # stage 7: synonym expansion
|
|
53
|
-
│ ├── stem.rs # stage 8: Snowball stemmer
|
|
54
|
-
│ └── ngram.rs # stage 9: n-gram extract
|
|
55
45
|
├── parse.rs # query string → QueryPlan
|
|
56
46
|
├── extract/
|
|
57
47
|
│ ├── mod.rs # extraction facade
|
|
@@ -66,6 +56,11 @@ engine/crates/query-parser/
|
|
|
66
56
|
└── cache.rs # query-scoped cache
|
|
67
57
|
```
|
|
68
58
|
|
|
59
|
+
The tokenization pipeline lives in `kbdb-shared`'s
|
|
60
|
+
[pipeline](../shared/pipeline/module.md) module.
|
|
61
|
+
This crate re-exports it via WASM FFI
|
|
62
|
+
(`qp_tokenize`).
|
|
63
|
+
|
|
69
64
|
## Modules
|
|
70
65
|
|
|
71
66
|
### [types/](types/module.md) -- Structs
|
|
@@ -79,10 +74,6 @@ engine/crates/query-parser/
|
|
|
79
74
|
|
|
80
75
|
### [functions/](functions/module.md) -- Operations
|
|
81
76
|
|
|
82
|
-
- **[pipeline](functions/pipeline.md)** -- 9-stage
|
|
83
|
-
tokenization pipeline. Marker stripping, NFC,
|
|
84
|
-
segmentation, identifier splitting, case folding,
|
|
85
|
-
stop words, synonym expansion, stemming, n-grams.
|
|
86
77
|
- **[parse](functions/parse.md)** -- Query string
|
|
87
78
|
parsing into `QueryPlan`.
|
|
88
79
|
- **[extract](functions/extract.md)** -- RAKE
|
|
@@ -90,6 +81,9 @@ engine/crates/query-parser/
|
|
|
90
81
|
- **[rank](functions/rank.md)** -- BM25F, proximity,
|
|
91
82
|
zone, and freshness scoring functions.
|
|
92
83
|
|
|
84
|
+
Tokenization is provided by
|
|
85
|
+
[kbdb-shared pipeline](../shared/pipeline/module.md).
|
|
86
|
+
|
|
93
87
|
## WASM Exports
|
|
94
88
|
|
|
95
89
|
| Export | Description |
|
|
@@ -114,12 +108,12 @@ engine/crates/query-parser/
|
|
|
114
108
|
```toml
|
|
115
109
|
[dependencies]
|
|
116
110
|
kbdb-shared = { path = "../shared" }
|
|
117
|
-
unicode-segmentation = "1"
|
|
118
|
-
unicode-normalization = "0.1"
|
|
119
|
-
rust-stemmers = "1"
|
|
120
|
-
regex = { version = "1", default-features = false }
|
|
121
111
|
```
|
|
122
112
|
|
|
113
|
+
Tokenization dependencies (`unicode-segmentation`,
|
|
114
|
+
`unicode-normalization`, `rust-stemmers`) are now in
|
|
115
|
+
`kbdb-shared` alongside the `pipeline` module.
|
|
116
|
+
|
|
123
117
|
## Build
|
|
124
118
|
|
|
125
119
|
```sh
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# query-parser/types -- Type Definitions
|
|
2
2
|
|
|
3
3
|
*Structs defined in the query-parser crate for
|
|
4
|
-
|
|
4
|
+
keyword extraction and ranking.*
|
|
5
5
|
|
|
6
6
|
## Modules
|
|
7
7
|
|
|
8
|
-
- **[token](token.md)** -- `Token`, `TokenStream`,
|
|
9
|
-
`Ngram`, `NgramType`, `StemResult`. Output types
|
|
10
|
-
from the tokenization pipeline.
|
|
11
8
|
- **[keyphrase](keyphrase.md)** -- `Keyphrase`,
|
|
12
9
|
`WeightedTerm`, `BM25FParams`, `FieldWeights`,
|
|
13
10
|
`SynonymMap`. Types for keyword extraction, ranking
|
|
@@ -15,3 +12,7 @@ tokenization, keyword extraction, and ranking.*
|
|
|
15
12
|
- **[cache](cache.md)** -- `QueryCache`. Short-lived
|
|
16
13
|
cache scoped to a single query or indexing
|
|
17
14
|
operation.
|
|
15
|
+
|
|
16
|
+
Token types (`Token`, `TokenStream`, `Ngram`,
|
|
17
|
+
`NgramType`, `StemResult`) are defined in
|
|
18
|
+
[kbdb-shared pipeline](../../shared/pipeline/types.md).
|