feat: TaskSelector v2 全链路展示 + 同步检查 + MCP Server + 服务器 Git 排除
- admin-web: TaskSelector 重构为按域+层全链路展示,新增同步检查功能 - admin-web: TaskConfig 动态加载 Flow/处理模式定义,DWD 表过滤内嵌域面板 - admin-web: App hydrate 完成前显示 loading,避免误跳 /login - backend: 新增 /tasks/sync-check 对比后端与 ETL 真实注册表 - backend: 新增 /tasks/flows 返回 Flow 和处理模式定义 - apps/mcp-server: 新增 MCP Server 模块(百炼 AI PostgreSQL 只读查询) - scripts/server: 新增 setup-server-git.py + server-exclude.txt - docs: 更新 LAUNCH-CHECKLIST 添加 Git 排除配置步骤 - pyproject.toml: workspace members 新增 mcp-server
This commit is contained in:
0
scripts/server/init-clean-branch.py
Normal file
0
scripts/server/init-clean-branch.py
Normal file
122
scripts/server/server-exclude.txt
Normal file
122
scripts/server/server-exclude.txt
Normal file
@@ -0,0 +1,122 @@
|
||||
# ==============================================================================
|
||||
# 服务器端 Git 排除规则
|
||||
# ==============================================================================
|
||||
# 用途:服务器上不需要的文件,避免占用磁盘空间和干扰运行环境。
|
||||
# 使用方式:运行 scripts/server/setup-server-git.py 自动配置。
|
||||
#
|
||||
# 原则:服务器只跑后端 API(+ 可选 ETL),其余全部排除。
|
||||
# 注意:此文件影响未 track 的新文件。
|
||||
# 对于已 track 但服务器不需要的文件,
|
||||
# 由 setup-server-git.py 配合 skip-worktree 处理。
|
||||
|
||||
# ===== 环境配置(服务器有自己的 .env,不用 Git 里的) =====
|
||||
.env
|
||||
.env.local
|
||||
# 模板保留,方便参考
|
||||
# !.env.template
|
||||
|
||||
# ===== ETL 导出数据(仅开发机留存) =====
|
||||
export/
|
||||
|
||||
# ===== 文档(开发参考用,服务器不需要) =====
|
||||
docs/
|
||||
# 如果需要部署文档可单独拉取,但运行时不依赖
|
||||
|
||||
# ===== H5 原型设计稿 =====
|
||||
# 已在 docs/h5_ui/ 下,被 docs/ 规则覆盖
|
||||
|
||||
# ===== 小程序源码(服务器不编译小程序) =====
|
||||
apps/miniprogram/
|
||||
|
||||
# ===== 管理后台源码(服务器只需要 dist/,不需要源码和 node_modules) =====
|
||||
apps/admin-web/src/
|
||||
apps/admin-web/node_modules/
|
||||
apps/admin-web/pnpm-lock.yaml
|
||||
|
||||
# ===== 测试(服务器不跑测试) =====
|
||||
tests/
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
pytest-cache-files-*/
|
||||
|
||||
# ===== 示例数据 =====
|
||||
samples/
|
||||
|
||||
# ===== 临时目录 =====
|
||||
tmp/
|
||||
|
||||
# ===== 运维脚本中的一次性脚本(服务器不需要开发用的 ops 脚本) =====
|
||||
scripts/ops/
|
||||
scripts/audit/
|
||||
scripts/migrate/
|
||||
|
||||
# ===== 根目录散文件(开发用,服务器不需要) =====
|
||||
*.png
|
||||
*.code-workspace
|
||||
start-admin.bat
|
||||
.kiroignore
|
||||
|
||||
# ===== Kiro 配置(服务器上不用 Kiro) =====
|
||||
.kiro/
|
||||
|
||||
# ===== infra 配置文档(参考用,服务器不需要) =====
|
||||
infra/
|
||||
|
||||
# ===== 日志文件(服务器自己产生的日志不入 Git) =====
|
||||
logs/
|
||||
*.log
|
||||
*.jsonl
|
||||
|
||||
# ===== Python 虚拟环境(服务器自己 uv sync 生成) =====
|
||||
.venv/
|
||||
venv/
|
||||
ENV/
|
||||
env/
|
||||
|
||||
# ===== Python 缓存与构建产物 =====
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.so
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
dist/
|
||||
|
||||
# ===== 测试覆盖率 =====
|
||||
.coverage
|
||||
htmlcov/
|
||||
|
||||
# ===== Node =====
|
||||
node_modules/
|
||||
|
||||
# ===== infra 敏感文件 =====
|
||||
infra/**/*.key
|
||||
infra/**/*.pem
|
||||
infra/**/*.secret
|
||||
|
||||
# ===== IDE =====
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.specstory/
|
||||
.cursorindexingignore
|
||||
|
||||
# ===== Windows 杂项 =====
|
||||
*.lnk
|
||||
.Deleted/
|
||||
137
scripts/server/setup-server-git.py
Normal file
137
scripts/server/setup-server-git.py
Normal file
@@ -0,0 +1,137 @@
|
||||
"""
|
||||
服务器 Git 环境配置脚本
|
||||
|
||||
在服务器上首次 git clone 后运行一次,完成两件事:
|
||||
1. 将 server-exclude.txt 复制到 .git/info/exclude
|
||||
2. 对已 track 但服务器不需要的文件/目录设置 skip-worktree,
|
||||
这样 git pull 不会覆盖本地删除,也不会在工作区还原这些文件。
|
||||
|
||||
用法:
|
||||
cd D:\\NeoZQYY\\test\\repo (或 prod\\repo)
|
||||
python scripts/server/setup-server-git.py
|
||||
|
||||
运行后可以安全删除 export/ 等目录释放磁盘空间。
|
||||
"""
|
||||
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
|
||||
# 需要 skip-worktree 的路径前缀(已被 track 但服务器不需要)
|
||||
SKIP_PREFIXES = [
|
||||
"export/",
|
||||
".env",
|
||||
"docs/",
|
||||
"tests/",
|
||||
"samples/",
|
||||
"infra/",
|
||||
".kiro/",
|
||||
".hypothesis/",
|
||||
"apps/miniprogram/",
|
||||
"apps/admin-web/src/",
|
||||
"apps/admin-web/pnpm-lock.yaml",
|
||||
"scripts/ops/",
|
||||
"scripts/audit/",
|
||||
"scripts/migrate/",
|
||||
# 根目录散文件(截图、workspace 文件等)
|
||||
"coach-detail-full.png",
|
||||
"customer-detail-full.png",
|
||||
"perf-records-current.png",
|
||||
"white-screen-debug.png",
|
||||
"NeoZQYY.code-workspace",
|
||||
"start-admin.bat",
|
||||
".kiroignore",
|
||||
]
|
||||
|
||||
# 完全不需要出现在服务器工作区的目录(skip-worktree 后可删除释放空间)
|
||||
DELETABLE_DIRS = [
|
||||
"export",
|
||||
"docs",
|
||||
"tests",
|
||||
"samples",
|
||||
"infra",
|
||||
".kiro",
|
||||
".hypothesis",
|
||||
"apps/miniprogram",
|
||||
"scripts/ops",
|
||||
"scripts/audit",
|
||||
"scripts/migrate",
|
||||
]
|
||||
|
||||
|
||||
def copy_exclude():
|
||||
"""复制排除规则到 .git/info/exclude"""
|
||||
src = REPO_ROOT / "scripts" / "server" / "server-exclude.txt"
|
||||
dst = REPO_ROOT / ".git" / "info" / "exclude"
|
||||
dst.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(src, dst)
|
||||
print(f" 已复制 {src.name} -> {dst}")
|
||||
|
||||
|
||||
def get_tracked_files(prefix: str) -> list[str]:
|
||||
"""获取匹配前缀的已 track 文件列表"""
|
||||
result = subprocess.run(
|
||||
["git", "ls-files", "--", prefix],
|
||||
capture_output=True, text=True, cwd=REPO_ROOT,
|
||||
)
|
||||
return [f for f in result.stdout.strip().split("\n") if f]
|
||||
|
||||
|
||||
def skip_worktree(files: list[str]):
|
||||
"""对文件列表设置 skip-worktree 标记"""
|
||||
if not files:
|
||||
return
|
||||
# git update-index 一次处理的文件数有限,分批
|
||||
batch_size = 50
|
||||
for i in range(0, len(files), batch_size):
|
||||
batch = files[i:i + batch_size]
|
||||
subprocess.run(
|
||||
["git", "update-index", "--skip-worktree"] + batch,
|
||||
cwd=REPO_ROOT,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
print("=== 服务器 Git 环境配置 ===\n")
|
||||
|
||||
# 1. 复制 exclude 规则
|
||||
print("[1/3] 配置 .git/info/exclude ...")
|
||||
copy_exclude()
|
||||
|
||||
# 2. 设置 skip-worktree
|
||||
print("\n[2/3] 设置 skip-worktree(已 track 但服务器不需要的文件)...")
|
||||
total_skipped = 0
|
||||
for prefix in SKIP_PREFIXES:
|
||||
files = get_tracked_files(prefix)
|
||||
if files:
|
||||
skip_worktree(files)
|
||||
total_skipped += len(files)
|
||||
print(f" {prefix} -> {len(files)} 个文件已标记")
|
||||
else:
|
||||
print(f" {prefix} -> 无匹配文件")
|
||||
print(f" 共标记 {total_skipped} 个文件")
|
||||
|
||||
# 3. 提示可删除的目录
|
||||
print("\n[3/3] 以下目录已标记 skip-worktree,可安全删除以释放磁盘空间:")
|
||||
for d in DELETABLE_DIRS:
|
||||
dir_path = REPO_ROOT / d
|
||||
if dir_path.exists():
|
||||
# 计算目录大小
|
||||
size = sum(f.stat().st_size for f in dir_path.rglob("*") if f.is_file())
|
||||
size_mb = size / (1024 * 1024)
|
||||
print(f" {d}/ ({size_mb:.1f} MB)")
|
||||
else:
|
||||
print(f" {d}/ (不存在,无需处理)")
|
||||
|
||||
print("\n如需删除,手动执行:")
|
||||
for d in DELETABLE_DIRS:
|
||||
print(f" rmdir /s /q {d}")
|
||||
|
||||
print("\n配置完成。后续 git pull 不会还原这些文件。")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user