gloomberb 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -19
- package/bin/gloomberb +3 -0
- package/package.json +5 -4
- package/patches/@opentui%2Fcore@0.1.90.patch +356 -0
- package/src/app.tsx +1330 -0
- package/src/brokers/sync-broker-instance.test.ts +100 -0
- package/src/brokers/sync-broker-instance.ts +341 -0
- package/src/cli/commands/plugins.ts +173 -0
- package/src/cli/commands/portfolio.ts +210 -0
- package/src/cli/commands/search.ts +120 -0
- package/src/cli/commands/ticker.ts +375 -0
- package/src/cli/commands/watchlist.ts +210 -0
- package/src/cli/context.ts +62 -0
- package/src/cli/errors.ts +13 -0
- package/src/cli/helpers.ts +85 -0
- package/src/cli/index.ts +143 -0
- package/src/cli/ticker-resolution.ts +39 -0
- package/src/cli/types.ts +15 -0
- package/src/cli.test.ts +361 -0
- package/src/components/chart/chart-data.ts +239 -0
- package/src/components/chart/chart-renderer.ts +1199 -0
- package/src/components/chart/chart-types.ts +82 -0
- package/src/components/chart/chart-viewport.ts +21 -0
- package/src/components/chart/chart.test.ts +439 -0
- package/src/components/chart/comparison-chart-data.test.ts +109 -0
- package/src/components/chart/comparison-chart-data.ts +316 -0
- package/src/components/chart/comparison-chart-renderer.test.ts +84 -0
- package/src/components/chart/comparison-chart-renderer.ts +354 -0
- package/src/components/chart/comparison-stock-chart.tsx +1486 -0
- package/src/components/chart/cursor-motion.ts +48 -0
- package/src/components/chart/native/chart-rasterizer.ts +732 -0
- package/src/components/chart/native/kitty-adapter.ts +12 -0
- package/src/components/chart/native/kitty-manager.ts +142 -0
- package/src/components/chart/native/kitty-protocol.ts +110 -0
- package/src/components/chart/native/kitty-support.ts +71 -0
- package/src/components/chart/native/kitty.test.ts +620 -0
- package/src/components/chart/native/renderer-selection.ts +24 -0
- package/src/components/chart/native/surface-manager.ts +225 -0
- package/src/components/chart/native/surface-sync.ts +34 -0
- package/src/components/chart/stock-chart-renderer-switch.test.tsx +165 -0
- package/src/components/chart/stock-chart.test.ts +107 -0
- package/src/components/chart/stock-chart.tsx +1556 -0
- package/src/components/command-bar/__snapshots__/command-bar.test.tsx.snap +137 -0
- package/src/components/command-bar/command-bar.test.tsx +1524 -0
- package/src/components/command-bar/command-bar.tsx +4823 -0
- package/src/components/command-bar/command-registry.ts +261 -0
- package/src/components/command-bar/helpers.test.ts +224 -0
- package/src/components/command-bar/helpers.ts +371 -0
- package/src/components/command-bar/root-shortcuts.ts +158 -0
- package/src/components/command-bar/view-model.test.ts +152 -0
- package/src/components/command-bar/view-model.ts +185 -0
- package/src/components/command-bar/workflow-ops.test.ts +70 -0
- package/src/components/command-bar/workflow-ops.ts +433 -0
- package/src/components/command-bar/workflow-types.ts +127 -0
- package/src/components/detail-feed-view.test.tsx +105 -0
- package/src/components/detail-feed-view.tsx +295 -0
- package/src/components/index.ts +32 -0
- package/src/components/layout/floating-pane.tsx +49 -0
- package/src/components/layout/header.tsx +129 -0
- package/src/components/layout/pane-header.tsx +44 -0
- package/src/components/layout/pane.tsx +49 -0
- package/src/components/layout/pixel-mouse-mode.test.ts +122 -0
- package/src/components/layout/pixel-mouse.test.ts +40 -0
- package/src/components/layout/shell.test.tsx +625 -0
- package/src/components/layout/shell.tsx +1200 -0
- package/src/components/layout/status-bar.test.tsx +173 -0
- package/src/components/layout/status-bar.tsx +138 -0
- package/src/components/markdown-editor.tsx +134 -0
- package/src/components/onboarding/onboarding-wizard.test.tsx +184 -0
- package/src/components/onboarding/onboarding-wizard.tsx +1365 -0
- package/src/components/pane-settings-dialog.tsx +468 -0
- package/src/components/pane-template-wizard.test.tsx +52 -0
- package/src/components/pane-template-wizard.tsx +199 -0
- package/src/components/price-selector-dialog.tsx +195 -0
- package/src/components/spinner.tsx +2 -0
- package/src/components/tab-bar.tsx +17 -0
- package/src/components/ticker-badge-text.test.tsx +160 -0
- package/src/components/ticker-badge-text.tsx +58 -0
- package/src/components/ticker-badge.tsx +88 -0
- package/src/components/ticker-list-table.tsx +188 -0
- package/src/components/toggle-list.tsx +74 -0
- package/src/components/ui/button.tsx +77 -0
- package/src/components/ui/data-table.tsx +210 -0
- package/src/components/ui/external-link.tsx +22 -0
- package/src/components/ui/fields.tsx +187 -0
- package/src/components/ui/frame.tsx +73 -0
- package/src/components/ui/index.ts +53 -0
- package/src/components/ui/list-view.tsx +166 -0
- package/src/components/ui/loading.tsx +70 -0
- package/src/components/ui/status.tsx +83 -0
- package/src/components/ui/tabs.tsx +47 -0
- package/src/components/ui/toggle.tsx +164 -0
- package/src/components/ui/ui.test.tsx +134 -0
- package/src/data/app-persistence.ts +25 -0
- package/src/data/config-store.test.ts +310 -0
- package/src/data/config-store.ts +469 -0
- package/src/data/plugin-state-store.ts +102 -0
- package/src/data/resource-store.ts +323 -0
- package/src/data/session-store.ts +52 -0
- package/src/data/sqlite-cache.test.ts +103 -0
- package/src/data/sqlite-database.ts +62 -0
- package/src/data/sqlite-json.ts +19 -0
- package/src/data/ticker-repository.ts +45 -0
- package/src/data/ticker-store.ts +46 -0
- package/src/index.tsx +67 -0
- package/src/market-data/coordinator.test.ts +369 -0
- package/src/market-data/coordinator.ts +580 -0
- package/src/market-data/hooks.tsx +234 -0
- package/src/market-data/query-store.ts +28 -0
- package/src/market-data/request-types.test.ts +64 -0
- package/src/market-data/request-types.ts +70 -0
- package/src/market-data/result-types.ts +56 -0
- package/src/market-data/selectors.ts +166 -0
- package/src/market-data/trace.ts +7 -0
- package/src/pane-settings.test.ts +71 -0
- package/src/pane-settings.ts +73 -0
- package/src/plugins/builtin/ai/ask-ai-detail-tab.tsx +338 -0
- package/src/plugins/builtin/ai/gloomberb-cli.ts +70 -0
- package/src/plugins/builtin/ai/index.test.tsx +139 -0
- package/src/plugins/builtin/ai/index.tsx +86 -0
- package/src/plugins/builtin/ai/providers.ts +99 -0
- package/src/plugins/builtin/ai/runner.ts +82 -0
- package/src/plugins/builtin/ai/screener-contract.test.ts +117 -0
- package/src/plugins/builtin/ai/screener-contract.ts +174 -0
- package/src/plugins/builtin/ai/screener-pane.test.tsx +365 -0
- package/src/plugins/builtin/ai/screener-pane.tsx +1161 -0
- package/src/plugins/builtin/ai/settings.ts +79 -0
- package/src/plugins/builtin/ai/ticker-context.ts +64 -0
- package/src/plugins/builtin/ai/utils.ts +71 -0
- package/src/plugins/builtin/ask-ai.test.tsx +258 -0
- package/src/plugins/builtin/ask-ai.tsx +9 -0
- package/src/plugins/builtin/chat-controller.test.ts +217 -0
- package/src/plugins/builtin/chat-controller.ts +340 -0
- package/src/plugins/builtin/chat.test.tsx +451 -0
- package/src/plugins/builtin/chat.tsx +620 -0
- package/src/plugins/builtin/comparison-chart.test.tsx +277 -0
- package/src/plugins/builtin/comparison-chart.tsx +169 -0
- package/src/plugins/builtin/data-providers.ts +16 -0
- package/src/plugins/builtin/debug.tsx +351 -0
- package/src/plugins/builtin/help.test.tsx +110 -0
- package/src/plugins/builtin/help.tsx +281 -0
- package/src/plugins/builtin/layout-manager.tsx +264 -0
- package/src/plugins/builtin/manual-entry.tsx +25 -0
- package/src/plugins/builtin/news.tsx +143 -0
- package/src/plugins/builtin/notes-files.ts +58 -0
- package/src/plugins/builtin/notes.tsx +396 -0
- package/src/plugins/builtin/options-availability.test.tsx +179 -0
- package/src/plugins/builtin/options-availability.ts +158 -0
- package/src/plugins/builtin/options.tsx +364 -0
- package/src/plugins/builtin/portfolio-list/header.tsx +227 -0
- package/src/plugins/builtin/portfolio-list/index.tsx +99 -0
- package/src/plugins/builtin/portfolio-list/metrics.ts +436 -0
- package/src/plugins/builtin/portfolio-list/pane.tsx +533 -0
- package/src/plugins/builtin/portfolio-list/settings.ts +280 -0
- package/src/plugins/builtin/portfolio-list/summary.tsx +270 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +64 -0
- package/src/plugins/builtin/portfolio-list.test.ts +74 -0
- package/src/plugins/builtin/portfolio-list.test.tsx +1164 -0
- package/src/plugins/builtin/portfolio-metrics.test.ts +153 -0
- package/src/plugins/builtin/quote-monitor.test.tsx +114 -0
- package/src/plugins/builtin/sec.tsx +250 -0
- package/src/plugins/builtin/ticker-detail/chart-tab.tsx +43 -0
- package/src/plugins/builtin/ticker-detail/financials-tab.tsx +390 -0
- package/src/plugins/builtin/ticker-detail/index.tsx +80 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +242 -0
- package/src/plugins/builtin/ticker-detail/pane.tsx +183 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor.tsx +83 -0
- package/src/plugins/builtin/ticker-detail/settings.ts +132 -0
- package/src/plugins/builtin/ticker-detail-chart-tab-switch.test.tsx +193 -0
- package/src/plugins/builtin/ticker-detail.test.tsx +578 -0
- package/src/plugins/builtin/yahoo.ts +18 -0
- package/src/plugins/event-bus.ts +37 -0
- package/src/plugins/ibkr/__snapshots__/trade-tab.test.tsx.snap +35 -0
- package/src/plugins/ibkr/account-cache.test.ts +101 -0
- package/src/plugins/ibkr/account-cache.ts +137 -0
- package/src/plugins/ibkr/broker-adapter.ts +168 -0
- package/src/plugins/ibkr/config.test.ts +68 -0
- package/src/plugins/ibkr/config.ts +262 -0
- package/src/plugins/ibkr/dialogs.tsx +83 -0
- package/src/plugins/ibkr/flex.test.ts +107 -0
- package/src/plugins/ibkr/flex.ts +267 -0
- package/src/plugins/ibkr/fundamental-parser.ts +149 -0
- package/src/plugins/ibkr/gateway-helpers.ts +28 -0
- package/src/plugins/ibkr/gateway-selection.ts +51 -0
- package/src/plugins/ibkr/gateway-service.test.ts +450 -0
- package/src/plugins/ibkr/gateway-service.ts +2228 -0
- package/src/plugins/ibkr/index.test.tsx +183 -0
- package/src/plugins/ibkr/index.tsx +153 -0
- package/src/plugins/ibkr/instance-selection.test.ts +121 -0
- package/src/plugins/ibkr/instance-selection.ts +36 -0
- package/src/plugins/ibkr/price-normalization.test.ts +38 -0
- package/src/plugins/ibkr/price-normalization.ts +59 -0
- package/src/plugins/ibkr/trade-badge.tsx +27 -0
- package/src/plugins/ibkr/trade-tab.test.tsx +225 -0
- package/src/plugins/ibkr/trade-tab.tsx +1050 -0
- package/src/plugins/ibkr/trade-utils.test.ts +175 -0
- package/src/plugins/ibkr/trade-utils.ts +149 -0
- package/src/plugins/ibkr/trading-pane.tsx +438 -0
- package/src/plugins/ibkr/trading-state.test.ts +109 -0
- package/src/plugins/ibkr/trading-state.ts +339 -0
- package/src/plugins/loader.ts +71 -0
- package/src/plugins/pane-manager.test.ts +103 -0
- package/src/plugins/pane-manager.ts +974 -0
- package/src/plugins/plugin-persistence.ts +85 -0
- package/src/plugins/plugin-runtime.test.tsx +185 -0
- package/src/plugins/plugin-runtime.tsx +175 -0
- package/src/plugins/prediction-markets/cache.ts +114 -0
- package/src/plugins/prediction-markets/categories.ts +223 -0
- package/src/plugins/prediction-markets/chart.tsx +512 -0
- package/src/plugins/prediction-markets/columns.ts +133 -0
- package/src/plugins/prediction-markets/controller-data.ts +614 -0
- package/src/plugins/prediction-markets/controller.ts +725 -0
- package/src/plugins/prediction-markets/detail/book.tsx +118 -0
- package/src/plugins/prediction-markets/detail/outcomes.tsx +102 -0
- package/src/plugins/prediction-markets/detail/overview.tsx +73 -0
- package/src/plugins/prediction-markets/detail/pane.tsx +308 -0
- package/src/plugins/prediction-markets/detail/rules.tsx +16 -0
- package/src/plugins/prediction-markets/detail/shared.tsx +29 -0
- package/src/plugins/prediction-markets/detail/trades.tsx +30 -0
- package/src/plugins/prediction-markets/detail.test.tsx +47 -0
- package/src/plugins/prediction-markets/index.tsx +102 -0
- package/src/plugins/prediction-markets/keyboard.ts +64 -0
- package/src/plugins/prediction-markets/launch.test.ts +126 -0
- package/src/plugins/prediction-markets/launch.ts +240 -0
- package/src/plugins/prediction-markets/metrics.ts +311 -0
- package/src/plugins/prediction-markets/navigation.ts +90 -0
- package/src/plugins/prediction-markets/outcome-order.ts +19 -0
- package/src/plugins/prediction-markets/pane.test.tsx +425 -0
- package/src/plugins/prediction-markets/pane.tsx +294 -0
- package/src/plugins/prediction-markets/plugin.test.tsx +570 -0
- package/src/plugins/prediction-markets/rows.ts +229 -0
- package/src/plugins/prediction-markets/services/fetch.ts +97 -0
- package/src/plugins/prediction-markets/services/kalshi-adapter.ts +555 -0
- package/src/plugins/prediction-markets/services/polymarket-adapter.ts +660 -0
- package/src/plugins/prediction-markets/services/polymarket-ws.ts +108 -0
- package/src/plugins/prediction-markets/settings.ts +164 -0
- package/src/plugins/prediction-markets/status.ts +24 -0
- package/src/plugins/prediction-markets/table.tsx +84 -0
- package/src/plugins/prediction-markets/test-helpers.tsx +636 -0
- package/src/plugins/prediction-markets/types.ts +186 -0
- package/src/plugins/registry.ts +633 -0
- package/src/sources/exchange-rates.ts +18 -0
- package/src/sources/gloomberb-cloud.test.ts +199 -0
- package/src/sources/gloomberb-cloud.ts +326 -0
- package/src/sources/provider-errors.ts +19 -0
- package/src/sources/provider-router.test.ts +1476 -0
- package/src/sources/provider-router.ts +1405 -0
- package/src/sources/sec-edgar.test.ts +286 -0
- package/src/sources/sec-edgar.ts +526 -0
- package/src/sources/yahoo-finance.test.ts +14 -0
- package/src/sources/yahoo-finance.ts +1017 -0
- package/src/state/app-activity.test.ts +41 -0
- package/src/state/app-activity.ts +106 -0
- package/src/state/app-bootstrap.test.ts +471 -0
- package/src/state/app-bootstrap.ts +308 -0
- package/src/state/app-context.test.ts +406 -0
- package/src/state/app-context.test.tsx +132 -0
- package/src/state/app-context.tsx +969 -0
- package/src/state/selectors.ts +67 -0
- package/src/state/session-persistence.test.ts +128 -0
- package/src/state/session-persistence.ts +161 -0
- package/src/state/ticker-refresh-queue.test.ts +46 -0
- package/src/state/ticker-refresh-queue.ts +40 -0
- package/src/state/use-inline-tickers.ts +174 -0
- package/src/state/use-quote-streaming.test.ts +37 -0
- package/src/state/use-quote-streaming.test.tsx +70 -0
- package/src/state/use-quote-streaming.ts +80 -0
- package/src/state/use-session-snapshot.ts +84 -0
- package/src/test-support/data-provider.ts +22 -0
- package/src/theme/color-utils.ts +67 -0
- package/src/theme/colors.ts +128 -0
- package/src/theme/themes.test.ts +45 -0
- package/src/theme/themes.ts +491 -0
- package/src/types/broker.ts +105 -0
- package/src/types/config.ts +434 -0
- package/src/types/data-provider.ts +81 -0
- package/src/types/financials.ts +142 -0
- package/src/types/instrument.ts +29 -0
- package/src/types/persistence.ts +21 -0
- package/src/types/plugin.ts +354 -0
- package/src/types/ticker.ts +58 -0
- package/src/types/trading.ts +85 -0
- package/src/updater.test.ts +162 -0
- package/src/updater.ts +247 -0
- package/src/utils/api-client.ts +666 -0
- package/src/utils/ascii-chart.ts +172 -0
- package/src/utils/broker-instances.ts +47 -0
- package/src/utils/cli-output.ts +83 -0
- package/src/utils/currency-units.test.ts +49 -0
- package/src/utils/currency-units.ts +82 -0
- package/src/utils/debug-log.ts +133 -0
- package/src/utils/exchange-rate-map.ts +8 -0
- package/src/utils/format.ts +158 -0
- package/src/utils/fuzzy-search.ts +34 -0
- package/src/utils/market-status.ts +95 -0
- package/src/utils/options.ts +86 -0
- package/src/utils/price-history.ts +39 -0
- package/src/utils/quote-time.test.ts +22 -0
- package/src/utils/quote-time.ts +50 -0
- package/src/utils/sec.test.ts +55 -0
- package/src/utils/sec.ts +45 -0
- package/src/utils/ticker-list.test.ts +22 -0
- package/src/utils/ticker-list.ts +35 -0
- package/src/utils/ticker-metadata.ts +51 -0
- package/src/utils/ticker-search.test.ts +227 -0
- package/src/utils/ticker-search.ts +764 -0
- package/src/utils/ticker-tokenizer.test.ts +48 -0
- package/src/utils/ticker-tokenizer.ts +72 -0
- package/src/version.ts +1 -0
- package/install.mjs +0 -68
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import type { AppAction } from "../../state/app-context";
|
|
2
|
+
import { themes, getThemeIds } from "../../theme/themes";
|
|
3
|
+
|
|
4
|
+
export type CommandExecutor = (dispatch: React.Dispatch<AppAction>, context: CommandContext) => void | Promise<void>;
|
|
5
|
+
|
|
6
|
+
export interface CommandContext {
|
|
7
|
+
activeTicker: string | null;
|
|
8
|
+
activeCollectionId: string | null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Command {
|
|
12
|
+
id: string;
|
|
13
|
+
prefix: string; // e.g., "T", "AW", "RP"
|
|
14
|
+
label: string;
|
|
15
|
+
description: string;
|
|
16
|
+
hasArg?: boolean; // true if prefix takes an argument (e.g., "T AMD")
|
|
17
|
+
argPlaceholder?: string;
|
|
18
|
+
shortcut?: string;
|
|
19
|
+
category: string;
|
|
20
|
+
execute: CommandExecutor;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const commands: Command[] = [
|
|
24
|
+
// Ticker search
|
|
25
|
+
{
|
|
26
|
+
id: "search-ticker",
|
|
27
|
+
prefix: "T",
|
|
28
|
+
label: "Search Ticker",
|
|
29
|
+
description: "Search Yahoo Finance for a ticker",
|
|
30
|
+
hasArg: true,
|
|
31
|
+
argPlaceholder: "symbol or name",
|
|
32
|
+
category: "Search",
|
|
33
|
+
execute: () => {}, // handled specially by command bar
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "help",
|
|
37
|
+
prefix: "HELP",
|
|
38
|
+
label: "Help",
|
|
39
|
+
description: "Open the help window",
|
|
40
|
+
category: "Navigation",
|
|
41
|
+
execute: () => {}, // handled specially by command bar
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
// Watchlist/Portfolio management
|
|
45
|
+
{
|
|
46
|
+
id: "add-watchlist",
|
|
47
|
+
prefix: "AW",
|
|
48
|
+
label: "Add to Watchlist",
|
|
49
|
+
description: "Add current ticker to active watchlist",
|
|
50
|
+
hasArg: true,
|
|
51
|
+
argPlaceholder: "ticker",
|
|
52
|
+
category: "Portfolio",
|
|
53
|
+
execute: () => {}, // handled by command bar
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "add-portfolio",
|
|
57
|
+
prefix: "AP",
|
|
58
|
+
label: "Add to Portfolio",
|
|
59
|
+
description: "Add current ticker to active portfolio",
|
|
60
|
+
hasArg: true,
|
|
61
|
+
argPlaceholder: "ticker",
|
|
62
|
+
category: "Portfolio",
|
|
63
|
+
execute: () => {},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "remove-watchlist",
|
|
67
|
+
prefix: "RW",
|
|
68
|
+
label: "Remove from Watchlist",
|
|
69
|
+
description: "Remove current ticker from active watchlist",
|
|
70
|
+
hasArg: true,
|
|
71
|
+
argPlaceholder: "ticker",
|
|
72
|
+
category: "Portfolio",
|
|
73
|
+
execute: () => {},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "remove-portfolio",
|
|
77
|
+
prefix: "RP",
|
|
78
|
+
label: "Remove from Portfolio",
|
|
79
|
+
description: "Remove current ticker from active portfolio",
|
|
80
|
+
hasArg: true,
|
|
81
|
+
argPlaceholder: "ticker",
|
|
82
|
+
category: "Portfolio",
|
|
83
|
+
execute: () => {},
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
// Create / Delete
|
|
87
|
+
{
|
|
88
|
+
id: "new-portfolio",
|
|
89
|
+
prefix: "",
|
|
90
|
+
label: "New Portfolio",
|
|
91
|
+
description: "Create a new portfolio",
|
|
92
|
+
category: "Create",
|
|
93
|
+
execute: () => {},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "new-watchlist",
|
|
97
|
+
prefix: "",
|
|
98
|
+
label: "New Watchlist",
|
|
99
|
+
description: "Create a new watchlist",
|
|
100
|
+
category: "Create",
|
|
101
|
+
execute: () => {},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: "delete-portfolio",
|
|
105
|
+
prefix: "",
|
|
106
|
+
label: "Delete Portfolio",
|
|
107
|
+
description: "Remove a portfolio and its data",
|
|
108
|
+
category: "Danger",
|
|
109
|
+
execute: () => {},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: "delete-watchlist",
|
|
113
|
+
prefix: "",
|
|
114
|
+
label: "Delete Watchlist",
|
|
115
|
+
description: "Remove a watchlist",
|
|
116
|
+
category: "Danger",
|
|
117
|
+
execute: () => {},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: "add-broker-account",
|
|
121
|
+
prefix: "",
|
|
122
|
+
label: "Add Broker Account",
|
|
123
|
+
description: "Connect a new broker profile",
|
|
124
|
+
category: "Config",
|
|
125
|
+
execute: () => {},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: "disconnect-broker-account",
|
|
129
|
+
prefix: "",
|
|
130
|
+
label: "Disconnect Broker Account",
|
|
131
|
+
description: "Remove one connected broker profile and its imported data",
|
|
132
|
+
category: "Danger",
|
|
133
|
+
execute: () => {},
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
{
|
|
137
|
+
id: "pane-settings",
|
|
138
|
+
prefix: "PS",
|
|
139
|
+
label: "Pane Settings",
|
|
140
|
+
description: "Edit settings for the focused pane",
|
|
141
|
+
category: "Config",
|
|
142
|
+
execute: () => {}, // handled by command bar
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "layout",
|
|
146
|
+
prefix: "LAY",
|
|
147
|
+
label: "Layout Actions",
|
|
148
|
+
description: "Organize panes and saved layouts",
|
|
149
|
+
hasArg: true,
|
|
150
|
+
argPlaceholder: "action",
|
|
151
|
+
category: "Config",
|
|
152
|
+
execute: () => {}, // handled by command bar
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: "new-pane",
|
|
156
|
+
prefix: "NP",
|
|
157
|
+
label: "New Pane",
|
|
158
|
+
description: "Add or create a new pane from plugin templates",
|
|
159
|
+
hasArg: true,
|
|
160
|
+
argPlaceholder: "pane",
|
|
161
|
+
category: "Config",
|
|
162
|
+
execute: () => {}, // handled by command bar
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: "toggle-status-bar",
|
|
166
|
+
prefix: "SB",
|
|
167
|
+
label: "Toggle Status Bar",
|
|
168
|
+
description: "Show or hide the keyboard shortcuts bar",
|
|
169
|
+
category: "Config",
|
|
170
|
+
execute: (dispatch) => {
|
|
171
|
+
dispatch({ type: "TOGGLE_STATUS_BAR" });
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
// Theme
|
|
176
|
+
{
|
|
177
|
+
id: "theme",
|
|
178
|
+
prefix: "TH",
|
|
179
|
+
label: "Change Theme",
|
|
180
|
+
description: "Switch color theme",
|
|
181
|
+
hasArg: true,
|
|
182
|
+
argPlaceholder: "theme name",
|
|
183
|
+
category: "Config",
|
|
184
|
+
execute: () => {}, // handled by command bar
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: "cycle-chart-renderer",
|
|
188
|
+
prefix: "CR",
|
|
189
|
+
label: "Cycle Chart Renderer",
|
|
190
|
+
description: "Cycle chart rendering between Auto, Kitty, and Braille",
|
|
191
|
+
category: "Config",
|
|
192
|
+
execute: () => {}, // handled specially by command bar
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
// Plugins
|
|
196
|
+
{
|
|
197
|
+
id: "plugins",
|
|
198
|
+
prefix: "PL",
|
|
199
|
+
label: "Manage Plugins",
|
|
200
|
+
description: "Toggle plugins on/off",
|
|
201
|
+
hasArg: true,
|
|
202
|
+
argPlaceholder: "plugin name",
|
|
203
|
+
category: "Config",
|
|
204
|
+
execute: () => {}, // handled by command bar
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
// Import/Export
|
|
208
|
+
{
|
|
209
|
+
id: "export-config",
|
|
210
|
+
prefix: "",
|
|
211
|
+
label: "Export Config",
|
|
212
|
+
description: "Save config to ~/gloomberb-config-backup.json",
|
|
213
|
+
category: "Config",
|
|
214
|
+
execute: () => {}, // handled by command bar
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
id: "import-config",
|
|
218
|
+
prefix: "",
|
|
219
|
+
label: "Import Config",
|
|
220
|
+
description: "Load config from ~/gloomberb-config-backup.json",
|
|
221
|
+
category: "Config",
|
|
222
|
+
execute: () => {}, // handled by command bar
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
// Danger zone
|
|
226
|
+
{
|
|
227
|
+
id: "reset-all-data",
|
|
228
|
+
prefix: "",
|
|
229
|
+
label: "Reset All Data",
|
|
230
|
+
description: "Delete all data and reset to first-run state",
|
|
231
|
+
category: "Danger",
|
|
232
|
+
execute: () => {}, // handled by command bar (needs confirm dialog)
|
|
233
|
+
},
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
/** Get theme options for the command bar */
|
|
237
|
+
export function getThemeOptions(): Array<{ id: string; name: string; description: string }> {
|
|
238
|
+
return getThemeIds().map((id) => ({
|
|
239
|
+
id,
|
|
240
|
+
name: themes[id]!.name,
|
|
241
|
+
description: themes[id]!.description,
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Find a command whose prefix matches the start of the input */
|
|
246
|
+
export function matchPrefix(input: string): { command: Command; arg: string } | null {
|
|
247
|
+
const upper = input.toUpperCase().trim();
|
|
248
|
+
if (!upper) return null;
|
|
249
|
+
|
|
250
|
+
// Sort by prefix length descending so longer prefixes match first (e.g., "AW" before "A")
|
|
251
|
+
const sorted = [...commands].sort((a, b) => b.prefix.length - a.prefix.length);
|
|
252
|
+
|
|
253
|
+
for (const cmd of sorted) {
|
|
254
|
+
if (upper.startsWith(cmd.prefix + " ") || upper === cmd.prefix) {
|
|
255
|
+
const arg = input.slice(cmd.prefix.length).trim();
|
|
256
|
+
return { command: cmd, arg };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import type { PaneTemplateDef, WizardStep } from "../../types/plugin";
|
|
3
|
+
import type {
|
|
4
|
+
CommandBarRoute,
|
|
5
|
+
CommandBarWorkflowField,
|
|
6
|
+
} from "./workflow-types";
|
|
7
|
+
import {
|
|
8
|
+
buildGeneratedTemplateField,
|
|
9
|
+
getCollectionCommandAction,
|
|
10
|
+
getCollectionCommandKind,
|
|
11
|
+
getCollectionCommandVerb,
|
|
12
|
+
getFirstVisibleFieldId,
|
|
13
|
+
getScreenFooterLeft,
|
|
14
|
+
getScreenFooterRight,
|
|
15
|
+
getVisibleWorkflowFields,
|
|
16
|
+
isCollectionCommand,
|
|
17
|
+
isRootParsedCommand,
|
|
18
|
+
isRouteCommandId,
|
|
19
|
+
isWorkflowTextField,
|
|
20
|
+
looksDestructiveCommand,
|
|
21
|
+
moveSelectedValue,
|
|
22
|
+
normalizeWizardFields,
|
|
23
|
+
routeCommandIdToScreen,
|
|
24
|
+
slugifyName,
|
|
25
|
+
summarizeError,
|
|
26
|
+
summarizePaneSettingValue,
|
|
27
|
+
summarizeWorkflowFieldValue,
|
|
28
|
+
toggleSelectedValue,
|
|
29
|
+
} from "./helpers";
|
|
30
|
+
|
|
31
|
+
const workflowFields: CommandBarWorkflowField[] = [
|
|
32
|
+
{
|
|
33
|
+
id: "source",
|
|
34
|
+
label: "Source",
|
|
35
|
+
type: "select",
|
|
36
|
+
options: [
|
|
37
|
+
{ label: "Manual", value: "manual" },
|
|
38
|
+
{ label: "Broker", value: "broker" },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "account",
|
|
43
|
+
label: "Account",
|
|
44
|
+
type: "text",
|
|
45
|
+
dependsOn: [{ key: "source", value: "broker" }],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "enabled",
|
|
49
|
+
label: "Enabled",
|
|
50
|
+
type: "toggle",
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
describe("command-bar helpers", () => {
|
|
55
|
+
test("filters visible workflow fields by dependencies", () => {
|
|
56
|
+
expect(getVisibleWorkflowFields(workflowFields, { source: "manual" }).map((field) => field.id)).toEqual([
|
|
57
|
+
"source",
|
|
58
|
+
"enabled",
|
|
59
|
+
]);
|
|
60
|
+
expect(getFirstVisibleFieldId(workflowFields, { source: "broker" })).toBe("source");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("summarizes workflow field values using labels and truncation", () => {
|
|
64
|
+
expect(summarizeWorkflowFieldValue(workflowFields[2]!, true)).toBe("On");
|
|
65
|
+
expect(summarizeWorkflowFieldValue(workflowFields[0]!, "broker")).toBe("Broker");
|
|
66
|
+
expect(summarizeWorkflowFieldValue({
|
|
67
|
+
id: "prompt",
|
|
68
|
+
label: "Prompt",
|
|
69
|
+
type: "textarea",
|
|
70
|
+
}, "quality\ncompounders")).toBe("quality compounders");
|
|
71
|
+
expect(summarizeWorkflowFieldValue({
|
|
72
|
+
id: "columns",
|
|
73
|
+
label: "Columns",
|
|
74
|
+
type: "ordered-multi-select",
|
|
75
|
+
options: [
|
|
76
|
+
{ label: "Symbol", value: "symbol" },
|
|
77
|
+
{ label: "Price", value: "price" },
|
|
78
|
+
{ label: "P&L", value: "pnl" },
|
|
79
|
+
{ label: "Volume", value: "volume" },
|
|
80
|
+
],
|
|
81
|
+
}, ["symbol", "price", "pnl", "volume"])).toBe("Symbol, Price, P&L +1");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("summarizes pane setting values consistently", () => {
|
|
85
|
+
expect(summarizePaneSettingValue({
|
|
86
|
+
key: "theme",
|
|
87
|
+
label: "Theme",
|
|
88
|
+
type: "select",
|
|
89
|
+
options: [{ label: "Nord", value: "nord" }],
|
|
90
|
+
}, "nord")).toBe("Nord");
|
|
91
|
+
expect(summarizePaneSettingValue({
|
|
92
|
+
key: "columns",
|
|
93
|
+
label: "Columns",
|
|
94
|
+
type: "ordered-multi-select",
|
|
95
|
+
options: [
|
|
96
|
+
{ label: "Symbol", value: "symbol" },
|
|
97
|
+
{ label: "Price", value: "price" },
|
|
98
|
+
{ label: "P&L", value: "pnl" },
|
|
99
|
+
{ label: "Volume", value: "volume" },
|
|
100
|
+
],
|
|
101
|
+
}, ["symbol", "price", "pnl", "volume"])).toBe("Symbol, Price, P&L +1");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("toggles and reorders selected values while preserving unknown entries", () => {
|
|
105
|
+
expect(toggleSelectedValue(["symbol", "price"], "price")).toEqual(["symbol"]);
|
|
106
|
+
expect(toggleSelectedValue(["symbol"], "price")).toEqual(["symbol", "price"]);
|
|
107
|
+
|
|
108
|
+
expect(moveSelectedValue(
|
|
109
|
+
{
|
|
110
|
+
options: [
|
|
111
|
+
{ label: "Symbol", value: "symbol" },
|
|
112
|
+
{ label: "Price", value: "price" },
|
|
113
|
+
{ label: "P&L", value: "pnl" },
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
["symbol", "price", "custom"],
|
|
117
|
+
"price",
|
|
118
|
+
"up",
|
|
119
|
+
)).toEqual(["price", "symbol", "custom"]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("normalizes wizard fields and derives defaults from steps", () => {
|
|
123
|
+
const steps: WizardStep[] = [
|
|
124
|
+
{ key: "intro", label: "Intro", type: "info", body: ["Line one", "Line two"] },
|
|
125
|
+
{ key: "_validate-broker", label: "Validate", type: "info", body: ["Connecting…", "Connected"] },
|
|
126
|
+
{ key: "mode", label: "Mode", type: "select", options: [{ label: "Paper", value: "paper" }, { label: "Live", value: "live" }] },
|
|
127
|
+
{ key: "account", label: "Account", type: "text", defaultValue: "DU12345", dependsOn: { key: "mode", value: "live" } },
|
|
128
|
+
{ key: "prompt", label: "Prompt", type: "textarea", defaultValue: "Find quality compounders" },
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
const normalized = normalizeWizardFields(steps);
|
|
132
|
+
|
|
133
|
+
expect(normalized.description).toEqual(["Line one", "Line two"]);
|
|
134
|
+
expect(normalized.pendingLabel).toBe("Connecting…");
|
|
135
|
+
expect(normalized.successLabel).toBe("Connected");
|
|
136
|
+
expect(normalized.initialValues).toEqual({
|
|
137
|
+
mode: "paper",
|
|
138
|
+
account: "DU12345",
|
|
139
|
+
prompt: "Find quality compounders",
|
|
140
|
+
});
|
|
141
|
+
expect(normalized.fields[1]?.dependsOn).toEqual([{ key: "mode", value: "live" }]);
|
|
142
|
+
expect(normalized.fields[2]?.type).toBe("textarea");
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test("builds generated template fields from shortcut placeholders", () => {
|
|
146
|
+
const tickerTemplate: PaneTemplateDef = {
|
|
147
|
+
id: "detail",
|
|
148
|
+
paneId: "detail",
|
|
149
|
+
label: "Detail",
|
|
150
|
+
description: "Open detail",
|
|
151
|
+
shortcut: { prefix: "detail", argPlaceholder: "ticker" },
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
expect(buildGeneratedTemplateField(tickerTemplate, "AAPL")).toEqual({
|
|
155
|
+
field: {
|
|
156
|
+
id: "ticker",
|
|
157
|
+
label: "Ticker",
|
|
158
|
+
type: "text",
|
|
159
|
+
required: true,
|
|
160
|
+
placeholder: "AAPL",
|
|
161
|
+
},
|
|
162
|
+
initialValue: "AAPL",
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
expect(buildGeneratedTemplateField({
|
|
166
|
+
...tickerTemplate,
|
|
167
|
+
shortcut: { prefix: "compare", argPlaceholder: "tickers" },
|
|
168
|
+
}, null)).toEqual({
|
|
169
|
+
field: {
|
|
170
|
+
id: "tickers",
|
|
171
|
+
label: "Tickers",
|
|
172
|
+
type: "text",
|
|
173
|
+
required: true,
|
|
174
|
+
placeholder: "AAPL, MSFT, NVDA",
|
|
175
|
+
},
|
|
176
|
+
initialValue: "",
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("formats screen footers based on route context", () => {
|
|
181
|
+
const orderedPickerRoute: CommandBarRoute = {
|
|
182
|
+
kind: "picker",
|
|
183
|
+
pickerId: "field-multi-select",
|
|
184
|
+
title: "Columns",
|
|
185
|
+
query: "",
|
|
186
|
+
selectedIdx: 0,
|
|
187
|
+
hoveredIdx: null,
|
|
188
|
+
options: [],
|
|
189
|
+
payload: { fieldType: "ordered-multi-select" },
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
expect(getScreenFooterLeft(null)).toBe("up/down move enter select");
|
|
193
|
+
expect(getScreenFooterLeft(orderedPickerRoute)).toBe("up/down move space toggle [ ] reorder enter done");
|
|
194
|
+
expect(getScreenFooterRight(orderedPickerRoute)).toBe("esc back");
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test("maps route and collection command ids", () => {
|
|
198
|
+
expect(isRouteCommandId("plugins")).toBe(true);
|
|
199
|
+
expect(routeCommandIdToScreen("plugins")).toBe("plugins");
|
|
200
|
+
expect(isRootParsedCommand("remove-portfolio")).toBe(true);
|
|
201
|
+
expect(isCollectionCommand("remove-portfolio")).toBe(true);
|
|
202
|
+
expect(getCollectionCommandKind("remove-portfolio")).toBe("portfolio");
|
|
203
|
+
expect(getCollectionCommandAction("remove-portfolio")).toBe("remove");
|
|
204
|
+
expect(getCollectionCommandVerb("add")).toBe("Add");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test("identifies workflow text fields and destructive commands", () => {
|
|
208
|
+
expect(isWorkflowTextField({ id: "name", label: "Name", type: "text" })).toBe(true);
|
|
209
|
+
expect(isWorkflowTextField({ id: "prompt", label: "Prompt", type: "textarea" })).toBe(true);
|
|
210
|
+
expect(isWorkflowTextField({ id: "enabled", label: "Enabled", type: "toggle" })).toBe(false);
|
|
211
|
+
expect(looksDestructiveCommand({
|
|
212
|
+
id: "reset-layout",
|
|
213
|
+
label: "Reset Layout",
|
|
214
|
+
description: "Reset all panes",
|
|
215
|
+
keywords: ["danger"],
|
|
216
|
+
})).toBe(true);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
test("slugifies names and summarizes errors", () => {
|
|
220
|
+
expect(slugifyName("Broker Account 01", "portfolio")).toBe("broker-account-01");
|
|
221
|
+
expect(summarizeError(new Error("boom"))).toMatchObject({ name: "Error", message: "boom" });
|
|
222
|
+
expect(summarizeError("broken")).toEqual({ message: "broken" });
|
|
223
|
+
});
|
|
224
|
+
});
|