[Bug] `ocx opencode` injects nothing when an opencode v2 background service is already running

オープン
#9,045 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript
領域
cli

調査の方向性

Start in src/cli/opencode.ts at buildOpencodeEnv and the spawn(inv.file, inv.args, { env }) call around lines 696-704, then reproduce with the isolated XDG home in the report by starting an opencode background service before running ocx opencode debug config. Read how the launcher detects or connects to an existing service, and compare the --standalone and cold-autostart paths that already work. Done means a warm service either receives the generated provider.opencodex / providers.opencodex blocks or the launcher stops printing the success line and fails loudly; the fix approach still needs a maintainer decision.

索引モデルが issue の本文から書いたものです。

説明

bug cli
Client or integration

Other

Area

CLI

Summary

ocx opencode reports that it wired the proxy and injected its provider blocks, but when an
opencode v2 background service is already running, the launched instance never sees those
blocks. The launcher's only output is a success line, so the failure is silent: the models it
just advertised are absent from the running opencode.

--standalone, and a cold start where no service exists yet, both work.

Reproduction

Isolated home so the test cannot touch a real config; opencode v2.3.2:

export XDG_STATE_HOME=/tmp/ocx-bug1/state XDG_DATA_HOME=/tmp/ocx-bug1/data \
       XDG_CONFIG_HOME=/tmp/ocx-bug1/config XDG_CACHE_HOME=/tmp/ocx-bug1/cache
mkdir -p "$XDG_STATE_HOME" "$XDG_DATA_HOME" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"

# 1. Start the background service the way an earlier plain `opencode` run would.
opencode service set port 51177
opencode service start            # -> http://127.0.0.1:51177

# 2. Launch through the launcher against that warm service.
ocx opencode debug config > c.json
# stderr: "✅ opencode wired to http://127.0.0.1:10100/v1 — 3 model(s) under provider `opencodex`."

# 3. Look for the injected blocks in what the instance actually loaded.
python3 -c '
import json; d=json.load(open("c.json")); out=[]
for s in d:
    info=s.get("info") or {}
    for blk in ("provider","providers"):
        b=(info.get(blk) or {}).get("opencodex")
        if b: out.append((blk,len(b.get("models") or {})))
print("opencodex blocks visible:", out or "NONE")'
# -> opencodex blocks visible: NONE

Controls, same isolated home:

Scenario opencodex blocks loaded
Warm background service, then ocx opencode NONE
ocx opencode debug config --standalone providers, 3 models
Service stopped, then ocx opencode (cold autostart) providers, 3 models
Expected behavior

The launched opencode should load the generated provider.opencodex / providers.opencodex
blocks in every case, or the launcher should refuse to claim success when it cannot deliver them.

Observed behavior

With a warm service the blocks are dropped entirely, and the launcher still prints the success
line, so the user only finds out when the models are missing from the picker.

Likely cause

src/cli/opencode.ts builds the env and spawns opencode with it
(buildOpencodeEnv -> spawn(inv.file, inv.args, { env }), around line 696-704). That env reaches
the client process only. When an opencode v2 background service is already listening, the
client connects to that daemon and the daemon serves config it loaded when it started — before
any OPENCODE_CONFIG_CONTENT existed in its environment. opencode's own help describes
--standalone as "Run with a private server instead of the background service", which matches
the observed split.

What I ruled out

A restart-with-the-runtime-layer fix does not work, so it is not on the table. I started the
service with OPENCODE_CONFIG_CONTENT already set in its own environment, and the daemon still
loaded no opencodex blocks — the variable is not present in the daemon process at all. A
background service therefore cannot be told about the proxy by injection under any restarted
state, which leaves only genuinely different approaches.

Still open, and a maintainer's call: run a private server (--standalone) whenever a service is
warm, which guarantees the injected layer applies but gives up the shared session the service
provides; or make the launcher fail loudly instead of printing the success line when the blocks
cannot be applied; or write a static block through the managed integration path. Each has a real
cost, so this is a report rather than a proposal.

Workaround

A static exported block on disk is read by the service and does work:

ocx export --client opencode   # merge the two blocks into ~/.config/opencode/opencode.json

The catch is that export is a snapshot: it does not follow catalog or visibility changes.

Version

opencodex 2.100.8 (npm install). Also reproduced from a local dev checkout at 9e0e298e
(the current dev tip, package.json version 2.100.0, run as bun bin/ocx.mjs).

Operating system

macOS 27.2.0 (Darwin), Bun 1.4.4, opencode v2.3.2

Logs or error output
$ ocx opencode debug config
✅ opencode wired to http://127.0.0.1:10100/v1 — 3 model(s) under provider `opencodex`.
   Your existing opencode config files are left untouched; only the runtime provider blocks are injected.
RESULT opencodex blocks visible to the warm daemon: NONE
Checks
  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.
主要言語
TypeScript
スター
16.9k
フォーク
1.3k
平均マージ
1日 4時間
マージ済み PR(30日)
814

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lidge-jun/opencodex のほかの issue

lidge-jun/opencodex の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。