fix(opencode): support opencode 2.x only (Issue #60, v4.9.6) #61

Merged
Godopu merged 6 commits from fix/issue-60-opencode-v2 into main 2026-10-18 10:36:17 +00:00
Owner

Refs #60 (macOS 확인분. Linux 호환성 확인은 이슈에서 계속)

opencode 1.x → 2.x 변경에 맞춰 MAM 이 opencode 2.x 만 지원하도록 바꿉니다. 사실은 macOS 에서 opencode 2.0.32 를 임시 HOME 으로 실측해 확인했습니다.

변경

  • 실행: opencode --auto --standalone (재개는 --session <id> 추가). 2.x TUI 는 --agent·-m 을 거부합니다. --standalone 은 세션마다 자기 서버를 띄우고 TUI 와 함께 끝나므로, 사용자의 공유 백그라운드 서비스에 붙지 않습니다.
  • 세션 저장소: discover·verify·status·reconcile 이 session_v2 를 읽고, 자식 세션은 대화 세션으로 고르지 않습니다.
  • DB 경로: opencode db path 대신 opencode debug paths. XDG_DATA_HOME 을 따릅니다.
  • purge: opencode session delete 로 자식 세션까지 지우고, 1.x 에서 이전된 DB 의 옛 행도 지웁니다. 실패하면 경고 + residual 보고.
  • 사용 중 판정: DB 를 늘 열어 두는 백그라운드 서비스는 보유자로 보지 않습니다.
  • 테스트·문서: 가짜 2.x CLI, 2.x 회귀 테스트, 설치된 2.x 가 있으면 임시 HOME 에서 실제 바이너리 계약 확인. 테스트 격리에 XDG_DATA_HOME 추가. 가이드 문서 2개 갱신.

검증 (macOS, Python 3.9.6)

  • 리뷰 3회차에서 4/4 PASS (1·2회차 지적은 모두 이 브랜치에서 수정). 리포트는 .agents/reports/ 에 있습니다.
  • 전체 스위트: 1949 passed, 56 skipped. 실제 opencode 데이터·설정·로그와 사용자 서비스는 바뀌지 않았습니다.

Linux 후속 확인 (별도)

  • 실제 2.x 화면 캡처로 입력 영역 fixture 갱신
  • /exit 정상 종료 확인
  • 홈 화면 안내 문구의 입력 판정
  • auth_ok (auth.json, 현재 미사용)
  • 실제 바이너리 계약 테스트 실행

🤖 Generated with Claude Code

https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff

Refs #60 (macOS 확인분. Linux 호환성 확인은 이슈에서 계속) opencode 1.x → 2.x 변경에 맞춰 MAM 이 opencode **2.x 만** 지원하도록 바꿉니다. 사실은 macOS 에서 opencode 2.0.32 를 임시 HOME 으로 실측해 확인했습니다. ## 변경 - **실행**: `opencode --auto --standalone` (재개는 `--session <id>` 추가). 2.x TUI 는 `--agent`·`-m` 을 거부합니다. `--standalone` 은 세션마다 자기 서버를 띄우고 TUI 와 함께 끝나므로, 사용자의 공유 백그라운드 서비스에 붙지 않습니다. - **세션 저장소**: discover·verify·status·reconcile 이 `session_v2` 를 읽고, 자식 세션은 대화 세션으로 고르지 않습니다. - **DB 경로**: `opencode db path` 대신 `opencode debug paths`. `XDG_DATA_HOME` 을 따릅니다. - **purge**: `opencode session delete` 로 자식 세션까지 지우고, 1.x 에서 이전된 DB 의 옛 행도 지웁니다. 실패하면 경고 + residual 보고. - **사용 중 판정**: DB 를 늘 열어 두는 백그라운드 서비스는 보유자로 보지 않습니다. - **테스트·문서**: 가짜 2.x CLI, 2.x 회귀 테스트, 설치된 2.x 가 있으면 임시 HOME 에서 실제 바이너리 계약 확인. 테스트 격리에 `XDG_DATA_HOME` 추가. 가이드 문서 2개 갱신. ## 검증 (macOS, Python 3.9.6) - 리뷰 3회차에서 4/4 PASS (1·2회차 지적은 모두 이 브랜치에서 수정). 리포트는 `.agents/reports/` 에 있습니다. - 전체 스위트: 1949 passed, 56 skipped. 실제 opencode 데이터·설정·로그와 사용자 서비스는 바뀌지 않았습니다. ## Linux 후속 확인 (별도) - 실제 2.x 화면 캡처로 입력 영역 fixture 갱신 - `/exit` 정상 종료 확인 - 홈 화면 안내 문구의 입력 판정 - `auth_ok` (`auth.json`, 현재 미사용) - 실제 바이너리 계약 테스트 실행 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
Godopu added 6 commits 2026-10-18 10:36:04 +00:00
Measured on opencode 2.0.32 (macOS):
- the TUI rejects --agent ("Unrecognized flag"), so create and resume could
  not start opencode at all; the default agent is build. MAM now spawns
  `opencode --auto --standalone` (resume adds --session <id>): the server
  runs as the TUI's child and ends with it, and the per-user background
  service is neither used nor started;
- sessions live in session_v2 (a fresh 2.x database has no `session` table;
  a migrated one keeps the 1.x tables but no longer writes them). discover,
  verify_artifact, reconcile drift C and status read session_v2, and
  discover / drift C skip child (subagent) sessions;
- `db path` is gone (it prints the help and exits 0): the db comes from
  the `db` line of `opencode debug paths`, else the default path;
- `opencode session delete` removes a session with its child sessions from
  the 2.x tables (and leaves the 1.x ones): purge runs it with --standalone
  for a session in session_v2, still deletes the 1.x message/part/session
  rows, and residual also reports a session_v2 row left by a failed delete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
tests/_fake_opencode.py implements the two commands MAM calls (debug paths,
session delete) as measured on 2.0.32; unit tests never run a real opencode
(it would migrate the test database). test_real_opencode_2x_contract runs a
real 2.x opencode, when installed, in a home and tmp dir of its own with
--standalone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
- Review 614b6263 (codex, P2): `opencode session delete` removes the child
  sessions with their parent, but their 1.x rows stayed and the parent's
  residual was empty. The child sessions (session_v2 and a 1.x session
  table, any depth) are taken before the delete; the 1.x tables (message,
  part, todo, session_share, session) are cleaned for all of them, and the
  residual also reports a child still on record (a failed delete).
- The in-use check counted any process holding the shared opencode.db; the
  per-user 2.x background service (`serve --service`) holds it for every
  session, so every opencode purge was refused while it ran (it does on
  this Mac). It no longer counts; any other holder and a command line
  naming the session still do.
- The data dir follows the caller's XDG_DATA_HOME when ctx is the caller's
  own home (else <home>/.local/share), for debug paths, the fallback and the
  residual scan (review 614b6263 / f4cedbae N4).
- resident_children = ('opencode',): the --standalone server stays the TUI's
  idle child; what runs under it still counts (review 1abe0a90).
- Tests: child sessions on a migrated database, a failed delete, the service
  holder, XDG, resident children, drift C pinning the parent over a newer
  child session (review f4cedbae N2), and the real-binary test no longer
  depends on PATH (N1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
- Review 8a485fa0 B1 / c9d06e85 / c4e96018 (blocking): the adapter now
  follows the caller's XDG_DATA_HOME for its own home, but the tests did not
  drop it: a sandbox that sets HOME resolved the runner's real data dir.
  XDG_DATA_HOME joins _agent_home_guard.DROPPED_VARS (dropped per test), and
  the session guard watches <XDG_DATA_HOME>/opencode when it is set.
  Checked with XDG_DATA_HOME set to a separate dir: the opencode modules
  pass and nothing is written there.
- status.sh asks the adapter for the db (`debug paths`, XDG-aware) instead
  of a fixed ~/.local/share/opencode (8a485fa0 N1).
- The opt-in test's `opencode --version` probe ran with the real HOME at
  import and appended to the real opencode log; it runs in a temporary home
  now (8a485fa0 N2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCgu9Fa9iT7TbJUSzdq4Ff
Godopu merged commit 1d7b7dab58 into main 2026-10-18 10:36:17 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: tmpl/multi-agent-mux#61