更新 .cnb.yml 中的命令行参数,修改 agent/npc.ts 以支持用户名称,更新 package.json 版本,完善 readme.md 环境变量说明

This commit is contained in:
xiongxiao
2026-03-16 22:20:39 +08:00
committed by cnb
parent c7a5200aa5
commit 95bcad7587
4 changed files with 22 additions and 6 deletions

View File

@@ -19,7 +19,7 @@ include:
- name: "task" - name: "task"
script: | script: |
git clone https://cnb.cool/kevisual/cnb cnb 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: vscode:
- docker: - docker:

View File

@@ -4,6 +4,7 @@ import { parse } from '@kevisual/router/src/commander.ts';
import { useIssueEnv, useCommentEnv, useRepoInfoEnv, IssueLabel } from '../src/index.ts' import { useIssueEnv, useCommentEnv, useRepoInfoEnv, IssueLabel } from '../src/index.ts'
import { pick } from 'es-toolkit'; import { pick } from 'es-toolkit';
import z from 'zod'; import z from 'zod';
import { useKey } from '@kevisual/context';
const writeToProcess = (message: string) => { const writeToProcess = (message: string) => {
if (process.send) { 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 repoInfoEnv = useRepoInfoEnv();
const commentEnv = useCommentEnv(); const commentEnv = useCommentEnv();
const issueEnv = useIssueEnv(); const issueEnv = useIssueEnv();
@@ -70,7 +71,7 @@ const main = async ({ exit }: { exit: (code: number) => void }) => {
content: `相关变量:${JSON.stringify({ ...pickCommentEnv, ...pickIssueEnv, ...pickRepoInfoEnv })}` content: `相关变量:${JSON.stringify({ ...pickCommentEnv, ...pickIssueEnv, ...pickRepoInfoEnv })}`
}, { }, {
role: 'user', role: 'user',
content: commentEnv.commentBody || pickIssueEnv.issueDescription || '无' content: question || commentEnv.commentBody || pickIssueEnv.issueDescription || '无'
} }
] ]
writeToProcess('输入消息:'); writeToProcess('输入消息:');
@@ -100,17 +101,25 @@ app.route({
metadata: { metadata: {
tags: ['notInNpcAgent'], tags: ['notInNpcAgent'],
args: { args: {
needExit: z.boolean().optional().describe('是否需要在执行完成后退出进程') needExit: z.boolean().optional().describe('是否需要在执行完成后退出进程'),
owner: z.string().optional().describe('用户名称')
} }
} }
}).define(async (ctx) => { }).define(async (ctx) => {
const needExit = ctx.args.needExit ?? true; const needExit = ctx.args.needExit ?? true;
const owner = ctx.args.owner || '';
const exit = (code: number) => { const exit = (code: number) => {
if (needExit) { if (needExit) {
process.exit(code); 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) }).addTo(app)
parse({ app: app, description: 'CNB控制台命令行工具', parse: true }) parse({ app: app, description: 'CNB控制台命令行工具', parse: true })

View File

@@ -1,6 +1,6 @@
{ {
"name": "@kevisual/cnb", "name": "@kevisual/cnb",
"version": "0.0.48", "version": "0.0.50",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"basename": "/root/cnb", "basename": "/root/cnb",

View File

@@ -1,6 +1,13 @@
# cnb.cool 能做什么 # cnb.cool 能做什么
所有的代码仓库,只基于一个准则 `group/repo` 所有的代码仓库,只基于一个准则 `group/repo`
## 环境变量
```sh
CNB_API_KEY
CNB_COOKIE
```
## 简介 ## 简介
纯粹调用api的模式去使用cnb.cool自动化方案。 纯粹调用api的模式去使用cnb.cool自动化方案。