84 lines
3.0 KiB
PowerShell
84 lines
3.0 KiB
PowerShell
#!/usr/bin/env pwsh
|
||
|
||
# cmbuyer 标准启动与验证入口(Windows PowerShell 版),与 init.sh 等价,二选一:
|
||
# - Windows 原生 PowerShell:./init.ps1
|
||
# - WSL / Git Bash:./init.sh
|
||
#
|
||
# 本项目是双端结构:web/(Go)+ desk/(Python)。脚本按目录是否存在分别处理,
|
||
# 未初始化的一端会跳过并提示对应任务,不会静默通过。
|
||
#
|
||
# T-001 / T-002 / T-003 落地后,把下面的命令补全,并同步:
|
||
# docs/03-tech-stack.md、docs/00-ai-start-here.md、docs/current-state.md
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
Set-Location -Path $PSScriptRoot
|
||
|
||
# Go 工具链固定用本机版本,避免自动下载
|
||
$env:GOTOOLCHAIN = "local"
|
||
|
||
$WebDir = Join-Path $PSScriptRoot "web"
|
||
$DeskDir = Join-Path $PSScriptRoot "desk"
|
||
$Pending = @()
|
||
|
||
Write-Host "==> 当前目录: $($PWD.Path)"
|
||
|
||
# ---------------------------------------------------------------- web 端(Go)
|
||
if (Test-Path $WebDir) {
|
||
Write-Host "==> web 端:同步依赖"
|
||
Push-Location $WebDir
|
||
try {
|
||
go mod download
|
||
Write-Host "==> web 端:静态检查"
|
||
go vet ./...
|
||
Write-Host "==> web 端:测试"
|
||
go test ./...
|
||
} finally {
|
||
Pop-Location
|
||
}
|
||
} else {
|
||
Write-Host "==> web 端:目录 web/ 不存在,跳过。先做 T-001(初始化 web 端 Go 骨架)。"
|
||
$Pending += "T-001 初始化 web 端 Go 骨架"
|
||
}
|
||
|
||
# ------------------------------------------------------------ desk 端(Python)
|
||
if (Test-Path $DeskDir) {
|
||
Write-Host "==> desk 端:同步依赖"
|
||
Push-Location $DeskDir
|
||
try {
|
||
if (-not (Test-Path ".venv")) {
|
||
python -m venv .venv
|
||
}
|
||
& ".venv\Scripts\python.exe" -m pip install -q -r requirements.txt
|
||
Write-Host "==> desk 端:语法检查"
|
||
& ".venv\Scripts\python.exe" -m compileall -q src tests
|
||
Write-Host "==> desk 端:测试"
|
||
& ".venv\Scripts\python.exe" -m unittest discover -s tests -t .
|
||
} finally {
|
||
Pop-Location
|
||
}
|
||
} else {
|
||
Write-Host "==> desk 端:目录 desk/ 不存在,跳过。先做 T-002(初始化 desk 端 Python 骨架)。"
|
||
$Pending += "T-002 初始化 desk 端 Python 骨架"
|
||
}
|
||
|
||
# ------------------------------------------------------------------ 文档自检
|
||
Write-Host "==> 校验 agent 上下文清单"
|
||
python scripts/validate_agent_context.py
|
||
|
||
# -------------------------------------------------------------------- 汇总
|
||
Write-Host ""
|
||
if ($Pending.Count -gt 0) {
|
||
Write-Host "==> 尚未初始化的部分:"
|
||
foreach ($item in $Pending) { Write-Host " - $item" }
|
||
Write-Host ""
|
||
Write-Host "当前仓库只有文档。按 docs/06-tasks.md 领取上述任务后再运行本脚本。"
|
||
exit 3
|
||
}
|
||
|
||
Write-Host "==> 启动命令"
|
||
Write-Host " web 端: cd web ; go run ./cmd/server"
|
||
Write-Host " desk 端: cd desk ; .venv\Scripts\python.exe src/main.py"
|
||
Write-Host ""
|
||
Write-Host "基础验证失败时先修基线,不要在坏的起点上继续叠新功能。"
|
||
Write-Host "真机连接与设备验收只能由人工完成,agent 不得据此把任务标为 DONE。"
|