@heybox/hb-sdk 0.4.5 → 0.4.6

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.
@@ -20,6 +20,7 @@
20
20
  - [Create a mini-program template](#create-a-mini-program-template)
21
21
  - [Local dev and mock runtime](#local-dev-and-mock-runtime)
22
22
  - [Deploy and backend operations](#deploy-and-backend-operations)
23
+ - [Remote entity scope](#remote-entity-scope)
23
24
  - [Remote management commands](#remote-management-commands)
24
25
  - [CLI login cache](#cli-login-cache)
25
26
  - [Agent Skill doctor](#agent-skill-doctor)
@@ -28,7 +29,7 @@
28
29
  - [Generated template README](#generated-template-readme)
29
30
  ## When to use the CLI
30
31
 
31
- Use the bundled `hb-sdk` CLI when the task is about creating an external mini-program project, starting local Vite development, debugging SDK calls in a browser mock runtime host, or managing the CLI's own Heybox auth cache.
32
+ Use the bundled `hb-sdk` CLI when the task is about creating an external mini-program project, starting local Vite development, debugging SDK calls in a browser mock runtime host, managing the CLI's own Heybox auth cache, or inspecting/switching the developer platform current entity for remote mini-program management.
32
33
 
33
34
  Do not use the CLI to replace iframe SDK calls. `hb-sdk login` is for CLI commands only and does not change `auth.login()`, `user.getInfo()`, `network.request()`, or mock-host user state.
34
35
 
@@ -39,13 +40,16 @@ The CLI, templates, and mock host are owned by `@heybox/hb-sdk`. Do not create a
39
40
  ```text
40
41
  hb-sdk create <project-name>
41
42
  hb-sdk dev [--port <port>] [--mock-port <port>] [--runtime-url <url>] [--no-open]
42
- hb-sdk login [--login-base-url <url>]
43
+ hb-sdk login [--login-base-url <url>] [--no-select-entity]
43
44
  hb-sdk login status
44
45
  hb-sdk login clear
45
46
  hb-sdk doctor
46
47
  hb-sdk remote access
48
+ hb-sdk remote entity list
49
+ hb-sdk remote entity current
50
+ hb-sdk remote entity switch <entity-id>
47
51
  hb-sdk remote list [--status <status>] [--keyword <text>]
48
- hb-sdk remote create --name <name> [--preview-image-url <url>] [--force-bind]
52
+ hb-sdk remote create --name <name> [--preview-image-url <url>] [--yes] [--force-bind]
49
53
  hb-sdk remote bind <mini-program-id> [--force]
50
54
  hb-sdk remote info
51
55
  hb-sdk remote update [--name <name>] [--preview-image-url <url>]
@@ -164,9 +168,12 @@ HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1 hb-sdk remote deploy --api-base-url http://12
164
168
 
165
169
  `hb-sdk doctor`、npm latest 检查、mock host 的 `network.request()` 不受这些配置影响。
166
170
 
171
+ Before precheck, build, upload, or submit audit, `hb-sdk remote deploy` must verify that the current project's bound mini-program belongs to the server-side current entity. If `detail.entity_id` differs from the current entity, the command fails with both entity ids/names and suggests `hb-sdk remote entity switch <entity-id>`. It must not auto-switch entities and must not continue into precheck/build/upload/submit on mismatch.
172
+
167
173
  Agent rules:
168
174
 
169
175
  - Use `hb-sdk remote deploy --release-note <text>` for normal build, upload, and submit-audit flows.
176
+ - Verify remote deploy guidance says current-entity mismatch fails before precheck/build/upload/submit and never auto-switches the developer entity.
170
177
  - Never recommend top-level `hb-sdk deploy`; it has been removed rather than retained as a compatibility alias.
171
178
  - After non-auto deploy succeeds, suggest `hb-sdk remote versions` and then `hb-sdk remote release <version>` after approval. Do not send the user to Open for manual publish when the CLI command exists.
172
179
  - Use `hb-sdk remote allowlist add <heybox_id>` when preview access needs to be granted.
@@ -177,6 +184,28 @@ Agent rules:
177
184
  - Custom base URLs must be origin-only; API origins must be Heybox trusted HTTPS unless the unsafe debug switch is explicit. Do not include path, query, or hash.
178
185
  - Do not expect custom base URLs to affect `hb-sdk doctor`, npm latest checks, or mock-host `network.request()`.
179
186
 
187
+ ## Remote entity scope
188
+
189
+ Developer entity selection lives under `hb-sdk remote entity`:
190
+
191
+ ```bash
192
+ hb-sdk remote entity list
193
+ hb-sdk remote entity current
194
+ hb-sdk remote entity switch <entity-id>
195
+ ```
196
+
197
+ The authoritative current entity is the developer platform server-side current entity. The CLI auth cache may contain a `selectedEntity` value, but that value is only a hint snapshot for `hb-sdk login status` display and drift troubleshooting. Do not use `selectedEntity` as the source of truth for permissions, ownership, create, bind, deploy, or release decisions.
198
+
199
+ `hb-sdk login` tries to make the server-side current entity explicit after browser login. Zero entities leaves login successful and prints a guidance message. One entity is displayed and, when needed, switched to current. Multiple entities in a TTY prompt for a choice; multiple entities in non-interactive mode do not block login but tell the user to run `hb-sdk remote entity switch <entity-id>`. Passing `--no-select-entity` writes only the login state and does not modify the server-side current entity.
200
+
201
+ Agent rules:
202
+
203
+ - Treat the server-side current entity as the authority for remote create, bind, deploy, list, access, versions, preview, release, withdraw, take-down, and reopen workflows.
204
+ - Treat CLI `selectedEntity` as a display/debug snapshot only; it can drift from the server-side current entity and must not be used as a permission source.
205
+ - Use `hb-sdk remote entity current` when a user needs to confirm which entity create/deploy will use.
206
+ - Use `hb-sdk remote entity switch <entity-id>` to change entity scope. Do not recommend `--entity-id` or an environment variable as a remote command override.
207
+ - `hb-sdk remote list` lists mini-programs in the current entity scope only; do not promise cross-entity aggregation.
208
+
180
209
  ## Remote management commands
181
210
 
182
211
  ## 远端管理命令
@@ -209,7 +238,10 @@ hb-sdk remote reopen
209
238
 
210
239
  Agent rules:
211
240
 
241
+ - Use `hb-sdk remote entity list/current/switch` for developer entity inspection and switching.
212
242
  - Use `hb-sdk remote create --name <name>` for create-and-bind and `hb-sdk remote bind <mini-program-id>` for binding an existing manageable remote mini-program.
243
+ - Explain that `remote create` creates under the current entity and that multi-entity non-TTY usage must confirm with `--yes`; `--yes` confirms current-entity usage but does not switch entities.
244
+ - Explain that `remote bind` verifies the mini-program is manageable by the current entity and does not write `package.json.heybox.miniProgramId` on entity mismatch.
213
245
  - Use `hb-sdk remote info`, `hb-sdk remote update`, `hb-sdk remote access`, `hb-sdk remote list`, `hb-sdk remote versions`, `hb-sdk remote preview <version>`, and `hb-sdk remote allowlist ...` instead of sending users to Open when a matching CLI command exists.
214
246
  - Treat `hb-sdk remote list` as discovery only. Dangerous write commands still target the bound mini-program from `package.json.heybox.miniProgramId`.
215
247
  - Require confirmation or `--yes` for `hb-sdk remote release`, `hb-sdk remote withdraw`, `hb-sdk remote take-down`, and `hb-sdk remote reopen`.
@@ -236,6 +268,7 @@ hb-sdk login clear
236
268
  Agent rules:
237
269
 
238
270
  - Keep CLI auth cache separate from iframe SDK login state.
271
+ - Keep `selectedEntity` guidance explicit: it is only a hint snapshot, while every remote command uses the server-side current entity.
239
272
  - It is correct to say status output is redacted.
240
273
  - Do not expose or template pkey, cookie, token, or private credential values.
241
274
  - Use `hb-sdk login clear` only to clear the `hb-sdk` CLI namespace.
@@ -322,7 +355,7 @@ npm run deploy
322
355
 
323
356
  - `npm run dev`:启动本地 Vite 服务和 `hb-sdk` 内置 mock runtime host,适合本地调试 SDK 能力;调试页内可点击按钮在 Mac 版 APP 中启动同一页面,也可以选择局域网网卡后用手机小黑盒 APP 扫码调试。手机需要与电脑处在同一局域网,并使用支持小程序调试壳的新版小黑盒 APP。Codex、VSCode 等内嵌浏览器可能无法唤起系统 APP,需要时请在系统浏览器中打开同一个调试页后重试。
324
357
  - `npm run build`:先执行 TypeScript 检查,再构建生产产物。
325
- - `npm run deploy -- --release-note "..."`:运行 `hb-sdk remote deploy`,构建、上传并提交当前小程序版本审核。部署前需要先通过 `hb-sdk remote create --name "..."` 创建并绑定远端小程序,或用 `hb-sdk remote bind <mini-program-id>` 绑定已有小程序,并执行过 `npx hb-sdk login`;默认审核通过后用 `hb-sdk remote versions` 查看状态,再用 `hb-sdk remote release <version>` 发布,如需审核通过后自动发布可追加 `--auto-publish`。顶层 `hb-sdk deploy` 已删除,不再作为兼容别名保留。
358
+ - `npm run deploy -- --release-note "..."`:运行 `hb-sdk remote deploy`,构建、上传并提交当前小程序版本审核。部署前需要先执行过 `npx hb-sdk login`;多主体账号还应通过 `npx hb-sdk remote entity current` 确认服务端 current entity。远端小程序可通过 `npx hb-sdk remote create --name "..."` current entity 下创建并绑定,或用 `npx hb-sdk remote bind <mini-program-id>` 绑定 current entity 可管理的已有小程序。`selectedEntity` 只是 CLI 登录缓存中的提示快照,实际 deploy/create/bind 以服务端 current entity 为准。默认审核通过后用 `hb-sdk remote versions` 查看状态,再用 `hb-sdk remote release <version>` 发布,如需审核通过后自动发布可追加 `--auto-publish`。顶层 `hb-sdk deploy` 已删除,不再作为兼容别名保留。
326
359
 
327
360
  ## 更多能力
328
361
 
@@ -209,13 +209,16 @@ const cliDoctorSection = extractSection(cliGuide, '## Agent Skill doctor');
209
209
  const cliUpdateSection = extractSection(cliGuide, '## 版本提醒');
210
210
  const cliCommandSurface = `hb-sdk create <project-name>
211
211
  hb-sdk dev [--port <port>] [--mock-port <port>] [--runtime-url <url>] [--no-open]
212
- hb-sdk login [--login-base-url <url>]
212
+ hb-sdk login [--login-base-url <url>] [--no-select-entity]
213
213
  hb-sdk login status
214
214
  hb-sdk login clear
215
215
  hb-sdk doctor
216
216
  hb-sdk remote access
217
+ hb-sdk remote entity list
218
+ hb-sdk remote entity current
219
+ hb-sdk remote entity switch <entity-id>
217
220
  hb-sdk remote list [--status <status>] [--keyword <text>]
218
- hb-sdk remote create --name <name> [--preview-image-url <url>] [--force-bind]
221
+ hb-sdk remote create --name <name> [--preview-image-url <url>] [--yes] [--force-bind]
219
222
  hb-sdk remote bind <mini-program-id> [--force]
220
223
  hb-sdk remote info
221
224
  hb-sdk remote update [--name <name>] [--preview-image-url <url>]
@@ -233,6 +236,18 @@ hb-sdk remote reopen [--yes]
233
236
 
234
237
  Removed: hb-sdk deploy`;
235
238
 
239
+ const cliRemoteEntitySection = `Developer entity selection lives under \`hb-sdk remote entity\`:
240
+
241
+ ${fenced('bash', `hb-sdk remote entity list
242
+ hb-sdk remote entity current
243
+ hb-sdk remote entity switch <entity-id>`)}
244
+
245
+ The authoritative current entity is the developer platform server-side current entity. The CLI auth cache may contain a \`selectedEntity\` value, but that value is only a hint snapshot for \`hb-sdk login status\` display and drift troubleshooting. Do not use \`selectedEntity\` as the source of truth for permissions, ownership, create, bind, deploy, or release decisions.
246
+
247
+ \`hb-sdk login\` tries to make the server-side current entity explicit after browser login. Zero entities leaves login successful and prints a guidance message. One entity is displayed and, when needed, switched to current. Multiple entities in a TTY prompt for a choice; multiple entities in non-interactive mode do not block login but tell the user to run \`hb-sdk remote entity switch <entity-id>\`. Passing \`--no-select-entity\` writes only the login state and does not modify the server-side current entity.`;
248
+
249
+ const cliRemoteEntityDeploySection = `Before precheck, build, upload, or submit audit, \`hb-sdk remote deploy\` must verify that the current project's bound mini-program belongs to the server-side current entity. If \`detail.entity_id\` differs from the current entity, the command fails with both entity ids/names and suggests \`hb-sdk remote entity switch <entity-id>\`. It must not auto-switch entities and must not continue into precheck/build/upload/submit on mismatch.`;
250
+
236
251
  const files = new Map();
237
252
 
238
253
  files.set('api-root.md', `${header('Root API reference', [
@@ -322,6 +337,7 @@ files.set('cli.md', `${header('CLI reference', [
322
337
  ['Create a mini-program template', 'create-a-mini-program-template'],
323
338
  ['Local dev and mock runtime', 'local-dev-and-mock-runtime'],
324
339
  ['Deploy and backend operations', 'deploy-and-backend-operations'],
340
+ ['Remote entity scope', 'remote-entity-scope'],
325
341
  ['Remote management commands', 'remote-management-commands'],
326
342
  ['CLI login cache', 'cli-login-cache'],
327
343
  ['Agent Skill doctor', 'agent-skill-doctor'],
@@ -330,7 +346,7 @@ files.set('cli.md', `${header('CLI reference', [
330
346
  ['Generated template README', 'generated-template-readme'],
331
347
  ])}## When to use the CLI
332
348
 
333
- Use the bundled \`hb-sdk\` CLI when the task is about creating an external mini-program project, starting local Vite development, debugging SDK calls in a browser mock runtime host, or managing the CLI's own Heybox auth cache.
349
+ Use the bundled \`hb-sdk\` CLI when the task is about creating an external mini-program project, starting local Vite development, debugging SDK calls in a browser mock runtime host, managing the CLI's own Heybox auth cache, or inspecting/switching the developer platform current entity for remote mini-program management.
334
350
 
335
351
  Do not use the CLI to replace iframe SDK calls. \`hb-sdk login\` is for CLI commands only and does not change \`auth.login()\`, \`user.getInfo()\`, \`network.request()\`, or mock-host user state.
336
352
 
@@ -363,9 +379,12 @@ Use \`hb-sdk dev\` for local browser SDK debugging. Use the Mock runtime host's
363
379
 
364
380
  ${cliDeploySection}
365
381
 
382
+ ${cliRemoteEntityDeploySection}
383
+
366
384
  Agent rules:
367
385
 
368
386
  - Use \`hb-sdk remote deploy --release-note <text>\` for normal build, upload, and submit-audit flows.
387
+ - Verify remote deploy guidance says current-entity mismatch fails before precheck/build/upload/submit and never auto-switches the developer entity.
369
388
  - Never recommend top-level \`hb-sdk deploy\`; it has been removed rather than retained as a compatibility alias.
370
389
  - After non-auto deploy succeeds, suggest \`hb-sdk remote versions\` and then \`hb-sdk remote release <version>\` after approval. Do not send the user to Open for manual publish when the CLI command exists.
371
390
  - Use \`hb-sdk remote allowlist add <heybox_id>\` when preview access needs to be granted.
@@ -376,13 +395,28 @@ Agent rules:
376
395
  - Custom base URLs must be origin-only; API origins must be Heybox trusted HTTPS unless the unsafe debug switch is explicit. Do not include path, query, or hash.
377
396
  - Do not expect custom base URLs to affect \`hb-sdk doctor\`, npm latest checks, or mock-host \`network.request()\`.
378
397
 
398
+ ## Remote entity scope
399
+
400
+ ${cliRemoteEntitySection}
401
+
402
+ Agent rules:
403
+
404
+ - Treat the server-side current entity as the authority for remote create, bind, deploy, list, access, versions, preview, release, withdraw, take-down, and reopen workflows.
405
+ - Treat CLI \`selectedEntity\` as a display/debug snapshot only; it can drift from the server-side current entity and must not be used as a permission source.
406
+ - Use \`hb-sdk remote entity current\` when a user needs to confirm which entity create/deploy will use.
407
+ - Use \`hb-sdk remote entity switch <entity-id>\` to change entity scope. Do not recommend \`--entity-id\` or an environment variable as a remote command override.
408
+ - \`hb-sdk remote list\` lists mini-programs in the current entity scope only; do not promise cross-entity aggregation.
409
+
379
410
  ## Remote management commands
380
411
 
381
412
  ${cliRemoteSection}
382
413
 
383
414
  Agent rules:
384
415
 
416
+ - Use \`hb-sdk remote entity list/current/switch\` for developer entity inspection and switching.
385
417
  - Use \`hb-sdk remote create --name <name>\` for create-and-bind and \`hb-sdk remote bind <mini-program-id>\` for binding an existing manageable remote mini-program.
418
+ - Explain that \`remote create\` creates under the current entity and that multi-entity non-TTY usage must confirm with \`--yes\`; \`--yes\` confirms current-entity usage but does not switch entities.
419
+ - Explain that \`remote bind\` verifies the mini-program is manageable by the current entity and does not write \`package.json.heybox.miniProgramId\` on entity mismatch.
386
420
  - Use \`hb-sdk remote info\`, \`hb-sdk remote update\`, \`hb-sdk remote access\`, \`hb-sdk remote list\`, \`hb-sdk remote versions\`, \`hb-sdk remote preview <version>\`, and \`hb-sdk remote allowlist ...\` instead of sending users to Open when a matching CLI command exists.
387
421
  - Treat \`hb-sdk remote list\` as discovery only. Dangerous write commands still target the bound mini-program from \`package.json.heybox.miniProgramId\`.
388
422
  - Require confirmation or \`--yes\` for \`hb-sdk remote release\`, \`hb-sdk remote withdraw\`, \`hb-sdk remote take-down\`, and \`hb-sdk remote reopen\`.
@@ -395,6 +429,7 @@ ${cliLoginSection}
395
429
  Agent rules:
396
430
 
397
431
  - Keep CLI auth cache separate from iframe SDK login state.
432
+ - Keep \`selectedEntity\` guidance explicit: it is only a hint snapshot, while every remote command uses the server-side current entity.
398
433
  - It is correct to say status output is redacted.
399
434
  - Do not expose or template pkey, cookie, token, or private credential values.
400
435
  - Use \`hb-sdk login clear\` only to clear the \`hb-sdk\` CLI namespace.
package/skill/skill.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.4.5+skill.f7eeb07997a5",
3
+ "skillVersion": "0.4.6+skill.1c7149a95a0b",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.4.5",
7
- "compatibility": "0.4.5"
6
+ "version": "0.4.6",
7
+ "compatibility": "0.4.6"
8
8
  },
9
9
  "source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
10
- "integrity": "sha256-f7eeb07997a5926a9f1d636d9e4d46ad412635a66da4a444095970ed17857c0e"
10
+ "integrity": "sha256-1c7149a95a0b5d0ffeaa479456186dab5f3bc06865fd5c28a975682381267811"
11
11
  }
@@ -1,6 +1,8 @@
1
1
  export declare const MINIAPP_UPLOAD_SCOPE = "activity";
2
2
  export declare const ACTIVITY_UPLOAD_KEY_MAX_LENGTH = 64;
3
3
  export declare const USER_MINIPROGRAM_ACCESS_STATUS_API_PATH = "/mall/developer/user_miniprogram/access_status";
4
+ export declare const DEVELOPER_ENTITY_LIST_API_PATH = "/mall/developer/entity/list";
5
+ export declare const DEVELOPER_ENTITY_SWITCH_API_PATH = "/mall/developer/entity/switch";
4
6
  export declare const LIST_USER_MINIPROGRAM_API_PATH = "/mall/developer/user_miniprogram/list";
5
7
  export declare const CREATE_USER_MINIPROGRAM_API_PATH = "/mall/developer/user_miniprogram/create";
6
8
  export declare const UPDATE_USER_MINIPROGRAM_API_PATH = "/mall/developer/user_miniprogram/update";