Files
yovision/init.sh
T
QiuSW a2790c1f5e
Harness governance / validate (pull_request) Has been cancelled
feat(brain): add single-stream visual prototype (T-017)
2026-08-11 11:02:37 +08:00

53 lines
2.5 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
# 标准启动与验证入口(Unix shell 版),与 init.ps1 等价,二选一:
# - WSL / Git Bash / macOS / Linux:用本文件 ./init.sh
# - Windows 原生 PowerShell:用 ./init.ps1
# 一条命令完成:依赖安装 -> 基础验证 -> 打印启动命令。
# 复制到新项目后,必须先替换下面三个变量,让每轮会话用同一条路径启动,不靠记忆。
# 本文件不绑定任何技术栈;换技术栈时只替换这三个变量,脚本结构不用动。
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"
# Sense/Bell 使用锁定 Go toolchain/module;Brain 原型依赖只做精确版本检查,不自动污染全局 Python 环境。
INSTALL_CMD=(bash -lc "go -C Sense mod download && go -C Bell mod download")
VERIFY_CMD=(bash -lc "python3 scripts/validate_agent_context.py && python3 -m unittest discover -s tests -p 'test_*.py' && python3 scripts/validate_harness_governance.py && python3 -c 'from importlib.metadata import version; assert version(\"numpy\") == \"1.26.4\"; assert version(\"opencv-python\") == \"4.9.0.80\"' && python3 -m unittest discover -s Brain/tests -p 'test_*.py' -v && python3 -m compileall -q Brain && go -C Sense generate ./internal/mtx ./internal/controlapi && git diff --exit-code -- Sense/internal/mtx/generated/client.gen.go Sense/internal/controlapi/generated.gen.go && go -C Sense test ./... && go -C Sense vet ./... && go -C Sense build ./... && go -C Bell test ./... && go -C Bell vet ./... && go -C Bell build ./...")
START_CMD=(go -C Sense run ./cmd/sense-api)
ensure_configured() {
local name="$1"
local first="$2"
if [[ "$first" == __REPLACE_* ]]; then
echo "ERROR: 请先在 init.sh 中替换 ${name}。"
echo " 同步更新 docs/03-tech-stack.md、docs/00-ai-start-here.md 和 docs/current-state.md 中的命令。"
exit 2
fi
}
ensure_configured "INSTALL_CMD" "${INSTALL_CMD[0]}"
ensure_configured "VERIFY_CMD" "${VERIFY_CMD[0]}"
ensure_configured "START_CMD" "${START_CMD[0]}"
echo "==> 当前目录: $PWD"
echo "==> 同步依赖"
"${INSTALL_CMD[@]}"
echo "==> 运行基础验证"
"${VERIFY_CMD[@]}"
echo "==> 启动命令"
printf ' %q' "${START_CMD[@]}"
printf '\n'
if [ "${RUN_START_COMMAND:-0}" = "1" ]; then
echo "==> 启动应用"
exec "${START_CMD[@]}"
fi
echo "如果希望 init.sh 直接启动应用,请设置 RUN_START_COMMAND=1。"
echo "如果基础验证失败,先修复基线状态,不要在坏的起点上继续叠新功能。"