@jango-blockchained/hoox-cli 0.3.4

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 (94) hide show
  1. package/README.md +403 -0
  2. package/bin/hoox.js +12 -0
  3. package/package.json +60 -0
  4. package/src/commands/check/check-command.test.ts +468 -0
  5. package/src/commands/check/check-command.ts +1144 -0
  6. package/src/commands/check/index.ts +10 -0
  7. package/src/commands/check/prerequisites-command.test.ts +19 -0
  8. package/src/commands/check/prerequisites-command.ts +92 -0
  9. package/src/commands/check/types.ts +103 -0
  10. package/src/commands/clone/clone-command.test.ts +442 -0
  11. package/src/commands/clone/clone-command.ts +440 -0
  12. package/src/commands/clone/index.ts +1 -0
  13. package/src/commands/config/config-command.test.ts +583 -0
  14. package/src/commands/config/config-command.ts +901 -0
  15. package/src/commands/config/env-command.test.ts +43 -0
  16. package/src/commands/config/env-command.ts +314 -0
  17. package/src/commands/config/index.ts +3 -0
  18. package/src/commands/config/kv-command.test.ts +14 -0
  19. package/src/commands/config/kv-command.ts +329 -0
  20. package/src/commands/dashboard/dashboard-command.test.ts +47 -0
  21. package/src/commands/dashboard/dashboard-command.ts +127 -0
  22. package/src/commands/dashboard/index.ts +1 -0
  23. package/src/commands/db/db-command.test.ts +21 -0
  24. package/src/commands/db/db-command.ts +314 -0
  25. package/src/commands/db/index.ts +1 -0
  26. package/src/commands/deploy/deploy-command.test.ts +304 -0
  27. package/src/commands/deploy/deploy-command.ts +1053 -0
  28. package/src/commands/deploy/index.ts +2 -0
  29. package/src/commands/deploy/telegram-service.ts +61 -0
  30. package/src/commands/deploy/types.ts +34 -0
  31. package/src/commands/dev/dev-command.test.ts +383 -0
  32. package/src/commands/dev/dev-command.ts +407 -0
  33. package/src/commands/dev/index.ts +1 -0
  34. package/src/commands/infra/index.ts +5 -0
  35. package/src/commands/infra/infra-command.test.ts +719 -0
  36. package/src/commands/infra/infra-command.ts +940 -0
  37. package/src/commands/infra/types.ts +23 -0
  38. package/src/commands/init/index.ts +1 -0
  39. package/src/commands/init/init-command.test.ts +827 -0
  40. package/src/commands/init/init-command.ts +627 -0
  41. package/src/commands/init/types.ts +185 -0
  42. package/src/commands/monitor/index.ts +2 -0
  43. package/src/commands/monitor/monitor-command.test.ts +235 -0
  44. package/src/commands/monitor/monitor-command.ts +245 -0
  45. package/src/commands/monitor/monitor-service.ts +50 -0
  46. package/src/commands/monitor/types.ts +13 -0
  47. package/src/commands/repair/index.ts +2 -0
  48. package/src/commands/repair/repair-command.test.ts +204 -0
  49. package/src/commands/repair/repair-command.ts +199 -0
  50. package/src/commands/repair/repair-service.ts +102 -0
  51. package/src/commands/repair/types.ts +13 -0
  52. package/src/commands/test/index.ts +2 -0
  53. package/src/commands/test/test-command.test.ts +319 -0
  54. package/src/commands/test/test-command.ts +412 -0
  55. package/src/commands/waf/index.ts +2 -0
  56. package/src/commands/waf/types.ts +48 -0
  57. package/src/commands/waf/waf-command.test.ts +506 -0
  58. package/src/commands/waf/waf-command.ts +548 -0
  59. package/src/index.ts +198 -0
  60. package/src/services/cloudflare/cloudflare-service.test.ts +654 -0
  61. package/src/services/cloudflare/cloudflare-service.ts +435 -0
  62. package/src/services/cloudflare/index.ts +2 -0
  63. package/src/services/cloudflare/types.ts +29 -0
  64. package/src/services/config/config-service.test.ts +395 -0
  65. package/src/services/config/config-service.ts +207 -0
  66. package/src/services/config/index.ts +9 -0
  67. package/src/services/config/types.ts +66 -0
  68. package/src/services/db/db-service.test.ts +51 -0
  69. package/src/services/db/db-service.ts +140 -0
  70. package/src/services/db/index.ts +1 -0
  71. package/src/services/docker/docker-service.ts +155 -0
  72. package/src/services/docker/index.ts +1 -0
  73. package/src/services/env/env-service.test.ts +210 -0
  74. package/src/services/env/env-service.ts +156 -0
  75. package/src/services/env/index.ts +1 -0
  76. package/src/services/kv/index.ts +1 -0
  77. package/src/services/kv/kv-sync-service.test.ts +38 -0
  78. package/src/services/kv/kv-sync-service.ts +151 -0
  79. package/src/services/prerequisites/index.ts +1 -0
  80. package/src/services/prerequisites/prerequisites-service.test.ts +89 -0
  81. package/src/services/prerequisites/prerequisites-service.ts +269 -0
  82. package/src/services/prerequisites/types.ts +48 -0
  83. package/src/services/secrets/index.ts +12 -0
  84. package/src/services/secrets/secrets-service.test.ts +486 -0
  85. package/src/services/secrets/secrets-service.ts +293 -0
  86. package/src/services/secrets/types.ts +57 -0
  87. package/src/ui/banner.ts +52 -0
  88. package/src/ui/index.ts +8 -0
  89. package/src/ui/menu.ts +473 -0
  90. package/src/utils/errors.test.ts +69 -0
  91. package/src/utils/errors.ts +23 -0
  92. package/src/utils/formatters.test.ts +180 -0
  93. package/src/utils/formatters.ts +252 -0
  94. package/src/utils/theme.ts +94 -0
package/README.md ADDED
@@ -0,0 +1,403 @@
1
+ # @jango-blockchained/hoox-cli
2
+
3
+ Hoox CLI — manage Cloudflare Workers, infrastructure, secrets, and deployments.
4
+
5
+ 381 unit tests, 15 command groups, 50+ subcommands.
6
+
7
+ ## Features
8
+
9
+ - **Interactive Setup**: `hoox init` guides you through project initialization with AI provider support
10
+ - **Infrastructure as Code**: Manage D1, KV, R2, Queues, Vectorize, and Analytics via `hoox infra`
11
+ - **Environment Management**: Declarative 31-key env matrix via `hoox config env`
12
+ - **KV Config Sync**: 16-key manifest with `apply-manifest` for CONFIG_KV
13
+ - **Database Operations**: Schema apply, migrations, query, export, reset via `hoox db`
14
+ - **Deploy Automation**: Workers + dashboard + telegram webhook + KV config in one flow
15
+ - **Operational Monitoring**: Health checks, recent trades, kill switch, queue depth, backup
16
+ - **Repair & Recovery**: Comprehensive system check, guided rebuild, per-component repair
17
+ - **Prerequisites Checks**: 7 tool/account/repository validations
18
+ - **Secret Management**: Sync, check, and rotate Cloudflare secrets
19
+ - **Interactive TUI**: Launch an interactive terminal UI when running `hoox` with no arguments
20
+ - **Worker Management**: Initialize, develop, and deploy Cloudflare Workers
21
+
22
+ ## Installation
23
+
24
+ ### Global Install (Recommended)
25
+
26
+ ```bash
27
+ # Using bun (recommended)
28
+ bun add -g @jango-blockchained/hoox-cli
29
+
30
+ # Using npm
31
+ npm install -g @jango-blockchained/hoox-cli
32
+ ```
33
+
34
+ ### Local Development
35
+
36
+ ```bash
37
+ cd packages/cli
38
+ bun install
39
+ bun run build
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ ```bash
45
+ # Launch interactive TUI (no arguments)
46
+ hoox
47
+
48
+ # Or use specific commands
49
+ hoox --help
50
+ hoox init
51
+ hoox dev
52
+ hoox deploy
53
+ hoox monitor status
54
+ ```
55
+
56
+ ## Available Commands
57
+
58
+ | Command | Description |
59
+ | ---------------- | ---------------------------------------------------------- |
60
+ | `hoox init` | Initialize a new Hoox project with worker configuration |
61
+ | `hoox clone` | Clone worker repositories as git submodules |
62
+ | `hoox dev` | Start local development environment for all workers |
63
+ | `hoox deploy` | Deploy workers, dashboard, telegram webhook, and KV config |
64
+ | `hoox infra` | Manage infrastructure (D1, KV, R2, Queues, Vectorize, Analytics) |
65
+ | `hoox config` | Manage wrangler.jsonc, env vars, KV keys, and secrets |
66
+ | `hoox check` | Validate setup, prerequisites, and worker health |
67
+ | `hoox db` | Manage D1 databases (apply, migrate, query, export, reset) |
68
+ | `hoox monitor` | Monitor health, trades, logs, kill switch, queue, backup |
69
+ | `hoox repair` | Diagnose and repair the system (check, rebuild, per-component) |
70
+ | `hoox logs` | Stream and filter Cloudflare Worker logs |
71
+ | `hoox test` | Run tests and CI pipeline |
72
+ | `hoox waf` | Manage Cloudflare WAF rules and policies |
73
+ | `hoox dashboard` | Launch or deploy the Next.js dashboard |
74
+
75
+ ### Global Options
76
+
77
+ All commands support these global options:
78
+
79
+ | Option | Description |
80
+ | --------- | -------------------------------------------- |
81
+ | `--json` | Output in JSON format (useful for scripting) |
82
+ | `--quiet` | Minimal output mode |
83
+
84
+ ## Usage Examples
85
+
86
+ ### Initialize a New Project
87
+
88
+ ```bash
89
+ hoox init
90
+ ```
91
+
92
+ Interactive prompts guide you through AI provider setup, Cloudflare credentials, and exchange API keys.
93
+
94
+ ### Check Prerequisites
95
+
96
+ ```bash
97
+ # Check all tools
98
+ hoox check prerequisites
99
+
100
+ # Check specific tool
101
+ hoox check prerequisites --tool bun
102
+ ```
103
+
104
+ Validates bun ≥1.2, git ≥2.40, wrangler, Docker, Cloudflare auth, and repository integrity.
105
+
106
+ ### Configure Environment
107
+
108
+ ```bash
109
+ # Interactive env setup (all 31 vars across 8 sections)
110
+ hoox config env init
111
+
112
+ # Show current env (secrets redacted)
113
+ hoox config env show
114
+
115
+ # Validate required vars
116
+ hoox config env validate
117
+
118
+ # Generate per-worker .dev.vars
119
+ hoox config env generate-dev-vars
120
+ ```
121
+
122
+ ### Manage KV Keys
123
+
124
+ ```bash
125
+ # Apply manifest defaults (16 keys)
126
+ hoox config kv apply-manifest
127
+
128
+ # Show expected manifest
129
+ hoox config kv manifest
130
+
131
+ # Individual key operations
132
+ hoox config kv list
133
+ hoox config kv get trade:kill_switch
134
+ hoox config kv set trade:kill_switch "false"
135
+ hoox config kv delete trade:kill_switch
136
+ ```
137
+
138
+ ### Deploy to Cloudflare
139
+
140
+ ```bash
141
+ # Deploy all workers then dashboard
142
+ hoox deploy all
143
+
144
+ # Deploy all — skip rebuild prompt, use existing build
145
+ hoox deploy all --auto
146
+
147
+ # Deploy with force rebuild
148
+ hoox deploy all --rebuild
149
+
150
+ # Post-deploy: set Telegram webhook
151
+ hoox deploy telegram-webhook
152
+
153
+ # Post-deploy: update dashboard service URLs
154
+ hoox deploy update-internal-urls
155
+
156
+ # Post-deploy: apply KV manifest
157
+ hoox deploy kv-config
158
+
159
+ # Deploy specific worker
160
+ hoox deploy worker trade-worker
161
+ ```
162
+
163
+ ### Manage Database
164
+
165
+ ```bash
166
+ # Apply schema to local or remote
167
+ hoox db apply
168
+ hoox db apply --remote
169
+
170
+ # Run tracking migrations
171
+ hoox db migrate --remote
172
+
173
+ # List tables
174
+ hoox db list --remote
175
+
176
+ # Execute read-only queries
177
+ hoox db query "SELECT COUNT(*) FROM trades" --remote
178
+
179
+ # Export to timestamped .sql
180
+ hoox db export
181
+
182
+ # Reset D1 (DESTRUCTIVE)
183
+ hoox db reset --confirm
184
+ ```
185
+
186
+ ### Manage Infrastructure
187
+
188
+ ```bash
189
+ # Auto-provision from wrangler.jsonc
190
+ hoox infra provision
191
+
192
+ # Individual resource management
193
+ hoox infra d1 list
194
+ hoox infra kv create my-namespace
195
+ hoox infra r2 list
196
+ hoox infra queues create my-queue
197
+ hoox infra vectorize list
198
+ hoox infra vectorize create my-index
199
+ hoox infra analytics list
200
+ ```
201
+
202
+ ### Monitor Operations
203
+
204
+ ```bash
205
+ # Check all worker health endpoints
206
+ hoox monitor status
207
+
208
+ # Show recent trades
209
+ hoox monitor trades 20
210
+
211
+ # Show system logs
212
+ hoox monitor logs
213
+ hoox monitor logs hoox
214
+
215
+ # Kill switch operations
216
+ hoox monitor kill-switch show
217
+ hoox monitor kill-switch on # Halt all trading
218
+ hoox monitor kill-switch off # Resume trading
219
+
220
+ # Queue depth
221
+ hoox monitor queue-depth
222
+
223
+ # Backup D1 database
224
+ hoox monitor backup
225
+ ```
226
+
227
+ ### Repair and Recovery
228
+
229
+ ```bash
230
+ # Comprehensive system check (5 steps)
231
+ hoox repair check
232
+
233
+ # Redeploy a single worker
234
+ hoox repair worker trade-worker
235
+
236
+ # Verify infrastructure exists
237
+ hoox repair infra
238
+
239
+ # Re-upload all secrets
240
+ hoox repair secrets
241
+
242
+ # Reset KV keys to defaults
243
+ hoox repair kv
244
+
245
+ # Re-apply schema + migrations
246
+ hoox repair db
247
+
248
+ # Full guided rebuild (interactive, WARNING: destructive)
249
+ hoox repair rebuild
250
+ ```
251
+
252
+ ### JSON Output for Scripting
253
+
254
+ ```bash
255
+ hoox check prerequisites --json
256
+ hoox monitor status --json
257
+ hoox infra d1 list --json
258
+ ```
259
+
260
+ ## Development Setup
261
+
262
+ ### Prerequisites
263
+
264
+ - [Bun](https://bun.sh) >= 1.2
265
+ - [Cloudflare account](https://dash.cloudflare.com/sign-up)
266
+ - Wrangler CLI (installed automatically with dependencies)
267
+
268
+ ### Build from Source
269
+
270
+ ```bash
271
+ # Clone the repository
272
+ git clone https://github.com/jango-blockchained/hoox-setup.git
273
+ cd hoox-setup
274
+
275
+ # Install dependencies
276
+ bun install
277
+
278
+ # Build the CLI
279
+ cd packages/cli
280
+ bun run build
281
+ ```
282
+
283
+ ### Running Tests
284
+
285
+ ```bash
286
+ # Run all tests
287
+ bun test
288
+
289
+ # Run with coverage
290
+ bun run test:coverage
291
+
292
+ # Run specific test file
293
+ bun test path/to/test.test.ts
294
+ ```
295
+
296
+ ### Linting and Type Checking
297
+
298
+ ```bash
299
+ # Lint code
300
+ bun run lint
301
+
302
+ # Type check
303
+ bun run typecheck
304
+ ```
305
+
306
+ ### CI Pipeline
307
+
308
+ The CI pipeline runs in this order:
309
+
310
+ 1. `bun run lint` — ESLint check
311
+ 2. `bun run typecheck` — TypeScript check (`tsc --noEmit`)
312
+ 3. `bun test packages/cli --coverage` — Run tests with coverage (80% threshold)
313
+ 4. `bun run build` — TypeScript build check
314
+
315
+ ## Project Structure
316
+
317
+ ```
318
+ packages/cli/
319
+ ├── src/
320
+ │ ├── index.ts # Main entry point
321
+ │ ├── commands/
322
+ │ │ ├── init/ # Interactive setup wizard
323
+ │ │ ├── dev/ # Local development
324
+ │ │ ├── deploy/ # Deploy, telegram-webhook, update-internal-urls
325
+ │ │ ├── infra/ # D1, KV, R2, Queues, Vectorize, Analytics
326
+ │ │ ├── config/ # Wrangler config, env, kv, secrets
327
+ │ │ ├── check/ # Prerequisites, setup, health
328
+ │ │ ├── db/ # Database operations
329
+ │ │ ├── monitor/ # Health, trades, logs, kill-switch
330
+ │ │ ├── repair/ # Check, worker, infra, secrets, rebuild
331
+ │ │ ├── logs/ # Worker log tailing
332
+ │ │ ├── test/ # CI pipeline
333
+ │ │ ├── waf/ # WAF management
334
+ │ │ ├── clone/ # Submodule cloning
335
+ │ │ └── dashboard/ # Dashboard operations
336
+ │ ├── services/
337
+ │ │ ├── cloudflare/ # Wrangler CLI wrapper
338
+ │ │ ├── config/ # wrangler.jsonc reader
339
+ │ │ ├── db/ # D1 operations
340
+ │ │ ├── docker/ # Docker compose wrapper
341
+ │ │ ├── env/ # Environment definitions
342
+ │ │ ├── kv/ # KV key management
343
+ │ │ ├── prerequisites/ # Tool version checks
344
+ │ │ └── secrets/ # Secret management
345
+ │ ├── ui/ # Interactive TUI
346
+ │ └── utils/ # Errors, formatters, theme
347
+ ├── bin/
348
+ │ └── hoox.js # CLI binary entry point
349
+ ├── package.json
350
+ └── README.md
351
+ ```
352
+
353
+ ## Key Dependencies
354
+
355
+ | Package | Purpose |
356
+ | --------------------------------- | -------------------------------------------------- |
357
+ | `commander` | CLI framework for command registration and parsing |
358
+ | `@clack/prompts` | Interactive prompts for the TUI |
359
+ | `ansis` | Terminal styling and colors |
360
+ | `jsonc-parser` | Parse `wrangler.jsonc` configuration files |
361
+ | `@jango-blockchained/hoox-shared` | Shared types and utilities |
362
+
363
+ ## Contributing
364
+
365
+ Contributions are welcome! Please follow these steps:
366
+
367
+ 1. Fork the repository
368
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
369
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
370
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
371
+ 5. Open a Pull Request
372
+
373
+ Please ensure your code passes linting, type checking, and all tests before submitting.
374
+
375
+ ## License
376
+
377
+ MIT License
378
+
379
+ Copyright (c) 2026 Hoox Team
380
+
381
+ Permission is hereby granted, free of charge, to any person obtaining a copy
382
+ of this software and associated documentation files (the "Software"), to deal
383
+ in the Software without restriction, including without limitation the rights
384
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
385
+ copies of the Software, and to permit persons to whom the Software is
386
+ furnished to do so, subject to the following conditions:
387
+
388
+ The above copyright notice and this permission notice shall be included in all
389
+ copies or substantial portions of the Software.
390
+
391
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
392
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
393
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
394
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
395
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
396
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
397
+ SOFTWARE.
398
+
399
+ ## Links
400
+
401
+ - [GitHub Repository](https://github.com/jango-blockchained/hoox-setup)
402
+ - [Issue Tracker](https://github.com/jango-blockchained/hoox-setup/issues)
403
+ - [Cloudflare Workers Documentation](https://developers.cloudflare.com/workers/)
package/bin/hoox.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Hoox CLI binary entry point.
4
+ *
5
+ * Bun's bin-symlink resolves here. We import and explicitly invoke main()
6
+ * rather than relying on import.meta.main (which is false when this file
7
+ * is the entry point but src/index.ts is loaded as a dependency).
8
+ */
9
+
10
+ import { main } from "../src/index.js";
11
+
12
+ await main();
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@jango-blockchained/hoox-cli",
3
+ "version": "0.3.4",
4
+ "description": "Hoox CLI — manage Cloudflare Workers, infrastructure, secrets, and deployments (@jango-blockchained/hoox-cli)",
5
+ "type": "module",
6
+ "main": "./bin/hoox.js",
7
+ "types": "./src/index.ts",
8
+ "exports": {
9
+ ".": "./bin/hoox.js"
10
+ },
11
+ "bin": {
12
+ "hoox": "./bin/hoox.js"
13
+ },
14
+ "scripts": {
15
+ "test": "bun test",
16
+ "test:coverage": "bun test --coverage",
17
+ "lint": "eslint .",
18
+ "typecheck": "tsc --noEmit",
19
+ "build": "bun build ./src/index.ts --outdir ./dist --target bun",
20
+ "prepublishOnly": "bun run build && bun run lint && bun run typecheck"
21
+ },
22
+ "dependencies": {
23
+ "@clack/prompts": "^1.3.0",
24
+ "@jango-blockchained/hoox-shared": "workspace:*",
25
+ "ansis": "^4.2.0",
26
+ "commander": "^14.0.3",
27
+ "jsonc-parser": "^3.3.1"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^25.6.0",
31
+ "bun-types": "^1.3.13",
32
+ "typescript": "^5.9.3"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/jango-blockchained/hoox-setup.git"
40
+ },
41
+ "keywords": [
42
+ "cloudflare",
43
+ "workers",
44
+ "cli",
45
+ "trading",
46
+ "crypto",
47
+ "automation",
48
+ "hoox"
49
+ ],
50
+ "author": "Hoox Team",
51
+ "license": "MIT",
52
+ "engines": {
53
+ "bun": ">=1.0"
54
+ },
55
+ "files": [
56
+ "bin",
57
+ "src",
58
+ "README.md"
59
+ ]
60
+ }