codex-sw 0.3.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 +16 -0
- package/LICENSE +21 -0
- package/README.md +57 -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.md +70 -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 +928 -0
- package/plugins/codex-switcher/scripts/test-switcher.sh +120 -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,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0 - 2026-04-12
|
|
4
|
+
|
|
5
|
+
- Added `codex-sw` namespaced entrypoint (kept `codex-switcher` compatibility).
|
|
6
|
+
- Added concurrency lock to protect profile pointer mutations.
|
|
7
|
+
- Added safer App lifecycle handling with managed PID tracking.
|
|
8
|
+
- Added status exit code conventions (`0/1/2`).
|
|
9
|
+
- Added pointer recovery command: `codex-sw recover`.
|
|
10
|
+
- Added init/bootstrap command: `codex-sw init`.
|
|
11
|
+
- Added doctor auto-fix mode: `codex-sw doctor --fix`.
|
|
12
|
+
- Added log redaction scanner in `check` / `doctor`.
|
|
13
|
+
- Added install/uninstall scripts and CI workflow.
|
|
14
|
+
- Added expanded smoke tests.
|
|
15
|
+
- Added npm release helper: `npm run release:npm`.
|
|
16
|
+
- Added `publishConfig` (public + npmjs registry) and publish guide docs.
|
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.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# codex-sw
|
|
2
|
+
|
|
3
|
+
`codex-sw` is a lightweight profile switcher for Codex CLI and Codex App.
|
|
4
|
+
It isolates accounts by running each profile in its own `CODEX_HOME` directory.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
### Option A: npm (global)
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i -g codex-sw
|
|
12
|
+
codex-sw check
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Option B: from source checkout
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
./scripts/install.sh
|
|
19
|
+
codex-sw check
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
codex-sw add work
|
|
26
|
+
codex-sw add personal
|
|
27
|
+
|
|
28
|
+
codex-sw use work
|
|
29
|
+
codex-sw login
|
|
30
|
+
codex-sw exec -- login status
|
|
31
|
+
|
|
32
|
+
codex-sw app use personal
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Command reference
|
|
36
|
+
|
|
37
|
+
See plugin guide:
|
|
38
|
+
- `plugins/codex-switcher/README.md`
|
|
39
|
+
|
|
40
|
+
## Development
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm run check
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Publish to npm
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm login --registry https://registry.npmjs.org/
|
|
50
|
+
npm run release:npm
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Docs
|
|
54
|
+
|
|
55
|
+
- `docs/macos-manual-checklist.md`
|
|
56
|
+
- `docs/upgrade.md`
|
|
57
|
+
- `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: `codex-sw`
|
|
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 codex-sw 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
|
+
npm i -g codex-sw@latest
|
|
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": "codex-sw",
|
|
3
|
+
"version": "0.3.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.3.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,70 @@
|
|
|
1
|
+
# codex-sw
|
|
2
|
+
|
|
3
|
+
Profile-based account switcher for Codex CLI and Codex App without modifying upstream source code.
|
|
4
|
+
|
|
5
|
+
## Core idea
|
|
6
|
+
|
|
7
|
+
- One profile = one isolated `CODEX_HOME` directory: `~/.codex-profiles/<profile>`
|
|
8
|
+
- CLI commands run under selected CLI profile
|
|
9
|
+
- App is restarted under selected App profile
|
|
10
|
+
- Current pointers are stored in `~/.codex-switcher/current_cli` and `~/.codex-switcher/current_app`
|
|
11
|
+
|
|
12
|
+
## Commands
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
codex-sw add <profile>
|
|
16
|
+
codex-sw remove <profile> [--force]
|
|
17
|
+
codex-sw list
|
|
18
|
+
codex-sw use <profile>
|
|
19
|
+
codex-sw switch <profile>
|
|
20
|
+
codex-sw current [cli|app]
|
|
21
|
+
codex-sw status
|
|
22
|
+
|
|
23
|
+
codex-sw exec -- <codex args...>
|
|
24
|
+
codex-sw login [profile]
|
|
25
|
+
codex-sw logout [profile]
|
|
26
|
+
codex-sw env [profile]
|
|
27
|
+
|
|
28
|
+
codex-sw app open [profile]
|
|
29
|
+
codex-sw app use <profile>
|
|
30
|
+
codex-sw app logout [profile]
|
|
31
|
+
codex-sw app status
|
|
32
|
+
codex-sw app stop
|
|
33
|
+
|
|
34
|
+
codex-sw init [--shell zsh|bash]
|
|
35
|
+
codex-sw recover
|
|
36
|
+
codex-sw check
|
|
37
|
+
codex-sw doctor [--fix]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Typical flow
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
codex-sw add work
|
|
44
|
+
codex-sw add personal
|
|
45
|
+
|
|
46
|
+
codex-sw use work
|
|
47
|
+
codex-sw login
|
|
48
|
+
codex-sw exec -- login status
|
|
49
|
+
|
|
50
|
+
codex-sw app use personal
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Notes
|
|
54
|
+
|
|
55
|
+
- Codex App is single-instance on macOS; switching App profile requires restart.
|
|
56
|
+
- `codex-sw app stop` only stops app instances started and tracked by `codex-sw`.
|
|
57
|
+
- `codex-sw status` exit codes:
|
|
58
|
+
- `0`: both current profiles logged in
|
|
59
|
+
- `1`: at least one current profile not logged in
|
|
60
|
+
- `2`: pointer/profile integrity issue (run `codex-sw recover`)
|
|
61
|
+
|
|
62
|
+
## Validation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
./plugins/codex-switcher/scripts/test-switcher.sh
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Compatibility command
|
|
69
|
+
|
|
70
|
+
`codex-switcher` is kept as a compatibility entrypoint and maps to the same implementation.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|