Skip to content

feat(e13-s6): add --auto/-a one-flag local credential sweep with dedup - #64

Merged
imneov merged 3 commits into
mainfrom
feat/e13-s6-auto
Jul 8, 2026
Merged

feat(e13-s6): add --auto/-a one-flag local credential sweep with dedup#64
imneov merged 3 commits into
mainfrom
feat/e13-s6-auto

Conversation

@imneov

@imneov imneov commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What

Collapses the five source flags into one. claudecm add <name> --auto (-a) sweeps every local source at once and skips credentials you already have — the "just find my key" path.

  • Sweep (best-effort, one source failing never aborts the others, zero network): clipboard → environment → ~/.claude/settings.json~/.codex/{auth.json,config.toml}.
    • Clipboard via pbpaste/wl-paste/xclip/xsel/PowerShell Get-Clipboard behind an injectable seam; absent tool → skipped with a reason, never fails.
    • Env via envextract; config files via the existing claude-code / codex adapter Import.
  • Dedup by normalized (base_url, api_key) against LoadAllProfiles() → each candidate marked NEW or already recorded as <profile> (secrets redacted).
  • Decision (refuse-don't-guess): no key → refuse naming swept sources; all already recorded → informational exit 0, nothing written; exactly one NEW → build the draft; multiple NEW → interactive pick in a TTY, refuse with a redacted list non-interactively.
  • Mutually exclusive with --from-*/--preset, and (post-review) with the identity flags --api-key/--base-url; reuses --dry-run/redaction/validation/overwrite; no auto-activation.

Review trail

Fresh-context adversarial review → REQUEST_CHANGES (2 High + 3 Medium), all remediated in 9444f9a:

  • High--auto --api-key= could write a keyless profile (identity check ran before flag override). Fixed: no-key check now applies to the final merged draft including --auto.
  • High--auto --api-key <existing> could bypass dedup. Fixed: --auto is now mutually exclusive with the identity flags (--api-key/--base-url); --model etc. still allowed.
  • Medium — default-port dedup miss (:443 vs none), JSON-mode disambiguation list missing, test harness couldn't simulate --api-key=. All fixed.

Evidence

  • Live (real ~/.claude/~/.codex copied into an isolated HOME): sweep found env + ~/.claude candidates, clipboard + malformed codex config skipped with reasons, multi-NEW non-TTY refused; after recording one, re-run reported already recorded as envp and built the sole remaining NEW as a draft.
  • Real binary: --auto --api-key= refuses (exit 1); --auto --api-key/--base-url refuse (mutual exclusion); --auto --model allowed.
  • go test ./... + go vet ./... clean; adversarial review confirmed no secret leakage, no clipboard command-injection, best-effort source isolation.

🤖 Generated with Claude Code

imneov and others added 3 commits July 8, 2026 04:52
Collapse the five source flags into one --auto/-a that sweeps clipboard +
env + ~/.claude + ~/.codex, dedups by (base_url, api_key) against existing
profiles, and offers only new credentials. Amend ADR-0003 to admit
read-only best-effort clipboard access for --auto.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@imneov
imneov merged commit c22d10f into main Jul 8, 2026
8 of 9 checks passed
@imneov
imneov deleted the feat/e13-s6-auto branch July 8, 2026 06:03
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