opencode-codex-account-switcher
v0.1.3
Published
TUI plugin for switching saved Codex ChatGPT logins in opencode
Readme
opencode-codex-account-switcher
TUI plugin for saving and switching multiple Codex ChatGPT logins in opencode.
Install
opencode plugin -g opencode-codex-account-switcherRestart the TUI after installation, then open the command palette and run Codex Accounts.
For local development, install with an absolute package path:
opencode plugin -g "/path/to/opencode/packages/codex-account-switcher"Usage
Use opencode's built-in login flow for the account you want to save:
opencode auth login --provider openaiThen open the TUI and run Codex Accounts: Save Current Login.
If the plugin sees a current opencode OpenAI login that is not saved yet, it
will also prompt once at TUI startup to save that login. Dismissing the prompt
keeps it from appearing again for the same account.
Repeat that login-and-save flow for each ChatGPT account. After that, use
Codex Accounts: Switch Account to switch the active openai credential.
The switcher opens immediately and refreshes each saved account with remaining
5-hour and week limits in the background.
To import an existing login from another machine, run
Codex Accounts: Import Auth JSON and paste either the full opencode
auth.json, the openai OAuth object inside it, or a
codex-accounts.json file exported by this plugin. You can also paste a path
to one of those JSON files. Imported accounts are saved as profiles; the
current opencode login is not switched until you choose Codex Accounts:
Switch Account.
Run Codex Accounts: Show Usage to view a detailed usage snapshot with reset
times and credits for all saved accounts.
To disable the startup prompt, configure the plugin as a tuple:
{
"plugin": [
[
"opencode-codex-account-switcher",
{
"promptUnsavedLogin": false
}
]
]
}Security
Saved profiles contain Codex OAuth access and refresh tokens. They are stored
locally next to opencode's auth data with file mode 0600, and are not included
in the npm package. The default data directory follows opencode's own XDG-style
path, so it is ~/.local/share/opencode unless XDG_DATA_HOME is set. If you
dismiss the startup save prompt, the plugin stores a SHA-256 fingerprint of that
login so it does not prompt repeatedly.
Publish
Run bun run build before publishing. The package export points at dist/tui.js.
