Skip to content

init: detect Ruby and runtime version pinning files#95

Draft
malmckay wants to merge 1 commit into
block:mainfrom
malmckay:mmckay/init-detect-ruby-and-runtime-pinning
Draft

init: detect Ruby and runtime version pinning files#95
malmckay wants to merge 1 commit into
block:mainfrom
malmckay:mmckay/init-detect-ruby-and-runtime-pinning

Conversation

@malmckay
Copy link
Copy Markdown

Closes #94.

What this changes

Two surgical edits to src/templates/init_rule.md — the Goose recipe template that ai-rules init uses to scan a repo and draft its first rule file.

  1. Step 2 (manifests): add Gemfile, gems.rb to the list and instruct the recipe to read the ruby "" directive.

  2. Step 3 (new): "Detect runtime version pinning" — finds .ruby-version, .nvmrc, .node-version, .python-version, .tool-versions, rust-toolchain.toml, mise.toml; cross-references with manifest declarations; and — if present — requires the generated rule file to include a "Runtime / Toolchain" section with the exact activation command.

  3. Adds "Runtime / Toolchain" to the recommended-sections list, with rationale: agents that skip this default to /usr/bin/ruby and hit syntax / gem-resolution errors against modern Ruby code.

Renumbers the existing Steps 4–7 to keep the sequence contiguous.

Why

The current template lists package.json, Cargo.toml, go.mod, pyproject.toml, Makefile, ... but never mentions Ruby. Every Ruby service that runs ai-rules init produces an example.md with no Ruby-version guidance, so agents default to system Ruby (often macOS 2.6.x) and fail on modern syntax.

The same gap exists for any repo pinning Node/Python/Rust via a side-channel pinning file when the manifest itself doesn't carry the version.

Default version managers recommended

Picked to match the most common Block/macOS dev-environment setups:

Pinning file Default Fallbacks
.ruby-version rvm rbenv, chruby, asdf, mise
.nvmrc / .node-version nvm fnm, volta, asdf, mise
.python-version pyenv asdf, mise
.tool-versions asdf or mise
rust-toolchain.toml rustup (auto)

Recipe is instructed to detect what the user actually has on $PATH via command -v and prefer that.

Test plan

  • Run ai-rules init on a Ruby repo with .ruby-version → generated file includes a "Runtime / Toolchain" section with rvm use $(cat .ruby-version).
  • Run on a Node repo with .nvmrc → section recommends nvm use.
  • Run on a repo with no pinning file → section is omitted (no false positives).
  • Run on a mixed repo (.tool-versions + Gemfile) → section prefers asdf/mise and mentions both languages.

Filing as draft for maintainer review of the template wording before promoting.

Add Gemfile/gems.rb to Step 2 manifest discovery and a new Step 3 for
runtime version pinning files (.ruby-version, .nvmrc, .python-version,
.tool-versions, rust-toolchain.toml, mise.toml).

Require generated rule files to include a "Runtime / Toolchain" section
with the exact activation command (e.g. `rvm use $(cat .ruby-version)`)
when a pinning file is present, so coding agents activate the pinned
runtime before running language-specific tooling.

Closes block#94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

init recipe doesn't detect Ruby (or other runtime version pinning)

1 participant