@heybox/hb-sdk 0.8.0-alpha → 0.8.0-alpha.3
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 +44 -1
- package/README.md +87 -14
- package/THIRD_PARTY_NOTICES.md +1755 -0
- package/dist/cli-chunks/{build-DJWFSM1B.cjs → build-qWzAbpS7.cjs} +2 -2
- package/dist/cli-chunks/{context-DV2UK1Nz.cjs → context-CtS2Thp0.cjs} +1 -26
- package/dist/cli-chunks/{create-2HfoB48V.cjs → create-PV5ua977.cjs} +1 -1
- package/dist/cli-chunks/{dev-Dgt2zS9k.cjs → dev-CwKbAm_H.cjs} +337 -522
- package/dist/cli-chunks/doctor-tJUGOYrm.cjs +65 -0
- package/dist/cli-chunks/{index-BjoSXl8C.cjs → index-DVuD75Hr.cjs} +1 -1
- package/dist/cli-chunks/{index-D62ANeBv.cjs → index-De687C6-.cjs} +33 -24
- package/dist/cli-chunks/{index.esm-CigcxJ2B.cjs → index.esm-B-4yrLNm.cjs} +6 -5
- package/dist/cli-chunks/{login-Cumknwdx.cjs → login-DolpqD8K.cjs} +2 -2
- package/dist/cli-chunks/{project-vite-CcE-HMmd.cjs → project-vite-1rvkK-M8.cjs} +1 -1
- package/dist/cli-chunks/{remote-DDdP3xcE.cjs → remote-rIAQE_G2.cjs} +4 -4
- package/dist/cli-chunks/{session-BDi_AZSv.cjs → session-CzaM2Cq3.cjs} +1 -1
- package/dist/cli-chunks/skill-CM40_9WH.cjs +83 -0
- package/dist/cli-chunks/version-Bz-AfXQU.cjs +8 -0
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-uq-Wac6k.js +97 -0
- package/dist/devtools/browser-dev-host/assets/heybox-logo-CogNENsk.svg +6 -0
- package/dist/devtools/browser-dev-host/assets/index-CeP6SLB3.js +567 -0
- package/dist/devtools/browser-dev-host/assets/index-KD2f3Jdz.css +1 -0
- package/dist/devtools/browser-dev-host/assets/workbench-state-D-1U0JRq.js +5 -0
- package/dist/devtools/browser-dev-host/index.html +6 -435
- package/dist/index.cjs.js +924 -28
- package/dist/index.esm.js +924 -29
- package/dist/protocol.cjs.js +208 -6
- package/dist/protocol.esm.js +182 -7
- package/dist/vite.cjs.js +1 -1
- package/dist/vite.esm.js +1 -1
- package/package.json +29 -10
- package/skill/SKILL.md +16 -13
- package/skill/references/api-protocol.md +100 -4
- package/skill/references/api-root.md +142 -15
- package/skill/references/cli.md +27 -22
- package/skill/references/examples.md +30 -1
- package/skill/references/llms-index.md +1 -1
- package/skill/references/recipes.md +106 -2
- package/skill/references/safety-boundaries.md +12 -1
- package/skill/skill.json +10 -5
- package/types/core/client.d.ts +17 -1
- package/types/core/sdk.d.ts +3 -0
- package/types/core/singleton.d.ts +3 -0
- package/types/index.d.ts +4 -2
- package/types/modules/files/index.d.ts +5 -0
- package/types/modules/files/registry.d.ts +35 -0
- package/types/modules/files/types.d.ts +159 -0
- package/types/modules/network/index.d.ts +50 -3
- package/types/protocol/capabilities.d.ts +2 -2
- package/types/protocol/constants.d.ts +1 -1
- package/types/protocol/guards.d.ts +1 -1
- package/types/protocol/types.d.ts +1 -1
- package/types/protocol.d.ts +4 -3
- package/types/skill-metadata.d.ts +0 -4
- package/dist/cli-chunks/doctor-C95gIao_.cjs +0 -204
- package/dist/devtools/browser-dev-host/main.js +0 -12263
- 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 -794
- package/skill/scripts/validate-skill.mjs +0 -263
|
@@ -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-De687C6-.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-De687C6-.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-De687C6-.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-De687C6-.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-De687C6-.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-De687C6-.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
|
|
|
@@ -13347,7 +13343,7 @@ function getPathname(pathWithQuery) {
|
|
|
13347
13343
|
}
|
|
13348
13344
|
|
|
13349
13345
|
const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
|
|
13350
|
-
const BUILT_CLI_VERSION = '0.8.0-alpha';
|
|
13346
|
+
const BUILT_CLI_VERSION = '0.8.0-alpha.3';
|
|
13351
13347
|
const PACKAGE_JSON_CANDIDATES = [
|
|
13352
13348
|
path.resolve(__dirname, '..', '..', 'package.json'),
|
|
13353
13349
|
path.resolve(__dirname, '..', 'package.json'),
|
|
@@ -13412,6 +13408,7 @@ function createCliProgram(overrides = {}) {
|
|
|
13412
13408
|
runDevCommand: defaultRunDevCommand,
|
|
13413
13409
|
runDoctorCommand: defaultRunDoctorCommand,
|
|
13414
13410
|
runRemoteCommand: defaultRunRemoteCommand,
|
|
13411
|
+
runSkillInstallCommand: defaultRunSkillInstallCommand,
|
|
13415
13412
|
...overrides,
|
|
13416
13413
|
};
|
|
13417
13414
|
const program = new Command();
|
|
@@ -13451,9 +13448,20 @@ function createCliProgram(overrides = {}) {
|
|
|
13451
13448
|
await handlers.runBuildCommand({}, { logger });
|
|
13452
13449
|
});
|
|
13453
13450
|
installRemoteCommands(program, handlers, resolveLogger);
|
|
13454
|
-
addVerboseOption(program.command('
|
|
13455
|
-
|
|
13456
|
-
|
|
13451
|
+
const skill = addVerboseOption(program.command('skill').description('管理 Agent Skill'));
|
|
13452
|
+
skill.command('install')
|
|
13453
|
+
.option('--global', '安装到用户级 Agent 目录')
|
|
13454
|
+
.option('--agent <agents...>', '指定 Agent')
|
|
13455
|
+
.option('--all-agents', '安装到所有检测到的 Agent')
|
|
13456
|
+
.option('--force', '覆盖已存在且被修改的 Skill')
|
|
13457
|
+
.action(async (options, command) => {
|
|
13458
|
+
const logger = resolveLogger(command);
|
|
13459
|
+
await handlers.runSkillInstallCommand({ ...options, logger });
|
|
13460
|
+
});
|
|
13461
|
+
addVerboseOption(program.command('doctor').description('诊断 hb-sdk 本地环境和 Agent Skill 版本').option('--json', '以 JSON 格式输出诊断结果')).action(async (...args) => {
|
|
13462
|
+
const command = readCommandFromActionArgs(args);
|
|
13463
|
+
const logger = resolveLogger(command);
|
|
13464
|
+
const result = await handlers.runDoctorCommand({ logger, json: Boolean(command?.opts().json) });
|
|
13457
13465
|
if (result.status !== 'SDK_MISMATCH') {
|
|
13458
13466
|
await handlers.printUpdateReminder({ logger });
|
|
13459
13467
|
}
|
|
@@ -13682,35 +13690,39 @@ function createCommandLoggerResolver(options) {
|
|
|
13682
13690
|
};
|
|
13683
13691
|
}
|
|
13684
13692
|
const defaultClearLoginStatus = async (...args) => {
|
|
13685
|
-
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
13693
|
+
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-DolpqD8K.cjs'); });
|
|
13686
13694
|
return clearLoginStatus(...args);
|
|
13687
13695
|
};
|
|
13688
13696
|
const defaultLoginToHeybox = async (...args) => {
|
|
13689
|
-
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-
|
|
13697
|
+
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-DolpqD8K.cjs'); });
|
|
13690
13698
|
return loginToHeybox(...args);
|
|
13691
13699
|
};
|
|
13692
13700
|
const defaultPrintLoginStatus = async (...args) => {
|
|
13693
|
-
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
13701
|
+
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-DolpqD8K.cjs'); });
|
|
13694
13702
|
return printLoginStatus(...args);
|
|
13695
13703
|
};
|
|
13696
13704
|
const defaultRunBuildCommand = async (...args) => {
|
|
13697
|
-
const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-
|
|
13705
|
+
const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-qWzAbpS7.cjs'); });
|
|
13698
13706
|
return runBuildCommand(...args);
|
|
13699
13707
|
};
|
|
13700
13708
|
const defaultRunCreateCommand = async (...args) => {
|
|
13701
|
-
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-
|
|
13709
|
+
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-PV5ua977.cjs'); });
|
|
13702
13710
|
return runCreateCommand(...args);
|
|
13703
13711
|
};
|
|
13704
13712
|
const defaultRunDevCommand = async (...args) => {
|
|
13705
|
-
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-
|
|
13713
|
+
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-CwKbAm_H.cjs'); }).then(function (n) { return n.dev; });
|
|
13706
13714
|
return runDevCommand(...args);
|
|
13707
13715
|
};
|
|
13708
13716
|
const defaultRunDoctorCommand = async (...args) => {
|
|
13709
|
-
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-
|
|
13717
|
+
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-tJUGOYrm.cjs'); });
|
|
13710
13718
|
return runDoctorCommand(...args);
|
|
13711
13719
|
};
|
|
13720
|
+
const defaultRunSkillInstallCommand = async (...args) => {
|
|
13721
|
+
const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-CM40_9WH.cjs'); });
|
|
13722
|
+
return runSkillInstallCommand(...args);
|
|
13723
|
+
};
|
|
13712
13724
|
const defaultRunRemoteCommand = async (...args) => {
|
|
13713
|
-
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-
|
|
13725
|
+
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-rIAQE_G2.cjs'); });
|
|
13714
13726
|
return runRemoteCommand(...args);
|
|
13715
13727
|
};
|
|
13716
13728
|
function resolveStandaloneLogger(options, verbose) {
|
|
@@ -13804,10 +13816,7 @@ function parseNonNegativeInteger(value) {
|
|
|
13804
13816
|
|
|
13805
13817
|
exports.CliError = CliError;
|
|
13806
13818
|
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
13819
|
exports.HB_SDK_SKILL_NAME = HB_SDK_SKILL_NAME;
|
|
13810
|
-
exports.HB_SDK_SKILL_SOURCE = HB_SDK_SKILL_SOURCE;
|
|
13811
13820
|
exports.applyServiceTagIfNeeded = applyServiceTagIfNeeded;
|
|
13812
13821
|
exports.commonjsGlobal = commonjsGlobal;
|
|
13813
13822
|
exports.createCliLogger = createCliLogger;
|
|
@@ -11,8 +11,8 @@ var require$$0$4 = require('url');
|
|
|
11
11
|
var require$$0 = require('zlib');
|
|
12
12
|
var require$$0$1 = require('buffer');
|
|
13
13
|
var require$$1 = require('util');
|
|
14
|
-
var index = require('./index-
|
|
15
|
-
var dev = require('./dev-
|
|
14
|
+
var index = require('./index-De687C6-.cjs');
|
|
15
|
+
var dev = require('./dev-CwKbAm_H.cjs');
|
|
16
16
|
require('node:module');
|
|
17
17
|
require('node:fs');
|
|
18
18
|
require('node:fs/promises');
|
|
@@ -27,8 +27,8 @@ require('node:net');
|
|
|
27
27
|
require('node:crypto');
|
|
28
28
|
require('node:dns/promises');
|
|
29
29
|
require('node:http');
|
|
30
|
-
require('./context-
|
|
31
|
-
require('./session-
|
|
30
|
+
require('./context-CtS2Thp0.cjs');
|
|
31
|
+
require('./session-CzaM2Cq3.cjs');
|
|
32
32
|
require('fs');
|
|
33
33
|
require('constants');
|
|
34
34
|
require('./runtime-permission-env-CjsCe5bp.cjs');
|
|
@@ -40,7 +40,8 @@ require('node:buffer');
|
|
|
40
40
|
require('node:url');
|
|
41
41
|
require('node:util');
|
|
42
42
|
require('node:child_process');
|
|
43
|
-
require('./project-vite-
|
|
43
|
+
require('./project-vite-1rvkK-M8.cjs');
|
|
44
|
+
require('./version-Bz-AfXQU.cjs');
|
|
44
45
|
|
|
45
46
|
var bufferUtil = {exports: {}};
|
|
46
47
|
|
|
@@ -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-
|
|
6
|
+
var session = require('./session-CzaM2Cq3.cjs');
|
|
7
7
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-De687C6-.cjs');
|
|
9
9
|
require('node:path');
|
|
10
10
|
require('fs');
|
|
11
11
|
require('constants');
|
|
@@ -5,7 +5,7 @@ var fs$1 = require('node:fs/promises');
|
|
|
5
5
|
var node_module = require('node:module');
|
|
6
6
|
var path = require('node:path');
|
|
7
7
|
var node_url = require('node:url');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-De687C6-.cjs');
|
|
9
9
|
|
|
10
10
|
function findProjectRoot(startDir) {
|
|
11
11
|
let current = path.resolve(startDir);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var promises = require('node:readline/promises');
|
|
4
|
-
var index = require('./index-
|
|
5
|
-
var session = require('./session-
|
|
4
|
+
var index = require('./index-De687C6-.cjs');
|
|
5
|
+
var session = require('./session-CzaM2Cq3.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');
|
|
@@ -10,7 +10,7 @@ var path = require('node:path');
|
|
|
10
10
|
var runtimePermissionEnv = require('./runtime-permission-env-CjsCe5bp.cjs');
|
|
11
11
|
var runtimeGate = require('./runtime-gate-DFjw66kF.cjs');
|
|
12
12
|
var node_crypto = require('node:crypto');
|
|
13
|
-
var context = require('./context-
|
|
13
|
+
var context = require('./context-CtS2Thp0.cjs');
|
|
14
14
|
require('node:module');
|
|
15
15
|
require('path');
|
|
16
16
|
require('os');
|
|
@@ -271,7 +271,7 @@ function createDefaultCosClient(uploadToken, COS) {
|
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
async function loadCosConstructor() {
|
|
274
|
-
const cosModule = await Promise.resolve().then(function () { return require('./index-
|
|
274
|
+
const cosModule = await Promise.resolve().then(function () { return require('./index-DVuD75Hr.cjs'); }).then(function (n) { return n.index; });
|
|
275
275
|
return cosModule.default;
|
|
276
276
|
}
|
|
277
277
|
function formatSize(bytes) {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('node:path');
|
|
4
|
+
var version = require('./version-Bz-AfXQU.cjs');
|
|
5
|
+
var childProcess = require('node:child_process');
|
|
6
|
+
var fs = require('node:fs/promises');
|
|
7
|
+
var index = require('./index-De687C6-.cjs');
|
|
8
|
+
require('node:module');
|
|
9
|
+
require('node:fs');
|
|
10
|
+
require('path');
|
|
11
|
+
require('os');
|
|
12
|
+
require('readline');
|
|
13
|
+
require('tty');
|
|
14
|
+
require('assert');
|
|
15
|
+
require('events');
|
|
16
|
+
require('stream');
|
|
17
|
+
require('buffer');
|
|
18
|
+
require('util');
|
|
19
|
+
|
|
20
|
+
function installSkill(options) {
|
|
21
|
+
const binary = require.resolve('skills/bin/cli.mjs');
|
|
22
|
+
const args = ['add', path.join(options.packageRoot, 'skill'), '--copy'];
|
|
23
|
+
if (options.global)
|
|
24
|
+
args.push('--global');
|
|
25
|
+
if (options.allAgents)
|
|
26
|
+
args.push('--agent', '*');
|
|
27
|
+
else if (options.agents?.length)
|
|
28
|
+
args.push('--agent', ...options.agents);
|
|
29
|
+
if (options.force)
|
|
30
|
+
args.push('--force');
|
|
31
|
+
const env = { ...process.env, ...options.env, DISABLE_TELEMETRY: '1', DO_NOT_TRACK: '1' };
|
|
32
|
+
const run = options.spawnImpl ?? childProcess.spawn;
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const child = run(process.execPath, [binary, ...args], { cwd: options.cwd, env, stdio: 'inherit' });
|
|
35
|
+
child.on('error', reject);
|
|
36
|
+
child.on('close', (code) => resolve({ code: code ?? 1 }));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function findProjectPackageJson(cwd = process.cwd()) {
|
|
41
|
+
let current = path.resolve(cwd);
|
|
42
|
+
while (true) {
|
|
43
|
+
const candidate = path.join(current, 'package.json');
|
|
44
|
+
try {
|
|
45
|
+
await fs.access(candidate);
|
|
46
|
+
return candidate;
|
|
47
|
+
}
|
|
48
|
+
catch { /* continue */ }
|
|
49
|
+
const parent = path.dirname(current);
|
|
50
|
+
if (parent === current)
|
|
51
|
+
return undefined;
|
|
52
|
+
current = parent;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function verifyProjectSdk(cwd, version) {
|
|
56
|
+
const file = await findProjectPackageJson(cwd);
|
|
57
|
+
if (!file)
|
|
58
|
+
throw new Error('未找到项目 package.json,请在项目目录执行');
|
|
59
|
+
const pkg = JSON.parse(await fs.readFile(file, 'utf8'));
|
|
60
|
+
const declared = pkg.dependencies?.['@heybox/hb-sdk'] ?? pkg.devDependencies?.['@heybox/hb-sdk'];
|
|
61
|
+
if (!declared)
|
|
62
|
+
throw new Error('项目缺少 @heybox/hb-sdk 依赖');
|
|
63
|
+
if (declared !== version && !String(declared).includes(version)) {
|
|
64
|
+
throw new Error(`项目 @heybox/hb-sdk 版本 ${declared} 与 CLI ${version} 不一致`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function runSkillInstallCommand(options = {}) {
|
|
69
|
+
if (options.agent?.length && options.allAgents)
|
|
70
|
+
throw new Error('--agent 与 --all-agents 互斥');
|
|
71
|
+
const logger = options.logger ?? index.createCliLogger();
|
|
72
|
+
const packageRoot = options.packageRoot ?? path.resolve(__dirname, '../../..');
|
|
73
|
+
const cwd = options.cwd ?? process.cwd();
|
|
74
|
+
if (!options.global)
|
|
75
|
+
await verifyProjectSdk(cwd, version.HB_SDK_VERSION);
|
|
76
|
+
const result = await installSkill({ packageRoot, cwd, global: options.global, agents: options.agent, allAgents: options.allAgents, force: options.force });
|
|
77
|
+
if (result.code !== 0)
|
|
78
|
+
throw new Error(`Skill 安装失败(退出码 ${result.code})`);
|
|
79
|
+
logger.success('hb-sdk Skill 安装完成');
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.runSkillInstallCommand = runSkillInstallCommand;
|