From 9ee2e9407e3001518e0a149510c85f50a9b69630 Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Wed, 1 Jul 2026 23:36:21 +0200 Subject: [PATCH 1/2] 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 # ============================================================ From 01d8b8f65c5f62b7a433a41269afc7303ea3e9fc Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Thu, 2 Jul 2026 13:09:51 +0200 Subject: [PATCH 2/2] feat(install-plugins): interactive ctx7 login + auto-setup, ignore find-docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit STEP 6 ctx7 auth, when anonymous: - interactive TTY -> prompt [y/N] then run `ctx7 login`; non-interactive (CI/headless/re-run) keeps text guidance, never opens a browser or blocks. - run `ctx7 setup --claude --cli` when the find-docs skill is absent, to (re)install CLI+Skills mode. Guarded on absence so a re-run never clobbers a customized ~/.claude/rules/context7.md. gitignore skills/find-docs/: it is a ctx7-managed skill materialized by `ctx7 setup --claude --cli` into ~/.claude/skills (symlink to repo skills/), re-created on demand by Step 6 — not vendored here. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01C8bmCXTHNccS7KRV4gWXEF --- .gitignore | 5 +++++ install-plugins.sh | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1be270c..b2af458 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,11 @@ skills/frontend-design skills/darwin-skill skills/find-skills +# Context7 docs-lookup skill — installed by `ctx7 setup --claude --cli` +# (install-plugins.sh Step 6, when absent) into ~/.claude/skills (a symlink to +# this repo's skills/). ctx7-managed and re-created on demand — not vendored here. +skills/find-docs/ + # Staging area used by lib/toggle-external.sh when disabling a tool skills-disabled/ diff --git a/install-plugins.sh b/install-plugins.sh index 84576ed..587c5d7 100644 --- a/install-plugins.sh +++ b/install-plugins.sh @@ -573,7 +573,8 @@ else err "ctx7 install failed — run manually: npm install -g ctx7" fi fi -# ctx7 auth — detect + guide only (an installer must never open a browser / log you in) +# ctx7 auth — detect, then offer login ONLY in an interactive TTY. A non-interactive +# run (CI / headless / re-run) must never open a browser or block on OAuth. if command -v ctx7 &>/dev/null; then # Deterministic offline oracle: ctx7's OAuth token lives here (XDG-aware). # Present => authenticated; absent => anonymous. No subprocess, no network, no browser. @@ -582,8 +583,35 @@ if command -v ctx7 &>/dev/null; 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)" + if [ -t 0 ] && [ -t 1 ]; then + # Interactive terminal: offer to log in now (opens a browser). + printf '%b' "${BLUE}→${NC} Authenticate ctx7 now for higher rate limits? [y/N] " + read -r ctx7_ans || ctx7_ans="" + if [[ "$ctx7_ans" =~ ^[Yy]([Ee][Ss])?$ ]]; then + if ctx7 login; then + ok "ctx7 authenticated (full rate limits)" + else + warn "ctx7 login did not finish — re-run 'ctx7 login' anytime" + fi + else + info "Skipped — authenticate later with: ctx7 login" + fi + else + # Non-interactive (CI / headless / re-run): never block — just guide. + info "For higher rate limits, authenticate: ctx7 login (opens a browser)" + info " headless: ctx7 login --no-browser (prints a URL to open yourself)" + fi + fi + # CLI + Skills mode: install the find-docs skill into ~/.claude/skills when + # absent (it is gitignored — ctx7 owns it, this regenerates it on a fresh + # clone). Guarded on absence so a re-run never clobbers a customized config + # (setup also (re)writes ~/.claude/rules/context7.md). + if [ ! -f "$HOME/.claude/skills/find-docs/SKILL.md" ]; then + if ctx7 setup --claude --cli -y /dev/null; then + ok "ctx7 CLI + Skills configured (find-docs skill installed)" + else + warn "ctx7 setup failed — run manually: ctx7 setup --claude --cli" + fi fi info "Standalone usage: ctx7 docs /vercel/next.js \"middleware\"" fi