launch-report: default to opencode-go/glm-5.2 + fix opencode run invocation
Report launcher now defaults backend=opencode, model=opencode-go/glm-5.2 (claude override → opus). Replaced the broken opencode 'attach + send-keys' path with the same 'opencode run -m … --share --attach --title' pattern as the upgrader (the old path passed no model and injected the prompt via keystrokes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""cc-ci recipe-report launcher — one-shot agent that runs /recipe-report after the weekly upgrade.
|
||||
|
||||
The report agent's model is configured SEPARATELY from the upgrader (so e.g. the upgrader runs on
|
||||
sonnet while the report is written by opus). Defaults: REPORT_MODEL=opus, REPORT_BACKEND=claude.
|
||||
The report agent's model is configured SEPARATELY from the upgrader (REPORT_BACKEND/REPORT_MODEL),
|
||||
but defaults to the same OpenCode Go subscription on glm-5.2. The model default tracks the backend
|
||||
(opencode→opencode-go/glm-5.2, claude→opus).
|
||||
|
||||
Usage:
|
||||
launch-report.py start [DATE] use-or-create the session; runs /recipe-report [DATE]
|
||||
@ -10,7 +11,8 @@ Usage:
|
||||
launch-report.py stop kill the session
|
||||
launch-report.py status show session state
|
||||
|
||||
Env: REPORT_MODEL (default opus), REPORT_BACKEND (default claude), REPORT_SESSION, REPORT_DIR.
|
||||
Env: REPORT_BACKEND (default opencode), REPORT_MODEL (default opencode-go/glm-5.2 | opus for claude),
|
||||
OPENCODE_SHARE (1=attach web server + public --share link), REPORT_SESSION, REPORT_DIR.
|
||||
"""
|
||||
import os, subprocess, sys, time
|
||||
from pathlib import Path
|
||||
@ -19,12 +21,14 @@ from datetime import datetime, timezone
|
||||
SESSION = os.environ.get("REPORT_SESSION", "cc-ci-report")
|
||||
WORKDIR = os.environ.get("REPORT_DIR", "/srv/cc-ci")
|
||||
LOG_DIR = os.environ.get("LOG_DIR", "/srv/cc-ci/.cc-ci-logs")
|
||||
BACKEND = os.environ.get("REPORT_BACKEND", "claude")
|
||||
MODEL = os.environ.get("REPORT_MODEL", "opus")
|
||||
BACKEND = os.environ.get("REPORT_BACKEND", "opencode")
|
||||
_DEFAULT_MODEL = "opencode-go/glm-5.2" if BACKEND == "opencode" else "opus"
|
||||
MODEL = os.environ.get("REPORT_MODEL", _DEFAULT_MODEL)
|
||||
CLAUDE_BIN = os.environ.get("CLAUDE_BIN", "claude")
|
||||
CLAUDE_FLAGS = os.environ.get("CLAUDE_FLAGS", "--dangerously-skip-permissions")
|
||||
OPENCODE_BIN = os.environ.get("OPENCODE_BIN", "/home/loops/.local/bin/opencode")
|
||||
OPENCODE_SERVER = os.environ.get("OPENCODE_SERVER", "http://127.0.0.1:4096")
|
||||
OPENCODE_SHARE = os.environ.get("OPENCODE_SHARE", "1") == "1"
|
||||
|
||||
|
||||
def log(m): print(f"[report {datetime.now(timezone.utc):%H:%M:%S}] {m}", flush=True)
|
||||
@ -70,17 +74,21 @@ def start(mode, date):
|
||||
cmd = f"{CLAUDE_BIN} --remote-control '{SESSION}' {model_flag} {CLAUDE_FLAGS} \"$(cat '{kf}')\""
|
||||
cwd = WORKDIR
|
||||
elif BACKEND == "opencode":
|
||||
# -m/--model/--attach/--title/--share are `run` SUBCOMMAND flags — must come AFTER `run`.
|
||||
cwd = "/srv/cc-ci-orch/cc-ci"
|
||||
cmd = f"set -a; . /srv/cc-ci/.testenv; set +a; NO_COLOR=1 {OPENCODE_BIN} attach {OPENCODE_SERVER} --dir {cwd}"
|
||||
share_flag = "--share" if OPENCODE_SHARE else ""
|
||||
cmd = (
|
||||
f"set -a; . /srv/cc-ci/.testenv; set +a; "
|
||||
f"{OPENCODE_BIN} run {model_flag} {share_flag} --attach '{OPENCODE_SERVER}' "
|
||||
f"--title '{SESSION}' --dir {cwd} \"$(cat '{kf}')\""
|
||||
)
|
||||
else:
|
||||
die(f"unknown REPORT_BACKEND '{BACKEND}'")
|
||||
log(f"starting {SESSION} (backend={BACKEND}, model={MODEL}, date={date or 'today'})")
|
||||
subprocess.run(["tmux", "new-session", "-d", "-s", SESSION, "-c", cwd, cmd])
|
||||
subprocess.run(["tmux", "pipe-pane", "-o", "-t", SESSION, f"cat >> '{LOG_DIR}/{SESSION}.log'"])
|
||||
if BACKEND == "opencode":
|
||||
time.sleep(12)
|
||||
subprocess.run(["tmux", "send-keys", "-t", SESSION, "-l", "--", f"Read {kf} and follow it."])
|
||||
time.sleep(0.5); subprocess.run(["tmux", "send-keys", "-t", SESSION, "C-m"])
|
||||
if BACKEND == "opencode" and OPENCODE_SHARE:
|
||||
log(f" attached to {OPENCODE_SERVER} → http://oc.commoninternet.net +public --share link")
|
||||
log(f"started. attach: tmux attach -t {SESSION}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user