Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
refactor(providers): the ask choice, the two API key names and the codex binary each take one name (CODEX_UNAVAILABLE_ASK, xai.AUTH_ENV, anthropic_api.AUTH_ENV, codex_provider.BINARY)
Soohong Kima98636e54db8
diff --git a/sprite_gen/gen/__init__.py b/sprite_gen/gen/__init__.pyindex 1a866fd..7de9127 100644--- a/sprite_gen/gen/__init__.py+++ b/sprite_gen/gen/__init__.py@@ -107,8 +107,9 @@ EXPLICIT_ONLY_PROVIDERS = (PROVIDER_OPENAI,)# key CODEX_UNAVAILABLE_SETTING), else `ask`. Until 2.44.0 it went to grok unasked.CODEX_UNAVAILABLE_ENV = "SPRITE_GEN_CODEX_UNAVAILABLE"CODEX_UNAVAILABLE_SETTING = "codex_unavailable"-CODEX_UNAVAILABLE_CHOICES = ("ask", PROVIDER_GROK, PROVIDER_OPENAI)-CODEX_UNAVAILABLE_DEFAULT = "ask"+CODEX_UNAVAILABLE_ASK = "ask"+CODEX_UNAVAILABLE_CHOICES = (CODEX_UNAVAILABLE_ASK, PROVIDER_GROK, PROVIDER_OPENAI)+CODEX_UNAVAILABLE_DEFAULT = CODEX_UNAVAILABLE_ASK# `--layout-guide`: the one-slot form of the guide `prepare` draws for every row# (`draw_guide`, the same 9.4 % safe margin), attached after the caller's refs, with@@ -364,7 +365,7 @@ def codex_unavailable(cause: str, reason: str, *, default_source: str) -> tuple[the user's choice: raises the question (`CodexUnavailableAsk`) for `ask`, else returns the chosen provider andthe switch the report keeps as `provider_fallback`."""choice, chosen_by = codex_unavailable_choice()- if choice == "ask":+ if choice == CODEX_UNAVAILABLE_ASK:raise ask_codex_unavailable(codex_unavailable_question(cause, reason))return choice, {"from": PROVIDER_CODEX, "to": choice, "cause": cause, "reason": reason,"default_source": default_source, "chosen_by": chosen_by}diff --git a/sprite_gen/gen/claude_login.py b/sprite_gen/gen/claude_login.pyindex feaf618..11dba80 100644--- a/sprite_gen/gen/claude_login.py+++ b/sprite_gen/gen/claude_login.py@@ -59,7 +59,7 @@ LOGIN_HINT = "`claude` then `/login` signs your Claude subscription in"# would win over `--effort`, and the calling Claude Code session's own variables (an agent running# this tool must not make the child part of its session). `CLAUDE_CODE_*` are Claude Code's; the# documented ones that choose how it signs in stay.-CHILD_DROP = ("ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN", "CLAUDECODE", "CLAUDE_PID", "CLAUDE_EFFORT")+CHILD_DROP = (api.AUTH_ENV, "ANTHROPIC_AUTH_TOKEN", "CLAUDECODE", "CLAUDE_PID", "CLAUDE_EFFORT")CHILD_KEEP = ("CLAUDE_CODE_OAUTH_TOKEN", "CLAUDE_CODE_USE_BEDROCK", "CLAUDE_CODE_USE_VERTEX","CLAUDE_CODE_USE_FOUNDRY")diff --git a/sprite_gen/gen/codex_provider.py b/sprite_gen/gen/codex_provider.pyindex 5e3032a..e5e4db7 100644--- a/sprite_gen/gen/codex_provider.py+++ b/sprite_gen/gen/codex_provider.py@@ -52,6 +52,7 @@ from .base import (AUTH_SOURCE_LOGIN = "codex-login" # signed in with ChatGPT: the subscriptionAUTH_SOURCE_API_KEY = "codex-api-key" # signed in with an API key: billed per callLOGIN_PROBE_TIMEOUT_SECONDS = 15+BINARY = "codex"LOGIN_HINT = "`codex login` signs your ChatGPT subscription in"@@ -106,7 +107,7 @@ def codex_login() -> CodexLogin:not asked and is not usable: its login is all it runs on."""if not logins_on():return CodexLogin(None, LOGINS_OFF)- binary = provider_binary("codex")+ binary = provider_binary(BINARY)try:completed = subprocess.run([binary, "login", "status"], capture_output=True, text=True, encoding="utf-8",errors="replace", env=provider_subprocess_env(),@@ -424,7 +425,7 @@ class CodexProvider:except OSError as exc:raise SystemExit(f"codex-gen: cannot create Codex generated-images dir {gen_dir}: {exc}") from exccmd = [- provider_binary("codex"),+ provider_binary(BINARY),"exec","--json","--sandbox",diff --git a/sprite_gen/gen/facing_vision.py b/sprite_gen/gen/facing_vision.pyindex 157d1a7..a56f57f 100644--- a/sprite_gen/gen/facing_vision.py+++ b/sprite_gen/gen/facing_vision.py@@ -59,14 +59,14 @@ def codex_inspect(path: Path, workdir: Path, *, prompt: str = INSPECTION_PROMPT,# Isolated cwd and ephemeral session: no project instructions, no stale# output reuse and no persistent vision rollouts. Uses the existing login,# on its config's model and effort unless the call names them.- from .codex_provider import announce_codex_billing, codex_login+ from .codex_provider import BINARY, announce_codex_billing, codex_loginlogin = codex_login()if login.source is None:raise SystemExit(f"{_tag(label)}: {login.reason}")announce_codex_billing(login, f" ({label})")with tempfile.TemporaryDirectory(prefix="facing-", dir=workdir) as directory:output = Path(directory) / "answer.txt"- command = [provider_binary("codex"), "exec", "--sandbox", "read-only",+ command = [provider_binary(BINARY), "exec", "--sandbox", "read-only","--skip-git-repo-check", "--ephemeral", "--color", "never", "-C", directory]if model:command += ["--model", model]diff --git a/sprite_gen/gen/xai.py b/sprite_gen/gen/xai.pyindex db43fc4..b14660e 100644--- a/sprite_gen/gen/xai.py+++ b/sprite_gen/gen/xai.py@@ -24,7 +24,7 @@ from . import address, refusal, retryfrom .base import LOGINS_ENV, env_api_key, logins_onAUTH_ENV = "XAI_API_KEY"-AUTH_SOURCE_API_KEY = "XAI_API_KEY"+AUTH_SOURCE_API_KEY = AUTH_ENVAUTH_SOURCE_GROK_LOGIN = "grok-login"HTTP_TIMEOUT_SECONDS = 120diff --git a/sprite_gen/workflow/catalog.py b/sprite_gen/workflow/catalog.pyindex cf89994..dd7092b 100644--- a/sprite_gen/workflow/catalog.py+++ b/sprite_gen/workflow/catalog.py@@ -1,6 +1,6 @@# SPDX-License-Identifier: Apache-2.0"""The two user journeys and their selectable fields, declared once."""-from sprite_gen.gen import CODEX_UNAVAILABLE_CHOICES, CODEX_UNAVAILABLE_SETTING, PROVIDERS+from sprite_gen.gen import CODEX_UNAVAILABLE_ASK, CODEX_UNAVAILABLE_CHOICES, CODEX_UNAVAILABLE_SETTING, PROVIDERSfrom sprite_gen.gen.base import PROVIDER_CODEX, PROVIDER_GROK, PROVIDER_OPENAIMOTION_METHODS = {@@ -45,7 +45,7 @@ FIELDS = {# `gen.codex_unavailable_choice` reads it, docs/gen.md "When codex cannot run" owns the rule.GENERAL_FIELDS = {CODEX_UNAVAILABLE_SETTING: {- "options": {"ask": "멈추고 묻기 (기본)", PROVIDER_GROK: "그록으로 만들기",+ "options": {CODEX_UNAVAILABLE_ASK: "멈추고 묻기 (기본)", PROVIDER_GROK: "그록으로 만들기",PROVIDER_OPENAI: "OpenAI API 로 만들기 (호출당 과금)"},"question": "지피티(codex)를 쓸 수 없을 때 — 로그인이 없거나 사용량을 다 썼을 때 — 어떻게 할까요?",},