MCPcopy Create free account
hub / github.com/Claw-AI-Lab/Claw-AI-Lab / _install_opencode

Function _install_opencode

backend/agent/researchclaw/cli.py:48–70  ·  view source on GitHub ↗

Install OpenCode globally via npm. Returns True on success.

()

Source from the content-addressed store, hash-verified

46
47
48def _install_opencode() -> bool:
49 """Install OpenCode globally via npm. Returns True on success."""
50 print(" Installing opencode-ai (this may take a minute)...")
51 try:
52 r = subprocess.run(
53 ["npm", "i", "-g", "opencode-ai@latest"],
54 capture_output=True, text=True, timeout=120,
55 )
56 if r.returncode == 0:
57 print(" OpenCode installed successfully!")
58 return True
59 else:
60 print(f" Installation failed (exit {r.returncode}):")
61 if r.stderr:
62 for line in r.stderr.strip().splitlines()[:5]:
63 print(f" {line}")
64 return False
65 except subprocess.TimeoutExpired:
66 print(" Installation timed out.")
67 return False
68 except Exception as exc: # noqa: BLE001
69 print(f" Installation failed: {exc}")
70 return False
71
72
73def _prompt_opencode_install() -> bool:

Callers 1

_prompt_opencode_installFunction · 0.85

Calls 1

runMethod · 0.45

Tested by

no test coverage detected