feat: automatic config migration + version 0.2.0#132
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📒 Files selected for processing (1)
WalkthroughThis 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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ 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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.
feat: automatic config migration + version 0.2.0
Summary
What's included
Config Migration System
migration.tsmodule withneedsMigration(),migrateConfig(), andcheckAndMigrate()functionsconfigVersionfield to config schema (set to "2.0" for this release)ralph-tui runwhen config version is outdatedBug Fix
mergeConfigs()dropping theconfigVersionfield when merging global + project configsHow it works
checkAndMigrate()detects config without version or with older versionconfigVersionin config fileTest plan
ralph-tui setupSummary by CodeRabbit
Release Notes
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.