@cnbcool/cnb-api-generate 2.14.1 → 2.14.2
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/client/lib/skills-list.ts +8 -13
- package/package.json +1 -1
|
@@ -90,22 +90,24 @@ export interface SkillsListOptions {
|
|
|
90
90
|
global?: boolean;
|
|
91
91
|
/** 仅列出项目 scope(对应 skills list -p) */
|
|
92
92
|
project?: boolean;
|
|
93
|
-
/** 按 agent
|
|
93
|
+
/** 按 agent 过滤:透传 -a 给底层 skills 命令(值会归一化为小写 key) */
|
|
94
94
|
agent?: string;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* 运行原始 `skills list [scope] --json` 并返回解析后的 JSON 数组。
|
|
98
|
+
* 运行原始 `skills list [scope] [--agent] --json` 并返回解析后的 JSON 数组。
|
|
99
99
|
*
|
|
100
|
-
*
|
|
100
|
+
* 参数规则与 `skills list` 一致:
|
|
101
101
|
* - 指定 `-g` → `-g`
|
|
102
102
|
* - 指定 `-p` → `-p`
|
|
103
103
|
* - 都不指定 → 不传 scope(由 skills 默认:项目优先,否则全局)
|
|
104
|
+
* - 指定 `-a/--agent` → 归一化为小写后透传(底层按 agent 目录 key 匹配)
|
|
104
105
|
*/
|
|
105
106
|
export function runSkillsListJson(opts: SkillsListOptions): SkillEntry[] {
|
|
106
107
|
const args = ['list'];
|
|
107
108
|
if (opts.global) args.push('-g');
|
|
108
109
|
if (opts.project) args.push('-p');
|
|
110
|
+
if (opts.agent) args.push('-a', opts.agent.toLowerCase());
|
|
109
111
|
args.push('--json');
|
|
110
112
|
|
|
111
113
|
let stdout: string;
|
|
@@ -132,24 +134,17 @@ export function runSkillsListJson(opts: SkillsListOptions): SkillEntry[] {
|
|
|
132
134
|
|
|
133
135
|
/**
|
|
134
136
|
* 对 `skills list --json` 输出做后处理:
|
|
135
|
-
*
|
|
136
|
-
* 2. 按 agent 过滤(若指定 -a)。
|
|
137
|
+
* 仅从 SKILL.md frontmatter 回填缺失的 description。
|
|
137
138
|
*
|
|
139
|
+
* agent 过滤已下沉到底层 `skills list -a`(大小写归一化后透传),此处不再过滤。
|
|
138
140
|
* 返回的是全新数组/对象,不修改原始输入。
|
|
139
141
|
*/
|
|
140
142
|
export function decorateSkillEntries(
|
|
141
143
|
entries: SkillEntry[],
|
|
142
|
-
opts: SkillsListOptions,
|
|
143
144
|
): SkillEntry[] {
|
|
144
145
|
const result: SkillEntry[] = [];
|
|
145
146
|
|
|
146
147
|
for (const entry of entries) {
|
|
147
|
-
// agent 过滤:保留 agents 中包含指定 agent 的条目
|
|
148
|
-
if (opts.agent) {
|
|
149
|
-
const agents = Array.isArray(entry.agents) ? entry.agents : [];
|
|
150
|
-
if (!agents.includes(opts.agent)) continue;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
148
|
const decorated: SkillEntry = { ...entry };
|
|
154
149
|
|
|
155
150
|
// 回填 description:缺失或为空时从 path 下的 SKILL.md frontmatter 解析
|
|
@@ -171,7 +166,7 @@ export function decorateSkillEntries(
|
|
|
171
166
|
*/
|
|
172
167
|
export function skillsList(opts: SkillsListOptions & { json?: boolean }): string {
|
|
173
168
|
const raw = runSkillsListJson(opts);
|
|
174
|
-
const decorated = decorateSkillEntries(raw
|
|
169
|
+
const decorated = decorateSkillEntries(raw);
|
|
175
170
|
|
|
176
171
|
// 与 `skills list --json` 保持一致的 JSON 输出(默认即 JSON,字段结构不变)
|
|
177
172
|
return JSON.stringify(decorated, null, 2);
|