@youdie006/swapdex 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +83 -47
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -23,28 +23,42 @@ else does.)
23
23
  ## Why
24
24
 
25
25
  If you run Claude Code, Codex, Gemini CLI, or Antigravity under more than one
26
- account -- a work seat and a
27
- personal subscription, a client's org and your own -- switching means logging
28
- out and back in every time. swapdex snapshots each logged-in account once, then
29
- swaps between them in place: the running CLI picks up the new account on your
30
- next message.
26
+ account -- a work seat and a personal subscription, a client's org and your own
27
+ -- switching means logging out and back in every time.
28
+
29
+ swapdex gives each account its **own permanent space** -- its own
30
+ `CLAUDE_CONFIG_DIR` slot -- and flips between them without ever copying a token.
31
+ `swapdex use work` points your default account there and a plain `claude`
32
+ follows it; `swapdex run work` launches straight into that account (each terminal
33
+ can be a different one). Because nothing is copied, **a switch can never log an
34
+ account out** -- even if a session is still running when you switch.
35
+ `swapdex onboard` sets this up in a few prompts.
31
36
 
32
37
  It is a **switcher, not a rotator.** It manages accounts you already own for
33
- distinct purposes. It has no feature for cycling accounts to get around a rate
34
- limit -- see [What it will not do](#what-it-will-not-do).
38
+ distinct purposes, with no feature for cycling them to get around a rate limit
39
+ -- see [What it will not do](#what-it-will-not-do).
35
40
 
36
- Safety is the design center: swapdex captures the *live* login before it swaps,
37
- so a switch can never lose or clobber an account, and it only ever hands the
38
- official CLI its own credentials -- no wrapper, no proxy, no client spoofing.
41
+ Safety is the design center: in the slot model swapdex never writes a credential
42
+ at all -- each account's own login creates and refreshes its token, in its own
43
+ slot -- and it only ever hands the official CLI its own credentials: no wrapper,
44
+ no proxy, no client spoofing.
39
45
 
40
46
  ## Concepts
41
47
 
42
- - **Profile** -- a named, point-in-time snapshot of a live login (the credential
43
- files, captured with `add`). It is a copy, not a live link.
44
- - **Account** -- the redacted identity a profile resolves to (email, tier,
45
- expiry). Shown by `ls` and `status`; never a token.
46
- - **Switch** -- `use` writes a profile's snapshot back into place atomically,
47
- backing up the current login first. One account is active per tool at a time.
48
+ - **Account** -- one login you own (a work seat, a personal subscription). Its
49
+ redacted identity (email, tier) is shown by `slots`, `status`, and `doctor`;
50
+ never a token.
51
+ - **Slot** -- an account's own permanent `CLAUDE_CONFIG_DIR`, where its login
52
+ lives and refreshes in place. swapdex creates one per account (or adopts a
53
+ `~/.claude-*` dir you already use) and never copies tokens between them.
54
+ - **Default account** -- the one a plain `claude` uses, via a tiny shim on your
55
+ PATH. `swapdex use <name>` repoints it; `swapdex run <name>` ignores it and
56
+ launches a specific account directly.
57
+
58
+ <sub>swapdex still keeps the classic snapshot commands (`add` copies a live login
59
+ into a profile, `use` on that profile swaps it back, guarded against the
60
+ running-session logout) for the shared-slot workflow; `swapdex migrate` moves
61
+ those profiles onto their own slots.</sub>
48
62
 
49
63
  ## Install
50
64
 
@@ -70,24 +84,28 @@ reference: [docs/COMMANDS.md](docs/COMMANDS.md).
70
84
  ## Use
71
85
 
72
86
  ```sh
73
- # Save the account you're currently logged in as
74
- swapdex add work # snapshots Claude + Codex, whichever is logged in
75
- swapdex add personal --tool claude
76
-
77
- # See what you have and who's active
78
- swapdex ls
87
+ # First run: guided setup -- registers ~/.claude-* dirs you already use,
88
+ # moves old profiles onto slots, offers the shim. A bare `swapdex` runs this
89
+ # automatically the first time there is something to set up.
90
+ swapdex onboard
91
+
92
+ # Launch an account in its own slot (first time = sign in; concurrent-safe,
93
+ # so each terminal can be a different account)
94
+ swapdex run work
95
+ swapdex run personal
96
+
97
+ # Make a plain `claude` follow a default account
98
+ swapdex shim # installs the claude shim once (prints a PATH line)
99
+ swapdex use personal # a plain `claude` now runs as personal
100
+ swapdex use work # switch the default -- no re-login, never logs out
101
+
102
+ # See your accounts and who's active
103
+ swapdex slots
79
104
  swapdex status
80
105
 
81
- # Switch (takes effect on your next message -- no restart)
82
- swapdex ui # full-screen picker: switch, then open a
83
- # conversation right there (resume or new)
84
- swapdex use work --tool claude --open --dir ~/proj # switch + launch in one
85
- swapdex login personal --tool claude # sign in to a NEW account and save it
86
- swapdex use personal
87
- swapdex use - # toggle back to the previous profile
88
- swapdex use w # a unique prefix is enough
89
- swapdex use work --tool codex
90
- swapdex use work --dry-run # show what would change, write nothing
106
+ # Register a config dir you already run by hand; move old profiles to slots
107
+ swapdex adopt company ~/.claude-company
108
+ swapdex migrate
91
109
 
92
110
  # Sessions grouped by the account active when they ran (needs sessionwiki)
93
111
  swapdex sessions
@@ -98,13 +116,16 @@ swapdex usage
98
116
  # Remaining quota per Claude account -- the one opt-in network read
99
117
  swapdex quota
100
118
 
101
- # Made a bad switch? Put back the login that was live before it
102
- swapdex restore
103
-
104
119
  # Anything off? Every finding comes with its fix
105
120
  swapdex doctor
106
121
  ```
107
122
 
123
+ The classic snapshot commands still work for the shared-slot workflow: `swapdex
124
+ add <name>` snapshots the current login, `swapdex use <name>` swaps it back
125
+ (backed up first, and refused while a `claude` session is running on that login
126
+ so it can't be logged out), `swapdex restore` undoes the last swap, and `swapdex
127
+ ui` is the full-screen picker. `swapdex migrate` moves these onto their own slots.
128
+
108
129
  `status` shows the live account per tool, matched back to a saved profile:
109
130
 
110
131
  ```
@@ -176,7 +197,20 @@ also in `swapdex ui` under the `%` key.
176
197
 
177
198
  ## How it works
178
199
 
179
- Each CLI keeps its login in a small on-disk file:
200
+ **Slots (the model swapdex uses now).** Each account gets its own
201
+ `CLAUDE_CONFIG_DIR` -- a directory under `~/.local/share/swapdex/slots/`, or a
202
+ `~/.claude-*` dir you adopt. Claude keys its login to that dir (a file on Linux,
203
+ a Keychain item on macOS), so each account's token lives and refreshes *in its
204
+ own slot*. swapdex never copies a token between slots: `swapdex run <name>`
205
+ `exec`s `claude` with that slot's `CLAUDE_CONFIG_DIR`, and `swapdex use <name>`
206
+ writes a one-line pointer that a small `claude` shim on your PATH reads. Shared
207
+ config (`settings.json`, global `CLAUDE.md`) is symlinked into each new slot;
208
+ the token and history stay per-slot. Because no credential is ever moved, a
209
+ token refresh in one account can never revoke another -- **a switch cannot log
210
+ you out**.
211
+
212
+ **Classic snapshots (still supported).** Each CLI also keeps its login in a
213
+ small on-disk file:
180
214
 
181
215
  - Claude Code: `~/.claude/.credentials.json` plus the `oauthAccount` block inside
182
216
  `~/.claude.json`
@@ -184,17 +218,14 @@ Each CLI keeps its login in a small on-disk file:
184
218
  - Gemini CLI: `~/.gemini/oauth_creds.json` plus `~/.gemini/google_accounts.json`
185
219
  - Antigravity: `~/.gemini/antigravity-cli/antigravity-oauth-token`
186
220
 
187
- `add` copies the current login into a private store at
188
- `~/.local/share/swapdex`. `use` writes a saved snapshot back into place
189
- atomically, backing up the current login first. For Claude, only the
190
- `oauthAccount` block of `~/.claude.json` is swapped -- your projects, MCP
191
- servers, and settings in that file are never touched.
192
-
193
- On macOS the Claude token lives in the login Keychain, one item per
194
- `CLAUDE_CONFIG_DIR` profile. swapdex manages **the profile of the environment
195
- it runs in**, exactly like `claude` itself resolves it: plain `swapdex`
196
- manages the default profile; profiles you run side by side via
197
- `CLAUDE_CONFIG_DIR` aliases are never touched.
221
+ `add` copies the current login into a private store at `~/.local/share/swapdex`;
222
+ `use` on a snapshot profile writes it back atomically, backing up the current
223
+ login first, and only the `oauthAccount` block of `~/.claude.json` is swapped so
224
+ your projects, MCP servers, and settings are untouched. That switch is refused
225
+ while a `claude` session is running on the same login slot, since the session's
226
+ next token refresh would otherwise revoke the saved copy. On macOS the Claude
227
+ token lives in the login Keychain, one item per `CLAUDE_CONFIG_DIR`. `swapdex
228
+ migrate` moves these profiles onto their own slots, retiring the shared slot.
198
229
 
199
230
  ## Safety
200
231
 
@@ -295,6 +326,11 @@ spoof the official client.
295
326
  Claude's login inside the macOS Keychain via `/usr/bin/security`, resolves
296
327
  the item exactly the way `claude` itself does (one item per
297
328
  `CLAUDE_CONFIG_DIR` profile), and `doctor` diagnoses any mismatch.
329
+ - ~~Permanent per-account slots.~~ **Shipped** (0.26): each account gets its own
330
+ `CLAUDE_CONFIG_DIR`, so a switch copies no token and can never log an account
331
+ out -- even with a session running. `run`, `use` (repoint) + the `claude`
332
+ shim, `onboard`, `adopt`, `migrate`, and `sync-mcp` (shares your MCP servers
333
+ across slots, since they live in the per-account `.claude.json`).
298
334
 
299
335
  Being considered, explicitly opt-in and advisory-only:
300
336
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youdie006/swapdex",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Switch between multiple Claude Code, Codex, Gemini, and Antigravity login accounts, locally and safely.",
5
5
  "bin": {
6
6
  "swapdex": "bin/swapdex.js"