update add openapi api

This commit is contained in:
xiongxiao
2026-01-16 13:03:57 +08:00
parent a8f2cb14a7
commit 7787337f13
32 changed files with 39023 additions and 43 deletions

View File

@@ -27,48 +27,53 @@ app.route({
if (!name) {
ctx.throw(400, '缺少参数 name');
}
try {
const res = await cnb.repo.createRepo({
name,
visibility,
description,
});
ctx.forward(res);
const res = await cnb.repo.createRepo({
name,
visibility,
description,
});
ctx.forward(res);
} catch (error) {
ctx.code = 200
ctx.body = { content: 'JS仓库可能已存在' }
}
}).addTo(app);
app.route({
path: 'cnb',
key: 'create-repo-file',
description: '在代码仓库中创建文件, name, path, content, encoding',
description: '在代码仓库中创建文件, repoName, filePath, content, encoding',
middleware: ['auth'],
metadata: {
tags: ['opencode'],
...createSkill({
skill: 'create-repo-file',
title: '在代码仓库中创建文件',
summary: `在代码仓库中创建文件, encoding 可选,默认 raw`,
args: {
name: tool.schema.string().describe('代码仓库名称'),
path: tool.schema.string().describe('文件路径, 如 src/index.ts'),
content: tool.schema.string().describe('文内容'),
encoding: tool.schema.string().describe('编码方式, 默认为 raw').optional(),
repoName: tool.schema.string().describe('代码仓库名称, 如 my-user/my-repo'),
filePath: tool.schema.string().describe('文件路径, 如 src/index.ts'),
content: tool.schema.string().describe('文本的字符串的内容'),
encoding: tool.schema.string().describe('编码方式,如 raw').optional(),
},
summary: '在代码仓库中创建文件',
})
}
}).define(async (ctx) => {
const name = ctx.query?.name;
const path = ctx.query?.path;
const repoName = ctx.query?.repoName;
const filePath = ctx.query?.filePath;
const content = ctx.query?.content;
const encoding = ctx.query?.encoding ?? 'raw';
if (!name || !path || !content) {
ctx.throw(400, '缺少参数 name, path 或 content');
if (!repoName || !filePath || !content) {
ctx.throw(400, '缺少参数 repoName, filePath 或 content');
}
const res = await cnb.repo.createCommit(name, {
message: `添加文件 ${path} 通过 API `,
const res = await cnb.repo.createCommit(repoName, {
message: `添加文件 ${filePath} 通过 API `,
files: [
{ path, content, encoding },
{ path: filePath, content, encoding },
],
});
ctx.forward(res);