37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { createSkill } from '@kevisual/router';
|
||
import { app, cnb } from '../../app.ts';
|
||
import { tool } from "@opencode-ai/plugin/tool"
|
||
|
||
app.route({
|
||
path: 'cnb',
|
||
key: 'list-repos',
|
||
description: '列出我的代码仓库',
|
||
middleware: ['auth'],
|
||
metadata: {
|
||
tags: ['opencode'],
|
||
...createSkill({
|
||
skill: 'list-repos',
|
||
title: '列出代码仓库',
|
||
summary: '列出代码仓库',
|
||
args: {
|
||
search: tool.schema.string().optional().describe('搜索关键词'),
|
||
pageSize: tool.schema.number().optional().describe('每页数量,默认999'),
|
||
},
|
||
})
|
||
}
|
||
}).define(async (ctx) => {
|
||
const search = ctx.query?.search;
|
||
const pageSize = ctx.query?.pageSize || 9999;
|
||
const res = await cnb.repo.getRepoList({ search, page_size: pageSize, role: 'developer' });
|
||
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) };
|
||
} else {
|
||
ctx.throw(500, '获取仓库列表失败');
|
||
}
|
||
}).addTo(app); |