From ac039b311d14463f0a49407d121c38ca32515dbe Mon Sep 17 00:00:00 2001 From: "KOKO\\Mimi" Date: Sun, 9 Aug 2026 01:37:24 +0900 Subject: [PATCH] fix: encode harness prompts as utf-8 --- scripts/execute.py | 1 + tests/test_execute.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/test_execute.py diff --git a/scripts/execute.py b/scripts/execute.py index 3ca984b..25e5232 100644 --- a/scripts/execute.py +++ b/scripts/execute.py @@ -259,6 +259,7 @@ class StepExecutor: input=prompt, capture_output=True, text=True, + encoding="utf-8", timeout=1800, ) except FileNotFoundError as exc: diff --git a/tests/test_execute.py b/tests/test_execute.py new file mode 100644 index 0000000..8b0f216 --- /dev/null +++ b/tests/test_execute.py @@ -0,0 +1,36 @@ +import json +import subprocess + +from scripts import execute + + +def test_invoke_codex_uses_utf8_for_unicode_prompt(tmp_path, monkeypatch): + phase_dir = tmp_path / "phases" / "unicode-phase" + phase_dir.mkdir(parents=True) + (phase_dir / "index.json").write_text( + json.dumps( + { + "project": "FESA Structural Solver", + "phase": "unicode-phase", + "steps": [{"step": 0, "name": "unicode", "status": "pending"}], + } + ), + encoding="utf-8", + ) + (phase_dir / "step0.md").write_text("Euler–Bernoulli 보", encoding="utf-8") + + invocation = {} + + def capture_run(command, **kwargs): + invocation["command"] = command + invocation["kwargs"] = kwargs + return subprocess.CompletedProcess(command, 0, stdout="", stderr="") + + monkeypatch.setattr(execute, "ROOT", tmp_path) + monkeypatch.setattr(execute.subprocess, "run", capture_run) + + executor = execute.StepExecutor("unicode-phase") + executor._invoke_codex({"step": 0, "name": "unicode"}, "승인된 설계 – ") + + assert "Euler–Bernoulli 보" in invocation["kwargs"]["input"] + assert invocation["kwargs"]["encoding"] == "utf-8"