agent-Specialization/setup.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

29 lines
908 B
Bash
Executable File
Raw 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
# 首次初始化入口:准备运行环境,然后运行交互式配置向导。
#
# 做的事:
# 1. 创建/复用 Python 虚拟环境并安装依赖
# 2. 准备 Node 依赖easyagent / 前端,依赖系统已装 Node
# 3. 运行 python -m scripts.setup 交互式向导,写出 .env 与模型配置
#
# 用法:
# ./setup.sh # 首次初始化(已存在 .env 时向导会提示备份后重配)
# ./setup.sh --force # 跳过『已存在 .env』确认仍会备份
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=_bootstrap.sh
source "$ROOT/_bootstrap.sh"
echo "========================================"
echo " AI Agent 初始化"
echo "========================================"
ensure_python_env
ensure_node_env
echo ""
echo "[setup] 启动配置向导..."
exec "$VENV_PY" -m scripts.setup "$@"