@kevisual/cnb 0.0.45 → 0.0.47
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/{commander.ts → cli.ts} +1 -1
- package/agent/npc.ts +26 -5
- package/agent/routes/chat/chat.ts +8 -0
- package/agent/routes/cnb-board/live/live-content.ts +1 -1
- package/bin/npc.js +2 -0
- package/package.json +8 -7
- package/src/issue/npc/env.ts +7 -0
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -67071
- package/dist/keep.d.ts +0 -47
- package/dist/keep.js +0 -3084
- package/dist/opencode.d.ts +0 -5
- package/dist/opencode.js +0 -79558
- package/dist/routes.d.ts +0 -885
- package/dist/routes.js +0 -64844
package/agent/npc.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { app } from './index.ts';
|
|
2
|
+
import { parse } from '@kevisual/router/src/commander.ts';
|
|
2
3
|
|
|
3
4
|
import { useIssueEnv, useCommentEnv, useRepoInfoEnv, IssueLabel } from '../src/index.ts'
|
|
4
5
|
import { pick } from 'es-toolkit';
|
|
6
|
+
import z from 'zod';
|
|
5
7
|
|
|
6
8
|
const writeToProcess = (message: string) => {
|
|
7
9
|
if (process.send) {
|
|
@@ -36,7 +38,7 @@ const getIssuesLabels = async () => {
|
|
|
36
38
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
const main = async () => {
|
|
41
|
+
const main = async ({ exit }: { exit: (code: number) => void }) => {
|
|
40
42
|
const repoInfoEnv = useRepoInfoEnv();
|
|
41
43
|
const commentEnv = useCommentEnv();
|
|
42
44
|
const issueEnv = useIssueEnv();
|
|
@@ -56,7 +58,7 @@ const main = async () => {
|
|
|
56
58
|
envList.forEach(item => writeToProcess(item));
|
|
57
59
|
if (!isComment && !issueLabelsNames.includes('Run')) {
|
|
58
60
|
writeToProcess('当前 Issue 不包含 Run 标签,跳过执行');
|
|
59
|
-
|
|
61
|
+
return exit(0);
|
|
60
62
|
}
|
|
61
63
|
const messages = [
|
|
62
64
|
{
|
|
@@ -84,11 +86,30 @@ const main = async () => {
|
|
|
84
86
|
let _message = result.data.message || []
|
|
85
87
|
writeToProcess('执行完成')
|
|
86
88
|
writeToProcess(JSON.stringify(_message, null, 2))
|
|
87
|
-
|
|
89
|
+
exit(0);
|
|
88
90
|
} else {
|
|
89
91
|
writeToProcess(result.message || '执行错误')
|
|
90
|
-
|
|
92
|
+
exit(1);
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
app.route({
|
|
97
|
+
path: 'cnb',
|
|
98
|
+
key: 'npc',
|
|
99
|
+
description: 'CNB智能助手,提供智能建议和帮助, 程序入口',
|
|
100
|
+
metadata: {
|
|
101
|
+
tags: ['notInNpcAgent'],
|
|
102
|
+
args: {
|
|
103
|
+
needExit: z.boolean().optional().describe('是否需要在执行完成后退出进程')
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}).define(async (ctx) => {
|
|
107
|
+
const exit = (code: number) => {
|
|
108
|
+
if (ctx.args.needExit) {
|
|
109
|
+
process.exit(code);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
await main({ exit });
|
|
113
|
+
}).addTo(app)
|
|
114
|
+
|
|
115
|
+
parse({ app: app, description: 'CNB控制台命令行工具', parse: true })
|
|
@@ -30,9 +30,17 @@ app.route({
|
|
|
30
30
|
role: 'user',
|
|
31
31
|
content: ctx.args.question
|
|
32
32
|
}]
|
|
33
|
+
const routes = app.routes.filter(route => {
|
|
34
|
+
const tags = route.metadata?.tags || [];
|
|
35
|
+
if (tags.includes('notInNpcAgent')) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true
|
|
39
|
+
});
|
|
33
40
|
const result = await runAgent({
|
|
34
41
|
app,
|
|
35
42
|
messages: messages,
|
|
43
|
+
routes,
|
|
36
44
|
languageModel: cnbAi(model),
|
|
37
45
|
token: '',
|
|
38
46
|
// token: ctx.query.token as string,
|
|
@@ -10,7 +10,7 @@ export const getLiveMdContent = (opts?: { more?: boolean }) => {
|
|
|
10
10
|
const token = useKey('CNB_TOKEN') || ''
|
|
11
11
|
const openclawPort = useKey('OPENCLAW_PORT') || '80'
|
|
12
12
|
const openclawUrl = url.replace('{{port}}', openclawPort)
|
|
13
|
-
const openclawUrlSecret = openclawUrl + '/openclaw
|
|
13
|
+
const openclawUrlSecret = openclawUrl + '/openclaw#token=' + token
|
|
14
14
|
|
|
15
15
|
const opencodePort = useKey('OPENCODE_PORT') || '100'
|
|
16
16
|
const opencodeUrl = url.replace('{{port}}', opencodePort)
|
package/bin/npc.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/cnb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"basename": "/root/cnb",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"keywords": [],
|
|
19
19
|
"bin": {
|
|
20
20
|
"cnb": "bin/index.js",
|
|
21
|
-
"cloud": "bin/index.js"
|
|
21
|
+
"cloud": "bin/index.js",
|
|
22
|
+
"cloud-npc": "bin/npc.js"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
24
25
|
"dist",
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"@kevisual/dts": "^0.0.4",
|
|
39
40
|
"@kevisual/remote-app": "^0.0.7",
|
|
40
41
|
"@kevisual/types": "^0.0.12",
|
|
41
|
-
"@opencode-ai/plugin": "^1.2.
|
|
42
|
+
"@opencode-ai/plugin": "^1.2.27",
|
|
42
43
|
"@types/bun": "^1.3.10",
|
|
43
44
|
"@types/node": "^25.5.0",
|
|
44
45
|
"@types/ws": "^8.18.1",
|
|
@@ -55,11 +56,11 @@
|
|
|
55
56
|
},
|
|
56
57
|
"dependencies": {
|
|
57
58
|
"@kevisual/query": "^0.0.53",
|
|
58
|
-
"@kevisual/router": "^0.1.
|
|
59
|
+
"@kevisual/router": "^0.1.2",
|
|
59
60
|
"@kevisual/use-config": "^1.0.30",
|
|
60
|
-
"@opencode-ai/sdk": "^1.2.
|
|
61
|
+
"@opencode-ai/sdk": "^1.2.27",
|
|
61
62
|
"es-toolkit": "^1.45.1",
|
|
62
|
-
"nanoid": "^5.1.
|
|
63
|
+
"nanoid": "^5.1.7",
|
|
63
64
|
"unstorage": "^1.17.4",
|
|
64
65
|
"ws": "npm:@kevisual/ws",
|
|
65
66
|
"zod": "^4.3.6"
|
|
@@ -74,4 +75,4 @@
|
|
|
74
75
|
"./src/*": "./src/*",
|
|
75
76
|
"./agent/*": "./agent/*"
|
|
76
77
|
}
|
|
77
|
-
}
|
|
78
|
+
}
|
package/src/issue/npc/env.ts
CHANGED
|
@@ -128,6 +128,7 @@ export const useIssueEnv = () => {
|
|
|
128
128
|
const issueState = useKey("CNB_ISSUE_STATE");
|
|
129
129
|
const issueIsResolved = useKey("CNB_ISSUE_IS_RESOLVED");
|
|
130
130
|
const issueAssignees = useKey("CNB_ISSUE_ASSIGNEES");
|
|
131
|
+
const issueLabels = useKey("CNB_ISSUE_LABELS");
|
|
131
132
|
const issuePriority = useKey("CNB_ISSUE_PRIORITY");
|
|
132
133
|
|
|
133
134
|
return {
|
|
@@ -179,6 +180,12 @@ export const useIssueEnv = () => {
|
|
|
179
180
|
*/
|
|
180
181
|
issueAssignees,
|
|
181
182
|
issueAssigneesLabel: "Issue 处理人列表",
|
|
183
|
+
/**
|
|
184
|
+
* @key CNB_ISSUE_LABELS
|
|
185
|
+
* @description:Issue 标签列表, 多个以 , 分隔。
|
|
186
|
+
*/
|
|
187
|
+
issueLabels,
|
|
188
|
+
issueLabelsLabel: "Issue 标签列表, 多个以 , 分隔。",
|
|
182
189
|
/**
|
|
183
190
|
* @key CNB_ISSUE_PRIORITY
|
|
184
191
|
* @description:Issue 优先级
|
package/dist/cli.d.ts
DELETED