Files
cnb/agent/routes/issues/list.ts
xiongxiao 38ee73e48f feat: update package version to 0.0.42 and add CNB version fetching functionality
- Updated package version in package.json from 0.0.40 to 0.0.42.
- Added getCNBVersion function to fetch CNB version information from the API.
- Enhanced Issue class with methods for managing comments (list, create, get, update).
- Introduced new NPC and comment environment hooks for better context management.
- Implemented Docker image synchronization route for CNB.
- Added tests for version fetching and issue comment functionalities.
2026-03-10 03:45:02 +08:00

52 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { createSkill, tool } from '@kevisual/router';
import { app, cnbManager } from '../../app.ts';
import { useKey } from '@kevisual/context';
// 查询 Issue 列表 repo是 kevisual/kevisual
app.route({
path: 'cnb',
key: 'list-issues',
description: '查询 Issue 列表, 参数 repo, state, keyword, labels, page, page_size 等',
middleware: ['auth'],
metadata: {
tags: ['opencode'],
...createSkill({
skill: 'list-issues',
title: '查询 Issue 列表',
args: {
repo: tool.schema.string().optional().describe('代码仓库名称, 如 my-user/my-repo'),
state: tool.schema.string().optional().describe('Issue 状态open 或 closed'),
keyword: tool.schema.string().optional().describe('问题搜索关键词'),
labels: tool.schema.string().optional().describe('问题标签,多个用逗号分隔'),
page: tool.schema.number().optional().describe('分页页码,默认: 1'),
page_size: tool.schema.number().optional().describe('分页每页大小,默认: 30'),
order_by: tool.schema.string().optional().describe('排序方式,如 created_at, -updated_at'),
},
summary: '查询 Issue 列表',
})
}
}).define(async (ctx) => {
const cnb = await cnbManager.getContext(ctx);
let repo = ctx.query?.repo || useKey('CNB_REPO_SLUG_LOWERCASE');
const state = ctx.query?.state;
const keyword = ctx.query?.keyword;
const labels = ctx.query?.labels;
const page = ctx.query?.page ? Number(ctx.query.page) : undefined;
const page_size = ctx.query?.page_size ? Number(ctx.query.page_size) : undefined;
const order_by = ctx.query?.order_by;
if (!repo) {
ctx.throw(400, '缺少参数 repo');
}
const params: Record<string, any> = {};
if (state) params.state = state;
if (keyword) params.keyword = keyword;
if (labels) params.labels = labels;
if (page) params.page = page;
if (page_size) params.page_size = page_size;
if (order_by) params.order_by = order_by;
const res = await cnb.issue.getList(repo, params);
ctx.forward(res);
}).addTo(app);