SuperAPI AI 工具集

ably-new-command

编程与开发

查看项目

更新于 10-15 19:49

技能介绍

用途:为 Ably CLI(基于 oclif 的 TypeScript 项目)创建新命令,包括命令文件、测试文件以及所需的 index/topic 文件,确保符合该 CLI 的严格约定。

主要能力:先判定命令模式(Subscribe、Publish/Send、History、Get、List、Enter、REST Mutation、CRUD),据此选择基类:产品 API 命令用 AblyBaseCommand,Control API 命令用 ControlBaseCommand,Chat、Spaces、Stats 等分组使用对应的专用基类(ChatBaseCommand、SpacesBaseCommand、StatsBaseCommand)。同时指导何时需要 room.attach()/space.enter():走 this._chatApi.* 的 REST 调用无需 attach,使用 this._channel.publish()、presence 或订阅事件时才需要。

使用方式:命令按文件系统映射,ably <topic> <subtopic> <action> 对应 src/commands/<topic>/<subtopic>/<action>.ts;新 topic 需补 index.ts。按命令类型选择标志集(productApiFlags、clientIdFlag、timeRangeFlags 等),历史与列表命令使用分页工具(collectPaginatedResults、collectFilteredPaginatedResults、buildPaginationNext、formatPaginationLog)。输出使用 this.logProgress、this.logSuccessMessage、this.logListening、this.logHolding、this.logWarning 等辅助方法,JSON 模式用 logJsonResult/logJsonEvent 并嵌套在领域键下;错误统一用 this.fail(),禁止 console.log/console.error。

适用场景:新增或迁移 Ably CLI 命令、添加子命令、为命令补测试。

限制:资料未提供具体安装命令、版本要求、收费信息或完整代码示例;实际实现需参照仓库现有文件与 SDK 源码确认。