@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
package/README.md
CHANGED
|
@@ -29,24 +29,74 @@ The KB auto-indexes configured source directories on startup, stores embeddings
|
|
|
29
29
|
|
|
30
30
|
## Quick Start
|
|
31
31
|
|
|
32
|
+
### Global Install (recommended for multi-project setups)
|
|
33
|
+
|
|
32
34
|
```bash
|
|
33
|
-
# Install
|
|
34
|
-
|
|
35
|
+
# Install once, works across all your projects
|
|
36
|
+
npx @vpxa/kb init --global
|
|
35
37
|
|
|
36
|
-
#
|
|
38
|
+
# Then in any workspace, scaffold instructions only
|
|
37
39
|
npx @vpxa/kb init
|
|
40
|
+
```
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
npx @vpxa/kb reindex
|
|
42
|
+
### Local Install (per-project, self-contained)
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
```bash
|
|
45
|
+
# Full local initialization
|
|
46
|
+
npx @vpxa/kb init --local
|
|
44
47
|
|
|
45
|
-
#
|
|
48
|
+
# Index and search
|
|
49
|
+
npx @vpxa/kb reindex
|
|
50
|
+
npx @vpxa/kb search "authentication middleware"
|
|
46
51
|
npx @vpxa/kb serve
|
|
47
52
|
```
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
### After upgrading
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx @vpxa/kb init --force # Overwrite all scaffold/skill files
|
|
58
|
+
npx @vpxa/kb init --guide # Check which files are outdated
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
> **Note:** In local mode, once `@vpxa/kb` is installed locally, you can use the short `kb` command (e.g. `kb search`, `kb serve`) since the local binary takes precedence.
|
|
62
|
+
|
|
63
|
+
## Global vs Local Mode
|
|
64
|
+
|
|
65
|
+
KB supports two installation modes:
|
|
66
|
+
|
|
67
|
+
| | Global | Local |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| **Install** | `kb init --global` (once) | `kb init --local` (per project) |
|
|
70
|
+
| **MCP config** | User-level (IDE-wide) | `.vscode/mcp.json` (workspace) |
|
|
71
|
+
| **Data store** | `~/.kb-data/<partition>/` | `.kb-data/store/` (in project) |
|
|
72
|
+
| **Skills** | `~/.kb-data/skills/` | `.github/skills/` (in project) |
|
|
73
|
+
| **Config** | Auto defaults per workspace | `kb.config.json` (in project) |
|
|
74
|
+
|
|
75
|
+
### How it works
|
|
76
|
+
|
|
77
|
+
- **`kb init --global`** — Installs the MCP server in your user-level IDE config (VS Code, Cursor, Claude Code). Creates `~/.kb-data/` for data. Skills are shared. The server auto-indexes each workspace it's opened in.
|
|
78
|
+
- **`kb init`** (smart default) — If global is installed, scaffolds workspace-only files (AGENTS.md, instructions, curated directories). If not, does a full local install.
|
|
79
|
+
- **`kb init --local`** — Traditional per-project install with full local config and data store.
|
|
80
|
+
|
|
81
|
+
### Checking your mode
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
kb status
|
|
85
|
+
# Mode: global (workspace scaffolded)
|
|
86
|
+
# Data: ~/.kb-data/my-project-a1b2c3d4/
|
|
87
|
+
# Registry: 3 workspace(s) enrolled
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Cross-workspace search (global mode only)
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
search({ query: "error handling", workspaces: ["*"] }) # All workspaces
|
|
94
|
+
search({ query: "CircuitBreaker", workspaces: ["other-project"] }) # Specific workspace
|
|
95
|
+
symbol({ name: "MyService", workspaces: ["*"] }) # Find symbol across all
|
|
96
|
+
find({ query: "retry logic", workspaces: ["backend", "shared"] }) # Multiple workspaces
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Tools supporting `workspaces` param: `search`, `find`, `symbol`.
|
|
50
100
|
|
|
51
101
|
## Tools by Category
|
|
52
102
|
|
|
@@ -191,6 +241,8 @@ After `kb init`, your `.vscode/mcp.json` is configured automatically:
|
|
|
191
241
|
}
|
|
192
242
|
```
|
|
193
243
|
|
|
244
|
+
> **Global mode:** When installed with `kb init --global`, the MCP server is configured at the user level — no per-project `mcp.json` needed. The server auto-detects and indexes each workspace.
|
|
245
|
+
|
|
194
246
|
## CLI Usage
|
|
195
247
|
|
|
196
248
|
```bash
|
|
@@ -261,7 +313,7 @@ kb status
|
|
|
261
313
|
kb reindex [--full]
|
|
262
314
|
kb onboard <path> [--generate] [--out-dir <dir>]
|
|
263
315
|
kb serve [--transport stdio|http] [--port N]
|
|
264
|
-
kb init [--force]
|
|
316
|
+
kb init [--global|--local] [--force] [--guide]
|
|
265
317
|
```
|
|
266
318
|
|
|
267
319
|
## Configuration
|
|
@@ -290,7 +342,7 @@ kb init [--force]
|
|
|
290
342
|
```text
|
|
291
343
|
@vpxa/kb
|
|
292
344
|
├── packages/
|
|
293
|
-
│ ├── core/ — types, config, logger, constants
|
|
345
|
+
│ ├── core/ — types, config, logger, constants, global registry
|
|
294
346
|
│ ├── store/ — LanceDB vector store
|
|
295
347
|
│ ├── embeddings/ — ONNX local embeddings
|
|
296
348
|
│ ├── chunker/ — tree-sitter + regex code chunking
|
|
@@ -335,6 +387,7 @@ Find relevant code, docs, patterns, and curated knowledge using hybrid (vector +
|
|
|
335
387
|
| `origin` | enum | no | — | Filter: `indexed` (from files), `curated` (agent memory), `produced` (auto-generated) |
|
|
336
388
|
| `category` | string | no | — | Filter by curated category (e.g., `decisions`, `patterns`) |
|
|
337
389
|
| `tags` | string[] | no | — | Filter by tags (OR matching) |
|
|
390
|
+
| `workspaces` | string[] | no | — | Cross-workspace search: partition names, folder basenames, or `["*"]` for all. Global mode only. |
|
|
338
391
|
| `min_score` | number (0–1) | no | 0.25 | Minimum similarity score threshold |
|
|
339
392
|
|
|
340
393
|
**Returns**: Ranked results with score, source path, content type, line range, heading path, origin, tags, and full content text. Each response includes a `_Next:` hint suggesting logical follow-up tools.
|
|
@@ -1149,6 +1202,6 @@ Every tool response includes a `_Next:` suggestion at the bottom. Follow these h
|
|
|
1149
1202
|
- **Workflow Hints**: Every tool response includes `_Next:` suggestions for logical follow-up actions
|
|
1150
1203
|
- **MCP SDK**: `@modelcontextprotocol/sdk` (stdio + StreamableHTTP transports)
|
|
1151
1204
|
- **Runtime**: Node.js ≥ 24, TypeScript, ESM, pnpm workspaces
|
|
1152
|
-
- **Build**:
|
|
1205
|
+
- **Build**: tsdown with integrated dts generation
|
|
1153
1206
|
- **Lint**: Biome
|
|
1154
1207
|
- **Test**: Vitest
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpxa/kb",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Local-first AI developer toolkit — knowledge base, code analysis, context management, and developer tools for LLM agents",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"bin/",
|
|
24
24
|
"packages/*/dist/**/*.js",
|
|
25
25
|
"packages/*/dist/**/*.d.ts",
|
|
26
|
+
"packages/chunker/wasm/*.wasm",
|
|
27
|
+
"packages/chunker/src/queries/**/*.scm",
|
|
28
|
+
"scaffold/",
|
|
26
29
|
"skills/",
|
|
27
30
|
"README.md",
|
|
28
31
|
"LICENSE"
|
|
@@ -31,7 +34,8 @@
|
|
|
31
34
|
".": "./packages/core/dist/index.js",
|
|
32
35
|
"./tools": "./packages/tools/dist/index.js",
|
|
33
36
|
"./store": "./packages/store/dist/index.js",
|
|
34
|
-
"./embeddings": "./packages/embeddings/dist/index.js"
|
|
37
|
+
"./embeddings": "./packages/embeddings/dist/index.js",
|
|
38
|
+
"./enterprise-bridge": "./packages/enterprise-bridge/dist/index.js"
|
|
35
39
|
},
|
|
36
40
|
"types": "./packages/core/dist/index.d.ts",
|
|
37
41
|
"bin": {
|
|
@@ -45,17 +49,20 @@
|
|
|
45
49
|
"linkedom": "^0.x",
|
|
46
50
|
"minimatch": "^10.x",
|
|
47
51
|
"sql.js": "^1.x",
|
|
52
|
+
"tree-sitter-wasms": "^0.x",
|
|
48
53
|
"turndown": "^7.x",
|
|
54
|
+
"web-tree-sitter": "^0.x",
|
|
49
55
|
"zod": "^4.x"
|
|
50
56
|
},
|
|
51
57
|
"devDependencies": {
|
|
52
58
|
"@biomejs/biome": "^2.x",
|
|
53
59
|
"@types/node": "^24.x",
|
|
54
|
-
"esbuild": "^0.x",
|
|
55
|
-
"glob": "^13.x",
|
|
56
60
|
"rimraf": "^6.x",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
61
|
+
"tsdown": "^0.x",
|
|
62
|
+
"turbo": "^2.x",
|
|
63
|
+
"typescript": "^6.x",
|
|
64
|
+
"vitest": "^4.x",
|
|
65
|
+
"ws": "^8.20.0"
|
|
59
66
|
},
|
|
60
67
|
"engines": {
|
|
61
68
|
"node": ">=24"
|
|
@@ -63,7 +70,7 @@
|
|
|
63
70
|
"scripts": {
|
|
64
71
|
"build": "node scripts/build.mjs",
|
|
65
72
|
"typecheck": "tsc -b tsconfig.build.json --emitDeclarationOnly",
|
|
66
|
-
"clean": "rimraf --glob packages/*/
|
|
73
|
+
"clean": "turbo run clean && rimraf --glob node_modules \"packages/*/node_modules\"",
|
|
67
74
|
"lint": "biome check .",
|
|
68
75
|
"lint:fix": "biome check --write .",
|
|
69
76
|
"format": "biome format --write .",
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
files: string[];
|
|
12
|
-
/** Maximum depth of transitive dependency traversal (default: 5) */
|
|
13
|
-
maxDepth?: number;
|
|
14
|
-
/** Output format */
|
|
15
|
-
format?: 'json' | 'markdown';
|
|
1
|
+
import { AnalysisResult } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/analyzers/src/blast-radius-analyzer.d.ts
|
|
4
|
+
interface BlastRadiusOptions {
|
|
5
|
+
/** Changed file paths (relative to root) */
|
|
6
|
+
files: string[];
|
|
7
|
+
/** Maximum depth of transitive dependency traversal (default: 5) */
|
|
8
|
+
maxDepth?: number;
|
|
9
|
+
/** Output format */
|
|
10
|
+
format?: 'json' | 'markdown';
|
|
16
11
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
declare class BlastRadiusAnalyzer {
|
|
13
|
+
readonly name = "blast-radius";
|
|
14
|
+
private depAnalyzer;
|
|
15
|
+
analyze(rootPath: string, options: BlastRadiusOptions): Promise<AnalysisResult>;
|
|
16
|
+
private formatMarkdown;
|
|
22
17
|
}
|
|
23
|
-
//#
|
|
18
|
+
//#endregion
|
|
19
|
+
export { BlastRadiusAnalyzer, BlastRadiusOptions };
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import{DependencyAnalyzer as
|
|
2
|
-
`),
|
|
3
|
-
`);
|
|
4
|
-
`);for(const e of f)t.push(`- \`${e.path}\``)}const p=n.filter(e=>e.reason==="direct-importer");if(p.length>0){t.push(`
|
|
5
|
-
### Direct Importers (${p.length} files)
|
|
6
|
-
`);for(const e of p)t.push(`- \`${e.path}\``)}const r=n.filter(e=>e.reason==="transitive-importer");if(r.length>0){t.push(`
|
|
7
|
-
### Transitive Importers (${r.length} files)
|
|
8
|
-
`);for(const e of r.slice(0,20))t.push(`- \`${e.path}\` (depth ${e.depth})`);r.length>20&&t.push(`- ... and ${r.length-20} more`)}const o=n.filter(e=>e.reason==="test");if(o.length>0){t.push(`
|
|
9
|
-
### Affected Tests (${o.length} files)
|
|
10
|
-
`);for(const e of o)t.push(`- \`${e.path}\``)}return t.push(`
|
|
1
|
+
import{DependencyAnalyzer as e}from"./dependency-analyzer.js";var t=class{name=`blast-radius`;depAnalyzer=new e;async analyze(e,t){let{files:n,maxDepth:r=5,format:i=`markdown`}=t,a=Date.now(),o=(await this.depAnalyzer.analyze(e,{format:`json`})).data,s=o.reverseGraph??{},c=o.testCoverage??{},l=new Map,u=[];for(let e of n){l.set(e,{path:e,reason:`changed`,depth:0});let t=e.replace(/\.[jt]sx?$/,``);u.push({path:t,depth:0})}for(;u.length>0;){let e=u.shift();if(!e)break;let{path:t,depth:n}=e;if(n>=r)continue;let i=s[t]??[];for(let e of i){if(l.has(e))continue;let t=n===0?`direct-importer`:`transitive-importer`;l.set(e,{path:e,reason:t,depth:n+1});let r=e.replace(/\.[jt]sx?$/,``);u.push({path:r,depth:n+1})}}let d=new Set;for(let[e]of l){let t=c[e.replace(/\.[jt]sx?$/,``)]??[];for(let e of t)l.has(e)||(d.add(e),l.set(e,{path:e,reason:`test`,depth:999}))}let f=[...l.values()].sort((e,t)=>e.depth-t.depth);return{output:i===`json`?JSON.stringify({changedFiles:n,affected:f},null,2):this.formatMarkdown(n,f,s),data:{changedFiles:n,affected:f},meta:{analyzedAt:new Date().toISOString(),scope:e,fileCount:f.length,durationMs:Date.now()-a}}}formatMarkdown(e,t,n){let r=[];r.push(`## Blast Radius Analysis
|
|
2
|
+
`),r.push(`**Changed files:** ${e.length}`),r.push(`**Total affected:** ${t.length}\n`);let i=t.filter(e=>e.reason===`changed`);if(i.length>0){r.push(`### Changed Files
|
|
3
|
+
`);for(let e of i)r.push(`- \`${e.path}\``)}let a=t.filter(e=>e.reason===`direct-importer`);if(a.length>0){r.push(`\n### Direct Importers (${a.length} files)\n`);for(let e of a)r.push(`- \`${e.path}\``)}let o=t.filter(e=>e.reason===`transitive-importer`);if(o.length>0){r.push(`\n### Transitive Importers (${o.length} files)\n`);for(let e of o.slice(0,20))r.push(`- \`${e.path}\` (depth ${e.depth})`);o.length>20&&r.push(`- ... and ${o.length-20} more`)}let s=t.filter(e=>e.reason===`test`);if(s.length>0){r.push(`\n### Affected Tests (${s.length} files)\n`);for(let e of s)r.push(`- \`${e.path}\``)}return r.push(`
|
|
11
4
|
### Review Summary
|
|
12
|
-
`),
|
|
13
|
-
`)}}export{
|
|
5
|
+
`),r.push(`| Category | Count |`),r.push(`|----------|-------|`),r.push(`| Changed | ${i.length} |`),r.push(`| Direct importers | ${a.length} |`),r.push(`| Transitive importers | ${o.length} |`),r.push(`| Affected tests | ${s.length} |`),r.push(`| **Total review scope** | **${t.length}** |`),r.join(`
|
|
6
|
+
`)}};export{t as BlastRadiusAnalyzer};
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { AnalysisResult, DependencyAnalyzerOptions, IAnalyzer, ImportInfo } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/analyzers/src/dependency-analyzer.d.ts
|
|
4
|
+
declare class DependencyAnalyzer implements IAnalyzer<DependencyAnalyzerOptions> {
|
|
5
|
+
readonly name = "dependencies";
|
|
6
|
+
/** Map of workspace package names to their relative entry point paths */
|
|
7
|
+
private workspacePackages;
|
|
8
|
+
analyze(rootPath: string, options?: DependencyAnalyzerOptions): Promise<AnalysisResult>;
|
|
9
|
+
private collectFiles;
|
|
10
|
+
private extractImportsRegex;
|
|
11
|
+
private groupExternalDeps;
|
|
12
|
+
private groupInternalDeps;
|
|
13
|
+
/**
|
|
14
|
+
* Build reverse graph: for each source file, who imports it?
|
|
15
|
+
*/
|
|
16
|
+
buildReverseGraph(imports: ImportInfo[], _rootPath: string): Record<string, string[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Build test coverage map: for each source file, which test files exercise it?
|
|
19
|
+
*/
|
|
20
|
+
buildTestCoverage(imports: ImportInfo[], _rootPath: string): Record<string, string[]>;
|
|
21
|
+
/** Resolve a relative import path to a normalized file path (best-effort). */
|
|
22
|
+
private resolveImportPath;
|
|
23
|
+
/**
|
|
24
|
+
* Build a map of workspace package names → relative entry point paths.
|
|
25
|
+
* Scans for package.json files in common workspace dirs.
|
|
26
|
+
*/
|
|
27
|
+
private buildWorkspaceMap;
|
|
28
|
+
private formatMarkdown;
|
|
29
|
+
private formatMermaid;
|
|
28
30
|
}
|
|
29
|
-
//#
|
|
31
|
+
//#endregion
|
|
32
|
+
export { DependencyAnalyzer };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)
|
|
3
|
-
`),g.length>0&&e.push(`**Top dependencies**: ${g.join(", ")}
|
|
4
|
-
`),e.push(`### External Dependencies
|
|
5
|
-
`),e.push("| Package | Imports | Used By |"),e.push("|---------|---------|---------|");for(const[l,p]of r)e.push(`| ${l} | ${p.count} | ${p.usedBy.length} ${p.usedBy.length===1?"file":"files"} |`);if(t&&Object.keys(t).length>0){const l=Object.keys(t).length,p=Object.keys(o).filter(f=>!y(f)&&!t[f.replace(/\\.[jt]sx?$/,"")]);e.push(`
|
|
1
|
+
import{readFile as e,readdir as t}from"node:fs/promises";import{dirname as n,extname as r,join as i,relative as a,resolve as o}from"node:path";import{SUPPORTED_EXTENSIONS as s,WasmRuntime as c,extractImports as l}from"../../chunker/dist/index.js";const u=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.py`,`.java`,`.go`,`.cs`,`.kt`,`.scala`,`.rb`,`.rs`,`.php`,`.swift`]),d=[{regex:/import\s+(?:(?:type\s+)?(?:(?:\{[^}]*\}|[\w*]+)\s+from\s+)?)['"]([^'"]+)['"]/g,confidence:`high`},{regex:/import\(\s*['"]([^'"]+)['"]\s*\)/g,confidence:`medium`},{regex:/require\(\s*['"]([^'"]+)['"]\s*\)/g,confidence:`medium`},{regex:/^from\s+([\w.]+)\s+import\b/gm,confidence:`high`,lang:`python`},{regex:/^import\s+([\w.]+)\s*$/gm,confidence:`high`,lang:`python`},{regex:/^import\s+(?:static\s+)?([\w.]+(?:\.\*)?)\s*;/gm,confidence:`high`,lang:`java`},{regex:/(?:^import\s+|^\s+)[""]([^""]+)[""]/gm,confidence:`high`,lang:`go`},{regex:/^using\s+(?:static\s+)?([\w.]+)\s*;/gm,confidence:`high`,lang:`csharp`},{regex:/^use\s+([\w:]+(?:::\w+)*)/gm,confidence:`high`,lang:`rust`},{regex:/^use\s+([\w\\]+)\s*;/gm,confidence:`high`,lang:`php`},{regex:/require(?:_relative)?\s+['"]([^'"]+)['"]/g,confidence:`medium`,lang:`ruby`},{regex:/^import\s+(\w+)\s*$/gm,confidence:`high`,lang:`swift`}],f=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`]),p=[/\.(test|spec)\.[jt]sx?$/,/\/__tests__\//,/\/test\//,/\/tests\//],m={".ts":`js`,".tsx":`js`,".js":`js`,".jsx":`js`,".mjs":`js`,".cjs":`js`,".py":`python`,".java":`java`,".kt":`java`,".scala":`java`,".go":`go`,".cs":`csharp`,".rs":`rust`,".php":`php`,".rb":`ruby`,".swift":`swift`};function h(e,t){return!t||t===`js`?!e.startsWith(`.`)&&!e.startsWith(`/`):t===`python`?!e.startsWith(`.`):t===`java`?!e.startsWith(`com.`)||e.startsWith(`com.amazonaws`)||e.startsWith(`com.google`)||e.startsWith(`com.fasterxml`):t===`go`?e.includes(`.`)&&!e.startsWith(`.`):t===`csharp`?e.startsWith(`System`)||e.startsWith(`Microsoft`)||e.startsWith(`Newtonsoft`)||e.startsWith(`Amazon`):t===`rust`?!e.startsWith(`crate::`)&&!e.startsWith(`self::`)&&!e.startsWith(`super::`):!0}function g(e){return p.some(t=>t.test(e))}var _=class{name=`dependencies`;workspacePackages=new Map;async analyze(t,n={}){let{format:i=`markdown`}=n,o=Date.now();this.workspacePackages=await this.buildWorkspaceMap(t);let u=!1;try{await c.ensure(),u=!0}catch{}let d=await this.collectFiles(t),f=[];for(let n of d){let i=await e(n,`utf-8`),o=r(n).toLowerCase(),c=a(t,n).replace(/\\/g,`/`);if(u&&s.has(o)){let e=await l(i,o,c);if(e.length>0)f.push(...e);else{let e=this.extractImportsRegex(i,n,t);f.push(...e)}}else{let e=this.extractImportsRegex(i,n,t);f.push(...e)}}let p=this.groupExternalDeps(f),m=this.groupInternalDeps(f,t),h=this.buildReverseGraph(f,t),g=this.buildTestCoverage(f,t);return{output:i===`json`?JSON.stringify({external:p,internal:m,reverseGraph:h,testCoverage:g},null,2):i===`mermaid`?this.formatMermaid(m):this.formatMarkdown(p,m,t,g),data:{external:p,internal:m,reverseGraph:h,testCoverage:g,totalImports:f.length},meta:{analyzedAt:new Date().toISOString(),scope:t,fileCount:d.length,durationMs:Date.now()-o}}}async collectFiles(e){let n=[],a=async e=>{let o=await t(e,{withFileTypes:!0});for(let t of o){if(f.has(t.name)||t.name.startsWith(`.`))continue;let o=i(e,t.name);t.isDirectory()?await a(o):u.has(r(t.name))&&n.push(o)}};return await a(e),n}extractImportsRegex(e,t,n){let i=[],o=m[r(t).toLowerCase()];for(let r of d){if(r.lang&&r.lang!==o||!r.lang&&o&&o!==`js`)continue;let s=new RegExp(r.regex.source,r.regex.flags),c;for(;(c=s.exec(e))!==null;){let e=c[1],s=h(e,o);i.push({source:e,specifiers:[],filePath:a(n,t).replace(/\\/g,`/`),isExternal:s,confidence:r.confidence})}}return i}groupExternalDeps(e){let t={};for(let n of e){if(!n.isExternal)continue;let e=m[r(n.filePath).toLowerCase()],i;if(e===`java`){let e=n.source.split(`.`);for(;e.length>1;){let t=e[e.length-1];if(t===`*`||/^[A-Z]/.test(t))e.pop();else break}i=e.length>=2?e.slice(0,2).join(`.`):e.join(`.`)}else if(e===`python`)i=n.source.split(`.`)[0];else if(e===`go`)i=n.source;else if(e===`csharp`){let e=n.source.split(`.`);i=e.length>=2?e.slice(0,2).join(`.`):n.source}else i=n.source.startsWith(`@`)?n.source.split(`/`).slice(0,2).join(`/`):n.source.split(`/`)[0];t[i]||(t[i]={count:0,confidence:n.confidence,usedBy:new Set}),t[i].count++,t[i].usedBy.add(n.filePath),n.confidence===`high`?t[i].confidence=`high`:n.confidence===`medium`&&t[i].confidence===`low`&&(t[i].confidence=`medium`)}let n={};for(let[e,r]of Object.entries(t))n[e]={count:r.count,confidence:r.confidence,usedBy:[...r.usedBy]};return n}groupInternalDeps(e,t){let n={};for(let t of e)t.isExternal||(n[t.filePath]||(n[t.filePath]=new Set),n[t.filePath].add(t.source));let r={};for(let[e,t]of Object.entries(n))r[e]=[...t];return r}buildReverseGraph(e,t){let r={};for(let t of e){let e=n(t.filePath),i=this.resolveImportPath(t.source,e);i&&(r[i]||(r[i]=new Set),r[i].add(t.filePath))}let i={};for(let[e,t]of Object.entries(r))i[e]=[...t];return i}buildTestCoverage(e,t){let r={};for(let t of e){if(!g(t.filePath))continue;let e=n(t.filePath),i=this.resolveImportPath(t.source,e);!i||g(i)||(r[i]||(r[i]=new Set),r[i].add(t.filePath))}let i={};for(let[e,t]of Object.entries(r))i[e]=[...t];return i}resolveImportPath(e,t){if(e.startsWith(`.`))return i(t,e).replace(/\\/g,`/`).replace(/\.[jt]sx?$/,``);let n=e.startsWith(`@`)?e.split(`/`).slice(0,2).join(`/`):e.split(`/`)[0],r=this.workspacePackages.get(n);return r?r.replace(/\.[jt]sx?$/,``):null}async buildWorkspaceMap(n){let r=new Map;for(let s of[`packages`,`functions`,`libs`,`apps`,`cdk`]){let c=i(n,s);try{let s=await t(c,{withFileTypes:!0});for(let t of s)if(!(!t.isDirectory()||f.has(t.name)))try{let s=i(c,t.name,`package.json`),l=JSON.parse(await e(s,`utf-8`));if(l.name){let e=l.main??l.exports?.[`.`]??`src/index.ts`,i=a(n,o(c,t.name,e)).replace(/\\/g,`/`);r.set(l.name,i)}}catch{}}catch{}}return r}formatMarkdown(e,t,n,r){let i=[];i.push(`## Dependencies: ${n}\n`);let a=Object.entries(e).sort((e,t)=>t[1].count-e[1].count),o=a.length,s=a.reduce((e,[,t])=>e+t.count,0),c=a.slice(0,5).map(([e])=>e);i.push(`**${o} external packages**, **${s} total imports**, **${Object.keys(t).length} files** with internal imports.\n`),c.length>0&&i.push(`**Top dependencies**: ${c.join(`, `)}\n`),i.push(`### External Dependencies
|
|
2
|
+
`),i.push(`| Package | Imports | Used By |`),i.push(`|---------|---------|---------|`);for(let[e,t]of a)i.push(`| ${e} | ${t.count} | ${t.usedBy.length} ${t.usedBy.length===1?`file`:`files`} |`);if(r&&Object.keys(r).length>0){let e=Object.keys(r).length,n=Object.keys(t).filter(e=>!g(e)&&!r[e.replace(/\\.[jt]sx?$/,``)]);i.push(`
|
|
6
3
|
### Test Coverage Summary
|
|
7
|
-
`),
|
|
4
|
+
`),i.push(`**${e} source modules** with test coverage.`),n.length>0&&i.push(`**${n.length} source files** with no detected test coverage.`);let a=Object.entries(r).sort((e,t)=>t[1].length-e[1].length);i.push(`
|
|
8
5
|
**Most-tested modules:**
|
|
9
|
-
`);for(
|
|
10
|
-
`)}formatMermaid(
|
|
11
|
-
`)}}export{
|
|
6
|
+
`);for(let[e,t]of a.slice(0,10)){let n=e.replace(/\/dist\/[^/]*$/,`/src/index`).replace(/\.mjs$/,`.ts`);i.push(`- ${n} (${t.length} ${t.length===1?`test`:`tests`})`)}}return i.join(`
|
|
7
|
+
`)}formatMermaid(e){let t=[`graph LR`],n=e=>e.replace(/[^a-zA-Z0-9]/g,`_`);for(let[r,i]of Object.entries(e).slice(0,40)){let e=n(r);for(let a of i){let i=n(a);t.push(` ${e}["${r}"] --> ${i}["${a}"]`)}}return t.join(`
|
|
8
|
+
`)}};export{_ as DependencyAnalyzer};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AnalysisResult, DiagramOptions, IAnalyzer } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/analyzers/src/diagram-generator.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Generates Mermaid diagrams by combining output from other analyzers.
|
|
4
6
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
declare class DiagramGenerator implements IAnalyzer<DiagramOptions> {
|
|
8
|
+
readonly name = "diagrams";
|
|
9
|
+
private readonly structureAnalyzer;
|
|
10
|
+
private readonly dependencyAnalyzer;
|
|
11
|
+
analyze(rootPath: string, options?: DiagramOptions): Promise<AnalysisResult>;
|
|
12
|
+
private generateArchitectureDiagram;
|
|
13
|
+
private generateDependencyDiagram;
|
|
12
14
|
}
|
|
13
|
-
//#
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DiagramGenerator };
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import{DependencyAnalyzer as
|
|
2
|
-
`)}async generateDependencyDiagram(
|
|
3
|
-
${(await this.dependencyAnalyzer.analyze(r,{format:"mermaid"})).output}
|
|
4
|
-
\`\`\``}}export{D as DiagramGenerator};
|
|
1
|
+
import{DependencyAnalyzer as e}from"./dependency-analyzer.js";import{StructureAnalyzer as t}from"./structure-analyzer.js";var n=class{name=`diagrams`;structureAnalyzer=new t;dependencyAnalyzer=new e;async analyze(e,t={}){let{diagramType:n=`architecture`}=t,r=Date.now(),i;switch(n){case`dependencies`:i=await this.generateDependencyDiagram(e);break;default:i=await this.generateArchitectureDiagram(e);break}return{output:i,data:{diagramType:n},meta:{analyzedAt:new Date().toISOString(),scope:e,fileCount:0,durationMs:Date.now()-r}}}async generateArchitectureDiagram(e){let t=(await this.structureAnalyzer.analyze(e,{format:`json`,maxDepth:4})).data.tree,n=(await this.dependencyAnalyzer.analyze(e,{format:`json`})).data,r=["```mermaid",`graph TB`],i=(t.children??[]).filter(e=>e.type===`directory`).slice(0,15);for(let e of i){let t=e.name.replace(/[^a-zA-Z0-9]/g,`_`),n=(e.children??[]).filter(e=>e.type===`directory`);if(n.length>0){r.push(` subgraph ${t}["${e.name}/"]`);for(let e of n.slice(0,12)){let n=`${t}_${e.name.replace(/[^a-zA-Z0-9]/g,`_`)}`,i=Array.isArray(e.children)?e.children.length:0;r.push(` ${n}["${e.name}/ (${i})"]`)}r.push(` end`)}else{let n=Array.isArray(e.children)?e.children.length:0;r.push(` ${t}["${e.name}/ (${n} files)"]`)}}let a=new Set;if(n.internal)for(let[e,t]of Object.entries(n.internal)){let n=e.split(`/`)[0]?.replace(/[^a-zA-Z0-9]/g,`_`);for(let e of t){if(e.startsWith(`.`))continue;let t=e.split(`/`)[0]?.replace(/[^a-zA-Z0-9]/g,`_`);if(n&&t&&n!==t){let e=`${n}->${t}`;a.has(e)||(a.add(e),r.push(` ${n} --> ${t}`))}}}return r.push("```"),r.join(`
|
|
2
|
+
`)}async generateDependencyDiagram(e){return`\`\`\`mermaid\n${(await this.dependencyAnalyzer.analyze(e,{format:`mermaid`})).output}\n\`\`\``}};export{n as DiagramGenerator};
|
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import { AnalysisResult, AnalyzerOptions, IAnalyzer } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region packages/analyzers/src/entry-point-analyzer.d.ts
|
|
4
|
+
declare class EntryPointAnalyzer implements IAnalyzer<AnalyzerOptions> {
|
|
5
|
+
readonly name = "entry-points";
|
|
6
|
+
analyze(rootPath: string, _options?: AnalyzerOptions): Promise<AnalysisResult>;
|
|
7
|
+
private fromPackageJson;
|
|
8
|
+
/** Parse package.json `exports` field into entry points. */
|
|
9
|
+
private parseExportsField;
|
|
10
|
+
/** Resolve export value through condition maps (import > default > first string). */
|
|
11
|
+
private resolveExportValue;
|
|
12
|
+
/**
|
|
13
|
+
* Find all workspace package directories in a monorepo.
|
|
14
|
+
* Supports pnpm-workspace.yaml and package.json#workspaces.
|
|
15
|
+
*/
|
|
16
|
+
private findWorkspacePackages;
|
|
17
|
+
/** Simple YAML parser for pnpm-workspace.yaml — extracts packages list. */
|
|
18
|
+
private parsePnpmWorkspaceYaml;
|
|
19
|
+
/**
|
|
20
|
+
* Expand a workspace glob like "packages/*" into actual directories
|
|
21
|
+
* that contain package.json files.
|
|
22
|
+
*/
|
|
23
|
+
private expandWorkspaceGlob;
|
|
24
|
+
private fromHandlerExports;
|
|
25
|
+
/** Check if a file is a test suite. */
|
|
26
|
+
private isTestFile;
|
|
27
|
+
/** Extract a meaningful name from the file path for non-JS entry points */
|
|
28
|
+
private inferNameFromFile;
|
|
29
|
+
/**
|
|
30
|
+
* Derive a contextual name from the directory path for generic handler/main files.
|
|
31
|
+
* E.g., "services/channels/email/delivery/src/handler.ts" → "email-delivery"
|
|
32
|
+
*/
|
|
33
|
+
private deriveContextualName;
|
|
34
|
+
private inferEntryType;
|
|
35
|
+
private detectTrigger;
|
|
36
|
+
private collectFiles;
|
|
37
|
+
private formatMarkdown;
|
|
36
38
|
}
|
|
37
|
-
//#
|
|
39
|
+
//#endregion
|
|
40
|
+
export { EntryPointAnalyzer };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import{access as
|
|
2
|
-
`)){
|
|
3
|
-
`),
|
|
4
|
-
`)
|
|
5
|
-
`);const n=new Map;for(const o of t){const a=n.get(o.type)??[];a.push(o),n.set(o.type,a)}const i=["lambda-handler","main","server","cli","bin","cdk-construct","test"],r=[...n.entries()].sort((o,a)=>i.indexOf(o[0])-i.indexOf(a[0]));s.push("| Name | Type | File | Trigger |"),s.push("|------|------|------|---------|");for(const[,o]of r)for(const a of o)s.push(`| ${a.name} | ${a.type} | ${a.filePath} | ${a.trigger??"\u2014"} |`);return s.join(`
|
|
6
|
-
`)}}export{$ as EntryPointAnalyzer};
|
|
1
|
+
import{access as e,readFile as t,readdir as n}from"node:fs/promises";import{extname as r,join as i,relative as a,resolve as o}from"node:path";import{SUPPORTED_EXTENSIONS as s,WasmRuntime as c,detectEntryPoints as l}from"../../chunker/dist/index.js";const u=new Set([`node_modules`,`.git`,`dist`,`build`,`coverage`,`.turbo`,`.cache`,`cdk.out`,`__pycache__`,`.venv`,`target`,`bin`,`obj`,`.gradle`,`venv`,`env`]),d=new Set([`test`,`tests`,`__tests__`,`spec`,`specs`,`test-utils`]),f=[/export\s+const\s+(handler|main)\s*(?::[^=]*)?\s*=/,/export\s+(?:async\s+)?function\s+(handler|main)\s*\(/,/export\s+const\s+(\w+Handler)\s*(?::[^=]*)?\s*=/,/export\s+default\s+app/,/^app\s*=\s*(?:Flask|FastAPI)\s*\(/m,/^urlpatterns\s*=\s*\[/m,/^if\s+__name__\s*==\s*['"]__main__['"]:/m,/public\s+static\s+void\s+main\s*\(\s*String/,/@SpringBootApplication/,/^func\s+main\s*\(\s*\)/m],p=/export\s+(?:default\s+)?class\s+(\w+)\s+extends\s+(?:Construct|Stack|NestedStack|Stage)/,m=[/from\s+['"]vitest['"]/,/from\s+['"]jest['"]/,/from\s+['"]mocha['"]/,/import\s+.*['"]@jest\/globals['"]/,/require\s*\(\s*['"](?:vitest|jest|mocha)['"]\s*\)/],h=[{regex:/SqsEventSource|SQSEvent|sqs/i,trigger:`SQS`},{regex:/SnsEventSource|SNSEvent|sns/i,trigger:`SNS`},{regex:/ApiGateway|APIGatewayEvent|httpApi|restApi/i,trigger:`API Gateway`},{regex:/ScheduleExpression|EventBridgeRule|schedule/i,trigger:`EventBridge Schedule`},{regex:/S3EventSource|S3Event|s3/i,trigger:`S3`},{regex:/DynamoEventSource|DynamoDBStream/i,trigger:`DynamoDB Stream`},{regex:/@RequestMapping|@GetMapping|@PostMapping/i,trigger:`HTTP Endpoint`},{regex:/http\.ListenAndServe|gin\.Default|echo\.New/i,trigger:`HTTP Server`},{regex:/app\.route\(|@app\.get|@app\.post|@router\./i,trigger:`HTTP Route`}];var g=class{name=`entry-points`;async analyze(e,t={}){let n=Date.now(),r=[],i=await this.findWorkspacePackages(e);if(i.length>0)for(let t of i){let n=await this.fromPackageJson(t,e);r.push(...n)}else{let t=await this.fromPackageJson(e,e);r.push(...t)}let a=await this.fromHandlerExports(e);return r.push(...a),{output:this.formatMarkdown(r,e),data:{entryPoints:r,total:r.length},meta:{analyzedAt:new Date().toISOString(),scope:e,fileCount:r.length,durationMs:Date.now()-n}}}async fromPackageJson(n,r){let o=[],s=a(r,n).replace(/\\/g,`/`)||`.`;try{let r=i(n,`package.json`);await e(r);let a=JSON.parse(await t(r,`utf-8`)),c=s===`.`?``:`${s}/`;if(a.main&&o.push({name:a.name?`${a.name}:main`:`main`,type:`main`,filePath:`${c}${a.main}`}),a.bin){let e=typeof a.bin==`string`?{[a.name??`cli`]:a.bin}:a.bin;for(let[t,n]of Object.entries(e))o.push({name:t,type:`cli`,filePath:`${c}${n}`})}if(a.exports){let e=this.parseExportsField(a.exports,a.name??s,c);o.push(...e)}a.scripts?.start&&o.push({name:a.name?`${a.name}:start`:`start`,type:`server`,filePath:a.scripts.start,trigger:`npm start`})}catch{}return o}parseExportsField(e,t,n){let r=[];if(typeof e==`string`)return r.push({name:t,type:`main`,filePath:`${n}${e}`}),r;if(typeof e!=`object`||!e)return r;for(let[i,a]of Object.entries(e)){if(!i.startsWith(`.`))continue;let e=i===`.`?t:`${t}/${i.slice(2)}`,o=this.resolveExportValue(a);o&&r.push({name:e,type:`main`,filePath:`${n}${o}`})}return r}resolveExportValue(e){if(typeof e==`string`)return e;if(typeof e!=`object`||!e)return;let t=e;for(let e of[`import`,`default`,`require`])if(typeof t[e]==`string`)return t[e];for(let e of Object.values(t))if(typeof e==`string`)return e}async findWorkspacePackages(n){let r=[];try{let a=i(n,`pnpm-workspace.yaml`);await e(a);let o=await t(a,`utf-8`),s=this.parsePnpmWorkspaceYaml(o);for(let e of s){let t=await this.expandWorkspaceGlob(n,e);r.push(...t)}if(r.length>0)return r}catch{}try{let e=i(n,`package.json`),a=JSON.parse(await t(e,`utf-8`)),o=Array.isArray(a.workspaces)?a.workspaces:a.workspaces?.packages??[];for(let e of o){let t=await this.expandWorkspaceGlob(n,e);r.push(...t)}}catch{}return r}parsePnpmWorkspaceYaml(e){let t=[],n=!1;for(let r of e.split(`
|
|
2
|
+
`)){let e=r.trim();if(e===`packages:`){n=!0;continue}if(n){if(e.startsWith(`- `))t.push(e.slice(2).replace(/^['"]|['"]$/g,``));else if(e&&!e.startsWith(`#`))break}}return t}async expandWorkspaceGlob(t,r){let a=[],s=r.indexOf(`*`);if(s===-1){let n=o(t,r);try{await e(i(n,`package.json`)),a.push(n)}catch{}return a}let c=o(t,r.slice(0,s));try{let t=await n(c,{withFileTypes:!0});for(let n of t){if(!n.isDirectory()||u.has(n.name))continue;let t=i(c,n.name);try{await e(i(t,`package.json`)),a.push(t)}catch{}}}catch{}return a}async fromHandlerExports(e){let n=[],i=await this.collectFiles(e),o=!1;try{await c.ensure(),o=!0}catch{}for(let c of i)try{let i=await t(c,`utf-8`),u=a(e,c).replace(/\\/g,`/`),m=r(c);if(!u.split(`/`).some(e=>d.has(e))){let e=!1;if(o&&s.has(m)){let t=await l(i,m,u);for(let r of t)r.trigger||(r.type===`cdk-construct`?r.trigger=`CDK Construct`:r.trigger=this.detectTrigger(i)),n.push(r),e=!0}if(!e)for(let t of f){let r=i.match(t);if(r){let t=r[1]??this.inferNameFromFile(u);(t===`handler`||t===`main`)&&(t=this.deriveContextualName(u)??t);let a=/@SpringBootApplication/.test(i)?`HTTP Server`:this.detectTrigger(i);n.push({name:t,type:this.inferEntryType(r[1]??t,u),filePath:u,trigger:a}),e=!0;break}}if(!e){let e=i.match(p);e&&n.push({name:e[1],type:`cdk-construct`,filePath:u,trigger:`CDK Construct`})}}this.isTestFile(u,i)&&n.push({name:this.inferNameFromFile(u),type:`test`,filePath:u,trigger:`Test Suite`})}catch{}return n}isTestFile(e,t){return/\.(test|spec)\.[jt]sx?$/.test(e)?m.some(e=>e.test(t)):!1}inferNameFromFile(e){return(e.split(/[/\\]/).pop()??`default`).replace(/\.\w+$/,``)}deriveContextualName(e){let t=e.split(`/`).filter(e=>e!==`src`&&e!==`lib`);if(t.pop(),t.length===0)return;let n=t.filter(e=>![`services`,`functions`,`lambdas`,`handlers`,`packages`,`apps`].includes(e));if(n.length===0)return;let r=n.slice(-2);return r.length===2&&r[1].startsWith(r[0])?r[1]:r.join(`-`)}inferEntryType(e,t){return e===`handler`||e===`main`||t.includes(`handler`)||/functions[/]/.test(t)||e.endsWith(`Handler`)?`lambda-handler`:(t.endsWith(`.py`)||t.endsWith(`.go`)||t.endsWith(`.java`),`main`)}detectTrigger(e){for(let t of h)if(t.regex.test(e))return t.trigger}async collectFiles(e){let t=[],a=new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.java`,`.py`,`.go`,`.cs`,`.kt`,`.rb`,`.rs`,`.php`,`.swift`]),o=async(e,s)=>{if(s>10)return;let c=await n(e,{withFileTypes:!0});for(let n of c){if(u.has(n.name)||n.name.startsWith(`.`))continue;let c=i(e,n.name);n.isDirectory()?await o(c,s+1):a.has(r(n.name))&&t.push(c)}};return await o(e,0),t}formatMarkdown(e,t){let n=[];if(n.push(`## Entry Points: ${t}\n`),n.push(`**${e.length} entry ${e.length===1?`point`:`points`}** found\n`),e.length===0)return n.push(`No entry points detected.`),n.join(`
|
|
3
|
+
`);let r=new Map;for(let t of e){let e=r.get(t.type)??[];e.push(t),r.set(t.type,e)}let i=[`lambda-handler`,`main`,`server`,`cli`,`bin`,`cdk-construct`,`test`],a=[...r.entries()].sort((e,t)=>i.indexOf(e[0])-i.indexOf(t[0]));n.push(`| Name | Type | File | Trigger |`),n.push(`|------|------|------|---------|`);for(let[,e]of a)for(let t of e)n.push(`| ${t.name} | ${t.type} | ${t.filePath} | ${t.trigger??`—`} |`);return n.join(`
|
|
4
|
+
`)}};export{g as EntryPointAnalyzer};
|