04. design_agent 추가 — 콘텐츠 시각 구조화 슬라이드 생성기
5단계 AI 파이프라인: 1. Kei 실장(Opus via Kei API) — 꼭지 추출 + 정보 구조 파악 2. 디자인 팀장 — FAISS 블록 검색 + Opus 추천 + Sonnet 블록 매핑 3. Kei 편집자(Kei API) — 도메인 전문 텍스트 정리 4. 디자인 실무자(Sonnet + Jinja2) — CSS 변수 조정 + HTML 조립 5. 디자인 팀장(Sonnet) — 균형 재검토 (최대 2회 루프) 블록 라이브러리 46개 (6 카테고리) + _legacy 13개 FAISS 블록 검색 (bge-m3, 1024차원) SVG N개 동적 배치 (cos/sin 좌표 계산) Pillow 이미지 크기 측정 + base64 인라인 컨테이너 예산 기반 블록 배치 (zone별 높이 px) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
84
04. design_agent/static/base.css
Normal file
84
04. design_agent/static/base.css
Normal file
@@ -0,0 +1,84 @@
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* ── 컨테이너 레이아웃 ── */
|
||||
/* grid area: flex 축소 허용. overflow는 프레임(.slide)에서만 hidden. */
|
||||
/* A-1(Sonnet 디자인 조정)이 텍스트 양에 맞게 CSS를 사전 조정하므로,
|
||||
area 레벨에서는 overflow: visible로 텍스트 잘림을 방지한다. */
|
||||
.slide > div {
|
||||
overflow: visible;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
/* area 안에서 flex-column 그룹핑된 블록들의 축소 허용 */
|
||||
.slide > div > div {
|
||||
min-height: 0;
|
||||
flex-shrink: 1;
|
||||
}
|
||||
265
04. design_agent/static/index.html
Normal file
265
04. design_agent/static/index.html
Normal file
@@ -0,0 +1,265 @@
|
||||
<!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 = '시작 중...';
|
||||
|
||||
// 이미지 참조 감지 → 경로 입력 팝업
|
||||
let basePath = '';
|
||||
const hasImages = /!\[.*?\]\(.*?\)/.test(content);
|
||||
if (hasImages) {
|
||||
basePath = prompt(
|
||||
'이미지가 포함된 콘텐츠입니다.\n' +
|
||||
'이미지 파일이 있는 프로젝트 폴더 경로를 입력해주세요.\n' +
|
||||
'예: D:\\ad-hoc\\kei\\content\n\n' +
|
||||
'이미지 처리가 필요 없으면 취소를 누르세요.'
|
||||
) || '';
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/generate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ content, base_path: basePath }),
|
||||
});
|
||||
|
||||
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
04. design_agent/static/tokens.css
Normal file
42
04. design_agent/static/tokens.css
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user