import { createSkill } from '@kevisual/router'; import { app, cnb } from '../../app.ts'; import { tool } from "@opencode-ai/plugin/tool" // "列出我的代码仓库,search blog" // 列出我的知识库的代码仓库 app.route({ path: 'cnb', key: 'list-repos', description: '列出我的代码仓库', middleware: ['admin-auth'], metadata: { tags: ['opencode'], ...createSkill({ skill: 'list-repos', title: '列出cnb代码仓库', summary: '列出cnb代码仓库, 可选flags参数,如 KnowledgeBase', args: { search: tool.schema.string().optional().describe('搜索关键词'), pageSize: tool.schema.number().optional().describe('每页数量,默认999'), flags: tool.schema.string().optional().describe('仓库标记,如果是知识库则填写 KnowledgeBase'), }, }) } }).define(async (ctx) => { const search = ctx.query?.search; const pageSize = ctx.query?.pageSize || 9999; const flags = ctx.query?.flags; const params: any = {}; if (flags) { params.flags = flags; } const res = await cnb.repo.getRepoList({ search, page_size: pageSize, role: 'developer', ...params }); if (res.code === 200) { const repos = res.data.map((item) => ({ name: item.name, path: item.path, description: item.description, web_url: item.web_url, })); ctx.body = { content: JSON.stringify(repos), list: res.data }; } else { ctx.throw(500, '获取仓库列表失败'); } }).addTo(app);