feat: lenient JSON repair for pasted MCP snippets
Pasted config snippets no longer have to be valid JSON. repair_json_text() auto-fixes markdown fences, surrounding prose, // /* */ # comments, trailing and missing commas, smart quotes, single quotes, unquoted keys, Python/JS literals, and unclosed braces. parse_pasted_json_verbose() reports every repair applied; the paste dialog now parses as you type and previews exactly what will be added and what was fixed. Also includes ruff lint fixes and formatting across bcc.py/bcc_core.py.
This commit is contained in:
@@ -8,10 +8,14 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
# Install runtime dependency
|
||||
pip install -r requirements.txt
|
||||
python bcc.py # run the GUI
|
||||
python test_core.py # run unit tests (23 tests, no GUI needed)
|
||||
|
||||
# Test & lint (no GUI / PySide6 needed — tests only exercise bcc_core)
|
||||
pip install -r requirements-dev.txt
|
||||
python -m pytest # unit tests in tests/
|
||||
ruff check . # lint
|
||||
ruff format . # format (CI enforces ruff format --check)
|
||||
|
||||
# Build a self-contained binary
|
||||
pip install -r requirements-dev.txt
|
||||
python scripts/build_icons.py # regenerate icons/app.icns + icons/app.ico if needed
|
||||
pyinstaller bcc.spec
|
||||
# macOS → dist/BetterClaudeConfig.app
|
||||
@@ -19,7 +23,7 @@ pyinstaller bcc.spec
|
||||
# Linux → dist/BetterClaudeConfig
|
||||
```
|
||||
|
||||
Requires Python 3.10+. Runtime dependency: `PySide6>=6.6`. Build-time: `pyinstaller>=6.0`, `pillow>=10.0`.
|
||||
Requires Python 3.10+. Runtime dependency: `PySide6>=6.6`. Tooling config (ruff, pytest, project metadata) lives in `pyproject.toml`. CI (`.github/workflows/ci.yml`) runs lint + tests on every push/PR; releases build on tag push (`release.yml`).
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -29,7 +33,7 @@ The codebase is split into two layers:
|
||||
- `Profile` / `ServerEntry` dataclasses (the data model)
|
||||
- `discover_profiles()` — scans the platform's app-support directory for `Claude*` folders (Claude Desktop) **and** always adds `~/.claude/settings.json` (Claude Code, cross-platform)
|
||||
- `load_config` / `extract_servers` / `apply_servers` / `write_config` — the read/write pipeline; writes are atomic with rotating timestamped backups in `.bcc_backups/`
|
||||
- `parse_pasted_json()` — accepts three JSON shapes (full config, inner map, or bare server object)
|
||||
- `parse_pasted_json()` / `parse_pasted_json_verbose()` — accepts three JSON shapes (full config, inner map, or bare server object). Input does not have to be valid JSON: `repair_json_text()` auto-fixes markdown fences, surrounding prose, `//` `/* */` `#` comments, trailing/missing commas, smart quotes, single quotes, unquoted keys, Python/JS literals, and unclosed braces. The verbose variant also returns human-readable notes describing every repair applied (shown live in the paste dialog)
|
||||
- `check_dependency()` / `diagnostics_text()` / `pin_command_path()` — PATH resolution logic; distinguishes "found on normal PATH" (ok) vs "found only on augmented PATH" (warn) vs "not found" (missing). Uses an `lru_cache`-memoized `augmented_path()` that extends the inherited PATH with common runtime locations (nvm, homebrew, cargo, volta, etc.)
|
||||
- `test_remote()` — synchronous HTTP reachability check, intended to run off the UI thread
|
||||
|
||||
|
||||
Reference in New Issue
Block a user