@monoes/monograph 1.2.0 → 1.2.2
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/.monomind/loops/mastermind-review-1782162423447.json +16 -0
- package/__tests__/mcp-tools/cypher.test.ts +10 -6
- package/__tests__/mcp-tools/detect-changes.test.ts +14 -11
- package/__tests__/pipeline/phases/wildcard-synthesis.test.ts +4 -4
- package/__tests__/search/embed-batch-config.test.ts +7 -7
- package/__tests__/search/hybrid-query.test.ts +3 -1
- package/__tests__/web/api.test.ts +1 -1
- package/dist/src/analysis/churn-cache.d.ts.map +1 -1
- package/dist/src/analysis/churn-cache.js +19 -6
- package/dist/src/analysis/churn-cache.js.map +1 -1
- package/dist/src/analysis/churn-trend.d.ts.map +1 -1
- package/dist/src/analysis/churn-trend.js +50 -6
- package/dist/src/analysis/churn-trend.js.map +1 -1
- package/dist/src/analysis/cluster-quality.d.ts +3 -0
- package/dist/src/analysis/cluster-quality.d.ts.map +1 -1
- package/dist/src/analysis/cluster-quality.js +18 -12
- package/dist/src/analysis/cluster-quality.js.map +1 -1
- package/dist/src/analysis/coverage-gaps.d.ts +3 -0
- package/dist/src/analysis/coverage-gaps.d.ts.map +1 -1
- package/dist/src/analysis/coverage-gaps.js +40 -1
- package/dist/src/analysis/coverage-gaps.js.map +1 -1
- package/dist/src/analysis/dep-classification.d.ts +2 -0
- package/dist/src/analysis/dep-classification.d.ts.map +1 -1
- package/dist/src/analysis/dep-classification.js +30 -0
- package/dist/src/analysis/dep-classification.js.map +1 -1
- package/dist/src/analysis/dependency-health.d.ts +4 -0
- package/dist/src/analysis/dependency-health.d.ts.map +1 -1
- package/dist/src/analysis/dependency-health.js +28 -0
- package/dist/src/analysis/dependency-health.js.map +1 -1
- package/dist/src/analysis/duplicate-exports.d.ts +9 -5
- package/dist/src/analysis/duplicate-exports.d.ts.map +1 -1
- package/dist/src/analysis/duplicate-exports.js +26 -2
- package/dist/src/analysis/duplicate-exports.js.map +1 -1
- package/dist/src/analysis/feature-flags.d.ts.map +1 -1
- package/dist/src/analysis/feature-flags.js +36 -17
- package/dist/src/analysis/feature-flags.js.map +1 -1
- package/dist/src/analysis/node-similarity.d.ts +19 -0
- package/dist/src/analysis/node-similarity.d.ts.map +1 -1
- package/dist/src/analysis/node-similarity.js +34 -3
- package/dist/src/analysis/node-similarity.js.map +1 -1
- package/dist/src/analysis/private-type-leaks.d.ts +4 -0
- package/dist/src/analysis/private-type-leaks.d.ts.map +1 -1
- package/dist/src/analysis/private-type-leaks.js +43 -2
- package/dist/src/analysis/private-type-leaks.js.map +1 -1
- package/dist/src/analysis/project-state.d.ts +2 -0
- package/dist/src/analysis/project-state.d.ts.map +1 -1
- package/dist/src/analysis/project-state.js +18 -7
- package/dist/src/analysis/project-state.js.map +1 -1
- package/dist/src/analysis/suppressions.d.ts.map +1 -1
- package/dist/src/analysis/suppressions.js +3 -1
- package/dist/src/analysis/suppressions.js.map +1 -1
- package/dist/src/analysis/trace.d.ts +5 -3
- package/dist/src/analysis/trace.d.ts.map +1 -1
- package/dist/src/analysis/trace.js +59 -53
- package/dist/src/analysis/trace.js.map +1 -1
- package/dist/src/analysis/unused-class-members.d.ts.map +1 -1
- package/dist/src/analysis/unused-class-members.js +7 -1
- package/dist/src/analysis/unused-class-members.js.map +1 -1
- package/dist/src/analysis/worker-pool.d.ts +3 -0
- package/dist/src/analysis/worker-pool.d.ts.map +1 -1
- package/dist/src/analysis/worker-pool.js +30 -8
- package/dist/src/analysis/worker-pool.js.map +1 -1
- package/dist/src/cli/augment.d.ts.map +1 -1
- package/dist/src/cli/augment.js +10 -3
- package/dist/src/cli/augment.js.map +1 -1
- package/dist/src/cli/skill-gen.js +3 -0
- package/dist/src/cli/skill-gen.js.map +1 -1
- package/dist/src/export/sarif.js +5 -5
- package/dist/src/export/sarif.js.map +1 -1
- package/dist/src/graph/analyzer.d.ts.map +1 -1
- package/dist/src/graph/analyzer.js +17 -2
- package/dist/src/graph/analyzer.js.map +1 -1
- package/dist/src/graph/author-analytics.d.ts +2 -0
- package/dist/src/graph/author-analytics.d.ts.map +1 -1
- package/dist/src/graph/author-analytics.js +39 -5
- package/dist/src/graph/author-analytics.js.map +1 -1
- package/dist/src/graph/baseline.d.ts +5 -0
- package/dist/src/graph/baseline.d.ts.map +1 -1
- package/dist/src/graph/baseline.js +65 -18
- package/dist/src/graph/baseline.js.map +1 -1
- package/dist/src/graph/clone-detector.d.ts.map +1 -1
- package/dist/src/graph/clone-detector.js +19 -33
- package/dist/src/graph/clone-detector.js.map +1 -1
- package/dist/src/graph/clone-families.d.ts +2 -0
- package/dist/src/graph/clone-families.d.ts.map +1 -1
- package/dist/src/graph/clone-families.js +38 -10
- package/dist/src/graph/clone-families.js.map +1 -1
- package/dist/src/graph/codeowners-extended.d.ts +17 -0
- package/dist/src/graph/codeowners-extended.d.ts.map +1 -1
- package/dist/src/graph/codeowners-extended.js +42 -0
- package/dist/src/graph/codeowners-extended.js.map +1 -1
- package/dist/src/graph/codeowners-gitlab.d.ts +21 -0
- package/dist/src/graph/codeowners-gitlab.d.ts.map +1 -1
- package/dist/src/graph/codeowners-gitlab.js +37 -0
- package/dist/src/graph/codeowners-gitlab.js.map +1 -1
- package/dist/src/graph/codeowners.d.ts +10 -0
- package/dist/src/graph/codeowners.d.ts.map +1 -1
- package/dist/src/graph/codeowners.js +24 -2
- package/dist/src/graph/codeowners.js.map +1 -1
- package/dist/src/graph/complexity.d.ts +10 -0
- package/dist/src/graph/complexity.d.ts.map +1 -1
- package/dist/src/graph/complexity.js +93 -43
- package/dist/src/graph/complexity.js.map +1 -1
- package/dist/src/graph/cross-reference-findings.d.ts.map +1 -1
- package/dist/src/graph/cross-reference-findings.js +19 -2
- package/dist/src/graph/cross-reference-findings.js.map +1 -1
- package/dist/src/graph/cross-reference.d.ts +4 -0
- package/dist/src/graph/cross-reference.d.ts.map +1 -1
- package/dist/src/graph/cross-reference.js +23 -0
- package/dist/src/graph/cross-reference.js.map +1 -1
- package/dist/src/graph/cycle-detection.d.ts +2 -0
- package/dist/src/graph/cycle-detection.d.ts.map +1 -1
- package/dist/src/graph/cycle-detection.js +26 -3
- package/dist/src/graph/cycle-detection.js.map +1 -1
- package/dist/src/graph/cycles.d.ts +11 -3
- package/dist/src/graph/cycles.d.ts.map +1 -1
- package/dist/src/graph/cycles.js +121 -83
- package/dist/src/graph/cycles.js.map +1 -1
- package/dist/src/graph/dead-code.d.ts +23 -0
- package/dist/src/graph/dead-code.d.ts.map +1 -1
- package/dist/src/graph/dead-code.js +53 -13
- package/dist/src/graph/dead-code.js.map +1 -1
- package/dist/src/graph/dependency-closure.d.ts.map +1 -1
- package/dist/src/graph/dependency-closure.js +20 -4
- package/dist/src/graph/dependency-closure.js.map +1 -1
- package/dist/src/graph/dfs.d.ts +14 -0
- package/dist/src/graph/dfs.d.ts.map +1 -1
- package/dist/src/graph/dfs.js +61 -0
- package/dist/src/graph/dfs.js.map +1 -1
- package/dist/src/graph/duplication-stats.d.ts.map +1 -1
- package/dist/src/graph/duplication-stats.js +19 -3
- package/dist/src/graph/duplication-stats.js.map +1 -1
- package/dist/src/graph/edge-filter.d.ts +2 -0
- package/dist/src/graph/edge-filter.d.ts.map +1 -1
- package/dist/src/graph/edge-filter.js +26 -12
- package/dist/src/graph/edge-filter.js.map +1 -1
- package/dist/src/graph/health-score.d.ts +8 -0
- package/dist/src/graph/health-score.d.ts.map +1 -1
- package/dist/src/graph/health-score.js +48 -17
- package/dist/src/graph/health-score.js.map +1 -1
- package/dist/src/graph/hotspots.d.ts +7 -0
- package/dist/src/graph/hotspots.d.ts.map +1 -1
- package/dist/src/graph/hotspots.js +50 -5
- package/dist/src/graph/hotspots.js.map +1 -1
- package/dist/src/graph/import-chain.d.ts +17 -1
- package/dist/src/graph/import-chain.d.ts.map +1 -1
- package/dist/src/graph/import-chain.js +68 -19
- package/dist/src/graph/import-chain.js.map +1 -1
- package/dist/src/graph/loader.d.ts.map +1 -1
- package/dist/src/graph/loader.js +9 -10
- package/dist/src/graph/loader.js.map +1 -1
- package/dist/src/graph/maintainability.d.ts +8 -0
- package/dist/src/graph/maintainability.d.ts.map +1 -1
- package/dist/src/graph/maintainability.js +65 -10
- package/dist/src/graph/maintainability.js.map +1 -1
- package/dist/src/graph/mirrored-dirs.d.ts +4 -0
- package/dist/src/graph/mirrored-dirs.d.ts.map +1 -1
- package/dist/src/graph/mirrored-dirs.js +48 -13
- package/dist/src/graph/mirrored-dirs.js.map +1 -1
- package/dist/src/graph/narrowing.d.ts +15 -0
- package/dist/src/graph/narrowing.d.ts.map +1 -1
- package/dist/src/graph/narrowing.js +33 -0
- package/dist/src/graph/narrowing.js.map +1 -1
- package/dist/src/graph/node-search.d.ts +3 -0
- package/dist/src/graph/node-search.d.ts.map +1 -1
- package/dist/src/graph/node-search.js +37 -4
- package/dist/src/graph/node-search.js.map +1 -1
- package/dist/src/graph/normalize-id.d.ts +4 -0
- package/dist/src/graph/normalize-id.d.ts.map +1 -1
- package/dist/src/graph/normalize-id.js +25 -2
- package/dist/src/graph/normalize-id.js.map +1 -1
- package/dist/src/graph/pagerank.d.ts +7 -0
- package/dist/src/graph/pagerank.d.ts.map +1 -1
- package/dist/src/graph/pagerank.js +49 -2
- package/dist/src/graph/pagerank.js.map +1 -1
- package/dist/src/graph/prune.d.ts +31 -0
- package/dist/src/graph/prune.d.ts.map +1 -1
- package/dist/src/graph/prune.js +65 -0
- package/dist/src/graph/prune.js.map +1 -1
- package/dist/src/graph/regex-search.d.ts +10 -2
- package/dist/src/graph/regex-search.d.ts.map +1 -1
- package/dist/src/graph/regex-search.js +33 -4
- package/dist/src/graph/regex-search.js.map +1 -1
- package/dist/src/graph/regression.d.ts +5 -0
- package/dist/src/graph/regression.d.ts.map +1 -1
- package/dist/src/graph/regression.js +45 -23
- package/dist/src/graph/regression.js.map +1 -1
- package/dist/src/graph/ripple-impact.d.ts +27 -0
- package/dist/src/graph/ripple-impact.d.ts.map +1 -1
- package/dist/src/graph/ripple-impact.js +55 -7
- package/dist/src/graph/ripple-impact.js.map +1 -1
- package/dist/src/graph/risk-profile.d.ts +7 -0
- package/dist/src/graph/risk-profile.d.ts.map +1 -1
- package/dist/src/graph/risk-profile.js +82 -48
- package/dist/src/graph/risk-profile.js.map +1 -1
- package/dist/src/graph/shingle-filter.d.ts.map +1 -1
- package/dist/src/graph/shingle-filter.js +25 -26
- package/dist/src/graph/shingle-filter.js.map +1 -1
- package/dist/src/graph/statistics.d.ts +19 -0
- package/dist/src/graph/statistics.d.ts.map +1 -1
- package/dist/src/graph/statistics.js +53 -40
- package/dist/src/graph/statistics.js.map +1 -1
- package/dist/src/graph/stats.d.ts +2 -0
- package/dist/src/graph/stats.d.ts.map +1 -1
- package/dist/src/graph/stats.js +54 -8
- package/dist/src/graph/stats.js.map +1 -1
- package/dist/src/graph/subgraph.d.ts +5 -0
- package/dist/src/graph/subgraph.d.ts.map +1 -1
- package/dist/src/graph/subgraph.js +73 -9
- package/dist/src/graph/subgraph.js.map +1 -1
- package/dist/src/graph/topo-sort.d.ts +15 -0
- package/dist/src/graph/topo-sort.d.ts.map +1 -1
- package/dist/src/graph/topo-sort.js +83 -10
- package/dist/src/graph/topo-sort.js.map +1 -1
- package/dist/src/graph/wcc.d.ts +29 -0
- package/dist/src/graph/wcc.d.ts.map +1 -1
- package/dist/src/graph/wcc.js +122 -39
- package/dist/src/graph/wcc.js.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp-tools/api-impact.d.ts.map +1 -1
- package/dist/src/mcp-tools/api-impact.js +13 -6
- package/dist/src/mcp-tools/api-impact.js.map +1 -1
- package/dist/src/mcp-tools/context.d.ts.map +1 -1
- package/dist/src/mcp-tools/context.js +19 -29
- package/dist/src/mcp-tools/context.js.map +1 -1
- package/dist/src/mcp-tools/cypher.d.ts +11 -0
- package/dist/src/mcp-tools/cypher.d.ts.map +1 -1
- package/dist/src/mcp-tools/cypher.js +13 -1
- package/dist/src/mcp-tools/cypher.js.map +1 -1
- package/dist/src/mcp-tools/detect-changes.d.ts.map +1 -1
- package/dist/src/mcp-tools/detect-changes.js +35 -20
- package/dist/src/mcp-tools/detect-changes.js.map +1 -1
- package/dist/src/mcp-tools/explain.d.ts.map +1 -1
- package/dist/src/mcp-tools/explain.js +4 -1
- package/dist/src/mcp-tools/explain.js.map +1 -1
- package/dist/src/mcp-tools/graph-query.d.ts +2 -0
- package/dist/src/mcp-tools/graph-query.d.ts.map +1 -1
- package/dist/src/mcp-tools/graph-query.js +20 -3
- package/dist/src/mcp-tools/graph-query.js.map +1 -1
- package/dist/src/mcp-tools/group-list.d.ts +1 -0
- package/dist/src/mcp-tools/group-list.d.ts.map +1 -1
- package/dist/src/mcp-tools/group-list.js +7 -9
- package/dist/src/mcp-tools/group-list.js.map +1 -1
- package/dist/src/mcp-tools/impact.d.ts.map +1 -1
- package/dist/src/mcp-tools/impact.js +20 -59
- package/dist/src/mcp-tools/impact.js.map +1 -1
- package/dist/src/mcp-tools/neighbors.d.ts.map +1 -1
- package/dist/src/mcp-tools/neighbors.js +24 -33
- package/dist/src/mcp-tools/neighbors.js.map +1 -1
- package/dist/src/mcp-tools/query.d.ts +2 -0
- package/dist/src/mcp-tools/query.d.ts.map +1 -1
- package/dist/src/mcp-tools/query.js +1 -0
- package/dist/src/mcp-tools/query.js.map +1 -1
- package/dist/src/mcp-tools/rename.d.ts.map +1 -1
- package/dist/src/mcp-tools/rename.js +12 -7
- package/dist/src/mcp-tools/rename.js.map +1 -1
- package/dist/src/mcp-tools/route-map.d.ts.map +1 -1
- package/dist/src/mcp-tools/route-map.js +19 -23
- package/dist/src/mcp-tools/route-map.js.map +1 -1
- package/dist/src/mcp-tools/shape-check.d.ts.map +1 -1
- package/dist/src/mcp-tools/shape-check.js +17 -13
- package/dist/src/mcp-tools/shape-check.js.map +1 -1
- package/dist/src/parsers/loader.js +6 -5
- package/dist/src/parsers/loader.js.map +1 -1
- package/dist/src/pipeline/cluster-only.d.ts.map +1 -1
- package/dist/src/pipeline/cluster-only.js +8 -4
- package/dist/src/pipeline/cluster-only.js.map +1 -1
- package/dist/src/pipeline/orchestrator.d.ts +2 -0
- package/dist/src/pipeline/orchestrator.d.ts.map +1 -1
- package/dist/src/pipeline/orchestrator.js +19 -0
- package/dist/src/pipeline/orchestrator.js.map +1 -1
- package/dist/src/pipeline/phases/boundary.d.ts +2 -0
- package/dist/src/pipeline/phases/boundary.d.ts.map +1 -1
- package/dist/src/pipeline/phases/boundary.js +31 -2
- package/dist/src/pipeline/phases/boundary.js.map +1 -1
- package/dist/src/pipeline/phases/communities.d.ts +14 -0
- package/dist/src/pipeline/phases/communities.d.ts.map +1 -1
- package/dist/src/pipeline/phases/communities.js +58 -5
- package/dist/src/pipeline/phases/communities.js.map +1 -1
- package/dist/src/pipeline/phases/contextual-proximity.d.ts.map +1 -1
- package/dist/src/pipeline/phases/contextual-proximity.js +21 -14
- package/dist/src/pipeline/phases/contextual-proximity.js.map +1 -1
- package/dist/src/pipeline/phases/cross-file.d.ts.map +1 -1
- package/dist/src/pipeline/phases/cross-file.js +35 -14
- package/dist/src/pipeline/phases/cross-file.js.map +1 -1
- package/dist/src/pipeline/phases/field-access.d.ts.map +1 -1
- package/dist/src/pipeline/phases/field-access.js +9 -4
- package/dist/src/pipeline/phases/field-access.js.map +1 -1
- package/dist/src/pipeline/phases/god-nodes.d.ts +4 -0
- package/dist/src/pipeline/phases/god-nodes.d.ts.map +1 -1
- package/dist/src/pipeline/phases/god-nodes.js +43 -9
- package/dist/src/pipeline/phases/god-nodes.js.map +1 -1
- package/dist/src/pipeline/phases/import-resolver.d.ts +11 -0
- package/dist/src/pipeline/phases/import-resolver.d.ts.map +1 -1
- package/dist/src/pipeline/phases/import-resolver.js +34 -7
- package/dist/src/pipeline/phases/import-resolver.js.map +1 -1
- package/dist/src/pipeline/phases/leiden.d.ts.map +1 -1
- package/dist/src/pipeline/phases/leiden.js +27 -19
- package/dist/src/pipeline/phases/leiden.js.map +1 -1
- package/dist/src/pipeline/phases/markdown.d.ts.map +1 -1
- package/dist/src/pipeline/phases/markdown.js +10 -5
- package/dist/src/pipeline/phases/markdown.js.map +1 -1
- package/dist/src/pipeline/phases/pdf-parse.d.ts.map +1 -1
- package/dist/src/pipeline/phases/pdf-parse.js +18 -3
- package/dist/src/pipeline/phases/pdf-parse.js.map +1 -1
- package/dist/src/pipeline/phases/processes.d.ts.map +1 -1
- package/dist/src/pipeline/phases/processes.js +26 -9
- package/dist/src/pipeline/phases/processes.js.map +1 -1
- package/dist/src/pipeline/phases/re-export-propagation.d.ts.map +1 -1
- package/dist/src/pipeline/phases/re-export-propagation.js +33 -14
- package/dist/src/pipeline/phases/re-export-propagation.js.map +1 -1
- package/dist/src/pipeline/phases/reachability.d.ts.map +1 -1
- package/dist/src/pipeline/phases/reachability.js +42 -26
- package/dist/src/pipeline/phases/reachability.js.map +1 -1
- package/dist/src/pipeline/phases/routes.d.ts.map +1 -1
- package/dist/src/pipeline/phases/routes.js +30 -21
- package/dist/src/pipeline/phases/routes.js.map +1 -1
- package/dist/src/pipeline/phases/scope-resolution.d.ts.map +1 -1
- package/dist/src/pipeline/phases/scope-resolution.js +93 -63
- package/dist/src/pipeline/phases/scope-resolution.js.map +1 -1
- package/dist/src/pipeline/runner.d.ts +4 -0
- package/dist/src/pipeline/runner.d.ts.map +1 -1
- package/dist/src/pipeline/runner.js +30 -11
- package/dist/src/pipeline/runner.js.map +1 -1
- package/dist/src/query/cypher-parser.d.ts +20 -0
- package/dist/src/query/cypher-parser.d.ts.map +1 -1
- package/dist/src/query/cypher-parser.js +73 -0
- package/dist/src/query/cypher-parser.js.map +1 -1
- package/dist/src/search/embed-batch.d.ts.map +1 -1
- package/dist/src/search/embed-batch.js +4 -1
- package/dist/src/search/embed-batch.js.map +1 -1
- package/dist/src/search/hybrid-query.d.ts +4 -0
- package/dist/src/search/hybrid-query.d.ts.map +1 -1
- package/dist/src/search/hybrid-query.js +5 -1
- package/dist/src/search/hybrid-query.js.map +1 -1
- package/dist/src/staleness/git-staleness.js +3 -3
- package/dist/src/staleness/git-staleness.js.map +1 -1
- package/dist/src/storage/db.d.ts.map +1 -1
- package/dist/src/storage/db.js +12 -0
- package/dist/src/storage/db.js.map +1 -1
- package/dist/src/storage/edge-store.d.ts +2 -0
- package/dist/src/storage/edge-store.d.ts.map +1 -1
- package/dist/src/storage/edge-store.js +26 -1
- package/dist/src/storage/edge-store.js.map +1 -1
- package/dist/src/storage/embedding-store.d.ts +16 -0
- package/dist/src/storage/embedding-store.d.ts.map +1 -1
- package/dist/src/storage/embedding-store.js +26 -2
- package/dist/src/storage/embedding-store.js.map +1 -1
- package/dist/src/storage/file-cache.d.ts +5 -0
- package/dist/src/storage/file-cache.d.ts.map +1 -1
- package/dist/src/storage/file-cache.js +35 -9
- package/dist/src/storage/file-cache.js.map +1 -1
- package/dist/src/storage/fts-store.d.ts +4 -0
- package/dist/src/storage/fts-store.d.ts.map +1 -1
- package/dist/src/storage/fts-store.js +8 -3
- package/dist/src/storage/fts-store.js.map +1 -1
- package/dist/src/storage/node-store.d.ts +2 -0
- package/dist/src/storage/node-store.d.ts.map +1 -1
- package/dist/src/storage/node-store.js +28 -1
- package/dist/src/storage/node-store.js.map +1 -1
- package/dist/src/wiki/wiki-generator.d.ts.map +1 -1
- package/dist/src/wiki/wiki-generator.js +5 -1
- package/dist/src/wiki/wiki-generator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/__tests__/pipeline/runner.parallel.test.ts +2 -2
- package/src/analysis/churn-cache.ts +18 -7
- package/src/analysis/churn-trend.ts +35 -6
- package/src/analysis/cluster-quality.ts +20 -11
- package/src/analysis/coverage-gaps.ts +44 -1
- package/src/analysis/dep-classification.ts +34 -0
- package/src/analysis/dependency-health.ts +25 -0
- package/src/analysis/duplicate-exports.ts +40 -4
- package/src/analysis/feature-flags.ts +37 -17
- package/src/analysis/node-similarity.ts +45 -4
- package/src/analysis/private-type-leaks.ts +49 -2
- package/src/analysis/project-state.ts +19 -9
- package/src/analysis/suppressions.ts +4 -1
- package/src/analysis/trace.ts +73 -54
- package/src/analysis/unused-class-members.ts +8 -1
- package/src/analysis/worker-pool.ts +40 -8
- package/src/cli/augment.ts +10 -3
- package/src/cli/skill-gen.ts +3 -0
- package/src/export/sarif.ts +5 -5
- package/src/graph/analyzer.ts +26 -2
- package/src/graph/author-analytics.ts +45 -5
- package/src/graph/baseline.ts +78 -24
- package/src/graph/clone-detector.ts +22 -36
- package/src/graph/clone-families.ts +34 -10
- package/src/graph/codeowners-extended.ts +54 -0
- package/src/graph/codeowners-gitlab.ts +46 -0
- package/src/graph/codeowners.ts +33 -2
- package/src/graph/complexity.ts +102 -47
- package/src/graph/cross-reference-findings.ts +23 -2
- package/src/graph/cross-reference.ts +26 -0
- package/src/graph/cycle-detection.ts +22 -3
- package/src/graph/cycles.ts +155 -96
- package/src/graph/dead-code.ts +76 -17
- package/src/graph/dependency-closure.ts +24 -7
- package/src/graph/dfs.ts +78 -0
- package/src/graph/duplication-stats.ts +17 -6
- package/src/graph/edge-filter.ts +26 -12
- package/src/graph/health-score.ts +47 -17
- package/src/graph/hotspots.ts +57 -8
- package/src/graph/import-chain.ts +89 -19
- package/src/graph/loader.ts +10 -7
- package/src/graph/maintainability.ts +72 -22
- package/src/graph/mirrored-dirs.ts +45 -14
- package/src/graph/narrowing.ts +44 -0
- package/src/graph/node-search.ts +50 -4
- package/src/graph/normalize-id.ts +26 -2
- package/src/graph/pagerank.ts +70 -2
- package/src/graph/prune.ts +76 -0
- package/src/graph/regex-search.ts +38 -4
- package/src/graph/regression.ts +48 -23
- package/src/graph/ripple-impact.ts +71 -11
- package/src/graph/risk-profile.ts +98 -53
- package/src/graph/shingle-filter.ts +33 -27
- package/src/graph/statistics.ts +73 -45
- package/src/graph/stats.ts +50 -16
- package/src/graph/subgraph.ts +97 -25
- package/src/graph/topo-sort.ts +101 -16
- package/src/graph/wcc.ts +146 -37
- package/src/index.ts +1 -1
- package/src/mcp-tools/api-impact.ts +13 -6
- package/src/mcp-tools/context.ts +31 -40
- package/src/mcp-tools/cypher.ts +14 -1
- package/src/mcp-tools/detect-changes.ts +38 -23
- package/src/mcp-tools/explain.ts +4 -1
- package/src/mcp-tools/graph-query.ts +24 -3
- package/src/mcp-tools/group-list.ts +9 -11
- package/src/mcp-tools/impact.ts +26 -66
- package/src/mcp-tools/neighbors.ts +34 -39
- package/src/mcp-tools/query.ts +3 -0
- package/src/mcp-tools/rename.ts +9 -8
- package/src/mcp-tools/route-map.ts +21 -23
- package/src/mcp-tools/shape-check.ts +18 -14
- package/src/parsers/loader.ts +5 -5
- package/src/pipeline/cluster-only.ts +8 -4
- package/src/pipeline/orchestrator.ts +22 -0
- package/src/pipeline/phases/boundary.ts +40 -2
- package/src/pipeline/phases/communities.ts +66 -5
- package/src/pipeline/phases/contextual-proximity.ts +15 -14
- package/src/pipeline/phases/cross-file.ts +35 -14
- package/src/pipeline/phases/field-access.ts +11 -4
- package/src/pipeline/phases/god-nodes.ts +47 -10
- package/src/pipeline/phases/import-resolver.ts +37 -5
- package/src/pipeline/phases/leiden.ts +25 -18
- package/src/pipeline/phases/markdown.ts +12 -7
- package/src/pipeline/phases/pdf-parse.ts +19 -2
- package/src/pipeline/phases/processes.ts +27 -15
- package/src/pipeline/phases/re-export-propagation.ts +40 -18
- package/src/pipeline/phases/reachability.ts +39 -24
- package/src/pipeline/phases/routes.ts +32 -21
- package/src/pipeline/phases/scope-resolution.ts +110 -71
- package/src/pipeline/runner.ts +28 -11
- package/src/query/cypher-parser.ts +83 -0
- package/src/search/embed-batch.ts +4 -1
- package/src/search/hybrid-query.ts +11 -1
- package/src/staleness/git-staleness.ts +3 -3
- package/src/storage/db.ts +11 -0
- package/src/storage/edge-store.ts +34 -1
- package/src/storage/embedding-store.ts +38 -6
- package/src/storage/file-cache.ts +35 -21
- package/src/storage/fts-store.ts +12 -3
- package/src/storage/node-store.ts +39 -1
- package/src/wiki/wiki-generator.ts +5 -1
- package/src/coverage/runtime.ts +0 -249
|
@@ -21,14 +21,15 @@ export function regexSearchNodes(
|
|
|
21
21
|
db: MonographDb,
|
|
22
22
|
pattern: RegExp | string,
|
|
23
23
|
fields: Array<'name' | 'filePath' | 'language' | 'label'> = ['name', 'filePath'],
|
|
24
|
+
limit = 200,
|
|
24
25
|
): RegexNodeMatch[] {
|
|
25
26
|
const re = typeof pattern === 'string' ? new RegExp(pattern) : pattern;
|
|
26
27
|
|
|
27
28
|
const rows = db.prepare(
|
|
28
29
|
`SELECT id, label, name, norm_label, file_path, start_line, end_line,
|
|
29
30
|
community_id, is_exported, language, properties
|
|
30
|
-
FROM nodes
|
|
31
|
-
).all() as {
|
|
31
|
+
FROM nodes LIMIT ?`,
|
|
32
|
+
).all(limit) as {
|
|
32
33
|
id: string;
|
|
33
34
|
label: string;
|
|
34
35
|
name: string;
|
|
@@ -96,13 +97,14 @@ export function regexSearchEdges(
|
|
|
96
97
|
db: MonographDb,
|
|
97
98
|
pattern: RegExp | string,
|
|
98
99
|
fields: Array<'relation' | 'confidence' | 'reason'> = ['relation', 'reason'],
|
|
100
|
+
limit = 200,
|
|
99
101
|
): RegexEdgeMatch[] {
|
|
100
102
|
const re = typeof pattern === 'string' ? new RegExp(pattern) : pattern;
|
|
101
103
|
|
|
102
104
|
const rows = db.prepare(
|
|
103
105
|
`SELECT id, source_id, target_id, relation, confidence, confidence_score, reason
|
|
104
|
-
FROM edges
|
|
105
|
-
).all() as {
|
|
106
|
+
FROM edges LIMIT ?`,
|
|
107
|
+
).all(limit) as {
|
|
106
108
|
id: string;
|
|
107
109
|
source_id: string;
|
|
108
110
|
target_id: string;
|
|
@@ -193,3 +195,35 @@ export function regexSearchEdgesInMemory(
|
|
|
193
195
|
|
|
194
196
|
return results;
|
|
195
197
|
}
|
|
198
|
+
|
|
199
|
+
// ── LLM formatters ─────────────────────────────────────────────────────────────
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Format node regex match results as structured text for LLM consumption.
|
|
203
|
+
*/
|
|
204
|
+
export function formatRegexNodeMatches(matches: RegexNodeMatch[], pattern: string): string {
|
|
205
|
+
if (matches.length === 0) return `No nodes matching /${pattern}/.`;
|
|
206
|
+
const lines: string[] = [`${matches.length} node(s) matching /${pattern}/:`];
|
|
207
|
+
for (const m of matches) {
|
|
208
|
+
const loc = m.node.filePath
|
|
209
|
+
? ` ${m.node.filePath}${m.node.startLine != null ? `:${m.node.startLine}` : ''}`
|
|
210
|
+
: '';
|
|
211
|
+
lines.push(` [${m.field}] ${m.node.label} ${m.node.name}${loc}`);
|
|
212
|
+
}
|
|
213
|
+
return lines.join('\n');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Format edge regex match results as structured text for LLM consumption.
|
|
218
|
+
*/
|
|
219
|
+
export function formatRegexEdgeMatches(matches: RegexEdgeMatch[], pattern: string): string {
|
|
220
|
+
if (matches.length === 0) return `No edges matching /${pattern}/.`;
|
|
221
|
+
const lines: string[] = [`${matches.length} edge(s) matching /${pattern}/:`];
|
|
222
|
+
for (const m of matches) {
|
|
223
|
+
lines.push(
|
|
224
|
+
` [${m.field}] ${m.edge.sourceId} -[${m.edge.relation}]-> ${m.edge.targetId}` +
|
|
225
|
+
(m.edge.reason ? ` // ${m.edge.reason}` : ''),
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
return lines.join('\n');
|
|
229
|
+
}
|
package/src/graph/regression.ts
CHANGED
|
@@ -86,6 +86,18 @@ const FINDING_TYPE_TO_METRIC: Record<string, string> = {
|
|
|
86
86
|
ambiguous_edge: 'ambiguousEdgeCount',
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
/** Canonical metric names — defined once to avoid duplicating the same literal Set/Object. */
|
|
90
|
+
const METRIC_NAMES = Object.values(FINDING_TYPE_TO_METRIC);
|
|
91
|
+
const METRIC_NAME_SET = new Set(METRIC_NAMES);
|
|
92
|
+
|
|
93
|
+
/** Module-level cache for parsed Tolerance objects — avoids re-parsing identical specs. */
|
|
94
|
+
const toleranceCache = new Map<string, Tolerance>();
|
|
95
|
+
function parseTolerance(spec: string): Tolerance {
|
|
96
|
+
let t = toleranceCache.get(spec);
|
|
97
|
+
if (!t) { t = Tolerance.parse(spec); toleranceCache.set(spec, t); }
|
|
98
|
+
return t;
|
|
99
|
+
}
|
|
100
|
+
|
|
89
101
|
// ── checkRegression ───────────────────────────────────────────────────────────
|
|
90
102
|
|
|
91
103
|
/**
|
|
@@ -104,51 +116,39 @@ export function checkRegression(
|
|
|
104
116
|
): RegressionOutcome {
|
|
105
117
|
const baseline: BaselineData | null = loadBaseline(baselinePath);
|
|
106
118
|
|
|
107
|
-
// Compute current counts from DB
|
|
119
|
+
// Compute current counts from DB using shared METRIC_NAMES init
|
|
108
120
|
const currentFindings = extractFindingsFromDb(db, '');
|
|
109
|
-
const currentCounts: Record<string, number> =
|
|
110
|
-
godNodeCount: 0,
|
|
111
|
-
surpriseCount: 0,
|
|
112
|
-
bridgeNodeCount: 0,
|
|
113
|
-
unreachableExportCount: 0,
|
|
114
|
-
ambiguousEdgeCount: 0,
|
|
115
|
-
};
|
|
121
|
+
const currentCounts: Record<string, number> = Object.fromEntries(METRIC_NAMES.map(m => [m, 0]));
|
|
116
122
|
for (const f of currentFindings) {
|
|
117
123
|
const metricName = FINDING_TYPE_TO_METRIC[f.type];
|
|
118
|
-
if (metricName && metricName
|
|
124
|
+
if (metricName && METRIC_NAME_SET.has(metricName)) {
|
|
119
125
|
currentCounts[metricName]++;
|
|
120
126
|
}
|
|
121
127
|
}
|
|
122
128
|
|
|
123
|
-
// Compute baseline counts
|
|
124
|
-
const baselineCounts: Record<string, number> =
|
|
125
|
-
godNodeCount: 0,
|
|
126
|
-
surpriseCount: 0,
|
|
127
|
-
bridgeNodeCount: 0,
|
|
128
|
-
unreachableExportCount: 0,
|
|
129
|
-
ambiguousEdgeCount: 0,
|
|
130
|
-
};
|
|
129
|
+
// Compute baseline counts using shared METRIC_NAMES init
|
|
130
|
+
const baselineCounts: Record<string, number> = Object.fromEntries(METRIC_NAMES.map(m => [m, 0]));
|
|
131
131
|
if (baseline) {
|
|
132
132
|
for (const f of baseline.findings) {
|
|
133
133
|
const metricName = FINDING_TYPE_TO_METRIC[f.type];
|
|
134
|
-
if (metricName && metricName
|
|
134
|
+
if (metricName && METRIC_NAME_SET.has(metricName)) {
|
|
135
135
|
baselineCounts[metricName]++;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
// Default tolerance
|
|
141
|
-
const defaultTolerance =
|
|
140
|
+
// Default tolerance — use cached parse to avoid rebuilding on repeated calls with same spec
|
|
141
|
+
const defaultTolerance = parseTolerance(toleranceSpec);
|
|
142
142
|
|
|
143
|
-
// Check each metric
|
|
143
|
+
// Check each metric — per-metric tolerances also cached
|
|
144
144
|
const checkedMetrics: RegressionMetric[] = [];
|
|
145
|
-
for (const metric of
|
|
145
|
+
for (const metric of METRIC_NAMES) {
|
|
146
146
|
const baselineVal = baselineCounts[metric] ?? 0;
|
|
147
147
|
const currentVal = currentCounts[metric] ?? 0;
|
|
148
148
|
const delta = currentVal - baselineVal;
|
|
149
149
|
|
|
150
150
|
const metricSpec = metricTolerances?.[metric];
|
|
151
|
-
const tol = metricSpec ?
|
|
151
|
+
const tol = metricSpec ? parseTolerance(metricSpec) : defaultTolerance;
|
|
152
152
|
const tolStr = tol.toString();
|
|
153
153
|
const violated = tol.exceeded(baselineVal, currentVal);
|
|
154
154
|
|
|
@@ -172,3 +172,28 @@ export function checkRegression(
|
|
|
172
172
|
|
|
173
173
|
return { passed, violations, checkedMetrics, summary };
|
|
174
174
|
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Format a RegressionOutcome as structured text for LLM consumption.
|
|
178
|
+
* Shows pass/fail status, per-metric results, and actionable violation details.
|
|
179
|
+
*/
|
|
180
|
+
export function formatRegressionOutcome(outcome: RegressionOutcome): string {
|
|
181
|
+
const lines: string[] = [outcome.summary];
|
|
182
|
+
|
|
183
|
+
lines.push('\nMetrics:');
|
|
184
|
+
for (const m of outcome.checkedMetrics) {
|
|
185
|
+
const sign = m.delta > 0 ? `+${m.delta}` : String(m.delta);
|
|
186
|
+
const status = m.violated ? 'VIOLATED' : 'ok';
|
|
187
|
+
lines.push(` ${m.metric}: baseline=${m.baseline} current=${m.current} delta=${sign} tolerance=${m.tolerance} [${status}]`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (outcome.violations.length > 0) {
|
|
191
|
+
lines.push('\nViolations requiring attention:');
|
|
192
|
+
for (const v of outcome.violations) {
|
|
193
|
+
const sign = v.delta > 0 ? `+${v.delta}` : String(v.delta);
|
|
194
|
+
lines.push(` ${v.metric} exceeded tolerance ${v.tolerance} (delta ${sign}): investigate new ${v.metric.replace(/Count$/, '')} introductions`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return lines.join('\n');
|
|
199
|
+
}
|
|
@@ -22,26 +22,38 @@ export interface RippleResult {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Build a directed outgoing adjacency map from an edge list.
|
|
26
|
+
*
|
|
27
|
+
* Callers that run rippleImpact for multiple starting nodes on the same edge set
|
|
28
|
+
* should build once and pass the map directly to `rippleImpactFromMap`.
|
|
29
|
+
*/
|
|
30
|
+
export function buildOutgoingMap(edges: RippleEdge[]): Map<string, string[]> {
|
|
31
|
+
const outgoing = new Map<string, string[]>();
|
|
32
|
+
for (const { sourceId, targetId } of edges) {
|
|
33
|
+
if (!outgoing.has(sourceId)) outgoing.set(sourceId, []);
|
|
34
|
+
outgoing.get(sourceId)!.push(targetId);
|
|
35
|
+
}
|
|
36
|
+
return outgoing;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Compute the ripple impact of changing `startNodeId` using a pre-built
|
|
41
|
+
* outgoing adjacency map.
|
|
42
|
+
*
|
|
43
|
+
* Use this variant when querying multiple start nodes on the same edge set —
|
|
44
|
+
* build the map once with `buildOutgoingMap` and reuse it across calls.
|
|
26
45
|
*
|
|
27
46
|
* @param startNodeId The node whose change we are propagating.
|
|
28
|
-
* @param
|
|
47
|
+
* @param outgoing Pre-built directed adjacency map (source → targets).
|
|
29
48
|
* @param maxDepth Maximum BFS depth (default 3).
|
|
30
49
|
* @param decayFactor Weight multiplier per depth level (default 0.5).
|
|
31
50
|
*/
|
|
32
|
-
export function
|
|
51
|
+
export function rippleImpactFromMap(
|
|
33
52
|
startNodeId: string,
|
|
34
|
-
|
|
53
|
+
outgoing: Map<string, string[]>,
|
|
35
54
|
maxDepth = 3,
|
|
36
55
|
decayFactor = 0.5,
|
|
37
56
|
): RippleResult {
|
|
38
|
-
// Build directed adjacency (source → targets)
|
|
39
|
-
const outgoing = new Map<string, string[]>();
|
|
40
|
-
for (const { sourceId, targetId } of edges) {
|
|
41
|
-
if (!outgoing.has(sourceId)) outgoing.set(sourceId, []);
|
|
42
|
-
outgoing.get(sourceId)!.push(targetId);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
57
|
if (!outgoing.has(startNodeId)) {
|
|
46
58
|
return { byDepth: {}, totalScore: 0 };
|
|
47
59
|
}
|
|
@@ -69,3 +81,51 @@ export function rippleImpact(
|
|
|
69
81
|
|
|
70
82
|
return { byDepth, totalScore };
|
|
71
83
|
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Compute the ripple impact of changing `startNodeId`.
|
|
87
|
+
*
|
|
88
|
+
* Builds the adjacency map from `edges` on each call. For repeated queries
|
|
89
|
+
* over the same edge set, prefer `buildOutgoingMap` + `rippleImpactFromMap`.
|
|
90
|
+
*
|
|
91
|
+
* @param startNodeId The node whose change we are propagating.
|
|
92
|
+
* @param edges Directed edges in the graph.
|
|
93
|
+
* @param maxDepth Maximum BFS depth (default 3).
|
|
94
|
+
* @param decayFactor Weight multiplier per depth level (default 0.5).
|
|
95
|
+
*/
|
|
96
|
+
export function rippleImpact(
|
|
97
|
+
startNodeId: string,
|
|
98
|
+
edges: RippleEdge[],
|
|
99
|
+
maxDepth = 3,
|
|
100
|
+
decayFactor = 0.5,
|
|
101
|
+
): RippleResult {
|
|
102
|
+
return rippleImpactFromMap(startNodeId, buildOutgoingMap(edges), maxDepth, decayFactor);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Format ripple impact results as structured text for LLM consumption.
|
|
107
|
+
*/
|
|
108
|
+
export function formatRippleImpact(
|
|
109
|
+
startNodeId: string,
|
|
110
|
+
result: RippleResult,
|
|
111
|
+
nodeLabels?: Map<string, string>,
|
|
112
|
+
): string {
|
|
113
|
+
const depths = Object.keys(result.byDepth).map(Number).sort((a, b) => a - b);
|
|
114
|
+
if (depths.length === 0) {
|
|
115
|
+
return `No ripple impact found for: ${startNodeId} (isolated or leaf node)`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const lines: string[] = [
|
|
119
|
+
`Ripple impact of changing: ${startNodeId}`,
|
|
120
|
+
` Total score: ${result.totalScore.toFixed(3)} (weighted cascade depth)`,
|
|
121
|
+
];
|
|
122
|
+
for (const depth of depths) {
|
|
123
|
+
const nodes = result.byDepth[depth]!;
|
|
124
|
+
lines.push(` Depth ${depth} (${nodes.length} node${nodes.length === 1 ? '' : 's'}):`);
|
|
125
|
+
for (const id of nodes) {
|
|
126
|
+
const label = nodeLabels?.get(id);
|
|
127
|
+
lines.push(` - ${id}${label ? ` [${label}]` : ''}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return lines.join('\n');
|
|
131
|
+
}
|
|
@@ -50,75 +50,78 @@ function percentile(sorted: number[], p: number): number {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export function computeRiskProfile(db: MonographDb): RiskProfileReport {
|
|
53
|
+
// Push paramCount extraction to SQL with json_extract to avoid per-row JSON.parse
|
|
53
54
|
const rows = db.prepare(`
|
|
54
|
-
SELECT
|
|
55
|
+
SELECT
|
|
56
|
+
start_line,
|
|
57
|
+
end_line,
|
|
58
|
+
CAST(json_extract(properties, '$.paramCount') AS INTEGER) AS param_count
|
|
55
59
|
FROM nodes
|
|
56
60
|
WHERE label IN ('Function', 'Method')
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
AND start_line IS NOT NULL
|
|
62
|
+
AND end_line IS NOT NULL
|
|
63
|
+
`).all() as { start_line: number; end_line: number; param_count: number | null }[];
|
|
64
|
+
|
|
65
|
+
// ── Single-pass: compute LOC, assign to bins, accumulate risk summary ─────
|
|
66
|
+
const locBinCounts = new Array<number>(LOC_BINS.length).fill(0);
|
|
67
|
+
const paramBinCounts = new Array<number>(PARAM_BINS.length).fill(0);
|
|
68
|
+
const sortedLocs: number[] = [];
|
|
69
|
+
let largeFunction = 0;
|
|
70
|
+
let longParamList = 0;
|
|
71
|
+
let highRisk = 0;
|
|
61
72
|
|
|
62
73
|
for (const row of rows) {
|
|
63
|
-
if (row.start_line === null || row.end_line === null) continue;
|
|
64
74
|
const loc = row.end_line - row.start_line + 1;
|
|
65
75
|
if (loc < 1) continue;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} catch {
|
|
76
|
-
// ignore malformed JSON
|
|
76
|
+
|
|
77
|
+
sortedLocs.push(loc);
|
|
78
|
+
|
|
79
|
+
// Assign to LOC bin in O(bins) rather than O(N×bins) via filter
|
|
80
|
+
for (let i = 0; i < LOC_BINS.length; i++) {
|
|
81
|
+
const bin = LOC_BINS[i];
|
|
82
|
+
if (loc >= bin.min && loc <= bin.max) {
|
|
83
|
+
locBinCounts[i]++;
|
|
84
|
+
break;
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
|
-
params.push(paramCount);
|
|
80
|
-
}
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// ── Param distribution ─────────────────────────────────────────────────────
|
|
97
|
-
const paramCountDistribution: SizeBin[] = PARAM_BINS.map(bin => {
|
|
98
|
-
const count = params.filter(p => p >= bin.min && p <= bin.max).length;
|
|
99
|
-
return {
|
|
100
|
-
label: bin.label,
|
|
101
|
-
min: bin.min,
|
|
102
|
-
max: bin.max === Infinity ? 999999 : bin.max,
|
|
103
|
-
count,
|
|
104
|
-
percentage: total > 0 ? Math.round((count / total) * 1000) / 10 : 0,
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// ── Risk summary ───────────────────────────────────────────────────────────
|
|
109
|
-
let largeFunction = 0;
|
|
110
|
-
let longParamList = 0;
|
|
111
|
-
let highRisk = 0;
|
|
112
|
-
for (let i = 0; i < locs.length; i++) {
|
|
113
|
-
const large = locs[i] > 100;
|
|
114
|
-
const longParam = (params[i] ?? 0) > 5;
|
|
88
|
+
const pc = row.param_count ?? 0;
|
|
89
|
+
for (let i = 0; i < PARAM_BINS.length; i++) {
|
|
90
|
+
const bin = PARAM_BINS[i];
|
|
91
|
+
if (pc >= bin.min && pc <= bin.max) {
|
|
92
|
+
paramBinCounts[i]++;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const large = loc > 100;
|
|
98
|
+
const longParam = pc > 5;
|
|
115
99
|
if (large) largeFunction++;
|
|
116
100
|
if (longParam) longParamList++;
|
|
117
101
|
if (large && longParam) highRisk++;
|
|
118
102
|
}
|
|
119
103
|
|
|
104
|
+
const total = sortedLocs.length;
|
|
105
|
+
|
|
106
|
+
// ── Build bin result arrays ───────────────────────────────────────────────
|
|
107
|
+
const functionSizeDistribution: SizeBin[] = LOC_BINS.map((bin, i) => ({
|
|
108
|
+
label: bin.label,
|
|
109
|
+
min: bin.min,
|
|
110
|
+
max: bin.max === Infinity ? 999999 : bin.max,
|
|
111
|
+
count: locBinCounts[i],
|
|
112
|
+
percentage: total > 0 ? Math.round((locBinCounts[i] / total) * 1000) / 10 : 0,
|
|
113
|
+
}));
|
|
114
|
+
|
|
115
|
+
const paramCountDistribution: SizeBin[] = PARAM_BINS.map((bin, i) => ({
|
|
116
|
+
label: bin.label,
|
|
117
|
+
min: bin.min,
|
|
118
|
+
max: bin.max === Infinity ? 999999 : bin.max,
|
|
119
|
+
count: paramBinCounts[i],
|
|
120
|
+
percentage: total > 0 ? Math.round((paramBinCounts[i] / total) * 1000) / 10 : 0,
|
|
121
|
+
}));
|
|
122
|
+
|
|
120
123
|
// ── Percentiles ────────────────────────────────────────────────────────────
|
|
121
|
-
|
|
124
|
+
sortedLocs.sort((a, b) => a - b);
|
|
122
125
|
const p50loc = percentile(sortedLocs, 0.50);
|
|
123
126
|
const p90loc = percentile(sortedLocs, 0.90);
|
|
124
127
|
const p95loc = percentile(sortedLocs, 0.95);
|
|
@@ -132,3 +135,45 @@ export function computeRiskProfile(db: MonographDb): RiskProfileReport {
|
|
|
132
135
|
p95loc,
|
|
133
136
|
};
|
|
134
137
|
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Format a RiskProfileReport as structured text with distribution tables for LLM navigation.
|
|
141
|
+
*
|
|
142
|
+
* @param report - RiskProfileReport from computeRiskProfile()
|
|
143
|
+
* @returns structured text suitable for LLM consumption
|
|
144
|
+
*/
|
|
145
|
+
export function formatRiskProfile(report: RiskProfileReport): string {
|
|
146
|
+
const { functionSizeDistribution, paramCountDistribution, riskSummary, p50loc, p90loc, p95loc } = report;
|
|
147
|
+
|
|
148
|
+
const total = functionSizeDistribution.reduce((s, b) => s + b.count, 0);
|
|
149
|
+
if (total === 0) {
|
|
150
|
+
return 'risk_profile: no Function/Method nodes with line info found\n';
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const lines: string[] = [
|
|
154
|
+
`risk_profile: ${total} functions analysed`,
|
|
155
|
+
` p50_loc: ${p50loc} p90_loc: ${p90loc} p95_loc: ${p95loc}`,
|
|
156
|
+
` large_functions(loc>100): ${riskSummary.largeFunction} long_param_list(params>5): ${riskSummary.longParamList} high_risk(both): ${riskSummary.highRisk}`,
|
|
157
|
+
'',
|
|
158
|
+
'function_size_distribution:',
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
for (const bin of functionSizeDistribution) {
|
|
162
|
+
const bar = '#'.repeat(Math.round(bin.percentage / 5)); // 1 char per 5%
|
|
163
|
+
lines.push(` ${bin.label.padEnd(15)} ${String(bin.count).padStart(5)} (${String(bin.percentage).padStart(5)}%) ${bar}`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
lines.push('');
|
|
167
|
+
lines.push('param_count_distribution:');
|
|
168
|
+
for (const bin of paramCountDistribution) {
|
|
169
|
+
const bar = '#'.repeat(Math.round(bin.percentage / 5));
|
|
170
|
+
lines.push(` ${bin.label.padEnd(15)} ${String(bin.count).padStart(5)} (${String(bin.percentage).padStart(5)}%) ${bar}`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (riskSummary.highRisk > 0) {
|
|
174
|
+
lines.push('');
|
|
175
|
+
lines.push(`high_risk_note: ${riskSummary.highRisk} function(s) have both loc>100 AND params>5 — prime refactor candidates`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return lines.join('\n');
|
|
179
|
+
}
|
|
@@ -29,26 +29,29 @@ function hashString(s: string): number {
|
|
|
29
29
|
return h;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
const MINHASH_PRIME = BigInt(4294967311); // first prime > 2^32
|
|
33
|
+
|
|
32
34
|
/**
|
|
33
35
|
* Compute a MinHash signature for a set of shingles using
|
|
34
|
-
* numHashes linear hash functions: h_i(x) = (a_i * x + b_i) % prime
|
|
36
|
+
* numHashes linear hash functions: h_i(x) = (a_i * x + b_i) % prime.
|
|
37
|
+
*
|
|
38
|
+
* @param seedsA Precomputed BigInt a-coefficients (length numHashes)
|
|
39
|
+
* @param seedsB Precomputed BigInt b-constants (length numHashes)
|
|
35
40
|
*/
|
|
36
|
-
function minHashSignature(
|
|
37
|
-
|
|
41
|
+
function minHashSignature(
|
|
42
|
+
shingles: string[],
|
|
43
|
+
numHashes: number,
|
|
44
|
+
seedsA: BigInt64Array,
|
|
45
|
+
seedsB: BigInt64Array,
|
|
46
|
+
): Uint32Array {
|
|
38
47
|
const sig = new Uint32Array(numHashes).fill(0xffffffff);
|
|
39
48
|
|
|
40
|
-
// Deterministic seeds derived from hash index
|
|
41
49
|
for (const shingle of shingles) {
|
|
42
|
-
const x = hashString(shingle);
|
|
50
|
+
const x = BigInt(hashString(shingle));
|
|
43
51
|
for (let i = 0; i < numHashes; i++) {
|
|
44
|
-
//
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
// Linear hash modulo prime (BigInt for correctness)
|
|
48
|
-
const hashVal = Number((BigInt(a) * BigInt(x) + BigInt(b)) % BigInt(PRIME)) >>> 0;
|
|
49
|
-
if (hashVal < sig[i]) {
|
|
50
|
-
sig[i] = hashVal;
|
|
51
|
-
}
|
|
52
|
+
// Precomputed seeds avoid recomputing the same (a, b) per shingle per call.
|
|
53
|
+
const hashVal = Number((seedsA[i]! * x + seedsB[i]!) % MINHASH_PRIME) >>> 0;
|
|
54
|
+
if (hashVal < sig[i]!) sig[i] = hashVal;
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
return sig;
|
|
@@ -65,11 +68,20 @@ export function createShingleFilter(k = 5, numHashes = 128): ShingleFilter {
|
|
|
65
68
|
const numBands = Math.round(Math.sqrt(numHashes));
|
|
66
69
|
const numRows = Math.floor(numHashes / numBands);
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
// Precompute MinHash seeds once per filter instance to avoid recomputing
|
|
72
|
+
// (a, b) inside the hot inner loop of minHashSignature().
|
|
73
|
+
const seedsA = new BigInt64Array(numHashes);
|
|
74
|
+
const seedsB = new BigInt64Array(numHashes);
|
|
75
|
+
for (let i = 0; i < numHashes; i++) {
|
|
76
|
+
seedsA[i] = BigInt(((i * 2654435761 + 0x9e3779b9) >>> 0));
|
|
77
|
+
seedsB[i] = BigInt(((i * 2246822519 + 0x85ebca6b) >>> 0));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function getBandKey(band: number, sig: Uint32Array): string {
|
|
69
81
|
const parts: number[] = [];
|
|
70
82
|
for (let r = 0; r < numRows; r++) {
|
|
71
83
|
const idx = band * numRows + r;
|
|
72
|
-
if (idx < numHashes) parts.push(sig[idx]);
|
|
84
|
+
if (idx < numHashes) parts.push(sig[idx]!);
|
|
73
85
|
}
|
|
74
86
|
return `b${band}:${parts.join(',')}`;
|
|
75
87
|
}
|
|
@@ -80,12 +92,12 @@ export function createShingleFilter(k = 5, numHashes = 128): ShingleFilter {
|
|
|
80
92
|
return {
|
|
81
93
|
add(id: string, tokens: string[]): void {
|
|
82
94
|
const shingles = kShingles(tokens, k);
|
|
83
|
-
const sig = minHashSignature(shingles, numHashes);
|
|
95
|
+
const sig = minHashSignature(shingles, numHashes, seedsA, seedsB);
|
|
84
96
|
index.set(id, sig);
|
|
85
97
|
|
|
86
98
|
// Insert into LSH band buckets
|
|
87
99
|
for (let band = 0; band < numBands; band++) {
|
|
88
|
-
const key = getBandKey(
|
|
100
|
+
const key = getBandKey(band, sig);
|
|
89
101
|
const bucket = bandBuckets.get(key);
|
|
90
102
|
if (bucket) {
|
|
91
103
|
bucket.push(id);
|
|
@@ -97,20 +109,14 @@ export function createShingleFilter(k = 5, numHashes = 128): ShingleFilter {
|
|
|
97
109
|
|
|
98
110
|
candidates(tokens: string[], topK = 10): string[] {
|
|
99
111
|
const shingles = kShingles(tokens, k);
|
|
100
|
-
const querySig = minHashSignature(shingles, numHashes);
|
|
112
|
+
const querySig = minHashSignature(shingles, numHashes, seedsA, seedsB);
|
|
101
113
|
|
|
102
|
-
// Collect candidate IDs via LSH band matching
|
|
114
|
+
// Collect candidate IDs via LSH band matching.
|
|
115
|
+
// Use getBandKey() consistently — eliminates the duplicate inline computation.
|
|
103
116
|
const candidateScores = new Map<string, number>();
|
|
104
117
|
|
|
105
118
|
for (let band = 0; band < numBands; band++) {
|
|
106
|
-
const
|
|
107
|
-
// Manually compute the key for the query signature
|
|
108
|
-
const parts: number[] = [];
|
|
109
|
-
for (let r = 0; r < numRows; r++) {
|
|
110
|
-
const idx = band * numRows + r;
|
|
111
|
-
if (idx < numHashes) parts.push(querySig[idx]);
|
|
112
|
-
}
|
|
113
|
-
const queryKey = `b${band}:${parts.join(',')}`;
|
|
119
|
+
const queryKey = getBandKey(band, querySig);
|
|
114
120
|
const bucket = bandBuckets.get(queryKey);
|
|
115
121
|
if (bucket) {
|
|
116
122
|
for (const id of bucket) {
|