@kevisual/cnb 0.0.47 → 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 +15 -5
- package/bin/npc.js +0 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +68090 -0
- package/dist/keep.d.ts +47 -0
- package/dist/keep.js +3084 -0
- package/dist/npc.d.ts +2 -0
- package/dist/npc.js +68238 -0
- package/dist/opencode.d.ts +5 -0
- package/dist/opencode.js +80535 -0
- package/dist/routes.d.ts +885 -0
- package/dist/routes.js +65342 -0
- package/package.json +1 -1
- package/readme.md +7 -0
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 (
|
|
112
|
+
if (needExit) {
|
|
109
113
|
process.exit(code);
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
|
-
|
|
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/cli.d.ts
ADDED