Add comprehensive documentation for Claude Code mode in both Chinese and English:
- Added claudeCodeMode configuration field description
- Explained Claude Code mode behavior and features
- Added configuration examples for both languages
- Documented OAuth token authentication support
- Explained automatic system prompt and Bash tool injection
Add integration tests in test/claude.go for Claude provider:
ParseConfig tests:
- claude standard config
- claude code mode config
- claude config without token fails
HttpRequestHeaders tests:
- claude standard mode uses x-api-key
- claude code mode uses bearer authorization
- claude code mode adds beta query param
- claude code mode with custom version
HttpRequestBody tests:
- claude standard mode does not inject defaults
- claude code mode injects default system prompt
- claude code mode injects bash tool
- claude code mode preserves existing system prompt
- claude code mode does not duplicate bash tool
- claude code mode adds bash tool alongside existing tools
All tests run in both go and wasm modes.
Add comprehensive unit tests for Claude Code mode:
- Test claudeProviderInitializer validation and capabilities
- Test header logic for beta=true query parameter
- Test buildClaudeTextGenRequest for standard and Claude Code modes
- Test system prompt injection when missing
- Test Bash tool injection when missing
- Test deduplication of existing system prompt and tools
- Test constants and GetApiName
Note: TransformRequestHeaders and TransformRequestBody tests are skipped
as they require WASM runtime. Core logic is tested indirectly through
buildClaudeTextGenRequest tests.
- Add default Claude Code system prompt if not present in request
- Add default Bash tool if not present in request
- Only inject defaults when claudeCodeMode is enabled and fields are missing
Add claudeCodeMode configuration option to emulate Claude Code client
requests, enabling OAuth token authentication with Claude API.
Changes:
- Add claudeCodeMode config field in ProviderConfig
- Transform request headers for Claude Code mode:
- Use Bearer token authorization instead of x-api-key
- Set user-agent to claude-cli/2.1.2 (external, cli)
- Set x-app: cli header
- Set anthropic-beta with OAuth and Claude Code features
- Add ?beta=true query parameter to path
- Add cache_control with ephemeral type to system prompts in Claude Code mode
This allows users to use Claude Code OAuth tokens with Higress AI proxy.