@youdie006/swapdex 0.164.1 → 0.165.1
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.
- package/README.md +162 -97
- package/man/swapdex.1 +2 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -6,19 +6,15 @@
|
|
|
6
6
|
[](https://crates.io/crates/swapdex)
|
|
7
7
|
[](https://www.npmjs.com/package/@youdie006/swapdex)
|
|
8
8
|
[](LICENSE)
|
|
9
|
-
[](#network-and-credential-behavior)
|
|
10
10
|
|
|
11
11
|
</div>
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<div align="center">
|
|
20
|
-
<img src="https://raw.githubusercontent.com/youdie006/swapdex/main/docs/demo.gif" alt="swapdex demo: ls lists two saved accounts, use personal switches Claude Code and Codex together, status confirms both, restore puts the previous login back" width="760" />
|
|
21
|
-
</div>
|
|
13
|
+
Keep your Claude Code and Codex accounts in separate login directories, then
|
|
14
|
+
choose which account handles the next request in a managed conversation.
|
|
15
|
+
Sign each account in once; subsequent account selections do not require a new
|
|
16
|
+
login while its credentials remain usable. Gemini CLI and Antigravity use the
|
|
17
|
+
supported snapshot-switching workflow.
|
|
22
18
|
|
|
23
19
|
```sh
|
|
24
20
|
brew install youdie006/tap/swapdex # macOS / Linux
|
|
@@ -26,8 +22,9 @@ npm i -g @youdie006/swapdex # or, if you have node
|
|
|
26
22
|
cargo install swapdex # or, if you have rust
|
|
27
23
|
```
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
[
|
|
25
|
+
Start with the [Claude/Codex quickstart](#quick-start).
|
|
26
|
+
[Install notes](#install) · [existing logins](#existing-logins-and-folders)
|
|
27
|
+
· [network behavior](#network-and-credential-behavior).
|
|
31
28
|
|
|
32
29
|
---
|
|
33
30
|
|
|
@@ -37,13 +34,11 @@ If you run Claude Code, Codex, Gemini CLI, or Antigravity under more than one
|
|
|
37
34
|
account -- a work seat and a personal subscription, a client's org and your own
|
|
38
35
|
-- switching means logging out and back in every time.
|
|
39
36
|
|
|
40
|
-
swapdex gives each account its **own permanent space** -- its
|
|
41
|
-
`CLAUDE_CONFIG_DIR` or `CODEX_HOME` slot
|
|
42
|
-
`
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
default changes.
|
|
46
|
-
`swapdex onboard` sets this up in a few prompts.
|
|
37
|
+
swapdex gives each Claude or Codex account its **own permanent space** -- its
|
|
38
|
+
own `CLAUDE_CONFIG_DIR` or `CODEX_HOME` slot. A small launcher called a **shim**
|
|
39
|
+
makes plain `claude` or `codex` commands use the selected space and local proxy.
|
|
40
|
+
The proxy chooses an account for each managed request, so changing the serving
|
|
41
|
+
account keeps the conversation and its working directory in place.
|
|
47
42
|
|
|
48
43
|
It manages accounts you already own, with separate launch defaults, proxy
|
|
49
44
|
selection and configurable failover. See [How it works](#how-it-works) for the
|
|
@@ -59,12 +54,15 @@ that application and uses a verified, read-only access snapshot when available.
|
|
|
59
54
|
- **Account** -- one login you own (a work seat, a personal subscription). Its
|
|
60
55
|
redacted identity (email, tier) is shown by `slots`, `status`, and `doctor`;
|
|
61
56
|
never a token.
|
|
62
|
-
- **Slot** -- an account's
|
|
63
|
-
lives and refreshes in place.
|
|
64
|
-
|
|
65
|
-
- **
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
- **Slot** -- an account's permanent Claude or Codex directory, where its login
|
|
58
|
+
lives and refreshes in place. Swapdex creates it, or registers a separate
|
|
59
|
+
directory you already use. Each new slot needs its own native sign-in.
|
|
60
|
+
- **Launch default** -- the slot a plain `claude` or `codex` starts in through
|
|
61
|
+
the shim. `swapdex use <name> --tool codex` selects a Codex default.
|
|
62
|
+
- **Serving account** -- the account the proxy uses for subsequent managed
|
|
63
|
+
requests. `swapdex serve <name> --tool codex` changes it without moving the
|
|
64
|
+
conversation's home. `swapdex run` launches the named slot directly, so it
|
|
65
|
+
is useful for login and for sessions that should use their own account.
|
|
68
66
|
|
|
69
67
|
<sub>swapdex still keeps the classic snapshot commands (`add` copies a live login
|
|
70
68
|
into a profile, `use` on that profile swaps it back, guarded against the
|
|
@@ -75,7 +73,7 @@ slots.</sub>
|
|
|
75
73
|
## Install
|
|
76
74
|
|
|
77
75
|
```sh
|
|
78
|
-
# npm
|
|
76
|
+
# npm (requires Node.js and npm)
|
|
79
77
|
npm install -g @youdie006/swapdex
|
|
80
78
|
|
|
81
79
|
# Homebrew (macOS / Linux)
|
|
@@ -93,60 +91,120 @@ with two of them the shims keep calling whichever copy wrote them - so updating
|
|
|
93
91
|
the other one changes nothing, silently. `swapdex doctor` reports this, along
|
|
94
92
|
with whether the version you are running is the one that is published.
|
|
95
93
|
|
|
96
|
-
Linux, WSL, and macOS
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
Linux, WSL, and macOS are supported. Install the native CLI you want to use
|
|
95
|
+
first; Swapdex does not install it. Codex-only and Claude-only machines are both
|
|
96
|
+
supported. Claude's macOS login uses the Keychain through `/usr/bin/security`.
|
|
97
|
+
For WSL, install and run Swapdex and the native CLI inside the same WSL
|
|
98
|
+
distribution. [Full command reference](docs/COMMANDS.md).
|
|
100
99
|
|
|
101
|
-
##
|
|
100
|
+
## Quick start
|
|
101
|
+
|
|
102
|
+
Choose the tool you have. `work` and `personal` are example names; sign into
|
|
103
|
+
the intended account in each login flow. The second account is optional.
|
|
104
|
+
|
|
105
|
+
### Codex
|
|
102
106
|
|
|
103
107
|
```sh
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
swapdex run work --tool codex -- login --device-auth
|
|
109
|
+
swapdex run personal --tool codex -- login --device-auth
|
|
110
|
+
swapdex shim
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Activate the PATH change printed by `swapdex shim`: open a new terminal, source
|
|
114
|
+
the shell file it names, or apply its printed `export PATH=...` command. Then:
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
swapdex use work --tool codex
|
|
118
|
+
codex
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
While that conversation stays open, use another terminal to select the account
|
|
122
|
+
for its next request:
|
|
108
123
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
swapdex
|
|
112
|
-
|
|
124
|
+
```sh
|
|
125
|
+
swapdex serve personal --tool codex
|
|
126
|
+
swapdex serve --tool codex --quiet
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The last command shows the selected serving account. It is a routing status,
|
|
130
|
+
not an independent billing statement. A request already in progress finishes
|
|
131
|
+
with the account it started with.
|
|
132
|
+
|
|
133
|
+
### Claude Code
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
swapdex run work --tool claude -- auth login
|
|
137
|
+
swapdex run personal --tool claude -- auth login
|
|
138
|
+
swapdex shim
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Activate the printed PATH change, then start a managed conversation:
|
|
113
142
|
|
|
114
|
-
|
|
115
|
-
swapdex
|
|
116
|
-
|
|
117
|
-
|
|
143
|
+
```sh
|
|
144
|
+
swapdex use work --tool claude
|
|
145
|
+
claude
|
|
146
|
+
```
|
|
118
147
|
|
|
119
|
-
|
|
120
|
-
swapdex
|
|
121
|
-
swapdex status
|
|
148
|
+
In another terminal, `swapdex serve personal --tool claude` selects the account
|
|
149
|
+
for the next managed request. `swapdex serve --tool claude --quiet` shows it.
|
|
122
150
|
|
|
123
|
-
|
|
124
|
-
swapdex
|
|
125
|
-
|
|
151
|
+
**Existing conversations:** a native process started before the shim was
|
|
152
|
+
installed, or started directly with `swapdex run`, keeps its direct routing.
|
|
153
|
+
Resume it once through plain `codex resume` or `claude --resume` after activating
|
|
154
|
+
the shim. Subsequent serving-account changes apply without restarting that
|
|
155
|
+
managed session. Explicit custom-provider options can also bypass managed
|
|
156
|
+
routing. If proxy startup fails, the managed launcher stops with an error.
|
|
126
157
|
|
|
127
|
-
|
|
128
|
-
swapdex
|
|
158
|
+
`swapdex slash` installs an in-chat `/swap` command. `swapdex ui` offers the
|
|
159
|
+
account picker and conversation menu. Run `swapdex doctor` if the plain CLI
|
|
160
|
+
still uses a different executable or account than expected.
|
|
129
161
|
|
|
130
|
-
|
|
131
|
-
swapdex usage
|
|
162
|
+
## Existing logins and folders
|
|
132
163
|
|
|
133
|
-
|
|
134
|
-
|
|
164
|
+
Already signed in through a default native directory? The quickstart creates
|
|
165
|
+
separate slots and leaves that login in place. It requires one sign-in in each
|
|
166
|
+
new slot; it does not import the existing credential into those slots.
|
|
135
167
|
|
|
136
|
-
|
|
137
|
-
swapdex export setup.json # on the machine you already use
|
|
138
|
-
swapdex import setup.json # on the new one, then sign each account in
|
|
168
|
+
If you already keep accounts in separate directories, register them in place:
|
|
139
169
|
|
|
140
|
-
|
|
141
|
-
swapdex
|
|
170
|
+
```sh
|
|
171
|
+
swapdex adopt work ~/.codex-work --tool codex
|
|
172
|
+
swapdex adopt work ~/.claude-work --tool claude
|
|
173
|
+
swapdex onboard
|
|
142
174
|
```
|
|
143
175
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
176
|
+
Run only the `adopt` command for a directory you actually have. `onboard` can
|
|
177
|
+
discover `~/.claude-*` directories, offer migration of saved Claude/Codex
|
|
178
|
+
profiles, and install available shims. Migration creates missing slots; each
|
|
179
|
+
new slot still needs its native sign-in.
|
|
180
|
+
|
|
181
|
+
### Saved snapshots and other tools
|
|
182
|
+
|
|
183
|
+
`swapdex setup` guides saving current logins as profiles and adding more.
|
|
184
|
+
`swapdex add work --tool codex` saves the Codex login that is already present;
|
|
185
|
+
calling `add` again under another name does not sign into a different account.
|
|
186
|
+
`swapdex login personal --tool codex` runs the legacy add-another-login flow,
|
|
187
|
+
preserving the old login and restoring it if sign-in fails.
|
|
188
|
+
|
|
189
|
+
`swapdex use <name>` applies a saved snapshot when no matching slot exists,
|
|
190
|
+
with backups and running-session guards. `swapdex restore` restores the last
|
|
191
|
+
snapshot switch. Gemini and Antigravity use this workflow; the live proxy and
|
|
192
|
+
slot quickstart above support Claude and Codex. Snapshot switching does not
|
|
193
|
+
reconfigure an already running native process.
|
|
194
|
+
|
|
195
|
+
## Everyday commands
|
|
196
|
+
|
|
197
|
+
| Task | Command |
|
|
198
|
+
| --- | --- |
|
|
199
|
+
| List accounts and their state | `swapdex ls` |
|
|
200
|
+
| Show launch defaults | `swapdex status` |
|
|
201
|
+
| Show the Codex serving account | `swapdex serve --tool codex --quiet` |
|
|
202
|
+
| Find a conversation by project | `swapdex whereis <project>` |
|
|
203
|
+
| Group indexed sessions by account | `swapdex sessions` (needs sessionwiki) |
|
|
204
|
+
| Read local session activity | `swapdex usage` |
|
|
205
|
+
| Fetch Claude/Codex account quota | `swapdex quota` |
|
|
206
|
+
| Check paths, accounts and services | `swapdex doctor` |
|
|
207
|
+
| Transfer setup without credentials | `swapdex export setup.json`, then `swapdex import setup.json` on the other machine and sign in there |
|
|
150
208
|
|
|
151
209
|
`status` shows the active account per tool, matched back to a saved profile:
|
|
152
210
|
|
|
@@ -206,8 +264,8 @@ each event's timestamp (the same honest join `sessions` uses); anything before
|
|
|
206
264
|
your first switch stays untagged. Still deliberately a hint, not a
|
|
207
265
|
quota-dodging auto-rotator.
|
|
208
266
|
|
|
209
|
-
Where `usage` is
|
|
210
|
-
|
|
267
|
+
Where `usage` is local activity, `quota` fetches the provider's reported usage
|
|
268
|
+
windows for Claude and Codex accounts:
|
|
211
269
|
|
|
212
270
|
```
|
|
213
271
|
$ swapdex quota
|
|
@@ -219,14 +277,14 @@ work (active) you@work.com
|
|
|
219
277
|
7d ▓▓▓▓▓▓░░░░ 57% left resets in 3d 4h
|
|
220
278
|
|
|
221
279
|
personal you@personal.com
|
|
222
|
-
|
|
280
|
+
usage endpoint rejected this credential - check `swapdex doctor`
|
|
223
281
|
```
|
|
224
282
|
|
|
225
|
-
It reads each account's
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
283
|
+
It reads usage endpoints using each account's **own** token and does not submit
|
|
284
|
+
a model request. It uses the slot or a verified current native login for that
|
|
285
|
+
account. An unavailable credential or failed lookup reports its state rather
|
|
286
|
+
than inventing current quota. The dashboard also fetches quota for its account
|
|
287
|
+
rows; `%` opens the detailed panel.
|
|
230
288
|
|
|
231
289
|
### The dashboard
|
|
232
290
|
|
|
@@ -244,8 +302,8 @@ setup is one keystroke and a name.
|
|
|
244
302
|
Use `codex resume` normally, or `codex resume --all` to include other working
|
|
245
303
|
directories. Swapdex keeps one stable OpenAI provider across account changes.
|
|
246
304
|
The paying account is shown by `swapdex serve --tool codex --quiet`.
|
|
247
|
-
If the proxy cannot start, the launcher
|
|
248
|
-
|
|
305
|
+
If the proxy cannot start, the managed launcher exits with an error before
|
|
306
|
+
starting Codex. It does not send the request through a different native login.
|
|
249
307
|
|
|
250
308
|
After updating from a version that created `swapdex` provider IDs, run
|
|
251
309
|
`swapdex shim` to refresh the launcher. It automatically repairs those legacy
|
|
@@ -267,7 +325,7 @@ remains valid, but provider expiry, revocation or renewal by another credential
|
|
|
267
325
|
holder can make a new browser sign-in necessary. Keep-alive reduces avoidable
|
|
268
326
|
idle expiry; it cannot guarantee that a login never expires.
|
|
269
327
|
|
|
270
|
-
|
|
328
|
+
Swapdex can renew idle accounts **while its proxy is running**,
|
|
271
329
|
because that is the process holding the timer:
|
|
272
330
|
|
|
273
331
|
```sh
|
|
@@ -281,7 +339,9 @@ nobody has opened. A slot the tool is running in is never touched: its own
|
|
|
281
339
|
session holds the refresh token, and renewing from outside would retire the one
|
|
282
340
|
that session is about to use.
|
|
283
341
|
|
|
284
|
-
|
|
342
|
+
The service keeps that timer available after the launching terminal closes.
|
|
343
|
+
A foreground or automatically started proxy also sweeps while it remains
|
|
344
|
+
running. You can run a sweep by hand:
|
|
285
345
|
|
|
286
346
|
```sh
|
|
287
347
|
swapdex refresh --keep-alive # renew every account heading for expiry
|
|
@@ -292,17 +352,16 @@ swapdex refresh <name> # renew one that has already lapsed
|
|
|
292
352
|
|
|
293
353
|
## How it works
|
|
294
354
|
|
|
295
|
-
**Slots
|
|
296
|
-
`
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
`
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
in different directories; the warning below applies to those copies.
|
|
355
|
+
**Slots.** Each Claude or Codex account gets its own `CLAUDE_CONFIG_DIR` or
|
|
356
|
+
`CODEX_HOME`, under Swapdex's data directory or in a directory you adopt.
|
|
357
|
+
Claude keys its login to that directory (a file on Linux, a Keychain item on
|
|
358
|
+
macOS); Codex stores its own auth file there. Each token refreshes in its own
|
|
359
|
+
slot. `swapdex run` invokes the native CLI directly with the named slot's home.
|
|
360
|
+
`swapdex use` selects the home for plain shimmed launches. Shared configuration
|
|
361
|
+
and conversation stores are linked where supported, so selecting a different
|
|
362
|
+
serving account does not require copying conversations. Independently signed-in
|
|
363
|
+
slots avoid sharing a rotating refresh chain. Copies of one login remain
|
|
364
|
+
coupled even when stored in different directories.
|
|
306
365
|
|
|
307
366
|
**Classic snapshots (still supported).** Each CLI also keeps its login in a
|
|
308
367
|
small on-disk file:
|
|
@@ -320,8 +379,8 @@ your projects, MCP servers, and settings are untouched. That switch is refused
|
|
|
320
379
|
while a `claude` session is running on the same login slot, since the session's
|
|
321
380
|
next token refresh would otherwise revoke the saved copy. On macOS the Claude
|
|
322
381
|
token lives in the login Keychain, one item per `CLAUDE_CONFIG_DIR`. `swapdex
|
|
323
|
-
migrate [--tool claude|codex]`
|
|
324
|
-
their
|
|
382
|
+
migrate [--tool claude|codex]` creates missing slots for saved Claude and Codex
|
|
383
|
+
accounts. It does not copy their credentials; sign in to each new slot once.
|
|
325
384
|
|
|
326
385
|
## Safety
|
|
327
386
|
|
|
@@ -336,7 +395,8 @@ their own slots, retiring the shared homes.
|
|
|
336
395
|
command if the switch was a mistake. The store keeps the last 2 backups per
|
|
337
396
|
tool, and `use` warns when the outgoing login is not saved as a profile --
|
|
338
397
|
so save accounts you care about with `add`.
|
|
339
|
-
-
|
|
398
|
+
- Diagnostics do not print tokens or refresh tokens. Setup commands may show
|
|
399
|
+
the local paths that need to be configured.
|
|
340
400
|
|
|
341
401
|
**The store holds plaintext refresh tokens.** Protect `~/.local/share/swapdex`
|
|
342
402
|
like `~/.ssh`, and do not sync it across machines (it is single-machine,
|
|
@@ -388,11 +448,16 @@ external consumers need their own login instead of a copy of a managed slot.
|
|
|
388
448
|
|
|
389
449
|
### Network and credential behavior
|
|
390
450
|
|
|
391
|
-
Account selection and listing
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
451
|
+
Account selection and listing use local state. Managed launches and `serve`
|
|
452
|
+
can start a local proxy; its scheduled renewal work contacts OAuth endpoints
|
|
453
|
+
for idle logins. `quota` and the dashboard contact provider usage endpoints;
|
|
454
|
+
`quota` can first renew eligible expired Claude slot credentials through the
|
|
455
|
+
same coordinated path. Saved snapshots remain read-only, and running native
|
|
456
|
+
sessions keep renewal ownership. `doctor` checks the published version online. Login commands invoke the
|
|
457
|
+
native tool's sign-in flow. The proxy relays model requests with the selected
|
|
458
|
+
credential using `ureq`, rustls and bundled roots; CI excludes heavy async
|
|
459
|
+
runtimes and system-TLS dependencies. An ordinary account selection does not
|
|
460
|
+
submit a model request.
|
|
396
461
|
|
|
397
462
|
Explicit account selection, launch defaults and configured proxy failover are
|
|
398
463
|
separate controls. A local file lock coordinates participating Swapdex callers;
|
package/man/swapdex.1
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.ie \n(.g .ds Aq \(aq
|
|
2
2
|
.el .ds Aq '
|
|
3
|
-
.TH swapdex 1 "swapdex 0.
|
|
3
|
+
.TH swapdex 1 "swapdex 0.165.1"
|
|
4
4
|
.SH NAME
|
|
5
5
|
swapdex \- Switch Claude Code / Codex / Gemini / Antigravity login accounts, locally and safely.
|
|
6
6
|
.SH SYNOPSIS
|
|
@@ -139,4 +139,4 @@ Print the man page (roff) to stdout
|
|
|
139
139
|
swapdex\-help(1)
|
|
140
140
|
Print this message or the help of the given subcommand(s)
|
|
141
141
|
.SH VERSION
|
|
142
|
-
v0.
|
|
142
|
+
v0.165.1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youdie006/swapdex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.165.1",
|
|
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"
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"man/swapdex.1"
|
|
13
13
|
],
|
|
14
14
|
"optionalDependencies": {
|
|
15
|
-
"@youdie006/swapdex-darwin-arm64": "0.
|
|
16
|
-
"@youdie006/swapdex-darwin-x64": "0.
|
|
17
|
-
"@youdie006/swapdex-linux-x64": "0.
|
|
18
|
-
"@youdie006/swapdex-linux-arm64": "0.
|
|
15
|
+
"@youdie006/swapdex-darwin-arm64": "0.165.1",
|
|
16
|
+
"@youdie006/swapdex-darwin-x64": "0.165.1",
|
|
17
|
+
"@youdie006/swapdex-linux-x64": "0.165.1",
|
|
18
|
+
"@youdie006/swapdex-linux-arm64": "0.165.1"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"cli",
|