24 Commits
Author SHA1 Message Date
mysqto ec2c415bc6 brew: bump cask + formula to v0.1.4 2026-09-17 13:28:50 +00:00
mysqtoandClaude Opus 5 8624699049 Release v0.1.4
Bump the crate version (which is what `ccswitch --version` reports) and
close out the changelog entry for the credential-store fixes.

The [Unreleased] compare link had pointed at v0.1.0 since that release,
and 0.1.1 through 0.1.3 had no link refs at all; give every release one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 21:26:04 +08:00
mysqtoandClaude Opus 5 550aef90f0 Address the credential store Claude Code actually uses
Claude Code's macOS credential store is a composite named
keychain-with-plaintext-fallback: it reads the Keychain first and falls
back to <config dir>/.credentials.json, and a failed Keychain write
migrates the credential into that file. ccswitch looked only at the
Keychain, under a hardcoded service name, and passed the token on argv.
Three consequences, all fixed here.

Headless and SSH machines. Over SSH the login Keychain cannot be
unlocked without a GUI prompt (security exits 36,
errSecInteractionNotAllowed), so Claude Code lives entirely in the
plaintext file. read() saw nothing, so save reported "no active
credential" on a signed-in machine and sync_current silently dropped
rotated tokens; write() could not land the incoming credential, leaving
~/.claude.json naming the new account while the live token still
belonged to the old one, which Claude Code reports as not logged in.
KeychainStore now mirrors the same arbitration and keeps exactly one
authoritative copy: a successful Keychain write deletes the plaintext
file, a failed one deletes the Keychain item, so a stale copy cannot
shadow the switch from the other kind of session. $CCSWITCH_CREDENTIALS
=file forces the plaintext path outright.

$CLAUDE_CONFIG_DIR. It moves .claude.json and the credential fallback,
and it renames the Keychain item: Claude Code namespaces the service
with the first eight hex characters of sha256($CLAUDE_CONFIG_DIR). With
the variable set, ccswitch was reading and writing a different account's
credential. This affected ordinary use, because ccswitch isolate
launches claude with CLAUDE_CONFIG_DIR set to the isolate directory.
claude_env.rs owns the derivation, including the related
$CLAUDE_SECURESTORAGE_CONFIG_DIR and $CLAUDE_CODE_CUSTOM_OAUTH_URL.

Token exposure. add-generic-password -w put the OAuth token in argv,
which ps shows to every user on the machine. It is now hex-encoded and
piped to security -i, with the same argv fallback Claude Code uses past
the stdin limit. The Keychain port collapses to one run(args, stdin) so
that choice is a tested decision in creds.rs rather than shim detail.

Also fixed: account_attr parsed stderr, but find-generic-password -g
prints attributes on stdout and the password on stderr, so it always
returned None and every profile stored an empty keychain_account. Writes
fell through to $USER, which is what Claude Code looks items up by, so
this was invisible. Account attributes are now sanitized the same way
Claude Code sanitizes them.

sha256.rs is hand-rolled against the FIPS vectors rather than pulling
sha2 and six transitive crates for one eight-character string, per the
dependency policy in AGENTS.md. Claude Code NFC-normalizes the directory
before hashing and we hash the bytes as given; that agrees for every
ASCII path, and the limitation is documented with its workaround.

Behavior change: profile and isolate storage now default to accounts/
and profiles/ inside the resolved config directory rather than always
~/.claude. Identical with $CLAUDE_CONFIG_DIR unset; with it set, each
config directory gets its own profiles. Set $CCSWITCH_HOME to a fixed
path to share one set across all of them.

legacy-fish is synced with the same three fixes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 22:45:40 +08:00
mysqtoandClaude Opus 4.8 9695b6d7a6 legacy-fish: remove daemon-stop (sync with plugin)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 11:17:05 +08:00
mysqto 10eb761141 brew: bump cask + formula to v0.1.3 2026-07-22 03:14:14 +00:00
mysqtoandClaude Opus 4.8 a5a94bb962 Default to PerAccountOrg token scope; drop the daemon-stop
A Claude Code OAuth token is bound server-side to the org it was minted
under (opaque token; the server re-derives the org at session start and
rewrites ~/.claude.json). The PerAccount scope wrongly treated the token
as shared across a login's orgs, so sync_current propagated one org's
token into the sibling profile and every "switch" only relabelled the
config while real sessions ran under the token's minting org. Default to
PerAccountOrg so each (account, org) keeps its own token and sync_current
re-snapshots only the outgoing profile.

Also remove the v0.1.1/v0.1.2 daemon-stop: it addressed a misdiagnosis
(no persistent daemon holds auth), and the worker-kill needlessly ended
background sessions.

Profiles saved before this release share one token and must be
re-provisioned (claude /login into the org, then save --force).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 11:12:18 +08:00
mysqtoandClaude Opus 4.8 e8ce4904aa brew: bump cask + formula to v0.1.2
Manual bump: the release workflow's auto-bump step lost the push race
against a later main commit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 23:33:04 +08:00
mysqtoandClaude Opus 4.8 e58e4c768a legacy-fish: stop daemon workers on switch (sync with plugin)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 23:30:54 +08:00
mysqtoandClaude Opus 4.8 cbc50ec2f6 Stop daemon session workers on switch, not just the supervisor
v0.1.1 stopped only the daemon supervisor (--keep-workers). But a kept
worker holds in memory the account it was started under, so
`claude --resume` reattached to the old worker and the switch appeared
to have no effect — the resumed session kept the previous org. Drop
--keep-workers so `claude daemon stop --any` also stops the workers, and
every subsequent session (resumed or fresh) picks up the switched
account. Trade-off: switching ends detached background sessions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 23:30:23 +08:00
mysqtoandClaude Opus 4.8 7a29dc8e07 legacy-fish: backport the daemon-stop-on-switch fix
Keep the vendored legacy-fish mirror in sync with lei-wego/ccswitch-fish:
stop the Claude Code daemon supervisor on switch so restored credentials
take effect. Best-effort, background sessions kept.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 18:46:43 +08:00
mysqto 8c929cbc70 brew: bump cask + formula to v0.1.1 2026-07-08 10:41:41 +00:00
mysqtoandClaude Opus 4.8 a790decf39 Stop the Claude Code daemon on switch so auth takes effect
Recent Claude Code releases keep a background daemon that caches each
account's auth in memory, so a profile switch didn't take effect until
the daemon exited. Every switch now stops the daemon supervisor first
via `claude daemon stop --any --keep-workers`, letting the next session
re-read the restored credentials while detached background sessions keep
running. Best-effort: an older Claude Code, a missing binary, or no
running daemon never blocks the switch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 18:40:13 +08:00
mysqto c4f8202c08 docs: document the required 'brew trust <tap>' step for install 2026-07-08 17:35:17 +08:00
mysqto 2b9cf4f603 brew: bump cask + formula to v0.1.0 2026-07-08 09:19:55 +00:00
mysqtoandClaude Opus 4.8 d01079e91d Rewrite ccswitch as a cross-shell Rust CLI
Replaces the fish-only plugin with one portable binary — completions for
bash/zsh/fish/PowerShell via `ccswitch completions <shell>`. Same UX
(save/add/use/list/current/rm/isolate/seed/search + bare-name switch-and-launch).

- Fixes the auth-loss bug: the OAuth token is per-account (org lives only in
  ~/.claude.json), so switching between same-login/different-org profiles left
  the sibling holding a rotated, dead refresh token. A switch now propagates the
  refreshed credential to every profile sharing the account.
- Adds `save --force` / `add --force` to overwrite a profile without rm first.
- macOS Keychain via `security` (shim); file-based creds on Linux/Windows.
- Ports-and-adapters; 100% line / 98.86% region coverage; clippy + fmt clean.
- Homebrew formula (auto-installs completions) + cask + release workflow.
- Old fish plugin preserved under legacy-fish/ (also at lei-wego/ccswitch-fish).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 17:17:01 +08:00
mysqtoandClaude Opus 4.8 41363ccc71 search: fuzzy-pick and resume a past session via csx
Adds 'ccswitch search' (alias 's') — an optional bridge to mysqto/csx.
Defaults the scope to the active tool, fuzzy-picks a session in fzf
(previewing the transcript via 'csx show'), and resumes it with the
originating tool's command (claude --resume / codex resume). Degrades
gracefully with a hint when csx/fzf aren't installed; every other
ccswitch command is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 09:37:28 +08:00
mysqtoandClaude Opus 4.8 d7175585c3 docs: promote 'Same login, multiple orgs' to a top-level section
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 21:46:38 +08:00
mysqtoandClaude Opus 4.8 d7ac8d8dc2 docs: full walkthrough from install to daily switching
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 21:45:06 +08:00
mysqtoandClaude Opus 4.8 d71ac42bb6 isolate: block with a confirm when shared memory is unseeded
Warn and prompt y/N before launching an isolated session while shared/
has no memory/history, so you don't start fresh by accident. The prompt
disappears once shared/ has content (from seed or a prior session).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 21:39:35 +08:00
mysqtoandClaude Opus 4.8 3d98e3aeab seed: explicit command to sync shared isolate memory from ~/.claude
Adds 'ccswitch seed [dir]' to copy CLAUDE.md, history.jsonl and projects/
(transcripts + memory) into the shared isolate dir on demand. Keeps
isolate itself starting fresh; seeding stays opt-in.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 21:34:05 +08:00
mysqtoandClaude Opus 4.8 0916618b7b isolate: concurrent sessions with shared memory via CLAUDE_CONFIG_DIR
Adds 'ccswitch isolate <name>': runs a session under a per-profile
CLAUDE_CONFIG_DIR (own credential + identity) while symlinking projects/,
history.jsonl and CLAUDE.md to a shared dir, so memory and history are
shared across profiles. Centralized under ~/.claude/profiles (override
with CCSWITCH_ISOLATE_HOME). Existing non-symlink files are never clobbered.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 21:30:11 +08:00
mysqtoandClaude Opus 4.8 6fcf87fb7c use: refresh outgoing profile before switching (token rotation)
OAuth refresh tokens rotate on every use, so a saved snapshot goes stale
as its account keeps running. Re-capture the live account into its
matching profile on every switch to keep snapshots valid.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-04 22:55:19 +08:00
mysqtoandClaude Opus 4.8 defea8d217 add: sign in to a new account and save it in one step
Onboards a new account via 'claude auth login', then snapshots it as a
profile. Deliberately does not call 'claude auth logout' — logout may
revoke the token server-side and invalidate an already-saved profile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-04 22:44:03 +08:00
mysqtoandClaude Opus 4.8 c6d5ef1fa6 ccswitch: multi-account switcher for Claude Code
Cross-platform fish plugin to save, list, and switch between multiple
Claude Code accounts (including the same login across different orgs),
then launch a session with the chosen profile.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-04 22:11:27 +08:00