feat: enhance code graph with AI assistant and file management improvements
This commit is contained in:
221
src/modules/opencode-api.ts
Normal file
221
src/modules/opencode-api.ts
Normal file
@@ -0,0 +1,221 @@
|
||||
import { createQueryApi } from '@kevisual/query/api';
|
||||
import { query } from '@/modules/query.ts';
|
||||
const api = {
|
||||
"opencode": {
|
||||
/**
|
||||
* 创建 OpenCode 客户端,如果存在则复用
|
||||
*
|
||||
* @param data - Request parameters
|
||||
* @param data.port - {number} OpenCode 服务端口,默认为 4096
|
||||
*/
|
||||
"create": {
|
||||
"path": "opencode",
|
||||
"key": "create",
|
||||
"description": "创建 OpenCode 客户端",
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"opencode"
|
||||
],
|
||||
"args": {
|
||||
"port": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"description": "OpenCode 服务端口,默认为 4096",
|
||||
"type": "number",
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"skill": "create-opencode-client",
|
||||
"title": "创建 OpenCode 客户端",
|
||||
"summary": "创建 OpenCode 客户端,如果存在则复用",
|
||||
"url": "/root/v1/cnb-dev",
|
||||
"source": "query-proxy-api"
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 关闭 OpenCode 客户端, 未提供端口则关闭默认端口
|
||||
*
|
||||
* @param data - Request parameters
|
||||
* @param data.port - {number} OpenCode 服务端口,默认为 4096
|
||||
*/
|
||||
"close": {
|
||||
"path": "opencode",
|
||||
"key": "close",
|
||||
"description": "关闭 OpenCode 客户端",
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"opencode"
|
||||
],
|
||||
"args": {
|
||||
"port": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"description": "OpenCode 服务端口,默认为 4096",
|
||||
"type": "number",
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"skill": "close-opencode-client",
|
||||
"title": "关闭 OpenCode 客户端",
|
||||
"summary": "关闭 OpenCode 客户端, 未提供端口则关闭默认端口",
|
||||
"url": "/root/v1/cnb-dev",
|
||||
"source": "query-proxy-api"
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 重启 OpenCode 客户端
|
||||
*
|
||||
* @param data - Request parameters
|
||||
* @param data.port - {number} OpenCode 服务端口,默认为 4096
|
||||
*/
|
||||
"restart": {
|
||||
"path": "opencode",
|
||||
"key": "restart",
|
||||
"description": "重启 OpenCode 客户端",
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"opencode"
|
||||
],
|
||||
"args": {
|
||||
"port": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"description": "OpenCode 服务端口,默认为 4096",
|
||||
"type": "number",
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"skill": "restart-opencode-client",
|
||||
"title": "重启 OpenCode 客户端",
|
||||
"summary": "重启 OpenCode 客户端",
|
||||
"url": "/root/v1/cnb-dev",
|
||||
"source": "query-proxy-api"
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取当前 OpenCode 服务的 URL 地址
|
||||
*
|
||||
* @param data - Request parameters
|
||||
* @param data.port - {number} OpenCode 服务端口,默认为 4096
|
||||
*/
|
||||
"getUrl": {
|
||||
"path": "opencode",
|
||||
"key": "getUrl",
|
||||
"description": "获取 OpenCode 服务 URL",
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"opencode"
|
||||
],
|
||||
"args": {
|
||||
"port": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"description": "OpenCode 服务端口,默认为 4096",
|
||||
"type": "number",
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"skill": "get-opencode-url",
|
||||
"title": "获取 OpenCode 服务 URL",
|
||||
"summary": "获取当前 OpenCode 服务的 URL 地址",
|
||||
"url": "/root/v1/cnb-dev",
|
||||
"source": "query-proxy-api"
|
||||
}
|
||||
},
|
||||
"ls-projects": {
|
||||
"path": "opencode",
|
||||
"key": "ls-projects",
|
||||
"metadata": {
|
||||
"url": "/root/v1/cnb-dev",
|
||||
"source": "query-proxy-api"
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 运行一个已有的 OpenCode 项目
|
||||
*
|
||||
* @param data - Request parameters
|
||||
* @param data.projectPath - {string} OpenCode 项目的路径, 默认为 /workspace
|
||||
*/
|
||||
"runProject": {
|
||||
"path": "opencode",
|
||||
"key": "runProject",
|
||||
"metadata": {
|
||||
"tags": [
|
||||
"opencode"
|
||||
],
|
||||
"args": {
|
||||
"projectPath": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"description": "OpenCode 项目的路径, 默认为 /workspace",
|
||||
"type": "string",
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"skill": "run-opencode-project",
|
||||
"title": "运行 OpenCode 项目",
|
||||
"summary": "运行一个已有的 OpenCode 项目",
|
||||
"url": "/root/v1/cnb-dev",
|
||||
"source": "query-proxy-api"
|
||||
}
|
||||
}
|
||||
},
|
||||
"opencode-cnb": {
|
||||
/**
|
||||
* 创建 OpenCode 客户端
|
||||
*
|
||||
* @param data - Request parameters
|
||||
* @param data.question - {string} 问题
|
||||
* @param data.baseUrl - {string} OpenCode 服务地址,默认为 http://localhost:4096
|
||||
* @param data.directory - {string} 运行目录,默认为根目录
|
||||
* @param data.messageID - {string} 消息 ID,选填
|
||||
* @param data.sessionId - {string} 会话 ID,选填
|
||||
* @param data.parts - {array} 消息内容的分块,优先于 question 参数
|
||||
*/
|
||||
"question": {
|
||||
"path": "opencode-cnb",
|
||||
"key": "question",
|
||||
"description": "创建 OpenCode 客户端",
|
||||
"metadata": {
|
||||
"args": {
|
||||
"question": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "string",
|
||||
"description": "问题"
|
||||
},
|
||||
"baseUrl": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"description": "OpenCode 服务地址,默认为 http://localhost:4096",
|
||||
"type": "string",
|
||||
"optional": true
|
||||
},
|
||||
"directory": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"description": "运行目录,默认为根目录",
|
||||
"type": "string",
|
||||
"optional": true
|
||||
},
|
||||
"messageID": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"description": "消息 ID,选填",
|
||||
"type": "string",
|
||||
"optional": true
|
||||
},
|
||||
"sessionId": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"description": "会话 ID,选填",
|
||||
"type": "string",
|
||||
"optional": true
|
||||
},
|
||||
"parts": {
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"description": "消息内容的分块,优先于 question 参数",
|
||||
"type": "array",
|
||||
"items": {},
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"url": "/root/v1/cnb-dev",
|
||||
"source": "query-proxy-api"
|
||||
}
|
||||
}
|
||||
}
|
||||
} as const;
|
||||
const queryApi = createQueryApi({ api, query });
|
||||
|
||||
export { queryApi };
|
||||
Reference in New Issue
Block a user