overcodex 0.2.0__tar.gz → 0.3.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 (47) hide show
  1. overcodex-0.3.1/PKG-INFO +251 -0
  2. overcodex-0.3.1/README.md +230 -0
  3. {overcodex-0.2.0 → overcodex-0.3.1}/bin/codex-swap +74 -10
  4. {overcodex-0.2.0 → overcodex-0.3.1}/codex/AGENTS-ULTRACODE.md +3 -3
  5. overcodex-0.3.1/config/hooks-block.toml.tpl +48 -0
  6. {overcodex-0.2.0 → overcodex-0.3.1}/hooks/overcodex-ctx-watch.sh +9 -6
  7. {overcodex-0.2.0 → overcodex-0.3.1}/hooks/overcodex-handoff-inject.sh +23 -30
  8. {overcodex-0.2.0 → overcodex-0.3.1}/hooks/overcodex-notify.sh +1 -1
  9. {overcodex-0.2.0 → overcodex-0.3.1}/hooks/overcodex-precompact-offer.sh +1 -1
  10. overcodex-0.3.1/install.sh +484 -0
  11. overcodex-0.3.1/lib/overcodex_config.py +1014 -0
  12. {overcodex-0.2.0 → overcodex-0.3.1}/pyproject.toml +10 -4
  13. overcodex-0.3.1/shell/zshrc-snippet.sh +24 -0
  14. {overcodex-0.2.0 → overcodex-0.3.1}/skill/overcodex-ultracode/SKILL.md +1 -1
  15. overcodex-0.3.1/skill/overcodex-ultracode/references/codex-adapter.md +18 -0
  16. overcodex-0.3.1/skills/handoff/SKILL.md +61 -0
  17. overcodex-0.3.1/skills/handoff-cancel/SKILL.md +25 -0
  18. overcodex-0.3.1/skills/handoff-claude/SKILL.md +60 -0
  19. overcodex-0.3.1/skills/handoff-status/SKILL.md +29 -0
  20. overcodex-0.2.0/prompts/ultracode.md → overcodex-0.3.1/skills/ultracode/SKILL.md +6 -4
  21. {overcodex-0.2.0 → overcodex-0.3.1}/src/overcodex/cli.py +11 -5
  22. overcodex-0.3.1/src/overcodex/doctor.py +156 -0
  23. overcodex-0.3.1/uninstall.sh +318 -0
  24. overcodex-0.2.0/PKG-INFO +0 -219
  25. overcodex-0.2.0/README.md +0 -199
  26. overcodex-0.2.0/config/hooks-block.toml.tpl +0 -42
  27. overcodex-0.2.0/install.sh +0 -544
  28. overcodex-0.2.0/prompts/handoff-cancel.md +0 -23
  29. overcodex-0.2.0/prompts/handoff-status.md +0 -26
  30. overcodex-0.2.0/prompts/handoff.md +0 -57
  31. overcodex-0.2.0/shell/zshrc-snippet.sh +0 -24
  32. overcodex-0.2.0/skill/overcodex-ultracode/references/codex-adapter.md +0 -18
  33. overcodex-0.2.0/uninstall.sh +0 -215
  34. {overcodex-0.2.0 → overcodex-0.3.1}/.gitignore +0 -0
  35. {overcodex-0.2.0 → overcodex-0.3.1}/LICENSE +0 -0
  36. {overcodex-0.2.0 → overcodex-0.3.1}/agents/judge-sol-xhigh.toml +0 -0
  37. {overcodex-0.2.0 → overcodex-0.3.1}/agents/reviewer-sol-high.toml +0 -0
  38. {overcodex-0.2.0 → overcodex-0.3.1}/agents/scout-luna-low.toml +0 -0
  39. {overcodex-0.2.0 → overcodex-0.3.1}/agents/worker-terra-medium.toml +0 -0
  40. {overcodex-0.2.0 → overcodex-0.3.1}/config/agents-block.toml.tpl +0 -0
  41. {overcodex-0.2.0 → overcodex-0.3.1}/config/statusline.toml +0 -0
  42. {overcodex-0.2.0 → overcodex-0.3.1}/hooks/overcodex-ctx-lib.sh +0 -0
  43. {overcodex-0.2.0 → overcodex-0.3.1}/install-openclaw.sh +0 -0
  44. {overcodex-0.2.0 → overcodex-0.3.1}/skill/overcodex-ultracode/agents/openai.yaml +0 -0
  45. {overcodex-0.2.0 → overcodex-0.3.1}/skill/overcodex-ultracode/references/openclaw-adapter.md +0 -0
  46. {overcodex-0.2.0 → overcodex-0.3.1}/skill/overcodex-ultracode/references/role-prompts.md +0 -0
  47. {overcodex-0.2.0 → overcodex-0.3.1}/src/overcodex/__init__.py +0 -0
@@ -0,0 +1,251 @@
1
+ Metadata-Version: 2.5
2
+ Name: overcodex
3
+ Version: 0.3.1
4
+ Summary: Codex CLI, overclocked — cold multi-account switching, context-threshold handoff skills, native statusline defaults, and AGENTS.md routing policy for multi-agent workflows
5
+ Project-URL: Homepage, https://github.com/arthur-bump-pm/overcodex
6
+ Project-URL: Repository, https://github.com/arthur-bump-pm/overcodex
7
+ Project-URL: Issues, https://github.com/arthur-bump-pm/overcodex/issues
8
+ Author: arthur-bump-pm
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: cli,codex,codex-cli,dotfiles
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Programming Language :: Python :: 3
18
+ Requires-Python: >=3.9
19
+ Requires-Dist: tomli>=1.1; python_version < '3.11'
20
+ Description-Content-Type: text/markdown
21
+
22
+ # overcodex
23
+
24
+ [![PyPI version](https://img.shields.io/pypi/v/overcodex)](https://pypi.org/project/overcodex/)
25
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
26
+ ![Platform: macOS](https://img.shields.io/badge/platform-macOS-lightgrey)
27
+
28
+ **Codex CLI, overclocked.** Cold-switch between Codex accounts, hand off to a fresh session with the `$handoff` skill before context fills up, watch usage on the native footer, and route multi-agent work with an AGENTS.md policy:
29
+
30
+ ```text
31
+ codex-swap use work # register/list accounts, then switch — restart required
32
+ $handoff # (inside Codex) package this session, resume fresh next launch
33
+
34
+ native footer: model with reasoning | current directory | project name | context remaining | 5h limit | weekly limit
35
+ ```
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ pipx install overcodex && overcodex install
41
+ ```
42
+
43
+ > **Fresh machine?** If you get `command not found: overcodex`, pipx's bin folder isn't on your PATH yet — run `pipx ensurepath && source ~/.zshrc`, then `overcodex install`. (Use `source`, not `exec zsh`: replacing the shell swallows any commands you pasted after it.)
44
+
45
+ Then register your accounts (once, per account):
46
+
47
+ ```bash
48
+ codex-swap add work # creates an isolated account home + links shared config, skills, hooks
49
+ codex-swap add personal # then log in to each: CODEX_HOME=~/.codex-accounts/work codex login
50
+ codex-swap use work # cold switch: only writes the ~/.codex-accounts/.active marker
51
+ # (shorthand: codex-swap work) — then start a new codex
52
+ ```
53
+
54
+ ### One manual step: trust the hooks (once per account)
55
+
56
+ Codex runs a hook only after you trust it. Start a **new** Codex session; when Codex shows **"Hooks need review"**, choose **"Trust all and continue"** (or inspect them first with `/hooks`). Codex keys that trust by config path (`<config path>:<event>:<group>:<handler>`, path not canonicalized), so every codex-swap account — `~/.codex-accounts/<name>/config.toml` is a different path even though it is a symlink to the shared file — asks once on its own. Any change to a hook's definition (an upgrade that changes the hooks block says so) asks again. `overcodex doctor` lists each account's hook trust status.
57
+
58
+ Then confirm the native footer shows the configured fields (Codex may omit unavailable usage-limit fields), and type `$handoff` inside Codex to hand off before you hit auto-compact.
59
+
60
+ The same routing policy is packaged as a portable skill for OpenClaw. Install it from a packaged overcodex build with `openclaw skills install "$(overcodex skill-path)" --global`, then configure the four role agent IDs described in `skill/overcodex-ultracode/references/openclaw-adapter.md`.
61
+
62
+ For agent-assisted setup, tell OpenClaw:
63
+
64
+ > Install and activate Overcodex UltraCode. Run `curl -fsSL https://raw.githubusercontent.com/arthur-bump-pm/overcodex/main/install-openclaw.sh | bash`, verify it with `openclaw skills list` and `openclaw agents list`, then configure the scout, worker, reviewer, and judge roles. Do not change credentials or existing agent settings without showing me the proposed diff first.
65
+
66
+ <details>
67
+ <summary>Other install methods, requirements, upgrading</summary>
68
+
69
+ ```bash
70
+ # uv
71
+ uv tool install overcodex && overcodex install
72
+
73
+ # from source
74
+ git clone https://github.com/arthur-bump-pm/overcodex && cd overcodex && ./install.sh
75
+ ```
76
+
77
+ Or paste this into any Codex CLI session and let it install itself:
78
+
79
+ > Install overcodex (https://github.com/arthur-bump-pm/overcodex) on this machine, fix anything its preflight complains about, and tell me what post-install steps I need to do myself.
80
+
81
+ **Requirements:** macOS, zsh, `pipx` or `uv`, Codex CLI 0.158+ (`codex --version`), `jq`. `config.toml` is only edited after a TOML validity check: `overcodex install` brings its own parser; a bare `./install.sh` needs `python3` ≥ 3.11 (or `tomli`) and otherwise leaves `config.toml` untouched and says so. No keychain daemon and no background credential engine — cold switching is just isolated `$CODEX_HOME` directories, one per account.
82
+
83
+ **Upgrade:** `pipx upgrade overcodex && overcodex install` — then re-trust the hooks in each account if the installer says they changed.
84
+
85
+ **Uninstall:** `overcodex uninstall` — removes exactly what install added (backed up), including the shared-config links `codex-swap add` created in each account; each account's `auth.json` and session state survive untouched.
86
+
87
+ The installer is idempotent and conservative: timestamped backups of everything it touches; a user's own `hooks`, `[agents]` or `status_line` settings are never overwritten; overcodex's own marker blocks are refreshed when the shipped content changes; re-running is a no-op. Codex's config writer puts the tables it adds (hook trust records, `[notice]`, `[features]`, …) inside the nearest overcodex block — install and uninstall move those below the block instead of deleting them, and a sentinel `[hooks.state]` table after the hooks block makes Codex append below it in the first place.
88
+
89
+ </details>
90
+
91
+ ## What you get
92
+
93
+ ### `codex-swap` — cold account switching
94
+ Each account gets its own isolated `CODEX_HOME` (a separate `auth.json`, never a copied/overwritten one — refresh tokens can be single-use across copies, so isolation is the only safe design). `codex-swap use <account>` only records which account is active (`~/.codex-accounts/.active`); the `codex()` shell wrapper passes that account's home to each new `codex` process (`CODEX_HOME=… command codex`, never exported into your shell, and your own `CODEX_HOME` is left alone when no account is active). **This is a cold switch**: any Codex session already running keeps its old credentials until you quit and relaunch it. There is no hot mid-session swap here — if you need that, it's overclaude's `/swap` for Claude Code, not this.
95
+
96
+ ### `$handoff` — escape context bloat, keep the thread
97
+
98
+ Codex 0.158 removed `/prompts:*` custom prompts, so the handoff flow ships as **Codex skills** in `$CODEX_HOME/skills/` (shared into every codex-swap account). Invoke one by typing its `$` mention anywhere in your message — `$handoff`, or `$handoff now please` — or browse them with `/skills`.
99
+
100
+ ```mermaid
101
+ flowchart LR
102
+ A[Context fills up] --> B[Hook offers a handoff at 60/75/85%]
103
+ B --> C[You type $handoff]
104
+ C --> D[Codex packages goals, state, next steps]
105
+ D --> E[You exit and relaunch codex in the same directory]
106
+ E --> F[SessionStart hook injects the package]
107
+ F --> G[Fresh session, ctx near zero]
108
+ G --> A
109
+ ```
110
+
111
+ You lose the token bloat, not the thread. The package format (header line, 12-hex sha256-of-cwd file name, 10-minute window) is byte-compatible with [overclaude](https://github.com/arthur-bump-pm/overclaude): `$handoff-claude` hands the work to Claude Code, and overclaude's `/handoff codex` hands it back. Combine with `codex-swap use <name>` before relaunching when you're also switching accounts.
112
+
113
+ ### Statusline
114
+ The kit ships conservative defaults for Codex's native footer, in this order: `model-with-reasoning`, `current-dir`, `project-name`, `context-remaining`, `five-hour-limit`, and `weekly-limit`, with colors enabled. Codex renders these native fields and may omit usage-limit fields that are unavailable. Installation adds the defaults only when you do not already have `tui.status_line`; an existing user setting is preserved (an inline `tui = { … }` table is left alone with a warning). Start a new Codex CLI session after installation for the footer to reload.
115
+
116
+ OverCodex hooks use rollout data separately to issue handoff warnings as context fills. They cannot inject a custom statusline command or replace Codex's native footer.
117
+
118
+ ### AGENTS.md routing policy + custom agents
119
+ A policy block appended to `$CODEX_HOME/AGENTS.md` (loaded globally, then project `AGENTS.md` files concatenate root-down) tells Codex when to delegate and enforces read-parallel/write-serial coordination, verification floors, escalation, and final synthesis. Four custom-agent definitions under `$CODEX_HOME/agents/`, registered in `[agents]`, pin bulk scouting to Luna, implementation to Terra, review to Sol/high, and adjudication to Sol/xhigh. Routed dispatches use an explicit `agent_type` and `fork_turns = "none"`; a task name alone does not route models.
120
+
121
+ For an explicit trigger inside Codex, type `$ultracode` followed by the objective. For qualifying complex tasks, the global policy also defaults to delegation and requires the parent to explain any decision to stay serial.
122
+
123
+ When Codex opens this GitHub checkout, the root `AGENTS.md` supplies the repository-local instruction layer. Prompt it with `Activate Overcodex UltraCode in this repository` to have it inspect the global marker and run `./install.sh` when activation is requested. For OpenClaw, prompt it to run `./install-openclaw.sh`; the portable `SKILL.md` then supplies the same orchestration policy.
124
+
125
+ The detailed agent-facing activation contract is in [`AGENT-SETUP.md`](AGENT-SETUP.md). Short prompts are enough because the repository's `AGENTS.md` directs the agent to read that contract:
126
+
127
+ **Codex:** `Activate Overcodex UltraCode for Codex from https://github.com/arthur-bump-pm/overcodex. Clone it if needed, follow AGENT-SETUP.md, preserve unrelated settings, verify the roles and the test suite, then report the restart and hook-trust steps.`
128
+
129
+ **OpenClaw:** `Activate Overcodex UltraCode for OpenClaw from https://github.com/arthur-bump-pm/overcodex. Clone it if needed, follow AGENT-SETUP.md, show configuration diffs before applying them, verify the skill and agents, then run a harmless scout check.`
130
+
131
+ The complete copy-paste versions are in [`overcodex-instructions.md`](overcodex-instructions.md).
132
+
133
+ **Models and reasoning effort.** Codex's model catalog (as of Codex 0.158) defaults to `gpt-6-astra`. Every listed model accepts `low`, `medium`, `high`, and `xhigh`; `max` is also available on GPT-6 Astra/Sol/Luna and GPT-5.6 Sol/Terra/Luna; `ultra` only on `gpt-6-astra`, `gpt-6-sol`, `gpt-5.6-sol`, and `gpt-5.6-terra` (not on Luna models; the legacy `gpt-5.5` stops at `xhigh`). No model accepts none as an effort. The bundled judge uses the portable `xhigh`; reserve `max`/`ultra` for a quality-critical adjudication on a model that lists it. Installing overcodex does not replace your existing model or effort preference.
134
+
135
+ ### Hooks + skills
136
+ `SessionStart` (`matcher = "startup"`, `additionalContextLimit = 8000` so a handoff package is not spilled/middle-truncated) / `UserPromptSubmit` / `Stop` / `PreCompact` hooks, wired via a marker-wrapped `[hooks]` block at the end of `config.toml`, plus five skills under `$CODEX_HOME/skills/<name>/SKILL.md` for the handoff flow and explicit multi-agent runs.
137
+
138
+ ## Cheat sheet
139
+
140
+ | Command | Effect |
141
+ |---|---|
142
+ | `codex-swap add <name>` | Create an isolated home under `~/.codex-accounts/<name>`, link shared config/skills/hooks, print the login + hook-trust steps |
143
+ | `codex-swap use <name\|primary>` | Write the active-account marker (cold switch) — **restart codex after** |
144
+ | `codex-swap <name>` | Shorthand for `codex-swap use <name>` |
145
+ | `codex-swap which` | Print the active account and its `CODEX_HOME` (a marker naming a deleted account falls back to primary) |
146
+ | `codex-swap list` | Show registered accounts, login state, and which is active |
147
+ | `codex-swap list --json` | The same as JSON (`name`, `codexHome`, `active`, `loggedIn`) |
148
+ | `codex-swap remove <name> [--yes]` | Delete an account's directory (never primary); resets the marker if it was active |
149
+ | `codex-swap path handoff [--cwd D]` | Print this directory's pending-handoff file (also where overclaude's `/handoff codex` writes) |
150
+ | `$handoff` | (in Codex) Package this session; auto-injected on the next launch in this directory |
151
+ | `$handoff-status` | (in Codex) Show whether a package is pending here and how old it is |
152
+ | `$handoff-cancel` | (in Codex) Remove this directory's pending package |
153
+ | `$handoff-claude` | (in Codex) Hand this work to Claude Code: writes the package overclaude's SessionStart hook loads (needs overclaude) |
154
+ | `$ultracode <objective>` | (in Codex) Explicit multi-agent run with the routed roles |
155
+ | `/skills`, `/hooks` | (in Codex) Browse skills; review/trust hooks |
156
+ | `overcodex install` | (Re)install/refresh the kit — idempotent |
157
+ | `overcodex uninstall` | Remove exactly what install added |
158
+ | `overcodex doctor` | Per-account hook trust + skill check (runs `codex app-server`, no model calls) |
159
+ | `overcodex path` | Print the bundled payload directory |
160
+ | `overcodex skill-path` | Print the portable OpenClaw/Codex skill directory |
161
+ | `install-openclaw.sh` | Install the packaged skill into OpenClaw |
162
+
163
+ Or skip memorizing and **paste a prompt**:
164
+
165
+ | Paste into Codex CLI | Runs |
166
+ |---|---|
167
+ | "Hand off — context is filling up" | the `$handoff` skill (after you confirm) |
168
+ | "Switch me to my work account" | walks you through `codex-swap use work` + the restart |
169
+ | "Install overcodex on this machine" | the whole install flow (works before the kit exists) |
170
+ | "Upgrade overcodex and refresh the hooks" | `pipx upgrade overcodex && overcodex install` |
171
+
172
+ ## How it fits together
173
+
174
+ ```mermaid
175
+ flowchart TD
176
+ AH[AGENTS.md routing policy] --> HK[config.toml hooks block: SessionStart/UserPromptSubmit/Stop/PreCompact]
177
+ HK --> TR[Trusted once per account]
178
+ TR --> SK[$handoff and friends: skills in CODEX_HOME/skills]
179
+ SK --> CS[codex-swap: isolated CODEX_HOME per account]
180
+ CS --> RS[Cold restart adopts the new account]
181
+ SL[Native footer: context-remaining + available usage limits] --> SK
182
+ HK --> RW[Hooks read rollout data for handoff warnings]
183
+ RW --> SK
184
+ ```
185
+
186
+ <details>
187
+ <summary>Caveats worth knowing</summary>
188
+
189
+ - **Cold switch only.** `codex-swap` changes which `$CODEX_HOME` new `codex` processes get; a session already running keeps reading its original `auth.json` until you quit and relaunch. There is no live/hot swap in this kit.
190
+ - **Refresh-token isolation is the whole point.** Codex's refresh tokens can be single-use across copies of the same credential (open upstream bug reports) — so accounts are never file-swapped or symlinked into a shared `auth.json`. Each account's `CODEX_HOME` refreshes its own token in place, permanently separate from the others.
191
+ - **Hooks need trust, per account.** Untrusted or modified hooks simply do not run (no handoff injection, no context warnings). See "trust the hooks" above; `overcodex doctor` shows where trust is missing.
192
+ - **Hooks run arbitrary shell on your events.** Review `hooks/*.sh` before trusting them on a machine you don't fully trust, same as any hook-based tool.
193
+ - **Sessions are rollout JSONL files.** Each session is `$CODEX_HOME/sessions/YYYY/MM/DD/rollout-<timestamp>-<thread-id>.jsonl` (with a sqlite index alongside); `codex resume --last` / `codex resume <id>` read from there. The context-watch hooks read the latest `token_count` event from that file.
194
+ - Enterprise configs can set `allow_managed_hooks_only`, which stops this kit's (user-level) hooks from **running** — only managed hooks run. Check that first if the hooks never fire.
195
+
196
+ </details>
197
+
198
+ <details>
199
+ <summary>Components (file → destination)</summary>
200
+
201
+ | File | Installs to | Role |
202
+ |---|---|---|
203
+ | `bin/codex-swap` | `~/.local/bin/` | Cold account switcher: register, list, switch, `path handoff` |
204
+ | `hooks/*.sh` | `$CODEX_HOME/hooks/` | SessionStart / UserPromptSubmit / Stop / PreCompact handlers |
205
+ | `skills/<name>/SKILL.md` | `$CODEX_HOME/skills/<name>/` | `$handoff`, `$handoff-status`, `$handoff-cancel`, `$handoff-claude`, `$ultracode` |
206
+ | `config/hooks-block.toml.tpl` | marker-wrapped hooks block at the end of `config.toml` | Hook wiring — skipped if you define your own hooks (Codex's `[hooks.state]` trust records don't count) |
207
+ | `config/agents-block.toml.tpl` | `[agents]` marker block in `config.toml` | Registers the four routed roles |
208
+ | `config/statusline.toml` | `[tui]` keys in `config.toml` (markers) | Native footer defaults — only if `status_line` is unset |
209
+ | `codex/AGENTS-ULTRACODE.md` | appended to `$CODEX_HOME/AGENTS.md` (markers) | Model/effort routing policy |
210
+ | `agents/*.toml` | `$CODEX_HOME/agents/` | Pinned Luna/Terra/Sol custom subagent roles |
211
+ | `lib/overcodex_config.py` | (runs from the payload) | Validated, marker-aware `config.toml` editor used by install/uninstall |
212
+ | `shell/zshrc-snippet.sh` | `~/.zshrc` (markers) | `codex()` account wrapper, `codex-swap` PATH/alias wiring |
213
+ | `skill/overcodex-ultracode/` | OpenClaw skill root (or packaged payload) | Portable policy, role prompts, and platform adapters |
214
+
215
+ </details>
216
+
217
+ <details>
218
+ <summary>Maintainer workflow</summary>
219
+
220
+ ```bash
221
+ ./tests/run.sh # full suite in throwaway $HOMEs (also drives `codex app-server` when codex is installed)
222
+ ./sync.sh # live setup -> repo: scrub-gated diff, commit, push
223
+ ./sync.sh --release # + release gate (shellcheck + tests), version bump unless already ahead, GitHub release -> PyPI
224
+ ./sync.sh --dry-run # preview either
225
+ ```
226
+
227
+ A plain `git push` updates git installs only — **PyPI users get changes only via releases**. The scrub gate (`scrub.sh`) aborts any commit whose diff or new untracked files contain usernames, emails, or `/Users/…` paths. See `CLAUDE.md` for the full protocol.
228
+
229
+ </details>
230
+
231
+ ## Versions
232
+
233
+ | Version | Date | Status | Highlights |
234
+ |---|---|---|---|
235
+ | **0.3.1** | 2026-10-09 | ✅ released | Same as 0.3.0, with the CI Python fix that let it reach PyPI |
236
+ | 0.3.0 | 2026-10-09 | GitHub release only (CI blocked the PyPI publish) | Handoff flow ported to Codex 0.158 skills (`$handoff`, `$handoff-status`, `$handoff-cancel`, `$handoff-claude`, `$ultracode`); `codex-swap path handoff`; hook-trust guidance + `overcodex doctor`; config.toml edits validated and Codex-written tables preserved (no more data loss on uninstall/upgrade; user hooks, role overrides, file modes, CRLF and damaged markers handled safely); hooks block refreshes on upgrade; `additionalContextLimit` + `matcher = "startup"` for SessionStart; `codex()` wrapper no longer exports `CODEX_HOME`; release gate + CI; `sync.sh --dry-run` no longer writes |
237
+ | 0.2.0 | 2026-07-23 | released | Portable UltraCode orchestration (four routed agent roles, OpenClaw skill), native footer defaults |
238
+ | 0.1.1 | 2026-07-17 | released | Docs: codext hot-swap investigation |
239
+ | 0.1.0 | 2026-07-17 | released | Codex CLI port of overclaude: codex-swap, handoff, hooks, AGENTS.md routing |
240
+
241
+ ## Credits
242
+
243
+ overcodex is the Codex CLI sibling of **[overclaude](https://github.com/arthur-bump-pm/overclaude)** (same author, same packaging shape) — overclaude does hot account swapping for Claude Code; Codex CLI's credential model only allows a cold switch, so this kit is built around that constraint instead of hiding it.
244
+
245
+ ### Hot-swap and the codext fork
246
+
247
+ True hot account switching exists on Codex only via [codext](https://github.com/Loongphy/codext) — an Apache-2.0 hard fork of the Codex CLI that polls `auth.json` and reloads it in-process at idle turn boundaries (verified in its source: `tui/src/auth_watch.rs`, `login/src/auth/manager.rs`). It works, with two trade-offs `codex-swap` deliberately doesn't make: it requires running a single-maintainer fork that rebases onto each upstream release, and it still doesn't solve cross-copy refresh-token rotation — switching back to an account whose token rotated elsewhere can force a re-login (codext issue #1 confirms). `codex-swap` stays cold-but-bulletproof by isolating accounts in separate `CODEX_HOME`s where tokens never move. If OpenAI ships auth live-reload upstream, `codex-swap` grows hot for free.
248
+
249
+ ## License
250
+
251
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,230 @@
1
+ # overcodex
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/overcodex)](https://pypi.org/project/overcodex/)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
5
+ ![Platform: macOS](https://img.shields.io/badge/platform-macOS-lightgrey)
6
+
7
+ **Codex CLI, overclocked.** Cold-switch between Codex accounts, hand off to a fresh session with the `$handoff` skill before context fills up, watch usage on the native footer, and route multi-agent work with an AGENTS.md policy:
8
+
9
+ ```text
10
+ codex-swap use work # register/list accounts, then switch — restart required
11
+ $handoff # (inside Codex) package this session, resume fresh next launch
12
+
13
+ native footer: model with reasoning | current directory | project name | context remaining | 5h limit | weekly limit
14
+ ```
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ pipx install overcodex && overcodex install
20
+ ```
21
+
22
+ > **Fresh machine?** If you get `command not found: overcodex`, pipx's bin folder isn't on your PATH yet — run `pipx ensurepath && source ~/.zshrc`, then `overcodex install`. (Use `source`, not `exec zsh`: replacing the shell swallows any commands you pasted after it.)
23
+
24
+ Then register your accounts (once, per account):
25
+
26
+ ```bash
27
+ codex-swap add work # creates an isolated account home + links shared config, skills, hooks
28
+ codex-swap add personal # then log in to each: CODEX_HOME=~/.codex-accounts/work codex login
29
+ codex-swap use work # cold switch: only writes the ~/.codex-accounts/.active marker
30
+ # (shorthand: codex-swap work) — then start a new codex
31
+ ```
32
+
33
+ ### One manual step: trust the hooks (once per account)
34
+
35
+ Codex runs a hook only after you trust it. Start a **new** Codex session; when Codex shows **"Hooks need review"**, choose **"Trust all and continue"** (or inspect them first with `/hooks`). Codex keys that trust by config path (`<config path>:<event>:<group>:<handler>`, path not canonicalized), so every codex-swap account — `~/.codex-accounts/<name>/config.toml` is a different path even though it is a symlink to the shared file — asks once on its own. Any change to a hook's definition (an upgrade that changes the hooks block says so) asks again. `overcodex doctor` lists each account's hook trust status.
36
+
37
+ Then confirm the native footer shows the configured fields (Codex may omit unavailable usage-limit fields), and type `$handoff` inside Codex to hand off before you hit auto-compact.
38
+
39
+ The same routing policy is packaged as a portable skill for OpenClaw. Install it from a packaged overcodex build with `openclaw skills install "$(overcodex skill-path)" --global`, then configure the four role agent IDs described in `skill/overcodex-ultracode/references/openclaw-adapter.md`.
40
+
41
+ For agent-assisted setup, tell OpenClaw:
42
+
43
+ > Install and activate Overcodex UltraCode. Run `curl -fsSL https://raw.githubusercontent.com/arthur-bump-pm/overcodex/main/install-openclaw.sh | bash`, verify it with `openclaw skills list` and `openclaw agents list`, then configure the scout, worker, reviewer, and judge roles. Do not change credentials or existing agent settings without showing me the proposed diff first.
44
+
45
+ <details>
46
+ <summary>Other install methods, requirements, upgrading</summary>
47
+
48
+ ```bash
49
+ # uv
50
+ uv tool install overcodex && overcodex install
51
+
52
+ # from source
53
+ git clone https://github.com/arthur-bump-pm/overcodex && cd overcodex && ./install.sh
54
+ ```
55
+
56
+ Or paste this into any Codex CLI session and let it install itself:
57
+
58
+ > Install overcodex (https://github.com/arthur-bump-pm/overcodex) on this machine, fix anything its preflight complains about, and tell me what post-install steps I need to do myself.
59
+
60
+ **Requirements:** macOS, zsh, `pipx` or `uv`, Codex CLI 0.158+ (`codex --version`), `jq`. `config.toml` is only edited after a TOML validity check: `overcodex install` brings its own parser; a bare `./install.sh` needs `python3` ≥ 3.11 (or `tomli`) and otherwise leaves `config.toml` untouched and says so. No keychain daemon and no background credential engine — cold switching is just isolated `$CODEX_HOME` directories, one per account.
61
+
62
+ **Upgrade:** `pipx upgrade overcodex && overcodex install` — then re-trust the hooks in each account if the installer says they changed.
63
+
64
+ **Uninstall:** `overcodex uninstall` — removes exactly what install added (backed up), including the shared-config links `codex-swap add` created in each account; each account's `auth.json` and session state survive untouched.
65
+
66
+ The installer is idempotent and conservative: timestamped backups of everything it touches; a user's own `hooks`, `[agents]` or `status_line` settings are never overwritten; overcodex's own marker blocks are refreshed when the shipped content changes; re-running is a no-op. Codex's config writer puts the tables it adds (hook trust records, `[notice]`, `[features]`, …) inside the nearest overcodex block — install and uninstall move those below the block instead of deleting them, and a sentinel `[hooks.state]` table after the hooks block makes Codex append below it in the first place.
67
+
68
+ </details>
69
+
70
+ ## What you get
71
+
72
+ ### `codex-swap` — cold account switching
73
+ Each account gets its own isolated `CODEX_HOME` (a separate `auth.json`, never a copied/overwritten one — refresh tokens can be single-use across copies, so isolation is the only safe design). `codex-swap use <account>` only records which account is active (`~/.codex-accounts/.active`); the `codex()` shell wrapper passes that account's home to each new `codex` process (`CODEX_HOME=… command codex`, never exported into your shell, and your own `CODEX_HOME` is left alone when no account is active). **This is a cold switch**: any Codex session already running keeps its old credentials until you quit and relaunch it. There is no hot mid-session swap here — if you need that, it's overclaude's `/swap` for Claude Code, not this.
74
+
75
+ ### `$handoff` — escape context bloat, keep the thread
76
+
77
+ Codex 0.158 removed `/prompts:*` custom prompts, so the handoff flow ships as **Codex skills** in `$CODEX_HOME/skills/` (shared into every codex-swap account). Invoke one by typing its `$` mention anywhere in your message — `$handoff`, or `$handoff now please` — or browse them with `/skills`.
78
+
79
+ ```mermaid
80
+ flowchart LR
81
+ A[Context fills up] --> B[Hook offers a handoff at 60/75/85%]
82
+ B --> C[You type $handoff]
83
+ C --> D[Codex packages goals, state, next steps]
84
+ D --> E[You exit and relaunch codex in the same directory]
85
+ E --> F[SessionStart hook injects the package]
86
+ F --> G[Fresh session, ctx near zero]
87
+ G --> A
88
+ ```
89
+
90
+ You lose the token bloat, not the thread. The package format (header line, 12-hex sha256-of-cwd file name, 10-minute window) is byte-compatible with [overclaude](https://github.com/arthur-bump-pm/overclaude): `$handoff-claude` hands the work to Claude Code, and overclaude's `/handoff codex` hands it back. Combine with `codex-swap use <name>` before relaunching when you're also switching accounts.
91
+
92
+ ### Statusline
93
+ The kit ships conservative defaults for Codex's native footer, in this order: `model-with-reasoning`, `current-dir`, `project-name`, `context-remaining`, `five-hour-limit`, and `weekly-limit`, with colors enabled. Codex renders these native fields and may omit usage-limit fields that are unavailable. Installation adds the defaults only when you do not already have `tui.status_line`; an existing user setting is preserved (an inline `tui = { … }` table is left alone with a warning). Start a new Codex CLI session after installation for the footer to reload.
94
+
95
+ OverCodex hooks use rollout data separately to issue handoff warnings as context fills. They cannot inject a custom statusline command or replace Codex's native footer.
96
+
97
+ ### AGENTS.md routing policy + custom agents
98
+ A policy block appended to `$CODEX_HOME/AGENTS.md` (loaded globally, then project `AGENTS.md` files concatenate root-down) tells Codex when to delegate and enforces read-parallel/write-serial coordination, verification floors, escalation, and final synthesis. Four custom-agent definitions under `$CODEX_HOME/agents/`, registered in `[agents]`, pin bulk scouting to Luna, implementation to Terra, review to Sol/high, and adjudication to Sol/xhigh. Routed dispatches use an explicit `agent_type` and `fork_turns = "none"`; a task name alone does not route models.
99
+
100
+ For an explicit trigger inside Codex, type `$ultracode` followed by the objective. For qualifying complex tasks, the global policy also defaults to delegation and requires the parent to explain any decision to stay serial.
101
+
102
+ When Codex opens this GitHub checkout, the root `AGENTS.md` supplies the repository-local instruction layer. Prompt it with `Activate Overcodex UltraCode in this repository` to have it inspect the global marker and run `./install.sh` when activation is requested. For OpenClaw, prompt it to run `./install-openclaw.sh`; the portable `SKILL.md` then supplies the same orchestration policy.
103
+
104
+ The detailed agent-facing activation contract is in [`AGENT-SETUP.md`](AGENT-SETUP.md). Short prompts are enough because the repository's `AGENTS.md` directs the agent to read that contract:
105
+
106
+ **Codex:** `Activate Overcodex UltraCode for Codex from https://github.com/arthur-bump-pm/overcodex. Clone it if needed, follow AGENT-SETUP.md, preserve unrelated settings, verify the roles and the test suite, then report the restart and hook-trust steps.`
107
+
108
+ **OpenClaw:** `Activate Overcodex UltraCode for OpenClaw from https://github.com/arthur-bump-pm/overcodex. Clone it if needed, follow AGENT-SETUP.md, show configuration diffs before applying them, verify the skill and agents, then run a harmless scout check.`
109
+
110
+ The complete copy-paste versions are in [`overcodex-instructions.md`](overcodex-instructions.md).
111
+
112
+ **Models and reasoning effort.** Codex's model catalog (as of Codex 0.158) defaults to `gpt-6-astra`. Every listed model accepts `low`, `medium`, `high`, and `xhigh`; `max` is also available on GPT-6 Astra/Sol/Luna and GPT-5.6 Sol/Terra/Luna; `ultra` only on `gpt-6-astra`, `gpt-6-sol`, `gpt-5.6-sol`, and `gpt-5.6-terra` (not on Luna models; the legacy `gpt-5.5` stops at `xhigh`). No model accepts none as an effort. The bundled judge uses the portable `xhigh`; reserve `max`/`ultra` for a quality-critical adjudication on a model that lists it. Installing overcodex does not replace your existing model or effort preference.
113
+
114
+ ### Hooks + skills
115
+ `SessionStart` (`matcher = "startup"`, `additionalContextLimit = 8000` so a handoff package is not spilled/middle-truncated) / `UserPromptSubmit` / `Stop` / `PreCompact` hooks, wired via a marker-wrapped `[hooks]` block at the end of `config.toml`, plus five skills under `$CODEX_HOME/skills/<name>/SKILL.md` for the handoff flow and explicit multi-agent runs.
116
+
117
+ ## Cheat sheet
118
+
119
+ | Command | Effect |
120
+ |---|---|
121
+ | `codex-swap add <name>` | Create an isolated home under `~/.codex-accounts/<name>`, link shared config/skills/hooks, print the login + hook-trust steps |
122
+ | `codex-swap use <name\|primary>` | Write the active-account marker (cold switch) — **restart codex after** |
123
+ | `codex-swap <name>` | Shorthand for `codex-swap use <name>` |
124
+ | `codex-swap which` | Print the active account and its `CODEX_HOME` (a marker naming a deleted account falls back to primary) |
125
+ | `codex-swap list` | Show registered accounts, login state, and which is active |
126
+ | `codex-swap list --json` | The same as JSON (`name`, `codexHome`, `active`, `loggedIn`) |
127
+ | `codex-swap remove <name> [--yes]` | Delete an account's directory (never primary); resets the marker if it was active |
128
+ | `codex-swap path handoff [--cwd D]` | Print this directory's pending-handoff file (also where overclaude's `/handoff codex` writes) |
129
+ | `$handoff` | (in Codex) Package this session; auto-injected on the next launch in this directory |
130
+ | `$handoff-status` | (in Codex) Show whether a package is pending here and how old it is |
131
+ | `$handoff-cancel` | (in Codex) Remove this directory's pending package |
132
+ | `$handoff-claude` | (in Codex) Hand this work to Claude Code: writes the package overclaude's SessionStart hook loads (needs overclaude) |
133
+ | `$ultracode <objective>` | (in Codex) Explicit multi-agent run with the routed roles |
134
+ | `/skills`, `/hooks` | (in Codex) Browse skills; review/trust hooks |
135
+ | `overcodex install` | (Re)install/refresh the kit — idempotent |
136
+ | `overcodex uninstall` | Remove exactly what install added |
137
+ | `overcodex doctor` | Per-account hook trust + skill check (runs `codex app-server`, no model calls) |
138
+ | `overcodex path` | Print the bundled payload directory |
139
+ | `overcodex skill-path` | Print the portable OpenClaw/Codex skill directory |
140
+ | `install-openclaw.sh` | Install the packaged skill into OpenClaw |
141
+
142
+ Or skip memorizing and **paste a prompt**:
143
+
144
+ | Paste into Codex CLI | Runs |
145
+ |---|---|
146
+ | "Hand off — context is filling up" | the `$handoff` skill (after you confirm) |
147
+ | "Switch me to my work account" | walks you through `codex-swap use work` + the restart |
148
+ | "Install overcodex on this machine" | the whole install flow (works before the kit exists) |
149
+ | "Upgrade overcodex and refresh the hooks" | `pipx upgrade overcodex && overcodex install` |
150
+
151
+ ## How it fits together
152
+
153
+ ```mermaid
154
+ flowchart TD
155
+ AH[AGENTS.md routing policy] --> HK[config.toml hooks block: SessionStart/UserPromptSubmit/Stop/PreCompact]
156
+ HK --> TR[Trusted once per account]
157
+ TR --> SK[$handoff and friends: skills in CODEX_HOME/skills]
158
+ SK --> CS[codex-swap: isolated CODEX_HOME per account]
159
+ CS --> RS[Cold restart adopts the new account]
160
+ SL[Native footer: context-remaining + available usage limits] --> SK
161
+ HK --> RW[Hooks read rollout data for handoff warnings]
162
+ RW --> SK
163
+ ```
164
+
165
+ <details>
166
+ <summary>Caveats worth knowing</summary>
167
+
168
+ - **Cold switch only.** `codex-swap` changes which `$CODEX_HOME` new `codex` processes get; a session already running keeps reading its original `auth.json` until you quit and relaunch. There is no live/hot swap in this kit.
169
+ - **Refresh-token isolation is the whole point.** Codex's refresh tokens can be single-use across copies of the same credential (open upstream bug reports) — so accounts are never file-swapped or symlinked into a shared `auth.json`. Each account's `CODEX_HOME` refreshes its own token in place, permanently separate from the others.
170
+ - **Hooks need trust, per account.** Untrusted or modified hooks simply do not run (no handoff injection, no context warnings). See "trust the hooks" above; `overcodex doctor` shows where trust is missing.
171
+ - **Hooks run arbitrary shell on your events.** Review `hooks/*.sh` before trusting them on a machine you don't fully trust, same as any hook-based tool.
172
+ - **Sessions are rollout JSONL files.** Each session is `$CODEX_HOME/sessions/YYYY/MM/DD/rollout-<timestamp>-<thread-id>.jsonl` (with a sqlite index alongside); `codex resume --last` / `codex resume <id>` read from there. The context-watch hooks read the latest `token_count` event from that file.
173
+ - Enterprise configs can set `allow_managed_hooks_only`, which stops this kit's (user-level) hooks from **running** — only managed hooks run. Check that first if the hooks never fire.
174
+
175
+ </details>
176
+
177
+ <details>
178
+ <summary>Components (file → destination)</summary>
179
+
180
+ | File | Installs to | Role |
181
+ |---|---|---|
182
+ | `bin/codex-swap` | `~/.local/bin/` | Cold account switcher: register, list, switch, `path handoff` |
183
+ | `hooks/*.sh` | `$CODEX_HOME/hooks/` | SessionStart / UserPromptSubmit / Stop / PreCompact handlers |
184
+ | `skills/<name>/SKILL.md` | `$CODEX_HOME/skills/<name>/` | `$handoff`, `$handoff-status`, `$handoff-cancel`, `$handoff-claude`, `$ultracode` |
185
+ | `config/hooks-block.toml.tpl` | marker-wrapped hooks block at the end of `config.toml` | Hook wiring — skipped if you define your own hooks (Codex's `[hooks.state]` trust records don't count) |
186
+ | `config/agents-block.toml.tpl` | `[agents]` marker block in `config.toml` | Registers the four routed roles |
187
+ | `config/statusline.toml` | `[tui]` keys in `config.toml` (markers) | Native footer defaults — only if `status_line` is unset |
188
+ | `codex/AGENTS-ULTRACODE.md` | appended to `$CODEX_HOME/AGENTS.md` (markers) | Model/effort routing policy |
189
+ | `agents/*.toml` | `$CODEX_HOME/agents/` | Pinned Luna/Terra/Sol custom subagent roles |
190
+ | `lib/overcodex_config.py` | (runs from the payload) | Validated, marker-aware `config.toml` editor used by install/uninstall |
191
+ | `shell/zshrc-snippet.sh` | `~/.zshrc` (markers) | `codex()` account wrapper, `codex-swap` PATH/alias wiring |
192
+ | `skill/overcodex-ultracode/` | OpenClaw skill root (or packaged payload) | Portable policy, role prompts, and platform adapters |
193
+
194
+ </details>
195
+
196
+ <details>
197
+ <summary>Maintainer workflow</summary>
198
+
199
+ ```bash
200
+ ./tests/run.sh # full suite in throwaway $HOMEs (also drives `codex app-server` when codex is installed)
201
+ ./sync.sh # live setup -> repo: scrub-gated diff, commit, push
202
+ ./sync.sh --release # + release gate (shellcheck + tests), version bump unless already ahead, GitHub release -> PyPI
203
+ ./sync.sh --dry-run # preview either
204
+ ```
205
+
206
+ A plain `git push` updates git installs only — **PyPI users get changes only via releases**. The scrub gate (`scrub.sh`) aborts any commit whose diff or new untracked files contain usernames, emails, or `/Users/…` paths. See `CLAUDE.md` for the full protocol.
207
+
208
+ </details>
209
+
210
+ ## Versions
211
+
212
+ | Version | Date | Status | Highlights |
213
+ |---|---|---|---|
214
+ | **0.3.1** | 2026-10-09 | ✅ released | Same as 0.3.0, with the CI Python fix that let it reach PyPI |
215
+ | 0.3.0 | 2026-10-09 | GitHub release only (CI blocked the PyPI publish) | Handoff flow ported to Codex 0.158 skills (`$handoff`, `$handoff-status`, `$handoff-cancel`, `$handoff-claude`, `$ultracode`); `codex-swap path handoff`; hook-trust guidance + `overcodex doctor`; config.toml edits validated and Codex-written tables preserved (no more data loss on uninstall/upgrade; user hooks, role overrides, file modes, CRLF and damaged markers handled safely); hooks block refreshes on upgrade; `additionalContextLimit` + `matcher = "startup"` for SessionStart; `codex()` wrapper no longer exports `CODEX_HOME`; release gate + CI; `sync.sh --dry-run` no longer writes |
216
+ | 0.2.0 | 2026-07-23 | released | Portable UltraCode orchestration (four routed agent roles, OpenClaw skill), native footer defaults |
217
+ | 0.1.1 | 2026-07-17 | released | Docs: codext hot-swap investigation |
218
+ | 0.1.0 | 2026-07-17 | released | Codex CLI port of overclaude: codex-swap, handoff, hooks, AGENTS.md routing |
219
+
220
+ ## Credits
221
+
222
+ overcodex is the Codex CLI sibling of **[overclaude](https://github.com/arthur-bump-pm/overclaude)** (same author, same packaging shape) — overclaude does hot account swapping for Claude Code; Codex CLI's credential model only allows a cold switch, so this kit is built around that constraint instead of hiding it.
223
+
224
+ ### Hot-swap and the codext fork
225
+
226
+ True hot account switching exists on Codex only via [codext](https://github.com/Loongphy/codext) — an Apache-2.0 hard fork of the Codex CLI that polls `auth.json` and reloads it in-process at idle turn boundaries (verified in its source: `tui/src/auth_watch.rs`, `login/src/auth/manager.rs`). It works, with two trade-offs `codex-swap` deliberately doesn't make: it requires running a single-maintainer fork that rebases onto each upstream release, and it still doesn't solve cross-copy refresh-token rotation — switching back to an account whose token rotated elsewhere can force a re-login (codext issue #1 confirms). `codex-swap` stays cold-but-bulletproof by isolating accounts in separate `CODEX_HOME`s where tokens never move. If OpenAI ships auth live-reload upstream, `codex-swap` grows hot for free.
227
+
228
+ ## License
229
+
230
+ MIT — see [LICENSE](LICENSE).