bfi-cli 0.1.7 → 0.1.10
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/dist/cli.mjs +48 -27
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -596,6 +596,9 @@ var SkillHubAPI = class {
|
|
|
596
596
|
async whoami() {
|
|
597
597
|
return (await this.request("GET", "/whoami")).body;
|
|
598
598
|
}
|
|
599
|
+
async myNamespaces() {
|
|
600
|
+
return (await this.request("GET", "/me/namespaces")).body;
|
|
601
|
+
}
|
|
599
602
|
async listPackages(namespace) {
|
|
600
603
|
const body = (await this.request("GET", `/namespaces/${namespace}/packages`)).body;
|
|
601
604
|
return body.data || body;
|
|
@@ -3997,8 +4000,8 @@ function buildAgentSummaryLines(targetAgents, installMode) {
|
|
|
3997
4000
|
const lines = [];
|
|
3998
4001
|
const { universal, symlinked } = splitAgentsByType(targetAgents);
|
|
3999
4002
|
if (installMode === "symlink") {
|
|
4000
|
-
if (universal.length > 0) lines.push(` ${import_picocolors.default.green("
|
|
4001
|
-
if (symlinked.length > 0) lines.push(` ${import_picocolors.default.dim("
|
|
4003
|
+
if (universal.length > 0) lines.push(` ${import_picocolors.default.green("共享目录:")} ${formatList$1(universal)}`);
|
|
4004
|
+
if (symlinked.length > 0) lines.push(` ${import_picocolors.default.dim("符号链接 →")} ${formatList$1(symlinked)}`);
|
|
4002
4005
|
} else {
|
|
4003
4006
|
const allNames = targetAgents.map((a) => agents[a].displayName);
|
|
4004
4007
|
lines.push(` ${import_picocolors.default.dim("copy →")} ${formatList$1(allNames)}`);
|
|
@@ -4027,8 +4030,8 @@ function buildTargetSummaryLines(targets, installMode) {
|
|
|
4027
4030
|
const subagentNames = targets.filter((t) => t.subagent).map(targetDisplayName);
|
|
4028
4031
|
const { universal, symlinked } = splitAgentsByType(rootAgents);
|
|
4029
4032
|
if (installMode === "symlink") {
|
|
4030
|
-
if (universal.length > 0) lines.push(` ${import_picocolors.default.green("
|
|
4031
|
-
if (symlinked.length > 0) lines.push(` ${import_picocolors.default.dim("
|
|
4033
|
+
if (universal.length > 0) lines.push(` ${import_picocolors.default.green("共享目录:")} ${formatList$1(universal)}`);
|
|
4034
|
+
if (symlinked.length > 0) lines.push(` ${import_picocolors.default.dim("符号链接 →")} ${formatList$1(symlinked)}`);
|
|
4032
4035
|
if (subagentNames.length > 0) lines.push(` ${import_picocolors.default.dim("copy →")} ${formatList$1(subagentNames)}`);
|
|
4033
4036
|
} else {
|
|
4034
4037
|
const allNames = targets.map(targetDisplayName);
|
|
@@ -4047,8 +4050,8 @@ function buildResultLines(results, targetAgents) {
|
|
|
4047
4050
|
const { universal, symlinked: symlinkAgents } = splitAgentsByType(targetAgents);
|
|
4048
4051
|
const successfulSymlinks = results.filter((r) => !r.symlinkFailed && !r.skipped && !universal.includes(r.agent)).map((r) => r.agent);
|
|
4049
4052
|
const failedSymlinks = results.filter((r) => r.symlinkFailed && !r.skipped).map((r) => r.agent);
|
|
4050
|
-
if (universal.length > 0) lines.push(` ${import_picocolors.default.green("
|
|
4051
|
-
if (successfulSymlinks.length > 0) lines.push(` ${import_picocolors.default.dim("
|
|
4053
|
+
if (universal.length > 0) lines.push(` ${import_picocolors.default.green("共享目录:")} ${formatList$1(universal)}`);
|
|
4054
|
+
if (successfulSymlinks.length > 0) lines.push(` ${import_picocolors.default.dim("符号链接:")} ${formatList$1(successfulSymlinks)}`);
|
|
4052
4055
|
if (failedSymlinks.length > 0) lines.push(` ${import_picocolors.default.yellow("copied:")} ${formatList$1(failedSymlinks)}`);
|
|
4053
4056
|
return lines;
|
|
4054
4057
|
}
|
|
@@ -4146,7 +4149,7 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
4146
4149
|
let selectedSkills;
|
|
4147
4150
|
if (options.skill?.includes("*")) {
|
|
4148
4151
|
selectedSkills = skills;
|
|
4149
|
-
log.info(
|
|
4152
|
+
log.info(`正在安装全部 ${skills.length} 个技能`);
|
|
4150
4153
|
} else if (options.skill && options.skill.length > 0) {
|
|
4151
4154
|
selectedSkills = skills.filter((s) => options.skill.some((name) => s.installName.toLowerCase() === name.toLowerCase() || s.name.toLowerCase() === name.toLowerCase()));
|
|
4152
4155
|
if (selectedSkills.length === 0) {
|
|
@@ -4161,7 +4164,7 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
4161
4164
|
log.info(`Skill: ${import_picocolors.default.cyan(firstSkill.installName)}`);
|
|
4162
4165
|
} else if (options.yes) {
|
|
4163
4166
|
selectedSkills = skills;
|
|
4164
|
-
log.info(
|
|
4167
|
+
log.info(`正在安装全部 ${skills.length} 个技能`);
|
|
4165
4168
|
} else {
|
|
4166
4169
|
const selected = await multiselect({
|
|
4167
4170
|
message: "选择要安装的技能",
|
|
@@ -4182,7 +4185,7 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
4182
4185
|
const validAgents = Object.keys(agents);
|
|
4183
4186
|
if (options.agent?.includes("*")) {
|
|
4184
4187
|
targetAgents = validAgents;
|
|
4185
|
-
log.info(
|
|
4188
|
+
log.info(`正在安装到全部 ${targetAgents.length} 个 Agent`);
|
|
4186
4189
|
} else if (options.agent && options.agent.length > 0) {
|
|
4187
4190
|
const invalidAgents = options.agent.filter((a) => !validAgents.includes(a));
|
|
4188
4191
|
if (invalidAgents.length > 0) {
|
|
@@ -4215,8 +4218,8 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
4215
4218
|
targetAgents = ensureUniversalAgents(installedAgents);
|
|
4216
4219
|
if (installedAgents.length === 1) {
|
|
4217
4220
|
const firstAgent = installedAgents[0];
|
|
4218
|
-
log.info(
|
|
4219
|
-
} else log.info(
|
|
4221
|
+
log.info(`安装到:${import_picocolors.default.cyan(agents[firstAgent].displayName)}`);
|
|
4222
|
+
} else log.info(`安装到:${installedAgents.map((a) => import_picocolors.default.cyan(agents[a].displayName)).join(", ")}`);
|
|
4220
4223
|
} else {
|
|
4221
4224
|
const selected = await selectAgentsInteractive({ global: options.global });
|
|
4222
4225
|
if (isCancel(selected)) {
|
|
@@ -4375,7 +4378,7 @@ async function handleWellKnownSkills(source, url, options, spinner) {
|
|
|
4375
4378
|
resultLines.push(...buildResultLines(skillResults, targetAgents));
|
|
4376
4379
|
}
|
|
4377
4380
|
}
|
|
4378
|
-
const title = import_picocolors.default.green(
|
|
4381
|
+
const title = import_picocolors.default.green(`已安装 ${skillCount} 个技能`);
|
|
4379
4382
|
note(resultLines.join("\n"), title);
|
|
4380
4383
|
if (symlinkFailures.length > 0) {
|
|
4381
4384
|
log.warn(import_picocolors.default.yellow(`符号链接失败: ${formatList$1(copiedAgents)}`));
|
|
@@ -4665,7 +4668,7 @@ async function runAdd(args, options = {}) {
|
|
|
4665
4668
|
let selectedSkills;
|
|
4666
4669
|
if (options.skill?.includes("*")) {
|
|
4667
4670
|
selectedSkills = skills;
|
|
4668
|
-
log.info(
|
|
4671
|
+
log.info(`正在安装全部 ${skills.length} 个技能`);
|
|
4669
4672
|
} else if (options.skill && options.skill.length > 0) {
|
|
4670
4673
|
selectedSkills = filterSkills(skills, options.skill);
|
|
4671
4674
|
if (selectedSkills.length === 0) {
|
|
@@ -4683,7 +4686,7 @@ async function runAdd(args, options = {}) {
|
|
|
4683
4686
|
log.message(import_picocolors.default.dim(firstSkill.description));
|
|
4684
4687
|
} else if (options.yes) {
|
|
4685
4688
|
selectedSkills = skills;
|
|
4686
|
-
log.info(
|
|
4689
|
+
log.info(`正在安装全部 ${skills.length} 个技能`);
|
|
4687
4690
|
} else {
|
|
4688
4691
|
const sortedSkills = [...skills].sort((a, b) => {
|
|
4689
4692
|
if (a.pluginName && !b.pluginName) return -1;
|
|
@@ -4732,7 +4735,7 @@ async function runAdd(args, options = {}) {
|
|
|
4732
4735
|
const validAgents = Object.keys(agents);
|
|
4733
4736
|
if (options.agent?.includes("*")) {
|
|
4734
4737
|
targetAgents = validAgents;
|
|
4735
|
-
log.info(
|
|
4738
|
+
log.info(`正在安装到全部 ${targetAgents.length} 个 Agent`);
|
|
4736
4739
|
} else if (options.agent && options.agent.length > 0) {
|
|
4737
4740
|
const invalidAgents = options.agent.filter((a) => !validAgents.includes(a));
|
|
4738
4741
|
if (invalidAgents.length > 0) {
|
|
@@ -4789,8 +4792,8 @@ async function runAdd(args, options = {}) {
|
|
|
4789
4792
|
targetAgents = ensureUniversalAgents(installedAgents);
|
|
4790
4793
|
if (installedAgents.length === 1) {
|
|
4791
4794
|
const firstAgent = installedAgents[0];
|
|
4792
|
-
log.info(
|
|
4793
|
-
} else log.info(
|
|
4795
|
+
log.info(`安装到:${import_picocolors.default.cyan(agents[firstAgent].displayName)}`);
|
|
4796
|
+
} else log.info(`安装到:${installedAgents.map((a) => import_picocolors.default.cyan(agents[a].displayName)).join(", ")}`);
|
|
4794
4797
|
} else {
|
|
4795
4798
|
const selected = await selectAgentsInteractive({ global: options.global });
|
|
4796
4799
|
if (isCancel(selected)) {
|
|
@@ -4837,11 +4840,11 @@ async function runAdd(args, options = {}) {
|
|
|
4837
4840
|
message: "安装范围",
|
|
4838
4841
|
options: [{
|
|
4839
4842
|
value: false,
|
|
4840
|
-
label: "
|
|
4843
|
+
label: "项目",
|
|
4841
4844
|
hint: "安装到当前目录(随项目一起提交)"
|
|
4842
4845
|
}, {
|
|
4843
4846
|
value: true,
|
|
4844
|
-
label: "
|
|
4847
|
+
label: "全局",
|
|
4845
4848
|
hint: "安装到主目录(跨所有项目可用)"
|
|
4846
4849
|
}]
|
|
4847
4850
|
});
|
|
@@ -5101,7 +5104,7 @@ async function runAdd(args, options = {}) {
|
|
|
5101
5104
|
}
|
|
5102
5105
|
printSkillResults(ungroupedResults);
|
|
5103
5106
|
}
|
|
5104
|
-
const title = import_picocolors.default.green(
|
|
5107
|
+
const title = import_picocolors.default.green(`已安装 ${skillCount} 个技能`);
|
|
5105
5108
|
note(resultLines.join("\n"), title);
|
|
5106
5109
|
if (symlinkFailures.length > 0) {
|
|
5107
5110
|
log.warn(import_picocolors.default.yellow(`符号链接失败: ${formatList$1(copiedAgents)}`));
|
|
@@ -5114,7 +5117,7 @@ async function runAdd(args, options = {}) {
|
|
|
5114
5117
|
for (const r of failed) log.message(` ${import_picocolors.default.red("✗")} ${r.skill} → ${r.agent}: ${import_picocolors.default.dim(r.error)}`);
|
|
5115
5118
|
}
|
|
5116
5119
|
console.log();
|
|
5117
|
-
outro(import_picocolors.default.green("
|
|
5120
|
+
outro(import_picocolors.default.green("完成!") + import_picocolors.default.dim(" Review skills before use; they run with full agent permissions."));
|
|
5118
5121
|
await promptForFindSkills(options, targetAgents);
|
|
5119
5122
|
} catch (error) {
|
|
5120
5123
|
if (error instanceof GitCloneError) {
|
|
@@ -6762,12 +6765,30 @@ async function runWhoami(globalOpts) {
|
|
|
6762
6765
|
console.error("未认证。运行:bfi auth login --token <token>");
|
|
6763
6766
|
process.exit(1);
|
|
6764
6767
|
}
|
|
6765
|
-
const
|
|
6768
|
+
const api = new SkillHubAPI(registry, token);
|
|
6769
|
+
const response = await api.whoami();
|
|
6766
6770
|
const user = response.user || response;
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
console.log(
|
|
6770
|
-
console.log(
|
|
6771
|
+
const displayName = user.displayName || user.name || "N/A";
|
|
6772
|
+
const userId = user.handle || user.id || "N/A";
|
|
6773
|
+
console.log(`\n用户名: ${displayName}`);
|
|
6774
|
+
console.log(`用户ID: ${userId}`);
|
|
6775
|
+
try {
|
|
6776
|
+
const nsResponse = await api.myNamespaces();
|
|
6777
|
+
const namespaces = nsResponse.data || nsResponse;
|
|
6778
|
+
if (Array.isArray(namespaces) && namespaces.length > 0) {
|
|
6779
|
+
console.log(`\n命名空间 (${namespaces.length}):`);
|
|
6780
|
+
for (const ns of namespaces) {
|
|
6781
|
+
const role = ns.currentUserRole || "MEMBER";
|
|
6782
|
+
const roleLabel = {
|
|
6783
|
+
OWNER: "拥有者",
|
|
6784
|
+
ADMIN: "管理员",
|
|
6785
|
+
MEMBER: "成员",
|
|
6786
|
+
VIEWER: "访客"
|
|
6787
|
+
}[role] || role;
|
|
6788
|
+
console.log(` @${ns.slug} ${ns.displayName || ""} [${roleLabel}]`);
|
|
6789
|
+
}
|
|
6790
|
+
}
|
|
6791
|
+
} catch {}
|
|
6771
6792
|
console.log();
|
|
6772
6793
|
}
|
|
6773
6794
|
function getOptionValue$3(args, flag) {
|
|
@@ -6842,7 +6863,7 @@ async function searchSkillHub(query, namespace, globalOpts) {
|
|
|
6842
6863
|
if (desc) console.log(` ${DIM$8}${truncate$2(desc, 100)}${RESET$8}`);
|
|
6843
6864
|
console.log(` ${TEXT$7}slug: ${skill.slug}${RESET$8}`);
|
|
6844
6865
|
if (skill.version) console.log(` ${DIM$8}version: ${skill.version}${RESET$8}`);
|
|
6845
|
-
console.log(` ${DIM$8}
|
|
6866
|
+
console.log(` ${DIM$8}安装:${TEXT$7}bfi skills add ${skill.slug}${RESET$8}`);
|
|
6846
6867
|
console.log();
|
|
6847
6868
|
}
|
|
6848
6869
|
} catch (error) {
|