fix(input): invoke codex exec with stdin
This commit is contained in:
		| @@ -184,23 +184,26 @@ def slugify(component: str) -> str: | |||||||
|     return "-".join(parts) |     return "-".join(parts) | ||||||
|  |  | ||||||
|  |  | ||||||
| def run_codex(prompt_path: Path, output_path: Path) -> None: | def run_codex(prompt_text: str, output_path: Path) -> None: | ||||||
|     """Execute the Codex CLI.""" |     """Execute the Codex CLI with the provided prompt text.""" | ||||||
|  |     output_path.parent.mkdir(parents=True, exist_ok=True) | ||||||
|  |  | ||||||
|     command = [ |     command = [ | ||||||
|         "codex", |         "codex", | ||||||
|         "prompt", |         "exec", | ||||||
|         "--input", |         "-", | ||||||
|         str(prompt_path), |         "--output-last-message", | ||||||
|         "--output", |  | ||||||
|         str(output_path), |         str(output_path), | ||||||
|         "--format", |         "--skip-git-repo-check", | ||||||
|         "markdown", |         "--sandbox", | ||||||
|  |         "read-only", | ||||||
|     ] |     ] | ||||||
|     logging.info("Running Codex CLI command: %s", " ".join(command)) |     logging.info("Running Codex CLI command: %s", " ".join(command)) | ||||||
|  |  | ||||||
|     try: |     try: | ||||||
|         subprocess.run( |         subprocess.run( | ||||||
|             command, |             command, | ||||||
|  |             input=prompt_text.encode("utf-8"), | ||||||
|             check=True, |             check=True, | ||||||
|             timeout=CODEX_TIMEOUT_SECONDS, |             timeout=CODEX_TIMEOUT_SECONDS, | ||||||
|             env=os.environ.copy(), |             env=os.environ.copy(), | ||||||
| @@ -287,11 +290,8 @@ def normalize_job_description(job_file: Path) -> NormalizedJobDescription: | |||||||
|  |  | ||||||
|     with TemporaryDirectory() as tmp_dir_str: |     with TemporaryDirectory() as tmp_dir_str: | ||||||
|         tmp_dir = Path(tmp_dir_str) |         tmp_dir = Path(tmp_dir_str) | ||||||
|         prompt_path = tmp_dir / "normalize_prompt.md" |  | ||||||
|         prompt_path.write_text(prompt_text, encoding="utf-8") |  | ||||||
|  |  | ||||||
|         output_path = tmp_dir / "normalize_output.md" |         output_path = tmp_dir / "normalize_output.md" | ||||||
|         run_codex(prompt_path, output_path) |         run_codex(prompt_text, output_path) | ||||||
|         normalized_text = output_path.read_text(encoding="utf-8").strip() |         normalized_text = output_path.read_text(encoding="utf-8").strip() | ||||||
|  |  | ||||||
|     return parse_normalized_output(normalized_text) |     return parse_normalized_output(normalized_text) | ||||||
| @@ -342,11 +342,8 @@ def process_job(job_file: Path) -> None: | |||||||
|  |  | ||||||
|     with TemporaryDirectory() as tmp_dir_str: |     with TemporaryDirectory() as tmp_dir_str: | ||||||
|         tmp_dir = Path(tmp_dir_str) |         tmp_dir = Path(tmp_dir_str) | ||||||
|         prompt_path = tmp_dir / "prompt.md" |  | ||||||
|         prompt_path.write_text(prompt_text, encoding="utf-8") |  | ||||||
|  |  | ||||||
|         output_path = tmp_dir / "codex_output.md" |         output_path = tmp_dir / "codex_output.md" | ||||||
|         run_codex(prompt_path, output_path) |         run_codex(prompt_text, output_path) | ||||||
|  |  | ||||||
|         generated_output = out_dir / output_filename |         generated_output = out_dir / output_filename | ||||||
|         counter = 1 |         counter = 1 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user