@kevisual/cnb 0.0.55 → 0.0.57
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/agent/routes/call/index.ts +5 -4
- package/agent/routes/cnb-env/env.ts +3 -2
- package/agent/routes/cnb-env/vscode.ts +9 -8
- package/agent/routes/index.ts +1 -0
- package/agent/routes/issues/comments.ts +18 -17
- package/agent/routes/issues/issue.ts +11 -10
- package/agent/routes/issues/list.ts +11 -10
- package/agent/routes/knowledge/ai.ts +6 -5
- package/agent/routes/labels/issue-label.ts +17 -16
- package/agent/routes/package/index.ts +2 -0
- package/agent/routes/package/package.ts +255 -0
- package/agent/routes/package/registry.ts +107 -0
- package/agent/routes/repo/list.ts +6 -5
- package/agent/routes/repo/repo-label.ts +17 -16
- package/agent/routes/repo/repo.ts +18 -17
- package/agent/routes/workspace/build.ts +7 -6
- package/agent/routes/workspace/index.ts +18 -17
- package/agent/routes/workspace/keep.ts +5 -5
- package/agent/routes/workspace/rerun.ts +60 -0
- package/agent/routes/workspace/skills.ts +2 -2
- package/dist/cli.js +927 -197
- package/dist/npc.js +981 -205
- package/dist/opencode.js +911 -203
- package/dist/routes.d.ts +235 -3
- package/dist/routes.js +903 -195
- package/package.json +1 -1
- package/src/index.ts +15 -1
- package/src/issue/index.ts +5 -2
- package/src/knowledge/index.ts +92 -5
- package/src/package/index.ts +2 -0
- package/src/package/package.ts +134 -0
- package/src/package/registry.ts +145 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router'
|
|
2
|
+
import { z } from 'zod'
|
|
2
3
|
import { app } from '../../app.ts'
|
|
3
4
|
|
|
4
5
|
// "调用 path: cnb key: list-repos"
|
|
@@ -14,9 +15,9 @@ app.route({
|
|
|
14
15
|
title: '调用app应用',
|
|
15
16
|
summary: '调用router的应用, 参数path, key, payload',
|
|
16
17
|
args: {
|
|
17
|
-
path:
|
|
18
|
-
key:
|
|
19
|
-
payload:
|
|
18
|
+
path: z.string().describe('应用路径,例如 cnb'),
|
|
19
|
+
key: z.string().optional().describe('应用key,例如 list-repos'),
|
|
20
|
+
payload: z.object({}).optional().describe('调用参数'),
|
|
20
21
|
}
|
|
21
22
|
})
|
|
22
23
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
|
|
4
5
|
// 设置 CNB_COOKIE环境变量和获取环境变量,用于界面操作定制模块功能
|
|
@@ -14,7 +15,7 @@ app.route({
|
|
|
14
15
|
title: '设置当前cnb工作空间的cookie环境变量',
|
|
15
16
|
summary: '设置当前cnb工作空间的cookie环境变量,用于界面操作定制模块功能,例子:CNBSESSION=xxxx;csrfkey=2222xxxx;',
|
|
16
17
|
args: {
|
|
17
|
-
cookie:
|
|
18
|
+
cookie: z.string().describe('cnb的cookie值'),
|
|
18
19
|
}
|
|
19
20
|
})
|
|
20
21
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, notCNBCheck } from '../../app.ts';
|
|
3
4
|
|
|
4
5
|
import { CNB_ENV } from "@/common/cnb-env.ts";
|
|
@@ -19,7 +20,7 @@ app.route({
|
|
|
19
20
|
title: '获取当前cnb工作空间的port代理uri',
|
|
20
21
|
summary: '获取当前cnb工作空间的port代理uri,用于端口转发',
|
|
21
22
|
args: {
|
|
22
|
-
port:
|
|
23
|
+
port: z.number().optional().describe('端口号,默认为51515'),
|
|
23
24
|
}
|
|
24
25
|
})
|
|
25
26
|
}
|
|
@@ -49,12 +50,12 @@ app.route({
|
|
|
49
50
|
title: '获取当前cnb工作空间的编辑器访问地址',
|
|
50
51
|
summary: '获取当前cnb工作空间的vscode代理uri,用于在浏览器中访问vscode,包含多种访问方式,如web、vscode、codebuddy、cursor、ssh',
|
|
51
52
|
args: {
|
|
52
|
-
web:
|
|
53
|
-
vscode:
|
|
54
|
-
codebuddy:
|
|
55
|
-
cursor:
|
|
56
|
-
// trae:
|
|
57
|
-
ssh:
|
|
53
|
+
web: z.boolean().optional().describe('是否获取vscode web的访问uri,默认为false'),
|
|
54
|
+
vscode: z.boolean().optional().describe('是否获取vscode的代理uri,默认为true'),
|
|
55
|
+
codebuddy: z.boolean().optional().describe('是否获取codebuddy的代理uri,默认为false'),
|
|
56
|
+
cursor: z.boolean().optional().describe('是否获取cursor的代理uri,默认为false'),
|
|
57
|
+
// trae: z.boolean().optional().describe('是否获取trae的代理uri,默认为false'),
|
|
58
|
+
ssh: z.boolean().optional().describe('是否获取vscode remote ssh的连接字符串,默认为false'),
|
|
58
59
|
}
|
|
59
60
|
})
|
|
60
61
|
}
|
package/agent/routes/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
import { useKey } from '@kevisual/context';
|
|
4
5
|
|
|
@@ -14,10 +15,10 @@ app.route({
|
|
|
14
15
|
skill: 'list-issue-comments',
|
|
15
16
|
title: '查询 Issue 评论列表',
|
|
16
17
|
args: {
|
|
17
|
-
repo:
|
|
18
|
-
issueNumber:
|
|
19
|
-
page:
|
|
20
|
-
page_size:
|
|
18
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
19
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
20
|
+
page: z.number().optional().describe('分页页码,默认: 1'),
|
|
21
|
+
page_size: z.number().optional().describe('分页每页大小,默认: 30'),
|
|
21
22
|
},
|
|
22
23
|
summary: '查询 Issue 评论列表',
|
|
23
24
|
})
|
|
@@ -56,10 +57,10 @@ app.route({
|
|
|
56
57
|
skill: 'create-issue-comment',
|
|
57
58
|
title: '创建 Issue 评论',
|
|
58
59
|
args: {
|
|
59
|
-
repo:
|
|
60
|
-
issueNumber:
|
|
61
|
-
body:
|
|
62
|
-
clearAt:
|
|
60
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
61
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
62
|
+
body: z.string().describe('评论内容'),
|
|
63
|
+
clearAt: z.boolean().optional().describe('是否清除评论内容中的 @ 提及,默认: true'),
|
|
63
64
|
},
|
|
64
65
|
summary: '创建 Issue 评论',
|
|
65
66
|
})
|
|
@@ -101,9 +102,9 @@ app.route({
|
|
|
101
102
|
skill: 'get-issue-comment',
|
|
102
103
|
title: '获取 Issue 评论',
|
|
103
104
|
args: {
|
|
104
|
-
repo:
|
|
105
|
-
issueNumber:
|
|
106
|
-
commentId:
|
|
105
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
106
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
107
|
+
commentId: z.number().describe('评论 ID'),
|
|
107
108
|
},
|
|
108
109
|
summary: '获取 Issue 评论',
|
|
109
110
|
})
|
|
@@ -140,11 +141,11 @@ app.route({
|
|
|
140
141
|
skill: 'update-issue-comment',
|
|
141
142
|
title: '修改 Issue 评论',
|
|
142
143
|
args: {
|
|
143
|
-
repo:
|
|
144
|
-
issueNumber:
|
|
145
|
-
commentId:
|
|
146
|
-
body:
|
|
147
|
-
clearAt:
|
|
144
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
145
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
146
|
+
commentId: z.number().describe('评论 ID'),
|
|
147
|
+
body: z.string().describe('评论内容'),
|
|
148
|
+
clearAt: z.boolean().optional().describe('是否清除评论内容中的 @ 提及,默认: true'),
|
|
148
149
|
},
|
|
149
150
|
summary: '修改 Issue 评论',
|
|
150
151
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
import { IssueItem } from '@/index.ts';
|
|
4
5
|
|
|
@@ -14,12 +15,12 @@ app.route({
|
|
|
14
15
|
skill: 'create-issue',
|
|
15
16
|
title: '创建 Issue',
|
|
16
17
|
args: {
|
|
17
|
-
repo:
|
|
18
|
-
title:
|
|
19
|
-
body:
|
|
20
|
-
assignees:
|
|
21
|
-
labels:
|
|
22
|
-
priority:
|
|
18
|
+
repo: z.string().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
19
|
+
title: z.string().describe('Issue 标题'),
|
|
20
|
+
body: z.string().optional().describe('Issue 描述内容'),
|
|
21
|
+
assignees: z.array(z.string()).optional().describe('指派人列表'),
|
|
22
|
+
labels: z.array(z.string()).optional().describe('标签列表'),
|
|
23
|
+
priority: z.string().optional().describe('优先级'),
|
|
23
24
|
},
|
|
24
25
|
summary: '创建一个新的 Issue',
|
|
25
26
|
})
|
|
@@ -59,9 +60,9 @@ app.route({
|
|
|
59
60
|
skill: 'complete-issue',
|
|
60
61
|
title: '完成 CNB的任务Issue',
|
|
61
62
|
args: {
|
|
62
|
-
repo:
|
|
63
|
-
issueNumber:
|
|
64
|
-
state:
|
|
63
|
+
repo: z.string().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
64
|
+
issueNumber: z.union([z.string(), z.number()]).describe('Issue 编号'),
|
|
65
|
+
state: z.string().optional().describe('Issue 状态,默认为 closed'),
|
|
65
66
|
},
|
|
66
67
|
summary: '完成一个 Issue(将 state 改为 closed)',
|
|
67
68
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
import { useKey } from '@kevisual/context';
|
|
4
5
|
|
|
@@ -14,13 +15,13 @@ app.route({
|
|
|
14
15
|
skill: 'list-issues',
|
|
15
16
|
title: '查询 Issue 列表',
|
|
16
17
|
args: {
|
|
17
|
-
repo:
|
|
18
|
-
state:
|
|
19
|
-
keyword:
|
|
20
|
-
labels:
|
|
21
|
-
page:
|
|
22
|
-
page_size:
|
|
23
|
-
order_by:
|
|
18
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
19
|
+
state: z.string().optional().describe('Issue 状态:open 或 closed'),
|
|
20
|
+
keyword: z.string().optional().describe('问题搜索关键词'),
|
|
21
|
+
labels: z.string().optional().describe('问题标签,多个用逗号分隔'),
|
|
22
|
+
page: z.number().optional().describe('分页页码,默认: 1'),
|
|
23
|
+
page_size: z.number().optional().describe('分页每页大小,默认: 30'),
|
|
24
|
+
order_by: z.string().optional().describe('排序方式,如 created_at, -updated_at'),
|
|
24
25
|
},
|
|
25
26
|
summary: '查询 Issue 列表',
|
|
26
27
|
})
|
|
@@ -62,8 +63,8 @@ app.route({
|
|
|
62
63
|
skill: 'getIssue',
|
|
63
64
|
title: '获取 单个 Issue',
|
|
64
65
|
args: {
|
|
65
|
-
repo:
|
|
66
|
-
issueNumber:
|
|
66
|
+
repo: z.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
67
|
+
issueNumber: z.union([z.string(), z.number()]).describe('Issue 编号'),
|
|
67
68
|
},
|
|
68
69
|
summary: '获取 单个 Issue',
|
|
69
70
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
import { CNBChat } from '@kevisual/ai/browser'
|
|
4
5
|
import { useKey } from '@kevisual/context';
|
|
@@ -21,8 +22,8 @@ app.route({
|
|
|
21
22
|
title: '调用cnb的知识库ai对话功能进行聊天',
|
|
22
23
|
summary: '调用cnb的知识库ai对话功能进行聊天,基于cnb提供的ai能力',
|
|
23
24
|
args: {
|
|
24
|
-
question:
|
|
25
|
-
repo:
|
|
25
|
+
question: z.string().describe('用户输入的消息内容'),
|
|
26
|
+
repo: z.string().optional().describe('知识库仓库ID,默认为空表示使用默认知识库'),
|
|
26
27
|
}
|
|
27
28
|
})
|
|
28
29
|
}
|
|
@@ -98,8 +99,8 @@ app.route({
|
|
|
98
99
|
title: '调用cnb的知识库RAG查询功能进行问答',
|
|
99
100
|
summary: '调用cnb的知识库RAG查询功能进行问答,基于cnb提供的知识库能力',
|
|
100
101
|
args: {
|
|
101
|
-
question:
|
|
102
|
-
repo:
|
|
102
|
+
question: z.string().describe('用户输入的消息内容'),
|
|
103
|
+
repo: z.string().optional().describe('知识库仓库ID,默认为空表示使用默认知识库'),
|
|
103
104
|
}
|
|
104
105
|
})
|
|
105
106
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { app, cnbManager } from '../../app.ts';
|
|
3
4
|
import { useKey } from '@kevisual/context';
|
|
4
5
|
|
|
@@ -15,10 +16,10 @@ app.route({
|
|
|
15
16
|
title: '查询 Issue 标签列表',
|
|
16
17
|
summary: '查询 Issue 的标签列表',
|
|
17
18
|
args: {
|
|
18
|
-
repo:
|
|
19
|
-
issueNumber:
|
|
20
|
-
page:
|
|
21
|
-
pageSize:
|
|
19
|
+
repo: z.string().optional().describe('仓库路径, 如 my-user/my-repo'),
|
|
20
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
21
|
+
page: z.number().optional().describe('分页页码,默认 1'),
|
|
22
|
+
pageSize: z.number().optional().describe('分页每页大小,默认 30'),
|
|
22
23
|
},
|
|
23
24
|
})
|
|
24
25
|
}
|
|
@@ -56,9 +57,9 @@ app.route({
|
|
|
56
57
|
title: '设置 Issue 标签',
|
|
57
58
|
summary: '设置 Issue 标签(完全替换现有标签)',
|
|
58
59
|
args: {
|
|
59
|
-
repo:
|
|
60
|
-
issueNumber:
|
|
61
|
-
labels:
|
|
60
|
+
repo: z.string().optional().describe('仓库路径, 如 my-user/my-repo'),
|
|
61
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
62
|
+
labels: z.array(z.string()).describe('标签名称数组'),
|
|
62
63
|
},
|
|
63
64
|
})
|
|
64
65
|
}
|
|
@@ -95,9 +96,9 @@ app.route({
|
|
|
95
96
|
title: '新增 Issue 标签',
|
|
96
97
|
summary: '新增 Issue 标签(追加到现有标签)',
|
|
97
98
|
args: {
|
|
98
|
-
repo:
|
|
99
|
-
issueNumber:
|
|
100
|
-
labels:
|
|
99
|
+
repo: z.string().optional().describe('仓库路径, 如 my-user/my-repo'),
|
|
100
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
101
|
+
labels: z.array(z.string()).describe('标签名称数组'),
|
|
101
102
|
},
|
|
102
103
|
})
|
|
103
104
|
}
|
|
@@ -134,8 +135,8 @@ app.route({
|
|
|
134
135
|
title: '清空 Issue 标签',
|
|
135
136
|
summary: '清空 Issue 标签(移除所有标签)',
|
|
136
137
|
args: {
|
|
137
|
-
repo:
|
|
138
|
-
issueNumber:
|
|
138
|
+
repo: z.string().optional().describe('仓库路径, 如 my-user/my-repo'),
|
|
139
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
139
140
|
},
|
|
140
141
|
})
|
|
141
142
|
}
|
|
@@ -168,9 +169,9 @@ app.route({
|
|
|
168
169
|
title: '删除 Issue 标签',
|
|
169
170
|
summary: '删除 Issue 指定标签',
|
|
170
171
|
args: {
|
|
171
|
-
repo:
|
|
172
|
-
issueNumber:
|
|
173
|
-
name:
|
|
172
|
+
repo: z.string().optional().describe('仓库路径, 如 my-user/my-repo'),
|
|
173
|
+
issueNumber: z.number().describe('Issue 编号'),
|
|
174
|
+
name: z.string().describe('标签名称'),
|
|
174
175
|
},
|
|
175
176
|
})
|
|
176
177
|
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { app, cnbManager } from '../../app.ts';
|
|
2
|
+
import { createSkill } from '@kevisual/router'
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
// 查询制品列表
|
|
6
|
+
app.route({
|
|
7
|
+
path: 'cnb',
|
|
8
|
+
key: 'list-packages',
|
|
9
|
+
description: '查询制品列表, 参数 slug, type',
|
|
10
|
+
middleware: ['auth'],
|
|
11
|
+
metadata: {
|
|
12
|
+
tags: ['package'],
|
|
13
|
+
...createSkill({
|
|
14
|
+
skill: 'list-packages',
|
|
15
|
+
title: '查询制品列表',
|
|
16
|
+
args: {
|
|
17
|
+
slug: z.string().describe('资源路径, 如 my-org/my-registry'),
|
|
18
|
+
type: z.string().describe('制品类型: all, docker, helm, docker-model, maven, npm, ohpm, pypi, nuget, composer, conan, cargo'),
|
|
19
|
+
ordering: z.string().describe('排序类型: pull_count, last_push_at, name_ascend, name_descend').optional(),
|
|
20
|
+
name: z.string().describe('关键字,搜索制品名称').optional(),
|
|
21
|
+
page: z.number().describe('页码').optional(),
|
|
22
|
+
page_size: z.number().describe('每页数量').optional(),
|
|
23
|
+
},
|
|
24
|
+
summary: '查询制品列表',
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}).define(async (ctx) => {
|
|
28
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
29
|
+
const slug = ctx.query?.slug;
|
|
30
|
+
const type = ctx.query?.type;
|
|
31
|
+
const { ordering, name, page, page_size } = ctx.query || {};
|
|
32
|
+
|
|
33
|
+
if (!slug) {
|
|
34
|
+
ctx.throw(400, '缺少参数 slug');
|
|
35
|
+
}
|
|
36
|
+
if (!type) {
|
|
37
|
+
ctx.throw(400, '缺少参数 type');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const res = await cnb.packages.package.list(slug, type, {
|
|
41
|
+
ordering,
|
|
42
|
+
name,
|
|
43
|
+
page,
|
|
44
|
+
page_size,
|
|
45
|
+
});
|
|
46
|
+
ctx.forward(res);
|
|
47
|
+
}).addTo(app);
|
|
48
|
+
|
|
49
|
+
// 获取制品详情
|
|
50
|
+
app.route({
|
|
51
|
+
path: 'cnb',
|
|
52
|
+
key: 'get-package',
|
|
53
|
+
description: '获取制品详情, 参数 slug, type, name',
|
|
54
|
+
middleware: ['auth'],
|
|
55
|
+
metadata: {
|
|
56
|
+
tags: ['package'],
|
|
57
|
+
...createSkill({
|
|
58
|
+
skill: 'get-package',
|
|
59
|
+
title: '获取制品详情',
|
|
60
|
+
args: {
|
|
61
|
+
slug: z.string().describe('资源路径, 如 my-org/my-registry'),
|
|
62
|
+
type: z.string().describe('制品类型'),
|
|
63
|
+
name: z.string().describe('制品名称'),
|
|
64
|
+
},
|
|
65
|
+
summary: '获取指定制品的详细信息',
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
}).define(async (ctx) => {
|
|
69
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
70
|
+
const slug = ctx.query?.slug;
|
|
71
|
+
const type = ctx.query?.type;
|
|
72
|
+
const name = ctx.query?.name;
|
|
73
|
+
|
|
74
|
+
if (!slug) {
|
|
75
|
+
ctx.throw(400, '缺少参数 slug');
|
|
76
|
+
}
|
|
77
|
+
if (!type) {
|
|
78
|
+
ctx.throw(400, '缺少参数 type');
|
|
79
|
+
}
|
|
80
|
+
if (!name) {
|
|
81
|
+
ctx.throw(400, '缺少参数 name');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const res = await cnb.packages.package.getOne(slug, type, name);
|
|
85
|
+
ctx.forward(res);
|
|
86
|
+
}).addTo(app);
|
|
87
|
+
|
|
88
|
+
// 删除制品
|
|
89
|
+
app.route({
|
|
90
|
+
path: 'cnb',
|
|
91
|
+
key: 'delete-package',
|
|
92
|
+
description: '删除制品, 参数 slug, type, name',
|
|
93
|
+
middleware: ['auth'],
|
|
94
|
+
metadata: {
|
|
95
|
+
tags: ['package'],
|
|
96
|
+
...createSkill({
|
|
97
|
+
skill: 'delete-package',
|
|
98
|
+
title: '删除制品',
|
|
99
|
+
args: {
|
|
100
|
+
slug: z.string().describe('资源路径, 如 my-org/my-registry'),
|
|
101
|
+
type: z.string().describe('制品类型'),
|
|
102
|
+
name: z.string().describe('制品名称'),
|
|
103
|
+
},
|
|
104
|
+
summary: '删除指定的制品',
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
}).define(async (ctx) => {
|
|
108
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
109
|
+
const slug = ctx.query?.slug;
|
|
110
|
+
const type = ctx.query?.type;
|
|
111
|
+
const name = ctx.query?.name;
|
|
112
|
+
|
|
113
|
+
if (!slug) {
|
|
114
|
+
ctx.throw(400, '缺少参数 slug');
|
|
115
|
+
}
|
|
116
|
+
if (!type) {
|
|
117
|
+
ctx.throw(400, '缺少参数 type');
|
|
118
|
+
}
|
|
119
|
+
if (!name) {
|
|
120
|
+
ctx.throw(400, '缺少参数 name');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const res = await cnb.packages.package.remove(slug, type, name);
|
|
124
|
+
ctx.forward(res);
|
|
125
|
+
}).addTo(app);
|
|
126
|
+
|
|
127
|
+
// 获取制品标签列表
|
|
128
|
+
app.route({
|
|
129
|
+
path: 'cnb',
|
|
130
|
+
key: 'list-package-tags',
|
|
131
|
+
description: '获取制品标签列表, 参数 slug, type, name',
|
|
132
|
+
middleware: ['auth'],
|
|
133
|
+
metadata: {
|
|
134
|
+
tags: ['package'],
|
|
135
|
+
...createSkill({
|
|
136
|
+
skill: 'list-package-tags',
|
|
137
|
+
title: '获取制品标签列表',
|
|
138
|
+
args: {
|
|
139
|
+
slug: z.string().describe('资源路径, 如 my-org/my-registry'),
|
|
140
|
+
type: z.string().describe('制品类型'),
|
|
141
|
+
name: z.string().describe('制品名称'),
|
|
142
|
+
page: z.number().describe('页码').optional(),
|
|
143
|
+
page_size: z.number().describe('每页数量').optional(),
|
|
144
|
+
},
|
|
145
|
+
summary: '获取制品的标签列表',
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
}).define(async (ctx) => {
|
|
149
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
150
|
+
const slug = ctx.query?.slug;
|
|
151
|
+
const type = ctx.query?.type;
|
|
152
|
+
const name = ctx.query?.name;
|
|
153
|
+
const { page, page_size } = ctx.query || {};
|
|
154
|
+
|
|
155
|
+
if (!slug) {
|
|
156
|
+
ctx.throw(400, '缺少参数 slug');
|
|
157
|
+
}
|
|
158
|
+
if (!type) {
|
|
159
|
+
ctx.throw(400, '缺少参数 type');
|
|
160
|
+
}
|
|
161
|
+
if (!name) {
|
|
162
|
+
ctx.throw(400, '缺少参数 name');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const res = await cnb.packages.package.listTags(slug, type, name, { page, page_size });
|
|
166
|
+
ctx.forward(res);
|
|
167
|
+
}).addTo(app);
|
|
168
|
+
|
|
169
|
+
// 获取制品标签详情
|
|
170
|
+
app.route({
|
|
171
|
+
path: 'cnb',
|
|
172
|
+
key: 'get-package-tag',
|
|
173
|
+
description: '获取制品标签详情, 参数 slug, type, name, tag',
|
|
174
|
+
middleware: ['auth'],
|
|
175
|
+
metadata: {
|
|
176
|
+
tags: ['package'],
|
|
177
|
+
...createSkill({
|
|
178
|
+
skill: 'get-package-tag',
|
|
179
|
+
title: '获取制品标签详情',
|
|
180
|
+
args: {
|
|
181
|
+
slug: z.string().describe('资源路径, 如 my-org/my-registry'),
|
|
182
|
+
type: z.string().describe('制品类型'),
|
|
183
|
+
name: z.string().describe('制品名称'),
|
|
184
|
+
tag: z.string().describe('标签名称'),
|
|
185
|
+
},
|
|
186
|
+
summary: '获取制品标签的详细信息',
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
}).define(async (ctx) => {
|
|
190
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
191
|
+
const slug = ctx.query?.slug;
|
|
192
|
+
const type = ctx.query?.type;
|
|
193
|
+
const name = ctx.query?.name;
|
|
194
|
+
const tag = ctx.query?.tag;
|
|
195
|
+
|
|
196
|
+
if (!slug) {
|
|
197
|
+
ctx.throw(400, '缺少参数 slug');
|
|
198
|
+
}
|
|
199
|
+
if (!type) {
|
|
200
|
+
ctx.throw(400, '缺少参数 type');
|
|
201
|
+
}
|
|
202
|
+
if (!name) {
|
|
203
|
+
ctx.throw(400, '缺少参数 name');
|
|
204
|
+
}
|
|
205
|
+
if (!tag) {
|
|
206
|
+
ctx.throw(400, '缺少参数 tag');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const res = await cnb.packages.package.getTag(slug, type, name, tag);
|
|
210
|
+
ctx.forward(res);
|
|
211
|
+
}).addTo(app);
|
|
212
|
+
|
|
213
|
+
// 删除制品标签
|
|
214
|
+
app.route({
|
|
215
|
+
path: 'cnb',
|
|
216
|
+
key: 'delete-package-tag',
|
|
217
|
+
description: '删除制品标签, 参数 slug, type, name, tag',
|
|
218
|
+
middleware: ['auth'],
|
|
219
|
+
metadata: {
|
|
220
|
+
tags: ['package'],
|
|
221
|
+
...createSkill({
|
|
222
|
+
skill: 'delete-package-tag',
|
|
223
|
+
title: '删除制品标签',
|
|
224
|
+
args: {
|
|
225
|
+
slug: z.string().describe('资源路径, 如 my-org/my-registry'),
|
|
226
|
+
type: z.string().describe('制品类型'),
|
|
227
|
+
name: z.string().describe('制品名称'),
|
|
228
|
+
tag: z.string().describe('标签名称'),
|
|
229
|
+
},
|
|
230
|
+
summary: '删除制品的指定标签',
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
}).define(async (ctx) => {
|
|
234
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
235
|
+
const slug = ctx.query?.slug;
|
|
236
|
+
const type = ctx.query?.type;
|
|
237
|
+
const name = ctx.query?.name;
|
|
238
|
+
const tag = ctx.query?.tag;
|
|
239
|
+
|
|
240
|
+
if (!slug) {
|
|
241
|
+
ctx.throw(400, '缺少参数 slug');
|
|
242
|
+
}
|
|
243
|
+
if (!type) {
|
|
244
|
+
ctx.throw(400, '缺少参数 type');
|
|
245
|
+
}
|
|
246
|
+
if (!name) {
|
|
247
|
+
ctx.throw(400, '缺少参数 name');
|
|
248
|
+
}
|
|
249
|
+
if (!tag) {
|
|
250
|
+
ctx.throw(400, '缺少参数 tag');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const res = await cnb.packages.package.removeTag(slug, type, name, tag);
|
|
254
|
+
ctx.forward(res);
|
|
255
|
+
}).addTo(app);
|