@kevisual/cnb 0.0.48 → 0.0.49

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
@@ -68227,8 +68227,9 @@ app.route({
68227
68227
  }
68228
68228
  }
68229
68229
  }).define(async (ctx) => {
68230
+ const needExit = ctx.args.needExit ?? true;
68230
68231
  const exit = (code) => {
68231
- if (ctx.args.needExit) {
68232
+ if (needExit) {
68232
68233
  process.exit(code);
68233
68234
  }
68234
68235
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cnb",
3
- "version": "0.0.48",
3
+ "version": "0.0.49",
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,自动化方案。