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
@@ -4,6 +4,7 @@ import { execFile } from 'node:child_process'
import { existsSync, readdirSync, readFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { resolve } from 'node:path'
import { cli } from './bin.mjs'
const pngNames = (dir) =>
readdirSync(resolve(import.meta.dirname, dir))
@@ -146,9 +147,12 @@ function schema(ctx, fixed = {}, topic = '') {
/** @returns {Promise<{ topic: string, copy: Record<string, string> }>} */
export function runPlan(ctx, { topic = '', feedback = '', fixed = {} } = {}) {
const args = ['-p', buildPrompt(ctx, { topic, feedback, fixed }), '--output-format', 'json', '--json-schema', JSON.stringify(schema(ctx, fixed, topic)), '--tools', '', '--no-session-persistence', '--model', 'sonnet']
// 프롬프트는 길고 여러 줄이라 명령줄(윈도우는 길이 제한) 대신 stdin 으로 준다
const prompt = buildPrompt(ctx, { topic, feedback, fixed })
return new Promise((done, fail) => {
execFile('claude', args, { cwd: tmpdir(), timeout: 180_000, maxBuffer: 10 * 1024 * 1024 }, (err, stdout) => {
const [claude, ...pre] = cli('claude')
const args = [...pre, '-p', '--output-format', 'json', '--json-schema', JSON.stringify(schema(ctx, fixed, topic)), '--tools', '', '--no-session-persistence', '--model', 'sonnet']
const child = execFile(claude, args, { cwd: tmpdir(), timeout: 180_000, maxBuffer: 10 * 1024 * 1024 }, (err, stdout) => {
if (err) return fail(new Error(`Claude CLI 실행 실패: ${err.message}. 터미널에서 claude 로그인 상태를 확인하세요.`))
let out
try {
@@ -178,5 +182,6 @@ export function runPlan(ctx, { topic = '', feedback = '', fixed = {} } = {}) {
if (isTarot(ctx)) for (const k of ['c1', 'c2', 'c3', 'i1', 'i2', 'i3']) if (result[k]) copy[k] = result[k]
done({ topic: finalTopic, copy })
})
child.stdin.end(prompt)
})
}