From 95bcad75876738b77ce26872d13db2d44d4e2011 Mon Sep 17 00:00:00 2001 From: xiongxiao Date: Mon, 16 Mar 2026 22:20:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.cnb.yml=20=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=8F=82=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20agent/npc.ts=20=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E7=A7=B0=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20package.json=20=E7=89=88=E6=9C=AC=EF=BC=8C=E5=AE=8C=E5=96=84?= =?UTF-8?q?=20readme.md=20=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cnb.yml | 2 +- agent/npc.ts | 17 +++++++++++++---- package.json | 2 +- readme.md | 7 +++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.cnb.yml b/.cnb.yml index 534e489..edadcbc 100644 --- a/.cnb.yml +++ b/.cnb.yml @@ -19,7 +19,7 @@ include: - name: "task" script: | git clone https://cnb.cool/kevisual/cnb cnb - cd cnb && bun run agent/npc.ts cnb npc + cd cnb && bun run agent/npc.ts cnb npc --args owner="小熊猫呜呜呜" $: vscode: - docker: diff --git a/agent/npc.ts b/agent/npc.ts index 27c6d27..8961573 100644 --- a/agent/npc.ts +++ b/agent/npc.ts @@ -4,6 +4,7 @@ import { parse } from '@kevisual/router/src/commander.ts'; import { useIssueEnv, useCommentEnv, useRepoInfoEnv, IssueLabel } from '../src/index.ts' import { pick } from 'es-toolkit'; import z from 'zod'; +import { useKey } from '@kevisual/context'; const writeToProcess = (message: string) => { if (process.send) { @@ -38,7 +39,7 @@ const getIssuesLabels = async () => { } -const main = async ({ exit }: { exit: (code: number) => void }) => { +const main = async ({ exit, question }: { exit: (code: number) => void, question?: string }) => { const repoInfoEnv = useRepoInfoEnv(); const commentEnv = useCommentEnv(); const issueEnv = useIssueEnv(); @@ -70,7 +71,7 @@ const main = async ({ exit }: { exit: (code: number) => void }) => { content: `相关变量:${JSON.stringify({ ...pickCommentEnv, ...pickIssueEnv, ...pickRepoInfoEnv })}` }, { role: 'user', - content: commentEnv.commentBody || pickIssueEnv.issueDescription || '无' + content: question || commentEnv.commentBody || pickIssueEnv.issueDescription || '无' } ] writeToProcess('输入消息:'); @@ -100,17 +101,25 @@ app.route({ metadata: { tags: ['notInNpcAgent'], args: { - needExit: z.boolean().optional().describe('是否需要在执行完成后退出进程') + needExit: z.boolean().optional().describe('是否需要在执行完成后退出进程'), + owner: z.string().optional().describe('用户名称') } } }).define(async (ctx) => { const needExit = ctx.args.needExit ?? true; + const owner = ctx.args.owner || ''; const exit = (code: number) => { if (needExit) { process.exit(code); } } - await main({ exit }); + const buildUserNickName = useKey('CNB_BUILD_USER_NICKNAME') + let admins = owner.split(',').map(item => item.trim()); + if (owner && admins.includes(buildUserNickName)) { + await main({ exit }); + } else { + await main({ exit, question: `你是${owner}的专属助手,请生成一条评论,说明你不具备其他用户能访问的能力。同时你需要提示说明,fork当前仓库后,即可成为你的专属助手` }); + } }).addTo(app) parse({ app: app, description: 'CNB控制台命令行工具', parse: true }) diff --git a/package.json b/package.json index 2638832..00209b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/cnb", - "version": "0.0.48", + "version": "0.0.50", "description": "", "main": "index.js", "basename": "/root/cnb", diff --git a/readme.md b/readme.md index 255bc71..bc2eca0 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,13 @@ # cnb.cool 能做什么 所有的代码仓库,只基于一个准则 `group/repo` + +## 环境变量 + +```sh +CNB_API_KEY +CNB_COOKIE +``` ## 简介 纯粹调用api的模式去使用cnb.cool,自动化方案。