## 一、版本功能(防新旧混用) 1. **单一版本源 + 构建注入**:根 package.json 的 version、git sha、构建时间经 esbuild `--define` 注入 agent;`system.info.build` 新增 `version/commit/built_at`(原有 `hash` 指纹不变)。 开发态用 typeof 探测(未注入也不崩)。 2. **握手携带版本**:`auth_ok` 新增可选字段 `agent_version` / `build` / `protocol`(只增不减 → 旧控制端忽略即可)。 3. **能力级兼容比对**:新增纯函数 `capabilityDiff(local, remote)` —— - `missingOnRemote`:本地有远端没有 → **远端较旧**,提示更新被控端 - `unknownLocally`:远端有本地没有 → **本控制端较旧**(不影响既有功能) 控制端不比版本号而比**能力集合**:版本号可能相同而内容不同,能力集合不会骗人。 4. **CLI 体检**:`nodeagent info` / `connect` 直接显示被控端版本与能力对齐情况, 把"调用时才炸"变成一句人话提示。 ## 二、发版自动化(GitHub 资产同步) `pnpm release <x.y.z|patch|minor|major>`:前置检查(干净/在 main/与远端同步)→ 改 7 个 package.json → 构建+打包 → 生成资产 → 提交打标签推送 → `gh release create` 上传。 - 资产:`agent.mjs`(**自更新载荷**)、`nodeagent-win-x64.zip`(人工安装包)、 `latest.json`(version/commit/能力数 + 两个资产的 url 与 sha256)、`SHA256SUMS` - `--dry-run` 无副作用演练;`--no-publish` 只到本地标签 - 能力数从 dist 动态取(避免写死漂移);刻意排除 `.github/`(缺 workflow 权限推不了) ## 三、兼容性契约文档 新增 `docs/VERSIONING.md`:semver 各位的含义、**只增不改**六条硬规则、 升级顺序建议(**先被控端**:新被控端向后兼容旧 CLI)、两条更新路径、发版流程、排查手册。 ## 验证 - 单测 147 → **149**(新增 capabilityDiff 用例:远端过旧 / 本机过旧 / 完全一致 / 真实清单自比无差异) - e2e 28 全绿;`node scripts/release.mjs 1.0.0 --dry-run` 演练通过且工作区无副作用
84 lines
2.6 KiB
Batchfile
84 lines
2.6 KiB
Batchfile
@echo off
|
|
REM ============================================================================
|
|
REM nodeagent - control menu (Windows)
|
|
REM
|
|
REM Double-click this file to manage an already-installed agent:
|
|
REM 1) status - task / process / port / config at a glance
|
|
REM 2) start - start the scheduled task
|
|
REM 3) stop - stop the scheduled task
|
|
REM 4) restart - stop then start
|
|
REM 5) logs - tail the agent's audit log
|
|
REM 6) uninstall - remove task + firewall rule (7) purge config and exit
|
|
REM
|
|
REM Usage: control.cmd [port]
|
|
REM port defaults to 8765; pass it only if the agent uses another.
|
|
REM
|
|
REM Pure ASCII on purpose - see the note in install.cmd. The heavy lifting
|
|
REM (and all Chinese output) lives in control.ps1, which carries a UTF-8 BOM
|
|
REM so Windows PowerShell 5.1 parses it correctly.
|
|
REM ============================================================================
|
|
setlocal EnableExtensions
|
|
|
|
set "HERE=%~dp0"
|
|
set "HELPER=%HERE%control.ps1"
|
|
set "PORT=%~1"
|
|
if not defined PORT set "PORT=8765"
|
|
|
|
if not exist "%HELPER%" (
|
|
echo [x] control.ps1 not found next to this file.
|
|
echo Folder: "%HERE%"
|
|
if not defined CI pause
|
|
exit /b 1
|
|
)
|
|
|
|
:MENU
|
|
cls
|
|
echo ==========================================================
|
|
echo nodeagent control console
|
|
echo ==========================================================
|
|
echo 1) Status
|
|
echo 2) Start agent
|
|
echo 3) Stop agent
|
|
echo 4) Restart agent
|
|
echo 5) Show recent audit log
|
|
echo 6) Uninstall ^(keep config^)
|
|
echo 7) Uninstall and purge config
|
|
echo Q) Quit
|
|
echo ==========================================================
|
|
echo.
|
|
|
|
set "CHOICE="
|
|
REM <nul makes `set /p` fail immediately -> CHOICE stays empty. Combined with
|
|
REM CI (see below) that exits instead of looping forever on piped/empty stdin.
|
|
set /p "CHOICE=Select: "
|
|
|
|
if not defined CHOICE (
|
|
if defined CI goto :QUIT
|
|
echo.
|
|
echo (no input - exiting)
|
|
goto :QUIT
|
|
)
|
|
|
|
if /i "%CHOICE%"=="Q" goto :QUIT
|
|
if "%CHOICE%"=="1" call :RUN status
|
|
if "%CHOICE%"=="2" call :RUN start
|
|
if "%CHOICE%"=="3" call :RUN stop
|
|
if "%CHOICE%"=="4" call :RUN restart
|
|
if "%CHOICE%"=="5" call :RUN logs
|
|
if "%CHOICE%"=="6" call :RUN uninstall
|
|
if "%CHOICE%"=="7" call :RUN uninstall-purge
|
|
goto :MENU
|
|
|
|
:QUIT
|
|
endlocal
|
|
exit /b 0
|
|
|
|
:RUN
|
|
REM %1 = subcommand forwarded to control.ps1
|
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%HELPER%" -Action %1 -Port %PORT%
|
|
echo.
|
|
if not defined CI pause
|
|
goto :MENU
|
|
REM unreachable; keeps `call :RUN` from falling through if the goto is removed
|
|
exit /b 0
|