Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@
# 通用设置(建议始终开启)
# ============================================================
DISABLE_TELEMETRY=1

# Azure OpenAI (Codex)
CLAUDE_CODE_USE_AZURE_OPENAI=1
AZURE_OPENAI_BASE_URL=https://your-resource.cognitiveservices.azure.com
AZURE_OPENAI_API_VERSION=2025-04-01-preview
AZURE_OPENAI_API_KEY=your_azure_openai_key
AZURE_OPENAI_CODEX_DEPLOYMENT=your_codex_deployment
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.env.*
!.env.example
node_modules
openspec
82 changes: 66 additions & 16 deletions README.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Claude Code Haha
# Claude Code Haha

<p align="right"><a href="./README.md">中文</a> | <strong>English</strong></p>
<p align="right"><a href="./README.md">涓枃</a> | <strong>English</strong></p>

A **locally runnable version** repaired from the leaked Claude Code source, with support for any Anthropic-compatible API endpoint such as MiniMax and OpenRouter.

Expand Down Expand Up @@ -163,7 +163,7 @@ echo "explain this code" | ./bin/claude-haha -p

The startup script `bin/claude-haha` is a bash script and cannot run directly in cmd or PowerShell. Use one of the following methods:

**Option 1: PowerShell / cmd call Bun directly (recommended)**
**Option 1: PowerShell / cmd 鈥?call Bun directly (recommended)**

```powershell
# Interactive TUI mode
Expand Down Expand Up @@ -202,6 +202,56 @@ bun --env-file=.env ./src/localRecoveryCli.ts
| `DISABLE_TELEMETRY` | No | Set to `1` to disable telemetry |
| `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | No | Set to `1` to disable non-essential network traffic |

### Azure OpenAI (Codex)

```env
CLAUDE_CODE_USE_AZURE_OPENAI=1
AZURE_OPENAI_BASE_URL=https://<resource>.cognitiveservices.azure.com
AZURE_OPENAI_API_VERSION=2025-04-01-preview
AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_CODEX_DEPLOYMENT=...
```

You can either set a single default deployment via env:

```env
AZURE_OPENAI_CODEX_DEPLOYMENT=...
```

Or map Codex models to deployments via settings (example `~/.claude/settings.json`):

```json
{
"modelOverrides": {
"gpt-5.2-codex": "codex-deployment-52",
"gpt-5.3-codex": "codex-deployment-53",
"gpt-5.4-codex": "codex-deployment-54"
}
}
```


### Azure OpenAI (Codex)

Set these env vars to route requests to Azure OpenAI:

```env
CLAUDE_CODE_USE_AZURE_OPENAI=1
AZURE_OPENAI_BASE_URL=https://<resource>.cognitiveservices.azure.com
AZURE_OPENAI_API_VERSION=2025-04-01-preview
AZURE_OPENAI_API_KEY=...
```

Map the Codex model to your deployment name via settings (example `~/.claude/settings.json`):

```json
{
"modelOverrides": {
"gpt-5.2-codex": "my-codex-deployment"
}
}
```

---

## Fallback Mode
Expand Down Expand Up @@ -236,19 +286,19 @@ bin/claude-haha # Entry script
preload.ts # Bun preload (sets MACRO globals)
.env.example # Environment variable template
src/
├── entrypoints/cli.tsx # Main CLI entry
├── main.tsx # Main TUI logic (Commander.js + React/Ink)
├── localRecoveryCli.ts # Fallback Recovery CLI
├── setup.ts # Startup initialization
├── screens/REPL.tsx # Interactive REPL screen
├── ink/ # Ink terminal rendering engine
├── components/ # UI components
├── tools/ # Agent tools (Bash, Edit, Grep, etc.)
├── commands/ # Slash commands (/commit, /review, etc.)
├── skills/ # Skill system
├── services/ # Service layer (API, MCP, OAuth, etc.)
├── hooks/ # React hooks
└── utils/ # Utility functions
鈹溾攢鈹€ entrypoints/cli.tsx # Main CLI entry
鈹溾攢鈹€ main.tsx # Main TUI logic (Commander.js + React/Ink)
鈹溾攢鈹€ localRecoveryCli.ts # Fallback Recovery CLI
鈹溾攢鈹€ setup.ts # Startup initialization
鈹溾攢鈹€ screens/REPL.tsx # Interactive REPL screen
鈹溾攢鈹€ ink/ # Ink terminal rendering engine
鈹溾攢鈹€ components/ # UI components
鈹溾攢鈹€ tools/ # Agent tools (Bash, Edit, Grep, etc.)
鈹溾攢鈹€ commands/ # Slash commands (/commit, /review, etc.)
鈹溾攢鈹€ skills/ # Skill system
鈹溾攢鈹€ services/ # Service layer (API, MCP, OAuth, etc.)
鈹溾攢鈹€ hooks/ # React hooks
鈹斺攢鈹€ utils/ # Utility functions
```

---
Expand Down
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Claude Code Haha
# Claude Code Haha

<p align="right"><strong>中文</strong> | <a href="./README.en.md">English</a></p>

Expand Down Expand Up @@ -202,6 +202,39 @@ bun --env-file=.env ./src/localRecoveryCli.ts
| `DISABLE_TELEMETRY` | 否 | 设为 `1` 禁用遥测 |
| `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | 否 | 设为 `1` 禁用非必要网络请求 |

### Azure OpenAI (Codex)

```env
CLAUDE_CODE_USE_AZURE_OPENAI=1
AZURE_OPENAI_BASE_URL=https://<resource>.cognitiveservices.azure.com
AZURE_OPENAI_API_VERSION=2025-04-01-preview
AZURE_OPENAI_API_KEY=...
```

AZURE_OPENAI_CODEX_DEPLOYMENT=...
```

也可以只用一个默认 deployment:

```env
AZURE_OPENAI_CODEX_DEPLOYMENT=...
```

或在 `~/.claude/settings.json` 中按模型映射:

`~/.claude/settings.json`:

```json
{
"modelOverrides": {
"gpt-5.2-codex": "codex-deployment-52",
"gpt-5.3-codex": "codex-deployment-53",
"gpt-5.4-codex": "codex-deployment-54"
}
}
```


---

## 降级模式
Expand Down
1 change: 1 addition & 0 deletions src/commands/feedback/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const feedback = {
isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_AZURE_OPENAI) ||
isEnvTruthy(process.env.DISABLE_FEEDBACK_COMMAND) ||
isEnvTruthy(process.env.DISABLE_BUG_COMMAND) ||
isEssentialTrafficOnly() ||
Expand Down
2 changes: 1 addition & 1 deletion src/entrypoints/sdk/coreSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ export const AccountInfoSchema = lazySchema(() =>
tokenSource: z.string().optional(),
apiKeySource: z.string().optional(),
apiProvider: z
.enum(['firstParty', 'bedrock', 'vertex', 'foundry'])
.enum(['firstParty', 'bedrock', 'vertex', 'foundry', 'azureOpenAI'])
.optional()
.describe(
'Active API backend. Anthropic OAuth login only applies when "firstParty"; for 3P providers the other fields are absent and auth is external (AWS creds, gcloud ADC, etc.).',
Expand Down
1 change: 1 addition & 0 deletions src/services/analytics/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function isAnalyticsDisabled(): boolean {
isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_AZURE_OPENAI) ||
isTelemetryDisabled()
)
}
Expand Down
Loading