docs: freeze GoAdmin technical baseline (#5)

This commit is contained in:
QiuSW
2026-08-12 09:31:21 +08:00
parent 6ff12e6a27
commit 7dac43436a
8 changed files with 288 additions and 6 deletions
+130
View File
@@ -3,6 +3,7 @@
from __future__ import annotations
import argparse
import json
import re
from pathlib import Path
@@ -47,6 +48,7 @@ CORE_DOCUMENT_REQUIREMENTS = {
"## 阅读入口",
"## 常用命令",
"## 环境、配置与凭据",
"## Sense/Bell GoAdmin 固定技术基线",
),
"docs/01-workflow.md": (
"## 面向初级维护者的修改边界",
@@ -75,6 +77,7 @@ CORE_DOCUMENT_REQUIREMENTS = {
),
"docs/04-local-development-and-verification.md": (
"## 环境要求",
"## Sense/Bell 固定工具链与只读参考源",
"## 第一次运行",
"## 常用调试方式",
"## 完成修改前",
@@ -140,6 +143,7 @@ REQUIRED_FILES = (
"docs/templates/task-archive.md",
*CORE_DOCUMENT_REQUIREMENTS,
"wiki-docs.json",
"goadmin-baseline.json",
"dev_scripts/wiki_docs.py",
"dev_scripts/sync_wiki_docs.py",
".gitea/issue_template/epic.md",
@@ -326,6 +330,131 @@ def check_go_admin_ui_rules(errors: list[str], root: Path = ROOT) -> None:
errors.append(f"{relative_path} 缺少 go-admin 规则:{section}")
GOADMIN_BASELINE_REQUIREMENTS = {
"runtimes": {
"go": "1.26.5",
"node": "22.22.1",
"package_manager": "pnpm",
"pnpm": "9.15.1",
},
"sources": {
"go-admin": {
"commit": "f06540883b41d03782bb6b2c4150f298f328c6b6",
"upstream_url": "https://github.com/go-admin-team/go-admin.git",
"branch": "master",
"describe": "v2.2.0-25-gf065408",
"exact_tag": None,
"local_reference_path": r"D:\github\goadmin\go-admin",
"license": "MIT",
},
"go-admin-ui": {
"commit": "67d393d713877572fab0b897296a4c1d525fc81d",
"upstream_url": "https://github.com/go-admin-team/go-admin-ui.git",
"branch": "master",
"describe": "v2.0.9-170-g67d393d",
"exact_tag": None,
"local_reference_path": r"D:\github\goadmin\go-admin-ui",
"package_version": "2.0.9",
"package_version_is_authoritative": False,
"license": "MIT",
},
"go-admin-doc": {
"commit": "424855aacf6905f3fde860c3331385cb25529a0d",
"upstream_url": "https://github.com/go-admin-team/go-admin-doc.git",
"branch": "master",
"describe": "424855a",
"exact_tag": None,
"local_reference_path": r"D:\github\goadmin\go-admin-doc",
"package_version_is_authoritative": False,
"license": "MIT",
},
},
}
def check_goadmin_baseline(errors: list[str], root: Path = ROOT) -> None:
"""检查 Sense/Bell 共用上游和工具链基线可复现且规则完整。"""
path = root / "goadmin-baseline.json"
if not path.is_file():
errors.append("缺少 GoAdmin 技术基线:goadmin-baseline.json")
return
try:
baseline = json.loads(path.read_text(encoding="utf-8"))
except (OSError, UnicodeDecodeError, json.JSONDecodeError) as exc:
errors.append(f"GoAdmin 技术基线不是有效 JSON:{exc}")
return
for group, entries in GOADMIN_BASELINE_REQUIREMENTS.items():
actual_group = baseline.get(group)
if not isinstance(actual_group, dict):
errors.append(f"GoAdmin 技术基线缺少对象:{group}")
continue
for name, expected in entries.items():
actual = actual_group.get(name)
if isinstance(expected, dict):
if not isinstance(actual, dict):
errors.append(f"GoAdmin 技术基线缺少来源:{name}")
continue
for field, value in expected.items():
if actual.get(field) != value:
errors.append(
f"GoAdmin 技术基线不匹配:{name}.{field} 应为 {value}"
)
elif actual != expected:
errors.append(
f"GoAdmin 技术基线不匹配:{group}.{name} 应为 {expected}"
)
if baseline.get("authority") != "upstream_url_and_commit":
errors.append("GoAdmin 技术基线必须以上游 URL 和 commit 为权威标识")
rules = baseline.get("rules")
required_rules = (
"local_repositories_are_read_only",
"product_code_must_not_be_developed_in_reference_repositories",
"preserve_upstream_license_and_copyright",
"upgrades_require_coordination_issue",
"sense_and_bell_release_independently",
)
if not isinstance(rules, dict):
errors.append("GoAdmin 技术基线缺少 rules")
else:
for rule in required_rules:
if rules.get(rule) is not True:
errors.append(f"GoAdmin 技术基线规则必须为 true:{rule}")
agent_requirements = {
"AGENTS.md": (
"### Sense/Bell GoAdmin 技术基线",
"`goadmin-baseline.json`",
"上游 URL 加完整 commit 是可复现标识",
"当前机器的只读参考副本",
"必须建立 Sense/Bell 协同升级工单",
"本机 Go 1.23.0 不满足要求",
),
"Sense/AGENTS.md": (
"## GoAdmin 技术基线",
"读取根 `goadmin-baseline.json`",
"不得在参考仓库原地开发",
"不得单独漂移上游或工具链版本",
),
"Bell/AGENTS.md": (
"## GoAdmin 技术基线",
"读取根 `goadmin-baseline.json`",
"不得在参考仓库原地开发",
"不得单独漂移上游或工具链版本",
),
}
for relative_path, required in agent_requirements.items():
agent_path = root / relative_path
if not agent_path.is_file():
errors.append(f"缺少 GoAdmin 基线规则文件:{relative_path}")
continue
content = agent_path.read_text(encoding="utf-8")
for section in missing_sections(content, required):
errors.append(f"{relative_path} 缺少 GoAdmin 基线规则:{section}")
def check_claude_code_entry(errors: list[str], root: Path = ROOT) -> None:
"""检查 Claude Code 入口直接复用共同 Agent 规则。"""
@@ -423,6 +552,7 @@ def main() -> int:
check_task_template(errors)
check_agent_efficiency_rules(errors)
check_go_admin_ui_rules(errors)
check_goadmin_baseline(errors)
check_claude_code_entry(errors)
check_archives(errors)