codebase-onboarder 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +174 -46
- package/bin/build-if-source.js +23 -0
- package/cli/commands.d.ts +26 -0
- package/cli/commands.js +836 -811
- package/cli/commands.js.map +1 -0
- package/cli/explorer/advanced.d.ts +14 -0
- package/cli/explorer/advanced.js +321 -329
- package/cli/explorer/advanced.js.map +1 -0
- package/cli/explorer/app.d.ts +1 -0
- package/cli/explorer/app.js +384 -313
- package/cli/explorer/app.js.map +1 -0
- package/cli/explorer/assistant.d.ts +9 -0
- package/cli/explorer/assistant.js +58 -0
- package/cli/explorer/assistant.js.map +1 -0
- package/cli/explorer/commands.d.ts +17 -0
- package/cli/explorer/commands.js +368 -302
- package/cli/explorer/commands.js.map +1 -0
- package/cli/explorer/featureViews.d.ts +124 -0
- package/cli/explorer/featureViews.js +179 -0
- package/cli/explorer/featureViews.js.map +1 -0
- package/cli/explorer/github.d.ts +21 -0
- package/cli/explorer/github.js +42 -44
- package/cli/explorer/github.js.map +1 -0
- package/cli/explorer/graphs.d.ts +7 -0
- package/cli/explorer/graphs.js +90 -95
- package/cli/explorer/graphs.js.map +1 -0
- package/cli/explorer/picker.d.ts +22 -0
- package/cli/explorer/picker.js +150 -0
- package/cli/explorer/picker.js.map +1 -0
- package/cli/explorer/report.d.ts +85 -0
- package/cli/explorer/report.js +60 -0
- package/cli/explorer/report.js.map +1 -0
- package/cli/explorer/session.d.ts +449 -0
- package/cli/explorer/session.js +143 -144
- package/cli/explorer/session.js.map +1 -0
- package/cli/explorer/views.d.ts +19 -0
- package/cli/explorer/views.js +465 -482
- package/cli/explorer/views.js.map +1 -0
- package/cli/explorer/wrap.d.ts +1 -0
- package/cli/explorer/wrap.js +28 -44
- package/cli/explorer/wrap.js.map +1 -0
- package/cli/main.d.ts +1 -0
- package/cli/main.js +214 -161
- package/cli/main.js.map +1 -0
- package/cli/prompt.d.ts +5 -0
- package/cli/prompt.js +84 -80
- package/cli/prompt.js.map +1 -0
- package/cli/scanOptions.d.ts +2 -0
- package/cli/scanOptions.js +11 -0
- package/cli/scanOptions.js.map +1 -0
- package/cli/ui.d.ts +33 -0
- package/cli/ui.js +35 -44
- package/cli/ui.js.map +1 -0
- package/cli/wizard.d.ts +187 -0
- package/cli/wizard.js +304 -284
- package/cli/wizard.js.map +1 -0
- package/package.json +15 -4
- package/public/app.d.ts +1 -0
- package/public/app.js +1057 -1009
- package/public/app.js.map +1 -0
- package/public/browser.d.ts +68 -0
- package/public/browser.js +2 -0
- package/public/browser.js.map +1 -0
- package/public/index.html +30 -13
- package/public/js/about.d.ts +6 -0
- package/public/js/about.js +152 -172
- package/public/js/about.js.map +1 -0
- package/public/js/aiDraft.d.ts +3 -0
- package/public/js/aiDraft.js +116 -124
- package/public/js/aiDraft.js.map +1 -0
- package/public/js/analysisPanel.d.ts +7 -0
- package/public/js/analysisPanel.js +166 -166
- package/public/js/analysisPanel.js.map +1 -0
- package/public/js/analysisReport.d.ts +38 -0
- package/public/js/analysisReport.js +105 -110
- package/public/js/analysisReport.js.map +1 -0
- package/public/js/api.d.ts +26 -0
- package/public/js/api.js +176 -167
- package/public/js/api.js.map +1 -0
- package/public/js/atlas.d.ts +6 -0
- package/public/js/atlas.js +50 -58
- package/public/js/atlas.js.map +1 -0
- package/public/js/blameView.d.ts +2 -0
- package/public/js/blameView.js +36 -37
- package/public/js/blameView.js.map +1 -0
- package/public/js/codeTab.d.ts +3 -0
- package/public/js/codeTab.js +175 -180
- package/public/js/codeTab.js.map +1 -0
- package/public/js/codeViewer.d.ts +5 -0
- package/public/js/codeViewer.js +162 -150
- package/public/js/codeViewer.js.map +1 -0
- package/public/js/components/FileChip.d.ts +9 -0
- package/public/js/components/FileChip.js +45 -49
- package/public/js/components/FileChip.js.map +1 -0
- package/public/js/components/MetricSparkline.d.ts +7 -0
- package/public/js/components/MetricSparkline.js +35 -44
- package/public/js/components/MetricSparkline.js.map +1 -0
- package/public/js/components/RiskBadge.d.ts +9 -0
- package/public/js/components/RiskBadge.js +55 -63
- package/public/js/components/RiskBadge.js.map +1 -0
- package/public/js/deepAnalysisView.d.ts +99 -0
- package/public/js/deepAnalysisView.js +282 -302
- package/public/js/deepAnalysisView.js.map +1 -0
- package/public/js/diagramPane.d.ts +8 -0
- package/public/js/diagramPane.js +133 -135
- package/public/js/diagramPane.js.map +1 -0
- package/public/js/diffView.d.ts +6 -0
- package/public/js/diffView.js +222 -209
- package/public/js/diffView.js.map +1 -0
- package/public/js/docsView.d.ts +2 -0
- package/public/js/docsView.js +441 -442
- package/public/js/docsView.js.map +1 -0
- package/public/js/dom.d.ts +189 -0
- package/public/js/dom.js +5 -0
- package/public/js/dom.js.map +1 -0
- package/public/js/fileSourceBrowser.d.ts +5 -0
- package/public/js/fileSourceBrowser.js +33 -41
- package/public/js/fileSourceBrowser.js.map +1 -0
- package/public/js/flameGraph.d.ts +5 -0
- package/public/js/flameGraph.js +62 -72
- package/public/js/flameGraph.js.map +1 -0
- package/public/js/forceGraph.d.ts +10 -0
- package/public/js/forceGraph.js +581 -556
- package/public/js/forceGraph.js.map +1 -0
- package/public/js/heatmap.d.ts +4 -0
- package/public/js/heatmap.js +142 -164
- package/public/js/heatmap.js.map +1 -0
- package/public/js/highlight.d.ts +2 -0
- package/public/js/highlight.js +116 -107
- package/public/js/highlight.js.map +1 -0
- package/public/js/html.d.ts +2 -0
- package/public/js/html.js +14 -44
- package/public/js/html.js.map +1 -0
- package/public/js/insightsView.d.ts +5 -0
- package/public/js/insightsView.js +93 -111
- package/public/js/insightsView.js.map +1 -0
- package/public/js/inspector.d.ts +37 -0
- package/public/js/inspector.js +416 -445
- package/public/js/inspector.js.map +1 -0
- package/public/js/llm.d.ts +113 -0
- package/public/js/llm.js +233 -272
- package/public/js/llm.js.map +1 -0
- package/public/js/mapView.d.ts +3 -0
- package/public/js/mapView.js +121 -120
- package/public/js/mapView.js.map +1 -0
- package/public/js/markdown.d.ts +3 -0
- package/public/js/markdown.js +84 -91
- package/public/js/markdown.js.map +1 -0
- package/public/js/mindmap.d.ts +32 -0
- package/public/js/mindmap.js +244 -259
- package/public/js/mindmap.js.map +1 -0
- package/public/js/mobilePanels.d.ts +5 -0
- package/public/js/mobilePanels.js +50 -0
- package/public/js/mobilePanels.js.map +1 -0
- package/public/js/repoFiles.d.ts +12 -0
- package/public/js/repoFiles.js +28 -27
- package/public/js/repoFiles.js.map +1 -0
- package/public/js/reviewView.d.ts +28 -0
- package/public/js/reviewView.js +256 -0
- package/public/js/reviewView.js.map +1 -0
- package/public/js/sbomView.d.ts +3 -0
- package/public/js/sbomView.js +59 -67
- package/public/js/sbomView.js.map +1 -0
- package/public/js/scanCache.d.ts +16 -0
- package/public/js/scanCache.js +67 -65
- package/public/js/scanCache.js.map +1 -0
- package/public/js/search.d.ts +7 -0
- package/public/js/search.js +868 -800
- package/public/js/search.js.map +1 -0
- package/public/js/searchLocal.d.ts +42 -0
- package/public/js/searchLocal.js +87 -0
- package/public/js/searchLocal.js.map +1 -0
- package/public/js/serverSettings.d.ts +5 -0
- package/public/js/serverSettings.js +153 -164
- package/public/js/serverSettings.js.map +1 -0
- package/public/js/state.d.ts +798 -0
- package/public/js/state.js +114 -122
- package/public/js/state.js.map +1 -0
- package/public/js/tour.d.ts +6 -0
- package/public/js/tour.js +5 -7
- package/public/js/tour.js.map +1 -0
- package/public/js/transitions.d.ts +2 -0
- package/public/js/transitions.js +9 -10
- package/public/js/transitions.js.map +1 -0
- package/public/js/tree.d.ts +12 -0
- package/public/js/tree.js +157 -154
- package/public/js/tree.js.map +1 -0
- package/public/js/workflowsView.d.ts +3 -0
- package/public/js/workflowsView.js +15 -22
- package/public/js/workflowsView.js.map +1 -0
- package/public/search.css +495 -0
- package/public/styles.css +163 -346
- package/public/workbench.css +166 -0
- package/server/apiAuth.d.ts +3 -0
- package/server/apiAuth.js +18 -20
- package/server/apiAuth.js.map +1 -0
- package/server/apiDiff.d.ts +2 -0
- package/server/apiDiff.js +20 -18
- package/server/apiDiff.js.map +1 -0
- package/server/apiDocs.d.ts +2 -0
- package/server/apiDocs.js +38 -40
- package/server/apiDocs.js.map +1 -0
- package/server/apiFile.d.ts +1 -0
- package/server/apiFile.js +14 -17
- package/server/apiFile.js.map +1 -0
- package/server/apiGitBlame.d.ts +2 -0
- package/server/apiGitBlame.js +50 -51
- package/server/apiGitBlame.js.map +1 -0
- package/server/apiMcp.d.ts +4 -0
- package/server/apiMcp.js +64 -66
- package/server/apiMcp.js.map +1 -0
- package/server/apiReview.d.ts +2 -0
- package/server/apiReview.js +45 -0
- package/server/apiReview.js.map +1 -0
- package/server/apiScan.d.ts +5 -0
- package/server/apiScan.js +90 -71
- package/server/apiScan.js.map +1 -0
- package/server/apiSearch.d.ts +33 -0
- package/server/apiSearch.js +184 -200
- package/server/apiSearch.js.map +1 -0
- package/server/apiSettings.d.ts +4 -0
- package/server/apiSettings.js +84 -85
- package/server/apiSettings.js.map +1 -0
- package/server/apiTools.d.ts +3 -0
- package/server/apiTools.js +55 -56
- package/server/apiTools.js.map +1 -0
- package/server/auth.d.ts +5 -0
- package/server/auth.js +54 -51
- package/server/auth.js.map +1 -0
- package/server/config.d.ts +42 -0
- package/server/config.js +189 -194
- package/server/config.js.map +1 -0
- package/server/daemon.d.ts +12 -0
- package/server/daemon.js +124 -114
- package/server/daemon.js.map +1 -0
- package/server/fileSourceNode.d.ts +2 -0
- package/server/fileSourceNode.js +34 -36
- package/server/fileSourceNode.js.map +1 -0
- package/server/gitClone.d.ts +9 -0
- package/server/gitClone.js +59 -61
- package/server/gitClone.js.map +1 -0
- package/server/gitDiff.d.ts +36 -0
- package/server/gitDiff.js +271 -169
- package/server/gitDiff.js.map +1 -0
- package/server/gitHistory.d.ts +12 -0
- package/server/gitHistory.js +80 -80
- package/server/gitHistory.js.map +1 -0
- package/server/gitRemote.d.ts +12 -0
- package/server/gitRemote.js +37 -38
- package/server/gitRemote.js.map +1 -0
- package/server/htmlText.d.ts +4 -0
- package/server/htmlText.js +16 -23
- package/server/htmlText.js.map +1 -0
- package/server/http.d.ts +5 -0
- package/server/http.js +27 -30
- package/server/http.js.map +1 -0
- package/server/httpGuards.d.ts +2 -0
- package/server/httpGuards.js +47 -43
- package/server/httpGuards.js.map +1 -0
- package/server/https.d.ts +34 -0
- package/server/https.js +121 -111
- package/server/https.js.map +1 -0
- package/server/index.d.ts +40 -0
- package/server/index.js +139 -147
- package/server/index.js.map +1 -0
- package/server/layout.d.ts +26 -0
- package/server/layout.js +59 -64
- package/server/layout.js.map +1 -0
- package/server/llmProxy.d.ts +3 -0
- package/server/llmProxy.js +137 -135
- package/server/llmProxy.js.map +1 -0
- package/server/logger.d.ts +38 -0
- package/server/logger.js +198 -211
- package/server/logger.js.map +1 -0
- package/server/mcp/analysis.d.ts +29 -0
- package/server/mcp/analysis.js +99 -120
- package/server/mcp/analysis.js.map +1 -0
- package/server/mcp/http.d.ts +9 -0
- package/server/mcp/http.js +128 -137
- package/server/mcp/http.js.map +1 -0
- package/server/mcp/runner.d.ts +68 -0
- package/server/mcp/runner.js +208 -218
- package/server/mcp/runner.js.map +1 -0
- package/server/mcp/server.d.ts +29 -0
- package/server/mcp/server.js +166 -179
- package/server/mcp/server.js.map +1 -0
- package/server/mcp/standalone.d.ts +1 -0
- package/server/mcp/standalone.js +8 -10
- package/server/mcp/standalone.js.map +1 -0
- package/server/mcp/tools.d.ts +2020 -0
- package/server/mcp/tools.js +523 -574
- package/server/mcp/tools.js.map +1 -0
- package/server/paths.d.ts +3 -0
- package/server/paths.js +17 -15
- package/server/paths.js.map +1 -0
- package/server/pidfile.d.ts +9 -0
- package/server/pidfile.js +43 -45
- package/server/pidfile.js.map +1 -0
- package/server/review.d.ts +5 -0
- package/server/review.js +35 -0
- package/server/review.js.map +1 -0
- package/server/router.d.ts +33 -0
- package/server/router.js +191 -197
- package/server/router.js.map +1 -0
- package/server/scanRequest.d.ts +3 -0
- package/server/scanRequest.js +36 -0
- package/server/scanRequest.js.map +1 -0
- package/server/searchIndex.d.ts +17 -0
- package/server/searchIndex.js +83 -80
- package/server/searchIndex.js.map +1 -0
- package/server/sessions.d.ts +14 -0
- package/server/sessions.js +62 -70
- package/server/sessions.js.map +1 -0
- package/server/startup.d.ts +118 -0
- package/server/startup.js +143 -148
- package/server/startup.js.map +1 -0
- package/server/static.d.ts +6 -0
- package/server/static.js +28 -31
- package/server/static.js.map +1 -0
- package/server/tools/install.d.ts +4 -0
- package/server/tools/install.js +176 -185
- package/server/tools/install.js.map +1 -0
- package/server/tools/parse.d.ts +8 -0
- package/server/tools/parse.js +112 -114
- package/server/tools/parse.js.map +1 -0
- package/server/tools/platform.d.ts +9 -0
- package/server/tools/platform.js +49 -47
- package/server/tools/platform.js.map +1 -0
- package/server/tools/registry.d.ts +137 -0
- package/server/tools/registry.js +173 -172
- package/server/tools/registry.js.map +1 -0
- package/server/tools/scan.d.ts +34 -0
- package/server/tools/scan.js +89 -98
- package/server/tools/scan.js.map +1 -0
- package/server/tools.d.ts +34 -0
- package/server/tools.js +94 -107
- package/server/tools.js.map +1 -0
- package/server/tunnel.d.ts +29 -0
- package/server/tunnel.js +61 -66
- package/server/tunnel.js.map +1 -0
- package/shared/analyzer/docs.d.ts +16 -0
- package/shared/analyzer/docs.js +99 -93
- package/shared/analyzer/docs.js.map +1 -0
- package/shared/analyzer/explainLocal.d.ts +4 -0
- package/shared/analyzer/explainLocal.js +122 -142
- package/shared/analyzer/explainLocal.js.map +1 -0
- package/shared/analyzer/github.d.ts +37 -0
- package/shared/analyzer/github.js +41 -43
- package/shared/analyzer/github.js.map +1 -0
- package/shared/analyzer/graph.d.ts +41 -0
- package/shared/analyzer/graph.js +393 -400
- package/shared/analyzer/graph.js.map +1 -0
- package/shared/analyzer/health.d.ts +33 -0
- package/shared/analyzer/health.js +197 -193
- package/shared/analyzer/health.js.map +1 -0
- package/shared/analyzer/history.d.ts +29 -0
- package/shared/analyzer/history.js +110 -111
- package/shared/analyzer/history.js.map +1 -0
- package/shared/analyzer/jsonConfig.d.ts +2 -0
- package/shared/analyzer/jsonConfig.js +61 -0
- package/shared/analyzer/jsonConfig.js.map +1 -0
- package/shared/analyzer/languages/csharp.d.ts +26 -0
- package/shared/analyzer/languages/csharp.js +83 -88
- package/shared/analyzer/languages/csharp.js.map +1 -0
- package/shared/analyzer/languages/generic.d.ts +23 -0
- package/shared/analyzer/languages/generic.js +94 -105
- package/shared/analyzer/languages/generic.js.map +1 -0
- package/shared/analyzer/languages/go.d.ts +24 -0
- package/shared/analyzer/languages/go.js +45 -54
- package/shared/analyzer/languages/go.js.map +1 -0
- package/shared/analyzer/languages/index.d.ts +6 -0
- package/shared/analyzer/languages/index.js +19 -20
- package/shared/analyzer/languages/index.js.map +1 -0
- package/shared/analyzer/languages/java.d.ts +20 -0
- package/shared/analyzer/languages/java.js +73 -78
- package/shared/analyzer/languages/java.js.map +1 -0
- package/shared/analyzer/languages/javascript.d.ts +12 -0
- package/shared/analyzer/languages/javascript.js +258 -209
- package/shared/analyzer/languages/javascript.js.map +1 -0
- package/shared/analyzer/languages/python.d.ts +23 -0
- package/shared/analyzer/languages/python.js +92 -100
- package/shared/analyzer/languages/python.js.map +1 -0
- package/shared/analyzer/languages/rust.d.ts +17 -0
- package/shared/analyzer/languages/rust.js +96 -98
- package/shared/analyzer/languages/rust.js.map +1 -0
- package/shared/analyzer/languages/typescript.d.ts +11 -0
- package/shared/analyzer/languages/typescript.js +117 -116
- package/shared/analyzer/languages/typescript.js.map +1 -0
- package/shared/analyzer/licenses.d.ts +18 -0
- package/shared/analyzer/licenses.js +130 -133
- package/shared/analyzer/licenses.js.map +1 -0
- package/shared/analyzer/metrics.d.ts +20 -0
- package/shared/analyzer/metrics.js +112 -104
- package/shared/analyzer/metrics.js.map +1 -0
- package/shared/analyzer/pathUtil.d.ts +10 -0
- package/shared/analyzer/pathUtil.js +29 -35
- package/shared/analyzer/pathUtil.js.map +1 -0
- package/shared/analyzer/patterns.d.ts +11 -0
- package/shared/analyzer/patterns.js +231 -253
- package/shared/analyzer/patterns.js.map +1 -0
- package/shared/analyzer/scan.d.ts +62 -0
- package/shared/analyzer/scan.js +451 -442
- package/shared/analyzer/scan.js.map +1 -0
- package/shared/analyzer/scanControl.d.ts +11 -0
- package/shared/analyzer/scanControl.js +62 -0
- package/shared/analyzer/scanControl.js.map +1 -0
- package/shared/analyzer/security.d.ts +18 -0
- package/shared/analyzer/security.js +159 -159
- package/shared/analyzer/security.js.map +1 -0
- package/shared/analyzer/services.d.ts +5 -0
- package/shared/analyzer/services.js +141 -138
- package/shared/analyzer/services.js.map +1 -0
- package/shared/analyzer/stack.d.ts +6 -0
- package/shared/analyzer/stack.js +134 -141
- package/shared/analyzer/stack.js.map +1 -0
- package/shared/analyzer/tour.d.ts +2 -0
- package/shared/analyzer/tour.js +45 -53
- package/shared/analyzer/tour.js.map +1 -0
- package/shared/analyzer/util.d.ts +8 -0
- package/shared/analyzer/util.js +130 -76
- package/shared/analyzer/util.js.map +1 -0
- package/shared/analyzer/workflows.d.ts +8 -0
- package/shared/analyzer/workflows.js +139 -134
- package/shared/analyzer/workflows.js.map +1 -0
- package/shared/contracts.d.ts +250 -0
- package/shared/contracts.js +2 -0
- package/shared/contracts.js.map +1 -0
- package/shared/diagram/aiFacts.d.ts +35 -0
- package/shared/diagram/aiFacts.js +102 -105
- package/shared/diagram/aiFacts.js.map +1 -0
- package/shared/diagram/aiMermaid.d.ts +5 -0
- package/shared/diagram/aiMermaid.js +46 -45
- package/shared/diagram/aiMermaid.js.map +1 -0
- package/shared/diagram/atlas.d.ts +16 -0
- package/shared/diagram/atlas.js +51 -60
- package/shared/diagram/atlas.js.map +1 -0
- package/shared/diagram/mermaid.d.ts +43 -0
- package/shared/diagram/mermaid.js +348 -370
- package/shared/diagram/mermaid.js.map +1 -0
- package/shared/review/contracts.d.ts +95 -0
- package/shared/review/contracts.js +2 -0
- package/shared/review/contracts.js.map +1 -0
- package/shared/review/review.d.ts +10 -0
- package/shared/review/review.js +184 -0
- package/shared/review/review.js.map +1 -0
- package/shared/search/query.d.ts +32 -0
- package/shared/search/query.js +395 -388
- package/shared/search/query.js.map +1 -0
package/cli/explorer/session.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { throwIfAborted } from '../../shared/analyzer/scanControl.js';
|
|
1
2
|
// One repository, loaded into memory, the way the website loads it.
|
|
2
3
|
//
|
|
3
4
|
// This is the whole reason the terminal app can stand in for the site: it runs
|
|
@@ -9,10 +10,8 @@
|
|
|
9
10
|
//
|
|
10
11
|
// Everything below the loader is pure data plus a few lookups. The loader is
|
|
11
12
|
// the only async part, and it is the only part that touches the filesystem.
|
|
12
|
-
|
|
13
13
|
import { promises as fs } from 'node:fs';
|
|
14
14
|
import path from 'node:path';
|
|
15
|
-
|
|
16
15
|
import { nodeFileSource } from '../../server/fileSourceNode.js';
|
|
17
16
|
import { buildSearchIndex } from '../../server/searchIndex.js';
|
|
18
17
|
import { searchDocuments } from '../../server/apiSearch.js';
|
|
@@ -29,7 +28,6 @@ import { analyzeStack } from '../../shared/analyzer/stack.js';
|
|
|
29
28
|
import { buildTourStops } from '../../shared/analyzer/tour.js';
|
|
30
29
|
import { explainFile, explainFolder, explainOverview } from '../../shared/analyzer/explainLocal.js';
|
|
31
30
|
import { languageLabel } from '../../shared/analyzer/languages/index.js';
|
|
32
|
-
|
|
33
31
|
// Does this argument name a repository to fetch, rather than a folder on this
|
|
34
32
|
// machine? The check is deliberately narrow: only the URL shapes git itself
|
|
35
33
|
// accepts, so a folder that happens to be called `ssh://stuff` cannot exist on a
|
|
@@ -38,109 +36,111 @@ import { languageLabel } from '../../shared/analyzer/languages/index.js';
|
|
|
38
36
|
// `github.com/src/server` because someone typed `cd src/server` would be a
|
|
39
37
|
// genuinely bad failure. The shorthand, if it is wanted, has to be asked for.
|
|
40
38
|
export function isGitUrl(target) {
|
|
41
|
-
|
|
39
|
+
return /^(https?:\/\/|git@|ssh:\/\/)/.test(String(target || '').trim());
|
|
42
40
|
}
|
|
43
|
-
|
|
44
41
|
// Open a local folder or clone a remote one — the same three ways in the web
|
|
45
42
|
// app's landing page offers, narrowed to the two that make sense for a command
|
|
46
43
|
// line. A clone is left in place when the session ends; `closeRemote` removes it,
|
|
47
44
|
// and the session calls that on `cd` and on exit, so nothing is orphaned in the
|
|
48
45
|
// temp dir.
|
|
49
|
-
export async function openRepoOrClone(target,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
46
|
+
export async function openRepoOrClone(target, options = {}) {
|
|
47
|
+
throwIfAborted(options.signal);
|
|
48
|
+
const onProgress = options.onProgress;
|
|
49
|
+
const raw = String(target || '').trim();
|
|
50
|
+
if (!isGitUrl(raw))
|
|
51
|
+
return openRepo(raw, options);
|
|
52
|
+
const url = assertGitUrl(raw);
|
|
53
|
+
if (onProgress)
|
|
54
|
+
onProgress({ phase: 'clone', url });
|
|
55
|
+
const clone = await cloneRepo(url);
|
|
56
|
+
try {
|
|
57
|
+
const repo = await openRepo(clone.dir, options);
|
|
58
|
+
// The repo's own name is what a person recognizes; the temp path is kept so
|
|
59
|
+
// `about` can still print a path someone could go and look at.
|
|
60
|
+
return {
|
|
61
|
+
...repo,
|
|
62
|
+
name: repoNameFromUrl(url) || repo.name,
|
|
63
|
+
gitUrl: url,
|
|
64
|
+
tempId: path.basename(clone.dir),
|
|
65
|
+
cloneDir: clone.dir,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
// A clone that was never loaded has no session to clean it up later, so it
|
|
70
|
+
// has to go now or it is a temp directory nobody owns.
|
|
71
|
+
await removeClone(clone.dir);
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
73
74
|
}
|
|
74
|
-
|
|
75
75
|
// The URL this repo should be asked about on GitHub, or null.
|
|
76
76
|
//
|
|
77
77
|
// A repo this session cloned knows its own URL. A repo someone was standing in
|
|
78
78
|
// does not, and git does. Asking git here rather than in the `github` command
|
|
79
79
|
// keeps the answer on the repo object, so every consumer gets it the same way.
|
|
80
80
|
export async function remoteUrlFor(repo) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
if (repo.gitUrl)
|
|
82
|
+
return repo.gitUrl;
|
|
83
|
+
if (repo.remoteChecked)
|
|
84
|
+
return null;
|
|
85
|
+
repo.remoteChecked = true;
|
|
86
|
+
const found = await gitRemoteOrigin(repo.root);
|
|
87
|
+
if (found.ok)
|
|
88
|
+
repo.gitUrl = found.url;
|
|
89
|
+
return repo.gitUrl || null;
|
|
87
90
|
}
|
|
88
|
-
|
|
89
91
|
// Drop a temp clone, if this repo is one. Safe to call on a local repo: it
|
|
90
92
|
// checks the shape of the directory rather than trusting a flag, so a bug
|
|
91
93
|
// elsewhere cannot turn "clean up" into "delete the folder the user is in".
|
|
92
94
|
export async function closeRemote(repo) {
|
|
93
|
-
|
|
95
|
+
if (repo?.cloneDir)
|
|
96
|
+
await removeClone(repo.cloneDir);
|
|
94
97
|
}
|
|
95
|
-
|
|
96
98
|
// Scan a directory and return the loaded repo, or throw an Error whose message
|
|
97
99
|
// is safe to print straight to the user. `target` may be `~`, a relative path,
|
|
98
100
|
// or anything `expandHome` understands; it defaults to the current directory.
|
|
99
|
-
export async function openRepo(target = '.',
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
101
|
+
export async function openRepo(target = '.', options = {}) {
|
|
102
|
+
const root = expandHome(String(target || '.'));
|
|
103
|
+
const stat = await fs.stat(root).catch(() => null);
|
|
104
|
+
if (!stat)
|
|
105
|
+
throw new Error('No such folder: ' + root);
|
|
106
|
+
if (!stat.isDirectory())
|
|
107
|
+
throw new Error('Not a folder: ' + root);
|
|
108
|
+
const source = nodeFileSource(root);
|
|
109
|
+
const scan = await scanRepo(source, options);
|
|
110
|
+
const manifest = await detectManifest(source);
|
|
111
|
+
const facts = computeFacts(scan, manifest);
|
|
112
|
+
const searchIndex = await buildSearchIndex(source, scan.files.map((f) => f.path));
|
|
113
|
+
// The layers projection is an input to patterns, not a parallel view of the
|
|
114
|
+
// same thing — `detectPatterns` reads the layer depths to place a file in the
|
|
115
|
+
// architecture. Compute once, share. The coupling matrix is the same kind of
|
|
116
|
+
// thing: a projection of `facts.folderEdges` that both the site and the
|
|
117
|
+
// terminal's heat grid read, so it is computed once here rather than per view.
|
|
118
|
+
const layers = computeLayers(scan, facts);
|
|
119
|
+
const loaded = {
|
|
120
|
+
root,
|
|
121
|
+
name: scan.name || path.basename(root),
|
|
122
|
+
scan,
|
|
123
|
+
facts,
|
|
124
|
+
manifest,
|
|
125
|
+
searchIndex,
|
|
126
|
+
layers,
|
|
127
|
+
coupling: couplingMatrix(scan, facts),
|
|
128
|
+
health: analyzeHealth(scan, facts),
|
|
129
|
+
patterns: detectPatterns(scan, facts, manifest, layers),
|
|
130
|
+
security: summarizeSecurity(scan),
|
|
131
|
+
stack: analyzeStack(manifest, scan.stats.languages || {}),
|
|
132
|
+
tour: buildTourStops(scan, facts),
|
|
133
|
+
languages: languageRows(scan),
|
|
134
|
+
};
|
|
135
|
+
return loaded;
|
|
134
136
|
}
|
|
135
|
-
|
|
136
137
|
// LOC per language, biggest first, with the display label the site uses — so
|
|
137
138
|
// `JavaScript` here and `JavaScript` there are the same string.
|
|
138
139
|
function languageRows(scan) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
return Object.entries(scan.stats.languages || {})
|
|
141
|
+
.map(([id, loc]) => ({ id, loc, label: languageLabel(id) }))
|
|
142
|
+
.sort((a, b) => Number(b.loc) - Number(a.loc) || a.label.localeCompare(b.label));
|
|
142
143
|
}
|
|
143
|
-
|
|
144
144
|
// The one place a typed path becomes a real file. People type `logger.js`, not
|
|
145
145
|
// `server/logger.js`, and a tool that says "no such file" for a file that is
|
|
146
146
|
// right there is worse than no tool. So: exact, then folder, then suffix, then
|
|
@@ -148,104 +148,103 @@ function languageRows(scan) {
|
|
|
148
148
|
// than guessed at — silently picking the wrong `index.js` is the failure mode
|
|
149
149
|
// that makes people stop trusting a map.
|
|
150
150
|
export function resolveTarget(repo, typed) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
151
|
+
const raw = String(typed || '').trim().replace(/^\.\//, '');
|
|
152
|
+
if (!raw)
|
|
153
|
+
return { error: 'Name a file or folder.' };
|
|
154
|
+
// `.` and `./` are the root, which is a real folder and a common thing to type
|
|
155
|
+
// (`tree .`, `explain .`). Without this they fell through to the substring
|
|
156
|
+
// match and offered eight unrelated files as "did you mean", which is worse
|
|
157
|
+
// than useless — it is actively misleading. The root folder's path is `''`.
|
|
158
|
+
if (raw === '.' || raw === './')
|
|
159
|
+
return { folder: ROOT_FOLDER };
|
|
160
|
+
const files = repo.scan.files;
|
|
161
|
+
if (!repo.byPath)
|
|
162
|
+
repo.byPath = new Map(files.map((f) => [f.path, f]));
|
|
163
|
+
if (repo.byPath.has(raw))
|
|
164
|
+
return { file: repo.byPath.get(raw) };
|
|
165
|
+
const folder = folderFor(repo, raw);
|
|
166
|
+
if (folder)
|
|
167
|
+
return { folder };
|
|
168
|
+
const lower = raw.toLowerCase();
|
|
169
|
+
const suffix = files.filter((f) => f.path.endsWith('/' + raw));
|
|
170
|
+
if (suffix.length === 1)
|
|
171
|
+
return { file: suffix[0] };
|
|
172
|
+
if (suffix.length > 1)
|
|
173
|
+
return { error: 'Which one?', candidates: suffix.map((f) => f.path) };
|
|
174
|
+
const base = files.filter((f) => f.name.toLowerCase() === lower);
|
|
175
|
+
if (base.length === 1)
|
|
176
|
+
return { file: base[0] };
|
|
177
|
+
if (base.length > 1)
|
|
178
|
+
return { error: 'Which one?', candidates: base.map((f) => f.path) };
|
|
179
|
+
const loose = files.filter((f) => f.path.toLowerCase().includes(lower));
|
|
180
|
+
if (loose.length) {
|
|
181
|
+
loose.sort((a, b) => a.path.length - b.path.length);
|
|
182
|
+
return { error: 'No exact match. Did you mean:', candidates: loose.slice(0, 8).map((f) => f.path) };
|
|
183
|
+
}
|
|
184
|
+
return { error: 'Nothing in this repo matches "' + raw + '".' };
|
|
182
185
|
}
|
|
183
|
-
|
|
184
186
|
// The root folder is a real answer, not a sentinel: `tree .` and `explain .`
|
|
185
187
|
// both need one, and it carries the same fields `resolveTarget` returns for any
|
|
186
188
|
// other folder so the callers need no special case.
|
|
187
189
|
const ROOT_FOLDER = Object.freeze({ name: '', path: '', loc: 0, comment: 0, blank: 0, size: 0, langs: {} });
|
|
188
|
-
|
|
189
190
|
function folderFor(repo, typed) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
const clean = typed.replace(/\/+$/, '');
|
|
192
|
+
if (clean === '')
|
|
193
|
+
return ROOT_FOLDER;
|
|
194
|
+
const exact = repo.scan.folders.find((d) => d.path === clean);
|
|
195
|
+
if (exact)
|
|
196
|
+
return exact;
|
|
197
|
+
const matches = repo.scan.folders.filter((d) => d.path.endsWith('/' + clean) || d.name === clean);
|
|
198
|
+
return matches.length === 1 ? matches[0] : null;
|
|
196
199
|
}
|
|
197
|
-
|
|
198
200
|
// Read a file through the same containment check the HTTP route uses. A tool
|
|
199
201
|
// whose job is showing you one repository has no business reading any path on
|
|
200
202
|
// the machine, and going through `resolveInside` means there is no second,
|
|
201
203
|
// looser door to get there.
|
|
202
204
|
export async function readRepoFile(repo, repoPath) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
const abs = resolveInside(repo.root, repoPath);
|
|
206
|
+
if (!abs)
|
|
207
|
+
throw new Error('That path is outside the repository.');
|
|
208
|
+
return fs.readFile(abs, 'utf8');
|
|
206
209
|
}
|
|
207
|
-
|
|
208
210
|
// The website's search, verbatim: same TF-IDF ranking, same query language
|
|
209
211
|
// (`ext:`, `path:`, `-exclude`, `"phrases"`, `/regex/`), same result shape. A
|
|
210
212
|
// query that works in one surface works in the other, because it is the same
|
|
211
213
|
// function.
|
|
212
214
|
export function searchRepo(repo, query, { limit = 12 } = {}) {
|
|
213
|
-
|
|
215
|
+
return searchDocuments(repo.searchIndex, query, { limit });
|
|
214
216
|
}
|
|
215
|
-
|
|
216
217
|
// A number a person typed, or nothing. `show f 1.5 2.5` used to print
|
|
217
218
|
// `1.5–3 of 344`: `Number('1.5')` passed the `|| 1` fallback, the label
|
|
218
219
|
// interpolated the fraction, and only `slice()` coerced it. A line range is
|
|
219
220
|
// either a whole number of lines or it is a mistake, and a mistake gets a
|
|
220
221
|
// message rather than a wrong heading.
|
|
221
222
|
export function lineNumber(value, fallback) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
if (value === undefined || value === null || value === '')
|
|
224
|
+
return fallback;
|
|
225
|
+
const n = Number(value);
|
|
226
|
+
return Number.isInteger(n) && n > 0 ? n : null;
|
|
225
227
|
}
|
|
226
|
-
|
|
227
228
|
export function explainRepoFile(repo, file) {
|
|
228
|
-
|
|
229
|
+
return explainFile(file.path, file, repo.facts);
|
|
229
230
|
}
|
|
230
|
-
|
|
231
231
|
export function explainRepoFolder(repo, folder) {
|
|
232
|
-
|
|
232
|
+
return explainFolder(folder.path, repo.scan, repo.facts);
|
|
233
233
|
}
|
|
234
|
-
|
|
235
234
|
export function explainRepoOverview(repo) {
|
|
236
|
-
|
|
235
|
+
return explainOverview(repo.scan, repo.facts, repo.manifest);
|
|
237
236
|
}
|
|
238
|
-
|
|
239
237
|
// Short facts about a file, in the order `docs.js` states them, so the terminal
|
|
240
238
|
// and the generated docs never describe the same file differently.
|
|
241
239
|
export function fileFacts(repo, file) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
240
|
+
return {
|
|
241
|
+
role: roleOf(file.path, repo.facts),
|
|
242
|
+
loc: file.loc || 0,
|
|
243
|
+
complexity: file.complexity || 0,
|
|
244
|
+
fanIn: repo.facts.fanIn[file.path] || 0,
|
|
245
|
+
fanOut: repo.facts.fanOut[file.path] || 0,
|
|
246
|
+
inCycle: (repo.facts.inCycle || []).includes(file.path),
|
|
247
|
+
findings: (file.findings || []).length,
|
|
248
|
+
};
|
|
251
249
|
}
|
|
250
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/cli/explorer/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAA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CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QACzC,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;QACvD,QAAQ,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM;KACvC,CAAC;AACJ,CAAC","sourcesContent":["import type { ScanOptions } from '../../shared/contracts.js';\nimport { throwIfAborted } from '../../shared/analyzer/scanControl.js';\n// One repository, loaded into memory, the way the website loads it.\n//\n// This is the whole reason the terminal app can stand in for the site: it runs\n// the *same* modules in the *same* order as `server/apiScan.js` — FileSource →\n// scanRepo → detectManifest → computeFacts → buildSearchIndex — and then the\n// same projections the browser's views are projections of (health, layers,\n// patterns, security, stack, tour). Nothing here re-implements analysis, so the\n// two surfaces cannot drift into telling different stories about one repo.\n//\n// Everything below the loader is pure data plus a few lookups. The loader is\n// the only async part, and it is the only part that touches the filesystem.\n\nimport { promises as fs } from 'node:fs';\nimport path from 'node:path';\n\nimport { nodeFileSource } from '../../server/fileSourceNode.js';\nimport { buildSearchIndex } from '../../server/searchIndex.js';\nimport { searchDocuments } from '../../server/apiSearch.js';\nimport { expandHome, resolveInside } from '../../server/paths.js';\nimport { assertGitUrl, cloneRepo, removeClone, repoNameFromUrl } from '../../server/gitClone.js';\nimport { gitRemoteOrigin } from '../../server/gitRemote.js';\nimport { scanRepo } from '../../shared/analyzer/scan.js';\nimport { detectManifest } from '../../shared/analyzer/services.js';\nimport { computeFacts, roleOf } from '../../shared/analyzer/graph.js';\nimport { analyzeHealth } from '../../shared/analyzer/health.js';\nimport { computeLayers, detectPatterns, couplingMatrix } from '../../shared/analyzer/patterns.js';\nimport { summarizeSecurity } from '../../shared/analyzer/security.js';\nimport { analyzeStack } from '../../shared/analyzer/stack.js';\nimport { buildTourStops } from '../../shared/analyzer/tour.js';\nimport { explainFile, explainFolder, explainOverview } from '../../shared/analyzer/explainLocal.js';\nimport { languageLabel } from '../../shared/analyzer/languages/index.js';\n\n// Does this argument name a repository to fetch, rather than a folder on this\n// machine? The check is deliberately narrow: only the URL shapes git itself\n// accepts, so a folder that happens to be called `ssh://stuff` cannot exist on a\n// filesystem anyway, while `owner/repo` is NOT accepted — too many real folders\n// are named like that (`src/server`, `app/models`) and silently cloning\n// `github.com/src/server` because someone typed `cd src/server` would be a\n// genuinely bad failure. The shorthand, if it is wanted, has to be asked for.\nexport function isGitUrl(target) {\n return /^(https?:\\/\\/|git@|ssh:\\/\\/)/.test(String(target || '').trim());\n}\n\n// Open a local folder or clone a remote one — the same three ways in the web\n// app's landing page offers, narrowed to the two that make sense for a command\n// line. A clone is left in place when the session ends; `closeRemote` removes it,\n// and the session calls that on `cd` and on exit, so nothing is orphaned in the\n// temp dir.\nexport async function openRepoOrClone(target: string, options: ScanOptions = {}) {\n throwIfAborted(options.signal);\n const onProgress = options.onProgress;\n const raw = String(target || '').trim();\n if (!isGitUrl(raw)) return openRepo(raw, options);\n\n const url = assertGitUrl(raw);\n if (onProgress) onProgress({ phase: 'clone', url });\n const clone = await cloneRepo(url);\n try {\n const repo = await openRepo(clone.dir, options);\n // The repo's own name is what a person recognizes; the temp path is kept so\n // `about` can still print a path someone could go and look at.\n return {\n ...repo,\n name: repoNameFromUrl(url) || repo.name,\n gitUrl: url,\n tempId: path.basename(clone.dir),\n cloneDir: clone.dir,\n };\n } catch (err) {\n // A clone that was never loaded has no session to clean it up later, so it\n // has to go now or it is a temp directory nobody owns.\n await removeClone(clone.dir);\n throw err;\n }\n}\n\n// The URL this repo should be asked about on GitHub, or null.\n//\n// A repo this session cloned knows its own URL. A repo someone was standing in\n// does not, and git does. Asking git here rather than in the `github` command\n// keeps the answer on the repo object, so every consumer gets it the same way.\nexport async function remoteUrlFor(repo) {\n if (repo.gitUrl) return repo.gitUrl;\n if (repo.remoteChecked) return null;\n repo.remoteChecked = true;\n const found = await gitRemoteOrigin(repo.root);\n if (found.ok) repo.gitUrl = found.url;\n return repo.gitUrl || null;\n}\n\n// Drop a temp clone, if this repo is one. Safe to call on a local repo: it\n// checks the shape of the directory rather than trusting a flag, so a bug\n// elsewhere cannot turn \"clean up\" into \"delete the folder the user is in\".\nexport async function closeRemote(repo) {\n if (repo?.cloneDir) await removeClone(repo.cloneDir);\n}\n\n// Scan a directory and return the loaded repo, or throw an Error whose message\n// is safe to print straight to the user. `target` may be `~`, a relative path,\n// or anything `expandHome` understands; it defaults to the current directory.\nexport async function openRepo(target: string = '.', options: ScanOptions = {}) {\n const root = expandHome(String(target || '.'));\n const stat = await fs.stat(root).catch(() => null);\n if (!stat) throw new Error('No such folder: ' + root);\n if (!stat.isDirectory()) throw new Error('Not a folder: ' + root);\n\n const source = nodeFileSource(root);\n const scan = await scanRepo(source, options);\n const manifest = await detectManifest(source);\n const facts = computeFacts(scan, manifest);\n const searchIndex = await buildSearchIndex(source, scan.files.map((f) => f.path));\n\n // The layers projection is an input to patterns, not a parallel view of the\n // same thing — `detectPatterns` reads the layer depths to place a file in the\n // architecture. Compute once, share. The coupling matrix is the same kind of\n // thing: a projection of `facts.folderEdges` that both the site and the\n // terminal's heat grid read, so it is computed once here rather than per view.\n const layers = computeLayers(scan, facts);\n\n const loaded = {\n root,\n name: scan.name || path.basename(root),\n scan,\n facts,\n manifest,\n searchIndex,\n layers,\n coupling: couplingMatrix(scan, facts),\n health: analyzeHealth(scan, facts),\n patterns: detectPatterns(scan, facts, manifest, layers),\n security: summarizeSecurity(scan),\n stack: analyzeStack(manifest, scan.stats.languages || {}),\n tour: buildTourStops(scan, facts),\n languages: languageRows(scan),\n };\n return loaded as typeof loaded & { gitUrl?: string; cloneDir?: string; tempId?: string };\n}\n\n// LOC per language, biggest first, with the display label the site uses — so\n// `JavaScript` here and `JavaScript` there are the same string.\nfunction languageRows(scan) {\n return Object.entries(scan.stats.languages || {})\n .map(([id, loc]) => ({ id, loc, label: languageLabel(id) }))\n .sort((a, b) => Number(b.loc) - Number(a.loc) || a.label.localeCompare(b.label));\n}\n\n// The one place a typed path becomes a real file. People type `logger.js`, not\n// `server/logger.js`, and a tool that says \"no such file\" for a file that is\n// right there is worse than no tool. So: exact, then folder, then suffix, then\n// basename, then a substring. Ambiguity is reported with the candidates rather\n// than guessed at — silently picking the wrong `index.js` is the failure mode\n// that makes people stop trusting a map.\nexport function resolveTarget(repo, typed) {\n const raw = String(typed || '').trim().replace(/^\\.\\//, '');\n if (!raw) return { error: 'Name a file or folder.' };\n\n // `.` and `./` are the root, which is a real folder and a common thing to type\n // (`tree .`, `explain .`). Without this they fell through to the substring\n // match and offered eight unrelated files as \"did you mean\", which is worse\n // than useless — it is actively misleading. The root folder's path is `''`.\n if (raw === '.' || raw === './') return { folder: ROOT_FOLDER };\n\n const files = repo.scan.files;\n if (!repo.byPath) repo.byPath = new Map(files.map((f) => [f.path, f]));\n if (repo.byPath.has(raw)) return { file: repo.byPath.get(raw) };\n\n const folder = folderFor(repo, raw);\n if (folder) return { folder };\n\n const lower = raw.toLowerCase();\n const suffix = files.filter((f) => f.path.endsWith('/' + raw));\n if (suffix.length === 1) return { file: suffix[0] };\n if (suffix.length > 1) return { error: 'Which one?', candidates: suffix.map((f) => f.path) };\n\n const base = files.filter((f) => f.name.toLowerCase() === lower);\n if (base.length === 1) return { file: base[0] };\n if (base.length > 1) return { error: 'Which one?', candidates: base.map((f) => f.path) };\n\n const loose = files.filter((f) => f.path.toLowerCase().includes(lower));\n if (loose.length) {\n loose.sort((a, b) => a.path.length - b.path.length);\n return { error: 'No exact match. Did you mean:', candidates: loose.slice(0, 8).map((f) => f.path) };\n }\n return { error: 'Nothing in this repo matches \"' + raw + '\".' };\n}\n\n// The root folder is a real answer, not a sentinel: `tree .` and `explain .`\n// both need one, and it carries the same fields `resolveTarget` returns for any\n// other folder so the callers need no special case.\nconst ROOT_FOLDER = Object.freeze({ name: '', path: '', loc: 0, comment: 0, blank: 0, size: 0, langs: {} });\n\nfunction folderFor(repo, typed) {\n const clean = typed.replace(/\\/+$/, '');\n if (clean === '') return ROOT_FOLDER;\n const exact = repo.scan.folders.find((d) => d.path === clean);\n if (exact) return exact;\n const matches = repo.scan.folders.filter((d) => d.path.endsWith('/' + clean) || d.name === clean);\n return matches.length === 1 ? matches[0] : null;\n}\n\n// Read a file through the same containment check the HTTP route uses. A tool\n// whose job is showing you one repository has no business reading any path on\n// the machine, and going through `resolveInside` means there is no second,\n// looser door to get there.\nexport async function readRepoFile(repo, repoPath) {\n const abs = resolveInside(repo.root, repoPath);\n if (!abs) throw new Error('That path is outside the repository.');\n return fs.readFile(abs, 'utf8');\n}\n\n// The website's search, verbatim: same TF-IDF ranking, same query language\n// (`ext:`, `path:`, `-exclude`, `\"phrases\"`, `/regex/`), same result shape. A\n// query that works in one surface works in the other, because it is the same\n// function.\nexport function searchRepo(repo, query, { limit = 12 }: Record<string, any> = {}) {\n return searchDocuments(repo.searchIndex, query, { limit });\n}\n\n// A number a person typed, or nothing. `show f 1.5 2.5` used to print\n// `1.5–3 of 344`: `Number('1.5')` passed the `|| 1` fallback, the label\n// interpolated the fraction, and only `slice()` coerced it. A line range is\n// either a whole number of lines or it is a mistake, and a mistake gets a\n// message rather than a wrong heading.\nexport function lineNumber(value, fallback) {\n if (value === undefined || value === null || value === '') return fallback;\n const n = Number(value);\n return Number.isInteger(n) && n > 0 ? n : null;\n}\n\nexport function explainRepoFile(repo, file) {\n return explainFile(file.path, file, repo.facts);\n}\n\nexport function explainRepoFolder(repo, folder) {\n return explainFolder(folder.path, repo.scan, repo.facts);\n}\n\nexport function explainRepoOverview(repo) {\n return explainOverview(repo.scan, repo.facts, repo.manifest);\n}\n\n// Short facts about a file, in the order `docs.js` states them, so the terminal\n// and the generated docs never describe the same file differently.\nexport function fileFacts(repo, file) {\n return {\n role: roleOf(file.path, repo.facts),\n loc: file.loc || 0,\n complexity: file.complexity || 0,\n fanIn: repo.facts.fanIn[file.path] || 0,\n fanOut: repo.facts.fanOut[file.path] || 0,\n inCycle: (repo.facts.inCycle || []).includes(file.path),\n findings: (file.findings || []).length,\n };\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function overview(repo: any): string;
|
|
2
|
+
export declare function tree(repo: any, { sub, depth, limit }?: Record<string, any>): string;
|
|
3
|
+
export declare function find(repo: any, { query, limit }?: Record<string, any>): string;
|
|
4
|
+
export declare function show(repo: any, { target, from, count }?: Record<string, any>): Promise<string>;
|
|
5
|
+
export declare function targetError(found: any): string;
|
|
6
|
+
export declare function deps(repo: any, { target, limit }?: Record<string, any>): string;
|
|
7
|
+
export declare function explain(repo: any, { target }?: Record<string, any>): string;
|
|
8
|
+
export declare function tour(repo: any): string;
|
|
9
|
+
export declare function health(repo: any): string;
|
|
10
|
+
export declare function hubs(repo: any, { limit }?: Record<string, any>): string;
|
|
11
|
+
export declare function layers(repo: any, { limit }?: Record<string, any>): string;
|
|
12
|
+
export declare function patterns(repo: any): string;
|
|
13
|
+
export declare function stats(repo: any, { limit }?: Record<string, any>): string;
|
|
14
|
+
export declare function security(repo: any, { limit }?: Record<string, any>): string;
|
|
15
|
+
export declare function stack(repo: any, { limit }?: Record<string, any>): string;
|
|
16
|
+
export declare function entry(repo: any): string;
|
|
17
|
+
export declare function externals(repo: any): string;
|
|
18
|
+
export declare function about(repo: any, version?: string): string;
|
|
19
|
+
export declare function github(repo: any, result: any): string;
|