codebase-onboarder 0.5.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.
Files changed (448) hide show
  1. package/README.md +196 -47
  2. package/bin/build-if-source.js +23 -0
  3. package/cli/commands.d.ts +26 -0
  4. package/cli/commands.js +836 -811
  5. package/cli/commands.js.map +1 -0
  6. package/cli/explorer/advanced.d.ts +14 -0
  7. package/cli/explorer/advanced.js +449 -0
  8. package/cli/explorer/advanced.js.map +1 -0
  9. package/cli/explorer/app.d.ts +1 -0
  10. package/cli/explorer/app.js +396 -229
  11. package/cli/explorer/app.js.map +1 -0
  12. package/cli/explorer/assistant.d.ts +9 -0
  13. package/cli/explorer/assistant.js +58 -0
  14. package/cli/explorer/assistant.js.map +1 -0
  15. package/cli/explorer/commands.d.ts +17 -0
  16. package/cli/explorer/commands.js +400 -162
  17. package/cli/explorer/commands.js.map +1 -0
  18. package/cli/explorer/featureViews.d.ts +124 -0
  19. package/cli/explorer/featureViews.js +179 -0
  20. package/cli/explorer/featureViews.js.map +1 -0
  21. package/cli/explorer/github.d.ts +21 -0
  22. package/cli/explorer/github.js +73 -0
  23. package/cli/explorer/github.js.map +1 -0
  24. package/cli/explorer/graphs.d.ts +7 -0
  25. package/cli/explorer/graphs.js +173 -0
  26. package/cli/explorer/graphs.js.map +1 -0
  27. package/cli/explorer/picker.d.ts +22 -0
  28. package/cli/explorer/picker.js +150 -0
  29. package/cli/explorer/picker.js.map +1 -0
  30. package/cli/explorer/report.d.ts +85 -0
  31. package/cli/explorer/report.js +60 -0
  32. package/cli/explorer/report.js.map +1 -0
  33. package/cli/explorer/session.d.ts +449 -0
  34. package/cli/explorer/session.js +184 -95
  35. package/cli/explorer/session.js.map +1 -0
  36. package/cli/explorer/views.d.ts +19 -0
  37. package/cli/explorer/views.js +496 -412
  38. package/cli/explorer/views.js.map +1 -0
  39. package/cli/explorer/wrap.d.ts +1 -0
  40. package/cli/explorer/wrap.js +33 -0
  41. package/cli/explorer/wrap.js.map +1 -0
  42. package/cli/main.d.ts +1 -0
  43. package/cli/main.js +235 -138
  44. package/cli/main.js.map +1 -0
  45. package/cli/prompt.d.ts +5 -0
  46. package/cli/prompt.js +84 -80
  47. package/cli/prompt.js.map +1 -0
  48. package/cli/scanOptions.d.ts +2 -0
  49. package/cli/scanOptions.js +11 -0
  50. package/cli/scanOptions.js.map +1 -0
  51. package/cli/ui.d.ts +33 -0
  52. package/cli/ui.js +55 -35
  53. package/cli/ui.js.map +1 -0
  54. package/cli/wizard.d.ts +187 -0
  55. package/cli/wizard.js +304 -284
  56. package/cli/wizard.js.map +1 -0
  57. package/package.json +15 -4
  58. package/public/app.d.ts +1 -0
  59. package/public/app.js +1057 -1009
  60. package/public/app.js.map +1 -0
  61. package/public/browser.d.ts +68 -0
  62. package/public/browser.js +2 -0
  63. package/public/browser.js.map +1 -0
  64. package/public/index.html +30 -13
  65. package/public/js/about.d.ts +6 -0
  66. package/public/js/about.js +165 -172
  67. package/public/js/about.js.map +1 -0
  68. package/public/js/aiDraft.d.ts +3 -0
  69. package/public/js/aiDraft.js +116 -124
  70. package/public/js/aiDraft.js.map +1 -0
  71. package/public/js/analysisPanel.d.ts +7 -0
  72. package/public/js/analysisPanel.js +166 -166
  73. package/public/js/analysisPanel.js.map +1 -0
  74. package/public/js/analysisReport.d.ts +38 -0
  75. package/public/js/analysisReport.js +105 -110
  76. package/public/js/analysisReport.js.map +1 -0
  77. package/public/js/api.d.ts +26 -0
  78. package/public/js/api.js +176 -167
  79. package/public/js/api.js.map +1 -0
  80. package/public/js/atlas.d.ts +6 -0
  81. package/public/js/atlas.js +50 -58
  82. package/public/js/atlas.js.map +1 -0
  83. package/public/js/blameView.d.ts +2 -0
  84. package/public/js/blameView.js +36 -37
  85. package/public/js/blameView.js.map +1 -0
  86. package/public/js/codeTab.d.ts +3 -0
  87. package/public/js/codeTab.js +175 -180
  88. package/public/js/codeTab.js.map +1 -0
  89. package/public/js/codeViewer.d.ts +5 -0
  90. package/public/js/codeViewer.js +162 -150
  91. package/public/js/codeViewer.js.map +1 -0
  92. package/public/js/components/FileChip.d.ts +9 -0
  93. package/public/js/components/FileChip.js +45 -49
  94. package/public/js/components/FileChip.js.map +1 -0
  95. package/public/js/components/MetricSparkline.d.ts +7 -0
  96. package/public/js/components/MetricSparkline.js +35 -44
  97. package/public/js/components/MetricSparkline.js.map +1 -0
  98. package/public/js/components/RiskBadge.d.ts +9 -0
  99. package/public/js/components/RiskBadge.js +55 -63
  100. package/public/js/components/RiskBadge.js.map +1 -0
  101. package/public/js/deepAnalysisView.d.ts +99 -0
  102. package/public/js/deepAnalysisView.js +282 -302
  103. package/public/js/deepAnalysisView.js.map +1 -0
  104. package/public/js/diagramPane.d.ts +8 -0
  105. package/public/js/diagramPane.js +133 -135
  106. package/public/js/diagramPane.js.map +1 -0
  107. package/public/js/diffView.d.ts +6 -0
  108. package/public/js/diffView.js +222 -209
  109. package/public/js/diffView.js.map +1 -0
  110. package/public/js/docsView.d.ts +2 -0
  111. package/public/js/docsView.js +441 -442
  112. package/public/js/docsView.js.map +1 -0
  113. package/public/js/dom.d.ts +189 -0
  114. package/public/js/dom.js +5 -0
  115. package/public/js/dom.js.map +1 -0
  116. package/public/js/fileSourceBrowser.d.ts +5 -0
  117. package/public/js/fileSourceBrowser.js +33 -41
  118. package/public/js/fileSourceBrowser.js.map +1 -0
  119. package/public/js/flameGraph.d.ts +5 -0
  120. package/public/js/flameGraph.js +62 -72
  121. package/public/js/flameGraph.js.map +1 -0
  122. package/public/js/forceGraph.d.ts +10 -0
  123. package/public/js/forceGraph.js +581 -556
  124. package/public/js/forceGraph.js.map +1 -0
  125. package/public/js/heatmap.d.ts +4 -0
  126. package/public/js/heatmap.js +142 -164
  127. package/public/js/heatmap.js.map +1 -0
  128. package/public/js/highlight.d.ts +2 -0
  129. package/public/js/highlight.js +116 -107
  130. package/public/js/highlight.js.map +1 -0
  131. package/public/js/html.d.ts +2 -0
  132. package/public/js/html.js +14 -44
  133. package/public/js/html.js.map +1 -0
  134. package/public/js/insightsView.d.ts +5 -0
  135. package/public/js/insightsView.js +93 -111
  136. package/public/js/insightsView.js.map +1 -0
  137. package/public/js/inspector.d.ts +37 -0
  138. package/public/js/inspector.js +416 -445
  139. package/public/js/inspector.js.map +1 -0
  140. package/public/js/llm.d.ts +113 -0
  141. package/public/js/llm.js +233 -272
  142. package/public/js/llm.js.map +1 -0
  143. package/public/js/mapView.d.ts +3 -0
  144. package/public/js/mapView.js +121 -120
  145. package/public/js/mapView.js.map +1 -0
  146. package/public/js/markdown.d.ts +3 -0
  147. package/public/js/markdown.js +84 -91
  148. package/public/js/markdown.js.map +1 -0
  149. package/public/js/mindmap.d.ts +32 -0
  150. package/public/js/mindmap.js +244 -259
  151. package/public/js/mindmap.js.map +1 -0
  152. package/public/js/mobilePanels.d.ts +5 -0
  153. package/public/js/mobilePanels.js +50 -0
  154. package/public/js/mobilePanels.js.map +1 -0
  155. package/public/js/repoFiles.d.ts +12 -0
  156. package/public/js/repoFiles.js +28 -27
  157. package/public/js/repoFiles.js.map +1 -0
  158. package/public/js/reviewView.d.ts +28 -0
  159. package/public/js/reviewView.js +256 -0
  160. package/public/js/reviewView.js.map +1 -0
  161. package/public/js/sbomView.d.ts +3 -0
  162. package/public/js/sbomView.js +59 -67
  163. package/public/js/sbomView.js.map +1 -0
  164. package/public/js/scanCache.d.ts +16 -0
  165. package/public/js/scanCache.js +67 -65
  166. package/public/js/scanCache.js.map +1 -0
  167. package/public/js/search.d.ts +7 -0
  168. package/public/js/search.js +868 -800
  169. package/public/js/search.js.map +1 -0
  170. package/public/js/searchLocal.d.ts +42 -0
  171. package/public/js/searchLocal.js +87 -0
  172. package/public/js/searchLocal.js.map +1 -0
  173. package/public/js/serverSettings.d.ts +5 -0
  174. package/public/js/serverSettings.js +153 -164
  175. package/public/js/serverSettings.js.map +1 -0
  176. package/public/js/state.d.ts +798 -0
  177. package/public/js/state.js +114 -122
  178. package/public/js/state.js.map +1 -0
  179. package/public/js/tour.d.ts +6 -0
  180. package/public/js/tour.js +5 -7
  181. package/public/js/tour.js.map +1 -0
  182. package/public/js/transitions.d.ts +2 -0
  183. package/public/js/transitions.js +9 -10
  184. package/public/js/transitions.js.map +1 -0
  185. package/public/js/tree.d.ts +12 -0
  186. package/public/js/tree.js +157 -154
  187. package/public/js/tree.js.map +1 -0
  188. package/public/js/workflowsView.d.ts +3 -0
  189. package/public/js/workflowsView.js +15 -22
  190. package/public/js/workflowsView.js.map +1 -0
  191. package/public/search.css +495 -0
  192. package/public/styles.css +163 -346
  193. package/public/workbench.css +166 -0
  194. package/server/apiAuth.d.ts +3 -0
  195. package/server/apiAuth.js +18 -20
  196. package/server/apiAuth.js.map +1 -0
  197. package/server/apiDiff.d.ts +2 -0
  198. package/server/apiDiff.js +20 -18
  199. package/server/apiDiff.js.map +1 -0
  200. package/server/apiDocs.d.ts +2 -0
  201. package/server/apiDocs.js +38 -40
  202. package/server/apiDocs.js.map +1 -0
  203. package/server/apiFile.d.ts +1 -0
  204. package/server/apiFile.js +14 -17
  205. package/server/apiFile.js.map +1 -0
  206. package/server/apiGitBlame.d.ts +2 -0
  207. package/server/apiGitBlame.js +50 -51
  208. package/server/apiGitBlame.js.map +1 -0
  209. package/server/apiMcp.d.ts +4 -0
  210. package/server/apiMcp.js +64 -66
  211. package/server/apiMcp.js.map +1 -0
  212. package/server/apiReview.d.ts +2 -0
  213. package/server/apiReview.js +45 -0
  214. package/server/apiReview.js.map +1 -0
  215. package/server/apiScan.d.ts +5 -0
  216. package/server/apiScan.js +90 -71
  217. package/server/apiScan.js.map +1 -0
  218. package/server/apiSearch.d.ts +33 -0
  219. package/server/apiSearch.js +184 -200
  220. package/server/apiSearch.js.map +1 -0
  221. package/server/apiSettings.d.ts +4 -0
  222. package/server/apiSettings.js +84 -85
  223. package/server/apiSettings.js.map +1 -0
  224. package/server/apiTools.d.ts +3 -0
  225. package/server/apiTools.js +55 -56
  226. package/server/apiTools.js.map +1 -0
  227. package/server/auth.d.ts +5 -0
  228. package/server/auth.js +54 -51
  229. package/server/auth.js.map +1 -0
  230. package/server/config.d.ts +42 -0
  231. package/server/config.js +189 -194
  232. package/server/config.js.map +1 -0
  233. package/server/daemon.d.ts +12 -0
  234. package/server/daemon.js +124 -114
  235. package/server/daemon.js.map +1 -0
  236. package/server/fileSourceNode.d.ts +2 -0
  237. package/server/fileSourceNode.js +34 -36
  238. package/server/fileSourceNode.js.map +1 -0
  239. package/server/gitClone.d.ts +9 -0
  240. package/server/gitClone.js +59 -61
  241. package/server/gitClone.js.map +1 -0
  242. package/server/gitDiff.d.ts +36 -0
  243. package/server/gitDiff.js +271 -169
  244. package/server/gitDiff.js.map +1 -0
  245. package/server/gitHistory.d.ts +12 -0
  246. package/server/gitHistory.js +80 -80
  247. package/server/gitHistory.js.map +1 -0
  248. package/server/gitRemote.d.ts +12 -0
  249. package/server/gitRemote.js +60 -0
  250. package/server/gitRemote.js.map +1 -0
  251. package/server/htmlText.d.ts +4 -0
  252. package/server/htmlText.js +16 -23
  253. package/server/htmlText.js.map +1 -0
  254. package/server/http.d.ts +5 -0
  255. package/server/http.js +27 -30
  256. package/server/http.js.map +1 -0
  257. package/server/httpGuards.d.ts +2 -0
  258. package/server/httpGuards.js +47 -43
  259. package/server/httpGuards.js.map +1 -0
  260. package/server/https.d.ts +34 -0
  261. package/server/https.js +121 -111
  262. package/server/https.js.map +1 -0
  263. package/server/index.d.ts +40 -0
  264. package/server/index.js +139 -147
  265. package/server/index.js.map +1 -0
  266. package/server/layout.d.ts +26 -0
  267. package/server/layout.js +59 -37
  268. package/server/layout.js.map +1 -0
  269. package/server/llmProxy.d.ts +3 -0
  270. package/server/llmProxy.js +137 -135
  271. package/server/llmProxy.js.map +1 -0
  272. package/server/logger.d.ts +38 -0
  273. package/server/logger.js +198 -211
  274. package/server/logger.js.map +1 -0
  275. package/server/mcp/analysis.d.ts +29 -0
  276. package/server/mcp/analysis.js +99 -120
  277. package/server/mcp/analysis.js.map +1 -0
  278. package/server/mcp/http.d.ts +9 -0
  279. package/server/mcp/http.js +128 -137
  280. package/server/mcp/http.js.map +1 -0
  281. package/server/mcp/runner.d.ts +68 -0
  282. package/server/mcp/runner.js +208 -218
  283. package/server/mcp/runner.js.map +1 -0
  284. package/server/mcp/server.d.ts +29 -0
  285. package/server/mcp/server.js +166 -179
  286. package/server/mcp/server.js.map +1 -0
  287. package/server/mcp/standalone.d.ts +1 -0
  288. package/server/mcp/standalone.js +8 -10
  289. package/server/mcp/standalone.js.map +1 -0
  290. package/server/mcp/tools.d.ts +2020 -0
  291. package/server/mcp/tools.js +523 -574
  292. package/server/mcp/tools.js.map +1 -0
  293. package/server/paths.d.ts +3 -0
  294. package/server/paths.js +17 -15
  295. package/server/paths.js.map +1 -0
  296. package/server/pidfile.d.ts +9 -0
  297. package/server/pidfile.js +43 -45
  298. package/server/pidfile.js.map +1 -0
  299. package/server/review.d.ts +5 -0
  300. package/server/review.js +35 -0
  301. package/server/review.js.map +1 -0
  302. package/server/router.d.ts +33 -0
  303. package/server/router.js +191 -197
  304. package/server/router.js.map +1 -0
  305. package/server/scanRequest.d.ts +3 -0
  306. package/server/scanRequest.js +36 -0
  307. package/server/scanRequest.js.map +1 -0
  308. package/server/searchIndex.d.ts +17 -0
  309. package/server/searchIndex.js +83 -80
  310. package/server/searchIndex.js.map +1 -0
  311. package/server/sessions.d.ts +14 -0
  312. package/server/sessions.js +62 -70
  313. package/server/sessions.js.map +1 -0
  314. package/server/startup.d.ts +118 -0
  315. package/server/startup.js +143 -148
  316. package/server/startup.js.map +1 -0
  317. package/server/static.d.ts +6 -0
  318. package/server/static.js +28 -31
  319. package/server/static.js.map +1 -0
  320. package/server/tools/install.d.ts +4 -0
  321. package/server/tools/install.js +176 -185
  322. package/server/tools/install.js.map +1 -0
  323. package/server/tools/parse.d.ts +8 -0
  324. package/server/tools/parse.js +112 -114
  325. package/server/tools/parse.js.map +1 -0
  326. package/server/tools/platform.d.ts +9 -0
  327. package/server/tools/platform.js +49 -47
  328. package/server/tools/platform.js.map +1 -0
  329. package/server/tools/registry.d.ts +137 -0
  330. package/server/tools/registry.js +173 -172
  331. package/server/tools/registry.js.map +1 -0
  332. package/server/tools/scan.d.ts +34 -0
  333. package/server/tools/scan.js +89 -98
  334. package/server/tools/scan.js.map +1 -0
  335. package/server/tools.d.ts +34 -0
  336. package/server/tools.js +94 -107
  337. package/server/tools.js.map +1 -0
  338. package/server/tunnel.d.ts +29 -0
  339. package/server/tunnel.js +61 -66
  340. package/server/tunnel.js.map +1 -0
  341. package/shared/analyzer/docs.d.ts +16 -0
  342. package/shared/analyzer/docs.js +99 -93
  343. package/shared/analyzer/docs.js.map +1 -0
  344. package/shared/analyzer/explainLocal.d.ts +4 -0
  345. package/shared/analyzer/explainLocal.js +122 -142
  346. package/shared/analyzer/explainLocal.js.map +1 -0
  347. package/shared/analyzer/github.d.ts +37 -0
  348. package/shared/analyzer/github.js +79 -0
  349. package/shared/analyzer/github.js.map +1 -0
  350. package/shared/analyzer/graph.d.ts +41 -0
  351. package/shared/analyzer/graph.js +393 -400
  352. package/shared/analyzer/graph.js.map +1 -0
  353. package/shared/analyzer/health.d.ts +33 -0
  354. package/shared/analyzer/health.js +197 -193
  355. package/shared/analyzer/health.js.map +1 -0
  356. package/shared/analyzer/history.d.ts +29 -0
  357. package/shared/analyzer/history.js +110 -111
  358. package/shared/analyzer/history.js.map +1 -0
  359. package/shared/analyzer/jsonConfig.d.ts +2 -0
  360. package/shared/analyzer/jsonConfig.js +61 -0
  361. package/shared/analyzer/jsonConfig.js.map +1 -0
  362. package/shared/analyzer/languages/csharp.d.ts +26 -0
  363. package/shared/analyzer/languages/csharp.js +83 -88
  364. package/shared/analyzer/languages/csharp.js.map +1 -0
  365. package/shared/analyzer/languages/generic.d.ts +23 -0
  366. package/shared/analyzer/languages/generic.js +94 -105
  367. package/shared/analyzer/languages/generic.js.map +1 -0
  368. package/shared/analyzer/languages/go.d.ts +24 -0
  369. package/shared/analyzer/languages/go.js +45 -54
  370. package/shared/analyzer/languages/go.js.map +1 -0
  371. package/shared/analyzer/languages/index.d.ts +6 -0
  372. package/shared/analyzer/languages/index.js +19 -20
  373. package/shared/analyzer/languages/index.js.map +1 -0
  374. package/shared/analyzer/languages/java.d.ts +20 -0
  375. package/shared/analyzer/languages/java.js +73 -78
  376. package/shared/analyzer/languages/java.js.map +1 -0
  377. package/shared/analyzer/languages/javascript.d.ts +12 -0
  378. package/shared/analyzer/languages/javascript.js +258 -209
  379. package/shared/analyzer/languages/javascript.js.map +1 -0
  380. package/shared/analyzer/languages/python.d.ts +23 -0
  381. package/shared/analyzer/languages/python.js +92 -100
  382. package/shared/analyzer/languages/python.js.map +1 -0
  383. package/shared/analyzer/languages/rust.d.ts +17 -0
  384. package/shared/analyzer/languages/rust.js +96 -98
  385. package/shared/analyzer/languages/rust.js.map +1 -0
  386. package/shared/analyzer/languages/typescript.d.ts +11 -0
  387. package/shared/analyzer/languages/typescript.js +117 -116
  388. package/shared/analyzer/languages/typescript.js.map +1 -0
  389. package/shared/analyzer/licenses.d.ts +18 -0
  390. package/shared/analyzer/licenses.js +130 -133
  391. package/shared/analyzer/licenses.js.map +1 -0
  392. package/shared/analyzer/metrics.d.ts +20 -0
  393. package/shared/analyzer/metrics.js +112 -104
  394. package/shared/analyzer/metrics.js.map +1 -0
  395. package/shared/analyzer/pathUtil.d.ts +10 -0
  396. package/shared/analyzer/pathUtil.js +29 -35
  397. package/shared/analyzer/pathUtil.js.map +1 -0
  398. package/shared/analyzer/patterns.d.ts +11 -0
  399. package/shared/analyzer/patterns.js +231 -253
  400. package/shared/analyzer/patterns.js.map +1 -0
  401. package/shared/analyzer/scan.d.ts +62 -0
  402. package/shared/analyzer/scan.js +451 -442
  403. package/shared/analyzer/scan.js.map +1 -0
  404. package/shared/analyzer/scanControl.d.ts +11 -0
  405. package/shared/analyzer/scanControl.js +62 -0
  406. package/shared/analyzer/scanControl.js.map +1 -0
  407. package/shared/analyzer/security.d.ts +18 -0
  408. package/shared/analyzer/security.js +159 -159
  409. package/shared/analyzer/security.js.map +1 -0
  410. package/shared/analyzer/services.d.ts +5 -0
  411. package/shared/analyzer/services.js +141 -138
  412. package/shared/analyzer/services.js.map +1 -0
  413. package/shared/analyzer/stack.d.ts +6 -0
  414. package/shared/analyzer/stack.js +134 -141
  415. package/shared/analyzer/stack.js.map +1 -0
  416. package/shared/analyzer/tour.d.ts +2 -0
  417. package/shared/analyzer/tour.js +45 -53
  418. package/shared/analyzer/tour.js.map +1 -0
  419. package/shared/analyzer/util.d.ts +8 -0
  420. package/shared/analyzer/util.js +130 -76
  421. package/shared/analyzer/util.js.map +1 -0
  422. package/shared/analyzer/workflows.d.ts +8 -0
  423. package/shared/analyzer/workflows.js +139 -134
  424. package/shared/analyzer/workflows.js.map +1 -0
  425. package/shared/contracts.d.ts +250 -0
  426. package/shared/contracts.js +2 -0
  427. package/shared/contracts.js.map +1 -0
  428. package/shared/diagram/aiFacts.d.ts +35 -0
  429. package/shared/diagram/aiFacts.js +102 -105
  430. package/shared/diagram/aiFacts.js.map +1 -0
  431. package/shared/diagram/aiMermaid.d.ts +5 -0
  432. package/shared/diagram/aiMermaid.js +46 -45
  433. package/shared/diagram/aiMermaid.js.map +1 -0
  434. package/shared/diagram/atlas.d.ts +16 -0
  435. package/shared/diagram/atlas.js +51 -60
  436. package/shared/diagram/atlas.js.map +1 -0
  437. package/shared/diagram/mermaid.d.ts +43 -0
  438. package/shared/diagram/mermaid.js +348 -370
  439. package/shared/diagram/mermaid.js.map +1 -0
  440. package/shared/review/contracts.d.ts +95 -0
  441. package/shared/review/contracts.js +2 -0
  442. package/shared/review/contracts.js.map +1 -0
  443. package/shared/review/review.d.ts +10 -0
  444. package/shared/review/review.js +184 -0
  445. package/shared/review/review.js.map +1 -0
  446. package/shared/search/query.d.ts +32 -0
  447. package/shared/search/query.js +395 -388
  448. package/shared/search/query.js.map +1 -0
@@ -0,0 +1,449 @@
1
+ // The advanced views: the parts of the site that had no terminal equivalent.
2
+ //
3
+ // Everything here is a *projection* of data the engine already computed or of
4
+ // git the repo already contains. Nothing re-implements analysis. Where the web
5
+ // draws a canvas (a heat grid, a force graph) the terminal draws block
6
+ // characters and an arrow tree from the same numbers, because those are the
7
+ // terminal's own idioms — not degraded versions of the web views.
8
+ import fs from 'node:fs/promises';
9
+ import path from 'node:path';
10
+ import { execFile } from 'node:child_process';
11
+ import { promisify } from 'node:util';
12
+ import { bold, cyan, dim, ok, warn, bad, panel, row, fit, termWidth } from '../ui.js';
13
+ import { bar, columns, couplingGrid, depTree, labelled, step } from './graphs.js';
14
+ import { fileFacts, resolveTarget } from './session.js';
15
+ import { targetError } from './views.js';
16
+ import { wrapText } from './wrap.js';
17
+ import { gitLog, parseGitLog } from '../../server/gitHistory.js';
18
+ import { analyzeHistory, unavailableHistory } from '../../shared/analyzer/history.js';
19
+ import { parsePorcelainBlame } from '../../server/apiGitBlame.js';
20
+ import { couplingMatrix } from '../../shared/analyzer/patterns.js';
21
+ import { overviewDiagram, layersDiagram, fileDetailDiagram } from '../../shared/diagram/mermaid.js';
22
+ import { fileStaticDoc, folderStaticDoc } from '../../shared/analyzer/docs.js';
23
+ const run = promisify(execFile);
24
+ const MAX = 200;
25
+ // Git history is loaded lazily and cached on the repo object. It shells out, and
26
+ // a person who never types `log` or `blame` should not pay for it — and on a
27
+ // large repo that is the difference between an instant prompt and a visible
28
+ // pause. A failure is cached too, so a missing `git` binary costs one failed
29
+ // call rather than one per keystroke.
30
+ export async function loadHistory(repo, { force = false } = {}) {
31
+ if (!force && repo._history !== undefined)
32
+ return repo._history;
33
+ try {
34
+ const log = await gitLog(repo.root);
35
+ if (!log.ok) {
36
+ repo._history = unavailableHistory(log.reason);
37
+ return repo._history;
38
+ }
39
+ repo._history = analyzeHistory(repo.scan, parseGitLog(log.text), { totalCommits: log.totalCommits });
40
+ }
41
+ catch (e) {
42
+ repo._history = unavailableHistory('The git history could not be read — the scan itself is unaffected.');
43
+ }
44
+ return repo._history;
45
+ }
46
+ // ------------------------------------------------------------------- log ---
47
+ // Recent commits, and the people who wrote them. The site shows this in a
48
+ // history tab; the terminal answer is a compact list, because the question this
49
+ // answers — "who is working on this, and what did they touch lately" — is one
50
+ // glance, not a browsing session.
51
+ export async function log(repo, { limit = 15 } = {}) {
52
+ const h = await loadHistory(repo);
53
+ if (!h.available)
54
+ return dim(wrapText('No git history: ' + h.reason));
55
+ const w = termWidth();
56
+ const out = [panel('git history', [
57
+ { label: 'commits', value: `${h.commitCount} analyzed` + (h.truncated ? dim(` (of ${h.totalCommits} — log capped)`) : '') },
58
+ { label: 'authors', value: h.authors.slice(0, 4).map((a) => `${a.name} (${a.commits})`).join(', ') || '—' },
59
+ { label: 'window', value: `${String(h.firstCommitAt || '').slice(0, 10)} → ${String(h.lastCommitAt || '').slice(0, 10)}` },
60
+ ])];
61
+ out.push(dim(fit(' recent commits', Math.max(4, termWidth() - 2))));
62
+ for (const c of h.commits.slice(0, Math.min(Number(limit) || 15, MAX))) {
63
+ // sha / author / date as marker, value, tail, so a narrow terminal drops the
64
+ // date rather than running the row off the edge.
65
+ out.push(labelled(dim(c.hash.slice(0, 8) + ' '), c.author?.name || '?', dim(String(c.date || '').slice(0, 10) + ' ' + (c.files?.length || 0) + 'f'), { pad: 4 }));
66
+ }
67
+ if (h.authors.length) {
68
+ out.push(dim(fit(' commits per author', Math.max(4, termWidth() - 2))));
69
+ const max = Math.max(...h.authors.map((a) => a.commits));
70
+ for (const a of h.authors.slice(0, 8)) {
71
+ const tail = dim(String(a.commits).padStart(4)) + (w > 30 ? ' ' + dim(bar(a.commits, max, Math.max(0, Math.min(18, w - 28)))) : '');
72
+ out.push(labelled('', a.name, tail, { pad: 4 }));
73
+ }
74
+ }
75
+ return out.join('\n');
76
+ }
77
+ const GLYPH_MARK = '●';
78
+ // ---------------------------------------------------------------- blame ---
79
+ // Who wrote each line, and when. `git blame --porcelain` through the same parser
80
+ // the site's blame view uses, so a line's author and date are the same answer in
81
+ // both places. Shown as a histogram of authors per line plus the recent
82
+ // commits, because a per-line listing of a 400-line file is a page of output
83
+ // nobody reads.
84
+ export async function blame(repo, { target = '', limit = 20 } = {}) {
85
+ const found = resolveTarget(repo, target);
86
+ if (found.error)
87
+ return targetError(found);
88
+ if (found.folder)
89
+ return dim(wrapText(`${found.folder.path || '.'} is a folder — blame a file inside it.`, ' '));
90
+ const p = found.file.path;
91
+ let raw;
92
+ try {
93
+ const { stdout } = await run('git', ['-C', repo.root, 'blame', '--line-porcelain', '--', p], { maxBuffer: 32 * 1024 * 1024 });
94
+ raw = stdout;
95
+ }
96
+ catch (e) {
97
+ const why = /not a git repository|Unable to read/.test(String(e.stderr || e.message))
98
+ ? 'This folder is not in a git repository.'
99
+ : 'git blame could not read this file.';
100
+ return dim(wrapText(why));
101
+ }
102
+ const lines = parsePorcelainBlame(raw);
103
+ if (!lines.length)
104
+ return dim(wrapText('No blame information for this file.'));
105
+ const w = termWidth();
106
+ const byAuthor = new Map();
107
+ for (const l of lines)
108
+ byAuthor.set(l.author, (byAuthor.get(l.author) || 0) + 1);
109
+ const authors = [...byAuthor.entries()].sort((a, b) => b[1] - a[1]);
110
+ const recent = [...new Map(lines.map((l) => [l.sha, l])).values()]
111
+ .sort((a, b) => String(b.date).localeCompare(String(a.date)))
112
+ .slice(0, Math.min(Number(limit) || 20, 10));
113
+ const out = [panel(p, [
114
+ { label: 'lines', value: String(lines.length) },
115
+ { label: 'authors', value: String(authors.length) },
116
+ { label: 'oldest', value: lines.map((l) => l.date).filter(Boolean).sort()[0]?.slice(0, 10) || '—' },
117
+ { label: 'newest', value: lines.map((l) => l.date).filter(Boolean).sort().pop()?.slice(0, 10) || '—' },
118
+ ])];
119
+ out.push(dim(fit(' lines per author', Math.max(4, termWidth() - 2))));
120
+ const max = Math.max(...authors.map(([, n]) => n));
121
+ for (const [name, n] of authors) {
122
+ const tail = dim(String(n).padStart(5)) + (w > 34 ? ' ' + dim(bar(n, max, Math.max(0, Math.min(20, w - 30)))) : '');
123
+ out.push(labelled('', name, tail, { pad: 4 }));
124
+ }
125
+ if (recent.length) {
126
+ out.push(dim(fit(' most recent commits touching this file', Math.max(4, termWidth() - 2))));
127
+ for (const c of recent) {
128
+ // Without a separator the author and date ran together into
129
+ // "Amitpandey882026-09-25" — the sha-width fit left no gap.
130
+ out.push(labelled(dim(c.sha.slice(0, 8) + ' '), c.author, dim(String(c.date || '').slice(0, 10)), { pad: 4 }));
131
+ }
132
+ }
133
+ return out.join('\n');
134
+ }
135
+ // ------------------------------------------------------------- coupling ---
136
+ // Folder-to-folder traffic as a heat grid. The site draws this on a canvas; a
137
+ // terminal draws density with block characters, which survives being piped to a
138
+ // file, printed, or read by someone who cannot distinguish the colors the web
139
+ // version relies on.
140
+ export function coupling(repo) {
141
+ if (!repo.coupling || !repo.coupling.folders.length) {
142
+ return dim(wrapText('No cross-folder imports — this repo is a single package, or nothing imports across folders.'));
143
+ }
144
+ const grid = couplingGrid(repo, { maxFolders: 10 });
145
+ const head = dim(wrapText('folder-to-folder imports (darker = more edges)', ' '));
146
+ const legend = dim(fit(' ' + [1, 2, 3, 4].map((n) => step(n, 4)).join('') + ' low → high', Math.max(1, termWidth() - 2)));
147
+ return [head, ...grid, legend].join('\n');
148
+ }
149
+ // ------------------------------------------------------------- clusters ---
150
+ // Louvain communities, described. The site draws these as colored blobs in a
151
+ // force graph; the terminal names them by the folder they mostly live in, which
152
+ // is the fact a person actually wants ("this repo is really four things") and is
153
+ // the same number, not a picture of it.
154
+ export function clusters(repo, { limit = 8 } = {}) {
155
+ const groups = (repo.facts.communities || []).filter((c) => c.size > 1);
156
+ if (!groups.length)
157
+ return dim(wrapText('No distinct module clusters — the graph is too small or too interconnected.'));
158
+ const w = termWidth();
159
+ const out = [
160
+ dim(fit(' module clusters', Math.max(1, termWidth() - 2))),
161
+ dim(wrapText('groups of files that import each other more than the rest', ' ')),
162
+ ];
163
+ for (const c of groups.slice(0, Math.min(Number(limit) || 8, MAX))) {
164
+ const folders = tally(c.members);
165
+ const where = Object.entries(folders).sort((a, b) => b[1] - a[1]).slice(0, 3)
166
+ .map(([f, n]) => `${f}/${n}`).join(' ');
167
+ out.push(labelled(ok(GLYPH_MARK + ' '), cyan(where || '(mixed)'), dim(` ${c.size} files`), { pad: 4 }));
168
+ }
169
+ return out.join('\n');
170
+ }
171
+ function tally(paths) {
172
+ const out = {};
173
+ for (const p of paths) {
174
+ const top = p.includes('/') ? p.slice(0, p.indexOf('/')) : '.';
175
+ out[top] = (out[top] || 0) + 1;
176
+ }
177
+ return out;
178
+ }
179
+ // ---------------------------------------------------------------- blast ---
180
+ // What breaks if this file breaks: the transitive set of files that import it,
181
+ // directly or through anything in between. Direct fan-in is on `deps`; this is
182
+ // the number that decides whether a change is a one-file edit or a quarter of
183
+ // the repo, and it is the reason the site has a blast-radius view.
184
+ export function blast(repo, { target = '', limit = 15 } = {}) {
185
+ const found = resolveTarget(repo, target);
186
+ if (found.error)
187
+ return targetError(found);
188
+ if (found.folder)
189
+ return dim(wrapText('Name a file, not a folder.', ' '));
190
+ const p = found.file.path;
191
+ // Walk importers transitively. The reverse graph is built once; the site's
192
+ // health engine does the same condensation with Tarjan, and for a single file
193
+ // this breadth-first walk is the cheap, obvious version of the same answer.
194
+ const reverse = new Map();
195
+ for (const e of repo.scan.edges) {
196
+ if (!reverse.has(e.to))
197
+ reverse.set(e.to, []);
198
+ reverse.get(e.to).push(e.from);
199
+ }
200
+ const seen = new Set([p]);
201
+ let frontier = [p];
202
+ const direct = (repo.facts.importers[p] || []).length;
203
+ while (frontier.length) {
204
+ const next = [];
205
+ for (const cur of frontier) {
206
+ for (const parent of reverse.get(cur) || []) {
207
+ if (seen.has(parent))
208
+ continue;
209
+ seen.add(parent);
210
+ next.push(parent);
211
+ }
212
+ }
213
+ frontier = next;
214
+ }
215
+ seen.delete(p);
216
+ const affected = [...seen].sort();
217
+ const w = termWidth();
218
+ const health = repo.health.perFile?.find((f) => f.path === p);
219
+ const out = [panel(p, [
220
+ { label: 'direct', value: `${direct} file${direct === 1 ? '' : 's'} import this` },
221
+ { label: 'transitive', value: `${affected.length} file${affected.length === 1 ? '' : 's'} affected if it breaks` },
222
+ { label: 'blast radius', value: repo.scan.files.length ? Math.round((affected.length / repo.scan.files.length) * 100) + '% of the repo' : '—' },
223
+ ...(health?.blast !== undefined ? [{ label: 'measured', value: health.blastExact ? String(health.blast) : dim('not computed at this size') }] : []),
224
+ ])];
225
+ if (!affected.length) {
226
+ out.push(ok(wrapText('Nothing imports this, directly or transitively. It is a leaf — safe to change.', ' ')));
227
+ }
228
+ else {
229
+ out.push(dim(fit(` affected files (${affected.length})`, Math.max(4, w - 2))));
230
+ for (const a of affected.slice(0, Math.min(Number(limit) || 15, MAX))) {
231
+ out.push(labelled(warn(GLYPH_MARK + ' '), a, '', { pad: 4 }));
232
+ }
233
+ const shown = Math.min(Number(limit) || 15, MAX);
234
+ if (affected.length > shown)
235
+ out.push(dim(fit(` … and ${affected.length - shown} more`, Math.max(4, w - 2))));
236
+ }
237
+ return out.join('\n');
238
+ }
239
+ // Files that are both complex and frequently changed. That combination is the
240
+ // thing worth a second look — complexity alone is a style opinion, churn alone
241
+ // is just activity, and the intersection is where bugs live. The same number the
242
+ // site's hotspot view ranks by.
243
+ export async function hotspots(repo, { limit = 12 } = {}) {
244
+ const h = await loadHistory(repo);
245
+ if (!h.available)
246
+ return dim(wrapText('No git history: ' + h.reason));
247
+ if (!h.perFile.length)
248
+ return dim(wrapText('No file has been committed in this window.'));
249
+ const w = termWidth();
250
+ const top = h.perFile.slice().sort((a, b) => b.hotspot - a.hotspot).slice(0, Math.min(Number(limit) || 12, MAX));
251
+ const max = Math.max(...top.map((f) => f.hotspot));
252
+ const nameRoom = Math.max(12, w - 34);
253
+ const out = [
254
+ dim(fit(' hotspots', Math.max(1, termWidth() - 2))),
255
+ dim(wrapText('complexity × churn — the files most worth a second look', ' ')),
256
+ ];
257
+ for (const f of top) {
258
+ // The hotspot score is drawn as a bar in the tail, and the bar is the first
259
+ // thing `labelled` drops on a narrow terminal — which is the right order:
260
+ // the path identifies the file, the churn/complexity numbers explain why it
261
+ // is on the list, and the bar is decoration.
262
+ const barRoom = Math.max(0, Math.min(16, w - 40));
263
+ const tail = dim(` ${f.churn}c ${f.complexity}x `) + (barRoom > 4 ? dim(bar(f.hotspot, max, barRoom)) : '');
264
+ out.push(labelled(warn(GLYPH_MARK + ' '), cyan(f.path), tail, { pad: 4 }));
265
+ }
266
+ const solo = h.perFile.filter((f) => f.solo).length;
267
+ if (solo)
268
+ out.push(dim(wrapText(`${solo} file${solo === 1 ? '' : 's'} changed by exactly one person — a bus factor of 1`, ' ')));
269
+ return out.join('\n');
270
+ }
271
+ // -------------------------------------------------------------- diagram ---
272
+ // Real Mermaid source, from the same generator the site's diagram pane uses. A
273
+ // terminal cannot render Mermaid, so the honest thing is to emit it and say
274
+ // where to paste it. The thing a terminal *can* draw is `graph` below, which is
275
+ // the same information in the terminal's own idiom.
276
+ export function diagram(repo, { target = '' } = {}) {
277
+ const w = termWidth();
278
+ const dump = (title, source) => [
279
+ bold(' mermaid — ' + title),
280
+ dim(' paste into any Mermaid renderer, or open it in the web UI'),
281
+ '',
282
+ ...source.split('\n').map((l) => ' ' + fit(l, w - 2)),
283
+ ].join('\n');
284
+ if (!String(target).trim())
285
+ return dump('whole repo', overviewDiagram(repo.scan, repo.facts).source);
286
+ const found = resolveTarget(repo, target);
287
+ if (found.error)
288
+ return targetError(found);
289
+ if (found.folder)
290
+ return dim(wrapText('Name a file, not a folder.', ' '));
291
+ return dump(found.file.path, fileDetailDiagram(repo.scan, repo.facts, found.file.path).source);
292
+ }
293
+ // The layer stack as Mermaid — the site's "layers" diagram, verbatim.
294
+ export function layerDiagram(repo) {
295
+ const w = termWidth();
296
+ return [
297
+ bold(' mermaid — layers'),
298
+ ...layersDiagram(repo.scan, repo.facts, repo.layers).source.split('\n').map((l) => ' ' + fit(l, w - 2)),
299
+ ].join('\n');
300
+ }
301
+ // ----------------------------------------------------------------- graph ---
302
+ // The dependency tree around a file, in arrows. This is the terminal's force
303
+ // graph: `→` is "imports", `←` is "imported by", and a cycle shows up as an
304
+ // arrow pointing back the way it came. Depth-limited because a terminal is not a
305
+ // canvas — an unbounded graph is a screen of noise in both.
306
+ export function graph(repo, { target = '', depth = 2, direction = 'both' } = {}) {
307
+ const found = resolveTarget(repo, target);
308
+ if (found.error)
309
+ return targetError(found);
310
+ if (found.folder)
311
+ return dim(wrapText('Name a file, not a folder.', ' '));
312
+ if (!repo.byPath)
313
+ repo.byPath = new Map(repo.scan.files.map((f) => [f.path, f]));
314
+ const d = Math.max(1, Math.min(Number(depth) || 2, 6));
315
+ return [
316
+ dim(fit(' graph — ' + found.file.path, Math.max(4, termWidth() - 2))),
317
+ ...depTree(repo, found.file.path, { depth: d, direction }),
318
+ dim(fit(' → imports ← imported by', Math.max(4, termWidth() - 2))),
319
+ ].join('\n');
320
+ }
321
+ // ------------------------------------------------------------------ docs ---
322
+ // Prose documentation for a file or a folder, from the same `docs.js` the site
323
+ // generates its reference pages from. With no argument it writes a whole
324
+ // ONBOARDER.md into the repo root — the terminal equivalent of the site's docs
325
+ // generator, and the thing you want when handing a codebase to someone.
326
+ export function docs(repo, { target = '' } = {}) {
327
+ if (String(target).trim()) {
328
+ const found = resolveTarget(repo, target);
329
+ if (found.error)
330
+ return targetError(found);
331
+ if (found.folder) {
332
+ return [bold(' ' + (found.folder.path || '.')), dim(wrapText(folderStaticDoc(found.folder.path, repo.scan, repo.facts, 0)))].join('\n');
333
+ }
334
+ return [bold(' ' + found.file.path), dim(wrapText(fileStaticDoc(found.file.path, repo.scan, repo.facts)))].join('\n');
335
+ }
336
+ const lines = [
337
+ `# ${repo.name}`, '',
338
+ `> Generated by \`onboarder docs\` — ${new Date().toISOString().slice(0, 10)}`, '',
339
+ 'A map of this codebase: what it is made of, where to start reading, and which files everything leans on.', '',
340
+ '## Start here', '',
341
+ ];
342
+ for (const stop of repo.tour)
343
+ lines.push(`- \`${stop.path}\` — ${stop.why}`);
344
+ lines.push('', '## Folders', '');
345
+ for (const folder of repo.scan.folders) {
346
+ lines.push(`- \`${folder.path}\` — ${folderStaticDoc(folder.path, repo.scan, repo.facts, 0)}`);
347
+ }
348
+ return lines.join('\n');
349
+ }
350
+ // Write the whole-repo doc to disk. Separated from `docs` because this one does
351
+ // I/O and needs to say where it wrote, and because the print form must stay pure
352
+ // for the tests.
353
+ export async function writeDocs(repo, target = 'ONBOARDER.md') {
354
+ const body = docs(repo, {});
355
+ const abs = path.join(repo.root, target);
356
+ await fs.writeFile(abs, body + '\n', 'utf8');
357
+ return abs;
358
+ }
359
+ // --------------------------------------------------------------- symbols ---
360
+ // The functions, classes and exports in one file, with line numbers. The site
361
+ // gets this from a Monaco outline panel; the terminal gets a list you can pipe
362
+ // into `grep` or read in one screen.
363
+ export function symbols(repo, { target = '' } = {}) {
364
+ const found = resolveTarget(repo, target);
365
+ if (found.error)
366
+ return targetError(found);
367
+ if (found.folder)
368
+ return dim(wrapText('Name a file, not a folder.', ' '));
369
+ const f = found.file;
370
+ const w = termWidth();
371
+ const fns = f.functions || [];
372
+ const classes = f.classes || [];
373
+ const exports = f.exports || [];
374
+ if (!fns.length && !classes.length && !exports.length) {
375
+ return dim(wrapText(`${f.name} has no functions, classes, or exports we can recognize.`));
376
+ }
377
+ const out = [panel(f.path, [
378
+ { label: 'functions', value: String(fns.length) },
379
+ { label: 'classes', value: String(classes.length) },
380
+ { label: 'exports', value: String(exports.length) },
381
+ ])];
382
+ if (classes.length) {
383
+ out.push(dim(fit(' classes', Math.max(2, w - 2))));
384
+ for (const c of classes)
385
+ out.push(labelled('', cyan(c.name), dim(` line ${c.line ?? '?'}`), { pad: 4 }));
386
+ }
387
+ if (fns.length) {
388
+ out.push(dim(fit(' functions', Math.max(2, w - 2))));
389
+ for (const fn of fns.slice(0, 60)) {
390
+ out.push(labelled('', cyan(fn.name), dim(` ${fn.kind || 'fn'} line ${fn.line ?? '?'}`), { pad: 4 }));
391
+ }
392
+ if (fns.length > 60)
393
+ out.push(dim(fit(` … and ${fns.length - 60} more`, Math.max(4, w - 2))));
394
+ }
395
+ return out.join('\n');
396
+ }
397
+ // ----------------------------------------------------------------- risks ---
398
+ // The problems, gathered in one place: cycles, orphans, dead exports, test
399
+ // coverage, dependency drift. Each has its own command on the site; in a
400
+ // terminal, "what is wrong with this repo" is one question and deserves one
401
+ // answer, so they are collected rather than made you ask five times.
402
+ export function risks(repo) {
403
+ const f = repo.facts;
404
+ const w = termWidth();
405
+ const out = [dim(fit(' risks', Math.max(4, w - 2)))];
406
+ const findings = [];
407
+ if (f.cycles?.length)
408
+ findings.push([f.cycles.length, `circular import${f.cycles.length === 1 ? '' : 's'} — the largest is ${f.cycles[0].length} files`]);
409
+ if (f.orphans?.length)
410
+ findings.push([f.orphans.length, 'files nothing imports — dead code, or entry points we did not see']);
411
+ if (f.deadExports?.length)
412
+ findings.push([f.deadExports.length, `exports nothing imports (${f.deadExports.slice(0, 2).map((e) => e.name).join(', ')})`]);
413
+ if (f.testCoverage && f.testCoverage.ratio < 50)
414
+ findings.push([f.testCoverage.ratio + '%', 'of non-test files are reachable from test imports']);
415
+ if (f.depsDrift?.undeclaredImported?.length)
416
+ findings.push([f.depsDrift.undeclaredImported.length, `imported but not declared (${f.depsDrift.undeclaredImported.slice(0, 2).join(', ')})`]);
417
+ if (f.depsDrift?.unusedDeclared?.length)
418
+ findings.push([f.depsDrift.unusedDeclared.length, `declared but never imported (${f.depsDrift.unusedDeclared.slice(0, 2).join(', ')})`]);
419
+ if (!findings.length)
420
+ return ok(wrapText('Nothing obvious is wrong with this repo. health and patterns have more.', ' '));
421
+ // Two layouts. Wide enough: marker, count, then the sentence filling the rest.
422
+ // Narrower than the marker plus a usable sentence: the count moves onto its
423
+ // own line, because a row of "● 11 imported" is worse than useless — the
424
+ // words that carry the meaning get one cell each. Everything is measured as
425
+ // plain text; styling happens last, so no escape sequence is ever sliced.
426
+ const wide = w >= leadWidth() + 14;
427
+ for (const [n, text] of findings) {
428
+ if (wide) {
429
+ const num = String(n).padStart(4);
430
+ const gutter = ' '.repeat(leadWidth() + num.length + 2);
431
+ const room = Math.max(1, w - gutter.length);
432
+ const wrapped = wrapText(text, '', room).split('\n');
433
+ out.push(lead() + dim(num) + ' ' + wrapped[0]
434
+ + (wrapped.length > 1 ? '\n' + gutter + wrapped.slice(1).join('\n' + gutter) : ''));
435
+ }
436
+ else {
437
+ out.push(fit(lead() + n, Math.max(1, w)));
438
+ out.push(wrapText(text, ' '));
439
+ }
440
+ }
441
+ if (f.cycles?.length)
442
+ out.push(' ' + dim(fit(f.cycles[0].slice(0, 3).join(' → ') + ' → …', Math.max(4, w - 6))));
443
+ out.push('');
444
+ out.push(dim(fit(' details: health · patterns · deps <file> · externals', Math.max(4, w - 2))));
445
+ return out.join('\n');
446
+ }
447
+ const leadWidth = () => (' ' + GLYPH_MARK + ' ').length;
448
+ const lead = () => ' ' + GLYPH_MARK + ' ';
449
+ //# sourceMappingURL=advanced.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advanced.js","sourceRoot":"","sources":["../../src/cli/explorer/advanced.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,uEAAuE;AACvE,4EAA4E;AAC5E,kEAAkE;AAElE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACtF,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAAa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AAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpH,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACb,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,wDAAwD,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjG,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CAAC,IAAI,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;AACzD,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,IAAI,GAAG,UAAU,GAAG,GAAG,CAAC","sourcesContent":["// The advanced views: the parts of the site that had no terminal equivalent.\n//\n// Everything here is a *projection* of data the engine already computed or of\n// git the repo already contains. Nothing re-implements analysis. Where the web\n// draws a canvas (a heat grid, a force graph) the terminal draws block\n// characters and an arrow tree from the same numbers, because those are the\n// terminal's own idioms — not degraded versions of the web views.\n\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\n\nimport { bold, cyan, dim, ok, warn, bad, panel, row, fit, termWidth } from '../ui.js';\nimport { bar, columns, couplingGrid, depTree, labelled, step } from './graphs.js';\nimport { fileFacts, resolveTarget } from './session.js';\nimport { targetError } from './views.js';\nimport { wrapText } from './wrap.js';\nimport { gitLog, parseGitLog } from '../../server/gitHistory.js';\nimport { analyzeHistory, unavailableHistory } from '../../shared/analyzer/history.js';\nimport { parsePorcelainBlame } from '../../server/apiGitBlame.js';\nimport { couplingMatrix } from '../../shared/analyzer/patterns.js';\nimport { overviewDiagram, layersDiagram, fileDetailDiagram } from '../../shared/diagram/mermaid.js';\nimport { fileStaticDoc, folderStaticDoc } from '../../shared/analyzer/docs.js';\n\nconst run = promisify(execFile);\nconst MAX = 200;\n\n// Git history is loaded lazily and cached on the repo object. It shells out, and\n// a person who never types `log` or `blame` should not pay for it — and on a\n// large repo that is the difference between an instant prompt and a visible\n// pause. A failure is cached too, so a missing `git` binary costs one failed\n// call rather than one per keystroke.\nexport async function loadHistory(repo, { force = false }: Record<string, any> = {}) {\n if (!force && repo._history !== undefined) return repo._history;\n try {\n const log = await gitLog(repo.root);\n if (!log.ok) {\n repo._history = unavailableHistory(log.reason);\n return repo._history;\n }\n repo._history = analyzeHistory(repo.scan, parseGitLog(log.text), { totalCommits: log.totalCommits });\n } catch (e) {\n repo._history = unavailableHistory('The git history could not be read — the scan itself is unaffected.');\n }\n return repo._history;\n}\n\n// ------------------------------------------------------------------- log ---\n\n// Recent commits, and the people who wrote them. The site shows this in a\n// history tab; the terminal answer is a compact list, because the question this\n// answers — \"who is working on this, and what did they touch lately\" — is one\n// glance, not a browsing session.\nexport async function log(repo, { limit = 15 }: Record<string, any> = {}) {\n const h = await loadHistory(repo);\n if (!h.available) return dim(wrapText('No git history: ' + h.reason));\n const w = termWidth();\n const out = [panel('git history', [\n { label: 'commits', value: `${h.commitCount} analyzed` + (h.truncated ? dim(` (of ${h.totalCommits} — log capped)`) : '') },\n { label: 'authors', value: h.authors.slice(0, 4).map((a) => `${a.name} (${a.commits})`).join(', ') || '—' },\n { label: 'window', value: `${String(h.firstCommitAt || '').slice(0, 10)} → ${String(h.lastCommitAt || '').slice(0, 10)}` },\n ])];\n\n out.push(dim(fit(' recent commits', Math.max(4, termWidth() - 2))));\n for (const c of h.commits.slice(0, Math.min(Number(limit) || 15, MAX))) {\n // sha / author / date as marker, value, tail, so a narrow terminal drops the\n // date rather than running the row off the edge.\n out.push(labelled(dim(c.hash.slice(0, 8) + ' '), c.author?.name || '?',\n dim(String(c.date || '').slice(0, 10) + ' ' + (c.files?.length || 0) + 'f'), { pad: 4 }));\n }\n if (h.authors.length) {\n out.push(dim(fit(' commits per author', Math.max(4, termWidth() - 2))));\n const max = Math.max(...h.authors.map((a) => a.commits));\n for (const a of h.authors.slice(0, 8)) {\n const tail = dim(String(a.commits).padStart(4)) + (w > 30 ? ' ' + dim(bar(a.commits, max, Math.max(0, Math.min(18, w - 28)))) : '');\n out.push(labelled('', a.name, tail, { pad: 4 }));\n }\n }\n return out.join('\\n');\n}\n\nconst GLYPH_MARK = '●';\n\n// ---------------------------------------------------------------- blame ---\n\n// Who wrote each line, and when. `git blame --porcelain` through the same parser\n// the site's blame view uses, so a line's author and date are the same answer in\n// both places. Shown as a histogram of authors per line plus the recent\n// commits, because a per-line listing of a 400-line file is a page of output\n// nobody reads.\nexport async function blame(repo, { target = '', limit = 20 }: Record<string, any> = {}) {\n const found = resolveTarget(repo, target);\n if (found.error) return targetError(found);\n if (found.folder) return dim(wrapText(`${found.folder.path || '.'} is a folder — blame a file inside it.`, ' '));\n\n const p = found.file.path;\n let raw;\n try {\n const { stdout } = await run('git', ['-C', repo.root, 'blame', '--line-porcelain', '--', p], { maxBuffer: 32 * 1024 * 1024 });\n raw = stdout;\n } catch (e) {\n const why = /not a git repository|Unable to read/.test(String(e.stderr || e.message))\n ? 'This folder is not in a git repository.'\n : 'git blame could not read this file.';\n return dim(wrapText(why));\n }\n\n const lines = parsePorcelainBlame(raw);\n if (!lines.length) return dim(wrapText('No blame information for this file.'));\n\n const w = termWidth();\n const byAuthor = new Map();\n for (const l of lines) byAuthor.set(l.author, (byAuthor.get(l.author) || 0) + 1);\n const authors = [...byAuthor.entries()].sort((a, b) => b[1] - a[1]);\n const recent = [...new Map(lines.map((l) => [l.sha, l])).values()]\n .sort((a, b) => String(b.date).localeCompare(String(a.date)))\n .slice(0, Math.min(Number(limit) || 20, 10));\n\n const out = [panel(p, [\n { label: 'lines', value: String(lines.length) },\n { label: 'authors', value: String(authors.length) },\n { label: 'oldest', value: lines.map((l) => l.date).filter(Boolean).sort()[0]?.slice(0, 10) || '—' },\n { label: 'newest', value: lines.map((l) => l.date).filter(Boolean).sort().pop()?.slice(0, 10) || '—' },\n ])];\n\n out.push(dim(fit(' lines per author', Math.max(4, termWidth() - 2))));\n const max = Math.max(...authors.map(([, n]) => n));\n for (const [name, n] of authors) {\n const tail = dim(String(n).padStart(5)) + (w > 34 ? ' ' + dim(bar(n, max, Math.max(0, Math.min(20, w - 30)))) : '');\n out.push(labelled('', name, tail, { pad: 4 }));\n }\n if (recent.length) {\n out.push(dim(fit(' most recent commits touching this file', Math.max(4, termWidth() - 2))));\n for (const c of recent) {\n // Without a separator the author and date ran together into\n // \"Amitpandey882026-09-25\" — the sha-width fit left no gap.\n out.push(labelled(dim(c.sha.slice(0, 8) + ' '), c.author, dim(String(c.date || '').slice(0, 10)), { pad: 4 }));\n }\n }\n return out.join('\\n');\n}\n\n// ------------------------------------------------------------- coupling ---\n\n// Folder-to-folder traffic as a heat grid. The site draws this on a canvas; a\n// terminal draws density with block characters, which survives being piped to a\n// file, printed, or read by someone who cannot distinguish the colors the web\n// version relies on.\nexport function coupling(repo) {\n if (!repo.coupling || !repo.coupling.folders.length) {\n return dim(wrapText('No cross-folder imports — this repo is a single package, or nothing imports across folders.'));\n }\n const grid = couplingGrid(repo, { maxFolders: 10 });\n const head = dim(wrapText('folder-to-folder imports (darker = more edges)', ' '));\n const legend = dim(fit(' ' + [1, 2, 3, 4].map((n) => step(n, 4)).join('') + ' low → high', Math.max(1, termWidth() - 2)));\n return [head, ...grid, legend].join('\\n');\n}\n\n// ------------------------------------------------------------- clusters ---\n\n// Louvain communities, described. The site draws these as colored blobs in a\n// force graph; the terminal names them by the folder they mostly live in, which\n// is the fact a person actually wants (\"this repo is really four things\") and is\n// the same number, not a picture of it.\nexport function clusters(repo, { limit = 8 }: Record<string, any> = {}) {\n const groups = (repo.facts.communities || []).filter((c) => c.size > 1);\n if (!groups.length) return dim(wrapText('No distinct module clusters — the graph is too small or too interconnected.'));\n const w = termWidth();\n const out = [\n dim(fit(' module clusters', Math.max(1, termWidth() - 2))),\n dim(wrapText('groups of files that import each other more than the rest', ' ')),\n ];\n for (const c of groups.slice(0, Math.min(Number(limit) || 8, MAX))) {\n const folders = tally(c.members);\n const where = Object.entries(folders).sort((a, b) => b[1] - a[1]).slice(0, 3)\n .map(([f, n]) => `${f}/${n}`).join(' ');\n out.push(labelled(ok(GLYPH_MARK + ' '), cyan(where || '(mixed)'), dim(` ${c.size} files`), { pad: 4 }));\n }\n return out.join('\\n');\n}\n\nfunction tally(paths) {\n const out: Record<string, any> = {};\n for (const p of paths) {\n const top = p.includes('/') ? p.slice(0, p.indexOf('/')) : '.';\n out[top] = (out[top] || 0) + 1;\n }\n return out;\n}\n\n// ---------------------------------------------------------------- blast ---\n\n// What breaks if this file breaks: the transitive set of files that import it,\n// directly or through anything in between. Direct fan-in is on `deps`; this is\n// the number that decides whether a change is a one-file edit or a quarter of\n// the repo, and it is the reason the site has a blast-radius view.\nexport function blast(repo, { target = '', limit = 15 }: Record<string, any> = {}) {\n const found = resolveTarget(repo, target);\n if (found.error) return targetError(found);\n if (found.folder) return dim(wrapText('Name a file, not a folder.', ' '));\n\n const p = found.file.path;\n // Walk importers transitively. The reverse graph is built once; the site's\n // health engine does the same condensation with Tarjan, and for a single file\n // this breadth-first walk is the cheap, obvious version of the same answer.\n const reverse = new Map();\n for (const e of repo.scan.edges) {\n if (!reverse.has(e.to)) reverse.set(e.to, []);\n reverse.get(e.to).push(e.from);\n }\n const seen = new Set([p]);\n let frontier = [p];\n const direct = (repo.facts.importers[p] || []).length;\n while (frontier.length) {\n const next = [];\n for (const cur of frontier) {\n for (const parent of reverse.get(cur) || []) {\n if (seen.has(parent)) continue;\n seen.add(parent);\n next.push(parent);\n }\n }\n frontier = next;\n }\n seen.delete(p);\n\n const affected = [...seen].sort();\n const w = termWidth();\n const health = repo.health.perFile?.find((f) => f.path === p);\n const out = [panel(p, [\n { label: 'direct', value: `${direct} file${direct === 1 ? '' : 's'} import this` },\n { label: 'transitive', value: `${affected.length} file${affected.length === 1 ? '' : 's'} affected if it breaks` },\n { label: 'blast radius', value: repo.scan.files.length ? Math.round((affected.length / repo.scan.files.length) * 100) + '% of the repo' : '—' },\n ...(health?.blast !== undefined ? [{ label: 'measured', value: health.blastExact ? String(health.blast) : dim('not computed at this size') }] : []),\n ])];\n\n if (!affected.length) {\n out.push(ok(wrapText('Nothing imports this, directly or transitively. It is a leaf — safe to change.', ' ')));\n } else {\n out.push(dim(fit(` affected files (${affected.length})`, Math.max(4, w - 2))));\n for (const a of affected.slice(0, Math.min(Number(limit) || 15, MAX))) {\n out.push(labelled(warn(GLYPH_MARK + ' '), a, '', { pad: 4 }));\n }\n const shown = Math.min(Number(limit) || 15, MAX);\n if (affected.length > shown) out.push(dim(fit(` … and ${affected.length - shown} more`, Math.max(4, w - 2))));\n }\n return out.join('\\n');\n}\n\n\n// Files that are both complex and frequently changed. That combination is the\n// thing worth a second look — complexity alone is a style opinion, churn alone\n// is just activity, and the intersection is where bugs live. The same number the\n// site's hotspot view ranks by.\nexport async function hotspots(repo, { limit = 12 }: Record<string, any> = {}) {\n const h = await loadHistory(repo);\n if (!h.available) return dim(wrapText('No git history: ' + h.reason));\n if (!h.perFile.length) return dim(wrapText('No file has been committed in this window.'));\n const w = termWidth();\n const top = h.perFile.slice().sort((a, b) => b.hotspot - a.hotspot).slice(0, Math.min(Number(limit) || 12, MAX));\n const max = Math.max(...top.map((f) => f.hotspot));\n const nameRoom = Math.max(12, w - 34);\n const out = [\n dim(fit(' hotspots', Math.max(1, termWidth() - 2))),\n dim(wrapText('complexity × churn — the files most worth a second look', ' ')),\n ];\n for (const f of top) {\n // The hotspot score is drawn as a bar in the tail, and the bar is the first\n // thing `labelled` drops on a narrow terminal — which is the right order:\n // the path identifies the file, the churn/complexity numbers explain why it\n // is on the list, and the bar is decoration.\n const barRoom = Math.max(0, Math.min(16, w - 40));\n const tail = dim(` ${f.churn}c ${f.complexity}x `) + (barRoom > 4 ? dim(bar(f.hotspot, max, barRoom)) : '');\n out.push(labelled(warn(GLYPH_MARK + ' '), cyan(f.path), tail, { pad: 4 }));\n }\n const solo = h.perFile.filter((f) => f.solo).length;\n if (solo) out.push(dim(wrapText(`${solo} file${solo === 1 ? '' : 's'} changed by exactly one person — a bus factor of 1`, ' ')));\n return out.join('\\n');\n}\n\n// -------------------------------------------------------------- diagram ---\n\n// Real Mermaid source, from the same generator the site's diagram pane uses. A\n// terminal cannot render Mermaid, so the honest thing is to emit it and say\n// where to paste it. The thing a terminal *can* draw is `graph` below, which is\n// the same information in the terminal's own idiom.\nexport function diagram(repo, { target = '' }: Record<string, any> = {}) {\n const w = termWidth();\n const dump = (title, source) => [\n bold(' mermaid — ' + title),\n dim(' paste into any Mermaid renderer, or open it in the web UI'),\n '',\n ...source.split('\\n').map((l) => ' ' + fit(l, w - 2)),\n ].join('\\n');\n\n if (!String(target).trim()) return dump('whole repo', overviewDiagram(repo.scan, repo.facts).source);\n\n const found = resolveTarget(repo, target);\n if (found.error) return targetError(found);\n if (found.folder) return dim(wrapText('Name a file, not a folder.', ' '));\n return dump(found.file.path, fileDetailDiagram(repo.scan, repo.facts, found.file.path).source);\n}\n\n// The layer stack as Mermaid — the site's \"layers\" diagram, verbatim.\nexport function layerDiagram(repo) {\n const w = termWidth();\n return [\n bold(' mermaid — layers'),\n ...layersDiagram(repo.scan, repo.facts, repo.layers).source.split('\\n').map((l) => ' ' + fit(l, w - 2)),\n ].join('\\n');\n}\n\n// ----------------------------------------------------------------- graph ---\n\n// The dependency tree around a file, in arrows. This is the terminal's force\n// graph: `→` is \"imports\", `←` is \"imported by\", and a cycle shows up as an\n// arrow pointing back the way it came. Depth-limited because a terminal is not a\n// canvas — an unbounded graph is a screen of noise in both.\nexport function graph(repo, { target = '', depth = 2, direction = 'both' }: Record<string, any> = {}) {\n const found = resolveTarget(repo, target);\n if (found.error) return targetError(found);\n if (found.folder) return dim(wrapText('Name a file, not a folder.', ' '));\n\n if (!repo.byPath) repo.byPath = new Map(repo.scan.files.map((f) => [f.path, f]));\n const d = Math.max(1, Math.min(Number(depth) || 2, 6));\n return [\n dim(fit(' graph — ' + found.file.path, Math.max(4, termWidth() - 2))),\n ...depTree(repo, found.file.path, { depth: d, direction }),\n dim(fit(' → imports ← imported by', Math.max(4, termWidth() - 2))),\n ].join('\\n');\n}\n\n// ------------------------------------------------------------------ docs ---\n\n// Prose documentation for a file or a folder, from the same `docs.js` the site\n// generates its reference pages from. With no argument it writes a whole\n// ONBOARDER.md into the repo root — the terminal equivalent of the site's docs\n// generator, and the thing you want when handing a codebase to someone.\nexport function docs(repo, { target = '' }: Record<string, any> = {}) {\n if (String(target).trim()) {\n const found = resolveTarget(repo, target);\n if (found.error) return targetError(found);\n if (found.folder) {\n return [bold(' ' + (found.folder.path || '.')), dim(wrapText(folderStaticDoc(found.folder.path, repo.scan, repo.facts, 0)))].join('\\n');\n }\n return [bold(' ' + found.file.path), dim(wrapText(fileStaticDoc(found.file.path, repo.scan, repo.facts)))].join('\\n');\n }\n\n const lines = [\n `# ${repo.name}`, '',\n `> Generated by \\`onboarder docs\\` — ${new Date().toISOString().slice(0, 10)}`, '',\n 'A map of this codebase: what it is made of, where to start reading, and which files everything leans on.', '',\n '## Start here', '',\n ];\n for (const stop of repo.tour) lines.push(`- \\`${stop.path}\\` — ${stop.why}`);\n lines.push('', '## Folders', '');\n for (const folder of repo.scan.folders) {\n lines.push(`- \\`${folder.path}\\` — ${folderStaticDoc(folder.path, repo.scan, repo.facts, 0)}`);\n }\n return lines.join('\\n');\n}\n\n// Write the whole-repo doc to disk. Separated from `docs` because this one does\n// I/O and needs to say where it wrote, and because the print form must stay pure\n// for the tests.\nexport async function writeDocs(repo, target = 'ONBOARDER.md') {\n const body = docs(repo, {});\n const abs = path.join(repo.root, target);\n await fs.writeFile(abs, body + '\\n', 'utf8');\n return abs;\n}\n\n// --------------------------------------------------------------- symbols ---\n\n// The functions, classes and exports in one file, with line numbers. The site\n// gets this from a Monaco outline panel; the terminal gets a list you can pipe\n// into `grep` or read in one screen.\nexport function symbols(repo, { target = '' }: Record<string, any> = {}) {\n const found = resolveTarget(repo, target);\n if (found.error) return targetError(found);\n if (found.folder) return dim(wrapText('Name a file, not a folder.', ' '));\n const f = found.file;\n const w = termWidth();\n const fns = f.functions || [];\n const classes = f.classes || [];\n const exports = f.exports || [];\n if (!fns.length && !classes.length && !exports.length) {\n return dim(wrapText(`${f.name} has no functions, classes, or exports we can recognize.`));\n }\n const out = [panel(f.path, [\n { label: 'functions', value: String(fns.length) },\n { label: 'classes', value: String(classes.length) },\n { label: 'exports', value: String(exports.length) },\n ])];\n if (classes.length) {\n out.push(dim(fit(' classes', Math.max(2, w - 2))));\n for (const c of classes) out.push(labelled('', cyan(c.name), dim(` line ${c.line ?? '?'}`), { pad: 4 }));\n }\n if (fns.length) {\n out.push(dim(fit(' functions', Math.max(2, w - 2))));\n for (const fn of fns.slice(0, 60)) {\n out.push(labelled('', cyan(fn.name), dim(` ${fn.kind || 'fn'} line ${fn.line ?? '?'}`), { pad: 4 }));\n }\n if (fns.length > 60) out.push(dim(fit(` … and ${fns.length - 60} more`, Math.max(4, w - 2))));\n }\n return out.join('\\n');\n}\n\n// ----------------------------------------------------------------- risks ---\n\n// The problems, gathered in one place: cycles, orphans, dead exports, test\n// coverage, dependency drift. Each has its own command on the site; in a\n// terminal, \"what is wrong with this repo\" is one question and deserves one\n// answer, so they are collected rather than made you ask five times.\nexport function risks(repo) {\n const f = repo.facts;\n const w = termWidth();\n const out = [dim(fit(' risks', Math.max(4, w - 2)))];\n\n const findings = [];\n if (f.cycles?.length) findings.push([f.cycles.length, `circular import${f.cycles.length === 1 ? '' : 's'} — the largest is ${f.cycles[0].length} files`]);\n if (f.orphans?.length) findings.push([f.orphans.length, 'files nothing imports — dead code, or entry points we did not see']);\n if (f.deadExports?.length) findings.push([f.deadExports.length, `exports nothing imports (${f.deadExports.slice(0, 2).map((e) => e.name).join(', ')})`]);\n if (f.testCoverage && f.testCoverage.ratio < 50) findings.push([f.testCoverage.ratio + '%', 'of non-test files are reachable from test imports']);\n if (f.depsDrift?.undeclaredImported?.length) findings.push([f.depsDrift.undeclaredImported.length, `imported but not declared (${f.depsDrift.undeclaredImported.slice(0, 2).join(', ')})`]);\n if (f.depsDrift?.unusedDeclared?.length) findings.push([f.depsDrift.unusedDeclared.length, `declared but never imported (${f.depsDrift.unusedDeclared.slice(0, 2).join(', ')})`]);\n\n if (!findings.length) return ok(wrapText('Nothing obvious is wrong with this repo. health and patterns have more.', ' '));\n\n // Two layouts. Wide enough: marker, count, then the sentence filling the rest.\n // Narrower than the marker plus a usable sentence: the count moves onto its\n // own line, because a row of \"● 11 imported\" is worse than useless — the\n // words that carry the meaning get one cell each. Everything is measured as\n // plain text; styling happens last, so no escape sequence is ever sliced.\n const wide = w >= leadWidth() + 14;\n for (const [n, text] of findings) {\n if (wide) {\n const num = String(n).padStart(4);\n const gutter = ' '.repeat(leadWidth() + num.length + 2);\n const room = Math.max(1, w - gutter.length);\n const wrapped = wrapText(text, '', room).split('\\n');\n out.push(lead() + dim(num) + ' ' + wrapped[0]\n + (wrapped.length > 1 ? '\\n' + gutter + wrapped.slice(1).join('\\n' + gutter) : ''));\n } else {\n out.push(fit(lead() + n, Math.max(1, w)));\n out.push(wrapText(text, ' '));\n }\n }\n if (f.cycles?.length) out.push(' ' + dim(fit(f.cycles[0].slice(0, 3).join(' → ') + ' → …', Math.max(4, w - 6))));\n out.push('');\n out.push(dim(fit(' details: health · patterns · deps <file> · externals', Math.max(4, w - 2))));\n return out.join('\\n');\n}\n\nconst leadWidth = () => (' ' + GLYPH_MARK + ' ').length;\nconst lead = () => ' ' + GLYPH_MARK + ' ';\n"]}
@@ -0,0 +1 @@
1
+ export declare function runExplore({ target, flags, out, err, version }?: Record<string, any>): Promise<unknown>;