codex-profile 0.2.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 ADDED
@@ -0,0 +1,77 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project follows semantic versioning for tagged releases.
7
+
8
+ ## Unreleased
9
+
10
+ ### Added
11
+
12
+ - npm package metadata for installing from GitHub and publishing the
13
+ `codex-profile` package to the public npm registry.
14
+
15
+ ### Tests
16
+
17
+ - Added npm package installation coverage.
18
+
19
+ ## 0.2.0 - 2026-05-21
20
+
21
+ ### Added
22
+
23
+ - `init` command for explicit profile home creation.
24
+ - `remove` command with profile-name confirmation and `--yes` automation mode.
25
+ - `logs` command for printing, tailing, or locating profile-local desktop logs.
26
+ - `clone-config` command for copying known non-secret config files between
27
+ profiles without copying auth, sessions, plugins, logs, or caches.
28
+ - `status --json` and `doctor --json` for script-friendly diagnostics.
29
+ - `completions` command for Bash, Zsh, and Fish completion generation.
30
+ - `list` command for read-only initialized profile discovery.
31
+ - `version` and `--version` output.
32
+ - `upgrade` command for source-style self-updates from the project git
33
+ repository, including `--dry-run`, `--prefix`, `--ref`, unversioned-candidate
34
+ refusal, older-version refusal, and branch, tag, or commit-SHA refs.
35
+
36
+ ### Changed
37
+
38
+ - Profile path mapping now treats only `default` as special. Every other valid
39
+ name, including `dev`, `main`, and `edu`, maps directly to
40
+ `.codex-<profile>`.
41
+ - All-profile `status` now skips invalid `.codex-*` directory names during
42
+ discovery.
43
+ - `doctor` now accepts options and can emit machine-readable output.
44
+
45
+ ### Tests
46
+
47
+ - Added coverage for CLI/login argument pass-through, invalid profile names,
48
+ direct profile-name path mapping, list output, version output, hardened
49
+ status discovery, JSON diagnostics, profile lifecycle commands, log
50
+ inspection, completion generation, source upgrades, dirty upgrade checkout
51
+ protection, commit-SHA refs, unversioned-candidate refusal, older-version
52
+ refusal, and safe config cloning.
53
+
54
+ ## 0.1.1 - 2026-04-25
55
+
56
+ ### Fixed
57
+
58
+ - Desktop app switching now waits for both the main Codex app process and the
59
+ bundled Codex app-server process to stop before launching a new profile.
60
+ - Profile directory permission setup now fails loudly if private permissions
61
+ cannot be applied.
62
+ - `status` no longer creates missing profile directories.
63
+ - `status` now propagates unexpected Codex CLI failures while still treating
64
+ "Not logged in" as a normal status result.
65
+
66
+ ## 0.1.0 - 2026-04-25
67
+
68
+ ### Added
69
+
70
+ - Initial `codex-profile` CLI.
71
+ - Profile-aware commands for Codex CLI, Codex Desktop, login, status, path, and
72
+ doctor workflows.
73
+ - macOS and Ubuntu CI smoke tests.
74
+ - Profile-local desktop log handling.
75
+ - Public README with installation, usage, FAQ, and security boundary sections.
76
+ - Contribution and security documentation.
77
+ - GitHub issue and pull request templates.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chai Pin Zheng
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,476 @@
1
+ # codex-profiles
2
+
3
+ [![CI](https://github.com/Ducksss/codex-profiles/actions/workflows/ci.yml/badge.svg)](https://github.com/Ducksss/codex-profiles/actions/workflows/ci.yml)
4
+ [![Latest release](https://img.shields.io/github/v/release/Ducksss/codex-profiles?sort=semver)](https://github.com/Ducksss/codex-profiles/releases)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+ [![Shell: Bash](https://img.shields.io/badge/shell-bash-4EAA25.svg)](bin/codex-profile)
7
+ [![Platform: macOS + Linux](https://img.shields.io/badge/platform-macOS%20%2B%20Linux-lightgrey.svg)](#platform-support)
8
+
9
+ Switch Codex CLI and Desktop accounts with isolated `CODEX_HOME` profiles
10
+ instead of copying `auth.json` token files around.
11
+
12
+ `codex-profiles` is a small Bash wrapper around Codex's `CODEX_HOME` support.
13
+ Each profile gets its own Codex home directory, so auth, settings, sessions,
14
+ connectors, plugins, caches, logs, and local state stay separated while the
15
+ wrapper launches Codex CLI or Codex Desktop with the selected profile.
16
+
17
+ ```sh
18
+ codex-profile cli personal
19
+ codex-profile cli work exec "review this repo"
20
+ codex-profile app edu
21
+ ```
22
+
23
+ ## Why It Exists
24
+
25
+ Codex already supports custom state directories through `CODEX_HOME`:
26
+
27
+ ```sh
28
+ CODEX_HOME="$HOME/.codex-personal" codex
29
+ CODEX_HOME="$HOME/.codex-work" codex exec "review this repo"
30
+ CODEX_HOME="$HOME/.codex-edu" /Applications/Codex.app/Contents/MacOS/Codex
31
+ ```
32
+
33
+ That is the right boundary, but it is awkward to type and easy to forget.
34
+ Copying `auth.json` is worse: it moves tokens while leaving sessions, config,
35
+ connector state, plugins, caches, and logs shared.
36
+
37
+ `codex-profile` gives the clean boundary a short command.
38
+
39
+ ## Why Not Swap Auth Files?
40
+
41
+ Auth-file switchers only move `auth.json`. That can change who Codex logs in as,
42
+ but it still leaves unrelated account state in the same `CODEX_HOME`: sessions,
43
+ config, plugins, connector and app caches, logs, and other local files.
44
+
45
+ `codex-profile` switches the whole Codex home instead. The boundary is the same
46
+ one Codex already supports, just named and wrapped in a CLI:
47
+
48
+ ```text
49
+ auth.json switcher -> one shared CODEX_HOME with swapped tokens
50
+ codex-profile <profile> -> one CODEX_HOME per profile
51
+ ```
52
+
53
+ That makes it a better fit for work, personal, education, and client accounts
54
+ where local Codex state should not bleed between contexts.
55
+
56
+ ## Demo
57
+
58
+ ![codex-profiles promo frame](media/codex-profiles-saas-promo-frame.png)
59
+
60
+ [Watch the short reveal video](media/codex-profiles-apple-reveal.mp4)
61
+
62
+ ## Highlights
63
+
64
+ - Isolated Codex homes per profile.
65
+ - CLI and Codex Desktop launch support.
66
+ - No token copying, parsing, printing, or migration.
67
+ - Read-only `list`, `status`, and `doctor` commands for diagnostics.
68
+ - JSON output for automation.
69
+ - Profile lifecycle commands: `init` and confirmed `remove`.
70
+ - Profile-local desktop logs with private permissions.
71
+ - Safe config cloning for known non-secret config files.
72
+ - Bash, Zsh, and Fish completion generators.
73
+ - Source-style self-upgrade with dry-run preview.
74
+ - No third-party runtime dependencies.
75
+ - Tested on macOS and Ubuntu.
76
+
77
+ ## Install
78
+
79
+ With npm from this GitHub repo:
80
+
81
+ ```sh
82
+ npm install -g github:Ducksss/codex-profiles
83
+ ```
84
+
85
+ With Homebrew:
86
+
87
+ ```sh
88
+ brew install Ducksss/tap/codex-profile
89
+ ```
90
+
91
+ From source:
92
+
93
+ ```sh
94
+ git clone https://github.com/Ducksss/codex-profiles.git
95
+ cd codex-profiles
96
+ make install
97
+ ```
98
+
99
+ Source installs copy `bin/codex-profile` to
100
+ `~/.local/bin/codex-profile`. Make sure `~/.local/bin` is on your `PATH`.
101
+
102
+ Verify the install:
103
+
104
+ ```sh
105
+ codex-profile doctor
106
+ ```
107
+
108
+ The package is also prepared for the public npm registry as `codex-profile`.
109
+ After the registry package is published, npm users can install it with:
110
+
111
+ ```sh
112
+ npm install -g codex-profile
113
+ ```
114
+
115
+ ## Quick Start
116
+
117
+ Create and log in to each profile once:
118
+
119
+ ```sh
120
+ codex-profile init personal
121
+ codex-profile init work
122
+ codex-profile login personal
123
+ codex-profile login work
124
+ ```
125
+
126
+ Run Codex CLI with a profile:
127
+
128
+ ```sh
129
+ codex-profile cli personal
130
+ codex-profile cli work exec "run tests and summarize failures"
131
+ ```
132
+
133
+ Run Codex Desktop with a profile on macOS:
134
+
135
+ ```sh
136
+ codex-profile app personal ~/Dev/my-project
137
+ codex-profile app work
138
+ ```
139
+
140
+ Check what exists and what is logged in:
141
+
142
+ ```sh
143
+ codex-profile list
144
+ codex-profile status
145
+ codex-profile doctor
146
+ ```
147
+
148
+ ## How Profiles Map To Disk
149
+
150
+ Only `default` is special:
151
+
152
+ ```text
153
+ default -> ~/.codex
154
+ <profile> -> ~/.codex-<profile>
155
+ ```
156
+
157
+ Examples:
158
+
159
+ ```text
160
+ personal -> ~/.codex-personal
161
+ work -> ~/.codex-work
162
+ dev -> ~/.codex-dev
163
+ main -> ~/.codex-main
164
+ edu -> ~/.codex-edu
165
+ ```
166
+
167
+ Profile names must start with a letter or number, then may contain letters,
168
+ numbers, dots, dashes, or underscores. You can inspect a path without launching
169
+ Codex:
170
+
171
+ ```sh
172
+ codex-profile path personal
173
+ ```
174
+
175
+ ## Common Workflows
176
+
177
+ ### Manage Profiles
178
+
179
+ Create a profile home without launching Codex:
180
+
181
+ ```sh
182
+ codex-profile init client-a
183
+ ```
184
+
185
+ Remove a profile home interactively:
186
+
187
+ ```sh
188
+ codex-profile remove client-a
189
+ ```
190
+
191
+ Use `--yes` for scripts:
192
+
193
+ ```sh
194
+ codex-profile remove client-a --yes
195
+ ```
196
+
197
+ Use `default` explicitly if you intend to remove `~/.codex`. Every other valid
198
+ name removes only its own `.codex-<profile>` directory.
199
+
200
+ ### Inspect Status
201
+
202
+ Human-readable output:
203
+
204
+ ```sh
205
+ codex-profile status
206
+ codex-profile status personal
207
+ codex-profile doctor
208
+ ```
209
+
210
+ Machine-readable output:
211
+
212
+ ```sh
213
+ codex-profile status --json
214
+ codex-profile doctor --json
215
+ ```
216
+
217
+ `status` and `list` are read-only. They report missing profiles instead of
218
+ creating directories for typos.
219
+
220
+ ### Read Desktop Logs
221
+
222
+ Desktop logs live inside the selected profile home:
223
+
224
+ ```sh
225
+ codex-profile logs personal --path
226
+ codex-profile logs personal
227
+ codex-profile logs personal --tail 100
228
+ ```
229
+
230
+ ### Clone Safe Config
231
+
232
+ Copy known non-secret config files from one profile to another:
233
+
234
+ ```sh
235
+ codex-profile clone-config personal work
236
+ codex-profile clone-config personal work --force
237
+ ```
238
+
239
+ Only these root-level files are considered:
240
+
241
+ ```text
242
+ config.toml
243
+ AGENTS.md
244
+ instructions.md
245
+ custom-instructions.md
246
+ ```
247
+
248
+ `clone-config` never copies `auth.json`, sessions, plugins, logs, caches, or
249
+ directories. It also refuses files with sensitive-looking key names such as
250
+ `token`, `secret`, `password`, `credential`, or `api_key`.
251
+
252
+ ### Upgrade Source Installs
253
+
254
+ Preview the upgrade:
255
+
256
+ ```sh
257
+ codex-profile upgrade --dry-run
258
+ ```
259
+
260
+ Install from the default project repo and branch:
261
+
262
+ ```sh
263
+ codex-profile upgrade
264
+ ```
265
+
266
+ By default, `upgrade` fetches `main` from
267
+ `https://github.com/Ducksss/codex-profiles.git` into
268
+ `~/.cache/codex-profile/source`, then runs `make install` with
269
+ `PREFIX=~/.local`.
270
+
271
+ Use a different install prefix or source ref:
272
+
273
+ ```sh
274
+ codex-profile upgrade --prefix /usr/local
275
+ codex-profile upgrade --ref v0.2.0
276
+ codex-profile upgrade --ref <commit-sha>
277
+ ```
278
+
279
+ Upgrade refuses to install a candidate with no declared version, or a candidate
280
+ whose declared version is older than the running `codex-profile`.
281
+
282
+ If you installed with Homebrew and do not want a source-style
283
+ `~/.local/bin/codex-profile`, use Homebrew instead:
284
+
285
+ ```sh
286
+ brew upgrade Ducksss/tap/codex-profile
287
+ ```
288
+
289
+ ## Shell Completions
290
+
291
+ Generate completions for Bash, Zsh, or Fish:
292
+
293
+ ```sh
294
+ codex-profile completions bash
295
+ codex-profile completions zsh
296
+ codex-profile completions fish
297
+ ```
298
+
299
+ Bash example:
300
+
301
+ ```sh
302
+ mkdir -p ~/.local/share/bash-completion/completions
303
+ codex-profile completions bash > ~/.local/share/bash-completion/completions/codex-profile
304
+ ```
305
+
306
+ Zsh example:
307
+
308
+ ```sh
309
+ mkdir -p ~/.zfunc
310
+ codex-profile completions zsh > ~/.zfunc/_codex-profile
311
+ ```
312
+
313
+ Add the directory to `fpath` in `~/.zshrc` before `compinit`:
314
+
315
+ ```sh
316
+ fpath=(~/.zfunc $fpath)
317
+ autoload -Uz compinit
318
+ compinit
319
+ ```
320
+
321
+ ## Aliases
322
+
323
+ Aliases are optional, but useful for accounts you use every day:
324
+
325
+ ```sh
326
+ alias codex-personal='codex-profile cli personal'
327
+ alias codex-work='codex-profile cli work'
328
+ alias codex-app-work='codex-profile app work'
329
+ ```
330
+
331
+ ## Command Reference
332
+
333
+ ```text
334
+ codex-profile app <profile> [workspace]
335
+ codex-profile cli <profile> [codex-args...]
336
+ codex-profile login <profile> [codex-login-args...]
337
+ codex-profile init <profile>
338
+ codex-profile remove <profile> [--yes]
339
+ codex-profile status [profile]
340
+ codex-profile status --json [profile]
341
+ codex-profile path <profile>
342
+ codex-profile logs <profile> [--path|--tail [lines]]
343
+ codex-profile clone-config <source-profile> <target-profile> [--force]
344
+ codex-profile list
345
+ codex-profile doctor [--json]
346
+ codex-profile completions <bash|zsh|fish>
347
+ codex-profile upgrade [--dry-run] [--prefix <path>] [--ref <git-ref>]
348
+ codex-profile version
349
+ codex-profile --version
350
+ ```
351
+
352
+ ## Environment Overrides
353
+
354
+ ```text
355
+ CODEX_APP Override Codex.app path
356
+ CODEX_APP_BIN Override Codex Desktop binary path
357
+ CODEX_CLI Override Codex CLI binary path
358
+ CODEX_PROFILE_UPGRADE_REPO Override upgrade repository
359
+ CODEX_PROFILE_UPGRADE_REF Override upgrade git ref
360
+ CODEX_PROFILE_UPGRADE_CACHE Override upgrade cache checkout
361
+ CODEX_PROFILE_UPGRADE_PREFIX Override upgrade install prefix
362
+ ```
363
+
364
+ Examples:
365
+
366
+ ```sh
367
+ CODEX_CLI=/path/to/codex codex-profile cli personal
368
+ CODEX_PROFILE_UPGRADE_REF=v0.2.0 codex-profile upgrade --dry-run
369
+ ```
370
+
371
+ ## Platform Support
372
+
373
+ CLI-oriented commands are Bash-based and tested on macOS and Ubuntu/Linux:
374
+
375
+ ```text
376
+ cli login init remove status path logs clone-config list doctor completions upgrade
377
+ ```
378
+
379
+ The `app` command is macOS-only because it launches `Codex.app` and uses macOS
380
+ app-control tooling to quit the running desktop app before relaunching it with a
381
+ different `CODEX_HOME`.
382
+
383
+ ## Desktop App Notes
384
+
385
+ Codex Desktop should run one profile at a time. `codex-profile app <profile>`
386
+ asks the running Codex app to quit, waits for it to close, then launches the app
387
+ with the selected `CODEX_HOME`.
388
+
389
+ For predictable account switching, launch Codex Desktop through `codex-profile`
390
+ instead of Dock or Spotlight.
391
+
392
+ ## Security Model
393
+
394
+ `codex-profile` does one security-sensitive thing: it sets `CODEX_HOME` before
395
+ running Codex. It does not read, copy, print, parse, or migrate auth tokens.
396
+
397
+ `clone-config` uses a small allowlist and refuses sensitive-looking config
398
+ files. It does not inspect or rewrite Codex auth files.
399
+
400
+ `upgrade` fetches and installs code from the configured git repository. The
401
+ default repository is this project. `--dry-run` prints the source ref, cache
402
+ path, and install prefix before anything changes. Do not point upgrade at a
403
+ repository you do not trust.
404
+
405
+ Separate Codex homes are cleaner than swapping `auth.json`, but they are not
406
+ full OS-level isolation. Your operating system user still shares SSH keys,
407
+ GitHub CLI auth, browser cookies, cloud CLI credentials, npm state, and other
408
+ external credentials.
409
+
410
+ For strict work/personal separation, use separate OS users.
411
+
412
+ ## FAQ
413
+
414
+ ### Is this an official OpenAI project?
415
+
416
+ No. This project is community-maintained and is not affiliated with OpenAI.
417
+
418
+ ### Is this the same as Codex's built-in config profiles?
419
+
420
+ No. Codex config profiles switch settings inside one `CODEX_HOME`, such as
421
+ model, approval policy, sandboxing, and hooks.
422
+
423
+ `codex-profiles` switches `CODEX_HOME` itself, so each account can have separate
424
+ auth, config, sessions, plugins, logs, caches, and local Codex state.
425
+
426
+ ### Does it copy my tokens?
427
+
428
+ No. It does not read or copy `auth.json`. Codex itself creates and uses auth
429
+ inside the selected `CODEX_HOME`.
430
+
431
+ ### Why not just swap `auth.json`?
432
+
433
+ Swapping only `auth.json` leaves other Codex state shared: sessions, config,
434
+ plugins, logs, connector/app caches, and more. Separate `CODEX_HOME` directories
435
+ are a cleaner boundary.
436
+
437
+ ### Can I run two desktop profiles at once?
438
+
439
+ Not safely. Codex Desktop is treated as one active profile at a time. The `app`
440
+ command quits the current Codex app before launching the selected profile.
441
+
442
+ ### Does this isolate external tools too?
443
+
444
+ No. Your OS user still shares SSH keys, GitHub CLI auth, cloud CLIs, browser
445
+ state, and other non-Codex credentials.
446
+
447
+ ## Development
448
+
449
+ Run the test suite:
450
+
451
+ ```sh
452
+ make test
453
+ ```
454
+
455
+ Run ShellCheck:
456
+
457
+ ```sh
458
+ make lint
459
+ ```
460
+
461
+ The test suite covers Bash syntax, profile path mapping, install smoke tests,
462
+ CLI/login pass-through, list/version output, npm package installation, source
463
+ upgrades, fresh-profile status checks, hardened status discovery, private
464
+ desktop log placement, and missing-CLI doctor output.
465
+
466
+ ## Contributing
467
+
468
+ Issues and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for
469
+ local setup, testing, and contribution guidelines.
470
+
471
+ Questions, workflow ideas, and launch feedback are welcome in the
472
+ [Codex profile workflows discussion](https://github.com/Ducksss/codex-profiles/discussions/1).
473
+
474
+ ## License
475
+
476
+ MIT
package/SECURITY.md ADDED
@@ -0,0 +1,33 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ `codex-profiles` is a small script project. Security fixes are made on `main`
6
+ and included in the next tagged release.
7
+
8
+ ## Reporting a Vulnerability
9
+
10
+ Please do not open a public issue for vulnerabilities that expose credentials,
11
+ tokens, or private account data.
12
+
13
+ Report privately through GitHub's private vulnerability reporting if available,
14
+ or contact the maintainer through the GitHub profile linked from this repository.
15
+
16
+ Include:
17
+
18
+ - A clear description of the issue.
19
+ - Steps to reproduce.
20
+ - Impact.
21
+ - A suggested fix, if you have one.
22
+
23
+ Do not include real `auth.json` contents, OpenAI tokens, GitHub tokens, OAuth
24
+ codes, connector credentials, or private logs.
25
+
26
+ ## Project Security Boundaries
27
+
28
+ `codex-profiles` does not read or copy Codex auth tokens. It only sets
29
+ `CODEX_HOME` before launching Codex.
30
+
31
+ It does not isolate non-Codex credentials such as SSH keys, GitHub CLI auth,
32
+ cloud CLI credentials, browser cookies, or OS keychain items. Use separate OS
33
+ users for stronger isolation.