@wangxt0223/codex-switcher 0.5.1 → 0.6.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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0 - 2026-04-12
4
+
5
+ - Refactored core model from profile-based switching to `env + account` with built-in `default=~/.codex`.
6
+ - Added env/account command groups: `env {list|create|use|remove|current|path}` and `account {list|add|remove|login|use|logout|current}`.
7
+ - Added per-env account auth slots at `~/.codex-switcher/env-accounts/<env>/<account>/auth.json`.
8
+ - Same-env account switch now swaps `auth.json` only and ignores `--sync`.
9
+ - `list` now shows usage columns with API-first fetch and local sessions fallback, and appends source marker `(api|local)`.
10
+ - Updated Chinese/English README and plugin docs to match the new env/account flow.
11
+ - Updated upgrade and manual checklist docs to remove legacy profile terminology.
12
+
3
13
  ## 0.5.1 - 2026-04-12
4
14
 
5
15
  - Added `version: <semver>` output in `codex-sw check` for quick runtime version verification.
package/README.en.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  [中文](README.md) | English
4
4
 
5
- `codex-switcher` 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.
5
+ `codex-switcher` is a lightweight switcher for Codex CLI and Codex App.
6
+ It now uses an `env + account` model: env for shared data, account for isolated `auth.json`.
7
7
 
8
8
  ## Background
9
9
 
@@ -21,7 +21,8 @@ The following is based on observed local behavior and filesystem layout:
21
21
  - Session/history/state data is also stored under the same `CODEX_HOME` (for example `history.jsonl`, `sessions/`, `state_*.sqlite`).
22
22
  - So when multiple accounts share one `CODEX_HOME`, auth/session data can overwrite or contaminate each other.
23
23
 
24
- `codex-switcher` solves this by assigning each account its own `CODEX_HOME` (`~/.codex-profiles/<profile>`) and switching that directory for CLI/App operations.
24
+ `codex-switcher` solves this by decoupling shared data from auth credentials.
25
+ Built-in `env=default` maps to `~/.codex`, and same-env account switch only swaps `auth.json`.
25
26
 
26
27
  ## Install
27
28
 
@@ -42,25 +43,22 @@ codex-switcher check
42
43
  ## Quick start
43
44
 
44
45
  ```bash
45
- codex-switcher add work
46
- codex-switcher add personal
46
+ codex-switcher account login personal --env default
47
+ codex-switcher account login work --env default
48
+ codex-switcher account use personal --env default
47
49
 
48
- codex-switcher use work --sync
49
- codex-switcher login --sync
50
- codex-switcher exec -- login status
51
-
52
- codex-switcher switch personal --sync
53
- codex-switcher app use personal
50
+ codex-switcher env create project-a --empty
51
+ codex-switcher account login corp --env project-a
52
+ codex-switcher account use corp --env project-a
54
53
  ```
55
54
 
56
55
  ## Sync options
57
56
 
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).
57
+ - Same-env account switch only replaces `auth.json`; no shared data sync is needed.
58
+ - `account login --sync` (cross-env setup) can sync default-env data into target env (excluding `auth.json`).
61
59
  - `use/switch` defaults to `--launch=auto`: on an interactive terminal, `codex` starts automatically after switch.
62
60
  - `use/switch --launch`: launch `codex` CLI immediately after switching.
63
- - `use/switch --no-launch`: switch CLI pointer only, without launching `codex`.
61
+ - `use/switch --no-launch`: switch account pointer only, without launching `codex`.
64
62
  - `use/switch -- <codex args...>`: run `codex` with args right after switch (implies launch).
65
63
 
66
64
  ## Command reference
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  中文 | [English](README.en.md)
4
4
 
5
5
  `codex-switcher` 是一个面向 Codex CLI 与 Codex App 的轻量账号切换工具。
6
- 它通过为每个 profile 使用独立的 `CODEX_HOME` 目录实现账号隔离。
6
+ 它基于 `env + account` 模型管理账号:`env` 共享数据目录,`account` 管理独立 `auth.json`。
7
7
 
8
8
  ## 项目背景
9
9
 
@@ -18,7 +18,8 @@
18
18
  简单说就是:Codex 会把“账号登录态 + 会话历史 + 一些本地状态”都放在 `CODEX_HOME` 这个目录里(默认一般是 `~/.codex`)。
19
19
  如果两个账号共用同一个目录,就很容易出现你登我下、我登你下,或者历史数据串在一起的问题。
20
20
 
21
- `codex-switcher` 做的事情其实不复杂:给每个账号分一个独立目录(`~/.codex-profiles/<profile>`),然后在你执行命令或启动 App 时自动切到对应目录。这样每个账号的数据都各管各的,切换也就稳定了。
21
+ `codex-switcher` 做的事情其实不复杂:把“共享数据”和“账号凭证”解耦。
22
+ 默认 `env=default` 对应 `~/.codex`,同一 env 下切换账号只替换 `auth.json`,不动共享数据目录里的其它文件。
22
23
 
23
24
  ## 安装
24
25
 
@@ -39,56 +40,30 @@ codex-switcher check
39
40
  ## 快速开始
40
41
 
41
42
  ```bash
42
- codex-switcher add work
43
- codex-switcher add personal
43
+ codex-switcher account login personal --env default
44
+ codex-switcher account login work --env default
45
+ codex-switcher account use personal --env default
44
46
 
45
- codex-switcher use work --sync
46
- codex-switcher login --sync
47
- codex-switcher exec -- login status
48
-
49
- codex-switcher switch personal --sync
50
- codex-switcher app use personal
47
+ codex-switcher env create project-a --empty
48
+ codex-switcher account login corp --env project-a
49
+ codex-switcher account use corp --env project-a
51
50
  ```
52
51
 
53
52
  ## 同步选项
54
53
 
55
- - `login --sync`:将 `~/.codex` 同步到目标 profile(不包含 `auth.json`)。
56
- - `use/switch --sync`:将当前 CLI profile 同步到目标 profile(不包含 `auth.json`)。
57
- - `--no-sync`:不进行数据同步(默认)。
58
- - `use/switch` 默认 `--launch=auto`:交互终端中切换后会自动启动 `codex` CLI。
54
+ - 同一 env 下切账号:只替换 `auth.json`,不进行共享数据同步。
55
+ - `account login --sync`(跨 env 场景):可将默认 env 数据同步到目标 env(不含 `auth.json`)。
56
+ - 兼容命令 `use/switch` 默认 `--launch=auto`:交互终端中切换后会自动启动 `codex` CLI。
59
57
  - `use/switch --launch`:切换后立即启动 `codex` CLI。
60
- - `use/switch --no-launch`:仅切换当前 CLI profile,不启动 `codex` CLI。
58
+ - `use/switch --no-launch`:仅切换账号指针,不启动 `codex` CLI。
61
59
  - `use/switch -- <codex args...>`:切换后直接执行 `codex` 参数(隐式启用 launch)。
62
60
 
63
61
  ## 命令参考
64
62
 
65
- 命令默认用 `codex-switcher`,你也可以继续使用兼容别名 `codex-sw`。
66
-
67
- | 分类 | 命令 | 说明 |
68
- | --- | --- | --- |
69
- | Profile 管理 | `codex-switcher add <profile>` | 新建 profile |
70
- | Profile 管理 | `codex-switcher remove <profile> [--force]` | 删除 profile |
71
- | Profile 管理 | `codex-switcher list` | 列出所有 profile |
72
- | Profile 管理 | `codex-switcher current [cli\|app]` | 查看当前 CLI / App profile |
73
- | Profile 管理 | `codex-switcher status` | 查看当前 profile 登录状态 |
74
- | Profile 管理 | `codex-switcher use <profile> [--sync\|--no-sync] [--launch\|--no-launch] [-- <codex args...>]` | 切换当前 CLI profile,可选立即启动 `codex` |
75
- | Profile 管理 | `codex-switcher switch <profile> [--sync\|--no-sync] [--launch\|--no-launch] [-- <codex args...>]` | `use` 的等价命令 |
76
- | 数据迁移 | `codex-switcher import-default <profile> [--with-auth] [--force]` | 从 `~/.codex` 导入数据到 profile |
77
- | CLI 登录态 | `codex-switcher login [profile] [--sync\|--no-sync]` | 登录指定或当前 CLI profile |
78
- | CLI 登录态 | `codex-switcher logout [profile]` | 登出指定或当前 CLI profile |
79
- | CLI 登录态 | `codex-switcher exec -- <codex args...>` | 在当前 CLI profile 下执行 codex 命令 |
80
- | CLI 登录态 | `codex-switcher env [profile]` | 输出指定 profile 的 `CODEX_HOME` |
81
- | App 控制 | `codex-switcher app open [profile]` | 用指定 profile 启动 App |
82
- | App 控制 | `codex-switcher app use <profile>` | 切换 App profile(等价于 open) |
83
- | App 控制 | `codex-switcher app logout [profile]` | 登出 App profile |
84
- | App 控制 | `codex-switcher app status` | 查看 App 运行状态 |
85
- | App 控制 | `codex-switcher app stop` | 停止由工具启动的 App 进程 |
86
- | App 控制 | `codex-switcher app current` | 查看当前 App profile |
87
- | 系统维护 | `codex-switcher check` | 基础环境与状态检查 |
88
- | 系统维护 | `codex-switcher doctor [--fix]` | 诊断并可选自动修复 |
89
- | 系统维护 | `codex-switcher recover [--dry-run]` | 恢复损坏的 current 指针 |
90
- | 系统维护 | `codex-switcher init [--shell zsh\|bash] [--dry-run]` | 初始化 PATH 与快捷命令 |
91
- | 系统维护 | `codex-switcher upgrade [--dry-run]` | 升级到最新版本 |
63
+ 完整命令说明请查看插件文档:
64
+
65
+ - 中文:`plugins/codex-switcher/README.md`
66
+ - English:`plugins/codex-switcher/README.en.md`
92
67
 
93
68
  ## 开发
94
69
 
@@ -5,19 +5,19 @@ Run this checklist on a macOS machine with Codex.app installed.
5
5
  ## Setup
6
6
 
7
7
  - [ ] `codex-sw check` returns `check: ok`
8
- - [ ] `codex-sw add work` and `codex-sw add personal` succeed
8
+ - [ ] `codex-sw account add work --env default` and `codex-sw account add personal --env default` succeed
9
9
 
10
10
  ## CLI isolation
11
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
12
+ - [ ] `codex-sw account use work --env default && codex-sw login`
13
+ - [ ] `codex-sw account use personal --env default && codex-sw login`
14
+ - [ ] `codex-sw status` shows both accounts logged in when selected as current env/account
15
15
 
16
16
  ## App switching
17
17
 
18
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`
19
+ - [ ] `codex-sw app current` prints `default/work`
20
+ - [ ] `codex-sw app use personal` restarts App under `default/personal`
21
21
  - [ ] `codex-sw app status` reports running when app is open
22
22
  - [ ] `codex-sw app stop` stops managed app process
23
23
 
@@ -30,5 +30,6 @@ Run this checklist on a macOS machine with Codex.app installed.
30
30
  ## Security checks
31
31
 
32
32
  - [ ] `~/.codex-switcher` permission is `700`
33
- - [ ] `~/.codex-profiles` permission is `700`
33
+ - [ ] `~/.codex-envs` permission is `700`
34
+ - [ ] `~/.codex-switcher/env-accounts` permission is `700`
34
35
  - [ ] no tokens are visible in `~/.codex-switcher/switcher.log`
package/docs/upgrade.md CHANGED
@@ -23,7 +23,7 @@ codex-sw check
23
23
 
24
24
  ## Recovery
25
25
 
26
- If pointers are corrupted or profile directories are missing:
26
+ If pointers are corrupted, or env/account data directories are missing:
27
27
 
28
28
  ```bash
29
29
  codex-sw recover
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wangxt0223/codex-switcher",
3
- "version": "0.5.1",
4
- "description": "Profile-based account switcher for Codex CLI and Codex App using isolated CODEX_HOME directories.",
3
+ "version": "0.6.0",
4
+ "description": "Env + account switcher for Codex CLI and Codex App with shared env data and per-account auth.",
5
5
  "license": "MIT",
6
6
  "author": "wangxt",
7
7
  "homepage": "https://github.com/wangxt/codex-switcher",
@@ -13,7 +13,8 @@
13
13
  "codex",
14
14
  "codex-cli",
15
15
  "account-switch",
16
- "profile",
16
+ "env",
17
+ "account",
17
18
  "codex-home"
18
19
  ],
19
20
  "bin": {
@@ -2,115 +2,88 @@
2
2
 
3
3
  [中文](README.md) | English
4
4
 
5
- Profile-based account switcher for Codex CLI and Codex App.
5
+ `codex-switcher` now uses an **env + account** model for Codex CLI / Codex App switching.
6
6
 
7
- ## Core idea
7
+ ## Core Model
8
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`
9
+ - Built-in default env: `default`, mapped to `~/.codex` (override via `CODEX_SWITCHER_DEFAULT_HOME`).
10
+ - Custom env data root: `~/.codex-envs/<env>/home` (shared history/sessions/config data).
11
+ - Account auth root: `~/.codex-switcher/env-accounts/<env>/<account>/auth.json`.
12
+ - Switching accounts in the same env only swaps `auth.json`; no sync is needed.
13
+ - Current pointers:
14
+ - `~/.codex-switcher/current_cli_env`
15
+ - `~/.codex-switcher/current_cli_account`
16
+ - `~/.codex-switcher/current_app_env`
17
+ - `~/.codex-switcher/current_app_account`
13
18
 
14
19
  ## Commands
15
20
 
16
21
  ```bash
17
- codex-switcher add <profile>
18
- codex-switcher remove <profile> [--force]
22
+ codex-switcher env list
23
+ codex-switcher env create <env> [--empty|--from-default|--from-env <src>]
24
+ codex-switcher env use <env> [--target cli|app|both]
25
+ codex-switcher env remove <env> [--force]
26
+ codex-switcher env current [cli|app]
27
+ codex-switcher env path [env]
28
+
29
+ codex-switcher account list [--env <env>]
30
+ codex-switcher account add <account> [--env <env>]
31
+ codex-switcher account remove <account> [--env <env>] [--force]
32
+ codex-switcher account login <account> [--env <env>] [--target cli|app|both] [--sync|--no-sync]
33
+ codex-switcher account use <account> [--env <env>] [--target cli|app|both] [--sync|--no-sync]
34
+ codex-switcher account logout [account] [--env <env>] [--target cli|app|both]
35
+ codex-switcher account current [cli|app]
36
+
19
37
  codex-switcher list
20
- codex-switcher import-default <profile> [--with-auth] [--force]
21
- codex-switcher use <profile> [--sync|--no-sync] [--launch|--no-launch] [-- <codex args...>]
22
- codex-switcher switch <profile> [--sync|--no-sync] [--launch|--no-launch] [-- <codex args...>]
23
- codex-switcher current [cli|app]
24
38
  codex-switcher status
25
-
39
+ codex-switcher current [cli|app]
26
40
  codex-switcher exec -- <codex args...>
27
- codex-switcher login [profile] [--sync|--no-sync]
28
- codex-switcher logout [profile]
29
- codex-switcher env [profile]
41
+ codex-switcher login [account] [--sync|--no-sync]
42
+ codex-switcher logout [account]
30
43
 
31
- codex-switcher app open [profile]
32
- codex-switcher app use <profile>
33
- codex-switcher app logout [profile]
44
+ codex-switcher app open [account] [-- <app args...>]
45
+ codex-switcher app use <account> [-- <app args...>]
46
+ codex-switcher app logout [account]
34
47
  codex-switcher app status
35
48
  codex-switcher app stop
36
-
37
- codex-switcher init [--shell zsh|bash]
38
- codex-switcher upgrade [--dry-run]
39
- codex-switcher recover
40
- codex-switcher check
41
- codex-switcher doctor [--fix]
49
+ codex-switcher app current
42
50
  ```
43
51
 
44
- ## Typical flow
52
+ ## Typical Flow
45
53
 
46
54
  ```bash
47
- codex-switcher add work
48
- codex-switcher add personal
49
-
50
- codex-switcher use work --sync
51
- codex-switcher login --sync
52
- codex-switcher exec -- login status
53
-
54
- codex-switcher switch personal --sync
55
- codex-switcher app use personal
55
+ # 1) Login two accounts under default env (default=~/.codex)
56
+ codex-switcher account login personal --env default
57
+ codex-switcher account login work --env default
58
+
59
+ # 2) Same-env account switch (auth.json swap only)
60
+ codex-switcher account use personal --env default
61
+ codex-switcher account use work --env default
62
+
63
+ # 3) Create a dedicated env and switch accounts there
64
+ codex-switcher env create project-a --empty
65
+ codex-switcher account login corp --env project-a
66
+ codex-switcher account use corp --env project-a
56
67
  ```
57
68
 
58
- ## Migrate Existing App/CLI Data
59
-
60
- If your existing data is in `~/.codex`, import it into a profile first:
69
+ ## list Output
61
70
 
62
- ```bash
63
- codex-switcher import-default work
64
- ```
71
+ `codex-switcher list` prints:
65
72
 
66
- This copies records/projects/history but excludes `auth.json` by default.
67
- If you want to carry login state too:
73
+ `ENV / ACCOUNT / EMAIL / PLAN / 5H USAGE / WEEKLY USAGE / LAST ACTIVITY`
68
74
 
69
- ```bash
70
- codex-switcher import-default work --with-auth
71
- ```
75
+ Usage data strategy:
72
76
 
73
- ## Sync Behavior
77
+ - API first (`chatgpt.com/backend-api/wham/usage`)
78
+ - Auto fallback to local `sessions/*.jsonl` on API failure
79
+ - `LAST ACTIVITY` appends source marker `(api)` or `(local)`
74
80
 
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
- - `use/switch` defaults to `--launch=auto`: in interactive terminals, `codex` starts right after switching.
79
- - `use/switch --launch`: launch `codex` CLI immediately after switching profile.
80
- - `use/switch --no-launch`: switch pointer only without launching `codex`.
81
- - `use/switch -- <codex args...>`: run `codex` with provided args after switch (implies launch).
81
+ ## Compatibility Commands
82
82
 
83
- Examples:
84
-
85
- ```bash
86
- codex-switcher login work --sync
87
- codex-switcher switch personal --sync
88
- codex-switcher use work --no-sync
89
- ```
90
-
91
- ## Upgrade
92
-
93
- ```bash
94
- codex-switcher upgrade
95
- ```
96
-
97
- ## Notes
98
-
99
- - Codex App is single-instance on macOS; switching App profile requires restart.
100
- - `codex-switcher app stop` only stops app instances started and tracked by `codex-switcher`.
101
- - `codex-switcher app open/use <profile>` requires that profile already exists and is logged in.
102
- - `--sync` uses overwrite strategy (not merge): source overwrites target for all files except `auth.json`.
103
- - `codex-switcher status` exit codes:
104
- - `0`: both current profiles logged in
105
- - `1`: at least one current profile not logged in
106
- - `2`: pointer/profile integrity issue (run `codex-switcher recover`)
83
+ Legacy commands (`add/remove/use/switch/login/logout/import-default`) are kept and mapped to the new model.
107
84
 
108
85
  ## Validation
109
86
 
110
87
  ```bash
111
88
  ./plugins/codex-switcher/scripts/test-switcher.sh
112
89
  ```
113
-
114
- ## Compatibility command
115
-
116
- `codex-sw` is kept as a compatibility entrypoint and maps to the same implementation.
@@ -2,115 +2,88 @@
2
2
 
3
3
  中文 | [English](README.en.md)
4
4
 
5
- 为 Codex CLI 与 Codex App 提供基于 profile 的账号切换能力。
5
+ 为 Codex CLI 与 Codex App 提供基于 **env + account** 的账号切换能力。
6
6
 
7
7
  ## 核心设计
8
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`
9
+ - 内置默认 env:`default`,对应 `~/.codex`(可由 `CODEX_SWITCHER_DEFAULT_HOME` 覆盖)。
10
+ - 自定义 env 数据目录:`~/.codex-envs/<env>/home`(共享 history/sessions/config 等数据)。
11
+ - 账号凭证目录:`~/.codex-switcher/env-accounts/<env>/<account>/auth.json`(每账号独立 auth)。
12
+ - 同一 env 下切账号只替换 `auth.json`,不做 sync。
13
+ - 当前指针:
14
+ - `~/.codex-switcher/current_cli_env`
15
+ - `~/.codex-switcher/current_cli_account`
16
+ - `~/.codex-switcher/current_app_env`
17
+ - `~/.codex-switcher/current_app_account`
13
18
 
14
19
  ## 命令
15
20
 
16
21
  ```bash
17
- codex-switcher add <profile>
18
- codex-switcher remove <profile> [--force]
22
+ codex-switcher env list
23
+ codex-switcher env create <env> [--empty|--from-default|--from-env <src>]
24
+ codex-switcher env use <env> [--target cli|app|both]
25
+ codex-switcher env remove <env> [--force]
26
+ codex-switcher env current [cli|app]
27
+ codex-switcher env path [env]
28
+
29
+ codex-switcher account list [--env <env>]
30
+ codex-switcher account add <account> [--env <env>]
31
+ codex-switcher account remove <account> [--env <env>] [--force]
32
+ codex-switcher account login <account> [--env <env>] [--target cli|app|both] [--sync|--no-sync]
33
+ codex-switcher account use <account> [--env <env>] [--target cli|app|both] [--sync|--no-sync]
34
+ codex-switcher account logout [account] [--env <env>] [--target cli|app|both]
35
+ codex-switcher account current [cli|app]
36
+
19
37
  codex-switcher list
20
- codex-switcher import-default <profile> [--with-auth] [--force]
21
- codex-switcher use <profile> [--sync|--no-sync] [--launch|--no-launch] [-- <codex args...>]
22
- codex-switcher switch <profile> [--sync|--no-sync] [--launch|--no-launch] [-- <codex args...>]
23
- codex-switcher current [cli|app]
24
38
  codex-switcher status
25
-
39
+ codex-switcher current [cli|app]
26
40
  codex-switcher exec -- <codex args...>
27
- codex-switcher login [profile] [--sync|--no-sync]
28
- codex-switcher logout [profile]
29
- codex-switcher env [profile]
41
+ codex-switcher login [account] [--sync|--no-sync]
42
+ codex-switcher logout [account]
30
43
 
31
- codex-switcher app open [profile]
32
- codex-switcher app use <profile>
33
- codex-switcher app logout [profile]
44
+ codex-switcher app open [account] [-- <app args...>]
45
+ codex-switcher app use <account> [-- <app args...>]
46
+ codex-switcher app logout [account]
34
47
  codex-switcher app status
35
48
  codex-switcher app stop
36
-
37
- codex-switcher init [--shell zsh|bash]
38
- codex-switcher upgrade [--dry-run]
39
- codex-switcher recover
40
- codex-switcher check
41
- codex-switcher doctor [--fix]
49
+ codex-switcher app current
42
50
  ```
43
51
 
44
52
  ## 典型流程
45
53
 
46
54
  ```bash
47
- codex-switcher add work
48
- codex-switcher add personal
49
-
50
- codex-switcher use work --sync
51
- codex-switcher login --sync
52
- codex-switcher exec -- login status
53
-
54
- codex-switcher switch personal --sync
55
- codex-switcher app use personal
55
+ # 1) 默认 env(default=~/.codex) 下登录两个账号
56
+ codex-switcher account login personal --env default
57
+ codex-switcher account login work --env default
58
+
59
+ # 2) 同 env 切账号(仅替换 auth.json)
60
+ codex-switcher account use personal --env default
61
+ codex-switcher account use work --env default
62
+
63
+ # 3) 新建业务 env,并在该 env 下登录/切换账号
64
+ codex-switcher env create project-a --empty
65
+ codex-switcher account login corp --env project-a
66
+ codex-switcher account use corp --env project-a
56
67
  ```
57
68
 
58
- ## 迁移已有数据
69
+ ## list 输出
59
70
 
60
- 如果你原本在 `~/.codex` 下使用 Codex,可先导入到某个 profile:
71
+ `codex-switcher list` 默认输出:
61
72
 
62
- ```bash
63
- codex-switcher import-default work
64
- ```
65
-
66
- 默认会迁移记录/项目等数据,但不包含 `auth.json`。
67
- 如需连登录态一起导入:
68
-
69
- ```bash
70
- codex-switcher import-default work --with-auth
71
- ```
73
+ `ENV / ACCOUNT / EMAIL / PLAN / 5H USAGE / WEEKLY USAGE / LAST ACTIVITY`
72
74
 
73
- ## 同步行为
75
+ 其中用量数据策略为:
74
76
 
75
- - `login --sync`:从默认 `~/.codex` 覆盖同步到目标 profile,排除 `auth.json`。
76
- - `use/switch --sync`:从当前 CLI profile 覆盖同步到目标 profile,排除 `auth.json`。
77
- - `--no-sync`:显式关闭同步(默认行为)。
78
- - `use/switch` 默认 `--launch=auto`:交互终端中切换后自动启动 `codex` CLI。
79
- - `use/switch --launch`:切换后立即以目标 profile 启动 `codex` CLI。
80
- - `use/switch --no-launch`:切换后只更新 profile 指针,不启动 `codex` CLI。
81
- - `use/switch -- <codex args...>`:切换后执行指定 `codex` 参数(等价于隐式 `--launch`)。
77
+ - 默认优先 API(`chatgpt.com/backend-api/wham/usage`)
78
+ - API 失败自动回退本地 `sessions/*.jsonl`
79
+ - `LAST ACTIVITY` 列会追加 `(api)` 或 `(local)` 标记来源
82
80
 
83
- 示例:
84
-
85
- ```bash
86
- codex-switcher login work --sync
87
- codex-switcher switch personal --sync
88
- codex-switcher use work --no-sync
89
- ```
90
-
91
- ## 升级
92
-
93
- ```bash
94
- codex-switcher upgrade
95
- ```
96
-
97
- ## 说明
81
+ ## 兼容命令
98
82
 
99
- - macOS 下 Codex App 是单实例;切换 App profile 需要重启。
100
- - `codex-switcher app stop` 仅停止由 `codex-switcher` 启动并跟踪的 App 进程。
101
- - `codex-switcher app open/use <profile>` 要求该 profile 已存在且已登录。
102
- - `--sync` 为覆盖策略(不是合并):源目录覆盖目标目录,`auth.json` 除外。
103
- - `codex-switcher status` 返回码:
104
- - `0`:当前 CLI/App profile 均已登录
105
- - `1`:至少一个当前 profile 未登录
106
- - `2`:指针或 profile 完整性异常(可执行 `codex-switcher recover`)
83
+ `add/remove/use/switch/login/logout/import-default` 仍保留兼容入口,内部映射到新模型。
107
84
 
108
85
  ## 验证
109
86
 
110
87
  ```bash
111
88
  ./plugins/codex-switcher/scripts/test-switcher.sh
112
89
  ```
113
-
114
- ## 兼容命令
115
-
116
- `codex-sw` 作为兼容入口保留,行为与 `codex-switcher` 一致。