@vpxa/kb 0.1.13 → 0.1.16
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 +65 -12
- package/package.json +14 -7
- package/packages/analyzers/dist/blast-radius-analyzer.d.ts +17 -21
- package/packages/analyzers/dist/blast-radius-analyzer.js +5 -12
- package/packages/analyzers/dist/dependency-analyzer.d.ts +31 -28
- package/packages/analyzers/dist/dependency-analyzer.js +6 -9
- package/packages/analyzers/dist/diagram-generator.d.ts +12 -9
- package/packages/analyzers/dist/diagram-generator.js +2 -4
- package/packages/analyzers/dist/entry-point-analyzer.d.ts +39 -36
- package/packages/analyzers/dist/entry-point-analyzer.js +4 -6
- package/packages/analyzers/dist/index.d.ts +12 -14
- package/packages/analyzers/dist/index.js +1 -1
- package/packages/analyzers/dist/knowledge-producer.d.ts +34 -26
- package/packages/analyzers/dist/knowledge-producer.js +17 -15
- package/packages/analyzers/dist/pattern-analyzer.d.ts +14 -11
- package/packages/analyzers/dist/pattern-analyzer.js +2 -5
- package/packages/analyzers/dist/regex-call-graph.d.ts +6 -13
- package/packages/analyzers/dist/regex-call-graph.js +1 -1
- package/packages/analyzers/dist/structure-analyzer.d.ts +13 -10
- package/packages/analyzers/dist/structure-analyzer.js +2 -4
- package/packages/analyzers/dist/symbol-analyzer.d.ts +13 -9
- package/packages/analyzers/dist/symbol-analyzer.js +9 -13
- package/packages/analyzers/dist/ts-call-graph.d.ts +16 -14
- package/packages/analyzers/dist/ts-call-graph.js +1 -1
- package/packages/analyzers/dist/types.d.ts +82 -80
- package/packages/analyzers/dist/types.js +1 -0
- package/packages/chunker/dist/call-graph-extractor.d.ts +15 -12
- package/packages/chunker/dist/call-graph-extractor.js +1 -1
- package/packages/chunker/dist/chunker-factory.d.ts +16 -4
- package/packages/chunker/dist/chunker-factory.js +1 -1
- package/packages/chunker/dist/chunker.interface.d.ts +8 -5
- package/packages/chunker/dist/chunker.interface.js +1 -0
- package/packages/chunker/dist/code-chunker.d.ts +16 -13
- package/packages/chunker/dist/code-chunker.js +11 -14
- package/packages/chunker/dist/extractors/call-extractor.d.ts +24 -0
- package/packages/chunker/dist/extractors/call-extractor.js +1 -0
- package/packages/chunker/dist/extractors/entry-point-detector.d.ts +14 -0
- package/packages/chunker/dist/extractors/entry-point-detector.js +1 -0
- package/packages/chunker/dist/extractors/import-extractor.d.ts +14 -0
- package/packages/chunker/dist/extractors/import-extractor.js +1 -0
- package/packages/chunker/dist/extractors/pattern-detector.d.ts +14 -0
- package/packages/chunker/dist/extractors/pattern-detector.js +1 -0
- package/packages/chunker/dist/extractors/scope-resolver.d.ts +26 -0
- package/packages/chunker/dist/extractors/scope-resolver.js +1 -0
- package/packages/chunker/dist/extractors/symbol-extractor.d.ts +14 -0
- package/packages/chunker/dist/extractors/symbol-extractor.js +1 -0
- package/packages/chunker/dist/extractors/types.d.ts +36 -0
- package/packages/chunker/dist/extractors/types.js +1 -0
- package/packages/chunker/dist/generic-chunker.d.ts +14 -11
- package/packages/chunker/dist/generic-chunker.js +5 -5
- package/packages/chunker/dist/index.d.ts +19 -8
- package/packages/chunker/dist/index.js +1 -1
- package/packages/chunker/dist/markdown-chunker.d.ts +16 -13
- package/packages/chunker/dist/markdown-chunker.js +3 -10
- package/packages/chunker/dist/wasm/languages.d.ts +18 -0
- package/packages/chunker/dist/wasm/languages.js +1 -0
- package/packages/chunker/dist/wasm/query-executor.d.ts +70 -0
- package/packages/chunker/dist/wasm/query-executor.js +1 -0
- package/packages/chunker/dist/wasm/runtime.d.ts +44 -0
- package/packages/chunker/dist/wasm/runtime.js +1 -0
- package/packages/chunker/dist/wasm/types.d.ts +84 -0
- package/packages/chunker/dist/wasm/types.js +1 -0
- package/packages/chunker/dist/wasm-chunker.d.ts +23 -0
- package/packages/chunker/dist/wasm-chunker.js +6 -0
- package/packages/chunker/src/queries/go/calls.scm +11 -0
- package/packages/chunker/src/queries/go/entry-points.scm +20 -0
- package/packages/chunker/src/queries/go/imports.scm +6 -0
- package/packages/chunker/src/queries/go/patterns.scm +25 -0
- package/packages/chunker/src/queries/go/symbols.scm +26 -0
- package/packages/chunker/src/queries/java/calls.scm +10 -0
- package/packages/chunker/src/queries/java/entry-points.scm +27 -0
- package/packages/chunker/src/queries/java/imports.scm +11 -0
- package/packages/chunker/src/queries/java/patterns.scm +27 -0
- package/packages/chunker/src/queries/java/symbols.scm +28 -0
- package/packages/chunker/src/queries/javascript/calls.scm +21 -0
- package/packages/chunker/src/queries/javascript/entry-points.scm +31 -0
- package/packages/chunker/src/queries/javascript/imports.scm +32 -0
- package/packages/chunker/src/queries/javascript/patterns.scm +28 -0
- package/packages/chunker/src/queries/javascript/symbols.scm +52 -0
- package/packages/chunker/src/queries/python/calls.scm +11 -0
- package/packages/chunker/src/queries/python/entry-points.scm +21 -0
- package/packages/chunker/src/queries/python/imports.scm +14 -0
- package/packages/chunker/src/queries/python/patterns.scm +25 -0
- package/packages/chunker/src/queries/python/symbols.scm +17 -0
- package/packages/chunker/src/queries/rust/calls.scm +20 -0
- package/packages/chunker/src/queries/rust/entry-points.scm +7 -0
- package/packages/chunker/src/queries/rust/imports.scm +26 -0
- package/packages/chunker/src/queries/rust/patterns.scm +18 -0
- package/packages/chunker/src/queries/rust/symbols.scm +73 -0
- package/packages/chunker/src/queries/typescript/calls.scm +21 -0
- package/packages/chunker/src/queries/typescript/entry-points.scm +48 -0
- package/packages/chunker/src/queries/typescript/imports.scm +35 -0
- package/packages/chunker/src/queries/typescript/patterns.scm +47 -0
- package/packages/chunker/src/queries/typescript/symbols.scm +79 -0
- package/packages/chunker/wasm/tree-sitter-go.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-java.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-javascript.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-python.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-rust.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter-typescript.wasm +0 -0
- package/packages/chunker/wasm/tree-sitter.wasm +0 -0
- package/packages/cli/dist/commands/analyze.d.ts +6 -3
- package/packages/cli/dist/commands/analyze.js +2 -3
- package/packages/cli/dist/commands/context-cmds.d.ts +6 -3
- package/packages/cli/dist/commands/context-cmds.js +1 -1
- package/packages/cli/dist/commands/environment.d.ts +6 -3
- package/packages/cli/dist/commands/environment.js +1 -2
- package/packages/cli/dist/commands/execution.d.ts +6 -3
- package/packages/cli/dist/commands/execution.js +1 -1
- package/packages/cli/dist/commands/graph.d.ts +6 -3
- package/packages/cli/dist/commands/graph.js +5 -6
- package/packages/cli/dist/commands/init/adapters.d.ts +28 -0
- package/packages/cli/dist/commands/init/adapters.js +1 -0
- package/packages/cli/dist/commands/init/config.d.ts +10 -0
- package/packages/cli/dist/commands/init/config.js +3 -0
- package/packages/cli/dist/commands/init/constants.d.ts +18 -0
- package/packages/cli/dist/commands/init/constants.js +1 -0
- package/packages/cli/dist/commands/init/curated.d.ts +7 -0
- package/packages/cli/dist/commands/init/curated.js +1 -0
- package/packages/cli/dist/commands/init/global.d.ts +34 -0
- package/packages/cli/dist/commands/init/global.js +5 -0
- package/packages/cli/dist/commands/init/index.d.ts +28 -0
- package/packages/cli/dist/commands/init/index.js +5 -0
- package/packages/cli/dist/commands/init/scaffold.d.ts +23 -0
- package/packages/cli/dist/commands/init/scaffold.js +1 -0
- package/packages/cli/dist/commands/init/templates.d.ts +9 -0
- package/packages/cli/dist/commands/init/templates.js +165 -0
- package/packages/cli/dist/commands/knowledge.d.ts +6 -3
- package/packages/cli/dist/commands/knowledge.js +1 -1
- package/packages/cli/dist/commands/search.d.ts +6 -3
- package/packages/cli/dist/commands/search.js +1 -8
- package/packages/cli/dist/commands/system.d.ts +6 -3
- package/packages/cli/dist/commands/system.js +4 -7
- package/packages/cli/dist/commands/workspace.d.ts +6 -3
- package/packages/cli/dist/commands/workspace.js +1 -2
- package/packages/cli/dist/context.d.ts +7 -5
- package/packages/cli/dist/context.js +1 -1
- package/packages/cli/dist/helpers.d.ts +51 -48
- package/packages/cli/dist/helpers.js +5 -5
- package/packages/cli/dist/index.d.ts +4 -2
- package/packages/cli/dist/index.js +2 -2
- package/packages/cli/dist/kb-init.d.ts +48 -51
- package/packages/cli/dist/kb-init.js +1 -1
- package/packages/cli/dist/types.d.ts +8 -6
- package/packages/cli/dist/types.js +1 -0
- package/packages/core/dist/constants.d.ts +58 -34
- package/packages/core/dist/constants.js +1 -1
- package/packages/core/dist/content-detector.d.ts +8 -8
- package/packages/core/dist/content-detector.js +1 -1
- package/packages/core/dist/errors.d.ts +15 -13
- package/packages/core/dist/errors.js +1 -1
- package/packages/core/dist/global-registry.d.ts +62 -0
- package/packages/core/dist/global-registry.js +1 -0
- package/packages/core/dist/index.d.ts +7 -6
- package/packages/core/dist/index.js +1 -1
- package/packages/core/dist/logger.d.ts +19 -8
- package/packages/core/dist/logger.js +1 -1
- package/packages/core/dist/types.d.ts +107 -92
- package/packages/core/dist/types.js +1 -0
- package/packages/embeddings/dist/embedder.interface.d.ts +22 -20
- package/packages/embeddings/dist/embedder.interface.js +1 -0
- package/packages/embeddings/dist/index.d.ts +3 -3
- package/packages/embeddings/dist/index.js +1 -1
- package/packages/embeddings/dist/onnx-embedder.d.ts +21 -23
- package/packages/embeddings/dist/onnx-embedder.js +1 -1
- package/packages/enterprise-bridge/dist/cache.d.ts +28 -0
- package/packages/enterprise-bridge/dist/cache.js +1 -0
- package/packages/enterprise-bridge/dist/er-client.d.ts +37 -0
- package/packages/enterprise-bridge/dist/er-client.js +1 -0
- package/packages/enterprise-bridge/dist/evolution-collector.d.ts +62 -0
- package/packages/enterprise-bridge/dist/evolution-collector.js +1 -0
- package/packages/enterprise-bridge/dist/index.d.ts +8 -0
- package/packages/enterprise-bridge/dist/index.js +1 -0
- package/packages/enterprise-bridge/dist/policy-store.d.ts +45 -0
- package/packages/enterprise-bridge/dist/policy-store.js +1 -0
- package/packages/enterprise-bridge/dist/push-adapter.d.ts +23 -0
- package/packages/enterprise-bridge/dist/push-adapter.js +1 -0
- package/packages/enterprise-bridge/dist/result-merger.d.ts +14 -0
- package/packages/enterprise-bridge/dist/result-merger.js +1 -0
- package/packages/enterprise-bridge/dist/types.d.ts +81 -0
- package/packages/enterprise-bridge/dist/types.js +1 -0
- package/packages/indexer/dist/file-hasher.d.ts +5 -3
- package/packages/indexer/dist/file-hasher.js +1 -1
- package/packages/indexer/dist/filesystem-crawler.d.ts +23 -21
- package/packages/indexer/dist/filesystem-crawler.js +1 -1
- package/packages/indexer/dist/graph-extractor.d.ts +9 -13
- package/packages/indexer/dist/graph-extractor.js +1 -1
- package/packages/indexer/dist/incremental-indexer.d.ts +49 -44
- package/packages/indexer/dist/incremental-indexer.js +1 -1
- package/packages/indexer/dist/index.d.ts +5 -5
- package/packages/indexer/dist/index.js +1 -1
- package/packages/server/dist/api.d.ts +3 -8
- package/packages/server/dist/api.js +1 -1
- package/packages/server/dist/config.d.ts +6 -3
- package/packages/server/dist/config.js +1 -1
- package/packages/server/dist/cross-workspace.d.ts +43 -0
- package/packages/server/dist/cross-workspace.js +1 -0
- package/packages/server/dist/curated-manager.d.ts +80 -78
- package/packages/server/dist/curated-manager.js +5 -10
- package/packages/server/dist/index.d.ts +1 -2
- package/packages/server/dist/index.js +1 -1
- package/packages/server/dist/replay-interceptor.d.ts +6 -7
- package/packages/server/dist/replay-interceptor.js +1 -1
- package/packages/server/dist/resources/resources.d.ts +7 -4
- package/packages/server/dist/resources/resources.js +2 -2
- package/packages/server/dist/server.d.ts +37 -25
- package/packages/server/dist/server.js +1 -1
- package/packages/server/dist/tools/analyze.tools.d.ts +14 -11
- package/packages/server/dist/tools/analyze.tools.js +1 -3
- package/packages/server/dist/tools/audit.tool.d.ts +8 -5
- package/packages/server/dist/tools/audit.tool.js +1 -4
- package/packages/server/dist/tools/bridge.tools.d.ts +34 -0
- package/packages/server/dist/tools/bridge.tools.js +15 -0
- package/packages/server/dist/tools/evolution.tools.d.ts +7 -0
- package/packages/server/dist/tools/evolution.tools.js +5 -0
- package/packages/server/dist/tools/forge.tools.d.ts +13 -12
- package/packages/server/dist/tools/forge.tools.js +10 -13
- package/packages/server/dist/tools/forget.tool.d.ts +7 -4
- package/packages/server/dist/tools/forget.tool.js +1 -7
- package/packages/server/dist/tools/graph.tool.d.ts +7 -4
- package/packages/server/dist/tools/graph.tool.js +4 -5
- package/packages/server/dist/tools/list.tool.d.ts +7 -4
- package/packages/server/dist/tools/list.tool.js +2 -8
- package/packages/server/dist/tools/lookup.tool.d.ts +7 -4
- package/packages/server/dist/tools/lookup.tool.js +2 -9
- package/packages/server/dist/tools/onboard.tool.d.ts +8 -5
- package/packages/server/dist/tools/onboard.tool.js +2 -2
- package/packages/server/dist/tools/policy.tools.d.ts +7 -0
- package/packages/server/dist/tools/policy.tools.js +2 -0
- package/packages/server/dist/tools/produce.tool.d.ts +6 -3
- package/packages/server/dist/tools/produce.tool.js +2 -2
- package/packages/server/dist/tools/read.tool.d.ts +7 -4
- package/packages/server/dist/tools/read.tool.js +2 -6
- package/packages/server/dist/tools/reindex.tool.d.ts +10 -7
- package/packages/server/dist/tools/reindex.tool.js +3 -2
- package/packages/server/dist/tools/remember.tool.d.ts +8 -4
- package/packages/server/dist/tools/remember.tool.js +3 -5
- package/packages/server/dist/tools/replay.tool.d.ts +6 -3
- package/packages/server/dist/tools/replay.tool.js +2 -6
- package/packages/server/dist/tools/search.tool.d.ts +10 -5
- package/packages/server/dist/tools/search.tool.js +6 -22
- package/packages/server/dist/tools/status.tool.d.ts +12 -4
- package/packages/server/dist/tools/status.tool.js +2 -3
- package/packages/server/dist/tools/toolkit.tools.d.ts +36 -35
- package/packages/server/dist/tools/toolkit.tools.js +20 -24
- package/packages/server/dist/tools/update.tool.d.ts +7 -4
- package/packages/server/dist/tools/update.tool.js +1 -6
- package/packages/server/dist/tools/utility.tools.d.ts +15 -15
- package/packages/server/dist/tools/utility.tools.js +10 -23
- package/packages/server/dist/version-check.d.ts +5 -2
- package/packages/server/dist/version-check.js +1 -1
- package/packages/store/dist/graph-store.interface.d.ts +89 -87
- package/packages/store/dist/graph-store.interface.js +1 -0
- package/packages/store/dist/index.d.ts +6 -6
- package/packages/store/dist/index.js +1 -1
- package/packages/store/dist/lance-store.d.ts +37 -31
- package/packages/store/dist/lance-store.js +1 -1
- package/packages/store/dist/sqlite-graph-store.d.ts +43 -47
- package/packages/store/dist/sqlite-graph-store.js +13 -13
- package/packages/store/dist/store-factory.d.ts +11 -8
- package/packages/store/dist/store-factory.js +1 -1
- package/packages/store/dist/store.interface.d.ts +47 -47
- package/packages/store/dist/store.interface.js +1 -0
- package/packages/tools/dist/audit.d.ts +61 -62
- package/packages/tools/dist/audit.js +4 -5
- package/packages/tools/dist/batch.d.ts +20 -18
- package/packages/tools/dist/batch.js +1 -1
- package/packages/tools/dist/changelog.d.ts +29 -27
- package/packages/tools/dist/changelog.js +2 -2
- package/packages/tools/dist/check.d.ts +42 -39
- package/packages/tools/dist/check.js +2 -2
- package/packages/tools/dist/checkpoint.d.ts +17 -15
- package/packages/tools/dist/checkpoint.js +1 -2
- package/packages/tools/dist/codemod.d.ts +35 -33
- package/packages/tools/dist/codemod.js +2 -2
- package/packages/tools/dist/compact.d.ts +34 -38
- package/packages/tools/dist/compact.js +2 -2
- package/packages/tools/dist/data-transform.d.ts +10 -8
- package/packages/tools/dist/data-transform.js +1 -1
- package/packages/tools/dist/dead-symbols.d.ts +29 -26
- package/packages/tools/dist/dead-symbols.js +2 -2
- package/packages/tools/dist/delegate.d.ts +26 -24
- package/packages/tools/dist/delegate.js +1 -5
- package/packages/tools/dist/diff-parse.d.ts +24 -22
- package/packages/tools/dist/diff-parse.js +3 -3
- package/packages/tools/dist/digest.d.ts +43 -46
- package/packages/tools/dist/digest.js +4 -5
- package/packages/tools/dist/dogfood-log.d.ts +49 -0
- package/packages/tools/dist/dogfood-log.js +2 -0
- package/packages/tools/dist/encode.d.ts +11 -9
- package/packages/tools/dist/encode.js +1 -1
- package/packages/tools/dist/env-info.d.ts +25 -23
- package/packages/tools/dist/env-info.js +1 -1
- package/packages/tools/dist/eval.d.ts +13 -11
- package/packages/tools/dist/eval.js +2 -3
- package/packages/tools/dist/evidence-map.d.ts +64 -62
- package/packages/tools/dist/evidence-map.js +2 -3
- package/packages/tools/dist/file-cache.d.ts +41 -0
- package/packages/tools/dist/file-cache.js +3 -0
- package/packages/tools/dist/file-summary.d.ts +50 -30
- package/packages/tools/dist/file-summary.js +2 -2
- package/packages/tools/dist/file-walk.d.ts +6 -4
- package/packages/tools/dist/file-walk.js +1 -1
- package/packages/tools/dist/find-examples.d.ts +26 -22
- package/packages/tools/dist/find-examples.js +3 -3
- package/packages/tools/dist/find.d.ts +39 -41
- package/packages/tools/dist/find.js +1 -1
- package/packages/tools/dist/forge-classify.d.ts +35 -39
- package/packages/tools/dist/forge-classify.js +2 -2
- package/packages/tools/dist/forge-ground.d.ts +58 -61
- package/packages/tools/dist/forge-ground.js +1 -1
- package/packages/tools/dist/git-context.d.ts +22 -20
- package/packages/tools/dist/git-context.js +3 -3
- package/packages/tools/dist/graph-query.d.ts +75 -79
- package/packages/tools/dist/graph-query.js +1 -1
- package/packages/tools/dist/guide.d.ts +14 -12
- package/packages/tools/dist/guide.js +1 -1
- package/packages/tools/dist/health.d.ts +13 -11
- package/packages/tools/dist/health.js +2 -2
- package/packages/tools/dist/http-request.d.ts +20 -18
- package/packages/tools/dist/http-request.js +1 -1
- package/packages/tools/dist/index.d.ts +55 -53
- package/packages/tools/dist/index.js +1 -1
- package/packages/tools/dist/lane.d.ts +28 -26
- package/packages/tools/dist/lane.js +6 -7
- package/packages/tools/dist/measure.d.ts +34 -30
- package/packages/tools/dist/measure.js +2 -2
- package/packages/tools/dist/onboard.d.ts +29 -27
- package/packages/tools/dist/onboard.js +17 -41
- package/packages/tools/dist/parse-output.d.ts +48 -46
- package/packages/tools/dist/parse-output.js +2 -2
- package/packages/tools/dist/path-resolver.d.ts +4 -2
- package/packages/tools/dist/path-resolver.js +1 -1
- package/packages/tools/dist/process-manager.d.ts +18 -16
- package/packages/tools/dist/process-manager.js +1 -1
- package/packages/tools/dist/queue.d.ts +28 -26
- package/packages/tools/dist/queue.js +1 -2
- package/packages/tools/dist/regex-test.d.ts +26 -24
- package/packages/tools/dist/regex-test.js +1 -1
- package/packages/tools/dist/rename.d.ts +28 -26
- package/packages/tools/dist/rename.js +2 -2
- package/packages/tools/dist/replay.d.ts +33 -31
- package/packages/tools/dist/replay.js +4 -6
- package/packages/tools/dist/response-envelope.d.ts +32 -30
- package/packages/tools/dist/response-envelope.js +1 -1
- package/packages/tools/dist/schema-validate.d.ts +15 -13
- package/packages/tools/dist/schema-validate.js +1 -1
- package/packages/tools/dist/scope-map.d.ts +45 -48
- package/packages/tools/dist/scope-map.js +1 -1
- package/packages/tools/dist/snippet.d.ts +26 -25
- package/packages/tools/dist/snippet.js +1 -1
- package/packages/tools/dist/stash.d.ts +13 -11
- package/packages/tools/dist/stash.js +1 -2
- package/packages/tools/dist/stratum-card.d.ts +27 -28
- package/packages/tools/dist/stratum-card.js +3 -5
- package/packages/tools/dist/symbol.d.ts +31 -26
- package/packages/tools/dist/symbol.js +3 -3
- package/packages/tools/dist/test-run.d.ts +19 -16
- package/packages/tools/dist/test-run.js +2 -2
- package/packages/tools/dist/text-utils.d.ts +6 -4
- package/packages/tools/dist/text-utils.js +2 -2
- package/packages/tools/dist/time-utils.d.ts +15 -13
- package/packages/tools/dist/time-utils.js +1 -1
- package/packages/tools/dist/trace.d.ts +26 -21
- package/packages/tools/dist/trace.js +2 -2
- package/packages/tools/dist/truncation.d.ts +6 -4
- package/packages/tools/dist/truncation.js +6 -13
- package/packages/tools/dist/watch.d.ts +28 -26
- package/packages/tools/dist/watch.js +1 -1
- package/packages/tools/dist/web-fetch.d.ts +35 -33
- package/packages/tools/dist/web-fetch.js +6 -12
- package/packages/tools/dist/web-search.d.ts +16 -14
- package/packages/tools/dist/web-search.js +1 -1
- package/packages/tools/dist/workset.d.ts +19 -17
- package/packages/tools/dist/workset.js +1 -2
- package/packages/tui/dist/App-CYLNJLr6.js +2 -0
- package/packages/tui/dist/App.d.ts +11 -6
- package/packages/tui/dist/App.js +1 -450
- package/packages/tui/dist/CuratedPanel-sYdZAICX.js +2 -0
- package/packages/tui/dist/LogPanel-DtMnoyXT.js +3 -0
- package/packages/tui/dist/SearchPanel-DREo6zgt.js +2 -0
- package/packages/tui/dist/StatusPanel-2ex8fLOO.js +2 -0
- package/packages/tui/dist/chunk-D6axbAb-.js +2 -0
- package/packages/tui/dist/devtools-DUyj952l.js +7 -0
- package/packages/tui/dist/embedder.interface-D4ew0HPW.d.ts +28 -0
- package/packages/tui/dist/index-B9VpfVPP.d.ts +13 -0
- package/packages/tui/dist/index.d.ts +3 -19
- package/packages/tui/dist/index.js +1 -476
- package/packages/tui/dist/jsx-runtime-Cof-kwFn.js +316 -0
- package/packages/tui/dist/panels/CuratedPanel.d.ts +11 -6
- package/packages/tui/dist/panels/CuratedPanel.js +1 -371
- package/packages/tui/dist/panels/LogPanel.d.ts +7 -3
- package/packages/tui/dist/panels/LogPanel.js +1 -449
- package/packages/tui/dist/panels/SearchPanel.d.ts +14 -8
- package/packages/tui/dist/panels/SearchPanel.js +1 -372
- package/packages/tui/dist/panels/StatusPanel.d.ts +11 -6
- package/packages/tui/dist/panels/StatusPanel.js +1 -371
- package/packages/tui/dist/store.interface-CnY6SPOH.d.ts +150 -0
- package/scaffold/adapters/claude-code.mjs +20 -0
- package/scaffold/adapters/copilot.mjs +320 -0
- package/scaffold/copilot/agents/Architect-Reviewer-Alpha.agent.md +21 -0
- package/scaffold/copilot/agents/Architect-Reviewer-Beta.agent.md +21 -0
- package/scaffold/copilot/agents/Documenter.agent.md +42 -0
- package/scaffold/copilot/agents/Orchestrator.agent.md +104 -0
- package/scaffold/copilot/agents/Planner.agent.md +54 -0
- package/scaffold/copilot/agents/Refactor.agent.md +36 -0
- package/scaffold/copilot/agents/Researcher-Alpha.agent.md +20 -0
- package/scaffold/copilot/agents/Researcher-Beta.agent.md +20 -0
- package/scaffold/copilot/agents/Researcher-Delta.agent.md +20 -0
- package/scaffold/copilot/agents/Researcher-Gamma.agent.md +20 -0
- package/scaffold/definitions/agents.mjs +165 -0
- package/scaffold/definitions/bodies.mjs +292 -0
- package/scaffold/definitions/hooks.mjs +43 -0
- package/scaffold/definitions/models.mjs +56 -0
- package/scaffold/definitions/plugins.mjs +24 -0
- package/scaffold/definitions/prompts.mjs +145 -0
- package/scaffold/definitions/protocols.mjs +322 -0
- package/scaffold/definitions/tools.mjs +176 -0
- package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +21 -0
- package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +21 -0
- package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +12 -0
- package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +12 -0
- package/scaffold/general/agents/Debugger.agent.md +31 -0
- package/scaffold/general/agents/Documenter.agent.md +42 -0
- package/scaffold/general/agents/Explorer.agent.md +50 -0
- package/scaffold/general/agents/Frontend.agent.md +29 -0
- package/scaffold/general/agents/Implementer.agent.md +31 -0
- package/scaffold/general/agents/Orchestrator.agent.md +104 -0
- package/scaffold/general/agents/Planner.agent.md +55 -0
- package/scaffold/general/agents/README.md +57 -0
- package/scaffold/general/agents/Refactor.agent.md +36 -0
- package/scaffold/general/agents/Researcher-Alpha.agent.md +20 -0
- package/scaffold/general/agents/Researcher-Beta.agent.md +20 -0
- package/scaffold/general/agents/Researcher-Delta.agent.md +20 -0
- package/scaffold/general/agents/Researcher-Gamma.agent.md +20 -0
- package/scaffold/general/agents/Security.agent.md +42 -0
- package/scaffold/general/agents/_shared/adr-protocol.md +91 -0
- package/scaffold/general/agents/_shared/architect-reviewer-base.md +50 -0
- package/scaffold/general/agents/_shared/code-agent-base.md +88 -0
- package/scaffold/general/agents/_shared/code-reviewer-base.md +54 -0
- package/scaffold/general/agents/_shared/decision-protocol.md +27 -0
- package/scaffold/general/agents/_shared/forge-protocol.md +46 -0
- package/scaffold/general/agents/_shared/researcher-base.md +61 -0
- package/scaffold/general/agents/templates/adr-template.md +27 -0
- package/scaffold/general/agents/templates/execution-state.md +25 -0
- package/scaffold/general/prompts/ask.prompt.md +20 -0
- package/scaffold/general/prompts/debug.prompt.md +25 -0
- package/scaffold/general/prompts/design.prompt.md +22 -0
- package/scaffold/general/prompts/implement.prompt.md +26 -0
- package/scaffold/general/prompts/plan.prompt.md +24 -0
- package/scaffold/general/prompts/review.prompt.md +31 -0
- package/scaffold/generate.mjs +74 -0
- package/skills/adr-skill/SKILL.md +329 -0
- package/skills/adr-skill/assets/templates/adr-madr.md +89 -0
- package/skills/adr-skill/assets/templates/adr-readme.md +20 -0
- package/skills/adr-skill/assets/templates/adr-simple.md +46 -0
- package/skills/adr-skill/references/adr-conventions.md +95 -0
- package/skills/adr-skill/references/examples.md +193 -0
- package/skills/adr-skill/references/review-checklist.md +77 -0
- package/skills/adr-skill/references/template-variants.md +52 -0
- package/skills/adr-skill/scripts/bootstrap_adr.js +259 -0
- package/skills/adr-skill/scripts/new_adr.js +391 -0
- package/skills/adr-skill/scripts/set_adr_status.js +169 -0
- package/skills/brainstorming/SKILL.md +259 -0
- package/skills/brainstorming/scripts/frame-template.html +365 -0
- package/skills/brainstorming/scripts/helper.js +216 -0
- package/skills/brainstorming/scripts/server.cjs +9 -0
- package/skills/brainstorming/scripts/server.src.cjs +249 -0
- package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/skills/brainstorming/visual-companion.md +430 -0
- package/skills/c4-architecture/SKILL.md +295 -0
- package/skills/c4-architecture/references/advanced-patterns.md +552 -0
- package/skills/c4-architecture/references/c4-syntax.md +492 -0
- package/skills/c4-architecture/references/common-mistakes.md +437 -0
- package/skills/knowledge-base/SKILL.md +100 -10
- package/skills/lesson-learned/SKILL.md +105 -0
- package/skills/lesson-learned/references/anti-patterns.md +55 -0
- package/skills/lesson-learned/references/se-principles.md +109 -0
- package/skills/requirements-clarity/SKILL.md +324 -0
- package/skills/session-handoff/SKILL.md +189 -0
- package/skills/session-handoff/references/handoff-template.md +139 -0
- package/skills/session-handoff/references/resume-checklist.md +80 -0
- package/skills/session-handoff/scripts/check_staleness.js +269 -0
- package/skills/session-handoff/scripts/create_handoff.js +299 -0
- package/skills/session-handoff/scripts/list_handoffs.js +113 -0
- package/skills/session-handoff/scripts/validate_handoff.js +241 -0
- package/packages/chunker/dist/treesitter-chunker.d.ts +0 -47
- package/packages/chunker/dist/treesitter-chunker.js +0 -8
- package/packages/cli/dist/commands/init.d.ts +0 -10
- package/packages/cli/dist/commands/init.js +0 -308
|
@@ -1,24 +1,26 @@
|
|
|
1
|
+
//#region packages/embeddings/src/embedder.interface.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Embedding abstraction — allows swapping embedding models.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
interface IEmbedder {
|
|
6
|
+
/** Generate an embedding vector for a single text string (used for documents/passages) */
|
|
7
|
+
embed(text: string): Promise<Float32Array>;
|
|
8
|
+
/**
|
|
9
|
+
* Generate an embedding vector for a search query.
|
|
10
|
+
* Some models (e.g., BGE) use a query prefix for asymmetric retrieval.
|
|
11
|
+
* Falls back to embed() if the model doesn't need query prefixing.
|
|
12
|
+
*/
|
|
13
|
+
embedQuery(query: string): Promise<Float32Array>;
|
|
14
|
+
/** Generate embeddings for multiple text strings (batched, for documents/passages) */
|
|
15
|
+
embedBatch(texts: string[]): Promise<Float32Array[]>;
|
|
16
|
+
/** The dimensionality of the embedding vectors */
|
|
17
|
+
readonly dimensions: number;
|
|
18
|
+
/** The model identifier */
|
|
19
|
+
readonly modelId: string;
|
|
20
|
+
/** Initialize the model (download if needed, load into memory) */
|
|
21
|
+
initialize(): Promise<void>;
|
|
22
|
+
/** Release model resources */
|
|
23
|
+
shutdown?(): Promise<void>;
|
|
23
24
|
}
|
|
24
|
-
//#
|
|
25
|
+
//#endregion
|
|
26
|
+
export { IEmbedder };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { IEmbedder } from "./embedder.interface.js";
|
|
2
|
+
import { OnnxEmbedder } from "./onnx-embedder.js";
|
|
3
|
+
export { type IEmbedder, OnnxEmbedder };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{OnnxEmbedder as
|
|
1
|
+
import{OnnxEmbedder as e}from"./onnx-embedder.js";export{e as OnnxEmbedder};
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
embed(text: string): Promise<Float32Array>;
|
|
21
|
-
embedQuery(query: string): Promise<Float32Array>;
|
|
22
|
-
embedBatch(texts: string[]): Promise<Float32Array[]>;
|
|
1
|
+
import { IEmbedder } from "./embedder.interface.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/embeddings/src/onnx-embedder.d.ts
|
|
4
|
+
declare class OnnxEmbedder implements IEmbedder {
|
|
5
|
+
private pipe;
|
|
6
|
+
readonly dimensions: number;
|
|
7
|
+
readonly modelId: string;
|
|
8
|
+
private readonly queryPrefix;
|
|
9
|
+
constructor(options?: {
|
|
10
|
+
model?: string;
|
|
11
|
+
dimensions?: number;
|
|
12
|
+
queryPrefix?: string;
|
|
13
|
+
});
|
|
14
|
+
private detectQueryPrefix;
|
|
15
|
+
initialize(): Promise<void>;
|
|
16
|
+
shutdown(): Promise<void>;
|
|
17
|
+
embed(text: string): Promise<Float32Array>;
|
|
18
|
+
embedQuery(query: string): Promise<Float32Array>;
|
|
19
|
+
embedBatch(texts: string[]): Promise<Float32Array[]>;
|
|
23
20
|
}
|
|
24
|
-
//#
|
|
21
|
+
//#endregion
|
|
22
|
+
export { OnnxEmbedder };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{homedir as
|
|
1
|
+
import{homedir as e}from"node:os";import{join as t}from"node:path";import{env as n,pipeline as r}from"@huggingface/transformers";import{EMBEDDING_DEFAULTS as i}from"../../core/dist/index.js";n.cacheDir=t(e(),`.cache`,`huggingface`,`transformers-js`);var a=class{pipe=null;dimensions;modelId;queryPrefix;constructor(e){this.modelId=e?.model??i.model,this.dimensions=e?.dimensions??i.dimensions,this.queryPrefix=e?.queryPrefix??this.detectQueryPrefix(this.modelId)}detectQueryPrefix(e){let t=e.toLowerCase();return t.includes(`bge`)||t.includes(`mxbai-embed`)?`Represent this sentence for searching relevant passages: `:t.includes(`/e5-`)||t.includes(`multilingual-e5`)?`query: `:``}async initialize(){if(!this.pipe)try{this.pipe=await r(`feature-extraction`,this.modelId,{dtype:`fp32`})}catch(e){throw Error(`Failed to initialize embedding model "${this.modelId}": ${e.message}`)}}async shutdown(){this.pipe=null}async embed(e){this.pipe||await this.initialize();let t=await this.pipe?.(e,{pooling:`mean`,normalize:!0});if(!t)throw Error(`Embedding pipeline returned no output`);return new Float32Array(t.data)}async embedQuery(e){return this.embed(this.queryPrefix+e)}async embedBatch(e){if(e.length===0)return[];this.pipe||await this.initialize();let t=[];for(let n=0;n<e.length;n+=32){let r=e.slice(n,n+32),i=await this.pipe?.(r,{pooling:`mean`,normalize:!0});if(!i)throw Error(`Embedding pipeline returned no output`);if(r.length===1)t.push(new Float32Array(i.data));else for(let e=0;e<r.length;e++){let n=e*this.dimensions,r=i.data.slice(n,n+this.dimensions);t.push(new Float32Array(r))}}return t}};export{a as OnnxEmbedder};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ERSearchResult } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/enterprise-bridge/src/cache.d.ts
|
|
4
|
+
declare class ERCache {
|
|
5
|
+
private readonly cache;
|
|
6
|
+
private readonly maxEntries;
|
|
7
|
+
private readonly defaultTtl;
|
|
8
|
+
constructor(options?: {
|
|
9
|
+
maxEntries?: number;
|
|
10
|
+
defaultTtl?: number;
|
|
11
|
+
});
|
|
12
|
+
/** Normalize query for cache key: lowercase, trim, collapse whitespace */
|
|
13
|
+
static normalizeKey(query: string): string;
|
|
14
|
+
get(query: string): ERSearchResult[] | undefined;
|
|
15
|
+
set(query: string, results: ERSearchResult[], ttl?: number): void;
|
|
16
|
+
/** Invalidate entries matching a topic (exact normalized key match) */
|
|
17
|
+
invalidate(query: string): boolean;
|
|
18
|
+
clear(): void;
|
|
19
|
+
get size(): number;
|
|
20
|
+
/** Get cache stats */
|
|
21
|
+
stats(): {
|
|
22
|
+
size: number;
|
|
23
|
+
maxEntries: number;
|
|
24
|
+
defaultTtlMs: number;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ERCache };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class e{cache=new Map;maxEntries;defaultTtl;constructor(e){this.maxEntries=e?.maxEntries??100,this.defaultTtl=e?.defaultTtl??216e5}static normalizeKey(e){return e.toLowerCase().trim().replace(/\s+/g,` `)}get(t){let n=e.normalizeKey(t),r=this.cache.get(n);if(r){if(Date.now()-r.cachedAt>r.ttl){this.cache.delete(n);return}return this.cache.delete(n),this.cache.set(n,r),r.results}}set(t,n,r){let i=e.normalizeKey(t);if(this.cache.size>=this.maxEntries&&!this.cache.has(i)){let e=this.cache.keys().next().value;e!==void 0&&this.cache.delete(e)}this.cache.set(i,{results:n,query:i,cachedAt:Date.now(),ttl:r??this.defaultTtl})}invalidate(t){let n=e.normalizeKey(t);return this.cache.delete(n)}clear(){this.cache.clear()}get size(){return this.cache.size}stats(){return{size:this.cache.size,maxEntries:this.maxEntries,defaultTtlMs:this.defaultTtl}}};export{e as ERCache};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ERBridgeConfig, ERPushRequest, ERPushResponse, ERSearchResult } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/enterprise-bridge/src/er-client.d.ts
|
|
4
|
+
declare class ERClient {
|
|
5
|
+
private readonly baseUrl;
|
|
6
|
+
private readonly apiKey;
|
|
7
|
+
private readonly timeoutMs;
|
|
8
|
+
private circuitState;
|
|
9
|
+
private consecutiveFailures;
|
|
10
|
+
private openUntil;
|
|
11
|
+
private halfOpenProbeInFlight;
|
|
12
|
+
private static readonly FAILURE_THRESHOLD;
|
|
13
|
+
private static readonly RESET_TIMEOUT_MS;
|
|
14
|
+
constructor(config: ERBridgeConfig);
|
|
15
|
+
/** Search ER knowledge base */
|
|
16
|
+
search(query: string, maxResults?: number): Promise<ERSearchResult[]>;
|
|
17
|
+
/** Push curated knowledge to ER via MCP tools endpoint */
|
|
18
|
+
push(request: ERPushRequest): Promise<ERPushResponse>;
|
|
19
|
+
/** Explicit pull from ER (bypasses local search, for cross-repo context) */
|
|
20
|
+
pull(query: string, maxResults?: number): Promise<ERSearchResult[]>;
|
|
21
|
+
/** Check ER health */
|
|
22
|
+
health(): Promise<{
|
|
23
|
+
healthy: boolean;
|
|
24
|
+
status?: number;
|
|
25
|
+
}>;
|
|
26
|
+
/** Check available MCP tools (verify curated_remember exists) */
|
|
27
|
+
listTools(): Promise<string[]>;
|
|
28
|
+
private fetch;
|
|
29
|
+
private checkCircuit;
|
|
30
|
+
private recordSuccess;
|
|
31
|
+
private recordFailure;
|
|
32
|
+
private backoffMs;
|
|
33
|
+
private parseRetryAfter;
|
|
34
|
+
private sleep;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ERClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ERTransientError as e}from"./types.js";var t=class t{baseUrl;apiKey;timeoutMs;circuitState=`closed`;consecutiveFailures=0;openUntil=0;halfOpenProbeInFlight=!1;static FAILURE_THRESHOLD=3;static RESET_TIMEOUT_MS=6e4;constructor(e){let t=new URL(e.baseUrl);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw Error(`Unsupported protocol: ${t.protocol} — only http/https allowed`);let n=t.hostname===`localhost`||t.hostname===`127.0.0.1`||t.hostname===`::1`;if(t.protocol===`http:`&&!n)throw Error(`Non-TLS (http://) ER endpoints are only allowed for localhost. Use https:// to avoid leaking API keys.`);this.baseUrl=e.baseUrl.replace(/\/+$/,``),this.apiKey=e.apiKey,this.timeoutMs=e.timeoutMs}async search(e,t=5){let n=await this.fetch(`/api/v1/search`,{method:`POST`,body:JSON.stringify({query:e,maxResults:t,generateResponse:!1})});if(!n.ok)throw Error(`ER search failed: ${n.status} ${n.statusText}`);return((await n.json()).sources??[]).map(e=>{let t=typeof e.score==`number`?e.score:void 0,n=typeof e.confidence==`number`?e.confidence:void 0;return{content:e.content,sourcePath:e.metadata?.sourceUri??`unknown`,score:t??n??0,metadata:e.metadata}})}async push(e){let t=await this.fetch(`/mcp/tools`,{method:`POST`,body:JSON.stringify({name:`curated_remember`,arguments:{title:e.title,content:e.content,category:e.category??`conventions`,tags:[...e.tags??[],`pushed-from-kb`]}})});if(!t.ok)return{pushed:!1,status:`failed`,timestamp:new Date().toISOString(),error:`ER push failed: ${t.status} ${t.statusText}`};let n=await t.json();return{pushed:!0,status:`stored`,remotePath:typeof n.path==`string`?n.path:void 0,timestamp:new Date().toISOString()}}async pull(e,t=10){return this.search(e,t)}async health(){try{let e=await this.fetch(`/api/v1/health`,{method:`GET`});return{healthy:e.ok,status:e.status}}catch{return{healthy:!1}}}async listTools(){try{let e=await this.fetch(`/mcp/tools`,{method:`GET`});return e.ok?((await e.json()).tools??[]).map(e=>e.name):[]}catch{return[]}}async fetch(e,t){this.checkCircuit();let n;for(let r=0;r<=2;r++){let i=new AbortController,a=setTimeout(()=>i.abort(),this.timeoutMs);try{let n=await fetch(`${this.baseUrl}${e}`,{...t,headers:{"Content-Type":`application/json`,"X-Api-Key":this.apiKey,"User-Agent":`kb-enterprise-bridge/1.0`,...t.headers},signal:i.signal});if(n.ok||n.status>=400&&n.status<500&&n.status!==429)return this.recordSuccess(),n;if(r<2){let e=this.parseRetryAfter(n)??this.backoffMs(r);await this.sleep(e);continue}return this.recordFailure(),n}catch(e){n=e,r<2&&await this.sleep(this.backoffMs(r))}finally{clearTimeout(a)}}throw this.recordFailure(),n??Error(`Fetch failed after retries`)}checkCircuit(){if(this.circuitState===`open`)if(Date.now()>=this.openUntil){if(this.halfOpenProbeInFlight)throw new e(`ER circuit breaker is half-open — probe in progress`);this.circuitState=`half-open`,this.halfOpenProbeInFlight=!0}else throw new e(`ER circuit breaker is open — skipping request`)}recordSuccess(){this.consecutiveFailures=0,this.circuitState=`closed`,this.halfOpenProbeInFlight=!1}recordFailure(){this.consecutiveFailures++,this.halfOpenProbeInFlight=!1,this.consecutiveFailures>=t.FAILURE_THRESHOLD&&(this.circuitState=`open`,this.openUntil=Date.now()+t.RESET_TIMEOUT_MS)}backoffMs(e){let t=500*3**e,n=t*.25*(Math.random()*2-1);return Math.round(t+n)}parseRetryAfter(e){let t=e.headers.get(`Retry-After`);if(!t)return;let n=Number(t);if(!Number.isNaN(n)&&n>=0)return Math.min(n*1e3,3e4)}sleep(e){return new Promise(t=>setTimeout(t,e))}};export{t as ERClient};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region packages/enterprise-bridge/src/evolution-collector.d.ts
|
|
2
|
+
/** Evolution data collector — tracks usage metrics for LLM review */
|
|
3
|
+
interface EvolutionMetrics {
|
|
4
|
+
/** Search metrics */
|
|
5
|
+
search: {
|
|
6
|
+
totalSearches: number;
|
|
7
|
+
erFallbackCount: number;
|
|
8
|
+
erFallbackRate: number;
|
|
9
|
+
erCacheHitCount: number;
|
|
10
|
+
erCacheHitRate: number;
|
|
11
|
+
topMissedQueries: Array<{
|
|
12
|
+
query: string;
|
|
13
|
+
count: number;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
/** Push metrics */
|
|
17
|
+
push: {
|
|
18
|
+
totalPushes: number;
|
|
19
|
+
successCount: number;
|
|
20
|
+
failCount: number;
|
|
21
|
+
pushRate: number; /** Classification match rate — how often rules fired vs knowledge stored */
|
|
22
|
+
classificationMatchRate: number; /** Push acceptance rate — how often LLM decided to push after recommendation */
|
|
23
|
+
pushAcceptanceRate: number;
|
|
24
|
+
};
|
|
25
|
+
/** Rule effectiveness */
|
|
26
|
+
rules: {
|
|
27
|
+
matchCounts: Record<string, number>;
|
|
28
|
+
pushCounts: Record<string, number>; /** Rules that fire often but rarely lead to pushes (potential false positives) */
|
|
29
|
+
lowConversionRules: Array<{
|
|
30
|
+
ruleId: string;
|
|
31
|
+
matchCount: number;
|
|
32
|
+
pushCount: number;
|
|
33
|
+
conversionRate: number;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
/** Summary period */
|
|
37
|
+
period: {
|
|
38
|
+
startedAt: string;
|
|
39
|
+
queriedAt: string;
|
|
40
|
+
totalEvents: number;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
declare class EvolutionCollector {
|
|
44
|
+
private searchEvents;
|
|
45
|
+
private classificationEvents;
|
|
46
|
+
private pushEvents;
|
|
47
|
+
private readonly startedAt;
|
|
48
|
+
constructor();
|
|
49
|
+
/** Record a search event */
|
|
50
|
+
recordSearch(query: string, erFallbackTriggered: boolean, erCacheHit: boolean): void;
|
|
51
|
+
/** Record a classification event (when remember returns classification signals) */
|
|
52
|
+
recordClassification(entryTitle: string, matchingRuleIds: string[], pushRecommended: boolean): void;
|
|
53
|
+
/** Record a push event */
|
|
54
|
+
recordPush(entryId: string, success: boolean, ruleId?: string): void;
|
|
55
|
+
/** Get aggregated metrics for LLM review */
|
|
56
|
+
getMetrics(): EvolutionMetrics;
|
|
57
|
+
/** Reset all collected data */
|
|
58
|
+
reset(): void;
|
|
59
|
+
private trimEvents;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { EvolutionCollector, EvolutionMetrics };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class{searchEvents=[];classificationEvents=[];pushEvents=[];startedAt;constructor(){this.startedAt=new Date().toISOString()}recordSearch(e,t,n){this.searchEvents.push({query:e.toLowerCase().trim(),erFallbackTriggered:t,erCacheHit:n,timestamp:Date.now()}),this.trimEvents()}recordClassification(e,t,n){this.classificationEvents.push({entryTitle:e,matchingRuleIds:t,pushRecommended:n,timestamp:Date.now()}),this.trimEvents()}recordPush(e,t,n){this.pushEvents.push({entryId:e,ruleId:n,success:t,timestamp:Date.now()}),this.trimEvents()}getMetrics(){let e=this.searchEvents.length,t=this.searchEvents.filter(e=>e.erFallbackTriggered).length,n=this.searchEvents.filter(e=>e.erCacheHit).length,r=new Map;for(let e of this.searchEvents)e.erFallbackTriggered&&r.set(e.query,(r.get(e.query)??0)+1);let i=[...r.entries()].sort((e,t)=>t[1]-e[1]).slice(0,20).map(([e,t])=>({query:e,count:t})),a=this.pushEvents.length,o=this.pushEvents.filter(e=>e.success).length,s=this.classificationEvents.length,c=this.classificationEvents.filter(e=>e.pushRecommended).length,l={},u={};for(let e of this.classificationEvents)for(let t of e.matchingRuleIds)l[t]=(l[t]??0)+1;for(let e of this.pushEvents)e.ruleId&&(u[e.ruleId]=(u[e.ruleId]??0)+1);let d=Object.entries(l).map(([e,t])=>{let n=u[e]??0;return{ruleId:e,matchCount:t,pushCount:n,conversionRate:t>0?n/t:0}}).filter(e=>e.matchCount>=3&&e.conversionRate<.3).sort((e,t)=>e.conversionRate-t.conversionRate);return{search:{totalSearches:e,erFallbackCount:t,erFallbackRate:e>0?t/e:0,erCacheHitCount:n,erCacheHitRate:t>0?n/t:0,topMissedQueries:i},push:{totalPushes:a,successCount:o,failCount:a-o,pushRate:s>0?a/s:0,classificationMatchRate:s>0?c/s:0,pushAcceptanceRate:c>0?a/c:0},rules:{matchCounts:l,pushCounts:u,lowConversionRules:d},period:{startedAt:this.startedAt,queriedAt:new Date().toISOString(),totalEvents:this.searchEvents.length+this.classificationEvents.length+this.pushEvents.length}}}reset(){this.searchEvents=[],this.classificationEvents=[],this.pushEvents=[]}trimEvents(){this.searchEvents.length>500&&(this.searchEvents=this.searchEvents.slice(-500)),this.classificationEvents.length>500&&(this.classificationEvents=this.classificationEvents.slice(-500)),this.pushEvents.length>500&&(this.pushEvents=this.pushEvents.slice(-500))}};export{e as EvolutionCollector};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ERBridgeConfig, ERCacheEntry, ERPushRequest, ERPushResponse, ERSearchResponse, ERSearchResult, ERSyncEntry, ERTransientError, MergedSearchResult } from "./types.js";
|
|
2
|
+
import { ERCache } from "./cache.js";
|
|
3
|
+
import { ERClient } from "./er-client.js";
|
|
4
|
+
import { EvolutionCollector, EvolutionMetrics } from "./evolution-collector.js";
|
|
5
|
+
import { ClassificationResult, ClassificationRule, PolicyStore } from "./policy-store.js";
|
|
6
|
+
import { PushAdapter } from "./push-adapter.js";
|
|
7
|
+
import { mergeResults } from "./result-merger.js";
|
|
8
|
+
export { type ClassificationResult, type ClassificationRule, type ERBridgeConfig, ERCache, type ERCacheEntry, ERClient, type ERPushRequest, type ERPushResponse, type ERSearchResponse, type ERSearchResult, type ERSyncEntry, ERTransientError, EvolutionCollector, type EvolutionMetrics, type MergedSearchResult, PolicyStore, PushAdapter, mergeResults };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ERCache as e}from"./cache.js";import{ERTransientError as t}from"./types.js";import{ERClient as n}from"./er-client.js";import{EvolutionCollector as r}from"./evolution-collector.js";import{PolicyStore as i}from"./policy-store.js";import{PushAdapter as a}from"./push-adapter.js";import{mergeResults as o}from"./result-merger.js";export{e as ERCache,n as ERClient,t as ERTransientError,r as EvolutionCollector,i as PolicyStore,a as PushAdapter,o as mergeResults};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region packages/enterprise-bridge/src/policy-store.d.ts
|
|
2
|
+
/** A single classification rule */
|
|
3
|
+
interface ClassificationRule {
|
|
4
|
+
id: string;
|
|
5
|
+
patterns: string[];
|
|
6
|
+
category: string;
|
|
7
|
+
pushWeight: number;
|
|
8
|
+
description: string;
|
|
9
|
+
examples: string[];
|
|
10
|
+
autoPush: false;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
}
|
|
15
|
+
/** Classification result for a knowledge entry */
|
|
16
|
+
interface ClassificationResult {
|
|
17
|
+
matchingRules: Array<{
|
|
18
|
+
ruleId: string;
|
|
19
|
+
category: string;
|
|
20
|
+
pushWeight: number;
|
|
21
|
+
matchedPatterns: string[];
|
|
22
|
+
}>;
|
|
23
|
+
pushRecommended: boolean;
|
|
24
|
+
maxPushWeight: number;
|
|
25
|
+
}
|
|
26
|
+
declare class PolicyStore {
|
|
27
|
+
private rules;
|
|
28
|
+
private readonly rulesPath;
|
|
29
|
+
constructor(curatedPath: string);
|
|
30
|
+
/** Classify a knowledge entry against all enabled rules */
|
|
31
|
+
classify(title: string, content: string, tags: string[]): ClassificationResult;
|
|
32
|
+
/** Get all rules */
|
|
33
|
+
getRules(): ClassificationRule[];
|
|
34
|
+
/** Get a single rule by ID */
|
|
35
|
+
getRule(ruleId: string): ClassificationRule | undefined;
|
|
36
|
+
/** Update an existing rule */
|
|
37
|
+
updateRule(ruleId: string, changes: Partial<Omit<ClassificationRule, 'id' | 'createdAt' | 'autoPush'>>): ClassificationRule | undefined;
|
|
38
|
+
/** Add a new rule */
|
|
39
|
+
addRule(rule: Omit<ClassificationRule, 'createdAt' | 'updatedAt' | 'autoPush'>): ClassificationRule;
|
|
40
|
+
/** Delete a rule */
|
|
41
|
+
deleteRule(ruleId: string): boolean;
|
|
42
|
+
private save;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { ClassificationResult, ClassificationRule, PolicyStore };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as e,mkdirSync as t,readFileSync as n,writeFileSync as r}from"node:fs";import{join as i}from"node:path";import{createLogger as a}from"../../core/dist/index.js";const o=a(`bridge`),s=()=>new Date().toISOString(),c=[{id:`cross-repo-contract`,patterns:[`contract`,`interface`,`api`,`event schema`,`publishes`,`subscribes`],category:`contract`,pushWeight:.8,description:`Knowledge describing cross-service interfaces`,examples:[`Service X publishes OrderCreated event with fields...`],autoPush:!1,enabled:!0,createdAt:s(),updatedAt:s()},{id:`architecture-decision`,patterns:[`decided`,`chose`,`tradeoff`,`adr`,`because we need`],category:`decision`,pushWeight:.7,description:`Architecture decisions that affect the ecosystem`,examples:[`We decided to use event sourcing because...`],autoPush:!1,enabled:!0,createdAt:s(),updatedAt:s()},{id:`shared-pattern`,patterns:[`pattern`,`convention`,`standard`,`guideline`,`always use`],category:`pattern`,pushWeight:.6,description:`Patterns and conventions that maintain consistency across repos`,examples:[`Always use the Result type for error handling...`],autoPush:!1,enabled:!0,createdAt:s(),updatedAt:s()},{id:`company-term`,patterns:[`means`,`defined as`,`acronym`,`refers to`],category:`glossary`,pushWeight:.7,description:`Shared vocabulary and terminology definitions`,examples:[`DDD means Domain-Driven Design in our context...`],autoPush:!1,enabled:!0,createdAt:s(),updatedAt:s()},{id:`implementation-detail`,patterns:[`private`,`internal`,`helper`,`todo`,`hack`,`workaround`],category:`local-only`,pushWeight:0,description:`Local-only implementation details — never push`,examples:[`TODO: refactor this helper`,`Internal workaround for...`],autoPush:!1,enabled:!0,createdAt:s(),updatedAt:s()}];var l=class{rules=[];rulesPath;constructor(r){let a=i(r,`_policy`);if(this.rulesPath=i(a,`rules.json`),e(a)||t(a,{recursive:!0}),e(this.rulesPath))try{let e=n(this.rulesPath,`utf-8`),t=JSON.parse(e);if(!Array.isArray(t))throw Error(`rules.json must be an array`);for(let e of t)if(typeof e!=`object`||!e||typeof e.id!=`string`||!Array.isArray(e.patterns)||typeof e.category!=`string`||typeof e.pushWeight!=`number`)throw Error(`Invalid rule: ${JSON.stringify(e).slice(0,100)}`);this.rules=t}catch{o.warn(`Failed to parse policy rules, resetting to starter set`),this.rules=[...c],this.save()}else this.rules=[...c],this.save()}classify(e,t,n){let r=`${e} ${t} ${n.join(` `)}`.toLowerCase(),i=[];for(let e of this.rules){if(!e.enabled)continue;let t=e.patterns.filter(e=>r.includes(e.toLowerCase()));t.length>0&&i.push({ruleId:e.id,category:e.category,pushWeight:e.pushWeight,matchedPatterns:t})}let a=i.length>0?Math.max(...i.map(e=>e.pushWeight)):0;return{matchingRules:i,pushRecommended:a>=.5,maxPushWeight:a}}getRules(){return[...this.rules]}getRule(e){return this.rules.find(t=>t.id===e)}updateRule(e,t){let n=this.rules.find(t=>t.id===e);if(n)return Object.assign(n,t,{updatedAt:new Date().toISOString(),autoPush:!1}),this.save(),n}addRule(e){if(this.rules.find(t=>t.id===e.id))throw Error(`Rule with id '${e.id}' already exists`);let t=new Date().toISOString(),n={...e,autoPush:!1,createdAt:t,updatedAt:t};return this.rules.push(n),this.save(),n}deleteRule(e){let t=this.rules.findIndex(t=>t.id===e);return t===-1?!1:(this.rules.splice(t,1),this.save(),!0)}save(){r(this.rulesPath,JSON.stringify(this.rules,null,2),`utf-8`)}};export{l as PolicyStore};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ERPushRequest, ERPushResponse, ERSyncEntry } from "./types.js";
|
|
2
|
+
import { ERClient } from "./er-client.js";
|
|
3
|
+
|
|
4
|
+
//#region packages/enterprise-bridge/src/push-adapter.d.ts
|
|
5
|
+
declare class PushAdapter {
|
|
6
|
+
private readonly client;
|
|
7
|
+
private readonly syncHistory;
|
|
8
|
+
private static readonly MAX_HISTORY;
|
|
9
|
+
constructor(client: ERClient);
|
|
10
|
+
/** Push a knowledge entry to ER */
|
|
11
|
+
push(entryId: string, request: ERPushRequest): Promise<ERPushResponse>;
|
|
12
|
+
/** Get sync history */
|
|
13
|
+
getHistory(): ERSyncEntry[];
|
|
14
|
+
/** Get sync status summary */
|
|
15
|
+
getStatus(): {
|
|
16
|
+
totalPushed: number;
|
|
17
|
+
successCount: number;
|
|
18
|
+
failCount: number;
|
|
19
|
+
lastPush?: ERSyncEntry;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { PushAdapter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class e{client;syncHistory=[];static MAX_HISTORY=100;constructor(e){this.client=e}async push(t,n){let r=await this.client.push(n);for(this.syncHistory.push({entryId:t,title:n.title,pushedAt:r.timestamp,status:r.status,remotePath:r.remotePath});this.syncHistory.length>e.MAX_HISTORY;)this.syncHistory.shift();return r}getHistory(){return[...this.syncHistory]}getStatus(){let e=this.syncHistory.filter(e=>e.status===`stored`).length;return{totalPushed:this.syncHistory.length,successCount:e,failCount:this.syncHistory.length-e,lastPush:this.syncHistory.at(-1)}}};export{e as PushAdapter};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ERSearchResult, MergedSearchResult } from "./types.js";
|
|
2
|
+
import { SearchResult } from "@kb/core";
|
|
3
|
+
|
|
4
|
+
//#region packages/enterprise-bridge/src/result-merger.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Merge local and ER results using local-first interleaving.
|
|
7
|
+
*
|
|
8
|
+
* Local RRF scores (~0.01-0.05) and ER raw similarity scores (~0.3-0.9) are on
|
|
9
|
+
* incomparable scales. Instead of sorting both together (which would always rank
|
|
10
|
+
* ER above local), we preserve local ordering, deduplicate, then append ER results.
|
|
11
|
+
*/
|
|
12
|
+
declare function mergeResults(localResults: SearchResult[], erResults: ERSearchResult[], limit: number): MergedSearchResult[];
|
|
13
|
+
//#endregion
|
|
14
|
+
export { mergeResults };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return{content:e.record.content,sourcePath:e.record.sourcePath,score:e.score,source:`local`,startLine:e.record.startLine,endLine:e.record.endLine,contentType:e.record.contentType,headingPath:e.record.headingPath,origin:e.record.origin,category:e.record.category,tags:e.record.tags}}function t(e){return{content:e.content,sourcePath:e.sourcePath,score:e.score,source:`er`,metadata:e.metadata}}function n(e){return`${e.slice(0,200).replace(/\s+/g,` `)}:${e.length}`}function r(r,i,a){let o=new Set,s=[];for(let t of r){let r=n(t.record.content);o.has(r)||(o.add(r),s.push(e(t)))}let c=[...i].sort((e,t)=>t.score-e.score);for(let e of c){let r=n(e.content);o.has(r)||(o.add(r),s.push(t(e)))}return s.slice(0,a)}export{r as mergeResults};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//#region packages/enterprise-bridge/src/types.d.ts
|
|
2
|
+
/** ER bridge configuration (subset of KBConfig.er) */
|
|
3
|
+
interface ERBridgeConfig {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
apiKey: string;
|
|
7
|
+
timeoutMs: number;
|
|
8
|
+
cacheTtlMs: number;
|
|
9
|
+
cacheMaxEntries: number;
|
|
10
|
+
fallbackThreshold: number;
|
|
11
|
+
}
|
|
12
|
+
/** Result from ER search API */
|
|
13
|
+
interface ERSearchResult {
|
|
14
|
+
content: string;
|
|
15
|
+
sourcePath: string;
|
|
16
|
+
score: number;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/** Response from ER search API (POST /api/v1/search) */
|
|
20
|
+
interface ERSearchResponse {
|
|
21
|
+
sources: Array<{
|
|
22
|
+
content: string;
|
|
23
|
+
metadata: Record<string, string>;
|
|
24
|
+
score?: number;
|
|
25
|
+
confidence?: number;
|
|
26
|
+
}>;
|
|
27
|
+
query?: string;
|
|
28
|
+
searchMode?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Push request to ER */
|
|
31
|
+
interface ERPushRequest {
|
|
32
|
+
title: string;
|
|
33
|
+
content: string;
|
|
34
|
+
category?: string;
|
|
35
|
+
tags?: string[];
|
|
36
|
+
}
|
|
37
|
+
/** Push response from ER */
|
|
38
|
+
interface ERPushResponse {
|
|
39
|
+
pushed: boolean;
|
|
40
|
+
status: 'stored' | 'failed';
|
|
41
|
+
remotePath?: string;
|
|
42
|
+
timestamp: string;
|
|
43
|
+
error?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Transient ER error (429, 5xx, network) — retries exhausted but not a permanent failure */
|
|
46
|
+
declare class ERTransientError extends Error {
|
|
47
|
+
readonly statusCode?: number | undefined;
|
|
48
|
+
constructor(message: string, statusCode?: number | undefined);
|
|
49
|
+
}
|
|
50
|
+
/** Sync status entry for tracking push history */
|
|
51
|
+
interface ERSyncEntry {
|
|
52
|
+
entryId: string;
|
|
53
|
+
title: string;
|
|
54
|
+
pushedAt: string;
|
|
55
|
+
status: 'stored' | 'failed';
|
|
56
|
+
remotePath?: string;
|
|
57
|
+
}
|
|
58
|
+
/** Cache entry wrapping ER search results */
|
|
59
|
+
interface ERCacheEntry {
|
|
60
|
+
results: ERSearchResult[];
|
|
61
|
+
query: string;
|
|
62
|
+
cachedAt: number;
|
|
63
|
+
ttl: number;
|
|
64
|
+
}
|
|
65
|
+
/** Merged search result with source provenance */
|
|
66
|
+
interface MergedSearchResult {
|
|
67
|
+
content: string;
|
|
68
|
+
sourcePath: string;
|
|
69
|
+
score: number;
|
|
70
|
+
source: 'local' | 'er';
|
|
71
|
+
startLine?: number;
|
|
72
|
+
endLine?: number;
|
|
73
|
+
contentType?: string;
|
|
74
|
+
headingPath?: string;
|
|
75
|
+
origin?: string;
|
|
76
|
+
category?: string;
|
|
77
|
+
tags?: string[];
|
|
78
|
+
metadata?: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
export { ERBridgeConfig, ERCacheEntry, ERPushRequest, ERPushResponse, ERSearchResponse, ERSearchResult, ERSyncEntry, ERTransientError, MergedSearchResult };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{constructor(e,t){super(e),this.statusCode=t,this.name=`ERTransientError`}};export{e as ERTransientError};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
//#region packages/indexer/src/file-hasher.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Generate a deterministic hash for a file's content.
|
|
3
4
|
* Used for incremental indexing -- skip files that haven't changed.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
declare function hashContent(content: string): string;
|
|
6
7
|
/**
|
|
7
8
|
* Generate a deterministic ID for a knowledge record.
|
|
8
9
|
* Based on source path + chunk index to ensure idempotent upserts.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
-
//#
|
|
11
|
+
declare function generateRecordId(sourcePath: string, chunkIndex: number): string;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { generateRecordId, hashContent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as e}from"node:crypto";function
|
|
1
|
+
import{createHash as e}from"node:crypto";function t(t){return e(`sha256`).update(t).digest(`hex`).slice(0,16)}function n(t,n){let r=`${t}:${n}`;return e(`sha256`).update(r).digest(`hex`).slice(0,16)}export{n as generateRecordId,t as hashContent};
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
//#region packages/indexer/src/filesystem-crawler.d.ts
|
|
2
|
+
interface CrawlResult {
|
|
3
|
+
/** File path relative to workspace root */
|
|
4
|
+
relativePath: string;
|
|
5
|
+
/** Absolute file path */
|
|
6
|
+
absolutePath: string;
|
|
7
|
+
/** File content */
|
|
8
|
+
content: string;
|
|
9
|
+
/** File extension (lowercase, with dot) */
|
|
10
|
+
extension: string;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
interface CrawlOptions {
|
|
13
|
+
/** Glob patterns to exclude */
|
|
14
|
+
excludePatterns: string[];
|
|
15
|
+
/** Root directory to crawl */
|
|
16
|
+
rootDir: string;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Crawl a directory tree and yield files that should be indexed.
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
declare class FilesystemCrawler {
|
|
22
|
+
/** Binary file extensions that should always be skipped */
|
|
23
|
+
private static readonly BINARY_EXTENSIONS;
|
|
24
|
+
crawl(options: CrawlOptions): Promise<CrawlResult[]>;
|
|
25
|
+
private walkDir;
|
|
26
|
+
private isExcluded;
|
|
26
27
|
}
|
|
27
|
-
//#
|
|
28
|
+
//#endregion
|
|
29
|
+
export { CrawlOptions, CrawlResult, FilesystemCrawler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{lstat as
|
|
1
|
+
import{lstat as e,readFile as t,readdir as n,stat as r}from"node:fs/promises";import{extname as i,join as a,relative as o}from"node:path";import{FILE_LIMITS as s,KB_PATHS as c,createLogger as l}from"../../core/dist/index.js";import{minimatch as u}from"minimatch";const d=l(`indexer`);var f=class l{static BINARY_EXTENSIONS=new Set(`.node,.so,.dylib,.dll,.wasm,.bin,.exe,.png,.jpg,.jpeg,.gif,.bmp,.ico,.webp,.svg,.mp3,.mp4,.wav,.avi,.mov,.flac,.zip,.gz,.tar,.bz2,.7z,.rar,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.ttf,.otf,.woff,.woff2,.eot,.pyc,.class,.o,.obj,.a,.lib`.split(`,`));async crawl(e){let t=[],n=new Set;return await this.walkDir(e.rootDir,e.rootDir,e.excludePatterns,t,n),t}async walkDir(u,f,p,m,h){let g;try{g=await n(u,{withFileTypes:!0})}catch(e){let t=e.code;(t===`EACCES`||t===`EPERM`)&&d.warn(`Permission denied, skipping directory`,{dir:u});return}for(let n of g){let d=a(u,n.name),g=o(f,d).replace(/\\/g,`/`);if(!this.isExcluded(g,p)){if(n.isDirectory()){if(n.name.startsWith(`.`)&&!(n.name===c.ai.slice(1)&&g.startsWith(c.ai)))continue;try{if((await e(d)).isSymbolicLink())continue}catch{continue}let t=d;if(h.has(t))continue;h.add(t),await this.walkDir(d,f,p,m,h)}else if(n.isFile()){let e=i(n.name).toLowerCase();if(l.BINARY_EXTENSIONS.has(e))continue;try{if((await r(d)).size>s.maxFileSizeBytes)continue;let n=await t(d,`utf-8`);if(n.includes(`\0`))continue;m.push({relativePath:g,absolutePath:d,content:n,extension:e})}catch{}}}}}isExcluded(e,t){return t.some(t=>u(e,t,{dot:!0}))}};export{f as FilesystemCrawler};
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
import type { GraphEdge, GraphNode } from '@kb/store';
|
|
9
|
-
export interface ExtractedGraph {
|
|
10
|
-
nodes: GraphNode[];
|
|
11
|
-
edges: GraphEdge[];
|
|
1
|
+
import { GraphEdge, GraphNode } from "@kb/store";
|
|
2
|
+
|
|
3
|
+
//#region packages/indexer/src/graph-extractor.d.ts
|
|
4
|
+
interface ExtractedGraph {
|
|
5
|
+
nodes: GraphNode[];
|
|
6
|
+
edges: GraphEdge[];
|
|
12
7
|
}
|
|
13
8
|
/**
|
|
14
9
|
* Extract graph nodes and edges from a single file's content.
|
|
@@ -18,5 +13,6 @@ export interface ExtractedGraph {
|
|
|
18
13
|
* - "defines" edges from module → symbol
|
|
19
14
|
* - "imports" edges from module → imported module
|
|
20
15
|
*/
|
|
21
|
-
|
|
22
|
-
//#
|
|
16
|
+
declare function extractGraph(content: string, sourcePath: string): ExtractedGraph;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ExtractedGraph, extractGraph };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as
|
|
1
|
+
import{createHash as e}from"node:crypto";import{dirname as t,extname as n,join as r}from"node:path";const i=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`]),a=[{pattern:/^export\s+(?:async\s+)?function\s+(\w+)/gm,kind:`function`,exported:!0},{pattern:/^export\s+(?:default\s+)?class\s+(\w+)/gm,kind:`class`,exported:!0},{pattern:/^export\s+interface\s+(\w+)/gm,kind:`interface`,exported:!0},{pattern:/^export\s+type\s+(\w+)/gm,kind:`type`,exported:!0},{pattern:/^export\s+(?:const|let)\s+(\w+)/gm,kind:`const`,exported:!0},{pattern:/^export\s+enum\s+(\w+)/gm,kind:`enum`,exported:!0},{pattern:/^(?:async\s+)?function\s+(\w+)/gm,kind:`function`,exported:!1},{pattern:/^class\s+(\w+)/gm,kind:`class`,exported:!1},{pattern:/^interface\s+(\w+)/gm,kind:`interface`,exported:!1},{pattern:/^type\s+(\w+)/gm,kind:`type`,exported:!1},{pattern:/^enum\s+(\w+)/gm,kind:`enum`,exported:!1}],o=[/import\s+(?:(?:type\s+)?(?:(?:\{[^}]*\}|[\w*]+)\s+from\s+)?)['"]([^'"]+)['"]/g,/import\(\s*['"]([^'"]+)['"]\s*\)/g,/require\(\s*['"]([^'"]+)['"]\s*\)/g];function s(t,n,r){return e(`sha256`).update(`${t}:${n}:${r}`).digest(`hex`).slice(0,16)}function c(t,n,r){return e(`sha256`).update(`${t}-${r}-${n}`).digest(`hex`).slice(0,16)}function l(e,n){return r(t(n),e).replace(/\\/g,`/`).replace(/\.(js|jsx|ts|tsx|mjs|cjs)$/,``)}function u(e){return e.replace(/\.(js|jsx|ts|tsx|mjs|cjs)$/,``)}function d(e,t){let r=n(t).toLowerCase();if(!i.has(r))return{nodes:[],edges:[]};let d=[],f=[],p=new Date().toISOString(),m=new Set,h=u(t),g=s(`module`,h,h);d.push({id:g,type:`module`,name:t,properties:{ext:r},sourcePath:t,createdAt:p});for(let{pattern:n,kind:r,exported:i}of a){let a=new RegExp(n.source,n.flags),o;for(;(o=a.exec(e))!==null;){let e=o[1],n=`${r}:${e}`;if(m.has(n))continue;m.add(n);let a=s(r,e,t);d.push({id:a,type:r,name:e,properties:{exported:i},sourcePath:t,createdAt:p}),f.push({id:c(g,a,`defines`),fromId:g,toId:a,type:`defines`,weight:i?1:.5})}}let _=new Set;for(let n of o){let r=new RegExp(n.source,n.flags),i;for(;(i=r.exec(e))!==null;){let e=i[1];if(!e.startsWith(`.`)||_.has(e))continue;_.add(e);let n=l(e,t),r=s(`module`,n,n);f.push({id:c(g,r,`imports`),fromId:g,toId:r,type:`imports`,properties:{source:e}})}}return{nodes:d,edges:f}}export{d as extractGraph};
|