@cnbcool/cnb-api-generate 2.19.1 → 2.20.1
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/register-modules.ts +2 -12
- package/client/shortcuts.ts +14 -11
- package/package.json +1 -1
- package/quick-commands.json +1 -1
- package/skills-template/SKILL.md +1 -2
|
@@ -3,7 +3,7 @@ import { trimSummary } from './trim-summary';
|
|
|
3
3
|
import { helpData } from './help-data';
|
|
4
4
|
import { flatOptionsData } from './flat-options-data';
|
|
5
5
|
import { executeAction } from './execute-action';
|
|
6
|
-
import {
|
|
6
|
+
import { getModuleShortcuts, SKILLS_SHORTCUTS, type ShortcutDefinition } from '../shortcuts';
|
|
7
7
|
|
|
8
8
|
interface FlatOption {
|
|
9
9
|
optKey: string;
|
|
@@ -106,16 +106,6 @@ function registerToolOptions(toolCmd: Command, moduleName: string, toolName: str
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
/**
|
|
110
|
-
* 获取指定模块的快捷命令列表
|
|
111
|
-
*/
|
|
112
|
-
function getShortcutsForModule(moduleName: string): ShortcutDefinition[] {
|
|
113
|
-
if (moduleName === 'issues') return ISSUE_SHORTCUTS;
|
|
114
|
-
if (moduleName === 'pulls') return PR_SHORTCUTS;
|
|
115
|
-
if (moduleName === 'skills') return SKILLS_SHORTCUTS;
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
109
|
/**
|
|
120
110
|
* 模块下未匹配到任何子命令时的兜底处理。
|
|
121
111
|
*
|
|
@@ -192,7 +182,7 @@ export function registerModuleCommands(program: Command): void {
|
|
|
192
182
|
|
|
193
183
|
// 为快捷命令注册 Commander 子命令(别名)
|
|
194
184
|
// 复用对应真实 tool 的选项定义,但跳过 path 参数(由环境变量自动注入)
|
|
195
|
-
const shortcuts =
|
|
185
|
+
const shortcuts = getModuleShortcuts(moduleName);
|
|
196
186
|
for (const shortcut of shortcuts) {
|
|
197
187
|
// 如果快捷命令名与真实 tool 名重复,跳过(真实 tool 优先)
|
|
198
188
|
if (registeredNames.has(shortcut.shortName)) continue;
|
package/client/shortcuts.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface ShortcutDefinition {
|
|
|
24
24
|
custom?: boolean;
|
|
25
25
|
/** 显示用的中文说明 */
|
|
26
26
|
description: string;
|
|
27
|
-
/** 自动注入的 data 参数(如 close/open 的状态值、create 的 work_mode) */
|
|
27
|
+
/** 自动注入的 data 参数(如 close/open 的状态值、create-issue 的 work_mode) */
|
|
28
28
|
autoData?: Record<string, any>;
|
|
29
29
|
/** --data 的使用提示(展示用) */
|
|
30
30
|
dataTip?: string;
|
|
@@ -233,6 +233,17 @@ function buildAutoPath(moduleName: string, repoOnly: boolean): Record<string, st
|
|
|
233
233
|
return { repo, number };
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
/**
|
|
237
|
+
* 按模块名取快捷命令列表;非快捷命令模块(含 undefined)返回空数组。
|
|
238
|
+
* 本文件与 lib/register-modules.ts 共用,避免两处各留一份模块名映射。
|
|
239
|
+
*/
|
|
240
|
+
export function getModuleShortcuts(moduleName: string | undefined): ShortcutDefinition[] {
|
|
241
|
+
if (moduleName === 'issues') return ISSUE_SHORTCUTS;
|
|
242
|
+
if (moduleName === 'pulls') return PR_SHORTCUTS;
|
|
243
|
+
if (moduleName === 'skills') return SKILLS_SHORTCUTS;
|
|
244
|
+
return [];
|
|
245
|
+
}
|
|
246
|
+
|
|
236
247
|
/**
|
|
237
248
|
* 尝试将用户输入的 module + tool 解析为快捷命令
|
|
238
249
|
*
|
|
@@ -244,16 +255,8 @@ export function resolveShortcut(
|
|
|
244
255
|
): ResolvedShortcut | null {
|
|
245
256
|
if (!moduleName || !toolName) return null;
|
|
246
257
|
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
: moduleName === 'pulls'
|
|
250
|
-
? PR_SHORTCUTS
|
|
251
|
-
: moduleName === 'skills'
|
|
252
|
-
? SKILLS_SHORTCUTS
|
|
253
|
-
: null;
|
|
254
|
-
if (!shortcuts) return null;
|
|
255
|
-
|
|
256
|
-
const matched = shortcuts.find((s) => s.shortName === toolName);
|
|
258
|
+
const matched = getModuleShortcuts(moduleName)
|
|
259
|
+
.find((s) => s.shortName === toolName);
|
|
257
260
|
if (!matched) return null;
|
|
258
261
|
|
|
259
262
|
let realTool = matched.realTool;
|
package/package.json
CHANGED
package/quick-commands.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"issues": [
|
|
3
|
-
{ "shortName": "create",
|
|
3
|
+
{ "shortName": "create-issue", "realTool": "create-issue", "description": "创建 issue", "autoData": { "work_mode": true }, "hideInSkill": true, "dataTip": "--title 标题" },
|
|
4
4
|
{ "shortName": "get", "realTool": "get-issue", "description": "获取详情" },
|
|
5
5
|
{ "shortName": "list-comments", "realTool": "list-issue-comments", "description": "获取评论列表" },
|
|
6
6
|
{ "shortName": "comment", "realTool": "post-issue-comment", "description": "评论", "dataTip": "--body 内容" },
|
package/skills-template/SKILL.md
CHANGED
|
@@ -13,8 +13,7 @@ description: CNB 平台交互命令,支持代码仓库、Issue、PR、CI、制
|
|
|
13
13
|
|
|
14
14
|
- **默认摘要省流**:默认精简输出,加 `--verbose` 输出完整数据。
|
|
15
15
|
- **多行用单引号**:bash 参数为多行文本时用单引号,降低命令注入风险。
|
|
16
|
-
- **创建 issue 默认带 `--work-mode`**:`cnb issues create`
|
|
17
|
-
用真实 tool 名 `cnb issues create-issue` 时则需自己加 `--work-mode`,否则创建出来的是普通 issue。
|
|
16
|
+
- **创建 issue 默认带 `--work-mode`**:`cnb issues create-issue` 已默认注入 `work_mode: true`,不必再传;`--work-mode` 也仍可从 `--help` 看到并显式覆盖。
|
|
18
17
|
|
|
19
18
|
## issue/pr 访问说明
|
|
20
19
|
|