feat: 카드·영상 스크립트를 윈도우에서도 돌게 — 외부 프로그램 위치를 scripts/bin.mjs 로 모음, 크롬이 45초 넘게 멈추면 그 장만 다시 찍음, claude 프롬프트는 stdin 으로

This commit is contained in:
minaChoi committed 2026-10-29 09:05:31 +09:00
1 parent 63b4fa74fe
commit e28359ff47
15 files changed
+150 -51

No files matched your search

+7 -2
View File
@@ -1,6 +1,7 @@
// 고른 스냅(사진 + 입은 상품 목록)에서 카드에 쓸 옷 목록을 Claude CLI로 뽑는다: 자리별 한글 이름표와 그림용 영어 설명.
import { execFile } from 'node:child_process'
import { tmpdir } from 'node:os'
import { cli } from './bin.mjs'
const SLOT_ORDER = ['top', 'outer', 'bottom', 'shoes', 'bag']
const PERSONA_TEXT = { f20: '20-30대 여자', m20: '20-30대 남자', f40: '40대 이상 여자', m40: '40대 이상 남자' }
@@ -55,9 +56,12 @@ function buildPrompt(pick, persona, weather) {
/** @returns {Promise<{ style: string, items: { slot: string, label: string, prompt: string }[] }>} */
export function extractOutfit(pick, persona, weather) {
const args = ['-p', buildPrompt(pick, persona, weather), '--output-format', 'json', '--json-schema', JSON.stringify(schema), '--tools', 'Read', '--allowedTools', 'Read', '--no-session-persistence', '--model', 'sonnet']
// 프롬프트는 길고 여러 줄이라 명령줄(윈도우는 길이 제한) 대신 stdin 으로 준다
const prompt = buildPrompt(pick, persona, weather)
return new Promise((done, fail) => {
execFile('claude', args, { cwd: tmpdir(), timeout: 240_000, maxBuffer: 10 * 1024 * 1024 }, (err, stdout) => {
const [claude, ...pre] = cli('claude')
const args = [...pre, '-p', '--output-format', 'json', '--json-schema', JSON.stringify(schema), '--tools', 'Read', '--allowedTools', 'Read', '--no-session-persistence', '--model', 'sonnet']
const child = execFile(claude, args, { cwd: tmpdir(), timeout: 240_000, maxBuffer: 10 * 1024 * 1024 }, (err, stdout) => {
if (err) return fail(new Error(`Claude CLI 실행 실패: ${err.message}. 터미널에서 claude 로그인 상태를 확인하세요.`))
let out
try {
@@ -72,5 +76,6 @@ export function extractOutfit(pick, persona, weather) {
items.sort((a, b) => SLOT_ORDER.indexOf(a.slot) - SLOT_ORDER.indexOf(b.slot))
done({ style: String(result.style ?? '').trim() || '데일리', items })
})
child.stdin.end(prompt)
})
}