@gloom-sh/terminal 0.20.12 → 0.20.14

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 (616) hide show
  1. package/package.json +2 -1
  2. package/patches/@opentui%2Fcore@0.3.2.patch +22 -4
  3. package/src/account/auth-dialog.tsx +22 -4
  4. package/src/account/auth-form.tsx +6 -1
  5. package/src/account/billing.ts +3 -2
  6. package/src/account/checkout-handoff.tsx +7 -14
  7. package/src/account/device-signin-dialog.tsx +35 -24
  8. package/src/account/upgrade-dialog.tsx +8 -8
  9. package/src/api-client/crypto-markets.ts +10 -0
  10. package/src/api-client/errors.ts +3 -1
  11. package/src/api-client/index.ts +10 -2
  12. package/src/api-client/install-experiments.ts +146 -0
  13. package/src/api-client/money-markets.ts +7 -0
  14. package/src/api-client/request.ts +12 -2
  15. package/src/api-client/telemetry.ts +47 -0
  16. package/src/api-client/types/market.ts +4 -0
  17. package/src/api-client/types/news.ts +16 -0
  18. package/src/architecture/floating-promise-allowlist.json +17 -34
  19. package/src/brokers/signed-in/adapter.ts +2 -2
  20. package/src/brokers/signed-in/catalog.ts +13 -4
  21. package/src/brokers/signed-in/sign-in-dialog.tsx +38 -38
  22. package/src/cli/commands/market.ts +146 -55
  23. package/src/cli/commands/overview.ts +21 -7
  24. package/src/cli/commands/search.ts +103 -9
  25. package/src/cli/commands/ticker.ts +22 -13
  26. package/src/cli/earnings-calendar.ts +33 -53
  27. package/src/cli/errors.ts +3 -1
  28. package/src/cli/freshness.ts +7 -2
  29. package/src/cli/glossary.ts +10 -5
  30. package/src/cli/helpers.ts +8 -16
  31. package/src/cli/history-export.ts +4 -0
  32. package/src/cli/history-rows.ts +18 -1
  33. package/src/cli/known-gaps.ts +11 -2
  34. package/src/cli/listing-arg.ts +183 -28
  35. package/src/cli/not-a-ticker.ts +4 -0
  36. package/src/cli/pane-functions/catalog.ts +81 -12
  37. package/src/cli/pane-functions/dom.ts +8 -1
  38. package/src/cli/pane-functions/freshness.ts +2 -2
  39. package/src/cli/pane-functions/headless.ts +13 -10
  40. package/src/cli/pane-functions/index.ts +1 -1
  41. package/src/cli/pane-functions/options.ts +7 -0
  42. package/src/cli/pane-functions/report.ts +4 -1
  43. package/src/cli/pane-functions/resolver.ts +61 -15
  44. package/src/cli/perpetual-contract.ts +4 -4
  45. package/src/cli/quote-answer.ts +6 -2
  46. package/src/cli/result.ts +24 -5
  47. package/src/cli/symbol-args.ts +5 -3
  48. package/src/cli/symbol-list.ts +23 -10
  49. package/src/cli/symbol-rows.ts +135 -3
  50. package/src/cli/treasury-yields.ts +15 -1
  51. package/src/components/chart/composite/axis-overlays.tsx +5 -2
  52. package/src/components/chart/composite/composite-chart.tsx +1 -0
  53. package/src/components/chart/composite/format.ts +103 -16
  54. package/src/components/chart/composite/legend.tsx +60 -25
  55. package/src/components/chart/composite/panel-surface/axis-markers.ts +133 -0
  56. package/src/components/chart/composite/panel-surface/level-labels.tsx +78 -0
  57. package/src/components/chart/composite/panel-surface/overlays.ts +108 -0
  58. package/src/components/chart/composite/panel-surface/pan-coast.ts +54 -0
  59. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +138 -0
  60. package/src/components/chart/composite/panel-surface/panel-levels.ts +47 -0
  61. package/src/components/chart/composite/panel-surface/plot-gestures.ts +403 -0
  62. package/src/components/chart/composite/panel-surface/plot-pointer.ts +65 -0
  63. package/src/components/chart/composite/panel-surface/plot-wheel.ts +102 -0
  64. package/src/components/chart/composite/panel-surface/pointer.ts +12 -0
  65. package/src/components/chart/composite/panel-surface/props.ts +79 -0
  66. package/src/components/chart/composite/panel-surface/tool-readout.ts +151 -0
  67. package/src/components/chart/composite/panel-surface/value-axis-gestures.ts +152 -0
  68. package/src/components/chart/composite/panel-surface.tsx +81 -1177
  69. package/src/components/chart/composite/time-axis.ts +51 -29
  70. package/src/components/chart/composite/toolbar.tsx +42 -6
  71. package/src/components/chart/curve/curve-surface.tsx +5 -5
  72. package/src/components/command-bar/commands/collection-list.ts +1 -0
  73. package/src/components/command-bar/list/badge.ts +8 -5
  74. package/src/components/command-bar/list/model.ts +0 -5
  75. package/src/components/command-bar/list/view.tsx +39 -2
  76. package/src/components/command-bar/routes/root/plugin-install.ts +4 -2
  77. package/src/components/command-bar/routes/root/provider-search.ts +23 -3
  78. package/src/components/command-bar/routes/root/results.ts +23 -11
  79. package/src/components/command-bar/routes/root/runtime.ts +3 -2
  80. package/src/components/command-bar/routes/root/selection.ts +3 -2
  81. package/src/components/command-bar/routes/root/shortcuts.ts +15 -0
  82. package/src/components/command-bar/routes/root/start-here.ts +1 -2
  83. package/src/components/command-bar/routes/ticker-search/actions.ts +2 -3
  84. package/src/components/command-bar/routes/ticker-search/results.ts +23 -4
  85. package/src/components/data-table/view.tsx +29 -6
  86. package/src/components/form-modal/host.tsx +1 -1
  87. package/src/components/layout/header.tsx +3 -2
  88. package/src/components/layout/market-summary.ts +3 -3
  89. package/src/components/layout/pane/error-boundary.tsx +2 -1
  90. package/src/components/layout/pane/title.ts +10 -4
  91. package/src/components/markdown-text.tsx +36 -0
  92. package/src/components/market-board/index.tsx +4 -3
  93. package/src/components/onboarding/first-run-workspace.ts +46 -11
  94. package/src/components/onboarding/onboarding-keyboard.ts +57 -5
  95. package/src/components/onboarding/onboarding-wizard.tsx +91 -24
  96. package/src/components/onboarding/portfolio-step/index.tsx +1 -0
  97. package/src/components/onboarding/portfolio-step/positions-panel.tsx +36 -9
  98. package/src/components/onboarding/portfolio-step/types.ts +2 -0
  99. package/src/components/onboarding/tickers-step-model.ts +140 -0
  100. package/src/components/onboarding/tickers-step.tsx +116 -0
  101. package/src/components/onboarding/use-onboarding-broker-form.ts +1 -1
  102. package/src/components/onboarding/use-onboarding-progress.ts +100 -11
  103. package/src/components/onboarding/use-onboarding-upgrade.ts +3 -2
  104. package/src/components/onboarding/wizard-model.ts +3 -1
  105. package/src/components/onboarding/wizard-tickers.ts +139 -0
  106. package/src/components/pane-settings-dialog/tui.tsx +6 -3
  107. package/src/components/pane-settings-dialog.tsx +2 -1
  108. package/src/components/pane-template-wizard.tsx +2 -0
  109. package/src/components/price-performance.tsx +2 -2
  110. package/src/components/speedometer-gauge/model.ts +2 -1
  111. package/src/components/speedometer-gauge/terminal.tsx +13 -8
  112. package/src/components/ui/choice-dialog.tsx +102 -33
  113. package/src/components/ui/confirm-dialog.tsx +3 -2
  114. package/src/components/ui/frame.tsx +7 -3
  115. package/src/components/ui/icon.tsx +4 -2
  116. package/src/components/ui/list-view.tsx +8 -0
  117. package/src/components/ui/multi-select/dialog.tsx +1 -7
  118. package/src/components/ui/not-meaningful.ts +16 -0
  119. package/src/components/ui/number-prompt-dialog.tsx +2 -1
  120. package/src/components/ui/query-bar.tsx +16 -4
  121. package/src/components/ui/stat-grid.tsx +27 -6
  122. package/src/components/use-pane-notice-footer.tsx +3 -1
  123. package/src/data/config/store/normalize.ts +2 -0
  124. package/src/docs/snapshot.json +3 -3
  125. package/src/i18n/es.ts +6 -2
  126. package/src/i18n/ja.ts +6 -2
  127. package/src/i18n/ko.ts +6 -2
  128. package/src/i18n/zh-cn.ts +6 -2
  129. package/src/i18n/zh-tw.ts +6 -2
  130. package/src/layout-marketplace/model.ts +2 -1
  131. package/src/market-data/futures-contract.ts +2 -1
  132. package/src/market-data/hooks.tsx +1 -1
  133. package/src/market-data/market/change-basis.ts +27 -5
  134. package/src/market-data/market/format.ts +48 -14
  135. package/src/market-data/quotes/contributions.ts +13 -0
  136. package/src/market-data/quotes/export-identity.ts +36 -1
  137. package/src/market-data/quotes/listing-enterprise-value.ts +3 -3
  138. package/src/market-data/quotes/resolution.ts +16 -0
  139. package/src/market-data/quotes/time.ts +17 -10
  140. package/src/market-data/tax-equivalent.ts +3 -2
  141. package/src/news/aggregator.ts +19 -8
  142. package/src/news/hooks.ts +1 -1
  143. package/src/news/news-model.ts +49 -0
  144. package/src/news/types.ts +9 -0
  145. package/src/plugins/builtin/account-management/calendar-tab.tsx +8 -3
  146. package/src/plugins/builtin/account-management/pane.tsx +9 -8
  147. package/src/plugins/builtin/account-management/password-dialog.tsx +2 -2
  148. package/src/plugins/builtin/alerts/calendar-events.ts +4 -5
  149. package/src/plugins/builtin/alerts/format.ts +6 -5
  150. package/src/plugins/builtin/alerts/headless.ts +3 -2
  151. package/src/plugins/builtin/alerts/history.ts +2 -1
  152. package/src/plugins/builtin/alerts/pane.tsx +2 -1
  153. package/src/plugins/builtin/alerts/price-text.ts +2 -1
  154. package/src/plugins/builtin/alerts/scheduled.ts +6 -5
  155. package/src/plugins/builtin/analytics/account-returns.ts +6 -7
  156. package/src/plugins/builtin/analytics/display.ts +2 -1
  157. package/src/plugins/builtin/analytics/pane-model.ts +5 -9
  158. package/src/plugins/builtin/analytics/risk-client.ts +12 -2
  159. package/src/plugins/builtin/analytics/risk-headless.ts +66 -6
  160. package/src/plugins/builtin/analytics/risk-math.ts +23 -6
  161. package/src/plugins/builtin/analytics/risk-model.ts +26 -15
  162. package/src/plugins/builtin/analytics/risk-pane.tsx +8 -7
  163. package/src/plugins/builtin/analytics/view.tsx +5 -5
  164. package/src/plugins/builtin/attention/model.ts +6 -5
  165. package/src/plugins/builtin/attention/pane.tsx +5 -4
  166. package/src/plugins/builtin/awards/detail.tsx +5 -4
  167. package/src/plugins/builtin/awards/headless.ts +8 -7
  168. package/src/plugins/builtin/awards/model.ts +4 -3
  169. package/src/plugins/builtin/awards/pane.tsx +4 -4
  170. package/src/plugins/builtin/backtest/format.ts +3 -2
  171. package/src/plugins/builtin/backtest/report.ts +3 -2
  172. package/src/plugins/builtin/bond-calculator/headless.ts +2 -1
  173. package/src/plugins/builtin/bond-calculator/pane.tsx +2 -1
  174. package/src/plugins/builtin/broker-manager/add-flow.tsx +1 -1
  175. package/src/plugins/builtin/broker-trading/orders-data.ts +3 -3
  176. package/src/plugins/builtin/broker-trading/orders.tsx +3 -2
  177. package/src/plugins/builtin/broker-trading/ticket.tsx +2 -2
  178. package/src/plugins/builtin/buildout/cells.tsx +2 -1
  179. package/src/plugins/builtin/buildout/company/pane.tsx +4 -3
  180. package/src/plugins/builtin/buildout/data-runtime.ts +21 -23
  181. package/src/plugins/builtin/buildout/detail/values.ts +2 -1
  182. package/src/plugins/builtin/buildout/format.ts +4 -3
  183. package/src/plugins/builtin/buildout/pane/index.tsx +3 -3
  184. package/src/plugins/builtin/catalysts/detail.tsx +2 -1
  185. package/src/plugins/builtin/catalysts/model.ts +6 -5
  186. package/src/plugins/builtin/catalysts/pane.tsx +2 -1
  187. package/src/plugins/builtin/cds/headless.ts +3 -2
  188. package/src/plugins/builtin/cds/model.ts +8 -8
  189. package/src/plugins/builtin/cds/pane.tsx +3 -2
  190. package/src/plugins/builtin/central-bank-rates/headless.ts +2 -1
  191. package/src/plugins/builtin/central-bank-rates/model.ts +3 -2
  192. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -5
  193. package/src/plugins/builtin/changelog/index.tsx +2 -2
  194. package/src/plugins/builtin/chart-composer/catalog-inventory.ts +5 -2
  195. package/src/plugins/builtin/chart-composer/editor.tsx +1 -0
  196. package/src/plugins/builtin/chart-composer/index.tsx +4 -2
  197. package/src/plugins/builtin/chart-composer/pane.tsx +8 -4
  198. package/src/plugins/builtin/chart-composer/quick-add.tsx +4 -1
  199. package/src/plugins/builtin/chart-composer/series-catalog.ts +17 -1
  200. package/src/plugins/builtin/chart-composer/use-series-catalog.ts +3 -1
  201. package/src/plugins/builtin/chart-composer/user-series.ts +3 -1
  202. package/src/plugins/builtin/chat/attachments/desktop.tsx +2 -1
  203. package/src/plugins/builtin/chat/controller/utils.ts +2 -1
  204. package/src/plugins/builtin/clinical-trials/model.ts +4 -3
  205. package/src/plugins/builtin/clinical-trials/sponsor-tickers.ts +4 -2
  206. package/src/plugins/builtin/cloud/askg/lock-note.ts +16 -4
  207. package/src/plugins/builtin/cloud/askg/model.ts +2 -1
  208. package/src/plugins/builtin/cloud/askg/pane.tsx +35 -1
  209. package/src/plugins/builtin/cloud/company-picker.tsx +1 -3
  210. package/src/plugins/builtin/cloud/plugin.tsx +2 -0
  211. package/src/plugins/builtin/cloud/team/pane.tsx +12 -12
  212. package/src/plugins/builtin/cloud/thesis/detail.tsx +13 -8
  213. package/src/plugins/builtin/cloud/thesis/module.tsx +2 -0
  214. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +6 -2
  215. package/src/plugins/builtin/cloud-tweets/model.ts +2 -2
  216. package/src/plugins/builtin/comment-letters/pane.tsx +2 -1
  217. package/src/plugins/builtin/commodity-balances/headless.ts +3 -2
  218. package/src/plugins/builtin/company-attention/app-rank.tsx +5 -4
  219. package/src/plugins/builtin/company-attention/building-model.ts +7 -7
  220. package/src/plugins/builtin/company-attention/headless.ts +6 -5
  221. package/src/plugins/builtin/company-attention/model.ts +4 -4
  222. package/src/plugins/builtin/company-attention/moves-model.ts +9 -9
  223. package/src/plugins/builtin/company-attention/signals-model.ts +9 -9
  224. package/src/plugins/builtin/company-kpis/headless.ts +2 -1
  225. package/src/plugins/builtin/company-kpis/model.ts +15 -10
  226. package/src/plugins/builtin/company-kpis/pane.tsx +2 -2
  227. package/src/plugins/builtin/congress-trades/detail.tsx +6 -5
  228. package/src/plugins/builtin/congress-trades/headless.ts +2 -1
  229. package/src/plugins/builtin/congress-trades/model.ts +6 -6
  230. package/src/plugins/builtin/congress-trades/table.tsx +7 -6
  231. package/src/plugins/builtin/connections/pane.tsx +5 -5
  232. package/src/plugins/builtin/correlation/headless.ts +2 -2
  233. package/src/plugins/builtin/correlation/index.tsx +4 -1
  234. package/src/plugins/builtin/correlation/matrix/selection.ts +2 -1
  235. package/src/plugins/builtin/correlation/relationship/view-model.ts +3 -3
  236. package/src/plugins/builtin/cot/headless.ts +3 -2
  237. package/src/plugins/builtin/cot/model.ts +2 -1
  238. package/src/plugins/builtin/cot/pane.tsx +4 -3
  239. package/src/plugins/builtin/cpi/headless.ts +10 -4
  240. package/src/plugins/builtin/cpi/model.ts +25 -7
  241. package/src/plugins/builtin/cpi/pane.tsx +3 -1
  242. package/src/plugins/builtin/credit-boards/cdx-pane.tsx +5 -4
  243. package/src/plugins/builtin/credit-boards/headless.ts +2 -1
  244. package/src/plugins/builtin/credit-boards/model.ts +5 -5
  245. package/src/plugins/builtin/credit-conditions/headless.ts +2 -1
  246. package/src/plugins/builtin/credit-conditions/index.tsx +2 -2
  247. package/src/plugins/builtin/credit-documents/model.ts +2 -2
  248. package/src/plugins/builtin/crypto-board/client.ts +6 -1
  249. package/src/plugins/builtin/crypto-board/defi-view.tsx +7 -7
  250. package/src/plugins/builtin/crypto-board/defi.ts +2 -2
  251. package/src/plugins/builtin/crypto-board/headless.ts +10 -2
  252. package/src/plugins/builtin/crypto-board/model.ts +93 -14
  253. package/src/plugins/builtin/crypto-board/pane.tsx +28 -13
  254. package/src/plugins/builtin/crypto-board/supply.ts +2 -2
  255. package/src/plugins/builtin/crypto-etf-flows/model.ts +4 -4
  256. package/src/plugins/builtin/custom-view/index.tsx +3 -1
  257. package/src/plugins/builtin/custom-view/pane.tsx +5 -1
  258. package/src/plugins/builtin/custom-view/view-spec.ts +11 -0
  259. package/src/plugins/builtin/debt-maturities/model.ts +3 -3
  260. package/src/plugins/builtin/debt-maturities/pane.tsx +2 -2
  261. package/src/plugins/builtin/dividend-yield/client.ts +31 -5
  262. package/src/plugins/builtin/dividend-yield/headless.ts +20 -13
  263. package/src/plugins/builtin/dividend-yield/pane.tsx +12 -10
  264. package/src/plugins/builtin/dividend-yield/ranking-view.tsx +4 -1
  265. package/src/plugins/builtin/dividend-yield/ranking.ts +21 -12
  266. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  267. package/src/plugins/builtin/dividend-yield/view.ts +8 -4
  268. package/src/plugins/builtin/docs/use-docs.ts +4 -2
  269. package/src/plugins/builtin/doe/headless.ts +2 -1
  270. package/src/plugins/builtin/doe/model.ts +12 -11
  271. package/src/plugins/builtin/earnings/board-model.ts +14 -8
  272. package/src/plugins/builtin/earnings/board-table.ts +13 -8
  273. package/src/plugins/builtin/earnings/calendar-model.ts +5 -5
  274. package/src/plugins/builtin/earnings/calendar.tsx +2 -1
  275. package/src/plugins/builtin/earnings/format.ts +16 -14
  276. package/src/plugins/builtin/earnings/headless.ts +57 -19
  277. package/src/plugins/builtin/earnings/history-model.ts +11 -7
  278. package/src/plugins/builtin/earnings/history-table.ts +22 -9
  279. package/src/plugins/builtin/earnings/history.tsx +4 -3
  280. package/src/plugins/builtin/earnings-calls/calendar.tsx +2 -1
  281. package/src/plugins/builtin/earnings-calls/format.ts +6 -5
  282. package/src/plugins/builtin/earnings-calls/upcoming.ts +5 -5
  283. package/src/plugins/builtin/earnings-ripple/headless.ts +2 -1
  284. package/src/plugins/builtin/earnings-ripple/index.tsx +2 -0
  285. package/src/plugins/builtin/earnings-ripple/model.ts +3 -2
  286. package/src/plugins/builtin/earnings-ripple/pane.tsx +6 -6
  287. package/src/plugins/builtin/econ/calendar-model.ts +19 -3
  288. package/src/plugins/builtin/econ/detail-view.tsx +2 -2
  289. package/src/plugins/builtin/econ/fred-catalog.ts +33 -4
  290. package/src/plugins/builtin/econ/index.tsx +7 -6
  291. package/src/plugins/builtin/econ-statistics/detail.tsx +2 -1
  292. package/src/plugins/builtin/econ-statistics/headless.ts +25 -4
  293. package/src/plugins/builtin/econ-statistics/pane.tsx +2 -2
  294. package/src/plugins/builtin/equity-screener/headless.ts +5 -5
  295. package/src/plugins/builtin/equity-screener/model.ts +6 -4
  296. package/src/plugins/builtin/equity-screener/pane.tsx +7 -7
  297. package/src/plugins/builtin/equity-screener/screen-check.ts +2 -1
  298. package/src/plugins/builtin/equity-screener/ticker-check.tsx +2 -1
  299. package/src/plugins/builtin/estimate-revisions/model.ts +3 -2
  300. package/src/plugins/builtin/estimate-revisions/pane.tsx +8 -8
  301. package/src/plugins/builtin/executives/format.ts +4 -4
  302. package/src/plugins/builtin/exposure/headless.ts +8 -8
  303. package/src/plugins/builtin/exposure/model.ts +4 -3
  304. package/src/plugins/builtin/exposure/pane.tsx +6 -5
  305. package/src/plugins/builtin/fear-greed/format.ts +7 -7
  306. package/src/plugins/builtin/fear-greed/headless.ts +2 -1
  307. package/src/plugins/builtin/filing-events/feed.ts +2 -1
  308. package/src/plugins/builtin/futures/table.tsx +8 -8
  309. package/src/plugins/builtin/futures-curve/headless.ts +18 -18
  310. package/src/plugins/builtin/futures-curve/model.ts +5 -5
  311. package/src/plugins/builtin/futures-curve/pane.tsx +8 -8
  312. package/src/plugins/builtin/fx-matrix/index.tsx +2 -2
  313. package/src/plugins/builtin/fx-matrix/pairs.ts +2 -1
  314. package/src/plugins/builtin/gpu/board.tsx +6 -5
  315. package/src/plugins/builtin/gpu/changes.tsx +2 -1
  316. package/src/plugins/builtin/gpu/equities.tsx +2 -2
  317. package/src/plugins/builtin/gpu/headless.ts +4 -3
  318. package/src/plugins/builtin/gpu/model.ts +8 -7
  319. package/src/plugins/builtin/help/functions-table.tsx +41 -9
  320. package/src/plugins/builtin/help/index.tsx +6 -3
  321. package/src/plugins/builtin/help/keybindings-editor.tsx +35 -7
  322. package/src/plugins/builtin/help/shortcut-table.tsx +19 -7
  323. package/src/plugins/builtin/help/table-cells.tsx +51 -0
  324. package/src/plugins/builtin/holders/pane.tsx +4 -1
  325. package/src/plugins/builtin/insider/base-values.ts +2 -2
  326. package/src/plugins/builtin/insider/display.ts +2 -1
  327. package/src/plugins/builtin/insider/headless.ts +16 -16
  328. package/src/plugins/builtin/insider/insider-data.ts +2 -1
  329. package/src/plugins/builtin/insider/signals-model.ts +3 -3
  330. package/src/plugins/builtin/insider/table-model.ts +27 -13
  331. package/src/plugins/builtin/insider/table.tsx +1 -1
  332. package/src/plugins/builtin/ipo-calendar/model.ts +4 -4
  333. package/src/plugins/builtin/iv-history/format.ts +8 -7
  334. package/src/plugins/builtin/iv-history/headless.ts +9 -8
  335. package/src/plugins/builtin/iv-history/pane.tsx +3 -2
  336. package/src/plugins/builtin/iv-history/screen-pane.tsx +5 -4
  337. package/src/plugins/builtin/jobs/headless.ts +11 -11
  338. package/src/plugins/builtin/jobs/model.ts +2 -2
  339. package/src/plugins/builtin/jobs/pane.tsx +5 -5
  340. package/src/plugins/builtin/jodi/model.ts +2 -2
  341. package/src/plugins/builtin/jodi/pane.tsx +2 -1
  342. package/src/plugins/builtin/kelly-sizer/headless.ts +4 -4
  343. package/src/plugins/builtin/kelly-sizer/model.ts +2 -1
  344. package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -2
  345. package/src/plugins/builtin/macro-day/headless.ts +27 -15
  346. package/src/plugins/builtin/macro-day/model.ts +42 -4
  347. package/src/plugins/builtin/macro-day/pane.tsx +30 -12
  348. package/src/plugins/builtin/macro-day/releases.ts +24 -1
  349. package/src/plugins/builtin/market-halts/model.ts +11 -10
  350. package/src/plugins/builtin/market-halts/pane.tsx +2 -1
  351. package/src/plugins/builtin/market-heatmap/index.tsx +4 -4
  352. package/src/plugins/builtin/market-movers/session-table.ts +3 -3
  353. package/src/plugins/builtin/market-movers/session.ts +2 -1
  354. package/src/plugins/builtin/market-movers/table.ts +5 -5
  355. package/src/plugins/builtin/market-valuation/detail.tsx +2 -2
  356. package/src/plugins/builtin/market-valuation/headless.ts +7 -7
  357. package/src/plugins/builtin/market-valuation/pane.tsx +7 -7
  358. package/src/plugins/builtin/members/breadth-pane.tsx +5 -4
  359. package/src/plugins/builtin/members/headless.ts +2 -1
  360. package/src/plugins/builtin/members/model.ts +3 -2
  361. package/src/plugins/builtin/members/pane.tsx +10 -9
  362. package/src/plugins/builtin/mna/distress/model.ts +2 -1
  363. package/src/plugins/builtin/mna/model.ts +5 -5
  364. package/src/plugins/builtin/money-markets/client.ts +4 -1
  365. package/src/plugins/builtin/money-markets/headless.ts +17 -5
  366. package/src/plugins/builtin/money-markets/index.tsx +1 -1
  367. package/src/plugins/builtin/money-markets/model.ts +3 -2
  368. package/src/plugins/builtin/money-markets/pane.tsx +11 -5
  369. package/src/plugins/builtin/news/headless.ts +5 -2
  370. package/src/plugins/builtin/news/wire/breaking/notifications.ts +21 -19
  371. package/src/plugins/builtin/news/wire/news/row.ts +3 -1
  372. package/src/plugins/builtin/news/wire/news/table.tsx +3 -2
  373. package/src/plugins/builtin/news/wire/persisted-articles.ts +28 -3
  374. package/src/plugins/builtin/notes/headless.ts +2 -1
  375. package/src/plugins/builtin/notes/model.ts +2 -1
  376. package/src/plugins/builtin/openfda/pane.tsx +4 -3
  377. package/src/plugins/builtin/options/carry.ts +3 -2
  378. package/src/plugins/builtin/options/market-reference.ts +2 -1
  379. package/src/plugins/builtin/options/table.ts +48 -9
  380. package/src/plugins/builtin/options/view.tsx +47 -17
  381. package/src/plugins/builtin/options-calculator/headless.ts +3 -2
  382. package/src/plugins/builtin/options-calculator/pane.tsx +7 -7
  383. package/src/plugins/builtin/options-positioning/headless.ts +8 -7
  384. package/src/plugins/builtin/options-positioning/model.ts +10 -10
  385. package/src/plugins/builtin/options-positioning/pane.tsx +5 -5
  386. package/src/plugins/builtin/options-scenario/collar.ts +5 -4
  387. package/src/plugins/builtin/options-scenario/csp-screen-headless.ts +11 -10
  388. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +15 -14
  389. package/src/plugins/builtin/options-scenario/csp-screen.ts +2 -1
  390. package/src/plugins/builtin/options-scenario/csp.ts +6 -5
  391. package/src/plugins/builtin/options-scenario/headless.ts +6 -5
  392. package/src/plugins/builtin/options-scenario/hedge.ts +3 -3
  393. package/src/plugins/builtin/options-scenario/pane.tsx +7 -6
  394. package/src/plugins/builtin/options-scenario/strategy-screen.ts +1 -1
  395. package/src/plugins/builtin/pe-band/headless.ts +9 -8
  396. package/src/plugins/builtin/pe-band/pane.tsx +7 -7
  397. package/src/plugins/builtin/perps/cascade.ts +3 -2
  398. package/src/plugins/builtin/perps/headless.ts +10 -9
  399. package/src/plugins/builtin/perps/model.ts +14 -14
  400. package/src/plugins/builtin/perps/pane.tsx +3 -2
  401. package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -2
  402. package/src/plugins/builtin/portfolio-list/cli/period-report.ts +61 -11
  403. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +11 -3
  404. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +2 -0
  405. package/src/plugins/builtin/portfolio-list/header.tsx +2 -2
  406. package/src/plugins/builtin/portfolio-list/headless.ts +33 -6
  407. package/src/plugins/builtin/portfolio-list/index.tsx +3 -2
  408. package/src/plugins/builtin/portfolio-list/pane/futures-terms.ts +4 -2
  409. package/src/plugins/builtin/portfolio-list/pane/index.tsx +5 -3
  410. package/src/plugins/builtin/portfolio-list/pane/period-pnl.ts +26 -7
  411. package/src/plugins/builtin/portfolio-list/pane/purchase-date-fx.ts +4 -2
  412. package/src/plugins/builtin/portfolio-list/period-pnl.ts +16 -1
  413. package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +2 -2
  414. package/src/plugins/builtin/portfolio-list/settings.ts +4 -1
  415. package/src/plugins/builtin/portfolio-list/summary/index.tsx +8 -5
  416. package/src/plugins/builtin/portfolio-list/summary/totals.ts +6 -4
  417. package/src/plugins/builtin/portfolio-list/table.tsx +25 -15
  418. package/src/plugins/builtin/power/detail.tsx +6 -5
  419. package/src/plugins/builtin/power/gas-model.ts +8 -7
  420. package/src/plugins/builtin/power/gas.tsx +2 -1
  421. package/src/plugins/builtin/power/headless.ts +7 -6
  422. package/src/plugins/builtin/power/model.ts +3 -2
  423. package/src/plugins/builtin/power/prices-headless.ts +10 -9
  424. package/src/plugins/builtin/power/prices-model.ts +3 -2
  425. package/src/plugins/builtin/power/prices.tsx +2 -1
  426. package/src/plugins/builtin/primary-dealers/model.ts +3 -3
  427. package/src/plugins/builtin/primary-dealers/pane.tsx +2 -2
  428. package/src/plugins/builtin/rate-path/headless.ts +8 -7
  429. package/src/plugins/builtin/rate-path/model.ts +6 -5
  430. package/src/plugins/builtin/rate-path/pane.tsx +6 -5
  431. package/src/plugins/builtin/realized-vol/fx-proxy.ts +2 -1
  432. package/src/plugins/builtin/realized-vol/headless.ts +11 -10
  433. package/src/plugins/builtin/realized-vol/pane.tsx +5 -4
  434. package/src/plugins/builtin/relative-rotation/headless.ts +2 -1
  435. package/src/plugins/builtin/relative-rotation/pane.tsx +6 -6
  436. package/src/plugins/builtin/research/analyst-headless.ts +5 -5
  437. package/src/plugins/builtin/research/analyst-model.ts +7 -7
  438. package/src/plugins/builtin/research/analyst-pane.tsx +7 -7
  439. package/src/plugins/builtin/research/client.ts +14 -0
  440. package/src/plugins/builtin/research/corporate-actions-pane.tsx +40 -30
  441. package/src/plugins/builtin/research/event-model.ts +55 -22
  442. package/src/plugins/builtin/research/event-sources.ts +26 -8
  443. package/src/plugins/builtin/research/relative-valuation-columns.ts +20 -12
  444. package/src/plugins/builtin/research/relative-valuation-currency.ts +16 -0
  445. package/src/plugins/builtin/research/relative-valuation-headless.ts +33 -21
  446. package/src/plugins/builtin/research/relative-valuation-model.ts +31 -17
  447. package/src/plugins/builtin/research/relative-valuation-pane.tsx +29 -14
  448. package/src/plugins/builtin/research-search/model.ts +2 -1
  449. package/src/plugins/builtin/research-search/saved-view.tsx +4 -3
  450. package/src/plugins/builtin/revenue-breakdown/model.ts +4 -4
  451. package/src/plugins/builtin/reverse-dcf/headless.ts +7 -7
  452. package/src/plugins/builtin/reverse-dcf/model.ts +4 -4
  453. package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -2
  454. package/src/plugins/builtin/scanner/flow-model.ts +7 -4
  455. package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
  456. package/src/plugins/builtin/scanner/headless.ts +3 -2
  457. package/src/plugins/builtin/scanner/hilo-model.ts +2 -1
  458. package/src/plugins/builtin/scanner/live-headless.ts +2 -2
  459. package/src/plugins/builtin/scanner/live-model.ts +3 -2
  460. package/src/plugins/builtin/scanner/live-pane.tsx +5 -5
  461. package/src/plugins/builtin/seasonality/headless.ts +2 -1
  462. package/src/plugins/builtin/seasonality/pane.tsx +4 -3
  463. package/src/plugins/builtin/sec/filing-display.tsx +12 -15
  464. package/src/plugins/builtin/sec/fund-facts.ts +2 -2
  465. package/src/plugins/builtin/sec/headless.ts +2 -1
  466. package/src/plugins/builtin/sec/index.tsx +6 -2
  467. package/src/plugins/builtin/sectors/headless.ts +4 -4
  468. package/src/plugins/builtin/sectors/index.tsx +7 -7
  469. package/src/plugins/builtin/shared/cloud-upgrade.ts +4 -2
  470. package/src/plugins/builtin/shared/cpi-year-gap.ts +67 -0
  471. package/src/plugins/builtin/shared/earnings-calendar.ts +90 -6
  472. package/src/plugins/builtin/shared/earnings-report.ts +13 -6
  473. package/src/plugins/builtin/shared/research-cells.tsx +2 -2
  474. package/src/plugins/builtin/shared/source-footer.ts +2 -1
  475. package/src/plugins/builtin/shared/trend.ts +2 -2
  476. package/src/plugins/builtin/shared/use-quote-board.ts +9 -8
  477. package/src/plugins/builtin/short-interest/headless.ts +6 -6
  478. package/src/plugins/builtin/short-interest/model.ts +9 -9
  479. package/src/plugins/builtin/short-interest/publications-model.ts +5 -5
  480. package/src/plugins/builtin/short-interest/publications-pane.tsx +3 -2
  481. package/src/plugins/builtin/short-interest/watch-headless.ts +5 -5
  482. package/src/plugins/builtin/short-interest/watch-pane.tsx +6 -6
  483. package/src/plugins/builtin/short-volume/model.ts +5 -5
  484. package/src/plugins/builtin/short-volume/pane.tsx +4 -4
  485. package/src/plugins/builtin/social-mentions/headless.ts +2 -1
  486. package/src/plugins/builtin/social-mentions/model.ts +4 -4
  487. package/src/plugins/builtin/supply-chain/graph-model.ts +2 -1
  488. package/src/plugins/builtin/supply-chain/graph-pane.tsx +2 -2
  489. package/src/plugins/builtin/supply-chain/headless.ts +3 -2
  490. package/src/plugins/builtin/supply-chain/model.ts +4 -4
  491. package/src/plugins/builtin/supply-chain/pane.tsx +2 -2
  492. package/src/plugins/builtin/supply-chain/row-evidence.tsx +2 -1
  493. package/src/plugins/builtin/themes/headless.ts +2 -1
  494. package/src/plugins/builtin/themes/model.ts +3 -2
  495. package/src/plugins/builtin/themes/pane.tsx +3 -2
  496. package/src/plugins/builtin/thirteenf/format.ts +9 -9
  497. package/src/plugins/builtin/thirteenf/headless.ts +3 -2
  498. package/src/plugins/builtin/thirteenf/model.ts +2 -1
  499. package/src/plugins/builtin/thirteenf/overlap-pane.tsx +2 -1
  500. package/src/plugins/builtin/thirteenf/pane.tsx +5 -4
  501. package/src/plugins/builtin/thirteenf/report-notes.ts +2 -1
  502. package/src/plugins/builtin/thirteenf/signals-pane.tsx +3 -2
  503. package/src/plugins/builtin/thirteenf/table.ts +6 -5
  504. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +45 -2
  505. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +4 -3
  506. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +4 -4
  507. package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +3 -3
  508. package/src/plugins/builtin/ticker-detail/financials/model.ts +83 -35
  509. package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +3 -1
  510. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +2 -2
  511. package/src/plugins/builtin/ticker-detail/financials/schema.ts +14 -18
  512. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +8 -13
  513. package/src/plugins/builtin/ticker-detail/headless.ts +33 -6
  514. package/src/plugins/builtin/ticker-detail/overview/chart-scale.ts +52 -0
  515. package/src/plugins/builtin/ticker-detail/overview/components.tsx +8 -9
  516. package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -14
  517. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +6 -0
  518. package/src/plugins/builtin/ticker-detail/overview/tax-equivalent.ts +2 -1
  519. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +43 -9
  520. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +7 -5
  521. package/src/plugins/builtin/ticker-detail/quote-monitor/rows.ts +4 -4
  522. package/src/plugins/builtin/ticker-detail/settings.ts +17 -0
  523. package/src/plugins/builtin/time-sales/headless.ts +3 -2
  524. package/src/plugins/builtin/time-sales/model.ts +7 -5
  525. package/src/plugins/builtin/time-sales/pane.tsx +7 -6
  526. package/src/plugins/builtin/trace-bonds/model.ts +3 -2
  527. package/src/plugins/builtin/trace-bonds/pane.tsx +3 -2
  528. package/src/plugins/builtin/treasury-auctions/client.ts +2 -1
  529. package/src/plugins/builtin/treasury-auctions/headless.ts +6 -6
  530. package/src/plugins/builtin/treasury-auctions/hk-headless.ts +3 -2
  531. package/src/plugins/builtin/treasury-auctions/hk-view.tsx +10 -9
  532. package/src/plugins/builtin/treasury-auctions/hk.ts +5 -5
  533. package/src/plugins/builtin/treasury-auctions/model.ts +4 -4
  534. package/src/plugins/builtin/treasury-auctions/pane.tsx +18 -18
  535. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +2 -1
  536. package/src/plugins/builtin/treasury-daily/model.ts +2 -2
  537. package/src/plugins/builtin/vol-surface/events.ts +5 -4
  538. package/src/plugins/builtin/vol-surface/headless.ts +19 -18
  539. package/src/plugins/builtin/vol-surface/heat-grid.tsx +2 -1
  540. package/src/plugins/builtin/vol-surface/pane.tsx +8 -7
  541. package/src/plugins/builtin/vol-surface/stored.ts +2 -1
  542. package/src/plugins/builtin/vol-surface/tables.ts +4 -3
  543. package/src/plugins/builtin/volatility/headless.ts +5 -4
  544. package/src/plugins/builtin/volatility/pane.tsx +6 -6
  545. package/src/plugins/builtin/world-indices/headless.ts +7 -7
  546. package/src/plugins/builtin/world-indices/index.tsx +3 -1
  547. package/src/plugins/builtin/world-venue-map/headless.ts +2 -1
  548. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +2 -1
  549. package/src/plugins/builtin/world-venue-map/layers.ts +3 -2
  550. package/src/plugins/builtin/world-venue-map/use-geo.ts +4 -2
  551. package/src/plugins/builtin/yield-curve/curves.ts +3 -3
  552. package/src/plugins/builtin/yield-curve/headless.ts +7 -6
  553. package/src/plugins/builtin/yield-curve/index.tsx +5 -4
  554. package/src/plugins/builtin/yield-curve/swaps.tsx +2 -1
  555. package/src/portfolio/allocation.ts +5 -5
  556. package/src/portfolio/collection-name.ts +2 -1
  557. package/src/portfolio/column-values.ts +61 -45
  558. package/src/portfolio/futures-positions.ts +2 -1
  559. package/src/portfolio/listed-symbol.ts +4 -2
  560. package/src/portfolio/period-pnl.ts +51 -1
  561. package/src/renderers/dom/dialog-host.tsx +5 -5
  562. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +7 -1
  563. package/src/renderers/electrobun/view/remote/capability-invoker.ts +1 -1
  564. package/src/renderers/opentui/dialog-host.tsx +3 -4
  565. package/src/renderers/opentui/ui-host.tsx +32 -2
  566. package/src/renderers/share/layout-view.tsx +2 -1
  567. package/src/sources/gloomberb-cloud/news.ts +9 -0
  568. package/src/sources/gloomberb-cloud/normalizers.ts +7 -0
  569. package/src/sources/provider-router/history.ts +5 -2
  570. package/src/sources/provider-router/search.ts +15 -10
  571. package/src/state/hooks/inline-tickers.ts +3 -2
  572. package/src/state/hooks/quote-streaming.ts +9 -10
  573. package/src/team/collections-sync.ts +8 -3
  574. package/src/telemetry/usage-counts.ts +26 -0
  575. package/src/test-support/plugin-persistence.ts +12 -0
  576. package/src/tickers/company-name-listing.ts +6 -5
  577. package/src/tickers/company-name.ts +36 -2
  578. package/src/tickers/instrument-coverage.ts +27 -0
  579. package/src/tickers/listing-venues.ts +26 -1
  580. package/src/tickers/renamed-listings.ts +2 -1
  581. package/src/tickers/search/home-listing.ts +38 -1
  582. package/src/tickers/search/index.ts +22 -2
  583. package/src/tickers/search/ranking.ts +21 -2
  584. package/src/tickers/starter-symbols.ts +7 -0
  585. package/src/time-series/base-series.ts +4 -0
  586. package/src/time-series/fundamentals/statement-fields.ts +11 -14
  587. package/src/time-series/history-acquisition.ts +1 -1
  588. package/src/time-series/log-scale.ts +9 -0
  589. package/src/time-series/reporting.ts +3 -3
  590. package/src/time-series/resolve.ts +6 -4
  591. package/src/time-series/transforms.ts +10 -5
  592. package/src/time-series/types.ts +5 -2
  593. package/src/types/config.ts +9 -0
  594. package/src/types/data-provider.ts +3 -2
  595. package/src/types/financials.ts +28 -0
  596. package/src/types/headless.ts +2 -0
  597. package/src/types/instrument.ts +6 -0
  598. package/src/types/plugin-panes.ts +1 -1
  599. package/src/types/plugin-reports.ts +8 -0
  600. package/src/ui/dialog-stack.ts +17 -0
  601. package/src/ui/dialog.tsx +6 -2
  602. package/src/utils/crypto-pair.ts +9 -0
  603. package/src/utils/datetime-format.ts +74 -33
  604. package/src/utils/exchanges.ts +13 -0
  605. package/src/utils/financial-statements.ts +98 -17
  606. package/src/utils/format.ts +4 -9
  607. package/src/utils/fundamentals.ts +38 -16
  608. package/src/utils/futures-generic.ts +14 -0
  609. package/src/utils/growth.ts +67 -0
  610. package/src/utils/keyboard.ts +6 -0
  611. package/src/utils/options.ts +1 -1
  612. package/src/utils/report-timing.ts +2 -2
  613. package/src/utils/served-rates.ts +45 -0
  614. package/src/utils/text-wrap.ts +84 -3
  615. package/src/utils/trailing-dividend.ts +13 -3
  616. package/src/utils/zoned-date-time.ts +47 -22
@@ -20,13 +20,14 @@ import {
20
20
  findListingOfCompanyName, isCompanyNameInput, marksAnotherListing, readTerminalCodeArg, serviceMarkedListing, serviceMarkedOtherListing, type CompanyNameListing,
21
21
  } from "../tickers/company-name-listing";
22
22
  import { movedAwayChange, startTickerChangeLookup, type MovedTickerChange } from "../tickers/ticker-changes";
23
- import { lineMayHaveMoved, listingChangeLine, loadListingFate, MovedSymbolError, SUCCESSOR_CHANGE_WAIT_MS, type ListingFate } from "../tickers/listing-fate";
23
+ import { isVenueAbroad, lineMayHaveMoved, listingChangeLine, loadListingFate, MovedSymbolError, SUCCESSOR_CHANGE_WAIT_MS, type ListingFate } from "../tickers/listing-fate";
24
24
  import { quotedListingName } from "../tickers/listing-name";
25
25
  import { withdrawalLabel } from "../market-data/quotes/delisting";
26
26
  import { cliStyles } from "../utils/cli-output";
27
- import { companyNameExtraWords, groupByCompany, namesDepositaryReceipt, sameCompany, sameListedName, shortCompanyName } from "../tickers/company-name";
27
+ import { companyLinesName, companyNameExtraWords, groupByCompany, namesDepositaryReceipt, sameCompany, sameCompanyName, sameListedName, shortCompanyName } from "../tickers/company-name";
28
28
  import {
29
29
  canonicalExchange,
30
+ displayTickerKey,
30
31
  exchangeCodeVenues,
31
32
  exchangeLabel,
32
33
  exchangeName,
@@ -258,6 +259,45 @@ function tradesOn(symbol: string, venues: readonly ListingVenue[]): string {
258
259
  return venues.length > 0 ? ` ${symbol} trades on: ${venues.map((venue) => venue.exchange).join(", ")}.` : "";
259
260
  }
260
261
 
262
+ /** The companies a symbol's venues are asked about for their line on another venue: the first few, home lines first. */
263
+ const MAX_COMPANIES_ASKED = 4;
264
+
265
+ /**
266
+ * " Prudential plc trades on HKEX as 2378:HKEX." when a company that lists
267
+ * as `symbol` elsewhere has a line of its own on `exchange`: PRU on LSE is
268
+ * Prudential plc, whose Hong Kong line is 2378, and HSBC on NYSE is HSBC
269
+ * Holdings, whose is 0005. Each company is asked once, by one of its venues;
270
+ * empty when none has a line there or the service cannot say.
271
+ */
272
+ async function companyLineOn(symbol: string, exchange: string, venues: readonly ListingVenue[], deps: ListingDeps): Promise<string> {
273
+ const { getIssuerListings } = deps.dataProvider;
274
+ if (!getIssuerListings) return "";
275
+ const byCompany = new Map<string, ListingVenue>();
276
+ for (const venue of [...venues].sort((a, b) => Number(!!b.home) - Number(!!a.home))) {
277
+ const company = venue.companyId ?? venue.name;
278
+ if (!byCompany.has(company)) byCompany.set(company, venue);
279
+ }
280
+ const asked = [...byCompany.values()].slice(0, MAX_COMPANIES_ASKED);
281
+ const issuers = await Promise.all(asked.map((venue) => Promise.resolve()
282
+ .then(() => getIssuerListings.call(deps.dataProvider, venue.symbol ?? symbol, venue.exchange))
283
+ .catch(logFailure("cli.listing-arg", "Read a company's listings failed", null))));
284
+ const lines = new Map<string, string>();
285
+ issuers.forEach((issuer, index) => {
286
+ const line = issuer?.listings.find((listing) => canonicalExchange(listing.exchange) === exchange);
287
+ if (!issuer || !line) return;
288
+ const key = parsePublicTickerKey(line.symbol).exchange ? displayTickerKey(line.symbol) : `${line.symbol}:${exchange}`;
289
+ // The name search writes the line asked about under, its home line first (Prudential plc), as ADR names it.
290
+ lines.set(key, `${companyLinesName(asked[index]!.name, issuer.name)} trades on ${exchange} as ${key}.`);
291
+ });
292
+ return [...lines.values()].map((line) => ` ${line}`).join("");
293
+ }
294
+
295
+ /** "PRU does not trade on HKEX. Prudential plc trades on HKEX as 2378:HKEX. PRU trades on: LSE, NYSE." */
296
+ async function notTradedText(listing: Pick<ListingArg, "symbol" | "exchange">, venues: readonly ListingVenue[], deps: ListingDeps): Promise<string> {
297
+ const companyLine = await companyLineOn(listing.symbol, listing.exchange, venues, deps);
298
+ return `${listing.symbol} does not trade on ${listing.exchange}.${companyLine}${tradesOn(listing.symbol, venues)}`;
299
+ }
300
+
261
301
  /** "Toronto Stock Exchange (TSX) or Tokyo Stock Exchange (JPX)". */
262
302
  function venueChoices(venues: readonly string[]): string {
263
303
  const labels = venues.map(exchangeLabel);
@@ -351,7 +391,7 @@ export async function notTradedMessage(
351
391
  if (withdrawn) return withdrawnListingMessage(listing, withdrawn);
352
392
  if (venues.length === 0 || venues.some((venue) => venue.exchange === listing.exchange)) return null;
353
393
  if (await quotedOnVenue(listing, deps)) return null;
354
- return `${listing.symbol} does not trade on ${listing.exchange}.${tradesOn(listing.symbol, venues)}`;
394
+ return notTradedText(listing, venues, deps);
355
395
  }
356
396
 
357
397
  /**
@@ -437,19 +477,61 @@ function namedByCode(symbol: string, venue: ListingVenue): boolean {
437
477
  }
438
478
 
439
479
  /**
440
- * Whether the venues' companies differ by name. A venue with no name is no other company, nor is one
441
- * that names its line by the code alone.
480
+ * The companies whose lines the venues are, when the data service identifies
481
+ * any of them, each company's venues in search order. Venues with one id are
482
+ * one company, never two because each names it its own way (DHL Group AG on
483
+ * Xetra, Deutsche Post AG in Vienna). A venue with no id is a company's whose
484
+ * identified venue it is named like, or whose name that venue's company is
485
+ * known by besides (Deutsche Post AG, DHL Group's former name, on a line the
486
+ * service cannot link), else another company (BMW Industries on BSE beside
487
+ * Bayerische Motoren Werke on Xetra). A venue with no name, one that names its line by the code alone, and
488
+ * a receipt named like no company there are none. Null when no venue has an id.
489
+ */
490
+ function identifiedCompanies(symbol: string, venues: readonly ListingVenue[]): ListingVenue[][] | null {
491
+ if (!venues.some((venue) => venue.companyId)) return null;
492
+ const groups: Array<{ id: string | null; venues: ListingVenue[] }> = [];
493
+ for (const venue of venues) {
494
+ if (!venue.companyId) continue;
495
+ const group = groups.find((entry) => entry.id === venue.companyId);
496
+ if (group) group.venues.push(venue);
497
+ else groups.push({ id: venue.companyId, venues: [venue] });
498
+ }
499
+ for (const venue of venues) {
500
+ if (venue.companyId || !venue.name.trim() || namedByCode(symbol, venue)) continue;
501
+ const named = (other: ListingVenue) => sameListedName(other.name, venue.name);
502
+ // Or named as the company is known besides: the former name the service sends on its rows (Deutsche Post AG).
503
+ const known = (other: ListingVenue) => (other.aliases ?? []).some((alias) => sameCompanyName(alias, venue.name));
504
+ const group = groups.find((entry) => entry.id && entry.venues.some((other) => !!other.companyId && (named(other) || known(other))))
505
+ ?? groups.find((entry) => !entry.id && entry.venues.some(named));
506
+ if (group) group.venues.push(venue);
507
+ else if (!namesDepositaryReceipt(venue.name)) groups.push({ id: null, venues: [venue] });
508
+ }
509
+ const order = (venue: ListingVenue) => venues.indexOf(venue);
510
+ return groups.map((group) => group.venues.sort((left, right) => order(left) - order(right)))
511
+ .sort((left, right) => order(left[0]!) - order(right[0]!));
512
+ }
513
+
514
+ /**
515
+ * Whether the venues are several companies' lines: by the data service's
516
+ * company ids where it gives any (`identifiedCompanies`). Without ids, the
517
+ * names decide: a venue with no name is no other company, nor is one that
518
+ * names its line by the code alone.
442
519
  */
443
520
  function listsSeveralCompanies(symbol: string, venues: readonly ListingVenue[]): boolean {
521
+ const identified = identifiedCompanies(symbol, venues);
522
+ if (identified) return identified.length > 1;
444
523
  return groupByCompany(venues, (venue) => namedByCode(symbol, venue) ? "" : venue.name).length > 1;
445
524
  }
446
525
 
447
526
  /**
448
- * The venue a bare code goes to: the first search lists with a real name, never one that names its
449
- * line by the code alone when another names it, and NSE, India's main venue, before BSE whichever
450
- * search listed first.
527
+ * The venue a bare code goes to: the line the data service marks as its
528
+ * company's home, else the first search lists with a real name, never one
529
+ * that names its line by the code alone when another names it, and NSE,
530
+ * India's main venue, before BSE whichever search listed first.
451
531
  */
452
532
  function homeVenue(symbol: string, venues: readonly ListingVenue[]): ListingVenue | null {
533
+ const home = venues.find((venue) => venue.home && !venue.withdrawal);
534
+ if (home) return home;
453
535
  const named = venues.filter((venue) => !namedByCode(symbol, venue));
454
536
  const candidates = named.length ? named : venues;
455
537
  const first = candidates[0] ?? null;
@@ -463,7 +545,10 @@ function homeVenue(symbol: string, venues: readonly ListingVenue[]): ListingVenu
463
545
  * form of its fund's name), is left out rather than guessed at, and one
464
546
  * fund's venues are one fund however each words it (`sameListedName`).
465
547
  */
466
- function otherCompanies(venues: readonly ListingVenue[], company: string): ListingVenue[] {
548
+ function otherCompanies(symbol: string, venues: readonly ListingVenue[], company: string, chosen?: ListingVenue): ListingVenue[] {
549
+ // A line the data service identifies is told apart by its id, never by a name difference (`identifiedCompanies`).
550
+ const identified = chosen?.companyId ? identifiedCompanies(symbol, venues) : null;
551
+ if (identified) return identified.filter((group) => !group.includes(chosen!)).map((group) => group[0]!);
467
552
  if (!company.trim()) return [];
468
553
  const known = venues.filter((venue) => !namesDepositaryReceipt(venue.name) || sameListedName(venue.name, company));
469
554
  return groupByCompany(known, (venue) => venue.name, sameListedName)
@@ -474,8 +559,12 @@ function otherCompanies(venues: readonly ListingVenue[], company: string): Listi
474
559
  /**
475
560
  * "CAR = Avis Budget Group, NASDAQ (different companies on XETRA, ASX)": the
476
561
  * listing a bare symbol several companies list was read on, and where the
477
- * others list it. Null when no other company is known to list it, so a symbol
478
- * that means one thing (XLK, and its receipt in Buenos Aires) says nothing.
562
+ * others list it. A bare symbol the data service read on the largest
563
+ * company's home listing abroad says so, as "SXR8 -> XETRA" does, with each
564
+ * other company's line: "BMW -> XETRA (Bayerische Motoren Werke); also
565
+ * BMW:BSE, Bmw Industries". Null when no other company is known to list it,
566
+ * so a symbol that means one thing (XLK, and its receipt in Buenos Aires)
567
+ * says nothing.
479
568
  */
480
569
  export function listingChoiceNote(
481
570
  symbol: string,
@@ -485,15 +574,42 @@ export function listingChoiceNote(
485
574
  if (!chosen.exchange) return null;
486
575
  const chosenVenue = venues.find((venue) => venue.exchange === chosen.exchange);
487
576
  const name = chosen.name?.trim() || chosenVenue?.name || "";
488
- const others = otherCompanies(venues, chosenVenue?.name || name).map((venue) => venue.exchange)
489
- .filter((exchange) => exchange !== chosen.exchange);
577
+ const otherVenues = otherCompanies(symbol, venues, chosenVenue?.name || name, chosenVenue)
578
+ .filter((venue) => venue.exchange !== chosen.exchange);
579
+ const others = otherVenues.map((venue) => venue.exchange);
490
580
  if (others.length === 0) return null;
491
581
  const more = others.length - MAX_OTHER_LISTINGS;
582
+ if (isVenueAbroad(chosen.exchange)) {
583
+ const also = otherVenues.slice(0, MAX_OTHER_LISTINGS)
584
+ .map((venue) => `${venueKey(symbol, venue)}${venue.name ? `, ${shortCompanyName(venue.name)}` : ""}`).join("; ");
585
+ return `${symbol} -> ${chosen.exchange}${name ? ` (${shortCompanyName(name)})` : ""}; also ${also}${more > 0 ? ` and ${more} more: gloom search ${symbol}` : ""}`;
586
+ }
492
587
  const named = `${others.slice(0, MAX_OTHER_LISTINGS).map(venueInProse).join(", ")}${more > 0 ? ` and ${more} more: gloom search ${symbol}` : ""}`;
493
588
  const which = others.length === 1 ? "a different company" : "different companies";
494
589
  return `${symbol} = ${name ? `${shortCompanyName(name)}, ` : ""}${exchangeName(chosen.exchange)} (${which} on ${named})`;
495
590
  }
496
591
 
592
+ /**
593
+ * "CON = Concentra Group (NYSE); Continental AG is CON:XETRA": a bare symbol
594
+ * read on a US company while another company's main listing abroad (the line
595
+ * the data service marks as its home) carries the symbol too. Companies are
596
+ * told apart by the service's ids where both lines carry one, else by name.
597
+ * Null when no other company's main listing carries it.
598
+ */
599
+ export function otherCompanyHomeNote(
600
+ symbol: string,
601
+ chosen: { exchange: string; name?: string | null },
602
+ venues: readonly ListingVenue[],
603
+ ): string | null {
604
+ const chosenVenue = venues.find((venue) => venue.exchange === chosen.exchange);
605
+ const name = chosen.name?.trim() || chosenVenue?.name || "";
606
+ const id = chosenVenue?.companyId;
607
+ const home = venues.find((venue) => venue.home && !venue.withdrawal && !isUsListingExchange(venue.exchange)
608
+ && (id && venue.companyId ? venue.companyId !== id : !!name && !sameListedName(venue.name, name)));
609
+ if (!home) return null;
610
+ return `${symbol} = ${name ? `${shortCompanyName(name)} ` : ""}(${chosen.exchange}); ${home.name} is ${venueKey(symbol, home)}`;
611
+ }
612
+
497
613
  /** A venue as a sentence names it, in full: "the Warsaw Stock Exchange", "Xetra", "NASDAQ" (a name that is its code). */
498
614
  function venueInProse(code: string): string {
499
615
  const name = exchangeName(code);
@@ -570,18 +686,27 @@ export async function listingChoiceNotes(
570
686
  if (listing.readFromName) return [...listingReadNotes(listing), ...coin];
571
687
  if (!quote || UNLISTED_TYPES.has(quote.instrumentType?.trim().toUpperCase() ?? "")) return coin;
572
688
  const exchange = canonicalExchange(quote.listingExchangeName || quote.exchangeName);
689
+ if (!exchange) return coin;
573
690
  // A bare symbol read on a company's own US line (JPM on NYSE) is what it means: companies abroad sharing the
574
- // letters are not named. A US receipt (SAN, Banco Santander's) may still be meant for another (Sanofi's SAN:EPA).
575
- if (!exchange || (isUsListingExchange(exchange) && quote.isDepositaryReceipt !== true)) return coin;
691
+ // letters are named only when one has its main listing under them (CON, Continental AG's on Xetra), from the
692
+ // venues already asked for. A US receipt (SAN, Banco Santander's) may still be meant for another (Sanofi's SAN:EPA).
693
+ if (isUsListingExchange(exchange) && quote.isDepositaryReceipt !== true) {
694
+ const listed = venues ? await venues : [];
695
+ const other = otherCompanyHomeNote(listing.symbol, { exchange, name: quote.name }, listed);
696
+ return [...other ? [other] : [], ...coin];
697
+ }
576
698
  const [listed, marked] = await Promise.all([
577
699
  venues ?? loadBareVenues(listing, deps) ?? [],
578
700
  // A primary listing the service names by the word, off the venue picked: NTT is NTT, Inc. (9432 on JPX), not Warsaw's NTT.
579
701
  serviceMarkedOtherListing(deps.dataProvider, listing.symbol, exchange).catch(logFailure("cli.listing-arg", "Read the listing a word names failed", null)),
580
702
  ]);
581
703
  const note = listingChoiceNote(listing.symbol, { exchange, name: quote.name }, listed);
582
- const also = marked ? `also ${marked.symbol}:${marked.exchange} ${marked.name}` : null;
704
+ const marking = marked ? `${marked.symbol}:${marked.exchange} ${marked.name}` : null;
583
705
  const named = quote.name?.trim() ? `${shortCompanyName(quote.name)}, ` : "";
584
- const choice = also ? `${note ?? `${listing.symbol} = ${named}${exchangeName(exchange)}`}; ${also}` : note;
706
+ // A note that already lists others ("; also BMW:BSE, Bmw Industries") takes the marked listing among them.
707
+ const choice = !marking ? note
708
+ : note?.includes("; also ") ? `${note}; ${marking}`
709
+ : `${note ?? `${listing.symbol} = ${named}${exchangeName(exchange)}`}; also ${marking}`;
585
710
  return [...choice ? [choice] : [], ...coin];
586
711
  }
587
712
 
@@ -1496,13 +1621,18 @@ export async function resolveCliListing(
1496
1621
  const read = await readTerminalCodeArg(deps.dataProvider, typed);
1497
1622
  // A company's name, an entry of a comma list (`WHR, Whirlpool Corporation`), is the listing search names for it.
1498
1623
  // A name before a legal form ("SAP SE", "SIEMENS AG") is looked up first: SE is also SIX Swiss's market code.
1499
- const named = !read || endsInLegalForm(typed) ? await companyNameListingArg(raw, deps) : null;
1624
+ const legalForm = !!read && endsInLegalForm(typed);
1625
+ const asName = !read || legalForm ? await companyNameListingArg(raw, deps) : null;
1626
+ // Read both ways as two companies ("ZURN SE": Zurich Insurance on SIX, Zurn Elkay by name), the code's listing wins.
1627
+ const codeWins = legalForm && asName ? await codeOverCompanyName(read!, asName.found, deps) : null;
1628
+ const named = codeWins ? null : asName?.listing ?? null;
1500
1629
  const terminal = named ? null : read;
1501
1630
  // "AAPL GP" is written as a code, with a market code no venue answers to and no company's name: one entry, never AAPL and GP.
1502
1631
  if (!terminal && !named) await refuseUnknownMarketCode(typed, deps);
1503
1632
  // `BP.` is London's code for BP: its London line where London lists it, and `GE.` a US ticker with a stray dot.
1504
1633
  const dotted = terminal || named || exchangeOption?.trim() ? null : readLondonDottedSymbol(typed);
1505
1634
  let parsed = named ?? (dotted ? await londonDottedListing(dotted, deps) : parseListingArg(raw, exchangeOption, { ...options, terminalCode: terminal }));
1635
+ if (codeWins) parsed = { ...parsed, readAs: codeWins };
1506
1636
  if (!parsed.symbol) throw new ListingArgError("Ticker symbol is required.");
1507
1637
  // $VIX is Schwab's code for ^VIX, unless a security trades as VIX: $AAPL is a cashtag.
1508
1638
  const index = named || parsed.exchange ? null : await readDollarIndexCode(raw, deps);
@@ -1560,6 +1690,33 @@ export async function resolveCliListing(
1560
1690
  };
1561
1691
  }
1562
1692
 
1693
+ /**
1694
+ * How a symbol and a market code read when the words are also a company's name
1695
+ * before its legal form, SE being both SIX Swiss's code and a European
1696
+ * company's form: "ZURN SE" is Zurich Insurance on SIX as a code and Zurn
1697
+ * Elkay Water Solutions as a name, "NOVN SE" Novartis and Novan, "SAP SE" SAP
1698
+ * either way. Two companies: the code names one listing on one venue, as a
1699
+ * desk typing a terminal's codes means it, so it wins, and the note names the
1700
+ * company the words would be ("Read "ZURN SE" as ZURN:SWX (Zurich Insurance
1701
+ * Group AG), not ZWS:NYSE (Zurn Elkay ...)"). One company, by the service's
1702
+ * company ids or by name: null, so the name reads the company's home listing
1703
+ * (SAP on Xetra, not its SIX line). Null too when the code's venue lists
1704
+ * nothing under the symbol.
1705
+ */
1706
+ async function codeOverCompanyName(code: TerminalListingCode, found: CompanyNameListing, deps: ListingDeps): Promise<string | null> {
1707
+ if (!code.exchange) return null;
1708
+ const venues = await listingVenues(code.symbol, deps).catch(logFailure("cli.listing-arg", "Read a market code's listing failed", [] as ListingVenue[]));
1709
+ const line = venues.find((venue) => venue.exchange === code.exchange && venue.name.trim());
1710
+ if (!line) return null;
1711
+ const company = found.meant ?? found;
1712
+ const companyLine = company.symbol.toUpperCase() === code.symbol.toUpperCase()
1713
+ ? venues.find((venue) => venue.exchange === company.exchange) : undefined;
1714
+ const ids = [line.companyId, companyLine?.companyId];
1715
+ if (ids[0] && ids[1] ? ids[0] === ids[1] : sameCompany(line.name, company.name)) return null;
1716
+ const key = company.exchange ? `${company.symbol}:${company.exchange}` : company.symbol;
1717
+ return `${terminalCodeReadAs(code).replace(/\.$/, "")} (${line.name.trim()}), not ${key} (${company.name.trim()}).`;
1718
+ }
1719
+
1563
1720
  /** A US share class typed with a space for its mark: `BRK B`, `brk b`. */
1564
1721
  const SPACED_SHARE_CLASS = /^([A-Za-z]{1,5})\s+([A-Za-z])$/;
1565
1722
  /** A US share class typed with no mark at all, in capitals: `BRKB`, `BFB`. */
@@ -1672,7 +1829,7 @@ async function checkTerminalCodeVenue(listing: ListingArg, market: string, deps:
1672
1829
  if (!hint && !isSearchOnlyVenue(listing.exchange)) return;
1673
1830
  const venues = await listingVenues(listing.symbol, deps).catch(logFailure("cli.listing-arg", "Read listing venues failed", []));
1674
1831
  if (venues.length === 0 || venues.some((venue) => venue.exchange === listing.exchange)) return;
1675
- throw new ListingArgError(`${listing.symbol} does not trade on ${listing.exchange}.${tradesOn(listing.symbol, venues)}`, hint ?? undefined);
1832
+ throw new ListingArgError(await notTradedText(listing, venues, deps), hint ?? undefined);
1676
1833
  }
1677
1834
 
1678
1835
  /**
@@ -1751,9 +1908,11 @@ const NAME_WRITTEN_WORD = /^(?=.*\p{Ll})\p{L}[\p{L}&'’-]*$/u;
1751
1908
  /**
1752
1909
  * Symbols at most whose venues a command looks up to name the company each
1753
1910
  * bare one went to, and whose words it checks as companies' names
1754
- * (`companyWord`, a quote each). A longer list is a batch of tickers.
1911
+ * (`companyWord`, a quote each): a desk's morning list of a dozen names (the
1912
+ * DAX names it covers) still says which company each one read. A longer
1913
+ * list is a batch of tickers.
1755
1914
  */
1756
- export const MAX_CHOICE_LOOKUPS = 10;
1915
+ export const MAX_CHOICE_LOOKUPS = 12;
1757
1916
 
1758
1917
  /** At most this many words typed apart are tried as one company's name (`joinCompanyNameWords`). */
1759
1918
  const MAX_JOINED_NAME_WORDS = 4;
@@ -1871,9 +2030,10 @@ async function japaneseNameListing(
1871
2030
  * symbol, and for a name search finds no listing for, which then fails as a
1872
2031
  * symbol would.
1873
2032
  */
1874
- async function companyNameListingArg(raw: string, deps: ListingDeps): Promise<ListingArg | null> {
2033
+ async function companyNameListingArg(raw: string, deps: ListingDeps): Promise<{ listing: ListingArg; found: CompanyNameListing } | null> {
1875
2034
  const typed = stripStrayEdges(raw).text || raw;
1876
- return isCompanyNameInput(typed) ? readCompanyName(typed, deps) : null;
2035
+ const found = isCompanyNameInput(typed) ? await findCompanyName(typed, deps) : null;
2036
+ return found ? { listing: companyListingArg(typed, found), found } : null;
1877
2037
  }
1878
2038
 
1879
2039
  /** `Read "crude oil" as CL=F (WTI Crude Oil), the benchmark future; Brent is BZ=F.` */
@@ -2017,11 +2177,6 @@ function movedWithoutQuote(change: ListingFate["change"], name: string | null):
2017
2177
  return moved && sameCompany(name, moved.issuer) ? moved : null;
2018
2178
  }
2019
2179
 
2020
- async function readCompanyName(typed: string, deps: Pick<ListingDeps, "dataProvider">, options: { oneWord?: boolean } = {}): Promise<ListingArg | null> {
2021
- const found = await findCompanyName(typed, deps, options);
2022
- return found ? companyListingArg(typed, found) : null;
2023
- }
2024
-
2025
2180
  function companyListingArg(typed: string, found: CompanyNameListing): ListingArg {
2026
2181
  const key = found.exchange ? `${found.symbol}:${found.exchange}` : found.symbol;
2027
2182
  // A fund or an index carrying the name asks about the company's stock: "Did you mean JPM (JPMorgan Chase & Co.)?".
@@ -1,4 +1,5 @@
1
1
  import { futuresContractByWord } from "../market-data/futures-board";
2
+ import { venueOfDatedContract } from "../utils/futures-generic";
2
3
  import { notATickerSymbol } from "../sources/provider-errors";
3
4
  import { renamedListingFor, renamedListingHint } from "../tickers/renamed-listings";
4
5
  import { boardCoinFor } from "./board-coins";
@@ -58,6 +59,9 @@ export function withSearchHints(text: string, args: readonly string[], isFredSer
58
59
  if (renamed) return `${sentence} ${renamedListingHint(renamed)}`;
59
60
  const coin = boardCoinFor(id);
60
61
  if (coin) return `${sentence} Did you mean ${coin.symbol}${coin.name && coin.name.toUpperCase() !== coin.symbol ? ` (${coin.name})` : ""}?`;
62
+ // A dated contract typed without its venue (ZQZ26) is quoted with it: ZQZ26.CBT, as WIRP prints it.
63
+ const contract = venueOfDatedContract(id);
64
+ if (contract) return `${sentence} Did you mean ${contract}?`;
61
65
  const tenor = treasuryYieldTenor(typed);
62
66
  // A currency's name (`yen`) is its rate and its pair, not a ticker search could find; a commodity's word
63
67
  // (`oil`, `brent`) is its future, which no search for the word finds first.
@@ -1,4 +1,6 @@
1
+ import type { TickerRecord } from "../../types/ticker";
1
2
  import { logFailure } from "../../utils/log-failure";
3
+ import { shellWord } from "../../utils/shell-word";
2
4
  import { commands as builtInCommands, getCommandPrefixes } from "../../components/command-bar/commands/registry";
3
5
  import type { HeadlessPaneDefinition, PaneDef, PaneTemplateCreateOptions, PaneTemplateDef } from "../../types/plugin";
4
6
  import type { MarketContext } from "../types";
@@ -287,18 +289,24 @@ function sampleArgForTemplate(template: PaneTemplateDef): string {
287
289
  }
288
290
  }
289
291
 
292
+ /**
293
+ * A template's catalog entry. Without a market context (a search from the app,
294
+ * `functionsForQuestion`) no instance is made to read its default settings
295
+ * from, and no example is given: only what the template itself says.
296
+ */
290
297
  async function buildTemplateCatalogEntry(
291
298
  template: PaneTemplateDef,
292
299
  pane: PaneDef,
293
- context: MarketContext,
300
+ context: MarketContext | null,
294
301
  token: string,
302
+ listName?: string | null,
295
303
  ): Promise<PaneCatalogEntry> {
296
304
  const sampleArg = sampleArgForTemplate(template);
297
305
  const createOptions: PaneTemplateCreateOptions | undefined = buildCreateOptions(template, sampleArg);
298
306
  const primarySymbol = createOptions?.symbol ?? createOptions?.symbols?.[0] ?? null;
299
307
  let defaultSettings: Record<string, unknown> = template.catalogSettings ?? {};
300
308
 
301
- if (template.catalogSettings === undefined && template.createInstance) {
309
+ if (context && template.catalogSettings === undefined && template.createInstance) {
302
310
  try {
303
311
  const spec = await template.createInstance(buildTemplateContext(context, primarySymbol), createOptions);
304
312
  defaultSettings = spec?.settings ?? {};
@@ -321,7 +329,7 @@ async function buildTemplateCatalogEntry(
321
329
  aliases: [...(template.shortcut?.aliases ?? [])],
322
330
  argKind: argument.kind,
323
331
  argPlaceholder: argument.placeholder,
324
- ...argExamples(headless, context),
332
+ ...context ? argExamples(headless, context, pane, listName) : null,
325
333
  ...(headless?.argument.kind === "tickers" && template.shortcut?.argKind === "ticker"
326
334
  ? { shotArgument: argumentHint({ argKind: "ticker", argPlaceholder: template.shortcut.argPlaceholder }) } : {}),
327
335
  keywords: template.keywords ?? [],
@@ -332,18 +340,34 @@ async function buildTemplateCatalogEntry(
332
340
 
333
341
  /**
334
342
  * The arguments a function's examples show past its placeholder: its own, and
335
- * for a list of more than two symbols, a watchlist's name, which stands for
336
- * its symbols (the reader's first watchlist).
343
+ * for a list of more than two symbols, a list's name, which stands for its
344
+ * symbols: the reader's first watchlist or portfolio that holds any
345
+ * (`listName`), so the example runs as printed.
337
346
  */
338
- function argExamples(headless: HeadlessPaneDefinition | undefined, context: MarketContext): { argExamples: readonly string[] } | null {
339
- const own = headless?.argument.examples ?? [];
347
+ function argExamples(
348
+ headless: HeadlessPaneDefinition | undefined,
349
+ context: MarketContext,
350
+ pane?: PaneDef,
351
+ listName: string | null = context.config.watchlists[0]?.name ?? "Watchlist",
352
+ ): { argExamples: readonly string[] } | null {
353
+ // A rendered view's own examples (VIEW's spec) stand where a headless model would give them.
354
+ const own = headless?.argument.examples ?? pane?.reportArgument?.examples ?? [];
340
355
  const argument = headless?.argument;
341
356
  const list = (argument?.kind === "symbol-list" || argument?.kind === "tickers") && (argument.maximum == null || argument.maximum > 2);
342
- const name = context.config.watchlists[0]?.name ?? "Watchlist";
343
- const examples = list ? [...own, /^[\w.-]+$/.test(name) ? name : `'${name.replace(/'/g, "'\\''")}'`] : own;
357
+ const examples = list && listName ? [...own, shellWord(listName)] : own;
344
358
  return examples.length > 0 ? { argExamples: examples } : null;
345
359
  }
346
360
 
361
+ /** The first watchlist, else portfolio, that holds a symbol: the list a function's example names. Null when none does. */
362
+ async function exampleListName(context: MarketContext): Promise<string | null> {
363
+ const tickers = await Promise.resolve().then(() => context.store.loadAllTickers())
364
+ .catch(logFailure("cli-catalog", "Read the lists for an example failed", [] as TickerRecord[]));
365
+ const watchlist = context.config.watchlists.find((list) => tickers.some((ticker) => ticker.metadata.watchlists.includes(list.id)));
366
+ const portfolio = watchlist ? null : context.config.portfolios.find((list) => tickers.some((ticker) => ticker.metadata.portfolios.includes(list.id)
367
+ || ticker.metadata.positions.some((position) => position.portfolio === list.id && position.shares !== 0)));
368
+ return (watchlist ?? portfolio)?.name ?? null;
369
+ }
370
+
347
371
  /**
348
372
  * The functions `gloom catalog` and search list. An unlisted one (`listed:
349
373
  * false`) is left out, and its pane is not listed in its place; `unlisted`
@@ -353,10 +377,12 @@ function argExamples(headless: HeadlessPaneDefinition | undefined, context: Mark
353
377
  */
354
378
  export async function buildPaneCatalogEntries(
355
379
  registry: PaneFunctionCatalog,
356
- context: MarketContext,
380
+ context: MarketContext | null,
357
381
  { unlisted = false, appPanes = false }: { unlisted?: boolean; appPanes?: boolean } = {},
358
382
  ): Promise<PaneCatalogEntry[]> {
359
383
  const entries: PaneCatalogEntry[] = [];
384
+ // Read once, when an example first needs it.
385
+ let listName: Promise<string | null> | undefined;
360
386
  const templatedPaneIds = new Set<string>();
361
387
  const codedPaneIds = new Set([...registry.paneTemplates.values()]
362
388
  .filter((template) => template.shortcut?.prefix && template.listed !== false)
@@ -371,7 +397,8 @@ export async function buildPaneCatalogEntries(
371
397
  if (!forUsers && !unlisted && !appPanes) continue;
372
398
  // A template only the UI audits list keeps the id an older catalog listed it by, so a base and a head picture it under one name.
373
399
  const token = forUsers || unlisted ? paneFunctionCode(template, pane, registry) : template.id;
374
- entries.push(await buildTemplateCatalogEntry(template, pane, context, token));
400
+ listName ??= context ? exampleListName(context) : Promise.resolve(null);
401
+ entries.push(await buildTemplateCatalogEntry(template, pane, context, token, await listName));
375
402
  }
376
403
 
377
404
  for (const pane of registry.panes.values()) {
@@ -388,7 +415,7 @@ export async function buildPaneCatalogEntries(
388
415
  aliases,
389
416
  argKind: argument.kind,
390
417
  argPlaceholder: argument.placeholder,
391
- ...argExamples(pane.headless, context),
418
+ ...context ? argExamples(pane.headless, context, pane, await (listName ??= exampleListName(context))) : null,
392
419
  keywords: [],
393
420
  defaultSettings: {},
394
421
  capability: getPaneFunctionCapability(undefined, pane),
@@ -727,6 +754,48 @@ export async function suggestPaneFunctions(
727
754
  return loose ? [] : shown;
728
755
  }
729
756
 
757
+ /**
758
+ * Words a question asks with, which name nothing a function covers: "what did the DAX do yesterday" asks about the
759
+ * DAX, and "do" alone found DOE and DOCS.
760
+ */
761
+ const QUESTION_WORDS = new Set([
762
+ "what", "whats", "what's", "which", "who", "why", "when", "where", "how", "much", "many", "did", "does", "do", "done", "is", "are", "was",
763
+ "were", "will", "would", "could", "should", "can", "has", "have", "had", "been", "be", "me", "my", "i", "we", "you", "it", "its", "it's",
764
+ "this", "that", "these", "those", "there", "show", "tell", "give", "get", "about", "today", "yesterday", "tonight", "now", "last",
765
+ "latest", "current", "currently", "doing", "happen", "happened", "going", "go", "went", "please", "the", "a", "an", "of", "on", "in",
766
+ "for", "to", "and", "or", "at", "by", "with", "from", "up", "down",
767
+ ]);
768
+
769
+ /** A question's topic: its words without the ones it asks with ("dax" for "what did the DAX do yesterday?"); empty when it is all asking. */
770
+ function questionTopic(question: string): string {
771
+ return question.toLowerCase().replace(/[?!.,;:"]/g, " ").split(/\s+/).filter((word) => word && !QUESTION_WORDS.has(word)).join(" ");
772
+ }
773
+
774
+ /** A function a question names, as ASKG offers it signed out. */
775
+ export interface FunctionForQuestion {
776
+ code: string;
777
+ label: string;
778
+ /** `gloom fn WEI`, `gloom fn CMP <tickers>`: the command that runs it. */
779
+ command: string;
780
+ }
781
+
782
+ /**
783
+ * The functions `catalog` finds for a question's topic, best first, up to
784
+ * `limit`: what Ask Gloom offers without an account ("what did the DAX do
785
+ * yesterday" finds WEI and CMP). Built from the templates alone, without a
786
+ * market context, so the app's pane asks it as the command line does.
787
+ */
788
+ export async function functionsForQuestion(registry: PaneFunctionCatalog, question: string, limit = 3): Promise<FunctionForQuestion[]> {
789
+ const topic = questionTopic(question);
790
+ if (!topic) return [];
791
+ const entries = await buildPaneCatalogEntries(registry, null);
792
+ const { shown } = selectPaneCatalogMatches(filterPaneCatalogEntries(entries, topic), topic, limit);
793
+ return shown.map((entry) => {
794
+ const argument = argumentHint(entry);
795
+ return { code: entry.token, label: entry.label, command: `gloom fn ${entry.token}${argument ? ` ${argument}` : ""}` };
796
+ });
797
+ }
798
+
730
799
  const CATALOG_TEXT_WIDTH = 100;
731
800
  const READINESS_LABELS: Record<PaneFunctionReadiness, string> = {
732
801
  ready: "ready",
@@ -4,6 +4,7 @@ import { formatUtcTime, parseReportTime } from "../../utils/utc-time";
4
4
  import type { MarketContext } from "../types";
5
5
  import type { PaneFunctionReport } from "./report";
6
6
  import type { ResolvedPaneFunction } from "./resolver";
7
+ import { functionsForQuestion, type PaneFunctionCatalog } from "./catalog";
7
8
  import { collectShotSymbols } from "./data";
8
9
  import { lockNoteLines } from "./lock-note";
9
10
  import { createHeadlessPaneContext } from "./headless";
@@ -437,12 +438,17 @@ async function signedOutDomReport(
437
438
  resolved: ResolvedPaneFunction,
438
439
  context: MarketContext,
439
440
  rawArg: string,
441
+ catalog?: PaneFunctionCatalog,
440
442
  ): Promise<PaneFunctionReport | null> {
441
443
  if (!resolved.pane.signInWall || !resolved.pane.reportLockNote || resolvePersistedCloudSessionToken(context)) return null;
442
444
  const symbols = collectShotSymbols(resolved, rawArg);
445
+ const argument = rawArg.trim();
443
446
  const note = await resolved.pane.reportLockNote({
444
447
  gate: "sign-in", symbol: symbols[0] ?? null, token: resolved.token,
445
448
  context: createHeadlessPaneContext(resolved, context, new AbortController().signal),
449
+ // A question asked behind the wall (ASKG) is offered the functions the catalog finds for it.
450
+ ...argument ? { argument } : {},
451
+ ...catalog ? { functionsFor: (question: string, limit: number) => functionsForQuestion(catalog, question, limit) } : {},
446
452
  });
447
453
  const reason = lockNoteReason(note);
448
454
  return {
@@ -473,8 +479,9 @@ export async function buildDomFunctionReport(
473
479
  resolved: ResolvedPaneFunction,
474
480
  context: MarketContext,
475
481
  rawArg: string,
482
+ catalog?: PaneFunctionCatalog,
476
483
  ): Promise<PaneFunctionReport> {
477
- const signedOut = await signedOutDomReport(resolved, context, rawArg);
484
+ const signedOut = await signedOutDomReport(resolved, context, rawArg, catalog);
478
485
  if (signedOut) return signedOut;
479
486
  let result: PaneScreenshotResult;
480
487
  try {
@@ -1029,7 +1029,7 @@ function reopenText(market: ReportMarket, now: number, local: boolean, short: bo
1029
1029
  const utc = `${day}${iso.slice(11, 16)} UTC`;
1030
1030
  const reader = local ? localTimeSuffix(at) : "";
1031
1031
  const zone = market.reopensTimeZone;
1032
- const label = zone ? timeZoneLabel(zone) : null;
1032
+ const label = zone ? timeZoneLabel(zone, at) : null;
1033
1033
  if (short || !zone || label === "UTC") return `${utc}${reader}`;
1034
1034
  const venue = zonedDateTimeParts(at, zone);
1035
1035
  const venueDay = `${venue.year}-${twoDigits(venue.month)}-${twoDigits(venue.day)}`;
@@ -1099,7 +1099,7 @@ function marketsText(markets: readonly VenueMarket[], now: number, short: boolea
1099
1099
  const opensAt = (market: VenueMarket) => market.reopensAt ? Date.parse(market.reopensAt) : Number.POSITIVE_INFINITY;
1100
1100
  const rank = (market: VenueMarket) => market.state === "open" ? 0 : market.state === "closed" ? 2 : 1;
1101
1101
  const ordered = [...markets].sort((left, right) => rank(left) - rank(right) || opensAt(left) - opensAt(right));
1102
- // `LSE opens 08:00 UTC, 08:00 UK · US 13:30 UTC, 09:30 ET`: a verb is said once for the opens that follow
1102
+ // `LSE opens 08:00 UTC, 08:00 GMT · US 13:30 UTC, 09:30 ET`: a verb is said once for the opens that follow
1103
1103
  // each other with it; a week's first trade after a session's open says its own (`reopens 22:00 UTC`).
1104
1104
  let previousVerb: string | null = null;
1105
1105
  const parts = ordered.map((market) => {