@cnbcool/cnb-api-generate 2.11.3 → 2.11.5

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.
@@ -99,7 +99,6 @@ interface IssueAssetUploadURLResponseData {
99
99
  path?: string;
100
100
  asset_link?: string;
101
101
  upload_url?: string;
102
- download_url?: string;
103
102
  }
104
103
 
105
104
  /** Pull 上传 API 响应 */
@@ -124,15 +123,19 @@ interface UploadErrorData {
124
123
  /** Issue 上传成功时的 data(asset_group_id 仅在创建 issue 流程下返回) */
125
124
  interface IssueUploadData {
126
125
  asset_link?: string;
126
+ /** asset_link 的别名,语义更直观,方便 AI 理解这是一个可直接插入评论的 markdown 链接 */
127
+ markdown?: string;
127
128
  name: string;
128
129
  path?: string;
129
130
  size: number;
130
131
  asset_group_id?: string;
131
- download_url?: string;
132
132
  }
133
133
 
134
134
  /** Pull 上传成功时的 data */
135
135
  interface PullUploadData {
136
+ /** asset_link 的别名,语义更直观,方便 AI 理解这是一个可直接插入评论的 markdown 链接 */
137
+ asset_link?: string;
138
+ markdown?: string;
136
139
  name: string;
137
140
  path?: string;
138
141
  size: number;
@@ -283,15 +286,17 @@ export async function handleIssueCreateUpload(
283
286
  if (putErr) return putErr;
284
287
 
285
288
  // 3. 返回结果(asset_link 拼入创建 issue 的 body,asset_group_id 备用)
289
+ // markdown 作为 asset_link 的别名,方便 AI 理解使用
290
+ const assetLink = firstEntry?.asset_link;
286
291
  return {
287
292
  status: 200,
288
293
  data: {
289
- asset_link: firstEntry?.asset_link,
294
+ asset_link: assetLink,
295
+ markdown: assetLink,
290
296
  name: firstEntry?.name || fileName,
291
297
  path: firstEntry?.path,
292
298
  size: fileSize,
293
299
  asset_group_id: groupData?.asset_group_id,
294
- download_url: firstEntry?.download_url,
295
300
  },
296
301
  };
297
302
  }
@@ -343,12 +348,13 @@ export async function handleUpload(
343
348
  const data = apiResponse?.data as IssueAssetUploadURLResponseData | undefined;
344
349
  uploadUrl = data?.upload_url;
345
350
  if (!uploadUrl) return apiResponse as unknown as UploadResult;
351
+ const assetLink = data?.asset_link;
346
352
  successData = {
347
- asset_link: data?.asset_link,
353
+ asset_link: assetLink,
354
+ markdown: assetLink,
348
355
  name: data?.name || fileName,
349
356
  path: data?.path,
350
357
  size: fileSize,
351
- download_url: data?.download_url,
352
358
  };
353
359
  } else {
354
360
  // Pull:沿用 upload-files / upload-imgs 一步走接口
@@ -357,9 +363,19 @@ export async function handleUpload(
357
363
  const data = apiResponse?.data as PullUploadResponseData | undefined;
358
364
  uploadUrl = data?.upload_url;
359
365
  if (!uploadUrl) return apiResponse as unknown as UploadResult;
366
+ // markdown 作为 asset_link 的别名,方便 AI 理解使用
367
+ // Pull 上传不返回 asset_link,由 assets.path + name 构造 markdown 链接
368
+ const assetPath = data?.assets?.path;
369
+ const assetName = data?.assets?.name || fileName;
370
+ const isImage = shortcut.kind === 'image';
371
+ const assetLink = assetPath
372
+ ? `${isImage ? '!' : ''}[${assetName}](${assetPath})`
373
+ : undefined;
360
374
  successData = {
361
- name: data?.assets?.name || fileName,
362
- path: data?.assets?.path,
375
+ asset_link: assetLink,
376
+ markdown: assetLink,
377
+ name: assetName,
378
+ path: assetPath,
363
379
  size: fileSize,
364
380
  token: data?.token,
365
381
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cnbcool/cnb-api-generate",
3
- "version": "2.11.3",
3
+ "version": "2.11.5",
4
4
  "main": "./built/index.js",
5
5
  "module": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -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, "kind": "file", "dataTip": "--file 文件路径" },
31
+ { "shortName": "upload-image", "realTool": "upload-imgs", "description": "上传图片", "repoOnly": true, "upload": true, "kind": "image", "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 图片路径" },