feat: 날씨 유형 그림 8장·미리보기 그림 9장, 한글 사용자 폴더에서 그림 도구가 멈추던 것 고침
- 유형 그림 8장(800×800 webp): 임시 그림을 Codex 로 그린 그림으로 교체 — 같은 토끼가 유형별 날씨 장면에 - 미리보기 그림 9장(1200×630 png)을 새 그림으로 다시 만듦 - 그림 프롬프트 admin/image-prompts/weather-type.json 추가 (다시 그려도 같은 그림체) - admin/scripts/bin.mjs: 윈도우에서 프로그램 위치를 PATH 로 직접 찾음 (where 출력은 경로의 한글이 깨짐), .cmd 가 .exe 를 가리키는 경우(npm 으로 깐 claude)도 부름 - admin/scripts/bin.mjs removeDir: 경로에 한글이 있으면 rmSync(recursive) 가 Node 를 꺼뜨려(종료 코드 127) 그림 한 장만 만들고 끝나던 것 — 하나씩 지우게 - admin 테스트 추가 (admin 에서 npm test)
This commit is contained in:
1 parent
4fc61d6c02
commit
11a7a270ff
23 files changed
+147
-17
No files matched your search
@@ -1,9 +1,9 @@
|
||||
// Codex CLI의 이미지 생성 도구로 그림 한 장을 만들어 webp 로 저장한다. gen-image.mjs(고정 데이터 그림)와 daily-ootd.mjs(그날 코디 그림)가 같이 쓴다.
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { mkdtempSync, readdirSync, rmSync } from 'node:fs'
|
||||
import { mkdtempSync, readdirSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { cli, toWebp } from './bin.mjs'
|
||||
import { cli, removeDir, toWebp } from './bin.mjs'
|
||||
|
||||
// 그림은 이미지 생성 도구가 만들고 Codex 는 도구를 부르고 결과를 저장하는 역할뿐이라 중간 모델·낮은 추론으로 고정한다 (가장 싼 gpt-6-luna 는 결과를 파일로 저장하지 못하고, 기본 설정의 gpt-6-astra·xhigh 는 한도를 금방 소진한다)
|
||||
export const IMAGE_MODEL = process.env.CODEX_IMAGE_MODEL ?? 'gpt-6-sol'
|
||||
@@ -31,7 +31,7 @@ export function drawWithCodex({ id, prompt, outPath, images = [], log = console.
|
||||
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 })
|
||||
removeDir(work)
|
||||
throw new Error(`${id}: Codex 실행이 실패했어요 (${e.message}). 사용 한도나 로그인을 확인하세요.`)
|
||||
}
|
||||
const png = readdirSync(work).find((f) => f === 'result.png') ?? readdirSync(work).find((f) => f.endsWith('.png'))
|
||||
@@ -40,7 +40,7 @@ export function drawWithCodex({ id, prompt, outPath, images = [], log = console.
|
||||
return 'not-saved'
|
||||
}
|
||||
toWebp(join(work, png), outPath)
|
||||
rmSync(work, { recursive: true, force: true })
|
||||
removeDir(work)
|
||||
log(`${id}: ${outPath}`)
|
||||
return 'ok'
|
||||
}
|
||||
Reference in new issue
Block a user