108c29f9eb
Checks the CLI on the server's PATH (install command when missing), signs in with the harness's own login only when needed (--login forces it), keeps the OpenCode/Pi model pickers, and verifies with the server's check. Works on native and Docker installs (Docker delegates to the container setup); --host is a hidden compatibility alias. harness list shows all four harnesses' installed/signed-in/configured/default status. ./install --opencode|--pi now point to the command; ./install ends with the next-step hint.
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Docker backend of `pipelines harness setup opencode|pi`.
|
|
|
|
Reconfigures one harness in the Docker installation without reinstalling or
|
|
restarting services or deleting login. Run `pipelines harness setup <name>`
|
|
instead of calling this directly.
|
|
"""
|
|
import importlib.util
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def module(name, file):
|
|
spec = importlib.util.spec_from_file_location(name, Path(__file__).with_name(file))
|
|
result = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(result)
|
|
return result
|
|
|
|
|
|
setup_docker = module("setup_docker", "setup-docker.py")
|
|
|
|
|
|
def main():
|
|
root = Path(__file__).resolve().parents[1]
|
|
if len(sys.argv) < 2 or sys.argv[1] not in ("opencode", "pi"):
|
|
sys.exit("Usage: pipelines harness setup opencode|pi [--login] [--model P/M] [--pipeline-model P/M] [--default]")
|
|
name = sys.argv[1]
|
|
settings = root / ".env"
|
|
docker = settings.is_file() and "PIPELINES_HOST_REPOSITORY=" in settings.read_text()
|
|
if not docker:
|
|
sys.exit("Docker installation is not configured. Run ./install first; harness setup does not fall back to a host runtime.")
|
|
installer = setup_docker.Setup(root)
|
|
installer.reconfigure_harness(name, sys.argv[2:])
|
|
installer.link_host(name)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
main()
|
|
except KeyboardInterrupt:
|
|
sys.exit(130)
|
|
except (ValueError, KeyError, OSError, subprocess.CalledProcessError) as error:
|
|
sys.exit(f"Harness setup incomplete; existing credentials retained: {error}")
|