bfi-cli 0.1.41 → 0.1.43
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 +25 -12
- package/dist/cli.mjs +38 -2
- package/package.json +1 -1
- package/skills/skillhub-skills/SKILL.md +3 -0
package/dist/_chunks/agents2.mjs
CHANGED
|
@@ -4,22 +4,24 @@ import fs from "node:fs";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
const CACHE_FILE = path.join(os.homedir(), ".bfi", "agents-cache.json");
|
|
7
|
-
const CACHE_TTL_MS = 1440 * 60 * 1e3;
|
|
8
7
|
function loadCache() {
|
|
9
8
|
try {
|
|
10
9
|
if (fs.existsSync(CACHE_FILE)) {
|
|
11
10
|
const raw = JSON.parse(fs.readFileSync(CACHE_FILE, "utf8"));
|
|
12
|
-
if (
|
|
11
|
+
if (raw && Array.isArray(raw.agents)) return {
|
|
12
|
+
maxUpdatedAt: typeof raw.maxUpdatedAt === "number" ? raw.maxUpdatedAt : 0,
|
|
13
|
+
agents: raw.agents
|
|
14
|
+
};
|
|
13
15
|
}
|
|
14
16
|
} catch {}
|
|
15
17
|
return null;
|
|
16
18
|
}
|
|
17
|
-
function saveCache(agents) {
|
|
19
|
+
function saveCache(agents, maxUpdatedAt) {
|
|
18
20
|
try {
|
|
19
21
|
const dir = path.dirname(CACHE_FILE);
|
|
20
22
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
21
23
|
fs.writeFileSync(CACHE_FILE, JSON.stringify({
|
|
22
|
-
|
|
24
|
+
maxUpdatedAt,
|
|
23
25
|
agents
|
|
24
26
|
}));
|
|
25
27
|
} catch {}
|
|
@@ -42,21 +44,32 @@ function mapCustomEntry(name, entry) {
|
|
|
42
44
|
detectInstalled: async () => false
|
|
43
45
|
};
|
|
44
46
|
}
|
|
47
|
+
function parseLastModifiedHeader(headers) {
|
|
48
|
+
const raw = headers?.["last-modified"];
|
|
49
|
+
if (!raw) return 0;
|
|
50
|
+
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
51
|
+
return Number(value) || 0;
|
|
52
|
+
}
|
|
45
53
|
async function resolveAgents(api) {
|
|
46
54
|
const merged = /* @__PURE__ */ new Map();
|
|
47
55
|
for (const [name, config] of Object.entries(agents)) merged.set(name, config);
|
|
48
56
|
if (api) {
|
|
49
57
|
let remoteAgents = null;
|
|
58
|
+
let shouldSaveCache = false;
|
|
59
|
+
let newMaxUpdatedAt = 0;
|
|
50
60
|
const cache = loadCache();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
try {
|
|
62
|
+
const resp = await api.getAgents(cache?.maxUpdatedAt);
|
|
63
|
+
if (resp.status === 304) remoteAgents = cache.agents.map(mapToAgentConfig);
|
|
64
|
+
else if (resp.status >= 200 && resp.status < 300 && Array.isArray(resp.body)) {
|
|
65
|
+
remoteAgents = resp.body.map(mapToAgentConfig);
|
|
66
|
+
newMaxUpdatedAt = parseLastModifiedHeader(resp.headers);
|
|
67
|
+
shouldSaveCache = remoteAgents.length > 0;
|
|
58
68
|
}
|
|
59
|
-
} catch {
|
|
69
|
+
} catch {
|
|
70
|
+
if (cache) remoteAgents = cache.agents.map(mapToAgentConfig);
|
|
71
|
+
}
|
|
72
|
+
if (shouldSaveCache && remoteAgents) saveCache(remoteAgents, newMaxUpdatedAt);
|
|
60
73
|
if (remoteAgents) for (const agent of remoteAgents) merged.set(agent.name, agent);
|
|
61
74
|
}
|
|
62
75
|
const config = loadGlobalConfig();
|
package/dist/cli.mjs
CHANGED
|
@@ -664,8 +664,10 @@ var SkillHubAPI = class {
|
|
|
664
664
|
confirmWarnings
|
|
665
665
|
} })).body;
|
|
666
666
|
}
|
|
667
|
-
async getAgents() {
|
|
668
|
-
|
|
667
|
+
async getAgents(ifModifiedSince) {
|
|
668
|
+
const options = {};
|
|
669
|
+
if (ifModifiedSince && ifModifiedSince > 0) options.headers = { "If-Modified-Since": String(ifModifiedSince) };
|
|
670
|
+
return this.request("GET", "/public/agents", options);
|
|
669
671
|
}
|
|
670
672
|
async uploadDoc(fileBuffer, fileName) {
|
|
671
673
|
const url = new URL(this.buildUrl("/public/process-docs"));
|
|
@@ -6672,6 +6674,9 @@ async function runPackage(args, globalOpts) {
|
|
|
6672
6674
|
case "search":
|
|
6673
6675
|
await handleSearch(args.slice(1), api, globalOpts);
|
|
6674
6676
|
break;
|
|
6677
|
+
case "info":
|
|
6678
|
+
await handleServerInfo(args.slice(1), api, globalOpts);
|
|
6679
|
+
break;
|
|
6675
6680
|
case "create":
|
|
6676
6681
|
await handleCreate(args.slice(1), api, globalOpts);
|
|
6677
6682
|
break;
|
|
@@ -7055,6 +7060,37 @@ async function handleRemoveSkills(args, api, globalOpts) {
|
|
|
7055
7060
|
process.exit(1);
|
|
7056
7061
|
}
|
|
7057
7062
|
}
|
|
7063
|
+
async function handleServerInfo(args, api, globalOpts) {
|
|
7064
|
+
const pkgRef = args[0];
|
|
7065
|
+
if (!pkgRef) {
|
|
7066
|
+
console.error("用法:bfi skills package info <package-ref>");
|
|
7067
|
+
process.exit(1);
|
|
7068
|
+
}
|
|
7069
|
+
const { namespace, slug } = parseSkillRef(pkgRef, globalOpts.namespace);
|
|
7070
|
+
const json = args.includes("--json");
|
|
7071
|
+
try {
|
|
7072
|
+
const result = await api.getPackage(namespace, slug);
|
|
7073
|
+
const pkg = result.data || result;
|
|
7074
|
+
if (json) {
|
|
7075
|
+
console.log(JSON.stringify(pkg, null, 2));
|
|
7076
|
+
return;
|
|
7077
|
+
}
|
|
7078
|
+
console.log(`\n${BOLD$1}${pkg.displayName || pkg.name || slug}${RESET$3}`);
|
|
7079
|
+
console.log(`${DIM$3}${"=".repeat(48)}${RESET$3}`);
|
|
7080
|
+
console.log(` ${BOLD$1}Slug:${RESET$3} ${toCanonicalSlug(namespace, slug)}`);
|
|
7081
|
+
console.log(` ${BOLD$1}命名空间:${RESET$3} @${namespace}`);
|
|
7082
|
+
console.log(` ${BOLD$1}可见性:${RESET$3} ${pkg.visibility || "PRIVATE"}`);
|
|
7083
|
+
const skills = pkg.skills || [];
|
|
7084
|
+
if (skills.length > 0) {
|
|
7085
|
+
console.log(`\n ${BOLD$1}技能(${skills.length} 个):${RESET$3}`);
|
|
7086
|
+
for (const s of skills) console.log(` ${DIM$3}- ${s.displayName || s.slug} (${s.namespace || namespace}--${s.slug})${RESET$3}`);
|
|
7087
|
+
}
|
|
7088
|
+
console.log();
|
|
7089
|
+
} catch (error) {
|
|
7090
|
+
console.error(`${RED$1}获取包信息失败:${error.message}${RESET$3}`);
|
|
7091
|
+
process.exit(1);
|
|
7092
|
+
}
|
|
7093
|
+
}
|
|
7058
7094
|
function getOptionValue(args, flag) {
|
|
7059
7095
|
const idx = args.indexOf(flag);
|
|
7060
7096
|
return idx !== -1 && args[idx + 1] ? args[idx + 1] : void 0;
|
package/package.json
CHANGED
|
@@ -62,7 +62,10 @@ bfi skills add <来源> -y # 跳过确认
|
|
|
62
62
|
### 1.4 技能包操作
|
|
63
63
|
```bash
|
|
64
64
|
bfi skills package search # 列出所有技能包
|
|
65
|
+
bfi skills package info @ns/pkg # 查看包详情
|
|
66
|
+
|
|
65
67
|
bfi skills package search <关键词> # 按关键词搜索
|
|
68
|
+
|
|
66
69
|
bfi skills package install @ns/pkg # 安装包(含全部技能)
|
|
67
70
|
bfi skills package list # 查看已安装的包
|
|
68
71
|
bfi skills package uninstall @ns/pkg # 卸载包(含全部技能)
|