@monoes/monograph 1.5.2 → 1.5.4
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/.monodesign/hook.cache.json +1 -1
- package/__tests__/integration/build-atomicity.test.ts +61 -0
- package/__tests__/integration/call-attribution.test.ts +116 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/coverage-summary.json +399 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +881 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/coverage/src/analysis/benchmark.ts.html +481 -0
- package/coverage/src/analysis/changed-files.ts.html +304 -0
- package/coverage/src/analysis/changed-workspaces.ts.html +367 -0
- package/coverage/src/analysis/churn-cache.ts.html +622 -0
- package/coverage/src/analysis/churn-trend.ts.html +256 -0
- package/coverage/src/analysis/churn.ts.html +874 -0
- package/coverage/src/analysis/cluster-quality.ts.html +511 -0
- package/coverage/src/analysis/combined.ts.html +208 -0
- package/coverage/src/analysis/corpus-health.ts.html +208 -0
- package/coverage/src/analysis/coverage-gaps.ts.html +823 -0
- package/coverage/src/analysis/dep-classification.ts.html +586 -0
- package/coverage/src/analysis/dependency-health.ts.html +523 -0
- package/coverage/src/analysis/duplicate-exports.ts.html +415 -0
- package/coverage/src/analysis/fallow-suppression.ts.html +379 -0
- package/coverage/src/analysis/feature-flags-config.ts.html +226 -0
- package/coverage/src/analysis/feature-flags.ts.html +754 -0
- package/coverage/src/analysis/file-classifier.ts.html +346 -0
- package/coverage/src/analysis/git-changed-files.ts.html +271 -0
- package/coverage/src/analysis/health-baseline.ts.html +325 -0
- package/coverage/src/analysis/index.html +641 -0
- package/coverage/src/analysis/issue-filters.ts.html +253 -0
- package/coverage/src/analysis/list.ts.html +307 -0
- package/coverage/src/analysis/node-similarity.ts.html +430 -0
- package/coverage/src/analysis/private-type-leaks.ts.html +442 -0
- package/coverage/src/analysis/progress.ts.html +214 -0
- package/coverage/src/analysis/project-state.ts.html +370 -0
- package/coverage/src/analysis/regression-config.ts.html +193 -0
- package/coverage/src/analysis/rule-overrides.ts.html +328 -0
- package/coverage/src/analysis/scripts.ts.html +370 -0
- package/coverage/src/analysis/shape-extractor.ts.html +691 -0
- package/coverage/src/analysis/since-duration.ts.html +211 -0
- package/coverage/src/analysis/suppression-context.ts.html +370 -0
- package/coverage/src/analysis/suppressions.ts.html +325 -0
- package/coverage/src/analysis/surprise-scorer.ts.html +307 -0
- package/coverage/src/analysis/targets.ts.html +796 -0
- package/coverage/src/analysis/unused-class-members.ts.html +322 -0
- package/coverage/src/analysis/workspace-filter.ts.html +352 -0
- package/coverage/src/analyze/boundary-analysis.ts.html +472 -0
- package/coverage/src/analyze/index.html +161 -0
- package/coverage/src/analyze/predicates/file.ts.html +343 -0
- package/coverage/src/analyze/predicates/import.ts.html +355 -0
- package/coverage/src/analyze/predicates/index.html +146 -0
- package/coverage/src/analyze/predicates/lifecycle.ts.html +250 -0
- package/coverage/src/analyze/unused-deps.ts.html +295 -0
- package/coverage/src/analyze/unused-exports.ts.html +520 -0
- package/coverage/src/analyze/unused-files.ts.html +223 -0
- package/coverage/src/api/index.html +131 -0
- package/coverage/src/api/production-override.ts.html +274 -0
- package/coverage/src/api/programmatic.ts.html +439 -0
- package/coverage/src/audit.ts.html +787 -0
- package/coverage/src/cache/augment-cache.ts.html +274 -0
- package/coverage/src/cache/extraction-cache.ts.html +508 -0
- package/coverage/src/cache/index.html +131 -0
- package/coverage/src/check/filtering.ts.html +319 -0
- package/coverage/src/check/index.html +161 -0
- package/coverage/src/check/index.ts.html +382 -0
- package/coverage/src/check/output.ts.html +322 -0
- package/coverage/src/check/rules.ts.html +268 -0
- package/coverage/src/ci-template.ts.html +337 -0
- package/coverage/src/claude-cli.ts.html +262 -0
- package/coverage/src/cli/ai-context.ts.html +664 -0
- package/coverage/src/cli/augment.ts.html +427 -0
- package/coverage/src/cli/check-update.ts.html +205 -0
- package/coverage/src/cli/doctor.ts.html +631 -0
- package/coverage/src/cli/eval-server.ts.html +463 -0
- package/coverage/src/cli/hooks-install.ts.html +691 -0
- package/coverage/src/cli/index.html +221 -0
- package/coverage/src/cli/setup.ts.html +676 -0
- package/coverage/src/cli/skill-gen.ts.html +1126 -0
- package/coverage/src/commands/flags.ts.html +301 -0
- package/coverage/src/commands/index.html +116 -0
- package/coverage/src/config/boundary-config.ts.html +634 -0
- package/coverage/src/config/cli-schema.ts.html +328 -0
- package/coverage/src/config/config-parsing.ts.html +391 -0
- package/coverage/src/config/duplicates-config.ts.html +271 -0
- package/coverage/src/config/external-plugin.ts.html +316 -0
- package/coverage/src/config/health-config.ts.html +211 -0
- package/coverage/src/config/ignore-exports-used-in-file.ts.html +223 -0
- package/coverage/src/config/index.html +341 -0
- package/coverage/src/config/migration-types.ts.html +304 -0
- package/coverage/src/config/output-format.ts.html +157 -0
- package/coverage/src/config/plugins/builtin.ts.html +1318 -0
- package/coverage/src/config/plugins/index.html +146 -0
- package/coverage/src/config/plugins/registry.ts.html +316 -0
- package/coverage/src/config/plugins/types.ts.html +127 -0
- package/coverage/src/config/resolution.ts.html +391 -0
- package/coverage/src/config/rules.ts.html +295 -0
- package/coverage/src/config/schema-gen.ts.html +430 -0
- package/coverage/src/config/types.ts.html +532 -0
- package/coverage/src/config/used-class-members.ts.html +244 -0
- package/coverage/src/config/validate.ts.html +409 -0
- package/coverage/src/config/workspace.ts.html +496 -0
- package/coverage/src/coverage/cloud-client.ts.html +418 -0
- package/coverage/src/coverage/index.html +146 -0
- package/coverage/src/coverage/upload-inventory.ts.html +337 -0
- package/coverage/src/coverage/upload-source-maps.ts.html +376 -0
- package/coverage/src/discover/entry-points.ts.html +238 -0
- package/coverage/src/discover/index.html +131 -0
- package/coverage/src/discover/infrastructure-entries.ts.html +610 -0
- package/coverage/src/duplicates/detect/concatenation.ts.html +196 -0
- package/coverage/src/duplicates/detect/extraction.ts.html +406 -0
- package/coverage/src/duplicates/detect/filtering.ts.html +421 -0
- package/coverage/src/duplicates/detect/index.html +206 -0
- package/coverage/src/duplicates/detect/lcp.ts.html +166 -0
- package/coverage/src/duplicates/detect/ranking.ts.html +133 -0
- package/coverage/src/duplicates/detect/statistics.ts.html +292 -0
- package/coverage/src/duplicates/detect/suffix-array.ts.html +349 -0
- package/coverage/src/duplicates/families.ts.html +370 -0
- package/coverage/src/duplicates/index.html +161 -0
- package/coverage/src/duplicates/normalize.ts.html +259 -0
- package/coverage/src/duplicates/shingle-filter.ts.html +196 -0
- package/coverage/src/duplicates/token-types.ts.html +271 -0
- package/coverage/src/duplicates/tokenize/index.html +116 -0
- package/coverage/src/duplicates/tokenize/index.ts.html +397 -0
- package/coverage/src/error/fallow-error.ts.html +367 -0
- package/coverage/src/error/index.html +116 -0
- package/coverage/src/error.ts.html +226 -0
- package/coverage/src/export/adjacency-matrix.ts.html +466 -0
- package/coverage/src/export/analysis-json.ts.html +346 -0
- package/coverage/src/export/badge.ts.html +400 -0
- package/coverage/src/export/canvas.ts.html +211 -0
- package/coverage/src/export/codeclimate.ts.html +688 -0
- package/coverage/src/export/compact-health.ts.html +442 -0
- package/coverage/src/export/compact.ts.html +334 -0
- package/coverage/src/export/csv.ts.html +184 -0
- package/coverage/src/export/cypher.ts.html +184 -0
- package/coverage/src/export/dot.ts.html +241 -0
- package/coverage/src/export/gexf.ts.html +262 -0
- package/coverage/src/export/graphml.ts.html +235 -0
- package/coverage/src/export/html.ts.html +1729 -0
- package/coverage/src/export/index.html +401 -0
- package/coverage/src/export/index.ts.html +112 -0
- package/coverage/src/export/json.ts.html +193 -0
- package/coverage/src/export/markdown.ts.html +955 -0
- package/coverage/src/export/mermaid.ts.html +385 -0
- package/coverage/src/export/obsidian.ts.html +217 -0
- package/coverage/src/export/sarif.ts.html +820 -0
- package/coverage/src/export/svg.ts.html +289 -0
- package/coverage/src/fix/deps.ts.html +295 -0
- package/coverage/src/fix/enum-members.ts.html +394 -0
- package/coverage/src/fix/export-surgery.ts.html +676 -0
- package/coverage/src/fix/exports.ts.html +364 -0
- package/coverage/src/fix/index.html +176 -0
- package/coverage/src/fix/orchestrator.ts.html +286 -0
- package/coverage/src/graph/analyzer.ts.html +292 -0
- package/coverage/src/graph/author-analytics.ts.html +736 -0
- package/coverage/src/graph/baseline.ts.html +1381 -0
- package/coverage/src/graph/clone-families.ts.html +481 -0
- package/coverage/src/graph/codeowners-extended.ts.html +427 -0
- package/coverage/src/graph/codeowners-gitlab.ts.html +535 -0
- package/coverage/src/graph/codeowners.ts.html +736 -0
- package/coverage/src/graph/complexity.ts.html +685 -0
- package/coverage/src/graph/cross-reference-findings.ts.html +340 -0
- package/coverage/src/graph/cross-reference.ts.html +502 -0
- package/coverage/src/graph/cycle-detection.ts.html +1018 -0
- package/coverage/src/graph/cycles.ts.html +751 -0
- package/coverage/src/graph/dead-code.ts.html +469 -0
- package/coverage/src/graph/dependency-closure.ts.html +463 -0
- package/coverage/src/graph/dfs.ts.html +439 -0
- package/coverage/src/graph/diff.ts.html +361 -0
- package/coverage/src/graph/duplication-stats.ts.html +322 -0
- package/coverage/src/graph/edge-filter.ts.html +436 -0
- package/coverage/src/graph/explain.ts.html +484 -0
- package/coverage/src/graph/external-style-usage.ts.html +328 -0
- package/coverage/src/graph/health-score.ts.html +622 -0
- package/coverage/src/graph/hotspots.ts.html +742 -0
- package/coverage/src/graph/import-chain.ts.html +529 -0
- package/coverage/src/graph/index.html +746 -0
- package/coverage/src/graph/loader.ts.html +217 -0
- package/coverage/src/graph/maintainability.ts.html +553 -0
- package/coverage/src/graph/merge.ts.html +607 -0
- package/coverage/src/graph/mirrored-dirs.ts.html +691 -0
- package/coverage/src/graph/narrowing.ts.html +361 -0
- package/coverage/src/graph/node-search.ts.html +688 -0
- package/coverage/src/graph/node-types.ts.html +286 -0
- package/coverage/src/graph/normalize-id.ts.html +499 -0
- package/coverage/src/graph/pagerank.ts.html +580 -0
- package/coverage/src/graph/prune.ts.html +370 -0
- package/coverage/src/graph/re-exports/index.html +116 -0
- package/coverage/src/graph/re-exports/propagate.ts.html +370 -0
- package/coverage/src/graph/reachability.ts.html +382 -0
- package/coverage/src/graph/regex-search.ts.html +781 -0
- package/coverage/src/graph/regression.ts.html +682 -0
- package/coverage/src/graph/resolve/discover-types.ts.html +220 -0
- package/coverage/src/graph/resolve/dynamic-imports.ts.html +391 -0
- package/coverage/src/graph/resolve/fallbacks.ts.html +322 -0
- package/coverage/src/graph/resolve/index.html +281 -0
- package/coverage/src/graph/resolve/index.ts.html +289 -0
- package/coverage/src/graph/resolve/path-info.ts.html +208 -0
- package/coverage/src/graph/resolve/re-exports.ts.html +127 -0
- package/coverage/src/graph/resolve/react-native.ts.html +166 -0
- package/coverage/src/graph/resolve/require-imports.ts.html +139 -0
- package/coverage/src/graph/resolve/specifier.ts.html +445 -0
- package/coverage/src/graph/resolve/static-imports.ts.html +127 -0
- package/coverage/src/graph/resolve/types.ts.html +409 -0
- package/coverage/src/graph/resolve/upgrades.ts.html +181 -0
- package/coverage/src/graph/ripple-impact.ts.html +478 -0
- package/coverage/src/graph/risk-profile.ts.html +622 -0
- package/coverage/src/graph/statistics.ts.html +580 -0
- package/coverage/src/graph/stats.ts.html +556 -0
- package/coverage/src/graph/subgraph.ts.html +571 -0
- package/coverage/src/graph/topo-sort.ts.html +598 -0
- package/coverage/src/graph/wcc.ts.html +646 -0
- package/coverage/src/groups/contract-bridge.ts.html +394 -0
- package/coverage/src/groups/contract-registry.ts.html +874 -0
- package/coverage/src/groups/group-config.ts.html +409 -0
- package/coverage/src/groups/group-search.ts.html +502 -0
- package/coverage/src/groups/group-sync.ts.html +331 -0
- package/coverage/src/groups/grpc-extractor.ts.html +277 -0
- package/coverage/src/groups/index.html +221 -0
- package/coverage/src/groups/service-boundary.ts.html +442 -0
- package/coverage/src/groups/topic-extractor.ts.html +355 -0
- package/coverage/src/health/analysis-counts-snapshot.ts.html +256 -0
- package/coverage/src/health/analysis-counts.ts.html +295 -0
- package/coverage/src/health/complexity-findings.ts.html +430 -0
- package/coverage/src/health/distribution-thresholds.ts.html +247 -0
- package/coverage/src/health/grouping.ts.html +499 -0
- package/coverage/src/health/health-grouping.ts.html +343 -0
- package/coverage/src/health/health-report-types.ts.html +580 -0
- package/coverage/src/health/health-report.ts.html +328 -0
- package/coverage/src/health/health-score.ts.html +280 -0
- package/coverage/src/health/hotspot-utils.ts.html +250 -0
- package/coverage/src/health/hotspots.ts.html +397 -0
- package/coverage/src/health/index.html +551 -0
- package/coverage/src/health/large-functions.ts.html +187 -0
- package/coverage/src/health/ownership-metrics.ts.html +268 -0
- package/coverage/src/health/ownership-risk.ts.html +379 -0
- package/coverage/src/health/ownership.ts.html +607 -0
- package/coverage/src/health/quality-gate.ts.html +256 -0
- package/coverage/src/health/risk-profile.ts.html +202 -0
- package/coverage/src/health/runtime-coverage-report.ts.html +388 -0
- package/coverage/src/health/runtime-coverage.ts.html +298 -0
- package/coverage/src/health/scores.ts.html +301 -0
- package/coverage/src/health/scoring-types.ts.html +229 -0
- package/coverage/src/health/target-thresholds.ts.html +361 -0
- package/coverage/src/health/target-types.ts.html +247 -0
- package/coverage/src/health/targets.ts.html +538 -0
- package/coverage/src/health/timings.ts.html +343 -0
- package/coverage/src/health/trend-types.ts.html +256 -0
- package/coverage/src/health/trends.ts.html +343 -0
- package/coverage/src/health/vital-signs-compute.ts.html +409 -0
- package/coverage/src/health/vital-signs-snapshot.ts.html +301 -0
- package/coverage/src/health/vital-signs.ts.html +388 -0
- package/coverage/src/index.html +191 -0
- package/coverage/src/index.ts.html +418 -0
- package/coverage/src/ingest/git-clone.ts.html +823 -0
- package/coverage/src/ingest/index.html +161 -0
- package/coverage/src/ingest/query-memory.ts.html +481 -0
- package/coverage/src/ingest/transcribe.ts.html +847 -0
- package/coverage/src/ingest/url-ingest.ts.html +346 -0
- package/coverage/src/init/agent-hooks.ts.html +343 -0
- package/coverage/src/init/git-hooks.ts.html +298 -0
- package/coverage/src/init/index.html +146 -0
- package/coverage/src/init/project-detection.ts.html +400 -0
- package/coverage/src/license/index.html +116 -0
- package/coverage/src/license/manager.ts.html +445 -0
- package/coverage/src/lsp/code-actions.ts.html +466 -0
- package/coverage/src/lsp/code-lens.ts.html +253 -0
- package/coverage/src/lsp/diagnostics-ext.ts.html +535 -0
- package/coverage/src/lsp/diagnostics-push.ts.html +394 -0
- package/coverage/src/lsp/diagnostics.ts.html +379 -0
- package/coverage/src/lsp/hover.ts.html +277 -0
- package/coverage/src/lsp/index.html +206 -0
- package/coverage/src/lsp/server.ts.html +847 -0
- package/coverage/src/mcp/index.html +146 -0
- package/coverage/src/mcp/params.ts.html +688 -0
- package/coverage/src/mcp/resources.ts.html +457 -0
- package/coverage/src/mcp/tool-builders.ts.html +694 -0
- package/coverage/src/mcp-resources/communities-resource.ts.html +301 -0
- package/coverage/src/mcp-resources/graph-resource.ts.html +127 -0
- package/coverage/src/mcp-resources/index.html +251 -0
- package/coverage/src/mcp-resources/index.ts.html +112 -0
- package/coverage/src/mcp-resources/named-cluster-resource.ts.html +190 -0
- package/coverage/src/mcp-resources/named-process-resource.ts.html +163 -0
- package/coverage/src/mcp-resources/processes-resource.ts.html +286 -0
- package/coverage/src/mcp-resources/repo-context-resource.ts.html +193 -0
- package/coverage/src/mcp-resources/repos-resource.ts.html +148 -0
- package/coverage/src/mcp-resources/schema-resource.ts.html +223 -0
- package/coverage/src/mcp-resources/wiki-resource.ts.html +154 -0
- package/coverage/src/mcp-tools/api-impact.ts.html +628 -0
- package/coverage/src/mcp-tools/context.ts.html +418 -0
- package/coverage/src/mcp-tools/cypher.ts.html +172 -0
- package/coverage/src/mcp-tools/detect-changes.ts.html +433 -0
- package/coverage/src/mcp-tools/explain.ts.html +280 -0
- package/coverage/src/mcp-tools/graph-query.ts.html +469 -0
- package/coverage/src/mcp-tools/group-list.ts.html +349 -0
- package/coverage/src/mcp-tools/group-query.ts.html +163 -0
- package/coverage/src/mcp-tools/group-sync.ts.html +181 -0
- package/coverage/src/mcp-tools/impact.ts.html +691 -0
- package/coverage/src/mcp-tools/index.html +431 -0
- package/coverage/src/mcp-tools/index.ts.html +148 -0
- package/coverage/src/mcp-tools/list-repos.ts.html +199 -0
- package/coverage/src/mcp-tools/neighbors.ts.html +325 -0
- package/coverage/src/mcp-tools/query.ts.html +343 -0
- package/coverage/src/mcp-tools/rename.ts.html +439 -0
- package/coverage/src/mcp-tools/route-map.ts.html +379 -0
- package/coverage/src/mcp-tools/serve.ts.html +208 -0
- package/coverage/src/mcp-tools/shape-check.ts.html +631 -0
- package/coverage/src/mcp-tools/staleness.ts.html +124 -0
- package/coverage/src/mcp-tools/tool-map.ts.html +283 -0
- package/coverage/src/mcp-tools/wiki-build.ts.html +196 -0
- package/coverage/src/mcp-tools/wiki.ts.html +169 -0
- package/coverage/src/migrate/index.html +161 -0
- package/coverage/src/migrate/jscpd.ts.html +319 -0
- package/coverage/src/migrate/jsonc-gen.ts.html +199 -0
- package/coverage/src/migrate/knip.ts.html +463 -0
- package/coverage/src/migrate/toml-gen.ts.html +229 -0
- package/coverage/src/parsers/c.ts.html +178 -0
- package/coverage/src/parsers/cpp.ts.html +172 -0
- package/coverage/src/parsers/csharp.ts.html +214 -0
- package/coverage/src/parsers/dart.ts.html +202 -0
- package/coverage/src/parsers/extractor.ts.html +691 -0
- package/coverage/src/parsers/go.ts.html +166 -0
- package/coverage/src/parsers/index.html +386 -0
- package/coverage/src/parsers/java.ts.html +166 -0
- package/coverage/src/parsers/kotlin.ts.html +193 -0
- package/coverage/src/parsers/language-config.ts.html +169 -0
- package/coverage/src/parsers/language-parsers.ts.html +445 -0
- package/coverage/src/parsers/loader.ts.html +532 -0
- package/coverage/src/parsers/named-bindings.ts.html +274 -0
- package/coverage/src/parsers/php.ts.html +196 -0
- package/coverage/src/parsers/python.ts.html +163 -0
- package/coverage/src/parsers/ruby.ts.html +202 -0
- package/coverage/src/parsers/rust.ts.html +160 -0
- package/coverage/src/parsers/swift.ts.html +169 -0
- package/coverage/src/parsers/typescript.ts.html +208 -0
- package/coverage/src/parsers/vue.ts.html +322 -0
- package/coverage/src/pipeline/cluster-only.ts.html +277 -0
- package/coverage/src/pipeline/effort.ts.html +235 -0
- package/coverage/src/pipeline/index.html +191 -0
- package/coverage/src/pipeline/orchestrator.ts.html +844 -0
- package/coverage/src/pipeline/phases/boundary.ts.html +538 -0
- package/coverage/src/pipeline/phases/bridge-adapters/electron-ipc.ts.html +358 -0
- package/coverage/src/pipeline/phases/bridge-adapters/index.html +176 -0
- package/coverage/src/pipeline/phases/bridge-adapters/registry.ts.html +127 -0
- package/coverage/src/pipeline/phases/bridge-adapters/tauri.ts.html +394 -0
- package/coverage/src/pipeline/phases/bridge-adapters/types.ts.html +178 -0
- package/coverage/src/pipeline/phases/bridge-adapters/wails.ts.html +184 -0
- package/coverage/src/pipeline/phases/bridge-resolver.ts.html +316 -0
- package/coverage/src/pipeline/phases/call-site-extractors.ts.html +592 -0
- package/coverage/src/pipeline/phases/communities.ts.html +634 -0
- package/coverage/src/pipeline/phases/contextual-proximity.ts.html +349 -0
- package/coverage/src/pipeline/phases/cross-file.ts.html +433 -0
- package/coverage/src/pipeline/phases/docs-parse.ts.html +1006 -0
- package/coverage/src/pipeline/phases/evidence.ts.html +112 -0
- package/coverage/src/pipeline/phases/field-access.ts.html +232 -0
- package/coverage/src/pipeline/phases/framework-detect.ts.html +412 -0
- package/coverage/src/pipeline/phases/god-nodes.ts.html +574 -0
- package/coverage/src/pipeline/phases/import-resolver.ts.html +427 -0
- package/coverage/src/pipeline/phases/index.html +626 -0
- package/coverage/src/pipeline/phases/leiden.ts.html +316 -0
- package/coverage/src/pipeline/phases/llm-extract.ts.html +577 -0
- package/coverage/src/pipeline/phases/markdown.ts.html +448 -0
- package/coverage/src/pipeline/phases/middleware-extractor.ts.html +466 -0
- package/coverage/src/pipeline/phases/module-resolution.ts.html +967 -0
- package/coverage/src/pipeline/phases/mro.ts.html +253 -0
- package/coverage/src/pipeline/phases/orm.ts.html +1594 -0
- package/coverage/src/pipeline/phases/parse.ts.html +751 -0
- package/coverage/src/pipeline/phases/pdf-parse.ts.html +484 -0
- package/coverage/src/pipeline/phases/processes.ts.html +832 -0
- package/coverage/src/pipeline/phases/re-export-propagation.ts.html +565 -0
- package/coverage/src/pipeline/phases/reachability.ts.html +553 -0
- package/coverage/src/pipeline/phases/routes.ts.html +1135 -0
- package/coverage/src/pipeline/phases/scan.ts.html +484 -0
- package/coverage/src/pipeline/phases/scope-resolution.ts.html +1147 -0
- package/coverage/src/pipeline/phases/structure.ts.html +289 -0
- package/coverage/src/pipeline/phases/suggest.ts.html +361 -0
- package/coverage/src/pipeline/phases/surprises.ts.html +334 -0
- package/coverage/src/pipeline/phases/tools.ts.html +625 -0
- package/coverage/src/pipeline/phases/variables-phase.ts.html +196 -0
- package/coverage/src/pipeline/phases/variables.ts.html +286 -0
- package/coverage/src/pipeline/phases/wildcard-phase.ts.html +235 -0
- package/coverage/src/pipeline/phases/wildcard-synthesis.ts.html +727 -0
- package/coverage/src/pipeline/progress.ts.html +259 -0
- package/coverage/src/pipeline/runner.ts.html +469 -0
- package/coverage/src/pipeline/types.ts.html +208 -0
- package/coverage/src/query/cypher-parser.ts.html +1435 -0
- package/coverage/src/query/index.html +116 -0
- package/coverage/src/registry/index.html +116 -0
- package/coverage/src/registry/repo-registry.ts.html +460 -0
- package/coverage/src/regression/baseline-deltas.ts.html +730 -0
- package/coverage/src/regression/baseline.ts.html +313 -0
- package/coverage/src/regression/counts.ts.html +346 -0
- package/coverage/src/regression/index.html +176 -0
- package/coverage/src/regression/outcome.ts.html +319 -0
- package/coverage/src/regression/tolerance.ts.html +190 -0
- package/coverage/src/report/attributed-duplication.ts.html +421 -0
- package/coverage/src/report/badge-svg.ts.html +385 -0
- package/coverage/src/report/cross-ref-human.ts.html +235 -0
- package/coverage/src/report/duplication-grouping.ts.html +307 -0
- package/coverage/src/report/grouping.ts.html +496 -0
- package/coverage/src/report/human-check.ts.html +958 -0
- package/coverage/src/report/human-dupes.ts.html +511 -0
- package/coverage/src/report/human-health.ts.html +670 -0
- package/coverage/src/report/human.ts.html +445 -0
- package/coverage/src/report/index.html +341 -0
- package/coverage/src/report/json-actions.ts.html +358 -0
- package/coverage/src/report/json-builders.ts.html +295 -0
- package/coverage/src/report/json-schema.ts.html +310 -0
- package/coverage/src/report/number-format.ts.html +358 -0
- package/coverage/src/report/output-grouped.ts.html +391 -0
- package/coverage/src/report/pipeline-perf.ts.html +253 -0
- package/coverage/src/report/trace-human.ts.html +466 -0
- package/coverage/src/reporting/graph-report.ts.html +1378 -0
- package/coverage/src/reporting/index.html +116 -0
- package/coverage/src/results/fallow-results.ts.html +541 -0
- package/coverage/src/results/index.html +131 -0
- package/coverage/src/results/types.ts.html +532 -0
- package/coverage/src/scope-resolution/evidence-weights.ts.html +208 -0
- package/coverage/src/scope-resolution/index.html +116 -0
- package/coverage/src/search/ast-chunker.ts.html +703 -0
- package/coverage/src/search/diacritic.ts.html +106 -0
- package/coverage/src/search/hybrid-query.ts.html +280 -0
- package/coverage/src/search/index.html +161 -0
- package/coverage/src/search/rrf.ts.html +238 -0
- package/coverage/src/security/index.html +131 -0
- package/coverage/src/security/safe-fetch.ts.html +424 -0
- package/coverage/src/security/sensitive-files.ts.html +157 -0
- package/coverage/src/skills/index.html +116 -0
- package/coverage/src/skills/platform-skills.ts.html +784 -0
- package/coverage/src/staleness/git-staleness.ts.html +283 -0
- package/coverage/src/staleness/index.html +116 -0
- package/coverage/src/storage/db.ts.html +415 -0
- package/coverage/src/storage/edge-store.ts.html +400 -0
- package/coverage/src/storage/file-cache.ts.html +319 -0
- package/coverage/src/storage/fts-store.ts.html +1240 -0
- package/coverage/src/storage/index.html +221 -0
- package/coverage/src/storage/node-store.ts.html +712 -0
- package/coverage/src/storage/schema.ts.html +598 -0
- package/coverage/src/storage/suppressions.ts.html +520 -0
- package/coverage/src/storage/unlinked-refs.ts.html +436 -0
- package/coverage/src/types.ts.html +676 -0
- package/coverage/src/validation/extraction-validator.ts.html +247 -0
- package/coverage/src/validation/index.html +116 -0
- package/coverage/src/watch/index.html +116 -0
- package/coverage/src/watch/watcher.ts.html +499 -0
- package/coverage/src/web/analyze-api.ts.html +523 -0
- package/coverage/src/web/api.ts.html +1837 -0
- package/coverage/src/web/async-jobs.ts.html +412 -0
- package/coverage/src/web/index.html +191 -0
- package/coverage/src/web/mcp-http.ts.html +766 -0
- package/coverage/src/web/react-ui.ts.html +319 -0
- package/coverage/src/web/server.ts.html +355 -0
- package/coverage/src/wiki/gist-publisher.ts.html +313 -0
- package/coverage/src/wiki/index.html +176 -0
- package/coverage/src/wiki/prompt-builder.ts.html +190 -0
- package/coverage/src/wiki/providers.ts.html +487 -0
- package/coverage/src/wiki/wiki-generator.ts.html +736 -0
- package/coverage/src/wiki/wiki-store.ts.html +232 -0
- package/dist/src/cli/eval-server.d.ts.map +1 -1
- package/dist/src/cli/eval-server.js +8 -1
- package/dist/src/cli/eval-server.js.map +1 -1
- package/dist/src/cli/skill-gen.js.map +1 -1
- package/dist/src/graph/regex-search.d.ts.map +1 -1
- package/dist/src/graph/regex-search.js +13 -13
- package/dist/src/graph/regex-search.js.map +1 -1
- package/dist/src/graph/statistics.d.ts +0 -4
- package/dist/src/graph/statistics.d.ts.map +1 -1
- package/dist/src/graph/statistics.js +0 -7
- package/dist/src/graph/statistics.js.map +1 -1
- package/dist/src/pipeline/orchestrator.js +22 -0
- package/dist/src/pipeline/orchestrator.js.map +1 -1
- package/dist/src/pipeline/phases/call-site-extractors.d.ts +8 -0
- package/dist/src/pipeline/phases/call-site-extractors.d.ts.map +1 -1
- package/dist/src/pipeline/phases/call-site-extractors.js +9 -9
- package/dist/src/pipeline/phases/call-site-extractors.js.map +1 -1
- package/dist/src/pipeline/phases/module-resolution.js +2 -2
- package/dist/src/pipeline/phases/module-resolution.js.map +1 -1
- package/dist/src/pipeline/phases/scope-resolution.d.ts.map +1 -1
- package/dist/src/pipeline/phases/scope-resolution.js +76 -1
- package/dist/src/pipeline/phases/scope-resolution.js.map +1 -1
- package/dist/src/registry/repo-registry.d.ts.map +1 -1
- package/dist/src/registry/repo-registry.js +1 -2
- package/dist/src/registry/repo-registry.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/cli/eval-server.ts +8 -1
- package/src/cli/skill-gen.ts +16 -16
- package/src/graph/regex-search.ts +13 -14
- package/src/graph/statistics.ts +0 -8
- package/src/pipeline/orchestrator.ts +18 -0
- package/src/pipeline/phases/call-site-extractors.ts +17 -9
- package/src/pipeline/phases/module-resolution.ts +2 -2
- package/src/pipeline/phases/scope-resolution.ts +89 -1
- package/src/registry/repo-registry.ts +1 -2
- package/vitest.config.ts +7 -0
- package/src/analysis/cycles.ts +0 -268
- package/src/analysis/trace.ts +0 -300
- package/src/analysis/worker-pool.ts +0 -81
- package/src/graph/clone-detector.ts +0 -163
- package/src/graph/shingle-filter.ts +0 -149
- package/src/watch/watch-runner.ts +0 -64
package/src/analysis/cycles.ts
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import type { MonographDb } from '../storage/db.js';
|
|
2
|
-
|
|
3
|
-
export interface DependencyCycle {
|
|
4
|
-
files: string[]; // file paths forming the cycle, in order
|
|
5
|
-
length: number;
|
|
6
|
-
isCrossCommunity: boolean; // true if files span multiple communities
|
|
7
|
-
edgeRelations: string[]; // relations used in the cycle edges
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface CycleDetectionResult {
|
|
11
|
-
cycles: DependencyCycle[];
|
|
12
|
-
totalCycles: number;
|
|
13
|
-
filesInCycles: number;
|
|
14
|
-
longestCycle: number;
|
|
15
|
-
crossCommunityCycles: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface NodeRow {
|
|
19
|
-
id: string;
|
|
20
|
-
file_path: string | null;
|
|
21
|
-
community_id: number | null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface EdgeRow {
|
|
25
|
-
source_id: string;
|
|
26
|
-
target_id: string;
|
|
27
|
-
relation: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Iterative Tarjan's SCC algorithm to avoid stack overflow on large graphs.
|
|
32
|
-
* Returns arrays of node IDs, each array is one SCC.
|
|
33
|
-
*/
|
|
34
|
-
function tarjanSCC(adjacency: Map<string, string[]>, nodes: string[]): string[][] {
|
|
35
|
-
const index: Map<string, number> = new Map();
|
|
36
|
-
const lowlink: Map<string, number> = new Map();
|
|
37
|
-
const onStack: Set<string> = new Set();
|
|
38
|
-
const stack: string[] = [];
|
|
39
|
-
const sccs: string[][] = [];
|
|
40
|
-
let counter = 0;
|
|
41
|
-
|
|
42
|
-
// Iterative DFS using explicit call stack
|
|
43
|
-
for (const startNode of nodes) {
|
|
44
|
-
if (index.has(startNode)) continue;
|
|
45
|
-
|
|
46
|
-
// Each frame: [nodeId, neighborIndex, parent]
|
|
47
|
-
type Frame = { node: string; neighborIdx: number };
|
|
48
|
-
const callStack: Frame[] = [{ node: startNode, neighborIdx: 0 }];
|
|
49
|
-
|
|
50
|
-
index.set(startNode, counter);
|
|
51
|
-
lowlink.set(startNode, counter);
|
|
52
|
-
counter++;
|
|
53
|
-
stack.push(startNode);
|
|
54
|
-
onStack.add(startNode);
|
|
55
|
-
|
|
56
|
-
while (callStack.length > 0) {
|
|
57
|
-
const frame = callStack[callStack.length - 1];
|
|
58
|
-
const { node } = frame;
|
|
59
|
-
const neighbors = adjacency.get(node) ?? [];
|
|
60
|
-
|
|
61
|
-
if (frame.neighborIdx < neighbors.length) {
|
|
62
|
-
const neighbor = neighbors[frame.neighborIdx];
|
|
63
|
-
frame.neighborIdx++;
|
|
64
|
-
|
|
65
|
-
if (!index.has(neighbor)) {
|
|
66
|
-
index.set(neighbor, counter);
|
|
67
|
-
lowlink.set(neighbor, counter);
|
|
68
|
-
counter++;
|
|
69
|
-
stack.push(neighbor);
|
|
70
|
-
onStack.add(neighbor);
|
|
71
|
-
callStack.push({ node: neighbor, neighborIdx: 0 });
|
|
72
|
-
} else if (onStack.has(neighbor)) {
|
|
73
|
-
const curLow = lowlink.get(node)!;
|
|
74
|
-
const neighborIdx = index.get(neighbor)!;
|
|
75
|
-
if (neighborIdx < curLow) {
|
|
76
|
-
lowlink.set(node, neighborIdx);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
// Done with this node — pop and propagate lowlink to parent
|
|
81
|
-
callStack.pop();
|
|
82
|
-
if (callStack.length > 0) {
|
|
83
|
-
const parent = callStack[callStack.length - 1].node;
|
|
84
|
-
const parentLow = lowlink.get(parent)!;
|
|
85
|
-
const nodeLow = lowlink.get(node)!;
|
|
86
|
-
if (nodeLow < parentLow) {
|
|
87
|
-
lowlink.set(parent, nodeLow);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// If this is an SCC root, pop the stack
|
|
92
|
-
if (lowlink.get(node) === index.get(node)) {
|
|
93
|
-
const scc: string[] = [];
|
|
94
|
-
let w: string;
|
|
95
|
-
do {
|
|
96
|
-
w = stack.pop()!;
|
|
97
|
-
onStack.delete(w);
|
|
98
|
-
scc.push(w);
|
|
99
|
-
} while (w !== node);
|
|
100
|
-
sccs.push(scc);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return sccs;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Enumerate elementary cycles within a given SCC using DFS.
|
|
111
|
-
* Caps at maxCycles to avoid exponential blowup.
|
|
112
|
-
*/
|
|
113
|
-
function findCyclesInSCC(
|
|
114
|
-
scc: string[],
|
|
115
|
-
adjacency: Map<string, string[]>,
|
|
116
|
-
maxCycles: number
|
|
117
|
-
): string[][] {
|
|
118
|
-
const sccSet = new Set(scc);
|
|
119
|
-
const cycles: string[][] = [];
|
|
120
|
-
const seen = new Set<string>();
|
|
121
|
-
|
|
122
|
-
for (const startNode of scc) {
|
|
123
|
-
if (cycles.length >= maxCycles) break;
|
|
124
|
-
|
|
125
|
-
const path: string[] = [startNode];
|
|
126
|
-
const onPath = new Set<string>([startNode]);
|
|
127
|
-
|
|
128
|
-
const dfs = (node: string): void => {
|
|
129
|
-
if (cycles.length >= maxCycles) return;
|
|
130
|
-
const neighbors = adjacency.get(node) ?? [];
|
|
131
|
-
for (const neighbor of neighbors) {
|
|
132
|
-
if (!sccSet.has(neighbor)) continue;
|
|
133
|
-
if (neighbor === startNode && path.length > 1) {
|
|
134
|
-
// Found a cycle — normalize via smallest-index-first rotation
|
|
135
|
-
const canonical = canonicalRotation([...path]);
|
|
136
|
-
const key = canonical.join('\0');
|
|
137
|
-
if (!seen.has(key)) {
|
|
138
|
-
seen.add(key);
|
|
139
|
-
cycles.push([...path, startNode]);
|
|
140
|
-
}
|
|
141
|
-
} else if (!onPath.has(neighbor)) {
|
|
142
|
-
path.push(neighbor);
|
|
143
|
-
onPath.add(neighbor);
|
|
144
|
-
dfs(neighbor);
|
|
145
|
-
path.pop();
|
|
146
|
-
onPath.delete(neighbor);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
dfs(startNode);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return cycles;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function canonicalRotation(cycle: string[]): string[] {
|
|
158
|
-
// Find index of lexicographically smallest element
|
|
159
|
-
let minIdx = 0;
|
|
160
|
-
for (let i = 1; i < cycle.length; i++) {
|
|
161
|
-
if (cycle[i] < cycle[minIdx]) minIdx = i;
|
|
162
|
-
}
|
|
163
|
-
return [...cycle.slice(minIdx), ...cycle.slice(0, minIdx)];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export function detectCycles(db: MonographDb): CycleDetectionResult {
|
|
167
|
-
// Load all File nodes
|
|
168
|
-
const nodeRows = db.prepare(
|
|
169
|
-
`SELECT id, file_path, community_id FROM nodes WHERE label = 'File'`
|
|
170
|
-
).all() as NodeRow[];
|
|
171
|
-
|
|
172
|
-
const nodeMap = new Map<string, NodeRow>();
|
|
173
|
-
for (const row of nodeRows) {
|
|
174
|
-
nodeMap.set(row.id, row);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Load all IMPORTS and RE_EXPORTS edges between File nodes
|
|
178
|
-
const edgeRows = db.prepare(
|
|
179
|
-
`SELECT e.source_id, e.target_id, e.relation
|
|
180
|
-
FROM edges e
|
|
181
|
-
WHERE e.relation IN ('IMPORTS', 'RE_EXPORTS')
|
|
182
|
-
AND e.source_id IN (SELECT id FROM nodes WHERE label = 'File')
|
|
183
|
-
AND e.target_id IN (SELECT id FROM nodes WHERE label = 'File')`
|
|
184
|
-
).all() as EdgeRow[];
|
|
185
|
-
|
|
186
|
-
// Build adjacency list
|
|
187
|
-
const adjacency = new Map<string, string[]>();
|
|
188
|
-
const edgeRelationMap = new Map<string, string>(); // "src\0tgt" -> relation
|
|
189
|
-
|
|
190
|
-
for (const row of nodeRows) {
|
|
191
|
-
adjacency.set(row.id, []);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
for (const edge of edgeRows) {
|
|
195
|
-
const neighbors = adjacency.get(edge.source_id);
|
|
196
|
-
if (neighbors) {
|
|
197
|
-
neighbors.push(edge.target_id);
|
|
198
|
-
}
|
|
199
|
-
edgeRelationMap.set(`${edge.source_id}\0${edge.target_id}`, edge.relation);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Run Tarjan's SCC
|
|
203
|
-
const nodeIds = nodeRows.map(n => n.id);
|
|
204
|
-
const sccs = tarjanSCC(adjacency, nodeIds);
|
|
205
|
-
|
|
206
|
-
// SCCs with size > 1 are multi-node cycles; size-1 SCCs are cycles only if self-referencing
|
|
207
|
-
const cycleSCCs = sccs.filter(scc =>
|
|
208
|
-
scc.length > 1 || (scc.length === 1 && adjacency.get(scc[0])?.includes(scc[0])),
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
const cycles: DependencyCycle[] = [];
|
|
212
|
-
const filesInCyclesSet = new Set<string>();
|
|
213
|
-
|
|
214
|
-
for (const scc of cycleSCCs) {
|
|
215
|
-
const elementaryCycles = scc.length === 1
|
|
216
|
-
? [[scc[0], scc[0]]]
|
|
217
|
-
: findCyclesInSCC(scc, adjacency, 20);
|
|
218
|
-
for (const cyclePath of elementaryCycles) {
|
|
219
|
-
// cyclePath is [...nodes, startNode] — last element = first
|
|
220
|
-
const cycleNodes = cyclePath.slice(0, -1);
|
|
221
|
-
|
|
222
|
-
for (const nodeId of cycleNodes) {
|
|
223
|
-
filesInCyclesSet.add(nodeId);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Collect file paths
|
|
227
|
-
const files = cycleNodes.map(id => nodeMap.get(id)?.file_path ?? id);
|
|
228
|
-
|
|
229
|
-
// isCrossCommunity: any two nodes with different community_id
|
|
230
|
-
const communityIds = cycleNodes
|
|
231
|
-
.map(id => nodeMap.get(id)?.community_id)
|
|
232
|
-
.filter((c): c is number => c !== null && c !== undefined);
|
|
233
|
-
const uniqueCommunities = new Set(communityIds);
|
|
234
|
-
const isCrossCommunity = uniqueCommunities.size > 1;
|
|
235
|
-
|
|
236
|
-
// Collect edge relations used in this cycle
|
|
237
|
-
const edgeRelations: string[] = [];
|
|
238
|
-
for (let i = 0; i < cyclePath.length - 1; i++) {
|
|
239
|
-
const key = `${cyclePath[i]}\0${cyclePath[i + 1]}`;
|
|
240
|
-
const rel = edgeRelationMap.get(key);
|
|
241
|
-
if (rel && !edgeRelations.includes(rel)) {
|
|
242
|
-
edgeRelations.push(rel);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
cycles.push({
|
|
247
|
-
files,
|
|
248
|
-
length: cycleNodes.length,
|
|
249
|
-
isCrossCommunity,
|
|
250
|
-
edgeRelations,
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// Sort by length ascending
|
|
256
|
-
cycles.sort((a, b) => a.length - b.length);
|
|
257
|
-
|
|
258
|
-
const longestCycle = cycles.length > 0 ? cycles.reduce((a, c) => Math.max(a, c.length), 0) : 0;
|
|
259
|
-
const crossCommunityCycles = cycles.filter(c => c.isCrossCommunity).length;
|
|
260
|
-
|
|
261
|
-
return {
|
|
262
|
-
cycles,
|
|
263
|
-
totalCycles: cycles.length,
|
|
264
|
-
filesInCycles: filesInCyclesSet.size,
|
|
265
|
-
longestCycle,
|
|
266
|
-
crossCommunityCycles,
|
|
267
|
-
};
|
|
268
|
-
}
|
package/src/analysis/trace.ts
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
export type TraceReason = 'no_references' | 'only_re_exported' | 'self_import' | 'has_references';
|
|
2
|
-
|
|
3
|
-
export interface ReferenceLocation {
|
|
4
|
-
filePath: string;
|
|
5
|
-
line: number;
|
|
6
|
-
col: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface ReExportChain {
|
|
10
|
-
path: string;
|
|
11
|
-
exportName: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ExportTrace {
|
|
15
|
-
file: string;
|
|
16
|
-
exportName: string;
|
|
17
|
-
isUsed: boolean;
|
|
18
|
-
directReferences: ReferenceLocation[];
|
|
19
|
-
reExportChains: ReExportChain[];
|
|
20
|
-
reason: TraceReason;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface FileTrace {
|
|
24
|
-
file: string;
|
|
25
|
-
exports: Array<{ name: string; isUsed: boolean; line: number }>;
|
|
26
|
-
importsFrom: string[];
|
|
27
|
-
importedBy: string[];
|
|
28
|
-
reExports: Array<{ name: string; fromFile: string }>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface DependencyTrace {
|
|
32
|
-
packageName: string;
|
|
33
|
-
directImporters: string[];
|
|
34
|
-
transitiveImporters: string[];
|
|
35
|
-
isUsed: boolean;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface CloneInstance {
|
|
39
|
-
filePath: string;
|
|
40
|
-
startLine: number;
|
|
41
|
-
endLine: number;
|
|
42
|
-
similarity: number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface CloneTrace {
|
|
46
|
-
sourceFile: string;
|
|
47
|
-
sourceLine: number;
|
|
48
|
-
matchingInstances: CloneInstance[];
|
|
49
|
-
groupId?: number;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface GraphNode {
|
|
53
|
-
id: string;
|
|
54
|
-
filePath?: string;
|
|
55
|
-
name: string;
|
|
56
|
-
isExported: boolean;
|
|
57
|
-
startLine?: number;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface GraphEdge {
|
|
61
|
-
sourceId: string;
|
|
62
|
-
targetId: string;
|
|
63
|
-
relation: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface Graph {
|
|
67
|
-
nodes: GraphNode[];
|
|
68
|
-
edges: GraphEdge[];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** Build an O(1) id→node index. Pass to the trace functions when calling multiple times on the same graph. */
|
|
72
|
-
export function buildNodeIndex(graph: Graph): Map<string, GraphNode> {
|
|
73
|
-
const index = new Map<string, GraphNode>();
|
|
74
|
-
for (const n of graph.nodes) index.set(n.id, n);
|
|
75
|
-
return index;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function traceExport(
|
|
79
|
-
graph: Graph,
|
|
80
|
-
file: string,
|
|
81
|
-
exportName: string,
|
|
82
|
-
nodeIndex?: Map<string, GraphNode>,
|
|
83
|
-
): ExportTrace {
|
|
84
|
-
// Build index once if not supplied — O(N) amortised when caller reuses it
|
|
85
|
-
const idx = nodeIndex ?? buildNodeIndex(graph);
|
|
86
|
-
|
|
87
|
-
// Find nodes in the target file matching exportName
|
|
88
|
-
const targetIds = new Set<string>();
|
|
89
|
-
for (const n of graph.nodes) {
|
|
90
|
-
if (n.filePath === file && n.name === exportName) targetIds.add(n.id);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Find CALLS or IMPORTS edges pointing to these nodes from other files
|
|
94
|
-
const directReferences: ReferenceLocation[] = [];
|
|
95
|
-
const reExportChains: ReExportChain[] = [];
|
|
96
|
-
|
|
97
|
-
for (const edge of graph.edges) {
|
|
98
|
-
if (!targetIds.has(edge.targetId)) continue;
|
|
99
|
-
|
|
100
|
-
const sourceNode = idx.get(edge.sourceId);
|
|
101
|
-
if (!sourceNode) continue;
|
|
102
|
-
|
|
103
|
-
// Skip self-references (same file)
|
|
104
|
-
if (sourceNode.filePath === file) continue;
|
|
105
|
-
|
|
106
|
-
if (edge.relation === 'CALLS' || edge.relation === 'IMPORTS') {
|
|
107
|
-
directReferences.push({
|
|
108
|
-
filePath: sourceNode.filePath ?? sourceNode.id,
|
|
109
|
-
line: sourceNode.startLine ?? 0,
|
|
110
|
-
col: 0,
|
|
111
|
-
});
|
|
112
|
-
} else if (edge.relation === 'RE_EXPORTS') {
|
|
113
|
-
reExportChains.push({
|
|
114
|
-
path: sourceNode.filePath ?? sourceNode.id,
|
|
115
|
-
exportName: sourceNode.name,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Determine reason
|
|
121
|
-
let reason: TraceReason;
|
|
122
|
-
let isUsed: boolean;
|
|
123
|
-
|
|
124
|
-
if (directReferences.length > 0) {
|
|
125
|
-
reason = 'has_references';
|
|
126
|
-
isUsed = true;
|
|
127
|
-
} else if (reExportChains.length > 0) {
|
|
128
|
-
reason = 'only_re_exported';
|
|
129
|
-
isUsed = false;
|
|
130
|
-
} else {
|
|
131
|
-
reason = 'no_references';
|
|
132
|
-
isUsed = false;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
file,
|
|
137
|
-
exportName,
|
|
138
|
-
isUsed,
|
|
139
|
-
directReferences,
|
|
140
|
-
reExportChains,
|
|
141
|
-
reason,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export function traceFile(
|
|
146
|
-
graph: Graph,
|
|
147
|
-
file: string,
|
|
148
|
-
nodeIndex?: Map<string, GraphNode>,
|
|
149
|
-
): FileTrace {
|
|
150
|
-
// Build index once if not supplied
|
|
151
|
-
const idx = nodeIndex ?? buildNodeIndex(graph);
|
|
152
|
-
|
|
153
|
-
// Find all nodes in this file
|
|
154
|
-
const fileNodes = graph.nodes.filter((n) => n.filePath === file);
|
|
155
|
-
const fileNodeIds = new Set(fileNodes.map((n) => n.id));
|
|
156
|
-
|
|
157
|
-
// Pre-compute which target node ids have external references in one edge pass
|
|
158
|
-
// to avoid O(exported_nodes * edges) in the map below.
|
|
159
|
-
const externallyReferenced = new Set<string>();
|
|
160
|
-
const importsFromSet = new Set<string>();
|
|
161
|
-
const importedBySet = new Set<string>();
|
|
162
|
-
const reExports: Array<{ name: string; fromFile: string }> = [];
|
|
163
|
-
|
|
164
|
-
for (const edge of graph.edges) {
|
|
165
|
-
const srcInFile = fileNodeIds.has(edge.sourceId);
|
|
166
|
-
const tgtInFile = fileNodeIds.has(edge.targetId);
|
|
167
|
-
|
|
168
|
-
if (edge.relation === 'IMPORTS') {
|
|
169
|
-
if (srcInFile) {
|
|
170
|
-
const targetNode = idx.get(edge.targetId);
|
|
171
|
-
if (targetNode?.filePath && targetNode.filePath !== file) {
|
|
172
|
-
importsFromSet.add(targetNode.filePath);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (tgtInFile) {
|
|
176
|
-
const sourceNode = idx.get(edge.sourceId);
|
|
177
|
-
if (sourceNode?.filePath && sourceNode.filePath !== file) {
|
|
178
|
-
importedBySet.add(sourceNode.filePath);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
// External IMPORTS into a file node → that node is externally referenced
|
|
182
|
-
if (tgtInFile && !srcInFile) {
|
|
183
|
-
externallyReferenced.add(edge.targetId);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (edge.relation === 'CALLS' && tgtInFile && !srcInFile) {
|
|
188
|
-
externallyReferenced.add(edge.targetId);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (edge.relation === 'RE_EXPORTS' && srcInFile) {
|
|
192
|
-
const sourceNode = idx.get(edge.sourceId);
|
|
193
|
-
const targetNode = idx.get(edge.targetId);
|
|
194
|
-
if (sourceNode && targetNode?.filePath) {
|
|
195
|
-
reExports.push({ name: sourceNode.name, fromFile: targetNode.filePath });
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Build exports list using pre-computed set — O(exported_nodes) not O(exported_nodes * edges)
|
|
201
|
-
const exports = fileNodes
|
|
202
|
-
.filter((n) => n.isExported)
|
|
203
|
-
.map((n) => ({
|
|
204
|
-
name: n.name,
|
|
205
|
-
isUsed: externallyReferenced.has(n.id),
|
|
206
|
-
line: n.startLine ?? 0,
|
|
207
|
-
}));
|
|
208
|
-
|
|
209
|
-
return {
|
|
210
|
-
file,
|
|
211
|
-
exports,
|
|
212
|
-
importsFrom: Array.from(importsFromSet),
|
|
213
|
-
importedBy: Array.from(importedBySet),
|
|
214
|
-
reExports,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export function traceDependency(
|
|
219
|
-
importEdges: Array<{ sourceFile: string; targetPackage: string }>,
|
|
220
|
-
packageName: string,
|
|
221
|
-
): DependencyTrace {
|
|
222
|
-
// Find direct importers
|
|
223
|
-
const directImporters = importEdges
|
|
224
|
-
.filter((e) => e.targetPackage === packageName)
|
|
225
|
-
.map((e) => e.sourceFile);
|
|
226
|
-
|
|
227
|
-
const directSet = new Set(directImporters);
|
|
228
|
-
|
|
229
|
-
// BFS to find transitive importers via reverse import graph
|
|
230
|
-
const reverseImportMap = new Map<string, Set<string>>();
|
|
231
|
-
for (const edge of importEdges) {
|
|
232
|
-
if (!reverseImportMap.has(edge.targetPackage)) {
|
|
233
|
-
reverseImportMap.set(edge.targetPackage, new Set());
|
|
234
|
-
}
|
|
235
|
-
reverseImportMap.get(edge.targetPackage)!.add(edge.sourceFile);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const transitiveSet = new Set<string>();
|
|
239
|
-
const queue = [...directImporters];
|
|
240
|
-
const visited = new Set(directImporters);
|
|
241
|
-
|
|
242
|
-
while (queue.length > 0) {
|
|
243
|
-
const current = queue.shift()!;
|
|
244
|
-
const upstream = reverseImportMap.get(current);
|
|
245
|
-
if (upstream) {
|
|
246
|
-
for (const file of upstream) {
|
|
247
|
-
if (!visited.has(file) && !directSet.has(file)) {
|
|
248
|
-
visited.add(file);
|
|
249
|
-
transitiveSet.add(file);
|
|
250
|
-
queue.push(file);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return {
|
|
257
|
-
packageName,
|
|
258
|
-
directImporters,
|
|
259
|
-
transitiveImporters: Array.from(transitiveSet),
|
|
260
|
-
isUsed: directImporters.length > 0 || transitiveSet.size > 0,
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export function traceClone(
|
|
265
|
-
cloneGroups: Array<{ id: number; instances: CloneInstance[] }>,
|
|
266
|
-
file: string,
|
|
267
|
-
line: number,
|
|
268
|
-
): CloneTrace {
|
|
269
|
-
// Find groups containing an instance at (file, line)
|
|
270
|
-
const matchingGroups = cloneGroups.filter((group) =>
|
|
271
|
-
group.instances.some(
|
|
272
|
-
(inst) =>
|
|
273
|
-
inst.filePath === file && inst.startLine <= line && inst.endLine >= line,
|
|
274
|
-
),
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
if (matchingGroups.length === 0) {
|
|
278
|
-
return {
|
|
279
|
-
sourceFile: file,
|
|
280
|
-
sourceLine: line,
|
|
281
|
-
matchingInstances: [],
|
|
282
|
-
groupId: undefined,
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// Use the first matching group
|
|
287
|
-
const group = matchingGroups[0];
|
|
288
|
-
|
|
289
|
-
// Return all OTHER instances (not the source one)
|
|
290
|
-
const matchingInstances = group.instances.filter(
|
|
291
|
-
(inst) => !(inst.filePath === file && inst.startLine <= line && inst.endLine >= line),
|
|
292
|
-
);
|
|
293
|
-
|
|
294
|
-
return {
|
|
295
|
-
sourceFile: file,
|
|
296
|
-
sourceLine: line,
|
|
297
|
-
matchingInstances,
|
|
298
|
-
groupId: group.id,
|
|
299
|
-
};
|
|
300
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Worker } from 'node:worker_threads';
|
|
2
|
-
import { cpus } from 'node:os';
|
|
3
|
-
|
|
4
|
-
const DEFAULT_STACK_SIZE_MB = 16;
|
|
5
|
-
|
|
6
|
-
export interface WorkerPoolOptions {
|
|
7
|
-
threads?: number;
|
|
8
|
-
stackSizeMb?: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface QueuedTask {
|
|
12
|
-
script: string;
|
|
13
|
-
input: unknown;
|
|
14
|
-
resolve: (value: unknown) => void;
|
|
15
|
-
reject: (reason: unknown) => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let _globalPool: WorkerPool | null = null;
|
|
19
|
-
|
|
20
|
-
export class WorkerPool {
|
|
21
|
-
readonly threads: number;
|
|
22
|
-
readonly stackSizeMb: number;
|
|
23
|
-
|
|
24
|
-
private _active = 0;
|
|
25
|
-
private readonly _queue: QueuedTask[] = [];
|
|
26
|
-
|
|
27
|
-
constructor(opts: WorkerPoolOptions = {}) {
|
|
28
|
-
this.threads = opts.threads ?? cpus().length;
|
|
29
|
-
this.stackSizeMb = opts.stackSizeMb ?? DEFAULT_STACK_SIZE_MB;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
run<T>(workerScript: string, input: unknown): Promise<T> {
|
|
33
|
-
return new Promise<T>((resolve, reject) => {
|
|
34
|
-
this._queue.push({ script: workerScript, input, resolve: resolve as (v: unknown) => void, reject });
|
|
35
|
-
this._drain();
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private _drain(): void {
|
|
40
|
-
while (this._active < this.threads && this._queue.length > 0) {
|
|
41
|
-
const task = this._queue.shift()!;
|
|
42
|
-
this._active++;
|
|
43
|
-
const worker = new Worker(task.script, {
|
|
44
|
-
workerData: task.input,
|
|
45
|
-
resourceLimits: { stackSizeMb: this.stackSizeMb },
|
|
46
|
-
});
|
|
47
|
-
let settled = false;
|
|
48
|
-
const settle = (fn: () => void) => {
|
|
49
|
-
if (settled) return;
|
|
50
|
-
settled = true;
|
|
51
|
-
fn();
|
|
52
|
-
this._active--;
|
|
53
|
-
this._drain();
|
|
54
|
-
};
|
|
55
|
-
worker.on('message', (v: unknown) => {
|
|
56
|
-
settle(() => task.resolve(v));
|
|
57
|
-
});
|
|
58
|
-
worker.on('error', (err: unknown) => {
|
|
59
|
-
settle(() => task.reject(err));
|
|
60
|
-
});
|
|
61
|
-
worker.on('exit', (code: number) => {
|
|
62
|
-
if (code !== 0) {
|
|
63
|
-
settle(() => task.reject(new Error(`Worker exited with code ${code}`)));
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function configureGlobalPool(threads?: number, stackSizeMb?: number): WorkerPool {
|
|
71
|
-
if (!_globalPool) _globalPool = new WorkerPool({ threads, stackSizeMb });
|
|
72
|
-
return _globalPool;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function getGlobalPool(): WorkerPool {
|
|
76
|
-
return _globalPool ?? configureGlobalPool();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function resetGlobalPool(): void {
|
|
80
|
-
_globalPool = null;
|
|
81
|
-
}
|