test(opencode): add adapter contract, TUI readiness, and lifecycle integration tests
This commit is contained in:
@@ -960,18 +960,18 @@ def test_grok_shell_and_scripts_integration(mam_sandbox):
|
||||
lib_path = mam_sandbox / "skills" / "lib.sh"
|
||||
lib_content = lib_path.read_text()
|
||||
assert '*-creator-grok|*-planner-grok|*-reviewer-grok) kind="grok"' in lib_content
|
||||
assert "'claude', 'agy', 'hermes', 'grok'" in lib_content
|
||||
assert "'claude', 'agy', 'hermes', 'grok', 'opencode'" in lib_content
|
||||
assert '[[ "$sess" =~ "grok" ]]' in lib_content
|
||||
|
||||
# 2. create_session.sh validation
|
||||
create_path = mam_sandbox / "skills" / "multi-agent-mux-create" / "scripts" / "create_session.sh"
|
||||
create_content = create_path.read_text()
|
||||
assert 'claude|agy|hermes|grok)' in create_content
|
||||
assert 'claude|agy|hermes|grok|opencode)' in create_content
|
||||
|
||||
# 3. stop_session.sh validation & state capture
|
||||
stop_path = mam_sandbox / "skills" / "multi-agent-mux-stop" / "scripts" / "stop_session.sh"
|
||||
stop_content = stop_path.read_text()
|
||||
assert 'claude|agy|hermes|grok)' in stop_content
|
||||
assert 'claude|agy|hermes|grok|opencode)' in stop_content
|
||||
assert "target['grok_session_id_own'] = captured" in stop_content
|
||||
|
||||
# 4. workspace_uuid OWN_KEY
|
||||
@@ -979,6 +979,71 @@ def test_grok_shell_and_scripts_integration(mam_sandbox):
|
||||
assert OWN_KEY.get('grok') == 'grok_session_id_own'
|
||||
|
||||
|
||||
def test_opencode_shell_and_scripts_integration(mam_sandbox):
|
||||
"""Verify lib.sh, create_session.sh, stop_session.sh, and workspace_uuid contain opencode."""
|
||||
import json, subprocess
|
||||
# 1. lib.sh kind mapping & binaries
|
||||
lib_path = mam_sandbox / "skills" / "lib.sh"
|
||||
lib_content = lib_path.read_text()
|
||||
assert '*-creator-opencode|*-planner-opencode|*-reviewer-opencode) kind="opencode"' in lib_content
|
||||
assert "'claude', 'agy', 'hermes', 'grok', 'opencode'" in lib_content
|
||||
|
||||
# 2. create_session.sh validation & OPENCODE_PERMISSION behavior (unset & preset)
|
||||
create_path = mam_sandbox / "skills" / "multi-agent-mux-create" / "scripts" / "create_session.sh"
|
||||
create_content = create_path.read_text()
|
||||
assert 'claude|agy|hermes|grok|opencode)' in create_content
|
||||
# Test unset path
|
||||
env_unset = {k: v for k, v in os.environ.items() if k != "OPENCODE_PERMISSION"}
|
||||
res_c_unset = subprocess.run(
|
||||
["bash", "-c", 'if [ -z "${OPENCODE_PERMISSION:-}" ]; then export OPENCODE_PERMISSION=\'{"*":"allow"}\'; fi; echo "$OPENCODE_PERMISSION"'],
|
||||
env=env_unset,
|
||||
capture_output=True, text=True, check=True
|
||||
)
|
||||
assert json.loads(res_c_unset.stdout.strip()) == {"*": "allow"}
|
||||
# Test preset path (user-supplied override preserved intact)
|
||||
res_c_preset = subprocess.run(
|
||||
["bash", "-c", 'if [ -z "${OPENCODE_PERMISSION:-}" ]; then export OPENCODE_PERMISSION=\'{"*":"allow"}\'; fi; echo "$OPENCODE_PERMISSION"'],
|
||||
env={**os.environ, "OPENCODE_PERMISSION": '{"*":"deny"}'},
|
||||
capture_output=True, text=True, check=True
|
||||
)
|
||||
assert json.loads(res_c_preset.stdout.strip()) == {"*": "deny"}
|
||||
|
||||
# 3. resume_session.sh OPENCODE_PERMISSION behavior (unset & preset)
|
||||
resume_path = mam_sandbox / "skills" / "multi-agent-mux-resume" / "scripts" / "resume_session.sh"
|
||||
resume_content = resume_path.read_text()
|
||||
assert 'export OPENCODE_PERMISSION=\'{"*":"allow"}\'' in resume_content
|
||||
# Test unset path
|
||||
res_r_unset = subprocess.run(
|
||||
["bash", "-c", 'if [ -z "${OPENCODE_PERMISSION:-}" ]; then export OPENCODE_PERMISSION=\'{"*":"allow"}\'; fi; echo "$OPENCODE_PERMISSION"'],
|
||||
env=env_unset,
|
||||
capture_output=True, text=True, check=True
|
||||
)
|
||||
assert json.loads(res_r_unset.stdout.strip()) == {"*": "allow"}
|
||||
# Test preset path (user-supplied override preserved intact)
|
||||
res_r_preset = subprocess.run(
|
||||
["bash", "-c", 'if [ -z "${OPENCODE_PERMISSION:-}" ]; then export OPENCODE_PERMISSION=\'{"*":"allow"}\'; fi; echo "$OPENCODE_PERMISSION"'],
|
||||
env={**os.environ, "OPENCODE_PERMISSION": '{"*":"deny"}'},
|
||||
capture_output=True, text=True, check=True
|
||||
)
|
||||
assert json.loads(res_r_preset.stdout.strip()) == {"*": "deny"}
|
||||
|
||||
# 4. stop_session.sh validation & state capture
|
||||
stop_path = mam_sandbox / "skills" / "multi-agent-mux-stop" / "scripts" / "stop_session.sh"
|
||||
stop_content = stop_path.read_text()
|
||||
assert 'claude|agy|hermes|grok|opencode)' in stop_content
|
||||
assert "target['opencode_session_id_own'] = captured" in stop_content
|
||||
|
||||
# 5. workspace_uuid OWN_KEY
|
||||
from lib_py.workspace_uuid import OWN_KEY
|
||||
assert OWN_KEY.get('opencode') == 'opencode_session_id_own'
|
||||
|
||||
# 6. reconcile.sh RECON_SRC imports shutil and get_adapter
|
||||
recon_path = mam_sandbox / "skills" / "multi-agent-mux-monitor" / "scripts" / "reconcile.sh"
|
||||
recon_content = recon_path.read_text()
|
||||
assert 'import os, json, glob, subprocess, time, sqlite3, re, shutil' in recon_content
|
||||
assert 'op_adapter = get_adapter(\'opencode\')' in recon_content
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user