Files

71 lines
3.0 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# codex-app-server 安装检查(不装包、不写密钥、不跑模型)。
#
# 用法:
# ./install.sh
#
# 通过后怎么启动(见 README“宿主快速开始”):
# python3 host.py health # 不跑模型,只做健康检查
# python3 host.py init --repo <你的仓库路径>
# python3 -m cloud.server # 云端控制面演示,默认 127.0.0.1:8765
#
# 三条硬规则(脚本本身也遵守):
# 1. bin/codex 约 367M 不进仓库:.gitignore 已排除 bin/,安装时需
# 自行配对官方二进制(本机 VM 做法见下;Mac 上 npm 正常安装
# 自带 codex-code-mode-host 与 codex-resources/bwrap,不需要 bin/)。
# 2. 模型 key 只走环境变量:配置文件里只放 env_key 这类名字
# (例如 XCM_API_KEY 这类名字),绝不在脚本、配置、日志里写 key 的值。
# 3. 本脚本不登录任何账号、不向任何外部服务发请求、不跑模型回合。
set -euo pipefail
cd "$(dirname "$0")"
fail=0
# 1. python3 是否存在
if command -v python3 >/dev/null 2>&1; then
echo "ok: python3 $(python3 --version 2>&1)"
else
echo "missing: python3(请先安装 Python 3)" >&2
fail=1
fi
# 2. git 是否存在(dispatch / review / merge 走 git worktree)
if command -v git >/dev/null 2>&1; then
echo "ok: git $(git --version 2>&1)"
else
echo "missing: git(host.py 的 worktree 隔离与合并门需要 git)" >&2
fail=1
fi
# 3. 官方 codex 二进制是否可用(只检查存在性,不启动、不登录)
if [ -n "${CODEX_BIN:-}" ] && [ -x "$CODEX_BIN" ]; then
echo "ok: codex via CODEX_BIN=$CODEX_BIN"
elif [ -x "bin/codex" ]; then
echo "ok: codex via bin/codex(本地配对三件套,约 367M,不进仓库)"
elif command -v codex >/dev/null 2>&1; then
echo "ok: codex via PATH: $(command -v codex)"
else
echo "warn: 未找到 codex(二进制需自行配对官方安装;"
echo " 本机 VM 曾用 bin/ 配对 codex + codex-code-mode-host +"
echo " codex-resources/bwrap 三件套,Mac 上 npm 安装自带三件套)"
echo " 没有 codex 时 host.py health 会报失败,dispatch 会跑不起来,"
echo " 但本脚本不替你下载或登录。"
fi
# 4. 提醒:模型 key 只走环境变量,这里只检查名字是否被设置过方向,
# 绝不打印、绝不写入任何 key 的值。
if [ -n "${XCM_API_KEY:-}" ]; then
echo "ok: 模型 key 已通过环境变量提供(名字:XCM_API_KEY;值不在此打印)"
else
echo "note: 未检测到 XCM_API_KEY 这类环境变量名——跑模型回合"
echo " (dispatch / run-due 到期派发)前需先在你自己的 shell 里"
echo " export 相应变量;health 不跑模型,不需要 key。"
fi
if [ "$fail" -ne 0 ]; then
echo "install check FAILED:补齐上面 missing 的项后再跑。" >&2
exit 1
fi
echo "install check OK:接下来跑 python3 host.py health,再按 README 快速开始走 init → dispatch → review → merge。"