feat(brain): add update, version commands and auto-check hint - #1009
Conversation
Add `genie brain update` to pull latest from GitHub, rebuild, and run migrations. Add `genie brain version` to show local vs latest version. After every brain command, a cache-only (no network, sync) check prints an update hint when a newer version is available.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 742160b6f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const brain = await import(BRAIN_PKG); | ||
| if (brain.runAllMigrations) { |
There was a problem hiding this comment.
Reload updated brain module before running migrations
After git pull and rebuild, this second import(BRAIN_PKG) reuses the module instance already loaded earlier in updateBrain, so migrations can run from the old code instead of the freshly updated package. In Bun/ESM, repeated imports of the same specifier are cached in-process, so updates that add/modify migration logic may be skipped until a new process starts.
Useful? React with 👍 / 👎.
| // Compare: strip prefix digit for comparison (dev uses 1.x, main uses 0.x) | ||
| const localCore = version.replace(/^\d+\./, ''); | ||
| const latestCore = latestVersion.replace(/^\d+\./, ''); | ||
| const updateAvailable = latestCore > localCore; |
There was a problem hiding this comment.
Compare version segments numerically for update detection
This uses lexicographic string comparison, which misorders multi-digit components (for example, 260403.10 compares as less than 260403.9), causing false "up to date" results and suppressing update hints. Parsing dotted numeric segments (or using a semver-style comparator) is needed to make updateAvailable accurate.
Useful? React with 👍 / 👎.
- checkForUpdates() now accepts optional cachePath param for testing - Tests use tmpdir() instead of writing to ~/.genie/ (EACCES in CI) - Removes module re-import hacks, tests function directly with temp path
Summary
genie brain updatecommand: pulls latest from GitHub, rebuilds, runs migrations, shows version changegenie brain versioncommand: shows local version and checks for available updatescheckForUpdates()unit tests covering cache states (missing, valid, invalid JSON, garbage data)Test plan
bun run checkpasses (typecheck + lint + dead-code + 1818 tests)checkForUpdates()returns correct results for all cache statesinit,search,health, etc.) still delegate to brain correctly