patch-cc 0.1.4__tar.gz → 0.2.1__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 (44) hide show
  1. {patch_cc-0.1.4 → patch_cc-0.2.1}/.github/workflows/ci.yml +1 -1
  2. {patch_cc-0.1.4 → patch_cc-0.2.1}/.gitignore +4 -0
  3. patch_cc-0.2.1/AGENTS.md +18 -0
  4. patch_cc-0.2.1/CLAUDE.md +1 -0
  5. patch_cc-0.2.1/PKG-INFO +225 -0
  6. patch_cc-0.2.1/README.md +196 -0
  7. {patch_cc-0.1.4 → patch_cc-0.2.1}/docs/INTERNALS.md +19 -3
  8. {patch_cc-0.1.4 → patch_cc-0.2.1}/docs/PLAYBOOK.md +224 -16
  9. patch_cc-0.2.1/docs/demo.gif +0 -0
  10. {patch_cc-0.1.4 → patch_cc-0.2.1}/pyproject.toml +3 -2
  11. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/__init__.py +1 -1
  12. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/bun/blob.py +8 -3
  13. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/bun/container.py +10 -0
  14. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/bun/macho.py +0 -12
  15. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/cache.py +28 -1
  16. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/cli.py +462 -35
  17. patch_cc-0.2.1/src/patch_cc/codex/__init__.py +62 -0
  18. patch_cc-0.2.1/src/patch_cc/codex/gateway.py +407 -0
  19. patch_cc-0.2.1/src/patch_cc/codex/models.py +334 -0
  20. patch_cc-0.2.1/src/patch_cc/codex/oauth.py +361 -0
  21. patch_cc-0.2.1/src/patch_cc/codex/translate.py +855 -0
  22. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/doctor.py +34 -8
  23. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/locate.py +29 -17
  24. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/menu.py +531 -76
  25. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/patcher.py +104 -45
  26. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/patches/__init__.py +12 -14
  27. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/patches/agents.py +56 -11
  28. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/patches/base.py +53 -21
  29. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/patches/chrome.py +72 -9
  30. patch_cc-0.2.1/src/patch_cc/patches/codex.py +523 -0
  31. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/patches/streaming.py +2 -2
  32. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/patches/thinking.py +80 -3
  33. patch_cc-0.2.1/src/patch_cc/ui.py +110 -0
  34. {patch_cc-0.1.4 → patch_cc-0.2.1}/uv.lock +1 -1
  35. patch_cc-0.1.4/PKG-INFO +0 -145
  36. patch_cc-0.1.4/README.md +0 -117
  37. patch_cc-0.1.4/src/patch_cc/ui.py +0 -69
  38. {patch_cc-0.1.4 → patch_cc-0.2.1}/.github/workflows/release.yml +0 -0
  39. {patch_cc-0.1.4 → patch_cc-0.2.1}/LICENSE +0 -0
  40. {patch_cc-0.1.4 → patch_cc-0.2.1}/docs/CONDUCT.md +0 -0
  41. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/bun/__init__.py +0 -0
  42. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/bun/elf.py +0 -0
  43. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/bun/errors.py +0 -0
  44. {patch_cc-0.1.4 → patch_cc-0.2.1}/src/patch_cc/patches/output.py +0 -0
@@ -11,7 +11,7 @@ jobs:
11
11
  strategy:
12
12
  fail-fast: false
13
13
  matrix:
14
- python-version: ["3.11", "3.12", "3.13"]
14
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
15
15
  steps:
16
16
  - uses: actions/checkout@v4
17
17
 
@@ -20,3 +20,7 @@ build/
20
20
  *.patched
21
21
  content*.js
22
22
  claude-*.bin
23
+ .opencode/
24
+
25
+ # Build journal, not documentation (see docs/PLAYBOOK.md for the shipped "why")
26
+ CODEX-PLAN.md
@@ -0,0 +1,18 @@
1
+ # patch-cc
2
+
3
+ Interactive patcher for the Claude Code native binary. What it does and how to
4
+ use it: [README.md](README.md).
5
+
6
+ Before changing anything, read [docs/CONDUCT.md](docs/CONDUCT.md) — how we
7
+ build here: the mindset, the guardrails, and who commits (the user does). Then:
8
+
9
+ - [docs/PLAYBOOK.md](docs/PLAYBOOK.md) — matcher rules, the patch reference,
10
+ how to repair a patch after a Claude update, and the map of the bundle's
11
+ native surfaces (the model registry and its consumers).
12
+ - [docs/INTERNALS.md](docs/INTERNALS.md) — the Bun container format and how
13
+ the binary is rewritten in place.
14
+
15
+ Verify with `uv run patch-cc doctor` (every patch against a clean bundle;
16
+ point it at the pristine copies in `~/.local/share/patch-cc/backups/` to sweep
17
+ older builds). There is no test suite by design — doctor against real bundles
18
+ is the check.
@@ -0,0 +1 @@
1
+ AGENTS.md
@@ -0,0 +1,225 @@
1
+ Metadata-Version: 2.4
2
+ Name: patch-cc
3
+ Version: 0.2.1
4
+ Summary: Interactive patcher for the Claude Code native binary
5
+ Project-URL: Homepage, https://github.com/anfreire/patch-cc
6
+ Project-URL: Repository, https://github.com/anfreire/patch-cc
7
+ Project-URL: Issues, https://github.com/anfreire/patch-cc/issues
8
+ Author-email: André Freire Ferreira <anfreire.dev@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: bun,claude,claude-code,cli,codex,gpt,openai,patch,tui
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Software Development
23
+ Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.11
25
+ Requires-Dist: blessed>=1.47.0
26
+ Requires-Dist: lief>=0.15; sys_platform == 'darwin'
27
+ Requires-Dist: rich>=13.7
28
+ Description-Content-Type: text/markdown
29
+
30
+ # patch-cc
31
+
32
+ [![CI](https://github.com/anfreire/patch-cc/actions/workflows/ci.yml/badge.svg)](https://github.com/anfreire/patch-cc/actions/workflows/ci.yml)
33
+ [![PyPI](https://img.shields.io/pypi/v/patch-cc)](https://pypi.org/project/patch-cc/)
34
+
35
+ An interactive patcher for the **Claude Code native binary**. Pick the tweaks
36
+ you want — inline and live thinking, detailed tool calls, subagent model
37
+ overrides, your own startup name, your **ChatGPT/Codex-plan GPT models as
38
+ native models** — and apply them to your installed `claude` in one keystroke.
39
+ Fully reversible: a pristine backup is kept, `patch-cc restore` puts it back.
40
+ Pure Python; no Node, no Bun.
41
+
42
+ ```bash
43
+ uvx patch-cc # fullscreen menu, no install needed
44
+ ```
45
+
46
+ ![patch-cc: pick tweaks, register a Codex model, pin the Plan agent to it, bake — the patched binary is 161 MB smaller](https://raw.githubusercontent.com/anfreire/patch-cc/main/docs/demo.gif)
47
+
48
+ ## Requirements
49
+
50
+ - **Linux or macOS**
51
+ - **Python 3.11+**
52
+ - **[uv](https://docs.astral.sh/uv/)** — how patch-cc is run and installed
53
+ below. Install it with `curl -LsSf https://astral.sh/uv/install.sh | sh`.
54
+ Not using uv? `pipx install patch-cc` (or `pip install patch-cc`) works too;
55
+ it is an ordinary PyPI package.
56
+ - **macOS only:** the Xcode command line tools, for `codesign` — a patched
57
+ binary has to be re-signed or macOS refuses to run it.
58
+
59
+ The menu is a single centered panel: move with `↑ ↓`, toggle with `space`,
60
+ press `s` to save. Patches that carry a setting — subagent models, Codex models,
61
+ the startup name, the `--version` marker, the org/email label — open a centered
62
+ modal on `enter`, and the row then shows what you chose. Everything choosable
63
+ is a picker: the agent names and model aliases are **discovered from your
64
+ binary itself** (and the Codex ones from your plan), so the menu can never
65
+ offer something your build would reject. Typing exists only for the genuinely
66
+ free-text values.
67
+
68
+ A patched binary records what was applied inside itself, so the menu always
69
+ comes up showing the real current state, and `patch-cc status` answers
70
+ exactly.
71
+
72
+ Prefer it always available on your PATH? Install it:
73
+
74
+ ```bash
75
+ uv tool install patch-cc
76
+ patch-cc # then just run it
77
+ ```
78
+
79
+ ## What it can do
80
+
81
+ | Group | Patch | |
82
+ |---|---|---|
83
+ | Output & display | Detailed tool calls | Show full read/search calls, not collapsed summaries |
84
+ | | Colour new files as diffs | Created files render with `+` lines and green |
85
+ | | Fix blank thinking blocks | Opt out of the server-side experiment that can empty every thinking block |
86
+ | | Always show thinking | Thinking blocks stay inline — no `ctrl+o` |
87
+ | | Stream thinking live | See reasoning as it is generated, inline and in order |
88
+ | | Show subagent prompts | Prompt blocks visible during normal use |
89
+ | Models & effort | Persist max effort | `/effort max` saves as your default for new sessions, like the other levels |
90
+ | | Codex models | Use OpenAI/Codex-plan models in Claude Code — see [Codex models](#codex-models) |
91
+ | | Override subagent models | Pick the model per built-in agent (discovered from your binary) |
92
+ | Chrome & branding | Disable spinner tips | No rotating tips on the spinner |
93
+ | | Mark `--version` | Appends `(patched)` — or any marker you choose |
94
+ | | Custom startup name | Defaults to `<your username>'s Code` |
95
+ | | Startup org/email label | Replace the org/email on the welcome screen — or hide it |
96
+
97
+ ## Usage
98
+
99
+ Everything the menu does is also a non-interactive subcommand (shown with
100
+ `uvx`; drop it if you installed the tool):
101
+
102
+ ```bash
103
+ uvx patch-cc apply # the default patch set
104
+ uvx patch-cc apply tool-calls live-thinking # just these
105
+ uvx patch-cc apply --brand # + branding as <username>'s Code
106
+ uvx patch-cc apply --brand "Ada's Code" # + branding, explicit name
107
+ uvx patch-cc apply --model Explore=haiku --model general-purpose=opus
108
+ uvx patch-cc apply --suffix "(mine)" # custom --version marker
109
+ uvx patch-cc apply --org-label # hide the welcome screen's org/email
110
+ uvx patch-cc apply --org-label "Ada's Lab" # ...or show this instead
111
+ uvx patch-cc apply --codex gpt-5.6-sol # + a Codex model (see below)
112
+ uvx patch-cc apply --from-cache # replay your last remembered selection
113
+ uvx patch-cc status # exactly what is applied
114
+ uvx patch-cc doctor # do all patches match this build?
115
+ uvx patch-cc doctor path/to/claude # ...or match some other binary
116
+ uvx patch-cc list # every patch, described
117
+ uvx patch-cc restore # put the original back
118
+ ```
119
+
120
+ A flag that configures a patch also selects it — `apply --help` lists them
121
+ all. Agents and models are validated against what your installed binary
122
+ actually ships, and Codex model ids against what your plan offers.
123
+
124
+ ## Codex models
125
+
126
+ Bring your **ChatGPT/Codex-plan** models (GPT-5.x) into Claude Code and use them
127
+ alongside your Claude ones — in the `/model` picker, as a subagent override,
128
+ with `/effort` driving how hard they think. It is two halves: a patch that
129
+ teaches your binary to accept and route the models you pick, and a small
130
+ localhost **gateway** that translates between Claude Code and OpenAI. Only the
131
+ models you pick are diverted — every Anthropic request stays byte-identical,
132
+ so your Claude plan is untouched. Nothing extra to install: the gateway is pure
133
+ Python and ships with patch-cc; you just sign in to a ChatGPT or Codex plan.
134
+
135
+ ```bash
136
+ uvx patch-cc codex login # sign in to your ChatGPT/Codex plan
137
+ uvx patch-cc # Codex models → pick models → save with `s`
138
+ uvx patch-cc codex serve # start the gateway; keep it running
139
+ ```
140
+
141
+ Which models you want is a patch setting like the startup name, so the menu's
142
+ **Codex models** row is where you pick them — it lists what your plan offers,
143
+ live. Everything the menu does the command line does too:
144
+
145
+ ```bash
146
+ uvx patch-cc apply --codex gpt-5.6-sol --codex gpt-5.5
147
+ uvx patch-cc apply --help # lists the model ids your plan offers
148
+ uvx patch-cc apply --from-cache # replay your last selection
149
+ ```
150
+
151
+ Then pick a model like any other:
152
+
153
+ ```bash
154
+ claude --model sol # shortcut → newest gpt-5.6-sol
155
+ claude --model gpt-5.6-sol # the full id also works, as does /model
156
+ ```
157
+
158
+ - **Shortcuts** (`sol`, `terra`, `luna`, …) are the last word of the model id;
159
+ the newest in a family wins, the way `opus` means the latest Claude Opus. They
160
+ are derived from the ids you picked — there is nothing to configure.
161
+ - **Your binary is the record.** The models and the port live in the patched
162
+ binary, so `patch-cc status` names exactly what is registered, and
163
+ `codex serve` finds the right port with nothing to tell it.
164
+ - **They read as native everywhere.** A registered model is added to the
165
+ binary's own model table, so its real name shows in the status line and the
166
+ welcome banner, its plan-reported effort levels are declared, and
167
+ `/advisor sol` works like any other model. Ask for an effort the model
168
+ doesn't run and the gateway quietly runs the closest lower one — the same
169
+ clamping Claude Code documents for its own models.
170
+ - **The gateway has to be running.** Every surface that names it says whether it
171
+ is — the apply report as soon as you bake, `patch-cc status`, and `codex
172
+ status` — so you never learn it from a request that hangs instead.
173
+ - The gateway holds *your* OpenAI token and listens only on localhost. No
174
+ Anthropic-model request is ever diverted to it. The Codex ones that *are*
175
+ still carry Claude Code's own auth header — the gateway ignores it and never
176
+ forwards it, but treat the port as trusted: whatever binds it first sees it.
177
+ - After a Claude update, **re-bake** — the patch reverts with the binary — but
178
+ the gateway is separate and keeps running. Until you do, a Codex model you had
179
+ saved as your default reads as unavailable; the models live in the patch.
180
+ Change the port and the gateway needs a restart to follow it.
181
+
182
+ ## After a Claude update
183
+
184
+ Claude auto-updates roughly daily and replaces the binary, which reverts the
185
+ patch. Re-run `patch-cc` — the menu remembers your last selection — replay it
186
+ without the menu via `patch-cc apply --from-cache`, or re-apply your set
187
+ explicitly:
188
+
189
+ ```bash
190
+ uvx patch-cc apply --brand --model Explore=haiku
191
+ ```
192
+
193
+ `uvx patch-cc status` tells you whether the current binary is patched, and the
194
+ startup name / `--version` marker are visible tells too.
195
+
196
+ ## Why native-only, and why it stays small
197
+
198
+ Claude Code now ships only as a Bun single-file executable; the npm package is a
199
+ wrapper that downloads it. patch-cc edits the JavaScript bundle embedded in the
200
+ binary's `.bun` section in place. It also drops the module's 154 MB of stale
201
+ precompiled bytecode — editing the source invalidates it anyway — so a patched
202
+ binary is *smaller* than the original (≈113 MB vs 267 MB), not larger.
203
+
204
+ See [docs/INTERNALS.md](docs/INTERNALS.md) for the container format and
205
+ [docs/PLAYBOOK.md](docs/PLAYBOOK.md) for repairing a patch after an update.
206
+ Changing anything here starts at [docs/CONDUCT.md](docs/CONDUCT.md) — how this
207
+ is built, and what a patch has to prove before it ships.
208
+
209
+ ## Credits
210
+
211
+ The patch set is a Python port of
212
+ [a-connoisseur/patch-claude-code](https://github.com/a-connoisseur/patch-claude-code),
213
+ with the subagent-model override idea from
214
+ [aleks-apostle/claude-code-patches](https://github.com/aleks-apostle/claude-code-patches).
215
+ Registering Codex models inside the bundle follows
216
+ [clodex](https://github.com/gxjansen/clodex); the routing here is done in the
217
+ bundle rather than with clodex's TLS interception.
218
+
219
+ ## License
220
+
221
+ MIT
222
+
223
+ ---
224
+
225
+ **More agent tooling** — [summon-cc](https://github.com/anfreire/summon-cc): give your agent a crew of Claude Code workers · [cc-oc](https://github.com/anfreire/cc-oc): drive opencode from inside Claude Code · [omoctl](https://github.com/anfreire/omoctl): manage oh-my-openagent profiles · [wiki-spaces](https://github.com/anfreire/wiki-spaces): a wiki your AI agent keeps
@@ -0,0 +1,196 @@
1
+ # patch-cc
2
+
3
+ [![CI](https://github.com/anfreire/patch-cc/actions/workflows/ci.yml/badge.svg)](https://github.com/anfreire/patch-cc/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/patch-cc)](https://pypi.org/project/patch-cc/)
5
+
6
+ An interactive patcher for the **Claude Code native binary**. Pick the tweaks
7
+ you want — inline and live thinking, detailed tool calls, subagent model
8
+ overrides, your own startup name, your **ChatGPT/Codex-plan GPT models as
9
+ native models** — and apply them to your installed `claude` in one keystroke.
10
+ Fully reversible: a pristine backup is kept, `patch-cc restore` puts it back.
11
+ Pure Python; no Node, no Bun.
12
+
13
+ ```bash
14
+ uvx patch-cc # fullscreen menu, no install needed
15
+ ```
16
+
17
+ ![patch-cc: pick tweaks, register a Codex model, pin the Plan agent to it, bake — the patched binary is 161 MB smaller](https://raw.githubusercontent.com/anfreire/patch-cc/main/docs/demo.gif)
18
+
19
+ ## Requirements
20
+
21
+ - **Linux or macOS**
22
+ - **Python 3.11+**
23
+ - **[uv](https://docs.astral.sh/uv/)** — how patch-cc is run and installed
24
+ below. Install it with `curl -LsSf https://astral.sh/uv/install.sh | sh`.
25
+ Not using uv? `pipx install patch-cc` (or `pip install patch-cc`) works too;
26
+ it is an ordinary PyPI package.
27
+ - **macOS only:** the Xcode command line tools, for `codesign` — a patched
28
+ binary has to be re-signed or macOS refuses to run it.
29
+
30
+ The menu is a single centered panel: move with `↑ ↓`, toggle with `space`,
31
+ press `s` to save. Patches that carry a setting — subagent models, Codex models,
32
+ the startup name, the `--version` marker, the org/email label — open a centered
33
+ modal on `enter`, and the row then shows what you chose. Everything choosable
34
+ is a picker: the agent names and model aliases are **discovered from your
35
+ binary itself** (and the Codex ones from your plan), so the menu can never
36
+ offer something your build would reject. Typing exists only for the genuinely
37
+ free-text values.
38
+
39
+ A patched binary records what was applied inside itself, so the menu always
40
+ comes up showing the real current state, and `patch-cc status` answers
41
+ exactly.
42
+
43
+ Prefer it always available on your PATH? Install it:
44
+
45
+ ```bash
46
+ uv tool install patch-cc
47
+ patch-cc # then just run it
48
+ ```
49
+
50
+ ## What it can do
51
+
52
+ | Group | Patch | |
53
+ |---|---|---|
54
+ | Output & display | Detailed tool calls | Show full read/search calls, not collapsed summaries |
55
+ | | Colour new files as diffs | Created files render with `+` lines and green |
56
+ | | Fix blank thinking blocks | Opt out of the server-side experiment that can empty every thinking block |
57
+ | | Always show thinking | Thinking blocks stay inline — no `ctrl+o` |
58
+ | | Stream thinking live | See reasoning as it is generated, inline and in order |
59
+ | | Show subagent prompts | Prompt blocks visible during normal use |
60
+ | Models & effort | Persist max effort | `/effort max` saves as your default for new sessions, like the other levels |
61
+ | | Codex models | Use OpenAI/Codex-plan models in Claude Code — see [Codex models](#codex-models) |
62
+ | | Override subagent models | Pick the model per built-in agent (discovered from your binary) |
63
+ | Chrome & branding | Disable spinner tips | No rotating tips on the spinner |
64
+ | | Mark `--version` | Appends `(patched)` — or any marker you choose |
65
+ | | Custom startup name | Defaults to `<your username>'s Code` |
66
+ | | Startup org/email label | Replace the org/email on the welcome screen — or hide it |
67
+
68
+ ## Usage
69
+
70
+ Everything the menu does is also a non-interactive subcommand (shown with
71
+ `uvx`; drop it if you installed the tool):
72
+
73
+ ```bash
74
+ uvx patch-cc apply # the default patch set
75
+ uvx patch-cc apply tool-calls live-thinking # just these
76
+ uvx patch-cc apply --brand # + branding as <username>'s Code
77
+ uvx patch-cc apply --brand "Ada's Code" # + branding, explicit name
78
+ uvx patch-cc apply --model Explore=haiku --model general-purpose=opus
79
+ uvx patch-cc apply --suffix "(mine)" # custom --version marker
80
+ uvx patch-cc apply --org-label # hide the welcome screen's org/email
81
+ uvx patch-cc apply --org-label "Ada's Lab" # ...or show this instead
82
+ uvx patch-cc apply --codex gpt-5.6-sol # + a Codex model (see below)
83
+ uvx patch-cc apply --from-cache # replay your last remembered selection
84
+ uvx patch-cc status # exactly what is applied
85
+ uvx patch-cc doctor # do all patches match this build?
86
+ uvx patch-cc doctor path/to/claude # ...or match some other binary
87
+ uvx patch-cc list # every patch, described
88
+ uvx patch-cc restore # put the original back
89
+ ```
90
+
91
+ A flag that configures a patch also selects it — `apply --help` lists them
92
+ all. Agents and models are validated against what your installed binary
93
+ actually ships, and Codex model ids against what your plan offers.
94
+
95
+ ## Codex models
96
+
97
+ Bring your **ChatGPT/Codex-plan** models (GPT-5.x) into Claude Code and use them
98
+ alongside your Claude ones — in the `/model` picker, as a subagent override,
99
+ with `/effort` driving how hard they think. It is two halves: a patch that
100
+ teaches your binary to accept and route the models you pick, and a small
101
+ localhost **gateway** that translates between Claude Code and OpenAI. Only the
102
+ models you pick are diverted — every Anthropic request stays byte-identical,
103
+ so your Claude plan is untouched. Nothing extra to install: the gateway is pure
104
+ Python and ships with patch-cc; you just sign in to a ChatGPT or Codex plan.
105
+
106
+ ```bash
107
+ uvx patch-cc codex login # sign in to your ChatGPT/Codex plan
108
+ uvx patch-cc # Codex models → pick models → save with `s`
109
+ uvx patch-cc codex serve # start the gateway; keep it running
110
+ ```
111
+
112
+ Which models you want is a patch setting like the startup name, so the menu's
113
+ **Codex models** row is where you pick them — it lists what your plan offers,
114
+ live. Everything the menu does the command line does too:
115
+
116
+ ```bash
117
+ uvx patch-cc apply --codex gpt-5.6-sol --codex gpt-5.5
118
+ uvx patch-cc apply --help # lists the model ids your plan offers
119
+ uvx patch-cc apply --from-cache # replay your last selection
120
+ ```
121
+
122
+ Then pick a model like any other:
123
+
124
+ ```bash
125
+ claude --model sol # shortcut → newest gpt-5.6-sol
126
+ claude --model gpt-5.6-sol # the full id also works, as does /model
127
+ ```
128
+
129
+ - **Shortcuts** (`sol`, `terra`, `luna`, …) are the last word of the model id;
130
+ the newest in a family wins, the way `opus` means the latest Claude Opus. They
131
+ are derived from the ids you picked — there is nothing to configure.
132
+ - **Your binary is the record.** The models and the port live in the patched
133
+ binary, so `patch-cc status` names exactly what is registered, and
134
+ `codex serve` finds the right port with nothing to tell it.
135
+ - **They read as native everywhere.** A registered model is added to the
136
+ binary's own model table, so its real name shows in the status line and the
137
+ welcome banner, its plan-reported effort levels are declared, and
138
+ `/advisor sol` works like any other model. Ask for an effort the model
139
+ doesn't run and the gateway quietly runs the closest lower one — the same
140
+ clamping Claude Code documents for its own models.
141
+ - **The gateway has to be running.** Every surface that names it says whether it
142
+ is — the apply report as soon as you bake, `patch-cc status`, and `codex
143
+ status` — so you never learn it from a request that hangs instead.
144
+ - The gateway holds *your* OpenAI token and listens only on localhost. No
145
+ Anthropic-model request is ever diverted to it. The Codex ones that *are*
146
+ still carry Claude Code's own auth header — the gateway ignores it and never
147
+ forwards it, but treat the port as trusted: whatever binds it first sees it.
148
+ - After a Claude update, **re-bake** — the patch reverts with the binary — but
149
+ the gateway is separate and keeps running. Until you do, a Codex model you had
150
+ saved as your default reads as unavailable; the models live in the patch.
151
+ Change the port and the gateway needs a restart to follow it.
152
+
153
+ ## After a Claude update
154
+
155
+ Claude auto-updates roughly daily and replaces the binary, which reverts the
156
+ patch. Re-run `patch-cc` — the menu remembers your last selection — replay it
157
+ without the menu via `patch-cc apply --from-cache`, or re-apply your set
158
+ explicitly:
159
+
160
+ ```bash
161
+ uvx patch-cc apply --brand --model Explore=haiku
162
+ ```
163
+
164
+ `uvx patch-cc status` tells you whether the current binary is patched, and the
165
+ startup name / `--version` marker are visible tells too.
166
+
167
+ ## Why native-only, and why it stays small
168
+
169
+ Claude Code now ships only as a Bun single-file executable; the npm package is a
170
+ wrapper that downloads it. patch-cc edits the JavaScript bundle embedded in the
171
+ binary's `.bun` section in place. It also drops the module's 154 MB of stale
172
+ precompiled bytecode — editing the source invalidates it anyway — so a patched
173
+ binary is *smaller* than the original (≈113 MB vs 267 MB), not larger.
174
+
175
+ See [docs/INTERNALS.md](docs/INTERNALS.md) for the container format and
176
+ [docs/PLAYBOOK.md](docs/PLAYBOOK.md) for repairing a patch after an update.
177
+ Changing anything here starts at [docs/CONDUCT.md](docs/CONDUCT.md) — how this
178
+ is built, and what a patch has to prove before it ships.
179
+
180
+ ## Credits
181
+
182
+ The patch set is a Python port of
183
+ [a-connoisseur/patch-claude-code](https://github.com/a-connoisseur/patch-claude-code),
184
+ with the subagent-model override idea from
185
+ [aleks-apostle/claude-code-patches](https://github.com/aleks-apostle/claude-code-patches).
186
+ Registering Codex models inside the bundle follows
187
+ [clodex](https://github.com/gxjansen/clodex); the routing here is done in the
188
+ bundle rather than with clodex's TLS interception.
189
+
190
+ ## License
191
+
192
+ MIT
193
+
194
+ ---
195
+
196
+ **More agent tooling** — [summon-cc](https://github.com/anfreire/summon-cc): give your agent a crew of Claude Code workers · [cc-oc](https://github.com/anfreire/cc-oc): drive opencode from inside Claude Code · [omoctl](https://github.com/anfreire/omoctl): manage oh-my-openagent profiles · [wiki-spaces](https://github.com/anfreire/wiki-spaces): a wiki your AI agent keeps
@@ -88,10 +88,12 @@ edit is followed by an ad-hoc `codesign` (mandatory on Apple Silicon).
88
88
 
89
89
  ## The manifest
90
90
 
91
- Every patched bundle ends with a single comment line:
91
+ Every patched bundle ends with a single comment line — the one description of
92
+ its shape; [PLAYBOOK.md](PLAYBOOK.md) covers what it means for matcher health:
92
93
 
93
94
  ```
94
- //patch-cc {"v":1,"tool":"0.1.0","patches":[...],"brand":...,"models":{...}}
95
+ //patch-cc {"v":1,"tool":"<version>","patches":[...],"brand":...,"models":{...},
96
+ "org":...,"codex":{"port":8817,"models":["gpt-5.6-sol", ...]}}
95
97
  ```
96
98
 
97
99
  That line is why `patch-cc status` can name exactly what is applied: several
@@ -100,6 +102,18 @@ can't collide with code and travels with the bundle through extract/repack.
100
102
  The menu also reads it to pre-select the current patch set — the binary is the
101
103
  state.
102
104
 
105
+ Every key after `patches` belongs to a patch and is written only when *that*
106
+ patch landed, so `status` can never assert a name, marker, or model the bundle
107
+ does not contain.
108
+
109
+ Each key records what was *asked for*, never what was derived from it. `codex`
110
+ carries model ids and a port and nothing else: a Codex model's display name and
111
+ context window are already baked into the bundle, and repeating them here would
112
+ be a second copy — one that a relabelling upstream could make disagree with the
113
+ binary it claims to describe. That is also what makes the manifest the single
114
+ home for the gateway port: `codex serve` and `codex status` read it from here
115
+ rather than from a store of their own.
116
+
103
117
  ## Safety
104
118
 
105
119
  - Before the first patch of a version, the pristine binary is copied to
@@ -112,4 +126,6 @@ state.
112
126
  - Every write is verified: patch-cc re-extracts the JS from the binary it just
113
127
  wrote and asserts it equals what it meant to write.
114
128
  - Patching a binary that is already marked, when no pristine backup exists, is
115
- refused unless `--force` — there is nothing clean to start from.
129
+ refused outright — there is nothing clean to start from, and our edits change
130
+ lengths, so a second pass would corrupt rather than update. `restore` or a
131
+ reinstall are the only honest fixes; there is deliberately no override.