SuperAPI AI 工具集

defold-project-build

通用与其它

查看项目

更新于 10-15 22:37

技能介绍

用途:借助正在运行的 Defold 编辑器的 HTTP API 构建并运行 Defold 项目,适合在自动化或代理流程中触发构建、收集编译错误。

前提:Defold 编辑器必须处于运行状态且已打开该项目。

读取端口:编辑器会把 HTTP 端口写入项目根目录的 .internal/editor.port。Windows(PowerShell):$port = Get-Content .internal/editor.port;Linux/macOS:port=$(cat .internal/editor.port)。若文件不存在,说明编辑器未运行或项目未打开。

构建:向 /command/build 发送 POST 请求。Windows:Invoke-RestMethod -Uri "http://127.0.0.1:$port/command/build" -Method Post;Linux/macOS:curl -X POST "http://127.0.0.1:$port/command/build" --silent。响应为 JSON,含 success(布尔,是否成功)与 issues(数组,构建问题,成功时为空)。success 为 true 时编辑器会自动启动游戏;为 false 时,issues 每项含 severity(error 或 warning)、message、resource(项目绝对路径)、range.start.line、range.start.character、range.end.line、range.end.character(均为 0 基)。

查看控制台:构建并启动成功后,可读取运行日志。Windows:Invoke-RestMethod -Uri "http://127.0.0.1:$port/console" -Method Get;Linux/macOS:curl "http://127.0.0.1:$port/console" --silent。

工作流:读取端口 → POST /command/build → 失败则报告全部问题(文件路径、行号、消息)→ 成功则游戏自动启动,必要时查 /console 获取运行日志。

限制与排错:连接被拒绝通常表示编辑器未运行或端口文件过期,需重启编辑器后重试。其余功能细节暂未提供。