Repository navigation
fix(agent-health): opencode-v2 の probe を利用者のモデル選択で起動する - #3434
Merged
Merged
Conversation
opencode-v2 の行に seedFiles を足し、利用者の `$XDG_STATE_HOME/opencode/model.json` だけを一時の XDG_STATE_HOME へ読み取り専用で複製する(#3021 の v1 と同じ形)。 v1 と v2 で同じ値を持つため、両行とも `opencodeModelSeed()` を参照する(v1 の出力は不変)。 ## v2 の保存先を確かめた根拠(読み取りのみ) - opencode2 2.0.18(/opt/homebrew/lib/node_modules/@opencode/cli/bin/opencode.exe)の 埋め込みソースを strings で読んだ: - TUI のモデル状態: `V=DB($A.join(l.state,"model.json"))`、`l=so()`(TuiPathsProvider)。 起動時のモデルは --model → 設定の model → `recent` の先頭から使えるもの → モデル一覧の先頭、の順。 model.json が無いと一覧の先頭(2026-10-08 は Mistral Large 4 / Ollama Cloud)に落ちる。 - TUI の保存領域は `iY(so().state, channel)` で `<state>/<channel>/tui/`。 - 汎用パス: `state: path.join(XDG_STATE_HOME || ~/.local/state, "opencode")`。 - service.json も `$XDG_STATE_HOME/opencode/service.json`(複製しない)。 - 実ファイル: ~/.local/state/opencode/ に v2 由来の `latest/tui/tabs.json`(10/5 10:34)・ `beta/tui/` があり、so().state = ~/.local/state/opencode と一致。model.json は同じ dir に 1 つだけ(10/5 10:42 更新、キー recent/favorite/variant、recent[0] = github-copilot/claude-sonnet-5.5)。 v2 専用の別の model.json は無い。 - よって v2 の保存先は v1 と同じ `$XDG_STATE_HOME/opencode/model.json`。 - 資格情報(auth.json)は `$XDG_DATA_HOME/opencode`(~/.local/share/opencode)にあり、probe は XDG_DATA_HOME を差し替えないため、複製は不要。写すのは model.json だけ。 ## 対になる場所 - tool-table.ts の v1 行の seedFiles: 同じ値の写し。共通関数へまとめた(出力は同一、#3021 のテストは無変更で通る)。 - probe-tool.ts の seedStateFiles / buildProbeLaunchCommand: spec を読むだけで v2 も通る。変更なし。 - tests/unit/scripts/agent-health/probe-opencode-v2.test.ts: launchEnv のみを固定。seedFiles が無いことを 固定したテストは無い(seedFiles/seedStateFiles を grep、3021 以外に無し)。変更なし。 - docs/user-guide/agent-health.md: v2 の起動の節と画面の表の opencode-v2 行を更新。en 版は無い(docs/en/user-guide に agent-health.md 無し)。 - docs/module-reference.md の scripts/agent-health/ 行の #3021 注記: 作業ルールにより編集せず断片で提出。 ## テスト - tests/unit/scripts/agent-health/opencode-v2-model-seed-3428.test.ts(os.tmpdir() 配下の private XDG_STATE_HOME): 陽性=model.json だけが写る・中身一致。陰性=prompt-history・service.json・kv.json・ latest/tui/tabs.json・locks は写らない、元のファイルが残り内容不変。元が無ければ何も写らない。 - npx vitest run(3428 / 3021 / 2953 / probe-opencode-v2)17 pass、npm run lint・npx tsc --noEmit 成功、 run-related-unit-tests --base origin/develop exit 0。 ## 起動したモデルの名前が出るか - opencode2 の画面下端に `Build · <モデル名> <プロバイダ>` が出るため、fail/skip の check の evidence (paneEvidence)と保存 frame には名前が出る。pass の check には evidence が無く、ログも `seeded <path>` だけなので、モデル名は出ない。 - 本文に無い指摘: scripts/agent-health/probe-tool.ts:642 seeded のログや pass の check に起動モデル名を 出していない。レポートの形を変えずに出すなら CM_AGENT_HEALTH_SAVE_FRAMES=all で screen-idle の frame を 残すのが既存の仕組みの範囲。常に出すにはレポートの項目追加が要り、本 Issue の範囲外。 ## 実機確認 probe は tmux(-L cm-agent-health)と opencode2 serve を起動するため、作業ルール(tmux・サーバ起動禁止) により実行していない。手順は dev-reports/issue-3428-manual-check.md(コミット外)。 ## 前後の一覧 ~/.local/state と ~/.commandmate の ls -la を前後で比較: エントリの増減なし。差分は $HOME 自身と ~/.local/state/commandagent の mtime のみ(本作業は触れておらず、別プロセスによる更新)。 ~/.local/state/opencode/model.json は 10/5 10:42・722 bytes のまま。 service.json は ~/.config/opencode/service.json のみ存在し、触れていない。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ode-v2-model-seed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
日次確認(agent-health)の opencode-v2 の probe は、空の
XDG_STATE_HOMEで起動していたため、既定のモデル(2026-10-08 は Mistral Large 4 / Ollama Cloud)を選び、Error: Unauthorizedで 3 チェックが失敗した(#3420〜#3422。PR #3425 で認可エラーを skip として報告するようにした)。変更:
scripts/agent-health/tool-table.tsの opencode-v2 の行にseedFilesを足し、利用者の$XDG_STATE_HOME/opencode/model.jsonだけを一時のXDG_STATE_HOMEへ複製する(#3021 の v1 と同じ形。v1 と v2 で同じ値なのでopencodeModelSeed()に共通化。v1 の出力は不変)。v2 の保存先を確かめた根拠(読み取りのみ):
<state>/model.json、state はXDG_STATE_HOME || ~/.local/stateの下のopencode~/.local/state/opencode/に v2 由来のlatest/tui/があり、model.jsonは同じディレクトリに 1 つだけauth.json)は$XDG_DATA_HOME/opencodeにあり、probe はXDG_DATA_HOMEを差し替えないので複製は不要。写すのはmodel.jsonだけで、入力履歴・service.json・ロックは写さないRefs #3428(develop 向けのため Closes は使わない)
範囲外(この PR では扱わない)
scripts/agent-health/probe-tool.ts:642: pass したチェックの報告に、起動したモデル名が出ない(fail / skip の evidence には出る)。追跡 Issue にするかは run の完了報告で判断するTest plan
commandmatedev verify --task: work-evidence / scope / env-clean / lint / typecheck / unit-related すべて PASS(exit 0)tests/unit/scripts/agent-health/opencode-v2-model-seed-3428.test.ts(一時のXDG_STATE_HOME): 陽性=model.jsonだけが写り中身が一致/陰性=prompt-history・service.json・kv.json・tui/tabs.json・locks は写らず、元のファイルは残る/元が無ければ何も写らないnpx tsc --noEmitとtests/unit/scripts/agent-health・guards・docs が合格。既存のit/describeの削除 0 件🤖 Generated with Claude Code