bfi-cli 0.1.42 → 0.1.44
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 +29 -12
- package/dist/cli.mjs +4 -2
- package/package.json +1 -1
- package/skills/skillhub-skills/SKILL.md +1 -2
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,36 @@ 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) {
|
|
65
|
+
const body = resp.body;
|
|
66
|
+
const list = body?.data || body;
|
|
67
|
+
if (Array.isArray(list)) {
|
|
68
|
+
remoteAgents = list.map(mapToAgentConfig);
|
|
69
|
+
newMaxUpdatedAt = parseLastModifiedHeader(resp.headers);
|
|
70
|
+
shouldSaveCache = remoteAgents.length > 0;
|
|
71
|
+
}
|
|
58
72
|
}
|
|
59
|
-
} catch {
|
|
73
|
+
} catch {
|
|
74
|
+
if (cache) remoteAgents = cache.agents.map(mapToAgentConfig);
|
|
75
|
+
}
|
|
76
|
+
if (shouldSaveCache && remoteAgents) saveCache(remoteAgents, newMaxUpdatedAt);
|
|
60
77
|
if (remoteAgents) for (const agent of remoteAgents) merged.set(agent.name, agent);
|
|
61
78
|
}
|
|
62
79
|
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"));
|
package/package.json
CHANGED
|
@@ -62,10 +62,9 @@ bfi skills add <来源> -y # 跳过确认
|
|
|
62
62
|
### 1.4 技能包操作
|
|
63
63
|
```bash
|
|
64
64
|
bfi skills package search # 列出所有技能包
|
|
65
|
-
|
|
65
|
+
bfi skills package info @ns/pkg # 查看包详情
|
|
66
66
|
|
|
67
67
|
bfi skills package search <关键词> # 按关键词搜索
|
|
68
|
-
bfi skills package info @ns/pkg # 查看包详情
|
|
69
68
|
|
|
70
69
|
bfi skills package install @ns/pkg # 安装包(含全部技能)
|
|
71
70
|
bfi skills package list # 查看已安装的包
|