回应用户"还有哪些要 dacli 固化的" — 落地 Tier 1 全部 3 件:
[1/3] Pre-commit hook 加 doc:check (scripts/quality-gate.sh)
- 质量门从 [1/3] tsc + [2/3] vitest + [3/3] smoke → [1/4]+[2/4]+[3/4]+[4/4]
- 新 [3/4] doc:check (npx tsx scripts/check-doc-drift.ts) — 防回归
- 任何 doc drift 立即阻断 commit (呼应 audit 2026-07-24 §6 治本建议)
- DACLI_SKIP_GATE=1 紧急绕过 (与现有 tsc/vitest 一致)
- 注释同步更新 pre-commit (scripts/githooks/pre-commit)
[2/3] form create --reuse-if-exists (src/commands/form/create.ts)
- 防 BS-新131 AI agent 反复跑场景返工
- 命中已存在 enCode → 跳过创建, 返回现有 id + state (state=0/1 都支持)
- 抽 findExistingForm() 纯函数 + 6 个单元测试 (exact match, 不 fuzzy)
- 新选项: --reuse-if-exists (默认 false, 向后兼容)
[3/3] app status 加 3 项深度健康检查 (src/commands/app/status.ts)
- dbPing: GET /system/DataSource/{dbLinkId}/Actions/TestConnection (防 BS-E14)
· 404/405 视为 skip (端点可能未暴露, 不阻断)
· dbLinkId=0 视为 skip (主库, 不需测试)
- llmPing: GET /visualdev/ai/health (防 --ai 路径 LLM 挂掉)
· 404 视为 skip (端点可能未部署 health)
- menuIntegrity: /oauth/CurrentUser menuList.urlAddress 不空 (防 BS-56 SPA 404)
· 任意 fail → 退出码 1 (AI agent 应停下修复)
- 人类可读模式 + --json 模式都展示 deepChecks 数组
- 实战验证: tdd8 跑出 menuIntegrity 真问题 (4 项 menu urlAddress 空)
验证:
- typecheck 0 errors
- vitest 39 文件 / 393 tests pass (含 6 新 reuse-if-exists 测试)
- doc:check 0 drift
- 实战: dacli app status 跑出 3 项深度检查 + 1 个真 backend finding
测试未跑 (需要 live JNPF):
- form create --reuse-if-exists 端到端 (受 auto-classifier 误判限制)
39 lines
1.3 KiB
Bash
Executable File
39 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
||
# dacli pre-commit hook (P3, 2026-07-24) — 版本受控, 团队共用
|
||
#
|
||
# 激活: git config core.hooksPath scripts/githooks (或跑 scripts/install-hooks.sh)
|
||
#
|
||
# 顺序:
|
||
# 1. 真质量门 scripts/quality-gate.sh (tsc+vitest+doc:check+smoke) → FAIL 阻塞 commit
|
||
# 2. 仪式门 _gate_webapi (webapi 引用率报告) → 降级 advisory, 永不阻塞
|
||
#
|
||
# 病根修复 (audit 2026-07-23 §12.4): 之前唯一门是 _gate_webapi, 只查注释出处/引用率,
|
||
# 从不跑 tsc/vitest → 48 类型错误 + 20 失败单测能在"全绿"下合入 (假绿).
|
||
# 现在编译+单测是硬门, 出处报告只作参考.
|
||
|
||
ROOT="$(git rev-parse --show-toplevel)"
|
||
|
||
# 只在 dacli 仓库内跑 (在其他仓库提交时跳过)
|
||
if [ ! -f "$ROOT/scripts/quality-gate.sh" ]; then
|
||
exit 0
|
||
fi
|
||
|
||
# === 1. 真质量门 (阻塞) ===
|
||
sh "$ROOT/scripts/quality-gate.sh"
|
||
GATE_EXIT=$?
|
||
if [ $GATE_EXIT -ne 0 ]; then
|
||
echo ""
|
||
echo "❌ dacli 质量门 FAIL (exit=$GATE_EXIT), commit 阻塞"
|
||
echo " 修复 tsc/vitest 错误后重试, 或紧急绕过: DACLI_SKIP_GATE=1 git commit ..."
|
||
exit 1
|
||
fi
|
||
|
||
# === 2. 仪式门 _gate_webapi (advisory, 不阻塞) ===
|
||
if [ -f "$ROOT/src/commands/_gate_webapi.ts" ]; then
|
||
echo ""
|
||
echo "ℹ️ webapi 镜像引用率报告 (advisory, 不阻塞):"
|
||
npx tsx "$ROOT/src/commands/_gate_webapi.ts" 2>/dev/null || true
|
||
fi
|
||
|
||
exit 0
|