2,184
Stars
263
Forks
59
Watchers
232
Open Issues
NOASSERTION
许可证
Ruby
语言
2019-03-10
创建时间
2026-11-10
最近更新
项目能做什么
为 Ruby 语言设计的类型签名与声明语言。
来源:AI 基于仓库事实生成
· 内容以仓库实际 README 为准
使用说明 查看原始 README 原仓库文档
中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# RBS
RBS is a language to describe the structure of Ruby programs.
You can write down the definition of a class or module: methods defined in the class, instance variables and their types, and inheritance/mix-in relations.
It also allows declaring constants and global variables.
The following is a small example of RBS for a chat app.
<!-- run-start:a.rbs:bundle exec rbs -I a.rbs validate -->
```rbs
module ChatApp
VERSION: String
class User
attr_reader login: String
attr_reader email: String
def initialize: (login: String, email: String) -> void
end
class Bot
attr_reader name: String
attr_reader email: String
attr_reader owner: User
def initialize: (name: String, owner: User) -> void
end
class Message
attr_reader id: String
attr_reader string: String
attr_reader from: User | Bot # `|` means union types: `#from` can be `User` or `Bot`
attr_reader reply_to: Message? # `?` means optional type: `#reply_to` can be `nil`
def initialize: (from: User | Bot, string: String) -> void
def reply: (from: User | Bot, string: String) -> Message
end
class Channel
attr_reader name: String
attr_reader messages: Array[Message]
attr_reader users: Array[User]
attr_reader bots: Array[Bot]
def initialize: (name: String) -> void
def each_member: () { (User | Bot) -> void } -> void # `{` and `}` means block.
| () -> Enumerator[User | Bot, void] # Method can be overloaded.
end
end
```
<!-- run-end -->
## The Target Version
* The standard library signatures targets the [latest release of Ruby](https://www.ruby-lang.org/en/downloads/branches/). (`4.0` as of 2026.)
* The library code targets [non-EOL versions of Ruby](https://www.ruby-lang.org/en/downloads/branches/). (`>= 3.3` as of 2026.)
## Installation
Install the `rbs` gem. `$ gem install rbs` from the command line, or add a line in your `Gemfile`.
```rb
gem "rbs"
```
## CLI
The gem ships with the `rbs` command line tool to demonstrate what it can do and help develop RBS.
```console
$ rbs version
$ rbs list
$ rbs ancestors ::Object
$ rbs methods ::Object
$ rbs method Object then
```
An end user of `rbs` will probably find `rbs prototype` the most useful. This command generates boilerplate signature declarations for ruby files. For example, say you have written the below ruby script.
```ruby
# person.rb
class Person
attr_reader :name
attr_reader :contacts
def initialize(name:)
@name = name
@contacts = []
end
def speak
"I'm #{@name} and I love Ruby!"
end
end
```
Running prototype on the above will automatically generate
```console
$ rbs prototype rb person.rb
class Person
@name: untyped
@contacts: untyped
attr_reader name: untyped
attr_reader contacts: untyped
def initialize: (name: untyped) -> void
def speak: () -> ::String
end
```
It prints signatures for all methods, classes, instance variables, and c
阅读完整原文
项目深度分析 AI 生成
AI 辅助的 Rails 项目 RBS 签名自动生成与补全 SaaS
| 产品构想 | 利用 RBS 的 prototype 基础,结合 LLM 和运行时追踪,为遗留 Ruby/Rails 代码全自动生成精准类型签名,解决原生 prototype 仅生成 untyped 的痛点。 |
| 核心功能 | 静态 AST 与运行时测试追踪结合推断类型、LLM 增强推导、直接输出符合 RBS 规范的 sig 文件、Git 变更增量分析。 |
| 目标用户 | 维护中大型 Ruby/Rails 应用且希望引入静态类型的企业研发团队。 |
| 难度/周期 | 中等 · 1-2 个月 · 成本:低(LLM API 调用成本及轻量云服务成本) |
| 收费模式 | SaaS 按项目代码行数/仓库数量订阅,或按生成请求量计费。 |
| 竞争风险 | Ruby 极其灵活的元编程特性导致推断不准;已有开源社区方案或 IDE 原生功能挤压空间。 |
| 依据 | 已验证事实(README 中指出 rbs prototype 默认生成大量 untyped,需要人工校对) |
企业级 Gem 类型签名托管与私有包 Registry
| 产品构想 | 提供类似 DefinitelyTyped/gem_rbs_collection 的企业私有版托管服务,统一管理内网私有 Gem 的 RBS 签名版本与依赖解析。 |
| 核心功能 | 私有 RBS 源同步与分发、CI 阶段类型兼容性 Breaking Change 检查、与 Bundler/RBS Loader 无缝集成。 |
| 目标用户 | 拥有大量内部共享 Gem 的中大型企业平台工程团队。 |
| 难度/周期 | 较低 · 2-4 周 · 成本:极低(主要是存储与轻量 Web 服务) |
| 收费模式 | 企业自托管许可证授权或企业 SaaS 席位订阅。 |
| 竞争风险 | 目标客群相对垂直且基数不大;开源社区正在完善公开的 gem-rbs-collection 机制。 |
| 依据 | 尚需验证的假设 |
Ruby 类型安全 CI 质量门禁与技术债看板
| 产品构想 | 基于 RBS 和相关工具链(如 Steep),提供开箱即用的 GitHub Action / CI 插件,可视化展示代码库的类型覆盖率、untyped 比例、类型健康趋势及 PR 拦截。 |
| 核心功能 | PR 增量类型覆盖率门禁、遗留代码 untyped 热力图分析、违规破坏性改动告警、类型完善任务看板。 |
| 目标用户 | Ruby 团队的技术负责人(Tech Lead)、架构师、DevOps 工程师。 |
| 难度/周期 | 较低 · 3-5 周 · 成本:极低 |
| 收费模式 | GitHub Marketplace 付费 App(免费版限制公共库,私有库按月/席位收费)。 |
| 竞争风险 | 团队若未广泛采纳 RBS 工作流则无法形成闭环;变现客单价可能偏低。 |
| 依据 | AI推测 |
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心
竞品与相似项目 GitHub Search 真实检索
相似项目数据正在完善中,暂不展示(避免误导)
项目优势与风险
| 技术成熟度 | 创建于 2019-03-10,近 30 天仍在推送,发布过 92 个 Release |
| 社区活跃 | Star 2,184 / Fork 263 / Issue 232(数据支持,可自行核实) |
| 许可证 | NOASSERTION |
| 主要风险 | 上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价 |
安装与使用
此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。