bfi-cli 0.1.39 → 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 CHANGED
@@ -6670,7 +6670,7 @@ async function runPackage(args, globalOpts) {
6670
6670
  await handleUpdate(args.slice(1), api, globalOpts);
6671
6671
  break;
6672
6672
  case "search":
6673
- await handleSearch(args.slice(1), api);
6673
+ await handleSearch(args.slice(1), api, globalOpts);
6674
6674
  break;
6675
6675
  case "create":
6676
6676
  await handleCreate(args.slice(1), api, globalOpts);
@@ -6878,40 +6878,64 @@ async function handleUpdate(args, api, globalOpts) {
6878
6878
  }
6879
6879
  console.log(`${GREEN$2}✓ 包更新完成${RESET$3}`);
6880
6880
  }
6881
- async function handleSearch(args, api) {
6882
- 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;
6883
6883
  const json = args.includes("--json");
6884
- if (!query) {
6885
- console.error("用法:bfi skills package search <query>");
6886
- process.exit(1);
6887
- }
6888
- const skills = (await api.searchSkills(query, { limit: 20 })).results || [];
6889
- const namespaces = /* @__PURE__ */ new Map();
6890
- for (const s of skills) {
6891
- const { namespace } = parseSkillRef(s.slug, "global");
6892
- if (!namespaces.has(namespace)) namespaces.set(namespace, []);
6893
- namespaces.get(namespace).push(s);
6894
- }
6895
- if (json) {
6896
- const groups = Array.from(namespaces.entries()).map(([ns, sk]) => ({
6897
- namespace: ns,
6898
- skillCount: sk.length,
6899
- skills: sk.map((s) => ({
6900
- name: s.displayName || s.name,
6901
- slug: s.slug
6902
- }))
6903
- }));
6904
- console.log(JSON.stringify(groups, null, 2));
6905
- return;
6906
- }
6907
- console.log(`\n${BOLD$1}找到 ${skills.length} 个相关技能(按命名空间分组):${RESET$3}\n`);
6908
- for (const [ns, sk] of namespaces) {
6909
- console.log(` ${BOLD$1}@${ns}${RESET$3}(${sk.length} 个技能)`);
6910
- for (const s of sk.slice(0, 5)) console.log(` ${DIM$3}- ${s.displayName || s.name} (${s.slug})${RESET$3}`);
6911
- if (sk.length > 5) console.log(` ${DIM$3}... 还有 ${sk.length - 5} 个${RESET$3}`);
6912
- console.log();
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
+ }
6913
6938
  }
6914
- console.log(`${DIM$3}使用 bfi skills package create <slug> --namespace <ns> 创建包,然后 add-skills 添加这些技能。${RESET$3}`);
6915
6939
  }
6916
6940
  async function handleCreate(args, api, globalOpts) {
6917
6941
  const slug = args[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bfi-cli",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "description": "用友大业财BFI统一命令行工具,支持技能,技能包,元数据,UI元数据等",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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 install @namespace/pkg
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 # 全局