@gloom-sh/terminal 0.20.16 → 0.20.18

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 (345) hide show
  1. package/package.json +3 -1
  2. package/src/account/auth-dialog.tsx +19 -1
  3. package/src/account/billing.ts +2 -1
  4. package/src/account/heard-from-question.tsx +235 -0
  5. package/src/account/heard-from.ts +97 -0
  6. package/src/api-client/data.ts +16 -5
  7. package/src/api-client/heard-from.ts +72 -0
  8. package/src/api-client/index.ts +63 -6
  9. package/src/api-client/mna.ts +18 -0
  10. package/src/api-client/supply-chain.ts +9 -0
  11. package/src/api-client/types/billing.ts +35 -1
  12. package/src/api-client/types/econ.ts +3 -0
  13. package/src/app/global-shortcuts.ts +5 -3
  14. package/src/app/pro-welcome/keys.ts +27 -0
  15. package/src/app/pro-welcome/model.ts +158 -0
  16. package/src/app/pro-welcome/row.tsx +176 -0
  17. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  18. package/src/app/runtime/external-profile-changes.ts +135 -0
  19. package/src/app.tsx +33 -2
  20. package/src/architecture/core-builtin-allowlist.json +1 -1
  21. package/src/architecture/floating-promise-allowlist.json +0 -1
  22. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  23. package/src/cli/alert-listing.ts +98 -0
  24. package/src/cli/commands/fred-series.ts +3 -1
  25. package/src/cli/commands/market.ts +138 -22
  26. package/src/cli/commands/overview.ts +72 -14
  27. package/src/cli/commands/plugins.ts +3 -2
  28. package/src/cli/commands/search.ts +30 -6
  29. package/src/cli/context.ts +16 -5
  30. package/src/cli/csv-export.ts +74 -0
  31. package/src/cli/desktop-pane-shot.ts +75 -11
  32. package/src/cli/glossary.ts +64 -10
  33. package/src/cli/help.ts +4 -2
  34. package/src/cli/history-demergers.ts +117 -0
  35. package/src/cli/history-rows.ts +6 -2
  36. package/src/cli/index.ts +1 -0
  37. package/src/cli/known-gaps.ts +16 -0
  38. package/src/cli/known-us-stocks.ts +18 -0
  39. package/src/cli/listing-arg.ts +105 -15
  40. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  41. package/src/cli/pane-functions/catalog-snapshot.json +866 -0
  42. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  43. package/src/cli/pane-functions/catalog.ts +50 -16
  44. package/src/cli/pane-functions/data.ts +16 -4
  45. package/src/cli/pane-functions/dom.ts +24 -6
  46. package/src/cli/pane-functions/freshness.ts +17 -1
  47. package/src/cli/pane-functions/headless.ts +7 -2
  48. package/src/cli/pane-functions/index.ts +102 -44
  49. package/src/cli/pane-functions/resolver.ts +8 -5
  50. package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
  51. package/src/cli/pane-functions/screenshot-bridge.ts +4 -2
  52. package/src/cli/pane-functions/screenshot-payload.ts +21 -0
  53. package/src/cli/pane-functions/screenshot-render.ts +3 -1
  54. package/src/cli/quote-answer.ts +32 -16
  55. package/src/cli/registry.ts +22 -2
  56. package/src/cli/report-tables.ts +17 -3
  57. package/src/cli/result.ts +8 -10
  58. package/src/cli/series-search.ts +45 -6
  59. package/src/cli/shot-temp-dir.ts +4 -9
  60. package/src/components/chart/composite/legend.tsx +80 -25
  61. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  62. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  63. package/src/components/chart-table/header.tsx +9 -0
  64. package/src/components/chart-table/layout.ts +11 -11
  65. package/src/components/command-bar/pane-templates/items.ts +17 -1
  66. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  67. package/src/components/command-bar/routes/root/results.ts +34 -2
  68. package/src/components/command-bar/routes/root/runtime.ts +8 -1
  69. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  70. package/src/components/command-bar/workflow/alert.ts +19 -8
  71. package/src/components/data-table/view.tsx +15 -2
  72. package/src/components/form-modal/content.tsx +9 -4
  73. package/src/components/index.ts +1 -1
  74. package/src/components/layout/header.tsx +9 -5
  75. package/src/components/layout/pane/capture-status.ts +6 -0
  76. package/src/components/layout/pane/footer/index.tsx +2 -0
  77. package/src/components/layout/pane/footer/model.ts +113 -15
  78. package/src/components/layout/pane/header.tsx +16 -2
  79. package/src/components/market-board/index.tsx +4 -2
  80. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  81. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  82. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  83. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  84. package/src/components/onboarding/setup-cards.ts +36 -0
  85. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  86. package/src/components/onboarding/wizard-account.ts +6 -1
  87. package/src/components/onboarding/wizard-model.ts +32 -6
  88. package/src/components/onboarding/wizard-positions.ts +1 -1
  89. package/src/components/sign-in-gate.tsx +3 -1
  90. package/src/components/toggle-list.tsx +6 -8
  91. package/src/components/ui/confirm-dialog.tsx +47 -7
  92. package/src/components/ui/data-table/display-columns.ts +4 -1
  93. package/src/components/ui/data-table/hooks.ts +2 -3
  94. package/src/components/ui/data-table/index.tsx +4 -1
  95. package/src/components/ui/data-table/types.ts +19 -4
  96. package/src/components/ui/data-table/visible-range.ts +11 -1
  97. package/src/components/ui/display.tsx +17 -2
  98. package/src/components/ui/index.ts +1 -1
  99. package/src/components/ui/stat-grid.tsx +4 -0
  100. package/src/components/ui/status.tsx +13 -1
  101. package/src/components/ui/table-layout.ts +2 -1
  102. package/src/components/use-pane-notice-footer.tsx +16 -3
  103. package/src/data/config/store/index.ts +31 -0
  104. package/src/data/config/store/node.ts +61 -11
  105. package/src/data/config/store/normalize.ts +4 -6
  106. package/src/data/config/store/shared-file.ts +309 -0
  107. package/src/data/profile-merge.ts +299 -0
  108. package/src/data/sqlite/checkpointer.ts +11 -1
  109. package/src/data/sqlite/database.ts +1 -1
  110. package/src/data/ticker-repository.ts +134 -10
  111. package/src/data/ticker-store.ts +67 -0
  112. package/src/data/ticker-writes.ts +5 -0
  113. package/src/i18n/es.ts +27 -0
  114. package/src/i18n/ja.ts +27 -0
  115. package/src/i18n/ko.ts +27 -0
  116. package/src/i18n/zh-cn.ts +27 -0
  117. package/src/i18n/zh-tw.ts +27 -0
  118. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  119. package/src/market-data/ah-pair.ts +103 -0
  120. package/src/market-data/depositary-pair.ts +6 -2
  121. package/src/market-data/hooks.tsx +33 -2
  122. package/src/market-data/market/change-basis.ts +2 -1
  123. package/src/market-data/market/header-market.ts +11 -0
  124. package/src/market-data/split-terms.ts +28 -0
  125. package/src/plugins/builtin/account-management/footer.ts +1 -1
  126. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  127. package/src/plugins/builtin/account-management/model.ts +1 -0
  128. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  129. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  130. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  131. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  132. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  133. package/src/plugins/builtin/alerts/cli.ts +36 -30
  134. package/src/plugins/builtin/alerts/constants.ts +10 -0
  135. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  136. package/src/plugins/builtin/alerts/format.ts +24 -8
  137. package/src/plugins/builtin/alerts/index.tsx +38 -9
  138. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  139. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  140. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  141. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  142. package/src/plugins/builtin/alerts/types.ts +7 -0
  143. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  144. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  145. package/src/plugins/builtin/analytics/risk-client.ts +26 -13
  146. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  147. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  148. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  149. package/src/plugins/builtin/awards/pane.tsx +7 -3
  150. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  151. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  152. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  153. package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
  154. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  155. package/src/plugins/builtin/chart-composer/pane.tsx +9 -3
  156. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  157. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  158. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  159. package/src/plugins/builtin/company-kpis/headless.ts +9 -4
  160. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  161. package/src/plugins/builtin/company-kpis/model.ts +38 -8
  162. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  163. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  164. package/src/plugins/builtin/composite/application.ts +14 -0
  165. package/src/plugins/builtin/composite/broker.ts +12 -0
  166. package/src/plugins/builtin/composite/credit.ts +33 -0
  167. package/src/plugins/builtin/composite/crypto.ts +10 -0
  168. package/src/plugins/builtin/composite/earnings.ts +12 -0
  169. package/src/plugins/builtin/composite/filings.ts +13 -0
  170. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  171. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  172. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  173. package/src/plugins/builtin/composite/ownership.ts +23 -0
  174. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  175. package/src/plugins/builtin/composite/quant.ts +15 -0
  176. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  177. package/src/plugins/builtin/composite/screeners.ts +11 -0
  178. package/src/plugins/builtin/composite/shared.ts +11 -0
  179. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  180. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  181. package/src/plugins/builtin/correlation/index.tsx +13 -17
  182. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  183. package/src/plugins/builtin/credit-conditions/series.ts +2 -2
  184. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  185. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  186. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  187. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  188. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  189. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  190. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  191. package/src/plugins/builtin/earnings/board-model.ts +12 -0
  192. package/src/plugins/builtin/earnings/board-table.ts +7 -4
  193. package/src/plugins/builtin/earnings/board.tsx +2 -2
  194. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  195. package/src/plugins/builtin/earnings/headless.ts +7 -4
  196. package/src/plugins/builtin/earnings/highlight.ts +1 -1
  197. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  198. package/src/plugins/builtin/earnings/history-table.ts +4 -3
  199. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  200. package/src/plugins/builtin/econ/calendar-model.ts +18 -0
  201. package/src/plugins/builtin/econ/fred-catalog.ts +1 -256
  202. package/src/plugins/builtin/econ/index.tsx +3 -0
  203. package/src/plugins/builtin/econ-statistics/cache.ts +1 -1
  204. package/src/plugins/builtin/econ-statistics/client.ts +11 -10
  205. package/src/plugins/builtin/econ-statistics/detail.tsx +1 -0
  206. package/src/plugins/builtin/econ-statistics/headless.ts +42 -6
  207. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  208. package/src/plugins/builtin/econ-statistics/pane.tsx +7 -2
  209. package/src/plugins/builtin/econ-statistics/stats.ts +2 -1
  210. package/src/plugins/builtin/econ-statistics/view.ts +9 -3
  211. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  212. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  213. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  214. package/src/plugins/builtin/exposure/model.ts +10 -0
  215. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  216. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  217. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  218. package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
  219. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  220. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  221. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  222. package/src/plugins/builtin/mna/detail.tsx +67 -6
  223. package/src/plugins/builtin/mna/headless.ts +128 -13
  224. package/src/plugins/builtin/mna/model.ts +219 -16
  225. package/src/plugins/builtin/mna/pane.tsx +34 -6
  226. package/src/plugins/builtin/money-markets/model.ts +14 -5
  227. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  228. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  229. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  230. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  231. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  232. package/src/plugins/builtin/pe-band/client.ts +13 -1
  233. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  234. package/src/plugins/builtin/pe-band/model.ts +63 -10
  235. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  236. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  237. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  238. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  239. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  240. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  241. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  242. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  243. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  244. package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
  245. package/src/plugins/builtin/research/event-model.ts +31 -13
  246. package/src/plugins/builtin/research/headless.ts +8 -1
  247. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  248. package/src/plugins/builtin/sectors/index.tsx +6 -9
  249. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  250. package/src/plugins/builtin/shared/earnings-report.ts +19 -4
  251. package/src/plugins/builtin/shared/fred-catalog.ts +256 -0
  252. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  253. package/src/plugins/builtin/shared/series-cache.ts +3 -0
  254. package/src/plugins/builtin/shared/series-detail-chart.tsx +3 -0
  255. package/src/plugins/builtin/short-interest/watch-pane.tsx +7 -7
  256. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  257. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  258. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  259. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  260. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  261. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  262. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  263. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  264. package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
  265. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  266. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  267. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +67 -1
  268. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +31 -16
  269. package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
  270. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
  271. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
  272. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  273. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  274. package/src/plugins/builtin/time-sales/headless.ts +4 -1
  275. package/src/plugins/builtin/time-sales/pane.tsx +2 -0
  276. package/src/plugins/builtin/time-sales/window.ts +12 -0
  277. package/src/plugins/builtin/treasury-auctions/client.ts +4 -0
  278. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +2 -0
  279. package/src/plugins/builtin/treasury-daily/client.ts +23 -11
  280. package/src/plugins/builtin/volatility/model.ts +17 -0
  281. package/src/plugins/builtin/volatility/pane.tsx +13 -4
  282. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  283. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  284. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  285. package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
  286. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  287. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  288. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  289. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  290. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  291. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  292. package/src/plugins/catalog-data.ts +20 -0
  293. package/src/plugins/catalog-lazy.ts +51 -0
  294. package/src/plugins/catalog-ui.ts +16 -18
  295. package/src/plugins/host-smoke.ts +5 -2
  296. package/src/portfolio/allocation.ts +79 -19
  297. package/src/portfolio/cash-balances.ts +76 -0
  298. package/src/portfolio/mutations.ts +43 -8
  299. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  300. package/src/renderers/desktop/window-layouts.ts +14 -0
  301. package/src/renderers/dom/data-table/row.tsx +2 -0
  302. package/src/renderers/dom/host/tabs.tsx +57 -8
  303. package/src/renderers/dom/styles.css +13 -5
  304. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  305. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  306. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  307. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  308. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -0
  309. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  310. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  311. package/src/series/standalone-catalog.ts +5 -4
  312. package/src/series/standalone.ts +13 -7
  313. package/src/sources/gloomberb-cloud/fred-publisher.ts +25 -0
  314. package/src/sources/gloomberb-cloud/fred-series.ts +1 -1
  315. package/src/sources/gloomberb-cloud/index.ts +14 -3
  316. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  317. package/src/sources/provider-router/financials.ts +20 -13
  318. package/src/sources/provider-router/index.ts +4 -0
  319. package/src/sources/provider-router/search.ts +1 -0
  320. package/src/sync/collections-contributor.ts +3 -1
  321. package/src/sync/config-merge.ts +10 -1
  322. package/src/sync/sanitize.ts +26 -2
  323. package/src/tickers/company-name-listing.ts +16 -2
  324. package/src/tickers/listing-fate.ts +12 -8
  325. package/src/tickers/renamed-listings.ts +43 -10
  326. package/src/tickers/search/home-listing.ts +28 -0
  327. package/src/tickers/search/index.ts +19 -7
  328. package/src/tickers/terminal-codes.ts +11 -1
  329. package/src/time-series/base-series.ts +3 -0
  330. package/src/time-series/ice-credit.ts +1 -0
  331. package/src/time-series/resolve.ts +3 -1
  332. package/src/time-series/spec.ts +2 -2
  333. package/src/time-series/types.ts +2 -1
  334. package/src/types/data-provider.ts +11 -0
  335. package/src/types/financials.ts +39 -3
  336. package/src/types/headless.ts +4 -2
  337. package/src/types/ticker.ts +10 -2
  338. package/src/utils/cli-output.ts +1 -1
  339. package/src/utils/declared-dividends.ts +13 -1
  340. package/src/utils/dividend-cash.ts +5 -1
  341. package/src/utils/forward-dividend.ts +4 -3
  342. package/src/utils/remove-folder.ts +37 -0
  343. package/src/utils/throttled-fetch.ts +15 -1
  344. package/src/utils/trailing-dividend.ts +1 -1
  345. package/src/plugins/builtin/composite-plugins.ts +0 -285
@@ -67,6 +67,9 @@ import {
67
67
  type PaneFunctionCapability,
68
68
  } from "./capabilities";
69
69
 
70
+ /** Plugins whose series a name that opens nothing is pointed at, or a function that gives them when that name is met. */
71
+ type SeriesSources = readonly SeriesSource[] | (() => readonly SeriesSource[]);
72
+
70
73
  export interface ResolvedPaneFunction {
71
74
  token: string;
72
75
  label: string;
@@ -207,7 +210,7 @@ function withKeywordNote(registry: PaneFunctionCatalog, parsed: ParsedPaneFuncti
207
210
  }
208
211
 
209
212
  /** Whether a word is the function's code, an alias or a name, rather than one of its keywords. */
210
- function namesFunction(template: PaneTemplateDef | undefined, pane: PaneDef, word: string): boolean {
213
+ export function namesFunction(template: PaneTemplateDef | undefined, pane: PaneDef, word: string): boolean {
211
214
  const wanted = normalizeLookupToken(word);
212
215
  const headless = getHeadlessPaneDefinition(template, pane);
213
216
  const names = [template?.shortcut?.prefix, ...template?.shortcut?.aliases ?? [], template?.id, template?.label, pane.id, pane.name,
@@ -468,7 +471,7 @@ async function unknownPaneFunctionError(
468
471
  name: string,
469
472
  arg: string,
470
473
  command: "fn" | "shot",
471
- seriesSources: readonly SeriesSource[] = [],
474
+ seriesSources: SeriesSources = [],
472
475
  pluginStop?: PluginCodeStopFinder,
473
476
  ): Promise<UnknownPaneFunctionError> {
474
477
  // NIM is one slip from NI, but a bank figure is in `fundamentals`, not in a function's statement lines.
@@ -494,7 +497,7 @@ async function unknownPaneFunctionError(
494
497
  // One code is run on the argument; the functions a word asks for are each.
495
498
  const runs = suggested.length > 0 ? suggested : near.length === 1 ? near : [];
496
499
  // A word no function is near that names data ("nikkei") points at the series `catalog` finds for it.
497
- const series = closest.length === 0 && near.length === 0 ? findCatalogSeries(seriesSources, name).slice(0, UNKNOWN_NAME_SERIES_LIMIT) : [];
500
+ const series = closest.length === 0 && near.length === 0 ? findCatalogSeries(typeof seriesSources === "function" ? seriesSources() : seriesSources, name).slice(0, UNKNOWN_NAME_SERIES_LIMIT) : [];
498
501
  const seriesWidth = Math.max(0, ...series.map((match) => match.expression.length));
499
502
  return new UnknownPaneFunctionError(name, [
500
503
  // A function a word asks for, typed with no argument, shows the one it takes (`<ticker>`).
@@ -519,8 +522,8 @@ export async function resolvePaneFunction(
519
522
  /** `fn`: a `--limit` or `--tail` the function takes no option for picks the report's rows (`rowWindow`). */
520
523
  rowWindow?: boolean;
521
524
  command?: "fn" | "shot";
522
- /** The plugins whose catalog series a name that opens nothing is pointed at. */
523
- seriesSources?: readonly SeriesSource[];
525
+ /** The plugins whose catalog series a name that opens nothing is pointed at; a function, to ask for them only then. */
526
+ seriesSources?: SeriesSources;
524
527
  /** Why a name that opens nothing is a plugin's code (`pluginCodeStop`). */
525
528
  pluginStop?: PluginCodeStopFinder;
526
529
  } = {},
@@ -139,7 +139,8 @@ export function assessPaneScreenshot(
139
139
  const unavailableSymbols = usesLiveDomEvidence
140
140
  ? []
141
141
  : shotUnavailableSymbols(resolved, payload, render.semanticUi);
142
- const complete = unavailableSymbols.length === 0;
142
+ const figureGaps = essentialFigureMismatches(render);
143
+ const complete = unavailableSymbols.length === 0 && figureGaps.length === 0 && !render.statusLineClipped;
143
144
  const expectedText = shotExpectedText(resolved, symbols, payload);
144
145
  const normalizedVisibleText = render.visibleText.toLowerCase();
145
146
  const missingExpectedText = expectedText.filter((value) => !shotShowsText(normalizedVisibleText, value));
@@ -156,6 +157,8 @@ export function assessPaneScreenshot(
156
157
  ...paneEvidenceMismatches(resolved, payload, render),
157
158
  ...financialRatioRenderMismatches(resolved, payload, render),
158
159
  ...surfaceNotDrawnMismatches(render),
160
+ ...figureGaps,
161
+ ...(render.statusLineClipped ? ["The as-of status line is clipped."] : []),
159
162
  ];
160
163
  const semanticMismatch = missingExpectedText.length > 0
161
164
  || missingExpectedSelections.length > 0
@@ -309,7 +312,10 @@ const BLANK_COLUMN_MIN_ROWS = 3;
309
312
  * and V/AVG did before the open. A column some rows leave empty is a sparse
310
313
  * marker (an event column), not a blank one, and neither is a column the pane
311
314
  * says can be blank (`mayBeBlank`: a value that comes after an event, such as
312
- * an upcoming report's move); section headers and tables of fewer than
315
+ * an upcoming report's move). A row the pane says is still waiting on the
316
+ * value (a cell's `mayBeBlank`: ECO's ACTUAL before the release) is left out:
317
+ * the column is blank when every other row is, and there are at least
318
+ * BLANK_COLUMN_MIN_ROWS of them. Section headers and tables of fewer than
313
319
  * BLANK_COLUMN_MIN_ROWS rows are not read.
314
320
  */
315
321
  function shotBlankColumns(rows: readonly Pick<DesktopPaneShotRenderedRow, "tableIndex" | "cells" | "section">[]): string[] {
@@ -322,18 +328,22 @@ function shotBlankColumns(rows: readonly Pick<DesktopPaneShotRenderedRow, "table
322
328
  const blank: string[] = [];
323
329
  for (const tableRows of tables.values()) {
324
330
  if (tableRows.length < BLANK_COLUMN_MIN_ROWS) continue;
325
- const columns = new Map<string, { label: string; placeholders: number; filled: boolean }>();
331
+ const columns = new Map<string, { label: string; placeholders: number; waiting: number; filled: boolean }>();
326
332
  for (const row of tableRows) {
327
333
  for (const cell of row.cells) {
328
334
  const key = cell.columnId ?? cell.columnLabel;
329
- const column = columns.get(key) ?? { label: cell.columnLabel, placeholders: 0, filled: false };
330
- if (PLACEHOLDER_VALUE.test(cell.text.trim()) && !cell.mayBeBlank) column.placeholders += 1;
335
+ const column = columns.get(key) ?? { label: cell.columnLabel, placeholders: 0, waiting: 0, filled: false };
336
+ // A row still waiting on the value (an upcoming release's ACTUAL) is neither a gap nor a value.
337
+ if (cell.mayBeBlank && PLACEHOLDER_VALUE.test(cell.text.trim())) column.waiting += 1;
338
+ else if (PLACEHOLDER_VALUE.test(cell.text.trim())) column.placeholders += 1;
331
339
  else column.filled = true;
332
340
  columns.set(key, column);
333
341
  }
334
342
  }
335
- for (const { label, placeholders, filled } of columns.values()) {
336
- if (!filled && placeholders === tableRows.length && !blank.includes(label)) blank.push(label);
343
+ for (const { label, placeholders, waiting, filled } of columns.values()) {
344
+ // Blank in every row that should have the value, and in enough of them to be no short list's gaps.
345
+ const owed = tableRows.length - waiting;
346
+ if (!filled && owed >= BLANK_COLUMN_MIN_ROWS && placeholders === owed && !blank.includes(label)) blank.push(label);
337
347
  }
338
348
  }
339
349
  return blank;
@@ -434,6 +444,19 @@ function plotsData(node: RemoteUiNodeSnapshot): boolean {
434
444
  return lists.some((list) => list.some((series) => isRecord(series) && typeof series.pointCount === "number" && series.pointCount > 0));
435
445
  }
436
446
 
447
+ export function essentialFigureMismatches(render: Pick<DesktopPaneShotRenderResult, "semanticUi" | "visibleText">): string[] {
448
+ return render.semanticUi.filter((node) => node.role === "figure-layout").flatMap((node) => {
449
+ const metadata = node.metadata;
450
+ if (!isRecord(metadata) || !Array.isArray(metadata.figures) || !Array.isArray(metadata.omitted)) return ["Essential figure evidence is unavailable."];
451
+ const omitted = metadata.omitted;
452
+ return metadata.figures.flatMap((figure) => {
453
+ if (!isRecord(figure) || typeof figure.label !== "string" || typeof figure.value !== "string") return ["Essential figure evidence is invalid."];
454
+ return omitted.includes(figure.label) || !shotShowsText(render.visibleText, figure.label) || !shotShowsText(render.visibleText, figure.value)
455
+ ? [`Essential figure is missing or clipped: ${figure.label}.`] : [];
456
+ });
457
+ });
458
+ }
459
+
437
460
  /**
438
461
  * A 3D surface that is not the real drawing: the frame has no mesh, or the 2D
439
462
  * grid stands in for it. Both are fine for a person using the pane and wrong
@@ -8,6 +8,7 @@ import {
8
8
  type HttpProxyRequestEnvelope,
9
9
  type HttpProxyResponseEnvelope,
10
10
  } from "../../utils/http-proxy-response";
11
+ import { signalWithTimeout } from "../../utils/async-deadline";
11
12
  import { fetchCheckingRedirects, readBytesWithin } from "../../utils/http-proxy-upstream";
12
13
  import { isPublicAddress } from "../../utils/public-address";
13
14
  import type { DesktopPaneShotApiProxy, DesktopPaneShotBridge } from "../desktop-pane-shot";
@@ -146,7 +147,7 @@ export function createDesktopShotBridge(
146
147
  args,
147
148
  );
148
149
  },
149
- httpFetch: (request) => runDesktopShotHttpFetch(request, httpOptions),
150
+ httpFetch: (request, signal) => runDesktopShotHttpFetch(request, httpOptions, signal),
150
151
  };
151
152
  }
152
153
 
@@ -196,6 +197,7 @@ async function checkShotHttpTarget(
196
197
  async function runDesktopShotHttpFetch(
197
198
  request: HttpProxyRequestEnvelope,
198
199
  options: ShotHttpOptions,
200
+ signal?: AbortSignal,
199
201
  ): Promise<HttpProxyResponseEnvelope> {
200
202
  const resolve = options.resolveHost ?? resolveHost;
201
203
  const addresses = new Map<string, string>();
@@ -218,7 +220,7 @@ async function runDesktopShotHttpFetch(
218
220
  return fetchShotHttpAddress(url, init ?? {}, address);
219
221
  }) as typeof fetch,
220
222
  check: checkTarget,
221
- signal: AbortSignal.timeout(SHOT_BRIDGE_HTTP_TIMEOUT_MS),
223
+ signal: signalWithTimeout(signal, SHOT_BRIDGE_HTTP_TIMEOUT_MS),
222
224
  });
223
225
  if ("error" in result) throw new Error(result.error);
224
226
  const { response } = result;
@@ -165,6 +165,25 @@ interface ShotSymbolCapture {
165
165
  unread?: { symbol: string; reason: string };
166
166
  tape?: TapeCapture;
167
167
  chain?: [string, OptionsChain];
168
+ /** More than one cadence the pane reads for the row, each answering only its own requests. */
169
+ historyVariants?: NonNullable<SnapshotMarketData["historyVariants"]>;
170
+ }
171
+
172
+ /**
173
+ * PEB reads every week on record and, for the years they are served, the
174
+ * daily closes that price each figure on its day. Captured history answers
175
+ * every request, so the weekly bars would stand in for the daily ones and
176
+ * the capture read the week around each figure's day: each cadence is its
177
+ * own, under the listing the pane asks for. Without daily closes the weekly
178
+ * bars stand alone, as in the app.
179
+ */
180
+ async function peBandHistoryVariants(
181
+ context: MarketContext, ticker: TickerRecord, exchange: string, weekly: TickerFinancials["priceHistory"],
182
+ ): Promise<NonNullable<SnapshotMarketData["historyVariants"]>> {
183
+ const target = { symbol: ticker.metadata.ticker, exchange: ticker.metadata.exchange ?? "" };
184
+ const daily = await (context.dataProvider.getPriceHistoryForResolution?.(target.symbol, exchange, "5Y", "1d", toMarketDataContext(target))
185
+ ?? Promise.resolve([])).catch(logFailure("cli.pane-functions.screenshot-payload", "Read PEB daily closes for a capture failed", []));
186
+ return [{ target, resolution: "1wk", points: weekly ?? [] }, ...(daily.length ? [{ target, resolution: "1d" as const, points: daily }] : [])];
168
187
  }
169
188
 
170
189
  export async function buildDesktopShotPayload(
@@ -348,6 +367,7 @@ export async function buildDesktopShotPayload(
348
367
  if (resolved.pane.id === "time-sales") {
349
368
  capture.tape = [entry.instrument.symbol, exchange, await fetchTape(entry.instrument.symbol, exchange)];
350
369
  }
370
+ if (resolved.pane.id === "pe-band") capture.historyVariants = await peBandHistoryVariants(context, capture.ticker, exchange, data.priceHistory);
351
371
  if (includeOptionsChains && context.dataProvider.getOptionsChain) {
352
372
  // A future with no chain of its own is the pane's to explain (the listed alternative), not a failed shot.
353
373
  const chain = await context.dataProvider.getOptionsChain(entry.instrument.symbol, exchange, undefined,
@@ -425,6 +445,7 @@ export async function buildDesktopShotPayload(
425
445
  }
426
446
  if (capture.tape) tapeSnapshots.push(capture.tape);
427
447
  if (capture.chain) optionsChains.push(capture.chain);
448
+ if (capture.historyVariants?.length) historyVariants = [...historyVariants ?? [], ...capture.historyVariants];
428
449
  }
429
450
  }
430
451
  // PF over a period draws the report's P&L between the two closes: the page reads no history of its own.
@@ -20,6 +20,7 @@ import {
20
20
  deriveCaptureReport,
21
21
  deriveHeadlessFreshness,
22
22
  deriveRenderedFreshness,
23
+ statusDateEvidence,
23
24
  type CaptureReport,
24
25
  type CaptureStatusLine,
25
26
  type ReportFreshness,
@@ -323,7 +324,8 @@ export async function renderDesktopShot({
323
324
  freshness = line.freshness;
324
325
  // A row whose read failed is marked on the picture, where its figures are missing.
325
326
  const unread = unreadRowsNote(shotPayload.unreadRows);
326
- return { variants: unread ? line.variants.map((variant) => `${variant} · ${unread}`) : line.variants, dates: line.dates };
327
+ return { variants: unread ? line.variants.map((variant) => `${variant} · ${unread}`) : line.variants, dates: line.dates,
328
+ dateEvidence: statusDateEvidence(line.freshness) };
327
329
  },
328
330
  });
329
331
  covered = coverage && await settledWithin(coverage, SHOT_REPORT_WAIT_MS);
@@ -1,4 +1,4 @@
1
- import type { QuoteBatchResult } from "../types/data-provider";
1
+ import type { QuoteBatchOptions, QuoteBatchResult } from "../types/data-provider";
2
2
  import type { Quote } from "../types/financials";
3
3
  import { bareListingNote } from "../tickers/listing-fate";
4
4
  import { isRateLimited, isTransientServiceFailure, notATickerSymbol, rateLimitedError } from "../sources/provider-errors";
@@ -35,13 +35,13 @@ import {
35
35
  tradingBoardNote,
36
36
  type CliListing,
37
37
  type ListingDataRequest,
38
+ type ListingDeps,
38
39
  type ListingVenue,
39
40
  } from "./listing-arg";
40
41
  import { isNotATickerMessage, withListingSuggestion } from "./not-a-ticker";
41
42
  import { notATickerWords } from "./company-name-hint";
42
43
  import { isNetworkFailure } from "../utils/network-failure";
43
44
  import { logFailure } from "../utils/log-failure";
44
- import type { MarketContext } from "./types";
45
45
 
46
46
  /** The text of an error, or null for none. */
47
47
  export function errorMessage(error: unknown): string | null {
@@ -96,7 +96,7 @@ export interface QuoteAnswer {
96
96
  export async function answerQuote(
97
97
  result: QuoteBatchResult,
98
98
  listing: CliListing,
99
- market: MarketContext,
99
+ market: ListingDeps,
100
100
  request: ListingDataRequest,
101
101
  refresh: boolean,
102
102
  venues: Promise<ListingVenue[]> | null,
@@ -209,7 +209,7 @@ export async function answerQuote(
209
209
  * (`.IS`, `.JO`): another one-letter suffix is as likely a US share class
210
210
  * (MKC.V, BRK.B) and keeps its own answer. Null otherwise.
211
211
  */
212
- async function notTradedOnSuffixVenue(listing: CliListing, market: MarketContext): Promise<string | null> {
212
+ async function notTradedOnSuffixVenue(listing: CliListing, market: ListingDeps): Promise<string | null> {
213
213
  if (listing.exchange) return null;
214
214
  const suffix = listing.symbol.slice(listing.symbol.lastIndexOf(".") + 1);
215
215
  if (!listing.symbol.includes(".") || (suffix.length < 2 && suffix.toUpperCase() !== "L")) return null;
@@ -231,7 +231,7 @@ async function notTradedOnSuffixVenue(listing: CliListing, market: MarketContext
231
231
  async function answerCompanyName(
232
232
  result: QuoteBatchResult,
233
233
  listing: CliListing,
234
- market: MarketContext,
234
+ market: ListingDeps,
235
235
  request: ListingDataRequest,
236
236
  refresh: boolean,
237
237
  datesChangeBasis: boolean,
@@ -261,7 +261,7 @@ async function answerCompanyName(
261
261
  export async function withJoinedCompanyNames(
262
262
  answers: readonly QuoteAnswer[],
263
263
  asked: readonly CliListing[],
264
- market: MarketContext,
264
+ market: ListingDeps,
265
265
  request: ListingDataRequest,
266
266
  refresh: boolean,
267
267
  datesChangeBasis: boolean,
@@ -281,7 +281,7 @@ export async function withJoinedCompanyNames(
281
281
  async function abroadShareClass(
282
282
  listing: CliListing,
283
283
  quote: Quote,
284
- market: MarketContext,
284
+ market: ListingDeps,
285
285
  request: ListingDataRequest,
286
286
  refresh: boolean,
287
287
  datesChangeBasis: boolean,
@@ -297,7 +297,7 @@ async function abroadShareClass(
297
297
  */
298
298
  async function answerNamedListing(
299
299
  named: ListingArg,
300
- market: MarketContext,
300
+ market: ListingDeps,
301
301
  request: ListingDataRequest,
302
302
  refresh: boolean,
303
303
  datesChangeBasis: boolean,
@@ -309,12 +309,28 @@ async function answerNamedListing(
309
309
  });
310
310
  const found = resolved ? { ...resolved, readAs: named.readAs, ...named.meant ? { meant: named.meant } : {}, ...named.readFromName ? { readFromName: named.readFromName } : {},
311
311
  ...named.wordAsName ? { wordAsName: named.wordAsName } : {} } : null;
312
- const [quoted] = found ? await market.dataProvider.getQuotesBatch([found.request], { forceRefresh: refresh, revalidate: true, datesChangeBasis }) : [];
312
+ const quoted = found ? await quoteOne(market, found.request, { forceRefresh: refresh, revalidate: true, datesChangeBasis }) : null;
313
313
  return found && quoted?.quote ? answerQuote(quoted, found, market, request, refresh, null, { datesChangeBasis }) : null;
314
314
  }
315
315
 
316
+ /**
317
+ * One listing's quote as `quote` asks for it: the service's quote of the
318
+ * moment, through the batch request where the provider has one (the app's
319
+ * own provider may not), with why there is none.
320
+ */
321
+ async function quoteOne(deps: ListingDeps, target: { symbol: string; exchange: string }, options: QuoteBatchOptions): Promise<QuoteBatchResult> {
322
+ if (deps.dataProvider.getQuotesBatch) {
323
+ const [result] = await deps.dataProvider.getQuotesBatch([target], options);
324
+ return result ?? { target, quote: null };
325
+ }
326
+ return deps.dataProvider.getQuote(target.symbol, target.exchange, {
327
+ cacheMode: options.forceRefresh ? "refresh" : "default",
328
+ ...(options.datesChangeBasis ? { datesChangeBasis: true } : {}),
329
+ }).then((quote) => ({ target, quote }), (error: unknown) => ({ target, quote: null, error }));
330
+ }
331
+
316
332
  /** A listing a command found a quote for, with what `quote` says beside it. */
317
- interface QuotedListing {
333
+ export interface QuotedListing {
318
334
  /** The listing the quote is of: the one typed, or the venue a bare symbol was quoted on. */
319
335
  listing: CliListing;
320
336
  quote: Quote;
@@ -334,15 +350,15 @@ interface QuotedListing {
334
350
  export async function requireQuotedListing(
335
351
  raw: string,
336
352
  exchange: string | null | undefined,
337
- market: MarketContext,
353
+ market: ListingDeps,
338
354
  ctx: Pick<Parameters<CliCommandDef["execute"]>[1], "fail">,
339
355
  command: string,
340
356
  ): Promise<QuotedListing> {
341
357
  // A word that names a company is read after the quote, as `quote` reads it.
342
358
  const listing = await requireCliListing(raw, exchange, market, ctx, { companyWord: false });
343
359
  const venues = loadBareVenues(listing, market);
344
- const [result] = await market.dataProvider.getQuotesBatch([listing.request], { revalidate: true });
345
- const answer = await answerQuote(result ?? { target: listing.request, quote: null }, listing, market, { command, noun: "quote" }, false, venues);
360
+ const result = await quoteOne(market, listing.request, { revalidate: true });
361
+ const answer = await answerQuote(result, listing, market, { command, noun: "quote" }, false, venues);
346
362
  const quote = answer.result.quote;
347
363
  if (!quote) {
348
364
  if (answer.failure) ctx.fail(answer.failure.message, answer.failure.details);
@@ -375,7 +391,7 @@ export type IndexFormRead = () => Promise<Quote | null>;
375
391
  * goes beside the quote the service has not answered yet instead of after it. A symbol some venue lists asks only
376
392
  * when its answer needs it.
377
393
  */
378
- export function indexFormRead(listing: CliListing, market: MarketContext, venues: Promise<ListingVenue[]> | null): IndexFormRead | null {
394
+ export function indexFormRead(listing: CliListing, market: ListingDeps, venues: Promise<ListingVenue[]> | null): IndexFormRead | null {
379
395
  if (listing.exchange || listing.saved || !CARETLESS_INDEX.test(listing.symbol) || indexRootFor(listing.symbol)) return null;
380
396
  let read: Promise<Quote | null> | null = null;
381
397
  const start: IndexFormRead = () => read ??= Promise.resolve().then(() => market.dataProvider.getQuote(`^${listing.symbol}`, ""))
@@ -412,7 +428,7 @@ const FIVE_DIGIT_CODE = /^0\d{4}$/;
412
428
  * (Tencent Holdings Limited)". Null for any other symbol, a named or saved
413
429
  * listing, and a code HKEX does not list.
414
430
  */
415
- async function hongKongCodeNote(listing: CliListing, quote: Quote, market: MarketContext): Promise<string | null> {
431
+ async function hongKongCodeNote(listing: CliListing, quote: Quote, market: ListingDeps): Promise<string | null> {
416
432
  if (listing.exchange || listing.saved || !FIVE_DIGIT_CODE.test(listing.symbol)) return null;
417
433
  if (canonicalExchange(quote.listingExchangeName || quote.exchangeName) === "HKEX") return null;
418
434
  const code = String(Number(listing.symbol));
@@ -429,7 +445,7 @@ async function hongKongCodeNote(listing: CliListing, quote: Quote, market: Marke
429
445
  * Naira)?". When search finds nothing near, the row keeps its own error and its
430
446
  * search hint.
431
447
  */
432
- async function withCurrencyPairHint(result: QuoteBatchResult, market: MarketContext): Promise<QuoteBatchResult> {
448
+ async function withCurrencyPairHint(result: QuoteBatchResult, market: ListingDeps): Promise<QuoteBatchResult> {
433
449
  const message = errorMessage(result.error);
434
450
  const symbol = message ? notATickerSymbol(message) : null;
435
451
  if (!message || !symbol || !looksLikeCurrencyPair(symbol)) return result;
@@ -52,6 +52,8 @@ export interface CliCommandRegistry {
52
52
  config: AppConfig | null;
53
53
  /** The plugins that run here: loaded, switched on, and declaring the command line among their targets. */
54
54
  plugins: GloomPlugin[];
55
+ /** The ones of those that contribute data capabilities, which a command reading market data needs without the rest. */
56
+ readonly dataPlugins: GloomPlugin[];
55
57
  readonly idlePlugins: IdleCliPlugin[];
56
58
  externalPlugins: LoadedExternalPlugin[];
57
59
  /** Loads installed contributions when dispatch or application services need them. */
@@ -170,6 +172,10 @@ export function buildCliCommandRegistry({
170
172
  .filter((entry) => !entry.error && !entry.unsupportedTarget && !disabledPlugins.has(entry.plugin.id))
171
173
  .map((entry) => entry.plugin);
172
174
  },
175
+ get dataPlugins() {
176
+ const { getLoadableDataPlugins } = require("../plugins/catalog-data") as typeof import("../plugins/catalog-data");
177
+ return getLoadableDataPlugins(registry.externalPlugins).filter((plugin) => !disabledPlugins.has(plugin.id));
178
+ },
173
179
  get idlePlugins() {
174
180
  const { getPluginCatalog } = require("../plugins/catalog") as typeof import("../plugins/catalog");
175
181
  return getPluginCatalog(registry.externalPlugins).flatMap((entry): IdleCliPlugin[] => {
@@ -196,13 +202,23 @@ export function buildCliCommandRegistry({
196
202
 
197
203
  /** The idle plugins of each command's context, kept off the plugin API's context type. */
198
204
  const idlePluginsByContext = new WeakMap<CliCommandContext, () => IdleCliPlugin[]>();
205
+ /** How many installed plugins a command's context found, loading them first, kept off the plugin API's context type too. */
206
+ const installedPluginCountByContext = new WeakMap<CliCommandContext, () => Promise<number>>();
207
+
208
+ /**
209
+ * How many installed plugins (loaded, failed or switched to other targets) a command has beside the built-in ones.
210
+ * A command that answers from what the built-in plugins declare may do so only when this is none.
211
+ */
212
+ export async function installedPluginCount(ctx: CliCommandContext): Promise<number> {
213
+ return (await installedPluginCountByContext.get(ctx)?.()) ?? 0;
214
+ }
199
215
 
200
216
  /** The installed plugins a command's context does not run (`IdleCliPlugin`); none for a context built without a registry. */
201
217
  export function idleCliPlugins(ctx: CliCommandContext): IdleCliPlugin[] {
202
218
  return idlePluginsByContext.get(ctx)?.() ?? [];
203
219
  }
204
220
 
205
- type ContextRegistry = Pick<CliCommandRegistry, "plugins" | "externalPlugins" | "ensureExternalPlugins"> & Partial<Pick<CliCommandRegistry, "idlePlugins">>;
221
+ type ContextRegistry = Pick<CliCommandRegistry, "plugins" | "externalPlugins" | "ensureExternalPlugins"> & Partial<Pick<CliCommandRegistry, "idlePlugins" | "dataPlugins">>;
206
222
 
207
223
  export function createCliCommandContext(
208
224
  ownerId: string,
@@ -217,7 +233,7 @@ export function createCliCommandContext(
217
233
  initConfigData,
218
234
  initMarketData: async () => {
219
235
  await registry.ensureExternalPlugins?.();
220
- return initMarketData({ plugins: registry.plugins });
236
+ return initMarketData({ plugins: () => registry.plugins, ...registry.dataPlugins ? { dataPlugins: registry.dataPlugins } : {} });
221
237
  },
222
238
  initServices: async () => {
223
239
  await registry.ensureExternalPlugins?.();
@@ -240,5 +256,9 @@ export function createCliCommandContext(
240
256
  log: debugLog.createLogger(ownerId === "core" ? "cli" : ownerId),
241
257
  };
242
258
  idlePluginsByContext.set(ctx, () => registry.idlePlugins ?? []);
259
+ installedPluginCountByContext.set(ctx, async () => {
260
+ await registry.ensureExternalPlugins?.();
261
+ return registry.externalPlugins.length;
262
+ });
243
263
  return ctx;
244
264
  }
@@ -539,7 +539,7 @@ export function exportRowsTable<Row extends Record<string, unknown>>(
539
539
  title: string,
540
540
  columns: readonly CliReportColumn<Row>[],
541
541
  rows: readonly Row[],
542
- { status = false, rowUnitKey }: { status?: boolean; rowUnitKey?: string } = {},
542
+ { status = false, rowUnitKey, appendedColumns = 0 }: { status?: boolean; rowUnitKey?: string; appendedColumns?: number } = {},
543
543
  ): CliReportTable {
544
544
  const reasons = rows.map((): Array<{ header: string; text: string }> => []);
545
545
  const units = columns.map(columnUnit);
@@ -587,7 +587,14 @@ export function exportRowsTable<Row extends Record<string, unknown>>(
587
587
  header: columns.some((column) => column.header.trim().toLowerCase() === "status") ? "value_status" : "status",
588
588
  values: reasons.map(statusText),
589
589
  } : undefined;
590
- return assembleTable(title, resolved, rows.length, statusColumn);
590
+ const table = assembleTable(title, resolved, rows.length, statusColumn);
591
+ if (appendedColumns && statusColumn) {
592
+ const before = table.columns.length - 1 - appendedColumns;
593
+ const reorder = <Value,>(values: Value[]) => [...values.slice(0, before), values.at(-1)!, ...values.slice(before, -1)];
594
+ table.columns = reorder(table.columns);
595
+ table.rows = table.rows.map(reorder);
596
+ }
597
+ return appendedColumns ? { ...table, appendedColumns } : table;
591
598
  }
592
599
 
593
600
  /** Label/value lines as `Metric,Value`; a number's unit moves into its label. */
@@ -787,7 +794,14 @@ export function splitCsvFooter(text: string): { csv: string; footer: string[] }
787
794
  const last = blocks.at(-1) ?? "";
788
795
  const lines = last.split("\n");
789
796
  if (!last || !lines.every(isComment) || lines.some((line) => line.startsWith("# section: "))) return { csv: text, footer: [] };
790
- return { csv: blocks.slice(0, -1).join("\n\n"), footer: lines.map((line) => line.slice(2)) };
797
+ const csv = blocks.slice(0, -1).join("\n\n");
798
+ let quoted = false;
799
+ for (let index = 0; index < csv.length; index++) {
800
+ if (csv[index] !== '"') continue;
801
+ if (quoted && csv[index + 1] === '"') index++;
802
+ else quoted = !quoted;
803
+ }
804
+ return quoted ? { csv: text, footer: [] } : { csv, footer: lines.map((line) => line.slice(2)) };
791
805
  }
792
806
 
793
807
  /** CSV with its closing `#` lines after a blank line. */
package/src/cli/result.ts CHANGED
@@ -3,6 +3,7 @@ import type { CliGlobalOptions } from "./options";
3
3
  import {
4
4
  cliPlainEnabled,
5
5
  cliStyles,
6
+ cliText,
6
7
  cliTerminalWidth,
7
8
  renderForFile,
8
9
  renderStats,
@@ -15,6 +16,7 @@ import {
15
16
  type CliTableColumn,
16
17
  } from "../utils/cli-output";
17
18
  import { serializeCsv } from "../utils/csv";
19
+ import { portableCsv } from "./csv-export";
18
20
  import { logFailure } from "../utils/log-failure";
19
21
  import { formatUtcTime, isEpochMilliseconds, isZonedIsoDateTime } from "../utils/utc-time";
20
22
  import { formatFreshnessLine, withSavedCopy, type ReportFreshness } from "./pane-functions/freshness";
@@ -623,7 +625,7 @@ function serializeCliRows<T, Row extends Record<string, unknown>>(
623
625
  return withCsvFooter(csv, [...exportSourceLines(cited), ...cutNote, ...(renderOptions.exportNotes ?? []).map((note) => `note: ${note}`)]);
624
626
  }
625
627
  if (renderOptions.text) {
626
- return renderOptions.text(result.data);
628
+ return cliText(renderOptions.text(result.data));
627
629
  }
628
630
  // The heading's lines, the summary and the notes are prose: each wraps to a narrow --width, as the source line does.
629
631
  const summary = wrapToTerminal(renderOptions.summary?.(result.data) ?? "");
@@ -732,28 +734,24 @@ export function printCliResult<T, Row extends Record<string, unknown> = Record<s
732
734
  const serialized = hinted(toFile
733
735
  ? renderForFile(() => serializeCliResult(cells, options, renderOptions))
734
736
  : serializeCliResult(cells, options, renderOptions));
735
- // A CSV's closing source and note lines go to stderr with the warnings: in the file they are rows of junk to a spreadsheet.
736
737
  const { csv, footer } = options.format === "csv" ? splitCsvFooter(serialized) : { csv: serialized, footer: [] };
737
- const output = csv;
738
+ const output = options.format === "csv" ? portableCsv(serialized, result.warnings,
739
+ [...renderOptions.exportNotes ?? [], ...renderOptions.footnote ? [renderOptions.footnote] : []]) : csv;
738
740
  if (toFile) fileExport.push(output);
739
741
  // Bun's console writer can truncate a large pipe write after stdout has been
740
742
  // initialized. The stream queues the remaining bytes until the reader drains.
741
743
  else if (output && !process.stdout.write(`${output}\n`)) {
742
744
  stdoutWritten = new Promise((resolve) => process.stdout.once("drain", () => resolve()));
743
745
  }
744
- // JSON carries warnings in its envelope. Text, CSV and NDJSON are only the
745
- // rows, so a warning goes to stderr, out of a file the rows are piped into.
746
746
  if (options.format !== "json" && !options.quiet) {
747
747
  // Each wraps to a narrow --width, as a note does.
748
748
  for (const warning of result.warnings ?? []) {
749
- console.error(wrapToTerminal(`${cliStyles.warning("warning:")} ${hinted(warning)}`));
749
+ console.error(wrapToTerminal(`${cliStyles.warning("warning:")} ${hinted(cliText(warning))}`));
750
750
  }
751
751
  }
752
- if (!options.quiet) for (const line of footer) console.error(line);
753
- // CSV says what its rows do not in closing `note:` lines, on stderr; NDJSON has no place for one among its rows,
754
- // so the same notes go to stderr, where the warnings are.
752
+ if (!options.quiet) for (const line of footer) console.error(cliText(line));
755
753
  if (options.format === "ndjson" && !options.quiet) {
756
- for (const note of exportNdjsonNotes(result, options, renderOptions)) console.error(`note: ${note}`);
754
+ for (const note of exportNdjsonNotes(result, options, renderOptions)) console.error(cliText(`note: ${note}`));
757
755
  }
758
756
  }
759
757
 
@@ -41,11 +41,43 @@ const isWord = (text: string, word: string) => new RegExp(`(^|[^a-z0-9])${escape
41
41
  /** A series whose name, tags and group have every word whole outranks any that has one only as the start of a longer word. */
42
42
  const WHOLE_WORDS_SCORE = 10;
43
43
 
44
+ /** What a catalog search reads of a series: enough to rank and list it, none of the code that loads it. */
45
+ export interface CatalogSeriesFact {
46
+ id: string;
47
+ name: string;
48
+ unit: string;
49
+ frequency: string;
50
+ publisher?: string;
51
+ tags?: readonly string[];
52
+ group?: string;
53
+ description?: string;
54
+ /** What `fn G` charts. */
55
+ expression: string;
56
+ }
57
+
58
+ /**
59
+ * The catalog series the plugins declare, as a search reads them. Series that ask for a ticker are left out; a
60
+ * search names data, not a field of every stock. A formula priced in one delivery month (a crack) charts by its
61
+ * id: its expression alone would mix months.
62
+ */
63
+ export function catalogSeriesFacts(plugins: readonly SeriesSource[]): CatalogSeriesFact[] {
64
+ return plugins.flatMap((plugin) => plugin.series ?? []).flatMap((definition) => definition.input ? [] : [{
65
+ id: definition.id,
66
+ name: definition.name,
67
+ unit: definition.unit,
68
+ frequency: definition.frequency,
69
+ ...definition.publisher ? { publisher: definition.publisher } : {},
70
+ ...definition.tags ? { tags: definition.tags } : {},
71
+ ...definition.group ? { group: definition.group } : {},
72
+ ...definition.description ? { description: definition.description } : {},
73
+ expression: "rollsWith" in definition && definition.rollsWith ? definition.id : seriesExpression(definition),
74
+ }]);
75
+ }
76
+
44
77
  /**
45
78
  * The plugins' catalog series whose words cover every word of the query: in
46
79
  * the name and tags only for `search`, also the description and publisher for
47
- * `catalog`. Series that ask for a ticker are left out; a search names data,
48
- * not a field of every stock. A query that is a series' id (`policy-rate:ch`),
80
+ * `catalog`. A query that is a series' id (`policy-rate:ch`),
49
81
  * what `fn G` charts (`CAP:policy-rate:ch`, `FRED:DFEDTARU`) or a FRED series
50
82
  * id (`DFEDTARU`) ranks it first, then one whose name, tags and group have
51
83
  * each word whole (`defi` is Total DeFi TVL's tag, before the "deficit" of the
@@ -57,15 +89,22 @@ export function findCatalogSeries(
57
89
  plugins: readonly SeriesSource[],
58
90
  query: string,
59
91
  scope: "names" | "all" = "all",
92
+ ): SeriesMatch[] {
93
+ return findSeriesFacts(catalogSeriesFacts(plugins), query, scope);
94
+ }
95
+
96
+ /** `findCatalogSeries` over series already read as facts. */
97
+ export function findSeriesFacts(
98
+ facts: readonly CatalogSeriesFact[],
99
+ query: string,
100
+ scope: "names" | "all" = "all",
60
101
  ): SeriesMatch[] {
61
102
  const words = query.toLowerCase().replace(/["']/g, "").split(/\s+/).filter(Boolean);
62
103
  if (words.length === 0 || words.join("").length < 3) return [];
63
104
  const phrase = words.join(" ");
64
105
  const ranked: Array<{ match: SeriesMatch; score: number; order: number }> = [];
65
- for (const definition of plugins.flatMap((plugin) => plugin.series ?? [])) {
66
- if (definition.input) continue;
67
- // A formula priced in one delivery month (a crack) charts by its id: its expression alone would mix months.
68
- const expression = "rollsWith" in definition && definition.rollsWith ? definition.id : seriesExpression(definition);
106
+ for (const definition of facts) {
107
+ const expression = definition.expression;
69
108
  const byId = words.length === 1
70
109
  && [definition.id, expression, fredSeriesIdOf(expression) ?? ""].some((id) => id.toLowerCase() === phrase);
71
110
  const name = definition.name.toLowerCase();
@@ -1,12 +1,8 @@
1
- import { mkdtemp, rm } from "fs/promises";
1
+ import { mkdtemp } from "fs/promises";
2
2
  import { tmpdir } from "os";
3
3
  import { join } from "path";
4
4
  import { logFailure } from "../utils/log-failure";
5
-
6
- type RemoveFolder = (
7
- path: string,
8
- options: { recursive: true; force: true; maxRetries: number; retryDelay: number },
9
- ) => Promise<void>;
5
+ import { removeFolder, type RemoveFolderOptions } from "../utils/remove-folder";
10
6
 
11
7
  /**
12
8
  * Hands `use` a fresh folder under the system temp folder and removes it
@@ -18,13 +14,12 @@ type RemoveFolder = (
18
14
  export async function withShotTempDir<T>(
19
15
  prefix: string,
20
16
  use: (dir: string) => Promise<T>,
21
- remove: RemoveFolder = rm,
17
+ removal: RemoveFolderOptions = {},
22
18
  ): Promise<T> {
23
19
  const dir = await mkdtemp(join(tmpdir(), prefix));
24
20
  try {
25
21
  return await use(dir);
26
22
  } finally {
27
- await remove(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
28
- .catch(logFailure("cli.screenshot", "Could not remove a capture's temporary folder"));
23
+ if (await removeFolder(dir, removal) !== null) logFailure("cli.screenshot", "Could not remove a capture's temporary folder")(null);
29
24
  }
30
25
  }