@heybox/hb-sdk 0.8.0-alpha.2 → 0.8.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -430
- package/README.md +26 -2
- package/dist/cli-chunks/{build-CCLWgXyA.cjs → build-DkokKVNy.cjs} +2 -2
- package/dist/cli-chunks/{context-Brh56h56.cjs → context-CKzZxKbF.cjs} +1 -1
- package/dist/cli-chunks/{create-BZ-hi2s1.cjs → create-BQy5Jdmu.cjs} +2 -2
- package/dist/cli-chunks/{dev-CoSXtEYa.cjs → dev-Dik2zr5R.cjs} +60 -63
- package/dist/cli-chunks/doctor-Byr4uwKG.cjs +65 -0
- package/dist/cli-chunks/{index-BL5eEPap.cjs → index-BwGBr1ZA.cjs} +50 -30
- package/dist/cli-chunks/{index-CS6Q0o5C.cjs → index-Cl0XaX8e.cjs} +1 -1
- package/dist/cli-chunks/{index.esm-BoBHPfpq.cjs → index.esm-BYifBABc.cjs} +6 -5
- package/dist/cli-chunks/{login-CILLxGuf.cjs → login-Dr9lclu3.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-Qu6Xe9Dn.cjs → project-vite-BIPrOtRO.cjs} +1 -1
- package/dist/cli-chunks/{remote-DRuTQ51u.cjs → remote-DXxyA14a.cjs} +4 -4
- package/dist/cli-chunks/{session-D-_N3WVL.cjs → session-B6Mo9eYW.cjs} +1 -1
- package/dist/cli-chunks/skill-f90sxv28.cjs +83 -0
- package/dist/cli-chunks/version-DDB_btOG.cjs +8 -0
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/{browser-dev-host-uq-Wac6k.js → browser-dev-host-CbhA4h8z.js} +15 -15
- package/dist/devtools/browser-dev-host/assets/{index-KD2f3Jdz.css → index-DJFB5ySU.css} +1 -1
- package/dist/devtools/browser-dev-host/assets/{index-CeP6SLB3.js → index-DaqmTjSF.js} +4 -4
- package/dist/devtools/browser-dev-host/assets/workbench-state-wHgWRb7I.js +5 -0
- package/dist/devtools/browser-dev-host/index.html +3 -3
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/templates/{vue3-vite-ts → vanilla-vite-js}/.gitignore.ejs +0 -1
- package/dist/templates/vanilla-vite-js/README.md.ejs +14 -0
- package/dist/templates/vanilla-vite-js/index.html.ejs +20 -0
- package/dist/templates/vanilla-vite-js/package.json.ejs +21 -0
- package/dist/templates/vanilla-vite-js/src/assets/heybox-logo.svg +8 -0
- package/dist/templates/vanilla-vite-js/src/main.js +39 -0
- package/dist/templates/vanilla-vite-js/src/styles.css +155 -0
- package/dist/templates/{vue3-vite-ts/vite.config.ts → vanilla-vite-js/vite.config.js} +1 -2
- package/dist/vite.cjs.js +1 -1
- package/dist/vite.esm.js +1 -1
- package/package.json +19 -10
- package/skill/SKILL.md +8 -9
- package/skill/references/api-protocol.md +2 -4
- package/skill/references/api-root.md +4 -2
- package/skill/references/cli.md +20 -7
- package/skill/references/examples.md +1 -1
- package/skill/references/llms-index.md +1 -1
- package/skill/references/recipes.md +6 -4
- package/skill/references/safety-boundaries.md +1 -1
- package/skill/skill.json +10 -5
- package/types/modules/share/index.d.ts +1 -1
- package/types/modules/share/show-share-menu.d.ts +1 -1
- package/types/modules/share/types.d.ts +2 -4
- package/types/skill-metadata.d.ts +0 -4
- package/dist/cli-chunks/doctor-EsCYJGhV.cjs +0 -204
- package/dist/devtools/browser-dev-host/assets/workbench-state-D-1U0JRq.js +0 -5
- package/dist/templates/vue3-vite-ts/README.md.ejs +0 -47
- package/dist/templates/vue3-vite-ts/index.html.ejs +0 -12
- package/dist/templates/vue3-vite-ts/package.json.ejs +0 -33
- package/dist/templates/vue3-vite-ts/src/App.vue +0 -78
- package/dist/templates/vue3-vite-ts/src/__tests__/App.spec.ts +0 -148
- package/dist/templates/vue3-vite-ts/src/auth-handoff.ts +0 -46
- package/dist/templates/vue3-vite-ts/src/main.ts +0 -5
- package/dist/templates/vue3-vite-ts/src/styles.css +0 -60
- package/dist/templates/vue3-vite-ts/src/vite-env.d.ts +0 -1
- package/dist/templates/vue3-vite-ts/tsconfig.app.json +0 -17
- package/dist/templates/vue3-vite-ts/tsconfig.json +0 -11
- package/dist/templates/vue3-vite-ts/tsconfig.node.json +0 -11
- package/dist/templates/vue3-vite-ts/vitest.config.ts +0 -10
- package/skill/scripts/check-references.mjs +0 -14
- package/skill/scripts/markdown-sections.mjs +0 -36
- package/skill/scripts/package-skill.mjs +0 -60
- package/skill/scripts/package-skill.sh +0 -6
- package/skill/scripts/skill-metadata.mjs +0 -77
- package/skill/scripts/sync-agent-skills-payload.mjs +0 -359
- package/skill/scripts/sync-references.mjs +0 -826
- package/skill/scripts/validate-skill.mjs +0 -263
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
小黑盒 APP 小程序工坊的前端 SDK 与开发 CLI,用于创建、调试、构建和发布工坊小程序,并在业务页面中调用小黑盒开放能力。
|
|
4
4
|
|
|
5
|
+
运行环境要求 Node.js `>=22.20.0`。`@heybox/hb-sdk` npm 包同时包含与当前 SDK 版本严格对应的 Agent Skill;Skill 不再依赖 Open 远端分发。
|
|
6
|
+
|
|
5
7
|
SDK 只提供面向小程序开发者的稳定接口,不提供客户端内部协议、登录凭据或私有实现入口。本地浏览器调试请使用 `hb-sdk dev` 提供的 Mock 环境,发布前仍需在小黑盒 APP 中完成真机验收。
|
|
6
8
|
|
|
7
9
|
宿主集成边界:`@heybox/hb-sdk-runtime` 运行在 iframe 外并负责 bridge/Host Port;跨 iframe 的 wire contract 唯一维护在零依赖 `@heybox/hb-sdk-protocol`。业务页面不需要创建 Runtime、实现 Host Port 或导入协议包;客户端 SDK 只依赖已兼容 re-export 的 `@heybox/hb-sdk/protocol`。
|
|
@@ -11,7 +13,7 @@ SDK 只提供面向小程序开发者的稳定接口,不提供客户端内部
|
|
|
11
13
|
### 创建新项目
|
|
12
14
|
|
|
13
15
|
```bash
|
|
14
|
-
npx @heybox/hb-sdk@
|
|
16
|
+
npx @heybox/hb-sdk@alpha create my-miniapp
|
|
15
17
|
cd my-miniapp
|
|
16
18
|
npm install
|
|
17
19
|
npm run dev
|
|
@@ -19,12 +21,32 @@ npm run dev
|
|
|
19
21
|
|
|
20
22
|
脚手架已包含 SDK、Vite 配置和常用开发命令。浏览器调试通过后,再从调试台的二维码入口使用手机小黑盒 APP 验收。
|
|
21
23
|
|
|
24
|
+
当前 `0.8` 模板位于 alpha 发布线;稳定版本发布后,创建命令会恢复使用 `@latest`。
|
|
25
|
+
|
|
22
26
|
### 接入已有项目
|
|
23
27
|
|
|
24
28
|
```bash
|
|
25
29
|
npm install @heybox/hb-sdk
|
|
26
30
|
```
|
|
27
31
|
|
|
32
|
+
### 安装 Agent Skill
|
|
33
|
+
|
|
34
|
+
在项目目录安装到项目 Agent 目录:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
hb-sdk skill install
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
安装到当前用户目录,或指定 Agent:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
hb-sdk skill install --global
|
|
44
|
+
hb-sdk skill install --agent codex cursor
|
|
45
|
+
hb-sdk skill install --all-agents
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
使用 `hb-sdk doctor` 或 `hb-sdk doctor --json` 检查各 Agent 的 Skill 是否与当前 npm 包匹配;已有内容被修改时,使用 `--force` 才会覆盖。
|
|
49
|
+
|
|
28
50
|
SDK 会在导入时启动握手,能力调用会自动等待 SDK 就绪。未开通网络权限的小程序通过 `user.getInfo()` 静默读取当前小程序内的隔离身份和公开资料:
|
|
29
51
|
|
|
30
52
|
需要可信用户手势的按钮不能在点击回调里等待握手。页面加载时先用 `getHandshakeState()` 读取当前状态,再用 `onHandshakeStateChange()` 订阅并立即接收当前状态;仅在 `status === 'ready'` 时启用按钮,并在组件或页面销毁时调用订阅返回的取消函数。`ready` 生命周期事件只是握手成功瞬间派发、不会重放的边沿通知,不能用来判断当前状态。
|
|
@@ -192,7 +214,7 @@ SDK 还提供 `getHandshakeState()` / `onHandshakeStateChange()` 管理持久握
|
|
|
192
214
|
|
|
193
215
|
## 分享扩展数据
|
|
194
216
|
|
|
195
|
-
|
|
217
|
+
`share.showShareMenu()` 的落地页固定为当前小程序的 `common_share`,不接受自定义 `url`。分享和复制链接可以携带小程序自行定义的页面状态:
|
|
196
218
|
|
|
197
219
|
```ts
|
|
198
220
|
await hbSDK.share.showShareMenu({
|
|
@@ -250,6 +272,8 @@ hb-sdk remote deploy --release-note "本次更新说明"
|
|
|
250
272
|
| `hb-sdk build` | 执行生产构建与产物校验,不包含类型检查 |
|
|
251
273
|
| `hb-sdk remote deploy` | 构建、上传并提交当前版本审核 |
|
|
252
274
|
|
|
275
|
+
`hb-sdk create` 默认生成可直接删除的 Vanilla JavaScript + Vite HelloWorld,只保留 SDK Toast 示例、三端 Manifest 和开发/构建/部署命令,不绑定业务框架或项目内测试工具。
|
|
276
|
+
|
|
253
277
|
`hb-sdk dev` 会启动 Vue 3 Browser Dev Host。左侧诊断面板集中展示调用日志、当前小程序作用域内的 Storage 快照和问题,右侧设备预览可在 iPhone 16 Pro Max(`440 x 956`)与 Pixel 9 Pro(`410 x 914`)间切换。切换预设只改变设备外框和 viewport,不会重新加载 iframe 或重启 Runtime;授权与操作弹窗、Toast、Loading 和振动反馈都限制在预览框内。
|
|
254
278
|
|
|
255
279
|
浏览器调试入口不要求 CLI 登录或项目绑定;需要账号或远端配置的能力会按当前可用上下文返回结果或明确失败。调试台不提供权限修改入口,远端权限快照始终是 Runtime 的规范输入。手机验收统一从右上角二维码入口进入,选择手机可达的局域网网卡后扫码;二维码使用 `open_inapp` 与 `heybox://` `openWindow` 包装的短链。完整操作见 [CLI 指南](https://docs.xiaoheihe.cn/hb_sdk/guide/cli),实现与安全边界由 [Runtime Host 迁移](./docs/runtime-host-migration.md) 维护。
|
|
@@ -5,8 +5,8 @@ var fs = require('node:fs/promises');
|
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
var runtimePermissionEnv = require('./runtime-permission-env-CjsCe5bp.cjs');
|
|
7
7
|
var runtimeGate = require('./runtime-gate-DFjw66kF.cjs');
|
|
8
|
-
var index = require('./index-
|
|
9
|
-
var projectVite = require('./project-vite-
|
|
8
|
+
var index = require('./index-BwGBr1ZA.cjs');
|
|
9
|
+
var projectVite = require('./project-vite-BIPrOtRO.cjs');
|
|
10
10
|
require('node:async_hooks');
|
|
11
11
|
require('node:module');
|
|
12
12
|
require('path');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var session = require('./session-
|
|
3
|
+
var session = require('./session-B6Mo9eYW.cjs');
|
|
4
4
|
var runtimePermissionEnv = require('./runtime-permission-env-CjsCe5bp.cjs');
|
|
5
5
|
var fs$1 = require('node:fs');
|
|
6
6
|
var fs = require('node:fs/promises');
|
|
@@ -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-
|
|
8
|
+
var index = require('./index-BwGBr1ZA.cjs');
|
|
9
9
|
require('node:module');
|
|
10
10
|
require('os');
|
|
11
11
|
require('readline');
|
|
@@ -1238,7 +1238,7 @@ function requireEjs () {
|
|
|
1238
1238
|
|
|
1239
1239
|
var ejsExports = requireEjs();
|
|
1240
1240
|
|
|
1241
|
-
const TEMPLATE_NAME = '
|
|
1241
|
+
const TEMPLATE_NAME = 'vanilla-vite-js';
|
|
1242
1242
|
const TEMPLATE_ROOT_CANDIDATES = [
|
|
1243
1243
|
path.resolve(__dirname, 'templates', TEMPLATE_NAME),
|
|
1244
1244
|
path.resolve(__dirname, '..', 'templates', TEMPLATE_NAME),
|
|
@@ -8,15 +8,16 @@ var node_crypto = require('node:crypto');
|
|
|
8
8
|
var promises = require('node:dns/promises');
|
|
9
9
|
var node_http = require('node:http');
|
|
10
10
|
var node_module = require('node:module');
|
|
11
|
-
var context = require('./context-
|
|
11
|
+
var context = require('./context-CKzZxKbF.cjs');
|
|
12
12
|
var undici = require('undici');
|
|
13
13
|
var fs$1 = require('node:fs/promises');
|
|
14
|
-
var index = require('./index-
|
|
14
|
+
var index = require('./index-BwGBr1ZA.cjs');
|
|
15
15
|
var require$$0$1 = require('crypto');
|
|
16
16
|
var require$$0 = require('buffer');
|
|
17
|
-
var session = require('./session-
|
|
17
|
+
var session = require('./session-B6Mo9eYW.cjs');
|
|
18
18
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
19
|
-
var projectVite = require('./project-vite-
|
|
19
|
+
var projectVite = require('./project-vite-BIPrOtRO.cjs');
|
|
20
|
+
var version = require('./version-DDB_btOG.cjs');
|
|
20
21
|
var runtimePermissionEnv = require('./runtime-permission-env-CjsCe5bp.cjs');
|
|
21
22
|
|
|
22
23
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -1604,7 +1605,7 @@ async function selectAvailablePort(options) {
|
|
|
1604
1605
|
port: createPortCandidates(options.startPort, maxAttempts),
|
|
1605
1606
|
});
|
|
1606
1607
|
if (port < options.startPort || port >= options.startPort + maxAttempts) {
|
|
1607
|
-
throw new Error(
|
|
1608
|
+
throw new Error(`无法找到可用端口(${options.label}),起始端口:${options.startPort}`);
|
|
1608
1609
|
}
|
|
1609
1610
|
return port;
|
|
1610
1611
|
}
|
|
@@ -1850,8 +1851,8 @@ const DEFAULT_CHANNEL_TRANSPORT = {
|
|
|
1850
1851
|
};
|
|
1851
1852
|
const IPV4_LOOPBACK_ADDRESSES = new net.BlockList();
|
|
1852
1853
|
IPV4_LOOPBACK_ADDRESSES.addSubnet('127.0.0.0', 8, 'ipv4');
|
|
1853
|
-
const { WebSocket, WebSocketServer } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-
|
|
1854
|
-
const { parse: parseHtml } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-
|
|
1854
|
+
const { WebSocket, WebSocketServer } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-Dik2zr5R.cjs', document.baseURI).href)))('ws');
|
|
1855
|
+
const { parse: parseHtml } = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/dev-Dik2zr5R.cjs', document.baseURI).href)))('parse5');
|
|
1855
1856
|
const BROWSER_DEV_HOST_ROOT_CANDIDATES = [
|
|
1856
1857
|
path.resolve(__dirname, 'devtools/browser-dev-host'),
|
|
1857
1858
|
path.resolve(__dirname, '../devtools/browser-dev-host'),
|
|
@@ -2967,7 +2968,7 @@ async function listenHttpServer(server, options, getPortImpl, listen) {
|
|
|
2967
2968
|
const port = await selectAvailablePort({
|
|
2968
2969
|
getPort: getPortImpl,
|
|
2969
2970
|
host: DEV_PORT_PROBE_HOST,
|
|
2970
|
-
label: '
|
|
2971
|
+
label: '浏览器调试页服务',
|
|
2971
2972
|
maxAttempts: lastCandidate - nextCandidate + 1,
|
|
2972
2973
|
startPort: nextCandidate,
|
|
2973
2974
|
});
|
|
@@ -2986,7 +2987,7 @@ async function listenHttpServer(server, options, getPortImpl, listen) {
|
|
|
2986
2987
|
nextCandidate = port + 1;
|
|
2987
2988
|
}
|
|
2988
2989
|
}
|
|
2989
|
-
throw lastAddressInUseError ?? new Error(
|
|
2990
|
+
throw lastAddressInUseError ?? new Error(`无法找到可用浏览器调试页服务端口,起始端口:${options.port}`);
|
|
2990
2991
|
}
|
|
2991
2992
|
const listenBrowserDevHostServer = (server, options) => new Promise((resolve, reject) => {
|
|
2992
2993
|
const onError = (error) => {
|
|
@@ -10894,7 +10895,7 @@ function assertNodeRuntimeCapabilities(ctx, settings) {
|
|
|
10894
10895
|
function createNodeRealtimeDriverRegistry() {
|
|
10895
10896
|
const registry = createRuntimeRealtimeDriverRegistry();
|
|
10896
10897
|
registry.registerLazy('node-websocket', async () => {
|
|
10897
|
-
const mod = await Promise.resolve().then(function () { return require('./index.esm-
|
|
10898
|
+
const mod = await Promise.resolve().then(function () { return require('./index.esm-BYifBABc.cjs'); });
|
|
10898
10899
|
return mod.createNodeWebSocketRuntimeDriver();
|
|
10899
10900
|
});
|
|
10900
10901
|
return registry;
|
|
@@ -14954,17 +14955,12 @@ function writeLaunchResponse(response, status, body) {
|
|
|
14954
14955
|
response.end(body ?? '');
|
|
14955
14956
|
}
|
|
14956
14957
|
|
|
14957
|
-
/** 构建时替换为当前发布包的实际版本。 */
|
|
14958
|
-
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
14959
|
-
? undefined
|
|
14960
|
-
: '0.8.0-alpha.2';
|
|
14961
|
-
|
|
14962
14958
|
const DEFAULT_APP_PORT = 5173;
|
|
14963
14959
|
const DEFAULT_BROWSER_DEV_HOST_PORT = 5174;
|
|
14964
14960
|
const DEFAULT_DEV_CONTEXT_TIMEOUT_MS = 3000;
|
|
14965
14961
|
const DEV_LISTEN_HOST = '0.0.0.0';
|
|
14966
14962
|
const LOCAL_DEV_URL_HOST = '127.0.0.1';
|
|
14967
|
-
//
|
|
14963
|
+
// 与 Heybox H5 Vite 插件共享,让 hb-sdk 统一管理启动输出。
|
|
14968
14964
|
const MANAGED_DEV_OUTPUT_ENV = 'HEYBOX_DEV_SERVER_MANAGED_OUTPUT';
|
|
14969
14965
|
const VITE_LOG_LEVEL = 'warn';
|
|
14970
14966
|
async function runDevCommand(options, runtime = {}) {
|
|
@@ -14979,7 +14975,7 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
14979
14975
|
const appPort = await selectAvailablePort({
|
|
14980
14976
|
getPort: getPortImpl,
|
|
14981
14977
|
host: DEV_LISTEN_HOST,
|
|
14982
|
-
label: 'Vite
|
|
14978
|
+
label: 'Vite 开发服务器',
|
|
14983
14979
|
startPort: options.port ?? DEFAULT_APP_PORT,
|
|
14984
14980
|
});
|
|
14985
14981
|
const resolvedOptions = {
|
|
@@ -14996,8 +14992,8 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
14996
14992
|
timeoutMs: runtime.devContextTimeoutMs ?? DEFAULT_DEV_CONTEXT_TIMEOUT_MS,
|
|
14997
14993
|
});
|
|
14998
14994
|
const launchRuntimePermissions = context.createBrowserDevRuntimePermissions(context.createBrowserDevPermissionState(devLaunchContext));
|
|
14999
|
-
const vite = await logger
|
|
15000
|
-
const appServer = await logger
|
|
14995
|
+
const vite = await runDevStartupTask(logger, '正在加载项目 Vite', () => projectVite.loadProjectVite(projectRoot), '已加载项目 Vite');
|
|
14996
|
+
const appServer = await runDevStartupTask(logger, '正在创建 Vite 开发服务器', () => runtimePermissionEnv.withMiniappPlatformCspEnv(context.shouldSkipMiniappPlatformCsp(devLaunchContext.runtimePermissions), () => withManagedDevOutputEnv(() => vite.createServer(createViteServerOptions(projectRoot, resolvedOptions)), runtime.env), runtime.env), '已创建 Vite 开发服务器');
|
|
15001
14997
|
const mobileDevContextUrlsByOrigin = new Map();
|
|
15002
14998
|
let currentLocalDevLaunchToken = devLaunchContext.localDevLaunchToken;
|
|
15003
14999
|
appServer.middlewares.use((request, response, next) => {
|
|
@@ -15006,17 +15002,13 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15006
15002
|
localDevLaunchToken: currentLocalDevLaunchToken,
|
|
15007
15003
|
miniProgramId: devLaunchContext.miniProgramId,
|
|
15008
15004
|
runtimePermissions: launchRuntimePermissions,
|
|
15009
|
-
sdkVersion: HB_SDK_VERSION,
|
|
15005
|
+
sdkVersion: version.HB_SDK_VERSION,
|
|
15010
15006
|
}));
|
|
15011
15007
|
if (!handled)
|
|
15012
15008
|
next();
|
|
15013
15009
|
});
|
|
15014
|
-
await logger
|
|
15015
|
-
|
|
15016
|
-
});
|
|
15017
|
-
const appUrl = await logger.task('正在探测小程序入口', () => resolveViteAppUrl(appServer, resolvedOptions, fetchImpl), {
|
|
15018
|
-
successText: '已确定小程序入口',
|
|
15019
|
-
});
|
|
15010
|
+
await runDevStartupTask(logger, '正在启动 Vite 开发服务器', () => appServer.listen(appPort), 'Vite 开发服务器已启动');
|
|
15011
|
+
const appUrl = await runDevStartupTask(logger, '正在探测小程序入口', () => resolveViteAppUrl(appServer, resolvedOptions, fetchImpl), '已确定小程序入口');
|
|
15020
15012
|
const buildLanAddresses = () => createLanAddressCandidates({
|
|
15021
15013
|
appUrl,
|
|
15022
15014
|
devContextUrlsByMiniUrlOrigin: mobileDevContextUrlsByOrigin,
|
|
@@ -15024,14 +15016,14 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15024
15016
|
interfaces: networkInterfaceSnapshot,
|
|
15025
15017
|
localDevLaunchToken: currentLocalDevLaunchToken,
|
|
15026
15018
|
miniProgramId: devLaunchContext.miniProgramId,
|
|
15027
|
-
sdkVersion: HB_SDK_VERSION,
|
|
15019
|
+
sdkVersion: version.HB_SDK_VERSION,
|
|
15028
15020
|
viteNetworkUrls: appServer.resolvedUrls?.network ?? [],
|
|
15029
15021
|
});
|
|
15030
15022
|
const lanAddresses = buildLanAddresses();
|
|
15031
15023
|
const closers = [() => appServer.close()];
|
|
15032
15024
|
let browserDevHost;
|
|
15033
15025
|
try {
|
|
15034
|
-
browserDevHost = await logger
|
|
15026
|
+
browserDevHost = await runDevStartupTask(logger, '正在启动浏览器调试页服务', () => startBrowserDevHostServer({
|
|
15035
15027
|
appUrl,
|
|
15036
15028
|
devContext: devLaunchContext,
|
|
15037
15029
|
fetchImpl,
|
|
@@ -15052,7 +15044,7 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15052
15044
|
root: runtime.browserDevHostRoot,
|
|
15053
15045
|
rootCandidates: runtime.browserDevHostRootCandidates,
|
|
15054
15046
|
runtimePermissions: devLaunchContext.runtimePermissions,
|
|
15055
|
-
}),
|
|
15047
|
+
}), '浏览器调试页服务已启动');
|
|
15056
15048
|
}
|
|
15057
15049
|
catch (error) {
|
|
15058
15050
|
await closeAll(closers);
|
|
@@ -15083,23 +15075,29 @@ async function runDevCommand(options, runtime = {}) {
|
|
|
15083
15075
|
});
|
|
15084
15076
|
closers.push(tokenSession.close);
|
|
15085
15077
|
}
|
|
15086
|
-
logger.success('
|
|
15087
|
-
logger.info(
|
|
15088
|
-
logger.info(
|
|
15089
|
-
logger.info('
|
|
15078
|
+
logger.success('本地调试已启动');
|
|
15079
|
+
logger.info(`调试页:${browserDevHost.url}`);
|
|
15080
|
+
logger.info(`小程序地址:${appUrl}`);
|
|
15081
|
+
logger.info('手机调试:请在调试页扫码');
|
|
15090
15082
|
if (options.open !== false) {
|
|
15091
15083
|
logger.debug('正在打开浏览器调试页');
|
|
15092
15084
|
void openUrl(browserDevHost.url);
|
|
15093
15085
|
}
|
|
15094
15086
|
installShutdownHandlers(closers, runtime.process ?? process);
|
|
15095
15087
|
}
|
|
15088
|
+
function runDevStartupTask(logger, text, action, successText) {
|
|
15089
|
+
if (!logger.verbose) {
|
|
15090
|
+
return action();
|
|
15091
|
+
}
|
|
15092
|
+
return logger.task(text, () => action(), { successText });
|
|
15093
|
+
}
|
|
15096
15094
|
async function loadDevLaunchContext(options) {
|
|
15097
15095
|
const miniProgramId = await context.readBoundMiniProgramId(options.projectRoot);
|
|
15098
15096
|
if (!miniProgramId) {
|
|
15099
15097
|
throw new Error('hb-sdk dev 需要绑定小程序。请先运行 hb-sdk remote create 或 hb-sdk remote bind <mini-program-id>。');
|
|
15100
15098
|
}
|
|
15101
15099
|
try {
|
|
15102
|
-
const { detail, miniProgramId: verifiedMiniProgramId } = await options.logger
|
|
15100
|
+
const { detail, miniProgramId: verifiedMiniProgramId } = await runDevStartupTask(options.logger, '正在读取远端小程序权限', () => loadRemoteDevContextWithTimeout({
|
|
15103
15101
|
fetchImpl: options.fetchImpl,
|
|
15104
15102
|
load: (fetchImpl) => context.getBoundMiniProgram({
|
|
15105
15103
|
cwd: options.projectRoot,
|
|
@@ -15107,7 +15105,7 @@ async function loadDevLaunchContext(options) {
|
|
|
15107
15105
|
fetchImpl,
|
|
15108
15106
|
}),
|
|
15109
15107
|
timeoutMs: options.timeoutMs,
|
|
15110
|
-
}),
|
|
15108
|
+
}), '已读取远端小程序权限');
|
|
15111
15109
|
return {
|
|
15112
15110
|
context: {
|
|
15113
15111
|
source: 'remote',
|
|
@@ -15307,25 +15305,30 @@ async function closeAll(closers) {
|
|
|
15307
15305
|
function startLocalDevLaunchTokenSession(options) {
|
|
15308
15306
|
let closed = false;
|
|
15309
15307
|
let expirationTimer;
|
|
15308
|
+
let hasReportedTokenFailure = false;
|
|
15310
15309
|
let refreshTimer;
|
|
15311
15310
|
const refresh = async () => {
|
|
15312
15311
|
try {
|
|
15313
15312
|
const issued = await issueLocalDevLaunchToken(options);
|
|
15314
15313
|
if (closed)
|
|
15315
15314
|
return;
|
|
15316
|
-
if (!issued) {
|
|
15317
|
-
schedule(options.timeoutMs);
|
|
15318
|
-
return;
|
|
15319
|
-
}
|
|
15320
15315
|
options.onToken(issued.token);
|
|
15321
15316
|
const ttl = Math.max(0, issued.expiresAt - Date.now());
|
|
15322
15317
|
scheduleExpiration(ttl);
|
|
15323
15318
|
schedule(Math.max(1_000, Math.floor(ttl * 0.8)));
|
|
15319
|
+
if (hasReportedTokenFailure) {
|
|
15320
|
+
hasReportedTokenFailure = false;
|
|
15321
|
+
options.logger.success('手机扫码调试已恢复');
|
|
15322
|
+
}
|
|
15324
15323
|
}
|
|
15325
15324
|
catch (error) {
|
|
15326
15325
|
if (closed)
|
|
15327
15326
|
return;
|
|
15328
|
-
|
|
15327
|
+
if (!hasReportedTokenFailure) {
|
|
15328
|
+
options.logger.warn('手机扫码调试凭证获取失败,将自动重试');
|
|
15329
|
+
}
|
|
15330
|
+
hasReportedTokenFailure = true;
|
|
15331
|
+
options.logger.debug(`手机扫码调试凭证获取失败,详细原因:${index.readRedactedErrorMessage(error, { verbose: true })}`);
|
|
15329
15332
|
schedule(options.timeoutMs);
|
|
15330
15333
|
}
|
|
15331
15334
|
};
|
|
@@ -15356,31 +15359,25 @@ function startLocalDevLaunchTokenSession(options) {
|
|
|
15356
15359
|
};
|
|
15357
15360
|
}
|
|
15358
15361
|
async function issueLocalDevLaunchToken(options) {
|
|
15359
|
-
|
|
15360
|
-
|
|
15361
|
-
|
|
15362
|
-
|
|
15363
|
-
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15372
|
-
throw new Error('响应缺少 token');
|
|
15373
|
-
}
|
|
15374
|
-
const expiresAt = normalizeExpiresAt(issued.expires_at);
|
|
15375
|
-
if (!expiresAt || expiresAt <= Date.now()) {
|
|
15376
|
-
throw new Error('响应缺少有效 expires_at');
|
|
15377
|
-
}
|
|
15378
|
-
return { expiresAt, token };
|
|
15362
|
+
const issued = await loadRemoteDevContextWithTimeout({
|
|
15363
|
+
fetchImpl: options.fetchImpl,
|
|
15364
|
+
timeoutMs: options.timeoutMs,
|
|
15365
|
+
load: (fetchImpl) => context.createLocalDevLaunchToken({
|
|
15366
|
+
cwd: options.projectRoot,
|
|
15367
|
+
env: options.env,
|
|
15368
|
+
fetchImpl,
|
|
15369
|
+
miniProgramId: options.miniProgramId,
|
|
15370
|
+
}),
|
|
15371
|
+
});
|
|
15372
|
+
const token = typeof issued.token === 'string' ? issued.token.trim() : '';
|
|
15373
|
+
if (!token) {
|
|
15374
|
+
throw new Error('响应缺少 token');
|
|
15379
15375
|
}
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
|
|
15376
|
+
const expiresAt = normalizeExpiresAt(issued.expires_at);
|
|
15377
|
+
if (!expiresAt || expiresAt <= Date.now()) {
|
|
15378
|
+
throw new Error('响应缺少有效 expires_at');
|
|
15383
15379
|
}
|
|
15380
|
+
return { expiresAt, token };
|
|
15384
15381
|
}
|
|
15385
15382
|
function normalizeExpiresAt(value) {
|
|
15386
15383
|
if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('node:fs/promises');
|
|
4
|
+
var os = require('node:os');
|
|
5
|
+
var path = require('node:path');
|
|
6
|
+
var index = require('./index-BwGBr1ZA.cjs');
|
|
7
|
+
require('node:module');
|
|
8
|
+
require('node:fs');
|
|
9
|
+
require('path');
|
|
10
|
+
require('os');
|
|
11
|
+
require('readline');
|
|
12
|
+
require('tty');
|
|
13
|
+
require('assert');
|
|
14
|
+
require('events');
|
|
15
|
+
require('stream');
|
|
16
|
+
require('buffer');
|
|
17
|
+
require('util');
|
|
18
|
+
|
|
19
|
+
const CANDIDATES = [path.resolve(__dirname, '..', 'package.json'), path.resolve(__dirname, '..', '..', 'package.json'), path.resolve(__dirname, '..', '..', '..', 'package.json')];
|
|
20
|
+
const AGENTS = ['codex', 'claude', 'cursor'];
|
|
21
|
+
async function runDoctorCommand(runtime = {}) {
|
|
22
|
+
const logger = runtime.logger ?? index.createCliLogger();
|
|
23
|
+
const result = await logger.task('正在检查本地 Agent Skill', () => getDoctorResult(runtime), { successText: 'Agent Skill 检查完成' });
|
|
24
|
+
if (runtime.json)
|
|
25
|
+
logger.raw(JSON.stringify(result));
|
|
26
|
+
else {
|
|
27
|
+
logger.section('Doctor');
|
|
28
|
+
logger.info(`SDK version: ${result.currentSdkVersion}`);
|
|
29
|
+
for (const a of result.agents)
|
|
30
|
+
logger.info(`${a.agent}: ${a.status}${a.skillVersion ? ` (${a.skillVersion})` : ''}`);
|
|
31
|
+
logger.info(`Status: ${result.status}`);
|
|
32
|
+
if (result.status !== 'OK')
|
|
33
|
+
logger.warn('请运行 hb-sdk skill install 安装或更新对应 Skill。');
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
async function getDoctorResult(runtime = {}) {
|
|
38
|
+
const version = await readVersion(runtime.packageJsonFiles);
|
|
39
|
+
const results = await Promise.all((runtime.agentNames ?? AGENTS).map(a => inspect(a, version, runtime)));
|
|
40
|
+
const status = results.every(a => a.status === 'OK') ? 'OK' : results.find(a => a.status !== 'OK').status;
|
|
41
|
+
return { currentSdkVersion: version, status, agents: results, localSkillJsonPath: results[0]?.path ?? '', localSkillVersion: results[0]?.skillVersion };
|
|
42
|
+
}
|
|
43
|
+
async function inspect(agent, version, runtime) {
|
|
44
|
+
const home = runtime.agentRoots?.[agent] ?? runtime.env?.[`${agent.toUpperCase()}_HOME`] ?? process.env[`${agent.toUpperCase()}_HOME`] ?? path.join(os.homedir(), `.${agent}`);
|
|
45
|
+
const file = path.join(home, 'skills', index.HB_SDK_SKILL_NAME, 'skill.json');
|
|
46
|
+
try {
|
|
47
|
+
const m = JSON.parse(await fs.readFile(file, 'utf8'));
|
|
48
|
+
const ok = m.name === index.HB_SDK_SKILL_NAME && m.sdk?.package === index.HB_SDK_PACKAGE_NAME && m.sdk?.version === version && m.distribution?.type === 'npm' && m.distribution?.package === index.HB_SDK_PACKAGE_NAME && m.distribution?.version === version && m.skillVersion?.startsWith(`${version}+skill.`);
|
|
49
|
+
return { agent, path: file, status: ok ? 'OK' : 'SKILL_OUTDATED', skillVersion: m.skillVersion };
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return { agent, path: file, status: 'SKILL_MISSING' };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function readVersion(files = CANDIDATES) { for (const file of files) {
|
|
56
|
+
try {
|
|
57
|
+
const m = JSON.parse(await fs.readFile(file, 'utf8'));
|
|
58
|
+
if (typeof m.version === 'string' && m.version)
|
|
59
|
+
return m.version;
|
|
60
|
+
}
|
|
61
|
+
catch { }
|
|
62
|
+
} throw new Error(`未能读取 ${index.HB_SDK_PACKAGE_NAME} 当前版本号`); }
|
|
63
|
+
|
|
64
|
+
exports.getDoctorResult = getDoctorResult;
|
|
65
|
+
exports.runDoctorCommand = runDoctorCommand;
|
|
@@ -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-
|
|
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-BwGBr1ZA.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-
|
|
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-BwGBr1ZA.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-
|
|
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-BwGBr1ZA.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-
|
|
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-BwGBr1ZA.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-
|
|
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-BwGBr1ZA.cjs', document.baseURI).href)));
|
|
250
250
|
function __require() { return require$1("node:process"); }
|
|
251
251
|
|
|
252
252
|
var help = {};
|
|
@@ -3883,10 +3883,6 @@ var envPaths = /*@__PURE__*/getDefaultExportFromCjs(envPathsExports);
|
|
|
3883
3883
|
|
|
3884
3884
|
const HB_SDK_PACKAGE_NAME = '@heybox/hb-sdk';
|
|
3885
3885
|
const HB_SDK_SKILL_NAME = 'hb-sdk';
|
|
3886
|
-
const HB_SDK_AGENT_SKILLS_BASE_URL = 'https://open.xiaoheihe.cn/agent-skills';
|
|
3887
|
-
const HB_SDK_SKILL_SOURCE = `${HB_SDK_AGENT_SKILLS_BASE_URL}/${HB_SDK_SKILL_NAME}`;
|
|
3888
|
-
const HB_SDK_SKILL_INDEX_URL = `${HB_SDK_AGENT_SKILLS_BASE_URL}/.well-known/agent-skills/index.json`;
|
|
3889
|
-
const HB_SDK_SKILL_INSTALL_COMMAND = `npx skills add ${HB_SDK_SKILL_SOURCE}`;
|
|
3890
3886
|
|
|
3891
3887
|
var ora$1 = {exports: {}};
|
|
3892
3888
|
|
|
@@ -12837,6 +12833,7 @@ const UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1000;
|
|
|
12837
12833
|
const DEFAULT_TIMEOUT_MS = 1500;
|
|
12838
12834
|
const UPDATE_CHECK_CACHE_FILE = 'update-check.json';
|
|
12839
12835
|
const NPM_REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(HB_SDK_PACKAGE_NAME)}`;
|
|
12836
|
+
const PUBLIC_CHANGELOG_URL = 'https://docs.xiaoheihe.cn/hb_sdk/changelog/';
|
|
12840
12837
|
const paths = envPaths('hb-sdk', { suffix: '' });
|
|
12841
12838
|
const PACKAGE_JSON_CANDIDATES$1 = [
|
|
12842
12839
|
path.resolve(__dirname, '..', 'package.json'),
|
|
@@ -12891,14 +12888,23 @@ async function getUpdateReminder(options = {}) {
|
|
|
12891
12888
|
return createUpdateReminder(currentVersion, latestVersion);
|
|
12892
12889
|
}
|
|
12893
12890
|
function formatUpdateReminder(reminder) {
|
|
12894
|
-
|
|
12891
|
+
const latestVersion = parseSemver(reminder.latestVersion);
|
|
12892
|
+
const anchor = latestVersion
|
|
12893
|
+
? `v${latestVersion.major}-${latestVersion.minor}-${latestVersion.patch}`
|
|
12894
|
+
: `v${reminder.latestVersion.replaceAll('.', '-')}`;
|
|
12895
|
+
const changelogUrl = `${PUBLIC_CHANGELOG_URL}#${anchor}`;
|
|
12896
|
+
return `发现新版 ${HB_SDK_PACKAGE_NAME}: ${reminder.currentVersion} -> ${reminder.latestVersion}。升级命令: npm i -D ${HB_SDK_PACKAGE_NAME}@latest;更新内容: ${changelogUrl}`;
|
|
12895
12897
|
}
|
|
12896
12898
|
function isVersionGreater(version, baseline) {
|
|
12897
12899
|
const compared = compareSemver(version, baseline);
|
|
12898
12900
|
return compared !== null && compared > 0;
|
|
12899
12901
|
}
|
|
12900
12902
|
function createUpdateReminder(currentVersion, latestVersion) {
|
|
12901
|
-
|
|
12903
|
+
const parsedLatestVersion = latestVersion ? parseSemver(latestVersion) : null;
|
|
12904
|
+
if (!latestVersion ||
|
|
12905
|
+
!parsedLatestVersion ||
|
|
12906
|
+
parsedLatestVersion.prerelease.length > 0 ||
|
|
12907
|
+
!isVersionGreater(latestVersion, currentVersion)) {
|
|
12902
12908
|
return null;
|
|
12903
12909
|
}
|
|
12904
12910
|
return {
|
|
@@ -13347,7 +13353,7 @@ function getPathname(pathWithQuery) {
|
|
|
13347
13353
|
}
|
|
13348
13354
|
|
|
13349
13355
|
const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
|
|
13350
|
-
const BUILT_CLI_VERSION = '0.8.0-alpha.
|
|
13356
|
+
const BUILT_CLI_VERSION = '0.8.0-alpha.9';
|
|
13351
13357
|
const PACKAGE_JSON_CANDIDATES = [
|
|
13352
13358
|
path.resolve(__dirname, '..', '..', 'package.json'),
|
|
13353
13359
|
path.resolve(__dirname, '..', 'package.json'),
|
|
@@ -13412,6 +13418,7 @@ function createCliProgram(overrides = {}) {
|
|
|
13412
13418
|
runDevCommand: defaultRunDevCommand,
|
|
13413
13419
|
runDoctorCommand: defaultRunDoctorCommand,
|
|
13414
13420
|
runRemoteCommand: defaultRunRemoteCommand,
|
|
13421
|
+
runSkillInstallCommand: defaultRunSkillInstallCommand,
|
|
13415
13422
|
...overrides,
|
|
13416
13423
|
};
|
|
13417
13424
|
const program = new Command();
|
|
@@ -13432,10 +13439,11 @@ function createCliProgram(overrides = {}) {
|
|
|
13432
13439
|
}, handlers.printUpdateReminder, resolveLogger));
|
|
13433
13440
|
addVerboseOption(program
|
|
13434
13441
|
.command('dev')
|
|
13435
|
-
.description('启动当前小程序项目的 Vite
|
|
13436
|
-
.option('--port <port>', '
|
|
13437
|
-
.option('--browser-dev-host-port <port>', '
|
|
13438
|
-
.option('--no-open', '不自动打开浏览器调试页')
|
|
13442
|
+
.description('启动当前小程序项目的 Vite 开发服务器和浏览器调试页服务')
|
|
13443
|
+
.option('--port <port>', '小程序开发服务器端口', parsePositivePort)
|
|
13444
|
+
.option('--browser-dev-host-port <port>', '浏览器调试页服务端口', parsePositivePort)
|
|
13445
|
+
.option('--no-open', '不自动打开浏览器调试页')
|
|
13446
|
+
.helpOption('-h, --help', '显示命令帮助')).action(withUpdateReminder(async (options, command) => {
|
|
13439
13447
|
const logger = resolveLogger(command);
|
|
13440
13448
|
await handlers.runDevCommand(options, { logger });
|
|
13441
13449
|
}, handlers.printUpdateReminder, resolveLogger));
|
|
@@ -13451,9 +13459,20 @@ function createCliProgram(overrides = {}) {
|
|
|
13451
13459
|
await handlers.runBuildCommand({}, { logger });
|
|
13452
13460
|
});
|
|
13453
13461
|
installRemoteCommands(program, handlers, resolveLogger);
|
|
13454
|
-
addVerboseOption(program.command('
|
|
13455
|
-
|
|
13456
|
-
|
|
13462
|
+
const skill = addVerboseOption(program.command('skill').description('管理 Agent Skill'));
|
|
13463
|
+
skill.command('install')
|
|
13464
|
+
.option('--global', '安装到用户级 Agent 目录')
|
|
13465
|
+
.option('--agent <agents...>', '指定 Agent')
|
|
13466
|
+
.option('--all-agents', '安装到所有检测到的 Agent')
|
|
13467
|
+
.option('--force', '覆盖已存在且被修改的 Skill')
|
|
13468
|
+
.action(async (options, command) => {
|
|
13469
|
+
const logger = resolveLogger(command);
|
|
13470
|
+
await handlers.runSkillInstallCommand({ ...options, logger });
|
|
13471
|
+
});
|
|
13472
|
+
addVerboseOption(program.command('doctor').description('诊断 hb-sdk 本地环境和 Agent Skill 版本').option('--json', '以 JSON 格式输出诊断结果')).action(async (...args) => {
|
|
13473
|
+
const command = readCommandFromActionArgs(args);
|
|
13474
|
+
const logger = resolveLogger(command);
|
|
13475
|
+
const result = await handlers.runDoctorCommand({ logger, json: Boolean(command?.opts().json) });
|
|
13457
13476
|
if (result.status !== 'SDK_MISMATCH') {
|
|
13458
13477
|
await handlers.printUpdateReminder({ logger });
|
|
13459
13478
|
}
|
|
@@ -13682,35 +13701,39 @@ function createCommandLoggerResolver(options) {
|
|
|
13682
13701
|
};
|
|
13683
13702
|
}
|
|
13684
13703
|
const defaultClearLoginStatus = async (...args) => {
|
|
13685
|
-
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
13704
|
+
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-Dr9lclu3.cjs'); });
|
|
13686
13705
|
return clearLoginStatus(...args);
|
|
13687
13706
|
};
|
|
13688
13707
|
const defaultLoginToHeybox = async (...args) => {
|
|
13689
|
-
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-
|
|
13708
|
+
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-Dr9lclu3.cjs'); });
|
|
13690
13709
|
return loginToHeybox(...args);
|
|
13691
13710
|
};
|
|
13692
13711
|
const defaultPrintLoginStatus = async (...args) => {
|
|
13693
|
-
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
13712
|
+
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-Dr9lclu3.cjs'); });
|
|
13694
13713
|
return printLoginStatus(...args);
|
|
13695
13714
|
};
|
|
13696
13715
|
const defaultRunBuildCommand = async (...args) => {
|
|
13697
|
-
const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-
|
|
13716
|
+
const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-DkokKVNy.cjs'); });
|
|
13698
13717
|
return runBuildCommand(...args);
|
|
13699
13718
|
};
|
|
13700
13719
|
const defaultRunCreateCommand = async (...args) => {
|
|
13701
|
-
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-
|
|
13720
|
+
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-BQy5Jdmu.cjs'); });
|
|
13702
13721
|
return runCreateCommand(...args);
|
|
13703
13722
|
};
|
|
13704
13723
|
const defaultRunDevCommand = async (...args) => {
|
|
13705
|
-
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-
|
|
13724
|
+
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-Dik2zr5R.cjs'); }).then(function (n) { return n.dev; });
|
|
13706
13725
|
return runDevCommand(...args);
|
|
13707
13726
|
};
|
|
13708
13727
|
const defaultRunDoctorCommand = async (...args) => {
|
|
13709
|
-
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-
|
|
13728
|
+
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-Byr4uwKG.cjs'); });
|
|
13710
13729
|
return runDoctorCommand(...args);
|
|
13711
13730
|
};
|
|
13731
|
+
const defaultRunSkillInstallCommand = async (...args) => {
|
|
13732
|
+
const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-f90sxv28.cjs'); });
|
|
13733
|
+
return runSkillInstallCommand(...args);
|
|
13734
|
+
};
|
|
13712
13735
|
const defaultRunRemoteCommand = async (...args) => {
|
|
13713
|
-
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-
|
|
13736
|
+
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-DXxyA14a.cjs'); });
|
|
13714
13737
|
return runRemoteCommand(...args);
|
|
13715
13738
|
};
|
|
13716
13739
|
function resolveStandaloneLogger(options, verbose) {
|
|
@@ -13804,10 +13827,7 @@ function parseNonNegativeInteger(value) {
|
|
|
13804
13827
|
|
|
13805
13828
|
exports.CliError = CliError;
|
|
13806
13829
|
exports.HB_SDK_PACKAGE_NAME = HB_SDK_PACKAGE_NAME;
|
|
13807
|
-
exports.HB_SDK_SKILL_INDEX_URL = HB_SDK_SKILL_INDEX_URL;
|
|
13808
|
-
exports.HB_SDK_SKILL_INSTALL_COMMAND = HB_SDK_SKILL_INSTALL_COMMAND;
|
|
13809
13830
|
exports.HB_SDK_SKILL_NAME = HB_SDK_SKILL_NAME;
|
|
13810
|
-
exports.HB_SDK_SKILL_SOURCE = HB_SDK_SKILL_SOURCE;
|
|
13811
13831
|
exports.applyServiceTagIfNeeded = applyServiceTagIfNeeded;
|
|
13812
13832
|
exports.commonjsGlobal = commonjsGlobal;
|
|
13813
13833
|
exports.createCliLogger = createCliLogger;
|