OpenCode 2.0
日本語訳
# タイタイトル
OpenCode 2.0
# 本文
OpenCode 2.0は大幅な刷新です。数百万人のデイリーユーザーの経験に基づき、エージェントが必要とするあらゆるものに適応できるシステムを提供します。多くの新機能、パフォーマンスの向上、バグ修正が含まれていますが、ここでは特にユーザーに影響を与える変更について紹介します。
### サービス
OpenCodeは当初からクライアント/サーバーモデルを採用していましたが、デフォルトではその利点を活かせておらず、主にパワーユーザー向けに使用されていました。
2.0では、このサーバーがマシン上で単一のバックグラウンドプロセスとして自動的に実行されるようになります。TUI、ウェブインターフェース、デスクトップアプリのどれを開いても、すべてが同じ中央プロセスと通信します。
独自のスクリプトを作成するためにプログラマティックなクライアント `@opencode/client` を使用している場合、ローカルサービスを自動的に検出してそのまま動作します。これはスケジュールされたタスクに特に便利です。また、`opencode api` コマンドを使用してCLI経由で呼び出すこともできます。
他のホストに公開して `/pair` または `opencode pair` を実行し、他のアプリケーションに接続することも可能です。現在、このフローを活用したネイティブアプリを開発中です。
### API
旧APIは、私たちと世界が「エージェントとは何か、どうあるべきか」を学習していく過程で、無計画に拡張されてきました。それは良くない状態でした。
私たちはゼロからやり直し、毎日OpenCodeを利用する数百万人のユーザーにおけるあらゆる特殊なユースケースを検討しました。現在のAPIは、必要とされるほぼすべての操作をサポートしています。
また、OpenCodeは自身のAPIを認識しており、新しい作業を開始する際に現在のセッションをgit worktreeに移動させるなど、有用な操作を自ら呼び出すことができます。
さらに、バニラJavaScriptおよびEffect用のクライアントを含む新しいクライアントパッケージ `@opencode/client` もリリースしました。
### Code Mode
モデルはコードを書くことを好みます。OpenCode 2.0は、他のどのコーディングエージェントよりもその特性を活かしています。私たちは `@opencode/codemode` パッケージ内に最小限のJavaScriptインタープリタを構築しました。
このパッケージはMCPサーバーやOpenAPIエンドポイントを取り込み、エージェントがスクリプト内で呼び出せる関数に変換します。Node.js VMのような複雑さや、QuickJSのような複雑なソリューションを組み込むことなく、これらのスクリプトをネイティブに実行できます。
これにより、エージェントは「ツールを呼び出し、その結果をマップして、別のツールを呼び出す」といったスクリプトを書くことができます。一つずつ呼び出すのではなく、一度のラウンドトリップで完結します。
2.0では、すべてのMCPサーバーがデフォルトでcodemodeの対象となります。これにより、コンテキストの肥大化を最小限に抑えつつ、数千のサーバーを追加でき、エージェントがそれらを発見・構成してタスクを遂行できるようになります。
### バックグラウンドタスク
最新のモデル群はオーケストレーションにおいて非常に優れており、ハーネス(実行基盤)がその能力を最大限に引き出せるようにすることが重要です。
第一に、バックグラウンド・サブエージェントを追加しました。これにより、プライマリ・エージェントが作業を継続しながら、別のエージェントに一部の作業を任せることができます。
これは自動的に行われますが、手動で(異なるモデルを使用して)トリガーすることも可能です。例えば、プロンプトの入力を続けながら「このコードをレビューするために、バックグラウンドでfableサブエージェントを起動して」といった指示が出せます。
第二に、バックグラウンド・シェルコマンドを追加しました。シェルツールを非同期で呼び出せるため、実行時間の長い作業がプライマリ・エージェントをブロックすることはありません。作業が完了すると通知を受け取ります。
フォアグラウンドのシェルコマンドやサブエージェントが予想以上に時間がかかる場合は、ホットキーを押してそれらをバックグラウンドに移動させ、プロンプトの入力を続けることができます。
### プラグイン
OpenCode 1.0にもプラグインシステムはありましたが、十分な注目を集めることはありませんでした。これを修正するため、OpenCode 2.0のほぼすべての機能を内部プラグインとして実装することを自分たちに課し、現在80以上のプラグインが存在します。これにより、プラグインAPIのメンテナンス性が保証されます。
また、TUIプラグインを実験的なものから安定版へと昇格させました。すべてはOpenTUIによって動作しているため、ほぼ何でも構築できます。以下は、役に立たないものの例です。
### SDK
OpenCodeは、`@opencode/sdk` パッケージを使用してライブラリとしても利用できるようになりました。これは、私たちのCLIを動かしているコードと全く同じものです。
つまり、これを軽量化して、サーバー上やDurable Objectsのような特殊な環境で動作する独自のOpenCodeを作成できます。そして、標準のOpenCodeサーバープロトコルに従っているため、あらゆるOpenCodeクライアントから接続可能です。
また、オプションとしてEffectベースのAPIも備えています。
### アップグレード
CLIをアップグレードするには、まず最新の1.xリリースであることを確認し、`opencode upgrade --major` を実行してください。
いくつかの破壊的変更があります。
* 1.0のプラグインは2.0では動作しません
* サーバーAPIが完全に異なります
* `tui.json` 設定は `.json` に移動されました
原文(英語)を表示
OpenCode 2.0 is a major overhaul. It draws on millions of daily users' experience to deliver a system that can flex to everything an agent needs to be. There are quite a lot of new features, performance improvements, and bug fixes but here are some of the more impactful user-facing changes.
The Service
From the beginning OpenCode adopted a client/server model. However, this was not something it took advantage of by default and was mostly used by power users.
In 2.0 this server now automatically runs as a single background process on your machine. When you open up a TUI, the web interface or the desktop app they're all talking to the same central process.
If you're using the programmatic client @opencode/client
to make your own scripts, they will autodiscover the local service and just work. This is particularly useful for scheduled tasks. You can also call it via CLI by using opencode
api
commands.
You can expose it to other hosts and run /pair
or opencode
pair
to connect it to other applications. We have native apps in the works that take advantage of this flow.
The API
The old API grew haphazardly as we and the world collectively learned what agents are and should be. It was bad.
We started from scratch and examined all the weird use cases across the millions of users who use OpenCode every day. It now supports nearly anything you need to be able to do.
OpenCode is also aware of its own API and will call it to do useful things like moving the current session into a git worktree when starting new work.
We've also shipped a new client package @opencode/client
that contains clients for vanilla JavaScript as well as Effect.
Code Mode
The models love to write code and OpenCode 2.0 takes advantage of that more than any other coding agent. We've built a minimal JavaScript interpreter in the @opencode/codemode
package.
This package ingests MCP servers or OpenAPI endpoints, converting them into functions that the agent can call in a script. It can run these scripts natively without the complexity of Node.js VMs or embedding complicated solutions like QuickJS.
This lets your agent write scripts that can do things like call a tool, map over the results and call another tool. Single round trip instead of calling them one at a time.
All MCP servers in 2.0 are opted into codemode by default. This means you can add a thousand of them with minimal context bloat and your agent will discover and compose them to get things done.
Background Tasks
The latest batch of models are incredibly good at orchestration and it is important for harnesses to let them express the full extent of that capability.
First, we've added background subagents. This allows the primary agent to kick off some work to another one while it continues.
This happens automatically but you can also trigger it manually - even with a different model. It lets you do things like “spawn a background fable subagent to review this code” while you keep prompting.
Second, we've added background shell commands. The shell tool can be invoked asynchronously so long-running work does not have to block the primary agent. It'll be notified when things are complete.
If any foreground shell command or subagent takes longer than you expect, you can hit a hotkey to move them to the background so you can keep prompting.
Plugins
Although OpenCode 1.0 had a plugin system, it never got the attention it needed. To correct that, we forced ourselves to implement nearly every OpenCode 2.0 feature as an internal plugin and there are now 80+ of them. This guarantees that the Plugin API stays well maintained.
We've also promoted TUI plugins from experimental to stable. Since it is all powered by OpenTUI, you can build nearly anything. Here is an example of something useless.
The SDK
OpenCode can also now be used as a library with the @opencode/sdk
package. This is the exact same code that powers our CLI.
This means you can strip it down and make your own flavor of OpenCode that runs on a server or in specialized environments like Durable Objects. And then you can connect to it from any OpenCode client since it speaks the standard OpenCode server protocol.
It also has an optional Effect-based API.
Upgrading
To upgrade the CLI, make sure you're on the latest 1.x release, then run opencode
upgrade
--major
.
There are some breaking changes.
1.0 plugins will not work in 2.0
Server API is completely different
tui.json config is moved to json