agent-Specialization/start.sh
JOJO 582f292114 feat(release): 新增开箱启动脚本 setup.sh / start.sh(P4 第一步)
为 release 开箱即用提供入口,把首启向导串进启动流程。Python/Node 均
依赖系统已装运行时(不内置解释器),便携包只带源码 + venv 创建逻辑。

- _bootstrap.sh: 共享引导逻辑(被 source)
  - ensure_python_env: 系统 python 建/复用 .venv,装 requirements.lock.txt
  - ensure_node_env: 系统 node 装 easyagent 依赖 + 前端构建(缺失才装)
  - has_env_file: 首启判断
- setup.sh: 初始化入口 → 备好环境 → 跑 python -m scripts.setup 向导
- start.sh: 启动入口 → 备好环境 → 无 .env 自动跑向导 → python -m server.app
  (透传参数给 server.app,如 --thinking-mode)
- CLAUDE.md: Build & Run 增加开箱方式(./setup.sh / ./start.sh)与
  requirements.lock 说明

验证:bash -n 语法通过;_bootstrap 函数逻辑(ROOT 定位 / 选系统 python /
has_env_file / node_modules 已存在时跳过)实测正确;setup 向导在系统
Python 3.9 下端到端跑通(含写文件),确认 from __future__ annotations
使新式类型注解在 3.9 兼容。

注:实际「建 venv + 联网装依赖 + 解压验证」需在本机网络环境执行;
沙箱内仅做了不联网的逻辑校验。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 17:19:45 +08:00

43 lines
1.3 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.

#!/usr/bin/env bash
# 启动入口:准备运行环境(按需),首次运行自动跑配置向导,然后启动 Web 服务。
#
# 做的事:
# 1. 确保 Python venv 与依赖就绪(缺失才安装)
# 2. 确保 Node 依赖就绪(缺失才安装)
# 3. 若没有 .env首次启动自动运行配置向导
# 4. 启动 python -m server.app
#
# 端口/监听地址/模式等由 .env 决定(见 config/server.py、config/paths.py
# 透传的命令行参数会传给 server.app如 --port / --path / --thinking-mode
#
# 用法:
# ./start.sh # 正常启动(首次会自动初始化)
# ./start.sh --thinking-mode # 透传参数给 server.app
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=_bootstrap.sh
source "$ROOT/_bootstrap.sh"
# 1+2) 环境就绪(已存在则很快跳过)
ensure_python_env
ensure_node_env
# 3) 首次启动:没有 .env 则先跑向导
if ! has_env_file; then
echo ""
echo "[start] 未检测到 .env进入首次初始化向导..."
"$VENV_PY" -m scripts.setup
if ! has_env_file; then
echo "[start] 初始化未完成(未生成 .env已退出。" >&2
exit 1
fi
fi
# 4) 启动服务
echo ""
echo "[start] 启动 Web 服务..."
cd "$ROOT"
exec "$VENV_PY" -m server.app "$@"