From 253ef2ac7d26abbeb30343d250b8dea35df7be24 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Fri, 6 Mar 2026 02:50:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20CNB=20API=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89=EF=BC=8C=E5=8C=85=E6=8B=AC?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=AA=8C=E8=AF=81=E3=80=81=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=92=8C=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/cnb/api.ts | 906 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 906 insertions(+) create mode 100644 src/pages/cnb/api.ts diff --git a/src/pages/cnb/api.ts b/src/pages/cnb/api.ts new file mode 100644 index 0000000..8459fa7 --- /dev/null +++ b/src/pages/cnb/api.ts @@ -0,0 +1,906 @@ +import { createQueryApi } from '@kevisual/query/api'; +import { queryClient as query } from '@/modules/query.ts'; +const api = { + "cnb": { + /** + * 验证 CNB 登录信息是否有效 + * + * @param data - Request parameters + * @param data.checkToken - {boolean} 是否检查 Token 的有效性 + * @param data.checkCookie - {boolean} 是否检查 Cookie 的有效性 + */ + "user-check": { + "path": "cnb", + "key": "user-check", + "description": "检查用户登录状态,参数checkToken,default true; checkCookie, default false", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "checkToken": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "default": true, + "type": "boolean", + "description": "是否检查 Token 的有效性", + "optional": true + }, + "checkCookie": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "default": false, + "type": "boolean", + "description": "是否检查 Cookie 的有效性", + "optional": true + } + }, + "skill": "cnb-login-verify", + "title": "CNB 登录验证信息", + "summary": "验证 CNB 登录信息是否有效", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 列出cnb代码仓库, 可选flags参数,如 KnowledgeBase + * + * @param data - Request parameters + * @param data.search - {string} 搜索关键词 + * @param data.pageSize - {number} 每页数量,默认999 + * @param data.flags - {string} 仓库标记,如果是知识库则填写 KnowledgeBase + */ + "list-repos": { + "path": "cnb", + "key": "list-repos", + "description": "列出我的代码仓库", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "search": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "搜索关键词", + "type": "string", + "optional": true + }, + "pageSize": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "每页数量,默认999", + "type": "number", + "optional": true + }, + "flags": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "仓库标记,如果是知识库则填写 KnowledgeBase", + "type": "string", + "optional": true + } + }, + "skill": "list-repos", + "title": "列出cnb代码仓库", + "summary": "列出cnb代码仓库, 可选flags参数,如 KnowledgeBase", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 创建一个新的代码仓库 + * + * @param data - Request parameters + * @param data.name - {string} 代码仓库名称, 如 my-user/my-repo + * @param data.visibility - {string} 代码仓库可见性, public 或 private + * @param data.description - {string} 代码仓库描述 + */ + "create-repo": { + "path": "cnb", + "key": "create-repo", + "description": "创建代码仓库, 参数name, visibility, description", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "name": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库名称, 如 my-user/my-repo" + }, + "visibility": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "default": "public", + "type": "string", + "description": "代码仓库可见性, public 或 private", + "optional": true + }, + "description": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库描述" + } + }, + "skill": "create-repo", + "title": "创建代码仓库", + "summary": "创建一个新的代码仓库", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 在代码仓库中创建文件, encoding 可选,默认 raw + * + * @param data - Request parameters + * @param data.repoName - {string} 代码仓库名称, 如 my-user/my-repo + * @param data.filePath - {string} 文件路径, 如 src/index.ts + * @param data.content - {string} 文本的字符串的内容 + * @param data.encoding - {string} 编码方式,如 raw + */ + "create-repo-file": { + "path": "cnb", + "key": "create-repo-file", + "description": "在代码仓库中创建文件, repoName, filePath, content, encoding。使用CNB_COOKIE进行鉴权", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "repoName": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库名称, 如 my-user/my-repo" + }, + "filePath": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "文件路径, 如 src/index.ts" + }, + "content": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "文本的字符串的内容" + }, + "encoding": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "编码方式,如 raw", + "optional": true + } + }, + "skill": "create-repo-file", + "title": "在代码仓库中创建文件", + "summary": "在代码仓库中创建文件, encoding 可选,默认 raw", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 删除一个代码仓库 + * + * @param data - Request parameters + * @param data.name - {string} 代码仓库名称 + */ + "delete-repo": { + "path": "cnb", + "key": "delete-repo", + "description": "删除代码仓库, 参数name", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "name": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库名称" + } + }, + "skill": "delete-repo", + "title": "删除代码仓库", + "summary": "删除一个代码仓库", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 批量删除已停止的cnb工作空间,释放资源 + */ + "clean-closed-workspace": { + "path": "cnb", + "key": "clean-closed-workspace", + "description": "批量删除已停止的cnb工作空间", + "metadata": { + "tags": [ + "opencode" + ], + "args": {}, + "skill": "clean-closed-workspace", + "title": "清理已关闭的cnb工作空间", + "summary": "批量删除已停止的cnb工作空间,释放资源", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 保持工作空间存活技能,参数repo:代码仓库路径,例如 user/repo,pipelineId:流水线ID,例如 cnb-708-1ji9sog7o-001 + * + * @param data - Request parameters + * @param data.repo - {string} 代码仓库路径,例如 user/repo + * @param data.pipelineId - {string} 流水线ID,例如 cnb-708-1ji9sog7o-001 + */ + "keep-workspace-alive": { + "path": "cnb", + "key": "keep-workspace-alive", + "description": "保持工作空间存活技能,参数repo:代码仓库路径,例如 user/repo,pipelineId:流水线ID,例如 cnb-708-1ji9sog7o-001", + "metadata": { + "tags": [], + "args": { + "repo": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库路径,例如 user/repo" + }, + "pipelineId": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "流水线ID,例如 cnb-708-1ji9sog7o-001" + } + }, + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 停止保持工作空间存活技能, 参数repo:代码仓库路径,例如 user/repo,pipelineId:流水线ID,例如 cnb-708-1ji9sog7o-001 + * + * @param data - Request parameters + * @param data.repo - {string} 代码仓库路径,例如 user/repo + * @param data.pipelineId - {string} 流水线ID,例如 cnb-708-1ji9sog7o-001 + */ + "stop-keep-workspace-alive": { + "path": "cnb", + "key": "stop-keep-workspace-alive", + "description": "停止保持工作空间存活技能, 参数repo:代码仓库路径,例如 user/repo,pipelineId:流水线ID,例如 cnb-708-1ji9sog7o-001", + "metadata": { + "tags": [], + "args": { + "repo": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库路径,例如 user/repo" + }, + "pipelineId": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "流水线ID,例如 cnb-708-1ji9sog7o-001" + } + }, + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 保持当前工作空间存活,防止被关闭或释放资源 + */ + "keep-alive-current-workspace": { + "path": "cnb", + "key": "keep-alive-current-workspace", + "description": "保持当前工作空间存活技能", + "metadata": { + "tags": [ + "opencode" + ], + "skill": "keep-alive-current-workspace", + "title": "保持当前工作空间存活", + "summary": "保持当前工作空间存活,防止被关闭或释放资源", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 启动cnb工作空间 + * + * @param data - Request parameters + * @param data.repo - {string} 代码仓库路径,例如 user/repo + * @param data.branch - {string} 分支名称,默认主分支 + * @param data.ref - {string} 提交引用,例如 commit sha + */ + "start-workspace": { + "path": "cnb", + "key": "start-workspace", + "description": "启动开发工作空间, 参数 repo", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "repo": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库路径,例如 user/repo" + }, + "branch": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "分支名称,默认主分支", + "type": "string", + "optional": true + }, + "ref": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "提交引用,例如 commit sha", + "type": "string", + "optional": true + } + }, + "skill": "start-workspace", + "title": "启动cnb工作空间", + "summary": "启动cnb工作空间", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 列出cnb工作空间列表,支持按状态过滤, status 可选值 running 或 closed + * + * @param data - Request parameters + * @param data.status - {string} 开发环境状态,running: 运行中,closed: 已关闭和停止的 + * @param data.page - {number} 分页页码,默认 1 + * @param data.pageSize - {number} 分页大小,默认 20,最大 100 + * @param data.slug - {string} 仓库路径,例如 groupname/reponame + * @param data.branch - {string} 分支名称 + */ + "list-workspace": { + "path": "cnb", + "key": "list-workspace", + "description": "获取cnb开发工作空间列表,可选参数 status=running 获取运行中的环境", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "status": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "开发环境状态,running: 运行中,closed: 已关闭和停止的", + "type": "string", + "optional": true + }, + "page": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "分页页码,默认 1", + "type": "number", + "optional": true + }, + "pageSize": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "分页大小,默认 20,最大 100", + "type": "number", + "optional": true + }, + "slug": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "仓库路径,例如 groupname/reponame", + "type": "string", + "optional": true + }, + "branch": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "分支名称", + "type": "string", + "optional": true + } + }, + "skill": "list-workspace", + "title": "列出cnb工作空间", + "summary": "列出cnb工作空间列表,支持按状态过滤, status 可选值 running 或 closed", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 获取工作空间详细信息 + * + * @param data - Request parameters + * @param data.repo - {string} 代码仓库路径,例如 user/repo + * @param data.sn - {string} 工作空间流水线的 sn + */ + "get-workspace": { + "path": "cnb", + "key": "get-workspace", + "description": "获取工作空间详情,通过 repo 和 sn 获取", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "repo": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库路径,例如 user/repo" + }, + "sn": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "工作空间流水线的 sn" + } + }, + "skill": "get-workspace", + "title": "获取工作空间详情", + "summary": "获取工作空间详细信息", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 删除工作空间,pipelineId 和 sn 二选一 + * + * @param data - Request parameters + * @param data.pipelineId - {string} 流水线 ID,优先使用 + * @param data.sn - {string} 流水线构建号 + * @param data.sns - {array} 批量流水线构建号 + */ + "delete-workspace": { + "path": "cnb", + "key": "delete-workspace", + "description": "删除工作空间,通过 pipelineId 或 sn", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "pipelineId": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "流水线 ID,优先使用", + "type": "string", + "optional": true + }, + "sn": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "流水线构建号", + "type": "string", + "optional": true + }, + "sns": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "批量流水线构建号", + "type": "array", + "items": { + "type": "string" + }, + "optional": true + } + }, + "skill": "delete-workspace", + "title": "删除工作空间", + "summary": "删除工作空间,pipelineId 和 sn 二选一", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 停止运行中的工作空间 + * + * @param data - Request parameters + * @param data.pipelineId - {string} 流水线 ID,优先使用 + * @param data.sn - {string} 流水线构建号 + */ + "stop-workspace": { + "path": "cnb", + "key": "stop-workspace", + "description": "停止工作空间,通过 pipelineId 或 sn", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "pipelineId": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "流水线 ID,优先使用", + "type": "string", + "optional": true + }, + "sn": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "流水线构建号", + "type": "string", + "optional": true + } + }, + "skill": "stop-workspace", + "title": "停止工作空间", + "summary": "停止运行中的工作空间", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 获取当前cnb工作空间的port代理uri,用于端口转发 + * + * @param data - Request parameters + * @param data.port - {number} 端口号,默认为51515 + */ + "get-cnb-port-uri": { + "path": "cnb", + "key": "get-cnb-port-uri", + "description": "获取当前cnb工作空间的port代理uri", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "port": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "端口号,默认为51515", + "type": "number", + "optional": true + } + }, + "skill": "get-cnb-port-uri", + "title": "获取当前cnb工作空间的port代理uri", + "summary": "获取当前cnb工作空间的port代理uri,用于端口转发", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 获取当前cnb工作空间的vscode代理uri,用于在浏览器中访问vscode,包含多种访问方式,如web、vscode、codebuddy、cursor、ssh + * + * @param data - Request parameters + * @param data.web - {boolean} 是否获取vscode web的访问uri,默认为false + * @param data.vscode - {boolean} 是否获取vscode的代理uri,默认为true + * @param data.codebuddy - {boolean} 是否获取codebuddy的代理uri,默认为false + * @param data.cursor - {boolean} 是否获取cursor的代理uri,默认为false + * @param data.ssh - {boolean} 是否获取vscode remote ssh的连接字符串,默认为false + */ + "get-cnb-vscode-uri": { + "path": "cnb", + "key": "get-cnb-vscode-uri", + "description": "获取当前cnb工作空间的vscode代理uri, 包括多种访问方式, 如web、vscode、codebuddy、cursor、ssh", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "web": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "是否获取vscode web的访问uri,默认为false", + "type": "boolean", + "optional": true + }, + "vscode": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "是否获取vscode的代理uri,默认为true", + "type": "boolean", + "optional": true + }, + "codebuddy": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "是否获取codebuddy的代理uri,默认为false", + "type": "boolean", + "optional": true + }, + "cursor": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "是否获取cursor的代理uri,默认为false", + "type": "boolean", + "optional": true + }, + "ssh": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "是否获取vscode remote ssh的连接字符串,默认为false", + "type": "boolean", + "optional": true + } + }, + "skill": "get-cnb-vscode-uri", + "title": "获取当前cnb工作空间的编辑器访问地址", + "summary": "获取当前cnb工作空间的vscode代理uri,用于在浏览器中访问vscode,包含多种访问方式,如web、vscode、codebuddy、cursor、ssh", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 设置当前cnb工作空间的cookie环境变量,用于界面操作定制模块功能,例子:CNBSESSION=xxxx;csrfkey=2222xxxx; + * + * @param data - Request parameters + * @param data.cookie - {string} cnb的cookie值 + */ + "set-cnb-cookie": { + "path": "cnb", + "key": "set-cnb-cookie", + "description": "设置当前cnb工作空间的cookie环境变量", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "cookie": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "cnb的cookie值" + } + }, + "skill": "set-cnb-cookie", + "title": "设置当前cnb工作空间的cookie环境变量", + "summary": "设置当前cnb工作空间的cookie环境变量,用于界面操作定制模块功能,例子:CNBSESSION=xxxx;csrfkey=2222xxxx;", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 获取当前cnb工作空间的cookie环境变量,用于界面操作定制模块功能 + */ + "get-cnb-cookie": { + "path": "cnb", + "key": "get-cnb-cookie", + "description": "获取当前cnb工作空间的cookie环境变量", + "metadata": { + "tags": [ + "opencode" + ], + "args": {}, + "skill": "get-cnb-cookie", + "title": "获取当前cnb工作空间的cookie环境变量", + "summary": "获取当前cnb工作空间的cookie环境变量,用于界面操作定制模块功能", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 调用cnb的知识库ai对话功能进行聊天,基于cnb提供的ai能力 + * + * @param data - Request parameters + * @param data.question - {string} 用户输入的消息内容 + * @param data.repo - {string} 知识库仓库ID,默认为空表示使用默认知识库 + */ + "cnb-ai-chat": { + "path": "cnb", + "key": "cnb-ai-chat", + "description": "调用cnb的知识库ai对话功能进行聊天", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "question": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "用户输入的消息内容" + }, + "repo": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "知识库仓库ID,默认为空表示使用默认知识库", + "type": "string", + "optional": true + } + }, + "skill": "cnb-ai-chat", + "title": "调用cnb的知识库ai对话功能进行聊天", + "summary": "调用cnb的知识库ai对话功能进行聊天,基于cnb提供的ai能力", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 调用cnb的知识库RAG查询功能进行问答,基于cnb提供的知识库能力 + * + * @param data - Request parameters + * @param data.question - {string} 用户输入的消息内容 + * @param data.repo - {string} 知识库仓库ID,默认为空表示使用默认知识库 + */ + "cnb-rag-query": { + "path": "cnb", + "key": "cnb-rag-query", + "description": "调用cnb的知识库RAG查询功能进行问答", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "question": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "用户输入的消息内容" + }, + "repo": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "知识库仓库ID,默认为空表示使用默认知识库", + "type": "string", + "optional": true + } + }, + "skill": "cnb-rag-query", + "title": "调用cnb的知识库RAG查询功能进行问答", + "summary": "调用cnb的知识库RAG查询功能进行问答,基于cnb提供的知识库能力", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 查询 Issue 列表 + * + * @param data - Request parameters + * @param data.repo - {string} 代码仓库名称, 如 my-user/my-repo + * @param data.state - {string} Issue 状态:open 或 closed + * @param data.keyword - {string} 问题搜索关键词 + * @param data.labels - {string} 问题标签,多个用逗号分隔 + * @param data.page - {number} 分页页码,默认: 1 + * @param data.page_size - {number} 分页每页大小,默认: 30 + * @param data.order_by - {string} 排序方式,如 created_at, -updated_at + */ + "list-issues": { + "path": "cnb", + "key": "list-issues", + "description": "查询 Issue 列表, 参数 repo, state, keyword, labels, page, page_size 等", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "repo": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库名称, 如 my-user/my-repo" + }, + "state": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "Issue 状态:open 或 closed", + "type": "string", + "optional": true + }, + "keyword": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "问题搜索关键词", + "type": "string", + "optional": true + }, + "labels": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "问题标签,多个用逗号分隔", + "type": "string", + "optional": true + }, + "page": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "分页页码,默认: 1", + "type": "number", + "optional": true + }, + "page_size": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "分页每页大小,默认: 30", + "type": "number", + "optional": true + }, + "order_by": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "排序方式,如 created_at, -updated_at", + "type": "string", + "optional": true + } + }, + "skill": "list-issues", + "title": "查询 Issue 列表", + "summary": "查询 Issue 列表", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 创建一个新的 Issue + * + * @param data - Request parameters + * @param data.repo - {string} 代码仓库名称, 如 my-user/my-repo + * @param data.title - {string} Issue 标题 + * @param data.body - {string} Issue 描述内容 + * @param data.assignees - {array} 指派人列表 + * @param data.labels - {array} 标签列表 + * @param data.priority - {string} 优先级 + */ + "create-issue": { + "path": "cnb", + "key": "create-issue", + "description": "创建 Issue, 参数 repo, title, body, assignees, labels, priority", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "repo": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库名称, 如 my-user/my-repo" + }, + "title": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "Issue 标题" + }, + "body": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "Issue 描述内容", + "type": "string", + "optional": true + }, + "assignees": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "指派人列表", + "type": "array", + "items": { + "type": "string" + }, + "optional": true + }, + "labels": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "标签列表", + "type": "array", + "items": { + "type": "string" + }, + "optional": true + }, + "priority": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "优先级", + "type": "string", + "optional": true + } + }, + "skill": "create-issue", + "title": "创建 Issue", + "summary": "创建一个新的 Issue", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + }, + /** + * 完成一个 Issue(将 state 改为 closed) + * + * @param data - Request parameters + * @param data.repo - {string} 代码仓库名称, 如 my-user/my-repo + * @param data.issueNumber - {unknown} Issue 编号 + * @param data.state - {string} Issue 状态,默认为 closed + */ + "complete-issue": { + "path": "cnb", + "key": "complete-issue", + "description": "完成 Issue, 参数 repo, issueNumber", + "metadata": { + "tags": [ + "opencode" + ], + "args": { + "repo": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "string", + "description": "代码仓库名称, 如 my-user/my-repo" + }, + "issueNumber": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + } + ], + "description": "Issue 编号" + }, + "state": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "Issue 状态,默认为 closed", + "type": "string", + "optional": true + } + }, + "skill": "complete-issue", + "title": "完成 CNB的任务Issue", + "summary": "完成一个 Issue(将 state 改为 closed)", + "url": "/root/v1/cnb-dev", + "source": "query-proxy-api" + } + } + } +} as const; +const queryApi = createQueryApi({ api, query }); + +export { queryApi };