@kevisual/cnb 0.0.48 → 0.0.50

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/npc.ts CHANGED
@@ -4,6 +4,7 @@ import { parse } from '@kevisual/router/src/commander.ts';
4
4
  import { useIssueEnv, useCommentEnv, useRepoInfoEnv, IssueLabel } from '../src/index.ts'
5
5
  import { pick } from 'es-toolkit';
6
6
  import z from 'zod';
7
+ import { useKey } from '@kevisual/context';
7
8
 
8
9
  const writeToProcess = (message: string) => {
9
10
  if (process.send) {
@@ -38,7 +39,7 @@ const getIssuesLabels = async () => {
38
39
 
39
40
  }
40
41
 
41
- const main = async ({ exit }: { exit: (code: number) => void }) => {
42
+ const main = async ({ exit, question }: { exit: (code: number) => void, question?: string }) => {
42
43
  const repoInfoEnv = useRepoInfoEnv();
43
44
  const commentEnv = useCommentEnv();
44
45
  const issueEnv = useIssueEnv();
@@ -70,7 +71,7 @@ const main = async ({ exit }: { exit: (code: number) => void }) => {
70
71
  content: `相关变量:${JSON.stringify({ ...pickCommentEnv, ...pickIssueEnv, ...pickRepoInfoEnv })}`
71
72
  }, {
72
73
  role: 'user',
73
- content: commentEnv.commentBody || pickIssueEnv.issueDescription || '无'
74
+ content: question || commentEnv.commentBody || pickIssueEnv.issueDescription || '无'
74
75
  }
75
76
  ]
76
77
  writeToProcess('输入消息:');
@@ -100,16 +101,25 @@ app.route({
100
101
  metadata: {
101
102
  tags: ['notInNpcAgent'],
102
103
  args: {
103
- needExit: z.boolean().optional().describe('是否需要在执行完成后退出进程')
104
+ needExit: z.boolean().optional().describe('是否需要在执行完成后退出进程'),
105
+ owner: z.string().optional().describe('用户名称')
104
106
  }
105
107
  }
106
108
  }).define(async (ctx) => {
109
+ const needExit = ctx.args.needExit ?? true;
110
+ const owner = ctx.args.owner || '';
107
111
  const exit = (code: number) => {
108
- if (ctx.args.needExit) {
112
+ if (needExit) {
109
113
  process.exit(code);
110
114
  }
111
115
  }
112
- await main({ exit });
116
+ const buildUserNickName = useKey('CNB_BUILD_USER_NICKNAME')
117
+ let admins = owner.split(',').map(item => item.trim());
118
+ if (owner && admins.includes(buildUserNickName)) {
119
+ await main({ exit });
120
+ } else {
121
+ await main({ exit, question: `你是${owner}的专属助手,请生成一条评论,说明你不具备其他用户能访问的能力。同时你需要提示说明,fork当前仓库后,即可成为你的专属助手` });
122
+ }
113
123
  }).addTo(app)
114
124
 
115
125
  parse({ app: app, description: 'CNB控制台命令行工具', parse: true })
package/bin/npc.js CHANGED
File without changes
package/dist/npc.js CHANGED
@@ -68162,7 +68162,7 @@ var getIssuesLabels = async () => {
68162
68162
  console.error("获取 Issue 详情失败", res);
68163
68163
  return [];
68164
68164
  };
68165
- var main = async ({ exit }) => {
68165
+ var main = async ({ exit, question }) => {
68166
68166
  const repoInfoEnv = useRepoInfoEnv();
68167
68167
  const commentEnv = useCommentEnv();
68168
68168
  const issueEnv = useIssueEnv();
@@ -68194,7 +68194,7 @@ var main = async ({ exit }) => {
68194
68194
  },
68195
68195
  {
68196
68196
  role: "user",
68197
- content: commentEnv.commentBody || pickIssueEnv.issueDescription || "无"
68197
+ content: question || commentEnv.commentBody || pickIssueEnv.issueDescription || "无"
68198
68198
  }
68199
68199
  ];
68200
68200
  writeToProcess("输入消息:");
@@ -68223,15 +68223,24 @@ app.route({
68223
68223
  metadata: {
68224
68224
  tags: ["notInNpcAgent"],
68225
68225
  args: {
68226
- needExit: zod_default.boolean().optional().describe("是否需要在执行完成后退出进程")
68226
+ needExit: zod_default.boolean().optional().describe("是否需要在执行完成后退出进程"),
68227
+ owner: zod_default.string().optional().describe("用户名称")
68227
68228
  }
68228
68229
  }
68229
68230
  }).define(async (ctx) => {
68231
+ const needExit = ctx.args.needExit ?? true;
68232
+ const owner = ctx.args.owner || "";
68230
68233
  const exit = (code) => {
68231
- if (ctx.args.needExit) {
68234
+ if (needExit) {
68232
68235
  process.exit(code);
68233
68236
  }
68234
68237
  };
68235
- await main({ exit });
68238
+ const buildUserNickName = useKey("CNB_BUILD_USER_NICKNAME");
68239
+ let admins = owner.split(",").map((item) => item.trim());
68240
+ if (owner && admins.includes(buildUserNickName)) {
68241
+ await main({ exit });
68242
+ } else {
68243
+ await main({ exit, question: `你是${owner}的专属助手,请生成一条评论,说明你不具备其他用户能访问的能力。同时你需要提示说明,fork当前仓库后,即可成为你的专属助手` });
68244
+ }
68236
68245
  }).addTo(app);
68237
68246
  parse12({ app, description: "CNB控制台命令行工具", parse: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cnb",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "basename": "/root/cnb",
package/readme.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # cnb.cool 能做什么
2
2
 
3
3
  所有的代码仓库,只基于一个准则 `group/repo`
4
+
5
+ ## 环境变量
6
+
7
+ ```sh
8
+ CNB_API_KEY
9
+ CNB_COOKIE
10
+ ```
4
11
  ## 简介
5
12
 
6
13
  纯粹调用api的模式去使用cnb.cool,自动化方案。