bfi-cli 0.1.38 → 0.1.40
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 +76 -36
- package/package.json +1 -1
- package/skills/skillhub-skills/SKILL.md +10 -4
package/dist/cli.mjs
CHANGED
|
@@ -4914,7 +4914,17 @@ async function resolveUpdateScope(options) {
|
|
|
4914
4914
|
function matchesSkillFilter(name, filter) {
|
|
4915
4915
|
if (!filter || filter.length === 0) return true;
|
|
4916
4916
|
const lower = name.toLowerCase();
|
|
4917
|
-
return filter.some((f) =>
|
|
4917
|
+
return filter.some((f) => {
|
|
4918
|
+
const fl = f.toLowerCase();
|
|
4919
|
+
if (fl === lower) return true;
|
|
4920
|
+
if (fl.startsWith("@")) {
|
|
4921
|
+
const slashIdx = fl.lastIndexOf("/");
|
|
4922
|
+
if (slashIdx > 0 && fl.slice(slashIdx + 1) === lower) return true;
|
|
4923
|
+
}
|
|
4924
|
+
const dashIdx = fl.indexOf("--");
|
|
4925
|
+
if (dashIdx > 0 && fl.slice(dashIdx + 2) === lower) return true;
|
|
4926
|
+
return false;
|
|
4927
|
+
});
|
|
4918
4928
|
}
|
|
4919
4929
|
function getSkipReason(entry) {
|
|
4920
4930
|
if (entry.sourceType === "local") return "本地路径";
|
|
@@ -6660,7 +6670,7 @@ async function runPackage(args, globalOpts) {
|
|
|
6660
6670
|
await handleUpdate(args.slice(1), api, globalOpts);
|
|
6661
6671
|
break;
|
|
6662
6672
|
case "search":
|
|
6663
|
-
await handleSearch(args.slice(1), api);
|
|
6673
|
+
await handleSearch(args.slice(1), api, globalOpts);
|
|
6664
6674
|
break;
|
|
6665
6675
|
case "create":
|
|
6666
6676
|
await handleCreate(args.slice(1), api, globalOpts);
|
|
@@ -6868,40 +6878,64 @@ async function handleUpdate(args, api, globalOpts) {
|
|
|
6868
6878
|
}
|
|
6869
6879
|
console.log(`${GREEN$2}✓ 包更新完成${RESET$3}`);
|
|
6870
6880
|
}
|
|
6871
|
-
async function handleSearch(args, api) {
|
|
6872
|
-
const query = args.filter((a) => !a.startsWith("--")).join(" ");
|
|
6881
|
+
async function handleSearch(args, api, globalOpts) {
|
|
6882
|
+
const query = args.filter((a) => !a.startsWith("--")).join(" ") || void 0;
|
|
6873
6883
|
const json = args.includes("--json");
|
|
6874
|
-
if (
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
if (
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
}))
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
}
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6884
|
+
if (query) {
|
|
6885
|
+
const skills = (await api.searchSkills(query, { limit: 20 })).results || [];
|
|
6886
|
+
const namespaces = /* @__PURE__ */ new Map();
|
|
6887
|
+
for (const s of skills) {
|
|
6888
|
+
const { namespace } = parseSkillRef(s.slug, "global");
|
|
6889
|
+
if (!namespaces.has(namespace)) namespaces.set(namespace, []);
|
|
6890
|
+
namespaces.get(namespace).push(s);
|
|
6891
|
+
}
|
|
6892
|
+
if (json) {
|
|
6893
|
+
console.log(JSON.stringify({
|
|
6894
|
+
query,
|
|
6895
|
+
results: Array.from(namespaces.entries())
|
|
6896
|
+
}, null, 2));
|
|
6897
|
+
return;
|
|
6898
|
+
}
|
|
6899
|
+
console.log(`\n${BOLD$1}找到 ${skills.length} 个相关技能(按命名空间分组):${RESET$3}\n`);
|
|
6900
|
+
for (const [ns, sk] of namespaces) {
|
|
6901
|
+
console.log(` ${BOLD$1}@${ns}${RESET$3}(${sk.length} 个技能)`);
|
|
6902
|
+
for (const s of sk.slice(0, 5)) console.log(` ${DIM$3}- ${s.displayName || s.name} (${s.slug})${RESET$3}`);
|
|
6903
|
+
if (sk.length > 5) console.log(` ${DIM$3}... 还有 ${sk.length - 5} 个${RESET$3}`);
|
|
6904
|
+
console.log();
|
|
6905
|
+
}
|
|
6906
|
+
} else {
|
|
6907
|
+
const nsList = [];
|
|
6908
|
+
try {
|
|
6909
|
+
const whoami = await api.whoami();
|
|
6910
|
+
for (const ns of whoami.namespaces || []) nsList.push(ns.slug);
|
|
6911
|
+
} catch {
|
|
6912
|
+
nsList.push("global");
|
|
6913
|
+
}
|
|
6914
|
+
const allPackages = [];
|
|
6915
|
+
for (const ns of nsList) try {
|
|
6916
|
+
const result = await api.listPackages(ns);
|
|
6917
|
+
const pkgs = result.packages || result.data || [];
|
|
6918
|
+
allPackages.push(...pkgs.map((p) => ({
|
|
6919
|
+
...p,
|
|
6920
|
+
_namespace: ns
|
|
6921
|
+
})));
|
|
6922
|
+
} catch {}
|
|
6923
|
+
if (json) {
|
|
6924
|
+
console.log(JSON.stringify(allPackages, null, 2));
|
|
6925
|
+
return;
|
|
6926
|
+
}
|
|
6927
|
+
if (allPackages.length === 0) {
|
|
6928
|
+
console.log("未找到任何技能包。");
|
|
6929
|
+
return;
|
|
6930
|
+
}
|
|
6931
|
+
console.log(`\n${BOLD$1}所有技能包(${allPackages.length} 个):${RESET$3}\n`);
|
|
6932
|
+
for (const pkg of allPackages) {
|
|
6933
|
+
console.log(` ${BOLD$1}${pkg.displayName || pkg.name || pkg.slug}${RESET$3}`);
|
|
6934
|
+
console.log(` ${DIM$3}@${pkg._namespace}/${pkg.slug} | 可见性:${pkg.visibility || "PRIVATE"} | 技能数:${pkg.skillCount || "?"}${RESET$3}`);
|
|
6935
|
+
if (pkg.description) console.log(` ${DIM$3}${pkg.description.slice(0, 80)}${RESET$3}`);
|
|
6936
|
+
console.log();
|
|
6937
|
+
}
|
|
6903
6938
|
}
|
|
6904
|
-
console.log(`${DIM$3}使用 bfi skills package create <slug> --namespace <ns> 创建包,然后 add-skills 添加这些技能。${RESET$3}`);
|
|
6905
6939
|
}
|
|
6906
6940
|
async function handleCreate(args, api, globalOpts) {
|
|
6907
6941
|
const slug = args[0];
|
|
@@ -7061,8 +7095,14 @@ async function runInstall(args, globalOpts) {
|
|
|
7061
7095
|
slug: name
|
|
7062
7096
|
};
|
|
7063
7097
|
} catch {}
|
|
7064
|
-
const
|
|
7065
|
-
|
|
7098
|
+
const filterArg = args[0];
|
|
7099
|
+
let skillEntries = Object.entries(lock.skills);
|
|
7100
|
+
let packageEntries = Object.entries(lock.packages);
|
|
7101
|
+
if (filterArg) {
|
|
7102
|
+
const slug = filterArg.replace(/^@[\w-]+\//, "").replace(/^[\w-]+--/, "");
|
|
7103
|
+
skillEntries = skillEntries.filter(([name]) => name === slug || name.includes(slug));
|
|
7104
|
+
packageEntries = packageEntries.filter(([ref]) => ref.includes(slug));
|
|
7105
|
+
}
|
|
7066
7106
|
if (skillEntries.length === 0 && packageEntries.length === 0) {
|
|
7067
7107
|
console.log(`${DIM$1}锁文件 (.bfi/lock.json) 中未找到技能或包。${RESET$1}`);
|
|
7068
7108
|
console.log(`${DIM$1}请先运行 'bfi skills add <source>' 安装技能。${RESET$1}`);
|
package/package.json
CHANGED
|
@@ -39,10 +39,11 @@ npm install -g bfi-cli
|
|
|
39
39
|
|
|
40
40
|
## 场景 1:使用技能
|
|
41
41
|
|
|
42
|
-
### 1.1
|
|
42
|
+
### 1.1 搜索技能
|
|
43
43
|
```bash
|
|
44
44
|
bfi skills search <关键词>
|
|
45
45
|
bfi skills search <关键词> --marketplace # skills.sh 公开市场
|
|
46
|
+
bfi skills search <关键词> --all # 所有技能
|
|
46
47
|
```
|
|
47
48
|
|
|
48
49
|
### 1.2 查看详情
|
|
@@ -58,12 +59,17 @@ bfi skills add github:owner/repo # GitHub
|
|
|
58
59
|
bfi skills add <来源> -y # 跳过确认
|
|
59
60
|
```
|
|
60
61
|
|
|
61
|
-
### 1.4
|
|
62
|
+
### 1.4 技能包操作
|
|
62
63
|
```bash
|
|
63
|
-
bfi skills package
|
|
64
|
+
bfi skills package search # 列出所有技能包
|
|
65
|
+
bfi skills package search <关键词> # 按关键词搜索
|
|
66
|
+
bfi skills package install @ns/pkg # 安装包(含全部技能)
|
|
67
|
+
bfi skills package list # 查看已安装的包
|
|
68
|
+
bfi skills package uninstall @ns/pkg # 卸载包(含全部技能)
|
|
69
|
+
bfi skills package update @ns/pkg # 更新包
|
|
64
70
|
```
|
|
65
71
|
|
|
66
|
-
### 1.5
|
|
72
|
+
### 1.5 查看已安装技能
|
|
67
73
|
```bash
|
|
68
74
|
bfi skills list
|
|
69
75
|
bfi skills ls -g # 全局
|