@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
|
@@ -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
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { app, cnbManager } from '../../app.ts';
|
|
2
|
-
import { createSkill, Skill
|
|
2
|
+
import { createSkill, Skill } from '@kevisual/router'
|
|
3
|
+
import { z } from 'zod'
|
|
3
4
|
|
|
4
5
|
// 创建一个仓库 kevisual/test-repo
|
|
5
6
|
app.route({
|
|
@@ -13,9 +14,9 @@ app.route({
|
|
|
13
14
|
skill: 'create-repo',
|
|
14
15
|
title: '创建代码仓库',
|
|
15
16
|
args: {
|
|
16
|
-
name:
|
|
17
|
-
visibility:
|
|
18
|
-
description:
|
|
17
|
+
name: z.string().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
18
|
+
visibility: z.string().describe('代码仓库可见性, public 或 private').default('public'),
|
|
19
|
+
description: z.string().describe('代码仓库描述'),
|
|
19
20
|
},
|
|
20
21
|
summary: '创建一个新的代码仓库',
|
|
21
22
|
})
|
|
@@ -50,7 +51,7 @@ app.route({
|
|
|
50
51
|
middleware: ['auth'],
|
|
51
52
|
metadata: {
|
|
52
53
|
args: {
|
|
53
|
-
name:
|
|
54
|
+
name: z.string().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
}).define(async (ctx) => {
|
|
@@ -76,10 +77,10 @@ app.route({
|
|
|
76
77
|
title: '在代码仓库中创建文件',
|
|
77
78
|
summary: `在代码仓库中创建文件, encoding 可选,默认 raw`,
|
|
78
79
|
args: {
|
|
79
|
-
repoName:
|
|
80
|
-
filePath:
|
|
81
|
-
content:
|
|
82
|
-
encoding:
|
|
80
|
+
repoName: z.string().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
81
|
+
filePath: z.string().describe('文件路径, 如 src/index.ts'),
|
|
82
|
+
content: z.string().describe('文本的字符串的内容'),
|
|
83
|
+
encoding: z.string().describe('编码方式,如 raw').optional(),
|
|
83
84
|
},
|
|
84
85
|
})
|
|
85
86
|
}
|
|
@@ -115,7 +116,7 @@ app.route({
|
|
|
115
116
|
skill: 'delete-repo',
|
|
116
117
|
title: '删除代码仓库',
|
|
117
118
|
args: {
|
|
118
|
-
name:
|
|
119
|
+
name: z.string().describe('代码仓库名称'),
|
|
119
120
|
},
|
|
120
121
|
summary: '删除一个代码仓库',
|
|
121
122
|
})
|
|
@@ -152,11 +153,11 @@ app.route({
|
|
|
152
153
|
skill: 'update-repo-info',
|
|
153
154
|
title: '更新代码仓库信息',
|
|
154
155
|
args: {
|
|
155
|
-
name:
|
|
156
|
-
description:
|
|
157
|
-
license:
|
|
158
|
-
site:
|
|
159
|
-
topics:
|
|
156
|
+
name: z.string().describe('代码仓库名称'),
|
|
157
|
+
description: z.string().describe('代码仓库描述'),
|
|
158
|
+
license: z.string().describe('代码仓库许可证类型,如 MIT').optional(),
|
|
159
|
+
site: z.string().describe('代码仓库主页链接').optional(),
|
|
160
|
+
topics: z.array(z.string()).describe('代码仓库话题标签列表').optional(),
|
|
160
161
|
},
|
|
161
162
|
summary: '更新代码仓库的信息',
|
|
162
163
|
})
|
|
@@ -187,8 +188,8 @@ app.route({
|
|
|
187
188
|
middleware: ['auth'],
|
|
188
189
|
metadata: {
|
|
189
190
|
args: {
|
|
190
|
-
name:
|
|
191
|
-
visibility:
|
|
191
|
+
name: z.string().describe('代码仓库名称'),
|
|
192
|
+
visibility: z.string().describe('代码仓库可见性, public 或 private 或 protected'),
|
|
192
193
|
},
|
|
193
194
|
}
|
|
194
195
|
}).define(async (ctx) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
|
|
3
4
|
import { app, cnbManager, notCNBCheck } from '../../app.ts';
|
|
4
5
|
|
|
@@ -15,11 +16,11 @@ app.route({
|
|
|
15
16
|
title: '云端构建',
|
|
16
17
|
summary: '在云端构建代码仓库,参数包括 event, repo, branch, ref, config, env',
|
|
17
18
|
args: {
|
|
18
|
-
env:
|
|
19
|
-
event:
|
|
20
|
-
branch:
|
|
21
|
-
config:
|
|
22
|
-
repo:
|
|
19
|
+
env: z.any().optional().describe('构建环境变量,格式为 { "KEY": "VALUE" }'),
|
|
20
|
+
event: z.string().optional().describe('触发事件类型,例如 api_trigger_event'),
|
|
21
|
+
branch: z.string().optional().describe('分支名称,默认主分支'),
|
|
22
|
+
config: z.string().describe('构建config文件内容,例如 cloudbuild.yaml对应的yml的内容'),
|
|
23
|
+
repo: z.string().describe('代码仓库路径,例如 user/repo'),
|
|
23
24
|
},
|
|
24
25
|
})
|
|
25
26
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
2
|
import { app, cnbManager, notCNBCheck } from '../../app.ts';
|
|
3
|
-
import z from 'zod';
|
|
3
|
+
import { z } from 'zod';
|
|
4
4
|
import './skills.ts';
|
|
5
5
|
import './keep.ts';
|
|
6
6
|
import './build.ts';
|
|
7
|
+
import './rerun.ts';
|
|
7
8
|
|
|
8
9
|
// 启动工作空间
|
|
9
10
|
app.route({
|
|
@@ -18,9 +19,9 @@ app.route({
|
|
|
18
19
|
title: '启动cnb工作空间',
|
|
19
20
|
summary: '启动cnb工作空间',
|
|
20
21
|
args: {
|
|
21
|
-
repo:
|
|
22
|
-
branch:
|
|
23
|
-
ref:
|
|
22
|
+
repo: z.string().describe('代码仓库路径,例如 user/repo'),
|
|
23
|
+
branch: z.string().optional().describe('分支名称,默认主分支'),
|
|
24
|
+
ref: z.string().optional().describe('提交引用,例如 commit sha'),
|
|
24
25
|
},
|
|
25
26
|
})
|
|
26
27
|
}
|
|
@@ -52,11 +53,11 @@ app.route({
|
|
|
52
53
|
title: '列出cnb工作空间',
|
|
53
54
|
summary: '列出cnb工作空间列表,支持按状态过滤, status 可选值 running 或 closed',
|
|
54
55
|
args: {
|
|
55
|
-
status:
|
|
56
|
-
page:
|
|
57
|
-
pageSize:
|
|
58
|
-
slug:
|
|
59
|
-
branch:
|
|
56
|
+
status: z.string().optional().describe('开发环境状态,running: 运行中,closed: 已关闭和停止的'),
|
|
57
|
+
page: z.number().optional().describe('分页页码,默认 1'),
|
|
58
|
+
pageSize: z.number().optional().describe('分页大小,默认 20,最大 100'),
|
|
59
|
+
slug: z.string().optional().describe('仓库路径,例如 groupname/reponame'),
|
|
60
|
+
branch: z.string().optional().describe('分支名称'),
|
|
60
61
|
},
|
|
61
62
|
})
|
|
62
63
|
}
|
|
@@ -84,8 +85,8 @@ app.route({
|
|
|
84
85
|
title: '获取工作空间详情',
|
|
85
86
|
summary: '获取工作空间详细信息',
|
|
86
87
|
args: {
|
|
87
|
-
repo:
|
|
88
|
-
sn:
|
|
88
|
+
repo: z.string().describe('代码仓库路径,例如 user/repo'),
|
|
89
|
+
sn: z.string().describe('工作空间流水线的 sn'),
|
|
89
90
|
},
|
|
90
91
|
})
|
|
91
92
|
}
|
|
@@ -116,9 +117,9 @@ app.route({
|
|
|
116
117
|
title: '删除工作空间',
|
|
117
118
|
summary: '删除工作空间,pipelineId 和 sn 二选一',
|
|
118
119
|
args: {
|
|
119
|
-
pipelineId:
|
|
120
|
-
sn:
|
|
121
|
-
sns:
|
|
120
|
+
pipelineId: z.string().optional().describe('流水线 ID,优先使用'),
|
|
121
|
+
sn: z.string().optional().describe('流水线构建号'),
|
|
122
|
+
sns: z.array(z.string()).optional().describe('批量流水线构建号'),
|
|
122
123
|
},
|
|
123
124
|
})
|
|
124
125
|
}
|
|
@@ -156,8 +157,8 @@ app.route({
|
|
|
156
157
|
title: '停止工作空间',
|
|
157
158
|
summary: '停止运行中的工作空间',
|
|
158
159
|
args: {
|
|
159
|
-
pipelineId:
|
|
160
|
-
sn:
|
|
160
|
+
pipelineId: z.string().optional().describe('流水线 ID,优先使用'),
|
|
161
|
+
sn: z.string().optional().describe('流水线构建号'),
|
|
161
162
|
},
|
|
162
163
|
})
|
|
163
164
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
import { app, cnbManager, notCNBCheck } from '../../app.ts';
|
|
3
3
|
import { addKeepAliveData, KeepAliveData, removeKeepAliveData, createLiveData } from '../../../src/workspace/keep-file-live.ts';
|
|
4
4
|
import { useKey } from '@kevisual/context';
|
|
@@ -13,8 +13,8 @@ app.route({
|
|
|
13
13
|
tags: [],
|
|
14
14
|
...({
|
|
15
15
|
args: {
|
|
16
|
-
repo:
|
|
17
|
-
pipelineId:
|
|
16
|
+
repo: z.string().describe('代码仓库路径,例如 user/repo'),
|
|
17
|
+
pipelineId: z.string().describe('流水线ID,例如 cnb-708-1ji9sog7o-001'),
|
|
18
18
|
}
|
|
19
19
|
})
|
|
20
20
|
}
|
|
@@ -58,8 +58,8 @@ app.route({
|
|
|
58
58
|
tags: [],
|
|
59
59
|
...({
|
|
60
60
|
args: {
|
|
61
|
-
repo:
|
|
62
|
-
pipelineId:
|
|
61
|
+
repo: z.string().describe('代码仓库路径,例如 user/repo'),
|
|
62
|
+
pipelineId: z.string().describe('流水线ID,例如 cnb-708-1ji9sog7o-001'),
|
|
63
63
|
}
|
|
64
64
|
})
|
|
65
65
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { app, cnbManager } from '../../app.ts';
|
|
3
|
+
|
|
4
|
+
app.route({
|
|
5
|
+
path: 'cnb',
|
|
6
|
+
key: 'rerun',
|
|
7
|
+
description: '重新启动工作区,定时任务',
|
|
8
|
+
middleware: ['auth'],
|
|
9
|
+
metadata: {
|
|
10
|
+
args: {
|
|
11
|
+
repo: z.string().optional().describe('仓库名称,例如:owner/repo'),
|
|
12
|
+
config: z.string().optional().describe('工作区配置'),
|
|
13
|
+
event: z.string().optional().describe('触发事件来源,api_trigger_event'),
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}).define(async (ctx) => {
|
|
17
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
18
|
+
const repo = ctx.args.repo;
|
|
19
|
+
const config = ctx.args.config;
|
|
20
|
+
const event = ctx.args.event || 'api_trigger_event';
|
|
21
|
+
const res = await cnb.workspace.list({ status: "running" })
|
|
22
|
+
if (res.code !== 200) {
|
|
23
|
+
ctx.throw(500, res.message || 'Failed to list workspaces');
|
|
24
|
+
}
|
|
25
|
+
const list = res.data?.list || []
|
|
26
|
+
const _list = list.filter(item => {
|
|
27
|
+
// 如果指定了 repo 参数,则只重启该仓库相关的工作区;如果未指定 repo 参数,则重启所有包含 '/dev' 的工作区
|
|
28
|
+
if (repo) {
|
|
29
|
+
if (item.slug === repo) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
if (item.slug.includes('/dev')) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
})
|
|
39
|
+
for (const item of _list) {
|
|
40
|
+
const branch = item.branch || 'main';
|
|
41
|
+
const repo = item.slug;
|
|
42
|
+
const sn = item.sn;
|
|
43
|
+
// 先停止工作区
|
|
44
|
+
const res = await cnb.workspace.stopWorkspace({ sn });
|
|
45
|
+
if (res.code !== 200) {
|
|
46
|
+
ctx.throw(500, res.message || 'Failed to stop workspace');
|
|
47
|
+
} else {
|
|
48
|
+
console.log(`工作区 ${repo} 停止成功,${res.data?.buildLogUrl ? `构建日志链接: ${res.data.buildLogUrl}` : ''}`);
|
|
49
|
+
}
|
|
50
|
+
if (config) {
|
|
51
|
+
await cnb.build.startBuild(repo, { branch, config, event });
|
|
52
|
+
} else {
|
|
53
|
+
await cnb.workspace.startWorkspace(repo, { branch });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
ctx.body = {
|
|
58
|
+
content: '工作区重新启动中',
|
|
59
|
+
}
|
|
60
|
+
}).addTo(app)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createSkill
|
|
1
|
+
import { createSkill } from '@kevisual/router';
|
|
2
2
|
import { app, cnbManager } from '../../app.ts';
|
|
3
3
|
|
|
4
4
|
// 批量删除已停止的cnb工作空间
|
|
@@ -14,7 +14,7 @@ import { app, cnbManager } from '../../app.ts';
|
|
|
14
14
|
// title: '清理已关闭的cnb工作空间',
|
|
15
15
|
// summary: '批量删除已停止的cnb工作空间,释放资源',
|
|
16
16
|
// args: {
|
|
17
|
-
// question:
|
|
17
|
+
// question: z.string().optional().describe('具体的要求的信息'),
|
|
18
18
|
// }
|
|
19
19
|
// })
|
|
20
20
|
// }
|