feat: professionalize control plane and standalone delivery
This commit is contained in:
44
src/biliup_next/infra/adapters/codex_cli.py
Normal file
44
src/biliup_next/infra/adapters/codex_cli.py
Normal file
@ -0,0 +1,44 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from biliup_next.core.errors import ModuleError
|
||||
|
||||
|
||||
class CodexCliAdapter:
|
||||
def run_song_detect(
|
||||
self,
|
||||
*,
|
||||
codex_cmd: str,
|
||||
work_dir: Path,
|
||||
prompt: str,
|
||||
) -> subprocess.CompletedProcess[str]:
|
||||
cmd = [
|
||||
codex_cmd,
|
||||
"exec",
|
||||
prompt.replace("\n", " "),
|
||||
"--full-auto",
|
||||
"--sandbox",
|
||||
"workspace-write",
|
||||
"--output-schema",
|
||||
"./song_schema.json",
|
||||
"-o",
|
||||
"songs.json",
|
||||
"--skip-git-repo-check",
|
||||
"--json",
|
||||
]
|
||||
try:
|
||||
return subprocess.run(
|
||||
cmd,
|
||||
cwd=str(work_dir),
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
except FileNotFoundError as exc:
|
||||
raise ModuleError(
|
||||
code="CODEX_NOT_FOUND",
|
||||
message=f"找不到 codex 命令: {codex_cmd}",
|
||||
retryable=False,
|
||||
) from exc
|
||||
Reference in New Issue
Block a user