Initial commit: Kei Design Agent

콘텐츠를 시각적으로 구조화된 슬라이드 HTML로 변환하는 독립 에이전트.

아키텍처 (4단계 파이프라인):
  1. Kei 실장 (Opus) — 콘텐츠 유형 분류 + 블록 배치
  2. 디자인 팀장 (Sonnet) — 레이아웃 컨셉 (블록 배치 + 페이지 수)
  3. 텍스트 편집자 (Sonnet) — 슬롯 텍스트 정리 (핵심 유지)
  4. CSS Grid 렌더러 — HTML 조립

블록 템플릿 7종:
  comparison, card-grid, relationship, process,
  quote-block, conclusion-bar, comparison-table

기술 스택:
  FastAPI + Anthropic API + Jinja2 + CSS Grid
  Pretendard Variable 한국어 폰트

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 17:25:47 +09:00
commit c42e65fc7e
28 changed files with 3302 additions and 0 deletions

69
static/base.css Normal file
View File

@@ -0,0 +1,69 @@
/* Design Agent — 기본 슬라이드 스타일 */
@import url('./tokens.css');
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* 슬라이드 컨테이너: 16:9 고정 비율 */
.slide {
width: 1280px;
height: 720px;
aspect-ratio: 16 / 9;
overflow: hidden;
background: var(--color-bg);
font-family: 'Pretendard Variable', 'Pretendard', 'Noto Sans KR', sans-serif;
color: var(--color-text);
font-size: var(--font-body);
line-height: var(--line-height-ko);
word-break: keep-all;
padding: var(--spacing-page);
display: grid;
gap: var(--spacing-block);
}
/* 슬라이드 제목 */
.slide-title {
font-size: var(--font-title);
font-weight: var(--weight-black);
color: var(--color-primary);
border-bottom: var(--accent-border) solid var(--color-accent);
padding-bottom: var(--spacing-small);
}
/* 섹션 제목 */
.section-title {
font-size: var(--font-subtitle);
font-weight: var(--weight-bold);
color: var(--color-primary);
margin-bottom: var(--spacing-small);
}
/* 본문 */
.body-text {
font-size: var(--font-body);
color: var(--color-text);
line-height: var(--line-height-ko);
}
/* 캡션/출처 */
.caption {
font-size: var(--font-caption);
color: var(--color-text-light);
font-style: italic;
}
/* 강조 텍스트 */
.highlight {
color: var(--color-accent);
font-weight: var(--weight-bold);
}
/* 경고/문제 강조 */
.danger {
color: var(--color-danger);
font-weight: var(--weight-bold);
}

253
static/index.html Normal file
View File

@@ -0,0 +1,253 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Design Agent — 슬라이드 생성기</title>
<link rel="preconnect" href="https://cdn.jsdelivr.net">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Pretendard Variable', sans-serif;
background: #f1f5f9;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
padding: 24px;
color: #1e293b;
}
h1 {
font-size: 1.5rem;
font-weight: 700;
margin-bottom: 16px;
}
.container {
width: 100%;
max-width: 1400px;
display: grid;
grid-template-columns: 400px 1fr;
gap: 24px;
flex: 1;
}
.input-panel {
background: white;
border-radius: 8px;
padding: 20px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
display: flex;
flex-direction: column;
gap: 12px;
}
.input-panel label {
font-weight: 600;
font-size: 0.9rem;
}
textarea {
width: 100%;
height: 400px;
border: 1px solid #e2e8f0;
border-radius: 6px;
padding: 12px;
font-family: inherit;
font-size: 0.85rem;
line-height: 1.6;
resize: vertical;
word-break: keep-all;
}
textarea:focus {
outline: none;
border-color: #2563eb;
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
button {
padding: 12px 24px;
background: #2563eb;
color: white;
border: none;
border-radius: 6px;
font-size: 0.95rem;
font-weight: 600;
cursor: pointer;
font-family: inherit;
}
button:hover { background: #1d4ed8; }
button:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-download {
background: #16a34a;
margin-top: 8px;
}
.btn-download:hover { background: #15803d; }
.progress {
font-size: 0.85rem;
color: #64748b;
padding: 8px 0;
}
.preview-panel {
background: #e2e8f0;
border-radius: 8px;
padding: 20px;
display: flex;
flex-direction: column;
gap: 12px;
overflow: auto;
}
.preview-label {
color: #64748b;
font-size: 0.85rem;
font-weight: 600;
}
.iframe-wrapper {
width: 100%;
aspect-ratio: 16 / 9;
position: relative;
overflow: hidden;
border-radius: 6px;
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
background: white;
}
iframe {
width: 1280px;
height: 720px;
border: none;
background: white;
transform-origin: top left;
/* scale은 JS에서 컨테이너 너비에 맞게 동적 계산 */
}
.error {
color: #dc2626;
font-size: 0.85rem;
padding: 8px 12px;
background: #fef2f2;
border-radius: 6px;
display: none;
}
</style>
</head>
<body>
<h1>Design Agent — 슬라이드 생성기</h1>
<div class="container">
<div class="input-panel">
<label>콘텐츠 입력</label>
<textarea id="content" placeholder="슬라이드로 변환할 텍스트를 붙여넣으세요..."></textarea>
<button id="btn-generate" onclick="generate()">슬라이드 생성</button>
<div id="progress" class="progress"></div>
<div id="error" class="error"></div>
<button id="btn-download" class="btn-download" style="display:none" onclick="download()">HTML 다운로드</button>
</div>
<div class="preview-panel">
<div class="preview-label">미리보기</div>
<div class="iframe-wrapper" id="iframe-wrapper">
<iframe id="preview"></iframe>
</div>
</div>
</div>
<script>
let generatedHTML = '';
function scalePreview() {
const wrapper = document.getElementById('iframe-wrapper');
const iframe = document.getElementById('preview');
if (!wrapper || !iframe) return;
const wrapperWidth = wrapper.clientWidth;
const scale = wrapperWidth / 1280;
iframe.style.transform = 'scale(' + scale + ')';
wrapper.style.height = (720 * scale) + 'px';
}
window.addEventListener('resize', scalePreview);
window.addEventListener('load', scalePreview);
async function generate() {
const content = document.getElementById('content').value.trim();
if (!content) return;
const btn = document.getElementById('btn-generate');
const progress = document.getElementById('progress');
const error = document.getElementById('error');
const downloadBtn = document.getElementById('btn-download');
btn.disabled = true;
error.style.display = 'none';
downloadBtn.style.display = 'none';
progress.textContent = '시작 중...';
try {
const response = await fetch('/api/generate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content }),
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
// SSE 이벤트는 빈 줄(\n\n)로 구분
const parts = buffer.split(/\r?\n\r?\n/);
buffer = parts.pop() || '';
for (const part of parts) {
if (!part.trim()) continue;
// 각 이벤트에서 event: 와 data: 추출
let eventType = '';
let eventData = '';
for (const line of part.split(/\r?\n/)) {
if (line.startsWith('event:')) {
eventType = line.slice(6).trim();
} else if (line.startsWith('data:')) {
eventData = line.slice(5).trim();
}
}
if (!eventData) continue;
try {
const parsed = JSON.parse(eventData);
if (eventType === 'progress') {
progress.textContent = parsed;
} else if (eventType === 'result') {
generatedHTML = parsed;
document.getElementById('preview').srcdoc = generatedHTML;
downloadBtn.style.display = 'block';
progress.textContent = '완료!';
setTimeout(scalePreview, 100);
} else if (eventType === 'error') {
error.textContent = parsed;
error.style.display = 'block';
}
} catch (e) {
// ping 등 무시
}
}
}
} catch (e) {
error.textContent = '오류: ' + e.message;
error.style.display = 'block';
} finally {
btn.disabled = false;
}
}
function download() {
if (!generatedHTML) return;
const blob = new Blob(['\uFEFF' + generatedHTML], { type: 'text/html;charset=utf-8' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'slide-' + Date.now() + '.html';
a.click();
URL.revokeObjectURL(url);
}
</script>
</body>
</html>

42
static/tokens.css Normal file
View File

@@ -0,0 +1,42 @@
/* Design Agent — 디자인 토큰 */
/* CLAUDE.md에 정의된 디자인 원칙을 CSS 변수로 구현 */
:root {
/* 색상 */
--color-primary: #1e293b;
--color-accent: #2563eb;
--color-neutral: #64748b;
--color-bg: #ffffff;
--color-bg-subtle: #f8fafc;
--color-border: #e2e8f0;
--color-danger: #dc2626;
--color-success: #16a34a;
--color-text: #1e293b;
--color-text-secondary: #64748b;
--color-text-light: #94a3b8;
/* 폰트 크기 */
--font-title: 2rem;
--font-subtitle: 1.25rem;
--font-body: 0.95rem;
--font-caption: 0.8rem;
--font-small: 0.7rem;
/* 폰트 두께 */
--weight-normal: 400;
--weight-medium: 500;
--weight-bold: 700;
--weight-black: 900;
/* 여백 */
--spacing-page: 40px;
--spacing-block: 20px;
--spacing-inner: 16px;
--spacing-small: 8px;
/* 기타 */
--radius: 6px;
--border-width: 1px;
--accent-border: 3px;
--line-height-ko: 1.7;
}