Phase P~S 전체 작업물: 검증 스크립트, 블록 템플릿, 설계 문서, 코드 수정

포함 내용:
- Phase P/Q/R/S 설계 문서 (IMPROVEMENT-PHASE-*.md)
- 영역별 검증 스크립트 (scripts/verify_*.py, test_*.py)
- 블록 템플릿 추가 (cards, emphasis 변형)
- 코드 수정: block_search, content_editor, design_director, slide_measurer
- catalog.yaml 블록 목록 업데이트
- CLAUDE.md, PROGRESS.md, README.md 업데이트

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-31 08:38:06 +09:00
parent 0e4b8c091c
commit 29f56187c0
44 changed files with 9431 additions and 313 deletions

View File

@@ -217,6 +217,76 @@ def format_measurement_for_kei(
return "\n".join(lines)
def measure_candidate_block(html: str) -> dict[str, Any]:
"""Phase P: 단일 후보 블록을 렌더링하여 높이 측정 + 스크린샷 캡처.
Args:
html: render_block_in_container()로 생성된 완전한 HTML
Returns:
{
"scrollHeight": 실제 콘텐츠 높이,
"containerHeight": 컨테이너 높이,
"overflowed": 넘침 여부,
"excess_px": 초과 px,
"screenshot_b64": base64 PNG 문자열
}
"""
options = Options()
options.add_argument("--headless=new")
options.add_argument("--disable-gpu")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--force-device-scale-factor=1")
options.add_argument("--window-size=1400,900")
driver = None
try:
driver = webdriver.Chrome(options=options)
import urllib.parse
encoded = urllib.parse.quote(html)
driver.get(f"data:text/html;charset=utf-8,{encoded}")
try:
driver.execute_script("return document.fonts.ready")
except Exception:
pass
result = driver.execute_script("""
var container = document.querySelector('.candidate-container');
if (!container) return {error: 'container not found'};
return {
scrollHeight: container.scrollHeight,
containerHeight: parseInt(container.style.height) || container.clientHeight,
overflowed: container.scrollHeight > container.clientHeight + 2,
excess_px: Math.max(0, container.scrollHeight - container.clientHeight)
};
""")
if not result or "error" in result:
return {"scrollHeight": 0, "containerHeight": 0, "overflowed": False, "excess_px": 0, "screenshot_b64": None}
# 스크린샷 캡처
from selenium.webdriver.common.by import By
container = driver.find_element(By.CSS_SELECTOR, ".candidate-container")
screenshot_b64 = container.screenshot_as_base64
result["screenshot_b64"] = screenshot_b64
return result
except Exception as e:
logger.warning(f"[Phase P] 후보 블록 측정 실패: {e}")
return {"scrollHeight": 0, "containerHeight": 0, "overflowed": False, "excess_px": 0, "screenshot_b64": None}
finally:
if driver:
try:
driver.quit()
except Exception:
pass
def capture_slide_screenshot(html: str) -> str | None:
"""Phase N-4: 렌더링된 슬라이드의 스크린샷을 base64 PNG로 캡처한다.