@kevisual/cnb 0.0.42 → 0.0.43
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/app.ts +5 -4
- package/agent/modules/cnb-manager.ts +20 -2
- package/agent/npc.ts +94 -0
- package/agent/routes/chat/chat.ts +41 -0
- package/agent/routes/index.ts +1 -0
- package/agent/routes/issues/comments.ts +14 -4
- package/agent/routes/issues/list.ts +33 -0
- package/agent/routes/opencode/index.ts +12 -0
- package/dist/cli.js +30510 -21932
- package/dist/keep.js +14 -14
- package/dist/opencode.js +56459 -47891
- package/dist/routes.d.ts +47 -4
- package/dist/routes.js +30383 -21816
- package/package.json +16 -11
- package/src/issue/index.ts +14 -3
- package/src/issue/npc/build-env.ts +217 -0
- package/src/issue/npc/env.ts +73 -296
- package/src/issue/npc/pr-env.ts +95 -0
- package/src/issue/npc/repo-env.ts +56 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/cnb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.43",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"basename": "/root/cnb",
|
|
@@ -12,11 +12,13 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "bun bun.config.ts",
|
|
14
14
|
"flow": "ev npm patch && pnpm build && ev npm publish npm -p",
|
|
15
|
+
"compile": "bun build --compile --minify agent/commander.ts --outfile=./dist/cnb ",
|
|
15
16
|
"pub": "ev pack -u -m false -c -p"
|
|
16
17
|
},
|
|
17
18
|
"keywords": [],
|
|
18
19
|
"bin": {
|
|
19
|
-
"cnb": "./bin/index.js"
|
|
20
|
+
"cnb": "./bin/index.js",
|
|
21
|
+
"cloud": "./bin/index.js"
|
|
20
22
|
},
|
|
21
23
|
"files": [
|
|
22
24
|
"dist",
|
|
@@ -25,22 +27,24 @@
|
|
|
25
27
|
],
|
|
26
28
|
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
|
27
29
|
"license": "MIT",
|
|
28
|
-
"packageManager": "pnpm@10.
|
|
30
|
+
"packageManager": "pnpm@10.32.1",
|
|
29
31
|
"type": "module",
|
|
30
32
|
"devDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@kevisual/
|
|
33
|
+
"@ai-sdk/openai-compatible": "^2.0.35",
|
|
34
|
+
"@kevisual/ai": "^0.0.28",
|
|
35
|
+
"@kevisual/api": "^0.0.64",
|
|
33
36
|
"@kevisual/code-builder": "^0.0.6",
|
|
34
37
|
"@kevisual/context": "^0.0.8",
|
|
35
38
|
"@kevisual/dts": "^0.0.4",
|
|
36
|
-
"@kevisual/remote-app": "^0.0.
|
|
39
|
+
"@kevisual/remote-app": "^0.0.7",
|
|
37
40
|
"@kevisual/types": "^0.0.12",
|
|
38
|
-
"@opencode-ai/plugin": "^1.2.
|
|
41
|
+
"@opencode-ai/plugin": "^1.2.24",
|
|
39
42
|
"@types/bun": "^1.3.10",
|
|
40
|
-
"@types/node": "^25.
|
|
43
|
+
"@types/node": "^25.5.0",
|
|
41
44
|
"@types/ws": "^8.18.1",
|
|
45
|
+
"ai": "^6.0.116",
|
|
42
46
|
"commander": "^14.0.3",
|
|
43
|
-
"dayjs": "^1.11.
|
|
47
|
+
"dayjs": "^1.11.20",
|
|
44
48
|
"dotenv": "^17.3.1"
|
|
45
49
|
},
|
|
46
50
|
"publishConfig": {
|
|
@@ -51,8 +55,9 @@
|
|
|
51
55
|
},
|
|
52
56
|
"dependencies": {
|
|
53
57
|
"@kevisual/query": "^0.0.53",
|
|
54
|
-
"@kevisual/router": "^0.
|
|
58
|
+
"@kevisual/router": "^0.1.1",
|
|
55
59
|
"@kevisual/use-config": "^1.0.30",
|
|
60
|
+
"@opencode-ai/sdk": "^1.2.24",
|
|
56
61
|
"es-toolkit": "^1.45.1",
|
|
57
62
|
"nanoid": "^5.1.6",
|
|
58
63
|
"unstorage": "^1.17.4",
|
|
@@ -60,7 +65,7 @@
|
|
|
60
65
|
"zod": "^4.3.6"
|
|
61
66
|
},
|
|
62
67
|
"exports": {
|
|
63
|
-
".": "./
|
|
68
|
+
".": "./src/index.ts",
|
|
64
69
|
"./opencode": "./dist/opencode.js",
|
|
65
70
|
"./keep": "./dist/keep.js",
|
|
66
71
|
"./keep.ts": "./src/keep.ts",
|
package/src/issue/index.ts
CHANGED
|
@@ -5,12 +5,23 @@ export type IssueAssignee = {
|
|
|
5
5
|
nickname: string;
|
|
6
6
|
username: string;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
8
|
export type IssueLabel = {
|
|
10
9
|
color: string;
|
|
11
10
|
description: string;
|
|
12
11
|
id: string;
|
|
13
12
|
name: string;
|
|
13
|
+
creator?: {
|
|
14
|
+
username: string;
|
|
15
|
+
nickname: string;
|
|
16
|
+
email: string;
|
|
17
|
+
is_npc: boolean;
|
|
18
|
+
};
|
|
19
|
+
applied_by?: {
|
|
20
|
+
username: string;
|
|
21
|
+
nickname: string;
|
|
22
|
+
email: string;
|
|
23
|
+
is_npc: boolean;
|
|
24
|
+
}
|
|
14
25
|
};
|
|
15
26
|
export type IssueState = 'open' | 'closed';
|
|
16
27
|
|
|
@@ -62,14 +73,14 @@ export class Issue extends CNBCore {
|
|
|
62
73
|
super(options);
|
|
63
74
|
}
|
|
64
75
|
|
|
65
|
-
createIssue(repo: string, data: Partial<IssueItem>): Promise<
|
|
76
|
+
createIssue(repo: string, data: Partial<IssueItem>): Promise<Result<IssueItem>> {
|
|
66
77
|
const url = `/${repo}/-/issues`;
|
|
67
78
|
let postData = {
|
|
68
79
|
...data,
|
|
69
80
|
};
|
|
70
81
|
return this.post({ url, data: postData });
|
|
71
82
|
}
|
|
72
|
-
updateIssue(repo: string, issueNumber: string | number, data: Partial<IssueItem>): Promise<
|
|
83
|
+
updateIssue(repo: string, issueNumber: string | number, data: Partial<IssueItem>): Promise<Result<IssueItem>> {
|
|
73
84
|
const url = `/${repo}/-/issues/${issueNumber}`;
|
|
74
85
|
let postData = {
|
|
75
86
|
...data,
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
|
|
2
|
+
import { useKey } from "@kevisual/context";
|
|
3
|
+
|
|
4
|
+
// CNB_BUILD_ID cnb-75b-1jj9hnk99 当前构建的流水号,全局唯一
|
|
5
|
+
// CNB_BUILD_WEB_URL https://cnb.cool/kevision/dev-cnb/-/build/logs/cnb-75b-1jj9hnk99 当前构建的日志地址
|
|
6
|
+
// CNB_BUILD_START_TIME 2026-03-09T14:59:01.550Z 当前构建的开始时间,UTC 格式,示例 2025-08-21T09:13:45.803Z
|
|
7
|
+
// CNB_BUILD_USER xiongxiao 当前构建的触发者用户名
|
|
8
|
+
// CNB_BUILD_USER_NICKNAME 小熊猫呜呜呜 当前构建的触发者昵称
|
|
9
|
+
// CNB_BUILD_USER_EMAIL kevisual@xiongxiao.me 当前构建的触发者邮箱
|
|
10
|
+
// CNB_BUILD_USER_ID 1935321989751226368 当前构建的触发者 id
|
|
11
|
+
// CNB_BUILD_USER_NPC_SLUG 当前构建若为 NPC 触发,则为 NPC 所属仓库的路径
|
|
12
|
+
// CNB_BUILD_USER_NPC_NAME 当前构建若为 NPC 触发,则为 NPC 角色名
|
|
13
|
+
// CNB_BUILD_STAGE_NAME 初始化开发机 当前构建的 stage 名称
|
|
14
|
+
// CNB_BUILD_JOB_NAME 初始化开发机 当前构建的 job 名称
|
|
15
|
+
// CNB_BUILD_JOB_KEY job-0 当前构建的 job key,同 stage 下唯一
|
|
16
|
+
// CNB_BUILD_WORKSPACE /workspace/ 自定义 shell 脚本执行的工作空间根目录
|
|
17
|
+
// CNB_BUILD_FAILED_MSG 流水线构建失败的错误信息,可在 failStages 中使用
|
|
18
|
+
// CNB_BUILD_FAILED_STAGE_NAME 流水线构建失败的 stage 的名称,可在 failStages 中使用
|
|
19
|
+
// CNB_PIPELINE_NAME pipeline-1 当前 pipeline 的 name,没声明时为空
|
|
20
|
+
// CNB_PIPELINE_KEY pipeline-1 当前 pipeline 的索引 key,例如 pipeline-0
|
|
21
|
+
// CNB_PIPELINE_ID cnb-75b-1jj9hnk99-001 当前 pipeline 的 id,全局唯一字符串
|
|
22
|
+
// CNB_PIPELINE_DOCKER_IMAGE docker.cnb.cool/kevisual/dev-env:latest 当前 pipeline 所使用的 docker image,如:alpine:latest
|
|
23
|
+
// CNB_PIPELINE_STATUS 当前流水线的构建状态,可在 endStages 中查看,其可能的值包括:success、error、cancel
|
|
24
|
+
// CNB_PIPELINE_MAX_RUN_TIME 72000000 流水线最大运行时间,单位为毫秒
|
|
25
|
+
// CNB_RUNNER_IP 10.235.16.3 当前 pipeline 所在 Runner 的 ip
|
|
26
|
+
// CNB_CPUS 16 当前构建流水线可以使用的最大 CPU 核数
|
|
27
|
+
// CNB_MEMORY 32 当前构建流水线可以使用的最大内存大小,单位为 GiB
|
|
28
|
+
// CNB_IS_RETRY false 当前构建是否由 rebuild 触发
|
|
29
|
+
// HUSKY_SKIP_INSTALL 1 兼容 ci 环境下 husky
|
|
30
|
+
export const useBuildEnv = () => {
|
|
31
|
+
const buildId = useKey("CNB_BUILD_ID");
|
|
32
|
+
const buildWebUrl = useKey("CNB_BUILD_WEB_URL");
|
|
33
|
+
const buildStartTime = useKey("CNB_BUILD_START_TIME");
|
|
34
|
+
const buildUser = useKey("CNB_BUILD_USER");
|
|
35
|
+
const buildUserNickname = useKey("CNB_BUILD_USER_NICKNAME");
|
|
36
|
+
const buildUserEmail = useKey("CNB_BUILD_USER_EMAIL");
|
|
37
|
+
const buildUserId = useKey("CNB_BUILD_USER_ID");
|
|
38
|
+
const buildUserNpcSlug = useKey("CNB_BUILD_USER_NPC_SLUG");
|
|
39
|
+
const buildUserNpcName = useKey("CNB_BUILD_USER_NPC_NAME");
|
|
40
|
+
const buildStageName = useKey("CNB_BUILD_STAGE_NAME");
|
|
41
|
+
const buildJobName = useKey("CNB_BUILD_JOB_NAME");
|
|
42
|
+
const buildJobKey = useKey("CNB_BUILD_JOB_KEY");
|
|
43
|
+
const buildWorkspace = useKey("CNB_BUILD_WORKSPACE");
|
|
44
|
+
const buildFailedMsg = useKey("CNB_BUILD_FAILED_MSG");
|
|
45
|
+
const buildFailedStageName = useKey("CNB_BUILD_FAILED_STAGE_NAME");
|
|
46
|
+
const pipelineName = useKey("CNB_PIPELINE_NAME");
|
|
47
|
+
const pipelineKey = useKey("CNB_PIPELINE_KEY");
|
|
48
|
+
const pipelineId = useKey("CNB_PIPELINE_ID");
|
|
49
|
+
const pipelineDockerImage = useKey("CNB_PIPELINE_DOCKER_IMAGE");
|
|
50
|
+
const pipelineStatus = useKey("CNB_PIPELINE_STATUS");
|
|
51
|
+
const pipelineMaxRunTime = useKey("CNB_PIPELINE_MAX_RUN_TIME");
|
|
52
|
+
const runnerIp = useKey("CNB_RUNNER_IP");
|
|
53
|
+
const cpus = useKey("CNB_CPUS");
|
|
54
|
+
const memory = useKey("CNB_MEMORY");
|
|
55
|
+
const isRetry = useKey("CNB_IS_RETRY");
|
|
56
|
+
const huskySkipInstall = useKey("HUSKY_SKIP_INSTALL");
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
/**
|
|
60
|
+
* @key CNB_BUILD_ID
|
|
61
|
+
* @description:当前构建的流水号,全局唯一
|
|
62
|
+
*/
|
|
63
|
+
buildId,
|
|
64
|
+
buildIdLabel: "当前构建的流水号,全局唯一",
|
|
65
|
+
/**
|
|
66
|
+
* @key CNB_BUILD_WEB_URL
|
|
67
|
+
* @description:当前构建的日志地址
|
|
68
|
+
*/
|
|
69
|
+
buildWebUrl,
|
|
70
|
+
buildWebUrlLabel: "当前构建的日志地址",
|
|
71
|
+
/**
|
|
72
|
+
* @key CNB_BUILD_START_TIME
|
|
73
|
+
* @description:当前构建的开始时间,UTC 格式
|
|
74
|
+
*/
|
|
75
|
+
buildStartTime,
|
|
76
|
+
buildStartTimeLabel: "当前构建的开始时间,UTC 格式",
|
|
77
|
+
/**
|
|
78
|
+
* @key CNB_BUILD_USER
|
|
79
|
+
* @description:当前构建的触发者用户名
|
|
80
|
+
*/
|
|
81
|
+
buildUser,
|
|
82
|
+
buildUserLabel: "当前构建的触发者用户名",
|
|
83
|
+
/**
|
|
84
|
+
* @key CNB_BUILD_USER_NICKNAME
|
|
85
|
+
* @description:当前构建的触发者昵称
|
|
86
|
+
*/
|
|
87
|
+
buildUserNickname,
|
|
88
|
+
buildUserNicknameLabel: "当前构建的触发者昵称",
|
|
89
|
+
/**
|
|
90
|
+
* @key CNB_BUILD_USER_EMAIL
|
|
91
|
+
* @description:当前构建的触发者邮箱
|
|
92
|
+
*/
|
|
93
|
+
buildUserEmail,
|
|
94
|
+
buildUserEmailLabel: "当前构建的触发者邮箱",
|
|
95
|
+
/**
|
|
96
|
+
* @key CNB_BUILD_USER_ID
|
|
97
|
+
* @description:当前构建的触发者 id
|
|
98
|
+
*/
|
|
99
|
+
buildUserId,
|
|
100
|
+
buildUserIdLabel: "当前构建的触发者 id",
|
|
101
|
+
/**
|
|
102
|
+
* @key CNB_BUILD_USER_NPC_SLUG
|
|
103
|
+
* @description:当前构建若为 NPC 触发,则为 NPC 所属仓库的路径
|
|
104
|
+
*/
|
|
105
|
+
buildUserNpcSlug,
|
|
106
|
+
buildUserNpcSlugLabel: "当前构建若为 NPC 触发,则为 NPC 所属仓库的路径",
|
|
107
|
+
/**
|
|
108
|
+
* @key CNB_BUILD_USER_NPC_NAME
|
|
109
|
+
* @description:当前构建若为 NPC 触发,则为 NPC 角色名
|
|
110
|
+
*/
|
|
111
|
+
buildUserNpcName,
|
|
112
|
+
buildUserNpcNameLabel: "当前构建若为 NPC 触发,则为 NPC 角色名",
|
|
113
|
+
/**
|
|
114
|
+
* @key CNB_BUILD_STAGE_NAME
|
|
115
|
+
* @description:当前构建的 stage 名称
|
|
116
|
+
*/
|
|
117
|
+
buildStageName,
|
|
118
|
+
buildStageNameLabel: "当前构建的 stage 名称",
|
|
119
|
+
/**
|
|
120
|
+
* @key CNB_BUILD_JOB_NAME
|
|
121
|
+
* @description:当前构建的 job 名称
|
|
122
|
+
*/
|
|
123
|
+
buildJobName,
|
|
124
|
+
buildJobNameLabel: "当前构建的 job 名称",
|
|
125
|
+
/**
|
|
126
|
+
* @key CNB_BUILD_JOB_KEY
|
|
127
|
+
* @description:当前构建的 job key,同 stage 下唯一
|
|
128
|
+
*/
|
|
129
|
+
buildJobKey,
|
|
130
|
+
buildJobKeyLabel: "当前构建的 job key,同 stage 下唯一",
|
|
131
|
+
/**
|
|
132
|
+
* @key CNB_BUILD_WORKSPACE
|
|
133
|
+
* @description:自定义 shell 脚本执行的工作空间根目录
|
|
134
|
+
*/
|
|
135
|
+
buildWorkspace,
|
|
136
|
+
buildWorkspaceLabel: "自定义 shell 脚本执行的工作空间根目录",
|
|
137
|
+
/**
|
|
138
|
+
* @key CNB_BUILD_FAILED_MSG
|
|
139
|
+
* @description:流水线构建失败的错误信息
|
|
140
|
+
*/
|
|
141
|
+
buildFailedMsg,
|
|
142
|
+
buildFailedMsgLabel: "流水线构建失败的错误信息",
|
|
143
|
+
/**
|
|
144
|
+
* @key CNB_BUILD_FAILED_STAGE_NAME
|
|
145
|
+
* @description:流水线构建失败的 stage 的名称
|
|
146
|
+
*/
|
|
147
|
+
buildFailedStageName,
|
|
148
|
+
buildFailedStageNameLabel: "流水线构建失败的 stage 的名称",
|
|
149
|
+
/**
|
|
150
|
+
* @key CNB_PIPELINE_NAME
|
|
151
|
+
* @description:当前 pipeline 的 name
|
|
152
|
+
*/
|
|
153
|
+
pipelineName,
|
|
154
|
+
pipelineNameLabel: "当前 pipeline 的 name",
|
|
155
|
+
/**
|
|
156
|
+
* @key CNB_PIPELINE_KEY
|
|
157
|
+
* @description:当前 pipeline 的索引 key
|
|
158
|
+
*/
|
|
159
|
+
pipelineKey,
|
|
160
|
+
pipelineKeyLabel: "当前 pipeline 的索引 key",
|
|
161
|
+
/**
|
|
162
|
+
* @key CNB_PIPELINE_ID
|
|
163
|
+
* @description:当前 pipeline 的 id
|
|
164
|
+
*/
|
|
165
|
+
pipelineId,
|
|
166
|
+
pipelineIdLabel: "当前 pipeline 的 id",
|
|
167
|
+
/**
|
|
168
|
+
* @key CNB_PIPELINE_DOCKER_IMAGE
|
|
169
|
+
* @description:当前 pipeline 所使用的 docker image
|
|
170
|
+
*/
|
|
171
|
+
pipelineDockerImage,
|
|
172
|
+
pipelineDockerImageLabel: "当前 pipeline 所使用的 docker image",
|
|
173
|
+
/**
|
|
174
|
+
* @key CNB_PIPELINE_STATUS
|
|
175
|
+
* @description:当前流水线的构建状态,可能的值包括:success、error、cancel
|
|
176
|
+
*/
|
|
177
|
+
pipelineStatus,
|
|
178
|
+
pipelineStatusLabel: "当前流水线的构建状态,可能的值包括:success、error、cancel",
|
|
179
|
+
/**
|
|
180
|
+
* @key CNB_PIPELINE_MAX_RUN_TIME
|
|
181
|
+
* @description:流水线最大运行时间,单位为毫秒
|
|
182
|
+
*/
|
|
183
|
+
pipelineMaxRunTime,
|
|
184
|
+
pipelineMaxRunTimeLabel: "流水线最大运行时间,单位为毫秒",
|
|
185
|
+
/**
|
|
186
|
+
* @key CNB_RUNNER_IP
|
|
187
|
+
* @description:当前 pipeline 所在 Runner 的 ip
|
|
188
|
+
*/
|
|
189
|
+
runnerIp,
|
|
190
|
+
runnerIpLabel: "当前 pipeline 所在 Runner 的 ip",
|
|
191
|
+
/**
|
|
192
|
+
* @key CNB_CPUS
|
|
193
|
+
* @description:当前构建流水线可以使用的最大 CPU 核数
|
|
194
|
+
*/
|
|
195
|
+
cpus,
|
|
196
|
+
cpusLabel: "当前构建流水线可以使用的最大 CPU 核数",
|
|
197
|
+
/**
|
|
198
|
+
* @key CNB_MEMORY
|
|
199
|
+
* @description:当前构建流水线可以使用的最大内存大小,单位为 GiB
|
|
200
|
+
*/
|
|
201
|
+
memory,
|
|
202
|
+
memoryLabel: "当前构建流水线可以使用的最大内存大小,单位为 GiB",
|
|
203
|
+
/**
|
|
204
|
+
* @key CNB_IS_RETRY
|
|
205
|
+
* @description:当前构建是否由 rebuild 触发
|
|
206
|
+
*/
|
|
207
|
+
isRetry,
|
|
208
|
+
isRetryLabel: "当前构建是否由 rebuild 触发",
|
|
209
|
+
/**
|
|
210
|
+
* @key HUSKY_SKIP_INSTALL
|
|
211
|
+
* @description:兼容 ci 环境下 husky
|
|
212
|
+
*/
|
|
213
|
+
huskySkipInstall,
|
|
214
|
+
huskySkipInstallLabel: "兼容 ci 环境下 husky"
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|