compshare-cli 0.3.1__tar.gz → 0.3.3__tar.gz

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 (51) hide show
  1. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/PKG-INFO +84 -18
  2. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/README.md +83 -17
  3. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/pyproject.toml +1 -1
  4. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/__init__.py +1 -1
  5. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/actions.py +15 -7
  6. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/api.py +0 -4
  7. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/cli.py +100 -42
  8. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/commands/common.py +25 -2
  9. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/commands/image.py +104 -42
  10. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/commands/instance.py +696 -90
  11. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/commands/storage.py +11 -36
  12. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/commands/team.py +19 -4
  13. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/i18n.py +107 -6
  14. compshare_cli-0.3.3/src/compshare_cli/instance_templates.py +202 -0
  15. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/location.py +38 -21
  16. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/output.py +22 -3
  17. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/ssh.py +136 -10
  18. compshare_cli-0.3.3/src/compshare_cli/ssh_cache.py +218 -0
  19. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli.egg-info/PKG-INFO +84 -18
  20. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli.egg-info/SOURCES.txt +5 -1
  21. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_actions.py +10 -5
  22. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_cli.py +979 -113
  23. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_feedback.py +1 -0
  24. compshare_cli-0.3.3/tests/test_instance_templates.py +73 -0
  25. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_location.py +47 -0
  26. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_output.py +13 -0
  27. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_ssh.py +42 -0
  28. compshare_cli-0.3.3/tests/test_ssh_cache.py +47 -0
  29. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/LICENSE +0 -0
  30. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/setup.cfg +0 -0
  31. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/__main__.py +0 -0
  32. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/commands/__init__.py +0 -0
  33. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/commands/ask.py +0 -0
  34. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/commands/doctor.py +0 -0
  35. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/commands/feedback.py +0 -0
  36. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/config.py +0 -0
  37. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/errors.py +0 -0
  38. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/insights.py +0 -0
  39. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/parsing.py +0 -0
  40. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/qa.py +0 -0
  41. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/runtime.py +0 -0
  42. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli/sdk.py +0 -0
  43. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli.egg-info/dependency_links.txt +0 -0
  44. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli.egg-info/entry_points.txt +0 -0
  45. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli.egg-info/requires.txt +0 -0
  46. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/src/compshare_cli.egg-info/top_level.txt +0 -0
  47. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_api.py +0 -0
  48. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_config.py +0 -0
  49. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_parsing.py +0 -0
  50. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_qa.py +0 -0
  51. {compshare_cli-0.3.1 → compshare_cli-0.3.3}/tests/test_sdk.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compshare-cli
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Command-line client for CompShare GPU compute
5
5
  Author: CompShare
6
6
  License-Expression: Apache-2.0
@@ -35,13 +35,14 @@ Dynamic: license-file
35
35
  - 可通过 `compshare feedback` 反馈 CLI 问题和建议
36
36
  - 基于官方 [`ucloud-sdk-python3`](https://github.com/ucloud/ucloud-sdk-python3)
37
37
 
38
- 当前版本:`0.3.1`,要求 Python 3.9 或更高版本。
38
+ 当前版本:`0.3.3`,要求 Python 3.9 或更高版本。
39
39
 
40
40
  ## 安装
41
41
 
42
42
  ```bash
43
43
  pip install compshare-cli
44
44
  compshare -h
45
+ compshare --version
45
46
  ```
46
47
 
47
48
  本地开发:
@@ -101,6 +102,11 @@ compshare instance search --region cn-sh2 --zone cn-sh2-02 \
101
102
  --gpu 4090 --image IMAGE_ID --available
102
103
  compshare instance list --all
103
104
 
105
+ # 聚焦查看实例信息;多个分组可组合
106
+ compshare instance show INSTANCE_ID --ip --softwares
107
+ compshare instance show INSTANCE_ID --spec --disks --billing
108
+ compshare instance show INSTANCE_ID --image --status
109
+
104
110
  # 交互式创建
105
111
  compshare instance create
106
112
 
@@ -116,9 +122,15 @@ compshare instance ssh INSTANCE_ID --no-auto-password
116
122
  # 自动登录后执行远程命令;远程参数用 -- 与 CLI 选项分隔
117
123
  compshare instance ssh INSTANCE_ID -- nvidia-smi --query-gpu=name
118
124
  compshare instance ssh INSTANCE_ID -- 'cd /workspace && python train.py'
119
- # 上传本地文件或目录,目录会自动递归复制
120
- compshare instance scp INSTANCE_ID ./model.bin /workspace/model.bin
121
- compshare instance scp INSTANCE_ID ./dataset /workspace/dataset
125
+ # Agent/脚本:执行并返回 ok、phase、exit_code、stdout、stderr、error
126
+ compshare --json instance ssh INSTANCE_ID -- nvidia-smi
127
+ # 强制刷新或禁用本地 SSH 连接缓存
128
+ compshare instance ssh INSTANCE_ID --refresh
129
+ compshare instance ssh INSTANCE_ID --no-cache
130
+ # 在本地与实例间双向复制;实例路径以 : 开头,目录会自动递归复制
131
+ compshare instance cp INSTANCE_ID ./model.bin :/workspace/model.bin
132
+ compshare instance cp INSTANCE_ID ./dataset :/workspace/dataset
133
+ compshare instance cp INSTANCE_ID :/workspace/result ./result
122
134
 
123
135
  # 产品问答
124
136
  compshare ask "按量实例关机以后,云硬盘还收费吗?"
@@ -143,16 +155,44 @@ compshare instance create \
143
155
 
144
156
  使用 `--dry-run` 只检查库存、价格和请求,不创建资源。
145
157
 
158
+ 本地实例模板可以保存常用创建参数,不依赖控制台或后端模板接口:
159
+
160
+ ```bash
161
+ compshare instance template create training-4090 \
162
+ --description '4090 训练环境' \
163
+ --gpu 4090 \
164
+ --count 1 \
165
+ --cpu 16 \
166
+ --memory 64GiB \
167
+ --image IMAGE_ID \
168
+ --region cn-sh2 \
169
+ --zone cn-sh2-02 \
170
+ --disk 100GiB \
171
+ --charge Postpay
172
+
173
+ compshare instance template list
174
+ compshare instance template show training-4090
175
+ compshare instance create --template training-4090 --yes
176
+
177
+ # 本次显式参数优先于模板值
178
+ compshare instance create --template training-4090 --cpu 32 --memory 128GiB --yes
179
+ ```
180
+
181
+ 模板存放在 `~/.config/compshare/instance-templates.json`;可用
182
+ `compshare instance template path` 查看实际路径。模板只保存实例创建参数,不保存 API
183
+ 凭证、`--yes`、`--show-sensitive` 或其他执行控制选项。
184
+
146
185
  ## 功能入口
147
186
 
148
187
  ```text
188
+ compshare config API 凭证配置
189
+ compshare feedback 反馈 CLI 问题或建议
190
+ compshare doctor 配置、鉴权、网络与 SSH 环境诊断
191
+ compshare ask 产品使用和计费问答
149
192
  compshare instance GPU 实例、规格、库存、价格和生命周期
150
193
  compshare image 平台、自定义、社区及共享镜像
151
194
  compshare storage 云盘和 US3 挂载
152
195
  compshare team 团队、邀请、成员额度、账单和审计
153
- compshare doctor 配置、鉴权、网络与 SSH 环境诊断
154
- compshare ask 产品使用和计费问答
155
- compshare feedback 反馈 CLI 问题或建议
156
196
  ```
157
197
 
158
198
  ## 产品问答
@@ -186,53 +226,79 @@ compshare instance -h
186
226
  compshare instance create -h
187
227
  ```
188
228
 
229
+ ## 命令补全
230
+
231
+ CLI 支持 Bash、Zsh、Fish 和 PowerShell 命令补全。为当前 Shell 自动安装:
232
+
233
+ ```bash
234
+ compshare --install-completion
235
+ ```
236
+
237
+ 如需检查、复制或自行加载补全脚本:
238
+
239
+ ```bash
240
+ compshare --show-completion
241
+ ```
242
+
189
243
  ## 脚本调用
190
244
 
191
245
  `--json`、`--profile` 和 `--show-sensitive` 是全局选项,必须放在子命令前:
192
246
 
193
247
  ```bash
194
248
  compshare --json instance list --status Running --all
195
- compshare --profile production image list --source community --region cn-sh2 --zone cn-sh2-02
249
+ compshare --profile production image list --source community
196
250
  compshare --json --show-sensitive instance show uhost-xxxxxxxx
197
251
  ```
198
252
 
199
253
  JSON 模式不会启动交互向导。生命周期操作可使用 `--wait`、`--no-wait` 和
200
254
  `--timeout` 控制等待行为;部分批量操作失败时,CLI 返回非零退出码。默认输出会递归隐藏
201
255
  密码、IP、访问 URL 和登录命令;只有显式指定 `--show-sensitive` 才会输出原值。
256
+ `instance show` 可使用 `--ip`、`--softwares`、`--spec`、`--disks`、`--billing`、
257
+ `--image` 和 `--status` 聚焦输出一个或多个信息分组;不传这些选项时保持完整摘要。
202
258
 
203
259
  Region 和 Zone 是资源参数,放在对应子命令后:
204
260
 
205
261
  ```bash
206
- compshare instance list --region cn-sh2
262
+ compshare instance list --region cn-sh2 --zone cn-sh2-02
207
263
  compshare instance create --region cn-sh2 --zone cn-sh2-02
208
- compshare image list --source custom --region cn-sh2 --zone cn-sh2-02
264
+ compshare image list --source custom
265
+ compshare storage disk list
209
266
  ```
210
267
 
211
- CLI 不保存或自动注入默认 Region/Zone。非交互式地域资源操作需要显式传入;按实例 ID
268
+ 镜像列表、网络检测和软件端口列表可进行全局查询,Region/Zone 只是可选过滤条件。CLI
269
+ 不保存或自动注入默认 Region/Zone;确实依赖地域的资源操作仍需显式传入。按实例 ID
212
270
  执行的生命周期操作使用 `DescribeCompShareInstance` 响应中的 Region 和 Zone;响应缺少任一
213
271
  字段时会停止操作,不会从 Zone 推导或用请求 Region 补齐。
214
272
 
215
273
  ## 语言
216
274
 
217
275
  ```bash
218
- compshare lang en
219
- compshare lang zh
220
- compshare lang # 查看当前语言
276
+ compshare --lang en --help
277
+ compshare --lang zh --help
221
278
  ```
222
279
 
223
- 也可以通过 `COMPSHARE_LANG=en` 临时覆盖。
280
+ `--lang` 会保存所选语言,后续命令继续使用;也可以通过 `COMPSHARE_LANG=en` 临时覆盖。
224
281
 
225
282
  ## 安全说明
226
283
 
227
284
  - 配置目录和文件分别使用 `0700`、`0600` 权限。
285
+ - 本地实例模板文件同样使用 `0600` 权限,所在目录使用 `0700` 权限。
228
286
  - API 私钥不会出现在命令输出中。
229
287
  - 默认使用 `***` 隐藏密码、私钥、IP、访问 URL、令牌和登录命令,包括嵌套 JSON 字段。
230
288
  - `instance ssh` 在支持的交互式终端中通过伪终端自动填写登录密码,不会打印密码或将其放入进程参数。
231
289
  - 自动登录会接受首次出现的 SSH 主机密钥;已记录主机的密钥发生变化时仍会拒绝连接。
232
290
  - `instance ssh INSTANCE_ID -- COMMAND` 可非交互执行远程命令,透传命令输出和退出码。
233
- - `instance scp INSTANCE_ID LOCAL_PATH REMOTE_PATH` 可自动认证并上传本地文件或目录。
291
+ - `--json instance ssh INSTANCE_ID -- COMMAND` 会真实执行命令,并结构化返回退出码、标准输出、标准错误及连接/认证错误阶段。
292
+ - `--json` 始终以 UTF-8 字节输出,不依赖 Windows 活动代码页或终端编码。
293
+ - `instance ssh` 默认将 API 返回的 SSH 命令和密码按 profile/实例缓存 1 小时;Windows 使用当前用户的 DPAPI 加密密码,其他平台将缓存文件权限限制为当前用户。可用 `--refresh` 强制更新、`--no-cache` 禁用;重置密码和重装实例会清除对应缓存。
294
+ - 实例创建是异步操作;`instance create` 默认等待到 `Running`,显式使用 `--no-wait` 才会在创建接口返回后立即退出。`instance ssh` 也会默认等待实例运行后再连接。
295
+ - `instance cp INSTANCE_ID SOURCE DESTINATION` 可自动认证并双向复制文件或目录;实例侧路径
296
+ 使用 `:/path` 表示。旧的 `instance scp INSTANCE_ID LOCAL_PATH REMOTE_PATH` 上传语法继续兼容。
297
+ - `--json instance cp ...` 会真实执行复制,并返回 `ok`、`phase`、`exit_code`、
298
+ `stdout`、`stderr` 和 `error`;只有显式使用 `--print` 才仅输出命令。
234
299
  - `--show-sensitive` 会恢复这些字段的原始值;请勿在共享终端、CI 日志或 Agent 会话中使用。
235
- - 删除、关机、重启、重装和改配等操作默认要求确认。
300
+ - 删除、关机、重启、重装和改配等操作默认要求输入 `y` 或 `n` 确认;空输入或无效输入
301
+ 最多重试三次。JSON 模式不启动确认提示,执行这类操作必须显式使用 `--yes`。
236
302
 
237
303
  ## 开发校验
238
304
 
@@ -10,13 +10,14 @@
10
10
  - 可通过 `compshare feedback` 反馈 CLI 问题和建议
11
11
  - 基于官方 [`ucloud-sdk-python3`](https://github.com/ucloud/ucloud-sdk-python3)
12
12
 
13
- 当前版本:`0.3.1`,要求 Python 3.9 或更高版本。
13
+ 当前版本:`0.3.3`,要求 Python 3.9 或更高版本。
14
14
 
15
15
  ## 安装
16
16
 
17
17
  ```bash
18
18
  pip install compshare-cli
19
19
  compshare -h
20
+ compshare --version
20
21
  ```
21
22
 
22
23
  本地开发:
@@ -76,6 +77,11 @@ compshare instance search --region cn-sh2 --zone cn-sh2-02 \
76
77
  --gpu 4090 --image IMAGE_ID --available
77
78
  compshare instance list --all
78
79
 
80
+ # 聚焦查看实例信息;多个分组可组合
81
+ compshare instance show INSTANCE_ID --ip --softwares
82
+ compshare instance show INSTANCE_ID --spec --disks --billing
83
+ compshare instance show INSTANCE_ID --image --status
84
+
79
85
  # 交互式创建
80
86
  compshare instance create
81
87
 
@@ -91,9 +97,15 @@ compshare instance ssh INSTANCE_ID --no-auto-password
91
97
  # 自动登录后执行远程命令;远程参数用 -- 与 CLI 选项分隔
92
98
  compshare instance ssh INSTANCE_ID -- nvidia-smi --query-gpu=name
93
99
  compshare instance ssh INSTANCE_ID -- 'cd /workspace && python train.py'
94
- # 上传本地文件或目录,目录会自动递归复制
95
- compshare instance scp INSTANCE_ID ./model.bin /workspace/model.bin
96
- compshare instance scp INSTANCE_ID ./dataset /workspace/dataset
100
+ # Agent/脚本:执行并返回 ok、phase、exit_code、stdout、stderr、error
101
+ compshare --json instance ssh INSTANCE_ID -- nvidia-smi
102
+ # 强制刷新或禁用本地 SSH 连接缓存
103
+ compshare instance ssh INSTANCE_ID --refresh
104
+ compshare instance ssh INSTANCE_ID --no-cache
105
+ # 在本地与实例间双向复制;实例路径以 : 开头,目录会自动递归复制
106
+ compshare instance cp INSTANCE_ID ./model.bin :/workspace/model.bin
107
+ compshare instance cp INSTANCE_ID ./dataset :/workspace/dataset
108
+ compshare instance cp INSTANCE_ID :/workspace/result ./result
97
109
 
98
110
  # 产品问答
99
111
  compshare ask "按量实例关机以后,云硬盘还收费吗?"
@@ -118,16 +130,44 @@ compshare instance create \
118
130
 
119
131
  使用 `--dry-run` 只检查库存、价格和请求,不创建资源。
120
132
 
133
+ 本地实例模板可以保存常用创建参数,不依赖控制台或后端模板接口:
134
+
135
+ ```bash
136
+ compshare instance template create training-4090 \
137
+ --description '4090 训练环境' \
138
+ --gpu 4090 \
139
+ --count 1 \
140
+ --cpu 16 \
141
+ --memory 64GiB \
142
+ --image IMAGE_ID \
143
+ --region cn-sh2 \
144
+ --zone cn-sh2-02 \
145
+ --disk 100GiB \
146
+ --charge Postpay
147
+
148
+ compshare instance template list
149
+ compshare instance template show training-4090
150
+ compshare instance create --template training-4090 --yes
151
+
152
+ # 本次显式参数优先于模板值
153
+ compshare instance create --template training-4090 --cpu 32 --memory 128GiB --yes
154
+ ```
155
+
156
+ 模板存放在 `~/.config/compshare/instance-templates.json`;可用
157
+ `compshare instance template path` 查看实际路径。模板只保存实例创建参数,不保存 API
158
+ 凭证、`--yes`、`--show-sensitive` 或其他执行控制选项。
159
+
121
160
  ## 功能入口
122
161
 
123
162
  ```text
163
+ compshare config API 凭证配置
164
+ compshare feedback 反馈 CLI 问题或建议
165
+ compshare doctor 配置、鉴权、网络与 SSH 环境诊断
166
+ compshare ask 产品使用和计费问答
124
167
  compshare instance GPU 实例、规格、库存、价格和生命周期
125
168
  compshare image 平台、自定义、社区及共享镜像
126
169
  compshare storage 云盘和 US3 挂载
127
170
  compshare team 团队、邀请、成员额度、账单和审计
128
- compshare doctor 配置、鉴权、网络与 SSH 环境诊断
129
- compshare ask 产品使用和计费问答
130
- compshare feedback 反馈 CLI 问题或建议
131
171
  ```
132
172
 
133
173
  ## 产品问答
@@ -161,53 +201,79 @@ compshare instance -h
161
201
  compshare instance create -h
162
202
  ```
163
203
 
204
+ ## 命令补全
205
+
206
+ CLI 支持 Bash、Zsh、Fish 和 PowerShell 命令补全。为当前 Shell 自动安装:
207
+
208
+ ```bash
209
+ compshare --install-completion
210
+ ```
211
+
212
+ 如需检查、复制或自行加载补全脚本:
213
+
214
+ ```bash
215
+ compshare --show-completion
216
+ ```
217
+
164
218
  ## 脚本调用
165
219
 
166
220
  `--json`、`--profile` 和 `--show-sensitive` 是全局选项,必须放在子命令前:
167
221
 
168
222
  ```bash
169
223
  compshare --json instance list --status Running --all
170
- compshare --profile production image list --source community --region cn-sh2 --zone cn-sh2-02
224
+ compshare --profile production image list --source community
171
225
  compshare --json --show-sensitive instance show uhost-xxxxxxxx
172
226
  ```
173
227
 
174
228
  JSON 模式不会启动交互向导。生命周期操作可使用 `--wait`、`--no-wait` 和
175
229
  `--timeout` 控制等待行为;部分批量操作失败时,CLI 返回非零退出码。默认输出会递归隐藏
176
230
  密码、IP、访问 URL 和登录命令;只有显式指定 `--show-sensitive` 才会输出原值。
231
+ `instance show` 可使用 `--ip`、`--softwares`、`--spec`、`--disks`、`--billing`、
232
+ `--image` 和 `--status` 聚焦输出一个或多个信息分组;不传这些选项时保持完整摘要。
177
233
 
178
234
  Region 和 Zone 是资源参数,放在对应子命令后:
179
235
 
180
236
  ```bash
181
- compshare instance list --region cn-sh2
237
+ compshare instance list --region cn-sh2 --zone cn-sh2-02
182
238
  compshare instance create --region cn-sh2 --zone cn-sh2-02
183
- compshare image list --source custom --region cn-sh2 --zone cn-sh2-02
239
+ compshare image list --source custom
240
+ compshare storage disk list
184
241
  ```
185
242
 
186
- CLI 不保存或自动注入默认 Region/Zone。非交互式地域资源操作需要显式传入;按实例 ID
243
+ 镜像列表、网络检测和软件端口列表可进行全局查询,Region/Zone 只是可选过滤条件。CLI
244
+ 不保存或自动注入默认 Region/Zone;确实依赖地域的资源操作仍需显式传入。按实例 ID
187
245
  执行的生命周期操作使用 `DescribeCompShareInstance` 响应中的 Region 和 Zone;响应缺少任一
188
246
  字段时会停止操作,不会从 Zone 推导或用请求 Region 补齐。
189
247
 
190
248
  ## 语言
191
249
 
192
250
  ```bash
193
- compshare lang en
194
- compshare lang zh
195
- compshare lang # 查看当前语言
251
+ compshare --lang en --help
252
+ compshare --lang zh --help
196
253
  ```
197
254
 
198
- 也可以通过 `COMPSHARE_LANG=en` 临时覆盖。
255
+ `--lang` 会保存所选语言,后续命令继续使用;也可以通过 `COMPSHARE_LANG=en` 临时覆盖。
199
256
 
200
257
  ## 安全说明
201
258
 
202
259
  - 配置目录和文件分别使用 `0700`、`0600` 权限。
260
+ - 本地实例模板文件同样使用 `0600` 权限,所在目录使用 `0700` 权限。
203
261
  - API 私钥不会出现在命令输出中。
204
262
  - 默认使用 `***` 隐藏密码、私钥、IP、访问 URL、令牌和登录命令,包括嵌套 JSON 字段。
205
263
  - `instance ssh` 在支持的交互式终端中通过伪终端自动填写登录密码,不会打印密码或将其放入进程参数。
206
264
  - 自动登录会接受首次出现的 SSH 主机密钥;已记录主机的密钥发生变化时仍会拒绝连接。
207
265
  - `instance ssh INSTANCE_ID -- COMMAND` 可非交互执行远程命令,透传命令输出和退出码。
208
- - `instance scp INSTANCE_ID LOCAL_PATH REMOTE_PATH` 可自动认证并上传本地文件或目录。
266
+ - `--json instance ssh INSTANCE_ID -- COMMAND` 会真实执行命令,并结构化返回退出码、标准输出、标准错误及连接/认证错误阶段。
267
+ - `--json` 始终以 UTF-8 字节输出,不依赖 Windows 活动代码页或终端编码。
268
+ - `instance ssh` 默认将 API 返回的 SSH 命令和密码按 profile/实例缓存 1 小时;Windows 使用当前用户的 DPAPI 加密密码,其他平台将缓存文件权限限制为当前用户。可用 `--refresh` 强制更新、`--no-cache` 禁用;重置密码和重装实例会清除对应缓存。
269
+ - 实例创建是异步操作;`instance create` 默认等待到 `Running`,显式使用 `--no-wait` 才会在创建接口返回后立即退出。`instance ssh` 也会默认等待实例运行后再连接。
270
+ - `instance cp INSTANCE_ID SOURCE DESTINATION` 可自动认证并双向复制文件或目录;实例侧路径
271
+ 使用 `:/path` 表示。旧的 `instance scp INSTANCE_ID LOCAL_PATH REMOTE_PATH` 上传语法继续兼容。
272
+ - `--json instance cp ...` 会真实执行复制,并返回 `ok`、`phase`、`exit_code`、
273
+ `stdout`、`stderr` 和 `error`;只有显式使用 `--print` 才仅输出命令。
209
274
  - `--show-sensitive` 会恢复这些字段的原始值;请勿在共享终端、CI 日志或 Agent 会话中使用。
210
- - 删除、关机、重启、重装和改配等操作默认要求确认。
275
+ - 删除、关机、重启、重装和改配等操作默认要求输入 `y` 或 `n` 确认;空输入或无效输入
276
+ 最多重试三次。JSON 模式不启动确认提示,执行这类操作必须显式使用 `--yes`。
211
277
 
212
278
  ## 开发校验
213
279
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "compshare-cli"
7
- version = "0.3.1"
7
+ version = "0.3.3"
8
8
  description = "Command-line client for CompShare GPU compute"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1,3 +1,3 @@
1
1
  """CompShare command-line client."""
2
2
 
3
- __version__ = "0.3.1"
3
+ __version__ = "0.3.3"
@@ -34,8 +34,9 @@ INSTANCE_ACTIONS = frozenset(
34
34
 
35
35
  IMAGE_ACTIONS = frozenset(
36
36
  {
37
- "AddFavoriteImage",
37
+ "CreateCompShareImageFavorite",
38
38
  "CreateCompShareCustomImage",
39
+ "DeleteCompShareImageFavorite",
39
40
  "DescribeCommunityImages",
40
41
  "DescribeCompShareCustomImages",
41
42
  "DescribeCompShareImages",
@@ -47,7 +48,6 @@ IMAGE_ACTIONS = frozenset(
47
48
  "GetCompShareImageCreateProgress",
48
49
  "ModifyCompShareImageShareAccount",
49
50
  "PublishCompShareImage",
50
- "RemoveFavoriteImage",
51
51
  "TerminateCompShareCustomImage",
52
52
  "UpdateCompShareImage",
53
53
  }
@@ -59,6 +59,7 @@ STORAGE_ACTIONS = frozenset(
59
59
  "AttachUS3",
60
60
  "CreateAndAttachCompshareDisk",
61
61
  "DeleteCompshareDisk",
62
+ "DescribeCompshareDisk",
62
63
  "DetachCompshareDisk",
63
64
  "GetCompShareAttachedDiskUpgradePrice",
64
65
  "ResizeCompShareDisk",
@@ -89,9 +90,16 @@ TEAM_ACTIONS = frozenset(
89
90
 
90
91
  PUBLIC_ACTIONS = INSTANCE_ACTIONS | IMAGE_ACTIONS | STORAGE_ACTIONS | TEAM_ACTIONS
91
92
 
92
- # Public API actions intentionally exposed as CLI placeholders until their
93
- # production request contract is ready.
94
- COMING_SOON_ACTIONS = frozenset({"GetCompShareInstanceMonitor"})
93
+ # No unavailable API actions are currently exposed as placeholders.
94
+ COMING_SOON_ACTIONS = frozenset()
95
95
 
96
- # Documented publicly but unavailable in the production API (RetCode 161).
97
- UNAVAILABLE_ACTIONS = frozenset({"DescribeFavoriteImages"})
96
+ # Documented publicly but unavailable in the production API.
97
+ UNAVAILABLE_ACTIONS = frozenset(
98
+ {
99
+ "AddFavoriteImage",
100
+ "DescribeFavoriteImages",
101
+ "GetCompShareInstanceMonitor",
102
+ "GetSoftwareURL",
103
+ "RemoveFavoriteImage",
104
+ }
105
+ )
@@ -228,10 +228,6 @@ def error_hint(action: str, code: int) -> Optional[str]:
228
228
  ("GetCompShareInstanceMonitor", 230): (
229
229
  "This production endpoint is currently incompatible; use the console for monitoring."
230
230
  ),
231
- ("GetSoftwareURL", 230): (
232
- "This production endpoint currently rejects its action; "
233
- "use instance show or the console."
234
- ),
235
231
  }
236
232
  return tr(hints[(action, code)]) if (action, code) in hints else None
237
233