@kevisual/cnb 0.0.4 → 0.0.7

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.
@@ -1,5 +1,5 @@
1
1
  import { app, appId } from '../app.ts';
2
- import './user/check.ts'
2
+ import './cnb-env/check.ts'
3
3
  import './repo/index.ts'
4
4
  import './workspace/index.ts'
5
5
  import './call/index.ts'
@@ -1,5 +1,6 @@
1
1
  import { createSkill, tool } from '@kevisual/router';
2
2
  import { app, cnb } from '../../app.ts';
3
+ import { IssueItem } from '@/index.ts';
3
4
 
4
5
  // 创建cnb issue, 仓库为 kevisual/kevisual 标题为 "自动化测试创建issue", 内容为 "这是通过API创建的issue,用于测试目的", body: "这是通过API创建的issue,用于测试目的"
5
6
  app.route({
@@ -55,7 +56,7 @@ app.route({
55
56
  tags: ['opencode'],
56
57
  ...createSkill({
57
58
  skill: 'complete-issue',
58
- title: '完成 Issue',
59
+ title: '完成 CNB的任务Issue',
59
60
  args: {
60
61
  repo: tool.schema.string().describe('代码仓库名称, 如 my-user/my-repo'),
61
62
  issueNumber: tool.schema.union([tool.schema.string(), tool.schema.number()]).describe('Issue 编号'),
@@ -72,9 +73,10 @@ app.route({
72
73
  if (!repo || !issueNumber) {
73
74
  ctx.throw(400, '缺少参数 repo 或 issueNumber');
74
75
  }
75
-
76
- const res = await cnb.issue.updateIssue(repo, issueNumber, {
77
- state: state,
78
- });
76
+ const iss: Partial<IssueItem> = { state: state };
77
+ if (iss.state === 'closed') {
78
+ iss.state_reason = 'completed';
79
+ }
80
+ const res = await cnb.issue.updateIssue(repo, issueNumber, iss);
79
81
  ctx.forward(res);
80
82
  }).addTo(app);
@@ -1,3 +1,50 @@
1
1
  import { createSkill, tool } from '@kevisual/router';
2
2
  import { app, cnb } from '../../app.ts';
3
3
 
4
+ // 查询 Issue 列表 repo是 kevisual/kevisual
5
+ app.route({
6
+ path: 'cnb',
7
+ key: 'list-issues',
8
+ description: '查询 Issue 列表, 参数 repo, state, keyword, labels, page, page_size 等',
9
+ middleware: ['auth'],
10
+ metadata: {
11
+ tags: ['opencode'],
12
+ ...createSkill({
13
+ skill: 'list-issues',
14
+ title: '查询 Issue 列表',
15
+ args: {
16
+ repo: tool.schema.string().describe('代码仓库名称, 如 my-user/my-repo'),
17
+ state: tool.schema.string().optional().describe('Issue 状态:open 或 closed'),
18
+ keyword: tool.schema.string().optional().describe('问题搜索关键词'),
19
+ labels: tool.schema.string().optional().describe('问题标签,多个用逗号分隔'),
20
+ page: tool.schema.number().optional().describe('分页页码,默认: 1'),
21
+ page_size: tool.schema.number().optional().describe('分页每页大小,默认: 30'),
22
+ order_by: tool.schema.string().optional().describe('排序方式,如 created_at, -updated_at'),
23
+ },
24
+ summary: '查询 Issue 列表',
25
+ })
26
+ }
27
+ }).define(async (ctx) => {
28
+ const repo = ctx.query?.repo;
29
+ const state = ctx.query?.state;
30
+ const keyword = ctx.query?.keyword;
31
+ const labels = ctx.query?.labels;
32
+ const page = ctx.query?.page ? Number(ctx.query.page) : undefined;
33
+ const page_size = ctx.query?.page_size ? Number(ctx.query.page_size) : undefined;
34
+ const order_by = ctx.query?.order_by;
35
+
36
+ if (!repo) {
37
+ ctx.throw(400, '缺少参数 repo');
38
+ }
39
+
40
+ const params: Record<string, any> = {};
41
+ if (state) params.state = state;
42
+ if (keyword) params.keyword = keyword;
43
+ if (labels) params.labels = labels;
44
+ if (page) params.page = page;
45
+ if (page_size) params.page_size = page_size;
46
+ if (order_by) params.order_by = order_by;
47
+
48
+ const res = await cnb.issue.getList(repo, params);
49
+ ctx.forward(res);
50
+ }).addTo(app);
package/dist/opencode.js CHANGED
@@ -32167,7 +32167,7 @@ function tool2(input) {
32167
32167
  }
32168
32168
  tool2.schema = exports_external;
32169
32169
 
32170
- // agent/routes/user/check.ts
32170
+ // agent/routes/cnb-env/check.ts
32171
32171
  app.route({
32172
32172
  path: "cnb",
32173
32173
  key: "user-check",
@@ -66267,6 +66267,57 @@ ${item.chunk}
66267
66267
  ctx.body = { content: answer };
66268
66268
  }).addTo(app);
66269
66269
 
66270
+ // agent/routes/issues/list.ts
66271
+ app.route({
66272
+ path: "cnb",
66273
+ key: "list-issues",
66274
+ description: "查询 Issue 列表, 参数 repo, state, keyword, labels, page, page_size 等",
66275
+ middleware: ["auth"],
66276
+ metadata: {
66277
+ tags: ["opencode"],
66278
+ ...createSkill({
66279
+ skill: "list-issues",
66280
+ title: "查询 Issue 列表",
66281
+ args: {
66282
+ repo: tool.schema.string().describe("代码仓库名称, 如 my-user/my-repo"),
66283
+ state: tool.schema.string().optional().describe("Issue 状态:open 或 closed"),
66284
+ keyword: tool.schema.string().optional().describe("问题搜索关键词"),
66285
+ labels: tool.schema.string().optional().describe("问题标签,多个用逗号分隔"),
66286
+ page: tool.schema.number().optional().describe("分页页码,默认: 1"),
66287
+ page_size: tool.schema.number().optional().describe("分页每页大小,默认: 30"),
66288
+ order_by: tool.schema.string().optional().describe("排序方式,如 created_at, -updated_at")
66289
+ },
66290
+ summary: "查询 Issue 列表"
66291
+ })
66292
+ }
66293
+ }).define(async (ctx) => {
66294
+ const repo2 = ctx.query?.repo;
66295
+ const state = ctx.query?.state;
66296
+ const keyword = ctx.query?.keyword;
66297
+ const labels = ctx.query?.labels;
66298
+ const page = ctx.query?.page ? Number(ctx.query.page) : undefined;
66299
+ const page_size = ctx.query?.page_size ? Number(ctx.query.page_size) : undefined;
66300
+ const order_by = ctx.query?.order_by;
66301
+ if (!repo2) {
66302
+ ctx.throw(400, "缺少参数 repo");
66303
+ }
66304
+ const params = {};
66305
+ if (state)
66306
+ params.state = state;
66307
+ if (keyword)
66308
+ params.keyword = keyword;
66309
+ if (labels)
66310
+ params.labels = labels;
66311
+ if (page)
66312
+ params.page = page;
66313
+ if (page_size)
66314
+ params.page_size = page_size;
66315
+ if (order_by)
66316
+ params.order_by = order_by;
66317
+ const res = await cnb.issue.getList(repo2, params);
66318
+ ctx.forward(res);
66319
+ }).addTo(app);
66320
+
66270
66321
  // agent/routes/issues/issue.ts
66271
66322
  app.route({
66272
66323
  path: "cnb",
@@ -66317,7 +66368,7 @@ app.route({
66317
66368
  tags: ["opencode"],
66318
66369
  ...createSkill({
66319
66370
  skill: "complete-issue",
66320
- title: "完成 Issue",
66371
+ title: "完成 CNB的任务Issue",
66321
66372
  args: {
66322
66373
  repo: tool.schema.string().describe("代码仓库名称, 如 my-user/my-repo"),
66323
66374
  issueNumber: tool.schema.union([tool.schema.string(), tool.schema.number()]).describe("Issue 编号"),
@@ -66333,9 +66384,11 @@ app.route({
66333
66384
  if (!repo2 || !issueNumber) {
66334
66385
  ctx.throw(400, "缺少参数 repo 或 issueNumber");
66335
66386
  }
66336
- const res = await cnb.issue.updateIssue(repo2, issueNumber, {
66337
- state
66338
- });
66387
+ const iss = { state };
66388
+ if (iss.state === "closed") {
66389
+ iss.state_reason = "completed";
66390
+ }
66391
+ const res = await cnb.issue.updateIssue(repo2, issueNumber, iss);
66339
66392
  ctx.forward(res);
66340
66393
  }).addTo(app);
66341
66394
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/cnb",
3
- "version": "0.0.4",
3
+ "version": "0.0.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
File without changes