@rollupdate/hctl 0.0.0-stage → 3.1.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.
Files changed (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1071 -2
  3. package/dist/auction/cache.d.ts +6 -0
  4. package/dist/auction/cache.js +55 -0
  5. package/dist/auction/client.d.ts +24 -0
  6. package/dist/auction/client.js +236 -0
  7. package/dist/auction/commands.d.ts +2 -0
  8. package/dist/auction/commands.js +440 -0
  9. package/dist/auction/diff-formatter.d.ts +3 -0
  10. package/dist/auction/diff-formatter.js +61 -0
  11. package/dist/auction/diff.d.ts +11 -0
  12. package/dist/auction/diff.js +28 -0
  13. package/dist/auction/formatter.d.ts +21 -0
  14. package/dist/auction/formatter.js +182 -0
  15. package/dist/auction/store.d.ts +24 -0
  16. package/dist/auction/store.js +177 -0
  17. package/dist/auction/types.d.ts +74 -0
  18. package/dist/auction/types.js +5 -0
  19. package/dist/cli.d.ts +2 -0
  20. package/dist/cli.js +74 -0
  21. package/dist/client.d.ts +2 -0
  22. package/dist/client.js +4 -0
  23. package/dist/cloud/browser-bootstrap.d.ts +28 -0
  24. package/dist/cloud/browser-bootstrap.js +480 -0
  25. package/dist/cloud/client.d.ts +520 -0
  26. package/dist/cloud/client.js +755 -0
  27. package/dist/cloud/commands/certificate.d.ts +2 -0
  28. package/dist/cloud/commands/certificate.js +108 -0
  29. package/dist/cloud/commands/context.d.ts +2 -0
  30. package/dist/cloud/commands/context.js +133 -0
  31. package/dist/cloud/commands/datacenter.d.ts +2 -0
  32. package/dist/cloud/commands/datacenter.js +24 -0
  33. package/dist/cloud/commands/firewall.d.ts +2 -0
  34. package/dist/cloud/commands/firewall.js +142 -0
  35. package/dist/cloud/commands/floating-ip.d.ts +2 -0
  36. package/dist/cloud/commands/floating-ip.js +138 -0
  37. package/dist/cloud/commands/image.d.ts +2 -0
  38. package/dist/cloud/commands/image.js +98 -0
  39. package/dist/cloud/commands/index.d.ts +2 -0
  40. package/dist/cloud/commands/index.js +47 -0
  41. package/dist/cloud/commands/inventory.d.ts +2 -0
  42. package/dist/cloud/commands/inventory.js +13 -0
  43. package/dist/cloud/commands/iso.d.ts +2 -0
  44. package/dist/cloud/commands/iso.js +27 -0
  45. package/dist/cloud/commands/load-balancer-type.d.ts +2 -0
  46. package/dist/cloud/commands/load-balancer-type.js +24 -0
  47. package/dist/cloud/commands/load-balancer.d.ts +2 -0
  48. package/dist/cloud/commands/load-balancer.js +269 -0
  49. package/dist/cloud/commands/location.d.ts +2 -0
  50. package/dist/cloud/commands/location.js +24 -0
  51. package/dist/cloud/commands/network.d.ts +2 -0
  52. package/dist/cloud/commands/network.js +157 -0
  53. package/dist/cloud/commands/placement-group.d.ts +2 -0
  54. package/dist/cloud/commands/placement-group.js +79 -0
  55. package/dist/cloud/commands/pricing.d.ts +2 -0
  56. package/dist/cloud/commands/pricing.js +15 -0
  57. package/dist/cloud/commands/primary-ip.d.ts +2 -0
  58. package/dist/cloud/commands/primary-ip.js +139 -0
  59. package/dist/cloud/commands/server-type.d.ts +2 -0
  60. package/dist/cloud/commands/server-type.js +24 -0
  61. package/dist/cloud/commands/server.d.ts +2 -0
  62. package/dist/cloud/commands/server.js +346 -0
  63. package/dist/cloud/commands/ssh-key.d.ts +2 -0
  64. package/dist/cloud/commands/ssh-key.js +94 -0
  65. package/dist/cloud/commands/volume.d.ts +2 -0
  66. package/dist/cloud/commands/volume.js +138 -0
  67. package/dist/cloud/context.d.ts +34 -0
  68. package/dist/cloud/context.js +215 -0
  69. package/dist/cloud/formatter.d.ts +40 -0
  70. package/dist/cloud/formatter.js +824 -0
  71. package/dist/cloud/helpers.d.ts +27 -0
  72. package/dist/cloud/helpers.js +67 -0
  73. package/dist/cloud/inventory.d.ts +100 -0
  74. package/dist/cloud/inventory.js +229 -0
  75. package/dist/cloud/pricing.d.ts +27 -0
  76. package/dist/cloud/pricing.js +103 -0
  77. package/dist/cloud/token-instructions.d.ts +2 -0
  78. package/dist/cloud/token-instructions.js +21 -0
  79. package/dist/cloud/types.d.ts +437 -0
  80. package/dist/cloud/types.js +5 -0
  81. package/dist/config.d.ts +1 -0
  82. package/dist/config.js +2 -0
  83. package/dist/formatter.d.ts +3 -0
  84. package/dist/formatter.js +6 -0
  85. package/dist/index.d.ts +12 -0
  86. package/dist/index.js +21 -0
  87. package/dist/robot/client.d.ts +256 -0
  88. package/dist/robot/client.js +745 -0
  89. package/dist/robot/commands/auth.d.ts +2 -0
  90. package/dist/robot/commands/auth.js +54 -0
  91. package/dist/robot/commands/boot.d.ts +2 -0
  92. package/dist/robot/commands/boot.js +76 -0
  93. package/dist/robot/commands/cancel.d.ts +2 -0
  94. package/dist/robot/commands/cancel.js +37 -0
  95. package/dist/robot/commands/failover.d.ts +2 -0
  96. package/dist/robot/commands/failover.js +46 -0
  97. package/dist/robot/commands/firewall.d.ts +2 -0
  98. package/dist/robot/commands/firewall.js +72 -0
  99. package/dist/robot/commands/index.d.ts +2 -0
  100. package/dist/robot/commands/index.js +36 -0
  101. package/dist/robot/commands/interactive.d.ts +2 -0
  102. package/dist/robot/commands/interactive.js +152 -0
  103. package/dist/robot/commands/ip.d.ts +2 -0
  104. package/dist/robot/commands/ip.js +55 -0
  105. package/dist/robot/commands/key.d.ts +2 -0
  106. package/dist/robot/commands/key.js +68 -0
  107. package/dist/robot/commands/order.d.ts +2 -0
  108. package/dist/robot/commands/order.js +33 -0
  109. package/dist/robot/commands/rdns.d.ts +2 -0
  110. package/dist/robot/commands/rdns.js +41 -0
  111. package/dist/robot/commands/reset.d.ts +2 -0
  112. package/dist/robot/commands/reset.js +77 -0
  113. package/dist/robot/commands/server.d.ts +2 -0
  114. package/dist/robot/commands/server.js +32 -0
  115. package/dist/robot/commands/storagebox.d.ts +2 -0
  116. package/dist/robot/commands/storagebox.js +126 -0
  117. package/dist/robot/commands/subnet.d.ts +2 -0
  118. package/dist/robot/commands/subnet.js +24 -0
  119. package/dist/robot/commands/traffic.d.ts +2 -0
  120. package/dist/robot/commands/traffic.js +23 -0
  121. package/dist/robot/commands/vswitch.d.ts +2 -0
  122. package/dist/robot/commands/vswitch.js +81 -0
  123. package/dist/robot/commands/wol.d.ts +2 -0
  124. package/dist/robot/commands/wol.js +20 -0
  125. package/dist/robot/formatter.d.ts +57 -0
  126. package/dist/robot/formatter.js +582 -0
  127. package/dist/robot/types.d.ts +359 -0
  128. package/dist/robot/types.js +5 -0
  129. package/dist/shared/config.d.ts +86 -0
  130. package/dist/shared/config.js +289 -0
  131. package/dist/shared/formatter.d.ts +29 -0
  132. package/dist/shared/formatter.js +121 -0
  133. package/dist/shared/helpers.d.ts +39 -0
  134. package/dist/shared/helpers.js +86 -0
  135. package/dist/shared/init.d.ts +2 -0
  136. package/dist/shared/init.js +107 -0
  137. package/dist/shared/reference.d.ts +5 -0
  138. package/dist/shared/reference.js +689 -0
  139. package/dist/shared/schemas.d.ts +1 -0
  140. package/dist/shared/schemas.js +1031 -0
  141. package/dist/types.d.ts +2 -0
  142. package/dist/types.js +2 -0
  143. package/package.json +127 -4
@@ -0,0 +1,689 @@
1
+ // ============================================================================
2
+ // LLM-Optimized CLI Reference
3
+ // Outputs a structured, verbose plaintext document designed for easy parsing
4
+ // by language models (Claude, GPT, etc.) while remaining human-readable.
5
+ // ============================================================================
6
+ import { createRequire } from "node:module";
7
+ const require = createRequire(import.meta.url);
8
+ const { version: packageVersion } = require("../../package.json");
9
+ const createPreamble = (version) => `\
10
+ # HCTL — COMPLETE REFERENCE
11
+ # =================================
12
+ # Version: ${version}
13
+ # Binary: hctl
14
+ # Install: npm install -g @rollupdate/hctl
15
+ # Source: https://github.com/p8-public/hetzner-cli
16
+ #
17
+ # This CLI manages three Hetzner APIs:
18
+ # 1. Robot API — dedicated server management (requires Robot web service credentials)
19
+ # 2. Cloud API — cloud server/resource management (requires Cloud API token)
20
+ # 3. Auction API — public server auction browser (no authentication required)
21
+ #
22
+ # OUTPUT MODES:
23
+ # All commands default to human-readable formatted tables.
24
+ # Add --json to any command to get machine-readable JSON output.
25
+ # Add --output-schema to print the TypeScript type of the --json output (no API call).
26
+ # Example: hctl server list --json | jq '.[].server.server_ip'
27
+ # Example: hctl server list --output-schema
28
+ #
29
+ # SECTIONS: Use "hctl reference --section robot|cloud|auction" to show only one section.
30
+ #
31
+ # FIRST-TIME SETUP:
32
+ # hctl init — interactive wizard for Robot + Cloud credentials
33
+ # (alias: hctl setup; shows links to where each credential is created)
34
+ # Robot credentials are created in Robot; Cloud tokens are created in Cloud Console.
35
+ `;
36
+ const AUTHENTICATION = `\
37
+ # ============================================================================
38
+ # AUTHENTICATION
39
+ # ============================================================================
40
+ #
41
+ # ROBOT API — Credential Resolution Order:
42
+ # Created in Robot UI: https://robot.hetzner.com
43
+ # These are web service credentials, not Cloud Console API tokens.
44
+ # 1. CLI flags: --user <username> --password <password>
45
+ # 2. Environment: HETZNER_ROBOT_USER and HETZNER_ROBOT_PASSWORD
46
+ # 3. System keychain: stored by "hctl auth login" (uses keytar)
47
+ # 4. Config file: ~/.hctl/config.json
48
+ # 5. Interactive: prompts for username/password at runtime
49
+ #
50
+ # Password from stdin (keeps password out of shell history):
51
+ # echo "$PASSWORD" | hctl server list -u myuser -p -
52
+ #
53
+ # With 1Password:
54
+ # op read "op://vault/item/password" | hctl server list -u $(op read "op://vault/item/user") -p -
55
+ #
56
+ # CLOUD API — Token Resolution Order:
57
+ # Created in Cloud Console per project: https://console.hetzner.cloud
58
+ # These are project-scoped API tokens, not Robot web service credentials.
59
+ # 1. CLI flag: --token <token> (per command)
60
+ # 2. Environment: HETZNER_CLOUD_TOKEN
61
+ # 3. Active context: ~/.hctl/cloud-contexts.json (set via "hctl cloud context use <name>")
62
+ #
63
+ # AUCTION API — No authentication required.
64
+
65
+ # ============================================================================
66
+ # GLOBAL OPTIONS (apply to all commands)
67
+ # ============================================================================
68
+
69
+ hctl [command] [options]
70
+ -u, --user <username> Robot API username
71
+ -p, --password <password> Robot API password (use "-" to read from stdin)
72
+ --json Output raw JSON instead of formatted tables
73
+ --output-schema Print TypeScript type for --json output and exit (no API call)
74
+ -V, --version Show version number
75
+ -h, --help Show help for any command`;
76
+ const SECTION_ROBOT = `\
77
+ # ============================================================================
78
+ # ROBOT API COMMANDS — Dedicated Server Management
79
+ # ============================================================================
80
+ # All robot commands require Robot API credentials (see AUTHENTICATION above).
81
+ # Robot API docs: https://robot.hetzner.com/doc/webservice/en.html
82
+
83
+ # --- init: First-Time Setup Wizard ---
84
+ hctl init # Interactive wizard: configures Robot + Cloud credentials
85
+ hctl setup # Alias for init
86
+ # Shows the exact URLs where Robot and Cloud credentials are created.
87
+ # Skips an API if it is already configured.
88
+
89
+ # --- auth: Credential Management ---
90
+ hctl auth login # Interactive login, saves credentials
91
+ hctl auth logout # Clear saved credentials from keychain and config
92
+ hctl auth status # Show current auth status (which credential source is active)
93
+ hctl auth test # Test credentials against the API
94
+
95
+ # --- server: Dedicated Server Management ---
96
+ hctl server list # List all servers (alias: ls)
97
+ hctl server get <server> # Get server details by ID or IP (alias: show)
98
+ hctl server rename <server> <name> # Rename a server
99
+
100
+ # --- reset: Server Reset Operations ---
101
+ hctl reset options [server] # Show available reset types for server(s)
102
+ hctl reset execute <servers...> # Reset one or more servers (alias: run)
103
+ -t, --type <type> # Reset type: sw (software, default), hw (hardware), man (manual), power, power_long
104
+ -i, --interactive # Interactively select reset type per server
105
+ -y, --yes # Skip confirmation prompt
106
+
107
+ # --- boot: Boot Configuration ---
108
+ hctl boot status <server> # Show all boot configuration (rescue, linux, vnc, windows, etc.)
109
+
110
+ # boot rescue: Rescue System
111
+ hctl boot rescue activate <server> # Activate rescue system
112
+ -o, --os <os> # OS: linux (default), linuxold, vkvm
113
+ -a, --arch <arch> # Architecture: 64 (default), 32
114
+ -k, --keys <fingerprints...> # SSH key fingerprints to authorize
115
+ hctl boot rescue deactivate <server> # Deactivate rescue system
116
+ hctl boot rescue last <server> # Show last rescue activation (including password if recent)
117
+
118
+ # boot linux: Linux Installation
119
+ hctl boot linux activate <server> # Activate Linux installation
120
+ -d, --dist <dist> # Distribution name (required), e.g. "Debian-1210-bookworm-amd64-base"
121
+ -a, --arch <arch> # Architecture: 64 (default), 32
122
+ -l, --lang <lang> # Language: en (default)
123
+ -k, --keys <fingerprints...> # SSH key fingerprints to authorize
124
+ hctl boot linux deactivate <server> # Deactivate pending Linux installation
125
+ hctl boot linux options <server> # Show available Linux distributions for this server
126
+
127
+ # --- ip: IP Address Management ---
128
+ hctl ip list # List all IP addresses (alias: ls)
129
+ hctl ip get <ip> # Get IP details (alias: show)
130
+ hctl ip update <ip> # Update IP traffic warning settings
131
+ --warnings <enabled> # Enable/disable warnings: true/false
132
+ --hourly <mb> # Hourly traffic warning threshold in MB
133
+ --daily <mb> # Daily traffic warning threshold in MB
134
+ --monthly <gb> # Monthly traffic warning threshold in GB
135
+
136
+ # ip mac: Separate MAC Addresses
137
+ hctl ip mac get <ip> # Get separate MAC address for IP
138
+ hctl ip mac generate <ip> # Generate a new separate MAC address
139
+ hctl ip mac delete <ip> # Delete separate MAC address
140
+
141
+ # --- subnet: Subnet Management ---
142
+ hctl subnet list # List all subnets (alias: ls)
143
+ hctl subnet get <subnet> # Get subnet details (alias: show)
144
+
145
+ # --- failover: Failover IP Management ---
146
+ hctl failover list # List all failover IPs (alias: ls)
147
+ hctl failover get <ip> # Get failover IP details (alias: show)
148
+ hctl failover switch <failover-ip> <target-server-ip> # Switch failover routing
149
+ -y, --yes # Skip confirmation
150
+ hctl failover delete <ip> # Delete failover IP routing
151
+ -y, --yes # Skip confirmation
152
+
153
+ # --- rdns: Reverse DNS Management ---
154
+ hctl rdns list # List all reverse DNS entries (alias: ls)
155
+ hctl rdns get <ip> # Get reverse DNS for IP (alias: show)
156
+ hctl rdns set <ip> <ptr> # Create or update reverse DNS entry
157
+ hctl rdns delete <ip> # Delete reverse DNS entry
158
+
159
+ # --- key: SSH Key Management ---
160
+ hctl key list # List all SSH keys (alias: ls)
161
+ hctl key get <fingerprint> # Get SSH key details (alias: show)
162
+ hctl key add <name> # Add new SSH key (prompts for key data if no flags)
163
+ -f, --file <path> # Path to public key file (e.g. ~/.ssh/id_rsa.pub)
164
+ -d, --data <key> # Public key data as string
165
+ hctl key rename <fingerprint> <name> # Rename an SSH key
166
+ hctl key delete <fingerprint> # Delete an SSH key (alias: rm)
167
+ -y, --yes # Skip confirmation
168
+
169
+ # --- firewall: Firewall Management ---
170
+ hctl firewall get <server> # Get firewall configuration (alias: show)
171
+ hctl firewall enable <server> # Enable firewall
172
+ hctl firewall disable <server> # Disable firewall
173
+ hctl firewall delete <server> # Delete all firewall rules
174
+ -y, --yes # Skip confirmation
175
+
176
+ # firewall template: Firewall Templates
177
+ hctl firewall template list # List firewall templates (alias: ls)
178
+ hctl firewall template get <id> # Get template details (alias: show)
179
+ hctl firewall template delete <id> # Delete template (alias: rm)
180
+ -y, --yes # Skip confirmation
181
+
182
+ # --- vswitch: vSwitch Management ---
183
+ hctl vswitch list # List all vSwitches (alias: ls)
184
+ hctl vswitch get <id> # Get vSwitch details (alias: show)
185
+ hctl vswitch servers [id] # List servers on all vSwitches, or one (one API request per vSwitch, plus one for names)
186
+ hctl vswitch create <name> <vlan> # Create a new vSwitch
187
+ hctl vswitch update <id> # Update vSwitch
188
+ -n, --name <name> # New name
189
+ -v, --vlan <vlan> # New VLAN ID
190
+ hctl vswitch delete <id> # Delete vSwitch (alias: rm)
191
+ -y, --yes # Skip confirmation
192
+ --date <date> # Cancellation date (YYYY-MM-DD format)
193
+ hctl vswitch add-server <vswitch-id> <server> # Add server to vSwitch
194
+ hctl vswitch remove-server <vswitch-id> <server> # Remove server from vSwitch
195
+
196
+ # --- storagebox: Storage Box Management (alias: storage) ---
197
+ hctl storagebox list # List all storage boxes (alias: ls)
198
+ hctl storagebox get <id> # Get storage box details (alias: show)
199
+ hctl storagebox update <id> # Update storage box settings
200
+ -n, --name <name> # Storage box name
201
+ --webdav <enabled> # Enable/disable WebDAV: true/false
202
+ --samba <enabled> # Enable/disable Samba: true/false
203
+ --ssh <enabled> # Enable/disable SSH/SFTP: true/false
204
+ --external <enabled> # Enable/disable external reachability: true/false
205
+ --zfs <enabled> # Enable/disable ZFS: true/false
206
+ hctl storagebox reset-password <id> # Reset storage box password
207
+
208
+ # storagebox snapshot: Snapshot Management
209
+ hctl storagebox snapshot list <box-id> # List snapshots (alias: ls)
210
+ hctl storagebox snapshot create <box-id> # Create a new snapshot
211
+ hctl storagebox snapshot delete <box-id> <name> # Delete a snapshot (alias: rm)
212
+ -y, --yes # Skip confirmation
213
+ hctl storagebox snapshot revert <box-id> <name> # Revert to a snapshot
214
+ -y, --yes # Skip confirmation
215
+
216
+ # storagebox subaccount: Subaccount Management
217
+ hctl storagebox subaccount list <box-id> # List subaccounts (alias: ls)
218
+ hctl storagebox subaccount create <box-id> <home-directory> # Create subaccount
219
+ --samba <enabled> # Enable Samba: true/false
220
+ --ssh <enabled> # Enable SSH: true/false
221
+ --webdav <enabled> # Enable WebDAV: true/false
222
+ --external <enabled> # Enable external access: true/false
223
+ --readonly <enabled> # Read-only mode: true/false
224
+ --comment <comment> # Comment
225
+ hctl storagebox subaccount delete <box-id> <username> # Delete subaccount (alias: rm)
226
+ -y, --yes # Skip confirmation
227
+
228
+ # --- traffic: Traffic Analytics ---
229
+ hctl traffic query # Query traffic data
230
+ -i, --ip <ips...> # IP addresses to query
231
+ -s, --subnet <subnets...> # Subnets to query
232
+ --from <date> # Start date (YYYY-MM-DD)
233
+ --to <date> # End date (YYYY-MM-DD)
234
+ -t, --type <type> # Query type: day, month (default), year
235
+
236
+ # --- wol: Wake on LAN ---
237
+ hctl wol status <server> # Check WoL status for server
238
+ hctl wol send <server> # Send Wake on LAN packet
239
+
240
+ # --- cancel: Server Cancellation ---
241
+ hctl cancel status <server> # Get cancellation status
242
+ hctl cancel request <server> # Request server cancellation
243
+ --date <date> # Cancellation date (YYYY-MM-DD)
244
+ --reason <reasons...> # Cancellation reasons
245
+ -y, --yes # Skip confirmation
246
+ hctl cancel revoke <server> # Revoke pending cancellation
247
+
248
+ # --- order: Server Ordering ---
249
+ hctl order products # List available server products
250
+ hctl order market # List server market/auction products (authenticated API)
251
+ hctl order transactions # List order transactions
252
+ hctl order transaction <id> # Get order transaction details
253
+
254
+ # --- interactive: Interactive Mode (alias: i) ---
255
+ hctl interactive # Launch menu-driven interface for common operations
256
+ hctl i # Short alias
257
+
258
+ # --- Robot API Examples ---
259
+ # List all dedicated servers:
260
+ # hctl server list
261
+ #
262
+ # Get server details as JSON:
263
+ # hctl server get 123456 --json
264
+ #
265
+ # Hardware reset a server:
266
+ # hctl reset execute 123456 -t hw -y
267
+ #
268
+ # Activate rescue mode with SSH key:
269
+ # hctl boot rescue activate 123456 -k ab:cd:ef:12:34:56
270
+ #
271
+ # Switch failover IP:
272
+ # hctl failover switch 1.2.3.4 5.6.7.8 -y
273
+ #
274
+ # Query monthly traffic:
275
+ # hctl traffic query --ip 1.2.3.4 --from 2025-01-01 --to 2025-01-31`;
276
+ const SECTION_CLOUD = `\
277
+ # ============================================================================
278
+ # CLOUD API COMMANDS — hctl cloud <resource> <action>
279
+ # ============================================================================
280
+ # All cloud commands require a Cloud API token (see AUTHENTICATION above).
281
+ # Cloud API docs: https://docs.hetzner.cloud/
282
+
283
+ # --- cloud context: Context/Token Management ---
284
+ hctl cloud context create <name> # Create a new cloud context (saves token)
285
+ -t, --token <token> # API token (prompts interactively if omitted)
286
+ --no-verify # Skip validation with api.hetzner.cloud
287
+ hctl cloud context test # Validate the resolved Cloud API token
288
+ -t, --token <token> # Validate this token instead of resolving one
289
+ hctl cloud context bootstrap <name> # Explicit browser-assisted token creation
290
+ --project <name> # Cloud project name
291
+ --create-project # Guide through creating the project first
292
+ --token-name <name> # API token name to use in Hetzner Console
293
+ --permission <permission> # read or read-write (default: read-write)
294
+ --write-env [path] # Also write HETZNER_CLOUD_TOKEN to .env or path
295
+ --no-verify # Skip validation with api.hetzner.cloud
296
+ hctl cloud context use <name> # Switch to a cloud context (sets it as active)
297
+ hctl cloud context delete <name> # Delete a cloud context (alias: rm)
298
+ hctl cloud context list # List all cloud contexts (alias: ls)
299
+ hctl cloud context active # Show the currently active cloud context
300
+
301
+ # --- cloud server: Cloud Server Management ---
302
+ hctl cloud server list # List all cloud servers (alias: ls)
303
+ -l, --label-selector <selector> # Filter by label (e.g. "env=prod")
304
+ -n, --name <name> # Filter by name
305
+ -s, --sort <field> # Sort by field (e.g. "name", "created")
306
+ --status <status> # Filter by status (e.g. "running", "off")
307
+ hctl cloud server describe <id> # Show server details
308
+ hctl cloud server create # Create a new server
309
+ --name <name> # Server name (REQUIRED)
310
+ --type <type> # Server type, e.g. cx22 (REQUIRED)
311
+ --image <image> # Image name or ID, e.g. ubuntu-22.04 (REQUIRED)
312
+ --location <location> # Location: fsn1, nbg1, hel1, ash, hil
313
+ --ssh-key <keys...> # SSH key IDs or names
314
+ --user-data <data> # Cloud-init user data
315
+ --start-after-create # Start server immediately (default: true)
316
+ --no-start-after-create # Create without starting
317
+ hctl cloud server delete <id> # Delete a server
318
+ -y, --yes # Skip confirmation
319
+ hctl cloud server update <id> # Update server
320
+ --name <name> # New server name
321
+ hctl cloud server poweron <id> # Power on a server
322
+ hctl cloud server poweroff <id> # Power off a server (hard power off)
323
+ hctl cloud server reboot <id> # Soft reboot a server (ACPI)
324
+ hctl cloud server reset <id> # Hard reset a server
325
+ hctl cloud server shutdown <id> # Graceful shutdown (ACPI signal)
326
+ hctl cloud server rebuild <id> # Rebuild server with new image
327
+ --image <image> # Image to rebuild with (REQUIRED)
328
+ hctl cloud server change-type <id> # Change server type (resize)
329
+ --type <type> # New server type (REQUIRED)
330
+ --upgrade-disk # Also upgrade disk (irreversible)
331
+ hctl cloud server enable-rescue <id> # Enable rescue mode
332
+ --type <type> # Rescue type: linux64 (default)
333
+ --ssh-key <keys...> # SSH key IDs
334
+ hctl cloud server disable-rescue <id> # Disable rescue mode
335
+ hctl cloud server enable-backup <id> # Enable automatic backups
336
+ hctl cloud server disable-backup <id> # Disable automatic backups
337
+ hctl cloud server create-image <id> # Create snapshot from server
338
+ --description <desc> # Image description
339
+ --type <type> # Image type: snapshot (default), backup
340
+ hctl cloud server attach-iso <id> # Attach ISO to server
341
+ --iso <iso> # ISO name or ID (REQUIRED)
342
+ hctl cloud server detach-iso <id> # Detach ISO from server
343
+ hctl cloud server reset-password <id> # Reset root password
344
+ hctl cloud server set-rdns <id> # Set reverse DNS
345
+ --ip <ip> # IP address (REQUIRED)
346
+ --dns-ptr <ptr> # DNS pointer record (REQUIRED)
347
+ hctl cloud server enable-protection <id> # Enable protection
348
+ --delete # Delete protection (default: true)
349
+ --rebuild # Rebuild protection (default: false)
350
+ hctl cloud server disable-protection <id> # Disable all protection
351
+ hctl cloud server request-console <id> # Get WebSocket VNC console URL + password
352
+ hctl cloud server attach-to-network <id> # Attach to network
353
+ --network <network> # Network ID (REQUIRED)
354
+ --ip <ip> # IP address in network (optional)
355
+ hctl cloud server detach-from-network <id> # Detach from network
356
+ --network <network> # Network ID (REQUIRED)
357
+ hctl cloud server add-label <id> <label> # Add label (format: key=value)
358
+ hctl cloud server remove-label <id> <key> # Remove label by key
359
+
360
+ # --- cloud network: Network Management ---
361
+ hctl cloud network list # List all networks (alias: ls)
362
+ hctl cloud network describe <id> # Show network details
363
+ hctl cloud network create # Create a network
364
+ --name <name> # Network name (REQUIRED)
365
+ --ip-range <cidr> # IP range in CIDR notation (REQUIRED)
366
+ hctl cloud network delete <id> # Delete a network
367
+ -y, --yes # Skip confirmation
368
+
369
+ # --- cloud firewall: Cloud Firewall Management ---
370
+ hctl cloud firewall list # List all firewalls (alias: ls)
371
+ hctl cloud firewall describe <id> # Show firewall details
372
+ hctl cloud firewall create # Create a firewall
373
+ --name <name> # Firewall name (REQUIRED)
374
+ hctl cloud firewall delete <id> # Delete a firewall
375
+ -y, --yes # Skip confirmation
376
+
377
+ # --- cloud floating-ip: Floating IP Management ---
378
+ hctl cloud floating-ip list # List all floating IPs (alias: ls)
379
+ hctl cloud floating-ip describe <id> # Show floating IP details
380
+ hctl cloud floating-ip create # Create a floating IP
381
+ --type <type> # IP type: ipv4, ipv6 (REQUIRED)
382
+ --home-location <location> # Home location (REQUIRED)
383
+ --description <desc> # Description
384
+ hctl cloud floating-ip delete <id> # Delete a floating IP
385
+ -y, --yes # Skip confirmation
386
+
387
+ # --- cloud primary-ip: Primary IP Management ---
388
+ hctl cloud primary-ip list # List all primary IPs (alias: ls)
389
+ hctl cloud primary-ip describe <id> # Show primary IP details
390
+ hctl cloud primary-ip create # Create a primary IP
391
+ --type <type> # IP type: ipv4, ipv6 (REQUIRED)
392
+ --name <name> # Name (REQUIRED)
393
+ --location <location> # Location, e.g. fsn1 (required unless --assignee-id is set)
394
+ --assignee-id <id> # Server to assign to
395
+ --auto-delete # Auto-delete with server
396
+ hctl cloud primary-ip delete <id> # Delete a primary IP
397
+ -y, --yes # Skip confirmation
398
+
399
+ # --- cloud volume: Volume Management ---
400
+ hctl cloud volume list # List all volumes (alias: ls)
401
+ hctl cloud volume describe <id> # Show volume details
402
+ hctl cloud volume create # Create a volume
403
+ --name <name> # Volume name (REQUIRED)
404
+ --size <gb> # Size in GB (REQUIRED)
405
+ --location <location> # Location
406
+ --server <id> # Attach to server immediately
407
+ hctl cloud volume delete <id> # Delete a volume
408
+ -y, --yes # Skip confirmation
409
+
410
+ # --- cloud load-balancer: Load Balancer Management ---
411
+ hctl cloud load-balancer list # List all load balancers (alias: ls)
412
+ hctl cloud load-balancer describe <id> # Show load balancer details
413
+ hctl cloud load-balancer create # Create a load balancer
414
+ --name <name> # Load balancer name (REQUIRED)
415
+ --type <type> # Load balancer type (REQUIRED)
416
+ --location <location> # Location
417
+ hctl cloud load-balancer delete <id> # Delete a load balancer
418
+ -y, --yes # Skip confirmation
419
+
420
+ # --- cloud image: Image Management ---
421
+ hctl cloud image list # List all images (alias: ls)
422
+ -l, --label-selector <selector> # Filter by label
423
+ -s, --sort <field> # Sort by field
424
+ --type <type> # Filter: system, snapshot, backup, app
425
+ --architecture <arch> # Filter: x86, arm
426
+ --status <status> # Filter by status
427
+ hctl cloud image describe <id> # Show image details
428
+ hctl cloud image update <id> # Update image
429
+ --description <desc> # New description
430
+ --type <type> # New type
431
+ hctl cloud image delete <id> # Delete an image
432
+ -y, --yes # Skip confirmation
433
+
434
+ # --- cloud ssh-key: Cloud SSH Key Management ---
435
+ hctl cloud ssh-key list # List all SSH keys (alias: ls)
436
+ hctl cloud ssh-key describe <id> # Show SSH key details
437
+ hctl cloud ssh-key create # Create an SSH key
438
+ --name <name> # Key name (REQUIRED)
439
+ --public-key <key> # Public key data (REQUIRED)
440
+ hctl cloud ssh-key delete <id> # Delete an SSH key
441
+ -y, --yes # Skip confirmation
442
+
443
+ # --- cloud certificate: TLS Certificate Management ---
444
+ hctl cloud certificate list # List all certificates (alias: ls)
445
+ hctl cloud certificate describe <id> # Show certificate details
446
+ hctl cloud certificate create # Create/upload a certificate
447
+ --name <name> # Certificate name (REQUIRED)
448
+ --certificate <cert> # PEM certificate data
449
+ --private-key <key> # PEM private key data
450
+ hctl cloud certificate delete <id> # Delete a certificate
451
+ -y, --yes # Skip confirmation
452
+
453
+ # --- cloud placement-group: Placement Group Management ---
454
+ hctl cloud placement-group list # List all placement groups (alias: ls)
455
+ hctl cloud placement-group describe <id> # Show placement group details
456
+ hctl cloud placement-group create # Create a placement group
457
+ --name <name> # Group name (REQUIRED)
458
+ --type <type> # Type: spread (REQUIRED)
459
+ hctl cloud placement-group delete <id> # Delete a placement group
460
+ -y, --yes # Skip confirmation
461
+
462
+ # --- cloud datacenter: Datacenter Information (read-only) ---
463
+ hctl cloud datacenter list # List all datacenters (alias: ls)
464
+ hctl cloud datacenter describe <id> # Show datacenter details
465
+
466
+ # --- cloud location: Location Information (read-only) ---
467
+ hctl cloud location list # List all locations (alias: ls)
468
+ hctl cloud location describe <id> # Show location details
469
+
470
+ # --- cloud server-type: Server Type Information (read-only) ---
471
+ hctl cloud server-type list # List all server types (alias: ls)
472
+ hctl cloud server-type describe <id> # Show server type details
473
+
474
+ # --- cloud load-balancer-type: Load Balancer Type Information (read-only) ---
475
+ hctl cloud load-balancer-type list # List all load balancer types (alias: ls)
476
+ hctl cloud load-balancer-type describe <id> # Show load balancer type details
477
+
478
+ # --- cloud iso: ISO Image Information ---
479
+ hctl cloud iso list # List all ISO images (alias: ls)
480
+ -n, --name <name> # Filter by name
481
+ -a, --architecture <arch> # Filter by architecture
482
+ hctl cloud iso describe <id> # Show ISO details
483
+
484
+ # --- Cloud API Examples ---
485
+ # Set up cloud authentication:
486
+ # hctl init
487
+ # Or create an additional named context:
488
+ # hctl cloud context create production -t hcloud_xxxxx
489
+ # hctl cloud context use production
490
+ #
491
+ # Create a cloud server:
492
+ # hctl cloud server create --name web1 --type cx22 --image ubuntu-22.04 --location fsn1 --ssh-key my-key
493
+ #
494
+ # List cloud servers filtered by label:
495
+ # hctl cloud server list -l "env=prod" --json
496
+ #
497
+ # Snapshot a server:
498
+ # hctl cloud server create-image 12345 --description "before upgrade"
499
+ #
500
+ # Resize a server:
501
+ # hctl cloud server change-type 12345 --type cx32`;
502
+ const SECTION_AUCTION = `\
503
+ # ============================================================================
504
+ # AUCTION COMMANDS — Public Server Auction Browser
505
+ # ============================================================================
506
+ # No authentication required. Data from hosted 15-minute cache by default:
507
+ # https://auction.hctl.dev/live_data_sb_EUR.json
508
+ # Use --direct to fetch from Hetzner's public endpoint instead:
509
+ # https://www.hetzner.com/_resources/app/data/app/live_data_sb_EUR.json
510
+ # Returns the current public auction inventory. All filtering and sorting is done client-side.
511
+ # Human output includes auction freshness timestamps. JSON output stays parseable on stdout.
512
+ # When offline, "auction list" and "auction show" can use the last local cache and mark it stale.
513
+ # "auction diff" and "auction watch" require current data and do not snapshot stale local fallback data.
514
+ # Use "hctl auction status --json" before automation when freshness matters.
515
+ #
516
+ # TYPICAL DATA RANGES (approximate, changes continuously):
517
+ # Price: 35 - 450 EUR/month
518
+ # Hourly: 0.04 - 0.72 EUR/hour
519
+ # RAM: 32 - 1024 GB
520
+ # Disk total: 240 - 230,000+ GB
521
+ # Disk count: 1 - 16 drives
522
+ # CPU models: Intel (i7, Xeon) and AMD (Ryzen, EPYC)
523
+ # Datacenters: FSN1-DC* (Falkenstein), HEL1-DC* (Helsinki), NBG1-DC* (Nuremberg)
524
+ # Specials: ECC, GPU, IPv4, iNIC (Intel NIC)
525
+
526
+ # --- auction list: List and Filter Auction Servers ---
527
+ hctl auction list # List all auction servers (alias: ls)
528
+
529
+ # PRICE FILTERS:
530
+ --min-price <n> # Minimum monthly price (EUR/USD)
531
+ --max-price <n> # Maximum monthly price
532
+ --max-hourly-price <n> # Maximum hourly price
533
+ --max-setup-price <n> # Maximum setup fee
534
+ --no-setup-fee # Only servers with zero setup fee (shorthand for --max-setup-price 0)
535
+ --fixed-price # Only fixed-price servers (price won't change)
536
+ --auction-only # Only auction servers (price decreases over time)
537
+
538
+ # HARDWARE FILTERS:
539
+ --cpu <text> # CPU model substring match, case-insensitive
540
+ # Examples: "Ryzen", "EPYC", "i7-6700", "Xeon"
541
+ --min-cpu-count <n> # Minimum CPU/socket count
542
+ --max-cpu-count <n> # Maximum CPU/socket count
543
+ --min-ram <gb> # Minimum RAM in GB
544
+ --max-ram <gb> # Maximum RAM in GB
545
+ --ecc # Only ECC RAM servers
546
+
547
+ # DISK FILTERS:
548
+ --min-disk-size <gb> # Minimum total disk capacity in GB (sum across all drives)
549
+ --max-disk-size <gb> # Maximum total disk capacity in GB
550
+ --min-disk-count <n> # Minimum number of physical drives
551
+ --max-disk-count <n> # Maximum number of physical drives
552
+ --disk-type <type> # Only servers with this disk type: nvme, sata, hdd
553
+ # Note: server may have OTHER types too; this checks presence
554
+
555
+ # NETWORK FILTERS:
556
+ --datacenter <text> # Datacenter substring match, case-insensitive
557
+ # Examples: "FSN" (all Falkenstein), "HEL1-DC2" (specific), "NBG"
558
+ --min-bandwidth <mbit> # Minimum bandwidth in Mbit/s
559
+
560
+ # FEATURE FILTERS:
561
+ --gpu # Only GPU servers
562
+ --inic # Only servers with Intel NIC
563
+ --highio # Only high I/O servers
564
+ --specials <text> # Filter by any special feature, substring match
565
+ # Examples: "GPU", "ECC", "iNIC", "IPv4"
566
+
567
+ # TEXT SEARCH:
568
+ --search <text> # Free-text search across server description lines
569
+ # Searches the description array (CPU, RAM, disk details, NIC info)
570
+
571
+ # SORTING:
572
+ --sort <field> # Sort field (default: price). Choices:
573
+ # price — monthly price
574
+ # hourly — hourly price
575
+ # setup — setup fee
576
+ # ram — RAM size in GB
577
+ # disk — total disk capacity (sum of all drives)
578
+ # disk_count — number of physical drives
579
+ # cpu — CPU model name (alphabetical)
580
+ # cpu_count — number of CPU sockets
581
+ # datacenter — datacenter name (alphabetical)
582
+ # bandwidth — bandwidth in Mbit/s
583
+ # next_reduce — minutes until next price reduction (auction servers only)
584
+ --desc # Sort in descending order (default: ascending)
585
+
586
+ # OUTPUT:
587
+ --currency <currency> # EUR (default) or USD
588
+ --direct # Fetch directly from Hetzner instead of hosted cache
589
+ --limit <n> # Limit number of results shown
590
+ --json # Output raw JSON array
591
+
592
+ # --- auction show: Show Auction Server Details ---
593
+ hctl auction show <id> # Show full details for a specific auction server
594
+ --currency <currency> # EUR (default) or USD
595
+ --direct # Fetch directly from Hetzner instead of hosted cache
596
+ --json # Output raw JSON object
597
+
598
+ # --- auction status: Show Auction Freshness and Cache State ---
599
+ hctl auction status # Show hosted/local cache freshness
600
+ --currency <currency> # EUR (default) or USD
601
+ --direct # Check Hetzner direct instead of hosted cache
602
+ --json # Output machine-readable freshness JSON
603
+ # Includes: updatedAt, ageSeconds, stale, source,
604
+ # serverCount, endpointUrl, localCache, usingLocalFallback
605
+
606
+ # --- Auction API Examples ---
607
+ # Browse all auction servers sorted by price:
608
+ # hctl auction list
609
+ #
610
+ # Find cheap AMD EPYC servers with NVMe and ECC in Helsinki:
611
+ # hctl auction list --cpu epyc --disk-type nvme --ecc --datacenter HEL --sort price
612
+ #
613
+ # Find GPU servers under 150 EUR:
614
+ # hctl auction list --gpu --max-price 150
615
+ #
616
+ # Find servers with at least 256 GB RAM and 4+ drives:
617
+ # hctl auction list --min-ram 256 --min-disk-count 4 --sort ram --desc
618
+ #
619
+ # Find the cheapest fixed-price servers with NVMe:
620
+ # hctl auction list --fixed-price --disk-type nvme --sort price --limit 10
621
+ #
622
+ # Find auction servers about to drop in price (sorted by nearest reduction):
623
+ # hctl auction list --auction-only --sort next_reduce --limit 20
624
+ #
625
+ # Get full details for a specific auction server:
626
+ # hctl auction show 2919866
627
+ #
628
+ # Export filtered results as JSON for scripting:
629
+ # hctl auction list --max-price 60 --ecc --json | jq '.[].id'
630
+ #
631
+ # Check freshness before an agent relies on auction data:
632
+ # hctl auction status --json
633
+ #
634
+ # Bypass the hosted cache:
635
+ # hctl auction list --direct --max-price 60
636
+ #
637
+ # Compare EUR vs USD pricing:
638
+ # hctl auction list --currency USD --max-price 50`;
639
+ const POSTAMBLE = `\
640
+ # ============================================================================
641
+ # CONFIGURATION FILES
642
+ # ============================================================================
643
+ # ~/.hctl/config.json Robot API credentials (file-based fallback)
644
+ # ~/.hctl/cloud-contexts.json Cloud API contexts and tokens
645
+ #
646
+ # System keychain (via keytar): Robot API credentials (preferred, secure)
647
+ # Service name: "hctl"
648
+ # Account key: "robot-api"
649
+ #
650
+ # Environment variables:
651
+ # HETZNER_ROBOT_USER Robot API username
652
+ # HETZNER_ROBOT_PASSWORD Robot API password
653
+ # HETZNER_CLOUD_TOKEN Cloud API token (overrides context)
654
+ # HCTL_AUCTION_SOURCE Set to "direct" to bypass hosted auction cache
655
+ # HCTL_AUCTION_CACHE_URL Override hosted auction cache base URL
656
+
657
+ # ============================================================================
658
+ # PROGRAMMATIC (LIBRARY) USAGE
659
+ # ============================================================================
660
+ # This package can also be imported as a Node.js/TypeScript library:
661
+ #
662
+ # import { HetznerRobotClient } from '@rollupdate/hctl';
663
+ # import { fetchAuctionData, fetchAuctionServers, filterAuctionServers, sortAuctionServers } from '@rollupdate/hctl';
664
+ #
665
+ # Robot Client:
666
+ # const client = new HetznerRobotClient(username, password);
667
+ # const servers = await client.listServers();
668
+ # const details = await client.getServer(123456);
669
+ # await client.resetServer(123456, 'sw');
670
+ #
671
+ # Auction Client (no auth):
672
+ # const { data, metadata } = await fetchAuctionData('EUR');
673
+ # const { server: servers } = data;
674
+ # console.log(metadata.updatedAt, metadata.ageSeconds, metadata.source);
675
+ # const filtered = filterAuctionServers(servers, { maxPrice: 50, ecc: true });
676
+ # const sorted = sortAuctionServers(filtered, 'price', false);`;
677
+ const SECTIONS = {
678
+ robot: SECTION_ROBOT,
679
+ cloud: SECTION_CLOUD,
680
+ auction: SECTION_AUCTION,
681
+ };
682
+ export function generateReference(section, options = {}) {
683
+ const preamble = `${createPreamble(options.version ?? packageVersion)}\n${AUTHENTICATION}`;
684
+ if (section) {
685
+ const body = SECTIONS[section];
686
+ return `${preamble}\n\n${body}`;
687
+ }
688
+ return `${preamble}\n\n${SECTION_ROBOT}\n\n${SECTION_CLOUD}\n\n${SECTION_AUCTION}\n\n${POSTAMBLE}`;
689
+ }