Skip to content

feat: add /codex:diff-review, /codex:watch, /codex:config and codex:optimize#146

Open
durgeshmahajann wants to merge 1 commit intoopenai:mainfrom
durgeshmahajann:feat/new-features
Open

feat: add /codex:diff-review, /codex:watch, /codex:config and codex:optimize#146
durgeshmahajann wants to merge 1 commit intoopenai:mainfrom
durgeshmahajann:feat/new-features

Conversation

@durgeshmahajann
Copy link
Copy Markdown

What

Adds four new features on top of the upstream plugin:

  • /codex:diff-review — runs Codex review + generates draft PR description, saves to file
  • /codex:watch — auto-queues a Codex lint pass after every file Claude writes
  • /codex:config — read/write .codex/config.toml without manual editing
  • codex:optimize — performance-focused Codex review agent

Why

The original plugin had no way to generate PR descriptions automatically,
no continuous feedback during a Claude session, and no easy way to
change Codex config without knowing TOML syntax.

How

  • Added post-tool-use-watch-hook.mjs — new PostToolUse hook
  • Added lib/toml.mjs — zero-dependency TOML reader/writer
  • Added handleDiffReview(), handleWatch(), handleConfig() in codex-companion.mjs
  • No new npm dependencies. All features are opt-in.

Testing

All existing tests pass unchanged. New features are off by default.

@durgeshmahajann durgeshmahajann requested a review from a team April 4, 2026 20:06
Copy link
Copy Markdown

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

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: d01920d8aa

ℹ️ 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 on lines +50 to +52
{
"codex:optimize": "scripts/codex-companion.mjs"
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep hooks.json as a single valid JSON object

The file now contains two top-level JSON objects, so hooks.json is not parseable JSON anymore. Any loader that reads this hooks config will fail before registering hooks, which can disable all hook behavior (including existing SessionStart/SessionEnd/Stop hooks), not just the new watch hook.

Useful? React with 👍 / 👎.

Comment on lines +1202 to +1205
if (result.stdout) {
try {
// The prompt asks Codex to embed pr_description in the JSON output
const parsed = JSON.parse(result.stdout);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Parse pr_description from the actual review result payload

executeReviewRun() returns structured data under payload/rendered, but this branch reads result.stdout, which is never set by that function. As a result, prDescription is always null and the command always falls back to the generic template instead of using Codex-generated PR text.

Useful? React with 👍 / 👎.

Comment on lines +1295 to +1298
return {
...result,
stdout: (result.stdout ?? "") + "\n" + footer
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Append the diff-review footer to rendered output

This modifies stdout, but foreground execution prints and stores execution.rendered, not execution.stdout (see runForegroundCommand/runTrackedJob usage). In practice the “PR description written to …” footer is dropped, so users are not told where the generated file was saved.

Useful? React with 👍 / 👎.

Comment on lines +1352 to +1354
case "optimize":
console.log("⚡ Optimize feature working!");
break;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Implement optimize subcommand instead of placeholder output

The new optimize branch only prints a static string and exits, so invoking the advertised optimize command does not run any Codex analysis or job flow. This makes the feature effectively non-functional for users who call the subcommand.

Useful? React with 👍 / 👎.

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.

1 participant