AGENTS.md
Project Identity
Project Name: rooibos
Description: Rooibos - part of the RatatuiRuby TUI framework ecosystem
Stability & Compatibility
-
Requirement: All breaking changes MUST be explicitly documented in the CHANGELOG.mdâs Unreleased section. Migration guides in
doc/are expected for releases with significant numbers of breaking changes.
1. Standards
STRICT REQUIREMENTS
-
Check Before Implementing: FIRST check tests for existing coverage. If it works, say so and point to the test.
-
Every file MUST begin with an SPDX-compliant header. Use
LGPL-3.0-or-laterfor code;CC-BY-SA-4.0for documentation.reuse annotatecan help you generate the header. For Ruby files, wrap SPDX comments in â / ++ to hide them from RDoc output. -
Every line of Ruby MUST be covered by tests that would stand up to mutation testing.
-
Tests must be meaningful and verify specific behavior or rendering output; simply verifying that code âdoesnât crashâ is insufficient and unacceptable.
-
Prefer snapshot tests (
assert_snapshots, plural) over manual assertions for UI output. Snapshots are self-documenting and easier to maintain. -
Pre-commit: Use
bundle exec agent_raketo ensure commit-readiness. See Tools for detailed instructions. -
Git Pager: ALWAYS set
PAGER=catfor ALLgitcommands (e.g.,PAGER=cat git diff). This is mandatory.
Rooibos-Specific Vocabulary
-
BANNED WORD: âcomponentâ â Reserved for Kit.
-
Avoid âwidgetâ for
Rooibosunits â âWidgetâ refers to Engine/Ratatui render primitives. InRooibos, call them fragments. -
Fragment: A module containing
Model,Init,Update, andViewconstants. Fragments compose: parent fragments delegate to child fragments. -
Use âmodelâ, âupdateâ, âviewâ for the MVU pattern. Use âmessageâ (not âmsgâ) and âcommandâ (not âcmdâ).
Tools
-
NEVER run
bundle exec rakedirectly. NEVER runbundle exec ruby -Ilib:test ...directly. -
ALWAYS use
bundle exec agent_rake(provided by theratatui_ruby-devtoolsgem) for running tests, linting, or checking compilation. -
Usage:
-
Runs default task (compile + test + lint):
bundle exec agent_rake -
Runs specific task:
bundle exec agent_rake test:ruby(for example)
-
-
Snapshot Testing: When tests fail due to intentional behavior changes (not bugs), update snapshots:
-
Command:
UPDATE_SNAPSHOTS=1 bundle exec agent_rake test:ruby -
This regenerates all
snapshot/*{txt,ansi}files to match current output -
When to use: After modifying rendering, changing default values, or updating UI behavior
-
When NOT to use: For actual test failures that indicate bugs in your code
-
After updating, verify the changes make sense by reviewing the diff of
.snapshotfiles -
Setup:
bin/setupmust handle Bundler dependencies. -
Git: ALWAYS set
PAGER=catwithgit. THIS IS CRITICAL! -
Rake: Our rake tasks use
git ls-files, so errors happen when you move or delete files. In this case, ask the user to stage changes for you.
Ruby Standards
-
Use
Data.definefor all value objects (Ruby 3.2+). (Preferclass Foo < Data.define()overFoo = Data.define() do). -
Define types in
.rbsfiles. Donât useuntypedjust because itâs easy; be comprehensive and accurate. Do not includeinitializein.rbsfiles; useself.newfor constructors instead. -
Every public Ruby class/method must be documented for humans in RDoc (preferred)ânot YARDâor markdown files (fallback), and must have
*.rbstypes defined. -
Every significant architectural and design decision must be documented for contributors in markdown files. Mermaid is allowed.
2. Configuration & Tooling
Development Environment
-
Scripting Preference: Simple
sedor shell one-liners are fine. When a one-off script grows to multiple lines of logic, prefer a temporary rake task orruby -e '...'over a multi-line shell script in a string. RubyâsFile.read/File.write,Dir.glob, and regex handle complex transformations more cleanly.
Documentation
-
The
doc/folder contains source markdown files that are included in RDoc output. -
Documentation should separate âUser Guideâ (for application developers) from âContributor Guideâ (for library developers).
-
DONâT write .md files for something RDoc (Ruby) can generate. DO use RDoc for documentation.
3. Committing
-
Who commits: DONâT stage (DONâT
git add) unless explicitly instructed. DONâT commit unless explicitly instructed. DO suggest a commit message when you finish, even if not instructed. -
When: Before reporting the task as complete to the user, suggest the commit message.
-
What: Consider not what you remember, but EVERYTHING in the
git diffandgit diff --cached. -
Format:
-
Format: Use Conventional Commits.
-
Body: Explanation if necessary (wrap at 72 chars).
-
Explain why this is the implementation, as opposed to other possible implementations.
-
Skip the body entirely if itâs rote, a duplication of the diff, or otherwise unhelpful.
-
DONâT list the files changed or the edits made in the body. Donât provide a bulleted list of changes. Use prose to explain the problem and the solution.
-
DONâT use markdown syntax (no backticks, no bolding, no lists, no links). The commit message must be plain text.
-
-
-
Type conventions by directory:
-
lib/,ext/,sig/: Usefeat,fix,refactor,perfas appropriate. -
bin/,tasks/, CI/CD: Usechorefor tooling internal to developing this gem. Usefeat/fixfor user-facing executables or changes that affect downstream users. -
examples/: Alwaysdocs(documentation by example). -
test/: Usetestfor new/changed tests, or match the type of the code being tested. -
doc/: Alwaysdocs.
-
4. Changelog
-
Follow Semantic Versioning
-
Follow the Keep a Changelog specification.
-
What belongs in CHANGELOG: Only changes that affect application developers or higher-level library developers who use or depend on
rooibos:-
New public APIs or widget parameters
-
Backwards-incompatible type signature changes, or behavioral additions to type signature changes
-
Observable behavior changes (rendering, styling, layout)
-
Deprecations and removals
-
Breaking changes
-
-
What does NOT belong in CHANGELOG: Internal or non-behavioral changes that donât affect downstream users:
-
Test additions or improvements
-
Documentation updates, RDoc fixes, markdown clarifications
-
Refactors of internal code
-
New or modified example code
-
Internal tooling, CI/CD, or build configuration changes
-
Code style or linting changes
-
Performance improvements that affect applications
-
-
Changelogs should be useful to downstream developers (both app and library developers), not simple restatements of diffs or commit messages.
-
The Unreleased section MUST be considered âsince the last git tagâ. Therefore, if a change was done in one commit and undone in another (both since the last tag), the second commit should remove its changelog entry.
-
Location: New entries ALWAYS go in
## [Unreleased]. Never edit past version sections (e.g.,## [0.4.0])âthose are frozen history.
5. Definition of Done (DoD)
Before considering a task complete and returning control to the user, you MUST ensure:
-
Production Ready: RBS types are complete and accurate (no
untyped), errors are handled with good DX, documentation follows guidelines, high code quality (no âpre-existing debtâ excuses). -
Default Rake Task Passes: Run
bundle exec agent_rake(no args). Confirm it passes with ZERO errors or warnings. -
You will save time if you run
bundle exec agent_rake rubocop:autocorrectfirst. -
If you think the rake is looking for deleted files, STOP EVERYTHING and tell the user.
-
Documentation Updated: If public APIs or observable behavior changed, update relevant RDoc,
doc/files, README.md. -
Changelog Updated: If public APIs, observable behavior, or gemspec dependencies have changed, update CHANGELOG.mdâs Unreleased section.
-
Commit Message Suggested: You MUST ensure the final message to the user includes a suggested commit message block. This is NOT optional.
-
You MUST also check
git log -n1to see the current standard AI footer (âGenerated withâ and âCo-Authored-Byâ) and include it in your suggested message.