@bumpyclock/pi-codex-compat
v0.2.0
Published
Pi extension consolidating OpenAI Codex fast mode, native compaction, named OAuth accounts, live quota, historical usage, and token throughput status.
Maintainers
Readme
@bumpyclock/pi-codex-compat
One Pi extension that consolidates OpenAI/Codex-focused behavior:
/fastpriority service tier (service_tier: "priority") for verified OpenAI Codex Responses requests- OpenAI native compaction replay for
openaiandopenai-codexResponses APIs - Named OpenAI Codex OAuth accounts (
/accounts) - Live Codex subscription quota (
/usage) - Historical Pi/Codex CLI cost report (
/usage-history) - Token throughput status (all providers)
- Unified
/codexmanager menu
Minimum tested Pi release: 0.82.1 (@earendil-works/*).
Install
pi install npm:@bumpyclock/pi-codex-compatOr from a local checkout:
pi install /absolute/path/to/pi-codex-compatImportant migration notes
Do not load this package together with:
- local
openai-codex-fast-mode.ts - local
openai-compaction - local
usage.ts/token-rate-status.ts pi-accounts/pi-codex-accountspi-usage/pi-codex-usage
Duplicate extensions can refresh the same rotating credential or register conflicting commands.
Disable or remove those local/extension copies before enabling this package.
Commands
| Command | Modes | Behavior |
| --- | --- | --- |
| /codex | TUI menu | Accounts, Quota, Fast mode, Historical usage, Settings, Status, Help |
| /codex status | TUI, RPC | Feature status |
| /codex help | TUI, RPC | Help text |
| /accounts | TUI | Named Codex OAuth account manager |
| /usage | TUI | Live Codex subscription quota |
| /usage-history | TUI, RPC | Agent-driven historical cost report |
| /fast [toggle\|on\|off\|status] | TUI, RPC | Priority tier toggle |
| Alt+Shift+F | TUI | Toggle fast mode |
Print and JSON modes throw a clear unsupported-mode error for these commands because Pi 0.82.1 has no observable extension-command output channel there. RPC receives a notification for TUI-only menus.
Settings
Canonical user settings:
~/.pi/agent/pi-codex-compat.jsonTrusted project overrides (non-secret only):
<workspace>/.pi/pi-codex-compat.jsonPrivate Codex account credentials:
~/.pi/agent/pi-codex-compat-accounts.jsonExample:
{
"fastMode": { "enabled": false },
"openaiNativeCompaction": {
"enabled": true,
"debug": false,
"redactSensitiveData": true,
"supportedProviders": ["openai", "openai-codex"],
"supportedApis": ["openai-responses", "openai-codex-responses"]
},
"tps": {
"enabled": true,
"notifyOnComplete": true
},
"auth": {
"disableApiKeyWhenCodexAuthenticated": false
}
}Auth cost-safety policy
auth.disableApiKeyWhenCodexAuthenticated (default false) is an opt-in guard:
- When on and a Codex OAuth login exists (default Pi
openai-codexOAuth inauth.json, or a named account selected by this extension), every exact provideropenaimodel is hidden — including built-ins andmodels.jsonadditions. - Stale sessions still selecting
openaiare blocked on each turn, compaction, and summarizing tree navigation. Non-summarizing tree navigation stays allowed. openai-codexand unrelated providers are unchanged. The policy never auto-switches models and never mutatesOPENAI_API_KEYor credential files.- When auth storage cannot be read, presence is treated as unknown and the policy fails closed while enabled.
- Toggle from
/codex→ Settings. Status showsDirect OpenAI API key: allowed|blocked while Codex is logged in.
Precedence
Defaults → old package-local compaction settings → legacy global settings.json → canonical user settings → legacy project settings.json → canonical project settings → PI_OPENAI_NATIVE_COMPACTION_* environment overrides.
Canonical values win over legacy values at the same scope. Environment overrides win over all files. Validated recognized values are migrated into canonical files; legacy sources are retained for rollback.
Legacy sources consulted when canonical values are absent:
~/.pi/agent/settings.json→extensionSettings.openaiCodexFastMode~/.pi/agent/extensions/openai-compaction/settings.jsonopenaiNativeCompactionin global/projectsettings.jsonPI_OPENAI_NATIVE_COMPACTION_*pi-accounts.json→ only theopenai-codexprovider sectionpi-codex-accounts.json/codex-accounts.json
Security and failure behavior
- Account activation failures fail closed for
openai-codex(no silent fallback credential). - When
auth.disableApiKeyWhenCodexAuthenticatedis enabled, unknown/corrupt Codex auth storage fails closed for directopenaiAPI-key use (hide/block with a redacted error). - The auth.json presence reader is extension-owned and read-only: it never creates or writes
auth.json, and never logs token fields. - Compaction failures fail open to Pi's normal compaction.
- Quota requests send credentials only to the official ChatGPT origin (
https://chatgpt.com) and use bounded response reads. - Debug artifacts redact authorization headers, API keys, JWT-like values, and exact credential strings.
- Credential files use private directory permissions and mode
0600on POSIX. - Pi extensions run with full user permissions. Only install packages you trust. See Pi's unsandboxed extension trust model.
Development
npm install
npm run format
npm run check
npm run pack:dry
npm run smoke:piReleases
Merges to main update a Release Please pull request. Merging that release pull request creates a GitHub release and publishes the matching package version through .github/workflows/release.yml.
The workflow uses npm trusted publishing with GitHub Actions OIDC and provenance; it does not require a long-lived npm token. Manual runs default to a dry run. Choose release only when package.json contains the version to release.
License
MIT. See LICENSE and NOTICES.md for adapted upstream attribution (Jordy Van Domselaar; narumiruna).
