Skip to content

feat(brain): add update, version commands and auto-check hint - #1009

Merged
automagik-genie merged 2 commits into
devfrom
feat/brain-auto-update
Apr 3, 2026
Merged

automagik-genie merged 2 commits into
devfrom
feat/brain-auto-update

Conversation

@namastex888

Copy link
Copy Markdown
Contributor

Summary

  • Add genie brain update command: pulls latest from GitHub, rebuilds, runs migrations, shows version change
  • Add genie brain version command: shows local version and checks for available updates
  • Add cache-only auto-check hint after brain commands when an update is available (no network latency added)
  • Add checkForUpdates() unit tests covering cache states (missing, valid, invalid JSON, garbage data)

Test plan

  • bun run check passes (typecheck + lint + dead-code + 1818 tests)
  • checkForUpdates() returns correct results for all cache states
  • Auto-check reads cache synchronously with no network calls
  • Existing commands (init, search, health, etc.) still delegate to brain correctly
  • No new dependencies added - only uses node:fs, node:path, node:os, node:child_process

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.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Apr 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e5e0cc47-beeb-47ba-9e86-0d52d9ce7030

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/brain-auto-update

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +142 to +143
const brain = await import(BRAIN_PKG);
if (brain.runAllMigrations) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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
@automagik-genie
automagik-genie merged commit 0d43aec into dev Apr 3, 2026
6 checks passed
@namastex888
namastex888 deleted the feat/brain-auto-update branch April 10, 2026 16:18
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.

2 participants