@hatanakahiroki/code-x-cli
v0.1.30
Published
Mac helper installer for Remote Code X.
Downloads
2,220
Maintainers
Readme
Code X CLI
Fresh Mac setup:
Paste the setup command shown in the iPhone app into Terminal. It starts with macOS built-in bash/curl, installs Node.js into ~/.codex-remote/node only when missing, installs Codex CLI and Code X into ~/.codex-remote/npm-global, then opens the QR.
/bin/bash -lc 'set -e; export RCX_CLOUD_RELAY_URL="https://remote-code-x-relay-hh.fly.dev"; RCX_HOME="$HOME/.codex-remote"; NODE_HOME="$RCX_HOME/node"; NPM_PREFIX="$RCX_HOME/npm-global"; mkdir -p "$RCX_HOME" "$NPM_PREFIX"; RCX_PATH_LINE="export PATH=\"\$HOME/.codex-remote/npm-global/bin:\$HOME/.codex-remote/node/bin:\$PATH\""; for f in "$HOME/.zprofile" "$HOME/.zshrc"; do touch "$f"; if ! grep -Fq ".codex-remote/npm-global/bin" "$f"; then printf "\n# Remote Code X\n%s\n" "$RCX_PATH_LINE" >> "$f"; fi; done; export PATH="$NPM_PREFIX/bin:$NODE_HOME/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"; if command -v code-x >/dev/null 2>&1; then echo "Opening Code X..."; exec code-x; fi; echo "Remote Code X setup"; echo "-------------------"; if ! command -v node >/dev/null 2>&1 || ! command -v npm >/dev/null 2>&1; then arch="$(uname -m)"; case "$arch" in arm64) node_arch="arm64" ;; x86_64) node_arch="x64" ;; *) echo "Unsupported Mac CPU: $arch"; exit 1 ;; esac; node_ver="v22.20.0"; node_pkg="node-$node_ver-darwin-$node_arch"; tmp="$(mktemp -d)"; echo "Installing Node.js to $NODE_HOME..."; curl -fL "https://nodejs.org/dist/$node_ver/$node_pkg.tar.gz" -o "$tmp/node.tgz"; rm -rf "$NODE_HOME"; mkdir -p "$NODE_HOME"; tar -xzf "$tmp/node.tgz" -C "$NODE_HOME" --strip-components=1; rm -rf "$tmp"; export PATH="$NODE_HOME/bin:$PATH"; else echo "Node.js/npm already installed."; fi; npm config set prefix "$NPM_PREFIX" >/dev/null; export PATH="$NPM_PREFIX/bin:$PATH"; echo "Installing/updating Codex CLI..."; npm install -g --prefix "$NPM_PREFIX" @openai/codex@latest; echo "Installing Code X..."; npm install -g --prefix "$NPM_PREFIX" --force @hatanakahiroki/code-x-cli; hash -r 2>/dev/null || true; if ! command -v code-x >/dev/null 2>&1; then echo "Code X installed. Open a new Terminal, then run: code-x"; exit 1; fi; echo "Opening QR..."; exec code-x'This does not require Homebrew. If Homebrew already exists, that is fine, but Code X does not depend on it for first setup.
If Node.js/npm already exists, this shorter command also works:
npm install -g --force @hatanakahiroki/code-x-cli && code-xAfter setup, reopen the QR screen with:
code-xThe setup command immediately opens code-x when it is already installed. On a new Mac, Node.js, Codex CLI, and the helper are installed only when missing. If an old remote-code-x-cli command exists from a previous build, the installer avoids the system global path and installs into the Remote Code X user directory.
The installer starts the Remote Code X Mac services, connects to the stable outside-home relay, and prints one pairing QR for the iPhone app.
Normal mode keeps iPhone access ON while the Terminal window stays open. Close the Terminal window to stop access. While access is ON, Code X keeps the Mac awake so Wi-Fi and outside-home access do not stop during idle sleep. The display may still lock or turn off.
The QR can save both:
- a local same-Wi-Fi relay URL
- a stable HTTPS relay URL for outside-home access
After the first setup, code-x reopens the same setup and QR screen. If the same Terminal still says command not found, open a new Terminal window or run source ~/.zshrc.
If you intentionally want it to keep running after Terminal closes:
code-x backgroundStop iPhone access to this Mac:
code-x stopCheck whether it is running:
code-x statusCheck the installed helper version:
code-x --versionMade by HatanakaHiroki / Hiro no Piano no Heya.
