@naram/codex-switch 0.1.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/LICENSE +21 -0
- package/README.en.md +125 -0
- package/README.md +181 -0
- package/dist/index.js +1965 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 naram
|
|
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,125 @@
|
|
|
1
|
+
# codex-switch
|
|
2
|
+
|
|
3
|
+
[한국어](README.md) | **English**
|
|
4
|
+
|
|
5
|
+
A CLI tool that interactively sets up multiple **Codex profiles** with isolated
|
|
6
|
+
login/session state, optional custom model providers, and permission/auto-review
|
|
7
|
+
settings.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @naram/codex-switch
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
After answering a few prompts, you can launch Codex with commands such as
|
|
14
|
+
`codex-o`, `codex-gpt`, or `codex-glm`.
|
|
15
|
+
|
|
16
|
+
## What is a "profile"?
|
|
17
|
+
|
|
18
|
+
Codex has a `--profile` configuration layer, but that layer alone is not account
|
|
19
|
+
or session isolation. In this tool, a profile means:
|
|
20
|
+
|
|
21
|
+
> an isolated **`CODEX_HOME`** + profile-local **`config.toml`** + optional
|
|
22
|
+
> provider-secret **`.env`** + launcher aliases/scripts
|
|
23
|
+
|
|
24
|
+
`CODEX_HOME` is the Codex state root for config, auth cache, logs, sessions,
|
|
25
|
+
skills, and other local state. Separating it per profile lets you keep logins and
|
|
26
|
+
sessions separate.
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx @naram/codex-switch
|
|
32
|
+
|
|
33
|
+
npm i -g @naram/codex-switch
|
|
34
|
+
codex-switch
|
|
35
|
+
codex-switch list
|
|
36
|
+
codex-switch doctor
|
|
37
|
+
codex-switch remove codex-glm
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## What gets created
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
~/.codex-switch/
|
|
44
|
+
├── profiles.json
|
|
45
|
+
├── codex-glm/
|
|
46
|
+
│ ├── config.toml
|
|
47
|
+
│ ├── .env
|
|
48
|
+
│ ├── launcher
|
|
49
|
+
│ └── ...
|
|
50
|
+
└── codex-o/
|
|
51
|
+
├── config.toml
|
|
52
|
+
└── launcher
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Secrets are not written to shell rc files or PATH scripts. Custom provider
|
|
56
|
+
secrets live only in the profile `.env` file with `0600` permissions. The
|
|
57
|
+
generated `config.toml` references the env var name through `env_key` or
|
|
58
|
+
`env_http_headers`.
|
|
59
|
+
|
|
60
|
+
## Permission / Auto-review Presets
|
|
61
|
+
|
|
62
|
+
The interactive flow can write Codex permission settings into each profile's
|
|
63
|
+
`config.toml`.
|
|
64
|
+
|
|
65
|
+
| Preset | Generated settings |
|
|
66
|
+
| ---------------------- | -------------------------------------------------------------------- |
|
|
67
|
+
| Codex default | No permission keys written |
|
|
68
|
+
| Read-only | `sandbox_mode = "read-only"`, `approval_policy = "on-request"` |
|
|
69
|
+
| Auto (manual approval) | `sandbox_mode = "workspace-write"`, `approval_policy = "on-request"` |
|
|
70
|
+
| Auto-review | Auto preset + `approvals_reviewer = "auto_review"` |
|
|
71
|
+
| No approval prompts | `sandbox_mode = "workspace-write"`, `approval_policy = "never"` |
|
|
72
|
+
|
|
73
|
+
Auto-review does not expand the sandbox or network permissions. It routes
|
|
74
|
+
eligible approval requests to a reviewer agent when approvals remain interactive.
|
|
75
|
+
|
|
76
|
+
## Commands
|
|
77
|
+
|
|
78
|
+
| Command | Description |
|
|
79
|
+
| ----------------------------- | -------------------------------------------------- |
|
|
80
|
+
| `codex-switch` / `create` | Create or update a profile interactively |
|
|
81
|
+
| `codex-switch list` | List registered profiles |
|
|
82
|
+
| `codex-switch remove <alias>` | Remove launchers and registry entry |
|
|
83
|
+
| `codex-switch doctor` | Check codex installation, PATH, and profile health |
|
|
84
|
+
| `codex-switch help` | Show help |
|
|
85
|
+
|
|
86
|
+
## Requirements
|
|
87
|
+
|
|
88
|
+
- Node.js **18+**
|
|
89
|
+
- **macOS / Linux** (Windows/PowerShell is out of scope for v1)
|
|
90
|
+
- Shells: **zsh / bash / fish**
|
|
91
|
+
- Codex CLI (`codex`) installed
|
|
92
|
+
|
|
93
|
+
Custom providers use Codex custom model provider config. Enter an OpenAI-compatible
|
|
94
|
+
base URL (for example OpenRouter `https://openrouter.ai/api/v1`); the wire protocol
|
|
95
|
+
defaults to `chat` (Chat Completions). Choose `responses` only for OpenAI
|
|
96
|
+
Responses-compatible gateways.
|
|
97
|
+
|
|
98
|
+
## Tab completion
|
|
99
|
+
|
|
100
|
+
When you install the `alias` launcher, the generated marker block also wires
|
|
101
|
+
shell completion onto the alias. If you already installed Codex's own completion
|
|
102
|
+
(`codex completion <shell>`), then `codex-or <TAB>` completes Codex subcommands
|
|
103
|
+
just like `codex <TAB>`.
|
|
104
|
+
|
|
105
|
+
| Shell | Injected line |
|
|
106
|
+
| ----- | ----------------------------------------------------------------- |
|
|
107
|
+
| zsh | `(( $+functions[compdef] )) && compdef <alias>=codex 2>/dev/null` |
|
|
108
|
+
| bash | `type _codex &>/dev/null && complete -F _codex <alias>` |
|
|
109
|
+
| fish | `complete -c <alias> -w codex` |
|
|
110
|
+
|
|
111
|
+
If Codex completion is not installed, these lines no-op quietly at shell startup.
|
|
112
|
+
With a `script`-only launcher no rc file is touched, so completion is not wired.
|
|
113
|
+
|
|
114
|
+
## Development
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npm install
|
|
118
|
+
npm run build
|
|
119
|
+
npm test
|
|
120
|
+
npm run lint
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# codex-switch
|
|
2
|
+
|
|
3
|
+
**한국어** | [English](README.en.md)
|
|
4
|
+
|
|
5
|
+
여러 개의 **Codex 프로필**(서로 다른 로그인 / 커스텀 모델 provider / 권한·auto-review
|
|
6
|
+
설정)을 대화형으로 세팅해 주는 CLI 도구입니다.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npx @naram/codex-switch
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
실행하면 몇 가지 질문에 답하는 것만으로 `codex-o`, `codex-gpt`, `codex-glm` 같은
|
|
13
|
+
명령으로 서로 다른 Codex 환경을 바로 띄울 수 있게 됩니다.
|
|
14
|
+
|
|
15
|
+
## "프로필"이란?
|
|
16
|
+
|
|
17
|
+
Codex에는 `--profile` 설정 레이어가 있지만, 그 자체는 계정·세션 격리용이 아닙니다.
|
|
18
|
+
이 도구가 말하는 프로필은:
|
|
19
|
+
|
|
20
|
+
> **격리된 `CODEX_HOME`** + **프로필별 `config.toml`** + (선택) **provider secret
|
|
21
|
+
> `.env`** + **실행 런처(alias/스크립트)** 의 묶음
|
|
22
|
+
|
|
23
|
+
`CODEX_HOME`은 Codex의 설정, 인증 캐시, 로그, 세션, 스킬 등을 저장하는 루트입니다.
|
|
24
|
+
프로필마다 이 디렉토리를 분리하면 로그인과 세션을 분리해서 운용할 수 있습니다.
|
|
25
|
+
|
|
26
|
+
## 빠른 시작
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# 대화형으로 프로필 생성
|
|
30
|
+
npx @naram/codex-switch
|
|
31
|
+
|
|
32
|
+
# 또는 전역 설치 후
|
|
33
|
+
npm i -g @naram/codex-switch
|
|
34
|
+
codex-switch # = codex-switch create
|
|
35
|
+
codex-switch list
|
|
36
|
+
codex-switch doctor
|
|
37
|
+
codex-switch remove codex-glm
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 예시 1 - 표준 Codex 로그인 분리
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
alias : codex-o
|
|
44
|
+
custom provider: No
|
|
45
|
+
model : gpt-5.5
|
|
46
|
+
permissions : Codex default
|
|
47
|
+
launchers : alias
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
새 셸에서 `codex-o login`으로 로그인하면 기본 `~/.codex`와 분리된
|
|
51
|
+
`~/.codex-switch/codex-o`에 인증과 세션이 저장됩니다.
|
|
52
|
+
|
|
53
|
+
### 예시 2 - 커스텀 provider (OpenRouter)
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
alias : codex-or
|
|
57
|
+
custom provider: Yes
|
|
58
|
+
auth method : env_key
|
|
59
|
+
base URL : https://openrouter.ai/api/v1
|
|
60
|
+
wire protocol : chat
|
|
61
|
+
secret : ******** (OpenRouter API 키)
|
|
62
|
+
model : anthropic/claude-sonnet-4.5
|
|
63
|
+
permissions : Auto-review
|
|
64
|
+
launchers : alias + script
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`codex-or` 명령은 해당 프로필의 `config.toml`을 사용하고, provider secret은
|
|
68
|
+
`~/.codex-switch/codex-or/.env`에서만 로드합니다.
|
|
69
|
+
|
|
70
|
+
> OpenRouter처럼 대부분의 OpenAI 호환 게이트웨이는 **Chat Completions** API를 쓰므로
|
|
71
|
+
> wire 프로토콜 기본값은 `chat`입니다. OpenAI Responses 호환 게이트웨이를 쓸 때만
|
|
72
|
+
> `responses`를 고르면 됩니다.
|
|
73
|
+
|
|
74
|
+
## 권한 / auto-review preset
|
|
75
|
+
|
|
76
|
+
대화형 질문에서 Codex 권한 preset을 선택하면 프로필별 `config.toml`에 durable 설정으로
|
|
77
|
+
저장됩니다.
|
|
78
|
+
|
|
79
|
+
| preset | 생성되는 설정 |
|
|
80
|
+
| ---------------------- | -------------------------------------------------------------------- |
|
|
81
|
+
| Codex default | 권한 관련 키를 쓰지 않음 |
|
|
82
|
+
| Read-only | `sandbox_mode = "read-only"`, `approval_policy = "on-request"` |
|
|
83
|
+
| Auto (manual approval) | `sandbox_mode = "workspace-write"`, `approval_policy = "on-request"` |
|
|
84
|
+
| Auto-review | Auto preset + `approvals_reviewer = "auto_review"` |
|
|
85
|
+
| No approval prompts | `sandbox_mode = "workspace-write"`, `approval_policy = "never"` |
|
|
86
|
+
|
|
87
|
+
Auto-review는 sandbox나 네트워크 권한을 넓히지 않습니다. `approval_policy = "on-request"`처럼
|
|
88
|
+
approval 요청이 남아 있을 때, 그 요청을 사용자 대신 reviewer agent에 라우팅합니다.
|
|
89
|
+
|
|
90
|
+
## 명령어
|
|
91
|
+
|
|
92
|
+
| 명령 | 설명 |
|
|
93
|
+
| -------------------------------------- | -------------------------------------------------- |
|
|
94
|
+
| `codex-switch` / `codex-switch create` | 대화형 프로필 생성 (기존 alias 재실행 시 업데이트) |
|
|
95
|
+
| `codex-switch list` | 등록된 프로필 목록 |
|
|
96
|
+
| `codex-switch remove <alias>` | 프로필 제거 (런처 정리; CODEX_HOME은 확인 후 삭제) |
|
|
97
|
+
| `codex-switch doctor` | codex 설치 / PATH / 프로필 상태 점검 |
|
|
98
|
+
| `codex-switch help` | 도움말 |
|
|
99
|
+
|
|
100
|
+
## 무엇이 어디에 생성되나
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
~/.codex-switch/
|
|
104
|
+
├── profiles.json # 중앙 레지스트리 (메타데이터, 0600) - 비밀은 저장 안 함
|
|
105
|
+
├── codex-glm/ # 프로필의 CODEX_HOME
|
|
106
|
+
│ ├── config.toml # Codex 설정 (0600)
|
|
107
|
+
│ ├── .env # provider secret (0600, custom일 때만)
|
|
108
|
+
│ ├── launcher # 내부 런처 (0700)
|
|
109
|
+
│ └── ... # 로그인 후 auth/log/sessions 등 Codex 상태
|
|
110
|
+
└── codex-o/
|
|
111
|
+
├── config.toml
|
|
112
|
+
└── launcher
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
alias 런처는 셸 rc 파일에 마커 블록으로 주입됩니다.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# >>> codex-switch: codex-glm >>>
|
|
119
|
+
alias codex-glm='"$HOME/.codex-switch/codex-glm/launcher"'
|
|
120
|
+
# <<< codex-switch: codex-glm <<<
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
PATH 스크립트는 내부 런처만 호출합니다.
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
#!/bin/sh
|
|
127
|
+
# codex-switch launcher: codex-glm
|
|
128
|
+
exec "$HOME/.codex-switch/codex-glm/launcher" "$@"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 보안 설계
|
|
132
|
+
|
|
133
|
+
- 토큰/API 키는 rc 파일이나 PATH 스크립트에 쓰지 않습니다.
|
|
134
|
+
- custom provider secret은 해당 프로필의 `.env`에만 저장하며 권한은 `0600`입니다.
|
|
135
|
+
- `config.toml`은 secret 값을 직접 저장하지 않고 `env_key` 또는 `env_http_headers`로
|
|
136
|
+
env var 이름만 참조합니다.
|
|
137
|
+
- 권한/auto-review preset은 `approval_policy`, `sandbox_mode`, `approvals_reviewer` 같은
|
|
138
|
+
Codex 설정 키로만 기록합니다.
|
|
139
|
+
- 내부 런처는 `.env`를 source한 뒤 `CODEX_HOME`을 export하고 `codex`를 실행합니다.
|
|
140
|
+
- 중앙 `profiles.json`에는 재구성용 메타데이터만 저장하고 비밀은 저장하지 않습니다.
|
|
141
|
+
- rc 파일을 수정하기 전에 항상 백업(`<rc>.codex-switch.bak`)을 만듭니다.
|
|
142
|
+
|
|
143
|
+
## 요구 사항
|
|
144
|
+
|
|
145
|
+
- Node.js **18+**
|
|
146
|
+
- **macOS / Linux** (Windows/PowerShell은 현재 범위 외)
|
|
147
|
+
- 셸: **zsh / bash / fish**
|
|
148
|
+
- Codex CLI (`codex`) 설치
|
|
149
|
+
|
|
150
|
+
custom provider는 Codex의 custom model provider 설정을 사용합니다. base URL은 OpenAI
|
|
151
|
+
호환 엔드포인트(예: OpenRouter `https://openrouter.ai/api/v1`)를 넣으면 되고, wire
|
|
152
|
+
프로토콜 기본값은 `chat`(Chat Completions)입니다. OpenAI Responses 호환 게이트웨이를
|
|
153
|
+
쓸 때만 `responses`를 선택하세요.
|
|
154
|
+
|
|
155
|
+
## 탭 자동완성
|
|
156
|
+
|
|
157
|
+
`alias` 런처를 설치하면, 생성되는 마커 블록에 셸별 completion 연결도 함께 들어갑니다.
|
|
158
|
+
이미 Codex 자체 completion(`codex completion <shell>`)을 설치해 두었다면 `codex-or <TAB>`
|
|
159
|
+
처럼 별칭에서도 Codex 서브커맨드가 그대로 완성됩니다.
|
|
160
|
+
|
|
161
|
+
| 셸 | 주입되는 줄 |
|
|
162
|
+
| ---- | ----------------------------------------------------------------- |
|
|
163
|
+
| zsh | `(( $+functions[compdef] )) && compdef <alias>=codex 2>/dev/null` |
|
|
164
|
+
| bash | `type _codex &>/dev/null && complete -F _codex <alias>` |
|
|
165
|
+
| fish | `complete -c <alias> -w codex` |
|
|
166
|
+
|
|
167
|
+
Codex completion이 설치돼 있지 않으면 이 줄들은 셸 시작 시 조용히 무시됩니다(에러 없음).
|
|
168
|
+
`script` 런처만 설치한 경우에는 rc를 건드리지 않으므로 completion도 연결되지 않습니다.
|
|
169
|
+
|
|
170
|
+
## 개발
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
npm install
|
|
174
|
+
npm run build
|
|
175
|
+
npm test
|
|
176
|
+
npm run lint
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 라이선스
|
|
180
|
+
|
|
181
|
+
MIT
|