Skip to content

fix(update): use claude plugin update with reinstall fallback#136

Open
yyiilluu wants to merge 1 commit into
mainfrom
fix/update-via-claude-plugin-update
Open

fix(update): use claude plugin update with reinstall fallback#136
yyiilluu wants to merge 1 commit into
mainfrom
fix/update-via-claude-plugin-update

Conversation

@yyiilluu

@yyiilluu yyiilluu commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What

npx claude-smart update (Claude Code host) previously stopped services and ran a full reinstall. This switches it to Claude Code's own plugin-update path:

  1. claude plugin marketplace add <package root>
  2. claude plugin update claude-smart@reflexioai
  3. Falls back to the prior stop+reinstall flow only if the plugin update subcommand fails.

Mirrored across both entrypoints — Node (runUpdate) and Python (cmd_update) — and the shared post-update bootstrap is factored into bootstrapClaudeCodeRuntime (Node) / _finish_claude_code_install (Python).

Also

  • The claude CLI existence check now runs before stopping the backend/dashboard, so a missing-CLI abort no longer leaves services stopped.

Testing

  • pytest tests/test_cli_install.py — 23 passed
  • Node/Python update subsets of tests/test_install_scripts.py — passed
  • biome check bin/claude-smart.js clean; ruff check on changed Python shows only pre-existing default-ruleset noise (S101/S603)

Release note

Sits on top of Release v0.2.50 (version-only bump). Publish 0.2.50 from this HEAD so the release contains this feature.

Summary by CodeRabbit

  • New Features

    • Updated the Claude Code update process to use the plugin’s marketplace update flow.
    • Automatically prepares required services and dependencies after installation or updates.
    • Added clearer, action-specific status and error messages.
  • Bug Fixes

    • Added automatic fallback to refresh or reinstall the plugin when an update fails.
    • Improved service handling by stopping active services before updates.
  • Tests

    • Expanded coverage for successful updates and fallback recovery scenarios.

`npx claude-smart update` (Claude Code host) previously stopped services
and ran a full reinstall. Use Claude Code's own plugin update path
instead: `claude plugin marketplace add` then `claude plugin update`,
falling back to the stop+reinstall flow only if the update subcommand
fails. Mirrored across the Node (`runUpdate`) and Python (`cmd_update`)
entrypoints, and factored the shared post-update bootstrap into
`bootstrapClaudeCodeRuntime` / `_finish_claude_code_install`.

Check for the `claude` CLI before stopping the backend/dashboard so a
missing-CLI abort no longer leaves services stopped.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Claude Code updates now use marketplace/plugin update commands, stop services before updating, fall back to reinstall on failure, and share runtime bootstrap finalization across install and update paths. Tests cover the new command sequences and recovery behavior.

Changes

Claude Code update and installation

Layer / File(s) Summary
Node CLI update and bootstrap flow
bin/claude-smart.js
Updates help text and Claude Code control flow, including service stopping, marketplace registration, plugin updates, reinstall fallback, and shared bootstrap errors.
Python CLI finalization and update flow
plugin/src/claude_smart/cli.py
Adds shared installation finalization and updates Claude Code handling with service stopping, marketplace updates, fallback installation, and consistent messaging.
CLI update path tests
tests/test_cli_install.py
Verifies service stopping, marketplace/plugin commands, runtime finalization, and fallback installation arguments.
Installer script regression coverage
tests/test_install_scripts.py
Updates command traces and failure simulations for the new update/reinstall behavior, alongside formatting-only assertion changes.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: wenchanghan, yilu331

🚥 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 Accurately summarizes the main change: the update flow now uses claude plugin update and falls back to reinstall on failure.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/update-via-claude-plugin-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.

@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: 1

🤖 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 `@bin/claude-smart.js`:
- Around line 2166-2181: Move stopClaudeSmartServices in bin/claude-smart.js to
after successful marketplace registration; reorder marketplace registration
before dashboard/backend shutdown in plugin/src/claude_smart/cli.py; update
tests/test_cli_install.py to expect the new ordering and verify marketplace-add
failure leaves services running.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e446b266-ce59-4bab-9ebf-a05f6fd0e3a5

📥 Commits

Reviewing files that changed from the base of the PR and between 3a34a1f and 7b73cc8.

📒 Files selected for processing (4)
  • bin/claude-smart.js
  • plugin/src/claude_smart/cli.py
  • tests/test_cli_install.py
  • tests/test_install_scripts.py

Comment thread bin/claude-smart.js
Comment on lines 2166 to +2181
const pluginRoot = findClaudeCodePluginRoot();
if (pluginRoot) {
stopClaudeSmartServices(pluginRoot);
}
process.stdout.write("Updating claude-smart by reinstalling from this package...\n");
await runInstall(args, { retryInstallAfterUninstall: true });

const setup = configureReflexioSetup(HOST_CLAUDE_CODE);
process.stdout.write("Updating claude-smart from this package...\n");
let code = await runClaude(["plugin", "marketplace", "add", PACKAGE_ROOT], {
spinnerLabel: "Adding marketplace…",
});
if (code !== 0) {
process.stderr.write(
`error: \`claude plugin marketplace add ${PACKAGE_ROOT}\` failed (exit ${code})\n`,
);
process.exit(code);
}

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 | 🟠 Major | ⚡ Quick win

Avoid taking services offline before marketplace registration succeeds.

Both implementations exit on marketplace-add failure without restoring the services they already stopped.

  • bin/claude-smart.js#L2166-L2181: move stopClaudeSmartServices after successful marketplace registration.
  • plugin/src/claude_smart/cli.py#L1645-L1666: run marketplace registration before stopping dashboard/backend services.
  • tests/test_cli_install.py#L480-L485: update the expected ordering and cover marketplace-add failure without service shutdown.
📍 Affects 3 files
  • bin/claude-smart.js#L2166-L2181 (this comment)
  • plugin/src/claude_smart/cli.py#L1645-L1666
  • tests/test_cli_install.py#L480-L485
🤖 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 `@bin/claude-smart.js` around lines 2166 - 2181, Move stopClaudeSmartServices
in bin/claude-smart.js to after successful marketplace registration; reorder
marketplace registration before dashboard/backend shutdown in
plugin/src/claude_smart/cli.py; update tests/test_cli_install.py to expect the
new ordering and verify marketplace-add failure leaves services running.

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