"""표준 AI WIKI 플랫폼를 새 프로젝트로 복사하거나, 기존 프로젝트의 표준 부분만 갱신한다. 사용: python tools/new_project.py <대상폴더> --type 개발용 --platforms android,windows [--modules player,explorer] python tools/new_project.py <기존프로젝트폴더> --update (표준 문서·도구만 덮어씀)""" import sys, shutil, pathlib, argparse, re SRC = pathlib.Path(__file__).resolve().parent.parent STD = ["CLAUDE.md", "README.md", "tools", ".claude", "assets/icons", "wiki/00_시작", "wiki/02_개발방법", "wiki/03_모듈화/01_모듈표준.md", "wiki/03_모듈화/02_모듈화프로젝트_진행.md", "wiki/04_플랫폼", "wiki/05_코딩표준", "wiki/06_저장소_동기화", "wiki/07_제안서/01_제안서_작업절차.md", "wiki/07_제안서/02_아이콘_PPT규칙.md", "wiki/09_연결가이드", "wiki/99_템플릿"] SKIP = shutil.ignore_patterns(".git", ".ppt_state.json", "workspace*.json", "__pycache__") def copy(rel, dst): s, d = SRC / rel, dst / rel d.parent.mkdir(parents=True, exist_ok=True) if s.is_dir(): shutil.copytree(s, d, dirs_exist_ok=True, ignore=SKIP) elif s.exists(): shutil.copy2(s, d) def main(): ap = argparse.ArgumentParser() ap.add_argument("dst"); ap.add_argument("--type", default="개발용") ap.add_argument("--platforms", default="windows"); ap.add_argument("--modules", default="") ap.add_argument("--update", action="store_true") a = ap.parse_args(); dst = pathlib.Path(a.dst).resolve() if a.update: for r in STD: copy(r, dst) print("표준 갱신 완료 (PROJECT.md, 지시, 화면, raw 는 유지):", dst); return if dst.exists() and any(dst.iterdir()): sys.exit("대상 폴더가 비어 있지 않습니다. --update 를 쓰세요.") shutil.copytree(SRC, dst, dirs_exist_ok=True, ignore=SKIP) # 프로젝트 고유 내용 초기화 for d in ["wiki/01_사용자지시"]: for f in (dst / d).glob("2*.md"): f.unlink() (dst / d / "00_지시목록.md").write_text("# 사용자 지시 목록\n\n| 일시(KST) | 제목 | 상태 | 파일 |\n|---|---|---|---|\n", encoding="utf-8") p = dst / "PROJECT.md"; t = p.read_text(encoding="utf-8") plats = ", ".join(x.strip() for x in a.platforms.split(",") if x.strip()) mods = ", ".join(x.strip() for x in a.modules.split(",") if x.strip()) t = re.sub(r"^project_name:.*$", f"project_name: {dst.name}", t, flags=re.M) t = re.sub(r"^project_type:\s*\S+", f"project_type: {a.type}", t, flags=re.M) t = re.sub(r"^platforms:.*$", f"platforms: [{plats}]", t, flags=re.M) t = re.sub(r"^uses_modules:.*$", f"uses_modules: [{mods}]", t, flags=re.M) p.write_text(t, encoding="utf-8") print("새 프로젝트 생성:", dst) if __name__ == "__main__": main()