mirror of
https://github.com/hanzoai/opencode-openai-codex-auth.git
synced 2026-09-24 17:01:02 +00:00
main
7
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0a9834c6fc |
docs: Enforce GPT 5.1 full-opencode.json as only supported configuration
This PR standardizes all documentation and configuration on GPT 5.1 model identifiers, removes deprecated GPT 5.0 models, and enforces full-opencode.json as the only officially supported configuration. The changes address GPT 5 model temperamental behavior and ensure users have the proper setup for reliable operation with OpenCode. Co-authored-by: Hanzo Dev <[email protected]> |
||
|
|
18d207ac9b | Add Codex Mini support | ||
|
|
3f2b00eb61 | feat: Enhance Codex integration with prompt caching and error handling improvements | ||
|
|
fe29b2110d |
feat: Add comprehensive compliance documentation and fix critical bugs (v2.1.2)
This release includes comprehensive OpenAI ToS compliance updates and fixes 4 critical bugs that prevented per-model options and multi-turn conversations from working correctly. ## ๐ Compliance & Legal Updates ### Terms of Service & Usage Guidelines - Added comprehensive ToS & Usage Notice to README emphasizing personal use only - Added Rate Limits & Responsible Use section with best practices - Added extensive FAQ section addressing TOS compliance questions - Updated LICENSE with MIT + Usage Disclaimer for personal development use - Added compliance header to index.ts documenting intended use cases ### New Documentation - **CONTRIBUTING.md**: Complete contribution guidelines with compliance requirements - **SECURITY.md**: Security policy, vulnerability reporting, best practices - **docs/privacy.md**: Comprehensive privacy & data handling documentation - **Issue Templates**: Bug reports & feature requests with compliance checklists ### Documentation Updates - Updated docs/index.md with usage notice and trademark disclaimers - Updated docs/getting-started.md with "Before You Begin" compliance notice - Updated docs/troubleshooting.md with subscription & compliance sections - All references updated to "Plus/Pro" (removed Team/Enterprise mentions) ### Key Compliance Principles - โ Emphasizes personal development use with own ChatGPT Plus/Pro subscription - โ Uses OpenAI's official OAuth authentication (same as Codex CLI) - โ Clear prohibition of commercial resale, multi-user services - โ Not a "free API alternative" - uses existing ChatGPT subscription - โ Proper trademark notices and attribution to OpenAI - โ Transparent about data handling and privacy ## ๐ Critical Bug Fixes ### Bug #1: Per-Model Options Ignored (Config Lookup Mismatch) **Severity:** ๐ด HIGH Users configured different reasoning levels for each model variant, but all variants behaved identically because the plugin was looking up normalized model names instead of the original config keys. **Fix:** lib/request/request-transformer.ts:277 - Use original model name for config lookup before normalization - Allows per-model options to work correctly - Impact: Different reasoning levels now properly applied per variant ### Bug #2: Multi-Turn Conversations Fail (AI SDK Compatibility) **Severity:** ๐ด CRITICAL Multi-turn conversations failed with "Item not found" errors because: 1. AI SDK sends `item_reference` (not in Codex API spec) 2. IDs weren't completely stripped for stateless mode (store: false) **Fix:** lib/request/request-transformer.ts:114-135 - Filter out AI SDK `item_reference` items - Strip ALL IDs from remaining items (not just rs_* prefix) - Confirmed ChatGPT backend requires store: false via testing - Full message history preserved for LLM context ### Bug #3: Case-Sensitive Normalization **Severity:** ๐ก MEDIUM **Fix:** lib/request/request-transformer.ts:22-27 - Added toLowerCase() for case-insensitive matching - Backwards compatible with old verbose config names - Handles uppercase/mixed case user input ### Bug #4: GitHub API Rate Limiting **Severity:** ๐ก MEDIUM Plugin checked GitHub on every request, exhausting 60 req/hour limit. 15-minute cache timestamp was stored but never checked. **Fix:** lib/prompts/codex.ts:50-53, lib/prompts/opencode-codex.ts:47-50 - Check cache TTL before GitHub API call - Only fetch if cache >15min old - Prevents rate limit exhaustion during testing ## โจ Enhancements ### Debug Logging System - New environment variable: `DEBUG_CODEX_PLUGIN=1` - Added logDebug() and logWarn() functions - Shows config lookups, ID filtering, options resolution - File: lib/logger.ts ### Optimized Config Structure - Changed to Codex CLI preset names (gpt-5-codex-low, etc.) - Removed redundant `id` field (not used by OpenAI provider) - Added `name` field for friendly TUI display - File: config/full-opencode.json ### GitHub Pages Documentation - Complete documentation restructure for GitHub Pages - User guides: getting-started.md, configuration.md, troubleshooting.md - Developer guides: ARCHITECTURE.md, CONFIG_FLOW.md, CONFIG_FIELDS.md, TESTING.md - Privacy policy, security policy, contribution guidelines ## ๐งช Testing ### Test Coverage - โ 159 unit tests passing (30+ new tests) - โ 14 integration tests passing (actual API verification) - โ All documented scenarios have test coverage ### Integration Tests (scripts/test-all-models.sh) - Tests all 9 custom model configurations - Tests all 4 default OpenCode models - Verifies backwards compatibility with old config format - Uses ENABLE_PLUGIN_REQUEST_LOGGING to verify actual API requests ### Test Results - 14/14 model configuration tests passing - All per-model options verified correct - Multi-turn conversations work without errors - Backwards compatibility confirmed ## ๐ Files Changed ### Modified (7 files) - lib/request/request-transformer.ts: Config lookup & ID filtering fixes - lib/prompts/codex.ts: 15-minute cache TTL - lib/prompts/opencode-codex.ts: 15-minute cache TTL - lib/logger.ts: Debug logging system - config/full-opencode.json: Optimized structure - test/request-transformer.test.ts: 30+ new tests - LICENSE: Added usage disclaimer - index.ts: Added compliance header - README.md: Added ToS, Rate Limits, FAQ sections ### Created (20+ files) - CONTRIBUTING.md: Contribution guidelines - SECURITY.md: Security policy - docs/index.md: GitHub Pages landing - docs/getting-started.md: Installation guide - docs/configuration.md: Advanced config - docs/troubleshooting.md: Debug guide - docs/privacy.md: Privacy policy - docs/development/ARCHITECTURE.md: Technical architecture - docs/development/CONFIG_FLOW.md: Config system internals - docs/development/CONFIG_FIELDS.md: Field usage guide - docs/development/TESTING.md: Testing guide - .github/ISSUE_TEMPLATE/bug_report.md - .github/ISSUE_TEMPLATE/feature_request.md - .github/ISSUE_TEMPLATE/config.yml - scripts/test-all-models.sh: Automated testing ## ๐ฏ Verification All scenarios tested and verified: - โ Default models work without config - โ Custom models with per-variant options - โ Old config format (backwards compatible) - โ Mixed default + custom models - โ Multi-turn conversations (no "item not found" errors) - โ Model switching with different options - โ All normalization patterns - โ Complete ID filtering ## ๐ Documentation Complete documentation suite (100+ KB): - User guides for installation, configuration, troubleshooting - Developer guides for architecture, config system, testing - Privacy policy and security policy - Compliance guidelines and contribution requirements - Release notes in tmp/release-notes/ ## ๐ References - OpenAI Terms of Use: https://openai.com/policies/terms-of-use/ - OpenAI Usage Policies: https://openai.com/policies/usage-policies/ - OpenAI Platform API: https://platform.openai.com/ - OpenAI Codex CLI: https://github.com/openai/codex Co-authored-by: Hanzo Dev <[email protected]> |
||
|
|
b32f67ba81 |
feat: Add Task tool & MCP awareness with ETag-based prompt verification
This release enhances the bridge prompt system with awareness of OpenCode's
advanced capabilities and implements cache-based verification for more robust
prompt filtering.
**New Features:**
- Task tool awareness: Bridge prompt now documents sub-agent system
- MCP tool awareness: Documents Model Context Protocol tool conventions
- OpenCode prompt verification: ETag-based caching of codex.txt for 100% accurate filtering
- AGENTS.md: Renamed from CLAUDE.md for broader AI agent applicability
**Technical Changes:**
- Created lib/prompts/opencode-codex.ts for prompt verification caching
- Made request transformation pipeline async to support cache fetching
- Enhanced isOpenCodeSystemPrompt() with dual verification (cached + fallback)
- Updated bridge prompt with "Advanced Tools" section (~550 tokens, was ~450)
- Added 6 new tests verifying AGENTS.md content safety (129 total tests)
**Verification System:**
Primary: Compare against cached OpenCode prompt from GitHub
Fallback: Text signature matching ("You are a coding agent running in")
This ensures 100% confidence when filtering OpenCode system prompts
**Breaking Changes:** None - all changes are additive
Co-authored-by: Hanzo Dev <[email protected]>
|
||
|
|
3890872781 |
feat: Add CODEX_MODE with bridge prompt and reorganize lib/ structure
## CODEX_MODE Implementation
Added configurable CODEX_MODE that replaces OpenCode system prompts with
a Codex-OpenCode bridge prompt for better Codex CLI parity.
**Key Features:**
- Enabled by default for optimal Codex CLI compatibility
- Configurable via ~/.opencode/openai-codex-auth-config.json
- Environment variable override support (CODEX_MODE=0 or CODEX_MODE=1)
- Priority: env var > config file > default (true)
**Bridge Prompt:**
- ~450 tokens (~90% reduction vs full OpenCode prompt)
- Critical tool replacements (apply_patch โ edit, update_plan โ todowrite)
- Available tools list and verification checklist
- OpenCode working style guidelines
**Configuration:**
```json
{
"codexMode": true // default
}
```
## Library Reorganization
Restructured lib/ into semantic subfolders:
```
lib/
โโโ auth/ # OAuth authentication
โ โโโ auth.ts
โ โโโ browser.ts
โ โโโ server.ts
โโโ prompts/ # System prompts
โ โโโ codex.ts
โ โโโ codex-opencode-bridge.ts
โโโ request/ # Request handling
โ โโโ fetch-helpers.ts
โ โโโ request-transformer.ts
โ โโโ response-handler.ts
โโโ config.ts # Plugin configuration
โโโ constants.ts
โโโ logger.ts
โโโ types.ts
โโโ oauth-success.html
```
## Files Changed
**New Files:**
- lib/config.ts - Plugin configuration loading
- lib/prompts/codex-opencode-bridge.ts - Bridge prompt
- test/plugin-config.test.ts - 12 new tests
**Modified:**
- lib/request/request-transformer.ts - CODEX_MODE parameter
- lib/request/fetch-helpers.ts - Pass codexMode through pipeline
- index.ts - Load config and determine codexMode
- lib/types.ts - Add PluginConfig type
- README.md - Document CODEX_MODE configuration
**Reorganized:**
- lib/*.ts โ lib/{auth,prompts,request}/*.ts
- Updated all imports across codebase and tests
## Testing
- 123 total tests (added 12 new tests for config loading)
- All tests passing
- Comprehensive CODEX_MODE coverage:
- Config file loading (exists, missing, invalid)
- Priority order testing
- Environment variable override
- Bridge prompt vs tool remap behavior
## Documentation
Updated README.md:
- Added "Plugin Configuration" section
- Documented CODEX_MODE setting and priority
- Updated features list (123 tests, CODEX_MODE)
- Updated "How It Works" section
Co-authored-by: Hanzo Dev <[email protected]>
|
||
|
|
7dae285752 |
feat: Major TypeScript rewrite with enhanced configuration and OAuth UI
## ๐ฏ Overview Complete TypeScript rewrite with comprehensive testing, modular architecture, and enhanced user experience. Adds 9 pre-configured model variants matching Codex CLI presets and a beautiful OAuth success page. ## โจ New Features ### Configuration System - **9 Model Variants**: Pre-configured reasoning levels (Low/Medium/High) for both gpt-5-codex and gpt-5, plus Minimal variants - **Full Config Example**: `config/full-opencode.json` with all variants ready to use - **Minimal Config Example**: `config/minimal-opencode.json` for basic setup - **Config Documentation**: Comprehensive guide in `config/README.md` ### OAuth Enhancement - **Animated Success Page**: Beautiful terminal-style UI with matrix rain effect, animated checkmark, and glowing effects - **Interactive Elements**: Mouse-responsive matrix rain and parallax effects - **Professional Branding**: OpenCode logo with pulse animations ### Developer Experience - **TypeScript Rewrite**: Complete migration from .mjs to .ts with strict typing - **93 Comprehensive Tests**: Full test coverage using Vitest - **Modular Architecture**: 10 focused helper functions, each < 40 lines - **Centralized Constants**: All magic values in `lib/constants.ts` - **CI/CD Pipeline**: GitHub Actions workflow for automated testing ### Documentation - **AGENTS.md**: Complete guide for AI assistants maintaining the codebase - **Enhanced README**: Updated with new configuration options and examples - **Inline JSDoc**: Comprehensive documentation for all public functions ## ๐๏ธ Technical Changes ### Architecture Improvements - Extracted 10 focused helper functions from monolithic fetch() - Centralized all constants and error messages - Separated concerns: auth, browser, codex, server, etc. - Type-safe discriminated unions for result types ### Build System - TypeScript compilation with declarations and source maps - Automatic HTML asset copying in build process - Test files excluded from distribution bundle - Clean dist/ output with only production code ### Testing Infrastructure - Vitest test runner with UI mode - 93 tests across 7 test files - Mock-based testing for external dependencies - Coverage reporting capability ## ๐ New Structure ``` opencode-openai-codex-auth/ โโโ index.ts # Main plugin (TypeScript) โโโ lib/ โ โโโ auth.ts # OAuth logic โ โโโ browser.ts # Platform-specific browser opening โ โโโ codex.ts # Codex instructions โ โโโ server.ts # OAuth callback server โ โโโ fetch-helpers.ts # 10 focused helpers โ โโโ constants.ts # All magic values โ โโโ types.ts # TypeScript types โ โโโ oauth-success.html # Animated success page โ โโโ ... โโโ config/ โ โโโ full-opencode.json # Complete config with variants โ โโโ minimal-opencode.json # Basic config โ โโโ README.md # Config docs โโโ test/ # 93 comprehensive tests โโโ AGENTS.md # AI maintenance guide โโโ tsconfig.json # TypeScript config ``` ## ๐ Migration Notes ### Breaking Changes - Plugin now requires TypeScript compilation (dist/ folder) - Configuration structure enhanced (backward compatible) - OAuth success page replaces plain HTML response ### Upgrade Path 1. Use new config from `config/full-opencode.json` for best experience 2. Or continue with minimal config (uses plugin defaults) 3. Rebuild plugin: `npm run build` ## ๐ Metrics - **Lines of Code**: Modular design with functions < 70 lines - **Test Coverage**: 93 tests covering all functionality - **Type Safety**: Strict TypeScript with no `any` types - **Dependencies**: Still minimal (only @openauthjs/openauth) - **Model Variants**: 9 pre-configured options for users ## ๐จ User Experience - **Codex CLI Parity**: Match official CLI reasoning presets - **Beautiful OAuth**: Professional animated success page - **Clear Documentation**: Step-by-step guides and examples - **Flexible Config**: From minimal to comprehensive setups Co-authored-by: Hanzo Dev <[email protected]> |