@spfunctions/cli 1.7.17 → 1.7.20

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 (180) hide show
  1. package/dist/101.index.js +1 -0
  2. package/dist/12.index.js +1 -0
  3. package/dist/160.index.js +1 -0
  4. package/dist/174.index.js +1 -0
  5. package/dist/278.index.js +6 -0
  6. package/dist/582.index.js +1 -0
  7. package/dist/641.index.js +324 -0
  8. package/dist/669.index.js +1 -0
  9. package/dist/722.index.js +1 -0
  10. package/dist/788.index.js +1 -0
  11. package/dist/816.index.js +12 -0
  12. package/dist/830.index.js +1 -0
  13. package/dist/921.index.js +1 -0
  14. package/dist/index.js +1 -813
  15. package/package.json +6 -2
  16. package/dist/cache.d.ts +0 -6
  17. package/dist/cache.js +0 -31
  18. package/dist/cache.test.d.ts +0 -1
  19. package/dist/cache.test.js +0 -73
  20. package/dist/client.d.ts +0 -56
  21. package/dist/client.js +0 -205
  22. package/dist/client.test.d.ts +0 -1
  23. package/dist/client.test.js +0 -89
  24. package/dist/commands/agent.d.ts +0 -20
  25. package/dist/commands/agent.js +0 -4119
  26. package/dist/commands/announcements.d.ts +0 -3
  27. package/dist/commands/announcements.js +0 -28
  28. package/dist/commands/augment.d.ts +0 -12
  29. package/dist/commands/augment.js +0 -56
  30. package/dist/commands/balance.d.ts +0 -3
  31. package/dist/commands/balance.js +0 -17
  32. package/dist/commands/book.d.ts +0 -17
  33. package/dist/commands/book.js +0 -220
  34. package/dist/commands/cancel.d.ts +0 -5
  35. package/dist/commands/cancel.js +0 -41
  36. package/dist/commands/context.d.ts +0 -6
  37. package/dist/commands/context.js +0 -208
  38. package/dist/commands/create.d.ts +0 -7
  39. package/dist/commands/create.js +0 -42
  40. package/dist/commands/dashboard.d.ts +0 -14
  41. package/dist/commands/dashboard.js +0 -215
  42. package/dist/commands/delta.d.ts +0 -16
  43. package/dist/commands/delta.js +0 -115
  44. package/dist/commands/edges.d.ts +0 -26
  45. package/dist/commands/edges.js +0 -237
  46. package/dist/commands/evaluate.d.ts +0 -4
  47. package/dist/commands/evaluate.js +0 -30
  48. package/dist/commands/explore.d.ts +0 -14
  49. package/dist/commands/explore.js +0 -115
  50. package/dist/commands/feed.d.ts +0 -13
  51. package/dist/commands/feed.js +0 -73
  52. package/dist/commands/fills.d.ts +0 -4
  53. package/dist/commands/fills.js +0 -29
  54. package/dist/commands/forecast.d.ts +0 -4
  55. package/dist/commands/forecast.js +0 -53
  56. package/dist/commands/get.d.ts +0 -5
  57. package/dist/commands/get.js +0 -98
  58. package/dist/commands/heartbeat.d.ts +0 -20
  59. package/dist/commands/heartbeat.js +0 -73
  60. package/dist/commands/history.d.ts +0 -3
  61. package/dist/commands/history.js +0 -38
  62. package/dist/commands/liquidity.d.ts +0 -14
  63. package/dist/commands/liquidity.js +0 -378
  64. package/dist/commands/list.d.ts +0 -5
  65. package/dist/commands/list.js +0 -38
  66. package/dist/commands/login.d.ts +0 -9
  67. package/dist/commands/login.js +0 -98
  68. package/dist/commands/markets.d.ts +0 -10
  69. package/dist/commands/markets.js +0 -39
  70. package/dist/commands/milestones.d.ts +0 -8
  71. package/dist/commands/milestones.js +0 -56
  72. package/dist/commands/orders.d.ts +0 -4
  73. package/dist/commands/orders.js +0 -28
  74. package/dist/commands/performance.d.ts +0 -11
  75. package/dist/commands/performance.js +0 -250
  76. package/dist/commands/positions.d.ts +0 -19
  77. package/dist/commands/positions.js +0 -294
  78. package/dist/commands/prompt.d.ts +0 -13
  79. package/dist/commands/prompt.js +0 -35
  80. package/dist/commands/publish.d.ts +0 -15
  81. package/dist/commands/publish.js +0 -39
  82. package/dist/commands/query.d.ts +0 -15
  83. package/dist/commands/query.js +0 -132
  84. package/dist/commands/rfq.d.ts +0 -5
  85. package/dist/commands/rfq.js +0 -35
  86. package/dist/commands/scan.d.ts +0 -11
  87. package/dist/commands/scan.js +0 -230
  88. package/dist/commands/schedule.d.ts +0 -3
  89. package/dist/commands/schedule.js +0 -38
  90. package/dist/commands/settlements.d.ts +0 -6
  91. package/dist/commands/settlements.js +0 -50
  92. package/dist/commands/setup.d.ts +0 -24
  93. package/dist/commands/setup.js +0 -700
  94. package/dist/commands/signal.d.ts +0 -6
  95. package/dist/commands/signal.js +0 -32
  96. package/dist/commands/strategies.d.ts +0 -11
  97. package/dist/commands/strategies.js +0 -130
  98. package/dist/commands/telegram.d.ts +0 -15
  99. package/dist/commands/telegram.js +0 -125
  100. package/dist/commands/trade.d.ts +0 -12
  101. package/dist/commands/trade.js +0 -112
  102. package/dist/commands/watch.d.ts +0 -19
  103. package/dist/commands/watch.js +0 -157
  104. package/dist/commands/whatif.d.ts +0 -17
  105. package/dist/commands/whatif.js +0 -209
  106. package/dist/commands/x.d.ts +0 -28
  107. package/dist/commands/x.js +0 -167
  108. package/dist/config.d.ts +0 -55
  109. package/dist/config.js +0 -139
  110. package/dist/config.test.d.ts +0 -1
  111. package/dist/config.test.js +0 -138
  112. package/dist/index.d.ts +0 -20
  113. package/dist/kalshi.d.ts +0 -144
  114. package/dist/kalshi.js +0 -498
  115. package/dist/polymarket.d.ts +0 -237
  116. package/dist/polymarket.js +0 -353
  117. package/dist/polymarket.test.d.ts +0 -1
  118. package/dist/polymarket.test.js +0 -424
  119. package/dist/share.d.ts +0 -4
  120. package/dist/share.js +0 -27
  121. package/dist/skills/loader.d.ts +0 -19
  122. package/dist/skills/loader.js +0 -86
  123. package/dist/telegram/agent-bridge.d.ts +0 -15
  124. package/dist/telegram/agent-bridge.js +0 -573
  125. package/dist/telegram/bot.d.ts +0 -10
  126. package/dist/telegram/bot.js +0 -297
  127. package/dist/telegram/commands.d.ts +0 -11
  128. package/dist/telegram/commands.js +0 -120
  129. package/dist/telegram/format.d.ts +0 -11
  130. package/dist/telegram/format.js +0 -51
  131. package/dist/telegram/format.test.d.ts +0 -1
  132. package/dist/telegram/format.test.js +0 -73
  133. package/dist/telegram/poller.d.ts +0 -6
  134. package/dist/telegram/poller.js +0 -32
  135. package/dist/topics.d.ts +0 -17
  136. package/dist/topics.js +0 -102
  137. package/dist/topics.test.d.ts +0 -1
  138. package/dist/topics.test.js +0 -131
  139. package/dist/tui/border.d.ts +0 -33
  140. package/dist/tui/border.js +0 -87
  141. package/dist/tui/chart.d.ts +0 -19
  142. package/dist/tui/chart.js +0 -117
  143. package/dist/tui/dashboard.d.ts +0 -9
  144. package/dist/tui/dashboard.js +0 -814
  145. package/dist/tui/layout.d.ts +0 -16
  146. package/dist/tui/layout.js +0 -41
  147. package/dist/tui/screen.d.ts +0 -33
  148. package/dist/tui/screen.js +0 -102
  149. package/dist/tui/state.d.ts +0 -40
  150. package/dist/tui/state.js +0 -36
  151. package/dist/tui/widgets/commandbar.d.ts +0 -8
  152. package/dist/tui/widgets/commandbar.js +0 -82
  153. package/dist/tui/widgets/detail.d.ts +0 -9
  154. package/dist/tui/widgets/detail.js +0 -151
  155. package/dist/tui/widgets/edges.d.ts +0 -4
  156. package/dist/tui/widgets/edges.js +0 -34
  157. package/dist/tui/widgets/liquidity.d.ts +0 -9
  158. package/dist/tui/widgets/liquidity.js +0 -142
  159. package/dist/tui/widgets/orders.d.ts +0 -4
  160. package/dist/tui/widgets/orders.js +0 -37
  161. package/dist/tui/widgets/portfolio.d.ts +0 -4
  162. package/dist/tui/widgets/portfolio.js +0 -59
  163. package/dist/tui/widgets/signals.d.ts +0 -4
  164. package/dist/tui/widgets/signals.js +0 -31
  165. package/dist/tui/widgets/statusbar.d.ts +0 -8
  166. package/dist/tui/widgets/statusbar.js +0 -72
  167. package/dist/tui/widgets/thesis.d.ts +0 -4
  168. package/dist/tui/widgets/thesis.js +0 -66
  169. package/dist/tui/widgets/trade.d.ts +0 -9
  170. package/dist/tui/widgets/trade.js +0 -117
  171. package/dist/tui/widgets/upcoming.d.ts +0 -4
  172. package/dist/tui/widgets/upcoming.js +0 -41
  173. package/dist/tui/widgets/whatif.d.ts +0 -7
  174. package/dist/tui/widgets/whatif.js +0 -113
  175. package/dist/types/output.d.ts +0 -412
  176. package/dist/types/output.js +0 -9
  177. package/dist/utils.d.ts +0 -42
  178. package/dist/utils.js +0 -124
  179. package/dist/utils.test.d.ts +0 -1
  180. package/dist/utils.test.js +0 -111
@@ -1,16 +0,0 @@
1
- /**
2
- * Layout Engine — divide terminal into named regions
3
- */
4
- export interface Region {
5
- name: string;
6
- row: number;
7
- col: number;
8
- width: number;
9
- height: number;
10
- }
11
- /** Compute OVERVIEW layout (6 panels + status bars) */
12
- export declare function overviewLayout(cols: number, rows: number): Region[];
13
- /** Full-screen region (for DETAIL, LIQUIDITY, WHATIF modes) */
14
- export declare function fullLayout(cols: number, rows: number): Region;
15
- /** Narrow layout for terminals < 80 cols (single column) */
16
- export declare function narrowLayout(cols: number, rows: number): Region[];
@@ -1,41 +0,0 @@
1
- "use strict";
2
- /**
3
- * Layout Engine — divide terminal into named regions
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.overviewLayout = overviewLayout;
7
- exports.fullLayout = fullLayout;
8
- exports.narrowLayout = narrowLayout;
9
- /** Compute OVERVIEW layout (6 panels + status bars) */
10
- function overviewLayout(cols, rows) {
11
- const contentRows = rows - 2; // -1 status bar, -1 command bar
12
- const leftWidth = Math.floor(cols * 0.55);
13
- const rightWidth = cols - leftWidth - 1; // -1 for vertical divider
14
- const rightCol = leftWidth + 1;
15
- // Vertical split: 45% top, 25% mid, 30% bottom
16
- const topH = Math.max(Math.floor(contentRows * 0.45), 6);
17
- const midH = Math.max(Math.floor(contentRows * 0.25), 4);
18
- const botH = Math.max(contentRows - topH - midH, 3);
19
- return [
20
- { name: 'positions', row: 1, col: 0, width: leftWidth, height: topH },
21
- { name: 'thesis', row: 1, col: rightCol, width: rightWidth, height: topH },
22
- { name: 'edges', row: 1 + topH, col: 0, width: leftWidth, height: midH },
23
- { name: 'upcoming', row: 1 + topH, col: rightCol, width: rightWidth, height: midH },
24
- { name: 'orders', row: 1 + topH + midH, col: 0, width: leftWidth, height: botH },
25
- { name: 'signals', row: 1 + topH + midH, col: rightCol, width: rightWidth, height: botH },
26
- ];
27
- }
28
- /** Full-screen region (for DETAIL, LIQUIDITY, WHATIF modes) */
29
- function fullLayout(cols, rows) {
30
- return { name: 'main', row: 1, col: 0, width: cols, height: rows - 2 };
31
- }
32
- /** Narrow layout for terminals < 80 cols (single column) */
33
- function narrowLayout(cols, rows) {
34
- const contentRows = rows - 2;
35
- const h = Math.floor(contentRows / 3);
36
- return [
37
- { name: 'positions', row: 1, col: 0, width: cols, height: h },
38
- { name: 'edges', row: 1 + h, col: 0, width: cols, height: h },
39
- { name: 'thesis', row: 1 + 2 * h, col: 0, width: cols, height: contentRows - 2 * h },
40
- ];
41
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * ScreenBuffer — Double-buffered terminal renderer
3
- *
4
- * Only writes changed cells to stdout (no flickering).
5
- * This is how Bloomberg terminals stay "alive" without blinking.
6
- */
7
- export interface Cell {
8
- char: string;
9
- fg: string;
10
- bg: string;
11
- }
12
- export declare class ScreenBuffer {
13
- private front;
14
- private back;
15
- cols: number;
16
- rows: number;
17
- constructor();
18
- private createBuffer;
19
- /** Write a plain string at position. Strips ANSI codes for positioning. */
20
- write(row: number, col: number, text: string, fg?: string, bg?: string): void;
21
- /** Write styled text — supports inline ANSI codes (parses them for fg tracking) */
22
- writeStyled(row: number, col: number, segments: Array<{
23
- text: string;
24
- fg?: string;
25
- bg?: string;
26
- }>): void;
27
- /** Fill a rectangular region with a character */
28
- fill(row: number, col: number, width: number, height: number, char?: string, fg?: string, bg?: string): void;
29
- /** Diff front vs back, output only changed cells */
30
- flush(): void;
31
- /** Handle terminal resize */
32
- resize(): void;
33
- }
@@ -1,102 +0,0 @@
1
- "use strict";
2
- /**
3
- * ScreenBuffer — Double-buffered terminal renderer
4
- *
5
- * Only writes changed cells to stdout (no flickering).
6
- * This is how Bloomberg terminals stay "alive" without blinking.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ScreenBuffer = void 0;
10
- class ScreenBuffer {
11
- front;
12
- back;
13
- cols;
14
- rows;
15
- constructor() {
16
- this.cols = process.stdout.columns || 120;
17
- this.rows = process.stdout.rows || 40;
18
- this.front = this.createBuffer();
19
- this.back = this.createBuffer();
20
- }
21
- createBuffer() {
22
- return Array.from({ length: this.rows }, () => Array.from({ length: this.cols }, () => ({ char: ' ', fg: '', bg: '' })));
23
- }
24
- /** Write a plain string at position. Strips ANSI codes for positioning. */
25
- write(row, col, text, fg = '', bg = '') {
26
- if (row < 0 || row >= this.rows)
27
- return;
28
- let pos = col;
29
- for (let i = 0; i < text.length && pos < this.cols; i++) {
30
- if (pos >= 0) {
31
- this.back[row][pos] = { char: text[i], fg, bg };
32
- }
33
- pos++;
34
- }
35
- }
36
- /** Write styled text — supports inline ANSI codes (parses them for fg tracking) */
37
- writeStyled(row, col, segments) {
38
- let pos = col;
39
- for (const seg of segments) {
40
- for (let i = 0; i < seg.text.length && pos < this.cols; i++) {
41
- if (row >= 0 && row < this.rows && pos >= 0) {
42
- this.back[row][pos] = { char: seg.text[i], fg: seg.fg || '', bg: seg.bg || '' };
43
- }
44
- pos++;
45
- }
46
- }
47
- }
48
- /** Fill a rectangular region with a character */
49
- fill(row, col, width, height, char = ' ', fg = '', bg = '') {
50
- for (let r = row; r < row + height && r < this.rows; r++) {
51
- for (let c = col; c < col + width && c < this.cols; c++) {
52
- if (r >= 0 && c >= 0) {
53
- this.back[r][c] = { char, fg, bg };
54
- }
55
- }
56
- }
57
- }
58
- /** Diff front vs back, output only changed cells */
59
- flush() {
60
- let output = '';
61
- let lastFg = '';
62
- let lastBg = '';
63
- for (let r = 0; r < this.rows; r++) {
64
- for (let c = 0; c < this.cols; c++) {
65
- const f = this.front[r][c];
66
- const b = this.back[r][c];
67
- if (f.char !== b.char || f.fg !== b.fg || f.bg !== b.bg) {
68
- // Move cursor
69
- output += `\x1b[${r + 1};${c + 1}H`;
70
- // Set colors if changed
71
- if (b.fg !== lastFg || b.bg !== lastBg) {
72
- output += '\x1b[0m';
73
- if (b.fg)
74
- output += b.fg;
75
- if (b.bg)
76
- output += b.bg;
77
- lastFg = b.fg;
78
- lastBg = b.bg;
79
- }
80
- output += b.char;
81
- }
82
- }
83
- }
84
- if (output) {
85
- output += '\x1b[0m'; // reset at end
86
- process.stdout.write(output);
87
- }
88
- // Swap: back becomes front, create fresh back
89
- this.front = this.back;
90
- this.back = this.createBuffer();
91
- }
92
- /** Handle terminal resize */
93
- resize() {
94
- this.cols = process.stdout.columns || 120;
95
- this.rows = process.stdout.rows || 40;
96
- this.front = this.createBuffer();
97
- this.back = this.createBuffer();
98
- // Force full redraw
99
- process.stdout.write('\x1b[2J');
100
- }
101
- }
102
- exports.ScreenBuffer = ScreenBuffer;
@@ -1,40 +0,0 @@
1
- /**
2
- * Dashboard state — single source of truth
3
- */
4
- export type Mode = 'overview' | 'detail' | 'liquidity' | 'whatif' | 'trade';
5
- export type FocusArea = 'positions' | 'edges';
6
- export interface DashboardState {
7
- mode: Mode;
8
- prevMode: Mode;
9
- selectedIndex: number;
10
- focusArea: FocusArea;
11
- detailTicker: string | null;
12
- liquidityTopic: string;
13
- liquiditySelectedIndex: number;
14
- whatifScenarioIndex: number;
15
- whatifResult: any | null;
16
- whatifThesisId: string | null;
17
- tradeParams: {
18
- ticker: string;
19
- side: string;
20
- action: string;
21
- qty: number;
22
- price: number;
23
- } | null;
24
- tradeCountdown: number;
25
- tradeField: 'qty' | 'price';
26
- positions: any[];
27
- theses: any[];
28
- contexts: Map<string, any>;
29
- edges: any[];
30
- orders: any[];
31
- signals: any[];
32
- events: any[];
33
- balance: number;
34
- candleCache: Map<string, any[]>;
35
- liquidityData: Map<string, any[]>;
36
- error: string | null;
37
- lastRefresh: Record<string, number>;
38
- exchangeOpen: boolean | null;
39
- }
40
- export declare function initialState(): DashboardState;
package/dist/tui/state.js DELETED
@@ -1,36 +0,0 @@
1
- "use strict";
2
- /**
3
- * Dashboard state — single source of truth
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initialState = initialState;
7
- function initialState() {
8
- return {
9
- mode: 'overview',
10
- prevMode: 'overview',
11
- selectedIndex: 0,
12
- focusArea: 'positions',
13
- detailTicker: null,
14
- liquidityTopic: 'oil',
15
- liquiditySelectedIndex: 0,
16
- whatifScenarioIndex: 0,
17
- whatifResult: null,
18
- whatifThesisId: null,
19
- tradeParams: null,
20
- tradeCountdown: -1,
21
- tradeField: 'qty',
22
- positions: [],
23
- theses: [],
24
- contexts: new Map(),
25
- edges: [],
26
- orders: [],
27
- signals: [],
28
- events: [],
29
- balance: 0,
30
- candleCache: new Map(),
31
- liquidityData: new Map(),
32
- error: null,
33
- lastRefresh: {},
34
- exchangeOpen: null,
35
- };
36
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Command bar — bottom row of the dashboard
3
- *
4
- * Context-sensitive key hints that change based on current mode.
5
- */
6
- import type { ScreenBuffer } from '../screen.js';
7
- import type { DashboardState } from '../state.js';
8
- export declare function renderCommandBar(screen: ScreenBuffer, row: number, state: DashboardState): void;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- /**
3
- * Command bar — bottom row of the dashboard
4
- *
5
- * Context-sensitive key hints that change based on current mode.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.renderCommandBar = renderCommandBar;
9
- const border_js_1 = require("../border.js");
10
- const CMD_BG = (0, border_js_1.bgRgb)(22, 22, 26);
11
- const HINTS = {
12
- overview: [
13
- { key: 'j/k', label: 'nav' },
14
- { key: 'Enter', label: 'detail' },
15
- { key: 'Tab', label: 'focus' },
16
- { key: 'l', label: 'liquidity' },
17
- { key: 'w', label: 'whatif' },
18
- { key: 'b', label: 'buy' },
19
- { key: 's', label: 'sell' },
20
- { key: 'e', label: 'evaluate' },
21
- { key: 'r', label: 'refresh' },
22
- { key: 'q', label: 'quit' },
23
- ],
24
- detail: [
25
- { key: 'b', label: 'buy' },
26
- { key: 's', label: 'sell' },
27
- { key: 'w', label: 'whatif' },
28
- { key: 'Esc', label: 'back' },
29
- { key: 'q', label: 'quit' },
30
- ],
31
- liquidity: [
32
- { key: 'j/k', label: 'nav' },
33
- { key: 'Tab', label: 'topic' },
34
- { key: 'b', label: 'buy' },
35
- { key: 'r', label: 'refresh' },
36
- { key: 'Esc', label: 'back' },
37
- { key: 'q', label: 'quit' },
38
- ],
39
- whatif: [
40
- { key: 'j/k', label: 'nav' },
41
- { key: 'Enter', label: 'apply' },
42
- { key: 'Esc', label: 'back' },
43
- { key: 'q', label: 'quit' },
44
- ],
45
- trade: [
46
- { key: '\u2191\u2193', label: 'adjust' },
47
- { key: 'Tab', label: 'field' },
48
- { key: 'Enter', label: 'confirm' },
49
- { key: 'Esc', label: 'cancel' },
50
- ],
51
- };
52
- function renderCommandBar(screen, row, state) {
53
- const w = screen.cols;
54
- // Fill background
55
- screen.fill(row, 0, w, 1, ' ', '', CMD_BG);
56
- const hints = HINTS[state.mode] || HINTS.overview;
57
- let col = 1;
58
- for (const hint of hints) {
59
- if (col + hint.key.length + hint.label.length + 4 > w)
60
- break;
61
- // Key in white/emerald, label in dim
62
- screen.write(row, col, hint.key, border_js_1.CLR.emerald, CMD_BG);
63
- col += hint.key.length;
64
- screen.write(row, col, ' ', border_js_1.CLR.dim, CMD_BG);
65
- col++;
66
- screen.write(row, col, hint.label, border_js_1.CLR.dim, CMD_BG);
67
- col += hint.label.length;
68
- // Separator
69
- col += 2;
70
- if (col < w - 2) {
71
- screen.write(row, col - 1, '│', border_js_1.CLR.veryDim, CMD_BG);
72
- }
73
- }
74
- // Error display on the right
75
- if (state.error) {
76
- const errStr = state.error.slice(0, 30);
77
- const errCol = w - errStr.length - 2;
78
- if (errCol > col) {
79
- screen.write(row, errCol, errStr, border_js_1.CLR.red, CMD_BG);
80
- }
81
- }
82
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Detail view — full-screen position deep-dive
3
- *
4
- * Shows position summary, P&L chart, causal tree nodes, and orderbook snapshot.
5
- */
6
- import type { ScreenBuffer } from '../screen.js';
7
- import type { Region } from '../layout.js';
8
- import type { DashboardState } from '../state.js';
9
- export declare function renderDetail(screen: ScreenBuffer, region: Region, state: DashboardState): void;
@@ -1,151 +0,0 @@
1
- "use strict";
2
- /**
3
- * Detail view — full-screen position deep-dive
4
- *
5
- * Shows position summary, P&L chart, causal tree nodes, and orderbook snapshot.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.renderDetail = renderDetail;
9
- const border_js_1 = require("../border.js");
10
- const chart_js_1 = require("../chart.js");
11
- function renderDetail(screen, region, state) {
12
- (0, border_js_1.drawBorder)(screen, region, 'POSITION DETAIL');
13
- const x = region.col + 2;
14
- const w = region.width - 4;
15
- // Find selected position
16
- const pos = state.positions.find(p => (p.ticker_symbol || p.ticker) === state.detailTicker) || state.positions[0];
17
- if (!pos) {
18
- screen.write(region.row + 2, x, 'No position selected', border_js_1.CLR.dim);
19
- return;
20
- }
21
- const ticker = pos.ticker_symbol || pos.ticker || '???';
22
- const qty = pos.quantity ?? 0;
23
- const entry = pos.average_price_paid ?? pos.cost_basis ?? 0;
24
- const current = pos.current_value ?? entry;
25
- const pnl = (current - entry) * qty;
26
- const pnlDollars = pnl / 100;
27
- const pnlColor = pnl >= 0 ? border_js_1.CLR.green : border_js_1.CLR.red;
28
- const side = pos.side || 'yes';
29
- // ── Top: Position Summary (3 rows) ──
30
- let line = 1;
31
- screen.writeStyled(region.row + line, x, [
32
- { text: (0, border_js_1.fit)(ticker, 30), fg: border_js_1.CLR.white },
33
- { text: ` ${side.toUpperCase()} `, fg: border_js_1.CLR.emerald },
34
- { text: ` qty: ${qty}`, fg: border_js_1.CLR.dim },
35
- ]);
36
- line++;
37
- screen.writeStyled(region.row + line, x, [
38
- { text: `Entry: ${entry.toFixed(0)}\u00A2`, fg: border_js_1.CLR.dim },
39
- { text: ` Current: ${current.toFixed(0)}\u00A2`, fg: border_js_1.CLR.text },
40
- { text: ` P&L: ${pnlDollars >= 0 ? '+' : ''}$${Math.abs(pnlDollars).toFixed(2)}`, fg: pnlColor },
41
- ]);
42
- line++;
43
- // Expiry
44
- const expiry = pos.expiration_time || pos.expiry || pos.close_time || '';
45
- if (expiry) {
46
- const expiryDate = new Date(expiry);
47
- const daysLeft = Math.ceil((expiryDate.getTime() - Date.now()) / 86400000);
48
- screen.write(region.row + line, x, `Expiry: ${expiryDate.toISOString().slice(0, 10)} (${daysLeft}d)`, border_js_1.CLR.dim);
49
- }
50
- line++;
51
- // ── Divider ──
52
- (0, border_js_1.drawHDivider)(screen, region, line);
53
- line++;
54
- // ── Middle: Chart area ──
55
- const chartHeight = Math.min(8, Math.floor((region.height - line - 8) / 2) + 4);
56
- const candles = state.candleCache.get(ticker) || [];
57
- if (candles.length > 1) {
58
- const values = candles.map((c) => {
59
- const close = c.close ?? 0; // already in cents from dashboard parsing
60
- return ((close - entry) * qty) / 100; // P&L in dollars
61
- });
62
- const dateLabels = candles.map((c) => {
63
- const d = c.date ? new Date(c.date) : new Date(c.end_period_ts ? c.end_period_ts * 1000 : 0);
64
- return `${d.getMonth() + 1}/${d.getDate()}`;
65
- });
66
- screen.write(region.row + line, x, 'Daily P&L ($)', border_js_1.CLR.title);
67
- line++;
68
- (0, chart_js_1.drawChart)(screen, region.row + line, x, w, chartHeight, values, dateLabels);
69
- line += chartHeight + 1;
70
- }
71
- else {
72
- screen.write(region.row + line, x, 'No chart data available', border_js_1.CLR.dim);
73
- line += 2;
74
- }
75
- // ── Divider ──
76
- if (line < region.height - 5) {
77
- (0, border_js_1.drawHDivider)(screen, region, line);
78
- line++;
79
- }
80
- // ── Bottom: Two columns — causal tree (left) and orderbook (right) ──
81
- const halfW = Math.floor(w / 2) - 1;
82
- const bottomRow = region.row + line;
83
- const remainingRows = region.height - line - 1;
84
- // Left: Causal tree nodes from context
85
- // Find context that contains an edge matching this ticker
86
- screen.write(bottomRow, x, 'Causal Tree', border_js_1.CLR.title);
87
- let ctx = null;
88
- for (const [, c] of state.contexts) {
89
- const edges = c?.edges || [];
90
- if (edges.some((e) => e.marketId === ticker || e.ticker === ticker)) {
91
- ctx = c;
92
- break;
93
- }
94
- }
95
- const treeNodes = ctx?.causalTree?.nodes || [];
96
- // Flatten nested nodes
97
- const flatNodes = [];
98
- function walk(nodes, depth = 0) {
99
- for (const n of nodes) {
100
- flatNodes.push({ ...n, depth });
101
- if (n.children)
102
- walk(n.children, depth + 1);
103
- }
104
- }
105
- walk(treeNodes);
106
- const nodes = flatNodes.filter(n => n.depth <= 1).slice(0, remainingRows - 1);
107
- for (let i = 0; i < nodes.length; i++) {
108
- const node = nodes[i];
109
- const indent = ' '.repeat(node.depth + 1);
110
- const name = node.label || node.claim || node.name || node.id || '?';
111
- const prob = node.probability != null ? `${Math.round(node.probability * 100)}%` : '';
112
- screen.writeStyled(bottomRow + 1 + i, x, [
113
- { text: indent + (0, border_js_1.fit)(name, halfW - indent.length - 5), fg: border_js_1.CLR.text },
114
- { text: (0, border_js_1.fit)(prob, 5, 'right'), fg: border_js_1.CLR.emerald },
115
- ]);
116
- }
117
- if (nodes.length === 0) {
118
- screen.write(bottomRow + 1, x, ' (no context data)', border_js_1.CLR.dim);
119
- }
120
- // Right: Orderbook snapshot
121
- const rightX = x + halfW + 2;
122
- screen.write(bottomRow, rightX, 'Orderbook', border_js_1.CLR.title);
123
- // Find orderbook from the edge matching this ticker
124
- const matchingEdge = ctx?.edges?.find((e) => e.marketId === ticker || e.ticker === ticker);
125
- const ob = matchingEdge?.orderbook;
126
- if (ob) {
127
- const bestBid = ob.bidPrice ?? ob.bestBid ?? 0;
128
- const bestAsk = ob.askPrice ?? ob.bestAsk ?? 0;
129
- const spread = ob.spread ?? (bestAsk - bestBid);
130
- screen.writeStyled(bottomRow + 1, rightX, [
131
- { text: 'Bid: ', fg: border_js_1.CLR.dim },
132
- { text: `${bestBid}\u00A2`, fg: border_js_1.CLR.green },
133
- { text: ' Ask: ', fg: border_js_1.CLR.dim },
134
- { text: `${bestAsk}\u00A2`, fg: border_js_1.CLR.red },
135
- ]);
136
- screen.writeStyled(bottomRow + 2, rightX, [
137
- { text: 'Spread: ', fg: border_js_1.CLR.dim },
138
- { text: `${spread}\u00A2`, fg: spread <= 2 ? border_js_1.CLR.green : spread <= 5 ? border_js_1.CLR.yellow : border_js_1.CLR.red },
139
- ]);
140
- if (ob.bidDepth != null) {
141
- screen.writeStyled(bottomRow + 3, rightX, [
142
- { text: 'Depth: ', fg: border_js_1.CLR.dim },
143
- { text: `bid ${ob.bidDepth}`, fg: border_js_1.CLR.dim },
144
- { text: ` / ask ${ob.askDepth}`, fg: border_js_1.CLR.dim },
145
- ]);
146
- }
147
- }
148
- else {
149
- screen.write(bottomRow + 1, rightX, ' (no orderbook data)', border_js_1.CLR.dim);
150
- }
151
- }
@@ -1,4 +0,0 @@
1
- import type { ScreenBuffer } from '../screen.js';
2
- import type { Region } from '../layout.js';
3
- import type { DashboardState } from '../state.js';
4
- export declare function renderEdges(screen: ScreenBuffer, region: Region, state: DashboardState): void;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderEdges = renderEdges;
4
- const border_js_1 = require("../border.js");
5
- function renderEdges(screen, region, state) {
6
- (0, border_js_1.drawBorder)(screen, region, 'TOP EDGES');
7
- const x = region.col + 2;
8
- const w = region.width - 4;
9
- const maxRows = region.height - 2;
10
- // Filter out edges already held as positions
11
- const heldTickers = new Set(state.positions.map((p) => p.ticker));
12
- const unpositioned = state.edges.filter((e) => !heldTickers.has(e.marketId || e.ticker || ''));
13
- const top = unpositioned.slice(0, Math.min(5, maxRows));
14
- if (top.length === 0) {
15
- screen.write(region.row + 1, x, 'No unpositioned edges', border_js_1.CLR.dim);
16
- return;
17
- }
18
- for (let i = 0; i < top.length; i++) {
19
- const e = top[i];
20
- const y = region.row + 1 + i;
21
- const selected = state.focusArea === 'edges' && state.selectedIndex === i;
22
- const marker = selected ? '▸' : ' ';
23
- const name = e.market || e.marketTitle || e.marketId || '???';
24
- const edgeVal = e.edge ?? e.edgeSize ?? 0;
25
- const edgeStr = `+${edgeVal.toFixed(1)}¢`;
26
- const liq = e.orderbook?.liquidityScore || '?';
27
- const liqColor = liq === 'high' ? border_js_1.CLR.green : liq === 'low' ? border_js_1.CLR.yellow : border_js_1.CLR.dim;
28
- const venueTag = e.venue === 'polymarket' ? 'P ' : 'K ';
29
- const nameWidth = Math.max(w - 20, 10);
30
- screen.write(y, x, `${marker}${venueTag}${(0, border_js_1.fit)(name, nameWidth)}`, selected ? border_js_1.CLR.white : border_js_1.CLR.text);
31
- screen.write(y, x + nameWidth + 3, (0, border_js_1.fit)(edgeStr, 8, 'right'), border_js_1.CLR.emerald);
32
- screen.write(y, x + nameWidth + 12, (0, border_js_1.fit)(liq, 5, 'right'), liqColor);
33
- }
34
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Liquidity view — full-screen market liquidity scanner
3
- *
4
- * Shows markets grouped by topic and horizon with bid/ask/spread/depth info.
5
- */
6
- import type { ScreenBuffer } from '../screen.js';
7
- import type { Region } from '../layout.js';
8
- import type { DashboardState } from '../state.js';
9
- export declare function renderLiquidity(screen: ScreenBuffer, region: Region, state: DashboardState): void;