Files
cmbuyer/init.sh
T

70 lines
2.9 KiB
Bash
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
# cmbuyer 标准启动与验证入口(Unix shell 版),与 init.ps1 等价,二选一。
#
# 注意:本项目的构建与验证工具链只在 Windows 侧(Go SDK、Python 环境、Android SDK)。
# 在 WSL 中运行本脚本通常会因缺少工具链而失败——这是预期行为,不是 bug。
# 正式验证请在 Windows PowerShell 运行 ./init.ps1。
# 双产品目录为 admin/(采购服务,Go)与 client/(采购工具,Python);分别以 go.mod 与
# requirements.txt 作为初始化哨兵,不能只按空目录存在判断。
#
# T-001 / T-002 / T-003 落地后补全命令,并同步:
# docs/03-tech-stack.md、docs/00-ai-start-here.md、docs/current-state.md
set -euo pipefail
cd "$(dirname "$0")"
export GOTOOLCHAIN=local
pending=()
echo "==> 当前目录: $(pwd)"
# ------------------------------------------------------- 采购服务(admin/,Go)
if [ -f admin/go.mod ]; then
echo "==> 采购服务:admin/ 同步依赖"
( cd admin && go mod download )
echo "==> 采购服务:admin/ 静态检查"
( cd admin && go vet ./... )
echo "==> 采购服务:admin/ 测试"
( cd admin && go test ./... )
else
echo "==> 采购服务:admin/go.mod 不存在,跳过。先做 T-001(初始化 admin/ Go 骨架)。"
pending+=("T-001 初始化采购服务 admin/ Go 骨架")
fi
# ---------------------------------------------------- 采购工具(client/,Python)
if [ -f client/requirements.txt ]; then
echo "==> 采购工具:client/ 同步依赖"
( cd client \
&& { [ -d .venv ] || python3 -m venv .venv; } \
&& .venv/bin/python -m pip install -q -r requirements.txt )
echo "==> 采购工具:client/ 语法检查"
( cd client && .venv/bin/python -m compileall -q src tests )
echo "==> 采购工具:client/ 测试"
( cd client && .venv/bin/python -m unittest discover -s tests -t . )
else
echo "==> 采购工具:client/requirements.txt 不存在,跳过。先做 T-002(初始化 client/ Python 骨架)。"
pending+=("T-002 初始化采购工具 client/ Python 骨架")
fi
# ------------------------------------------------------------------ 文档自检
echo "==> 校验 agent 上下文清单"
python3 scripts/validate_agent_context.py
# -------------------------------------------------------------------- 汇总
echo
if [ ${#pending[@]} -gt 0 ]; then
echo "==> 尚未初始化的部分:"
for item in "${pending[@]}"; do echo " - $item"; done
echo
echo "当前仓库只有文档。按 docs/06-tasks.md 领取上述任务后再运行本脚本。"
exit 3
fi
echo "==> 启动命令"
echo " 采购服务:cd admin && go run ./cmd/server"
echo " 采购工具:cd client && .venv/bin/python src/main.py"
echo
echo "基础验证失败时先修基线,不要在坏的起点上继续叠新功能。"
echo "真机连接与设备验收只能由人工完成,agent 不得据此把任务标为 DONE。"