@kevisual/cnb 0.0.3 → 0.0.4
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/routes/index.ts +1 -1
- package/agent/routes/issues/index.ts +2 -0
- package/agent/routes/issues/issue.ts +80 -0
- package/agent/routes/issues/list.ts +3 -0
- package/dist/opencode.js +107 -19
- package/package.json +6 -6
- package/src/issue/index.ts +1 -0
package/agent/routes/index.ts
CHANGED
|
@@ -5,8 +5,8 @@ import './workspace/index.ts'
|
|
|
5
5
|
import './call/index.ts'
|
|
6
6
|
import './cnb-env/index.ts'
|
|
7
7
|
import './knowledge/index.ts'
|
|
8
|
+
import './issues/index.ts'
|
|
8
9
|
|
|
9
|
-
import { isEqual } from 'es-toolkit'
|
|
10
10
|
/**
|
|
11
11
|
* 验证上下文中的 App ID 是否与指定的 App ID 匹配
|
|
12
12
|
* @param {any} ctx - 上下文对象,可能包含 appId 属性
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createSkill, tool } from '@kevisual/router';
|
|
2
|
+
import { app, cnb } from '../../app.ts';
|
|
3
|
+
|
|
4
|
+
// 创建cnb issue, 仓库为 kevisual/kevisual 标题为 "自动化测试创建issue", 内容为 "这是通过API创建的issue,用于测试目的", body: "这是通过API创建的issue,用于测试目的"
|
|
5
|
+
app.route({
|
|
6
|
+
path: 'cnb',
|
|
7
|
+
key: 'create-issue',
|
|
8
|
+
description: '创建 Issue, 参数 repo, title, body, assignees, labels, priority',
|
|
9
|
+
middleware: ['auth'],
|
|
10
|
+
metadata: {
|
|
11
|
+
tags: ['opencode'],
|
|
12
|
+
...createSkill({
|
|
13
|
+
skill: 'create-issue',
|
|
14
|
+
title: '创建 Issue',
|
|
15
|
+
args: {
|
|
16
|
+
repo: tool.schema.string().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
17
|
+
title: tool.schema.string().describe('Issue 标题'),
|
|
18
|
+
body: tool.schema.string().optional().describe('Issue 描述内容'),
|
|
19
|
+
assignees: tool.schema.array(tool.schema.string()).optional().describe('指派人列表'),
|
|
20
|
+
labels: tool.schema.array(tool.schema.string()).optional().describe('标签列表'),
|
|
21
|
+
priority: tool.schema.string().optional().describe('优先级'),
|
|
22
|
+
},
|
|
23
|
+
summary: '创建一个新的 Issue',
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}).define(async (ctx) => {
|
|
27
|
+
const repo = ctx.query?.repo;
|
|
28
|
+
const title = ctx.query?.title;
|
|
29
|
+
const body = ctx.query?.body;
|
|
30
|
+
const assignees = ctx.query?.assignees;
|
|
31
|
+
const labels = ctx.query?.labels;
|
|
32
|
+
const priority = ctx.query?.priority;
|
|
33
|
+
|
|
34
|
+
if (!repo || !title) {
|
|
35
|
+
ctx.throw(400, '缺少参数 repo 或 title');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const res = await cnb.issue.createIssue(repo, {
|
|
39
|
+
title,
|
|
40
|
+
body,
|
|
41
|
+
assignees,
|
|
42
|
+
labels,
|
|
43
|
+
priority,
|
|
44
|
+
});
|
|
45
|
+
ctx.forward(res);
|
|
46
|
+
}).addTo(app);
|
|
47
|
+
|
|
48
|
+
// 完成 issue 8, 仓库是 kevisual/kevisaul
|
|
49
|
+
app.route({
|
|
50
|
+
path: 'cnb',
|
|
51
|
+
key: 'complete-issue',
|
|
52
|
+
description: '完成 Issue, 参数 repo, issueNumber',
|
|
53
|
+
middleware: ['auth'],
|
|
54
|
+
metadata: {
|
|
55
|
+
tags: ['opencode'],
|
|
56
|
+
...createSkill({
|
|
57
|
+
skill: 'complete-issue',
|
|
58
|
+
title: '完成 Issue',
|
|
59
|
+
args: {
|
|
60
|
+
repo: tool.schema.string().describe('代码仓库名称, 如 my-user/my-repo'),
|
|
61
|
+
issueNumber: tool.schema.union([tool.schema.string(), tool.schema.number()]).describe('Issue 编号'),
|
|
62
|
+
state: tool.schema.string().optional().describe('Issue 状态,默认为 closed'),
|
|
63
|
+
},
|
|
64
|
+
summary: '完成一个 Issue(将 state 改为 closed)',
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}).define(async (ctx) => {
|
|
68
|
+
const repo = ctx.query?.repo;
|
|
69
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
70
|
+
const state = ctx.query?.state ?? 'closed';
|
|
71
|
+
|
|
72
|
+
if (!repo || !issueNumber) {
|
|
73
|
+
ctx.throw(400, '缺少参数 repo 或 issueNumber');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const res = await cnb.issue.updateIssue(repo, issueNumber, {
|
|
77
|
+
state: state,
|
|
78
|
+
});
|
|
79
|
+
ctx.forward(res);
|
|
80
|
+
}).addTo(app);
|
package/dist/opencode.js
CHANGED
|
@@ -9,7 +9,7 @@ var __export = (target, all) => {
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
// node_modules/.pnpm/@kevisual+router@0.0.
|
|
12
|
+
// node_modules/.pnpm/@kevisual+router@0.0.63_typescript@5.9.3/node_modules/@kevisual/router/dist/router.js
|
|
13
13
|
import require$$1, { webcrypto } from "node:crypto";
|
|
14
14
|
import require$$2 from "node:http";
|
|
15
15
|
import require$$1$1 from "node:https";
|
|
@@ -2083,7 +2083,7 @@ class Doc {
|
|
|
2083
2083
|
var version = {
|
|
2084
2084
|
major: 4,
|
|
2085
2085
|
minor: 3,
|
|
2086
|
-
patch:
|
|
2086
|
+
patch: 6
|
|
2087
2087
|
};
|
|
2088
2088
|
var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
2089
2089
|
var _a;
|
|
@@ -3367,7 +3367,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3367
3367
|
if (keyResult instanceof Promise) {
|
|
3368
3368
|
throw new Error("Async schemas not supported in object keys currently");
|
|
3369
3369
|
}
|
|
3370
|
-
const checkNumericKey = typeof key === "string" && number$2.test(key) && keyResult.issues.length
|
|
3370
|
+
const checkNumericKey = typeof key === "string" && number$2.test(key) && keyResult.issues.length;
|
|
3371
3371
|
if (checkNumericKey) {
|
|
3372
3372
|
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
3373
3373
|
if (retryResult instanceof Promise) {
|
|
@@ -10682,7 +10682,7 @@ function finalize(ctx, schema) {
|
|
|
10682
10682
|
}
|
|
10683
10683
|
}
|
|
10684
10684
|
}
|
|
10685
|
-
if (refSchema.$ref) {
|
|
10685
|
+
if (refSchema.$ref && refSeen.def) {
|
|
10686
10686
|
for (const key in schema2) {
|
|
10687
10687
|
if (key === "$ref" || key === "allOf")
|
|
10688
10688
|
continue;
|
|
@@ -32161,7 +32161,7 @@ function date5(params) {
|
|
|
32161
32161
|
|
|
32162
32162
|
// node_modules/.pnpm/zod@4.1.8/node_modules/zod/v4/classic/external.js
|
|
32163
32163
|
config3(en_default());
|
|
32164
|
-
// node_modules/.pnpm/@opencode-ai+plugin@1.1.
|
|
32164
|
+
// node_modules/.pnpm/@opencode-ai+plugin@1.1.39/node_modules/@opencode-ai/plugin/dist/tool.js
|
|
32165
32165
|
function tool2(input) {
|
|
32166
32166
|
return input;
|
|
32167
32167
|
}
|
|
@@ -46252,7 +46252,7 @@ app.route({
|
|
|
46252
46252
|
ctx.body = { content: `当前cnb工作空间的cookie环境变量为:${cookie}` };
|
|
46253
46253
|
}).addTo(app);
|
|
46254
46254
|
|
|
46255
|
-
// node_modules/.pnpm/@kevisual+ai@0.0.
|
|
46255
|
+
// node_modules/.pnpm/@kevisual+ai@0.0.24/node_modules/@kevisual/ai/dist/ai-provider-browser.js
|
|
46256
46256
|
var __create2 = Object.create;
|
|
46257
46257
|
var __getProtoOf2 = Object.getPrototypeOf;
|
|
46258
46258
|
var __defProp3 = Object.defineProperty;
|
|
@@ -66074,15 +66074,28 @@ class BaseChat {
|
|
|
66074
66074
|
}
|
|
66075
66075
|
class CNBChat extends BaseChat {
|
|
66076
66076
|
static BASE_URL = "https://api.cnb.cool/{repo}/-/ai";
|
|
66077
|
+
repo;
|
|
66077
66078
|
constructor(options) {
|
|
66078
66079
|
const baseURL = CNBChat.BASE_URL.replace("{repo}", options.repo);
|
|
66079
|
-
super({ ...options, baseURL });
|
|
66080
|
+
super({ model: "hunyuan-a13b", ...options, baseURL });
|
|
66080
66081
|
}
|
|
66081
|
-
query(
|
|
66082
|
-
const
|
|
66083
|
-
this.post(
|
|
66084
|
-
data:
|
|
66082
|
+
async query(params) {
|
|
66083
|
+
const url4 = this.baseURL.replace("/ai", "/knowledge/base/query");
|
|
66084
|
+
const response = await this.post(url4, {
|
|
66085
|
+
data: {
|
|
66086
|
+
score_threshold: 0.62,
|
|
66087
|
+
top_k: 10,
|
|
66088
|
+
...params
|
|
66089
|
+
}
|
|
66085
66090
|
});
|
|
66091
|
+
if (!response.ok) {
|
|
66092
|
+
throw new Error(`query API error: ${response.status} ${response.statusText}`);
|
|
66093
|
+
}
|
|
66094
|
+
const res = await response.json();
|
|
66095
|
+
return {
|
|
66096
|
+
code: 200,
|
|
66097
|
+
data: res || []
|
|
66098
|
+
};
|
|
66086
66099
|
}
|
|
66087
66100
|
}
|
|
66088
66101
|
var import_aes = __toESM2(require_aes(), 1);
|
|
@@ -66254,6 +66267,78 @@ ${item.chunk}
|
|
|
66254
66267
|
ctx.body = { content: answer };
|
|
66255
66268
|
}).addTo(app);
|
|
66256
66269
|
|
|
66270
|
+
// agent/routes/issues/issue.ts
|
|
66271
|
+
app.route({
|
|
66272
|
+
path: "cnb",
|
|
66273
|
+
key: "create-issue",
|
|
66274
|
+
description: "创建 Issue, 参数 repo, title, body, assignees, labels, priority",
|
|
66275
|
+
middleware: ["auth"],
|
|
66276
|
+
metadata: {
|
|
66277
|
+
tags: ["opencode"],
|
|
66278
|
+
...createSkill({
|
|
66279
|
+
skill: "create-issue",
|
|
66280
|
+
title: "创建 Issue",
|
|
66281
|
+
args: {
|
|
66282
|
+
repo: tool.schema.string().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
66283
|
+
title: tool.schema.string().describe("Issue 标题"),
|
|
66284
|
+
body: tool.schema.string().optional().describe("Issue 描述内容"),
|
|
66285
|
+
assignees: tool.schema.array(tool.schema.string()).optional().describe("指派人列表"),
|
|
66286
|
+
labels: tool.schema.array(tool.schema.string()).optional().describe("标签列表"),
|
|
66287
|
+
priority: tool.schema.string().optional().describe("优先级")
|
|
66288
|
+
},
|
|
66289
|
+
summary: "创建一个新的 Issue"
|
|
66290
|
+
})
|
|
66291
|
+
}
|
|
66292
|
+
}).define(async (ctx) => {
|
|
66293
|
+
const repo2 = ctx.query?.repo;
|
|
66294
|
+
const title = ctx.query?.title;
|
|
66295
|
+
const body = ctx.query?.body;
|
|
66296
|
+
const assignees = ctx.query?.assignees;
|
|
66297
|
+
const labels = ctx.query?.labels;
|
|
66298
|
+
const priority = ctx.query?.priority;
|
|
66299
|
+
if (!repo2 || !title) {
|
|
66300
|
+
ctx.throw(400, "缺少参数 repo 或 title");
|
|
66301
|
+
}
|
|
66302
|
+
const res = await cnb.issue.createIssue(repo2, {
|
|
66303
|
+
title,
|
|
66304
|
+
body,
|
|
66305
|
+
assignees,
|
|
66306
|
+
labels,
|
|
66307
|
+
priority
|
|
66308
|
+
});
|
|
66309
|
+
ctx.forward(res);
|
|
66310
|
+
}).addTo(app);
|
|
66311
|
+
app.route({
|
|
66312
|
+
path: "cnb",
|
|
66313
|
+
key: "complete-issue",
|
|
66314
|
+
description: "完成 Issue, 参数 repo, issueNumber",
|
|
66315
|
+
middleware: ["auth"],
|
|
66316
|
+
metadata: {
|
|
66317
|
+
tags: ["opencode"],
|
|
66318
|
+
...createSkill({
|
|
66319
|
+
skill: "complete-issue",
|
|
66320
|
+
title: "完成 Issue",
|
|
66321
|
+
args: {
|
|
66322
|
+
repo: tool.schema.string().describe("代码仓库名称, 如 my-user/my-repo"),
|
|
66323
|
+
issueNumber: tool.schema.union([tool.schema.string(), tool.schema.number()]).describe("Issue 编号"),
|
|
66324
|
+
state: tool.schema.string().optional().describe("Issue 状态,默认为 closed")
|
|
66325
|
+
},
|
|
66326
|
+
summary: "完成一个 Issue(将 state 改为 closed)"
|
|
66327
|
+
})
|
|
66328
|
+
}
|
|
66329
|
+
}).define(async (ctx) => {
|
|
66330
|
+
const repo2 = ctx.query?.repo;
|
|
66331
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
66332
|
+
const state = ctx.query?.state ?? "closed";
|
|
66333
|
+
if (!repo2 || !issueNumber) {
|
|
66334
|
+
ctx.throw(400, "缺少参数 repo 或 issueNumber");
|
|
66335
|
+
}
|
|
66336
|
+
const res = await cnb.issue.updateIssue(repo2, issueNumber, {
|
|
66337
|
+
state
|
|
66338
|
+
});
|
|
66339
|
+
ctx.forward(res);
|
|
66340
|
+
}).addTo(app);
|
|
66341
|
+
|
|
66257
66342
|
// agent/routes/index.ts
|
|
66258
66343
|
var checkAppId = (ctx, appId2) => {
|
|
66259
66344
|
const _appId = ctx?.app?.appId;
|
|
@@ -66285,7 +66370,7 @@ if (!app.hasRoute("auth")) {
|
|
|
66285
66370
|
}).addTo(app);
|
|
66286
66371
|
}
|
|
66287
66372
|
|
|
66288
|
-
// node_modules/.pnpm/@kevisual+router@0.0.
|
|
66373
|
+
// node_modules/.pnpm/@kevisual+router@0.0.63_typescript@5.9.3/node_modules/@kevisual/router/dist/opencode.js
|
|
66289
66374
|
function getDefaultExportFromCjs4(x) {
|
|
66290
66375
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
66291
66376
|
}
|
|
@@ -68723,7 +68808,7 @@ class Doc4 {
|
|
|
68723
68808
|
var version4 = {
|
|
68724
68809
|
major: 4,
|
|
68725
68810
|
minor: 3,
|
|
68726
|
-
patch:
|
|
68811
|
+
patch: 6
|
|
68727
68812
|
};
|
|
68728
68813
|
var $ZodType4 = /* @__PURE__ */ $constructor4("$ZodType", (inst, def) => {
|
|
68729
68814
|
var _a3;
|
|
@@ -70007,7 +70092,7 @@ var $ZodRecord4 = /* @__PURE__ */ $constructor4("$ZodRecord", (inst, def) => {
|
|
|
70007
70092
|
if (keyResult instanceof Promise) {
|
|
70008
70093
|
throw new Error("Async schemas not supported in object keys currently");
|
|
70009
70094
|
}
|
|
70010
|
-
const checkNumericKey = typeof key === "string" && number$22.test(key) && keyResult.issues.length
|
|
70095
|
+
const checkNumericKey = typeof key === "string" && number$22.test(key) && keyResult.issues.length;
|
|
70011
70096
|
if (checkNumericKey) {
|
|
70012
70097
|
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
70013
70098
|
if (retryResult instanceof Promise) {
|
|
@@ -77322,7 +77407,7 @@ function finalize3(ctx, schema) {
|
|
|
77322
77407
|
}
|
|
77323
77408
|
}
|
|
77324
77409
|
}
|
|
77325
|
-
if (refSchema.$ref) {
|
|
77410
|
+
if (refSchema.$ref && refSeen.def) {
|
|
77326
77411
|
for (const key in schema2) {
|
|
77327
77412
|
if (key === "$ref" || key === "allOf")
|
|
77328
77413
|
continue;
|
|
@@ -80870,8 +80955,11 @@ var createRouterAgentPluginFn = (opts) => {
|
|
|
80870
80955
|
}
|
|
80871
80956
|
return false;
|
|
80872
80957
|
});
|
|
80873
|
-
const AgentPlugin = async (
|
|
80958
|
+
const AgentPlugin = async (pluginInput) => {
|
|
80959
|
+
useContextKey3("plugin-input", () => pluginInput, true);
|
|
80960
|
+
const hooks = opts?.hooks ? await opts.hooks(pluginInput) : {};
|
|
80874
80961
|
return {
|
|
80962
|
+
...hooks,
|
|
80875
80963
|
tool: {
|
|
80876
80964
|
...routes.reduce((acc, route) => {
|
|
80877
80965
|
const metadata = route.metadata;
|
|
@@ -80903,9 +80991,9 @@ var createRouterAgentPluginFn = (opts) => {
|
|
|
80903
80991
|
}
|
|
80904
80992
|
};
|
|
80905
80993
|
return acc;
|
|
80906
|
-
}, {})
|
|
80907
|
-
|
|
80908
|
-
|
|
80994
|
+
}, {}),
|
|
80995
|
+
...hooks?.tool
|
|
80996
|
+
}
|
|
80909
80997
|
};
|
|
80910
80998
|
};
|
|
80911
80999
|
return AgentPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/cnb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"packageManager": "pnpm@10.28.2",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@kevisual/ai": "^0.0.
|
|
21
|
+
"@kevisual/ai": "^0.0.24",
|
|
22
22
|
"@kevisual/context": "^0.0.4",
|
|
23
23
|
"@kevisual/types": "^0.0.12",
|
|
24
|
-
"@opencode-ai/plugin": "^1.1.
|
|
25
|
-
"@types/bun": "^1.3.
|
|
26
|
-
"@types/node": "^25.0
|
|
24
|
+
"@opencode-ai/plugin": "^1.1.39",
|
|
25
|
+
"@types/bun": "^1.3.7",
|
|
26
|
+
"@types/node": "^25.1.0",
|
|
27
27
|
"dotenv": "^17.2.3"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@kevisual/query": "^0.0.38",
|
|
34
|
-
"@kevisual/router": "^0.0.
|
|
34
|
+
"@kevisual/router": "^0.0.63",
|
|
35
35
|
"@kevisual/use-config": "^1.0.28",
|
|
36
36
|
"es-toolkit": "^1.44.0",
|
|
37
37
|
"nanoid": "^5.1.6",
|