@kevisual/cnb 0.0.55 → 0.0.56
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/workspace/index.ts +1 -0
- package/agent/routes/workspace/rerun.ts +55 -0
- package/dist/cli.js +262 -8
- package/dist/npc.js +316 -16
- package/dist/opencode.js +238 -6
- package/dist/routes.js +238 -6
- package/package.json +1 -1
package/dist/opencode.js
CHANGED
|
@@ -44711,7 +44711,8 @@ app.route({
|
|
|
44711
44711
|
summary: "列出cnb代码仓库, 可选flags参数,如 KnowledgeBase",
|
|
44712
44712
|
args: {
|
|
44713
44713
|
search: tool.schema.string().optional().describe("搜索关键词"),
|
|
44714
|
-
|
|
44714
|
+
page: tool.schema.number().optional().describe("分页页码,默认 1"),
|
|
44715
|
+
pageSize: tool.schema.number().optional().describe("每页数量,默认99"),
|
|
44715
44716
|
flags: tool.schema.string().optional().describe("仓库标记,如果是知识库则填写 KnowledgeBase")
|
|
44716
44717
|
}
|
|
44717
44718
|
})
|
|
@@ -44719,13 +44720,17 @@ app.route({
|
|
|
44719
44720
|
}).define(async (ctx) => {
|
|
44720
44721
|
const cnb = await cnbManager.getContext(ctx);
|
|
44721
44722
|
const search = ctx.query?.search;
|
|
44722
|
-
const
|
|
44723
|
+
const page = ctx.query?.page || 1;
|
|
44724
|
+
let pageSize = ctx.query?.pageSize || 99;
|
|
44723
44725
|
const flags = ctx.query?.flags;
|
|
44724
44726
|
const params = {};
|
|
44725
44727
|
if (flags) {
|
|
44726
44728
|
params.flags = flags;
|
|
44727
44729
|
}
|
|
44728
|
-
|
|
44730
|
+
if (pageSize > 99) {
|
|
44731
|
+
pageSize = 99;
|
|
44732
|
+
}
|
|
44733
|
+
const res = await cnb.repo.getRepoList({ search, page, page_size: pageSize + 1, role: "developer", ...params });
|
|
44729
44734
|
if (res.code === 200) {
|
|
44730
44735
|
const repos = res.data.map((item) => ({
|
|
44731
44736
|
name: item.name,
|
|
@@ -44733,7 +44738,9 @@ app.route({
|
|
|
44733
44738
|
description: item.description,
|
|
44734
44739
|
web_url: item.web_url
|
|
44735
44740
|
}));
|
|
44736
|
-
|
|
44741
|
+
const list = repos.slice(0, pageSize);
|
|
44742
|
+
const hasMore = repos.length > pageSize;
|
|
44743
|
+
ctx.body = { content: JSON.stringify(repos), list, hasMore, page, pageSize };
|
|
44737
44744
|
} else {
|
|
44738
44745
|
ctx.throw(500, "获取仓库列表失败");
|
|
44739
44746
|
}
|
|
@@ -45326,6 +45333,57 @@ app.route({
|
|
|
45326
45333
|
ctx.forward(res);
|
|
45327
45334
|
}).addTo(app);
|
|
45328
45335
|
|
|
45336
|
+
// agent/routes/workspace/rerun.ts
|
|
45337
|
+
app.route({
|
|
45338
|
+
path: "cnb",
|
|
45339
|
+
key: "rerun",
|
|
45340
|
+
description: "重新启动工作区,定时任务",
|
|
45341
|
+
middleware: ["auth"],
|
|
45342
|
+
metadata: {
|
|
45343
|
+
args: {
|
|
45344
|
+
repo: zod_default.string().optional().describe("仓库名称,例如:owner/repo"),
|
|
45345
|
+
config: zod_default.string().optional().describe("工作区配置"),
|
|
45346
|
+
event: zod_default.string().optional().describe("触发事件来源,api_trigger_event")
|
|
45347
|
+
}
|
|
45348
|
+
}
|
|
45349
|
+
}).define(async (ctx) => {
|
|
45350
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
45351
|
+
const repo2 = ctx.args.repo;
|
|
45352
|
+
const config3 = ctx.args.config;
|
|
45353
|
+
const event = ctx.args.event || "api_trigger_event";
|
|
45354
|
+
const res = await cnb.workspace.list({ status: "running" });
|
|
45355
|
+
if (res.code !== 200) {
|
|
45356
|
+
ctx.throw(500, res.message || "Failed to list workspaces");
|
|
45357
|
+
}
|
|
45358
|
+
const list = res.data?.list || [];
|
|
45359
|
+
const _list = list.filter((item) => {
|
|
45360
|
+
if (repo2) {
|
|
45361
|
+
if (item.slug === repo2) {
|
|
45362
|
+
return true;
|
|
45363
|
+
}
|
|
45364
|
+
} else {
|
|
45365
|
+
if (item.slug.includes("/dev")) {
|
|
45366
|
+
return true;
|
|
45367
|
+
}
|
|
45368
|
+
}
|
|
45369
|
+
return false;
|
|
45370
|
+
});
|
|
45371
|
+
for (const item of _list) {
|
|
45372
|
+
const branch = item.branch || "main";
|
|
45373
|
+
const repo3 = item.slug;
|
|
45374
|
+
const sn = item.sn;
|
|
45375
|
+
await cnb.workspace.stopWorkspace({ sn });
|
|
45376
|
+
if (config3) {
|
|
45377
|
+
await cnb.build.startBuild(repo3, { branch, config: config3, event });
|
|
45378
|
+
} else {
|
|
45379
|
+
await cnb.workspace.startWorkspace(repo3, { branch });
|
|
45380
|
+
}
|
|
45381
|
+
}
|
|
45382
|
+
ctx.body = {
|
|
45383
|
+
content: "工作区重新启动中"
|
|
45384
|
+
};
|
|
45385
|
+
}).addTo(app);
|
|
45386
|
+
|
|
45329
45387
|
// agent/routes/workspace/index.ts
|
|
45330
45388
|
app.route({
|
|
45331
45389
|
path: "cnb",
|
|
@@ -46310,8 +46368,8 @@ app.route({
|
|
|
46310
46368
|
const cnb = await cnbManager.getContext(ctx);
|
|
46311
46369
|
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
46312
46370
|
const issueNumber = ctx.query?.issueNumber;
|
|
46313
|
-
const page = ctx.query?.page
|
|
46314
|
-
const page_size = ctx.query?.page_size
|
|
46371
|
+
const page = ctx.query?.page ?? 1;
|
|
46372
|
+
const page_size = ctx.query?.page_size ?? 100;
|
|
46315
46373
|
if (!repo2) {
|
|
46316
46374
|
ctx.throw(400, "缺少参数 repo");
|
|
46317
46375
|
}
|
|
@@ -53320,6 +53378,180 @@ app.route({
|
|
|
53320
53378
|
ctx.forward(res);
|
|
53321
53379
|
}).addTo(app);
|
|
53322
53380
|
|
|
53381
|
+
// agent/routes/labels/issue-label.ts
|
|
53382
|
+
app.route({
|
|
53383
|
+
path: "cnb",
|
|
53384
|
+
key: "list-issue-labels",
|
|
53385
|
+
description: "查询 Issue 的标签列表",
|
|
53386
|
+
middleware: ["auth"],
|
|
53387
|
+
metadata: {
|
|
53388
|
+
tags: ["opencode"],
|
|
53389
|
+
...createSkill({
|
|
53390
|
+
skill: "list-issue-labels",
|
|
53391
|
+
title: "查询 Issue 标签列表",
|
|
53392
|
+
summary: "查询 Issue 的标签列表",
|
|
53393
|
+
args: {
|
|
53394
|
+
repo: tool.schema.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
53395
|
+
issueNumber: tool.schema.number().describe("Issue 编号"),
|
|
53396
|
+
page: tool.schema.number().optional().describe("分页页码,默认 1"),
|
|
53397
|
+
pageSize: tool.schema.number().optional().describe("分页每页大小,默认 30")
|
|
53398
|
+
}
|
|
53399
|
+
})
|
|
53400
|
+
}
|
|
53401
|
+
}).define(async (ctx) => {
|
|
53402
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53403
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
53404
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
53405
|
+
const page = ctx.query?.page;
|
|
53406
|
+
const pageSize = ctx.query?.pageSize;
|
|
53407
|
+
if (!repo2) {
|
|
53408
|
+
ctx.throw(400, "缺少参数 repo");
|
|
53409
|
+
}
|
|
53410
|
+
if (!issueNumber) {
|
|
53411
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
53412
|
+
}
|
|
53413
|
+
const res = await cnb.labels.issueLabel.list(repo2, issueNumber, {
|
|
53414
|
+
page,
|
|
53415
|
+
page_size: pageSize
|
|
53416
|
+
});
|
|
53417
|
+
ctx.forward(res);
|
|
53418
|
+
}).addTo(app);
|
|
53419
|
+
app.route({
|
|
53420
|
+
path: "cnb",
|
|
53421
|
+
key: "set-issue-labels",
|
|
53422
|
+
description: "设置 Issue 标签(完全替换现有标签)",
|
|
53423
|
+
middleware: ["auth"],
|
|
53424
|
+
metadata: {
|
|
53425
|
+
tags: ["opencode"],
|
|
53426
|
+
...createSkill({
|
|
53427
|
+
skill: "set-issue-labels",
|
|
53428
|
+
title: "设置 Issue 标签",
|
|
53429
|
+
summary: "设置 Issue 标签(完全替换现有标签)",
|
|
53430
|
+
args: {
|
|
53431
|
+
repo: tool.schema.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
53432
|
+
issueNumber: tool.schema.number().describe("Issue 编号"),
|
|
53433
|
+
labels: tool.schema.array(tool.schema.string()).describe("标签名称数组")
|
|
53434
|
+
}
|
|
53435
|
+
})
|
|
53436
|
+
}
|
|
53437
|
+
}).define(async (ctx) => {
|
|
53438
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53439
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
53440
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
53441
|
+
const labels2 = ctx.query?.labels;
|
|
53442
|
+
if (!repo2) {
|
|
53443
|
+
ctx.throw(400, "缺少参数 repo");
|
|
53444
|
+
}
|
|
53445
|
+
if (!issueNumber) {
|
|
53446
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
53447
|
+
}
|
|
53448
|
+
if (!labels2 || !Array.isArray(labels2)) {
|
|
53449
|
+
ctx.throw(400, "缺少参数 labels");
|
|
53450
|
+
}
|
|
53451
|
+
const res = await cnb.labels.issueLabel.set(repo2, issueNumber, { labels: labels2 });
|
|
53452
|
+
ctx.forward(res);
|
|
53453
|
+
}).addTo(app);
|
|
53454
|
+
app.route({
|
|
53455
|
+
path: "cnb",
|
|
53456
|
+
key: "add-issue-labels",
|
|
53457
|
+
description: "新增 Issue 标签(追加到现有标签)",
|
|
53458
|
+
middleware: ["auth"],
|
|
53459
|
+
metadata: {
|
|
53460
|
+
tags: ["opencode"],
|
|
53461
|
+
...createSkill({
|
|
53462
|
+
skill: "add-issue-labels",
|
|
53463
|
+
title: "新增 Issue 标签",
|
|
53464
|
+
summary: "新增 Issue 标签(追加到现有标签)",
|
|
53465
|
+
args: {
|
|
53466
|
+
repo: tool.schema.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
53467
|
+
issueNumber: tool.schema.number().describe("Issue 编号"),
|
|
53468
|
+
labels: tool.schema.array(tool.schema.string()).describe("标签名称数组")
|
|
53469
|
+
}
|
|
53470
|
+
})
|
|
53471
|
+
}
|
|
53472
|
+
}).define(async (ctx) => {
|
|
53473
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53474
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
53475
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
53476
|
+
const labels2 = ctx.query?.labels;
|
|
53477
|
+
if (!repo2) {
|
|
53478
|
+
ctx.throw(400, "缺少参数 repo");
|
|
53479
|
+
}
|
|
53480
|
+
if (!issueNumber) {
|
|
53481
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
53482
|
+
}
|
|
53483
|
+
if (!labels2 || !Array.isArray(labels2)) {
|
|
53484
|
+
ctx.throw(400, "缺少参数 labels");
|
|
53485
|
+
}
|
|
53486
|
+
const res = await cnb.labels.issueLabel.add(repo2, issueNumber, { labels: labels2 });
|
|
53487
|
+
ctx.forward(res);
|
|
53488
|
+
}).addTo(app);
|
|
53489
|
+
app.route({
|
|
53490
|
+
path: "cnb",
|
|
53491
|
+
key: "clear-issue-labels",
|
|
53492
|
+
description: "清空 Issue 标签(移除所有标签)",
|
|
53493
|
+
middleware: ["auth"],
|
|
53494
|
+
metadata: {
|
|
53495
|
+
tags: ["opencode"],
|
|
53496
|
+
...createSkill({
|
|
53497
|
+
skill: "clear-issue-labels",
|
|
53498
|
+
title: "清空 Issue 标签",
|
|
53499
|
+
summary: "清空 Issue 标签(移除所有标签)",
|
|
53500
|
+
args: {
|
|
53501
|
+
repo: tool.schema.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
53502
|
+
issueNumber: tool.schema.number().describe("Issue 编号")
|
|
53503
|
+
}
|
|
53504
|
+
})
|
|
53505
|
+
}
|
|
53506
|
+
}).define(async (ctx) => {
|
|
53507
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53508
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
53509
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
53510
|
+
if (!repo2) {
|
|
53511
|
+
ctx.throw(400, "缺少参数 repo");
|
|
53512
|
+
}
|
|
53513
|
+
if (!issueNumber) {
|
|
53514
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
53515
|
+
}
|
|
53516
|
+
const res = await cnb.labels.issueLabel.clear(repo2, issueNumber);
|
|
53517
|
+
ctx.forward(res);
|
|
53518
|
+
}).addTo(app);
|
|
53519
|
+
app.route({
|
|
53520
|
+
path: "cnb",
|
|
53521
|
+
key: "remove-issue-label",
|
|
53522
|
+
description: "删除 Issue 指定标签",
|
|
53523
|
+
middleware: ["auth"],
|
|
53524
|
+
metadata: {
|
|
53525
|
+
tags: ["opencode"],
|
|
53526
|
+
...createSkill({
|
|
53527
|
+
skill: "remove-issue-label",
|
|
53528
|
+
title: "删除 Issue 标签",
|
|
53529
|
+
summary: "删除 Issue 指定标签",
|
|
53530
|
+
args: {
|
|
53531
|
+
repo: tool.schema.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
53532
|
+
issueNumber: tool.schema.number().describe("Issue 编号"),
|
|
53533
|
+
name: tool.schema.string().describe("标签名称")
|
|
53534
|
+
}
|
|
53535
|
+
})
|
|
53536
|
+
}
|
|
53537
|
+
}).define(async (ctx) => {
|
|
53538
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53539
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
53540
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
53541
|
+
const name21 = ctx.query?.name;
|
|
53542
|
+
if (!repo2) {
|
|
53543
|
+
ctx.throw(400, "缺少参数 repo");
|
|
53544
|
+
}
|
|
53545
|
+
if (!issueNumber) {
|
|
53546
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
53547
|
+
}
|
|
53548
|
+
if (!name21) {
|
|
53549
|
+
ctx.throw(400, "缺少参数 name");
|
|
53550
|
+
}
|
|
53551
|
+
const res = await cnb.labels.issueLabel.remove(repo2, issueNumber, name21);
|
|
53552
|
+
ctx.forward(res);
|
|
53553
|
+
}).addTo(app);
|
|
53554
|
+
|
|
53323
53555
|
// agent/routes/index.ts
|
|
53324
53556
|
var checkAppId = (ctx, appId) => {
|
|
53325
53557
|
const _appId = ctx?.app?.appId;
|
package/dist/routes.js
CHANGED
|
@@ -44711,7 +44711,8 @@ app.route({
|
|
|
44711
44711
|
summary: "列出cnb代码仓库, 可选flags参数,如 KnowledgeBase",
|
|
44712
44712
|
args: {
|
|
44713
44713
|
search: tool.schema.string().optional().describe("搜索关键词"),
|
|
44714
|
-
|
|
44714
|
+
page: tool.schema.number().optional().describe("分页页码,默认 1"),
|
|
44715
|
+
pageSize: tool.schema.number().optional().describe("每页数量,默认99"),
|
|
44715
44716
|
flags: tool.schema.string().optional().describe("仓库标记,如果是知识库则填写 KnowledgeBase")
|
|
44716
44717
|
}
|
|
44717
44718
|
})
|
|
@@ -44719,13 +44720,17 @@ app.route({
|
|
|
44719
44720
|
}).define(async (ctx) => {
|
|
44720
44721
|
const cnb = await cnbManager.getContext(ctx);
|
|
44721
44722
|
const search = ctx.query?.search;
|
|
44722
|
-
const
|
|
44723
|
+
const page = ctx.query?.page || 1;
|
|
44724
|
+
let pageSize = ctx.query?.pageSize || 99;
|
|
44723
44725
|
const flags = ctx.query?.flags;
|
|
44724
44726
|
const params = {};
|
|
44725
44727
|
if (flags) {
|
|
44726
44728
|
params.flags = flags;
|
|
44727
44729
|
}
|
|
44728
|
-
|
|
44730
|
+
if (pageSize > 99) {
|
|
44731
|
+
pageSize = 99;
|
|
44732
|
+
}
|
|
44733
|
+
const res = await cnb.repo.getRepoList({ search, page, page_size: pageSize + 1, role: "developer", ...params });
|
|
44729
44734
|
if (res.code === 200) {
|
|
44730
44735
|
const repos = res.data.map((item) => ({
|
|
44731
44736
|
name: item.name,
|
|
@@ -44733,7 +44738,9 @@ app.route({
|
|
|
44733
44738
|
description: item.description,
|
|
44734
44739
|
web_url: item.web_url
|
|
44735
44740
|
}));
|
|
44736
|
-
|
|
44741
|
+
const list = repos.slice(0, pageSize);
|
|
44742
|
+
const hasMore = repos.length > pageSize;
|
|
44743
|
+
ctx.body = { content: JSON.stringify(repos), list, hasMore, page, pageSize };
|
|
44737
44744
|
} else {
|
|
44738
44745
|
ctx.throw(500, "获取仓库列表失败");
|
|
44739
44746
|
}
|
|
@@ -45326,6 +45333,57 @@ app.route({
|
|
|
45326
45333
|
ctx.forward(res);
|
|
45327
45334
|
}).addTo(app);
|
|
45328
45335
|
|
|
45336
|
+
// agent/routes/workspace/rerun.ts
|
|
45337
|
+
app.route({
|
|
45338
|
+
path: "cnb",
|
|
45339
|
+
key: "rerun",
|
|
45340
|
+
description: "重新启动工作区,定时任务",
|
|
45341
|
+
middleware: ["auth"],
|
|
45342
|
+
metadata: {
|
|
45343
|
+
args: {
|
|
45344
|
+
repo: zod_default.string().optional().describe("仓库名称,例如:owner/repo"),
|
|
45345
|
+
config: zod_default.string().optional().describe("工作区配置"),
|
|
45346
|
+
event: zod_default.string().optional().describe("触发事件来源,api_trigger_event")
|
|
45347
|
+
}
|
|
45348
|
+
}
|
|
45349
|
+
}).define(async (ctx) => {
|
|
45350
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
45351
|
+
const repo2 = ctx.args.repo;
|
|
45352
|
+
const config3 = ctx.args.config;
|
|
45353
|
+
const event = ctx.args.event || "api_trigger_event";
|
|
45354
|
+
const res = await cnb.workspace.list({ status: "running" });
|
|
45355
|
+
if (res.code !== 200) {
|
|
45356
|
+
ctx.throw(500, res.message || "Failed to list workspaces");
|
|
45357
|
+
}
|
|
45358
|
+
const list = res.data?.list || [];
|
|
45359
|
+
const _list = list.filter((item) => {
|
|
45360
|
+
if (repo2) {
|
|
45361
|
+
if (item.slug === repo2) {
|
|
45362
|
+
return true;
|
|
45363
|
+
}
|
|
45364
|
+
} else {
|
|
45365
|
+
if (item.slug.includes("/dev")) {
|
|
45366
|
+
return true;
|
|
45367
|
+
}
|
|
45368
|
+
}
|
|
45369
|
+
return false;
|
|
45370
|
+
});
|
|
45371
|
+
for (const item of _list) {
|
|
45372
|
+
const branch = item.branch || "main";
|
|
45373
|
+
const repo3 = item.slug;
|
|
45374
|
+
const sn = item.sn;
|
|
45375
|
+
await cnb.workspace.stopWorkspace({ sn });
|
|
45376
|
+
if (config3) {
|
|
45377
|
+
await cnb.build.startBuild(repo3, { branch, config: config3, event });
|
|
45378
|
+
} else {
|
|
45379
|
+
await cnb.workspace.startWorkspace(repo3, { branch });
|
|
45380
|
+
}
|
|
45381
|
+
}
|
|
45382
|
+
ctx.body = {
|
|
45383
|
+
content: "工作区重新启动中"
|
|
45384
|
+
};
|
|
45385
|
+
}).addTo(app);
|
|
45386
|
+
|
|
45329
45387
|
// agent/routes/workspace/index.ts
|
|
45330
45388
|
app.route({
|
|
45331
45389
|
path: "cnb",
|
|
@@ -46310,8 +46368,8 @@ app.route({
|
|
|
46310
46368
|
const cnb = await cnbManager.getContext(ctx);
|
|
46311
46369
|
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
46312
46370
|
const issueNumber = ctx.query?.issueNumber;
|
|
46313
|
-
const page = ctx.query?.page
|
|
46314
|
-
const page_size = ctx.query?.page_size
|
|
46371
|
+
const page = ctx.query?.page ?? 1;
|
|
46372
|
+
const page_size = ctx.query?.page_size ?? 100;
|
|
46315
46373
|
if (!repo2) {
|
|
46316
46374
|
ctx.throw(400, "缺少参数 repo");
|
|
46317
46375
|
}
|
|
@@ -53320,6 +53378,180 @@ app.route({
|
|
|
53320
53378
|
ctx.forward(res);
|
|
53321
53379
|
}).addTo(app);
|
|
53322
53380
|
|
|
53381
|
+
// agent/routes/labels/issue-label.ts
|
|
53382
|
+
app.route({
|
|
53383
|
+
path: "cnb",
|
|
53384
|
+
key: "list-issue-labels",
|
|
53385
|
+
description: "查询 Issue 的标签列表",
|
|
53386
|
+
middleware: ["auth"],
|
|
53387
|
+
metadata: {
|
|
53388
|
+
tags: ["opencode"],
|
|
53389
|
+
...createSkill({
|
|
53390
|
+
skill: "list-issue-labels",
|
|
53391
|
+
title: "查询 Issue 标签列表",
|
|
53392
|
+
summary: "查询 Issue 的标签列表",
|
|
53393
|
+
args: {
|
|
53394
|
+
repo: tool.schema.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
53395
|
+
issueNumber: tool.schema.number().describe("Issue 编号"),
|
|
53396
|
+
page: tool.schema.number().optional().describe("分页页码,默认 1"),
|
|
53397
|
+
pageSize: tool.schema.number().optional().describe("分页每页大小,默认 30")
|
|
53398
|
+
}
|
|
53399
|
+
})
|
|
53400
|
+
}
|
|
53401
|
+
}).define(async (ctx) => {
|
|
53402
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53403
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
53404
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
53405
|
+
const page = ctx.query?.page;
|
|
53406
|
+
const pageSize = ctx.query?.pageSize;
|
|
53407
|
+
if (!repo2) {
|
|
53408
|
+
ctx.throw(400, "缺少参数 repo");
|
|
53409
|
+
}
|
|
53410
|
+
if (!issueNumber) {
|
|
53411
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
53412
|
+
}
|
|
53413
|
+
const res = await cnb.labels.issueLabel.list(repo2, issueNumber, {
|
|
53414
|
+
page,
|
|
53415
|
+
page_size: pageSize
|
|
53416
|
+
});
|
|
53417
|
+
ctx.forward(res);
|
|
53418
|
+
}).addTo(app);
|
|
53419
|
+
app.route({
|
|
53420
|
+
path: "cnb",
|
|
53421
|
+
key: "set-issue-labels",
|
|
53422
|
+
description: "设置 Issue 标签(完全替换现有标签)",
|
|
53423
|
+
middleware: ["auth"],
|
|
53424
|
+
metadata: {
|
|
53425
|
+
tags: ["opencode"],
|
|
53426
|
+
...createSkill({
|
|
53427
|
+
skill: "set-issue-labels",
|
|
53428
|
+
title: "设置 Issue 标签",
|
|
53429
|
+
summary: "设置 Issue 标签(完全替换现有标签)",
|
|
53430
|
+
args: {
|
|
53431
|
+
repo: tool.schema.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
53432
|
+
issueNumber: tool.schema.number().describe("Issue 编号"),
|
|
53433
|
+
labels: tool.schema.array(tool.schema.string()).describe("标签名称数组")
|
|
53434
|
+
}
|
|
53435
|
+
})
|
|
53436
|
+
}
|
|
53437
|
+
}).define(async (ctx) => {
|
|
53438
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53439
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
53440
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
53441
|
+
const labels2 = ctx.query?.labels;
|
|
53442
|
+
if (!repo2) {
|
|
53443
|
+
ctx.throw(400, "缺少参数 repo");
|
|
53444
|
+
}
|
|
53445
|
+
if (!issueNumber) {
|
|
53446
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
53447
|
+
}
|
|
53448
|
+
if (!labels2 || !Array.isArray(labels2)) {
|
|
53449
|
+
ctx.throw(400, "缺少参数 labels");
|
|
53450
|
+
}
|
|
53451
|
+
const res = await cnb.labels.issueLabel.set(repo2, issueNumber, { labels: labels2 });
|
|
53452
|
+
ctx.forward(res);
|
|
53453
|
+
}).addTo(app);
|
|
53454
|
+
app.route({
|
|
53455
|
+
path: "cnb",
|
|
53456
|
+
key: "add-issue-labels",
|
|
53457
|
+
description: "新增 Issue 标签(追加到现有标签)",
|
|
53458
|
+
middleware: ["auth"],
|
|
53459
|
+
metadata: {
|
|
53460
|
+
tags: ["opencode"],
|
|
53461
|
+
...createSkill({
|
|
53462
|
+
skill: "add-issue-labels",
|
|
53463
|
+
title: "新增 Issue 标签",
|
|
53464
|
+
summary: "新增 Issue 标签(追加到现有标签)",
|
|
53465
|
+
args: {
|
|
53466
|
+
repo: tool.schema.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
53467
|
+
issueNumber: tool.schema.number().describe("Issue 编号"),
|
|
53468
|
+
labels: tool.schema.array(tool.schema.string()).describe("标签名称数组")
|
|
53469
|
+
}
|
|
53470
|
+
})
|
|
53471
|
+
}
|
|
53472
|
+
}).define(async (ctx) => {
|
|
53473
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53474
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
53475
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
53476
|
+
const labels2 = ctx.query?.labels;
|
|
53477
|
+
if (!repo2) {
|
|
53478
|
+
ctx.throw(400, "缺少参数 repo");
|
|
53479
|
+
}
|
|
53480
|
+
if (!issueNumber) {
|
|
53481
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
53482
|
+
}
|
|
53483
|
+
if (!labels2 || !Array.isArray(labels2)) {
|
|
53484
|
+
ctx.throw(400, "缺少参数 labels");
|
|
53485
|
+
}
|
|
53486
|
+
const res = await cnb.labels.issueLabel.add(repo2, issueNumber, { labels: labels2 });
|
|
53487
|
+
ctx.forward(res);
|
|
53488
|
+
}).addTo(app);
|
|
53489
|
+
app.route({
|
|
53490
|
+
path: "cnb",
|
|
53491
|
+
key: "clear-issue-labels",
|
|
53492
|
+
description: "清空 Issue 标签(移除所有标签)",
|
|
53493
|
+
middleware: ["auth"],
|
|
53494
|
+
metadata: {
|
|
53495
|
+
tags: ["opencode"],
|
|
53496
|
+
...createSkill({
|
|
53497
|
+
skill: "clear-issue-labels",
|
|
53498
|
+
title: "清空 Issue 标签",
|
|
53499
|
+
summary: "清空 Issue 标签(移除所有标签)",
|
|
53500
|
+
args: {
|
|
53501
|
+
repo: tool.schema.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
53502
|
+
issueNumber: tool.schema.number().describe("Issue 编号")
|
|
53503
|
+
}
|
|
53504
|
+
})
|
|
53505
|
+
}
|
|
53506
|
+
}).define(async (ctx) => {
|
|
53507
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53508
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
53509
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
53510
|
+
if (!repo2) {
|
|
53511
|
+
ctx.throw(400, "缺少参数 repo");
|
|
53512
|
+
}
|
|
53513
|
+
if (!issueNumber) {
|
|
53514
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
53515
|
+
}
|
|
53516
|
+
const res = await cnb.labels.issueLabel.clear(repo2, issueNumber);
|
|
53517
|
+
ctx.forward(res);
|
|
53518
|
+
}).addTo(app);
|
|
53519
|
+
app.route({
|
|
53520
|
+
path: "cnb",
|
|
53521
|
+
key: "remove-issue-label",
|
|
53522
|
+
description: "删除 Issue 指定标签",
|
|
53523
|
+
middleware: ["auth"],
|
|
53524
|
+
metadata: {
|
|
53525
|
+
tags: ["opencode"],
|
|
53526
|
+
...createSkill({
|
|
53527
|
+
skill: "remove-issue-label",
|
|
53528
|
+
title: "删除 Issue 标签",
|
|
53529
|
+
summary: "删除 Issue 指定标签",
|
|
53530
|
+
args: {
|
|
53531
|
+
repo: tool.schema.string().optional().describe("仓库路径, 如 my-user/my-repo"),
|
|
53532
|
+
issueNumber: tool.schema.number().describe("Issue 编号"),
|
|
53533
|
+
name: tool.schema.string().describe("标签名称")
|
|
53534
|
+
}
|
|
53535
|
+
})
|
|
53536
|
+
}
|
|
53537
|
+
}).define(async (ctx) => {
|
|
53538
|
+
const cnb = await cnbManager.getContext(ctx);
|
|
53539
|
+
let repo2 = ctx.query?.repo || useKey("CNB_REPO_SLUG_LOWERCASE");
|
|
53540
|
+
const issueNumber = ctx.query?.issueNumber;
|
|
53541
|
+
const name21 = ctx.query?.name;
|
|
53542
|
+
if (!repo2) {
|
|
53543
|
+
ctx.throw(400, "缺少参数 repo");
|
|
53544
|
+
}
|
|
53545
|
+
if (!issueNumber) {
|
|
53546
|
+
ctx.throw(400, "缺少参数 issueNumber");
|
|
53547
|
+
}
|
|
53548
|
+
if (!name21) {
|
|
53549
|
+
ctx.throw(400, "缺少参数 name");
|
|
53550
|
+
}
|
|
53551
|
+
const res = await cnb.labels.issueLabel.remove(repo2, issueNumber, name21);
|
|
53552
|
+
ctx.forward(res);
|
|
53553
|
+
}).addTo(app);
|
|
53554
|
+
|
|
53323
53555
|
// agent/routes/index.ts
|
|
53324
53556
|
var checkAppId = (ctx, appId) => {
|
|
53325
53557
|
const _appId = ctx?.app?.appId;
|