feat: complete wikification of War Commander batch 1&2 and final grey dot cleanup
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
raw_path = r'E:\Wiki\2nd\00_Raw'
|
||||
target_base = r'E:\Wiki\2nd\10_Wiki\Topics\Game Design'
|
||||
|
||||
if not os.path.exists(target_base):
|
||||
os.makedirs(target_base)
|
||||
|
||||
def sanitize_filename(filename):
|
||||
# Extract English name from parentheses if exists, else clean Korean
|
||||
match = re.search(r'\((.*?)\)', filename)
|
||||
if match:
|
||||
name = match.group(1)
|
||||
else:
|
||||
name = filename.replace('.md', '')
|
||||
|
||||
# Remove special chars, replace spaces with hyphens
|
||||
name = re.sub(r'[^\w\s-]', '', name)
|
||||
name = name.strip().replace(' ', '-')
|
||||
return name + '.md'
|
||||
|
||||
files = [f for f in os.listdir(raw_path) if f.endswith('.md')]
|
||||
|
||||
for f in files:
|
||||
src_path = os.path.join(raw_path, f)
|
||||
new_filename = sanitize_filename(f)
|
||||
dest_path = os.path.join(target_base, new_filename)
|
||||
|
||||
try:
|
||||
with open(src_path, 'r', encoding='utf-8', errors='ignore') as f_obj:
|
||||
content = f_obj.read()
|
||||
|
||||
# Extract title from first line if it's a header
|
||||
title_match = re.search(r'^#\s+\[\[(.*?)\]\]', content)
|
||||
if title_match:
|
||||
display_title = title_match.group(1)
|
||||
else:
|
||||
display_title = f.replace('.md', '')
|
||||
|
||||
# Build Wikified Content
|
||||
wikified = f"""---
|
||||
id: GAME-WC-{new_filename.split('.')[0].upper()}
|
||||
category: "10_Wiki/💡 Topics/Game Design"
|
||||
confidence_score: 1.0
|
||||
tags: [war-commander, game-mechanics, tactical-analysis]
|
||||
last_reinforced: 2026-04-27
|
||||
---
|
||||
|
||||
# [[{display_title}]]
|
||||
|
||||
"""
|
||||
# Reformat sections if they follow the draft pattern
|
||||
content = content.replace('## 📌 Brief Summary', '## 📌 한 줄 통찰 (The Karpathy Summary)')
|
||||
content = content.replace('## 📖 Core Content', '## 📖 구조화된 지식 (Synthesized Content)')
|
||||
content = content.replace('## 🔗 Knowledge Connections', '## 🔗 지식 연결 (Graph)')
|
||||
|
||||
# Add the rest of the content (skipping the original title if we already added one)
|
||||
body = re.sub(r'^#\s+\[\[.*?\]\]\s*', '', content, flags=re.MULTILINE)
|
||||
|
||||
# Ensure Contradictions header exists
|
||||
if '## ⚠️ 모순 및 업데이트' not in body:
|
||||
body = body.replace('## 🔗 지식 연결', '## ⚠️ 모순 및 업데이트 (Contradictions & RL Update)\n- 신규 지식 자산화 (2026-04-27).\n- War Commander 전투 생태계 데이터 통합.\n\n## 🔗 지식 연결')
|
||||
|
||||
wikified += body
|
||||
|
||||
with open(dest_path, 'w', encoding='utf-8') as f_obj:
|
||||
f_obj.write(wikified)
|
||||
|
||||
# Delete raw file
|
||||
os.remove(src_path)
|
||||
print(f"Wikified: {f} -> {new_filename}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error processing {f}: {e}")
|
||||
@@ -0,0 +1,56 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
base_path = r'E:\Wiki\2nd\10_Wiki\Topics'
|
||||
existing_files = set()
|
||||
|
||||
# 1. Map all existing files
|
||||
for root, dirs, files in os.walk(base_path):
|
||||
for f in files:
|
||||
if f.endswith('.md'):
|
||||
existing_files.add(f[:-3].lower()) # Case-insensitive check
|
||||
|
||||
# Regex patterns
|
||||
raw_source_pattern = re.compile(r'^- Raw Source: \[\[00_Raw/.*?\]\].*$', re.MULTILINE)
|
||||
link_pattern = re.compile(r'\[\[([^\]|#]+)(?:[\]|#][^\]]*)?\]\]')
|
||||
|
||||
processed_count = 0
|
||||
link_cleanup_count = 0
|
||||
|
||||
for root, dirs, files in os.walk(base_path):
|
||||
for f in files:
|
||||
if f.endswith('.md'):
|
||||
file_path = os.path.join(root, f)
|
||||
if len(file_path) > 240: continue
|
||||
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f_obj:
|
||||
content = f_obj.read()
|
||||
|
||||
new_content = content
|
||||
|
||||
# 2. Remove Raw Source lines (pointing to deleted 00_Raw)
|
||||
new_content = raw_source_pattern.sub('', new_content)
|
||||
|
||||
# 3. Clean up other broken links
|
||||
def link_replacer(match):
|
||||
global link_cleanup_count
|
||||
target = match.group(1).strip()
|
||||
# Check if target exists (handles paths by taking basename if needed, but simple name check first)
|
||||
target_name = os.path.basename(target).lower()
|
||||
if target_name not in existing_files and target.lower() not in existing_files:
|
||||
link_cleanup_count += 1
|
||||
return target # Remove brackets
|
||||
return match.group(0) # Keep original
|
||||
|
||||
new_content = link_pattern.sub(link_replacer, new_content)
|
||||
|
||||
if new_content != content:
|
||||
with open(file_path, 'w', encoding='utf-8') as f_obj:
|
||||
f_obj.write(new_content)
|
||||
processed_count += 1
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
print(f"Processed {processed_count} files.")
|
||||
print(f"Cleaned up {link_cleanup_count} broken links (Grey Dots).")
|
||||
@@ -0,0 +1,87 @@
|
||||
import os
|
||||
|
||||
topics_path = r'E:\Wiki\2nd\10_Wiki\Topics'
|
||||
|
||||
def get_files_with_prefix(prefix):
|
||||
matches = []
|
||||
for root, dirs, files in os.walk(topics_path):
|
||||
for f in files:
|
||||
if f.lower().startswith(prefix.lower()) and f.endswith('.md'):
|
||||
# Extract name without ext and handle paths relative to Topics
|
||||
rel_path = os.path.relpath(os.path.join(root, f), topics_path).replace('\\', '/')
|
||||
matches.append(rel_path[:-3])
|
||||
return sorted(matches)
|
||||
|
||||
# 1. Skybound Orphans
|
||||
skybound_files = get_files_with_prefix('2026-04-')
|
||||
skybound_files = [f for f in skybound_files if 'skybound' in f.lower()]
|
||||
|
||||
# 2. Datacollector Orphans
|
||||
dc_files = get_files_with_prefix('2026-04-')
|
||||
dc_files = [f for f in dc_files if 'datacollector' in f.lower()]
|
||||
|
||||
# 3. War Commander (Game Design) files
|
||||
wc_files = get_files_with_prefix('') # Look for files in Game Design
|
||||
wc_files = [f for f in wc_files if 'Game Design' in f]
|
||||
|
||||
print(f"Skybound files found: {len(skybound_files)}")
|
||||
print(f"Datacollector files found: {len(dc_files)}")
|
||||
print(f"War Commander files found: {len(wc_files)}")
|
||||
|
||||
# Generating Skybound Update
|
||||
with open(os.path.join(topics_path, 'Skybound', 'Skybound-Knowledge-Hub.md'), 'r', encoding='utf-8') as f:
|
||||
hub_content = f.read()
|
||||
|
||||
if '## 🏷️ Keyword Cluster: #Project_Logs' not in hub_content:
|
||||
log_section = "\n## 🏷️ Keyword Cluster: #Project_Logs (최근 개발 로그)\n"
|
||||
for f in skybound_files:
|
||||
name = os.path.basename(f)
|
||||
log_section += f"- [[{f}|{name}]]\n"
|
||||
hub_content += log_section
|
||||
with open(os.path.join(topics_path, 'Skybound', 'Skybound-Knowledge-Hub.md'), 'w', encoding='utf-8') as f:
|
||||
f.write(hub_content)
|
||||
|
||||
# Generating Datacollector Hub
|
||||
dc_hub = f"""# 📡 Datacollector Project: Engineering Hub (MOC)
|
||||
|
||||
데이터 수집 및 자동화 프로세스를 관리하는 핵심 허브입니다.
|
||||
|
||||
---
|
||||
|
||||
## 🏷️ Keyword Cluster: #Development_Logs (개발 및 이슈 기록)
|
||||
- {"".join([f"- [[{f}]]\n" for f in dc_files])}
|
||||
|
||||
---
|
||||
**Status**: Managed by Antigravity AI
|
||||
"""
|
||||
with open(os.path.join(topics_path, 'Datacollector', 'Datacollector-Knowledge-Hub.md'), 'w', encoding='utf-8') as f:
|
||||
f.write(dc_hub)
|
||||
|
||||
# Generating War Commander Hub
|
||||
wc_hub = f"""# ⚔️ War Commander: Strategic Knowledge Hub (MOC)
|
||||
|
||||
전장 지배를 위한 핵심 전술 및 자원 관리 체계입니다.
|
||||
|
||||
---
|
||||
|
||||
## 🏷️ Keyword Cluster: #Tactical_Units (전술 부대 및 운용)
|
||||
- [[Game Design/Combined-Arms|Combined Arms (제병협동)]]
|
||||
- [[Game Design/Mixed-Platoons|Mixed Platoons (혼성 소대)]]
|
||||
- [[Game Design/Rock-Paper-Scissors-Dynamic|Rock-Paper-Scissors Dynamic (상성 체계)]]
|
||||
|
||||
## 🏷️ Keyword Cluster: #Base_Defense (기지 방어 및 건축)
|
||||
- [[Game Design/Defensive-Architecture|Defensive Architecture (방어 건축학)]]
|
||||
- [[Game Design/Defense-Buildings|Defense Buildings (방어 건물)]]
|
||||
- [[Game Design/Base-Layouts|Base Layouts (기지 배치)]]
|
||||
- [[Game Design/Anti-Air-and-Anti-Ground-Combat|Anti-Air & Anti-Ground Combat]]
|
||||
|
||||
## 🏷️ Keyword Cluster: #Resources_Progression (자원 및 성장)
|
||||
- [[Game Design/Iridium|Iridium (이리듐)]]
|
||||
- [[Game Design/Arc-2-Technology|Arc 2 Technology]]
|
||||
- [[Game Design/Evolution-of-the-War-Commander-Combat-Ecosystem|Combat Ecosystem Evolution]]
|
||||
|
||||
---
|
||||
**Last Update**: 2026-04-27
|
||||
"""
|
||||
with open(os.path.join(topics_path, 'Game Design', 'War-Commander-Strategic-Hub.md'), 'w', encoding='utf-8') as f:
|
||||
f.write(wc_hub)
|
||||
Reference in New Issue
Block a user