import os import random import uuid import datetime import shutil import re SOURCE_DIR = "/Volumes/Data/project/Antigravity/Datacollector_MAC/out_wiki" TARGET_DIR = "/Volumes/Data/project/Antigravity/Wiki/10_Wiki/Topics" MEETING_DIR = "/Volumes/Data/project/Antigravity/Wiki/10_Wiki/Topics_meeting" ARCHIVE_DIR = f"/Volumes/Data/project/Antigravity/Wiki/01_Archive/{datetime.date.today()}" def generate_id(): return f"P-REINFORCE-AUTO-{uuid.uuid4().hex[:6].upper()}" def process_file(filename): if not filename.endswith(".md"): return file_path = os.path.join(SOURCE_DIR, filename) title = filename.replace(".md", "") with open(file_path, 'r', encoding='utf-8') as f: content = f.read() # Determine Category category = "Software Engineering" if any(k in title.lower() for k in ["architecture", "pattern", "design"]): category = "Architecture" elif any(k in title.lower() for k in ["rendering", "components", "css", "hydration"]): category = "Web Development" # 1. Frontmatter id_str = generate_id() frontmatter = f"""--- id: {id_str} category: "10_Wiki/๐Ÿ’ก Topics/{category}" confidence_score: 0.95 tags: [auto-reinforced] last_reinforced: {datetime.date.today()} github_commit: "[P-Reinforce] Continuous Worker - {title}" --- """ # 2. Section Transformation new_content = content # Remove old title if exists or wrap it new_content = re.sub(r'^#\s+.*$', f"# [[{title}|{title}]]", new_content, flags=re.MULTILINE) replacements = { "## ๐Ÿ“Œ Brief Summary": "## ๐Ÿ“Œ ํ•œ ์ค„ ํ†ต์ฐฐ (The Karpathy Summary)", "## ๐Ÿ“– Core Content": "## ๐Ÿ“– ๊ตฌ์กฐํ™”๋œ ์ง€์‹ (Synthesized Content)", "## โš–๏ธ Trade-offs & Caveats": "## โš ๏ธ ๋ชจ์ˆœ ๋ฐ ์—…๋ฐ์ดํŠธ (Contradictions & RL Update)", "## ๐Ÿ”— Knowledge Connections": "## ๐Ÿ”— ์ง€์‹ ์—ฐ๊ฒฐ (Graph)" } for old, new in replacements.items(): new_content = new_content.replace(old, new) # 3. Footer footer = f""" --- *Last updated: {datetime.date.today()}* - Raw Source: 00_Raw/{datetime.date.today()}/{filename} --- """ final_output = frontmatter + new_content + footer # 4. Save to Topics target_path = os.path.join(TARGET_DIR, filename) with open(target_path, 'w', encoding='utf-8') as f: f.write(final_output) # 5. Duplicate for Meetings if "ํšŒ์˜" in title: meeting_path = os.path.join(MEETING_DIR, filename) shutil.copy2(target_path, meeting_path) print(f"[DUPLICATED] {filename} -> Topics_meeting") # 6. Archive Original os.makedirs(ARCHIVE_DIR, exist_ok=True) shutil.move(file_path, os.path.join(ARCHIVE_DIR, filename)) print(f"[REINFORCED] {filename}") if __name__ == "__main__": files = os.listdir(SOURCE_DIR) for f in files: if f.endswith(".md"): process_file(f) print("P-Reinforce Wikification Completed.")