codex-configure 0.2.0__tar.gz

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.
Files changed (29) hide show
  1. codex_configure-0.2.0/LICENSE +201 -0
  2. codex_configure-0.2.0/NOTICE +12 -0
  3. codex_configure-0.2.0/PKG-INFO +201 -0
  4. codex_configure-0.2.0/README.md +178 -0
  5. codex_configure-0.2.0/codex_configure.egg-info/PKG-INFO +201 -0
  6. codex_configure-0.2.0/codex_configure.egg-info/SOURCES.txt +27 -0
  7. codex_configure-0.2.0/codex_configure.egg-info/dependency_links.txt +1 -0
  8. codex_configure-0.2.0/codex_configure.egg-info/entry_points.txt +2 -0
  9. codex_configure-0.2.0/codex_configure.egg-info/requires.txt +1 -0
  10. codex_configure-0.2.0/codex_configure.egg-info/top_level.txt +2 -0
  11. codex_configure-0.2.0/pyproject.toml +41 -0
  12. codex_configure-0.2.0/setup.cfg +4 -0
  13. codex_configure-0.2.0/src/codex-configure/__init__.py +3 -0
  14. codex_configure-0.2.0/src/codex-configure/__main__.py +4 -0
  15. codex_configure-0.2.0/src/codex-configure/catalog.py +211 -0
  16. codex_configure-0.2.0/src/codex-configure/cli.py +725 -0
  17. codex_configure-0.2.0/src/codex-configure/errors.py +2 -0
  18. codex_configure-0.2.0/src/codex-configure/patcher.py +636 -0
  19. codex_configure-0.2.0/src/codex-configure/providers.py +522 -0
  20. codex_configure-0.2.0/src/codex-configure/runtime.py +951 -0
  21. codex_configure-0.2.0/src/core-provider-model-picker/README.md +90 -0
  22. codex_configure-0.2.0/src/core-provider-model-picker/__init__.py +1 -0
  23. codex_configure-0.2.0/src/core-provider-model-picker/app_server_canary.py +474 -0
  24. codex_configure-0.2.0/src/core-provider-model-picker/codex-provider-model-picker.patch +2884 -0
  25. codex_configure-0.2.0/src/core-provider-model-picker/prepare.sh +127 -0
  26. codex_configure-0.2.0/src/core-provider-model-picker/test_canary.py +126 -0
  27. codex_configure-0.2.0/src/core-provider-model-picker/upstream-pin.env +5 -0
  28. codex_configure-0.2.0/tests/test_cli.py +710 -0
  29. codex_configure-0.2.0/tests/test_patcher.py +75 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,12 @@
1
+ codex-configure
2
+ Copyright 2026 Christopher Brooks
3
+
4
+ This product includes a patch derived from OpenAI Codex.
5
+
6
+ OpenAI Codex
7
+ Copyright 2025 OpenAI
8
+
9
+ OpenAI Codex includes code derived from Ratatui
10
+ (https://github.com/ratatui/ratatui), licensed under the MIT License.
11
+ Copyright (c) 2016-2022 Florian Dehau
12
+ Copyright (c) 2023-2025 The Ratatui Developers
@@ -0,0 +1,201 @@
1
+ Metadata-Version: 2.4
2
+ Name: codex-configure
3
+ Version: 0.2.0
4
+ Summary: Configure stock and dynamic Codex model-provider profiles.
5
+ Author: Christopher Brooks
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/cab938/codex-configure
8
+ Project-URL: Issues, https://github.com/cab938/codex-configure/issues
9
+ Project-URL: Repository, https://github.com/cab938/codex-configure.git
10
+ Keywords: codex,configuration,model providers
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ License-File: NOTICE
21
+ Requires-Dist: tomlkit<1,>=0.13
22
+ Dynamic: license-file
23
+
24
+ # codex-configure
25
+
26
+ `codex-configure` lets one Codex home use OpenAI and one or more named U-M GPT Toolkit services. Each U-M service has its own API key, billing allocation, and selected model catalog.
27
+
28
+ There are two ways to use it:
29
+
30
+ - **Per-launch Profiles** works with the stock Codex CLI and stock desktop app on macOS and Linux. Choose one provider when you launch.
31
+ - **Dynamic Picker** uses a patched Codex Core on Linux. OpenAI and every configured U-M profile appear together in the desktop and CLI model picker.
32
+
33
+ Both modes preserve the existing OpenAI sign-in and share the same tasks, settings, skills, and plugins in `CODEX_HOME`.
34
+
35
+ > **Important:** Every `codex-configure run` command writes the selected active configuration to `$CODEX_HOME/config.toml` before launching Codex. This is a persistent change to the file, not a process-local override: it remains after Codex exits until another `codex-configure run` or `codex-configure restore` replaces it. Initialization preserves the original configuration, and switches are transactional and recoverable, but this tool does modify Codex's `config.toml`.
36
+
37
+ ## Install
38
+
39
+ All users need:
40
+
41
+ - Python 3.11 or newer;
42
+ - [pipx](https://pipx.pypa.io/latest/how-to/install-pipx.html);
43
+ - the [Codex CLI](https://learn.chatgpt.com/docs/codex/cli), signed in with ChatGPT; and
44
+ - the ChatGPT desktop app, signed in with the same account.
45
+
46
+ Linux users can follow the [ChatGPT Linux installation guide](https://learn.chatgpt.com/docs/linux/linux-app). macOS users can install the ChatGPT app from the [OpenAI desktop page](https://openai.com/chatgpt/desktop/). Fully quit both clients before changing an active profile.
47
+
48
+ Install `codex-configure` from PyPI:
49
+
50
+ ```bash
51
+ pipx install codex-configure
52
+ ```
53
+
54
+ `pipx` creates an isolated environment and exposes the `codex-configure` command. If the command is not found after installation, run `pipx ensurepath` and open a new terminal. To install a source checkout instead, run `pipx install .` from the repository root.
55
+
56
+ On macOS, install Python and pipx first if they are unavailable. Homebrew users can run `brew install python pipx`. Dynamic Picker also requires Git and Rust as described below.
57
+
58
+ ## Initialize Providers
59
+
60
+ Run setup once for each U-M Toolkit key you want to use:
61
+
62
+ ```bash
63
+ codex-configure init
64
+ ```
65
+
66
+ Setup shows the stock and existing providers, then offers **New U-M GPT Toolkit Service**. It asks for:
67
+
68
+ - a short name containing lowercase letters, digits, hyphens, or underscores, such as `teaching` or `research-2026`;
69
+ - a key from [U-M GPT Toolkit](https://toolkit.umgpt.umich.edu/); and
70
+ - the endpoint models to expose.
71
+
72
+ The model selector shows everything advertised for that key. Models for which the installed Codex build has metadata are selectable; other entries remain visible but disabled. Compatible `gpt-5.6` models are checked by default.
73
+
74
+ Run `init` again to add another service. The short name becomes the profile name, descriptor filename, credential variable prefix, and Dynamic Picker namespace. For example, `teaching` creates `TEACHING_API_KEY` and models such as `teaching::gpt-5.6-terra`.
75
+
76
+ ## Per-launch Profiles
77
+
78
+ Per-launch profiles work on macOS and Linux without changing Codex Core. The provider and target are written as `provider/app`:
79
+
80
+ ```bash
81
+ # Existing OpenAI sign-in, stock Core
82
+ codex-configure run openai/cli
83
+ codex-configure run openai/desktop
84
+
85
+ # A named U-M profile, stock Core
86
+ codex-configure run teaching/cli
87
+ codex-configure run teaching/desktop
88
+ ```
89
+
90
+ Before launching, this mode replaces the active `$CODEX_HOME/config.toml` with a configuration for the selected provider. The change is not automatically undone when the CLI or desktop app exits; it remains active until a later `codex-configure run` selects another configuration or `codex-configure restore` is run. The command prints the profile directory it used and removes any inherited `CODEX_CLI_PATH` so a global shell setting cannot accidentally select the patched Core.
91
+
92
+ Only the selected U-M key is added to that child process. OpenAI launches receive no U-M credentials.
93
+ When returning from Dynamic Picker, a saved `openai::` model is unqualified for stock Core; an external-qualified model is omitted so stock OpenAI can choose its own supported default.
94
+
95
+ On macOS, `codex-configure` launches the executable inside `ChatGPT.app` so the selected environment reaches Codex Core. Set `CODEX_DESKTOP_COMMAND` if the application is installed somewhere unusual. On Linux, the normal command is `chatgpt`; the same override supports another compatible desktop command or VM flags.
96
+
97
+ ## Dynamic Picker
98
+
99
+ Dynamic Picker is a research feature currently supported and tested on Linux only. It keeps the stock desktop renderer and patches the open-source Codex Core used behind it.
100
+
101
+ An agent or developer can install it with this bounded sequence:
102
+
103
+ - Install Rust 1.94 or newer with [rustup](https://rustup.rs/) and make sure `cargo` is on `PATH`. If an older stable toolchain is already installed, run `rustup update stable` first.
104
+ - Run `codex-configure patch`.
105
+ - Wait for the pinned OpenAI Codex source to be cloned, patched, and built under `~/.codex-configure/codex-core/`. The build produces both `codex` and its required `codex-code-mode-host` companion. It uses the pinned repository's checksum-verifying resolver for OpenAI's matching V8 artifacts.
106
+ - Set the exact `export CODEX_CLI_PATH=...` line printed by the command in the shell used to launch Codex.
107
+ - Run `codex-configure run desktop` or `codex-configure run cli`.
108
+
109
+ To place the source checkout elsewhere, pass the destination explicitly:
110
+
111
+ ```bash
112
+ codex-configure patch /absolute/path/to/codex-core
113
+ ```
114
+
115
+ The unqualified `desktop` and `cli` targets are intentionally different from `provider/app`: before launching, they replace `$CODEX_HOME/config.toml` with the shared OpenAI base, load all configured provider credentials, and use the binary at `CODEX_CLI_PATH`. This change to `config.toml` also remains after Codex exits. The desktop child receives `CODEX_CLI_PATH`; the CLI executes that binary directly. Both targets require an executable `codex-code-mode-host` beside the patched binary.
116
+
117
+ The existing picker shows qualified entries such as:
118
+
119
+ ```text
120
+ openai::gpt-5.6-sol
121
+ teaching::gpt-5.6-terra
122
+ research::gpt-5.6-luna
123
+ ```
124
+
125
+ You can change provider/model between turns in one task. The working directory, execution host, permissions, and semantic conversation stay with the task. Provider-private reasoning data is discarded at a provider boundary because another provider cannot safely consume it.
126
+
127
+ The patched Core builds its picker catalog at startup from:
128
+
129
+ - the current built-in OpenAI catalog; and
130
+ - each valid `$CODEX_HOME/codex-configure/providers.d/*.toml` descriptor and its required JSON catalog under `$CODEX_HOME/codex-configure/catalogs/`.
131
+
132
+ A missing or malformed external catalog is warned about and skipped. The patched Core does not query arbitrary provider `/models` endpoints or invent missing Codex metadata.
133
+
134
+ `CODEX_CLI_PATH` is an observed desktop integration hook, not a documented stable OpenAI interface. Re-run the documented acceptance checks after updating the desktop app or refreshing the pinned Core patch.
135
+
136
+ ## Files And Safety
137
+
138
+ The default Codex home is `~/.codex`. A custom `CODEX_HOME` is respected without changing the layout:
139
+
140
+ ```text
141
+ $CODEX_HOME/
142
+ |-- auth.json # owned by Codex; never changed here
143
+ |-- config.toml # active materialized configuration
144
+ `-- codex-configure/
145
+ |-- .env # provider keys, mode 0600
146
+ |-- providers.d/<shortname>.toml # provider configuration, no secrets
147
+ |-- catalogs/<shortname>.json # selected Codex model metadata
148
+ |-- profiles/ # stock-Core launch profiles
149
+ |-- base/ # original and maintained config snapshots
150
+ `-- recovery/ # last-known-good transaction state
151
+ ```
152
+
153
+ On first initialization, the existing `config.toml` is preserved before any profile is activated. Normal `run` commands then write the selected materialized configuration to the active `config.toml`; atomic switching and recovery protect that operation, but do not make it temporary. `codex-configure` never replaces `auth.json`, recursively backs up `CODEX_HOME`, or copies credentials into descriptors, catalogs, profiles, diagnostics, or recovery files.
154
+
155
+ The `.env` file is created with mode `0600`, and tool-owned directories use mode `0700`. An environment variable with the expected name can override a stored key for one launch.
156
+
157
+ ## Check And Recover
158
+
159
+ Inspect the managed configuration without changing it:
160
+
161
+ ```bash
162
+ codex-configure doctor
163
+ ```
164
+
165
+ Restore the maintained OpenAI base, or the immutable first-run snapshot:
166
+
167
+ ```bash
168
+ codex-configure restore
169
+ codex-configure restore --original
170
+ ```
171
+
172
+ Switching and restore commands refuse to proceed while a known Codex or ChatGPT process is running. They also reject unexpected outside changes to routing fields instead of overwriting them. Unrelated settings written by Codex are retained.
173
+
174
+ ## Troubleshooting
175
+
176
+ If the CLI says setup is missing, run `codex-configure init` with the intended `CODEX_HOME`. Copying a complete managed `$CODEX_HOME/codex-configure/` layout, including its base/state files and valid provider catalogs, also counts as initialized after validation.
177
+
178
+ If the desktop command cannot be found, set an explicit launch command:
179
+
180
+ ```bash
181
+ CODEX_DESKTOP_COMMAND=/path/to/chatgpt codex-configure run openai/desktop
182
+ ```
183
+
184
+ Some Linux virtual machines need Chromium software rendering:
185
+
186
+ ```bash
187
+ CODEX_DESKTOP_COMMAND='chatgpt --use-angle=swiftshader' codex-configure run desktop
188
+ ```
189
+
190
+ If a credential permission check fails, repair it with:
191
+
192
+ ```bash
193
+ chmod 700 "${CODEX_HOME:-$HOME/.codex}/codex-configure"
194
+ chmod 600 "${CODEX_HOME:-$HOME/.codex}/codex-configure/.env"
195
+ ```
196
+
197
+ Architecture, patch maintenance, and manual acceptance details are in [docs/architecture.md](https://github.com/cab938/codex-configure/blob/main/docs/architecture.md). U-M model discovery is not an entitlement guarantee: a provider may still reject an advertised model because of deployment access, account policy, or budget.
198
+
199
+ ## License
200
+
201
+ Licensed under the Apache License, Version 2.0. See [LICENSE](https://github.com/cab938/codex-configure/blob/main/LICENSE) and [NOTICE](https://github.com/cab938/codex-configure/blob/main/NOTICE).
@@ -0,0 +1,178 @@
1
+ # codex-configure
2
+
3
+ `codex-configure` lets one Codex home use OpenAI and one or more named U-M GPT Toolkit services. Each U-M service has its own API key, billing allocation, and selected model catalog.
4
+
5
+ There are two ways to use it:
6
+
7
+ - **Per-launch Profiles** works with the stock Codex CLI and stock desktop app on macOS and Linux. Choose one provider when you launch.
8
+ - **Dynamic Picker** uses a patched Codex Core on Linux. OpenAI and every configured U-M profile appear together in the desktop and CLI model picker.
9
+
10
+ Both modes preserve the existing OpenAI sign-in and share the same tasks, settings, skills, and plugins in `CODEX_HOME`.
11
+
12
+ > **Important:** Every `codex-configure run` command writes the selected active configuration to `$CODEX_HOME/config.toml` before launching Codex. This is a persistent change to the file, not a process-local override: it remains after Codex exits until another `codex-configure run` or `codex-configure restore` replaces it. Initialization preserves the original configuration, and switches are transactional and recoverable, but this tool does modify Codex's `config.toml`.
13
+
14
+ ## Install
15
+
16
+ All users need:
17
+
18
+ - Python 3.11 or newer;
19
+ - [pipx](https://pipx.pypa.io/latest/how-to/install-pipx.html);
20
+ - the [Codex CLI](https://learn.chatgpt.com/docs/codex/cli), signed in with ChatGPT; and
21
+ - the ChatGPT desktop app, signed in with the same account.
22
+
23
+ Linux users can follow the [ChatGPT Linux installation guide](https://learn.chatgpt.com/docs/linux/linux-app). macOS users can install the ChatGPT app from the [OpenAI desktop page](https://openai.com/chatgpt/desktop/). Fully quit both clients before changing an active profile.
24
+
25
+ Install `codex-configure` from PyPI:
26
+
27
+ ```bash
28
+ pipx install codex-configure
29
+ ```
30
+
31
+ `pipx` creates an isolated environment and exposes the `codex-configure` command. If the command is not found after installation, run `pipx ensurepath` and open a new terminal. To install a source checkout instead, run `pipx install .` from the repository root.
32
+
33
+ On macOS, install Python and pipx first if they are unavailable. Homebrew users can run `brew install python pipx`. Dynamic Picker also requires Git and Rust as described below.
34
+
35
+ ## Initialize Providers
36
+
37
+ Run setup once for each U-M Toolkit key you want to use:
38
+
39
+ ```bash
40
+ codex-configure init
41
+ ```
42
+
43
+ Setup shows the stock and existing providers, then offers **New U-M GPT Toolkit Service**. It asks for:
44
+
45
+ - a short name containing lowercase letters, digits, hyphens, or underscores, such as `teaching` or `research-2026`;
46
+ - a key from [U-M GPT Toolkit](https://toolkit.umgpt.umich.edu/); and
47
+ - the endpoint models to expose.
48
+
49
+ The model selector shows everything advertised for that key. Models for which the installed Codex build has metadata are selectable; other entries remain visible but disabled. Compatible `gpt-5.6` models are checked by default.
50
+
51
+ Run `init` again to add another service. The short name becomes the profile name, descriptor filename, credential variable prefix, and Dynamic Picker namespace. For example, `teaching` creates `TEACHING_API_KEY` and models such as `teaching::gpt-5.6-terra`.
52
+
53
+ ## Per-launch Profiles
54
+
55
+ Per-launch profiles work on macOS and Linux without changing Codex Core. The provider and target are written as `provider/app`:
56
+
57
+ ```bash
58
+ # Existing OpenAI sign-in, stock Core
59
+ codex-configure run openai/cli
60
+ codex-configure run openai/desktop
61
+
62
+ # A named U-M profile, stock Core
63
+ codex-configure run teaching/cli
64
+ codex-configure run teaching/desktop
65
+ ```
66
+
67
+ Before launching, this mode replaces the active `$CODEX_HOME/config.toml` with a configuration for the selected provider. The change is not automatically undone when the CLI or desktop app exits; it remains active until a later `codex-configure run` selects another configuration or `codex-configure restore` is run. The command prints the profile directory it used and removes any inherited `CODEX_CLI_PATH` so a global shell setting cannot accidentally select the patched Core.
68
+
69
+ Only the selected U-M key is added to that child process. OpenAI launches receive no U-M credentials.
70
+ When returning from Dynamic Picker, a saved `openai::` model is unqualified for stock Core; an external-qualified model is omitted so stock OpenAI can choose its own supported default.
71
+
72
+ On macOS, `codex-configure` launches the executable inside `ChatGPT.app` so the selected environment reaches Codex Core. Set `CODEX_DESKTOP_COMMAND` if the application is installed somewhere unusual. On Linux, the normal command is `chatgpt`; the same override supports another compatible desktop command or VM flags.
73
+
74
+ ## Dynamic Picker
75
+
76
+ Dynamic Picker is a research feature currently supported and tested on Linux only. It keeps the stock desktop renderer and patches the open-source Codex Core used behind it.
77
+
78
+ An agent or developer can install it with this bounded sequence:
79
+
80
+ - Install Rust 1.94 or newer with [rustup](https://rustup.rs/) and make sure `cargo` is on `PATH`. If an older stable toolchain is already installed, run `rustup update stable` first.
81
+ - Run `codex-configure patch`.
82
+ - Wait for the pinned OpenAI Codex source to be cloned, patched, and built under `~/.codex-configure/codex-core/`. The build produces both `codex` and its required `codex-code-mode-host` companion. It uses the pinned repository's checksum-verifying resolver for OpenAI's matching V8 artifacts.
83
+ - Set the exact `export CODEX_CLI_PATH=...` line printed by the command in the shell used to launch Codex.
84
+ - Run `codex-configure run desktop` or `codex-configure run cli`.
85
+
86
+ To place the source checkout elsewhere, pass the destination explicitly:
87
+
88
+ ```bash
89
+ codex-configure patch /absolute/path/to/codex-core
90
+ ```
91
+
92
+ The unqualified `desktop` and `cli` targets are intentionally different from `provider/app`: before launching, they replace `$CODEX_HOME/config.toml` with the shared OpenAI base, load all configured provider credentials, and use the binary at `CODEX_CLI_PATH`. This change to `config.toml` also remains after Codex exits. The desktop child receives `CODEX_CLI_PATH`; the CLI executes that binary directly. Both targets require an executable `codex-code-mode-host` beside the patched binary.
93
+
94
+ The existing picker shows qualified entries such as:
95
+
96
+ ```text
97
+ openai::gpt-5.6-sol
98
+ teaching::gpt-5.6-terra
99
+ research::gpt-5.6-luna
100
+ ```
101
+
102
+ You can change provider/model between turns in one task. The working directory, execution host, permissions, and semantic conversation stay with the task. Provider-private reasoning data is discarded at a provider boundary because another provider cannot safely consume it.
103
+
104
+ The patched Core builds its picker catalog at startup from:
105
+
106
+ - the current built-in OpenAI catalog; and
107
+ - each valid `$CODEX_HOME/codex-configure/providers.d/*.toml` descriptor and its required JSON catalog under `$CODEX_HOME/codex-configure/catalogs/`.
108
+
109
+ A missing or malformed external catalog is warned about and skipped. The patched Core does not query arbitrary provider `/models` endpoints or invent missing Codex metadata.
110
+
111
+ `CODEX_CLI_PATH` is an observed desktop integration hook, not a documented stable OpenAI interface. Re-run the documented acceptance checks after updating the desktop app or refreshing the pinned Core patch.
112
+
113
+ ## Files And Safety
114
+
115
+ The default Codex home is `~/.codex`. A custom `CODEX_HOME` is respected without changing the layout:
116
+
117
+ ```text
118
+ $CODEX_HOME/
119
+ |-- auth.json # owned by Codex; never changed here
120
+ |-- config.toml # active materialized configuration
121
+ `-- codex-configure/
122
+ |-- .env # provider keys, mode 0600
123
+ |-- providers.d/<shortname>.toml # provider configuration, no secrets
124
+ |-- catalogs/<shortname>.json # selected Codex model metadata
125
+ |-- profiles/ # stock-Core launch profiles
126
+ |-- base/ # original and maintained config snapshots
127
+ `-- recovery/ # last-known-good transaction state
128
+ ```
129
+
130
+ On first initialization, the existing `config.toml` is preserved before any profile is activated. Normal `run` commands then write the selected materialized configuration to the active `config.toml`; atomic switching and recovery protect that operation, but do not make it temporary. `codex-configure` never replaces `auth.json`, recursively backs up `CODEX_HOME`, or copies credentials into descriptors, catalogs, profiles, diagnostics, or recovery files.
131
+
132
+ The `.env` file is created with mode `0600`, and tool-owned directories use mode `0700`. An environment variable with the expected name can override a stored key for one launch.
133
+
134
+ ## Check And Recover
135
+
136
+ Inspect the managed configuration without changing it:
137
+
138
+ ```bash
139
+ codex-configure doctor
140
+ ```
141
+
142
+ Restore the maintained OpenAI base, or the immutable first-run snapshot:
143
+
144
+ ```bash
145
+ codex-configure restore
146
+ codex-configure restore --original
147
+ ```
148
+
149
+ Switching and restore commands refuse to proceed while a known Codex or ChatGPT process is running. They also reject unexpected outside changes to routing fields instead of overwriting them. Unrelated settings written by Codex are retained.
150
+
151
+ ## Troubleshooting
152
+
153
+ If the CLI says setup is missing, run `codex-configure init` with the intended `CODEX_HOME`. Copying a complete managed `$CODEX_HOME/codex-configure/` layout, including its base/state files and valid provider catalogs, also counts as initialized after validation.
154
+
155
+ If the desktop command cannot be found, set an explicit launch command:
156
+
157
+ ```bash
158
+ CODEX_DESKTOP_COMMAND=/path/to/chatgpt codex-configure run openai/desktop
159
+ ```
160
+
161
+ Some Linux virtual machines need Chromium software rendering:
162
+
163
+ ```bash
164
+ CODEX_DESKTOP_COMMAND='chatgpt --use-angle=swiftshader' codex-configure run desktop
165
+ ```
166
+
167
+ If a credential permission check fails, repair it with:
168
+
169
+ ```bash
170
+ chmod 700 "${CODEX_HOME:-$HOME/.codex}/codex-configure"
171
+ chmod 600 "${CODEX_HOME:-$HOME/.codex}/codex-configure/.env"
172
+ ```
173
+
174
+ Architecture, patch maintenance, and manual acceptance details are in [docs/architecture.md](https://github.com/cab938/codex-configure/blob/main/docs/architecture.md). U-M model discovery is not an entitlement guarantee: a provider may still reject an advertised model because of deployment access, account policy, or budget.
175
+
176
+ ## License
177
+
178
+ Licensed under the Apache License, Version 2.0. See [LICENSE](https://github.com/cab938/codex-configure/blob/main/LICENSE) and [NOTICE](https://github.com/cab938/codex-configure/blob/main/NOTICE).