@hoox-sh/hoox-tui 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +247 -0
- package/bin/hoox-tui.js +35 -0
- package/dist/main.js +17594 -0
- package/package.json +72 -0
- package/src/app.tsx +696 -0
- package/src/cli-bridge-test-double.ts +212 -0
- package/src/components/layout/layout.test.tsx +205 -0
- package/src/components/layout/sidebar.tsx +69 -0
- package/src/components/layout/statusbar.test.tsx +423 -0
- package/src/components/layout/statusbar.tsx +348 -0
- package/src/components/shared/animated-border.tsx +58 -0
- package/src/components/shared/chrome.test.tsx +29 -0
- package/src/components/shared/command-palette.tsx +361 -0
- package/src/components/shared/cool-brackets.tsx +75 -0
- package/src/components/shared/crash-screen.tsx +167 -0
- package/src/components/shared/error-boundary.tsx +99 -0
- package/src/components/shared/keybinding-hint.tsx +37 -0
- package/src/components/shared/panel.tsx +61 -0
- package/src/components/shared/quit-modal.tsx +65 -0
- package/src/components/shared/shared.test.tsx +538 -0
- package/src/components/shared/spinner.tsx +85 -0
- package/src/components/shared/status-dot.tsx +54 -0
- package/src/components/shared/view-header.tsx +53 -0
- package/src/components/ui/connection-toasts.test.ts +50 -0
- package/src/components/ui/connection-toasts.ts +215 -0
- package/src/components/ui/dialog.tsx +281 -0
- package/src/components/ui/select.tsx +197 -0
- package/src/components/ui/toast.tsx +185 -0
- package/src/components/views/ai-chat.test.tsx +81 -0
- package/src/components/views/ai-chat.tsx +576 -0
- package/src/components/views/config-editor/action-bar.tsx +102 -0
- package/src/components/views/config-editor/code-editor.tsx +597 -0
- package/src/components/views/config-editor/file-tree.tsx +113 -0
- package/src/components/views/config-editor/types.ts +37 -0
- package/src/components/views/config-editor.test.tsx +465 -0
- package/src/components/views/config-editor.tsx +709 -0
- package/src/components/views/dashboard/alerts-panel.tsx +154 -0
- package/src/components/views/dashboard/auto-repair-panel.tsx +229 -0
- package/src/components/views/dashboard/model-health-section.tsx +276 -0
- package/src/components/views/dashboard/pyne-health-section.tsx +112 -0
- package/src/components/views/dashboard.test.tsx +347 -0
- package/src/components/views/dashboard.tsx +647 -0
- package/src/components/views/db-query.test.tsx +115 -0
- package/src/components/views/db-query.tsx +849 -0
- package/src/components/views/edge-topology.test.tsx +198 -0
- package/src/components/views/edge-topology.tsx +572 -0
- package/src/components/views/kv-viewer.test.tsx +241 -0
- package/src/components/views/kv-viewer.tsx +717 -0
- package/src/components/views/logs-viewer.test.tsx +273 -0
- package/src/components/views/logs-viewer.tsx +616 -0
- package/src/components/views/queue-depth.test.tsx +221 -0
- package/src/components/views/queue-depth.tsx +376 -0
- package/src/components/views/secrets-viewer.test.tsx +65 -0
- package/src/components/views/secrets-viewer.tsx +548 -0
- package/src/components/views/service-manager.test.tsx +358 -0
- package/src/components/views/service-manager.tsx +946 -0
- package/src/components/views/settings.test.tsx +648 -0
- package/src/components/views/settings.tsx +1497 -0
- package/src/components/views/setup-wizard.test.tsx +297 -0
- package/src/components/views/setup-wizard.tsx +1321 -0
- package/src/components/views/trade-monitor.test.tsx +592 -0
- package/src/components/views/trade-monitor.tsx +745 -0
- package/src/components/views/worker-detail.test.tsx +289 -0
- package/src/components/views/worker-detail.tsx +676 -0
- package/src/components/views/worker-settings.test.tsx +43 -0
- package/src/components/views/worker-settings.tsx +563 -0
- package/src/components/views/workers-overview.test.tsx +260 -0
- package/src/components/views/workers-overview.tsx +631 -0
- package/src/hooks/hooks.test.ts +72 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/renderer-ref.ts +22 -0
- package/src/hooks/use-keyboard.ts +130 -0
- package/src/hooks/use-polling.ts +73 -0
- package/src/hooks/use-service-data.ts +18 -0
- package/src/main.tsx +117 -0
- package/src/network-test-double.ts +133 -0
- package/src/opentui-augment.d.ts +45 -0
- package/src/opentui-jsx.d.ts +70 -0
- package/src/services/cli-bridge/index.ts +1662 -0
- package/src/services/cli-bridge/standalone.ts +315 -0
- package/src/services/cli-bridge/types.ts +307 -0
- package/src/services/cli-bridge.test.ts +406 -0
- package/src/services/clipboard.test.ts +57 -0
- package/src/services/clipboard.ts +180 -0
- package/src/services/dashboard-settings-loader.ts +31 -0
- package/src/services/dev-log.test.ts +168 -0
- package/src/services/dev-log.ts +194 -0
- package/src/services/hoox-path-service.test.ts +183 -0
- package/src/services/hoox-path-service.ts +185 -0
- package/src/services/tui-connection.test.ts +212 -0
- package/src/services/tui-connection.ts +236 -0
- package/src/services/tui-storage.test.ts +92 -0
- package/src/services/tui-storage.ts +86 -0
- package/src/stores/config-store.test.ts +360 -0
- package/src/stores/service-store.test.ts +1026 -0
- package/src/stores/session-restore.test.ts +134 -0
- package/src/stores/ui-store.test.ts +276 -0
- package/src/test-setup.ts +265 -0
- package/src/test-utils.ts +179 -0
- package/src/types.ts +153 -0
- package/src/utils/colors.test.ts +326 -0
- package/src/utils/formatters.test.ts +236 -0
- package/src/view-registry.test.ts +132 -0
- package/src/view-registry.tsx +368 -0
package/README.md
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Hoox TUI
|
|
2
|
+
|
|
3
|
+
**Terminal Operations Center** for the Hoox algorithmic trading framework.
|
|
4
|
+
A full-screen terminal dashboard built with [OpenTUI](https://github.com/anomalyco/opentui), [Bun](https://bun.sh), and [Zustand](https://zustand.docs.pmnd.rs/).
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Quick Start
|
|
9
|
+
|
|
10
|
+
### Outside a monorepo (recommended for operators)
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# CLI + TUI as global packages
|
|
14
|
+
bun add -g @hoox-sh/hoox-cli @hoox-sh/hoox-tui
|
|
15
|
+
# or after CLI is already installed:
|
|
16
|
+
bun add -g @hoox-sh/hoox-tui
|
|
17
|
+
|
|
18
|
+
hx tui
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
If the TUI package is missing, `hx tui` prints install instructions.
|
|
22
|
+
Full monorepo under `~/.hoox/repo` is optional (`hx doctor --fix-runtime`).
|
|
23
|
+
|
|
24
|
+
### From this monorepo
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Install dependencies (from repo root)
|
|
28
|
+
bun install
|
|
29
|
+
|
|
30
|
+
# Launch via CLI (recommended) — LOCAL → http://localhost:8787
|
|
31
|
+
hoox tui
|
|
32
|
+
|
|
33
|
+
# Connect to remote management plane (REMOTE) — fail-closed auth
|
|
34
|
+
# Server secret: wrangler secret put OPERATOR_API_KEY (must match token)
|
|
35
|
+
export HOOX_API_TOKEN=… # required (or Access service-token env)
|
|
36
|
+
# Optional Access: CF_ACCESS_CLIENT_ID + CF_ACCESS_CLIENT_SECRET
|
|
37
|
+
# Optional: HOOX_TRANSPORT=access
|
|
38
|
+
hoox tui --remote
|
|
39
|
+
# or: hoox tui --api-url https://mgmt.example.com --token "$HOOX_API_TOKEN"
|
|
40
|
+
# Escape hatch only: hoox tui --remote --allow-insecure
|
|
41
|
+
# Management API: GET /v1/health, /v1/workers, SSE /v1/trades|logs/stream
|
|
42
|
+
|
|
43
|
+
# Dev logging → $HOME/.hoox/.tui-state/debug.log (secrets redacted)
|
|
44
|
+
hoox tui --debug
|
|
45
|
+
# or: HOOX_DEBUG=1 / TUI_DEBUG=1
|
|
46
|
+
|
|
47
|
+
# Or launch from package
|
|
48
|
+
cd packages/tui
|
|
49
|
+
bun run dev
|
|
50
|
+
|
|
51
|
+
# Build bundle
|
|
52
|
+
bun run build
|
|
53
|
+
|
|
54
|
+
# Run the built bundle
|
|
55
|
+
bun run start
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Prerequisites:**
|
|
59
|
+
|
|
60
|
+
- [Bun](https://bun.sh) >= 1.2
|
|
61
|
+
- Terminal with 256-color support (xterm-256color, kitty, iTerm2, Windows Terminal)
|
|
62
|
+
- Minimum terminal size: 80 columns × 24 rows
|
|
63
|
+
- OpenTUI packages (`@opentui/core`, `@opentui/react`) — installed via `bun install`
|
|
64
|
+
|
|
65
|
+
Persistent UI state lives under `$HOME/.hoox/.tui-state/` (session, crash log, chat history, DB query history).
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Keyboard Shortcuts
|
|
70
|
+
|
|
71
|
+
| Key | Action |
|
|
72
|
+
| ------------------- | ---------------------------------------- |
|
|
73
|
+
| `Ctrl+1` | Dashboard view |
|
|
74
|
+
| `Ctrl+2` | Workers Overview |
|
|
75
|
+
| `Ctrl+3` | Worker Detail |
|
|
76
|
+
| `Ctrl+4` | Trade Monitor |
|
|
77
|
+
| `Ctrl+5` | Logs Viewer |
|
|
78
|
+
| `Ctrl+6` | Service Manager |
|
|
79
|
+
| `Ctrl+7` | Config Editor |
|
|
80
|
+
| `Ctrl+8` | Setup Wizard |
|
|
81
|
+
| `Ctrl+9` | Settings |
|
|
82
|
+
| `Ctrl+0` | Queue Depth |
|
|
83
|
+
| `Ctrl+Alt+K` | KV Viewer |
|
|
84
|
+
| `Ctrl+Alt+S` | Secrets Viewer |
|
|
85
|
+
| `Ctrl+Alt+C` | AI Chat |
|
|
86
|
+
| `Ctrl+Alt+Q` | DB Query |
|
|
87
|
+
| `Ctrl+Alt+E` | Edge Topology |
|
|
88
|
+
| `Ctrl+Alt+W` | Worker Settings (dashboard.jsonc) |
|
|
89
|
+
| `Ctrl+P` | Open Command Palette |
|
|
90
|
+
| `Ctrl+B` | Toggle Sidebar |
|
|
91
|
+
| `Ctrl+R` | Refresh all data |
|
|
92
|
+
| `Ctrl+Q` | Quit (with confirmation) |
|
|
93
|
+
| `Esc` | Close palette / dismiss modal / go back |
|
|
94
|
+
| `↑` `↓` | Navigate within active view |
|
|
95
|
+
| `Tab` / `Shift+Tab` | Cycle focus between interactive elements |
|
|
96
|
+
| `Enter` | Select / confirm |
|
|
97
|
+
| `Space` | Toggle |
|
|
98
|
+
| `/` | Focus search (in searchable views) |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Views
|
|
103
|
+
|
|
104
|
+
| View | Description |
|
|
105
|
+
| -------------------- | -------------------------------------------------------------------------------------------------- |
|
|
106
|
+
| **Dashboard** | System health overview: service grid, alerts, quick stats, agent health, and **PYNE** edge health. |
|
|
107
|
+
| **Workers Overview** | List of all Cloudflare Workers with status, uptime, CPU, memory, and request metrics. |
|
|
108
|
+
| **Worker Detail** | Detailed view of a single worker — logs, metrics, Durable Objects, and deployment info. |
|
|
109
|
+
| **Trade Monitor** | Live trade stream with symbol, side, price, quantity, and P&L per trade. |
|
|
110
|
+
| **Logs Viewer** | Scrollable log stream with level filtering, worker selection, and full-text search. |
|
|
111
|
+
| **Service Manager** | Start, stop, restart, and deploy workers. View deployment history and rollback. |
|
|
112
|
+
| **Config Editor** | Edit Hoox configuration — exchange credentials, strategy parameters, risk limits. |
|
|
113
|
+
| **Setup Wizard** | Step-by-step guided setup for new Hoox installations (API keys, exchanges, wallet). |
|
|
114
|
+
| **Settings** | Display preferences, theme, notification toggles, and keyboard shortcut customization. |
|
|
115
|
+
| **Queue Depth** | Queue backlog visualization across workers. |
|
|
116
|
+
| **KV Viewer** | Read-only Cloudflare KV key browser. |
|
|
117
|
+
| **Secrets Viewer** | Read-only secret names/metadata (values never shown). |
|
|
118
|
+
| **AI Chat** | Streaming chat with the agent worker. |
|
|
119
|
+
| **DB Query** | Read-only D1 SQL panel (`SELECT` / `WITH` / `EXPLAIN` only). |
|
|
120
|
+
| **Edge Topology** | Worker mesh / service-binding graph. |
|
|
121
|
+
| **Worker Settings** | Same settings as the web dashboard — fields from `workers/*/dashboard.jsonc` backed by CONFIG_KV. |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Tech Stack
|
|
126
|
+
|
|
127
|
+
| Component | Technology |
|
|
128
|
+
| -------------------- | ---------------------------------------------------------------------------- |
|
|
129
|
+
| **TUI Framework** | OpenTUI — `@opentui/core` + `@opentui/react` (JSX-based terminal rendering) |
|
|
130
|
+
| **Runtime** | [Bun](https://bun.sh) — fast all-in-one JS runtime |
|
|
131
|
+
| **State Management** | [Zustand](https://zustand.docs.pmnd.rs/) with Immer middleware |
|
|
132
|
+
| **Language** | TypeScript (strict mode) |
|
|
133
|
+
| **Testing** | Bun test runner (`bun test`) |
|
|
134
|
+
| **Build** | `bun build` — bundles entry to `dist/main.js` (OpenTUI packages external) |
|
|
135
|
+
| **Shared Module** | `@hoox-sh/hoox-shared` — API client, SSE streaming, color tokens, formatters |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Running Tests
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# From package
|
|
143
|
+
cd packages/tui
|
|
144
|
+
bun test
|
|
145
|
+
|
|
146
|
+
# From monorepo root (recommended — includes preload)
|
|
147
|
+
bun run test:tui
|
|
148
|
+
|
|
149
|
+
# Scoped foundation suite (stores / utils / integration / registry)
|
|
150
|
+
bun test --preload ./packages/tui/src/test-setup.ts \
|
|
151
|
+
packages/tui/src/stores packages/tui/src/utils \
|
|
152
|
+
packages/tui/test packages/tui/src/view-registry.test.ts
|
|
153
|
+
|
|
154
|
+
# Typecheck
|
|
155
|
+
bun run typecheck
|
|
156
|
+
|
|
157
|
+
# E2E smoke (requires interactive TTY + OpenTUI)
|
|
158
|
+
bun test test/e2e/
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Troubleshooting
|
|
164
|
+
|
|
165
|
+
### "Cannot find module @opentui/core"
|
|
166
|
+
|
|
167
|
+
OpenTUI packages must be installed. Ensure `bun install` completed successfully.
|
|
168
|
+
If the packages are in a local path, verify the workspace configuration in the root `package.json`.
|
|
169
|
+
|
|
170
|
+
### API unreachable (OFFLINE in status bar)
|
|
171
|
+
|
|
172
|
+
**Local:** HTTP first, then CLI `monitorStatus` fallback.
|
|
173
|
+
**Remote:** fail-closed HTTP only (no CLI fallback). Auth requires `HOOX_API_TOKEN`, Access env, or `--allow-insecure`.
|
|
174
|
+
|
|
175
|
+
1. Is a local dev mesh / API reachable? (`HOOX_API_URL`, default `http://localhost:8787`)
|
|
176
|
+
2. Remote: is `HOOX_API_TOKEN` set and matching server `OPERATOR_API_KEY`?
|
|
177
|
+
3. Is the `hoox` CLI on `PATH` for local fallback? (`bun add -g @hoox-sh/hoox-cli`)
|
|
178
|
+
4. Are you on the correct network / VPN?
|
|
179
|
+
|
|
180
|
+
### Terminal too small
|
|
181
|
+
|
|
182
|
+
The TUI requires at least **80 columns × 24 rows**. Resize your terminal window.
|
|
183
|
+
If you see garbled output, try: `export TERM=xterm-256color`
|
|
184
|
+
|
|
185
|
+
### Garbled screen after exit
|
|
186
|
+
|
|
187
|
+
If the alternate screen buffer isn't cleaned up, run: `reset` or `tput reset`
|
|
188
|
+
|
|
189
|
+
### Ctrl+Q not working
|
|
190
|
+
|
|
191
|
+
Some terminal emulators intercept Ctrl+Q for flow control (XON/XOFF).
|
|
192
|
+
Disable flow control in your terminal settings, or use `stty -ixon` before launching.
|
|
193
|
+
You can also open the command palette (`Ctrl+P`) and run **QUIT HOOX**.
|
|
194
|
+
|
|
195
|
+
### Build fails with missing dependencies
|
|
196
|
+
|
|
197
|
+
The `bun build` command bundles TypeScript sources with OpenTUI marked external. If dependencies aren't resolved:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
bun install
|
|
201
|
+
bun run build
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Ensure `@hoox-sh/hoox-shared` is linked as a workspace dependency.
|
|
205
|
+
|
|
206
|
+
### Colors look wrong
|
|
207
|
+
|
|
208
|
+
The TUI uses 256-color ANSI escape sequences. Ensure:
|
|
209
|
+
|
|
210
|
+
- `TERM=xterm-256color` (or `kitty`, `screen-256color`)
|
|
211
|
+
- Your terminal supports 256 colors
|
|
212
|
+
- No conflicting terminal color schemes
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Project Structure
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
packages/tui/
|
|
220
|
+
├── src/
|
|
221
|
+
│ ├── main.tsx # Entry point — OpenTUI renderer setup
|
|
222
|
+
│ ├── app.tsx # Root component — layout, keyboard, crash recovery
|
|
223
|
+
│ ├── components/
|
|
224
|
+
│ │ ├── views/ # Dashboard, workers, trades, logs, queues, …
|
|
225
|
+
│ │ ├── layout/ # Sidebar + status bar
|
|
226
|
+
│ │ ├── shared/ # Palette, crash screen, error boundary, …
|
|
227
|
+
│ │ └── ui/ # Dialog / toast wrappers
|
|
228
|
+
│ ├── services/
|
|
229
|
+
│ │ ├── cli-bridge/ # Spawns `hoox` CLI with typed results
|
|
230
|
+
│ │ ├── hoox-path-service.ts # $HOME/.hoox path helpers
|
|
231
|
+
│ │ └── tui-storage.ts # File-backed JSON state (no localStorage)
|
|
232
|
+
│ ├── hooks/ # Keyboard, polling, renderer ref
|
|
233
|
+
│ └── stores/ # Store unit tests (stores live in hoox-shared)
|
|
234
|
+
├── test/
|
|
235
|
+
│ ├── e2e/smoke.test.ts
|
|
236
|
+
│ └── integration/navigation.test.tsx
|
|
237
|
+
├── package.json
|
|
238
|
+
└── README.md
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Design
|
|
244
|
+
|
|
245
|
+
Near-black canvas (`#050508`), cool indigo accent (`#818CF8`) + cyan highlight,
|
|
246
|
+
static accent brackets on chrome (no rainbow animation), squared edges.
|
|
247
|
+
Follows the Hoox landing page design DNA. No CSS, no DOM — pure terminal rendering via OpenTUI's JSX intrinsics (`<box>`, `<text>`, `<input>`, `<scrollbox>`). UI persistence uses the filesystem under `$HOME/.hoox/.tui-state/` (Bun has no `localStorage`).
|
package/bin/hoox-tui.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 HOOX · HOOX · jango-blockchained (hoox-sh)
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Hoox TUI binary entry point.
|
|
8
|
+
*
|
|
9
|
+
* Resolution order (first match wins):
|
|
10
|
+
* 1. `../dist/main.js` — bundled output from `bun run build`
|
|
11
|
+
* 2. `../src/main.tsx` — monorepo / bun link dev path
|
|
12
|
+
* 3. Clear error with install/build instructions
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync } from "node:fs";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import { dirname, resolve } from "node:path";
|
|
17
|
+
|
|
18
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const distEntry = resolve(here, "..", "dist", "main.js");
|
|
20
|
+
const srcEntry = resolve(here, "..", "src", "main.tsx");
|
|
21
|
+
|
|
22
|
+
if (existsSync(distEntry)) {
|
|
23
|
+
await import(distEntry);
|
|
24
|
+
} else if (existsSync(srcEntry)) {
|
|
25
|
+
await import(srcEntry);
|
|
26
|
+
} else {
|
|
27
|
+
console.error(
|
|
28
|
+
`hoox-tui: could not find an entry point. Looked for:\n` +
|
|
29
|
+
` - ${distEntry}\n` +
|
|
30
|
+
` - ${srcEntry}\n\n` +
|
|
31
|
+
`Install the package: bun add -g @hoox-sh/hoox-tui\n` +
|
|
32
|
+
`Or from the monorepo: cd packages/tui && bun run build`
|
|
33
|
+
);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|