@@ -259,6 +259,80 @@ B の状態を実測した。`git status --short` は無確認で実行され、
259259
260260サイズと評価コストは倍になるが、判定結果は変わらない。
261261
262+ ### なぜ Orca が ` OPENCODE_CONFIG_DIR ` を設定するのか
263+
264+ [ stablyai/orca #10328 ] ( https://github.com/stablyai/orca/pull/10328 ) が該当機能。
265+
266+ > OpenCode reports status via a JS ** plugin** dropped into ` OPENCODE_CONFIG_DIR `
267+ > (unlike Claude/Codex, which use managed ` hooks.json ` scripts).
268+
269+ Orca のサイドバーへ Idle / Working / Done を出すためだけの仕組み。Claude や
270+ Codex は ` hooks.json ` で済むが、OpenCode は plugin を置く必要があり、その
271+ 置き場所として ` OPENCODE_CONFIG_DIR ` を使っている。
272+
273+ Orca は** 既存の ` OPENCODE_CONFIG_DIR ` があれば symlink で overlay へ mirror**
274+ してから自分の plugin を足す設計で、ユーザー設定を壊さない配慮がある。
275+ 元の値は ` ORCA_OPENCODE_SOURCE_CONFIG_DIR ` に退避される。
276+
277+ ** しかし既定の ` ~/.config/opencode ` は mirror の対象外。** mirror するのは
278+ 「ユーザーが既に指定していた config dir」だけなので、` OPENCODE_CONFIG_DIR ` を
279+ 設定していない環境では plugin だけの素の overlay が作られる。
280+
281+ さらに Orca 側のレビューには次の記述がある。
282+
283+ > OpenCode also confirmed ** ` OPENCODE_CONFIG_DIR ` is additive** :
284+ > default XDG config and the extra directory were both loaded.
285+
286+ ** 検証されたのは OpenCode 1.18.x(v1)。** v2 で挙動が変わったため、
287+ Orca の前提が崩れている。どちらも単体では正しく、組み合わせで壊れる。
288+
289+ ### overlay の plugin は v2 でロードに失敗している
290+
291+ ` ~/.local/share/opencode/log/opencode.log ` より。
292+
293+ ``` text
294+ level=WARN message="failed to load plugin"
295+ target=.../opencode-overlays/<hash>/plugins/orca-opencode-status.js
296+ cause="Plugin must export a default definition with an id and an effect or
297+ setup function. SchemaError(Missing key at ["default"]["effect"]
298+ / ["default"]["setup"])"
299+ ```
300+
301+ つまり現状は、** overlay の目的(ステータス表示)が達成できていないまま、
302+ 副作用(global config を隠す)だけが出ている** 。
303+
304+ Orca は [ #14612 ] ( https://github.com/stablyai/orca/pull/14612 ) で V2 互換に
305+ 取り組んでいるが、そちらは ` server() ` を足す内容で、2.0.10 が要求する
306+ ` effect ` / ` setup ` とは噛み合っていない(PR 本文に「1.18.18 で検証、
307+ v2 では未確認」と明記されている)。
308+
309+ ### 採用した対処
310+
311+ ` home/dot_config/shell/shellenv.sh.tmpl ` に条件付きで入れた。
312+ ` shellenv.sh ` は ` .zshenv ` から無条件に source され、** zsh のあらゆる起動で
313+ 最初に走る** ため、Orca がログインシェル経由で opencode を起動する経路に
314+ 間に合う。
315+
316+ ``` sh
317+ if [[ -n " ${OPENCODE_CONFIG_DIR:- } " && -f " ${HOME} /.config/opencode/opencode.json" ]]; then
318+ export OPENCODE_CONFIG=" ${HOME} /.config/opencode/opencode.json"
319+ fi
320+ ```
321+
322+ ` OPENCODE_CONFIG_DIR ` があるときだけ働くので、二重 merge を避けられる。
323+ Orca が将来 mirror するようになったり overlay をやめたりしても、
324+ 自然に無害化する。
325+
326+ 実環境での確認(` opencode api config.get ` ):
327+
328+ | 条件 | global config |
329+ | --- | --- |
330+ | 現状の Orca セッション | ** document 0 件** |
331+ | 条件分岐が発火した状態 | ** 218 rules を 1 回** |
332+
333+ Orca 側には ` agentStatusHooksEnabled ` を ` false ` にして overlay をやめる
334+ 経路もあるが、内部の ` PtySpawnConfig ` の値で、UI から切れるかは** 未確認** 。
335+
262336## 8. 配備先の想定は正しい
263337
264338実環境の ` ~/.config/opencode/ ` には OpenCode 自身が作った ` service.json ` が
0 commit comments