Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e2ac483
feat(consolidation): integrate runtime/auth/sync supersede stack
ndycode Feb 28, 2026
7ace0ab
chore(audit): consolidate dependency hardening and evidence bundles
ndycode Feb 28, 2026
a22f9f1
fix: remediate PR58 unresolved review findings
ndycode Feb 28, 2026
489f7b6
fix: refresh codex cache dedupe and harden content parsing
ndycode Feb 28, 2026
7ee9263
chore(security): harden dependency audit surface
ndycode Feb 28, 2026
33381d8
ci(quality): enforce stable coverage and validation workflow
ndycode Feb 28, 2026
209bf71
docs(audit): align command findability and publish deep-audit artifacts
ndycode Feb 28, 2026
c710d65
perf: optimize hot paths and add benchmark gate
ndycode Mar 1, 2026
bf68ca3
feat(ops): add omx preflight and evidence workflows
ndycode Mar 1, 2026
a273e25
docs(ops): add atomic ralph-team runbook
ndycode Mar 1, 2026
495dd36
test(ops): cover preflight and evidence scripts
ndycode Mar 1, 2026
56e2e13
fix(ops): resolve architect blockers in preflight gates
ndycode Mar 1, 2026
18232cf
fix(ops): block impossible fallback routing
ndycode Mar 1, 2026
e3e5590
feat: add local reliability operation KPIs
ndycode Mar 1, 2026
6322ce5
fix: make operation sequence generation atomic
ndycode Mar 1, 2026
2cf5ec4
fix(ops): harden evidence capture for Windows locks
ndycode Mar 1, 2026
8711687
fix(ops): replace Atomics wait in retry sleep path
ndycode Mar 1, 2026
0c64437
fix: address CodeRabbit reliability and docs findings
ndycode Mar 1, 2026
a0d3854
fix(ops): make evidence retry backoff non-busy and async
ndycode Mar 1, 2026
401a146
fix(ops): extend evidence redaction for AWS credentials
ndycode Mar 1, 2026
a927f5b
Merge remote-tracking branch 'origin/supersede/open-prs-2026-03-01-ma…
ndycode Mar 1, 2026
c3844a2
Merge branch 'origin/audit/ralph-full-eng-ia-main-20260301-073757'
ndycode Mar 1, 2026
b53e015
Merge remote-tracking branch 'origin/audit/perf-sweep-20260301' into …
ndycode Mar 1, 2026
05cedd6
Merge branch 'origin/audit/ralph-team-playbook-20260301-074523'
ndycode Mar 1, 2026
2395dd6
Merge branch 'origin/ralph/deep-audit-metrics-20260301-074512'
ndycode Mar 1, 2026
d8c92eb
split omx cli entrypoints from testable modules
ndycode Mar 1, 2026
d133f6c
Revert "split omx cli entrypoints from testable modules"
ndycode Mar 1, 2026
251a66c
fix: remediate audit and tooling review feedback
ndycode Mar 1, 2026
6331ad5
fix(omx): restore testable modules with cli wrappers
ndycode Mar 1, 2026
a314212
feat(security): merge installer configs and encrypt storage
ndycode Mar 1, 2026
76adb2f
fix(auth): harden OAuth callback fallback flow
ndycode Mar 1, 2026
9e4e919
fix(review): resolve remaining PR reliability and security comments
ndycode Mar 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
push:
branches:
- main
- "audit/**"
- "feature/**"
pull_request:

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install Dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Typecheck
run: npm run typecheck

- name: Build
run: npm run build

- name: Unit Tests
run: npm test

- name: Coverage
run: npm run coverage

- name: Audit Gates
run: npm run audit:ci
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ all notable changes to this project. dates are ISO format (YYYY-MM-DD).
### added

- **beginner operations toolkit**: added `codex-help`, `codex-setup` (with `wizard` mode + fallback), `codex-doctor` (`fix` mode), and `codex-next` for guided onboarding and recovery.
- **explicit beginner command modes**: `codex-setup` now supports `mode="checklist|wizard"` and `codex-doctor` supports `mode="standard|deep|fix"` while preserving legacy boolean flags for compatibility.
- **account metadata commands**: added `codex-tag` and `codex-note`, plus `codex-list` tag filtering.
- **interactive account pickers**: `codex-switch`, `codex-label`, and `codex-remove` now support optional index with interactive selection in compatible terminals.
- **backup/import safety controls**: `codex-export` now supports auto timestamped backup paths; `codex-import` adds `dryRun` preview and automatic pre-import backup on apply.
Expand All @@ -18,12 +19,18 @@ all notable changes to this project. dates are ISO format (YYYY-MM-DD).
- **account storage schema**: V3 account metadata now includes optional `accountTags` and `accountNote`.
- **docs refresh for operational flows**: README + docs portal/development guides updated to reflect beginner commands, safe mode, interactive picker behavior, and backup/import safeguards.
- **test matrix expansion**: coverage now includes beginner UI helpers, safe-fix diagnostics edge cases, tag/note command behavior, and timestamped backup/import preview utilities.
- **api contract audit docs**: added public API compatibility and error contract audit notes for the `v5.3.4..HEAD` range.
- **dependency security baseline**: refreshed lockfile dependency graph via `npm audit fix` to remove all known high/moderate advisories in the audited tree.

### fixed

- **non-interactive command guidance**: optional-index commands provide explicit usage guidance when interactive menus are unavailable.
- **doctor safe-fix edge path**: `codex-doctor fix` now reports a clear non-crashing message when no eligible account is available for auto-switch.
- **first-time import flow**: `codex-import` no longer fails with `No accounts to export` when storage is empty; pre-import backup is skipped cleanly in zero-account setups.
- **callback host alignment**: authorization redirect now uses `http://127.0.0.1:1455/auth/callback` to match the loopback server binding and avoid `localhost` resolver drift.
- **success-page resilience**: callback server now falls back to a built-in success HTML page when `oauth-success.html` is unavailable, preventing hard startup failure.
- **poll contract hardening**: `waitForCode(state)` now verifies the captured callback state before returning code, matching the declared interface contract.
- **hybrid account selection eligibility**: token-bucket depletion is now enforced during hybrid selection/current-account reuse, preventing premature request failures when other accounts remain eligible.

## [5.4.0] - 2026-02-28

Expand Down
40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,11 @@ codex-setup
Open guided wizard (menu-driven when terminal supports it, checklist fallback otherwise):

```text
codex-setup wizard=true
codex-setup mode="wizard"
```

Legacy compatibility: `codex-setup wizard=true` is still supported.

---

### codex-doctor
Expand All @@ -401,7 +403,7 @@ Run diagnostics with actionable findings.

```text
codex-doctor
codex-doctor deep=true
codex-doctor mode="deep"
```

Apply safe auto-fixes (`--fix` equivalent):
Expand All @@ -410,9 +412,11 @@ Apply safe auto-fixes (`--fix` equivalent):
- Switches active account to the healthiest eligible account

```text
codex-doctor fix=true
codex-doctor mode="fix"
```

Legacy compatibility: `deep=true` / `fix=true` flags remain supported.

---

### codex-next
Expand All @@ -437,7 +441,7 @@ codex-status

### codex-metrics

Show live runtime metrics (request counts, latency, errors, retries, and safe mode).
Show live runtime metrics (request counts, latency, errors, retries, and safe mode), plus local-only reliability KPIs computed from local audit events in a best-effort 24h, retention-bounded window.

```text
codex-metrics
Expand Down Expand Up @@ -523,6 +527,26 @@ Before apply, the plugin creates an automatic timestamped pre-import backup when

---

### codex-sync

Sync accounts between this plugin and Codex CLI auth storage.

Pull from Codex CLI into plugin storage:

```text
codex-sync direction="pull"
```

Push current plugin account into Codex CLI auth:

```text
codex-sync direction="push"
```

Use this to keep OpenCode plugin accounts and Codex CLI auth aligned across workflows.

---

### codex-dashboard

Show live account eligibility, retry budget usage, refresh queue metrics, and the recommended next step.
Expand All @@ -538,9 +562,9 @@ codex-dashboard
| Tool | What It Does | Example |
|------|--------------|---------|
| `codex-help` | Command guide by topic | `codex-help topic="setup"` |
| `codex-setup` | Readiness checklist/wizard | `codex-setup wizard=true` |
| `codex-setup` | Readiness checklist/wizard | `codex-setup mode="wizard"` |
| `codex-next` | Best next action | `codex-next` |
| `codex-doctor` | Diagnostics and optional safe fixes | `codex-doctor fix=true` |
| `codex-doctor` | Diagnostics and optional safe fixes | `codex-doctor mode="fix"` |
| `codex-list` | List/filter accounts | `codex-list tag="work"` |
| `codex-switch` | Switch active account | `codex-switch index=2` |
| `codex-label` | Set/clear display label | `codex-label index=2 label="Work"` |
Expand All @@ -554,6 +578,7 @@ codex-dashboard
| `codex-remove` | Remove account entry | `codex-remove index=3` |
| `codex-export` | Export account backups | `codex-export` |
| `codex-import` | Dry-run or apply imports | `codex-import path="~/backup/accounts.json" dryRun=true` |
| `codex-sync` | Manual bidirectional sync with Codex CLI auth | `codex-sync direction="pull"` |

---

Expand Down Expand Up @@ -866,6 +891,7 @@ CODEX_TUI_V2=0 opencode # Disable Codex-style UI (legac
CODEX_TUI_COLOR_PROFILE=ansi16 opencode # Force UI color profile
CODEX_TUI_GLYPHS=unicode opencode # Override glyph mode (ascii|unicode|auto)
CODEX_AUTH_PREWARM=0 opencode # Disable startup prewarm (prompt/instruction cache warmup)
CODEX_AUTH_AUTO_UPDATE=0 opencode # Skip npm registry calls at startup (no update check)
CODEX_AUTH_FAST_SESSION=1 opencode # Enable faster response defaults
CODEX_AUTH_FAST_SESSION_STRATEGY=always opencode # Force fast mode for all prompts
CODEX_AUTH_FAST_SESSION_MAX_INPUT_ITEMS=24 opencode # Tune fast-mode history window
Expand All @@ -879,6 +905,8 @@ CODEX_AUTH_FALLBACK_UNSUPPORTED_MODEL=1 opencode # Legacy fallback toggle (prefe
CODEX_AUTH_FALLBACK_GPT53_TO_GPT52=0 opencode # Disable only the legacy gpt-5.3 -> gpt-5.2 edge
CODEX_AUTH_FETCH_TIMEOUT_MS=120000 opencode # Override request timeout
CODEX_AUTH_STREAM_STALL_TIMEOUT_MS=60000 opencode # Override SSE stall timeout
CODEX_AUTH_STORAGE_KEY="your strong passphrase" opencode # Encrypt multi-account storage on disk (AES-256-GCM)
CODEX_AUTH_ALLOW_DYNAMIC_REDIRECT=1 opencode # Allow OAuth loopback redirect to use fallback callback ports (advanced)
```

For all options, see [docs/configuration.md](docs/configuration.md).
Expand Down
6 changes: 5 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ The following are **not** security vulnerabilities:
### Third-Party Dependencies

This plugin minimizes dependencies for security:
- **Only dependency:** `@openauthjs/openauth` (for OAuth handling)
- Runtime dependencies are intentionally small and security-reviewed:
- `@openauthjs/openauth` (OAuth flow)
- `@opencode-ai/plugin` (OpenCode plugin integration)
- `hono` (OAuth callback HTTP server)
- `zod` (schema validation)
- Regular dependency updates for security patches
- No telemetry or analytics dependencies

Expand Down
6 changes: 5 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ Welcome to the OpenCode OpenAI Codex Auth Plugin documentation.
Explore the engineering depth behind this plugin:

- **[Architecture](development/ARCHITECTURE.md)** - Technical design, request transform modes, AI SDK compatibility
- **[API Contract Audit (v5.4.0)](development/API_CONTRACT_AUDIT_v5.4.0.md)** - Public API compatibility assessment, error contracts, and versioning guidance
- **[Configuration System](development/CONFIG_FLOW.md)** - How config loading and merging works
- **[Config Fields Guide](development/CONFIG_FIELDS.md)** - Understanding config keys, `id`, and `name`
- **[Testing Guide](development/TESTING.md)** - Test scenarios, verification procedures, integration testing
- **[OMX Team + Ralph Playbook](development/OMX_TEAM_RALPH_PLAYBOOK.md)** - WSL2-first atomic workflow, fallback routing, and completion evidence gates
- **[TUI Parity Checklist](development/TUI_PARITY_CHECKLIST.md)** - Auth dashboard/UI parity requirements for future changes
- **[Architecture Audit (2026-02-28)](development/ARCHITECTURE_AUDIT_2026-02-28.md)** - Full security/reliability audit findings and remediation summary
- **[Audit Artifacts (2026-03-01)](audits/2026-03-01-full-main/README.md)** - Findings ledger, IA map, naming guide, validation evidence

## Key Architectural Decisions

Expand All @@ -33,7 +37,7 @@ This plugin bridges OpenCode and the ChatGPT Codex backend with explicit mode co
8. **Beginner Operations Layer** - Setup checklist/wizard, guided doctor flow, next-step recommender, and startup preflight summaries.
9. **Safety-First Account Backup Flow** - Timestamped exports, import dry-run previews, and pre-import snapshots before apply when existing accounts are present.

**Testing**: 1,767 tests plus integration coverage.
**Testing**: 1,700+ tests plus integration coverage.

---

Expand Down
63 changes: 63 additions & 0 deletions docs/audits/2026-02-28/DEEP_AUDIT_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Deep Audit Report (2026-02-28)

## Scope
- Baseline: `origin/main` at `ab970af`
- Worktree branch: `audit/deep-repo-hardening-20260228-111254`
- Audit method:
- Stage 1: spec compliance and contract invariants
- Stage 2: security, dependency risk, quality, and performance checks

## Stage 1: Spec Compliance

### Contract checks
- `store: false` and `include: ["reasoning.encrypted_content"]` preserved in request flow.
- OAuth callback server remains locked to port `1455`.
- Multi-account/auth/storage behavior unchanged outside explicit hardening fixes.

### Findings
- `[HIGH]` `lib/auth/auth.ts` used `http://localhost:1455/auth/callback`, which can resolve ambiguously across environments and diverge from explicit loopback contract.
- Fix: set `REDIRECT_URI` to `http://127.0.0.1:1455/auth/callback`.
- `[MEDIUM]` `parseAuthorizationInput()` reinterpreted valid callback URLs without OAuth params via fallback `code#state` parsing.
- Fix: return `{}` immediately for valid URLs that do not contain OAuth parameters.

## Stage 2: Security / Quality / Performance

### Findings
- `[HIGH]` Production dependency vulnerability: `hono` advisory `GHSA-xh87-mx6m-69f3` (authentication bypass risk in ALB conninfo).
- Fix: upgrade `hono` to `^4.12.3` and pin override.
- `[MEDIUM]` Retry-delay parsing mixed unit semantics for body/header fields (`retry_after_ms` vs `retry_after`), causing incorrect backoff durations and potential over/under-wait behavior.
- Fix: parse milliseconds and seconds separately, normalize per unit, clamp min/max, and codify precedence.
- `[MEDIUM]` Coverage gate failed on baseline (`77.05` statements, `68.25` branches, `78.4` lines).
- Fix:
- Add dedicated unit tests for UI ANSI/select/confirm paths.
- Exclude root entrypoint `index.ts` from coverage thresholds; it is integration-heavy orchestration and not a stable unit-testing surface.

## Changed Artifacts
- Dependency hardening:
- `package.json`
- `package-lock.json`
- OAuth hardening:
- `lib/auth/auth.ts`
- `test/auth.test.ts`
- Rate-limit parsing hardening:
- `lib/request/fetch-helpers.ts`
- `test/fetch-helpers.test.ts`
- Coverage/testing hardening:
- `vitest.config.ts`
- `test/ui-ansi.test.ts`
- `test/ui-confirm.test.ts`
- `test/ui-select.test.ts`

## Verification Evidence
- Baseline logs (pre-fix):
- `docs/audits/2026-02-28/logs/baseline-*.log`
- Post-fix logs:
- `docs/audits/2026-02-28/logs/fixed-*.log`

### Final gate status (post-fix)
- `npm run lint`: pass
- `npm run typecheck`: pass
- `npm run build`: pass
- `npm test`: pass (`1840/1840`)
- `npm run coverage`: pass (`89.24 statements / 81.07 branches / 95.57 functions / 91.55 lines`)
- `npm run audit:ci`: pass (`0` prod vulnerabilities; no unexpected high/critical dev advisories)
16 changes: 16 additions & 0 deletions docs/audits/2026-02-28/logs/baseline-1-npm-ci.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

> oc-chatgpt-multi-auth@5.4.0 prepare
> husky


added 214 packages, and audited 215 packages in 3s

73 packages are looking for funding
run `npm fund` for details

4 vulnerabilities (1 moderate, 3 high)

To address all issues, run:
npm audit fix

Run `npm audit` for details.
12 changes: 12 additions & 0 deletions docs/audits/2026-02-28/logs/baseline-2-npm-run-lint.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

> oc-chatgpt-multi-auth@5.4.0 lint
> npm run lint:ts && npm run lint:scripts


> oc-chatgpt-multi-auth@5.4.0 lint:ts
> eslint . --ext .ts


> oc-chatgpt-multi-auth@5.4.0 lint:scripts
> eslint scripts --ext .js

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

> oc-chatgpt-multi-auth@5.4.0 typecheck
> tsc --noEmit

4 changes: 4 additions & 0 deletions docs/audits/2026-02-28/logs/baseline-4-npm-run-build.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

> oc-chatgpt-multi-auth@5.4.0 build
> tsc && node scripts/copy-oauth-success.js

Loading