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

+4 -2
View File
@@ -3,6 +3,7 @@ import { execFileSync } from 'node:child_process'
import { mkdtempSync, readdirSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { cli, toWebp } from './bin.mjs'
// 그림은 이미지 생성 도구가 만들고 Codex 는 도구를 부르고 결과를 저장하는 역할뿐이라 중간 모델·낮은 추론으로 고정한다 (가장 싼 gpt-6-luna 는 결과를 파일로 저장하지 못하고, 기본 설정의 gpt-6-astra·xhigh 는 한도를 금방 소진한다)
export const IMAGE_MODEL = process.env.CODEX_IMAGE_MODEL ?? 'gpt-6-sol'
@@ -27,7 +28,8 @@ export function drawWithCodex({ id, prompt, outPath, images = [], log = console.
try {
// -i 는 파일을 여러 개 받아서 뒤의 프롬프트까지 파일로 읽는다 → 프롬프트는 stdin 으로 준다
const imageArgs = images.flatMap((p) => ['-i', p])
execFileSync('codex', ['exec', '--skip-git-repo-check', '-C', work, '-s', 'workspace-write', '-m', IMAGE_MODEL, '-c', 'model_reasoning_effort="low"', ...imageArgs], { input: task, stdio: ['pipe', 'ignore', 'inherit'] })
const [codex, ...pre] = cli('codex')
execFileSync(codex, [...pre, 'exec', '--skip-git-repo-check', '-C', work, '-s', 'workspace-write', '-m', IMAGE_MODEL, '-c', 'model_reasoning_effort="low"', ...imageArgs], { input: task, stdio: ['pipe', 'ignore', 'inherit'] })
} catch (e) {
rmSync(work, { recursive: true, force: true })
throw new Error(`${id}: Codex 실행이 실패했어요 (${e.message}). 사용 한도나 로그인을 확인하세요.`)
@@ -37,7 +39,7 @@ export function drawWithCodex({ id, prompt, outPath, images = [], log = console.
log(`${id}: Codex가 그림을 저장하지 않았어요. 작업 폴더: ${work}`)
return 'not-saved'
}
execFileSync('cwebp', ['-quiet', '-q', '88', '-resize', '1024', '0', join(work, png), '-o', outPath])
toWebp(join(work, png), outPath)
rmSync(work, { recursive: true, force: true })
log(`${id}: ${outPath}`)
return 'ok'