@kevisual/cnb 0.0.40 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cnb",
3
- "version": "0.0.40",
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.31.0",
30
+ "packageManager": "pnpm@10.32.1",
29
31
  "type": "module",
30
32
  "devDependencies": {
31
- "@kevisual/ai": "^0.0.26",
32
- "@kevisual/api": "^0.0.62",
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.6",
39
+ "@kevisual/remote-app": "^0.0.7",
37
40
  "@kevisual/types": "^0.0.12",
38
- "@opencode-ai/plugin": "^1.2.23",
41
+ "@opencode-ai/plugin": "^1.2.24",
39
42
  "@types/bun": "^1.3.10",
40
- "@types/node": "^25.3.5",
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.19",
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.0.90",
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
- ".": "./mod.ts",
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/index.ts CHANGED
@@ -67,4 +67,17 @@ export * from './user/index.ts'
67
67
  export * from './build/index.ts'
68
68
  export * from './issue/index.ts'
69
69
  export * from './mission/index.ts'
70
- export * from './ai/index.ts'
70
+ export * from './ai/index.ts'
71
+
72
+ export const getCNBVersion = () => {
73
+ const url = 'https://cnb.cool/api/version';
74
+ // {"version":"1.18.8-2e3e01f0-20260309","commitID":"2e3e01f0","hash":"897b088418dccd05"}
75
+ return fetch(url).then(res => res.json()) as Promise<VersionInfo>;
76
+ }
77
+ type VersionInfo = {
78
+ version: string;
79
+ commitID: string;
80
+ hash: string;
81
+ }
82
+
83
+ export * from './issue/npc/env.ts'
@@ -1,16 +1,27 @@
1
1
  import { CNBCore, CNBCoreOptions, RequestOptions, Result } from "../cnb-core.ts";
2
2
  import { extractAliveInfo } from "./issue-alive.ts";
3
-
3
+ import { useNPCEnv, useCommentEnv, usePullRequestEnv, useRepoInfoEnv } from "./npc/env.ts";
4
4
  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
 
@@ -22,6 +33,26 @@ export type IssueAuthor = {
22
33
  ended_at: string;
23
34
  };
24
35
 
36
+ export type IssueCommentUser = {
37
+ username: string;
38
+ nickname: string;
39
+ avatar: string;
40
+ is_npc: boolean;
41
+ };
42
+
43
+ export type IssueCommentReaction = {
44
+ // 根据实际返回数据补充
45
+ };
46
+
47
+ export type IssueComment = {
48
+ id: string;
49
+ body: string;
50
+ author: IssueCommentUser;
51
+ reactions: IssueCommentReaction[];
52
+ created_at: string;
53
+ updated_at: string;
54
+ };
55
+
25
56
  export type IssueItem = {
26
57
  assignees: IssueAssignee[];
27
58
  author: IssueAuthor;
@@ -42,14 +73,14 @@ export class Issue extends CNBCore {
42
73
  super(options);
43
74
  }
44
75
 
45
- createIssue(repo: string, data: Partial<IssueItem>): Promise<any> {
76
+ createIssue(repo: string, data: Partial<IssueItem>): Promise<Result<IssueItem>> {
46
77
  const url = `/${repo}/-/issues`;
47
78
  let postData = {
48
79
  ...data,
49
80
  };
50
81
  return this.post({ url, data: postData });
51
82
  }
52
- updateIssue(repo: string, issueNumber: string | number, data: Partial<IssueItem>): Promise<any> {
83
+ updateIssue(repo: string, issueNumber: string | number, data: Partial<IssueItem>): Promise<Result<IssueItem>> {
53
84
  const url = `/${repo}/-/issues/${issueNumber}`;
54
85
  let postData = {
55
86
  ...data,
@@ -76,10 +107,34 @@ export class Issue extends CNBCore {
76
107
  }
77
108
  });
78
109
  }
79
- getCommentList(repo: string, issueNumber: string | number): Promise<any> {
110
+ getCommentList(repo: string, issueNumber: string | number, params?: { page?: number; page_size?: number }): Promise<Result<IssueComment[]>> {
80
111
  const url = `/${repo}/-/issues/${issueNumber}/comments`;
81
112
  return this.get({
82
113
  url,
114
+ params,
115
+ });
116
+ }
117
+
118
+ getComment(repo: string, issueNumber: string | number, commentId: string | number): Promise<Result<IssueComment>> {
119
+ const url = `/${repo}/-/issues/${issueNumber}/comments/${commentId}`;
120
+ return this.get({
121
+ url,
122
+ });
123
+ }
124
+
125
+ createComment(repo: string, issueNumber: string | number, body: string): Promise<Result<IssueComment>> {
126
+ const url = `/${repo}/-/issues/${issueNumber}/comments`;
127
+ return this.post({
128
+ url,
129
+ data: { body },
130
+ });
131
+ }
132
+
133
+ updateComment(repo: string, issueNumber: string | number, commentId: string | number, body: string): Promise<Result<IssueComment>> {
134
+ const url = `/${repo}/-/issues/${issueNumber}/comments/${commentId}`;
135
+ return this.patch({
136
+ url,
137
+ data: { body },
83
138
  });
84
139
  }
85
140
  setIssueProperty(repo: string, issueNumber: string | number, properties: { [key: string]: any }[]): Promise<any> {
@@ -134,6 +189,18 @@ export class Issue extends CNBCore {
134
189
  },
135
190
  };
136
191
  }
192
+ useNPCEnv() {
193
+ return useNPCEnv();
194
+ }
195
+ useCommentEnv() {
196
+ return useCommentEnv();
197
+ }
198
+ usePullRequestEnv() {
199
+ return usePullRequestEnv();
200
+ }
201
+ useRepoInfoEnv() {
202
+ return useRepoInfoEnv();
203
+ }
137
204
  }
138
205
 
139
206
  type GetListParams = {
@@ -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
+
@@ -0,0 +1,194 @@
1
+ // CNB_NPC_SLUG 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库路径,否则为空字符串
2
+ // CNB_NPC_NAME 对于 NPC 事件触发的构建,值为 NPC 角色名,否则为空字符串
3
+ // CNB_NPC_SHA 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库默认分支最新提交的 sha,否则为空字符串
4
+ // CNB_NPC_PROMPT 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色 Prompt,否则为空字符串
5
+ // CNB_NPC_AVATAR 对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色头像,否则为空字符串
6
+ // CNB_NPC_ENABLE_THINKING 对于 @npc 事件触发的构建,值为 NPC 角色是否开启思考,否则为空字符串
7
+ import { useKey } from "@kevisual/context";
8
+
9
+ export function useNPCEnv() {
10
+ const npcSlug = useKey("CNB_NPC_SLUG");
11
+ const npcName = useKey("CNB_NPC_NAME");
12
+ const npcSha = useKey("CNB_NPC_SHA");
13
+ const npcPrompt = useKey("CNB_NPC_PROMPT");
14
+ const npcAvatar = useKey("CNB_NPC_AVATAR");
15
+ const npcEnableThinking = useKey("CNB_NPC_ENABLE_THINKING");
16
+
17
+ return {
18
+ /**
19
+ * @key CNB_NPC_SLUG
20
+ * @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库路径,否则为空字符串
21
+ */
22
+ npcSlug,
23
+ npcSlugLabel: "对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库路径,否则为空字符串",
24
+ /**
25
+ * @key CNB_NPC_NAME
26
+ * @description:对于 NPC 事件触发的构建,值为 NPC 角色名,否则为空字符串
27
+ */
28
+ npcName,
29
+ npcNameLabel: "对于 NPC 事件触发的构建,值为 NPC 角色名,否则为空字符串",
30
+ /**
31
+ * @key CNB_NPC_SHA
32
+ * @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库默认分支最新提交的 sha,否则为空字符串
33
+ */
34
+ npcSha,
35
+ npcShaLabel: "对于 @ 知识库角色触发的 NPC 事件,值为 NPC 所属仓库默认分支最新提交的 sha,否则为空字符串",
36
+ /**
37
+ * @key CNB_NPC_PROMPT
38
+ * @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色 Prompt,否则为空字符串
39
+ */
40
+ npcPrompt,
41
+ npcPromptLabel: "对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色 Prompt,否则为空字符串",
42
+ /**
43
+ * @key CNB_NPC_AVATAR
44
+ * @description:对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色头像,否则为空字符串
45
+ */
46
+ npcAvatar,
47
+ npcAvatarLabel: "对于 @ 知识库角色触发的 NPC 事件,值为 NPC 角色头像,否则为空字符串",
48
+ /**
49
+ * @key CNB_NPC_ENABLE_THINKING
50
+ * @description:对于 @npc 事件触发的构建,值为 NPC 角色是否开启思考,否则为空字符串
51
+ */
52
+ npcEnableThinking,
53
+ npcEnableThinkingLabel: "对于 @npc 事件触发的构建,值为 NPC 角色是否开启思考,否则为空字符串"
54
+ };
55
+ }
56
+
57
+ // CNB_COMMENT_ID 对于评论事件触发的构建,值为评论全局唯一 ID,否则为空字符串
58
+ // CNB_COMMENT_BODY 对于评论事件触发的构建,值为评论内容,否则为空字符串
59
+ // CNB_COMMENT_TYPE note 对于 PR 代码评审评论,值为 diff_note;对于 PR 非代码评审评论以及 Issue 评论,值为 note;否则为空字符串
60
+ // CNB_COMMENT_FILE_PATH 对于 PR 代码评审评论,值为评论所在文件,否则为空字符串
61
+ // CNB_COMMENT_RANGE 对于 PR 代码评审评论,值为评论所在代码行。如,单行为 L12,多行为 L13-L16,否则为空字符串
62
+ // CNB_REVIEW_ID 对于 PR 代码评审,值为评审 ID,否则为空字符串
63
+
64
+ export function useCommentEnv() {
65
+ const commentId = useKey("CNB_COMMENT_ID");
66
+ const commentBody = useKey("CNB_COMMENT_BODY");
67
+ const commentType = useKey("CNB_COMMENT_TYPE");
68
+ const commentFilePath = useKey("CNB_COMMENT_FILE_PATH");
69
+ const commentRange = useKey("CNB_COMMENT_RANGE");
70
+ const reviewId = useKey("CNB_REVIEW_ID");
71
+
72
+ return {
73
+ /**
74
+ * @key CNB_COMMENT_ID
75
+ * @description:对于评论事件触发的构建,值为评论全局唯一 ID,否则为空字符串
76
+ */
77
+ commentId,
78
+ commentIdLabel: "对于评论事件触发的构建,值为评论全局唯一 ID,否则为空字符串",
79
+ /**
80
+ * @key CNB_COMMENT_BODY
81
+ * @description:对于评论事件触发的构建,值为评论内容,否则为空字符串
82
+ */
83
+ commentBody,
84
+ commentBodyLabel: "对于评论事件触发的构建,值为评论内容,否则为空字符串",
85
+ /**
86
+ * @key CNB_COMMENT_TYPE
87
+ * @description:note 对于 PR 代码评审评论,值为 diff_note;对于 PR 非代码评审评论以及 Issue 评论,值为 note;否则为空字符串
88
+ */
89
+ commentType,
90
+ commentTypeLabel: "对于 PR 代码评审评论,值为 diff_note;对于 PR 非代码评审评论以及 Issue 评论,值为 note;否则为空字符串",
91
+ /**
92
+ * @key CNB_COMMENT_FILE_PATH
93
+ * @description:对于 PR 代码评审评论,值为评论所在文件,否则为空字符串
94
+ */
95
+ commentFilePath,
96
+ commentFilePathLabel: "对于 PR 代码评审评论,值为评论所在文件,否则为空字符串",
97
+ /**
98
+ * @key CNB_COMMENT_RANGE
99
+ * @description:对于 PR 代码评审评论,值为评论所在代码行。如,单行为 L12,多行为 L13-L16,否则为空字符串
100
+ */
101
+ commentRange,
102
+ commentRangeLabel: "对于 PR 代码评审评论,值为评论所在代码行。如,单行为 L12,多行为 L13-L16,否则为空字符串",
103
+ /**
104
+ * @key CNB_REVIEW_ID
105
+ * @description:对于 PR 代码评审,值为评审 ID,否则为空字符串
106
+ */
107
+ reviewId,
108
+ reviewIdLabel: "对于 PR 代码评审,值为评审 ID,否则为空字符串"
109
+ };
110
+ }
111
+
112
+ // CNB_ISSUE_ID Issue 全局唯一 ID
113
+ // CNB_ISSUE_IID Issue 仓库编号
114
+ // CNB_ISSUE_TITLE Issue 标题
115
+ // CNB_ISSUE_DESCRIPTION Issue 描述
116
+ // CNB_ISSUE_OWNER Issue 作者
117
+ // CNB_ISSUE_STATE Issue 状态
118
+ // CNB_ISSUE_IS_RESOLVED Issue 是否已解决
119
+ // CNB_ISSUE_ASSIGNEES Issue 处理人列表
120
+ // CNB_ISSUE_LABELS Issue 标签列表
121
+ // CNB_ISSUE_PRIORITY Issue 优先级
122
+ export const useIssueEnv = () => {
123
+ const issueId = useKey("CNB_ISSUE_ID");
124
+ const issueIid = useKey("CNB_ISSUE_IID");
125
+ const issueTitle = useKey("CNB_ISSUE_TITLE");
126
+ const issueDescription = useKey("CNB_ISSUE_DESCRIPTION");
127
+ const issueOwner = useKey("CNB_ISSUE_OWNER");
128
+ const issueState = useKey("CNB_ISSUE_STATE");
129
+ const issueIsResolved = useKey("CNB_ISSUE_IS_RESOLVED");
130
+ const issueAssignees = useKey("CNB_ISSUE_ASSIGNEES");
131
+ const issuePriority = useKey("CNB_ISSUE_PRIORITY");
132
+
133
+ return {
134
+ /**
135
+ * @key CNB_ISSUE_ID
136
+ * @description:Issue 全局唯一 ID
137
+ */
138
+ issueId,
139
+ issueIdLabel: "Issue 全局唯一 ID",
140
+ /**
141
+ * @key CNB_ISSUE_IID
142
+ * @description:Issue 仓库编号
143
+ */
144
+ issueIid,
145
+ issueIidLabel: "Issue 仓库编号",
146
+ /**
147
+ * @key CNB_ISSUE_TITLE
148
+ * @description:Issue 标题
149
+ */
150
+ issueTitle,
151
+ issueTitleLabel: "Issue 标题",
152
+ /**
153
+ * @key CNB_ISSUE_DESCRIPTION
154
+ * @description:Issue 描述
155
+ */
156
+ issueDescription,
157
+ issueDescriptionLabel: "Issue 描述",
158
+ /**
159
+ * @key CNB_ISSUE_OWNER
160
+ * @description:Issue 作者
161
+ */
162
+ issueOwner,
163
+ issueOwnerLabel: "Issue 作者",
164
+ /**
165
+ * @key CNB_ISSUE_STATE
166
+ * @description:Issue 状态
167
+ */
168
+ issueState,
169
+ issueStateLabel: "Issue 状态",
170
+ /**
171
+ * @key CNB_ISSUE_IS_RESOLVED
172
+ * @description:Issue 是否已解决
173
+ */
174
+ issueIsResolved,
175
+ issueIsResolvedLabel: "Issue 是否已解决",
176
+ /**
177
+ * @key CNB_ISSUE_ASSIGNEES
178
+ * @description:Issue 处理人列表
179
+ */
180
+ issueAssignees,
181
+ issueAssigneesLabel: "Issue 处理人列表",
182
+ /**
183
+ * @key CNB_ISSUE_PRIORITY
184
+ * @description:Issue 优先级
185
+ */
186
+ issuePriority,
187
+ issuePriorityLabel: "Issue 优先级"
188
+ };
189
+ }
190
+
191
+
192
+ export * from './build-env.ts'
193
+ export * from './pr-env.ts'
194
+ export * from './repo-env.ts'