@heybox/hb-sdk 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -421,7 +421,7 @@ try {
421
421
  2. 已运行过 `hb-sdk login` 登录 Heybox;多主体用户应确认 `hb-sdk remote entity current` 指向要发布的主体。
422
422
  3. 当前项目绑定的小程序必须属于服务端 current entity;如不一致,先运行 `hb-sdk remote entity switch <entity-id>` 切换主体。
423
423
  4. 如果需要以公司的名义发布小程序,需先找 @秦浩东 申请小程序开发权限。
424
- 5. 每次部署都要在 `package.json` 里配置 `heybox.miniProgramProfile.name`、`iconUrl` 和至少一张 `coverImageUrls`,这些资料会随版本提交审核。
424
+ 5. 小程序名称、icon 和介绍图在开放平台版本发布中维护;CLI 项目配置只保留 `heybox.miniProgramId`。首次部署且无历史审核通过资料时,服务端使用默认名与默认图。
425
425
  6. 每次部署都要准备发布日志:`hb-sdk remote deploy --release-note "..."`。发布日志 trim 后不能为空,最多 500 个字符,允许换行;CI / 非 TTY 环境缺失时会直接失败,TTY 环境会提示输入。
426
426
  7. 项目根有 `scripts.build`,会被 CLI 通过 lockfile 自动选用的 `pnpm`、`yarn` 或 `npm` 触发;无 lockfile 时回退 `npm`。
427
427
  8. 构建产物落在 `dist/`,包含 `index.html` 和 `manifest.json`。
@@ -444,20 +444,7 @@ try {
444
444
 
445
445
  `--from-version <version>` 用于复用已经上传过的远端历史版本产物提交新一轮审核。该模式不读取本地 `dist/`,也不会执行 build 或上传;目标审核版本由服务端根据版本表最高 SemVer 自动派生。
446
446
 
447
- `manifest.json` 不会上传到 CDN,只作为 submit audit 请求的 `manifest` 字段提交。`sdkVersion` 由 SDK 构建自动生成,业务配置不能覆盖;复用历史 Version Artifact 时继续使用源 Artifact 的 `sdkVersion`。名称、icon 和介绍图从 `package.json.heybox.miniProgramProfile` 读取,并随 precheck submit audit 一起提交:
448
-
449
- ```json
450
- {
451
- "heybox": {
452
- "miniProgramId": "mp_xxxxxxxx",
453
- "miniProgramProfile": {
454
- "name": "我的小程序",
455
- "iconUrl": "https://img.example.test/icon.png",
456
- "coverImageUrls": ["https://img.example.test/cover.png"]
457
- }
458
- }
459
- }
460
- ```
447
+ `manifest.json` 不会上传到 CDN,只作为 submit audit 请求的 `manifest` 字段提交。`sdkVersion` 由 SDK 构建自动生成,业务配置不能覆盖;复用历史 Version Artifact 时继续使用源 Artifact 的 `sdkVersion`。CLI precheck / submit audit **不传** name / icon / cover:服务端沿用最近一次审核通过的展示资料,没有则注入默认名「我的小程序」与平台默认图。正式名称与图片请在开放平台版本发布中修改;仍使用默认资料时可以 release,但无法 `square show` 对普通用户公开展示。
461
448
 
462
449
  内部测试或预发环境可通过 origin 级别的自定义地址切换后台环境:
463
450
 
@@ -490,7 +477,7 @@ hb-sdk remote deploy --env test --service-tag other-tag --release-note "灰度"
490
477
 
491
478
  `--env <name>` 会读取项目根下的 `.env.<name>`,`--env-file <path>` 显式指定路径且优先级高于 `--env`;两者也可通过 `HB_SDK_ENV=<name>` 触发。加载遵循 dotenv 惯例:不覆盖进程已有的同名变量,因此 CI 或命令行显式设置的值优先。使用 `--env <name>` 或 `HB_SDK_ENV=<name>` 执行 `remote deploy` 时,CLI 还会把同一个 `name` 作为 `--mode <name>` 传给项目 build,使 CLI 后端环境与 Vite mode 保持一致。文件仅支持 `KEY=VALUE`、空行和 `#` 注释,不做变量插值;文件不存在时静默跳过。`--verbose` 会打印生效的文件路径和被跳过的 key。
492
479
 
493
- `--api-base-url` 优先于 `HB_SDK_API_BASE_URL`,影响 `hb-sdk remote` 里的远端平台后台 API,包括预检、CDN 上传凭证/回调、提交审核、版本、发布、撤回、下架、重新上架、详情和白名单等调用;`--login-base-url` 优先于 `HB_SDK_LOGIN_BASE_URL`,用于 `hb-sdk login` 的登录入口,以及 remote 命令前校验当前 CLI 登录态是否属于同一个登录环境。`--service-tag <tag>` 优先于 `HB_SDK_SERVICE_TAG`,给 Heybox 后台请求附加 `x-rylai-service-tag` header,并复用命中的 tag 追加 `special_tag` 请求参数,用于开发环境路由或灰度验证。deploy 子构建会继承 `.env.<name>` 中的 `HB_SDK_SERVICE_TAG`,Vite 最低 SDK 版本门禁请求也会同时携带该 header 和 query;仓库内开发也可继续在 `packages/hb-sdk/src/cli/config.ts` 里按 `@heybox/hb-types` 的 `RylaiServiceTagConfig` 配置 path-prefix 级 `special_tag`。自定义地址只接受 origin,不允许包含 path、query 或 hash;API origin 默认还必须是 Heybox 受信 HTTPS 域名,只有本地联调等场景可显式使用 `--allow-unsafe-api-base-url` 或 `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` 放开。日志只输出 origin,不输出带身份和签名参数的完整请求 URL。`hb-sdk doctor`、npm latest 检查、mock host 的 `network.request()` 不受这些配置影响。
480
+ `--api-base-url` 优先于 `HB_SDK_API_BASE_URL`,影响 `hb-sdk remote` 里的远端平台后台 API,包括预检、CDN 上传凭证/回调、提交审核、版本、发布、撤回、下架、重新上架、详情和白名单等调用;`--login-base-url` 优先于 `HB_SDK_LOGIN_BASE_URL`,用于 `hb-sdk login` 的登录入口,以及 remote 命令前校验当前 CLI 登录态是否属于同一个登录环境。`--service-tag <tag>` 优先于 `HB_SDK_SERVICE_TAG`,给 Heybox 后台请求附加 `x-rylai-service-tag` header,并复用命中的 tag 追加 `special_tag` 请求参数,用于开发环境路由或灰度验证。手动 Vite build 的最低 SDK 版本门禁请求会同时携带该 header 和 query;`remote deploy` 的子构建不执行客户端最低版本门禁。仓库内开发也可继续在 `packages/hb-sdk/src/cli/config.ts` 里按 `@heybox/hb-types` 的 `RylaiServiceTagConfig` 配置 path-prefix 级 `special_tag`。自定义地址只接受 origin,不允许包含 path、query 或 hash;API origin 默认还必须是 Heybox 受信 HTTPS 域名,只有本地联调等场景可显式使用 `--allow-unsafe-api-base-url` 或 `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` 放开。日志只输出 origin,不输出带身份和签名参数的完整请求 URL。`hb-sdk doctor`、npm latest 检查、mock host 的 `network.request()` 不受这些配置影响。
494
481
 
495
482
  ## hb-sdk remote 命令参考
496
483
 
@@ -548,7 +535,7 @@ CLI 登录态只供 CLI 命令访问黑盒接口时复用,不会注入 iframe
548
535
  ```json
549
536
  {
550
537
  "version": "1.2.3",
551
- "sdkVersion": "0.6.0"
538
+ "sdkVersion": "0.6.1"
552
539
  }
553
540
  ```
554
541
 
@@ -570,7 +557,7 @@ export default defineConfig({
570
557
 
571
558
  插件只接受单页应用:输出目录只能存在入口 `index.html`。build 会用结构化 HTML parser 校验入口,并把平台 CSP 插入 `<head>` 首位;已有 CSP 会原样保留,两份策略按浏览器交集生效。正式策略禁止 `fetch`、XHR、WebSocket、EventSource、Beacon、Worker、iframe、表单和对象加载等浏览器原生出口;业务网络请求应使用 `network.request()`。dev 使用相同策略,只额外放行当前 Vite 的精确 HMR WebSocket 地址。
572
559
 
573
- meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev`、build deploy 会读取 `/user_miniprogram/public/sdk_config` 的 `minimumSdkVersion`;最新请求失败时只回退当前 Remote Environment 下 24 小时内的有效缓存,无缓存则默认阻断并提示升级 `@heybox/hb-sdk@latest`。
560
+ meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev` 和手动 Vite build 会读取 `/user_miniprogram/public/sdk_config` 的 `minimumSdkVersion`;最新请求失败时只回退当前 Remote Environment 下 24 小时内的有效缓存,无缓存则默认阻断并提示升级 `@heybox/hb-sdk@latest`。`hb-sdk remote deploy`(包括 `--from-version`)不执行客户端最低版本查询或比较,但仍校验 Manifest 结构并经过服务端 precheck / submit-audit 策略。
574
561
 
575
562
  失败与警告语义:
576
563
 
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var session = require('./session-DIcRjyDY.cjs');
3
+ var session = require('./session-D7mPwyx4.cjs');
4
+ var index = require('./index-CTyguEza.cjs');
4
5
  var fs$1 = require('node:fs');
5
6
  var fs = require('node:fs/promises');
6
7
  var path = require('node:path');
7
- var index = require('./index-CCeHouBU.cjs');
8
8
 
9
9
  const APIUserMiniprogramPublicSdkConfigPath = '/user_miniprogram/public/sdk_config';
10
10
  function createUserMiniprogramPublicSdkConfigRequest(serviceTag) {
@@ -3214,91 +3214,6 @@ function isTruthyEnvFlag(value) {
3214
3214
  .toLowerCase());
3215
3215
  }
3216
3216
 
3217
- const CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1_000;
3218
- const CACHE_FILE_NAME = 'minimum-sdk-versions.json';
3219
- async function resolveMinimumSdkVersion(options) {
3220
- const now = options.now ?? Date.now();
3221
- const cachePath = path.join(options.cacheDir, CACHE_FILE_NAME);
3222
- const cache = await readCache(cachePath);
3223
- let minimumSdkVersion;
3224
- try {
3225
- minimumSdkVersion = validateStableSdkVersion(await options.fetchMinimumSdkVersion(), 'minimumSdkVersion');
3226
- }
3227
- catch {
3228
- const cached = cache.environments[options.environment];
3229
- const cacheAge = cached ? now - cached.fetchedAt : Number.NaN;
3230
- if (cached && Number.isFinite(cached.fetchedAt) && cacheAge >= 0 && cacheAge <= CACHE_MAX_AGE_MS) {
3231
- try {
3232
- return validateStableSdkVersion(cached.minimumSdkVersion, 'cached minimumSdkVersion');
3233
- }
3234
- catch {
3235
- // 非法缓存按不存在处理。
3236
- }
3237
- }
3238
- throw new Error('MINIMUM_SDK_VERSION_UNAVAILABLE:无法获取最低 SDK 版本,且没有 24 小时内的有效缓存');
3239
- }
3240
- cache.environments[options.environment] = { fetchedAt: now, minimumSdkVersion };
3241
- try {
3242
- await writeCache(cachePath, cache);
3243
- }
3244
- catch {
3245
- // 已校验的远端策略仍然可信;缓存只是离线回退优化。
3246
- }
3247
- return minimumSdkVersion;
3248
- }
3249
- function validateCurrentSdkVersion(currentSdkVersion, minimumSdkVersion, options) {
3250
- const current = validateSdkVersion(currentSdkVersion, '当前 SDK 版本');
3251
- const minimum = validateStableSdkVersion(minimumSdkVersion, 'minimumSdkVersion');
3252
- if (!options.allowPrerelease && semverExports.prerelease(current) !== null) {
3253
- throw new Error('正式发布不允许使用预发布 SDK,请运行 pnpm add @heybox/hb-sdk@latest 后重新构建');
3254
- }
3255
- if (!semverExports.satisfies(current, `>=${minimum}`, { includePrerelease: options.allowPrerelease })) {
3256
- throw new Error(`SDK_VERSION_TOO_LOW:当前 @heybox/hb-sdk@${current} 低于最低版本 ${minimum},请运行 pnpm add @heybox/hb-sdk@latest`);
3257
- }
3258
- return current;
3259
- }
3260
- function validateSdkVersion(value, label) {
3261
- const normalized = String(value).trim();
3262
- const parsed = semverExports.parse(normalized);
3263
- if (!parsed || parsed.version !== normalized || parsed.build.length > 0) {
3264
- throw new Error(`${label} 必须是合法 SemVer:${normalized}`);
3265
- }
3266
- return normalized;
3267
- }
3268
- function validateStableSdkVersion(value, label) {
3269
- const normalized = validateSdkVersion(value, label);
3270
- if (semverExports.prerelease(normalized) !== null)
3271
- throw new Error(`${label} 必须是稳定 SemVer:${normalized}`);
3272
- return normalized;
3273
- }
3274
- async function readCache(cachePath) {
3275
- try {
3276
- const parsed = JSON.parse(await fs.readFile(cachePath, 'utf8'));
3277
- if (parsed && typeof parsed === 'object' && parsed.environments && typeof parsed.environments === 'object')
3278
- return parsed;
3279
- }
3280
- catch {
3281
- // 缓存缺失或损坏时继续请求最新配置。
3282
- }
3283
- return { environments: {} };
3284
- }
3285
- async function writeCache(cachePath, cache) {
3286
- await fs.mkdir(path.dirname(cachePath), { recursive: true });
3287
- const temporaryPath = `${cachePath}.${process.pid}.tmp`;
3288
- await fs.writeFile(temporaryPath, `${JSON.stringify(cache, null, 2)}\n`, { mode: 0o600 });
3289
- await fs.rename(temporaryPath, cachePath);
3290
- }
3291
-
3292
- const paths = index.envPaths('hb-sdk');
3293
- async function enforceRemoteSdkVersion(options) {
3294
- const minimumSdkVersion = await resolveMinimumSdkVersion({
3295
- cacheDir: options.cacheDir ?? paths.cache,
3296
- environment: options.environment,
3297
- fetchMinimumSdkVersion: async () => (await getPublicSdkConfig({ baseUrl: options.environment, fetchImpl: options.fetchImpl })).minimum_sdk_version,
3298
- });
3299
- return validateCurrentSdkVersion(options.sdkVersion, minimumSdkVersion, { allowPrerelease: options.allowPrerelease });
3300
- }
3301
-
3302
3217
  exports.ACTIVITY_UPLOAD_KEY_MAX_LENGTH = ACTIVITY_UPLOAD_KEY_MAX_LENGTH;
3303
3218
  exports.MINIAPP_UPLOAD_BATCH_SIZE = MINIAPP_UPLOAD_BATCH_SIZE;
3304
3219
  exports.MINIAPP_UPLOAD_SCOPE = MINIAPP_UPLOAD_SCOPE;
@@ -3306,9 +3221,9 @@ exports.MiniProgramProjectBindingError = MiniProgramProjectBindingError;
3306
3221
  exports.PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH = PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH;
3307
3222
  exports.SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH = SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH;
3308
3223
  exports.createRemoteApiClientForEnvironment = createRemoteApiClientForEnvironment;
3309
- exports.enforceRemoteSdkVersion = enforceRemoteSdkVersion;
3310
3224
  exports.getBoundMiniProgram = getBoundMiniProgram;
3311
3225
  exports.getMiniappUploadKey = getMiniappUploadKey;
3226
+ exports.getPublicSdkConfig = getPublicSdkConfig;
3312
3227
  exports.normalizeRelativePath = normalizeRelativePath;
3313
3228
  exports.readBoundMiniProgramId = readBoundMiniProgramId;
3314
3229
  exports.readBoundMiniProgramIdFromPackageJson = readBoundMiniProgramIdFromPackageJson;
@@ -5,7 +5,7 @@ var fs = require('node:fs/promises');
5
5
  var path = require('node:path');
6
6
  var require$$0 = require('fs');
7
7
  var require$$1 = require('path');
8
- var index = require('./index-CCeHouBU.cjs');
8
+ var index = require('./index-CTyguEza.cjs');
9
9
  require('node:module');
10
10
  require('os');
11
11
  require('readline');
@@ -9,9 +9,9 @@ var node_url = require('node:url');
9
9
  var net = require('node:net');
10
10
  var node_http = require('node:http');
11
11
  var browser = require('./browser-RAy8e8cV.cjs');
12
- var index = require('./index-CCeHouBU.cjs');
13
- var sdkVersionPolicy = require('./sdk-version-policy-B1CFC1Dk.cjs');
14
- var session = require('./session-DIcRjyDY.cjs');
12
+ var index = require('./index-CTyguEza.cjs');
13
+ var context = require('./context-DmxbC_iV.cjs');
14
+ var session = require('./session-D7mPwyx4.cjs');
15
15
  require('node:process');
16
16
  require('node:buffer');
17
17
  require('node:util');
@@ -666,10 +666,95 @@ function createHeyboxProtocol(payload) {
666
666
  return `heybox://${encodeURIComponent(JSON.stringify(payload))}`;
667
667
  }
668
668
 
669
+ const CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1_000;
670
+ const CACHE_FILE_NAME = 'minimum-sdk-versions.json';
671
+ async function resolveMinimumSdkVersion(options) {
672
+ const now = options.now ?? Date.now();
673
+ const cachePath = path.join(options.cacheDir, CACHE_FILE_NAME);
674
+ const cache = await readCache(cachePath);
675
+ let minimumSdkVersion;
676
+ try {
677
+ minimumSdkVersion = validateStableSdkVersion(await options.fetchMinimumSdkVersion(), 'minimumSdkVersion');
678
+ }
679
+ catch {
680
+ const cached = cache.environments[options.environment];
681
+ const cacheAge = cached ? now - cached.fetchedAt : Number.NaN;
682
+ if (cached && Number.isFinite(cached.fetchedAt) && cacheAge >= 0 && cacheAge <= CACHE_MAX_AGE_MS) {
683
+ try {
684
+ return validateStableSdkVersion(cached.minimumSdkVersion, 'cached minimumSdkVersion');
685
+ }
686
+ catch {
687
+ // 非法缓存按不存在处理。
688
+ }
689
+ }
690
+ throw new Error('MINIMUM_SDK_VERSION_UNAVAILABLE:无法获取最低 SDK 版本,且没有 24 小时内的有效缓存');
691
+ }
692
+ cache.environments[options.environment] = { fetchedAt: now, minimumSdkVersion };
693
+ try {
694
+ await writeCache(cachePath, cache);
695
+ }
696
+ catch {
697
+ // 已校验的远端策略仍然可信;缓存只是离线回退优化。
698
+ }
699
+ return minimumSdkVersion;
700
+ }
701
+ function validateCurrentSdkVersion(currentSdkVersion, minimumSdkVersion, options) {
702
+ const current = validateSdkVersion(currentSdkVersion, '当前 SDK 版本');
703
+ const minimum = validateStableSdkVersion(minimumSdkVersion, 'minimumSdkVersion');
704
+ if (!options.allowPrerelease && context.semverExports.prerelease(current) !== null) {
705
+ throw new Error('正式发布不允许使用预发布 SDK,请运行 pnpm add @heybox/hb-sdk@latest 后重新构建');
706
+ }
707
+ if (!context.semverExports.satisfies(current, `>=${minimum}`, { includePrerelease: options.allowPrerelease })) {
708
+ throw new Error(`SDK_VERSION_TOO_LOW:当前 @heybox/hb-sdk@${current} 低于最低版本 ${minimum},请运行 pnpm add @heybox/hb-sdk@latest`);
709
+ }
710
+ return current;
711
+ }
712
+ function validateSdkVersion(value, label) {
713
+ const normalized = String(value).trim();
714
+ const parsed = context.semverExports.parse(normalized);
715
+ if (!parsed || parsed.version !== normalized || parsed.build.length > 0) {
716
+ throw new Error(`${label} 必须是合法 SemVer:${normalized}`);
717
+ }
718
+ return normalized;
719
+ }
720
+ function validateStableSdkVersion(value, label) {
721
+ const normalized = validateSdkVersion(value, label);
722
+ if (context.semverExports.prerelease(normalized) !== null)
723
+ throw new Error(`${label} 必须是稳定 SemVer:${normalized}`);
724
+ return normalized;
725
+ }
726
+ async function readCache(cachePath) {
727
+ try {
728
+ const parsed = JSON.parse(await fs$1.readFile(cachePath, 'utf8'));
729
+ if (parsed && typeof parsed === 'object' && parsed.environments && typeof parsed.environments === 'object')
730
+ return parsed;
731
+ }
732
+ catch {
733
+ // 缓存缺失或损坏时继续请求最新配置。
734
+ }
735
+ return { environments: {} };
736
+ }
737
+ async function writeCache(cachePath, cache) {
738
+ await fs$1.mkdir(path.dirname(cachePath), { recursive: true });
739
+ const temporaryPath = `${cachePath}.${process.pid}.tmp`;
740
+ await fs$1.writeFile(temporaryPath, `${JSON.stringify(cache, null, 2)}\n`, { mode: 0o600 });
741
+ await fs$1.rename(temporaryPath, cachePath);
742
+ }
743
+
744
+ const paths = index.envPaths('hb-sdk');
745
+ async function enforceRemoteSdkVersion(options) {
746
+ const minimumSdkVersion = await resolveMinimumSdkVersion({
747
+ cacheDir: options.cacheDir ?? paths.cache,
748
+ environment: options.environment,
749
+ fetchMinimumSdkVersion: async () => (await context.getPublicSdkConfig({ baseUrl: options.environment, fetchImpl: options.fetchImpl })).minimum_sdk_version,
750
+ });
751
+ return validateCurrentSdkVersion(options.sdkVersion, minimumSdkVersion, { allowPrerelease: options.allowPrerelease });
752
+ }
753
+
669
754
  /** 构建时替换为当前发布包的实际版本。 */
670
755
  const HB_SDK_VERSION = typeof undefined === 'string'
671
756
  ? undefined
672
- : '0.6.0';
757
+ : '0.6.2';
673
758
 
674
759
  const DEFAULT_APP_PORT = 5173;
675
760
  const DEFAULT_MOCK_PORT = 5174;
@@ -682,7 +767,7 @@ async function runDevCommand(options, runtime = {}) {
682
767
  const logger = runtime.logger ?? index.createCliLogger();
683
768
  const fetchImpl = runtime.fetchImpl ?? fetch;
684
769
  const environment = session.resolveHeyboxApiBaseUrl({ env: runtime.env });
685
- await (runtime.enforceRemoteSdkVersion ?? sdkVersionPolicy.enforceRemoteSdkVersion)({
770
+ await (runtime.enforceRemoteSdkVersion ?? enforceRemoteSdkVersion)({
686
771
  sdkVersion: HB_SDK_VERSION,
687
772
  environment,
688
773
  fetchImpl,
@@ -771,14 +856,14 @@ async function runDevCommand(options, runtime = {}) {
771
856
  installShutdownHandlers(closers, runtime.process ?? process);
772
857
  }
773
858
  async function loadDevLaunchContext(options) {
774
- const miniProgramId = await sdkVersionPolicy.readBoundMiniProgramId(options.projectRoot);
859
+ const miniProgramId = await context.readBoundMiniProgramId(options.projectRoot);
775
860
  if (!miniProgramId) {
776
861
  const nativeAppLaunchUnavailableReason = '当前项目未绑定小程序。请先运行 hb-sdk remote create 或 hb-sdk remote bind <mini-program-id>。';
777
862
  options.logger.warn(`未读取到远端 Runtime 权限,Mock runtime 将默认拒绝受管能力:${nativeAppLaunchUnavailableReason}`);
778
863
  return { nativeAppLaunchUnavailableReason };
779
864
  }
780
865
  try {
781
- const { detail, miniProgramId: verifiedMiniProgramId } = await options.logger.task('正在读取远端小程序权限', () => sdkVersionPolicy.getBoundMiniProgram({
866
+ const { detail, miniProgramId: verifiedMiniProgramId } = await options.logger.task('正在读取远端小程序权限', () => context.getBoundMiniProgram({
782
867
  cwd: options.projectRoot,
783
868
  env: options.env,
784
869
  fetchImpl: options.fetchImpl,
@@ -796,7 +881,7 @@ async function loadDevLaunchContext(options) {
796
881
  }
797
882
  }
798
883
  function canFallbackToDefaultRuntimePermissions(error) {
799
- if (error instanceof sdkVersionPolicy.MiniProgramProjectBindingError) {
884
+ if (error instanceof context.MiniProgramProjectBindingError) {
800
885
  return error.code === 'MINI_PROGRAM_UNBOUND';
801
886
  }
802
887
  if (error instanceof TypeError && error.message === 'fetch failed') {
@@ -4,7 +4,7 @@ var fs$1 = require('node:fs');
4
4
  var fs = require('node:fs/promises');
5
5
  var os = require('node:os');
6
6
  var path = require('node:path');
7
- var index = require('./index-CCeHouBU.cjs');
7
+ var index = require('./index-CTyguEza.cjs');
8
8
  require('node:module');
9
9
  require('path');
10
10
  require('os');
@@ -234,19 +234,19 @@ function requireArgument () {
234
234
 
235
235
  var command = {};
236
236
 
237
- const require$5 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CCeHouBU.cjs', document.baseURI).href)));
237
+ const require$5 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CTyguEza.cjs', document.baseURI).href)));
238
238
  function __require$4() { return require$5("node:events"); }
239
239
 
240
- const require$4 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CCeHouBU.cjs', document.baseURI).href)));
240
+ const require$4 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CTyguEza.cjs', document.baseURI).href)));
241
241
  function __require$3() { return require$4("node:child_process"); }
242
242
 
243
- const require$3 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CCeHouBU.cjs', document.baseURI).href)));
243
+ const require$3 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CTyguEza.cjs', document.baseURI).href)));
244
244
  function __require$2() { return require$3("node:path"); }
245
245
 
246
- const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CCeHouBU.cjs', document.baseURI).href)));
246
+ const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CTyguEza.cjs', document.baseURI).href)));
247
247
  function __require$1() { return require$2("node:fs"); }
248
248
 
249
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CCeHouBU.cjs', document.baseURI).href)));
249
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CTyguEza.cjs', document.baseURI).href)));
250
250
  function __require() { return require$1("node:process"); }
251
251
 
252
252
  var help = {};
@@ -13323,7 +13323,7 @@ function getPathname(pathWithQuery) {
13323
13323
  }
13324
13324
 
13325
13325
  const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
13326
- const BUILT_CLI_VERSION = '0.6.0';
13326
+ const BUILT_CLI_VERSION = '0.6.2';
13327
13327
  const PACKAGE_JSON_CANDIDATES = [
13328
13328
  path.resolve(__dirname, '..', '..', 'package.json'),
13329
13329
  path.resolve(__dirname, '..', 'package.json'),
@@ -13644,31 +13644,31 @@ function createCommandLoggerResolver(options) {
13644
13644
  };
13645
13645
  }
13646
13646
  const defaultClearLoginStatus = async (...args) => {
13647
- const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-DtXHSm8R.cjs'); });
13647
+ const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-BWN2-2Gk.cjs'); });
13648
13648
  return clearLoginStatus(...args);
13649
13649
  };
13650
13650
  const defaultLoginToHeybox = async (...args) => {
13651
- const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-DtXHSm8R.cjs'); });
13651
+ const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-BWN2-2Gk.cjs'); });
13652
13652
  return loginToHeybox(...args);
13653
13653
  };
13654
13654
  const defaultPrintLoginStatus = async (...args) => {
13655
- const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-DtXHSm8R.cjs'); });
13655
+ const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-BWN2-2Gk.cjs'); });
13656
13656
  return printLoginStatus(...args);
13657
13657
  };
13658
13658
  const defaultRunCreateCommand = async (...args) => {
13659
- const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-DYb53EQ-.cjs'); });
13659
+ const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-CXBnqr5r.cjs'); });
13660
13660
  return runCreateCommand(...args);
13661
13661
  };
13662
13662
  const defaultRunDevCommand = async (...args) => {
13663
- const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-CPKTuA6q.cjs'); });
13663
+ const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-OCij_ecL.cjs'); });
13664
13664
  return runDevCommand(...args);
13665
13665
  };
13666
13666
  const defaultRunDoctorCommand = async (...args) => {
13667
- const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-TshFvqHC.cjs'); });
13667
+ const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-DQIzL_3_.cjs'); });
13668
13668
  return runDoctorCommand(...args);
13669
13669
  };
13670
13670
  const defaultRunRemoteCommand = async (...args) => {
13671
- const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-BWfn7qIN.cjs'); });
13671
+ const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-DxKtJ21x.cjs'); });
13672
13672
  return runRemoteCommand(...args);
13673
13673
  };
13674
13674
  function resolveStandaloneLogger(options, verbose) {
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var index$2 = require('./index-CCeHouBU.cjs');
3
+ var index$2 = require('./index-CTyguEza.cjs');
4
4
  var require$$0$2 = require('fs');
5
5
  var require$$2$1 = require('crypto');
6
6
  var require$$1$2 = require('path');
7
7
  var require$$0$3 = require('assert');
8
8
  var require$$4$2 = require('events');
9
9
  var require$$1$1 = require('util');
10
- var sdkVersionPolicy = require('./sdk-version-policy-B1CFC1Dk.cjs');
10
+ var context$1 = require('./context-DmxbC_iV.cjs');
11
11
  var require$$0$5 = require('net');
12
12
  var require$$0$4 = require('url');
13
13
  var require$$2$2 = require('http');
@@ -13707,7 +13707,7 @@ function requireSource () {
13707
13707
  const ajv_1 = requireAjv$1();
13708
13708
  const ajv_formats_1 = requireDist();
13709
13709
  const debounceFn = requireDebounceFn();
13710
- const semver = sdkVersionPolicy.requireSemver();
13710
+ const semver = context$1.requireSemver();
13711
13711
  const onetime = index$2.requireOnetime();
13712
13712
  const encryptionAlgorithm = 'aes-256-cbc';
13713
13713
  const createPlainObject = () => {
@@ -3,9 +3,9 @@
3
3
  var promises = require('node:readline/promises');
4
4
  var node_crypto = require('node:crypto');
5
5
  var node_http = require('node:http');
6
- var session = require('./session-DIcRjyDY.cjs');
6
+ var session = require('./session-D7mPwyx4.cjs');
7
7
  var browser = require('./browser-RAy8e8cV.cjs');
8
- var index = require('./index-CCeHouBU.cjs');
8
+ var index = require('./index-CTyguEza.cjs');
9
9
  require('node:path');
10
10
  require('fs');
11
11
  require('constants');
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var promises = require('node:readline/promises');
4
- var index = require('./index-CCeHouBU.cjs');
5
- var session = require('./session-DIcRjyDY.cjs');
4
+ var index = require('./index-CTyguEza.cjs');
5
+ var session = require('./session-D7mPwyx4.cjs');
6
6
  var childProcess = require('node:child_process');
7
7
  var fs = require('node:fs');
8
8
  var fs$1 = require('node:fs/promises');
9
9
  var path = require('node:path');
10
- var sdkVersionPolicy = require('./sdk-version-policy-B1CFC1Dk.cjs');
10
+ var context = require('./context-DmxbC_iV.cjs');
11
11
  require('node:module');
12
12
  require('path');
13
13
  require('os');
@@ -61,7 +61,7 @@ function validateSdkVersion(version, sourceLabel = 'sdkVersion') {
61
61
  throw new Error(`${sourceLabel} 必须是合法 SemVer:${String(version)}`);
62
62
  }
63
63
  const normalized = version.trim();
64
- const parsed = sdkVersionPolicy.semverExports.parse(normalized);
64
+ const parsed = context.semverExports.parse(normalized);
65
65
  if (!parsed || parsed.version !== normalized || parsed.build.length > 0) {
66
66
  throw new Error(`${sourceLabel} 必须是合法 SemVer:${normalized}`);
67
67
  }
@@ -75,7 +75,7 @@ function getMiniappManifestVersionError(version) {
75
75
  return `必须是合法 SemVer:${String(version)}`;
76
76
  }
77
77
  const normalized = version.trim();
78
- const parsed = sdkVersionPolicy.semverExports.parse(normalized);
78
+ const parsed = context.semverExports.parse(normalized);
79
79
  if (!parsed) {
80
80
  return `必须是合法 SemVer:${normalized}`;
81
81
  }
@@ -142,7 +142,7 @@ async function runUpload(options, runtime = {}) {
142
142
  const postCDNUploadCallback$1 = runtime.postCDNUploadCallback ?? postCDNUploadCallback;
143
143
  const createReadStream = runtime.createReadStream ?? fs.createReadStream;
144
144
  const orderedFiles = [...options.files].sort((a, b) => a.relativePath.localeCompare(b.relativePath));
145
- const batches = chunkUploadFiles(orderedFiles, sdkVersionPolicy.MINIAPP_UPLOAD_BATCH_SIZE);
145
+ const batches = chunkUploadFiles(orderedFiles, context.MINIAPP_UPLOAD_BATCH_SIZE);
146
146
  await logger.task(`正在上传 ${orderedFiles.length} 个文件`, async (taskContext) => {
147
147
  logger.debug(`上传并发数: ${concurrency}`);
148
148
  logger.debug(`上传批次数: ${batches.length}`);
@@ -152,7 +152,7 @@ async function runUpload(options, runtime = {}) {
152
152
  logger.debug(`正在处理上传批次 ${batchIndex + 1}/${batches.length},文件数: ${batch.length}`);
153
153
  logger.debug('正在获取 CDN 上传信息');
154
154
  const fileInfos = createUploadFileInfos(batch, options);
155
- const uploadInfo = await getCDNUploadInfo$1({ session: options.session, scope: sdkVersionPolicy.MINIAPP_UPLOAD_SCOPE, fileInfos, needCache: false }, { baseUrl: runtime.baseUrl, fetchImpl });
155
+ const uploadInfo = await getCDNUploadInfo$1({ session: options.session, scope: context.MINIAPP_UPLOAD_SCOPE, fileInfos, needCache: false }, { baseUrl: runtime.baseUrl, fetchImpl });
156
156
  logger.debug(`CDN bucket: ${uploadInfo.bucket}`);
157
157
  logger.debug(`CDN region: ${uploadInfo.region}`);
158
158
  validateUploadInfoKeys(batch, uploadInfo.keys, options);
@@ -213,7 +213,7 @@ function createUploadFileInfos(files, options) {
213
213
  name: file.relativePath.split('/').pop() ?? file.relativePath,
214
214
  mimetype: file.mimeType,
215
215
  fsize: file.size,
216
- path: sdkVersionPolicy.getMiniappUploadKey({
216
+ path: context.getMiniappUploadKey({
217
217
  miniProgramId: options.miniProgramId,
218
218
  version: options.version,
219
219
  relativePath: file.relativePath,
@@ -225,7 +225,7 @@ function validateUploadInfoKeys(files, keys, options) {
225
225
  throw new index.CliError(`CDN 上传接口返回 key 数量异常:期望 ${files.length},实际 ${keys.length}`);
226
226
  }
227
227
  for (let index$1 = 0; index$1 < files.length; index$1 += 1) {
228
- const expectedKey = sdkVersionPolicy.getMiniappUploadKey({
228
+ const expectedKey = context.getMiniappUploadKey({
229
229
  miniProgramId: options.miniProgramId,
230
230
  version: options.version,
231
231
  relativePath: files[index$1].relativePath,
@@ -264,7 +264,7 @@ async function createDefaultCosClient(uploadToken) {
264
264
  };
265
265
  }
266
266
  async function loadCosConstructor() {
267
- const cosModule = await Promise.resolve().then(function () { return require('./index-NOO3q8_C.cjs'); }).then(function (n) { return n.index; });
267
+ const cosModule = await Promise.resolve().then(function () { return require('./index-Ulhxo0YK.cjs'); }).then(function (n) { return n.index; });
268
268
  return cosModule.default;
269
269
  }
270
270
  function formatSize(bytes) {
@@ -308,10 +308,8 @@ function isRecord(value) {
308
308
  }
309
309
 
310
310
  async function precheckUserMiniprogramVersion(options, runtime = {}) {
311
- return postUserMiniprogramVersionForm(sdkVersionPolicy.PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, options, {
312
- name: options.name,
313
- icon_url: options.iconUrl,
314
- cover_image_urls: options.coverImageUrls.join(','),
311
+ return postUserMiniprogramVersionForm(context.PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, options, {
312
+ // 展示资料由服务端沿用 last approved 或注入默认名/默认图;CLI 不传 name/icon/cover。
315
313
  ...(options.version ? { version: options.version } : {}),
316
314
  ...(options.source_version ? { source_version: options.source_version } : {}),
317
315
  release_note: options.releaseNote,
@@ -319,10 +317,8 @@ async function precheckUserMiniprogramVersion(options, runtime = {}) {
319
317
  }, runtime);
320
318
  }
321
319
  async function submitUserMiniprogramAudit(options, runtime = {}) {
322
- return postUserMiniprogramVersionForm(sdkVersionPolicy.SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, options, {
323
- name: options.name,
324
- icon_url: options.iconUrl,
325
- cover_image_urls: options.coverImageUrls.join(','),
320
+ return postUserMiniprogramVersionForm(context.SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, options, {
321
+ // 展示资料由服务端沿用 last approved 或注入默认名/默认图;CLI 不传 name/icon/cover。
326
322
  ...(options.manifest ? { manifest: JSON.stringify(options.manifest) } : {}),
327
323
  ...(options.source_version ? { source_version: options.source_version } : {}),
328
324
  release_note: options.releaseNote,
@@ -8670,7 +8666,6 @@ async function runDeployCommand(options, runtime = {}) {
8670
8666
  if (typeof miniProgramId !== 'string' || !miniProgramId.trim()) {
8671
8667
  throw new Error('未在 package.json 中找到 heybox.miniProgramId,请先配置 mini program id');
8672
8668
  }
8673
- const miniProgramProfile = readMiniProgramVersionProfile(packageJson);
8674
8669
  const fromVersion = options.fromVersion?.trim();
8675
8670
  const releaseNote = await resolveDeployReleaseNote(options, runtime);
8676
8671
  const session$1 = await logger.task('正在校验 Heybox 登录态', () => (runtime.requireAuthSession ?? session.requireHeyboxAuthSession)({ loginBaseUrl }), { successText: 'Heybox 登录态有效' });
@@ -8682,7 +8677,6 @@ async function runDeployCommand(options, runtime = {}) {
8682
8677
  const precheck = await runVersionPrecheck({
8683
8678
  session: session$1,
8684
8679
  miniProgramId,
8685
- ...miniProgramProfile,
8686
8680
  ...historyArtifact,
8687
8681
  releaseNote,
8688
8682
  autoPublish,
@@ -8691,12 +8685,6 @@ async function runDeployCommand(options, runtime = {}) {
8691
8685
  if (!sourceSdkVersion) {
8692
8686
  throw new Error('历史产物缺少 sdkVersion,无法复用,请重新构建并上传新版本');
8693
8687
  }
8694
- await (runtime.enforceRemoteSdkVersion ?? sdkVersionPolicy.enforceRemoteSdkVersion)({
8695
- sdkVersion: sourceSdkVersion,
8696
- environment: apiBaseUrl,
8697
- fetchImpl: runtime.fetchImpl,
8698
- allowPrerelease: false,
8699
- });
8700
8688
  precheckVersion = precheck.version || precheck.version_normalized || fromVersion;
8701
8689
  }
8702
8690
  else {
@@ -8707,7 +8695,6 @@ async function runDeployCommand(options, runtime = {}) {
8707
8695
  await runVersionPrecheck({
8708
8696
  session: session$1,
8709
8697
  miniProgramId,
8710
- ...miniProgramProfile,
8711
8698
  version: precheckVersion,
8712
8699
  releaseNote,
8713
8700
  autoPublish,
@@ -8716,6 +8703,7 @@ async function runDeployCommand(options, runtime = {}) {
8716
8703
  const buildMode = env.HB_SDK_ENV?.trim();
8717
8704
  logger.info(`开始构建: ${pm} ${createBuildArgs(pm, buildMode).join(' ')}`);
8718
8705
  await runBuildScript(pm, projectRoot, runtime.spawn ?? childProcess.spawn, {
8706
+ env,
8719
8707
  mode: buildMode,
8720
8708
  outputMode: options.buildOutputMode ?? 'inherit',
8721
8709
  stderr: runtime.stderr,
@@ -8729,27 +8717,21 @@ async function runDeployCommand(options, runtime = {}) {
8729
8717
  const distDir = path.join(projectRoot, 'dist');
8730
8718
  parsedManifest ??= await readDeployManifest(projectRoot, logger);
8731
8719
  ({ manifest, version } = parsedManifest);
8732
- await (runtime.enforceRemoteSdkVersion ?? sdkVersionPolicy.enforceRemoteSdkVersion)({
8733
- sdkVersion: parsedManifest.sdkVersion,
8734
- environment: apiBaseUrl,
8735
- fetchImpl: runtime.fetchImpl,
8736
- allowPrerelease: false,
8737
- });
8738
8720
  if (version !== precheckVersion) {
8739
8721
  throw new Error(`dist/manifest.json.version (${version}) 与预检版本 (${precheckVersion}) 不一致,请重新 build 后再 deploy`);
8740
8722
  }
8741
8723
  const uploadFiles = await logger.task('正在校验 dist 上传文件', async () => {
8742
8724
  const allFiles = await walkDistFiles(distDir);
8743
- const blocked = allFiles.find((entry) => sdkVersionPolicy.relativePathContainsNodeModulesSegment(entry.relativePath));
8725
+ const blocked = allFiles.find((entry) => context.relativePathContainsNodeModulesSegment(entry.relativePath));
8744
8726
  if (blocked) {
8745
8727
  throw new Error(`dist 目录含 node_modules:${blocked.relativePath}`);
8746
8728
  }
8747
- const files = allFiles.filter((entry) => sdkVersionPolicy.shouldUploadDistFile(entry.relativePath));
8748
- const pathError = sdkVersionPolicy.validateUploadPaths(files, { miniProgramId, version, maxLength: sdkVersionPolicy.ACTIVITY_UPLOAD_KEY_MAX_LENGTH });
8729
+ const files = allFiles.filter((entry) => context.shouldUploadDistFile(entry.relativePath));
8730
+ const pathError = context.validateUploadPaths(files, { miniProgramId, version, maxLength: context.ACTIVITY_UPLOAD_KEY_MAX_LENGTH });
8749
8731
  if (pathError) {
8750
8732
  throw new Error(pathError);
8751
8733
  }
8752
- const sizeError = sdkVersionPolicy.validateUploadTotalSize(files);
8734
+ const sizeError = context.validateUploadTotalSize(files);
8753
8735
  if (sizeError) {
8754
8736
  throw new Error(sizeError);
8755
8737
  }
@@ -8765,8 +8747,8 @@ async function runDeployCommand(options, runtime = {}) {
8765
8747
  }
8766
8748
  try {
8767
8749
  const submitOptions = fromVersion
8768
- ? { session: session$1, miniProgramId, ...miniProgramProfile, ...historyArtifact, releaseNote, autoPublish }
8769
- : { session: session$1, miniProgramId, ...miniProgramProfile, manifest, releaseNote, autoPublish };
8750
+ ? { session: session$1, miniProgramId, ...historyArtifact, releaseNote, autoPublish }
8751
+ : { session: session$1, miniProgramId, manifest, releaseNote, autoPublish };
8770
8752
  submitAuditResult = await logger.task('正在提交审核', () => (runtime.submitUserMiniprogramAudit ?? submitUserMiniprogramAudit)(submitOptions, {
8771
8753
  baseUrl: apiBaseUrl,
8772
8754
  fetchImpl: runtime.fetchImpl,
@@ -8825,42 +8807,6 @@ function findProjectRoot(startDir) {
8825
8807
  async function readPackageJson(projectRoot) {
8826
8808
  return JSON.parse(await fs$1.readFile(path.join(projectRoot, 'package.json'), 'utf8'));
8827
8809
  }
8828
- function readMiniProgramVersionProfile(packageJson) {
8829
- const profile = packageJson.heybox?.miniProgramProfile;
8830
- return {
8831
- name: readRequiredProfileText(profile?.name, 'heybox.miniProgramProfile.name'),
8832
- iconUrl: readRequiredHttpsUrl(profile?.iconUrl, 'heybox.miniProgramProfile.iconUrl'),
8833
- coverImageUrls: readCoverImageUrls(profile?.coverImageUrls),
8834
- };
8835
- }
8836
- function readRequiredProfileText(value, pathLabel) {
8837
- const text = typeof value === 'string' ? value.trim() : '';
8838
- if (!text) {
8839
- throw new Error(`${pathLabel} 不能为空;请在 package.json 配置本次提交审核的小程序资料`);
8840
- }
8841
- return text;
8842
- }
8843
- function readRequiredHttpsUrl(value, pathLabel) {
8844
- const text = readRequiredProfileText(value, pathLabel);
8845
- if (!/^https:\/\//i.test(text)) {
8846
- throw new Error(`${pathLabel} 必须是 HTTPS 地址`);
8847
- }
8848
- return text;
8849
- }
8850
- function readCoverImageUrls(value) {
8851
- if (!Array.isArray(value)) {
8852
- throw new Error('heybox.miniProgramProfile.coverImageUrls 至少配置 1 张 HTTPS 图片');
8853
- }
8854
- const urls = value.map((item) => (typeof item === 'string' ? item.trim() : '')).filter(Boolean);
8855
- if (urls.length === 0) {
8856
- throw new Error('heybox.miniProgramProfile.coverImageUrls 至少配置 1 张 HTTPS 图片');
8857
- }
8858
- const invalidUrl = urls.find((url) => !/^https:\/\//i.test(url));
8859
- if (invalidUrl) {
8860
- throw new Error(`heybox.miniProgramProfile.coverImageUrls 必须都是 HTTPS 地址:${invalidUrl}`);
8861
- }
8862
- return urls;
8863
- }
8864
8810
  async function readDeployManifest(projectRoot, logger) {
8865
8811
  const distDir = path.join(projectRoot, 'dist');
8866
8812
  const manifestPath = path.join(distDir, 'manifest.json');
@@ -8950,6 +8896,7 @@ async function runBuildScript(pm, cwd, spawnImpl, options) {
8950
8896
  const buildArgs = createBuildArgs(pm, options.mode);
8951
8897
  const child = spawnImpl(pm, buildArgs, {
8952
8898
  cwd,
8899
+ env: { ...process.env, ...options.env, HB_SDK_DEPLOY_BUILD: '1' },
8953
8900
  stdio: pipeStdoutToStderr ? ['inherit', 'pipe', 'inherit'] : 'inherit',
8954
8901
  });
8955
8902
  if (pipeStdoutToStderr) {
@@ -8993,7 +8940,7 @@ async function walkDistFiles(distDir) {
8993
8940
  }
8994
8941
  const fileStat = await fs$1.stat(absPath);
8995
8942
  results.push({
8996
- relativePath: sdkVersionPolicy.normalizeRelativePath(relPath),
8943
+ relativePath: context.normalizeRelativePath(relPath),
8997
8944
  absolutePath: absPath,
8998
8945
  size: fileStat.size,
8999
8946
  mimeType: inferMimeType(entry.name),
@@ -9152,7 +9099,7 @@ async function runRemoteDeployCommand(options, runtime) {
9152
9099
  async function createRemoteCommandContext(options, runtime) {
9153
9100
  index.applyServiceTagIfNeeded(options.serviceTag);
9154
9101
  const logger = resolveRemoteLogger(options, runtime);
9155
- const environment = await sdkVersionPolicy.resolveRemoteEnvironment({
9102
+ const environment = await context.resolveRemoteEnvironment({
9156
9103
  allowUnsafeApiBaseUrl: options.allowUnsafeApiBaseUrl,
9157
9104
  apiBaseUrl: options.apiBaseUrl,
9158
9105
  env: options.env,
@@ -9162,10 +9109,10 @@ async function createRemoteCommandContext(options, runtime) {
9162
9109
  fetchImpl: runtime.fetchImpl,
9163
9110
  requireAuthSession: runtime.requireAuthSession,
9164
9111
  });
9165
- const packageJson = await sdkVersionPolicy.readMiniProgramProjectPackage(runtime.cwd ?? process.cwd());
9166
- const binding = sdkVersionPolicy.readBoundMiniProgramIdFromPackageJson(packageJson.packageJson);
9112
+ const packageJson = await context.readMiniProgramProjectPackage(runtime.cwd ?? process.cwd());
9113
+ const binding = context.readBoundMiniProgramIdFromPackageJson(packageJson.packageJson);
9167
9114
  const api = {
9168
- ...adaptRemoteApiClient(sdkVersionPolicy.createRemoteApiClientForEnvironment(environment)),
9115
+ ...adaptRemoteApiClient(context.createRemoteApiClientForEnvironment(environment)),
9169
9116
  ...runtime.api,
9170
9117
  };
9171
9118
  logger.debug(`Heybox API: ${environment.apiBaseUrl}`);
@@ -9306,39 +9253,39 @@ async function remoteList(options, context, runtime) {
9306
9253
  }
9307
9254
  return finishRemoteCommand(options, runtime, output);
9308
9255
  }
9309
- async function remoteCreate(options, context, runtime) {
9310
- if (context.binding && !options.forceBind) {
9311
- throw new Error(`当前项目已绑定 ${context.binding};如需覆盖,请使用 --force-bind`);
9256
+ async function remoteCreate(options, context$1, runtime) {
9257
+ if (context$1.binding && !options.forceBind) {
9258
+ throw new Error(`当前项目已绑定 ${context$1.binding};如需覆盖,请使用 --force-bind`);
9312
9259
  }
9313
- const access = await context.api.accessStatus();
9260
+ const access = await context$1.api.accessStatus();
9314
9261
  if (access.status !== 'approved') {
9315
9262
  throw new Error(`当前 CLI 用户没有创建工坊小程序权限:${String(access.status ?? 'unknown')}`);
9316
9263
  }
9317
- await confirmCreateWithCurrentEntity(options, context, runtime);
9318
- const result = await context.api.createMiniProgram();
9264
+ await confirmCreateWithCurrentEntity(options, context$1, runtime);
9265
+ const result = await context$1.api.createMiniProgram();
9319
9266
  const miniProgramId = requireMiniProgramId(result);
9320
- await sdkVersionPolicy.writeBoundMiniProgramId(context.packageJson.projectRoot, miniProgramId, { force: options.forceBind });
9267
+ await context.writeBoundMiniProgramId(context$1.packageJson.projectRoot, miniProgramId, { force: options.forceBind });
9321
9268
  const output = { changed: true, miniProgramId, remote: toCamelCaseDeep(result) };
9322
9269
  if (!options.json) {
9323
- context.logger.success(`创建并绑定成功:${miniProgramId}`);
9270
+ context$1.logger.success(`创建并绑定成功:${miniProgramId}`);
9324
9271
  }
9325
9272
  return finishRemoteCommand(options, runtime, output);
9326
9273
  }
9327
- async function remoteBind(options, context, runtime) {
9274
+ async function remoteBind(options, context$1, runtime) {
9328
9275
  const miniProgramId = requireNonEmpty(options.miniProgramId, 'remote bind 必须传 <mini-program-id>');
9329
- if (context.binding && context.binding !== miniProgramId && !options.force) {
9330
- throw new Error(`当前项目已绑定 ${context.binding};如需覆盖本地绑定,请使用 --force`);
9276
+ if (context$1.binding && context$1.binding !== miniProgramId && !options.force) {
9277
+ throw new Error(`当前项目已绑定 ${context$1.binding};如需覆盖本地绑定,请使用 --force`);
9331
9278
  }
9332
- const detail = await context.api.getMiniProgramDetail(miniProgramId);
9279
+ const detail = await context$1.api.getMiniProgramDetail(miniProgramId);
9333
9280
  const verifiedId = requireMiniProgramId(detail);
9334
- await assertMiniProgramEntityMatchesCurrent(context, detail);
9335
- const changed = context.binding !== verifiedId;
9281
+ await assertMiniProgramEntityMatchesCurrent(context$1, detail);
9282
+ const changed = context$1.binding !== verifiedId;
9336
9283
  if (changed) {
9337
- await sdkVersionPolicy.writeBoundMiniProgramId(context.packageJson.projectRoot, verifiedId, { force: options.force });
9284
+ await context.writeBoundMiniProgramId(context$1.packageJson.projectRoot, verifiedId, { force: options.force });
9338
9285
  }
9339
9286
  const output = { changed, miniProgramId: verifiedId, remote: toCamelCaseDeep(detail) };
9340
9287
  if (!options.json) {
9341
- context.logger.success(changed ? `绑定成功:${verifiedId}` : `已绑定:${verifiedId}`);
9288
+ context$1.logger.success(changed ? `绑定成功:${verifiedId}` : `已绑定:${verifiedId}`);
9342
9289
  }
9343
9290
  return finishRemoteCommand(options, runtime, output);
9344
9291
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-CCeHouBU.cjs');
3
+ var index = require('./index-CTyguEza.cjs');
4
4
  var node_crypto = require('node:crypto');
5
5
  var path = require('node:path');
6
6
  var require$$0$2 = require('fs');
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./cli-chunks/index-CCeHouBU.cjs');
3
+ var index = require('./cli-chunks/index-CTyguEza.cjs');
4
4
  require('node:module');
5
5
  require('node:fs');
6
6
  require('node:fs/promises');
package/dist/index.cjs.js CHANGED
@@ -325,7 +325,7 @@ function createMessageId() {
325
325
  /** 构建时替换为当前发布包的实际版本。 */
326
326
  const HB_SDK_VERSION = typeof undefined === 'string'
327
327
  ? undefined
328
- : '0.6.0';
328
+ : '0.6.2';
329
329
 
330
330
  /**
331
331
  * 判断未知数据是否符合小程序 bridge 消息信封。
package/dist/index.esm.js CHANGED
@@ -321,7 +321,7 @@ function createMessageId() {
321
321
  /** 构建时替换为当前发布包的实际版本。 */
322
322
  const HB_SDK_VERSION = typeof undefined === 'string'
323
323
  ? undefined
324
- : '0.6.0';
324
+ : '0.6.2';
325
325
 
326
326
  /**
327
327
  * 判断未知数据是否符合小程序 bridge 消息信封。
@@ -21,7 +21,7 @@ npm run deploy
21
21
 
22
22
  - `npm run dev`:启动本地 Vite 服务和 `hb-sdk` 内置 mock runtime host,适合本地调试 SDK 能力;调试页内可点击按钮在 Mac 版 APP 中启动同一页面,也可以选择局域网网卡后用手机小黑盒 APP 扫码调试。手机需要与电脑处在同一局域网,并使用支持小程序调试壳的新版小黑盒 APP。Codex、VSCode 等内嵌浏览器可能无法唤起系统 APP,需要时请在系统浏览器中打开同一个调试页后重试。
23
23
  - `npm run build`:先执行 TypeScript 检查,再构建生产产物。
24
- - `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` 在 current entity 下创建并绑定,或用 `npx hb-sdk remote bind <mini-program-id>` 绑定 current entity 可管理的已有小程序。小程序名称、icon 和介绍图在 `package.json.heybox.miniProgramProfile` 中配置并随版本审核提交。`selectedEntity` 只是 CLI 登录缓存中的提示快照,实际 deploy/create/bind 以服务端 current entity 为准。默认审核通过后用 `hb-sdk remote versions` 查看状态,再用 `hb-sdk remote release <version>` 发布,如需审核通过后自动发布可追加 `--auto-publish`。顶层 `hb-sdk deploy` 已删除,不再作为兼容别名保留。
24
+ - `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` 在 current entity 下创建并绑定,或用 `npx hb-sdk remote bind <mini-program-id>` 绑定 current entity 可管理的已有小程序。小程序名称、icon 和介绍图在开放平台版本发布中维护;CLI 项目配置只保留 `heybox.miniProgramId`,首次部署服务端会使用默认名与默认图。`selectedEntity` 只是 CLI 登录缓存中的提示快照,实际 deploy/create/bind 以服务端 current entity 为准。默认审核通过后用 `hb-sdk remote versions` 查看状态,再用 `hb-sdk remote release <version>` 发布,如需审核通过后自动发布可追加 `--auto-publish`。顶层 `hb-sdk deploy` 已删除,不再作为兼容别名保留。
25
25
 
26
26
  ## 更多能力
27
27
 
@@ -4,12 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "heybox": {
7
- "miniProgramId": "",
8
- "miniProgramProfile": {
9
- "name": "<%= packageName %>",
10
- "iconUrl": "",
11
- "coverImageUrls": []
12
- }
7
+ "miniProgramId": ""
13
8
  },
14
9
  "scripts": {
15
10
  "hb-sdk": "hb-sdk",
package/dist/vite.cjs.js CHANGED
@@ -10,7 +10,7 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
10
10
  /** 构建时替换为当前发布包的实际版本。 */
11
11
  const HB_SDK_VERSION = typeof undefined === 'string'
12
12
  ? undefined
13
- : '0.6.0';
13
+ : '0.6.2';
14
14
 
15
15
  function getDefaultExportFromCjs (x) {
16
16
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -11933,7 +11933,7 @@ function miniappManifest(options = {}) {
11933
11933
  hmrWebSocketUrl = resolveHmrWebSocketUrl(resolved);
11934
11934
  },
11935
11935
  async buildStart() {
11936
- if (command !== 'build')
11936
+ if (command !== 'build' || process.env.HB_SDK_DEPLOY_BUILD === '1')
11937
11937
  return;
11938
11938
  try {
11939
11939
  await (options.enforceSdkVersion ?? enforceViteSdkVersion)({
@@ -11966,10 +11966,10 @@ function miniappManifest(options = {}) {
11966
11966
  const sdkVersion = resolveSdkVersion();
11967
11967
  const outputRoot = path.resolve(root, outDir);
11968
11968
  const htmlFiles = collectHtmlFiles(outputRoot);
11969
- const unexpectedHtmlFiles = htmlFiles.filter(file => path.relative(outputRoot, file) !== 'index.html');
11969
+ const unexpectedHtmlFiles = htmlFiles.filter((file) => path.relative(outputRoot, file) !== 'index.html');
11970
11970
  if (unexpectedHtmlFiles.length > 0) {
11971
11971
  throw new Error(`工坊小程序只支持单页应用,构建产物不允许额外 HTML:${unexpectedHtmlFiles
11972
- .map(file => path.relative(outputRoot, file).split(path.sep).join('/'))
11972
+ .map((file) => path.relative(outputRoot, file).split(path.sep).join('/'))
11973
11973
  .join(', ')}`);
11974
11974
  }
11975
11975
  const indexHtmlPath = path.join(outputRoot, 'index.html');
package/dist/vite.esm.js CHANGED
@@ -7,7 +7,7 @@ import { readFile, mkdir, writeFile, rename } from 'node:fs/promises';
7
7
  /** 构建时替换为当前发布包的实际版本。 */
8
8
  const HB_SDK_VERSION = typeof undefined === 'string'
9
9
  ? undefined
10
- : '0.6.0';
10
+ : '0.6.2';
11
11
 
12
12
  function getDefaultExportFromCjs (x) {
13
13
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -11930,7 +11930,7 @@ function miniappManifest(options = {}) {
11930
11930
  hmrWebSocketUrl = resolveHmrWebSocketUrl(resolved);
11931
11931
  },
11932
11932
  async buildStart() {
11933
- if (command !== 'build')
11933
+ if (command !== 'build' || process.env.HB_SDK_DEPLOY_BUILD === '1')
11934
11934
  return;
11935
11935
  try {
11936
11936
  await (options.enforceSdkVersion ?? enforceViteSdkVersion)({
@@ -11963,10 +11963,10 @@ function miniappManifest(options = {}) {
11963
11963
  const sdkVersion = resolveSdkVersion();
11964
11964
  const outputRoot = path.resolve(root, outDir);
11965
11965
  const htmlFiles = collectHtmlFiles(outputRoot);
11966
- const unexpectedHtmlFiles = htmlFiles.filter(file => path.relative(outputRoot, file) !== 'index.html');
11966
+ const unexpectedHtmlFiles = htmlFiles.filter((file) => path.relative(outputRoot, file) !== 'index.html');
11967
11967
  if (unexpectedHtmlFiles.length > 0) {
11968
11968
  throw new Error(`工坊小程序只支持单页应用,构建产物不允许额外 HTML:${unexpectedHtmlFiles
11969
- .map(file => path.relative(outputRoot, file).split(path.sep).join('/'))
11969
+ .map((file) => path.relative(outputRoot, file).split(path.sep).join('/'))
11970
11970
  .join(', ')}`);
11971
11971
  }
11972
11972
  const indexHtmlPath = path.join(outputRoot, 'index.html');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heybox/hb-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "sideEffects": [
5
5
  "./src/index.ts",
6
6
  "./src/core/singleton.ts",
@@ -92,7 +92,7 @@
92
92
  "vue": "^2.7.16",
93
93
  "vite": "^8.0.12",
94
94
  "vitest": "^3.2.4",
95
- "@heybox/hb-api": "~1.25.0"
95
+ "@heybox/hb-api": "~1.25.1"
96
96
  },
97
97
  "publishConfig": {
98
98
  "registry": "https://registry.npmjs.org/",
package/skill/SKILL.md CHANGED
@@ -52,14 +52,14 @@ Apply these instructions when writing, reviewing, or debugging code that consume
52
52
  2. Use `hb-sdk dev` for local browser debugging through the built-in mock runtime host. The project must bind `package.json.heybox.miniProgramId` and the CLI must be logged in so dev can load the real Runtime permission snapshot before starting Vite.
53
53
  3. Use `hb-sdk remote ...` for developer-owned remote mini-program management. Top-level `hb-sdk deploy` has been hard-cut and must not be recommended as a compatibility alias.
54
54
  4. Use `hb-sdk remote entity list`, `hb-sdk remote entity current`, and `hb-sdk remote entity switch <entity-id>` to inspect or change the developer platform server-side current entity before remote management commands.
55
- 5. Use `hb-sdk remote create` to create a remote mini-program under the server-side current entity and bind the returned id into `package.json.heybox.miniProgramId`; use `hb-sdk remote bind <mini-program-id>` to bind an existing remote mini-program after current-entity manageability is verified. Mini-program name, icon, and cover images belong in `package.json.heybox.miniProgramProfile` and are submitted with version audit.
55
+ 5. Use `hb-sdk remote create` to create a remote mini-program under the server-side current entity and bind the returned id into `package.json.heybox.miniProgramId`; use `hb-sdk remote bind <mini-program-id>` to bind an existing remote mini-program after current-entity manageability is verified. CLI project configuration contains only `package.json.heybox.miniProgramId`; mini-program name, icon, and cover images are maintained on the Open platform version-publish flow. On first submit without prior approved profile, the server injects a default name and default images.
56
56
  6. 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 read/basic/preview management workflows. Mini-program name and image changes must go through version audit, so the CLI must not expose a basic-info update command.
57
- 7. Use `hb-sdk remote deploy --release-note <text>` to build, upload, and submit the current project for audit. It reads `package.json.heybox.miniProgramId`, validates that the bound mini-program belongs to the server-side current entity before precheck/build/upload, prechecks `package.json.version` before build, runs the project's `build` script via the package manager auto-detected by lockfile, uploads `dist/` to CDN (skipping `manifest.json`, `.DS_Store`, `.map`), then calls the submit-audit API. When `--env <name>` or `HB_SDK_ENV=<name>` selects an environment preset, deploy also passes the same name to the project build as its Vite mode. The deploy upload pipeline rejects actual upload artifacts over 100MiB before any upload request, processes CDN upload metadata and callback confirmation at 50 files per batch, keeps 4-way upload concurrency within each batch, and validates CDN-returned keys exactly against the local expected upload keys.
57
+ 7. Use `hb-sdk remote deploy --release-note <text>` to build, upload, and submit the current project for audit. It reads `package.json.heybox.miniProgramId`, validates that the bound mini-program belongs to the server-side current entity before precheck/build/upload, prechecks `package.json.version` before build, runs the project's `build` script via the package manager auto-detected by lockfile, uploads `dist/` to CDN (skipping `manifest.json`, `.DS_Store`, `.map`), then calls the submit-audit API. Deploy and `--from-version` do not fetch or compare the client-side `minimumSdkVersion`; Manifest validation and server-side precheck / submit-audit policy still apply. When `--env <name>` or `HB_SDK_ENV=<name>` selects an environment preset, deploy also passes the same name to the project build as its Vite mode. The deploy upload pipeline rejects actual upload artifacts over 100MiB before any upload request, processes CDN upload metadata and callback confirmation at 50 files per batch, keeps 4-way upload concurrency within each batch, and validates CDN-returned keys exactly against the local expected upload keys.
58
58
  8. Use `hb-sdk remote deploy --from-version <version> --release-note <text>` to reuse a previously uploaded remote version artifact and submit a new audit version without reading local `dist`, building, or uploading.
59
59
  9. Always provide a concise release note before deploy. Non-interactive environments must pass `--release-note`; interactive terminals may prompt for it. The default is manual release after approval with `hb-sdk remote release <version>`; use `--auto-publish` when the audited version should automatically release after approval.
60
60
  10. Use `hb-sdk remote release <version>`, `hb-sdk remote withdraw <version>`, `hb-sdk remote take-down`, and `hb-sdk remote reopen` for dangerous remote changes. Interactive terminals should confirm after showing enough context; non-interactive environments must pass `--yes`.
61
61
  11. For internal test/staging backend operations, use origin-only custom URLs: `HB_SDK_API_BASE_URL` or `hb-sdk remote ... --api-base-url <url>` for remote platform APIs, and `HB_SDK_LOGIN_BASE_URL` or `hb-sdk login --login-base-url <url>` for browser login. CLI flags override env vars. API base URLs must be Heybox trusted HTTPS origins by default; use `--allow-unsafe-api-base-url` or `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` only for local backend debugging. Do not include path, query, or hash in these URLs.
62
- 12. For development routing or gray validation, use `HB_SDK_SERVICE_TAG` to attach `x-rylai-service-tag` and the matching `special_tag` query parameter to CLI backend requests and the Vite minimum-SDK-version gate. Repository-local path-specific routing can still be configured in `packages/hb-sdk/src/cli/config.ts` with `@heybox/hb-types` `RylaiServiceTagConfig` (`default_tag` / path-specific `special_tag`).
62
+ 12. For development routing or gray validation, use `HB_SDK_SERVICE_TAG` to attach `x-rylai-service-tag` and the matching `special_tag` query parameter to CLI backend requests and the Vite minimum-SDK-version gate used by manual builds. Deploy builds skip that client-side version gate. Repository-local path-specific routing can still be configured in `packages/hb-sdk/src/cli/config.ts` with `@heybox/hb-types` `RylaiServiceTagConfig` (`default_tag` / path-specific `special_tag`).
63
63
  13. If a remote command targets a custom login environment, pass the same `--login-base-url` or `HB_SDK_LOGIN_BASE_URL` used for `hb-sdk login`; remote commands reject cached CLI login state from a different login origin.
64
64
  14. Add `--verbose` / `-v` only when diagnosing failures; default CLI errors are intentionally concise, while verbose output includes backend envelope, HTTP status, trace fields, raw body, or original submit-audit failure details.
65
65
  15. Use `--json` for script consumption of `hb-sdk remote` commands. With `--json`, stdout must contain exactly one JSON object; progress, warnings, update reminders, and verbose diagnostics must not pollute stdout.
@@ -19,7 +19,7 @@
19
19
  ## Package metadata
20
20
 
21
21
  - Package: `@heybox/hb-sdk`
22
- - Version at generation time: `0.6.0`
22
+ - Version at generation time: `0.6.2`
23
23
  - Public root export: `@heybox/hb-sdk`
24
24
  - Protocol export: `@heybox/hb-sdk/protocol`
25
25
  - Vite plugin export: `@heybox/hb-sdk/vite`
@@ -200,10 +200,7 @@ Use `@heybox/hb-sdk/vite` only in `vite.config.ts`. Do not import it from iframe
200
200
  import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
201
201
  import path from 'node:path';
202
202
  import { HB_SDK_VERSION } from '../core/version';
203
- import {
204
- renderMiniappManifest,
205
- validateMiniappPackageVersionForBuild,
206
- } from '../miniapp-manifest/schema';
203
+ import { renderMiniappManifest, validateMiniappPackageVersionForBuild } from '../miniapp-manifest/schema';
207
204
  import { readMiniappVersionFromPackageJson } from '../miniapp-manifest/node';
208
205
  import { enforceMiniappHtmlPolicy } from './html-policy';
209
206
  import { enforceViteSdkVersion as defaultEnforceRemoteSdkVersion } from './sdk-version-gate';
@@ -243,12 +240,14 @@ interface MiniappManifestResolvedConfig {
243
240
  server: {
244
241
  host?: string | boolean;
245
242
  port?: number;
246
- hmr?: boolean | {
247
- clientPort?: number;
248
- host?: string;
249
- port?: number;
250
- protocol?: 'ws' | 'wss';
251
- };
243
+ hmr?:
244
+ | boolean
245
+ | {
246
+ clientPort?: number;
247
+ host?: string;
248
+ port?: number;
249
+ protocol?: 'ws' | 'wss';
250
+ };
252
251
  };
253
252
  }
254
253
 
@@ -281,7 +280,7 @@ export function miniappManifest(options: MiniappManifestOptions = {}): MiniappMa
281
280
  hmrWebSocketUrl = resolveHmrWebSocketUrl(resolved);
282
281
  },
283
282
  async buildStart() {
284
- if (command !== 'build') return;
283
+ if (command !== 'build' || process.env.HB_SDK_DEPLOY_BUILD === '1') return;
285
284
  try {
286
285
  await (options.enforceSdkVersion ?? defaultEnforceRemoteSdkVersion)({
287
286
  sdkVersion: resolveSdkVersion(),
@@ -313,11 +312,11 @@ export function miniappManifest(options: MiniappManifestOptions = {}): MiniappMa
313
312
  const sdkVersion = resolveSdkVersion();
314
313
  const outputRoot = path.resolve(root, outDir);
315
314
  const htmlFiles = collectHtmlFiles(outputRoot);
316
- const unexpectedHtmlFiles = htmlFiles.filter(file => path.relative(outputRoot, file) !== 'index.html');
315
+ const unexpectedHtmlFiles = htmlFiles.filter((file) => path.relative(outputRoot, file) !== 'index.html');
317
316
  if (unexpectedHtmlFiles.length > 0) {
318
317
  throw new Error(
319
318
  `工坊小程序只支持单页应用,构建产物不允许额外 HTML:${unexpectedHtmlFiles
320
- .map(file => path.relative(outputRoot, file).split(path.sep).join('/'))
319
+ .map((file) => path.relative(outputRoot, file).split(path.sep).join('/'))
321
320
  .join(', ')}`,
322
321
  );
323
322
  }
@@ -383,7 +382,7 @@ function resolveHmrWebSocketUrl(resolved: MiniappManifestResolvedConfig) {
383
382
  ```json
384
383
  {
385
384
  "version": "1.2.3",
386
- "sdkVersion": "0.6.0"
385
+ "sdkVersion": "0.6.1"
387
386
  }
388
387
  ```
389
388
 
@@ -405,7 +404,7 @@ export default defineConfig({
405
404
 
406
405
  插件只接受单页应用:输出目录只能存在入口 `index.html`。build 会用结构化 HTML parser 校验入口,并把平台 CSP 插入 `<head>` 首位;已有 CSP 会原样保留,两份策略按浏览器交集生效。正式策略禁止 `fetch`、XHR、WebSocket、EventSource、Beacon、Worker、iframe、表单和对象加载等浏览器原生出口;业务网络请求应使用 `network.request()`。dev 使用相同策略,只额外放行当前 Vite 的精确 HMR WebSocket 地址。
407
406
 
408
- meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev`、build deploy 会读取 `/user_miniprogram/public/sdk_config` 的 `minimumSdkVersion`;最新请求失败时只回退当前 Remote Environment 下 24 小时内的有效缓存,无缓存则默认阻断并提示升级 `@heybox/hb-sdk@latest`。
407
+ meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev` 和手动 Vite build 会读取 `/user_miniprogram/public/sdk_config` 的 `minimumSdkVersion`;最新请求失败时只回退当前 Remote Environment 下 24 小时内的有效缓存,无缓存则默认阻断并提示升级 `@heybox/hb-sdk@latest`。`hb-sdk remote deploy`(包括 `--from-version`)不执行客户端最低版本查询或比较,但仍校验 Manifest 结构并经过服务端 precheck / submit-audit 策略。
409
408
 
410
409
  失败与警告语义:
411
410
 
@@ -165,9 +165,11 @@ HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1 hb-sdk remote deploy --api-base-url http://12
165
165
 
166
166
  `manifest.json` 仅作为提交审核接口的 `manifest` 字段提交,不会上传到 CDN。Vite 项目通过 `miniappManifest()` 插件生成;CLI 不会自动注入插件,请在 `vite.config.ts` 中显式挂载。小程序构建产物需要使用相对资源路径;`hb-sdk create` 模板会显式配置 `base: './'`,未配置 `base` 的项目也会由 `miniappManifest()` 在 build 时默认补成 `./`。构建产物只能在兼容的小黑盒 Runtime 中启动,普通浏览器直接打开时不会执行标准业务脚本。
167
167
 
168
+ `remote deploy` 的本地构建和 `--from-version` 路径都不执行客户端 `minimumSdkVersion` 查询或比较;Manifest 结构校验、版本 precheck 和服务端 submit-audit 策略仍然生效。开发者手动执行 Vite build 时仍会运行最低 SDK 版本门禁。
169
+
168
170
  默认发布策略是 `auto_publish=false`:运营审核通过后使用 `hb-sdk remote versions` 查看版本状态,再用 `hb-sdk remote release <version>` 发布。需要审核通过后自动发布并下架旧线上版本时,使用 `--auto-publish`。如需让指定用户预览未发布候选版本,使用 `hb-sdk remote allowlist add <heybox_id>` 管理预览白名单。
169
171
 
170
- 内部测试或预发环境可通过 `HB_SDK_API_BASE_URL` / `HB_SDK_LOGIN_BASE_URL` 设置默认后台环境,也可以用 `--api-base-url` / `--login-base-url` 覆盖单次命令。自定义地址只接受 origin,不允许包含 path、query 或 hash;API origin 默认还必须是 Heybox 受信 HTTPS 域名,只有本地联调等场景可显式使用 `--allow-unsafe-api-base-url` 或 `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` 放开。`apiBaseUrl` 影响 `hb-sdk remote` 里的远端平台后台 API,包括预检、CDN 上传凭证/回调、提交审核、版本、发布、撤回、下架、重新上架、详情和白名单等调用;`loginBaseUrl` 用于 `hb-sdk login` 的登录入口,以及 remote 命令前校验当前 CLI 登录态是否属于同一个登录环境。开发环境如需给后台请求带 `x-rylai-service-tag` 和 `special_tag`,优先用 `--service-tag <tag>` 或 `HB_SDK_SERVICE_TAG`;deploy 子构建会继承 `.env.<name>` 中的 `HB_SDK_SERVICE_TAG`,Vite 最低 SDK 版本门禁请求也会同时携带该 header 和 querypath-prefix 级 `special_tag` 仍可在 `packages/hb-sdk/src/cli/config.ts` 里按 `@heybox/hb-types` 的 `RylaiServiceTagConfig` 配置。日志只输出 origin,不输出带身份和签名参数的完整请求 URL。
172
+ 内部测试或预发环境可通过 `HB_SDK_API_BASE_URL` / `HB_SDK_LOGIN_BASE_URL` 设置默认后台环境,也可以用 `--api-base-url` / `--login-base-url` 覆盖单次命令。自定义地址只接受 origin,不允许包含 path、query 或 hash;API origin 默认还必须是 Heybox 受信 HTTPS 域名,只有本地联调等场景可显式使用 `--allow-unsafe-api-base-url` 或 `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` 放开。`apiBaseUrl` 影响 `hb-sdk remote` 里的远端平台后台 API,包括预检、CDN 上传凭证/回调、提交审核、版本、发布、撤回、下架、重新上架、详情和白名单等调用;`loginBaseUrl` 用于 `hb-sdk login` 的登录入口,以及 remote 命令前校验当前 CLI 登录态是否属于同一个登录环境。开发环境如需给后台请求带 `x-rylai-service-tag` 和 `special_tag`,优先用 `--service-tag <tag>` 或 `HB_SDK_SERVICE_TAG`;手动 Vite build 的最低 SDK 版本门禁请求会同时携带该 header 和 query,deploy 子构建不执行该门禁。path-prefix 级 `special_tag` 仍可在 `packages/hb-sdk/src/cli/config.ts` 里按 `@heybox/hb-types` 的 `RylaiServiceTagConfig` 配置。日志只输出 origin,不输出带身份和签名参数的完整请求 URL。
171
173
 
172
174
  `hb-sdk doctor`、npm latest 检查、mock host 的 `network.request()` 不受这些配置影响。
173
175
 
@@ -254,20 +256,7 @@ hb-sdk remote square show
254
256
 
255
257
  `hb-sdk remote create` 会创建远端工坊小程序并写入当前项目绑定;已有绑定时必须传 `--force-bind` 才能覆盖。`hb-sdk remote bind <mini-program-id>` 会先校验当前 CLI 用户可管理目标小程序,再写入本地配置;`--force` 只允许覆盖本地绑定,不跳过远端校验。
256
258
 
257
- 小程序名称、icon 和介绍图需要随版本提交审核,CLI 不再提供直接更新基础信息的命令。提交审核前在 `package.json.heybox.miniProgramProfile` 配置 `name`、HTTPS `iconUrl` 和至少一张 HTTPS `coverImageUrls`:
258
-
259
- ```json
260
- {
261
- "heybox": {
262
- "miniProgramId": "mp_xxxxxxxx",
263
- "miniProgramProfile": {
264
- "name": "我的小程序",
265
- "iconUrl": "https://img.example.test/icon.png",
266
- "coverImageUrls": ["https://img.example.test/cover.png"]
267
- }
268
- }
269
- }
270
- ```
259
+ 小程序名称、icon 和介绍图在开放平台「版本发布」中维护并随版本审核。CLI 项目配置只保留 `package.json.heybox.miniProgramId`;首次部署且没有历史审核资料时,服务端会使用默认名称「我的小程序」与平台默认图片。
271
260
 
272
261
  `hb-sdk remote square hide` 会隐藏当前绑定小程序在普通用户侧的小程序工坊广场展示;白名单用户仍可在小程序工坊广场看到,直接链接访问已发布版本也不受影响。`hb-sdk remote square show` 会恢复普通用户侧的小程序工坊广场展示。
273
262
 
@@ -279,7 +268,7 @@ Agent rules:
279
268
 
280
269
  - Use `hb-sdk remote entity list/current/switch` for developer entity inspection and switching.
281
270
  - Use `hb-sdk remote create` for create-and-bind and `hb-sdk remote bind <mini-program-id>` for binding an existing manageable remote mini-program.
282
- - Keep mini-program name, icon, and cover images in `package.json.heybox.miniProgramProfile`; these fields are submitted with version audit.
271
+ - Do not require or submit mini-program name/icon/cover from CLI; maintain them on Open version publish. CLI project configuration contains only `package.json.heybox.miniProgramId`.
283
272
  - 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.
284
273
  - 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.
285
274
  - Use `hb-sdk remote info`, `hb-sdk remote access`, `hb-sdk remote list`, `hb-sdk remote versions`, `hb-sdk remote preview <version>`, `hb-sdk remote square show/hide`, and `hb-sdk remote allowlist ...` instead of sending users to Open when a matching CLI command exists.
@@ -396,7 +385,7 @@ npm run deploy
396
385
 
397
386
  - `npm run dev`:启动本地 Vite 服务和 `hb-sdk` 内置 mock runtime host,适合本地调试 SDK 能力;调试页内可点击按钮在 Mac 版 APP 中启动同一页面,也可以选择局域网网卡后用手机小黑盒 APP 扫码调试。手机需要与电脑处在同一局域网,并使用支持小程序调试壳的新版小黑盒 APP。Codex、VSCode 等内嵌浏览器可能无法唤起系统 APP,需要时请在系统浏览器中打开同一个调试页后重试。
398
387
  - `npm run build`:先执行 TypeScript 检查,再构建生产产物。
399
- - `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` 在 current entity 下创建并绑定,或用 `npx hb-sdk remote bind <mini-program-id>` 绑定 current entity 可管理的已有小程序。小程序名称、icon 和介绍图在 `package.json.heybox.miniProgramProfile` 中配置并随版本审核提交。`selectedEntity` 只是 CLI 登录缓存中的提示快照,实际 deploy/create/bind 以服务端 current entity 为准。默认审核通过后用 `hb-sdk remote versions` 查看状态,再用 `hb-sdk remote release <version>` 发布,如需审核通过后自动发布可追加 `--auto-publish`。顶层 `hb-sdk deploy` 已删除,不再作为兼容别名保留。
388
+ - `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` 在 current entity 下创建并绑定,或用 `npx hb-sdk remote bind <mini-program-id>` 绑定 current entity 可管理的已有小程序。小程序名称、icon 和介绍图在开放平台版本发布中维护;CLI 项目配置只保留 `heybox.miniProgramId`,首次部署服务端会使用默认名与默认图。`selectedEntity` 只是 CLI 登录缓存中的提示快照,实际 deploy/create/bind 以服务端 current entity 为准。默认审核通过后用 `hb-sdk remote versions` 查看状态,再用 `hb-sdk remote release <version>` 发布,如需审核通过后自动发布可追加 `--auto-publish`。顶层 `hb-sdk deploy` 已删除,不再作为兼容别名保留。
400
389
 
401
390
  ## 更多能力
402
391
 
@@ -429,7 +429,7 @@ Agent rules:
429
429
 
430
430
  - Use \`hb-sdk remote entity list/current/switch\` for developer entity inspection and switching.
431
431
  - Use \`hb-sdk remote create\` for create-and-bind and \`hb-sdk remote bind <mini-program-id>\` for binding an existing manageable remote mini-program.
432
- - Keep mini-program name, icon, and cover images in \`package.json.heybox.miniProgramProfile\`; these fields are submitted with version audit.
432
+ - Do not require or submit mini-program name/icon/cover from CLI; maintain them on Open version publish. CLI project configuration contains only \`package.json.heybox.miniProgramId\`.
433
433
  - 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.
434
434
  - 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.
435
435
  - Use \`hb-sdk remote info\`, \`hb-sdk remote access\`, \`hb-sdk remote list\`, \`hb-sdk remote versions\`, \`hb-sdk remote preview <version>\`, \`hb-sdk remote square show/hide\`, and \`hb-sdk remote allowlist ...\` instead of sending users to Open when a matching CLI command exists.
package/skill/skill.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.6.0+skill.451f74e19672",
3
+ "skillVersion": "0.6.2+skill.f2a041bb2256",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.6.0",
7
- "compatibility": "0.6.0"
6
+ "version": "0.6.2",
7
+ "compatibility": "0.6.2"
8
8
  },
9
9
  "source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
10
- "integrity": "sha256-451f74e19672cca0953ebb9d47d6f2632c9341ba2c4f9bcf4a861d5344285673"
10
+ "integrity": "sha256-f2a041bb22563610e0fcaa991e2e5a2a94c331a029aafe4535083ecf89a4a6b0"
11
11
  }