Skip to content

About

Unofficial OpenCode CLI wrapper for Termux (Android aarch64)

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

62 Commits

Folders and files

Repository files navigation

@bash0816/opencode-termux

OpenCode CLI for Termux on Android ARM64.

Termux 向け OpenCode CLI wrapper package です。

Notice / お知らせ

Please update to 2.2.5. It fixes the first-run failure cannot locate symbol "_ZNSt6__ndk113__hash_memoryEPKvm" (an outdated libc++ that patchelf cannot start with). Before downloading anything, opencode-termux now checks that the glibc loader, patchelf and readelf can run, explains what is missing, and offers the matching pkg install after you confirm. It also offers to install a missing glibc loader or tar after you confirm.

  1. Update the wrapper: npm install -g @bash0816/opencode-termux@latest
  2. Install anything that is missing (see Prerequisites): pkg install patchelf libc++ llvm, and pkg install glibc-repo && pkg install glibc if the glibc loader is missing.

If you are still on 2.2.0 or earlier and see this error, run pkg install libc++ and try again (details).

2.2.5 への更新をお願いします。 初回起動の失敗 cannot locate symbol "_ZNSt6__ndk113__hash_memoryEPKvm"(libc++ が古く、patchelf が起動できない)が修正されています。ダウンロードの前に、glibc のローダー、patchelf、readelf が実行できるかを確認し、足りないものを説明して、確認のうえで該当の pkg install を実行します。また、glibc のローダーや tar が不足している場合も、確認のうえで導入します。

  1. ラッパーを更新: npm install -g @bash0816/opencode-termux@latest
  2. 足りないものを入れる(前提条件 を参照): pkg install patchelf libc++ llvm。glibc のローダーが無い場合は pkg install glibc-repo && pkg install glibc も実行してください。

2.2.0 以前のままでこのエラーが出る場合は、pkg install libc++ を実行してから、もう一度お試しください(詳細)。

This project is not affiliated with, endorsed by, or sponsored by SST / the OpenCode project. このプロジェクトは OpenCode プロジェクト(SST)と無関係です。公式から承認・提携・保証されたものではありません。

OpenCode is released under the MIT License. This wrapper downloads the official upstream binary and adjusts it to run on Termux/Android. It handles update, upgrade, and uninstall only when one of those is the first argument; all other argv, including flags before a management word, go unchanged to upstream.

OpenCode 本体は MIT ライセンス で公開されています。 本ラッパーは公式 upstream バイナリをダウンロードし、Termux/Android 上で動作するよう調整します。argv[0] が update・upgrade・uninstall の場合だけラッパーが処理します。flag が先頭にある場合を含むその他の argv は変更せず upstream に渡します。

What this does / 仕組み

This package downloads the official OpenCode CLI binary from npm (@opencode/cli-linux-arm64) at the user's explicit request, then rewrites the binary's ELF interpreter (using patchelf) so it can be executed directly on Termux/Android using a glibc runtime, instead of Android's default bionic libc.

このパッケージはユーザーの明示的な操作により、npm から OpenCode CLI の公式バイナリ (@opencode/cli-linux-arm64) をダウンロードし、patchelf を使って ELF インタープリタを書き換えることで、Android 標準の bionic libc ではなく glibc ランタイム上で 直接実行できるようにします。

  • No OpenCode binaries or modified binaries are distributed by this package.
  • このパッケージは OpenCode バイナリや改変済みバイナリを配布しません。
  • The rewrite is intended solely for Termux/Android runtime interoperability. It does not bypass authentication, licensing, payment, access controls, or usage restrictions.
  • 書き換えの目的は Termux/Android 実行環境への互換性確保のみです。 認証・ライセンス・課金・アクセス制御・利用制限の回避を意図するものではありません。

OpenCode 1.x and 2.x / OpenCode の 1系と2系

OpenCode has two separate npm distribution lines: 1.x (opencode-ai) and 2.x. The official npm package for 2.x is @opencode/cli; @opencode/cli-linux-arm64 is its Linux ARM64 binary package. This package supports only the 2.x line (@opencode/cli-linux-arm64), not the 1.x line (opencode-ai). For the official documentation, see OpenCode 1.x and OpenCode 2.x.

OpenCode には npm 上で別系統の配布ラインが 2 つあります。1系は opencode-ai、 2系の公式 npm パッケージは @opencode/cli です。 @opencode/cli-linux-arm64 はその Linux ARM64 用バイナリパッケージです。 本パッケージが対応するのは2系 (@opencode/cli-linux-arm64) のみで、1系 (opencode-ai) には対応していません。公式ドキュメントは1系、 2系を参照してください。

Prerequisites / 前提条件

# Updates ALL installed packages (recommended by Termux) / インストール済みの全パッケージを更新します(Termux 推奨)
pkg update && pkg upgrade
pkg install glibc-repo && pkg install glibc
pkg install patchelf libc++
pkg install llvm

readelf は llvm パッケージが提供します / readelf is provided by the llvm package

On first run (when setup runs), opencode-termux checks for missing prerequisites: glibc, patchelf, libc++, llvm (for readelf), and tar. If any are missing, it shows the commands it will run and asks for confirmation (type y) before installing them with pkg install. If you answer n, or if the terminal is non-interactive, it installs nothing, shows the commands to run manually, and exits. If glibc is missing, glibc-repo (which adds the repository configuration) is installed first. Changes to the repository configuration are persistent, and there is no guarantee they can be reverted. If you need to remove them, check the effects on dependencies first, then remove them manually. It does not run a full upgrade (pkg update && pkg upgrade) automatically. For problems it cannot fix automatically (for example, package link errors or a loader that cannot run), it shows the commands to run manually and exits.

初回セットアップの実行時、opencode-termux は不足している前提パッケージ(glibc、patchelf、libc++、llvm(readelf 用)、tar)を検査します。不足があれば、実行するコマンドを表示し、確認(y を入力)のうえで pkg install により導入します。n と答えた場合、または対話できない(非対話の)端末の場合は、何も導入せず、手動で実行するコマンドを案内して終了します。glibc が無い場合は、先に glibc-repo(リポジトリ設定の追加)を導入します。リポジトリ設定の変更は永続的で、元に戻す保証はありません。削除が必要な場合は、依存関係などへの影響を確認したうえで、手動で行ってください。全体更新(pkg update && pkg upgrade)は自動では実行しません。パッケージのリンクエラーや実行できないローダーなど、自動では直せない問題の場合は、手動で実行するコマンドを案内して終了します。

If setup fails with cannot locate symbol "_ZNSt6__ndk1..." / セットアップが cannot locate symbol で失敗する場合

On first run, opencode may stop with an error like this:

opencode-termux: setup failed: Command failed: patchelf --set-interpreter ...
CANNOT LINK EXECUTABLE "patchelf": cannot locate symbol "_ZNSt6__ndk113__hash_memoryEPKvm" ...

This error can occur when the installed libc++ is older than the version your patchelf needs. Update libc++, then run opencode again:

pkg install libc++

If pkg does not offer a newer version, switch to a current mirror with termux-change-repo, then run pkg update && pkg upgrade (this updates all installed packages, not only OpenCode's prerequisites).

初回起動で上記のようなエラーが出る場合は、インストール済みの libc++ が patchelf の必要とするバージョンより古いことが原因の場合があります。libc++ を更新してから、もう一度 opencode を実行してください。

pkg install libc++

pkg が新しいバージョンを見つけられない場合は、termux-change-repo で最新のミラーに切り替え、pkg update && pkg upgrade を実行してください(OpenCode に必要なパッケージだけでなく、インストール済みの全パッケージが更新されます)。

Install / インストール

npm install -g @bash0816/opencode-termux

On first run, the official OpenCode binary will be downloaded from npm and patched for this device. Subsequent runs reuse the cached, verified installation.

初回起動時に npm から公式 OpenCode バイナリがダウンロードされ、このデバイス向けに パッチが適用されます。以降の起動ではキャッシュ済みの検証済みインストールを再利用します。

Tested with OpenCode 2.2.5 on Termux/Android ARM64.

OpenCode 2.2.5・Termux/Android ARM64 で動作確認済み。

Update / 更新

OpenCode 2.0.22 以降では opencode update と opencode upgrade がこの npm wrapper 自体を更新します。更新先は npm の latest です。明示した version への更新は opencode update 2.0.22 のように指定できます。更新後の OpenCode バイナリは次回起動時に取得されます。wrapper の npm prefix を検出できない場合は更新を中止し、prefix を指定した npm コマンドを案内します。

TUI 内の /update(更新ダイアログの Update)は Termux では使えません。「Installation method not found」と表示され、更新は実行されません。シェルで opencode update を実行してください。

利用者が自動更新環境変数を設定していない場合、通常の起動時自動更新チェックを停止します。これは OpenCode のすべての更新経路を無効にする説明ではありません。

npm 更新に成功した後、次回起動で setup に失敗した場合は、同じ prefix を指定して以前の wrapper version を再インストールしてください:

npm install -g --prefix <prefix> @bash0816/opencode-termux@<previous-version>

package.json の version は対応する upstream @opencode/cli-linux-arm64 の version です。

OpenCode 2.0.22 and later route opencode update and opencode upgrade to update this npm wrapper to the registry's latest version. To request a specific version, use opencode update 2.0.22. The new OpenCode binary is fetched on the next launch. If the wrapper's npm prefix cannot be detected, the update stops and prints an npm command with an explicit prefix.

The TUI /update command (Update in the update dialog) is unavailable on Termux. It displays “Installation method not found” and does not perform an update. Run opencode update in the shell instead.

When the user has not set OPENCODE_DISABLE_AUTOUPDATE, the wrapper disables the normal startup update check. This does not describe every possible update path as disabled.

If setup fails on the next launch after npm successfully updates the wrapper, reinstall the previous wrapper version using the same prefix:

npm install -g --prefix <prefix> @bash0816/opencode-termux@<previous-version>

実体配置は標準 npm 配置である必要があります。package または lib/ の実体配置が標準配置と不整合な構成には対応していません。標準配置にある package への symlink は利用できます。

The package must resolve to the standard npm layout, and its lib/ realpath must match that layout. Nonstandard real locations or inconsistent package and library realpaths are unsupported. A symlink to a package in the standard layout is supported.

The package.json version is the corresponding upstream @opencode/cli-linux-arm64 version.

Uninstall / アンインストール

opencode uninstall は OpenCode のデータ・設定・認証・セッション・cache・state を削除する可能性があるため実行せず、案内を表示して終了します。wrapper を削除するには次を実行し、キャッシュ ~/.opencode-termux も削除してください。prefix を特定できない場合は、インストール時の prefix を <prefix> に指定してください。

npm uninstall -g --prefix <prefix> @bash0816/opencode-termux

OpenCode 自身の設定・認証・セッションデータはこの手順では削除されません。保存先は削除前に opencode debug paths で確認してください。

opencode uninstall is not run because it may delete OpenCode data, settings, authentication, sessions, cache, and state. The wrapper prints removal instructions and exits. Remove this wrapper and its cache with:

npm uninstall -g --prefix <prefix> @bash0816/opencode-termux
rm -rf ~/.opencode-termux

Use the prefix from installation. Before removing the wrapper, check OpenCode data locations with opencode debug paths.

Authentication / 認証

Before using OpenCode, log in to a provider. Requirements such as billing information, credits, and API keys vary by provider; see the official Console instructions:

OpenCode を使う前に、プロバイダへログインしてください。請求情報・クレジット・APIキー等の 必要な手順はプロバイダごとに異なるため、公式の Console 手順を参照してください:

opencode auth login opencode

This starts the login process. Follow the on-screen instructions to complete it. Run opencode auth list to check saved authentication. For details, see opencode auth login --help.

opencode auth login opencode でログインを開始し、画面の案内に従って完了してください。 保存済み認証は opencode auth list で確認できます。詳細は opencode auth login --help を参照してください。

To use a different provider (Anthropic, OpenAI, etc.), see opencode auth login --help and the OpenCode provider documentation.

他のプロバイダ(Anthropic・OpenAI 等)を使う場合は opencode auth login --help と OpenCode プロバイダ ドキュメント を参照してください。

Usage / 使い方

opencode [command] [options]
opencode run "your prompt here"
opencode run --model opencode/<model-id> "your prompt here"

Run opencode models to list available models. Availability and requirements vary by provider; see the official Console instructions.

利用可能なモデル一覧は opencode models で確認できます。提供状況や利用条件は プロバイダごとに異なるため、公式のConsole 手順を参照してください。

For available commands, see the OpenCode documentation.

利用可能なコマンドは OpenCode ドキュメント を参照してください。

License / ライセンス

This package (opencode-termux) is licensed under GPL-3.0-only.

このパッケージ (opencode-termux) は GPL-3.0-only ライセンスです。

The GPL does not apply to the OpenCode binary itself. The OpenCode binary downloaded at runtime is released by its authors under the MIT License and is subject to OpenCode's own terms.

GPL は OpenCode バイナリ自体には適用されません。 実行時にダウンロードされる OpenCode バイナリは、その作者により MIT ライセンスで公開されており、OpenCode 自体の利用条件に従います。

Disclaimer / 免責事項

Users are responsible for ensuring that their use of OpenCode complies with OpenCode's Terms of Service and applicable laws.

OpenCode の利用条件・適用法令への適合性はユーザー自身が確認してください。 OpenCode 利用規約 を参照してください。

If a rights holder or platform operator raises a substantiated concern regarding this package, we will promptly review it and may remove or disable the affected functionality.

権利者またはプラットフォーム運営者から具体的な懸念が示された場合、 内容を確認し、必要に応じて公開停止・機能停止・修正を行います。

Compatibility / 動作環境

  • Platform / プラットフォーム: Android (Termux)
  • Architecture / アーキテクチャ: ARM64 (aarch64)
  • Monitored upstream package / 監視対象パッケージ: @opencode/cli-linux-arm64 (v2 series). Not to be confused with the separate opencode-ai npm package (v1 series). opencode-ai(v1系列)という別系統のnpmパッケージとは異なりますのでご注意ください。

Known limitations / 既知の制限

  • Upstream OpenCode updates may require a compatibility update to this package. 上流 OpenCode のアップデートにより本パッケージの更新が必要になる場合があります。
  • If the downloaded binary fails verification, the tool will exit safely. ダウンロードしたバイナリが検証に失敗した場合、安全に終了します。
  • This package does not currently provide an automatic cleanup command for old cached installs under ~/.opencode-termux/installs/; old versions may need to be removed manually to reclaim disk space. ~/.opencode-termux/installs/ 配下の古いキャッシュ済みインストールを自動削除する コマンドは現時点で提供していません。ディスク容量が必要な場合は手動で削除してください (他の OpenCode セッションが実行中でないことを確認の上で)。

Rollback / ロールバック手順

(For package maintainers / パッケージ管理者向けの手順です)

If a critical issue is discovered after promoting a new version to latest, you can immediately roll back to the previous version using the following command:

新バージョン昇格後に重大な問題が発見された場合、以下のコマンドで前バージョンに ロールバックできます:

npm dist-tag add @bash0816/opencode-termux@<previous known-good version> latest

This moves the latest tag to a previous known-good version. The change applies to subsequent new installations and updates.

これにより latest タグが指す版が変わり、以降の新規インストール・更新に反映されます。

About

Unofficial OpenCode CLI wrapper for Termux (Android aarch64)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages