bfi-cli 0.1.46 → 0.1.56
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/_chunks/agents2.mjs +9 -1
- package/dist/cli.mjs +28 -43
- package/package.json +2 -2
- /package/bin/{bfi.mjs → bfi.js} +0 -0
package/dist/_chunks/agents2.mjs
CHANGED
|
@@ -85,7 +85,15 @@ async function resolveAgents(api) {
|
|
|
85
85
|
if (cache) remoteAgents = cache.agents.map(mapToAgentConfig);
|
|
86
86
|
}
|
|
87
87
|
if (shouldSaveCache && remoteAgents) saveCache(remoteAgents, newMaxUpdatedAt);
|
|
88
|
-
if (remoteAgents) for (const agent of remoteAgents)
|
|
88
|
+
if (remoteAgents) for (const agent of remoteAgents) {
|
|
89
|
+
const existing = merged.get(agent.name);
|
|
90
|
+
if (existing) merged.set(agent.name, {
|
|
91
|
+
...agent,
|
|
92
|
+
showInUniversalList: existing.showInUniversalList,
|
|
93
|
+
showInUniversalPrompt: existing.showInUniversalPrompt
|
|
94
|
+
});
|
|
95
|
+
else merged.set(agent.name, agent);
|
|
96
|
+
}
|
|
89
97
|
}
|
|
90
98
|
const config = loadGlobalConfig();
|
|
91
99
|
if (config?.customAgents) for (const [name, entry] of Object.entries(config.customAgents)) merged.set(name, mapCustomEntry(name, entry));
|
package/dist/cli.mjs
CHANGED
|
@@ -352,11 +352,15 @@ async function searchMultiselect(options) {
|
|
|
352
352
|
lines.push(`${icon} ${import_picocolors.default.bold(message)}`);
|
|
353
353
|
if (state === "active") {
|
|
354
354
|
if (lockedSection && lockedSection.items.length > 0) {
|
|
355
|
+
const maxVisible = lockedSection.maxVisibleItems;
|
|
356
|
+
const visibleLocked = maxVisible && maxVisible < lockedSection.items.length ? lockedSection.items.slice(0, maxVisible) : lockedSection.items;
|
|
357
|
+
const lockedRemaining = lockedSection.items.length - visibleLocked.length;
|
|
355
358
|
lines.push(`${S_BAR}`);
|
|
356
359
|
const lockedTitle = `${import_picocolors.default.bold(lockedSection.title)} ${import_picocolors.default.dim("── always included")}`;
|
|
357
360
|
lines.push(`${S_BAR} ${S_BAR_H}${S_BAR_H} ${lockedTitle} ${S_BAR_H.repeat(12)}`);
|
|
358
|
-
for (const item of
|
|
359
|
-
if (
|
|
361
|
+
for (const item of visibleLocked) lines.push(`${S_BAR} ${S_BULLET} ${import_picocolors.default.bold(item.label)}`);
|
|
362
|
+
if (lockedRemaining > 0) lines.push(`${S_BAR} ${import_picocolors.default.dim(`...and ${lockedRemaining} more`)}`);
|
|
363
|
+
else if (lockedSection.hiddenCount && lockedSection.hiddenCount > 0) lines.push(`${S_BAR} ${import_picocolors.default.dim(`...and ${lockedSection.hiddenCount} more`)}`);
|
|
360
364
|
lines.push(`${S_BAR}`);
|
|
361
365
|
lines.push(`${S_BAR} ${S_BAR_H}${S_BAR_H} ${import_picocolors.default.bold("Additional agents")} ${S_BAR_H.repeat(29)}`);
|
|
362
366
|
}
|
|
@@ -2997,7 +3001,6 @@ async function selectAgentsInteractive(options) {
|
|
|
2997
3001
|
try {
|
|
2998
3002
|
installedAgents = await detectInstalledAgents();
|
|
2999
3003
|
} catch {}
|
|
3000
|
-
const hasDetected = installedAgents.length > 0;
|
|
3001
3004
|
const installedSet = new Set(installedAgents);
|
|
3002
3005
|
const universalAgents = getUniversalAgents().filter(supportsGlobalFilter);
|
|
3003
3006
|
const visibleUniversalAgents = getVisibleUniversalAgents().filter(supportsGlobalFilter);
|
|
@@ -3011,54 +3014,33 @@ async function selectAgentsInteractive(options) {
|
|
|
3011
3014
|
universalAgents.sort(sortByPriority);
|
|
3012
3015
|
visibleUniversalAgents.sort(sortByPriority);
|
|
3013
3016
|
otherAgents.sort(sortByPriority);
|
|
3014
|
-
const showAll = hasDetected ? false : true;
|
|
3015
|
-
const filteredUniversal = showAll ? visibleUniversalAgents : visibleUniversalAgents.filter((a) => installedSet.has(a));
|
|
3016
3017
|
const universalSection = {
|
|
3017
|
-
title: `共享目录 (.agents/skills)
|
|
3018
|
-
items:
|
|
3018
|
+
title: `共享目录 (.agents/skills)${installedAgents.length > 0 ? ` — 已检测到 ${visibleUniversalAgents.filter((a) => installedSet.has(a)).length} 个` : ""}`,
|
|
3019
|
+
items: visibleUniversalAgents.map((a) => ({
|
|
3019
3020
|
value: a,
|
|
3020
3021
|
label: agents[a].displayName
|
|
3021
3022
|
})),
|
|
3022
|
-
hiddenCount:
|
|
3023
|
+
hiddenCount: universalAgents.length - visibleUniversalAgents.length,
|
|
3024
|
+
maxVisibleItems: 5
|
|
3023
3025
|
};
|
|
3024
|
-
const
|
|
3025
|
-
const otherChoices = filteredOther.map((a) => ({
|
|
3026
|
+
const otherChoices = otherAgents.map((a) => ({
|
|
3026
3027
|
value: a,
|
|
3027
3028
|
label: agents[a].displayName,
|
|
3028
3029
|
hint: options.global ? agents[a].globalSkillsDir : agents[a].skillsDir
|
|
3029
3030
|
}));
|
|
3030
|
-
|
|
3031
|
-
value: "__show_all__",
|
|
3032
|
-
label: `显示全部 ${otherAgents.length + universalAgents.length} 个 Agent...`,
|
|
3033
|
-
hint: "包括未检测到的"
|
|
3034
|
-
});
|
|
3035
|
-
let lastSelected;
|
|
3031
|
+
let lastSelected = [];
|
|
3036
3032
|
try {
|
|
3037
|
-
lastSelected = await getLastSelectedAgents();
|
|
3033
|
+
lastSelected = await getLastSelectedAgents() || [];
|
|
3038
3034
|
} catch {}
|
|
3039
3035
|
const selected = await searchMultiselect({
|
|
3040
3036
|
message: "请选择要安装到的 Agent:",
|
|
3041
3037
|
items: otherChoices,
|
|
3042
|
-
initialSelected:
|
|
3038
|
+
initialSelected: [.../* @__PURE__ */ new Set([...installedAgents, ...lastSelected])].filter((a) => otherAgents.includes(a) && !universalAgents.includes(a)),
|
|
3043
3039
|
lockedSection: universalSection
|
|
3044
3040
|
});
|
|
3045
|
-
if (!isCancelled(selected)) {
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
const allSelected = [
|
|
3049
|
-
...selection.filter((s) => s !== "__show_all__"),
|
|
3050
|
-
...otherAgents.filter((a) => !installedSet.has(a)),
|
|
3051
|
-
...universalAgents.filter((a) => !installedSet.has(a))
|
|
3052
|
-
];
|
|
3053
|
-
try {
|
|
3054
|
-
await saveSelectedAgents(allSelected);
|
|
3055
|
-
} catch {}
|
|
3056
|
-
return [...new Set(allSelected)];
|
|
3057
|
-
}
|
|
3058
|
-
try {
|
|
3059
|
-
await saveSelectedAgents(selection);
|
|
3060
|
-
} catch {}
|
|
3061
|
-
}
|
|
3041
|
+
if (!isCancelled(selected)) try {
|
|
3042
|
+
await saveSelectedAgents(selected);
|
|
3043
|
+
} catch {}
|
|
3062
3044
|
return selected;
|
|
3063
3045
|
}
|
|
3064
3046
|
async function handleWellKnownSkills(source, url, options, spinner) {
|
|
@@ -6264,13 +6246,14 @@ async function handleUpload(args, globalOpts) {
|
|
|
6264
6246
|
try {
|
|
6265
6247
|
const fileBuffer = fs.readFileSync(resolvedPath);
|
|
6266
6248
|
const result = await api.uploadDoc(fileBuffer, fileName);
|
|
6249
|
+
const doc = result.data || result;
|
|
6267
6250
|
console.log(`${TEXT$4}✓ 上传成功${RESET$5}`);
|
|
6268
6251
|
console.log();
|
|
6269
|
-
if (
|
|
6270
|
-
if (
|
|
6271
|
-
if (
|
|
6252
|
+
if (doc.id) console.log(` ${BOLD$3}ID:${RESET$5} ${TEXT$4}${doc.id}${RESET$5}`);
|
|
6253
|
+
if (doc.status) console.log(` ${BOLD$3}状态:${RESET$5} ${TEXT$4}${doc.status}${RESET$5}`);
|
|
6254
|
+
if (doc.fileName) console.log(` ${BOLD$3}文件:${RESET$5} ${TEXT$4}${doc.fileName}${RESET$5}`);
|
|
6272
6255
|
console.log();
|
|
6273
|
-
if (
|
|
6256
|
+
if (doc.id) console.log(`${DIM$5}查看状态:bfi docs info ${doc.id}${RESET$5}`);
|
|
6274
6257
|
} catch (error) {
|
|
6275
6258
|
console.error(`上传失败:${error.message}`);
|
|
6276
6259
|
process.exit(1);
|
|
@@ -6283,25 +6266,27 @@ async function handleList(args, globalOpts) {
|
|
|
6283
6266
|
const api = new SkillHubAPI(registry, token);
|
|
6284
6267
|
try {
|
|
6285
6268
|
const result = await api.listDocs(page, size);
|
|
6286
|
-
const
|
|
6269
|
+
const data = result.data || result;
|
|
6270
|
+
const docs = data.items || data.content || data.docs || (Array.isArray(data) ? data : []);
|
|
6287
6271
|
if (!Array.isArray(docs) || docs.length === 0) {
|
|
6288
6272
|
console.log(`${DIM$5}未找到文档。${RESET$5}`);
|
|
6289
6273
|
return;
|
|
6290
6274
|
}
|
|
6275
|
+
const total = data.total || data.totalElements || result.total || result.totalElements;
|
|
6291
6276
|
console.log();
|
|
6292
|
-
console.log(`${BOLD$3}文档${RESET$5}(第 ${page} 页,共 ${
|
|
6277
|
+
if (total) console.log(`${BOLD$3}文档${RESET$5}(第 ${page + 1} 页,共 ${total} 条):`);
|
|
6278
|
+
else console.log(`${BOLD$3}文档${RESET$5}(第 ${page + 1} 页,共 ${docs.length} 条结果):`);
|
|
6293
6279
|
console.log(`${DIM$5}${"─".repeat(64)}${RESET$5}`);
|
|
6294
6280
|
for (const doc of docs) {
|
|
6295
6281
|
const id = doc.id || "?";
|
|
6296
6282
|
const fileName = doc.fileName || doc.file_name || "unknown";
|
|
6297
|
-
const status = doc.status || "
|
|
6283
|
+
const status = doc.status || "N/A";
|
|
6298
6284
|
const createdAt = doc.createdAt || doc.created_at;
|
|
6299
6285
|
const dateStr = createdAt ? new Date(createdAt).toISOString().split("T")[0] : "N/A";
|
|
6300
6286
|
console.log(` ${BOLD$3}#${id}${RESET$5} ${TEXT$4}${fileName}${RESET$5}`);
|
|
6301
6287
|
console.log(` ${DIM$5}状态:${status} | 日期:${dateStr}${RESET$5}`);
|
|
6302
6288
|
console.log();
|
|
6303
6289
|
}
|
|
6304
|
-
const total = result.total || result.totalElements;
|
|
6305
6290
|
if (total && Number(total) > (page + 1) * size) console.log(`${DIM$5}下一页:bfi docs list ${page + 1}${RESET$5}`);
|
|
6306
6291
|
console.log();
|
|
6307
6292
|
} catch (error) {
|
package/package.json
CHANGED
/package/bin/{bfi.mjs → bfi.js}
RENAMED
|
File without changes
|