SuperAPI AI 工具集

arkts-sta-playground

编程与开发

查看项目

更新于 10-16 03:11

技能介绍

用途:该技能用于执行 ArkTS-Sta 代码,通过 Playground 的 HTTP API 完成编译与运行,适合测试 ArkTS 语法、学习语言特性、验证代码逻辑或调试代码片段。

主要能力:可运行 .ets 文件或直接传入代码字符串;支持 JSON 输出便于程序化解析;返回成功状态、执行输出、错误信息及是否存在编译错误。

使用方式:先安装依赖 pip install -r scripts/requirements.txt(需要 requests>=2.31.0)。运行文件:python3 scripts/run_playground.py path/to/code.ets;直接运行代码:python3 scripts/run_playground.py --code "let x: number = 42; console.log(x);";JSON 输出:python3 scripts/run_playground.py --json --code "console.log('Hello');"。可配合 shell 循环批量测试多个文件,也可用 --timeout 60 调整超时。

工作原理:脚本向 https://arkts-play.cn.bz-openlab.ru:10443/compile 发送 POST 请求,请求体为 {"code": "..."},响应包含 output 与 error 字段。

适用场景:学习 ArkTS 语法、快速原型验证、调试编译错误、批量测试代码文件。

限制:需要能访问该 API 的网络连接;可能存在 API 速率限制;编译输出格式取决于 API 响应;SSL 证书问题需确保系统 CA 证书更新,不建议在生产环境禁用 SSL 验证。