huaweicloud-devkit 1.0.2-dev.9 → 1.0.2-next.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 (97) hide show
  1. package/.agents/plugins/marketplace.json +20 -20
  2. package/LICENSE +201 -201
  3. package/README.md +163 -138
  4. package/README.zh-CN.md +161 -138
  5. package/bin/setup.cjs +8 -8
  6. package/integrations/opencode/commands/huaweicloud-doctor.md +14 -14
  7. package/integrations/opencode/opencode.json +14 -14
  8. package/integrations/opencode/skills/huaweicloud-core/SKILL.md +32 -32
  9. package/package.json +46 -44
  10. package/plugins/huaweicloud-core/.claude-plugin/plugin.json +44 -44
  11. package/plugins/huaweicloud-core/.codex-plugin/plugin.json +43 -43
  12. package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +44 -44
  13. package/plugins/huaweicloud-core/.mcp.json +15 -15
  14. package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +44 -44
  15. package/plugins/huaweicloud-core/hooks/hooks.json +26 -26
  16. package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +136 -136
  17. package/plugins/huaweicloud-core/safety/policy.json +99 -99
  18. package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +199 -199
  19. package/plugins/huaweicloud-core/skills/huawei-apig/SKILL.md +164 -164
  20. package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +48 -48
  21. package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +50 -50
  22. package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +101 -101
  23. package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +90 -90
  24. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/SKILL.md +190 -190
  25. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/scripts/search-skills.mjs +124 -124
  26. package/plugins/huaweicloud-core/skills/huawei-cts/SKILL.md +55 -55
  27. package/plugins/huaweicloud-core/skills/huawei-dds-dcs/SKILL.md +70 -70
  28. package/plugins/huaweicloud-core/skills/huawei-deployment/SKILL.md +56 -56
  29. package/plugins/huaweicloud-core/skills/huawei-dew/SKILL.md +97 -97
  30. package/plugins/huaweicloud-core/skills/huawei-dew/references/csms-usage.md +29 -29
  31. package/plugins/huaweicloud-core/skills/huawei-dew/references/kms-usage.md +23 -23
  32. package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +185 -185
  33. package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +133 -133
  34. package/plugins/huaweicloud-core/skills/huawei-ecs/references/evs.md +31 -31
  35. package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +55 -55
  36. package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +52 -52
  37. package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +131 -131
  38. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +58 -58
  39. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +71 -71
  40. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/deploy-workflow.md +119 -119
  41. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +142 -142
  42. package/plugins/huaweicloud-core/skills/huawei-gaussdb/SKILL.md +56 -56
  43. package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +65 -65
  44. package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +111 -111
  45. package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +122 -122
  46. package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +56 -56
  47. package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +65 -65
  48. package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +133 -127
  49. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +49 -49
  50. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +26 -26
  51. package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +100 -100
  52. package/plugins/huaweicloud-core/skills/huawei-obs/references/single-file-share.md +40 -40
  53. package/plugins/huaweicloud-core/skills/huawei-obs/references/static-website.md +56 -56
  54. package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +224 -224
  55. package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +135 -134
  56. package/plugins/huaweicloud-core/skills/huawei-smn-dms/SKILL.md +69 -69
  57. package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +84 -84
  58. package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +76 -76
  59. package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +59 -59
  60. package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +50 -50
  61. package/plugins/huaweicloud-core/skills/huawei-waf-aad/SKILL.md +63 -63
  62. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +56 -56
  63. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/agents/openai.yaml +4 -4
  64. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +51 -47
  65. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/agents/openai.yaml +4 -4
  66. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +128 -128
  67. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/agents/openai.yaml +4 -4
  68. package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +110 -95
  69. package/plugins/huaweicloud-core/skills/huaweicloud-core/agents/openai.yaml +4 -4
  70. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +19 -19
  71. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +27 -27
  72. package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +60 -60
  73. package/plugins/huaweicloud-core/skills/huaweicloud-safety/agents/openai.yaml +4 -4
  74. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +83 -83
  75. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/agents/openai.yaml +4 -4
  76. package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +105 -87
  77. package/plugins/huaweicloud-core/src/auth/credentials.mjs +95 -95
  78. package/plugins/huaweicloud-core/src/auth/service.mjs +63 -63
  79. package/plugins/huaweicloud-core/src/hcloud-cli.mjs +265 -265
  80. package/plugins/huaweicloud-core/src/mcp-server.mjs +129 -129
  81. package/plugins/huaweicloud-core/src/proxy/proxy-agent.mjs +155 -0
  82. package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +87 -0
  83. package/plugins/huaweicloud-core/src/risk-rule-engine.mjs +137 -137
  84. package/plugins/huaweicloud-core/src/safety-policy.mjs +302 -302
  85. package/plugins/huaweicloud-core/src/sandbox/hdkitservice-api.mjs +91 -87
  86. package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +162 -153
  87. package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +112 -105
  88. package/plugins/huaweicloud-core/src/search-market.mjs +174 -169
  89. package/plugins/huaweicloud-core/src/setup-cli.mjs +2017 -1594
  90. package/plugins/huaweicloud-core/src/tools.mjs +1008 -993
  91. package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.js +427 -427
  92. package/plugins/huaweicloud-core/src/ws-exec/hwlink-fair-queue.js +132 -132
  93. package/plugins/huaweicloud-core/src/ws-exec/hwlink-multiplexer.js +227 -227
  94. package/plugins/huaweicloud-core/src/ws-exec/hwlink-packet.js +202 -202
  95. package/plugins/huaweicloud-core/src/ws-exec/hwlink-terminal-channel.js +158 -158
  96. package/plugins/huaweicloud-core/src/ws-exec/index.js +19 -19
  97. package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.js +338 -338
@@ -1,23 +1,23 @@
1
- # KMS Usage Guide
2
-
3
- ## Create Key
4
- hcloud KMS CreateKey --key_alias=app-encryption-key --key_description="Application data encryption"
5
-
6
- ## List Keys (metadata only)
7
- hcloud KMS ListKeys
8
-
9
- ## Encrypt (offline preferred)
10
- hcloud KMS EncryptData --key_id=<key-id> --plaintext=<base64-data>
11
-
12
- ## Decrypt (BLOCKED - use runtime)
13
- DO NOT use hcloud KMS DecryptData directly.
14
- Use SDK with KMS client in application runtime.
15
-
16
- ## Key Rotation
17
- - Enable: hcloud KMS EnableKeyRotation --key_id=<key-id>
18
- - Rotation period: 365 days (default)
19
-
20
- ## Key Deletion
21
- - Schedule: hcloud KMS ScheduleKeyDeletion --key_id=<key-id> --pending_days=7
22
- - Cancel during pending window: hcloud KMS CancelKeyDeletion --key_id=<key-id>
23
- - WARNING: After deletion window passes, data encrypted with this key is UNRECOVERABLE
1
+ # KMS Usage Guide
2
+
3
+ ## Create Key
4
+ hcloud KMS CreateKey --key_alias=app-encryption-key --key_description="Application data encryption"
5
+
6
+ ## List Keys (metadata only)
7
+ hcloud KMS ListKeys
8
+
9
+ ## Encrypt (offline preferred)
10
+ hcloud KMS EncryptData --key_id=<key-id> --plaintext=<base64-data>
11
+
12
+ ## Decrypt (BLOCKED - use runtime)
13
+ DO NOT use hcloud KMS DecryptData directly.
14
+ Use SDK with KMS client in application runtime.
15
+
16
+ ## Key Rotation
17
+ - Enable: hcloud KMS EnableKeyRotation --key_id=<key-id>
18
+ - Rotation period: 365 days (default)
19
+
20
+ ## Key Deletion
21
+ - Schedule: hcloud KMS ScheduleKeyDeletion --key_id=<key-id> --pending_days=7
22
+ - Cancel during pending window: hcloud KMS CancelKeyDeletion --key_id=<key-id>
23
+ - WARNING: After deletion window passes, data encrypted with this key is UNRECOVERABLE
@@ -1,185 +1,185 @@
1
- ---
2
- name: huawei-ecs
3
- description: "Use when creating, configuring, managing, or troubleshooting ECS instances on Huawei Cloud. Covers instance creation (hcloud ECS CreateServers), flavor selection, image management, security groups, EIP binding, disk attachment, auto-scaling (AS), and troubleshooting. Triggers on: ECS, instance, flavor, image, security group, EIP, EVS, auto-scaling. NOT for: CCE container workloads (use huawei-cce), BMS bare metal servers."
4
- version: 1
5
- ---
6
-
7
- # Huawei Cloud ECS
8
-
9
- **STOP - Do not answer from general knowledge.** Follow the procedure below.
10
-
11
- Always run `hcloud <Service> <Operation> --help` before constructing commands to discover exact parameter names and requirements.
12
-
13
- ## Overview
14
-
15
- Domain expertise for Huawei Cloud Elastic Cloud Server (ECS). Covers instance lifecycle, flavor selection, image management, networking, storage attachment, auto-scaling, and troubleshooting.
16
-
17
- ## Prerequisites
18
-
19
- Before creating an ECS instance from scratch, you MUST have:
20
- - A VPC (see `huawei-vpc`)
21
- - A subnet with DNS configured (see `huawei-vpc`)
22
- - A security group with application ports open (see `huawei-vpc`)
23
-
24
- If these do not exist, load the `huawei-vpc` skill first and create them before returning here.
25
-
26
- ## Critical Warnings
27
-
28
- | Trap | Why |
29
- |------|-----|
30
- | Flavor not in region | Not all flavors available everywhere. Check with ECS ListFlavors first |
31
- | Security group denies all | New SGs deny ALL inbound. Must explicitly add rules |
32
- | EIP bills when idle | Unattached EIP still incurs charges |
33
- | Stopped instance still bills | Pay-per-use instances bill when stopped (unless shutdown-no-billing flavor) |
34
- | Disk survives instance delete | Deleting instance does NOT delete system disk by default |
35
-
36
- ## Flavor Selection Guide
37
-
38
- Flavor families are **region-dependent**. Always run `hcloud ECS ListFlavors --cli-region=<r>` to discover available flavors before recommending.
39
-
40
- | Scenario | Family | What to look for |
41
- |----------|--------|-----------------|
42
- | Web app / microservices | General-purpose (ac, s, sn, c) | 2-4 vCPU, 4-8 GB RAM |
43
- | Database / big data | Memory-optimized (m, r) | 4-8 vCPU, 16-64 GB RAM |
44
- | AI inference | GPU (g, p) | 8+ vCPU, 64+ GB RAM + GPU |
45
- | HPC | High-IO (h, ir, i) | 8+ vCPU, local SSD |
46
-
47
- > See `references/flavors.md` for discovery workflow. **Do not hardcode flavor names** — availability changes by region and over time.
48
-
49
- ## Common Workflows
50
-
51
- | Task | Command | Steps |
52
- |------|---------|-------|
53
- | List flavors | hcloud ECS ListFlavors --cli-region=<region> | references/flavors.md |
54
- | Create instance | hcloud ECS CreateServers --server.name=<n> --server.flavorRef=<id> --server.imageRef=<id> --server.nics.1.subnet_id=<id> --server.availability_zone=<az> | references/create-instance.md |
55
- | Find by name | See "How to search for instances" below | |
56
- | Bind EIP | hcloud EIP AssociatePublicips --publicip_id=<id> --publicip.associate_instance_id=<port-id> --publicip.associate_instance_type=PORT | Get port ID from `hcloud ECS ListServersDetails --server_id=<id>` → `OS-EXT-IPS:port_id` |
57
- | Security group rule | hcloud VPC CreateSecurityGroupRule --security_group_id=<id> --direction=<direction> --protocol=<protocol> | references/sg.md |
58
- | Attach disk | hcloud EVS AttachVolume --volume_id=<id> --server_id=<id> | references/evs.md |
59
- | Delete instance | hcloud ECS DeleteServers --servers.1.id=<id> --delete_publicip=true --delete_volume=true | references/create-instance.md |
60
- | Reboot instance | hcloud ECS BatchRebootServers --reboot.servers.1.id=<id> --reboot.type=SOFT | NOT `RebootServer` — that operation does not exist |
61
-
62
- ## How to Search for Instances
63
-
64
- `ListServersDetails` supports `--name` for exact match only. For fuzzy search:
65
-
66
- 1. List all instances: `hcloud ECS ListServersDetails --cli-region=<region> --limit=100`
67
- 2. Filter client-side by name substring, tag, or status
68
- 3. Use `--server_tags` filter if instances are tagged: `hcloud ECS ListServersDetails --server_tags.1.key=Project`
69
-
70
- > **Return structure**: `ListServersDetails` returns `{"servers": [...]}` (array), NOT `{"server": ...}`. Parse as `.servers[0].status`, NOT `.server.status`.
71
-
72
- Abort if the result set is larger than `--limit` and ask the user to narrow the search.
73
-
74
- ## Instance Status Polling
75
-
76
- ECS creation is asynchronous. Status transitions: `BUILD` → `ACTIVE` (or `ERROR`). Wait times vary widely (20s–3min), never use fixed sleep.
77
-
78
- Poll strategy:
79
-
80
- ```bash
81
- for i in $(seq 1 30); do
82
- status=$(hcloud ECS ListServersDetails --cli-region=<region> --server_id=<id> --cli-output=json | jq -r '.servers[0].status')
83
- if [ "$status" = "ACTIVE" ]; then break; fi
84
- if [ "$status" = "ERROR" ]; then echo "Creation failed"; exit 1; fi
85
- sleep 10
86
- done
87
- ```
88
-
89
- - Poll interval: 10 seconds
90
- - Maximum wait: 5 minutes (30 iterations)
91
- - Check for `ERROR` status to detect creation failures early
92
-
93
- ## SSH Connection Verification
94
-
95
- After ECS is ACTIVE and EIP is bound, verify SSH connectivity:
96
-
97
- ```bash
98
- hcloud ECS ListServersDetails --cli-region=<region> --server_id=<id>
99
- # → addresses.<vpc-id>[].OS-EXT-IPS:addr
100
-
101
- ssh -o StrictHostKeyChecking=accept-new -i <path-to-private-key> root@<eip-address>
102
- ```
103
-
104
- > **SSH verification checklist**: EIP bound → security group has port 22 ingress → keypair private key saved locally → known_hosts handled with `StrictHostKeyChecking=accept-new` (or delete stale entries with `ssh-keygen -R <ip>`).
105
-
106
- ### Running Commands Inside the Instance
107
-
108
- Use SSH for any in-instance operations (install software, check logs, start services):
109
-
110
- ```bash
111
- ssh -o StrictHostKeyChecking=accept-new -i <key> root@<eip> 'command'
112
- ```
113
-
114
- Example — re-run failed cloud-init setup manually:
115
- ```bash
116
- ssh -o StrictHostKeyChecking=accept-new -i <key> root@<eip> 'dnf install -y nginx && systemctl enable --now nginx'
117
- ```
118
-
119
- > If SCP blocks SSH, use cloud-init `--server.user_data` for full deployment instead. See `references/create-instance.md` §Bootstrap.
120
-
121
- ## Deleting Instances
122
-
123
- - Show the user the exact command and get explicit approval before running
124
- - By default, `--delete_publicip` and `--delete_volume` are **false** — public IP and system disk survive deletion
125
- - Set both to `true` to avoid orphaned resources and unexpected billing
126
- - Data disks ARE deleted by default (unlike system disk)
127
-
128
- ## Troubleshooting
129
-
130
- | Error | Root Cause -> Fix |
131
- |-------|------------------|
132
- | Cannot SSH | SG missing port 22 or no EIP -> Add ingress rule / Bind EIP |
133
- | Flavor unavailable | Region limitation -> ListFlavors in target region |
134
- | Insufficient resources | Stock depleted -> Change flavor or AZ |
135
- | AuthFailure | Expired AK/SK -> re-run `npx huaweicloud-devkit auth init` |
136
- | APIGW.0802 / region permission | IAM user has no access to this region -> IAM console → User → Permissions → add region, or switch to another region |
137
- | Cannot SSH (port 22 open) | SCP policy may be blocking SSH. Check `SYS.0403` errors in command output -> Use cloud-init/user_data for initial setup instead. See `references/create-instance.md` §Bootstrap |
138
-
139
- ## Security Considerations
140
-
141
- - MUST use security groups, not iptables
142
- - MUST store SSH keys in DEW, never in user-data
143
- - SHOULD enable CTS audit logging
144
- - MUST NOT open 0.0.0.0/0 for SSH
145
-
146
- ## MCP Tools
147
-
148
- Prefer these tools over raw hcloud CLI — they enforce safety policies:
149
-
150
- - huaweicloud_list_operations service=ECS
151
- - huaweicloud_run_readonly_command for discovery (auto-redacts output)
152
- - huaweicloud_plan_cli_command for command planning (returns command text + safety classification)
153
- - huaweicloud_run_approved_command for writes (requires exact command approval)
154
- - huaweicloud_check_cli to verify hcloud is available
155
-
156
- > **approvedCommand trap**: `huaweicloud_run_approved_command` validates that `approvedCommand` matches the planned command EXACTLY (including `<redacted>` placeholders). Always use the `command` field value returned by `huaweicloud_plan_cli_command` verbatim — never reconstruct or retype it. Mismatches cause rejection with "approvedCommand must exactly match the planned hcloud command."
157
-
158
- ## Without MCP (Fallback)
159
-
160
- If MCP tools are NOT available (new install, session not restarted):
161
- - Raw hcloud commands WILL appear in shell history — passwords and secrets are at risk
162
- - Always use key_name instead of adminPass
163
- - Verify safety manually: no secret value reads, no credential file access
164
- - Restart session as soon as possible to enable safety policies
165
-
166
- ## Without MCP
167
-
168
- Fall back to hcloud CLI. State: "MCP unavailable, using local hcloud CLI."
169
-
170
- ## Flexus (Lightweight ECS)
171
-
172
- Flexus is the lightweight ECS family. Two variants:
173
-
174
- | Variant | API | CLI | Billing |
175
- |---------|-----|:---:|---------|
176
- | **Flexus L** | HCSS (hcss:lightInstances) | ❌ No hcloud — Python SDK only | Prepaid only |
177
- | **Flexus X** | Standard ECS API | ✅ `hcloud ECS` with `x1.*` flavors | On-demand & prepaid |
178
-
179
- For Flexus X, use standard ECS CreateServers flow with `x1.*` flavors. For Flexus L, manual console provisioning is recommended — no KooCLI path exists.
180
-
181
- ## References
182
-
183
- - ECS Docs: https://support.huaweicloud.com/ecs/
184
- - Flavor specs: references/flavors.md
185
- - Create instance: references/create-instance.md
1
+ ---
2
+ name: huawei-ecs
3
+ description: "Use when creating, configuring, managing, or troubleshooting ECS instances on Huawei Cloud. Covers instance creation (hcloud ECS CreateServers), flavor selection, image management, security groups, EIP binding, disk attachment, auto-scaling (AS), and troubleshooting. Triggers on: ECS, instance, flavor, image, security group, EIP, EVS, auto-scaling. NOT for: CCE container workloads (use huawei-cce), BMS bare metal servers."
4
+ version: 1
5
+ ---
6
+
7
+ # Huawei Cloud ECS
8
+
9
+ **STOP - Do not answer from general knowledge.** Follow the procedure below.
10
+
11
+ Always run `hcloud <Service> <Operation> --help` before constructing commands to discover exact parameter names and requirements.
12
+
13
+ ## Overview
14
+
15
+ Domain expertise for Huawei Cloud Elastic Cloud Server (ECS). Covers instance lifecycle, flavor selection, image management, networking, storage attachment, auto-scaling, and troubleshooting.
16
+
17
+ ## Prerequisites
18
+
19
+ Before creating an ECS instance from scratch, you MUST have:
20
+ - A VPC (see `huawei-vpc`)
21
+ - A subnet with DNS configured (see `huawei-vpc`)
22
+ - A security group with application ports open (see `huawei-vpc`)
23
+
24
+ If these do not exist, load the `huawei-vpc` skill first and create them before returning here.
25
+
26
+ ## Critical Warnings
27
+
28
+ | Trap | Why |
29
+ |------|-----|
30
+ | Flavor not in region | Not all flavors available everywhere. Check with ECS ListFlavors first |
31
+ | Security group denies all | New SGs deny ALL inbound. Must explicitly add rules |
32
+ | EIP bills when idle | Unattached EIP still incurs charges |
33
+ | Stopped instance still bills | Pay-per-use instances bill when stopped (unless shutdown-no-billing flavor) |
34
+ | Disk survives instance delete | Deleting instance does NOT delete system disk by default |
35
+
36
+ ## Flavor Selection Guide
37
+
38
+ Flavor families are **region-dependent**. Always run `hcloud ECS ListFlavors --cli-region=<r>` to discover available flavors before recommending.
39
+
40
+ | Scenario | Family | What to look for |
41
+ |----------|--------|-----------------|
42
+ | Web app / microservices | General-purpose (ac, s, sn, c) | 2-4 vCPU, 4-8 GB RAM |
43
+ | Database / big data | Memory-optimized (m, r) | 4-8 vCPU, 16-64 GB RAM |
44
+ | AI inference | GPU (g, p) | 8+ vCPU, 64+ GB RAM + GPU |
45
+ | HPC | High-IO (h, ir, i) | 8+ vCPU, local SSD |
46
+
47
+ > See `references/flavors.md` for discovery workflow. **Do not hardcode flavor names** — availability changes by region and over time.
48
+
49
+ ## Common Workflows
50
+
51
+ | Task | Command | Steps |
52
+ |------|---------|-------|
53
+ | List flavors | hcloud ECS ListFlavors --cli-region=<region> | references/flavors.md |
54
+ | Create instance | hcloud ECS CreateServers --server.name=<n> --server.flavorRef=<id> --server.imageRef=<id> --server.nics.1.subnet_id=<id> --server.availability_zone=<az> | references/create-instance.md |
55
+ | Find by name | See "How to search for instances" below | |
56
+ | Bind EIP | hcloud EIP AssociatePublicips --publicip_id=<id> --publicip.associate_instance_id=<port-id> --publicip.associate_instance_type=PORT | Get port ID from `hcloud ECS ListServersDetails --server_id=<id>` → `OS-EXT-IPS:port_id` |
57
+ | Security group rule | hcloud VPC CreateSecurityGroupRule --security_group_id=<id> --direction=<direction> --protocol=<protocol> | references/sg.md |
58
+ | Attach disk | hcloud EVS AttachVolume --volume_id=<id> --server_id=<id> | references/evs.md |
59
+ | Delete instance | hcloud ECS DeleteServers --servers.1.id=<id> --delete_publicip=true --delete_volume=true | references/create-instance.md |
60
+ | Reboot instance | hcloud ECS BatchRebootServers --reboot.servers.1.id=<id> --reboot.type=SOFT | NOT `RebootServer` — that operation does not exist |
61
+
62
+ ## How to Search for Instances
63
+
64
+ `ListServersDetails` supports `--name` for exact match only. For fuzzy search:
65
+
66
+ 1. List all instances: `hcloud ECS ListServersDetails --cli-region=<region> --limit=100`
67
+ 2. Filter client-side by name substring, tag, or status
68
+ 3. Use `--server_tags` filter if instances are tagged: `hcloud ECS ListServersDetails --server_tags.1.key=Project`
69
+
70
+ > **Return structure**: `ListServersDetails` returns `{"servers": [...]}` (array), NOT `{"server": ...}`. Parse as `.servers[0].status`, NOT `.server.status`.
71
+
72
+ Abort if the result set is larger than `--limit` and ask the user to narrow the search.
73
+
74
+ ## Instance Status Polling
75
+
76
+ ECS creation is asynchronous. Status transitions: `BUILD` → `ACTIVE` (or `ERROR`). Wait times vary widely (20s–3min), never use fixed sleep.
77
+
78
+ Poll strategy:
79
+
80
+ ```bash
81
+ for i in $(seq 1 30); do
82
+ status=$(hcloud ECS ListServersDetails --cli-region=<region> --server_id=<id> --cli-output=json | jq -r '.servers[0].status')
83
+ if [ "$status" = "ACTIVE" ]; then break; fi
84
+ if [ "$status" = "ERROR" ]; then echo "Creation failed"; exit 1; fi
85
+ sleep 10
86
+ done
87
+ ```
88
+
89
+ - Poll interval: 10 seconds
90
+ - Maximum wait: 5 minutes (30 iterations)
91
+ - Check for `ERROR` status to detect creation failures early
92
+
93
+ ## SSH Connection Verification
94
+
95
+ After ECS is ACTIVE and EIP is bound, verify SSH connectivity:
96
+
97
+ ```bash
98
+ hcloud ECS ListServersDetails --cli-region=<region> --server_id=<id>
99
+ # → addresses.<vpc-id>[].OS-EXT-IPS:addr
100
+
101
+ ssh -o StrictHostKeyChecking=accept-new -i <path-to-private-key> root@<eip-address>
102
+ ```
103
+
104
+ > **SSH verification checklist**: EIP bound → security group has port 22 ingress → keypair private key saved locally → known_hosts handled with `StrictHostKeyChecking=accept-new` (or delete stale entries with `ssh-keygen -R <ip>`).
105
+
106
+ ### Running Commands Inside the Instance
107
+
108
+ Use SSH for any in-instance operations (install software, check logs, start services):
109
+
110
+ ```bash
111
+ ssh -o StrictHostKeyChecking=accept-new -i <key> root@<eip> 'command'
112
+ ```
113
+
114
+ Example — re-run failed cloud-init setup manually:
115
+ ```bash
116
+ ssh -o StrictHostKeyChecking=accept-new -i <key> root@<eip> 'dnf install -y nginx && systemctl enable --now nginx'
117
+ ```
118
+
119
+ > If SCP blocks SSH, use cloud-init `--server.user_data` for full deployment instead. See `references/create-instance.md` §Bootstrap.
120
+
121
+ ## Deleting Instances
122
+
123
+ - Show the user the exact command and get explicit approval before running
124
+ - By default, `--delete_publicip` and `--delete_volume` are **false** — public IP and system disk survive deletion
125
+ - Set both to `true` to avoid orphaned resources and unexpected billing
126
+ - Data disks ARE deleted by default (unlike system disk)
127
+
128
+ ## Troubleshooting
129
+
130
+ | Error | Root Cause -> Fix |
131
+ |-------|------------------|
132
+ | Cannot SSH | SG missing port 22 or no EIP -> Add ingress rule / Bind EIP |
133
+ | Flavor unavailable | Region limitation -> ListFlavors in target region |
134
+ | Insufficient resources | Stock depleted -> Change flavor or AZ |
135
+ | AuthFailure | Expired AK/SK -> re-run `npx huaweicloud-devkit auth init` |
136
+ | APIGW.0802 / region permission | IAM user has no access to this region -> IAM console → User → Permissions → add region, or switch to another region |
137
+ | Cannot SSH (port 22 open) | SCP policy may be blocking SSH. Check `SYS.0403` errors in command output -> Use cloud-init/user_data for initial setup instead. See `references/create-instance.md` §Bootstrap |
138
+
139
+ ## Security Considerations
140
+
141
+ - MUST use security groups, not iptables
142
+ - MUST store SSH keys in DEW, never in user-data
143
+ - SHOULD enable CTS audit logging
144
+ - MUST NOT open 0.0.0.0/0 for SSH
145
+
146
+ ## MCP Tools
147
+
148
+ Prefer these tools over raw hcloud CLI — they enforce safety policies:
149
+
150
+ - huaweicloud_list_operations service=ECS
151
+ - huaweicloud_run_readonly_command for discovery (auto-redacts output)
152
+ - huaweicloud_plan_cli_command for command planning (returns command text + safety classification)
153
+ - huaweicloud_run_approved_command for writes (requires exact command approval)
154
+ - huaweicloud_check_cli to verify hcloud is available
155
+
156
+ > **approvedCommand trap**: `huaweicloud_run_approved_command` validates that `approvedCommand` matches the planned command EXACTLY (including `<redacted>` placeholders). Always use the `command` field value returned by `huaweicloud_plan_cli_command` verbatim — never reconstruct or retype it. Mismatches cause rejection with "approvedCommand must exactly match the planned hcloud command."
157
+
158
+ ## Without MCP (Fallback)
159
+
160
+ If MCP tools are NOT available (new install, session not restarted):
161
+ - Raw hcloud commands WILL appear in shell history — passwords and secrets are at risk
162
+ - Always use key_name instead of adminPass
163
+ - Verify safety manually: no secret value reads, no credential file access
164
+ - Restart session as soon as possible to enable safety policies
165
+
166
+ ## Without MCP
167
+
168
+ Fall back to hcloud CLI. State: "MCP unavailable, using local hcloud CLI."
169
+
170
+ ## Flexus (Lightweight ECS)
171
+
172
+ Flexus is the lightweight ECS family. Two variants:
173
+
174
+ | Variant | API | CLI | Billing |
175
+ |---------|-----|:---:|---------|
176
+ | **Flexus L** | HCSS (hcss:lightInstances) | ❌ No hcloud — Python SDK only | Prepaid only |
177
+ | **Flexus X** | Standard ECS API | ✅ `hcloud ECS` with `x1.*` flavors | On-demand & prepaid |
178
+
179
+ For Flexus X, use standard ECS CreateServers flow with `x1.*` flavors. For Flexus L, manual console provisioning is recommended — no KooCLI path exists.
180
+
181
+ ## References
182
+
183
+ - ECS Docs: https://support.huaweicloud.com/ecs/
184
+ - Flavor specs: references/flavors.md
185
+ - Create instance: references/create-instance.md