diff --git a/.claude/commands/daily-cards.md b/.claude/commands/daily-cards.md index a88c64f..0df5d09 100644 --- a/.claude/commands/daily-cards.md +++ b/.claude/commands/daily-cards.md @@ -1,16 +1,16 @@ --- description: 오늘 날씨 타로·코디 카드를 만들어 검수하고 킹서버에 승인 대기로 저장한다 (올리지는 않는다) -argument-hint: <타로 주제> +argument-hint: <타로 주제> [코디 스타일: casual|semi|formal|street|minimal] --- -오늘 인스타 카드를 만든다. 인자: `$ARGUMENTS` (타로 주제. 비어 있으면 Claude 가 오늘 날씨에 맞는 주제를 고른다). +오늘 인스타 카드를 만든다. 인자: `$ARGUMENTS` — 앞은 타로 주제(비어 있으면 Claude 가 오늘 날씨에 맞는 주제를 고른다), 마지막 단어가 casual·semi·formal·street·minimal 중 하나면 코디 스타일(없으면 minimal=꾸안꾸). 코디 포스트 하나는 스타일 하나: 네 사람 모두 같은 스타일. 재확인 질문 없이 순서대로 진행하고, 막히면 그 자리에서 보고하고 멈춘다. **인스타·날씨각 피드에 올리지 않는다** — 승인 대기 저장까지만. 1. 관리자 서버: `curl -s http://localhost:5175/api/targets` 에 `king` 이 있어야 한다. 없으면 `admin/` 에서 백그라운드로 켠다 (`admin/AGENTS.md` '켜기', 킹서버 키는 `ssh King_admin` 의 `~/proj/o2o-weather/.env` `ADMIN_API_KEY`, 값은 출력하지 않는다). 2. 예보: `curl -s "https://weather.o2o.kr/v1/weather/today?region=1114000000"` 의 `day` 가 오늘인지 보고 slots 의 기온·하늘·비 확률을 적어 둔다. 3. 타로: `cd admin && VITE_API_BASE_URL=https://weather.o2o.kr ADMIN_URL=http://localhost:5175 npm run card -- tarot --topic "<주제>" --color sky --post-wait`. 출력된 기획 문구를 2의 예보와 대조한다(숫자·하늘 묘사가 틀리면 `--copy <값> --feedback "실제 수치…"` 로 한 번만 다시). "일부 그림을 못 만들어" 가 나오면 멈추고 보고한다. 크롬이 한 장에서 45초 넘게 멈추면 그 프로세스를 죽이고 그 장만 다시 찍는다. -4. 코디(그날 코디): `npm run card -- ootd --daily --color sky --post-wait`. 무신사 인기 스냅에서 사람 4명(20-30대·40대~ 여·남) 코디를 고르고, Claude 가 옷 목록을 뽑고, Codex 가 참고 사진대로 플랫레이 그림을 그린다(사람당 2~4분). 고른 스냅 주소와 옷 목록이 출력된다. "스냅이 없어요"·"저장하지 못했어요" 가 나오면 멈추고 보고한다. +4. 코디(그날 코디): `npm run card -- ootd --daily --style <스타일> --color sky --post-wait`. 무신사 인기 스냅 중 그 스타일 태그(꾸안꾸·오피스룩·캐주얼·스트릿·정장)가 붙은 것에서 사람 4명(20-30대·40대~ 여·남) 코디를 고르고, Claude 가 옷 목록을 뽑고, Codex 가 참고 사진대로 플랫레이 그림을 그린다(사람당 2~4분). 고른 스냅 주소와 옷 목록이 출력된다. "스냅이 없어요"·"저장하지 못했어요" 가 나오면 멈추고 보고한다. 5. 검수(예외 없음): 만든 JPEG 전부를 **한 장씩 원본 크기로** Read 로 연다. 축소 시트로 판단하지 않는다. 볼 것: 글자 잘림·겹침, 그림 누락, 그림 속 사람·얼굴·글자, 코디는 그림 아래 옷 목록의 옷이 그림에 전부 있고 추가 옷이 없는지, 스냅 사진(`out/<날짜>/snaps/<사람>/snap.jpg`)과 옷·색이 같은지, 날씨 줄 수치가 예보와 맞는지. 틀리면 고치고 다시 찍어 다시 본다. 6. 새 타로 그림이 생겼으면 `git add admin/src/assets/gak-card admin/src/assets/tarot-bg` 후 `feat: <날짜> 각 카드 그림(…)` 로 커밋한다 (Claude 서명 없이). 코디 그림(`admin/public/daily`)은 커밋하지 않는다. 7. 보고(한국어, 짧게): 킹서버 카드 번호 2개(승인 대기), 만든 JPEG 경로, 참고한 스냅 주소 4개, 검수에서 고친 것, 남은 이슈. 올리는 건 사용자가 관리자 '만든 카드' 탭이나 "올려" 로 한다. diff --git a/admin/AGENTS.md b/admin/AGENTS.md index e6220ca..aaf14c2 100644 --- a/admin/AGENTS.md +++ b/admin/AGENTS.md @@ -60,9 +60,11 @@ VITE_API_BASE_URL=http://localhost:9810 npm run card -- tarot --topic 주식 [-- 코디 카드는 고정 데이터(`image-prompts/ootd.json` 구간×스타일 옷) 대신 **그날 무신사 인기 스냅**으로 만든다. 같은 날씨라도 매일 다른 코디가 나온다. ```bash -VITE_API_BASE_URL=https://weather.o2o.kr npm run card -- ootd --daily --color sky --post-wait +VITE_API_BASE_URL=https://weather.o2o.kr npm run card -- ootd --daily --style minimal --color sky --post-wait ``` +포스트 하나는 스타일 하나(`--style`, 기본 minimal=꾸안꾸): 네 사람 모두 그 스타일 태그(`scripts/snap.mjs STYLE_TAGS`)가 붙은 스냅에서 고르고 제목도 그 스타일로 통일한다. + 흐름(`scripts/daily-ootd.mjs`): 1. 오늘 예보로 기온 구간을 정한다(`scripts/daily-ootd.mjs weatherToday`). 2. `scripts/snap.mjs`: 무신사 스냅 공개 API에서 구간에 맞는 태그(가을코디·간절기코디·겨울코디…)와 단정 키워드(오피스룩·댄디룩…)로 인기 스냅을 모으고, 상품 카테고리로 상의·하의·신발이 다 있는 것만 남긴 뒤 사람별(40대~ 먼저, 단정 태그 가산점)로 하나씩 고른다. 45일 지난 스냅, 구간에 안 맞는 아우터(패딩·코트 등)·반바지는 뺀다. 사진·상품 썸네일은 `out/<날짜>/snaps/<사람>/`에 참고용으로만 받고 어디에도 올리지 않는다. diff --git a/admin/scripts/card.mjs b/admin/scripts/card.mjs index f76ddd6..32af089 100644 --- a/admin/scripts/card.mjs +++ b/admin/scripts/card.mjs @@ -34,6 +34,7 @@ let copy = flag('--copy') const topic = flag('--topic') const feedback = flag('--feedback') const color = flag('--color') +const styleArg = flag('--style') const outArg = flag('--out') const take = (name) => args.includes(name) && args.splice(args.indexOf(name), 1).length > 0 let noImages = take('--no-images') @@ -80,8 +81,10 @@ const outDir = resolve(outArg ?? `out/${day}`) if (daily) { if (template !== 'ootd') fail('--daily 는 ootd 템플릿에서만 써요.') const { runDailyOotd, toCardOutfits } = await import('./daily-ootd.mjs') - const { outfits } = await runDailyOotd({ outDir }) - copy = Buffer.from(JSON.stringify({ ...decode(copy), outfits: JSON.stringify(toCardOutfits(outfits)) })).toString('base64url') + // 포스트 하나는 스타일 하나: --style , 없으면 --copy 의 style, 그것도 없으면 꾸안꾸 + const style = styleArg ?? decode(copy).style ?? 'minimal' + const { outfits } = await runDailyOotd({ outDir, style }) + copy = Buffer.from(JSON.stringify({ ...decode(copy), style, outfits: JSON.stringify(toCardOutfits(outfits)) })).toString('base64url') noImages = true } diff --git a/admin/scripts/daily-ootd.mjs b/admin/scripts/daily-ootd.mjs index 056658d..bd6648f 100644 --- a/admin/scripts/daily-ootd.mjs +++ b/admin/scripts/daily-ootd.mjs @@ -52,12 +52,15 @@ function buildPrompt(persona, outfit, weather) { .replace('{layering}', weather.layering) } -/** @returns {Promise<{ weather: object, outfits: { persona: string, label: string, style: string, labels: string[], image: string, source: string, items: object[] }[] }>} */ -export async function runDailyOotd({ outDir, log = console.log }) { +/** 포스트 하나는 스타일 하나(기본 꾸안꾸). 네 사람 모두 그 스타일 스냅에서 고르고 제목도 같은 스타일로 간다. + * @returns {Promise<{ weather: object, outfits: { persona: string, label: string, style: string, labels: string[], image: string, source: string, items: object[] }[] }>} */ +export async function runDailyOotd({ outDir, style = 'minimal', log = console.log }) { + if (!spec.styles[style]) throw new Error(`스타일은 ${Object.keys(spec.styles).join(', ')} 중 하나예요: ${style}`) + const styleLabel = spec.styles[style].label const weather = await weatherToday() - log(`오늘 ${weather.day}: 아침 ${weather.morningC}° · 낮 ${weather.maxC}° → 구간 ${weather.band}`) + log(`오늘 ${weather.day}: 아침 ${weather.morningC}° · 낮 ${weather.maxC}° → 구간 ${weather.band} · 스타일 ${styleLabel}`) mkdirSync(outDir, { recursive: true }) - const picks = await pickSnaps({ band: weather.band, outDir: join(outDir, 'snaps'), log }) + const picks = await pickSnaps({ band: weather.band, style, outDir: join(outDir, 'snaps'), log }) const dailyDir = resolve('public/daily') mkdirSync(dailyDir, { recursive: true }) const outfits = [] @@ -65,6 +68,8 @@ export async function runDailyOotd({ outDir, log = console.log }) { const pick = picks[persona] log(`${persona}: Claude가 옷 목록을 뽑는 중… (${pick.url})`) const outfit = await extractOutfit(pick, persona, weather) + // 제목은 Claude 가 본 분위기가 아니라 포스트 스타일로 통일한다 + outfit.style = styleLabel const by = Object.fromEntries(outfit.items.map((it) => [it.slot, it])) const labels = LABEL_ORDER.filter((s) => by[s]).map((s) => by[s].label) log(` ${outfit.style}: ${labels.join(' · ')}`) @@ -86,9 +91,11 @@ export const toCardOutfits = (outfits) => outfits.map(({ persona, label, style, if (process.argv[1]?.endsWith('daily-ootd.mjs')) { const args = process.argv.slice(2) - const outArg = args.includes('--out') ? args[args.indexOf('--out') + 1] : null + const flag = (n) => (args.includes(n) ? args[args.indexOf(n) + 1] : null) + const outArg = flag('--out') + const style = flag('--style') ?? 'minimal' const day = new Date(Date.now() + 9 * 3600_000).toISOString().slice(0, 10) - const { outfits } = await runDailyOotd({ outDir: resolve(outArg ?? `out/${day}`) }) - const copy = Buffer.from(JSON.stringify({ outfits: JSON.stringify(toCardOutfits(outfits)), theme: 'sky' })).toString('base64url') + const { outfits } = await runDailyOotd({ outDir: resolve(outArg ?? `out/${day}`), style }) + const copy = Buffer.from(JSON.stringify({ outfits: JSON.stringify(toCardOutfits(outfits)), style, theme: 'sky' })).toString('base64url') console.log(`카드 그리기: npm run card -- ootd --no-images --copy ${copy}`) } diff --git a/admin/scripts/snap.mjs b/admin/scripts/snap.mjs index 6870500..1444946 100644 --- a/admin/scripts/snap.mjs +++ b/admin/scripts/snap.mjs @@ -32,6 +32,14 @@ const BAND = { } // 철 지난 스냅은 뺀다 const MAX_AGE_DAYS = 45 +// 포스트 하나는 스타일 하나: 네 사람 모두 이 태그가 붙은 스냅에서 고른다 (image-prompts/ootd.json styles 의 id) +export const STYLE_TAGS = { + casual: ['데일리룩', '캐주얼룩', '캐주얼'], + semi: ['오피스룩', '출근룩', '비즈니스캐주얼'], + formal: ['정장', '수트', '포멀룩'], + street: ['스트릿', '스트릿룩', '스트릿패션'], + minimal: ['꾸안꾸', '미니멀룩', '미니멀'], +} // 40대~ 는 단정한 코디 태그로 한 번 더 모은다 const MATURE_KEYWORDS = { WOMEN: ['오피스룩', '출근룩', '미니멀룩'], MEN: ['오피스룩', '댄디룩', '비즈니스캐주얼'] } const MATURE_TAG = /오피스|출근|미니멀|클래식|단정|하객|댄디|비즈니스|포멀|꾸안꾸/ @@ -139,24 +147,28 @@ async function download(url, path) { writeFileSync(path, Buffer.from(await res.arrayBuffer())) } -/** 사람별로 스냅 하나씩: { f20: {...snap, files: { image, thumbs[] }}, ... } */ -export async function pickSnaps({ band, outDir, pages = 2, log = console.log }) { +/** 사람별로 스냅 하나씩: { f20: {...snap, files: { image, thumbs[] }}, ... }. style 을 주면 네 사람 모두 그 스타일 태그가 붙은 스냅에서 고른다 */ +export async function pickSnaps({ band, style, outDir, pages = 2, log = console.log }) { mkdirSync(outDir, { recursive: true }) const rule = BAND[band] ?? BAND.mild + const styleTags = STYLE_TAGS[style] ?? [] const pool = new Map() const add = (list) => list.forEach((s) => s.goodsNos.length >= 3 && !pool.has(s.id) && pool.set(s.id, s)) + for (const tag of styleTags) add(await listSnaps({ tags: tag }, pages)) for (const tag of rule.tags) add(await listSnaps({ tags: tag }, pages)) for (const gender of ['WOMEN', 'MEN']) for (const kw of MATURE_KEYWORDS[gender]) add(await listSnaps({ keyword: kw }, 1)) - log(`무신사 스냅 후보 ${pool.size}개 (구간 ${band}: #${rule.tags.join(' #')} + 단정 키워드). 상품 정보를 받아 거르는 중…`) + const hasStyle = (s) => styleTags.length === 0 || s.tags.some((t) => styleTags.some((st) => t.includes(st))) + log(`무신사 스냅 후보 ${pool.size}개 (구간 ${band}${styleTags.length ? ` · 스타일 #${styleTags.join(' #')} ${[...pool.values()].filter(hasStyle).length}개` : ''}). 상품 정보를 받아 거르는 중…`) const picks = {} const used = new Set() // 40대~ 를 먼저 골라야 단정한 코디가 남는다. 좋아요 순으로 상품 정보를 받아 보며 맞는 첫 코디를 고른다 for (const persona of ['f40', 'm40', 'f20', 'm20']) { const { gender } = PERSONAS[persona] + // 스타일 태그가 붙은 스냅을 먼저, 모자라면 나머지 (스타일 태그 없는 스냅은 뒤로) const candidates = [...pool.values()] .filter((s) => s.gender === gender && !used.has(s.id)) - .sort((a, b) => score(b, persona) - score(a, persona)) + .sort((a, b) => Number(hasStyle(b)) - Number(hasStyle(a)) || score(b, persona) - score(a, persona)) .slice(0, 25) let best = null for (const c of candidates) { @@ -184,8 +196,8 @@ export async function pickSnaps({ band, outDir, pages = 2, log = console.log }) // 썸네일 없으면 상품명만 쓴다 } } - picks[persona] = { ...best, files: { image, thumbs } } - log(` ${persona}: ${best.url} ♥${best.likes} #${best.tags.slice(0, 3).join(' #')} | ${best.goods.map((g) => g.name).join(' / ').slice(0, 90)}`) + picks[persona] = { ...best, styled: hasStyle(best), files: { image, thumbs } } + log(` ${persona}: ${best.url} ♥${best.likes}${styleTags.length && !hasStyle(best) ? ' (스타일 태그 없음, 대체)' : ''} #${best.tags.slice(0, 3).join(' #')} | ${best.goods.map((g) => g.name).join(' / ').slice(0, 90)}`) } writeFileSync(join(outDir, 'picks.json'), JSON.stringify(picks, null, 1)) return picks @@ -196,5 +208,5 @@ if (process.argv[1]?.endsWith('snap.mjs')) { const flag = (n) => (args.includes(n) ? args[args.indexOf(n) + 1] : null) const band = flag('--band') ?? 'mild' const outDir = flag('--out') ?? `out/${new Date(Date.now() + 9 * 3600_000).toISOString().slice(0, 10)}/snaps` - await pickSnaps({ band, outDir, pages: Number(flag('--pages') ?? 2) }) + await pickSnaps({ band, style: flag('--style') ?? undefined, outDir, pages: Number(flag('--pages') ?? 2) }) } diff --git a/admin/src/cards/templates.tsx b/admin/src/cards/templates.tsx index d2fb1b3..1c10d58 100644 --- a/admin/src/cards/templates.tsx +++ b/admin/src/cards/templates.tsx @@ -60,7 +60,7 @@ const ootd: Template = { // 예시: 17~22도 캐주얼 (Codex 그림 6장) example: { style: 'casual', band: 'mild', theme: 'berry' }, post: (d, c) => ({ - title: dailyOutfits(c) ? '오늘의 코디' : `오늘의 코디 · ${styleLabel(c.style)}`, + title: `오늘의 코디 · ${styleLabel(c.style)}`, caption: `낮 최고 ${d.maxC}도, 20대부터 40대~까지 오늘 입을 옷을 넘겨 보세요`, hashtags: '#날씨각 #오늘의코디 #OOTD #데일리룩 #옷차림 #코디추천 #날씨 #오늘날씨 #서울날씨 #일상', }),