@heybox/hb-sdk 0.8.0-alpha.2 → 0.8.0-alpha.9

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 (71) hide show
  1. package/CHANGELOG.md +85 -430
  2. package/README.md +26 -2
  3. package/dist/cli-chunks/{build-CCLWgXyA.cjs → build-DkokKVNy.cjs} +2 -2
  4. package/dist/cli-chunks/{context-Brh56h56.cjs → context-CKzZxKbF.cjs} +1 -1
  5. package/dist/cli-chunks/{create-BZ-hi2s1.cjs → create-BQy5Jdmu.cjs} +2 -2
  6. package/dist/cli-chunks/{dev-CoSXtEYa.cjs → dev-Dik2zr5R.cjs} +60 -63
  7. package/dist/cli-chunks/doctor-Byr4uwKG.cjs +65 -0
  8. package/dist/cli-chunks/{index-BL5eEPap.cjs → index-BwGBr1ZA.cjs} +50 -30
  9. package/dist/cli-chunks/{index-CS6Q0o5C.cjs → index-Cl0XaX8e.cjs} +1 -1
  10. package/dist/cli-chunks/{index.esm-BoBHPfpq.cjs → index.esm-BYifBABc.cjs} +6 -5
  11. package/dist/cli-chunks/{login-CILLxGuf.cjs → login-Dr9lclu3.cjs} +2 -2
  12. package/dist/cli-chunks/{project-vite-Qu6Xe9Dn.cjs → project-vite-BIPrOtRO.cjs} +1 -1
  13. package/dist/cli-chunks/{remote-DRuTQ51u.cjs → remote-DXxyA14a.cjs} +4 -4
  14. package/dist/cli-chunks/{session-D-_N3WVL.cjs → session-B6Mo9eYW.cjs} +1 -1
  15. package/dist/cli-chunks/skill-f90sxv28.cjs +83 -0
  16. package/dist/cli-chunks/version-DDB_btOG.cjs +8 -0
  17. package/dist/cli.cjs +1 -1
  18. package/dist/devtools/browser-dev-host/assets/{browser-dev-host-uq-Wac6k.js → browser-dev-host-CbhA4h8z.js} +15 -15
  19. package/dist/devtools/browser-dev-host/assets/{index-KD2f3Jdz.css → index-DJFB5ySU.css} +1 -1
  20. package/dist/devtools/browser-dev-host/assets/{index-CeP6SLB3.js → index-DaqmTjSF.js} +4 -4
  21. package/dist/devtools/browser-dev-host/assets/workbench-state-wHgWRb7I.js +5 -0
  22. package/dist/devtools/browser-dev-host/index.html +3 -3
  23. package/dist/index.cjs.js +2 -2
  24. package/dist/index.esm.js +2 -2
  25. package/dist/templates/{vue3-vite-ts → vanilla-vite-js}/.gitignore.ejs +0 -1
  26. package/dist/templates/vanilla-vite-js/README.md.ejs +14 -0
  27. package/dist/templates/vanilla-vite-js/index.html.ejs +20 -0
  28. package/dist/templates/vanilla-vite-js/package.json.ejs +21 -0
  29. package/dist/templates/vanilla-vite-js/src/assets/heybox-logo.svg +8 -0
  30. package/dist/templates/vanilla-vite-js/src/main.js +39 -0
  31. package/dist/templates/vanilla-vite-js/src/styles.css +155 -0
  32. package/dist/templates/{vue3-vite-ts/vite.config.ts → vanilla-vite-js/vite.config.js} +1 -2
  33. package/dist/vite.cjs.js +1 -1
  34. package/dist/vite.esm.js +1 -1
  35. package/package.json +19 -10
  36. package/skill/SKILL.md +8 -9
  37. package/skill/references/api-protocol.md +2 -4
  38. package/skill/references/api-root.md +4 -2
  39. package/skill/references/cli.md +20 -7
  40. package/skill/references/examples.md +1 -1
  41. package/skill/references/llms-index.md +1 -1
  42. package/skill/references/recipes.md +6 -4
  43. package/skill/references/safety-boundaries.md +1 -1
  44. package/skill/skill.json +10 -5
  45. package/types/modules/share/index.d.ts +1 -1
  46. package/types/modules/share/show-share-menu.d.ts +1 -1
  47. package/types/modules/share/types.d.ts +2 -4
  48. package/types/skill-metadata.d.ts +0 -4
  49. package/dist/cli-chunks/doctor-EsCYJGhV.cjs +0 -204
  50. package/dist/devtools/browser-dev-host/assets/workbench-state-D-1U0JRq.js +0 -5
  51. package/dist/templates/vue3-vite-ts/README.md.ejs +0 -47
  52. package/dist/templates/vue3-vite-ts/index.html.ejs +0 -12
  53. package/dist/templates/vue3-vite-ts/package.json.ejs +0 -33
  54. package/dist/templates/vue3-vite-ts/src/App.vue +0 -78
  55. package/dist/templates/vue3-vite-ts/src/__tests__/App.spec.ts +0 -148
  56. package/dist/templates/vue3-vite-ts/src/auth-handoff.ts +0 -46
  57. package/dist/templates/vue3-vite-ts/src/main.ts +0 -5
  58. package/dist/templates/vue3-vite-ts/src/styles.css +0 -60
  59. package/dist/templates/vue3-vite-ts/src/vite-env.d.ts +0 -1
  60. package/dist/templates/vue3-vite-ts/tsconfig.app.json +0 -17
  61. package/dist/templates/vue3-vite-ts/tsconfig.json +0 -11
  62. package/dist/templates/vue3-vite-ts/tsconfig.node.json +0 -11
  63. package/dist/templates/vue3-vite-ts/vitest.config.ts +0 -10
  64. package/skill/scripts/check-references.mjs +0 -14
  65. package/skill/scripts/markdown-sections.mjs +0 -36
  66. package/skill/scripts/package-skill.mjs +0 -60
  67. package/skill/scripts/package-skill.sh +0 -6
  68. package/skill/scripts/skill-metadata.mjs +0 -77
  69. package/skill/scripts/sync-agent-skills-payload.mjs +0 -359
  70. package/skill/scripts/sync-references.mjs +0 -826
  71. package/skill/scripts/validate-skill.mjs +0 -263
package/skill/SKILL.md CHANGED
@@ -50,7 +50,7 @@ Apply these instructions when writing, reviewing, or debugging code that consume
50
50
  10. When authorization UI is required, call `auth.login()` from a trusted user action. Missing gesture returns `USER_GESTURE_REQUIRED`; cancelling, rejecting, or closing returns `AUTHORIZATION_CANCELLED` and does not confirm or change authorization. An already-authorized `auth.login()` request may return a new code silently.
51
51
  11. `user.getSteamGameList()` is available only to network-disabled mini-programs. In a network-enabled mini-program it returns `SERVER_API_REQUIRED`, and there is no Steam library authorization scope or OpenAPI resource. Treat `user.getInfo()` returning `SERVER_API_REQUIRED` as a server-boundary signal, not as logged-out state.
52
52
  12. Use `share.showShareMenu({ post })` or `share.screenshot({ post })` to preset editable community destinations and topics. Pass partition IDs through `topicIds` and topic text without surrounding `#` through `topics`; do not construct the underlying client post protocol.
53
- 13. Use `share.showShareMenu({ extra })` to open the share menu or `share.copyLink({ extra })` to copy and return the default mini-program share link. Read the JSON-compatible page state synchronously with `share.getExtra()` after launch, validate the developer-defined fields, and fall back to the default page when it returns `undefined`.
53
+ 13. Use `share.showShareMenu({ extra })` to open the share menu or `share.copyLink({ extra })` to copy and return the mini-program share link. `share.showShareMenu()` always uses the platform `common_share` landing page and does not accept a custom `url`. Read the JSON-compatible page state synchronously with `share.getExtra()` after launch, validate the developer-defined fields, and fall back to the default page when it returns `undefined`.
54
54
  14. Treat `files` and `network.download()` as a retained public contract that is not yet enabled by a current Host. The legacy PC adapter was dropped because the new PC will implement the Host ports directly. Until then, legacy PC, Mobile, Web, and Browser Dev Host return `METHOD_FORBIDDEN` and provide no memory/Blob fallback. Once a supporting Host is available, call `files.pickFiles()` / `pickDirectory()` / `saveFile()` only from trusted user actions; `saveFile()` accepts only `suggestedName`, `remove()` only deletes sandbox objects, and non-empty directories require `remove({ recursive: true })`.
55
55
  15. Use `network.download()` only with an SDK-created File/Directory target. It is GET-only, does not follow redirects, and exposes local `AbortSignal` / progress callbacks without sending functions over the bridge. Abort is a cancellation intent; a Host commit that already won still resolves successfully.
56
56
 
@@ -114,17 +114,16 @@ For host/runtime/protocol-maintenance code:
114
114
  - `cat packages/hb-sdk/DOC_SYNC_CHECKLIST.md`
115
115
  3. When preparing a package release, run `pnpm --filter @heybox/hb-sdk run release:prepare -- --bump patch` or `pnpm --filter @heybox/hb-sdk run release:prepare -- --version <x.y.z>`. The release assistant updates the Protocol/Runtime/SDK family versions, inserts `packages/hb-sdk/CHANGELOG.md`, and runs `check:changelog`. Use `--ai-command "<command>"` or `HB_SDK_CHANGELOG_AI_COMMAND` when an AI writer should rewrite the Conventional Commit draft. Review the entry for Mini-program developers and Host/Runtime integration maintainers, and do not expose Runtime internal adapter, state-machine, or security-policy details.
116
116
  4. When modifying this repo's source skill at `packages/hb-sdk/skill` and preparing distributable artifacts, also run:
117
- - `node packages/hb-sdk/skill/scripts/package-skill.mjs`
117
+ - `node packages/hb-sdk/scripts/skill/sync-references.mjs`
118
+ - `node packages/hb-sdk/scripts/skill/validate-skill.mjs`
118
119
  5. When modifying CLI, local debugging, package exports, or package dependency direction, also run:
119
120
  - `pnpm --filter @heybox/hb-sdk run check:boundary`
120
121
  - `pnpm --filter @heybox/hb-sdk run test:unit`
121
- 6. Inspect the generated zip before distribution:
122
- - `unzip -l packages/hb-sdk/hb-sdk.zip | sed -n '1,120p'`
123
- 7. When adding or modifying the deploy command or its upload pipeline, also run:
122
+ 6. When adding or modifying the deploy command or its upload pipeline, also run:
124
123
  - `pnpm --filter @heybox/hb-sdk run check:boundary`
125
124
  - `pnpm --filter @heybox/hb-sdk run test:unit`
126
125
  - Verify `dist/cli.cjs` does not have any `require('cos-nodejs-sdk-v5')` left after `build:cli`; the boundary check enforces this automatically.
127
- 8. Verify the canonical payload before publishing:
128
- - `pnpm exec hbexec hb-sdk sync`
129
- - `pnpm exec hbexec hb-sdk check`
130
- - For a release artifact, run `pnpm exec hbexec hb-sdk sync --out-dir <payload-dir>` and then `pnpm exec hbexec hb-sdk check-artifact --artifact-dir <payload-dir>`.
126
+ 7. Verify the canonical payload before publishing:
127
+ - `node packages/hb-sdk/scripts/skill/sync-references.mjs`
128
+ - `node packages/hb-sdk/scripts/skill/validate-skill.mjs`
129
+ - For a release artifact, run `npm pack --dry-run` and `node packages/hb-sdk/scripts/skill/verify-tarball-install.mjs`.
@@ -1,6 +1,6 @@
1
1
  # Protocol API reference
2
2
 
3
- > Generated by `node packages/hb-sdk/skill/scripts/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
3
+ > Generated by `node packages/hb-sdk/scripts/skill/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
4
4
 
5
5
  ## Sources
6
6
 
@@ -284,13 +284,11 @@ Reference 由 `@heybox/hb-sdk` 的公开导出与源码注释自动生成,不
284
284
  | [Protocol API](#public-protocol-entrypoint) | `@heybox/hb-sdk/protocol` 的协议常量、消息类型与 method 契约。 |
285
285
  | [Miniapp Publish API](https://open.xiaoheihe.cn/docs/hb_sdk/reference/miniapp-publish/) | `@heybox/hb-sdk/miniapp-publish` 的构建产物发布前的公开校验工具。 |
286
286
  | [Vite API](https://open.xiaoheihe.cn/docs/hb_sdk/reference/vite/) | `@heybox/hb-sdk/vite` 的Vite 工坊小程序插件。 |
287
- | [Host Runtime 集成](https://docs.xiaoheihe.cn/hb_sdk/reference/runtime/) | `@heybox/hb-sdk-runtime` 的 Host Port、Web Host 与 Runtime 集成入口;声明 Reference 在 Runtime package 内生成。 |
288
287
 
289
288
  ## 查询建议
290
289
 
291
290
  - 想查业务接入路径:先看 [Guide](recipes.md)。
292
291
  - 想查导出符号:从上方对应公开入口进入分类页。
293
- - 想接入详情页或 Browser Dev Host:先看 [Host Runtime 集成](https://docs.xiaoheihe.cn/hb_sdk/reference/runtime/),再查 Runtime package 的声明 Reference。
294
292
  - 想看场景化用法:优先看 Guide / Recipes 页面中的“进一步阅读”。
295
293
 
296
294
  ## 统计
@@ -302,7 +300,7 @@ Reference 由 `@heybox/hb-sdk` 的公开导出与源码注释自动生成,不
302
300
  | Miniapp Publish API | 0 | 5 | 2 | 0 | 0 |
303
301
  | Vite API | 0 | 1 | 5 | 1 | 1 |
304
302
 
305
- <!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=2; fingerprint=904f09f0012164f5d6b18c0f93477bb2bd541a41b99da8f270d0a40b93e96602 -->
303
+ <!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=2; fingerprint=336b8f72066321af3104fc51e5922f63eee5f3076c2e5c4d84384da7b9008032 -->
306
304
 
307
305
  ## SDK API
308
306
 
@@ -1,6 +1,6 @@
1
1
  # Root API reference
2
2
 
3
- > Generated by `node packages/hb-sdk/skill/scripts/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
3
+ > Generated by `node packages/hb-sdk/scripts/skill/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
4
4
 
5
5
  ## Sources
6
6
 
@@ -24,7 +24,7 @@
24
24
  ## Package metadata
25
25
 
26
26
  - Package: `@heybox/hb-sdk`
27
- - Version at generation time: `0.8.0-alpha.2`
27
+ - Version at generation time: `0.8.0-alpha.9`
28
28
  - Public root export: `@heybox/hb-sdk`
29
29
  - Protocol export: `@heybox/hb-sdk/protocol`
30
30
  - Vite plugin export: `@heybox/hb-sdk/vite`
@@ -439,6 +439,8 @@ hb-sdk build [--env <name>] [--verbose]
439
439
 
440
440
  # 快速开始
441
441
 
442
+ 新项目可先运行 `hb-sdk create my-miniapp` 获得 Vanilla JavaScript + Vite HelloWorld;模板只演示 Toast,业务代码可以直接替换。
443
+
442
444
  如果页面不需要小黑盒开放能力,可以不接入 SDK。SDK 导入时会自动启动握手,能力调用会自动等待;业务只需根据小程序是否开通网络权限选择身份流程。
443
445
 
444
446
  ## 交互控件与握手状态
@@ -1,6 +1,6 @@
1
1
  # CLI reference
2
2
 
3
- > Generated by `node packages/hb-sdk/skill/scripts/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
3
+ > Generated by `node packages/hb-sdk/scripts/skill/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
4
4
 
5
5
  ## Sources
6
6
 
@@ -40,7 +40,8 @@ hb-sdk build [--env <name>] [--verbose]
40
40
  hb-sdk login
41
41
  hb-sdk login status
42
42
  hb-sdk login clear
43
- hb-sdk doctor
43
+ hb-sdk skill install [--global] [--agent <agent>] [--all-agents] [--force]
44
+ hb-sdk doctor [--agent <agent>] [--all-agents] [--json]
44
45
  hb-sdk remote access
45
46
  hb-sdk remote entity list
46
47
  hb-sdk remote entity current
@@ -75,12 +76,16 @@ Top-level `hb-sdk deploy` has been hard-cut and must not be documented as a vali
75
76
  新项目可以直接从模板开始:
76
77
 
77
78
  ```bash
78
- npx @heybox/hb-sdk@latest create my-miniapp
79
+ npx @heybox/hb-sdk@alpha create my-miniapp
79
80
  cd my-miniapp
80
81
  npm install
81
82
  npm run dev
82
83
  ```
83
84
 
85
+ 默认产物是 Vanilla JavaScript + Vite HelloWorld,只演示一次 `ui.showToast()` 调用,并预填 `android`、`ios`、`ohos` 三个平台。Demo 可以整体删除,项目不绑定 Vue、TypeScript 或测试框架。
86
+
87
+ 当前 `0.8` 模板位于 alpha 发布线;稳定版本发布后,本页会将创建命令切回 `@latest`。
88
+
84
89
  已有项目则在项目目录运行 `npm run dev` 或 `hb-sdk dev`。
85
90
 
86
91
  Agent rules:
@@ -102,6 +107,8 @@ hb-sdk dev
102
107
 
103
108
  CLI 会启动页面服务并自动打开 Vue 3 本地调试台。左侧集中放置调用日志、Storage 和问题三个诊断页签,右侧保持稳定的小程序内容与设备预览。
104
109
 
110
+ 默认终端只显示启动结果、调试页地址、小程序地址和手机调试入口。排查启动问题时使用 `hb-sdk dev --verbose` 查看完整启动阶段;手机扫码调试凭证连续重试失败时,默认只在失败和恢复两次状态变化时提示。
111
+
105
112
  <img src="/assets/browser-dev-host-workbench.png" alt="小程序工坊 Vue 3 调试台" style="width: 100%; max-width: 1120px;" />
106
113
 
107
114
  浏览器调试入口不要求 CLI 登录或项目绑定。没有账号、绑定小程序或远端 Dev Context 时,页面和基础 Browser Mock 仍可启动;依赖这些上下文的能力会返回明确失败。远端管理、部署和发布仍要求完成登录与绑定。
@@ -137,7 +144,7 @@ Browser Mock 会自动在实时与兼容链路间切换。手机调试使用 `op
137
144
  | 参数 | 用途 |
138
145
  | -------------------------------- | -------------------------------- |
139
146
  | `--port <port>` | 指定页面开发服务端口。 |
140
- | `--browser-dev-host-port <port>` | 指定 Browser Dev Host 端口。 |
147
+ | `--browser-dev-host-port <port>` | 指定浏览器调试页服务端口。 |
141
148
  | `--no-open` | 启动后不自动打开浏览器。 |
142
149
  | `--verbose` | 出现问题时输出更详细的诊断信息。 |
143
150
 
@@ -272,8 +279,14 @@ Agent rules:
272
279
 
273
280
  Agent rules:
274
281
 
275
- - Use `hb-sdk doctor` for read-only diagnosis of local SDK, remote latest skill metadata, and local skill metadata.
276
- - Do not use `hb-sdk doctor` to auto-install skills; when installation or refresh is needed, tell the user to run `npx skills add https://open.xiaoheihe.cn/agent-skills/hb-sdk`.
277
- - If doctor reports `SDK_MISMATCH`, tell the user to upgrade `@heybox/hb-sdk@latest` before reinstalling the skill.
282
+ - Use `hb-sdk doctor [--agent <agent>] [--all-agents] [--json]` for read-only diagnosis of the locally installed SDK and its bundled Skill.
283
+ - Use `hb-sdk skill install` to install or refresh the Skill bundled with the matching npm package. Add `--global` for user scope, `--agent <agent>` for one Agent, or `--all-agents` for every supported Agent.
284
+ - If doctor reports `SDK_MISMATCH`, upgrade the project dependency to the matching @heybox/hb-sdk version before reinstalling the skill.
278
285
 
279
286
  ## Update reminders
287
+
288
+ ## 版本提醒
289
+
290
+ CLI 会从 npm 的 `latest` 标签检查稳定版更新,发现新版本时在命令结束后输出一行提醒,包含升级命令和目标版本的[更新日志](https://docs.xiaoheihe.cn/hb_sdk/changelog/)链接。提醒最多每 24 小时检查一次,请求超时或网络异常不会影响原命令;CI 环境默认不检查。
291
+
292
+ 需要临时关闭本地检查时,设置 `HB_SDK_NO_UPDATE_CHECK=1`。版本提醒不会读取 Alpha、Beta 或 RC 等预发布标签。
@@ -1,6 +1,6 @@
1
1
  # Smoke examples and anti-examples
2
2
 
3
- > Generated by `node packages/hb-sdk/skill/scripts/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
3
+ > Generated by `node packages/hb-sdk/scripts/skill/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
4
4
 
5
5
  ## Sources
6
6
 
@@ -1,6 +1,6 @@
1
1
  # LLM documentation index
2
2
 
3
- > Generated by `node packages/hb-sdk/skill/scripts/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
3
+ > Generated by `node packages/hb-sdk/scripts/skill/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
4
4
 
5
5
  ## Sources
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Recipes
2
2
 
3
- > Generated by `node packages/hb-sdk/skill/scripts/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
3
+ > Generated by `node packages/hb-sdk/scripts/skill/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
4
4
 
5
5
  ## Sources
6
6
 
@@ -26,6 +26,8 @@
26
26
 
27
27
  # 快速开始
28
28
 
29
+ 新项目可先运行 `hb-sdk create my-miniapp` 获得 Vanilla JavaScript + Vite HelloWorld;模板只演示 Toast,业务代码可以直接替换。
30
+
29
31
  如果页面不需要小黑盒开放能力,可以不接入 SDK。SDK 导入时会自动启动握手,能力调用会自动等待;业务只需根据小程序是否开通网络权限选择身份流程。
30
32
 
31
33
  ## 交互控件与握手状态
@@ -523,7 +525,7 @@ async function handleSubmit() {
523
525
 
524
526
  ## 普通分享
525
527
 
526
- 普通分享只支持一个默认分区,并且配置 `post` 时不要同时指定站外 `channel`。
528
+ 普通分享的落地页固定为当前小程序的 `common_share`,不接受自定义 `url`。普通分享只支持一个默认分区,并且配置 `post` 时不要同时指定站外 `channel`。
527
529
 
528
530
  ```ts
529
531
  import { share } from '@heybox/hb-sdk'
@@ -555,7 +557,7 @@ await share.screenshot({
555
557
 
556
558
  ## 恢复分享页面状态
557
559
 
558
- 使用默认通用分享链接时,可以通过 `extra` 携带由小程序自行定义的页面状态。分享方只负责写入状态,接收方负责决定如何使用:
560
+ 通过固定通用分享链接分享时,可以使用 `extra` 携带由小程序自行定义的页面状态。分享方只负责写入状态,接收方负责决定如何使用:
559
561
 
560
562
  ```ts
561
563
  await share.showShareMenu({
@@ -588,7 +590,7 @@ if (sharedState && typeof sharedState === 'object' && !Array.isArray(sharedState
588
590
  }
589
591
  ```
590
592
 
591
- `getExtra()` 不依赖异步请求;没有有效数据时返回 `undefined`,业务应回退到默认首页。`extra` 只支持 JSON-compatible 数据,最多 8 层,单个数组或对象最多 64 项,内容不超过 128 字节;不能与自定义 `url` 同时使用,也不要存放 token、个人信息等敏感数据。`copyLink()` 不会继承当前启动链接中的 `extra`,只携带本次显式传入的数据。
593
+ `getExtra()` 不依赖异步请求;没有有效数据时返回 `undefined`,业务应回退到默认首页。`extra` 只支持 JSON-compatible 数据,最多 8 层,单个数组或对象最多 64 项,内容不超过 128 字节,也不要存放 token、个人信息等敏感数据。`copyLink()` 不会继承当前启动链接中的 `extra`,只携带本次显式传入的数据。
592
594
 
593
595
  ## 参数边界
594
596
 
@@ -1,6 +1,6 @@
1
1
  # Safety boundaries
2
2
 
3
- > Generated by `node packages/hb-sdk/skill/scripts/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
3
+ > Generated by `node packages/hb-sdk/scripts/skill/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
4
4
 
5
5
  ## Sources
6
6
 
package/skill/skill.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.8.0-alpha.2+skill.417e5072238c",
3
+ "skillVersion": "0.8.0-alpha.9+skill.94bc5bff8aed",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.8.0-alpha.2",
7
- "compatibility": "0.8.0-alpha.2"
6
+ "version": "0.8.0-alpha.9",
7
+ "compatibility": "0.8.0-alpha.9"
8
8
  },
9
- "source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
10
- "integrity": "sha256-417e5072238c0b2a53836824d60639046935ad28ca337a63d82016421c97127b"
9
+ "distribution": {
10
+ "type": "npm",
11
+ "package": "@heybox/hb-sdk",
12
+ "version": "0.8.0-alpha.9",
13
+ "path": "skill"
14
+ },
15
+ "integrity": "sha256-94bc5bff8aed44fa6e6ca3066e8ccfc864b57631c64e76763717a36e5672f2df"
11
16
  }
@@ -43,7 +43,7 @@ export interface MiniProgramShareModule {
43
43
  */
44
44
  getExtra(): MiniProgramShareExtraValue | undefined;
45
45
  /**
46
- * 展示基础分享面板。
46
+ * 展示以当前小程序通用分享页为落地页的基础分享面板。
47
47
  *
48
48
  * @since 0.2.0-alpha.0
49
49
  * @hbPlatform android
@@ -6,7 +6,7 @@ export type ShowShareMenuPayload = MiniProgramShowShareMenuOptions;
6
6
  /** `share.showShareMenu` 返回值由客户端协议决定。 */
7
7
  export type ShowShareMenuResult = unknown;
8
8
  /**
9
- * 展示基础分享面板。
9
+ * 展示以当前小程序通用分享页为落地页的基础分享面板。
10
10
  *
11
11
  * @param requester - 底层 bridge 请求能力。
12
12
  * @param options - 基础分享参数。
@@ -25,16 +25,14 @@ export interface MiniProgramSharePostOptions {
25
25
  * 展示基础分享面板的配置。
26
26
  *
27
27
  * @remarks
28
- * 该配置只暴露基础分享字段,不暴露宿主内部上报、回调、自定义按钮等协议参数。
28
+ * 分享落地页固定为当前小程序的通用分享页。该配置只暴露基础分享字段,不暴露宿主内部上报、回调、自定义按钮等协议参数。
29
29
  */
30
30
  export interface MiniProgramShowShareMenuOptions {
31
31
  /** 分享标题。 */
32
32
  title: string;
33
33
  /** 分享描述。 */
34
34
  desc: string;
35
- /** 分享落地页 URL;不传时由宿主 runtime 生成当前小程序的通用分享页。 */
36
- url?: string;
37
- /** 分享扩展数据;最多 8 层、单层最多 64 项、容量不超过 128 字节,且不能与 `url` 同时使用。 */
35
+ /** 分享扩展数据;最多 8 层、单层最多 64 项、容量不超过 128 字节。 */
38
36
  extra?: MiniProgramShareExtraValue;
39
37
  /** 分享缩略图 URL。 */
40
38
  imageUrl?: string;
@@ -1,6 +1,2 @@
1
1
  export declare const HB_SDK_PACKAGE_NAME = "@heybox/hb-sdk";
2
2
  export declare const HB_SDK_SKILL_NAME = "hb-sdk";
3
- export declare const HB_SDK_AGENT_SKILLS_BASE_URL = "https://open.xiaoheihe.cn/agent-skills";
4
- export declare const HB_SDK_SKILL_SOURCE = "https://open.xiaoheihe.cn/agent-skills/hb-sdk";
5
- export declare const HB_SDK_SKILL_INDEX_URL = "https://open.xiaoheihe.cn/agent-skills/.well-known/agent-skills/index.json";
6
- export declare const HB_SDK_SKILL_INSTALL_COMMAND = "npx skills add https://open.xiaoheihe.cn/agent-skills/hb-sdk";
@@ -1,204 +0,0 @@
1
- 'use strict';
2
-
3
- var fs$1 = require('node:fs');
4
- var fs = require('node:fs/promises');
5
- var os = require('node:os');
6
- var path = require('node:path');
7
- var index = require('./index-BL5eEPap.cjs');
8
- require('node:module');
9
- require('path');
10
- require('os');
11
- require('readline');
12
- require('tty');
13
- require('assert');
14
- require('events');
15
- require('stream');
16
- require('buffer');
17
- require('util');
18
-
19
- const DEFAULT_TIMEOUT_MS = 3000;
20
- const PACKAGE_JSON_CANDIDATES = [
21
- path.resolve(__dirname, '..', 'package.json'),
22
- path.resolve(__dirname, '..', '..', 'package.json'),
23
- path.resolve(__dirname, '..', '..', '..', 'package.json'),
24
- ];
25
- async function runDoctorCommand(runtime = {}) {
26
- const logger = runtime.logger ?? index.createCliLogger();
27
- const result = await logger.task('正在检查 Agent Skill 元数据', () => getDoctorResult(runtime), {
28
- successText: 'Agent Skill 检查完成',
29
- });
30
- printDoctorResult(result, logger);
31
- printDoctorNextStep(result, logger);
32
- return result;
33
- }
34
- async function getDoctorResult(runtime = {}) {
35
- const currentSdkVersion = await readCurrentSdkVersion(runtime.packageJsonFiles);
36
- const localSkillJsonPath = await resolveLocalSkillJsonPath(runtime);
37
- let remoteSkill;
38
- try {
39
- remoteSkill = await fetchRemoteSkill(runtime);
40
- }
41
- catch {
42
- return {
43
- currentSdkVersion,
44
- localSkillJsonPath,
45
- status: 'REMOTE_UNAVAILABLE',
46
- };
47
- }
48
- if (remoteSkill?.sdk?.version !== currentSdkVersion) {
49
- return {
50
- currentSdkVersion,
51
- localSkillJsonPath,
52
- remoteSkill,
53
- status: 'SDK_MISMATCH',
54
- };
55
- }
56
- const localSkill = await readLocalSkillManifest(localSkillJsonPath);
57
- if (!localSkill.exists) {
58
- return {
59
- currentSdkVersion,
60
- localSkillJsonPath,
61
- remoteSkill,
62
- status: 'SKILL_MISSING',
63
- };
64
- }
65
- if (!localSkill.manifest ||
66
- localSkill.manifest.name !== index.HB_SDK_SKILL_NAME ||
67
- localSkill.manifest.skillVersion !== remoteSkill.version ||
68
- localSkill.manifest.sdk?.version !== remoteSkill.sdk?.version) {
69
- return {
70
- currentSdkVersion,
71
- localSkillJsonPath,
72
- localSkillVersion: localSkill.manifest?.skillVersion,
73
- remoteSkill,
74
- status: 'SKILL_OUTDATED',
75
- };
76
- }
77
- return {
78
- currentSdkVersion,
79
- localSkillJsonPath,
80
- localSkillVersion: localSkill.manifest.skillVersion,
81
- remoteSkill,
82
- status: 'OK',
83
- };
84
- }
85
- function printDoctorResult(result, logger) {
86
- logger.section('Doctor');
87
- logger.info(`SDK version: ${result.currentSdkVersion}`);
88
- logger.info(`Remote skill: ${result.remoteSkill?.version ? `${result.remoteSkill.version} (sdk ${result.remoteSkill.sdk?.version ?? 'unknown'})` : 'unavailable'}`);
89
- logger.info(`Local skill: ${result.localSkillVersion ?? 'missing'}`);
90
- logger.debug(`Local skill path: ${result.localSkillJsonPath}`);
91
- logger.info(`Status: ${result.status}`);
92
- }
93
- function printDoctorNextStep(result, logger) {
94
- if (result.status === 'OK') {
95
- logger.success('Skill is up to date.');
96
- return;
97
- }
98
- if (result.status === 'SDK_MISMATCH') {
99
- logger.warn(`Current SDK does not match the latest skill metadata. Upgrade with: npm i -D ${index.HB_SDK_PACKAGE_NAME}@latest`);
100
- logger.info(`Then install or refresh the skill manually: ${formatSkillInstallCommand(result)}`);
101
- return;
102
- }
103
- if (result.status === 'REMOTE_UNAVAILABLE') {
104
- logger.warn('Remote skill metadata is unavailable. Try again later.');
105
- logger.info(`Manual install command: ${index.HB_SDK_SKILL_INSTALL_COMMAND}`);
106
- return;
107
- }
108
- logger.info(`Install or refresh the skill manually: ${formatSkillInstallCommand(result)}`);
109
- }
110
- function formatSkillInstallCommand(result) {
111
- return `npx skills add ${result.remoteSkill?.source || index.HB_SDK_SKILL_SOURCE}`;
112
- }
113
- async function fetchRemoteSkill(runtime) {
114
- const fetchImpl = runtime.fetchImpl ?? fetch;
115
- const controller = new AbortController();
116
- const timeout = setTimeout(() => controller.abort(), runtime.timeoutMs ?? DEFAULT_TIMEOUT_MS);
117
- try {
118
- const response = await fetchImpl(runtime.remoteIndexUrl ?? index.HB_SDK_SKILL_INDEX_URL, {
119
- headers: {
120
- accept: 'application/json',
121
- },
122
- signal: controller.signal,
123
- });
124
- if (!response.ok) {
125
- throw new Error(`remote skill index returned ${response.status}`);
126
- }
127
- const index$1 = (await response.json());
128
- const skill = index$1.skills?.find(item => item.name === index.HB_SDK_SKILL_NAME);
129
- if (!skill?.version || skill.sdk?.package !== index.HB_SDK_PACKAGE_NAME || !skill.sdk.version) {
130
- throw new Error('remote hb-sdk skill metadata is incomplete');
131
- }
132
- return skill;
133
- }
134
- finally {
135
- clearTimeout(timeout);
136
- }
137
- }
138
- async function readLocalSkillManifest(skillJsonPath) {
139
- if (!(await pathExists(skillJsonPath))) {
140
- return {
141
- exists: false,
142
- };
143
- }
144
- try {
145
- return {
146
- exists: true,
147
- manifest: JSON.parse(await fs.readFile(skillJsonPath, 'utf8')),
148
- };
149
- }
150
- catch {
151
- return {
152
- exists: true,
153
- };
154
- }
155
- }
156
- async function readCurrentSdkVersion(packageJsonCandidates = PACKAGE_JSON_CANDIDATES) {
157
- for (const candidate of packageJsonCandidates) {
158
- if (!(await pathExists(candidate))) {
159
- continue;
160
- }
161
- const packageJson = JSON.parse(await fs.readFile(candidate, 'utf8'));
162
- if (typeof packageJson.version === 'string' && packageJson.version) {
163
- return packageJson.version;
164
- }
165
- }
166
- throw new Error('未能读取 @heybox/hb-sdk 当前版本号');
167
- }
168
- async function resolveLocalSkillJsonPath(runtime) {
169
- if (runtime.localSkillJsonPath) {
170
- return runtime.localSkillJsonPath;
171
- }
172
- const projectSkillJsonPath = await findProjectSkillJsonPath(runtime.cwd ?? process.cwd());
173
- if (projectSkillJsonPath) {
174
- return projectSkillJsonPath;
175
- }
176
- const codexHome = runtime.codexHome ?? runtime.env?.CODEX_HOME ?? process.env.CODEX_HOME ?? path.join(os.homedir(), '.codex');
177
- return path.join(codexHome, 'skills', index.HB_SDK_SKILL_NAME, 'skill.json');
178
- }
179
- async function findProjectSkillJsonPath(startDir) {
180
- let current = path.resolve(startDir);
181
- while (true) {
182
- const skillJsonPath = path.join(current, '.agents', 'skills', index.HB_SDK_SKILL_NAME, 'skill.json');
183
- if ((await pathExists(path.join(current, 'package.json'))) && (await pathExists(skillJsonPath))) {
184
- return skillJsonPath;
185
- }
186
- const parent = path.dirname(current);
187
- if (parent === current) {
188
- return undefined;
189
- }
190
- current = parent;
191
- }
192
- }
193
- async function pathExists(filePath) {
194
- try {
195
- await fs.access(filePath, fs$1.constants.F_OK);
196
- return true;
197
- }
198
- catch {
199
- return false;
200
- }
201
- }
202
-
203
- exports.getDoctorResult = getDoctorResult;
204
- exports.runDoctorCommand = runDoctorCommand;