@cnbcool/cnb-api-generate 2.11.6 → 2.11.8
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.
|
@@ -18,7 +18,8 @@ function renderQuickCommandsMarkdown(byModule, cliCmd) {
|
|
|
18
18
|
return '';
|
|
19
19
|
const lines = [];
|
|
20
20
|
for (const moduleName of moduleNames) {
|
|
21
|
-
|
|
21
|
+
// hideInSkill 的命令仍正常注册可执行,仅不在 SKILL.md 中展示
|
|
22
|
+
const items = byModule[moduleName].filter((cmd) => !cmd.hideInSkill);
|
|
22
23
|
if (!items.length)
|
|
23
24
|
continue;
|
|
24
25
|
lines.push(`${moduleName}:`);
|
|
@@ -42,21 +42,31 @@ export function buildToolParams(formattedParams: {
|
|
|
42
42
|
|
|
43
43
|
// 2) 按形态构造第 1 个参数
|
|
44
44
|
let firstParam: Record<string, any> | string | null = null;
|
|
45
|
+
let hasFirstParam = false;
|
|
45
46
|
if (isObjectShape) {
|
|
46
|
-
// 对象形态:合并 path 与运行期 query
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
// 对象形态:合并 path 与运行期 query。
|
|
48
|
+
// 即便 path 与 query 都为空,也必须传入 {}——生成代码的第 1 形参是无默认值的解构
|
|
49
|
+
// (如 `async function _default({ ...query }, ...)`),不给会触发
|
|
50
|
+
// `Cannot destructure 'undefined' as it is undefined`。
|
|
51
|
+
// 典型场景:`workspace/list-workspaces`——无 path、query 全部可选,用户不传任何参数。
|
|
52
|
+
firstParam = { ...(path ?? {}), ...(query ?? {}) };
|
|
53
|
+
hasFirstParam = true;
|
|
50
54
|
} else if (path) {
|
|
51
55
|
// 标量形态:仅当 path 恰好 1 个字段时拆出值;其它情形(含异常的多字段)不构造,
|
|
52
56
|
// 避免悄悄把不该传的字段塞给 toolFunction
|
|
53
57
|
const keys = Object.keys(path);
|
|
54
|
-
if (keys.length === 1)
|
|
58
|
+
if (keys.length === 1) {
|
|
59
|
+
firstParam = path[keys[0]];
|
|
60
|
+
hasFirstParam = true;
|
|
61
|
+
}
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
// 3)
|
|
64
|
+
// 3) 组装最终位置参数列表
|
|
65
|
+
// - 对象形态:始终占位(即便为空对象),保证解构安全
|
|
66
|
+
// - 标量形态:仅当拿到实际值时 push
|
|
67
|
+
// - data:真值才 push(与历史行为一致)
|
|
58
68
|
const toolsParam: any[] = [];
|
|
59
|
-
if (
|
|
69
|
+
if (hasFirstParam) toolsParam.push(firstParam);
|
|
60
70
|
if (data) toolsParam.push(data);
|
|
61
71
|
return toolsParam;
|
|
62
72
|
}
|
package/client/utils/upload.ts
CHANGED
|
@@ -124,7 +124,6 @@ interface UploadErrorData {
|
|
|
124
124
|
interface IssueUploadData {
|
|
125
125
|
asset_link?: string;
|
|
126
126
|
name: string;
|
|
127
|
-
path?: string;
|
|
128
127
|
size: number;
|
|
129
128
|
asset_group_id?: string;
|
|
130
129
|
}
|
|
@@ -132,7 +131,6 @@ interface IssueUploadData {
|
|
|
132
131
|
/** Pull 上传成功时的 data */
|
|
133
132
|
interface PullUploadData {
|
|
134
133
|
name: string;
|
|
135
|
-
path?: string;
|
|
136
134
|
size: number;
|
|
137
135
|
token?: string;
|
|
138
136
|
}
|
|
@@ -286,7 +284,6 @@ export async function handleIssueCreateUpload(
|
|
|
286
284
|
data: {
|
|
287
285
|
asset_link: firstEntry?.asset_link,
|
|
288
286
|
name: firstEntry?.name || fileName,
|
|
289
|
-
path: firstEntry?.path,
|
|
290
287
|
size: fileSize,
|
|
291
288
|
asset_group_id: groupData?.asset_group_id,
|
|
292
289
|
},
|
|
@@ -343,7 +340,6 @@ export async function handleUpload(
|
|
|
343
340
|
successData = {
|
|
344
341
|
asset_link: data?.asset_link,
|
|
345
342
|
name: data?.name || fileName,
|
|
346
|
-
path: data?.path,
|
|
347
343
|
size: fileSize,
|
|
348
344
|
};
|
|
349
345
|
} else {
|
|
@@ -355,7 +351,6 @@ export async function handleUpload(
|
|
|
355
351
|
if (!uploadUrl) return apiResponse as unknown as UploadResult;
|
|
356
352
|
successData = {
|
|
357
353
|
name: data?.assets?.name || fileName,
|
|
358
|
-
path: data?.assets?.path,
|
|
359
354
|
size: fileSize,
|
|
360
355
|
token: data?.token,
|
|
361
356
|
};
|
package/package.json
CHANGED
package/quick-commands.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
{ "shortName": "add-labels", "realTool": "post-issue-labels", "description": "添加标签", "dataTip": "--labels bug --labels feature" },
|
|
10
10
|
{ "shortName": "list-assignees", "realTool": "list-issue-assignees", "description": "查看处理人" },
|
|
11
11
|
{ "shortName": "add-assignees", "realTool": "post-issue-assignees", "description": "添加处理人", "dataTip": "--assignees username" },
|
|
12
|
-
{ "shortName": "upload-file", "realTool": "post-issue-comment-file-asset-upload-url", "description": "上传 issue 评论文件", "upload": true, "kind": "file", "dataTip": "--file 文件路径" },
|
|
13
|
-
{ "shortName": "upload-image", "realTool": "post-issue-comment-image-asset-upload-url","description": "上传 issue 评论图片", "upload": true, "kind": "image", "dataTip": "--file 图片路径" },
|
|
12
|
+
{ "shortName": "upload-file", "realTool": "post-issue-comment-file-asset-upload-url", "description": "上传 issue 评论文件", "upload": true, "kind": "file", "hideInSkill": true, "dataTip": "--file 文件路径" },
|
|
13
|
+
{ "shortName": "upload-image", "realTool": "post-issue-comment-image-asset-upload-url","description": "上传 issue 评论图片", "upload": true, "kind": "image", "hideInSkill": true, "dataTip": "--file 图片路径" },
|
|
14
14
|
{ "shortName": "create-upload-file", "realTool": "post-asset-group", "description": "创建 issue 时上传文件", "upload": true, "kind": "file", "dataTip": "--file 文件路径" },
|
|
15
15
|
{ "shortName": "create-upload-image", "realTool": "post-asset-group", "description": "创建 issue 时上传图片", "upload": true, "kind": "image", "dataTip": "--file 图片路径" },
|
|
16
16
|
{ "shortName": "get-imgs", "realTool": "get-issue-imgs", "description": "获取 issue 图片", "repoOnly": true, "dataTip": "--img-path 图片路径" },
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
{ "shortName": "check-status", "realTool": "list-pull-commit-statuses", "description": "查看 CI 状态" },
|
|
28
28
|
{ "shortName": "list-reviews", "realTool": "list-pull-reviews", "description": "查看评审列表" },
|
|
29
29
|
{ "shortName": "list-assignees", "realTool": "list-pull-assignees", "description": "查看处理人" },
|
|
30
|
-
{ "shortName": "upload-file", "realTool": "upload-files", "description": "上传文件", "repoOnly": true, "upload": true, "dataTip": "--file 文件路径" },
|
|
31
|
-
{ "shortName": "upload-image", "realTool": "upload-imgs", "description": "上传图片", "repoOnly": true, "upload": true, "dataTip": "--file 图片路径" },
|
|
30
|
+
{ "shortName": "upload-file", "realTool": "upload-files", "description": "上传文件", "repoOnly": true, "upload": true, "hideInSkill": true, "dataTip": "--file 文件路径" },
|
|
31
|
+
{ "shortName": "upload-image", "realTool": "upload-imgs", "description": "上传图片", "repoOnly": true, "upload": true, "hideInSkill": true, "dataTip": "--file 图片路径" },
|
|
32
32
|
{ "shortName": "get-ci-logs", "realTool": "__get-ci-logs__", "description": "获取 CI 失败日志", "repoOnly": true, "custom": true, "dataTip": "--sn 构建号(可选)" },
|
|
33
33
|
{ "shortName": "get-ci-timing", "realTool": "__get-ci-timing__", "description": "分析 CI 耗时瓶颈", "repoOnly": true, "custom": true, "dataTip": "--sn 构建号(可选)" },
|
|
34
34
|
{ "shortName": "get-imgs", "realTool": "get-pr-imgs", "description": "获取 PR 图片", "repoOnly": true, "dataTip": "--img-path 图片路径" },
|
package/skills-template/SKILL.md
CHANGED
|
@@ -12,6 +12,7 @@ description: CNB 平台交互命令,支持代码仓库、Issue、PR、CI、制
|
|
|
12
12
|
<$QUICK_COMMANDS$>
|
|
13
13
|
|
|
14
14
|
注意事项:
|
|
15
|
+
|
|
15
16
|
- **参数自动识别**:快捷命令中的 Issue/PR 编号会自动从环境变量识别,无需额外传递。
|
|
16
17
|
- **默认仅需摘要**:默认会精简响应输出结果,添加 `--verbose` 输出完整数据。
|
|
17
18
|
- **单引号传参**:当 bash 的参数为多行文本时,使用单引号可减少防止命令注入攻击。
|
|
@@ -21,6 +22,7 @@ description: CNB 平台交互命令,支持代码仓库、Issue、PR、CI、制
|
|
|
21
22
|
## 常用链接
|
|
22
23
|
|
|
23
24
|
在生成链接时请遵循下面的结构:
|
|
25
|
+
|
|
24
26
|
- Issue: `<host>/<slug>/-/issues/<number>`
|
|
25
27
|
- PR: `<host>/<slug>/-/pulls/<number>`
|
|
26
28
|
|