Skip to content

Conversation

github-actions[bot]
Copy link

Closes #532

Applied changes based on Issue #532.

I’ve refactored src/client/codex.ts to pull out and simplify the core steps into three small helpers—argument‑building, env‑building, and output‑parsing—and cleaned up the main runCodex flow. Here’s what changed:

  • Extracted helpers

    • buildCliArgs(prompt, model, images) uses flatMap for image flags and assembles the full argument list.
    • buildEnvVars(config) centralizes all environment‑variable setup via object spreads.
    • extractCodexOutput(stdout) splits on newlines, finds the second‑last/last timestamp markers via a single reduce, and returns the trimmed block.
  • Streamlined runCodex

    • Moved arg/env construction out of the try block and removed manual loops/spreads in favor of the new helpers.
    • Simplified the execa invocation and merged stderr/exit‑code error checks into concise conditionals.
    • Replaced the old fencing + split/map/filter logic with extractCodexOutput(result.stdout).
  • Maintained identical behavior
    All existing logging, error types (CliError, TimeoutError), and timestamp‑block logic remain functionally unchanged—just reorganized for clarity and performance.

Please let me know if any tweaks are needed!

@YiweiShen YiweiShen merged commit cd0dd31 into main Jul 26, 2025
3 checks passed
@YiweiShen YiweiShen deleted the codez-chore-532-refactor-client-clean-up-codex-module-3121137626 branch July 26, 2025 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Done] Refactor src/client/codex.ts

1 participant