@heybox/hb-sdk 0.8.0-alpha → 0.8.0-alpha.12

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 (96) hide show
  1. package/CHANGELOG.md +106 -395
  2. package/README.md +107 -24
  3. package/THIRD_PARTY_NOTICES.md +1755 -0
  4. package/dist/cli-chunks/{build-DJWFSM1B.cjs → build-DNtjBmyy.cjs} +8 -5
  5. package/dist/cli-chunks/{context-DV2UK1Nz.cjs → context-CO_3KgM_.cjs} +39 -81
  6. package/dist/cli-chunks/{create-2HfoB48V.cjs → create-DG8JxrPU.cjs} +2 -2
  7. package/dist/cli-chunks/{dev-Dgt2zS9k.cjs → dev-C5U1Lo4e.cjs} +404 -577
  8. package/dist/cli-chunks/doctor-B50OXvrj.cjs +65 -0
  9. package/dist/cli-chunks/{index-D62ANeBv.cjs → index-B4nFqf-3.cjs} +50 -30
  10. package/dist/cli-chunks/{index-BjoSXl8C.cjs → index-B8FK1ojC.cjs} +2 -2
  11. package/dist/cli-chunks/{index.esm-CigcxJ2B.cjs → index.esm-DiX5WKSp.cjs} +8 -7
  12. package/dist/cli-chunks/{login-Cumknwdx.cjs → login-CBwmxsEK.cjs} +2 -2
  13. package/dist/cli-chunks/{project-vite-CcE-HMmd.cjs → project-vite-DWpmHOsV.cjs} +1 -1
  14. package/dist/cli-chunks/{remote-DDdP3xcE.cjs → remote-Dt-U4gDD.cjs} +57 -25
  15. package/dist/cli-chunks/{runtime-gate-DFjw66kF.cjs → runtime-gate-CMnGCdfq.cjs} +11 -3
  16. package/dist/cli-chunks/{runtime-permission-env-CjsCe5bp.cjs → runtime-permission-env-BcUsO3nG.cjs} +351 -0
  17. package/dist/cli-chunks/{session-BDi_AZSv.cjs → session-yy543BIB.cjs} +1 -1
  18. package/dist/cli-chunks/skill-B4SWt2o6.cjs +83 -0
  19. package/dist/cli-chunks/version-CmizPu7D.cjs +8 -0
  20. package/dist/cli.cjs +1 -1
  21. package/dist/devtools/browser-dev-host/assets/browser-dev-host-TzYf9L6C.js +99 -0
  22. package/dist/devtools/browser-dev-host/assets/heybox-logo-CogNENsk.svg +6 -0
  23. package/dist/devtools/browser-dev-host/assets/index-C5MZZDa5.js +567 -0
  24. package/dist/devtools/browser-dev-host/assets/index-P-ra4m1y.css +1 -0
  25. package/dist/devtools/browser-dev-host/assets/workbench-state-BwV7bm4n.js +5 -0
  26. package/dist/devtools/browser-dev-host/index.html +6 -435
  27. package/dist/index.cjs.js +1023 -29
  28. package/dist/index.esm.js +1023 -30
  29. package/dist/protocol.cjs.js +381 -37
  30. package/dist/protocol.esm.js +355 -38
  31. package/dist/templates/{vue3-vite-ts → vanilla-vite-js}/.gitignore.ejs +0 -1
  32. package/dist/templates/vanilla-vite-js/README.md.ejs +14 -0
  33. package/dist/templates/vanilla-vite-js/index.html.ejs +20 -0
  34. package/dist/templates/vanilla-vite-js/package.json.ejs +22 -0
  35. package/dist/templates/vanilla-vite-js/src/assets/heybox-logo.svg +8 -0
  36. package/dist/templates/vanilla-vite-js/src/main.js +39 -0
  37. package/dist/templates/vanilla-vite-js/src/styles.css +155 -0
  38. package/dist/templates/{vue3-vite-ts/vite.config.ts → vanilla-vite-js/vite.config.js} +1 -2
  39. package/dist/vite.cjs.js +281 -13
  40. package/dist/vite.esm.js +281 -13
  41. package/package.json +34 -11
  42. package/skill/SKILL.md +22 -20
  43. package/skill/references/api-protocol.md +100 -6
  44. package/skill/references/api-root.md +199 -28
  45. package/skill/references/cli.md +41 -24
  46. package/skill/references/examples.md +30 -1
  47. package/skill/references/llms-index.md +1 -1
  48. package/skill/references/recipes.md +139 -36
  49. package/skill/references/safety-boundaries.md +20 -5
  50. package/skill/skill.json +10 -5
  51. package/types/core/client.d.ts +17 -1
  52. package/types/core/mini-dev-console.d.ts +36 -0
  53. package/types/core/sdk.d.ts +3 -0
  54. package/types/core/singleton.d.ts +3 -0
  55. package/types/index.d.ts +4 -2
  56. package/types/miniapp-manifest/index.d.ts +1 -0
  57. package/types/miniapp-manifest/node.d.ts +3 -0
  58. package/types/miniapp-manifest/permissions.d.ts +37 -0
  59. package/types/miniapp-manifest/schema.d.ts +5 -0
  60. package/types/modules/files/index.d.ts +5 -0
  61. package/types/modules/files/registry.d.ts +35 -0
  62. package/types/modules/files/types.d.ts +159 -0
  63. package/types/modules/network/index.d.ts +50 -3
  64. package/types/modules/share/index.d.ts +1 -1
  65. package/types/modules/share/show-share-menu.d.ts +1 -1
  66. package/types/modules/share/types.d.ts +2 -4
  67. package/types/protocol/capabilities.d.ts +2 -2
  68. package/types/protocol/constants.d.ts +1 -1
  69. package/types/protocol/guards.d.ts +1 -1
  70. package/types/protocol/types.d.ts +1 -1
  71. package/types/protocol.d.ts +4 -3
  72. package/types/skill-metadata.d.ts +0 -4
  73. package/types/vite/index.d.ts +3 -1
  74. package/dist/cli-chunks/doctor-C95gIao_.cjs +0 -204
  75. package/dist/devtools/browser-dev-host/main.js +0 -12263
  76. package/dist/templates/vue3-vite-ts/README.md.ejs +0 -47
  77. package/dist/templates/vue3-vite-ts/index.html.ejs +0 -12
  78. package/dist/templates/vue3-vite-ts/package.json.ejs +0 -33
  79. package/dist/templates/vue3-vite-ts/src/App.vue +0 -78
  80. package/dist/templates/vue3-vite-ts/src/__tests__/App.spec.ts +0 -148
  81. package/dist/templates/vue3-vite-ts/src/auth-handoff.ts +0 -46
  82. package/dist/templates/vue3-vite-ts/src/main.ts +0 -5
  83. package/dist/templates/vue3-vite-ts/src/styles.css +0 -60
  84. package/dist/templates/vue3-vite-ts/src/vite-env.d.ts +0 -1
  85. package/dist/templates/vue3-vite-ts/tsconfig.app.json +0 -17
  86. package/dist/templates/vue3-vite-ts/tsconfig.json +0 -11
  87. package/dist/templates/vue3-vite-ts/tsconfig.node.json +0 -11
  88. package/dist/templates/vue3-vite-ts/vitest.config.ts +0 -10
  89. package/skill/scripts/check-references.mjs +0 -14
  90. package/skill/scripts/markdown-sections.mjs +0 -36
  91. package/skill/scripts/package-skill.mjs +0 -60
  92. package/skill/scripts/package-skill.sh +0 -6
  93. package/skill/scripts/skill-metadata.mjs +0 -77
  94. package/skill/scripts/sync-agent-skills-payload.mjs +0 -359
  95. package/skill/scripts/sync-references.mjs +0 -794
  96. package/skill/scripts/validate-skill.mjs +0 -263
package/dist/vite.esm.js CHANGED
@@ -5,7 +5,30 @@ import { AsyncLocalStorage } from 'node:async_hooks';
5
5
  /** 构建时替换为当前发布包的实际版本。 */
6
6
  const HB_SDK_VERSION = typeof undefined === 'string'
7
7
  ? undefined
8
- : '0.8.0-alpha';
8
+ : '0.8.0-alpha.12';
9
+
10
+ /**
11
+ * iframe 与调试台页面的开发期 console 捕获转发。
12
+ *
13
+ * 双条件门控(iframe 转发):
14
+ * 1. 构建期:`hb-sdk dev`(vite serve)注入 `false`;`hb-sdk build` /
15
+ * `vite build`(生产)永不注入或替换为 `false`,本模块被死代码消除。
16
+ * 2. 运行期:仅在 `window.name` 为 `__hb_sdk_mini_dev__` 的调试 iframe 中激活,
17
+ * 用户设备上的正式运行环境没有该标记。
18
+ *
19
+ * 无侵入 patch `console.log/debug/info/warn/error`:原样放行(DevTools 不受影响)+
20
+ * 通过 `window.parent.postMessage` 转发给调试台(CSP 的 connect-src 不约束 postMessage,
21
+ * 网络上报由调试台页面代理)。发送全程静默:失败不得回打 console,避免自触发死循环。
22
+ *
23
+ * 激活时机:由 SDK 默认单例初始化时调用(业务 `import '@heybox/hb-sdk'` 即生效);
24
+ * iframe 标记由调试台 `iframe.name` 与 vite dev 注入的无依赖 bootstrap 共同设置。
25
+ * 调试台页面自身(runtime 跑在这里,`[hb-sdk-runtime]` 日志不经过 iframe)另用
26
+ * `installMiniDevConsoleSelfCapture` 接入「日志」页签(source: 'host')。
27
+ */
28
+ const MINI_DEV_IFRAME_WINDOW_NAME = '__hb_sdk_mini_dev__';
29
+ const MINI_DEV_CONSOLE_EVENT_TYPE = 'hb-sdk:mini-dev-console';
30
+ /** 调试台页面与 iframe bootstrap 共用的已安装标记(window/console 上的属性名)。 */
31
+ const MINI_DEV_CONSOLE_INSTALL_FLAG = '__hb_sdk_mini_dev_console_installed__';
9
32
 
10
33
  var re = {exports: {}};
11
34
 
@@ -2792,6 +2815,197 @@ function requireSemver () {
2792
2815
 
2793
2816
  var semverExports = requireSemver();
2794
2817
 
2818
+ const MINI_PROGRAM_MESSAGE_NAMESPACE = 'heybox:miniprogram';
2819
+ const MINI_PROGRAM_MESSAGE_VERSION = 2;
2820
+ const MINI_PROGRAM_BRIDGE_NONCE_PARAM = 'hb_mini_bridge_nonce';
2821
+
2822
+ const MINI_PROGRAM_PERMISSION_KEYS = [
2823
+ 'userInfo',
2824
+ 'steamLibrary',
2825
+ 'share',
2826
+ 'storage',
2827
+ 'filesystem',
2828
+ 'clipboard',
2829
+ 'leaderboard',
2830
+ 'network',
2831
+ ];
2832
+ const MINI_PROGRAM_PERMISSION_CATALOG = [
2833
+ {
2834
+ key: 'userInfo',
2835
+ name: '用户信息',
2836
+ description: '登录小程序并读取当前用户的授权信息。',
2837
+ access: 'declaration',
2838
+ risk: 'medium',
2839
+ config: {},
2840
+ methods: ['auth.login', 'user.getInfo'],
2841
+ conditions: ['继续执行黑盒登录、用户授权和可信手势规则。'],
2842
+ },
2843
+ {
2844
+ key: 'steamLibrary',
2845
+ name: 'Steam 游戏库',
2846
+ description: '读取当前用户授权的 Steam 游戏库。',
2847
+ access: 'declaration',
2848
+ risk: 'high',
2849
+ config: {},
2850
+ methods: ['user.getSteamGameList'],
2851
+ conditions: ['继续执行账号绑定和数据可用性规则。'],
2852
+ },
2853
+ {
2854
+ key: 'share',
2855
+ name: '分享',
2856
+ description: '使用小程序分享、分享菜单和截图能力。',
2857
+ access: 'declaration',
2858
+ risk: 'medium',
2859
+ config: {},
2860
+ methods: ['share.copyLink', 'share.showShareMenu', 'share.screenshot'],
2861
+ conditions: ['继续执行分享参数校验和 Host 支持检查。'],
2862
+ },
2863
+ {
2864
+ key: 'storage',
2865
+ name: '键值存储',
2866
+ description: '读写按小程序隔离的简单键值数据。',
2867
+ access: 'declaration',
2868
+ risk: 'medium',
2869
+ config: {},
2870
+ methods: ['storage.getStorage', 'storage.setStorage'],
2871
+ conditions: ['仅用于简单键值存储,不包含文件系统。'],
2872
+ },
2873
+ {
2874
+ key: 'filesystem',
2875
+ name: '文件系统',
2876
+ description: '访问小程序沙盒文件和用户选择的外部文件。',
2877
+ access: 'declaration',
2878
+ risk: 'high',
2879
+ config: {},
2880
+ methods: [
2881
+ 'network.download',
2882
+ 'files.pickFiles',
2883
+ 'files.pickDirectory',
2884
+ 'files.saveFile',
2885
+ 'file.create',
2886
+ 'file.remove',
2887
+ 'file.exists',
2888
+ 'file.readText',
2889
+ 'file.writeText',
2890
+ 'file.readBytes',
2891
+ 'file.writeBytes',
2892
+ 'file.stat',
2893
+ 'directory.create',
2894
+ 'directory.remove',
2895
+ 'directory.exists',
2896
+ 'directory.list',
2897
+ ],
2898
+ conditions: ['外部文件继续要求有效的用户选择、会话句柄和匹配的读写模式。'],
2899
+ },
2900
+ {
2901
+ key: 'clipboard',
2902
+ name: '剪贴板',
2903
+ description: '向系统剪贴板写入文本。',
2904
+ access: 'declaration',
2905
+ risk: 'medium',
2906
+ config: {},
2907
+ methods: ['device.setClipboard'],
2908
+ conditions: ['继续执行文本长度和 Host 支持限制。'],
2909
+ },
2910
+ {
2911
+ key: 'leaderboard',
2912
+ name: '排行榜',
2913
+ description: '读写小程序云排行榜。',
2914
+ access: 'declaration',
2915
+ risk: 'medium',
2916
+ config: {},
2917
+ methods: [
2918
+ 'cloud.leaderboard.submit',
2919
+ 'cloud.leaderboard.getList',
2920
+ 'cloud.leaderboard.getCurrentUserEntry',
2921
+ 'cloud.leaderboard.deleteCurrentUserEntry',
2922
+ 'cloud.leaderboard.getInfo',
2923
+ ],
2924
+ conditions: ['排行榜必须已创建,用户和资源规则保持不变。'],
2925
+ },
2926
+ {
2927
+ key: 'network',
2928
+ name: '网络',
2929
+ description: '通过 network 模块请求或下载外部资源。',
2930
+ access: 'platform-approval',
2931
+ risk: 'high',
2932
+ config: {
2933
+ useOfficialDomain: {
2934
+ type: 'boolean',
2935
+ required: false,
2936
+ default: false,
2937
+ description: '是否申请访问小黑盒官方域名。',
2938
+ },
2939
+ },
2940
+ methods: ['network.request', 'network.download'],
2941
+ conditions: ['声明后仍需平台批准,并继续执行网络安全策略。'],
2942
+ },
2943
+ ];
2944
+ new Set(MINI_PROGRAM_PERMISSION_KEYS);
2945
+
2946
+ new Set(MINI_PROGRAM_PERMISSION_KEYS);
2947
+
2948
+ const MINIAPP_PERMISSION_KEYS = MINI_PROGRAM_PERMISSION_KEYS;
2949
+ function parseMiniappPermissions(value, options) {
2950
+ const sourceLabel = options.sourceLabel ?? 'package.json#heybox.permissions';
2951
+ if (!options.present) {
2952
+ if (requiresExplicitPermissions(options.sdkVersion)) {
2953
+ throw new Error(`${sourceLabel} 在 @heybox/hb-sdk ${options.sdkVersion} 中必须声明;无权限需求时请配置空对象 {}`);
2954
+ }
2955
+ return { declared: false };
2956
+ }
2957
+ if (!isRecord$1(value)) {
2958
+ throw new Error(`${sourceLabel} 必须是 JSON 对象`);
2959
+ }
2960
+ const knownKeys = new Set(MINIAPP_PERMISSION_KEYS);
2961
+ for (const key of Object.keys(value)) {
2962
+ if (!knownKeys.has(key))
2963
+ throw new Error(`${sourceLabel} 包含未知权限:${key}`);
2964
+ }
2965
+ const permissions = {};
2966
+ for (const key of MINIAPP_PERMISSION_KEYS) {
2967
+ if (!Object.prototype.hasOwnProperty.call(value, key))
2968
+ continue;
2969
+ const declaration = value[key];
2970
+ const itemLabel = `${sourceLabel}.${key}`;
2971
+ if (!isRecord$1(declaration))
2972
+ throw new Error(`${itemLabel} 必须是 JSON 对象`);
2973
+ const definition = MINI_PROGRAM_PERMISSION_CATALOG.find((item) => item.key === key);
2974
+ if (!definition)
2975
+ throw new Error(`权限目录缺少定义:${key}`);
2976
+ const allowedFields = new Set(['enabled', ...Object.keys(definition.config)]);
2977
+ for (const field of Object.keys(declaration)) {
2978
+ if (!allowedFields.has(field))
2979
+ throw new Error(`${itemLabel} 包含未知字段:${field}`);
2980
+ }
2981
+ if (typeof declaration.enabled !== 'boolean')
2982
+ throw new Error(`${itemLabel}.enabled 必须是 boolean`);
2983
+ let useOfficialDomain = false;
2984
+ if (key === 'network') {
2985
+ if (declaration.useOfficialDomain !== undefined && typeof declaration.useOfficialDomain !== 'boolean') {
2986
+ throw new Error(`${itemLabel}.useOfficialDomain 必须是 boolean`);
2987
+ }
2988
+ useOfficialDomain = declaration.useOfficialDomain === true;
2989
+ }
2990
+ if (!declaration.enabled)
2991
+ continue;
2992
+ permissions[key] = key === 'network' ? { enabled: true, useOfficialDomain } : { enabled: true };
2993
+ }
2994
+ return { declared: true, permissions: permissions };
2995
+ }
2996
+ function requiresExplicitPermissions(sdkVersion) {
2997
+ const parsed = semverExports.parse(sdkVersion);
2998
+ if (!parsed)
2999
+ throw new Error(`sdkVersion 必须是合法 SemVer:${sdkVersion}`);
3000
+ return parsed.major > 0 || parsed.minor >= 9;
3001
+ }
3002
+ function getMissingPermissionsWarning(sourceLabel = 'package.json#heybox.permissions') {
3003
+ return `${sourceLabel} 尚未声明。当前按 0.8 兼容行为构建;0.9.0 起将拒绝构建,请尽快补充权限声明(无权限需求时配置 {})。`;
3004
+ }
3005
+ function isRecord$1(value) {
3006
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
3007
+ }
3008
+
2795
3009
  const MINIAPP_PLATFORM_VALUES = ['android', 'ios', 'ohos', 'windows', 'macos', 'linux'];
2796
3010
  function validateMiniappPackageVersionForBuild(version) {
2797
3011
  return validateMiniappManifestVersion(version, 'package.json.version');
@@ -2805,7 +3019,13 @@ function validateMiniappManifestVersion(version, sourceLabel = 'manifest.version
2805
3019
  }
2806
3020
  function renderMiniappManifest(manifest) {
2807
3021
  const platforms = validateMiniappPlatforms(manifest.platforms, 'manifest.platforms');
2808
- return `${JSON.stringify({ version: manifest.version, sdkVersion: manifest.sdkVersion, platforms }, null, 2)}\n`;
3022
+ const output = {
3023
+ version: manifest.version,
3024
+ sdkVersion: manifest.sdkVersion,
3025
+ platforms,
3026
+ ...(manifest.permissions === undefined ? {} : { permissions: manifest.permissions }),
3027
+ };
3028
+ return `${JSON.stringify(output, null, 2)}\n`;
2809
3029
  }
2810
3030
  function validateMiniappPlatforms(platforms, sourceLabel = 'platforms') {
2811
3031
  if (!Array.isArray(platforms) || platforms.length === 0) {
@@ -2860,6 +3080,21 @@ function findNearestPackageJsonPath(startDir) {
2860
3080
  }
2861
3081
  }
2862
3082
  function readMiniappVersionFromPackageJson(root) {
3083
+ return readMiniappPackageJson(root, true).version;
3084
+ }
3085
+ function readMiniappPermissionsFromPackageJson(root, sdkVersion) {
3086
+ const { packageJson } = readMiniappPackageJson(root, false);
3087
+ const heybox = packageJson.heybox;
3088
+ if (heybox !== undefined && !isRecord(heybox)) {
3089
+ throw new Error('@heybox/hb-sdk 提示:package.json#heybox 必须是 JSON 对象');
3090
+ }
3091
+ const present = isRecord(heybox) && Object.prototype.hasOwnProperty.call(heybox, 'permissions');
3092
+ return parseMiniappPermissions(isRecord(heybox) ? heybox.permissions : undefined, {
3093
+ present,
3094
+ sdkVersion,
3095
+ });
3096
+ }
3097
+ function readMiniappPackageJson(root, requireVersion) {
2863
3098
  const packageJsonPath = findNearestPackageJsonPath(root);
2864
3099
  let content;
2865
3100
  try {
@@ -2875,10 +3110,13 @@ function readMiniappVersionFromPackageJson(root) {
2875
3110
  catch (error) {
2876
3111
  throw new Error(`@heybox/hb-sdk 解析 package.json 失败:${formatReason(error)}`);
2877
3112
  }
2878
- if (typeof packageJson.version !== 'string' || packageJson.version.trim() === '') {
3113
+ if (requireVersion && (typeof packageJson.version !== 'string' || packageJson.version.trim() === '')) {
2879
3114
  throw new Error('@heybox/hb-sdk 提示:package.json.version 必须是非空字符串');
2880
3115
  }
2881
- return packageJson.version.trim();
3116
+ return { packageJson, version: typeof packageJson.version === 'string' ? packageJson.version.trim() : '' };
3117
+ }
3118
+ function isRecord(value) {
3119
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
2882
3120
  }
2883
3121
  function formatReason(error) {
2884
3122
  if (error instanceof Error && error.message) {
@@ -11317,10 +11555,6 @@ function parse(html, options) {
11317
11555
  return Parser.parse(html, options);
11318
11556
  }
11319
11557
 
11320
- const MINI_PROGRAM_MESSAGE_NAMESPACE = 'heybox:miniprogram';
11321
- const MINI_PROGRAM_MESSAGE_VERSION = 2;
11322
- const MINI_PROGRAM_BRIDGE_NONCE_PARAM = 'hb_mini_bridge_nonce';
11323
-
11324
11558
  const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
11325
11559
  const RUNTIME_GATE_MARKER = 'data-heybox-runtime-gate';
11326
11560
  const RUNTIME_GATE_STYLE_MARKER = 'data-heybox-runtime-gate-style';
@@ -11643,8 +11877,29 @@ function shouldSkipMiniappPlatformCspFromEnv(env = process.env) {
11643
11877
  return env[HB_SDK_RUNTIME_PERMISSION_CONTEXT_ENV] === VERIFIED_RUNTIME_PERMISSION_CONTEXT && env[HB_SDK_RUNTIME_USE_OFFICIAL_DOMAIN_ENV] === '1';
11644
11878
  }
11645
11879
 
11880
+ /**
11881
+ * dev serve 时在入口 HTML 最早位置注入无依赖 console 捕获 bootstrap。
11882
+ *
11883
+ * 必须内联完整 patch 逻辑而非等 SDK 模块加载:vite client、业务代码的 console 调用
11884
+ * 都可能早于 SDK 单例初始化(如 [vite] connecting)。捕获条件:
11885
+ * 1. 构建期只有 vite serve 走到本分支(生产构建无此代码,双保险之 define 常量仍注入给 SDK 侧);
11886
+ * 2. 运行期仅调试 iframe(window.name 标记由调试台 iframe.name 与本 bootstrap 设置)激活。
11887
+ * 转发经 window.parent.postMessage(CSP connect-src 不约束 postMessage),失败静默,
11888
+ * 严禁回打 console 造成自触发循环。SDK 侧 installMiniDevConsoleForwarding 安装时
11889
+ * 检测同款 INSTALL_FLAG,不会重复 patch。
11890
+ */
11891
+ function injectMiniDevConsoleBootstrap(html) {
11892
+ const bootstrap = `<script>(function(){var LEVELS=['log','debug','info','warn','error'];var FLAG='${MINI_DEV_CONSOLE_INSTALL_FLAG}';var TYPE='${MINI_DEV_CONSOLE_EVENT_TYPE}';if(window.name!=='${MINI_DEV_IFRAME_WINDOW_NAME}')window.name='${MINI_DEV_IFRAME_WINDOW_NAME}';if(window[FLAG])return;var patched=false;for(var i=0;i<LEVELS.length;i++)(function(level){var original=console[level];if(typeof original!=='function')return;console[level]=function(){try{parent.postMessage({type:TYPE,detail:{level:level,args:Array.prototype.slice.call(arguments),timestamp:Date.now()}},'*')}catch(e){}return original.apply(this,arguments)};patched=true})(LEVELS[i]);if(patched)window[FLAG]=true})();</script>`;
11893
+ const headIndex = html.indexOf('<head>');
11894
+ if (headIndex < 0) {
11895
+ return html;
11896
+ }
11897
+ const insertAt = headIndex + '<head>'.length;
11898
+ return `${html.slice(0, insertAt)}${bootstrap}${html.slice(insertAt)}`;
11899
+ }
11646
11900
  const sdkVersionPlaceholder = ['__HB_SDK', 'VERSION__'].join('_');
11647
11901
  const sdkVersionBuildConstant = ['__HB_SDK_BUILD', 'VERSION__'].join('_');
11902
+ const miniDevLoggingConstant = ['__HB_SDK_DEV', 'LOGGING__'].join('_');
11648
11903
  function miniappManifest(options) {
11649
11904
  const platforms = validateMiniappPlatforms(options?.platforms, 'miniappManifest().platforms');
11650
11905
  const skipPlatformCsp = shouldSkipMiniappPlatformCspFromEnv();
@@ -11656,12 +11911,17 @@ function miniappManifest(options) {
11656
11911
  let priorBuildError;
11657
11912
  return {
11658
11913
  name: 'heybox-miniapp-manifest',
11659
- config(config) {
11914
+ config(config, env) {
11660
11915
  assertMiniappViteBase(config.base);
11916
+ // command 在本钩子时序早于 configResolved,必须取自 env 命令而非闭包;
11917
+ // 旧调用方(测试等)未传 env 时按 build 处理。
11918
+ const isServe = env?.command === 'serve';
11661
11919
  return {
11662
11920
  ...(config.base === undefined ? { base: './' } : {}),
11663
11921
  define: {
11664
11922
  [sdkVersionBuildConstant]: JSON.stringify(resolveSdkVersion()),
11923
+ // 仅 vite serve(hb-sdk dev)注入;vite build / hb-sdk build 永不注入,捕获模块被死代码消除。
11924
+ ...(isServe ? { [miniDevLoggingConstant]: 'true' } : {}),
11665
11925
  },
11666
11926
  };
11667
11927
  },
@@ -11683,12 +11943,12 @@ function miniappManifest(options) {
11683
11943
  }
11684
11944
  },
11685
11945
  transformIndexHtml(html) {
11686
- return enforceMiniappHtmlPolicy(html, {
11946
+ const enforced = enforceMiniappHtmlPolicy(html, {
11687
11947
  ...(command === 'serve' ? { hmrWebSocketUrl } : {}),
11688
11948
  skipPlatformCsp,
11689
11949
  });
11690
- },
11691
- async closeBundle() {
11950
+ return command === 'serve' ? injectMiniDevConsoleBootstrap(enforced) : enforced;
11951
+ }, async closeBundle() {
11692
11952
  // Rollup 在 buildStart/transform 失败后仍会调用 closeBundle。
11693
11953
  // 若此时再抛「缺 index.html」等二次错误,会掩盖真实失败原因。
11694
11954
  if (priorBuildError) {
@@ -11696,6 +11956,9 @@ function miniappManifest(options) {
11696
11956
  }
11697
11957
  const version = validateMiniappPackageVersionForBuild(readMiniappVersionFromPackageJson(root));
11698
11958
  const sdkVersion = resolveSdkVersion();
11959
+ const parsedPermissions = readMiniappPermissionsFromPackageJson(root, sdkVersion);
11960
+ if (!parsedPermissions.declared)
11961
+ this.warn(getMissingPermissionsWarning());
11699
11962
  const outputRoot = path.resolve(root, outDir);
11700
11963
  const htmlFiles = collectHtmlFiles(outputRoot);
11701
11964
  const unexpectedHtmlFiles = htmlFiles.filter((file) => path.relative(outputRoot, file) !== 'index.html');
@@ -11711,7 +11974,12 @@ function miniappManifest(options) {
11711
11974
  writeFileSync(indexHtmlPath, enforceMiniappHtmlPolicy(readFileSync(indexHtmlPath, 'utf8'), { skipPlatformCsp }));
11712
11975
  const manifestPath = path.join(outputRoot, 'manifest.json');
11713
11976
  mkdirSync(path.dirname(manifestPath), { recursive: true });
11714
- writeFileSync(manifestPath, renderMiniappManifest({ version, sdkVersion, platforms }));
11977
+ writeFileSync(manifestPath, renderMiniappManifest({
11978
+ version,
11979
+ sdkVersion,
11980
+ platforms,
11981
+ ...(parsedPermissions.permissions === undefined ? {} : { permissions: parsedPermissions.permissions }),
11982
+ }));
11715
11983
  },
11716
11984
  };
11717
11985
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heybox/hb-sdk",
3
- "version": "0.8.0-alpha",
3
+ "version": "0.8.0-alpha.12",
4
4
  "sideEffects": [
5
5
  "./src/index.ts",
6
6
  "./src/core/singleton.ts",
@@ -44,6 +44,7 @@
44
44
  "files": [
45
45
  "README.md",
46
46
  "CHANGELOG.md",
47
+ "THIRD_PARTY_NOTICES.md",
47
48
  "bin",
48
49
  "dist",
49
50
  "skill",
@@ -52,12 +53,16 @@
52
53
  "keywords": [],
53
54
  "author": "",
54
55
  "license": "ISC",
56
+ "engines": {
57
+ "node": ">=22.20.0"
58
+ },
55
59
  "dependencies": {
56
60
  "@msgpack/msgpack": "2.8.0",
57
61
  "parse5": "^7.3.0",
62
+ "skills": "1.5.23",
58
63
  "undici": "^7.28.0",
59
64
  "ws": "^8.18.0",
60
- "@heybox/hb-sdk-protocol": "0.8.0-alpha"
65
+ "@heybox/hb-sdk-protocol": "0.8.0-alpha.12"
61
66
  },
62
67
  "peerDependencies": {
63
68
  "vite": ">=5"
@@ -73,7 +78,8 @@
73
78
  "@rollup/plugin-node-resolve": "^16.0.1",
74
79
  "@heybox/hb-types": "^1.0.1",
75
80
  "@playwright/test": "^1.55.1",
76
- "@vitejs/plugin-vue2": "^2.3.3",
81
+ "@sneas/telephone": "1.1.2",
82
+ "@vitejs/plugin-vue": "^6.0.1",
77
83
  "@rollup/plugin-typescript": "^11.1.6",
78
84
  "@types/ejs": "^3.1.5",
79
85
  "@types/fs-extra": "^11.0.4",
@@ -82,6 +88,7 @@
82
88
  "@types/semver": "^7.7.1",
83
89
  "@types/ws": "^8.5.13",
84
90
  "@vitest/coverage-v8": "^3.2.4",
91
+ "@vue/test-utils": "^2",
85
92
  "commander": "^12.1.0",
86
93
  "cos-nodejs-sdk-v5": "2.15.4",
87
94
  "ejs": "^3.1.10",
@@ -89,19 +96,27 @@
89
96
  "fs-extra": "^11.3.0",
90
97
  "get-port": "^7.1.0",
91
98
  "happy-dom": "^19.0.2",
99
+ "lucide-vue-next": "1.0.0",
100
+ "markdown-it": "^14.1.0",
92
101
  "open": "^10.2.0",
93
102
  "ora": "^5.4.1",
94
103
  "picocolors": "^1.1.1",
95
104
  "qrcode": "^1.5.4",
96
105
  "rimraf": "^5.0.5",
106
+ "reka-ui": "2.10.4",
97
107
  "rollup": "^4.52.4",
98
108
  "semver": "^7.8.0",
109
+ "sass-embedded": "1.97.3",
110
+ "splitpanes": "^4.1.0",
99
111
  "typescript": "^5.9.3",
100
- "vue": "^2.7.16",
112
+ "vue": "^3.5.22",
113
+ "vue-tsc": "^3.3.7",
101
114
  "vite": "^8.0.12",
102
115
  "vitest": "^3.2.4",
103
- "@heybox/hb-api": "~1.25.23",
104
- "@heybox/hb-sdk-runtime": "~0.8.0-alpha",
116
+ "@heybox-domain/heybox-theme": "~0.1.0",
117
+ "@heybox/hb-api": "~1.28.2",
118
+ "@heybox/hb-sdk-runtime": "~0.8.0-alpha.12",
119
+ "@heybox-domain/heybox-vue3-ui": "~0.1.0",
105
120
  "@heybox/runtime": "~0.2.0",
106
121
  "@heybox/runtime-policy": "~0.2.0",
107
122
  "@heybox/runtime-transport-fetch": "~0.2.0"
@@ -117,6 +132,10 @@
117
132
  "{projectRoot}/src/**/*",
118
133
  "{projectRoot}/devtools/browser-dev-host/**/*",
119
134
  "{projectRoot}/scripts/copy-browser-dev-host.cjs",
135
+ "{projectRoot}/scripts/check-browser-dev-host-assets.cjs",
136
+ "{projectRoot}/scripts/generate-browser-dev-host-notices.cjs",
137
+ "{projectRoot}/licenses/**/*",
138
+ "{projectRoot}/THIRD_PARTY_NOTICES.md",
120
139
  "{projectRoot}/rollup.config.ts",
121
140
  "{projectRoot}/tsconfig*.json",
122
141
  "{workspaceRoot}/packages/hb-sdk-runtime/src/**/*",
@@ -144,30 +163,34 @@
144
163
  "build:lib:bundle": "rollup -c rollup.config.ts --configPlugin 'typescript={\"tsconfig\":\"tsconfig.build.json\"}'",
145
164
  "build:cli": "pnpm run build:hb-sdk-protocol && pnpm run build:hb-api-contract && pnpm run build:cli:bundle",
146
165
  "build:cli:bundle": "rollup -c rollup.config.ts --environment HB_SDK_BUILD:cli --configPlugin 'typescript={\"tsconfig\":\"tsconfig.build.json\"}' && pnpm run build:browser-dev-host",
147
- "build:browser-dev-host": "node scripts/copy-browser-dev-host.cjs",
166
+ "build:browser-dev-host": "vite build --config vite.browser-dev-host.config.ts && node scripts/check-browser-dev-host-assets.cjs && node scripts/generate-browser-dev-host-notices.cjs",
148
167
  "build:templates": "node scripts/copy-cli-templates.cjs",
149
168
  "build:types": "tsc -p tsconfig.dts.json",
150
169
  "check:boundary": "node scripts/check-boundary.cjs",
151
- "check:docs-sync": "pnpm -w exec hbexec hb-sdk check",
170
+ "check:docs-sync": "pnpm --filter @heybox-docs/docs-hb_sdk run check:reference && node scripts/skill/check-references.mjs && node scripts/skill/validate-skill.mjs",
152
171
  "check:compatibility-evidence": "node scripts/validate-compatibility-evidence.mjs",
153
172
  "check:api-semver": "node ../../ops/jobs/hb-sdk-docs-contract/semantic-diff.cjs",
154
173
  "clean": "rimraf ./dist && rimraf ./types",
155
174
  "test:unit": "NODE_OPTIONS='--conditions=heybox' vitest run",
156
175
  "test:types:characterization": "tsc -p tsconfig.characterization.json --noEmit --pretty false",
157
- "test:types:browser-dev-host": "tsc -p tsconfig.browser-dev-host.json --noEmit --pretty false",
176
+ "test:types:browser-dev-host": "vue-tsc -p tsconfig.browser-dev-host.json --noEmit --pretty false",
158
177
  "test:types": "pnpm run test:types:characterization && pnpm run test:types:browser-dev-host",
159
178
  "test:e2e:browser-dev-host": "pnpm run build:browser-dev-host && NODE_OPTIONS='--conditions=heybox' vitest run --config vitest.browser-dev-host-e2e.config.ts",
179
+ "test:create-template:artifact": "node scripts/test-create-template-artifact.mjs",
160
180
  "test:unit:coverage": "NODE_OPTIONS='--conditions=heybox' vitest run --coverage",
161
181
  "test:vite": "pnpm run build:hb-sdk-protocol && pnpm run build:hb-api-contract && vitest run --config vitest.vite.config.ts",
162
182
  "test:watch": "NODE_OPTIONS='--conditions=heybox' vitest",
163
183
  "changelog:draft": "node scripts/changelog-draft.cjs",
164
184
  "check:changelog": "node scripts/check-changelog.cjs",
165
- "test:release": "node --test scripts/release-family.test.cjs ../../ops/jobs/publish-changed-packages/publish.test.cjs ../../ops/jobs/release-hb-sdk/docs-release-contract.test.cjs",
185
+ "release:verify-tarball": "node scripts/skill/verify-tarball-install.mjs",
186
+ "test:release": "node --test scripts/public-changelog.test.mjs scripts/public-changelog-workflow.test.cjs scripts/release-family.test.cjs ../../ops/jobs/publish-changed-packages/publish.test.cjs ../../ops/jobs/release-hb-sdk/docs-release-contract.test.cjs ../../ops/jobs/release-hb-sdk/stable-promote-coordinator.test.cjs",
166
187
  "test:compatibility-evidence": "node --test scripts/validate-compatibility-evidence.test.mjs",
167
188
  "release:prepare": "node scripts/release-prepare.cjs",
168
189
  "release:tag": "node scripts/release-tag.cjs",
169
190
  "release:family:dry-run": "node ../../ops/jobs/publish-changed-packages/publish.cjs --dry-run",
170
191
  "release:family:promote": "node ../../ops/jobs/publish-changed-packages/publish.cjs --family-action promote",
171
- "release:family:rollback": "node ../../ops/jobs/publish-changed-packages/publish.cjs --family-action rollback"
192
+ "release:family:rollback": "node ../../ops/jobs/publish-changed-packages/publish.cjs --family-action rollback",
193
+ "release:stable:promote": "node ../../ops/jobs/release-hb-sdk/stable-promote-coordinator.cjs --action promote",
194
+ "release:stable:rollback": "node ../../ops/jobs/release-hb-sdk/stable-promote-coordinator.cjs --action rollback"
172
195
  }
173
196
  }
package/skill/SKILL.md CHANGED
@@ -39,34 +39,35 @@ Apply these instructions when writing, reviewing, or debugging code that consume
39
39
  ## Step 4: Implement workshop mini-program code
40
40
 
41
41
  1. Import the root package eagerly; the SDK starts its handshake automatically and capability calls wait for it internally.
42
- 2. For a network-enabled mini-program, use `auth.login({ scopes? })` to obtain `{ code, expiresIn: 300, scopes }`. Identity is always implicit; request only optional scopes the business actually needs.
43
- 3. Send the code only to the developer's backend. That backend follows the backend OpenAPI documentation to exchange it for a token; mini-program code must never exchange application credentials itself.
44
- 4. For a network-disabled mini-program, call `user.getInfo()` to read the current login state, `userInfo.app_user_id`, and `userInfo.profile`. The Host silently grants the current local user scopes (`identity` and `profile`), so this call does not require a trusted user action or authorization UI. It still cannot obtain a code or call OpenAPI.
42
+ 2. Declare protected capabilities in `package.json#heybox.permissions`. `auth.login()` and `user.getInfo()` require `userInfo`; `user.getSteamGameList()` requires `steamLibrary`; none of them implicitly require the public `network` permission.
43
+ 3. Use `auth.login({ scopes? })` to obtain `{ code, expiresIn: 300, scopes }`. Identity is always implicit; request only optional scopes the business actually needs.
44
+ 4. Send the code only to the developer's backend. That backend follows the backend OpenAPI documentation to exchange it for a token; mini-program code must never exchange application credentials itself.
45
45
  5. Handle `HbMiniProgramSDKError` for SDK initialization and capability failures.
46
46
  6. Handle `HbMiniProgramNetworkError` separately when HTTP completed but `validateStatus` rejected the status.
47
47
  7. Use `getHandshakeState()` for the current persistent handshake state and `onHandshakeStateChange()` for an immediate replay plus future changes. Cancel the returned subscription when the page or component unmounts.
48
48
  8. Treat the non-replayed `ready` lifecycle event only as an edge notification. After a duplicate handshake it may repeat, so never use it as state or as the source for enabling a late-mounted control.
49
49
  9. Use the default SDK instance exposed by the root package. For gesture-gated controls, initialize from the current handshake state, subscribe to changes, and enable the control only when `status === 'ready'`. Keep calls such as `auth.login()` in the original user-action callback; do not wait for handshake inside that callback.
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
- 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
- 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`.
51
+ 11. 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.
52
+ 12. 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`.
53
+ 13. New PC enables the retained `files` and `network.download()` contract with persistent sandbox storage, single-file/directory pickers, exact File saving, and public-network streaming downloads. Mobile, Web, Browser Dev Host, and legacy PC return `METHOD_FORBIDDEN` and provide no memory/Blob fallback. 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 })`.
54
+ 14. 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.
54
55
 
55
56
  ## Step 5: Use CLI workflows
56
57
 
57
58
  1. Use `hb-sdk create <project-name>` to scaffold a workshop mini-program.
58
- 2. Use `hb-sdk dev` for Browser Mock, Mac App, or Mobile App debugging. It requires an active CLI login, a bound Mini-program, and an available remote Dev Context; it must stop before starting Vite or any debugging service when a prerequisite is missing. Mobile uses the `open_inapp` and `heybox://` `openWindow` wrapper with a LAN short URL, then opens `heybox-mini-dev://sandbox` with the complete launch context.
59
- 3. Treat debugging-page permission overrides as local development behavior; overrides do not change remote permissions. Use `--port`, `--browser-dev-host-port`, and `--no-open` to control local endpoints and browser opening. Select a Mobile network interface the device can reach. `launch.json` is a LAN discovery document, not authentication, encryption, signing, or HMAC protection.
59
+ 2. Use `hb-sdk dev` for Browser Mock and Mobile App debugging. Browser debugging can start without CLI login, project binding, or a remote Dev Context; capabilities that need those inputs fail explicitly. Mobile uses the single QR entry with the `open_inapp` and `heybox://` `openWindow` wrapper around a LAN short URL, then opens `heybox-mini-dev://sandbox` with the complete launch context.
60
+ 3. The debugging page does not edit permissions. Treat the validated remote permission snapshot as canonical Runtime input. Use `--port`, `--browser-dev-host-port`, and `--no-open` to control local endpoints and browser opening. Select a Mobile network interface the device can reach. `launch.json` is a LAN discovery document, not authentication, encryption, signing, or HMAC protection.
60
61
  4. Use `hb-sdk build [--env <name>] [--verbose]` as the recommended production build entry. It directly owns the Vite build, always cleans and writes `dist/`, and works without CLI login, project binding, or network access.
61
62
  5. Keep `miniappManifest()` explicitly enabled in `vite.config.ts`; `hb-sdk build` must fail when the required Manifest or Runtime gate output is missing.
62
63
  6. Keep project typechecking in `scripts.build`, for example `vue-tsc --noEmit && hb-sdk build`; `hb-sdk build` does not run typechecking or invoke `scripts.build` itself.
63
64
  7. Existing projects may continue to use `vite build`; do not auto-migrate them. Do not invent `--mode`, `--json`, config, or output-directory flags for `hb-sdk build`.
64
- 8. Use `hb-sdk login`, `hb-sdk login status`, and `hb-sdk login clear` for development, publishing, and Browser Mock Host `heybox-session` requests. Mini-program code must still call `auth.login()`; the debug page only confirms authorization. Do not paste CLI credentials into page JavaScript. Phone debugging continues to use the App login.
65
+ 8. Use `hb-sdk login`, `hb-sdk login status`, and `hb-sdk login clear` for remote management, publishing, Mobile debugging, and optional Browser Mock Host `heybox-session` requests. Browser debugging itself can start without CLI login. Mini-program code must still call `auth.login()`; the debug page only confirms authorization. Do not paste CLI credentials into page JavaScript. Phone debugging continues to use the App login.
65
66
  9. Use `hb-sdk remote entity current` to confirm the current developer account and `hb-sdk remote entity switch <entity-id>` to change it before remote operations.
66
67
  10. Use `hb-sdk remote create` to create and bind a mini-program; use `hb-sdk remote bind <mini-program-id>` to bind an existing manageable mini-program.
67
68
  11. Use `hb-sdk remote info`, `hb-sdk remote list`, `hb-sdk remote access`, `hb-sdk remote versions`, `hb-sdk remote preview <version>`, and `hb-sdk remote allowlist ...` for remote inspection and preview management.
68
69
  12. Use `hb-sdk remote deploy --release-note <text>` to run the project's `scripts.build`, upload, and submit the current project for audit. Do not recommend the removed top-level `hb-sdk deploy` alias.
69
- 13. `hb-sdk dev` and `hb-sdk remote deploy` skip the platform CSP only when the validated remote permission snapshot has `network.request.status=enabled`. `useOfficialDomain` does not participate in CSP skip decisions. Direct `hb-sdk build`, direct Vite build, anonymous or invalid snapshots, and local Dev Context overrides must keep the platform CSP. Runtime Gate, Manifest, and HTML validation always remain active.
70
+ 13. `hb-sdk dev` and `hb-sdk remote deploy` skip the platform CSP only when the current version declares and the platform approves `network`. `useOfficialDomain` does not participate in CSP skip decisions. Direct `hb-sdk build`, direct Vite build, anonymous or invalid snapshots, and local Dev Context overrides must keep the platform CSP. Runtime Gate, Manifest, and HTML validation always remain active.
70
71
  14. After approval, use `hb-sdk remote release <version>` for manual release or `--auto-publish` when an eligible low-risk version should release automatically.
71
72
  15. Treat approval, release, and public display as separate states. Do not promise square, search, or recommendation visibility after release.
72
73
  16. Use `hb-sdk remote withdraw`, `hb-sdk remote take-down`, `hb-sdk remote reopen`, and square visibility commands only after showing the target and obtaining required confirmation.
@@ -81,11 +82,12 @@ For workshop mini-program business code:
81
82
  1. Do not read or request tokens, cookies, phone numbers, or private credentials from the SDK.
82
83
  2. Do not expose raw share protocol fields, JS callbacks, activity reporting, custom buttons, direct post publishing, or upload-only flows. Public `share.*({ post })` options only preset an editable client post flow and never publish automatically.
83
84
  3. Do not use unsupported storage operations such as delete, clear, info listing, or global client storage access.
84
- 4. Use only the public `network.request` configuration.
85
+ 4. Use only the public `network.request` / `network.download` configurations.
85
86
  5. Do not use private package paths or client protocols.
86
87
  6. Build artifacts may include `dist/manifest.json`; business code should not fetch a deployed manifest directly because it is not a CDN asset.
87
88
  7. Do not use `network.request()` to reach platform-reserved runtime auth or OpenAPI internal paths.
88
89
  8. Do not expose credentials or describe internal Host authorization state machines and routes in app-facing guidance.
90
+ 9. Do not invent string paths, File System Access API handles, Blob downloads, uploads, Range/resume, external deletion, move, append, or persistent external grants. Public file operations use only SDK-created handles; deletion is limited to SDK sandbox handles.
89
91
 
90
92
  For CLI and local development:
91
93
 
@@ -93,8 +95,9 @@ For CLI and local development:
93
95
  2. Do not skip `auth.login()` in mini-program code. Browser Mock may reuse the Node `hb-sdk login` session for Host network requests, but the page must still call `auth.login()` and handle the authorization dialog. Never paste CLI credentials into page JavaScript.
94
96
  3. Use the built-in local debugging page instead of creating another browser Mock.
95
97
  4. Keep the Vite `miniappManifest()` plugin enabled.
96
- 5. Treat permission changes made in the `hb-sdk dev` debugging page as local debugging overrides, not online configuration changes. Use the page's reset action to return to the remote baseline.
98
+ 5. Do not suggest changing or resetting permissions in the `hb-sdk dev` debugging page; that UI does not exist. Diagnose permission behavior from the remote snapshot and capability result.
97
99
  6. Treat browser Mock results as development feedback only. Validate permissions, identity flows, and user interactions again in a real Heybox client before publishing.
100
+ 7. The Browser Dev Host offers iPhone 16 Pro Max (`440 x 956`) and Pixel 9 Pro (`410 x 914`) presets. Switching a preset must preserve the iframe, Runtime session, and page state. Authorization/action dialogs, Toast, Loading, and vibration feedback render inside the preview. Use the upper-right QR popover as the only Mobile QR entry.
98
101
 
99
102
  For host/runtime/protocol-maintenance code:
100
103
 
@@ -110,17 +113,16 @@ For host/runtime/protocol-maintenance code:
110
113
  - `cat packages/hb-sdk/DOC_SYNC_CHECKLIST.md`
111
114
  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.
112
115
  4. When modifying this repo's source skill at `packages/hb-sdk/skill` and preparing distributable artifacts, also run:
113
- - `node packages/hb-sdk/skill/scripts/package-skill.mjs`
116
+ - `node packages/hb-sdk/scripts/skill/sync-references.mjs`
117
+ - `node packages/hb-sdk/scripts/skill/validate-skill.mjs`
114
118
  5. When modifying CLI, local debugging, package exports, or package dependency direction, also run:
115
119
  - `pnpm --filter @heybox/hb-sdk run check:boundary`
116
120
  - `pnpm --filter @heybox/hb-sdk run test:unit`
117
- 6. Inspect the generated zip before distribution:
118
- - `unzip -l packages/hb-sdk/hb-sdk.zip | sed -n '1,120p'`
119
- 7. When adding or modifying the deploy command or its upload pipeline, also run:
121
+ 6. When adding or modifying the deploy command or its upload pipeline, also run:
120
122
  - `pnpm --filter @heybox/hb-sdk run check:boundary`
121
123
  - `pnpm --filter @heybox/hb-sdk run test:unit`
122
124
  - Verify `dist/cli.cjs` does not have any `require('cos-nodejs-sdk-v5')` left after `build:cli`; the boundary check enforces this automatically.
123
- 8. Verify the canonical payload before publishing:
124
- - `pnpm exec hbexec hb-sdk sync`
125
- - `pnpm exec hbexec hb-sdk check`
126
- - 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>`.
125
+ 7. Verify the canonical payload before publishing:
126
+ - `node packages/hb-sdk/scripts/skill/sync-references.mjs`
127
+ - `node packages/hb-sdk/scripts/skill/validate-skill.mjs`
128
+ - For a release artifact, run `npm pack --dry-run` and `node packages/hb-sdk/scripts/skill/verify-tarball-install.mjs`.