feat: 3.2.17中途变更处理(git驱动) + 3.2.9a Worker git强制 + 3.2.5 Phase7 squash merge + Arc git初始化检测
- 新增 ChangeClassifier(爆炸半径分类:IMPLEMENTATION/INTERFACE/GLOBAL_CONSTRAINT) - 新增 ImpactPropagator(BFS影响传播:IMPACTED/BOUNDARY/SAFE差异化标记) - task_graph.py:invalidate_by_adr()差异化失效 + CascadeReport扩展字段(向后兼容) - eng_mode.py:三阶段差异化流程(分类→传播→失效→git操作→验证任务→重规划) - eng_mode.py:_git_squash_merge_and_tag() + Phase 7 集成 - do_mode.py:_ensure_all_committed() Worker git操作强制 - adr_watcher.py:内容快照 + get_content_for_classification() - events.py:ADR_CLASSIFIED/IMPACT_PROPAGATED/BOUNDARY_VERIFICATION_GENERATED - partial_replanner.py:replan_with_constraints() + generate_verification_tasks() - project_bootstrap.py:ensure_git_initialized() Arc规划前检测 - test_p1_21_phase2.py:21个新测试,95个全量测试0失败 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -5,9 +5,74 @@ V2 保持与 V1 相同的不变量:制品驱动通信、上下文隔离。
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def ensure_git_initialized(project_root: Path) -> dict:
|
||||
"""3.2.5: Arc 规划前 git 初始化检测。
|
||||
|
||||
检测项目是否为 git 仓库,至少有 1 个 commit。
|
||||
如果没有则自动初始化并创建空提交,确保 worktree 操作可行。
|
||||
"""
|
||||
git_dir = project_root / ".git"
|
||||
result = {"git": False, "commits": False, "initialized": False}
|
||||
|
||||
if git_dir.exists():
|
||||
result["git"] = True
|
||||
try:
|
||||
r = subprocess.run(
|
||||
["git", "rev-parse", "HEAD"],
|
||||
cwd=project_root, capture_output=True, text=True, timeout=10,
|
||||
)
|
||||
if r.returncode == 0:
|
||||
result["commits"] = True
|
||||
return result
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 初始化 git
|
||||
if not result["git"]:
|
||||
try:
|
||||
subprocess.run(
|
||||
["git", "init"],
|
||||
cwd=project_root, capture_output=True, timeout=10,
|
||||
)
|
||||
result["git"] = True
|
||||
except Exception as e:
|
||||
result["error"] = f"git init failed: {e}"
|
||||
return result
|
||||
|
||||
# 创建初始提交
|
||||
try:
|
||||
subprocess.run(
|
||||
["git", "config", "user.email", "airplan@local"],
|
||||
cwd=project_root, capture_output=True, timeout=5,
|
||||
)
|
||||
subprocess.run(
|
||||
["git", "config", "user.name", "AirPlan"],
|
||||
cwd=project_root, capture_output=True, timeout=5,
|
||||
)
|
||||
# 创建 .gitkeep 确保有文件可提交
|
||||
gitkeep = project_root / ".gitkeep"
|
||||
if not gitkeep.exists():
|
||||
gitkeep.touch()
|
||||
subprocess.run(
|
||||
["git", "add", ".gitkeep"],
|
||||
cwd=project_root, capture_output=True, timeout=10,
|
||||
)
|
||||
subprocess.run(
|
||||
["git", "commit", "-m", "AirPlan: initial empty commit"],
|
||||
cwd=project_root, capture_output=True, timeout=10,
|
||||
)
|
||||
result["commits"] = True
|
||||
result["initialized"] = True
|
||||
except Exception as e:
|
||||
result["error"] = f"initial commit failed: {e}"
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def ensure_project_bootstrap(project_root: Path) -> dict[str, bool]:
|
||||
"""创建 AirPlan 必需目录结构。"""
|
||||
root = project_root / "AirPlan"
|
||||
|
||||
Reference in New Issue
Block a user