@bash0816/opencode-termux 2.0.18 → 2.0.22
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 +268 -0
- package/bin/opencode-termux +28 -22
- package/config/opencode-candidate-version.json +5 -5
- package/config/opencode-verified-versions.json +6 -6
- package/lib/argv-route.js +13 -0
- package/lib/self-update.js +66 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# @bash0816/opencode-termux
|
|
2
|
+
|
|
3
|
+
[OpenCode](https://opencode.ai/) CLI for Termux on Android ARM64.
|
|
4
|
+
|
|
5
|
+
Termux 向け OpenCode CLI wrapper package です。
|
|
6
|
+
|
|
7
|
+
> **This project is not affiliated with, endorsed by, or sponsored by SST / the OpenCode project.**
|
|
8
|
+
> このプロジェクトは OpenCode プロジェクト(SST)と無関係です。公式から承認・提携・保証されたものではありません。
|
|
9
|
+
|
|
10
|
+
OpenCode is released under the [MIT License](https://github.com/anomalyco/opencode/blob/dev/LICENSE).
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
OpenCode 本体は [MIT ライセンス](https://github.com/anomalyco/opencode/blob/dev/LICENSE) で公開されています。
|
|
14
|
+
本ラッパーは公式 upstream バイナリをダウンロードし、Termux/Android 上で動作するよう調整します。argv[0] が `update`・`upgrade`・`uninstall` の場合だけラッパーが処理します。flag が先頭にある場合を含むその他の argv は変更せず upstream に渡します。
|
|
15
|
+
|
|
16
|
+
> **Notice: updating from 2.0.18 / 2.0.19 / 更新に関するお知らせ**
|
|
17
|
+
> Versions 2.0.18 and 2.0.19 have a bug in OpenCode's built-in update command. Please update with npm instead:
|
|
18
|
+
> `npm update -g @bash0816/opencode-termux`
|
|
19
|
+
> This is planned to be fixed in the next release. Releases have been slower than usual; thank you for your patience.
|
|
20
|
+
>
|
|
21
|
+
> 2.0.18 と 2.0.19 には、OpenCode 組み込みのアップデート機能に不具合があります。更新は npm で行ってください:
|
|
22
|
+
> `npm update -g @bash0816/opencode-termux`
|
|
23
|
+
> 次回のリリースで修正予定です。リリースが通常より遅れており、ご迷惑をおかけしています。
|
|
24
|
+
|
|
25
|
+
## What this does / 仕組み
|
|
26
|
+
|
|
27
|
+
This package downloads the official OpenCode CLI binary from npm
|
|
28
|
+
([`@opencode/cli-linux-arm64`](https://www.npmjs.com/package/@opencode/cli-linux-arm64))
|
|
29
|
+
at the user's explicit request, then rewrites the binary's ELF interpreter (using
|
|
30
|
+
[`patchelf`](https://github.com/NixOS/patchelf)) so it can be executed directly on
|
|
31
|
+
Termux/Android using a glibc runtime, instead of Android's default bionic libc.
|
|
32
|
+
|
|
33
|
+
このパッケージはユーザーの明示的な操作により、npm から OpenCode CLI の公式バイナリ
|
|
34
|
+
([`@opencode/cli-linux-arm64`](https://www.npmjs.com/package/@opencode/cli-linux-arm64))
|
|
35
|
+
をダウンロードし、[`patchelf`](https://github.com/NixOS/patchelf) を使って ELF
|
|
36
|
+
インタープリタを書き換えることで、Android 標準の bionic libc ではなく glibc ランタイム上で
|
|
37
|
+
直接実行できるようにします。
|
|
38
|
+
|
|
39
|
+
- **No OpenCode binaries or modified binaries are distributed by this package.**
|
|
40
|
+
- **このパッケージは OpenCode バイナリや改変済みバイナリを配布しません。**
|
|
41
|
+
- The rewrite is intended solely for Termux/Android runtime interoperability.
|
|
42
|
+
It does not bypass authentication, licensing, payment, access controls, or usage restrictions.
|
|
43
|
+
- 書き換えの目的は Termux/Android 実行環境への互換性確保のみです。
|
|
44
|
+
認証・ライセンス・課金・アクセス制御・利用制限の回避を意図するものではありません。
|
|
45
|
+
|
|
46
|
+
## OpenCode 1.x and 2.x / OpenCode の 1系と2系
|
|
47
|
+
|
|
48
|
+
OpenCode has two separate npm distribution lines: 1.x (`opencode-ai`) and 2.x.
|
|
49
|
+
The official npm package for 2.x is [`@opencode/cli`](https://www.npmjs.com/package/@opencode/cli);
|
|
50
|
+
`@opencode/cli-linux-arm64` is its Linux ARM64 binary package. This package supports
|
|
51
|
+
only the 2.x line (`@opencode/cli-linux-arm64`), not the 1.x line (`opencode-ai`).
|
|
52
|
+
For the official documentation, see [OpenCode 1.x](https://opencode.ai/docs) and
|
|
53
|
+
[OpenCode 2.x](https://opencode.ai/v2/docs).
|
|
54
|
+
|
|
55
|
+
OpenCode には npm 上で別系統の配布ラインが 2 つあります。1系は `opencode-ai`、
|
|
56
|
+
2系の公式 npm パッケージは [`@opencode/cli`](https://www.npmjs.com/package/@opencode/cli) です。
|
|
57
|
+
`@opencode/cli-linux-arm64` はその Linux ARM64 用バイナリパッケージです。
|
|
58
|
+
本パッケージが対応するのは2系 (`@opencode/cli-linux-arm64`) のみで、1系
|
|
59
|
+
(`opencode-ai`) には対応していません。公式ドキュメントは[1系](https://opencode.ai/docs)、
|
|
60
|
+
[2系](https://opencode.ai/v2/docs)を参照してください。
|
|
61
|
+
|
|
62
|
+
## Prerequisites / 前提条件
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
pkg install glibc-repo && pkg install glibc
|
|
66
|
+
pkg install patchelf
|
|
67
|
+
pkg install llvm
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
readelf は llvm パッケージが提供します / readelf is provided by the llvm package
|
|
71
|
+
|
|
72
|
+
## Install / インストール
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
npm install -g @bash0816/opencode-termux
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
On first run, the official OpenCode binary will be downloaded from npm and patched
|
|
79
|
+
for this device. Subsequent runs reuse the cached, verified installation.
|
|
80
|
+
|
|
81
|
+
初回起動時に npm から公式 OpenCode バイナリがダウンロードされ、このデバイス向けに
|
|
82
|
+
パッチが適用されます。以降の起動ではキャッシュ済みの検証済みインストールを再利用します。
|
|
83
|
+
|
|
84
|
+
**Tested with OpenCode 2.0.18 on Termux/Android ARM64.**
|
|
85
|
+
|
|
86
|
+
**OpenCode 2.0.18・Termux/Android ARM64 で動作確認済み。**
|
|
87
|
+
|
|
88
|
+
## Update / 更新
|
|
89
|
+
|
|
90
|
+
OpenCode 2.0.22 以降では `opencode update` と `opencode upgrade` がこの npm wrapper 自体を更新します。更新先は npm の `latest` です。明示した version への更新は `opencode update 2.0.22` のように指定できます。更新後の OpenCode バイナリは次回起動時に取得されます。wrapper の npm prefix を検出できない場合は更新を中止し、prefix を指定した npm コマンドを案内します。
|
|
91
|
+
|
|
92
|
+
TUI 内の `/update`(更新ダイアログの Update)は Termux では使えません。「Installation method not found」と表示され、更新は実行されません。シェルで `opencode update` を実行してください。
|
|
93
|
+
|
|
94
|
+
利用者が自動更新環境変数を設定していない場合、通常の起動時自動更新チェックを停止します。これは OpenCode のすべての更新経路を無効にする説明ではありません。
|
|
95
|
+
|
|
96
|
+
2.0.18 / 2.0.19 を使用中の場合、`opencode update` は利用できません。次のコマンドで wrapper を更新してください:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
npm install -g @bash0816/opencode-termux@latest
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
npm 更新に成功した後、次回起動で setup に失敗した場合は、同じ prefix を指定して以前の wrapper version を再インストールしてください:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
npm install -g --prefix <prefix> @bash0816/opencode-termux@<previous-version>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`package.json` の version は対応する upstream `@opencode/cli-linux-arm64` の version です。
|
|
109
|
+
|
|
110
|
+
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.
|
|
111
|
+
|
|
112
|
+
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.
|
|
113
|
+
|
|
114
|
+
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.
|
|
115
|
+
|
|
116
|
+
Users on 2.0.18 / 2.0.19 cannot use `opencode update`; update the wrapper directly:
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
npm install -g @bash0816/opencode-termux@latest
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
If setup fails on the next launch after npm successfully updates the wrapper, reinstall the previous wrapper version using the same prefix:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
npm install -g --prefix <prefix> @bash0816/opencode-termux@<previous-version>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
実体配置は標準 npm 配置である必要があります。package または `lib/` の実体配置が標準配置と不整合な構成には対応していません。標準配置にある package への symlink は利用できます。
|
|
129
|
+
|
|
130
|
+
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.
|
|
131
|
+
|
|
132
|
+
The `package.json` version is the corresponding upstream `@opencode/cli-linux-arm64` version.
|
|
133
|
+
|
|
134
|
+
## Uninstall / アンインストール
|
|
135
|
+
|
|
136
|
+
`opencode uninstall` は OpenCode のデータ・設定・認証・セッション・cache・state を削除する可能性があるため実行せず、案内を表示して終了します。wrapper を削除するには次を実行し、キャッシュ `~/.opencode-termux` も削除してください。prefix を特定できない場合は、インストール時の prefix を `<prefix>` に指定してください。
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
npm uninstall -g --prefix <prefix> @bash0816/opencode-termux
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
OpenCode 自身の設定・認証・セッションデータはこの手順では削除されません。保存先は削除前に `opencode debug paths` で確認してください。
|
|
143
|
+
|
|
144
|
+
`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:
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
npm uninstall -g --prefix <prefix> @bash0816/opencode-termux
|
|
148
|
+
rm -rf ~/.opencode-termux
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Use the prefix from installation. Before removing the wrapper, check OpenCode data locations with `opencode debug paths`.
|
|
152
|
+
|
|
153
|
+
## Authentication / 認証
|
|
154
|
+
|
|
155
|
+
Before using OpenCode, log in to a provider. Requirements such as billing information,
|
|
156
|
+
credits, and API keys vary by provider; see the official
|
|
157
|
+
[Console instructions](https://opencode.ai/v2/docs/console/models/):
|
|
158
|
+
|
|
159
|
+
OpenCode を使う前に、プロバイダへログインしてください。請求情報・クレジット・APIキー等の
|
|
160
|
+
必要な手順はプロバイダごとに異なるため、公式の
|
|
161
|
+
[Console 手順](https://opencode.ai/v2/docs/console/models/)を参照してください:
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
opencode auth login opencode
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
This starts the login process. Follow the on-screen instructions to complete it.
|
|
168
|
+
Run `opencode auth list` to check saved authentication. For details, see
|
|
169
|
+
`opencode auth login --help`.
|
|
170
|
+
|
|
171
|
+
`opencode auth login opencode` でログインを開始し、画面の案内に従って完了してください。
|
|
172
|
+
保存済み認証は `opencode auth list` で確認できます。詳細は
|
|
173
|
+
`opencode auth login --help` を参照してください。
|
|
174
|
+
|
|
175
|
+
To use a different provider (Anthropic, OpenAI, etc.), see
|
|
176
|
+
`opencode auth login --help` and the
|
|
177
|
+
[OpenCode provider documentation](https://opencode.ai/v2/docs/providers).
|
|
178
|
+
|
|
179
|
+
他のプロバイダ(Anthropic・OpenAI 等)を使う場合は `opencode auth login --help` と
|
|
180
|
+
[OpenCode プロバイダ ドキュメント](https://opencode.ai/v2/docs/providers) を参照してください。
|
|
181
|
+
|
|
182
|
+
## Usage / 使い方
|
|
183
|
+
|
|
184
|
+
```sh
|
|
185
|
+
opencode [command] [options]
|
|
186
|
+
opencode run "your prompt here"
|
|
187
|
+
opencode run --model opencode/<model-id> "your prompt here"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Run `opencode models` to list available models. Availability and requirements vary
|
|
191
|
+
by provider; see the official [Console instructions](https://opencode.ai/v2/docs/console/models/).
|
|
192
|
+
|
|
193
|
+
利用可能なモデル一覧は `opencode models` で確認できます。提供状況や利用条件は
|
|
194
|
+
プロバイダごとに異なるため、公式の[Console 手順](https://opencode.ai/v2/docs/console/models/)を参照してください。
|
|
195
|
+
|
|
196
|
+
For available commands, see the [OpenCode documentation](https://opencode.ai/v2/docs/cli/commands).
|
|
197
|
+
|
|
198
|
+
利用可能なコマンドは [OpenCode ドキュメント](https://opencode.ai/v2/docs/cli/commands) を参照してください。
|
|
199
|
+
|
|
200
|
+
## License / ライセンス
|
|
201
|
+
|
|
202
|
+
This package (`opencode-termux`) is licensed under [GPL-3.0-only](./LICENSE).
|
|
203
|
+
|
|
204
|
+
このパッケージ (`opencode-termux`) は [GPL-3.0-only](./LICENSE) ライセンスです。
|
|
205
|
+
|
|
206
|
+
**The GPL does not apply to the OpenCode binary itself.** The OpenCode binary
|
|
207
|
+
downloaded at runtime is released by its authors under the MIT License and is
|
|
208
|
+
subject to OpenCode's own terms.
|
|
209
|
+
|
|
210
|
+
**GPL は OpenCode バイナリ自体には適用されません。** 実行時にダウンロードされる
|
|
211
|
+
OpenCode バイナリは、その作者により MIT ライセンスで公開されており、OpenCode
|
|
212
|
+
自体の利用条件に従います。
|
|
213
|
+
|
|
214
|
+
## Disclaimer / 免責事項
|
|
215
|
+
|
|
216
|
+
Users are responsible for ensuring that their use of OpenCode complies with
|
|
217
|
+
OpenCode's [Terms of Service](https://opencode.ai/legal/terms-of-service) and
|
|
218
|
+
applicable laws.
|
|
219
|
+
|
|
220
|
+
OpenCode の利用条件・適用法令への適合性はユーザー自身が確認してください。
|
|
221
|
+
[OpenCode 利用規約](https://opencode.ai/legal/terms-of-service) を参照してください。
|
|
222
|
+
|
|
223
|
+
If a rights holder or platform operator raises a substantiated concern regarding
|
|
224
|
+
this package, we will promptly review it and may remove or disable the affected
|
|
225
|
+
functionality.
|
|
226
|
+
|
|
227
|
+
権利者またはプラットフォーム運営者から具体的な懸念が示された場合、
|
|
228
|
+
内容を確認し、必要に応じて公開停止・機能停止・修正を行います。
|
|
229
|
+
|
|
230
|
+
## Compatibility / 動作環境
|
|
231
|
+
|
|
232
|
+
- **Platform / プラットフォーム**: Android (Termux)
|
|
233
|
+
- **Architecture / アーキテクチャ**: ARM64 (aarch64)
|
|
234
|
+
- **Monitored upstream package / 監視対象パッケージ**: `@opencode/cli-linux-arm64`
|
|
235
|
+
(v2 series). Not to be confused with the separate `opencode-ai` npm package (v1 series).
|
|
236
|
+
`opencode-ai`(v1系列)という別系統のnpmパッケージとは異なりますのでご注意ください。
|
|
237
|
+
|
|
238
|
+
## Known limitations / 既知の制限
|
|
239
|
+
|
|
240
|
+
- Upstream OpenCode updates may require a compatibility update to this package.
|
|
241
|
+
上流 OpenCode のアップデートにより本パッケージの更新が必要になる場合があります。
|
|
242
|
+
- If the downloaded binary fails verification, the tool will exit safely.
|
|
243
|
+
ダウンロードしたバイナリが検証に失敗した場合、安全に終了します。
|
|
244
|
+
- This package does not currently provide an automatic cleanup command for old
|
|
245
|
+
cached installs under `~/.opencode-termux/installs/`; old versions may need to
|
|
246
|
+
be removed manually to reclaim disk space.
|
|
247
|
+
`~/.opencode-termux/installs/` 配下の古いキャッシュ済みインストールを自動削除する
|
|
248
|
+
コマンドは現時点で提供していません。ディスク容量が必要な場合は手動で削除してください
|
|
249
|
+
(他の OpenCode セッションが実行中でないことを確認の上で)。
|
|
250
|
+
|
|
251
|
+
## Rollback / ロールバック手順
|
|
252
|
+
|
|
253
|
+
**(For package maintainers / パッケージ管理者向けの手順です)**
|
|
254
|
+
|
|
255
|
+
If a critical issue is discovered after promoting a new version to `latest`, you can
|
|
256
|
+
immediately roll back to the previous version using the following command:
|
|
257
|
+
|
|
258
|
+
新バージョン昇格後に重大な問題が発見された場合、以下のコマンドで前バージョンに
|
|
259
|
+
ロールバックできます:
|
|
260
|
+
|
|
261
|
+
```sh
|
|
262
|
+
npm dist-tag add @bash0816/opencode-termux@<previous known-good version> latest
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
This moves the `latest` tag to a previous known-good version. The change applies to
|
|
266
|
+
subsequent new installations and updates.
|
|
267
|
+
|
|
268
|
+
これにより `latest` タグが指す版が変わり、以降の新規インストール・更新に反映されます。
|
package/bin/opencode-termux
CHANGED
|
@@ -4,30 +4,36 @@ const path = require('path');
|
|
|
4
4
|
const { execFileSync } = require('child_process');
|
|
5
5
|
const { setup } = require('../lib/setup');
|
|
6
6
|
const { GLIBC_LIB_DIR } = require('../lib/patcher');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const { route, withAutoUpdateEnv } = require('../lib/argv-route');
|
|
8
|
+
const { runUpdate, uninstallMessage, detectInstallPrefix } = require('../lib/self-update');
|
|
9
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
10
10
|
const pkg = require('../package.json');
|
|
11
11
|
const TARGET_VERSION = pkg.version;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
async function main(deps = {}) {
|
|
13
|
+
const args = deps.args || process.argv.slice(2), routed = route(args);
|
|
14
|
+
const setupFn = deps.setup || setup;
|
|
15
|
+
const execFn = deps.execFileSync || execFileSync;
|
|
16
|
+
const output = deps.write || (s => process.stderr.write(s));
|
|
17
|
+
const exit = deps.exit || (c => process.exit(c));
|
|
18
|
+
const fs = deps.fs || require('fs');
|
|
19
|
+
const child = deps.childProcess || require('child_process');
|
|
20
|
+
if (routed.kind === 'update') {
|
|
21
|
+
await (deps.runUpdate || runUpdate)(routed.rest, { fs, currentVersion: pkg.version,
|
|
22
|
+
spawnSync: deps.spawnSync || child.spawnSync, registryGet: deps.registryGet, packageRoot: deps.packageRoot || packageRoot, libPath: deps.libPath || path.resolve(__dirname, '..', 'lib'),
|
|
23
|
+
write: output, exit }); return;
|
|
21
24
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
execFileSync(binPath, args, { stdio: 'inherit', env });
|
|
28
|
-
} catch (e) {
|
|
29
|
-
process.exit(e.status || 1);
|
|
25
|
+
if (routed.kind === 'uninstall') {
|
|
26
|
+
let prefix = null;
|
|
27
|
+
try { prefix = detectInstallPrefix(fs, deps.packageRoot || packageRoot, deps.libPath || path.resolve(__dirname, '..', 'lib')); } catch (_) {}
|
|
28
|
+
output(uninstallMessage(prefix)); exit(1); return;
|
|
30
29
|
}
|
|
30
|
+
let target;
|
|
31
|
+
try { target = await setupFn(TARGET_VERSION); }
|
|
32
|
+
catch (e) { output(`opencode-termux: setup failed: ${e.message}\nTry running the command again, or check your network connection.\n`); exit(1); return; }
|
|
33
|
+
const binPath = path.join(target, 'bin', 'opencode');
|
|
34
|
+
const env = withAutoUpdateEnv({ ...(deps.env || process.env), LD_PRELOAD: '', LD_LIBRARY_PATH: deps.glibcLibDir || GLIBC_LIB_DIR });
|
|
35
|
+
try { execFn(binPath, args, { stdio: 'inherit', env }); }
|
|
36
|
+
catch (e) { exit(e.status || 1); }
|
|
31
37
|
}
|
|
32
|
-
|
|
33
|
-
main
|
|
38
|
+
if (require.main === module) main();
|
|
39
|
+
module.exports = { main };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.
|
|
3
|
-
"download_url": "https://registry.npmjs.org/@opencode/cli-linux-arm64/-/cli-linux-arm64-2.0.
|
|
4
|
-
"sha256_tar": "
|
|
5
|
-
"integrity": "sha512-
|
|
2
|
+
"version": "2.0.22",
|
|
3
|
+
"download_url": "https://registry.npmjs.org/@opencode/cli-linux-arm64/-/cli-linux-arm64-2.0.22.tgz",
|
|
4
|
+
"sha256_tar": "49e5466de60f65001cddd7583419f842140697daead2b4d8826be54d9056e70b",
|
|
5
|
+
"integrity": "sha512-t/yuu9Dqd/M44dFH95bphu7ikO6FATMQuVk/91QBnCMzsP8zVrXU7zAxD1wVLpYYUDqIonEmi80XETlFqx7chw==",
|
|
6
6
|
"patchelf_verified": true,
|
|
7
7
|
"source_repo": "anomalyco/opencode",
|
|
8
8
|
"upstream_package": "@opencode/cli-linux-arm64",
|
|
9
|
-
"detected_date": "2026-
|
|
9
|
+
"detected_date": "2026-10-03",
|
|
10
10
|
"status": "pending_device_verification"
|
|
11
11
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.
|
|
3
|
-
"download_url": "https://registry.npmjs.org/@opencode/cli-linux-arm64/-/cli-linux-arm64-2.0.
|
|
4
|
-
"sha256_tar": "
|
|
5
|
-
"integrity": "sha512-
|
|
2
|
+
"version": "2.0.22",
|
|
3
|
+
"download_url": "https://registry.npmjs.org/@opencode/cli-linux-arm64/-/cli-linux-arm64-2.0.22.tgz",
|
|
4
|
+
"sha256_tar": "49e5466de60f65001cddd7583419f842140697daead2b4d8826be54d9056e70b",
|
|
5
|
+
"integrity": "sha512-t/yuu9Dqd/M44dFH95bphu7ikO6FATMQuVk/91QBnCMzsP8zVrXU7zAxD1wVLpYYUDqIonEmi80XETlFqx7chw==",
|
|
6
6
|
"patchelf_verified": true,
|
|
7
7
|
"source_repo": "anomalyco/opencode",
|
|
8
8
|
"upstream_package": "@opencode/cli-linux-arm64",
|
|
9
|
-
"verified_date": "2026-
|
|
9
|
+
"verified_date": "2026-10-03",
|
|
10
10
|
"release_state": "stable",
|
|
11
|
-
"notes": "Promoted via promote-opencode-candidate.js --confirm-device-verified on 2026-
|
|
11
|
+
"notes": "Promoted via promote-opencode-candidate.js --confirm-device-verified on 2026-10-03. Patchelf interpreter static check recorded as verified. Device/functional verification confirmed by the operator invoking this script with --confirm-device-verified."
|
|
12
12
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
function withAutoUpdateEnv(env) {
|
|
3
|
+
const result = { ...env };
|
|
4
|
+
if (result.OPENCODE_DISABLE_AUTOUPDATE === undefined) result.OPENCODE_DISABLE_AUTOUPDATE = '1';
|
|
5
|
+
return result;
|
|
6
|
+
}
|
|
7
|
+
function route(argv) {
|
|
8
|
+
const first = argv[0];
|
|
9
|
+
if (first === 'update' || first === 'upgrade') return { kind: 'update', rest: argv.slice(1) };
|
|
10
|
+
if (first === 'uninstall') return { kind: 'uninstall', rest: [] };
|
|
11
|
+
return { kind: 'passthrough', rest: [] };
|
|
12
|
+
}
|
|
13
|
+
module.exports = { route, withAutoUpdateEnv };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const PACKAGE = '@bash0816/opencode-termux';
|
|
3
|
+
const REGISTRY = 'https://registry.npmjs.org';
|
|
4
|
+
const path = require('path');
|
|
5
|
+
function parseArgs(args) {
|
|
6
|
+
if (args.length === 0) return { kind: 'latest' };
|
|
7
|
+
if (args.length === 1 && (args[0] === '--help' || args[0] === '-h')) return { kind: 'help' };
|
|
8
|
+
if (args.length !== 1) return { kind: 'error', message: '余分な引数があります / Unexpected argument.' };
|
|
9
|
+
const arg = args[0];
|
|
10
|
+
if (arg.startsWith('-')) return { kind: 'error', message: 'この方式には非対応です / This option is not supported.' };
|
|
11
|
+
const version = arg.replace(/^v/, '');
|
|
12
|
+
if (!validVersion(version)) return { kind: 'error', message: 'バージョン形式が不正です / Invalid version.' };
|
|
13
|
+
return { kind: 'version', version };
|
|
14
|
+
}
|
|
15
|
+
function compare(a, b) { const x=a.split('.').map(Number), y=b.split('.').map(Number); for(let i=0;i<3;i++) if(x[i]!==y[i]) return x[i]<y[i]?-1:1; return 0; }
|
|
16
|
+
function detectPrefix(realPath) {
|
|
17
|
+
const parts = realPath.split('/').filter(Boolean), suffix = ['lib','node_modules','@bash0816','opencode-termux','lib'];
|
|
18
|
+
if (parts.length <= suffix.length || !suffix.every((v,i)=>parts[parts.length-suffix.length+i]===v)) return null;
|
|
19
|
+
return '/' + parts.slice(0,-suffix.length).join('/');
|
|
20
|
+
}
|
|
21
|
+
function detectInstallPrefix(fs = require('fs'), packageRoot = path.resolve(__dirname, '..'), libPath = __dirname) {
|
|
22
|
+
const pkg = fs.realpathSync(packageRoot);
|
|
23
|
+
const lib = fs.realpathSync(libPath);
|
|
24
|
+
const ownPackage = fs.realpathSync(path.resolve(libPath, '..'));
|
|
25
|
+
const fromPackage = detectPrefix(path.join(pkg, 'lib'));
|
|
26
|
+
const fromOwnPackage = detectPrefix(path.join(ownPackage, 'lib'));
|
|
27
|
+
const fromLib = detectPrefix(lib);
|
|
28
|
+
return fromPackage && fromPackage === fromOwnPackage && fromOwnPackage === fromLib &&
|
|
29
|
+
pkg === ownPackage && lib === path.join(pkg, 'lib') ? fromPackage : null;
|
|
30
|
+
}
|
|
31
|
+
function validVersion(v) {
|
|
32
|
+
const m = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.exec(v);
|
|
33
|
+
return !!m && m.slice(1).every(x => Number.isSafeInteger(Number(x)));
|
|
34
|
+
}
|
|
35
|
+
function registryGet(url, timeoutMs, https = require('https')) {
|
|
36
|
+
return new Promise((resolve,reject)=>{
|
|
37
|
+
let settled=false;
|
|
38
|
+
const timer=setTimeout(()=>req.destroy(new Error('request timeout')),timeoutMs);
|
|
39
|
+
const finish=(fn,value)=>{if(settled)return;settled=true;clearTimeout(timer);fn(value);};
|
|
40
|
+
const req=https.get(url,res=>{ const chunks=[]; res.on('data',c=>chunks.push(c)); res.on('error',e=>finish(reject,e)); res.on('aborted',()=>finish(reject,new Error('response aborted'))); res.on('end',()=>finish(resolve,{statusCode:res.statusCode,body:Buffer.concat(chunks).toString('utf8')})); });
|
|
41
|
+
req.on('error',e=>finish(reject,e));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async function runUpdate(args, deps) {
|
|
45
|
+
const {write=()=>{},exit=()=>{},fs,registryGet:get=registryGet,spawnSync,currentVersion}=deps;
|
|
46
|
+
const parsed=parseArgs(args);
|
|
47
|
+
if(parsed.kind==='help'){write('Usage: opencode update [version]\n');exit(0);return;}
|
|
48
|
+
if(parsed.kind==='error'){write(parsed.message+'\n');exit(2);return;}
|
|
49
|
+
let prefix=null; try{prefix=detectInstallPrefix(fs, deps.packageRoot || path.resolve(__dirname, '..'), deps.libPath || __dirname);}catch(_){}
|
|
50
|
+
if(!prefix){write('インストール先を特定できないため更新しません。`npm install -g --prefix <インストール時のprefix> @bash0816/opencode-termux@latest` を実行してください。\nCould not detect the installation prefix. Run `npm install -g --prefix <installation prefix> @bash0816/opencode-termux@latest`.\n');exit(1);return;}
|
|
51
|
+
const requested=parsed.kind==='version'?parsed.version:'latest'; let meta;
|
|
52
|
+
try{const res=await get(`${REGISTRY}/${PACKAGE.replace('/', '%2F')}/${requested}`,5000);if(res.statusCode!==200)throw Error('http');meta=JSON.parse(res.body);if(!meta||typeof meta.version!=='string'||!validVersion(meta.version))throw Error('version');if(parsed.kind==='version'&&meta.version!==parsed.version)throw Error('mismatch');}catch(_){write('npm registry から有効なバージョン情報を取得できませんでした。\nCould not retrieve valid version information from the npm registry.\n');exit(1);return;}
|
|
53
|
+
const cmp=compare(meta.version,currentVersion);
|
|
54
|
+
if(cmp===0){write(`Already on latest version: ${currentVersion}\n`);exit(0);return;}
|
|
55
|
+
if(cmp<0&&parsed.kind!=='version'){write(`現在のバージョン ${currentVersion} は ${meta.version} より新しいため、変更しません。\nCurrent version ${currentVersion} is newer than ${meta.version}; no change made.\n`);exit(0);return;}
|
|
56
|
+
const result=spawnSync('npm',['install','-g','--prefix',prefix,`${PACKAGE}@${meta.version}`],{stdio:'inherit'});
|
|
57
|
+
if(result.error||result.signal||result.status===null){write('npm install を実行できませんでした。\nCould not run npm install.\n');exit(1);return;}
|
|
58
|
+
if(result.status!==0){exit(result.status);return;}
|
|
59
|
+
write('次回起動時に新しい OpenCode を取得します。\nThe new OpenCode binary will be fetched on the next launch.\n');exit(0);
|
|
60
|
+
}
|
|
61
|
+
function uninstallMessage(prefix) {
|
|
62
|
+
const quote = value => "'" + String(value).replace(/'/g, "'\\''") + "'";
|
|
63
|
+
const install=prefix?`npm uninstall -g --prefix ${quote(prefix)} ${PACKAGE}`:`npm uninstall -g --prefix <インストール時のprefix> ${PACKAGE}`;
|
|
64
|
+
return 'このラッパー環境では opencode uninstall は対応していません。OpenCode のデータ・設定・認証・セッション・cache・state が削除される可能性があるため実行しません。\n削除するには `' + install + '` を実行し、キャッシュ `~/.opencode-termux` を削除してください。prefix を特定できない場合は <インストール時のprefix> を実際の prefix に置き換えてください。OpenCode 自身の設定・認証・セッションデータは削除されません。保存先は削除前に `opencode debug paths` で確認してください。\n\nThe wrapper does not support opencode uninstall and will not run it because it may delete OpenCode data, settings, authentication, sessions, cache, and state.\nTo remove this wrapper, run `' + install + '` and delete `~/.opencode-termux`. If the prefix is unknown, replace <インストール時のprefix> with the prefix used during installation. OpenCode settings, authentication, and session data are retained. Before removing the wrapper, check their locations with `opencode debug paths`.\n';
|
|
65
|
+
}
|
|
66
|
+
module.exports={runUpdate,parseArgs,compare,detectPrefix,detectInstallPrefix,uninstallMessage,validVersion,registryGet,PACKAGE};
|