Nexus-CLI – DeepSeek R1/V3とClaude Code、Ollamaサポートのための純粋なGoブリッジ
Nexus-CLI – Pure Go Bridge to DeepSeek R1/V3 with Claude Code and Ollama Support (github.com)
要約
Nexus-CLIは、公式の有料DeepSeek APIキーなしで、無料のWebアカウント(chat.deepseek.com)経由でDeepSeek V3およびR1モデルに接続できる高性能なGolang CLIユーティリティおよびローカルAPIプロキシサーバーです。純粋なGoでゼロランタイム依存関係で書かれており、並列PoWソルバー、インタラクティブターミナルチャット、Unixパイプサポート、OpenAI/Anthropic/Ollama互換プロキシサーバー、構造化出力、および複数の統合ランチャーを提供します。
全文翻訳
Nexus-CLI(DeepSeek Web Bridge for Golang)⚡
高性能なGolang CLIユーティリティおよびローカルAPIプロキシサーバーで、あらゆるアプリケーションまたはコーディングエージェントが、公式の有料DeepSeek APIキーを必要とせずに、無料のWebアカウント(chat.deepseek.com)を介してDeepSeek V3(deepseek-chat)およびR1(deepseek-reasoner / Thinking)モデルに接続できるようにします。
Node.js(FreeDeepseekAPI-EN)およびPython(deepseek_bridge)プロジェクトの詳細な分析に基づいて、純粋なGo(Golang)でゼロから書き直され、ランタイム依存関係ゼロを特徴としています。
🚀 主な機能
- 純粋なGo並列PoW(Proof-of-Work)ソルバー:
DeepSeekHashV1アルゴリズム(Keccak-f[1600] 1..23ラウンドSHA3-256)を使用してDeepSeekサーバーのチャレンジを解決します。CPUコア全体で並列化されています。- 難易度144,000のチャレンジをわずか約40〜50ミリ秒で解決します(CGO、WASM、Pythonの依存関係は不要)。
- インタラクティブターミナルチャット(REPL):
- R1モデルの思考プロセス(
reasoning_content)を専用のスタイリング(イタリック/シアン)でリアルタイムにストリーミングします。 - カラフルなプロンプトとアニメーションローディングスピナーを備えた洗練されたANSI UI。
- 内蔵スラッシュコマンド:
/help、/new、/model、/thinking、/search、/whoami、/clear、/exit。
- R1モデルの思考プロセス(
- ワンオフ&Unixパイプサポート:
- 直接CLIクエリ:
nexus "What is quantum computing?" - Linux/macOSパイプワークフロー:
cat main.go | nexus "Review this code for security and performance"
- 直接CLIクエリ:
- OpenAI、Anthropic&Ollama互換プロキシサーバー(
nexus serve):POST /v1/chat/completions(OpenAI形式、SSEストリーミング、JSON)POST /v1/messages(Anthropic Messages API — Claude CodeおよびAnthropic SDKと100%互換!)POST /v1/responses(OpenAI Responses API)GET /v1/modelsおよびGET /v1/model-capabilitiesGET /v1/sessionsおよびPOST /v1/sessions/reset- Open WebUI、Continue.dev、Cursor、Cline、およびその他のOpenAI/Anthropicクライアントとシームレスに接続します。
- ネイティブOllama APIエミュレーション 🦙:
GET /api/tags、POST /api/chat、POST /api/generate、GET /api/versionをエミュレートします。- Open WebUI、Dify、AnythingLLM、Cursor、LlamaIndex、および公式Ollama SDKとの直接プラグアンドプレイ互換性。
- 構造化出力&JSONスキーマ 🎯:
- CLI、Ollama、およびOpenAIエンドポイント全体で、厳密なJSON出力またはJSONスキーマに対する検証を強制します。
- ユニバーサル統合(ランチャー)🚀:
- Claude Code、DeepSeek Harness、Codex、OpenCode、Goose、およびAider(Nexusはプロキシをバックグラウンドで自動的に起動します)のワンコマンドランチャー。
- マルチアカウントプール 👥:
- ラウンドロビン(Round-Robin)スケジューリングを使用して複数のDeepSeekアカウントをローテーションし、レート制限の障害(HTTP 429)を排除します。
- 認証管理(
nexus auth):- 手動ログイン:
nexus auth login(ブラウザのLocalStorageからuserTokenを抽出) - Chrome経由の自動ログイン:
nexus auth chrome(CDP経由でブラウザメモリからセッショントークンを読み取る) - アカウント検査:
nexus auth whoami
- 手動ログイン:
- システム診断(Doctor):
nexus doctor— トークン有効性、サーバー接続性、PoWソルバーパフォーマンス、セッション作成を即座にチェックします。
📦 インストールとビルド
Go 1.20+ が必要です。
# リポジトリをクローンしてディレクトリに移動します:
git clone https://github.com/xamrayev/nexus-cli.git
cd nexus-cli
# 実行可能バイナリをビルドします:
go build -o bin/nexus .
# システムPATHにグローバルにインストールします(オプション):
go install .
🔑 認証(アカウントリンク)
DeepSeekアカウントを接続するには3つの方法があります。
1. インタラクティブCLIプロンプト:
./bin/nexus auth login
userTokenを求められます。
- ブラウザで
https://chat.deepseek.comを開きます。 F12(またはmacOSではCmd+Option+I)を押します。Application->Local Storage->https://chat.deepseek.comに移動します ->userTokenの値をコピーしてプロンプトに貼り付けます。
2. Chrome経由の自動(CDP):
./bin/nexus auth chrome
これにより、Chromeウィンドウが自動的に起動します。ログインすると、Nexusはセッショントークンを安全にキャプチャして保存します。
3. .envファイル経由:
プロジェクトルートに.envファイルを作成します。
DEEPSEEK_TOKEN=your_deepseek_token_here
💡 使用例
1. インタラクティブチャット(REPL)
./bin/nexus chat
または単に:
./bin/nexus
リアルタイムR1思考ストリーム:
nexus ❯ Why is the sky blue?
💭 Thinking Process:
The user is asking about the physical cause behind the color of the sky...
Need to explain the mechanism of Rayleigh scattering of sunlight by atmospheric molecules...
🤖 DeepSeek (deepseek-reasoner):
The primary reason the sky appears blue is due to a phenomenon called Rayleigh scattering...
2. ワンオフプロンプト
./bin/nexus "Provide 3 key facts about general relativity"
3. Unixパイプ経由のコード分析
cat main.go | ./bin/nexus "Review this code for security and performance"
4. ローカルAPIプロキシサーバーの実行
./bin/nexus serve --port 9655
これで、任意のツール(Cursor、Open WebUI、Claude Code)をhttp://localhost:9655/v1にルーティングできます!
OpenAI形式のサンプルcURLリクエスト:
curl http://localhost:9655/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-reasoner",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
5. ネイティブOllama APIエミュレーション 🦙
NexusはOllama API仕様を実装しています。Open WebUI、Dify、AnythingLLM、Cursor、LlamaIndex、および公式Ollamaライブラリは、http://localhost:9655に直接接続できます。
# 1. 利用可能なモデルを取得(Ollama形式)
curl http://localhost:9655/api/tags
# 2. Ollamaチャットリクエスト(NDJSONストリーミング)
curl http://localhost:9655/api/chat -d '{
"model": "deepseek-reasoner",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
公式Python Ollama SDKを使用:
import ollama
client = ollama.Client(host="http://localhost:9655")
resp = client.chat(model="deepseek-reasoner", messages=[
{"role": "user", "content": "Write a simple HTTP server in Go"}
])
print(resp["message"]["content"])
6. 構造化出力&JSONスキーマ 🎯
厳密なJSON出力または指定されたスキーマへの準拠を強制します。
# 1. CLIからの直接JSON(jqにパイプ可能)
./bin/nexus "Top 3 programming languages and their primary domains" --format json | jq .
# 2. Ollama API経由:
curl http://localhost:9655/api/chat -d '{
"model": "deepseek-reasoner",
"messages": [{"role": "user", "content": "List 3 fruits in JSON"}],
"format": "json",
"stream": false
}'
# 3. OpenAI API経由(response_format):
curl http://localhost:9655/v1/chat/completions -d '{
"model": "deepseek-reasoner",
"messages": [{"role": "user", "content": "Return device specs as JSON"}],
"response_format": {"type": "json_object"}
}'
7. ユニバーサル統合(ランチャー)🚀
単一のコマンドでコーディングツールやエージェントを起動します。Nexusはプロキシサーバーをバックグラウンドで自動的に起動します。
# 1. Claude Code CLI(DeepSeek R1 / V3搭載)
./bin/nexus launch claude
./bin/nexus launch claude -p "Refactor this Go code"
# 2. 公式DeepSeek Harness CLI(@deepseek-ai/dsh)
./bin/nexus launch dsh
# 3. OpenAI Codex CLI(レスポンスワイヤーAPIで自動設定)
./bin/nexus launch codex
# 4. OpenCode CLI(自動設定注入付き)
./bin/nexus launch opencode
# 5. Block Goose AI Agent(OpenAIプロバイダー経由)
./bin/nexus launch goose
# 6. AiderペアプログラミングCLI(DeepSeek R1搭載)
./bin/nexus launch aider
# 7. ChatGPT Desktop(macOS)&ローカルブリッジ
./bin/nexus launch chatgpt
# 8. マルチアカウントプールモニター
./bin/nexus launch pool
# 9. DeepSeek Agentic Eval & Benchmark Harness
./bin/nexus launch harness
8. マルチアカウントプール 👥
ラウンドロビンローテーションを使用して複数のDeepSeekアカウントを循環させることで、レート制限(HTTP 429)を回避します。
# 新しいアカウントを追加
./bin/nexus auth add acc2 --chrome
# アカウントをリストし、ステータスを確認します
./bin/nexus auth list
# アクティブなアカウントを切り替えます
./bin/nexus auth switch acc2
# プール内のすべてのアカウントを検証します
./bin/nexus auth test
9. システム診断(Doctor)
./bin/nexus doctor
📁 プロジェクト構造
nexus-cli/
├── bin/
│ └── nexus # コンパイル済みバイナリ実行可能ファイル
├── cmd/
│ └── nexus/main.go # CLIコマンドディスパッチャー
├── pkg/
│ ├── deepseek/
│ │ ├── pow.go # 純粋なGo並列DeepSeekHashV1 Keccak PoWソルバー
│ │ ├── pow_test.go # PoWテストスイートとベンチマーク
│ │ ├── stream.go # SSE JSONパッチとOpenAIストリームパーサー
│ │ ├── stream_test.go # ストリームテスト
│ │ ├── auth.go # トークン、セッション、プロファイルマネージャー
│ │ ├── chrome_auth.go # 自動Chrome CDP認証
│ │ ├── client.go # DeepSeek Web APIクライアント(チャット、セッション、自動リトライ)
│ │ └── types.go # モデル設定と型定義
│ ├── server/
│ │ ├── server.go # ローカルHTTPプロキシサーバー(ルーティング、CORS、認証)
│ │ ├── server_test.go # サーバーエンドポイント単体テスト
│ │ ├── openai.go # OpenAI Chat Completions APIアダプター
│ │ ├── anthropic.go # Anthropic Messages APIアダプター(Claude Code用)
│ │ └── session.go # エージェントセッションの分離とクリーンアップ
│ ├── launcher/
│ │ └── launcher.go # Claude Code、Codex、Goose、Aiderなどのランチャー
│ └── cli/
│ ├── terminal.go # ANSIスタイリング、バナー、スピナー
│ ├── repl.go # インタラクティブターミナルチャットとスラッシュコマンド
│ ├── runner.go # ワンプロンプトおよびUnixパイプランナー
│ └── doctor.go # エンドツーエンドシステム診断
├── main.go # アプリケーションのエントリーポイント
├── go.mod # Goモジュール定義
├── README.md # メインドキュメント(英語)
├── README.ru.md # ロシア語ドキュメント(Русский)
└── README.uz.md # ウズベク語ドキュメント(O'zbekcha)
📄 ライセンス
MITライセンスで配布されています。