From 9ee2e9407e3001518e0a149510c85f50a9b69630 Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Wed, 1 Jul 2026 23:36:21 +0200 Subject: [PATCH] fix(install-plugins): auth-aware ctx7 guidance + drop obsolete MCP nudge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 6 printed its ctx7 hints unconditionally — telling already-authed users to log in, and pointing at `ctx7 setup --claude` (MCP-adjacent). Anonymous mode is fully functional (docs + library work without auth); auth only buys rate limits, so setup was never required for ctx7 to work. - Detect auth via an offline oracle: credentials.json presence (XDG-aware), no subprocess / network / browser — mirrors the idempotent-claude fix. - Authenticated -> "ctx7 authenticated"; anonymous -> non-blocking guidance (works anonymously; `ctx7 login`, `--no-browser` for headless). The installer guides, never launches login/setup. - Drop `ctx7 setup --claude`: leftover reopening MCP path, aligns w/ TODO:48 CLI-only decision. Verified: bash -n, shellcheck (no new findings), + simulated both auth states (credentials.json present/absent) — correct branch each, credentials restored. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01VeBXkDr74N9whdiJyjzyVN --- install-plugins.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/install-plugins.sh b/install-plugins.sh index 466a7a8..84576ed 100644 --- a/install-plugins.sh +++ b/install-plugins.sh @@ -573,11 +573,19 @@ else err "ctx7 install failed — run manually: npm install -g ctx7" fi fi -# Suggest setup for Claude Code integration (optional — ctx7 also works standalone) +# ctx7 auth — detect + guide only (an installer must never open a browser / log you in) if command -v ctx7 &>/dev/null; then - info "Run 'ctx7 setup --claude' to configure Context7 for Claude Code" - info "Or use ctx7 standalone: ctx7 docs /vercel/next.js \"middleware\"" - info "Free higher rate limits: ctx7 login (OAuth) or --api-key from context7.com/dashboard" + # Deterministic offline oracle: ctx7's OAuth token lives here (XDG-aware). + # Present => authenticated; absent => anonymous. No subprocess, no network, no browser. + ctx7_creds="${XDG_CONFIG_HOME:-$HOME/.config}/context7/credentials.json" + if [ -f "$ctx7_creds" ]; then + ok "ctx7 authenticated (full rate limits)" + else + info "ctx7 works anonymously — docs + library already usable, no auth required." + info "For higher rate limits, authenticate: ctx7 login (opens a browser)" + info " headless: ctx7 login --no-browser (prints a URL to open yourself)" + fi + info "Standalone usage: ctx7 docs /vercel/next.js \"middleware\"" fi # ============================================================