@kevisual/cnb 0.0.56 → 0.0.58
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/org/index.ts +2 -0
- package/agent/routes/org/list.ts +137 -0
- package/agent/routes/org/org.ts +241 -0
- 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 +17 -17
- package/agent/routes/workspace/keep.ts +5 -5
- package/agent/routes/workspace/rerun.ts +6 -1
- package/agent/routes/workspace/skills.ts +2 -2
- package/dist/cli.js +764 -207
- package/dist/npc.js +764 -207
- package/dist/opencode.js +772 -215
- package/dist/routes.d.ts +643 -3
- package/dist/routes.js +764 -207
- package/package.json +1 -1
- package/src/index.ts +21 -1
- package/src/issue/index.ts +5 -2
- package/src/knowledge/index.ts +92 -5
- package/src/org/index.ts +574 -0
- package/src/package/index.ts +2 -0
- package/src/package/package.ts +134 -0
- package/src/package/registry.ts +145 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { app, cnbManager } from '../../app.ts';
|
|
4
|
+
|
|
5
|
+
// 创建组织
|
|
6
|
+
app.route({
|
|
7
|
+
path: 'cnb',
|
|
8
|
+
key: 'create-organization',
|
|
9
|
+
description: '创建新组织',
|
|
10
|
+
middleware: ['auth'],
|
|
11
|
+
metadata: {
|
|
12
|
+
tags: ['opencode'],
|
|
13
|
+
skill: 'create-organization',
|
|
14
|
+
title: '创建组织',
|
|
15
|
+
args: {
|
|
16
|
+
path: z.string().describe('组织路径'),
|
|
17
|
+
description: z.string().optional().describe('组织描述'),
|
|
18
|
+
bind_domain: z.string().optional().describe('根组织绑定的域名'),
|
|
19
|
+
remark: z.string().optional().describe('组织展示名称'),
|
|
20
|
+
},
|
|
21
|
+
summary: '创建一个新组织',
|
|
22
|
+
}
|
|
23
|
+
}).define(async (ctx) => {
|
|
24
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
25
|
+
const path = ctx.query?.path;
|
|
26
|
+
const description = ctx.query?.description;
|
|
27
|
+
const bind_domain = ctx.query?.bind_domain;
|
|
28
|
+
const remark = ctx.query?.remark;
|
|
29
|
+
|
|
30
|
+
if (!path) {
|
|
31
|
+
ctx.throw(400, '缺少参数 path');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const res = await cnb.org.create({ path, description, bind_domain, remark });
|
|
35
|
+
ctx.forward(res);
|
|
36
|
+
}).addTo(app);
|
|
37
|
+
|
|
38
|
+
// 获取组织信息
|
|
39
|
+
app.route({
|
|
40
|
+
path: 'cnb',
|
|
41
|
+
key: 'get-organization',
|
|
42
|
+
description: '获取组织信息',
|
|
43
|
+
middleware: ['auth'],
|
|
44
|
+
metadata: {
|
|
45
|
+
tags: ['opencode'],
|
|
46
|
+
...createSkill({
|
|
47
|
+
skill: 'get-organization',
|
|
48
|
+
title: '获取组织信息',
|
|
49
|
+
args: {
|
|
50
|
+
group: z.string().describe('组织路径'),
|
|
51
|
+
},
|
|
52
|
+
summary: '获取指定组织的信息',
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}).define(async (ctx) => {
|
|
56
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
57
|
+
const group = ctx.query?.group;
|
|
58
|
+
|
|
59
|
+
if (!group) {
|
|
60
|
+
ctx.throw(400, '缺少参数 group');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const res = await cnb.org.getGroup(group);
|
|
64
|
+
ctx.forward(res);
|
|
65
|
+
}).addTo(app);
|
|
66
|
+
|
|
67
|
+
// 更新组织信息
|
|
68
|
+
app.route({
|
|
69
|
+
path: 'cnb',
|
|
70
|
+
key: 'update-organization',
|
|
71
|
+
description: '更新组织信息',
|
|
72
|
+
middleware: ['auth'],
|
|
73
|
+
metadata: {
|
|
74
|
+
tags: ['opencode'],
|
|
75
|
+
...createSkill({
|
|
76
|
+
skill: 'update-organization',
|
|
77
|
+
title: '更新组织信息',
|
|
78
|
+
args: {
|
|
79
|
+
group: z.string().describe('组织路径'),
|
|
80
|
+
description: z.string().optional().describe('组织描述'),
|
|
81
|
+
remark: z.string().optional().describe('组织展示名称'),
|
|
82
|
+
site: z.string().optional().describe('组织网站'),
|
|
83
|
+
email: z.string().optional().describe('组织联系邮箱'),
|
|
84
|
+
domain: z.string().optional().describe('绑定的域名'),
|
|
85
|
+
wechat_mp: z.string().optional().describe('微信公众号'),
|
|
86
|
+
},
|
|
87
|
+
summary: '更新组织信息,包括描述、展示名称、网站、邮箱等',
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}).define(async (ctx) => {
|
|
91
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
92
|
+
const group = ctx.query?.group;
|
|
93
|
+
const description = ctx.query?.description;
|
|
94
|
+
const remark = ctx.query?.remark;
|
|
95
|
+
const site = ctx.query?.site;
|
|
96
|
+
const email = ctx.query?.email;
|
|
97
|
+
const domain = ctx.query?.domain;
|
|
98
|
+
const wechat_mp = ctx.query?.wechat_mp;
|
|
99
|
+
|
|
100
|
+
if (!group) {
|
|
101
|
+
ctx.throw(400, '缺少参数 group');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const res = await cnb.org.updateGroup(group, { description, remark, site, email, domain, wechat_mp });
|
|
105
|
+
ctx.forward(res);
|
|
106
|
+
}).addTo(app);
|
|
107
|
+
|
|
108
|
+
// 删除组织
|
|
109
|
+
app.route({
|
|
110
|
+
path: 'cnb',
|
|
111
|
+
key: 'delete-organization',
|
|
112
|
+
description: '删除组织',
|
|
113
|
+
middleware: ['auth'],
|
|
114
|
+
metadata: {
|
|
115
|
+
skill: 'delete-organization',
|
|
116
|
+
title: '删除组织',
|
|
117
|
+
args: {
|
|
118
|
+
group: z.string().describe('组织路径'),
|
|
119
|
+
identityTicket: z.string().optional().describe('微信身份验证票据'),
|
|
120
|
+
},
|
|
121
|
+
summary: '删除指定组织',
|
|
122
|
+
}
|
|
123
|
+
}).define(async (ctx) => {
|
|
124
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
125
|
+
const group = ctx.query?.group;
|
|
126
|
+
const identityTicket = ctx.query?.identityTicket;
|
|
127
|
+
|
|
128
|
+
if (!group) {
|
|
129
|
+
ctx.throw(400, '缺少参数 group');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const res = await cnb.org.deleteGroup(group, identityTicket);
|
|
133
|
+
ctx.forward(res);
|
|
134
|
+
}).addTo(app);
|
|
135
|
+
|
|
136
|
+
// 转移组织
|
|
137
|
+
app.route({
|
|
138
|
+
path: 'cnb',
|
|
139
|
+
key: 'transfer-organization',
|
|
140
|
+
description: '转移组织',
|
|
141
|
+
middleware: ['auth'],
|
|
142
|
+
metadata: {
|
|
143
|
+
skill: 'transfer-organization',
|
|
144
|
+
title: '转移组织',
|
|
145
|
+
args: {
|
|
146
|
+
group: z.string().describe('组织路径'),
|
|
147
|
+
source: z.string().describe('源组织路径'),
|
|
148
|
+
target: z.string().describe('目标组织路径'),
|
|
149
|
+
},
|
|
150
|
+
summary: '将组织从源路径转移到目标路径',
|
|
151
|
+
}
|
|
152
|
+
}).define(async (ctx) => {
|
|
153
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
154
|
+
const group = ctx.query?.group;
|
|
155
|
+
const source = ctx.query?.source;
|
|
156
|
+
const target = ctx.query?.target;
|
|
157
|
+
|
|
158
|
+
if (!group || !source || !target) {
|
|
159
|
+
ctx.throw(400, '缺少参数 group, source 或 target');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const res = await cnb.org.transfer(group, { source, target });
|
|
163
|
+
ctx.forward(res);
|
|
164
|
+
}).addTo(app);
|
|
165
|
+
|
|
166
|
+
// 获取组织设置
|
|
167
|
+
app.route({
|
|
168
|
+
path: 'cnb',
|
|
169
|
+
key: 'get-organization-setting',
|
|
170
|
+
description: '获取组织配置详情',
|
|
171
|
+
middleware: ['auth'],
|
|
172
|
+
metadata: {
|
|
173
|
+
tags: ['opencode'],
|
|
174
|
+
...createSkill({
|
|
175
|
+
skill: 'get-organization-setting',
|
|
176
|
+
title: '获取组织设置',
|
|
177
|
+
args: {
|
|
178
|
+
slug: z.string().describe('组织路径'),
|
|
179
|
+
},
|
|
180
|
+
summary: '获取指定组织的配置详情,包括可见性设置、邮箱验证等',
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
}).define(async (ctx) => {
|
|
184
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
185
|
+
const slug = ctx.query?.slug;
|
|
186
|
+
|
|
187
|
+
if (!slug) {
|
|
188
|
+
ctx.throw(400, '缺少参数 slug');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const res = await cnb.org.getSetting(slug);
|
|
192
|
+
ctx.forward(res);
|
|
193
|
+
}).addTo(app);
|
|
194
|
+
|
|
195
|
+
// 更新组织设置
|
|
196
|
+
app.route({
|
|
197
|
+
path: 'cnb',
|
|
198
|
+
key: 'update-organization-setting',
|
|
199
|
+
description: '更新组织配置',
|
|
200
|
+
middleware: ['auth'],
|
|
201
|
+
metadata: {
|
|
202
|
+
tags: ['opencode'],
|
|
203
|
+
...createSkill({
|
|
204
|
+
skill: 'update-organization-setting',
|
|
205
|
+
title: '更新组织设置',
|
|
206
|
+
args: {
|
|
207
|
+
slug: z.string().describe('组织路径'),
|
|
208
|
+
hide_members: z.number().optional().describe('是否对外隐藏组织成员,0 - 否, 1 - 是'),
|
|
209
|
+
hide_sub_groups: z.number().optional().describe('是否对外隐藏子组织,0 - 否, 1 - 是'),
|
|
210
|
+
show_private_repo_watermark: z.number().optional().describe('是否对外显示私有仓库水印,0 - 否, 1 - 是'),
|
|
211
|
+
group_protection: z.number().optional().describe('组织保护开关,0 - 关闭,1 - 打开'),
|
|
212
|
+
email_verification: z.array(z.string()).optional().describe('限制指定邮箱认证才能加入'),
|
|
213
|
+
values: z.string().optional().describe('组织设置值,多个选项用逗号拼接'),
|
|
214
|
+
},
|
|
215
|
+
summary: '更新组织配置,包括成员可见性、子组织可见性、水印等',
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
}).define(async (ctx) => {
|
|
219
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
220
|
+
const slug = ctx.query?.slug;
|
|
221
|
+
const hide_members = ctx.query?.hide_members ? Number(ctx.query.hide_members) : undefined;
|
|
222
|
+
const hide_sub_groups = ctx.query?.hide_sub_groups ? Number(ctx.query.hide_sub_groups) : undefined;
|
|
223
|
+
const show_private_repo_watermark = ctx.query?.show_private_repo_watermark ? Number(ctx.query.show_private_repo_watermark) : undefined;
|
|
224
|
+
const group_protection = ctx.query?.group_protection ? Number(ctx.query.group_protection) : undefined;
|
|
225
|
+
const email_verification = ctx.query?.email_verification;
|
|
226
|
+
const values = ctx.query?.values;
|
|
227
|
+
|
|
228
|
+
if (!slug) {
|
|
229
|
+
ctx.throw(400, '缺少参数 slug');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const res = await cnb.org.updateSetting(slug, {
|
|
233
|
+
hide_members,
|
|
234
|
+
hide_sub_groups,
|
|
235
|
+
show_private_repo_watermark,
|
|
236
|
+
group_protection,
|
|
237
|
+
email_verification,
|
|
238
|
+
values,
|
|
239
|
+
});
|
|
240
|
+
ctx.forward(res);
|
|
241
|
+
}).addTo(app);
|
|
@@ -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);
|
|
@@ -0,0 +1,107 @@
|
|
|
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-group-registries',
|
|
9
|
+
description: '查询组织下的制品库列表, 参数 slug',
|
|
10
|
+
middleware: ['auth'],
|
|
11
|
+
metadata: {
|
|
12
|
+
tags: ['package'],
|
|
13
|
+
...createSkill({
|
|
14
|
+
skill: 'list-group-registries',
|
|
15
|
+
title: '查询制品库列表',
|
|
16
|
+
args: {
|
|
17
|
+
slug: z.string().describe('组织 slug, 如 my-org'),
|
|
18
|
+
page: z.number().describe('页码').optional(),
|
|
19
|
+
page_size: z.number().describe('每页数量').optional(),
|
|
20
|
+
registry_type: z.string().describe('制品仓库类型: npm, maven, ohpm').optional(),
|
|
21
|
+
filter_type: z.string().describe('制品仓库可见性: private, public').optional(),
|
|
22
|
+
order_by: z.string().describe('排序字段: created_at, name').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 { page, page_size, registry_type, filter_type, order_by } = ctx.query || {};
|
|
31
|
+
|
|
32
|
+
if (!slug) {
|
|
33
|
+
ctx.throw(400, '缺少参数 slug');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const res = await cnb.packages.registry.listGroupRegistries(slug, {
|
|
37
|
+
page,
|
|
38
|
+
page_size,
|
|
39
|
+
registry_type,
|
|
40
|
+
filter_type,
|
|
41
|
+
order_by,
|
|
42
|
+
});
|
|
43
|
+
ctx.forward(res);
|
|
44
|
+
}).addTo(app);
|
|
45
|
+
|
|
46
|
+
// 设置制品库可见性
|
|
47
|
+
app.route({
|
|
48
|
+
path: 'cnb',
|
|
49
|
+
key: 'set-registry-visibility',
|
|
50
|
+
description: '设置制品库可见性, 参数 registry, visibility',
|
|
51
|
+
middleware: ['auth'],
|
|
52
|
+
metadata: {
|
|
53
|
+
tags: ['package'],
|
|
54
|
+
...createSkill({
|
|
55
|
+
skill: 'set-registry-visibility',
|
|
56
|
+
title: '设置制品库可见性',
|
|
57
|
+
args: {
|
|
58
|
+
registry: z.string().describe('制品库路径, 如 my-org/my-registry'),
|
|
59
|
+
visibility: z.string().describe('可见性: private 或 public'),
|
|
60
|
+
},
|
|
61
|
+
summary: '设置制品库的可见性',
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
}).define(async (ctx) => {
|
|
65
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
66
|
+
const registry = ctx.query?.registry;
|
|
67
|
+
const visibility = ctx.query?.visibility;
|
|
68
|
+
|
|
69
|
+
if (!registry) {
|
|
70
|
+
ctx.throw(400, '缺少参数 registry');
|
|
71
|
+
}
|
|
72
|
+
if (!visibility) {
|
|
73
|
+
ctx.throw(400, '缺少参数 visibility');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const res = await cnb.packages.registry.setVisibility(registry, { visibility });
|
|
77
|
+
ctx.forward(res);
|
|
78
|
+
}).addTo(app);
|
|
79
|
+
|
|
80
|
+
// 删除制品库
|
|
81
|
+
app.route({
|
|
82
|
+
path: 'cnb',
|
|
83
|
+
key: 'delete-registry',
|
|
84
|
+
description: '删除制品库, 参数 registry',
|
|
85
|
+
middleware: ['auth'],
|
|
86
|
+
metadata: {
|
|
87
|
+
tags: ['package'],
|
|
88
|
+
...createSkill({
|
|
89
|
+
skill: 'delete-registry',
|
|
90
|
+
title: '删除制品库',
|
|
91
|
+
args: {
|
|
92
|
+
registry: z.string().describe('制品库路径, 如 my-org/my-registry'),
|
|
93
|
+
},
|
|
94
|
+
summary: '删除指定的制品库',
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
}).define(async (ctx) => {
|
|
98
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
99
|
+
const registry = ctx.query?.registry;
|
|
100
|
+
|
|
101
|
+
if (!registry) {
|
|
102
|
+
ctx.throw(400, '缺少参数 registry');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const res = await cnb.packages.registry.remove(registry);
|
|
106
|
+
ctx.forward(res);
|
|
107
|
+
}).addTo(app);
|
|
@@ -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
|
// "列出我的代码仓库,search blog"
|
|
@@ -15,10 +16,10 @@ app.route({
|
|
|
15
16
|
title: '列出cnb代码仓库',
|
|
16
17
|
summary: '列出cnb代码仓库, 可选flags参数,如 KnowledgeBase',
|
|
17
18
|
args: {
|
|
18
|
-
search:
|
|
19
|
-
page:
|
|
20
|
-
pageSize:
|
|
21
|
-
flags:
|
|
19
|
+
search: z.string().optional().describe('搜索关键词'),
|
|
20
|
+
page: z.number().optional().describe('分页页码,默认 1'),
|
|
21
|
+
pageSize: z.number().optional().describe('每页数量,默认99'),
|
|
22
|
+
flags: z.string().optional().describe('仓库标记,如果是知识库则填写 KnowledgeBase'),
|
|
22
23
|
},
|
|
23
24
|
})
|
|
24
25
|
}
|
|
@@ -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
|
// 查询仓库标签列表
|
|
@@ -14,10 +15,10 @@ app.route({
|
|
|
14
15
|
title: '查询仓库标签列表',
|
|
15
16
|
summary: '查询仓库的标签列表',
|
|
16
17
|
args: {
|
|
17
|
-
repo:
|
|
18
|
-
page:
|
|
19
|
-
pageSize:
|
|
20
|
-
keyword:
|
|
18
|
+
repo: z.string().describe('仓库路径, 如 my-user/my-repo'),
|
|
19
|
+
page: z.number().optional().describe('分页页码,默认 1'),
|
|
20
|
+
pageSize: z.number().optional().describe('分页每页大小,默认 30'),
|
|
21
|
+
keyword: z.string().optional().describe('标签搜索关键词'),
|
|
21
22
|
},
|
|
22
23
|
})
|
|
23
24
|
}
|
|
@@ -53,10 +54,10 @@ app.route({
|
|
|
53
54
|
title: '创建仓库标签',
|
|
54
55
|
summary: '创建一个仓库标签',
|
|
55
56
|
args: {
|
|
56
|
-
repo:
|
|
57
|
-
name:
|
|
58
|
-
color:
|
|
59
|
-
description:
|
|
57
|
+
repo: z.string().describe('仓库路径, 如 my-user/my-repo'),
|
|
58
|
+
name: z.string().describe('标签名称'),
|
|
59
|
+
color: z.string().describe('标签颜色,十六进制颜色码,不含 # 前缀'),
|
|
60
|
+
description: z.string().optional().describe('标签描述'),
|
|
60
61
|
},
|
|
61
62
|
})
|
|
62
63
|
}
|
|
@@ -92,11 +93,11 @@ app.route({
|
|
|
92
93
|
title: '更新仓库标签',
|
|
93
94
|
summary: '更新仓库标签信息',
|
|
94
95
|
args: {
|
|
95
|
-
repo:
|
|
96
|
-
name:
|
|
97
|
-
color:
|
|
98
|
-
description:
|
|
99
|
-
newName:
|
|
96
|
+
repo: z.string().describe('仓库路径, 如 my-user/my-repo'),
|
|
97
|
+
name: z.string().describe('标签名称'),
|
|
98
|
+
color: z.string().optional().describe('标签颜色,十六进制颜色码,不含 # 前缀'),
|
|
99
|
+
description: z.string().optional().describe('标签描述'),
|
|
100
|
+
newName: z.string().optional().describe('新标签名称'),
|
|
100
101
|
},
|
|
101
102
|
})
|
|
102
103
|
}
|
|
@@ -133,8 +134,8 @@ app.route({
|
|
|
133
134
|
title: '删除仓库标签',
|
|
134
135
|
summary: '删除指定的仓库标签',
|
|
135
136
|
args: {
|
|
136
|
-
repo:
|
|
137
|
-
name:
|
|
137
|
+
repo: z.string().describe('仓库路径, 如 my-user/my-repo'),
|
|
138
|
+
name: z.string().describe('标签名称'),
|
|
138
139
|
},
|
|
139
140
|
})
|
|
140
141
|
}
|