claudish 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,783 @@
1
+ # Claudish
2
+
3
+ > Run Claude Code with OpenRouter models via local proxy
4
+
5
+ **Claudish** (Claude-ish) is a CLI tool that allows you to run Claude Code with any OpenRouter model by proxying requests through a local Anthropic API-compatible server.
6
+
7
+ ## Features
8
+
9
+ - ✅ **Monitor mode** - Proxy to real Anthropic API and log all traffic (for debugging)
10
+ - ✅ **Protocol compliance** - 1:1 compatibility with Claude Code communication protocol
11
+ - ✅ **Snapshot testing** - Comprehensive test suite with 13/13 passing tests
12
+ - ✅ **Headless mode** - Automatic print mode for non-interactive execution
13
+ - ✅ **Quiet mode** - Clean output by default (no log pollution)
14
+ - ✅ **JSON output** - Structured data for tool integration
15
+ - ✅ **Real-time streaming** - See Claude Code output as it happens
16
+ - ✅ **Parallel runs** - Each instance gets isolated proxy
17
+ - ✅ **Autonomous mode** - Bypass all prompts with flags
18
+ - ✅ **Context inheritance** - Runs in current directory with same `.claude` settings
19
+ - ✅ **Multiple models** - 5 prioritized OpenRouter models
20
+
21
+ ## Installation
22
+
23
+ ### Prerequisites
24
+
25
+ - [Bun](https://bun.sh) - JavaScript runtime
26
+ - [Claude Code](https://claude.com/claude-code) - Claude CLI must be installed
27
+ - [OpenRouter API Key](https://openrouter.ai/keys) - Free tier available
28
+
29
+ ### Install Claudish
30
+
31
+ **IMPORTANT: Claudish requires Bun runtime for optimal performance.**
32
+
33
+ **Option 1: Install from npm (recommended)**
34
+
35
+ ```bash
36
+ # Install globally (requires Bun in PATH)
37
+ npm install -g claudish
38
+
39
+ # Or use bunx (recommended - always uses Bun)
40
+ bunx claudish --version
41
+ ```
42
+
43
+ **Option 2: Install from source**
44
+
45
+ ```bash
46
+ cd mcp/claudish
47
+ bun install
48
+ bun run build
49
+ bun link
50
+ ```
51
+
52
+ **Why Bun?** Claudish is built with Bun and runs 10x faster than Node.js for proxy operations. The shebang `#!/usr/bin/env bun` ensures it always runs with Bun, but Bun must be installed on your system.
53
+
54
+ ## Quick Start
55
+
56
+ ### 1. Set up environment
57
+
58
+ ```bash
59
+ # Copy example env file
60
+ cp .env.example .env
61
+
62
+ # Add your OpenRouter API key
63
+ export OPENROUTER_API_KEY=sk-or-v1-...
64
+
65
+ # Recommended: Set placeholder to avoid Claude Code's API key prompt
66
+ export ANTHROPIC_API_KEY=sk-ant-api03-placeholder
67
+ ```
68
+
69
+ ### 2. Run claudish
70
+
71
+ ```bash
72
+ # Basic usage (auto-approve enabled by default)
73
+ claudish "implement user authentication"
74
+
75
+ # Use specific model
76
+ claudish --model openai/gpt-5-codex "add tests"
77
+
78
+ # Fully autonomous mode (auto-approve + dangerous)
79
+ claudish --dangerous "refactor codebase"
80
+ ```
81
+
82
+ ## Usage
83
+
84
+ ### Basic Syntax
85
+
86
+ ```bash
87
+ claudish [OPTIONS] <claude-args...>
88
+ ```
89
+
90
+ ### Options
91
+
92
+ | Flag | Description | Default |
93
+ |------|-------------|---------|
94
+ | `-i, --interactive` | Run in interactive mode (persistent session) | Single-shot mode |
95
+ | `-m, --model <model>` | OpenRouter model to use | `x-ai/grok-code-fast-1` |
96
+ | `-p, --port <port>` | Proxy server port | Random (3000-9000) |
97
+ | `-q, --quiet` | Suppress [claudish] log messages | **Quiet in single-shot** |
98
+ | `-v, --verbose` | Show [claudish] log messages | Verbose in interactive |
99
+ | `--json` | Output in JSON format (implies --quiet) | `false` |
100
+ | `-d, --debug` | Enable debug logging to file | `false` |
101
+ | `--no-auto-approve` | Disable auto-approve (require prompts) | Auto-approve **enabled** |
102
+ | `--dangerous` | Pass `--dangerouslyDisableSandbox` | `false` |
103
+ | `--list-models` | List available models | - |
104
+ | `-h, --help` | Show help message | - |
105
+
106
+ ### Environment Variables
107
+
108
+ | Variable | Description | Required |
109
+ |----------|-------------|----------|
110
+ | `OPENROUTER_API_KEY` | Your OpenRouter API key | ✅ Yes |
111
+ | `ANTHROPIC_API_KEY` | Placeholder to prevent Claude Code dialog (not used for auth) | ✅ **Required** |
112
+ | `CLAUDISH_MODEL` | Default model to use | ❌ No |
113
+ | `CLAUDISH_PORT` | Default proxy port | ❌ No |
114
+ | `CLAUDISH_ACTIVE_MODEL_NAME` | Automatically set by claudish to show active model in status line (read-only) | ❌ No |
115
+
116
+ **Important:** You MUST set `ANTHROPIC_API_KEY=sk-ant-api03-placeholder` (or any value). Without it, Claude Code will show a dialog, and if you select "No", it will bypass the proxy and use real Anthropic API. Claudish now enforces this requirement.
117
+
118
+ ## Available Models
119
+
120
+ Claudish supports 5 OpenRouter models in priority order:
121
+
122
+ 1. **x-ai/grok-code-fast-1** (Default)
123
+ - Fast coding-focused model from xAI
124
+ - Best for quick iterations
125
+
126
+ 2. **openai/gpt-5-codex**
127
+ - Advanced coding model from OpenAI
128
+ - Best for complex implementations
129
+
130
+ 3. **minimax/minimax-m2**
131
+ - High-performance model from MiniMax
132
+ - Good for general coding tasks
133
+
134
+ 4. **zhipu-ai/glm-4.6**
135
+ - Advanced model from Zhipu AI
136
+ - Good for multilingual code
137
+
138
+ 5. **qwen/qwen3-vl-235b-a22b-instruct**
139
+ - Vision-language model from Alibaba
140
+ - Best for UI/visual tasks
141
+
142
+ List models anytime with:
143
+
144
+ ```bash
145
+ claudish --list-models
146
+ ```
147
+
148
+ ## Status Line Display
149
+
150
+ Claudish automatically shows critical information in the Claude Code status bar - **no setup required!**
151
+
152
+ **Ultra-Compact Format:** `directory • model-id • $cost • ctx%`
153
+
154
+ **Visual Design:**
155
+ - 🔵 **Directory** (bright cyan, bold) - Where you are
156
+ - 🟡 **Model ID** (bright yellow) - Actual OpenRouter model ID
157
+ - 🟢 **Cost** (bright green) - Real-time session cost from OpenRouter
158
+ - 🟣 **Context** (bright magenta) - % of context window remaining
159
+ - ⚪ **Separators** (dim) - Visual dividers
160
+
161
+ **Examples:**
162
+ - `claudish • x-ai/grok-code-fast-1 • $0.003 • 95%` - Using Grok, $0.003 spent, 95% context left
163
+ - `my-project • openai/gpt-5-codex • $0.12 • 67%` - Using GPT-5, $0.12 spent, 67% context left
164
+ - `backend • minimax/minimax-m2 • $0.05 • 82%` - Using MiniMax M2, $0.05 spent, 82% left
165
+ - `test • openrouter/auto • $0.01 • 90%` - Using any custom model, $0.01 spent, 90% left
166
+
167
+ **Critical Tracking (Live Updates):**
168
+ - 💰 **Cost tracking** - Real-time USD from Claude Code session data
169
+ - 📊 **Context monitoring** - Percentage of model's context window remaining
170
+ - ⚡ **Performance optimized** - Ultra-compact to fit with thinking mode UI
171
+
172
+ **Thinking Mode Optimized:**
173
+ - ✅ **Ultra-compact** - Directory limited to 15 chars (leaves room for everything)
174
+ - ✅ **Critical first** - Most important info (directory, model) comes first
175
+ - ✅ **Smart truncation** - Long directories shortened with "..."
176
+ - ✅ **Space reservation** - Reserves ~40 chars for Claude's thinking mode UI
177
+ - ✅ **Color-coded** - Instant visual scanning
178
+ - ✅ **No overflow** - Fits perfectly even with thinking mode enabled
179
+
180
+ **Custom Model Support:**
181
+ - ✅ **ANY OpenRouter model** - Not limited to shortlist (e.g., `openrouter/auto`, custom models)
182
+ - ✅ **Actual model IDs** - Shows exact OpenRouter model ID (no translation)
183
+ - ✅ **Context fallback** - Unknown models use 100k context window (safe default)
184
+ - ✅ **Shortlist optimized** - Our recommended models have accurate context sizes
185
+ - ✅ **Future-proof** - Works with new models added to OpenRouter
186
+
187
+ **How it works:**
188
+ - Each Claudish instance creates a temporary settings file with custom status line
189
+ - Settings use `--settings` flag (doesn't modify global Claude Code config)
190
+ - Status line uses simple bash script with ANSI colors (no external dependencies!)
191
+ - Displays actual OpenRouter model ID from `CLAUDISH_ACTIVE_MODEL_NAME` env var
192
+ - Context tracking uses model-specific sizes for our shortlist, 100k fallback for others
193
+ - Temp files are automatically cleaned up when Claudish exits
194
+ - Each instance is completely isolated - run multiple in parallel!
195
+
196
+ **Per-instance isolation:**
197
+ - ✅ Doesn't modify `~/.claude/settings.json`
198
+ - ✅ Each instance has its own config
199
+ - ✅ Safe to run multiple Claudish instances in parallel
200
+ - ✅ Standard Claude Code unaffected
201
+ - ✅ Temp files auto-cleanup on exit
202
+ - ✅ No external dependencies (bash only, no jq!)
203
+
204
+ ## Examples
205
+
206
+ ### Basic Usage
207
+
208
+ ```bash
209
+ # Simple prompt
210
+ claudish "fix the bug in user.ts"
211
+
212
+ # Multi-word prompt
213
+ claudish "implement user authentication with JWT tokens"
214
+ ```
215
+
216
+ ### With Specific Model
217
+
218
+ ```bash
219
+ # Use Grok for fast coding
220
+ claudish --model x-ai/grok-code-fast-1 "add error handling"
221
+
222
+ # Use GPT-5 Codex for complex tasks
223
+ claudish --model openai/gpt-5-codex "refactor entire API layer"
224
+
225
+ # Use Qwen for UI tasks
226
+ claudish --model qwen/qwen3-vl-235b-a22b-instruct "implement dashboard UI"
227
+ ```
228
+
229
+ ### Autonomous Mode
230
+
231
+ Auto-approve is **enabled by default**. For fully autonomous mode, add `--dangerous`:
232
+
233
+ ```bash
234
+ # Basic usage (auto-approve already enabled)
235
+ claudish "delete unused files"
236
+
237
+ # Fully autonomous (auto-approve + dangerous sandbox disabled)
238
+ claudish --dangerous "install dependencies"
239
+
240
+ # Disable auto-approve if you want prompts
241
+ claudish --no-auto-approve "make important changes"
242
+ ```
243
+
244
+ ### Custom Port
245
+
246
+ ```bash
247
+ # Use specific port
248
+ claudish --port 3000 "analyze codebase"
249
+
250
+ # Or set default
251
+ export CLAUDISH_PORT=3000
252
+ claudish "your task"
253
+ ```
254
+
255
+ ### Passing Claude Flags
256
+
257
+ ```bash
258
+ # Verbose mode
259
+ claudish "debug issue" --verbose
260
+
261
+ # Custom working directory
262
+ claudish "analyze code" --cwd /path/to/project
263
+
264
+ # Multiple flags
265
+ claudish --model openai/gpt-5-codex "task" --verbose --debug
266
+ ```
267
+
268
+ ### Monitor Mode
269
+
270
+ **NEW!** Claudish now includes a monitor mode to help you understand how Claude Code works internally.
271
+
272
+ ```bash
273
+ # Enable monitor mode (requires real Anthropic API key)
274
+ claudish --monitor --debug "implement a feature"
275
+ ```
276
+
277
+ **What Monitor Mode Does:**
278
+ - ✅ **Proxies to REAL Anthropic API** (not OpenRouter) - Uses your actual Anthropic API key
279
+ - ✅ **Logs ALL traffic** - Captures complete requests and responses
280
+ - ✅ **Both streaming and JSON** - Logs SSE streams and JSON responses
281
+ - ✅ **Debug logs to file** - Saves to `logs/claudish_*.log` when `--debug` is used
282
+ - ✅ **Pass-through proxy** - No translation, forwards as-is to Anthropic
283
+
284
+ **When to use Monitor Mode:**
285
+ - 🔍 Understanding Claude Code's API protocol
286
+ - 🐛 Debugging integration issues
287
+ - 📊 Analyzing Claude Code's behavior
288
+ - 🔬 Research and development
289
+
290
+ **Requirements:**
291
+ ```bash
292
+ # Monitor mode requires a REAL Anthropic API key (not placeholder)
293
+ export ANTHROPIC_API_KEY='sk-ant-api03-...'
294
+
295
+ # Use with --debug to save logs to file
296
+ claudish --monitor --debug "your task"
297
+
298
+ # Logs are saved to: logs/claudish_TIMESTAMP.log
299
+ ```
300
+
301
+ **Example Output:**
302
+ ```
303
+ [Monitor] Server started on http://127.0.0.1:8765
304
+ [Monitor] Mode: Passthrough to real Anthropic API
305
+ [Monitor] All traffic will be logged for analysis
306
+
307
+ === [MONITOR] Claude Code → Anthropic API Request ===
308
+ {
309
+ "model": "claude-sonnet-4.5",
310
+ "messages": [...],
311
+ "max_tokens": 4096,
312
+ ...
313
+ }
314
+ === End Request ===
315
+
316
+ === [MONITOR] Anthropic API → Claude Code Response (Streaming) ===
317
+ event: message_start
318
+ data: {"type":"message_start",...}
319
+
320
+ event: content_block_start
321
+ data: {"type":"content_block_start",...}
322
+ ...
323
+ === End Streaming Response ===
324
+ ```
325
+
326
+ **Note:** Monitor mode charges your Anthropic account (not OpenRouter). Use `--debug` flag to save logs for analysis.
327
+
328
+ ### Output Modes
329
+
330
+ Claudish supports three output modes for different use cases:
331
+
332
+ #### 1. Quiet Mode (Default in Single-Shot)
333
+
334
+ Clean output with no `[claudish]` logs - perfect for piping to other tools:
335
+
336
+ ```bash
337
+ # Quiet by default in single-shot
338
+ claudish "what is 2+2?"
339
+ # Output: 2 + 2 equals 4.
340
+
341
+ # Use in pipelines
342
+ claudish "list 3 colors" | grep -i blue
343
+
344
+ # Redirect to file
345
+ claudish "analyze code" > analysis.txt
346
+ ```
347
+
348
+ #### 2. Verbose Mode
349
+
350
+ Show all `[claudish]` log messages for debugging:
351
+
352
+ ```bash
353
+ # Verbose mode
354
+ claudish --verbose "what is 2+2?"
355
+ # Output:
356
+ # [claudish] Starting Claude Code with openai/gpt-4o
357
+ # [claudish] Proxy URL: http://127.0.0.1:8797
358
+ # [claudish] Status line: dir • openai/gpt-4o • $cost • ctx%
359
+ # ...
360
+ # 2 + 2 equals 4.
361
+ # [claudish] Shutting down proxy server...
362
+ # [claudish] Done
363
+
364
+ # Interactive mode is verbose by default
365
+ claudish --interactive
366
+ ```
367
+
368
+ #### 3. JSON Output Mode
369
+
370
+ Structured output perfect for automation and tool integration:
371
+
372
+ ```bash
373
+ # JSON output (always quiet)
374
+ claudish --json "what is 2+2?"
375
+ # Output: {"type":"result","result":"2 + 2 equals 4.","total_cost_usd":0.068,"usage":{...}}
376
+
377
+ # Extract just the result with jq
378
+ claudish --json "list 3 colors" | jq -r '.result'
379
+
380
+ # Get cost and token usage
381
+ claudish --json "analyze code" | jq '{result, cost: .total_cost_usd, tokens: .usage.input_tokens}'
382
+
383
+ # Use in scripts
384
+ RESULT=$(claudish --json "check if tests pass" | jq -r '.result')
385
+ echo "AI says: $RESULT"
386
+
387
+ # Track costs across multiple runs
388
+ for task in task1 task2 task3; do
389
+ claudish --json "$task" | jq -r '"\(.total_cost_usd)"'
390
+ done | awk '{sum+=$1} END {print "Total: $"sum}'
391
+ ```
392
+
393
+ **JSON Output Fields:**
394
+ - `result` - The AI's response text
395
+ - `total_cost_usd` - Total cost in USD
396
+ - `usage.input_tokens` - Input tokens used
397
+ - `usage.output_tokens` - Output tokens used
398
+ - `duration_ms` - Total duration in milliseconds
399
+ - `num_turns` - Number of conversation turns
400
+ - `modelUsage` - Per-model usage breakdown
401
+
402
+ ## How It Works
403
+
404
+ ### Architecture
405
+
406
+ ```
407
+ claudish "your prompt"
408
+
409
+ 1. Parse arguments (--model, --no-auto-approve, --dangerous, etc.)
410
+ 2. Find available port (random or specified)
411
+ 3. Start local proxy on http://127.0.0.1:PORT
412
+ 4. Spawn: claude --auto-approve --env ANTHROPIC_BASE_URL=http://127.0.0.1:PORT
413
+ 5. Proxy translates: Anthropic API → OpenRouter API
414
+ 6. Stream output in real-time
415
+ 7. Cleanup proxy on exit
416
+ ```
417
+
418
+ ### Request Flow
419
+
420
+ **Normal Mode (OpenRouter):**
421
+ ```
422
+ Claude Code → Anthropic API format → Local Proxy → OpenRouter API format → OpenRouter
423
+
424
+ Claude Code ← Anthropic API format ← Local Proxy ← OpenRouter API format ← OpenRouter
425
+ ```
426
+
427
+ **Monitor Mode (Anthropic Passthrough):**
428
+ ```
429
+ Claude Code → Anthropic API format → Local Proxy (logs) → Anthropic API
430
+
431
+ Claude Code ← Anthropic API format ← Local Proxy (logs) ← Anthropic API
432
+ ```
433
+
434
+ ### Parallel Runs
435
+
436
+ Each `claudish` invocation:
437
+ - Gets a unique random port
438
+ - Starts isolated proxy server
439
+ - Runs independent Claude Code instance
440
+ - Cleans up on exit
441
+
442
+ This allows multiple parallel runs:
443
+
444
+ ```bash
445
+ # Terminal 1
446
+ claudish --model x-ai/grok-code-fast-1 "task A"
447
+
448
+ # Terminal 2
449
+ claudish --model openai/gpt-5-codex "task B"
450
+
451
+ # Terminal 3
452
+ claudish --model minimax/minimax-m2 "task C"
453
+ ```
454
+
455
+ ## Extended Thinking Support
456
+
457
+ **NEW in v1.1.0**: Claudish now fully supports models with extended thinking/reasoning capabilities (Grok, o1, etc.) with complete Anthropic Messages API protocol compliance.
458
+
459
+ ### What is Extended Thinking?
460
+
461
+ Some AI models (like Grok and OpenAI's o1) can show their internal reasoning process before providing the final answer. This "thinking" content helps you understand how the model arrived at its conclusion.
462
+
463
+ ### How Claudish Handles Thinking
464
+
465
+ Claudish implements the Anthropic Messages API's `interleaved-thinking` protocol:
466
+
467
+ **Thinking Blocks (Hidden):**
468
+ - Contains model's reasoning process
469
+ - Automatically collapsed in Claude Code UI
470
+ - Shows "Claude is thinking..." indicator
471
+ - User can expand to view reasoning
472
+
473
+ **Text Blocks (Visible):**
474
+ - Contains final response
475
+ - Displayed normally
476
+ - Streams incrementally
477
+
478
+ ### Supported Models with Thinking
479
+
480
+ - ✅ **x-ai/grok-code-fast-1** - Grok's reasoning mode
481
+ - ✅ **openai/gpt-5-codex** - o1 reasoning (when enabled)
482
+ - ✅ **openai/o1-preview** - Full reasoning support
483
+ - ✅ **openai/o1-mini** - Compact reasoning
484
+ - ⚠️ Other models may support reasoning in future
485
+
486
+ ### Technical Details
487
+
488
+ **Streaming Protocol (V2 - Protocol Compliant):**
489
+ ```
490
+ 1. message_start
491
+ 2. content_block_start (text, index=0) ← IMMEDIATE! (required)
492
+ 3. ping
493
+ 4. [If reasoning arrives]
494
+ - content_block_stop (index=0) ← Close initial empty block
495
+ - content_block_start (thinking, index=1) ← Reasoning
496
+ - thinking_delta events × N
497
+ - content_block_stop (index=1)
498
+ 5. content_block_start (text, index=2) ← Response
499
+ 6. text_delta events × M
500
+ 7. content_block_stop (index=2)
501
+ 8. message_delta + message_stop
502
+ ```
503
+
504
+ **Critical:** `content_block_start` must be sent immediately after `message_start`, before `ping`. This is required by the Anthropic Messages API protocol for proper UI initialization.
505
+
506
+ **Key Features:**
507
+ - ✅ Separate thinking and text blocks (proper indices)
508
+ - ✅ `thinking_delta` vs `text_delta` event types
509
+ - ✅ Thinking content hidden by default
510
+ - ✅ Smooth transitions between blocks
511
+ - ✅ Full Claude Code UI compatibility
512
+
513
+ ### UX Benefits
514
+
515
+ **Before (v1.0.0 - No Thinking Support):**
516
+ - Reasoning visible as regular text
517
+ - Confusing output with internal thoughts
518
+ - No progress indicators
519
+ - "All at once" message updates
520
+
521
+ **After (v1.1.0 - Full Protocol Support):**
522
+ - ✅ Reasoning hidden/collapsed
523
+ - ✅ Clean, professional output
524
+ - ✅ "Claude is thinking..." indicator shown
525
+ - ✅ Smooth incremental streaming
526
+ - ✅ Message headers/structure visible
527
+ - ✅ Protocol compliant with Anthropic Messages API
528
+
529
+ ### Documentation
530
+
531
+ For complete protocol documentation, see:
532
+ - [STREAMING_PROTOCOL.md](./STREAMING_PROTOCOL.md) - Complete SSE protocol spec
533
+ - [PROTOCOL_FIX_V2.md](./PROTOCOL_FIX_V2.md) - Critical V2 protocol fix (event ordering)
534
+ - [COMPREHENSIVE_UX_ISSUE_ANALYSIS.md](./COMPREHENSIVE_UX_ISSUE_ANALYSIS.md) - Technical analysis
535
+ - [THINKING_BLOCKS_IMPLEMENTATION.md](./THINKING_BLOCKS_IMPLEMENTATION.md) - Implementation summary
536
+
537
+ ## Development
538
+
539
+ ### Project Structure
540
+
541
+ ```
542
+ mcp/claudish/
543
+ ├── src/
544
+ │ ├── index.ts # Main entry point
545
+ │ ├── cli.ts # CLI argument parser
546
+ │ ├── proxy-server.ts # Hono-based proxy server
547
+ │ ├── transform.ts # API format translation (from claude-code-proxy)
548
+ │ ├── claude-runner.ts # Claude CLI runner (creates temp settings)
549
+ │ ├── port-manager.ts # Port utilities
550
+ │ ├── config.ts # Constants and defaults
551
+ │ └── types.ts # TypeScript types
552
+ ├── tests/ # Test files
553
+ ├── package.json
554
+ ├── tsconfig.json
555
+ └── biome.json
556
+ ```
557
+
558
+ ### Proxy Implementation
559
+
560
+ Claudish uses a **Hono-based proxy server** inspired by [claude-code-proxy](https://github.com/kiyo-e/claude-code-proxy):
561
+
562
+ - **Framework**: [Hono](https://hono.dev/) - Fast, lightweight web framework
563
+ - **API Translation**: Converts Anthropic API format ↔ OpenAI format
564
+ - **Streaming**: Full support for Server-Sent Events (SSE)
565
+ - **Tool Calling**: Handles Claude's tool_use ↔ OpenAI's tool_calls
566
+ - **Battle-tested**: Based on production-ready claude-code-proxy implementation
567
+
568
+ **Why Hono?**
569
+ - Native Bun support (no adapters needed)
570
+ - Extremely fast and lightweight
571
+ - Middleware support (CORS, logging, etc.)
572
+ - Works across Node.js, Bun, and Cloudflare Workers
573
+
574
+ ### Build & Test
575
+
576
+ ```bash
577
+ # Install dependencies
578
+ bun install
579
+
580
+ # Development mode
581
+ bun run dev "test prompt"
582
+
583
+ # Build
584
+ bun run build
585
+
586
+ # Lint
587
+ bun run lint
588
+
589
+ # Format
590
+ bun run format
591
+
592
+ # Type check
593
+ bun run typecheck
594
+
595
+ # Run tests
596
+ bun test
597
+ ```
598
+
599
+ ### Protocol Compliance Testing
600
+
601
+ Claudish includes a comprehensive snapshot testing system to ensure 1:1 compatibility with the official Claude Code protocol:
602
+
603
+ ```bash
604
+ # Run snapshot tests (13/13 passing ✅)
605
+ bun test tests/snapshot.test.ts
606
+
607
+ # Full workflow: capture fixtures + run tests
608
+ ./tests/snapshot-workflow.sh --full
609
+
610
+ # Capture new test fixtures from monitor mode
611
+ ./tests/snapshot-workflow.sh --capture
612
+
613
+ # Debug SSE events
614
+ bun tests/debug-snapshot.ts
615
+ ```
616
+
617
+ **What Gets Tested:**
618
+ - ✅ Event sequence (message_start → content_block_start → deltas → stop → message_delta → message_stop)
619
+ - ✅ Content block indices (sequential: 0, 1, 2, ...)
620
+ - ✅ Tool input streaming (fine-grained JSON chunks)
621
+ - ✅ Usage metrics (present in message_start and message_delta)
622
+ - ✅ Stop reasons (always present and valid)
623
+ - ✅ Cache metrics (creation and read tokens)
624
+
625
+ **Documentation:**
626
+ - [Quick Start Guide](./QUICK_START_TESTING.md) - Get started with testing
627
+ - [Snapshot Testing Guide](./SNAPSHOT_TESTING.md) - Complete testing documentation
628
+ - [Implementation Details](./ai_docs/IMPLEMENTATION_COMPLETE.md) - Technical implementation summary
629
+ - [Protocol Compliance Plan](./ai_docs/PROTOCOL_COMPLIANCE_PLAN.md) - Detailed compliance roadmap
630
+
631
+ ### Install Globally
632
+
633
+ ```bash
634
+ # Link for global use
635
+ bun run install:global
636
+
637
+ # Now use anywhere
638
+ claudish "your task"
639
+ ```
640
+
641
+ ## Troubleshooting
642
+
643
+ ### "Claude Code CLI is not installed"
644
+
645
+ Install Claude Code:
646
+
647
+ ```bash
648
+ npm install -g claude-code
649
+ # or visit: https://claude.com/claude-code
650
+ ```
651
+
652
+ ### "OPENROUTER_API_KEY environment variable is required"
653
+
654
+ Set your API key:
655
+
656
+ ```bash
657
+ export OPENROUTER_API_KEY=sk-or-v1-...
658
+ ```
659
+
660
+ Or add to your shell profile (`~/.zshrc`, `~/.bashrc`):
661
+
662
+ ```bash
663
+ echo 'export OPENROUTER_API_KEY=sk-or-v1-...' >> ~/.zshrc
664
+ source ~/.zshrc
665
+ ```
666
+
667
+ ### "No available ports found"
668
+
669
+ Specify a custom port:
670
+
671
+ ```bash
672
+ claudish --port 3000 "your task"
673
+ ```
674
+
675
+ Or increase port range in `src/config.ts`.
676
+
677
+ ### Proxy errors
678
+
679
+ Check OpenRouter API status:
680
+ - https://openrouter.ai/status
681
+
682
+ Verify your API key works:
683
+ - https://openrouter.ai/keys
684
+
685
+ ### Status line not showing model
686
+
687
+ If the status line doesn't show the model name:
688
+
689
+ 1. **Check if --settings flag is being passed:**
690
+ ```bash
691
+ # Look for this in Claudish output:
692
+ # [claudish] Instance settings: /tmp/claudish-settings-{timestamp}.json
693
+ ```
694
+
695
+ 2. **Verify environment variable is set:**
696
+ ```bash
697
+ # Should be set automatically by Claudish
698
+ echo $CLAUDISH_ACTIVE_MODEL_NAME
699
+ # Should output something like: xAI/Grok-1
700
+ ```
701
+
702
+ 3. **Test status line command manually:**
703
+ ```bash
704
+ export CLAUDISH_ACTIVE_MODEL_NAME="xAI/Grok-1"
705
+ cat > /dev/null && echo "[$CLAUDISH_ACTIVE_MODEL_NAME] 📁 $(basename "$(pwd)")"
706
+ # Should output: [xAI/Grok-1] 📁 your-directory-name
707
+ ```
708
+
709
+ 4. **Check temp settings file:**
710
+ ```bash
711
+ # File is created in /tmp/claudish-settings-*.json
712
+ ls -la /tmp/claudish-settings-*.json 2>/dev/null | tail -1
713
+ cat /tmp/claudish-settings-*.json | head -1
714
+ ```
715
+
716
+ 5. **Verify bash is available:**
717
+ ```bash
718
+ which bash
719
+ # Should show path to bash (usually /bin/bash or /usr/bin/bash)
720
+ ```
721
+
722
+ **Note:** Temp settings files are automatically cleaned up when Claudish exits. If you see multiple files, you may have crashed instances - they're safe to delete manually.
723
+
724
+ ## Comparison with Claude Code
725
+
726
+ | Feature | Claude Code | Claudish |
727
+ |---------|-------------|----------|
728
+ | Model | Anthropic models only | Any OpenRouter model |
729
+ | API | Anthropic API | OpenRouter API |
730
+ | Cost | Anthropic pricing | OpenRouter pricing |
731
+ | Setup | API key → direct | API key → proxy → OpenRouter |
732
+ | Speed | Direct connection | ~Same (local proxy) |
733
+ | Features | All Claude Code features | All Claude Code features |
734
+
735
+ **When to use Claudish:**
736
+ - ✅ Want to try different models (Grok, GPT-5, etc.)
737
+ - ✅ Need OpenRouter-specific features
738
+ - ✅ Prefer OpenRouter pricing
739
+ - ✅ Testing model performance
740
+
741
+ **When to use Claude Code:**
742
+ - ✅ Want latest Anthropic models only
743
+ - ✅ Need official Anthropic support
744
+ - ✅ Simpler setup (no proxy)
745
+
746
+ ## Contributing
747
+
748
+ Contributions welcome! Please:
749
+
750
+ 1. Fork the repo
751
+ 2. Create feature branch: `git checkout -b feature/amazing`
752
+ 3. Commit changes: `git commit -m 'Add amazing feature'`
753
+ 4. Push to branch: `git push origin feature/amazing`
754
+ 5. Open Pull Request
755
+
756
+ ## License
757
+
758
+ MIT © MadAppGang
759
+
760
+ ## Acknowledgments
761
+
762
+ Claudish's proxy implementation is based on [claude-code-proxy](https://github.com/kiyo-e/claude-code-proxy) by [@kiyo-e](https://github.com/kiyo-e). We've adapted their excellent Hono-based API translation layer for OpenRouter integration.
763
+
764
+ **Key contributions from claude-code-proxy:**
765
+ - Anthropic ↔ OpenAI API format translation (`transform.ts`)
766
+ - Streaming response handling with Server-Sent Events
767
+ - Tool calling compatibility layer
768
+ - Clean Hono framework architecture
769
+
770
+ Thank you to the claude-code-proxy team for building a robust, production-ready foundation! 🙏
771
+
772
+ ## Links
773
+
774
+ - **GitHub**: https://github.com/MadAppGang/claude-code
775
+ - **OpenRouter**: https://openrouter.ai
776
+ - **Claude Code**: https://claude.com/claude-code
777
+ - **Bun**: https://bun.sh
778
+ - **Hono**: https://hono.dev
779
+ - **claude-code-proxy**: https://github.com/kiyo-e/claude-code-proxy
780
+
781
+ ---
782
+
783
+ Made with ❤️ by [MadAppGang](https://madappgang.com)