@wangxt0223/codex-switcher 0.4.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.
- package/CHANGELOG.md +38 -0
- package/LICENSE +21 -0
- package/README.en.md +91 -0
- package/README.md +92 -0
- package/docs/macos-manual-checklist.md +34 -0
- package/docs/publish.md +41 -0
- package/docs/upgrade.md +31 -0
- package/package.json +46 -0
- package/plugins/codex-switcher/.app.json +3 -0
- package/plugins/codex-switcher/.codex-plugin/plugin.json +48 -0
- package/plugins/codex-switcher/.mcp.json +3 -0
- package/plugins/codex-switcher/README.en.md +112 -0
- package/plugins/codex-switcher/README.md +112 -0
- package/plugins/codex-switcher/assets/icon.png +0 -0
- package/plugins/codex-switcher/assets/logo.png +0 -0
- package/plugins/codex-switcher/assets/screenshot1.png +0 -0
- package/plugins/codex-switcher/hooks.json +3 -0
- package/plugins/codex-switcher/scripts/codex-sw +5 -0
- package/plugins/codex-switcher/scripts/codex-switcher +1133 -0
- package/plugins/codex-switcher/scripts/test-switcher.sh +183 -0
- package/plugins/codex-switcher/skills/README.md +3 -0
- package/scripts/install.sh +15 -0
- package/scripts/uninstall.sh +37 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.4.0 - 2026-04-12
|
|
4
|
+
|
|
5
|
+
- Changed npm package name to `@wangxt0223/codex-switcher` (CLI command remains `codex-sw`).
|
|
6
|
+
- Updated `upgrade` implementation to install the scoped package by default.
|
|
7
|
+
- Added `CODEX_SWITCHER_NPM_PACKAGE` env override for custom package source.
|
|
8
|
+
- Updated README/docs to reflect new package install/publish references.
|
|
9
|
+
|
|
10
|
+
## 0.3.2 - 2026-04-12
|
|
11
|
+
|
|
12
|
+
- Added built-in self-upgrade command: `codex-sw upgrade` (supports `--dry-run`).
|
|
13
|
+
- Updated `--help` and README/docs to include upgrade usage.
|
|
14
|
+
|
|
15
|
+
## 0.3.1 - 2026-04-12
|
|
16
|
+
|
|
17
|
+
- Added strict App profile guard: `app open/use` now requires existing and logged-in profile.
|
|
18
|
+
- Added `import-default` to migrate data from `~/.codex` into a profile.
|
|
19
|
+
- Added `--sync|--no-sync` for `login`, `use`, and `switch` with overwrite sync (excluding `auth.json`).
|
|
20
|
+
- Updated `--help` and README docs for sync and migration workflows.
|
|
21
|
+
|
|
22
|
+
## 0.3.0 - 2026-04-12
|
|
23
|
+
|
|
24
|
+
- Added `codex-sw` namespaced entrypoint (kept `codex-switcher` compatibility).
|
|
25
|
+
- Added concurrency lock to protect profile pointer mutations.
|
|
26
|
+
- Added safer App lifecycle handling with managed PID tracking.
|
|
27
|
+
- Added status exit code conventions (`0/1/2`).
|
|
28
|
+
- Added pointer recovery command: `codex-sw recover`.
|
|
29
|
+
- Added init/bootstrap command: `codex-sw init`.
|
|
30
|
+
- Added doctor auto-fix mode: `codex-sw doctor --fix`.
|
|
31
|
+
- Added log redaction scanner in `check` / `doctor`.
|
|
32
|
+
- Added install/uninstall scripts and CI workflow.
|
|
33
|
+
- Added expanded smoke tests.
|
|
34
|
+
- Added npm release helper: `npm run release:npm`.
|
|
35
|
+
- Added `publishConfig` (public + npmjs registry) and publish guide docs.
|
|
36
|
+
- Added `import-default` command to migrate existing `~/.codex` data into a profile.
|
|
37
|
+
- Changed `app open/use` to require existing and logged-in profile (no silent auto-create).
|
|
38
|
+
- Added `login --sync` and `use/switch --sync` overwrite sync (all files except `auth.json`).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 wangxt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# codex-sw
|
|
2
|
+
|
|
3
|
+
[中文](README.md) | English
|
|
4
|
+
|
|
5
|
+
`codex-sw` is a lightweight profile switcher for Codex CLI and Codex App.
|
|
6
|
+
It isolates accounts by running each profile in its own `CODEX_HOME` directory.
|
|
7
|
+
|
|
8
|
+
## Background
|
|
9
|
+
|
|
10
|
+
I originally used Codex for personal work while my company account lived in Cursor, so there was no conflict.
|
|
11
|
+
After the company migrated from Cursor to Codex, my personal and company Codex accounts started conflicting on the same machine, and switching became unreliable.
|
|
12
|
+
|
|
13
|
+
After inspecting local behavior, I found Codex's local auth model is straightforward: if account-local data is isolated per directory, account switching becomes stable. Based on that, I built `codex-sw` with Codex to manage, switch, and isolate all my Codex accounts.
|
|
14
|
+
|
|
15
|
+
## Codex Local Auth Model (Summary)
|
|
16
|
+
|
|
17
|
+
The following is based on observed local behavior and filesystem layout:
|
|
18
|
+
|
|
19
|
+
- Both `Codex CLI` and `Codex App` read the same root directory: `CODEX_HOME` (default is usually `~/.codex`).
|
|
20
|
+
- Auth state is primarily persisted in `CODEX_HOME/auth.json`.
|
|
21
|
+
- Session/history/state data is also stored under the same `CODEX_HOME` (for example `history.jsonl`, `sessions/`, `state_*.sqlite`).
|
|
22
|
+
- So when multiple accounts share one `CODEX_HOME`, auth/session data can overwrite or contaminate each other.
|
|
23
|
+
|
|
24
|
+
`codex-sw` solves this by assigning each account its own `CODEX_HOME` (`~/.codex-profiles/<profile>`) and switching that directory for CLI/App operations.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
### Option A: npm (global)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm i -g @wangxt0223/codex-switcher
|
|
32
|
+
codex-sw check
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Option B: from source checkout
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
./scripts/install.sh
|
|
39
|
+
codex-sw check
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick start
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
codex-sw add work
|
|
46
|
+
codex-sw add personal
|
|
47
|
+
|
|
48
|
+
codex-sw use work --sync
|
|
49
|
+
codex-sw login --sync
|
|
50
|
+
codex-sw exec -- login status
|
|
51
|
+
|
|
52
|
+
codex-sw switch personal --sync
|
|
53
|
+
codex-sw app use personal
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Sync options
|
|
57
|
+
|
|
58
|
+
- `login --sync`: sync `~/.codex` into the target profile (excluding `auth.json`).
|
|
59
|
+
- `use/switch --sync`: sync current CLI profile into target profile (excluding `auth.json`).
|
|
60
|
+
- `--no-sync`: keep strict isolation without data copy (default).
|
|
61
|
+
|
|
62
|
+
## Command reference
|
|
63
|
+
|
|
64
|
+
See plugin guide:
|
|
65
|
+
- Chinese: `plugins/codex-switcher/README.md`
|
|
66
|
+
- English: `plugins/codex-switcher/README.en.md`
|
|
67
|
+
|
|
68
|
+
## Development
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm run check
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Publish to npm
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm login --registry https://registry.npmjs.org/
|
|
78
|
+
npm run release:npm
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Upgrade
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
codex-sw upgrade
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Docs
|
|
88
|
+
|
|
89
|
+
- `docs/macos-manual-checklist.md`
|
|
90
|
+
- `docs/upgrade.md`
|
|
91
|
+
- `docs/publish.md`
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# codex-sw
|
|
2
|
+
|
|
3
|
+
中文 | [English](README.en.md)
|
|
4
|
+
|
|
5
|
+
`codex-sw` 是一个面向 Codex CLI 与 Codex App 的轻量账号切换工具。
|
|
6
|
+
它通过为每个 profile 使用独立的 `CODEX_HOME` 目录实现账号隔离。
|
|
7
|
+
|
|
8
|
+
## 项目背景
|
|
9
|
+
|
|
10
|
+
最早我自己一直在用 Codex,公司配的是 Cursor,所以在我的电脑上两套账号互不影响。
|
|
11
|
+
后来公司从 Cursor 切到 Codex 后,我就得在同一台电脑上同时用个人账号和公司账号,很快就遇到冲突:登录态会互相覆盖,切换也不顺手。
|
|
12
|
+
|
|
13
|
+
为了搞清楚原因,我看了下 Codex 的本地数据机制,发现思路其实很直接:只要把不同账号对应的本地目录隔离开,就能稳定切换。
|
|
14
|
+
基于这个思路,我用 Codex 写了 `codex-sw`,专门用来管理、切换和隔离我所有的 Codex 账号,现在日常在个人/公司账号之间切换方便很多。
|
|
15
|
+
|
|
16
|
+
## Codex 本地认证机制(简述)
|
|
17
|
+
|
|
18
|
+
以下是基于本地行为和目录结构观察到的机制:
|
|
19
|
+
|
|
20
|
+
- `Codex CLI` 与 `Codex App` 都会读取同一个工作目录根:`CODEX_HOME`(默认通常是 `~/.codex`)。
|
|
21
|
+
- 账号认证状态主要保存在 `CODEX_HOME/auth.json`。
|
|
22
|
+
- 会话、历史、索引和状态等数据也会写在同一 `CODEX_HOME` 下(如 `history.jsonl`、`sessions/`、`state_*.sqlite` 等)。
|
|
23
|
+
- 因此当多个账号共享同一个 `CODEX_HOME` 时,最容易出现“登录态互相覆盖/污染”的问题。
|
|
24
|
+
|
|
25
|
+
`codex-sw` 的做法就是为每个账号分配独立 `CODEX_HOME`(`~/.codex-profiles/<profile>`),并在执行命令或启动 App 时切换到对应目录,从而实现账号隔离与可控切换。
|
|
26
|
+
|
|
27
|
+
## 安装
|
|
28
|
+
|
|
29
|
+
### 方式 A:npm 全局安装
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm i -g @wangxt0223/codex-switcher
|
|
33
|
+
codex-sw check
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 方式 B:源码安装
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
./scripts/install.sh
|
|
40
|
+
codex-sw check
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 快速开始
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
codex-sw add work
|
|
47
|
+
codex-sw add personal
|
|
48
|
+
|
|
49
|
+
codex-sw use work --sync
|
|
50
|
+
codex-sw login --sync
|
|
51
|
+
codex-sw exec -- login status
|
|
52
|
+
|
|
53
|
+
codex-sw switch personal --sync
|
|
54
|
+
codex-sw app use personal
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 同步选项
|
|
58
|
+
|
|
59
|
+
- `login --sync`:将 `~/.codex` 同步到目标 profile(不包含 `auth.json`)。
|
|
60
|
+
- `use/switch --sync`:将当前 CLI profile 同步到目标 profile(不包含 `auth.json`)。
|
|
61
|
+
- `--no-sync`:不进行数据同步(默认)。
|
|
62
|
+
|
|
63
|
+
## 命令参考
|
|
64
|
+
|
|
65
|
+
详见插件文档:
|
|
66
|
+
- 中文:`plugins/codex-switcher/README.md`
|
|
67
|
+
- English: `plugins/codex-switcher/README.en.md`
|
|
68
|
+
|
|
69
|
+
## 开发
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm run check
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 发布到 npm
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm login --registry https://registry.npmjs.org/
|
|
79
|
+
npm run release:npm
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 升级
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
codex-sw upgrade
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 文档
|
|
89
|
+
|
|
90
|
+
- `docs/macos-manual-checklist.md`
|
|
91
|
+
- `docs/upgrade.md`
|
|
92
|
+
- `docs/publish.md`
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# macOS Manual Checklist
|
|
2
|
+
|
|
3
|
+
Run this checklist on a macOS machine with Codex.app installed.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
- [ ] `codex-sw check` returns `check: ok`
|
|
8
|
+
- [ ] `codex-sw add work` and `codex-sw add personal` succeed
|
|
9
|
+
|
|
10
|
+
## CLI isolation
|
|
11
|
+
|
|
12
|
+
- [ ] `codex-sw use work && codex-sw login`
|
|
13
|
+
- [ ] `codex-sw use personal && codex-sw login`
|
|
14
|
+
- [ ] `codex-sw status` shows both profiles logged in when selected as current
|
|
15
|
+
|
|
16
|
+
## App switching
|
|
17
|
+
|
|
18
|
+
- [ ] `codex-sw app use work` opens App
|
|
19
|
+
- [ ] `codex-sw app current` prints `work`
|
|
20
|
+
- [ ] `codex-sw app use personal` restarts App under `personal`
|
|
21
|
+
- [ ] `codex-sw app status` reports running when app is open
|
|
22
|
+
- [ ] `codex-sw app stop` stops managed app process
|
|
23
|
+
|
|
24
|
+
## Recovery and integrity
|
|
25
|
+
|
|
26
|
+
- [ ] Corrupt pointer file manually and run `codex-sw recover`
|
|
27
|
+
- [ ] `codex-sw doctor --fix` completes successfully
|
|
28
|
+
- [ ] `codex-sw check` passes after recovery
|
|
29
|
+
|
|
30
|
+
## Security checks
|
|
31
|
+
|
|
32
|
+
- [ ] `~/.codex-switcher` permission is `700`
|
|
33
|
+
- [ ] `~/.codex-profiles` permission is `700`
|
|
34
|
+
- [ ] no tokens are visible in `~/.codex-switcher/switcher.log`
|
package/docs/publish.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# npm Publish Guide
|
|
2
|
+
|
|
3
|
+
This project publishes to npm as:
|
|
4
|
+
|
|
5
|
+
- package: `@wangxt0223/codex-switcher`
|
|
6
|
+
- command: `codex-sw`
|
|
7
|
+
|
|
8
|
+
## One-command publish
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm login --registry https://registry.npmjs.org/
|
|
12
|
+
npm run release:npm
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`release:npm` runs:
|
|
16
|
+
|
|
17
|
+
1. `npm run check`
|
|
18
|
+
2. `npm pack --dry-run`
|
|
19
|
+
3. login check (`npm whoami --registry ...`)
|
|
20
|
+
4. `npm publish --access public --registry ...`
|
|
21
|
+
|
|
22
|
+
## Mirror registry note
|
|
23
|
+
|
|
24
|
+
If your default npm registry is a mirror (for example `https://registry.npmmirror.com`), publishing may fail unless you authenticate against that mirror.
|
|
25
|
+
|
|
26
|
+
This project forces publish target to npmjs using:
|
|
27
|
+
|
|
28
|
+
- `package.json` -> `publishConfig.registry = https://registry.npmjs.org/`
|
|
29
|
+
- `scripts/publish-npm.sh` -> `--registry https://registry.npmjs.org/`
|
|
30
|
+
|
|
31
|
+
## Optional: use a custom registry explicitly
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
NPM_REGISTRY=https://registry.npmjs.org/ npm run release:npm
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Verify publish
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm view @wangxt0223/codex-switcher version dist-tags --registry https://registry.npmjs.org/
|
|
41
|
+
```
|
package/docs/upgrade.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Upgrade Guide
|
|
2
|
+
|
|
3
|
+
## Source install users
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
git pull
|
|
7
|
+
./scripts/install.sh
|
|
8
|
+
codex-sw check
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## npm users
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
codex-sw upgrade
|
|
15
|
+
codex-sw check
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Breaking behavior notes
|
|
19
|
+
|
|
20
|
+
- `codex-sw` is the preferred command namespace.
|
|
21
|
+
- `codex-switcher` remains available for compatibility.
|
|
22
|
+
- `codex-sw app stop` now targets only managed App processes launched by `codex-sw`.
|
|
23
|
+
|
|
24
|
+
## Recovery
|
|
25
|
+
|
|
26
|
+
If pointers are corrupted or profile directories are missing:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
codex-sw recover
|
|
30
|
+
codex-sw status
|
|
31
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wangxt0223/codex-switcher",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Profile-based account switcher for Codex CLI and Codex App using isolated CODEX_HOME directories.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "wangxt",
|
|
7
|
+
"homepage": "https://github.com/wangxt/codex-switcher",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/wangxt/codex-switcher.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"codex",
|
|
14
|
+
"codex-cli",
|
|
15
|
+
"account-switch",
|
|
16
|
+
"profile",
|
|
17
|
+
"codex-home"
|
|
18
|
+
],
|
|
19
|
+
"bin": {
|
|
20
|
+
"codex-sw": "plugins/codex-switcher/scripts/codex-sw",
|
|
21
|
+
"codex-switcher": "plugins/codex-switcher/scripts/codex-switcher"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"plugins/codex-switcher/**",
|
|
25
|
+
"docs/**",
|
|
26
|
+
"scripts/install.sh",
|
|
27
|
+
"scripts/uninstall.sh",
|
|
28
|
+
"CHANGELOG.md",
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"lint": "bash -n plugins/codex-switcher/scripts/codex-switcher && bash -n plugins/codex-switcher/scripts/codex-sw",
|
|
34
|
+
"test": "plugins/codex-switcher/scripts/test-switcher.sh",
|
|
35
|
+
"check": "npm run lint && npm run test",
|
|
36
|
+
"prepublishOnly": "npm run check",
|
|
37
|
+
"release:npm": "./scripts/publish-npm.sh"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"registry": "https://registry.npmjs.org/"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codex-switcher",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Profile-based account switcher for Codex CLI and Codex App without modifying upstream source.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "wangxt",
|
|
7
|
+
"email": "noreply@example.com",
|
|
8
|
+
"url": "https://github.com/wangxt"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/wangxt/codex-switcher",
|
|
11
|
+
"repository": "https://github.com/wangxt/codex-switcher",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"codex",
|
|
15
|
+
"account-switching",
|
|
16
|
+
"profiles",
|
|
17
|
+
"codex-home"
|
|
18
|
+
],
|
|
19
|
+
"skills": "./skills/",
|
|
20
|
+
"hooks": "./hooks.json",
|
|
21
|
+
"mcpServers": "./.mcp.json",
|
|
22
|
+
"apps": "./.app.json",
|
|
23
|
+
"interface": {
|
|
24
|
+
"displayName": "Codex Switcher",
|
|
25
|
+
"shortDescription": "Manage Codex App/CLI accounts via CODEX_HOME profiles.",
|
|
26
|
+
"longDescription": "Use isolated profile directories for Codex CLI and restart Codex App into a selected profile without patching Codex source code.",
|
|
27
|
+
"developerName": "wangxt",
|
|
28
|
+
"category": "Productivity",
|
|
29
|
+
"capabilities": [
|
|
30
|
+
"Shell Automation",
|
|
31
|
+
"Account Profile Switching"
|
|
32
|
+
],
|
|
33
|
+
"websiteURL": "https://github.com/wangxt/codex-switcher",
|
|
34
|
+
"privacyPolicyURL": "https://openai.com/policies/row-privacy-policy/",
|
|
35
|
+
"termsOfServiceURL": "https://openai.com/policies/row-terms-of-use/",
|
|
36
|
+
"defaultPrompt": [
|
|
37
|
+
"Create a new Codex profile for my work account.",
|
|
38
|
+
"Switch Codex CLI to the personal profile.",
|
|
39
|
+
"Restart Codex App with the selected account profile."
|
|
40
|
+
],
|
|
41
|
+
"brandColor": "#2563EB",
|
|
42
|
+
"composerIcon": "./assets/icon.png",
|
|
43
|
+
"logo": "./assets/logo.png",
|
|
44
|
+
"screenshots": [
|
|
45
|
+
"./assets/screenshot1.png"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# codex-sw
|
|
2
|
+
|
|
3
|
+
[中文](README.md) | English
|
|
4
|
+
|
|
5
|
+
Profile-based account switcher for Codex CLI and Codex App.
|
|
6
|
+
|
|
7
|
+
## Core idea
|
|
8
|
+
|
|
9
|
+
- One profile = one isolated `CODEX_HOME` directory: `~/.codex-profiles/<profile>`
|
|
10
|
+
- CLI commands run under selected CLI profile
|
|
11
|
+
- App is restarted under selected App profile
|
|
12
|
+
- Current pointers are stored in `~/.codex-switcher/current_cli` and `~/.codex-switcher/current_app`
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
codex-sw add <profile>
|
|
18
|
+
codex-sw remove <profile> [--force]
|
|
19
|
+
codex-sw list
|
|
20
|
+
codex-sw import-default <profile> [--with-auth] [--force]
|
|
21
|
+
codex-sw use <profile> [--sync|--no-sync]
|
|
22
|
+
codex-sw switch <profile> [--sync|--no-sync]
|
|
23
|
+
codex-sw current [cli|app]
|
|
24
|
+
codex-sw status
|
|
25
|
+
|
|
26
|
+
codex-sw exec -- <codex args...>
|
|
27
|
+
codex-sw login [profile] [--sync|--no-sync]
|
|
28
|
+
codex-sw logout [profile]
|
|
29
|
+
codex-sw env [profile]
|
|
30
|
+
|
|
31
|
+
codex-sw app open [profile]
|
|
32
|
+
codex-sw app use <profile>
|
|
33
|
+
codex-sw app logout [profile]
|
|
34
|
+
codex-sw app status
|
|
35
|
+
codex-sw app stop
|
|
36
|
+
|
|
37
|
+
codex-sw init [--shell zsh|bash]
|
|
38
|
+
codex-sw upgrade [--dry-run]
|
|
39
|
+
codex-sw recover
|
|
40
|
+
codex-sw check
|
|
41
|
+
codex-sw doctor [--fix]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Typical flow
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
codex-sw add work
|
|
48
|
+
codex-sw add personal
|
|
49
|
+
|
|
50
|
+
codex-sw use work --sync
|
|
51
|
+
codex-sw login --sync
|
|
52
|
+
codex-sw exec -- login status
|
|
53
|
+
|
|
54
|
+
codex-sw switch personal --sync
|
|
55
|
+
codex-sw app use personal
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Migrate Existing App/CLI Data
|
|
59
|
+
|
|
60
|
+
If your existing data is in `~/.codex`, import it into a profile first:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
codex-sw import-default work
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This copies records/projects/history but excludes `auth.json` by default.
|
|
67
|
+
If you want to carry login state too:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
codex-sw import-default work --with-auth
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Sync Behavior
|
|
74
|
+
|
|
75
|
+
- `login --sync`: overwrite sync from default `~/.codex` to target profile, excluding `auth.json`.
|
|
76
|
+
- `use/switch --sync`: overwrite sync from current CLI profile to target profile, excluding `auth.json`.
|
|
77
|
+
- `--no-sync`: explicit no-sync mode (default behavior).
|
|
78
|
+
|
|
79
|
+
Examples:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
codex-sw login work --sync
|
|
83
|
+
codex-sw switch personal --sync
|
|
84
|
+
codex-sw use work --no-sync
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Upgrade
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
codex-sw upgrade
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Notes
|
|
94
|
+
|
|
95
|
+
- Codex App is single-instance on macOS; switching App profile requires restart.
|
|
96
|
+
- `codex-sw app stop` only stops app instances started and tracked by `codex-sw`.
|
|
97
|
+
- `codex-sw app open/use <profile>` requires that profile already exists and is logged in.
|
|
98
|
+
- `--sync` uses overwrite strategy (not merge): source overwrites target for all files except `auth.json`.
|
|
99
|
+
- `codex-sw status` exit codes:
|
|
100
|
+
- `0`: both current profiles logged in
|
|
101
|
+
- `1`: at least one current profile not logged in
|
|
102
|
+
- `2`: pointer/profile integrity issue (run `codex-sw recover`)
|
|
103
|
+
|
|
104
|
+
## Validation
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
./plugins/codex-switcher/scripts/test-switcher.sh
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Compatibility command
|
|
111
|
+
|
|
112
|
+
`codex-switcher` is kept as a compatibility entrypoint and maps to the same implementation.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# codex-sw
|
|
2
|
+
|
|
3
|
+
中文 | [English](README.en.md)
|
|
4
|
+
|
|
5
|
+
为 Codex CLI 与 Codex App 提供基于 profile 的账号切换能力。
|
|
6
|
+
|
|
7
|
+
## 核心设计
|
|
8
|
+
|
|
9
|
+
- 一个 profile 对应一个独立 `CODEX_HOME`:`~/.codex-profiles/<profile>`
|
|
10
|
+
- CLI 命令在当前 CLI profile 下执行
|
|
11
|
+
- App 在当前 App profile 下重启
|
|
12
|
+
- 当前指针存储在 `~/.codex-switcher/current_cli` 与 `~/.codex-switcher/current_app`
|
|
13
|
+
|
|
14
|
+
## 命令
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
codex-sw add <profile>
|
|
18
|
+
codex-sw remove <profile> [--force]
|
|
19
|
+
codex-sw list
|
|
20
|
+
codex-sw import-default <profile> [--with-auth] [--force]
|
|
21
|
+
codex-sw use <profile> [--sync|--no-sync]
|
|
22
|
+
codex-sw switch <profile> [--sync|--no-sync]
|
|
23
|
+
codex-sw current [cli|app]
|
|
24
|
+
codex-sw status
|
|
25
|
+
|
|
26
|
+
codex-sw exec -- <codex args...>
|
|
27
|
+
codex-sw login [profile] [--sync|--no-sync]
|
|
28
|
+
codex-sw logout [profile]
|
|
29
|
+
codex-sw env [profile]
|
|
30
|
+
|
|
31
|
+
codex-sw app open [profile]
|
|
32
|
+
codex-sw app use <profile>
|
|
33
|
+
codex-sw app logout [profile]
|
|
34
|
+
codex-sw app status
|
|
35
|
+
codex-sw app stop
|
|
36
|
+
|
|
37
|
+
codex-sw init [--shell zsh|bash]
|
|
38
|
+
codex-sw upgrade [--dry-run]
|
|
39
|
+
codex-sw recover
|
|
40
|
+
codex-sw check
|
|
41
|
+
codex-sw doctor [--fix]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 典型流程
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
codex-sw add work
|
|
48
|
+
codex-sw add personal
|
|
49
|
+
|
|
50
|
+
codex-sw use work --sync
|
|
51
|
+
codex-sw login --sync
|
|
52
|
+
codex-sw exec -- login status
|
|
53
|
+
|
|
54
|
+
codex-sw switch personal --sync
|
|
55
|
+
codex-sw app use personal
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 迁移已有数据
|
|
59
|
+
|
|
60
|
+
如果你原本在 `~/.codex` 下使用 Codex,可先导入到某个 profile:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
codex-sw import-default work
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
默认会迁移记录/项目等数据,但不包含 `auth.json`。
|
|
67
|
+
如需连登录态一起导入:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
codex-sw import-default work --with-auth
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 同步行为
|
|
74
|
+
|
|
75
|
+
- `login --sync`:从默认 `~/.codex` 覆盖同步到目标 profile,排除 `auth.json`。
|
|
76
|
+
- `use/switch --sync`:从当前 CLI profile 覆盖同步到目标 profile,排除 `auth.json`。
|
|
77
|
+
- `--no-sync`:显式关闭同步(默认行为)。
|
|
78
|
+
|
|
79
|
+
示例:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
codex-sw login work --sync
|
|
83
|
+
codex-sw switch personal --sync
|
|
84
|
+
codex-sw use work --no-sync
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 升级
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
codex-sw upgrade
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 说明
|
|
94
|
+
|
|
95
|
+
- macOS 下 Codex App 是单实例;切换 App profile 需要重启。
|
|
96
|
+
- `codex-sw app stop` 仅停止由 `codex-sw` 启动并跟踪的 App 进程。
|
|
97
|
+
- `codex-sw app open/use <profile>` 要求该 profile 已存在且已登录。
|
|
98
|
+
- `--sync` 为覆盖策略(不是合并):源目录覆盖目标目录,`auth.json` 除外。
|
|
99
|
+
- `codex-sw status` 返回码:
|
|
100
|
+
- `0`:当前 CLI/App profile 均已登录
|
|
101
|
+
- `1`:至少一个当前 profile 未登录
|
|
102
|
+
- `2`:指针或 profile 完整性异常(可执行 `codex-sw recover`)
|
|
103
|
+
|
|
104
|
+
## 验证
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
./plugins/codex-switcher/scripts/test-switcher.sh
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 兼容命令
|
|
111
|
+
|
|
112
|
+
`codex-switcher` 作为兼容入口保留,行为与 `codex-sw` 一致。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|