@limecloud/cli 0.0.0-stage → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,293 @@
1
- # Temporary Holding Version
1
+ # @limecloud/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Lime Cloud 官方命令行客户端,提供 `limecloud-cli` 和 `limecloud` 两个命令。命令、参数、请求与响应来自本仓库的公共 OpenAPI,覆盖身份、开放平台、个人账户、运营和平台管理。要求 Node.js 22.12 或更高版本,使用 i18next 处理本地消息,采用 Apache-2.0 许可证。
4
+
5
+ 本仓库新增的安装引导以本轮后续发布的新版本为准;npm 的实际版本和内容以 registry 为准,构建和测试不会自动发布。
6
+
7
+ 本包参考官方 `@larksuite/cli@1.0.98` 的 npm 安装器与原生 REA 证据,提供安装引导、三层命令、Schema 自省、结构化输出、请求预览和设备授权,并按 Lime 的实际公共 API 组织领域。
8
+
9
+ ## 安装与首次使用
10
+
11
+ 手动安装:
12
+
13
+ ```sh
14
+ npx @limecloud/cli@latest install
15
+ ```
16
+
17
+ Agent 自动安装:将以下指令发送给你的 AI 工具。
18
+
19
+ ```text
20
+ 帮我安装 LimeCloud CLI:https://open.limeai.run/docs/zh-CN/cli-installation-guide.md
21
+ ```
22
+
23
+ 英文机器可读指南为 <https://open.limeai.run/docs/cli-installation-guide.md>。
24
+
25
+ `install` 使用 npm 将本次运行的精确包版本安装到用户目录 `~/.local`,然后引导配置已登记的公共 CLI 客户端。缺少 Client ID 时,CLI 从当前身份服务的 `/runtime/v1/cli` 读取公开部署配置;响应必须与本次 Issuer 一致,不发送令牌或 Secret。部署未开放元数据或获取失败时,配置保持 `pending`,按提示向部署管理员获取公共 CLI Client ID 后手动配置。显式 Client ID 和已有配置优先,`--dry-run` 不读取网络元数据。
26
+
27
+ 安装完成后返回可执行文件目录与 PATH 提示;不会改写 shell 配置。用户明确选择后才发起设备授权,终端返回用户码、浏览器确认链接和恢复命令,不自动批准授权。
28
+
29
+ ```sh
30
+ # 自定义安装目录,可用于隔离环境
31
+ npx @limecloud/cli@latest install --prefix "/YOUR/INSTALL/PREFIX"
32
+
33
+ # 仅查看安装与配置计划,不联网、不安装、不保存
34
+ npx @limecloud/cli@latest install --dry-run
35
+
36
+ # 自动化安装:显式配置,保留用户授权步骤
37
+ npx @limecloud/cli@latest install \
38
+ --client-id "YOUR_REGISTERED_PUBLIC_CLI_CLIENT_ID" \
39
+ --issuer "https://YOUR_AUTH_ORIGIN" \
40
+ --api-origin "https://YOUR_API_ORIGIN" \
41
+ --skip-login
42
+ ```
43
+
44
+ 也可用 `LIMECLOUD_INSTALL_PREFIX` 设置安装目录。Windows 的默认目录同样位于当前用户的 `.local`,请通过 npx 执行安装,以复用 npm 的 JavaScript 入口。非交互运行不会询问或自动发起授权;缺少客户端时,结果明确标记配置为 `pending`,按返回命令完成后续步骤。`--no-config` 仅安装,`--login` 显式发起非阻塞设备授权,不能与 `--no-config` 或 `--skip-login` 同用。
45
+
46
+ ```sh
47
+ limecloud-cli config init
48
+ limecloud-cli auth login
49
+ limecloud-cli auth status
50
+ limecloud-cli doctor --offline
51
+ limecloud-cli schema
52
+ ```
53
+
54
+ 安装失败会返回 `installation_failed`,检查 npm 网络和目标目录权限后重试同一命令。安装与配置不创建平台应用、不授予业务权限;CLI 不安装全局 Agent Skills。
55
+
56
+ ## 从仓库运行与分发
57
+
58
+ ```sh
59
+ node "packages/cli/bin/limecloud-cli.mjs" --help
60
+ node "packages/cli/bin/limecloud-cli.mjs" --version
61
+ node "packages/cli/bin/limecloud-cli.mjs" schema
62
+ node "packages/cli/bin/limecloud-cli.mjs" open --help
63
+ node "packages/cli/bin/limecloud-cli.mjs" api list --format table
64
+ ```
65
+
66
+ ```sh
67
+ pnpm --filter @limecloud/cli build
68
+ pnpm --filter @limecloud/cli test
69
+ npm pack "./packages/cli" --pack-destination ".dev/releases"
70
+ ```
71
+
72
+ 打包前需要存在 `.dev/releases/`。`prepack` 从 `contracts/openapi/identity.json` 和 `management.json` 生成随包合同、检查工作区版本,从 `contracts/i18n/locales.json` 复制唯一语言登记并检查对应 CLI 消息资源,再复制根 `LICENSE`。分发包仅包含命令入口、实现、公开合同、语言登记和消息、README 与许可证,不包含凭据、研究产物或测试夹具。npm 包的实际发布状态以 npmjs 为准;本仓库的构建与打包步骤不会自动发布。
73
+
74
+ ## 输出语言
75
+
76
+ ```sh
77
+ limecloud-cli --help --locale zh-CN
78
+ limecloud-cli schema open.application.list --locale zh-CN
79
+ LIMECLOUD_LOCALE=en limecloud-cli api list
80
+ ```
81
+
82
+ 每次命令按 `--locale`、`LIMECLOUD_LOCALE`、`LC_ALL`、`LC_MESSAGES`、`LANG`、英文默认值的顺序协商。显式不支持的 `--locale` 会在读取凭据或请求网络前报错;环境语言未知时回退英文。POSIX 环境中的编码/修饰后缀会被移除,语言别名与明确前缀按统一登记归一,不会将繁体中文模糊匹配为简体中文。
83
+
84
+ 帮助、本地错误、设备授权通知和合同提供的摘要/描述按本次语言输出;合同缺少翻译时回退英文。请求发送规范 `Accept-Language`,响应语言由服务端协商。命令、选项、JSON/CSV 字段、错误码、Scope 与路径保持稳定,不用翻译消息判断程序结果。语言协商不修改配置或用户偏好,并发命令各自持有独立 i18next 实例。
85
+
86
+ ## 配置与登录
87
+
88
+ 先由平台明确登记公共 CLI 客户端,然后使用其 Client ID。交互式 `config init` 会询问身份服务、业务 API 来源和 Client ID;非交互运行可显式传参。CLI 不创建平台客户端、不保存客户端 Secret,也不会通过本地设置授予平台角色。
89
+
90
+ ```sh
91
+ limecloud-cli config init \
92
+ --issuer "https://YOUR_AUTH_ORIGIN" \
93
+ --api-origin "https://YOUR_API_ORIGIN" \
94
+ --client-id "YOUR_REGISTERED_PUBLIC_CLI_CLIENT_ID"
95
+ limecloud-cli config show
96
+ limecloud-cli config set api_origin "https://YOUR_API_ORIGIN"
97
+ ```
98
+
99
+ 业务 API Origin 必须显式提供;CLI 不猜测尚未部署的正式地址。身份服务 Origin 和业务 API Origin 分别保存、分别校验;HTTP 仅允许本机回环地址。
100
+
101
+ ```sh
102
+ limecloud-cli auth login
103
+ limecloud-cli auth status
104
+ limecloud-cli auth whoami
105
+ limecloud-cli whoami
106
+ limecloud-cli doctor --offline
107
+ ```
108
+
109
+ 默认登录仅请求 `openid profile email offline_access`。终端显示验证地址和用户码;用户在自己的浏览器核对客户端、权限及代码后决定是否授权。CLI 按服务端间隔轮询,收到 `slow_down` 后每次增加 5 秒,拒绝或到期即停止。浏览器同意不会被 CLI 自动批准。
110
+
111
+ 业务访问需显式请求对应 Scope,例如:
112
+
113
+ ```sh
114
+ limecloud-cli auth login \
115
+ --scope "openid profile email offline_access lime:open:read"
116
+ limecloud-cli auth check --scope "lime:open:read"
117
+ limecloud-cli auth scopes
118
+ ```
119
+
120
+ | Scope | 领域 |
121
+ | --- | --- |
122
+ | `lime:open:read` / `lime:open:write` | 工作空间、应用、配置、版本、客户端、分发、事件与协作者 |
123
+ | `lime:account:read` / `lime:account:write` | 个人账户、空间、应用安装、报价、订单及账户安全 |
124
+ | `lime:operations:read` / `lime:operations:write` | 商品、营销、订单、通知、财务及运营审计 |
125
+ | `lime:admin:read` / `lime:admin:write` | 平台审核、访问绑定和管理审计 |
126
+
127
+ Scope 控制委托入口,当前空间成员、领域角色、环境、修订号、幂等、强认证和独立审核仍由服务端检查。CLI 不会因调用失败自动扩大授权。`schema <service.resource.method>` 返回具体方法所需的 Scope。
128
+
129
+ `auth scopes` 读取 OIDC 支持的 Scope,并报告本地授予记录;它不等于客户端已启用权限查询。`auth check --scope` 只核对当前未过期的本地授权。`auth status` 与根 `whoami` 显示本地有效上下文,不代替远端核验;`auth whoami` 调用真实 UserInfo。`doctor` 默认只检查本地配置、合同和令牌状态,不发网络请求。
130
+
131
+ ### 非阻塞设备授权
132
+
133
+ ```sh
134
+ limecloud-cli auth login --no-wait --json
135
+ limecloud-cli auth login --resume --json
136
+ ```
137
+
138
+ `--no-wait` 输出 `verification_uri`、`user_code`、`expires_at` 和 `resume_command`,保密设备码只保存在私有 pending 文件。完成浏览器确认后用 `--resume` 继续;恢复保持原 Client ID、Issuer、API Origin、Scope 和安装上下文。为避免命令行历史泄露,Lime 使用本地恢复上下文,没有照搬裸传 `--device-code`。
139
+
140
+ 授权请求或令牌兑换结果未知时不重放旧设备码;需要重新发起登录。Ctrl+C 取消等待并释放锁,等待阶段可以随后恢复。强制终止进程可能遗留锁;CLI 不自动删除未知锁。
141
+
142
+ ## 三层命令
143
+
144
+ 优先选择对应任务的快捷命令,其次使用合同映射的领域命令,最后按已知公开路径调用。所有层次共享同一份合同校验和认证边界。
145
+
146
+ ```sh
147
+ # 1. 快捷命令
148
+ limecloud-cli identity +login
149
+ limecloud-cli identity +whoami
150
+
151
+ # 2. 领域命令
152
+ limecloud-cli open application list --space-id "YOUR_SPACE_ID"
153
+ limecloud-cli account profile get
154
+ limecloud-cli operations product list --app-id "YOUR_APP_ID" --environment "sandbox"
155
+ limecloud-cli admin review list --kind "releases"
156
+
157
+ # 3. 按公开 HTTP 路径调用
158
+ limecloud-cli api GET "/api/v1/open/spaces/YOUR_SPACE_ID/applications"
159
+ limecloud-cli api GET "/api/v1/account/profile"
160
+ ```
161
+
162
+ 领域命令采用 `<service> <resource> <method>`,资源名使用 `snake_case`。当前合同包括 9 项 OAuth/OIDC 操作和 124 项委托管理操作;数量随 PRD、服务实现与公共合同更新。通过 `api list` 和 `schema` 查看当前版本,不以本说明中的数字替代运行时目录。
163
+
164
+ ```sh
165
+ limecloud-cli schema open.application.create
166
+ limecloud-cli schema open application create
167
+ limecloud-cli schema open
168
+ limecloud-cli api list application --format table
169
+ ```
170
+
171
+ 每个方法的 Schema 包含 `name`、`description`、`inputSchema`、`outputSchema` 和 `_meta`。路径、查询、HTTP Header、请求体、必填字段、字段 Flag、HTTP 方法、Scope、风险等级和文档入口均可发现。`--params` 支持路径及查询字段,`--header` 只允许合同声明的请求 Header;不能通过它覆盖 Authorization、Cookie 或 Host。
172
+
173
+ ```sh
174
+ limecloud-cli open application get \
175
+ --params '{"spaceID":"YOUR_SPACE_ID","appID":"YOUR_APP_ID"}'
176
+ ```
177
+
178
+ 显式字段 Flag 覆盖同名 JSON 参数。管理客户端等命令中的 `--client-id` 是业务资源字段;需要覆盖当前 OAuth 客户端上下文时使用 `--auth-client-id`。登录和 `config init` 继续使用 `--client-id`。
179
+
180
+ ### JSON 与文件输入
181
+
182
+ 将以下内容保存为 `application.json`,包含创建应用所需的名称、描述、类型和预设图标:
183
+
184
+ ```json
185
+ {
186
+ "name": "Example application",
187
+ "description": "An application for the example workflow",
188
+ "kind": "internal",
189
+ "icon": "leaf"
190
+ }
191
+ ```
192
+
193
+ ```sh
194
+ limecloud-cli open application create \
195
+ --space-id "YOUR_SPACE_ID" \
196
+ --data "@application.json" \
197
+ --dry-run
198
+ ```
199
+
200
+ `--params JSON` 和 `--data JSON` 支持 `@file` 或 `-` 从 stdin 读取。OAuth/OIDC 方法按合同转换为表单编码;管理 API 保留 JSON 类型。密码、令牌和 Secret 等敏感字段需使用文件、stdin 或 `--param-env 字段=环境变量名`,不能作为普通命令行参数传入。
201
+
202
+ ```sh
203
+ limecloud-cli identity token revoke \
204
+ --param-env "token=TOKEN_TO_REVOKE" \
205
+ --param "token_type_hint=refresh_token"
206
+ ```
207
+
208
+ 幂等方法可按 Schema 使用显式 Header:
209
+
210
+ 将当前环境与最新修订号保存为 `rotation.json`;示例中的 `1` 需替换为目标客户端的当前修订号:
211
+
212
+ ```json
213
+ { "environment": "sandbox", "revision": 1 }
214
+ ```
215
+
216
+ ```sh
217
+ limecloud-cli open client rotate_secret \
218
+ --space-id "YOUR_SPACE_ID" \
219
+ --app-id "YOUR_APP_ID" \
220
+ --client-id "RESOURCE_CLIENT_ID" \
221
+ --header "Idempotency-Key=YOUR_UNIQUE_REQUEST_KEY" \
222
+ --data "@rotation.json" \
223
+ --dry-run
224
+ ```
225
+
226
+ CLI 不自动生成或重试业务写请求的幂等键。结果未知时保留原键、原请求和上下文,按对应领域恢复流程处理。
227
+
228
+ ### 图标上传
229
+
230
+ ```sh
231
+ limecloud-cli open application_icon create \
232
+ --space-id "YOUR_SPACE_ID" \
233
+ --file "cropped-icon.png" \
234
+ --dry-run
235
+ ```
236
+
237
+ 图标合同使用 `image/png` 原始二进制正文,不是 JSON 或 multipart。`--file -` 读取二进制 stdin。图标需预先裁剪为 256×256、最大 320KiB;服务端继续完整解码、重编码并检查当前权限。`--dry-run` 只展示文件尺寸、字节数和 SHA-256,不打印或发送图像字节。
238
+
239
+ ## 输出与请求预览
240
+
241
+ 默认成功输出到 stdout,退出码为 0:
242
+
243
+ ```json
244
+ { "ok": true, "identity": "user", "data": {}, "meta": {} }
245
+ ```
246
+
247
+ 失败输出到 stderr;参数校验失败退出码 2,其他失败通常为 1,SIGINT/SIGTERM 分别为 130/143:
248
+
249
+ ```json
250
+ { "ok": false, "error": { "type": "validation", "subtype": "invalid_argument", "code": "invalid_arguments", "message": "..." } }
251
+ ```
252
+
253
+ 错误可能包含上游稳定 `code`、HTTP `status` 及 `retry_after`,不回显服务端可能包含敏感输入的描述。判断命令是否成功使用退出码或 `ok`,不要把原始业务 API 的字段当作 CLI 成功标志。
254
+
255
+ ```sh
256
+ limecloud-cli api list --format json
257
+ limecloud-cli api list --format ndjson
258
+ limecloud-cli api list --format table --fields "command,method,path"
259
+ limecloud-cli api list --format csv --fields "command,method,path"
260
+ ```
261
+
262
+ JSON 返回统一 Envelope;NDJSON 按记录逐行输出 Envelope;Table 与 CSV 输出所选数据字段。`--json` 等价于 `--format json`,`--fields` 支持逗号分隔的字段路径。Table 会去除终端控制字符。Lime 不依赖外部 jq,也不实现飞书专属身份切换或办公 API 分页假象。
263
+
264
+ 默认响应将访问令牌、刷新令牌、ID Token、设备码、客户端 Secret、密码和签名密钥等替换为 `[REDACTED]`。只有 API 调用显式 `--show-secrets` 才输出原始凭据;登录、状态与刷新始终不输出凭据。`--dry-run` 始终脱敏,即使同时指定 `--show-secrets`。
265
+
266
+ `--dry-run` 只读取合同、配置与输入,验证后打印请求,不发 HTTP、不写入凭据、不触发业务操作。没有设置业务 API Origin 时,预览显示 `<api-origin>` 占位;实际调用会报配置缺失。
267
+
268
+ ## 凭据与环境隔离
269
+
270
+ | 配置 | 用途 |
271
+ | --- | --- |
272
+ | `--issuer` / `LIMECLOUD_ISSUER` | 身份服务 Origin,默认 `https://auth.limeai.run` |
273
+ | `--api-origin` / `LIMECLOUD_API_ORIGIN` | 显式业务 API Origin,无猜测默认值 |
274
+ | `--client-id` / `--auth-client-id` / `LIMECLOUD_CLIENT_ID` | 已登记的 OAuth 公共客户端上下文 |
275
+ | `LIMECLOUD_ACCESS_TOKEN` | 外部管理的用户访问令牌,不写入本地凭据 |
276
+ | `LIMECLOUD_CLIENT_SECRET` | 仅适用于显式机密/机器客户端身份协议 API;公共 CLI 登录不使用 |
277
+ | `LIMECLOUD_CONFIG` | 私有凭据文件,默认 `~/.config/limecloud/credentials.json` |
278
+ | `LIMECLOUD_SETTINGS` | 公共设置文件,默认与凭据同目录的 `config.json` |
279
+ | `LIMECLOUD_INSTALL_PREFIX` / `install --prefix` | CLI 安装前缀,默认当前用户的 `~/.local` |
280
+
281
+ 显式 Flag 优先于环境变量,之后使用设置文件和匹配的登录记录。每份凭据文件保存一个上下文;多环境可分别设置 `LIMECLOUD_CONFIG` 和 `LIMECLOUD_SETTINGS`。
282
+
283
+ 保存的令牌绑定 Issuer、Client ID 与 API Origin。改变 API Origin 不能把旧令牌发送到新站点,必须重新登录确认绑定。所有 HTTP 重定向都被拒绝,Authorization 不跟随重定向发送。`LIMECLOUD_ACCESS_TOKEN` 的来源与权限由调用者管理,服务端仍验证其 Scope、Audience 和当前领域权限。
284
+
285
+ 凭据、设置和 pending 文件使用当前用户所有的 0600 常规文件,拒绝符号链接及他人可读文件;认证写操作持有排他锁并原子替换。`auth refresh` 串行刷新,兑换前记录未知结果状态,成功后替换轮换令牌。网络失败或响应丢失后禁止重用旧刷新令牌,需重新登录。
286
+
287
+ `auth logout` 先撤销保存的刷新令牌(若没有则撤销访问令牌),成功后清空本地记录;撤销失败保留信息以便恢复。`--local-only` 仅清空本地,不撤销远端,也不执行浏览器中央退出。设置了 `LIMECLOUD_ACCESS_TOKEN` 时,管理本地认证前需先清除该环境变量,CLI 不会误报外部令牌已被清除。
288
+
289
+ ## 验证边界
290
+
291
+ 本包测试覆盖公开合同完整目录与方法预览、真实 loopback Auth/API 分站 HTTP、表单与 JSON 编码、路径/查询/Header、设备授权及恢复、刷新结果未知防重放、格式化输出、二进制及 JSON stdin、PNG 上传入口、私有存储和凭据隔离。
292
+
293
+ 合同目录与请求预览不代替真实业务验收。正式业务 API、客户端登记和 PRD 场景须由本轮服务实现、数据库专项与部署验收证明;包发布不会自动部署平台。管理 BFF 的浏览器会话及 CSRF 入口保持独立,CLI 只调用公共合同中的路径。ID Token 不作为 CLI 凭据解析,应用需要验证 ID Token 时应使用完整 OIDC 库。
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { run } from "../src/cli.mjs";
3
+ // 下游命令提前关闭管道时安静结束,继续执行 finally 以释放私有文件锁。
4
+ process.stdout.on("error", error => { if (error.code !== "EPIPE") throw error; });
5
+ await run(process.argv.slice(2));