Skip to content

fix auto updates#16

Merged
quuu merged 3 commits into
mainfrom
fix-auto-updates
Apr 10, 2026
Merged

fix auto updates#16
quuu merged 3 commits into
mainfrom
fix-auto-updates

Conversation

@quuu

@quuu quuu commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@vercel

vercel Bot commented Apr 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
open-plugin-docs Ready Ready Preview, Comment, Open in v0 Apr 10, 2026 4:38am

Comment thread packages/add-plugin/lib/install.ts
…ilently resets settings to `{}` and then writes it back, destroying all existing user settings (permissions, model preferences, allowed/blocked tools, etc.).

This commit fixes the issue reported at packages/add-plugin/lib/install.ts:291

## Bug Analysis

**Why it happens:** In `installToPluginCache()`, when reading `~/.claude/settings.json`, if the file exists but `JSON.parse` throws (e.g., due to trailing commas, minor corruption, comments, BOM characters), the catch block silently falls through with `settings = {}`. The function then proceeds to write `{ "enabledPlugins": { ... } }` back to disk, overwriting the entire file.

**When it manifests:** Any time `settings.json` contains valid-for-Claude-but-invalid-for-strict-JSON content (trailing commas, comments, BOM, or actual corruption). JSON5-style files that Claude Code may tolerate would trigger this.

**Impact:** This is a data-loss bug. `settings.json` is a shared config file owned by Claude Code that contains many important user-managed settings beyond `enabledPlugins` — permissions, model preferences, allowed/blocked tools, etc. The "start fresh" pattern that's safe for plugin-specific files (`known_marketplaces.json`, `installed_plugins.json`) is destructive when applied to this shared config file.

**Contrast with other files:** For `known_marketplaces.json` and `installed_plugins.json`, starting fresh on parse failure is acceptable because `installToPluginCache` is the sole writer/owner of those files. But `settings.json` belongs to Claude Code and other tools may write to it.

## Fix Explanation

The fix introduces a `settingsCorrupted` flag. When `JSON.parse` fails on an existing `settings.json`, instead of proceeding with an empty object (which would overwrite all settings), the code:
1. Warns the user that `settings.json` couldn't be parsed
2. Informs them they may need to manually enable plugins
3. Skips writing to `settings.json` entirely

When the file doesn't exist (the normal first-run case), `settings` remains `{}` and `settingsCorrupted` stays `false`, so the file is correctly created with just `enabledPlugins`.

Also added `warn` to the import from `./ui.js`.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: quuu <qual1337@gmail.com>
@quuu
quuu merged commit e826839 into main Apr 10, 2026
10 of 11 checks passed
@jonathanhefner
jonathanhefner deleted the fix-auto-updates branch July 21, 2026 15:39
jonathanhefner pushed a commit that referenced this pull request Jul 21, 2026
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