Skip to content

fix: keep updater CLI in sync#211

Merged
VickyXAI merged 1 commit into
BlockRunAI:mainfrom
0xCheetah1:fix/updater-cli-shim
Jul 18, 2026
Merged

fix: keep updater CLI in sync#211
VickyXAI merged 1 commit into
BlockRunAI:mainfrom
0xCheetah1:fix/updater-cli-shim

Conversation

@0xCheetah1

@0xCheetah1 0xCheetah1 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the ClawRouter updater so curl -fsSL https://blockrun.ai/ClawRouter-update | bash updates the user-facing clawrouter CLI to the same package OpenClaw installed.

What changed

  • Detects the active ClawRouter package across OpenClaw install locations:
    • ~/.openclaw/npm/projects/*/node_modules/@blockrun/clawrouter
    • ~/.openclaw/extensions/clawrouter
    • ~/.openclaw/npm/node_modules/@blockrun/clawrouter
  • Updates the npm-prefix clawrouter CLI shim to execute the active OpenClaw-installed package.
  • Verifies the active package version against npm latest instead of only checking ~/.openclaw/extensions/clawrouter.
  • Fixes curl | bash path handling by reading src/top-models.json from the active package instead of $SCRIPT_DIR.
  • Prepends npm global bin to PATH so openclaw is found in non-login shell updater runs.
  • Resolves wallet address dependencies from the active package.

Why

The updater could report success while clawrouter --version stayed on an older global npm install. On testbed, OpenClaw installed 0.12.229, but the CLI still resolved to global 0.12.220.

Verification

  • bash -n scripts/update.sh
  • npm run format:check
  • npm run typecheck
  • npm run lint
  • tested the patched updater on testbed:
    • clawrouter --version returns 0.12.229
    • gateway health check passes on 127.0.0.1:8402
    • top-models.json migration no longer fails with ENOENT
    • wallet address display works

Summary by CodeRabbit

  • Bug Fixes
    • Improved package detection across supported installation locations.
    • Fixed wallet address and backup checks to use the active installed package.
    • Improved version verification and recovery when the installation is missing or outdated.
    • Ensured the command-line launcher stays synchronized with the installed package.
    • Fixed model allowlist loading for installations outside the default location.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The update script now discovers the active @blockrun/clawrouter installation, verifies or reinstalls its version, synchronizes the CLI shim, installs dependencies from that package, and resolves wallet and model assets from its directory.

Changes

ClawRouter runtime update flow

Layer / File(s) Summary
Package discovery and CLI shim
scripts/update.sh
Adds package-directory discovery across candidate locations and synchronizes a clawrouter executable with the detected package’s CLI entry point.
Runtime dependency resolution
scripts/update.sh
Resolves viem/accounts through ACTIVE_PACKAGE_DIR for both wallet address checks.
Package verification and configuration
scripts/update.sh
Compares installed and latest versions, conditionally reinstalls the package, validates the active installation, installs its dependencies, and loads top-models.json from the detected package directory.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant update.sh
  participant npm_registry
  participant ClawRouter
  participant CLI_shim
  participant viem_accounts
  update.sh->>npm_registry: fetch latest ClawRouter version
  update.sh->>ClawRouter: discover or install package
  ClawRouter-->>update.sh: return active package directory
  update.sh->>CLI_shim: synchronize clawrouter executable
  update.sh->>viem_accounts: resolve wallet accounts from active package
  viem_accounts-->>update.sh: derive wallet address
Loading

Possibly related PRs

Suggested reviewers: 1bcmax

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: synchronizing the updater CLI with the installed package.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/update.sh`:
- Line 104: Update the generated CLI invocation sites in scripts/update.sh to
pass ACTIVE_PACKAGE_DIR as runtime data rather than interpolating it into
JavaScript source. Use an environment variable or process.argv with shell-safe
quoting for the Node commands and generated shim, preserving support for package
paths containing both single and double quotes.
- Around line 68-75: Update the candidate-selection logic around versionOrder so
location priority is ranked before package version, with version and mtime used
only when candidates share the same location priority; ensure the active
priority-0 OpenClaw extension is selected over unrelated npm/projects
installations. After force_install_from_npm, verify that INSTALLED_VER equals
LATEST_VER and enforce the requested version when it does not.
- Around line 22-25: Update the PATH setup in scripts/update.sh to prepend
"$NPM_PREFIX/bin" whenever NPM_PREFIX is set, without requiring the bin
directory to already exist. Keep exporting PATH so the directory created later
by sync_cli_shim is available to subsequent commands.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ad05d1de-d06a-4228-80c4-0b7007a63ef1

📥 Commits

Reviewing files that changed from the base of the PR and between 8268cb5 and 92361c4.

📒 Files selected for processing (1)
  • scripts/update.sh

Comment thread scripts/update.sh
Comment on lines +22 to +25
if [ -n "$NPM_PREFIX" ] && [ -d "$NPM_PREFIX/bin" ]; then
PATH="$NPM_PREFIX/bin:$PATH"
export PATH
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add npm’s bin directory to PATH even when it does not exist yet.

This guard skips the path entry, but sync_cli_shim later creates that directory. Consequently, the newly created clawrouter shim remains unavailable to subsequent commands in this process.

-if [ -n "$NPM_PREFIX" ] && [ -d "$NPM_PREFIX/bin" ]; then
+if [ -n "$NPM_PREFIX" ]; then
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ -n "$NPM_PREFIX" ] && [ -d "$NPM_PREFIX/bin" ]; then
PATH="$NPM_PREFIX/bin:$PATH"
export PATH
fi
if [ -n "$NPM_PREFIX" ]; then
PATH="$NPM_PREFIX/bin:$PATH"
export PATH
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/update.sh` around lines 22 - 25, Update the PATH setup in
scripts/update.sh to prepend "$NPM_PREFIX/bin" whenever NPM_PREFIX is set,
without requiring the bin directory to already exist. Keep exporting PATH so the
directory created later by sync_cli_shim is available to subsequent commands.

Comment thread scripts/update.sh
Comment on lines +68 to +75
const versionOrder = best ? compareVersions(pkg.version, best.pkg.version) : 1;
if (
!best ||
versionOrder > 0 ||
(versionOrder === 0 &&
(candidate.priority < best.priority ||
(candidate.priority === best.priority && stat.mtimeMs > best.mtimeMs)))
) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Select the active location before comparing versions, then enforce the requested version.

A newer package under npm/projects currently overrides the priority-0 OpenClaw extension. The updater can therefore skip updating the actual active package and point the CLI, wallet, and model assets at an unrelated installation.

Rank by location priority first, use version/mtime only within that location, and verify INSTALLED_VER = LATEST_VER after force_install_from_npm.

Also applies to: 663-681

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/update.sh` around lines 68 - 75, Update the candidate-selection logic
around versionOrder so location priority is ranked before package version, with
version and mtime used only when candidates share the same location priority;
ensure the active priority-0 OpenClaw extension is selected over unrelated
npm/projects installations. After force_install_from_npm, verify that
INSTALLED_VER equals LATEST_VER and enforce the requested version when it does
not.

Comment thread scripts/update.sh
rm -f "$bin_dir/clawrouter"
cat >"$bin_dir/clawrouter" <<EOF
#!/bin/sh
exec node "$package_dir/dist/cli.js" "\$@"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Pass ACTIVE_PACKAGE_DIR as data instead of embedding it into source code.

A valid package path containing ' breaks each JavaScript snippet, while " can break the generated CLI shim. Use an environment variable or process.argv for Node and shell-safe quoting when generating the shim.

Also applies to: 199-199, 666-666, 675-675, 831-831, 1132-1132

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/update.sh` at line 104, Update the generated CLI invocation sites in
scripts/update.sh to pass ACTIVE_PACKAGE_DIR as runtime data rather than
interpolating it into JavaScript source. Use an environment variable or
process.argv with shell-safe quoting for the Node commands and generated shim,
preserving support for package paths containing both single and double quotes.

@VickyXAI
VickyXAI merged commit a2515d6 into BlockRunAI:main Jul 18, 2026
4 checks passed
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