Skip to content

feat: forward CODEX_PLUGIN_CC_ARGS to codex launches - #419

Open
klmklmnb wants to merge 6 commits into
openai:mainfrom
klmklmnb:feat/codex-plugin-cc-args
Open

klmklmnb wants to merge 6 commits into
openai:mainfrom
klmklmnb:feat/codex-plugin-cc-args

Conversation

@klmklmnb

@klmklmnb klmklmnb commented Jul 2, 2026

Copy link
Copy Markdown

What

Adds a CODEX_PLUGIN_CC_ARGS environment variable. When set, its value is tokenized (shell-style, reusing the existing splitRawArgumentString) and prepended to every codex invocation the plugin makes:

  • the codex app-server runtime spawn (app-server.mjs), which covers both direct and broker modes
  • the availability checks codex --version and codex app-server --help (codex.mjs)

Example:

export CODEX_PLUGIN_CC_ARGS='-c model_provider=litellm'
# plugin now runs: codex -c model_provider=litellm app-server

Why

Closes #418. Previously only --model/--effort were forwarded and the app-server was always spawned bare, so there was no way to pass Codex global overrides (custom model_provider, --profile, arbitrary -c key=value) without editing config.toml. This makes it opt-in via a single env var, reusing Codex's own config-override surface.

Changes

  • scripts/lib/args.mjs: new getCodexPassthroughArgs(env) + CODEX_PLUGIN_ARGS_ENV constant
  • scripts/lib/app-server.mjs: prepend args to the codex app-server spawn (reads the same env passed to the child)
  • scripts/lib/codex.mjs: prepend args to the availability checks
  • tests/fake-codex-fixture.mjs: tolerate leading global flags before the subcommand; record boot argv
  • tests/args.test.mjs (new): unit tests for the parser
  • tests/runtime.test.mjs: e2e test asserting the args reach the codex process
  • README.md: documents the variable, quoting, and the shared-runtime caveat

Testing

npm test — 95/95 passing locally.

Notes

  • Args are prepended (before the subcommand), the canonical position for Codex global flags like -c / --profile.
  • Read when a Codex runtime starts; if a shared runtime is already active for the session, a fresh session is needed for new values to take effect (documented in the README).

Add a CODEX_PLUGIN_CC_ARGS environment variable. When set, its value is
tokenized (shell-style) and prepended to every codex invocation the plugin
makes: the app-server runtime spawn and the availability checks.

This lets users force codex global overrides (e.g. a custom provider via
`-c model_provider=...` or `--profile`) without editing config.toml, and
without a per-command flag. Previously only --model/--effort were forwarded
and the app-server was always spawned as `codex app-server`.

- args.mjs: getCodexPassthroughArgs(env) + CODEX_PLUGIN_ARGS_ENV
- app-server.mjs: prepend args to the `codex app-server` spawn
- codex.mjs: prepend args to `--version` / `app-server --help` checks
- fake codex fixture: tolerate leading global flags, record boot argv
- tests: unit tests for the parser + e2e passthrough assertion
- README: document the variable

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@klmklmnb
klmklmnb requested a review from a team July 2, 2026 11:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da5b881948

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/codex/scripts/lib/args.mjs Resolved
klmklmnb pushed a commit to klmklmnb/codex-plugin-cc that referenced this pull request Jul 3, 2026
splitRawArgumentString treated `\` as an escape even inside single quotes,
so CODEX_PLUGIN_CC_ARGS values like `--add-dir 'C:\work\repo'` were mangled
into `C:workrepo`. Handle single-quote context before the escape check so
single-quoted content is literal (POSIX semantics); double-quote escaping
is unchanged.

Addresses the Codex review comment on openai#419.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6f1ab7714

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/codex/mcp/lib/tools.mjs Resolved
Comment thread plugins/codex/scripts/lib/args.mjs Resolved
splitRawArgumentString treated `\` as an escape regardless of quote context,
so CODEX_PLUGIN_CC_ARGS values with backslashes were mangled — e.g.
`--add-dir 'C:\work\repo'` and `--add-dir "C:\work\repo"` both became
`C:workrepo`.

Apply POSIX quoting semantics:
- single quotes: everything literal, including backslashes
- double quotes: backslash only escapes " \ $ ` ; before any other char it
  stays literal (so `"a\"b"` still yields `a"b`)

Adds unit tests for single/double-quote backslash handling.
Addresses the Codex review comments on openai#419.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@klmklmnb
klmklmnb force-pushed the feat/codex-plugin-cc-args branch from f6f1ab7 to 2f75ad1 Compare July 3, 2026 02:39
@klmklmnb

klmklmnb commented Jul 3, 2026

Copy link
Copy Markdown
Author

@codex review

The parsing feedback (single- and double-quote backslash handling) is addressed in 2f75ad1, and the unrelated plugins/codex/mcp/** + tests/mcp-server.test.mjs files that were accidentally swept into an earlier commit have been removed via force-push. Please re-review the current head.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 2f75ad1621

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kvokka

kvokka commented Aug 21, 2026

Copy link
Copy Markdown

@klmklmnb Any chance of moving forward with it?

Codex does not support plugins with project scopes (and it's a mess for a while) - openai/codex#18115

This PR will help to fit everything in for this case too, sending something like CODEX_PLUGIN_CC_ARGS="-p foo"

Thank you

Copy link
Copy Markdown
Author

@codex review

All existing review threads are resolved. Please review the current head (2f75ad1621af9ed446bba3890b591be01767d10f) and report any remaining actionable issues.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f75ad1621

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread README.md Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab10b9ce78

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread plugins/codex/scripts/lib/process.mjs Resolved
…args

# Conflicts:
#	plugins/codex/scripts/lib/process.mjs
@klmklmnb

Copy link
Copy Markdown
Author

@codex review

Addressed the two outstanding review comments in ab10b9c and merged the latest main in 8a4764a. All review threads are resolved; please re-review the current head.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 8a4764a2aa

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@klmklmnb

Copy link
Copy Markdown
Author

@codex review

The follow-up percent-expansion finding is fixed in a4d25dab7e4136ad18962bf62622533382d83e2b. All review threads are resolved; please review the current head.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4d25da35d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread plugins/codex/scripts/lib/process.mjs Resolved
@klmklmnb

Copy link
Copy Markdown
Author

@codex review

The PowerShell-shell finding is fixed in 433b846b5973b84aeafef395d80b305c0729c4c6. All review threads are resolved; please review the current head.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 433b846e41

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@klmklmnb

Copy link
Copy Markdown
Author

@klmklmnb Any chance of moving forward with it?

Codex does not support plugins with project scopes (and it's a mess for a while) - openai/codex#18115

This PR will help to fit everything in for this case too, sending something like CODEX_PLUGIN_CC_ARGS="-p foo"

Thank you

@kvokka Thanks for the nudge! I’ve now addressed all code review issues, including the Windows/PowerShell handling. The PR is ready for another look and should support your CODEX_PLUGIN_CC_ARGS="-p foo" use case. Appreciate your patience!

@kvokka

kvokka commented Aug 24, 2026

Copy link
Copy Markdown

Thank you so much for such a quick response and for refreshing the PR. Hope that will be merged soon

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.

Feature: forward extra args (custom model_provider / profile) to every codex launch

3 participants