Skip to content

feat: automatic config migration + version 0.2.0#132

Merged
subsy merged 3 commits intomainfrom
feature/config-migration-v2
Jan 17, 2026
Merged

feat: automatic config migration + version 0.2.0#132
subsy merged 3 commits intomainfrom
feature/config-migration-v2

Conversation

@subsy
Copy link
Copy Markdown
Owner

@subsy subsy commented Jan 17, 2026

Summary

  • Automatic config migration for seamless upgrades when users update ralph-tui
  • Version bump to 0.2.0 for this release

What's included

Config Migration System

  • New migration.ts module with needsMigration(), migrateConfig(), and checkAndMigrate() functions
  • Added configVersion field to config schema (set to "2.0" for this release)
  • Migration runs automatically on ralph-tui run when config version is outdated
  • Installs/updates bundled AI skills during migration
  • Preserves all existing user config values

Bug Fix

  • Fixed mergeConfigs() dropping the configVersion field when merging global + project configs

How it works

  1. User updates ralph-tui to 0.2.0
  2. On first run, checkAndMigrate() detects config without version or with older version
  3. Migration installs bundled skills and updates configVersion in config file
  4. Subsequent runs skip migration (config is current)

Test plan

  • 15 new tests for migration module (all passing)
  • Full test suite passes (1204 tests)
  • Typecheck passes
  • Build succeeds
  • Manual test: fresh install with ralph-tui setup
  • Manual test: upgrade from old config (no configVersion)
  • Manual test: no migration when config is current

Summary by CodeRabbit

Release Notes

  • New Features

    • Configuration now automatically migrates on startup, with version tracking to monitor upgrades.
    • Bundled skills and prompt templates automatically install or update, whilst preserving user customisations.
  • Chores

    • Updated package version to 0.2.0.

✏️ Tip: You can customize this high-level summary in your review settings.

AI Agent added 2 commits January 17, 2026 19:29
This implements the auto-upgrade pattern for ralph-tui config changes:

- Add configVersion field to StoredConfig schema (currently "2.0")
- Create migration.ts module with needsMigration(), migrateConfig(),
  and checkAndMigrate() functions
- Integrate migration check into run command startup
- Update setup wizard to set configVersion on new configs
- Fix bug in mergeConfigs() that dropped configVersion field

Migration automatically:
- Detects configs without version or with older versions
- Installs/updates bundled AI skills
- Preserves all existing user config values
- Updates configVersion after successful migration

Tests: 15 new tests covering all migration scenarios
This release includes:
- Automatic config migration for seamless upgrades
- New prompt engine v2 with Handlebars templates
- Bundled AI skills installation during setup/upgrade
- configVersion field for future migration support
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
ralph-tui Ignored Ignored Jan 17, 2026 7:39pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 17, 2026

Warning

Rate limit exceeded

@subsy has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 13 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 46a25ea and 78770be.

📒 Files selected for processing (1)
  • src/tui/components/RightPanel.tsx

Walkthrough

This pull request introduces a configuration migration system that automatically upgrades user configurations to version 2.0 on startup. The system handles skill installation and template updates whilst preserving customisations, integrating seamlessly into the run command's initialisation flow.

Changes

Cohort / File(s) Summary
Version Update
package.json
Version bumped from 0.1.7 to 0.2.0.
Config Type Definitions
src/config/schema.ts, src/config/types.ts
Added optional configVersion: string field to StoredConfigSchema and StoredConfig interface to track configuration versions.
Config Merging
src/config/index.ts
Extended mergeConfigs to apply project config's configVersion when defined, giving it precedence over global version.
Migration System
src/setup/migration.ts
New module implementing configuration migration utilities: CURRENT_CONFIG_VERSION = "2.0", needsMigration() to detect outdated configs, migrateConfig() to execute migrations including skill installation and template updates, and checkAndMigrate() as the entry point. Handles error logging and preserves user customisations.
Migration Tests
src/setup/migration.test.ts
Comprehensive test suite (245+ lines) validating migration scenarios: version detection, skill updates, template preservation, config persistence, and error handling.
Setup Exports
src/setup/index.ts
Added re-exports of migration functions and types: checkAndMigrate, migrateConfig, needsMigration, CURRENT_CONFIG_VERSION, and MigrationResult.
Integration Points
src/commands/run.tsx, src/setup/wizard.ts
Run command now calls checkAndMigrate before initialisation to auto-upgrade configs. Wizard's saveConfig now sets configVersion to CURRENT_CONFIG_VERSION for new/updated configurations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RunCmd as Run Command
    participant Migration
    participant Config as Config System
    participant Skills
    participant Templates
    participant Disk

    User->>RunCmd: Execute run command
    RunCmd->>Migration: checkAndMigrate(cwd)
    
    Migration->>Disk: Load project config
    alt Config exists
        Migration->>Migration: needsMigration(config)?
        alt Migration required
            Migration->>Config: Read current version
            Migration->>Skills: listBundledSkills()
            Skills-->>Migration: Skills list
            
            loop For each skill
                Migration->>Skills: installSkill(skill, {force})
                Skills->>Disk: Install/update skill
                Disk-->>Skills: Success/error
                Skills-->>Migration: Result
            end
            
            Migration->>Templates: updateTemplateIfNotCustomized()
            Templates->>Disk: Check custom template
            alt Custom template exists
                Templates-->>Migration: Preserve existing
            else
                Templates->>Disk: Update template
                Disk-->>Templates: Updated
            end
            
            Migration->>Config: Write new configVersion
            Config->>Disk: Update config.toml
            Disk-->>Config: Confirmed
            
            Migration-->>RunCmd: MigrationResult{migrated, versions, skills}
        else
            Migration-->>RunCmd: MigrationResult{migrated: false}
        end
    else
        Migration-->>RunCmd: null
    end
    
    RunCmd->>RunCmd: Continue with Ralph TUI initialization
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • feat: notification sounds and config fixes #15: Overlaps in config surface modifications (mergeConfigs, StoredConfig schema/types) and integration point (src/commands/run.tsx), suggesting potential coordination needed between these changes.

Poem

🐰 Hop, hop, hooray! Configs now upgrade with flair,
Skills and templates migrate with care,
No version clash in sight, version two takes flight,
From 0.1.7 we spring into 0.2's light!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the two main changes in the PR: automatic config migration and version bump to 0.2.0, matching the core objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 17, 2026

Codecov Report

❌ Patch coverage is 86.46617% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.92%. Comparing base (6ad7029) to head (78770be).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/setup/migration.ts 91.59% 10 Missing ⚠️
src/commands/run.tsx 11.11% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #132      +/-   ##
==========================================
+ Coverage   46.08%   46.92%   +0.84%     
==========================================
  Files          59       60       +1     
  Lines       13337    13445     +108     
==========================================
+ Hits         6146     6309     +163     
+ Misses       7191     7136      -55     
Files with missing lines Coverage Δ
src/config/index.ts 67.21% <100.00%> (+0.06%) ⬆️
src/config/schema.ts 100.00% <100.00%> (ø)
src/config/types.ts 100.00% <ø> (ø)
src/setup/index.ts 100.00% <100.00%> (ø)
src/setup/wizard.ts 79.81% <100.00%> (+0.12%) ⬆️
src/commands/run.tsx 9.69% <11.11%> (-0.06%) ⬇️
src/setup/migration.ts 91.59% <91.59%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@subsy subsy merged commit 3fab4e6 into main Jan 17, 2026
8 checks passed
@subsy subsy deleted the feature/config-migration-v2 branch January 17, 2026 19:41
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@src/setup/migration.ts`:
- Around line 51-61: The version comparison in needsMigration (accepting
StoredConfig and using CURRENT_CONFIG_VERSION) uses string comparison which
mis-orders versions like "2.10" vs "2.9"; change it to a proper numeric
semver-style comparison: when version exists, split both version and
CURRENT_CONFIG_VERSION on '.' (and ignore any pre-release/build metadata or
normalize to numeric segments), compare each segment as integers left-to-right
returning true if config version is less than CURRENT_CONFIG_VERSION, treat
missing segments as 0, and ensure the function still returns true when version
is falsy (pre-2.0); you can either implement this numeric-segment compare inline
in needsMigration or call a small helper (e.g., compareSemverStrings) to perform
the integer segment comparison.
- Around line 99-155: The code currently calls loadStoredConfig(cwd) which
merges global + project config and then writes that merged object back via
saveProjectConfig — instead call the project-only loader (e.g.,
loadProjectConfig(cwd) or the existing project-only reader in your codebase) to
obtain only the project config (or an empty/default StoredConfig if none
exists), update its configVersion to CURRENT_CONFIG_VERSION, and then call
saveProjectConfig(updatedConfig, cwd); keep references to loadStoredConfig,
saveProjectConfig, getProjectConfigPath and CURRENT_CONFIG_VERSION so you
replace the former load with the project-only loader and avoid persisting merged
global settings into the project file.
- Around line 188-208: The helper updateTemplateIfNotCustomized currently always
returns false so templatesUpdated can never be true; modify
updateTemplateIfNotCustomized to perform actual updates: locate the templatePath
(join(cwd, '.ralph-tui', 'prompt.hbs')), use access/readFile to detect absence
or to compare contents against the previous default template (e.g., by reading
the file and comparing to the packaged default string or hash), and when the
template is missing or matches the old default, write or copy the new default
template into templatePath (using writeFile/copyFile) and return true; keep the
existing behavior of preserving user-customized templates (if the contents
differ from the old default) and return false in that case.

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.

1 participant