Skip to content

[DO NOT MERGE] feat: Check Nix package is working as part of the CI workflow #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d60f350
feat: add support for -c/--config to override individual config items…
bolinfest May 28, 2025
ae1a83f
feat: introduce CellWidget trait (#1148)
bolinfest May 28, 2025
392fdd7
fix: honor RUST_LOG in mcp-client CLI and default to DEBUG (#1149)
bolinfest May 29, 2025
25a9949
fix: ensure inputSchema for MCP tool always has "properties" field wh…
bolinfest May 29, 2025
a768a6a
fix: introduce ResponseInputItem::McpToolCallOutput variant (#1151)
bolinfest May 29, 2025
a32d305
fix: update UI treatment of slash command menu to match that of the T…
bolinfest May 29, 2025
8c1902b
chore: update GitHub workflow for native artifacts for npm release (#…
bolinfest May 29, 2025
92957c4
fix: update justfile to facilitate running CLIs from source and forma…
bolinfest May 29, 2025
828e206
fix(codex-rs): use codex-mini-latest as default (#1164)
fouad-openai May 29, 2025
bdfa95e
docs: split the config-related portion of codex-rs/README.md into its…
bolinfest May 29, 2025
a0239c3
fix: enable `set positional-arguments` in justfile (#1169)
bolinfest May 30, 2025
baa92f3
feat: initial import of experimental GitHub Action (#1170)
bolinfest May 30, 2025
8676185
fix: update outdated repo setup in codex.yml (#1171)
bolinfest May 30, 2025
0f40ef5
fix: missed a step in #1171 for codex.yml (#1172)
bolinfest May 30, 2025
e207f20
fix: add extra debugging to GitHub Action (#1173)
bolinfest May 30, 2025
1bf8205
fix: introduce `create_tools_json()` and share it with chat_completio…
bolinfest May 30, 2025
ae743d5
feat: for `codex exec`, if PROMPT is not specified, read from stdin i…
bolinfest May 30, 2025
cf1d070
feat: grab-bag of improvements to `exec` output (#1179)
bolinfest May 30, 2025
4f3d294
feat: dim the timestamp in the exec output (#1180)
bolinfest May 30, 2025
e81327e
feat: add hide_agent_reasoning config option (#1181)
bolinfest May 31, 2025
1159eaf
feat: show the version when starting Codex (#1182)
bolinfest May 31, 2025
fccf5f3
fix: disable agent reasoning output by default in the GitHub Action (…
bolinfest May 31, 2025
1410ae9
fix: set `--config hide_agent_reasoning=true` in the GitHub Action (#…
bolinfest May 31, 2025
7896b10
chore: update the WORKFLOW_URL in install_native_deps.sh to the lates…
bolinfest May 31, 2025
e40f86b
chore: logging cleanup (#1196)
bolinfest Jun 2, 2025
d7245cb
fix: chat completions API now also passes tools along (#1167)
bolinfest Jun 2, 2025
0f3cc8f
feat: make reasoning effort/summaries configurable (#1199)
bolinfest Jun 2, 2025
5a5aa89
chore: replace regex with regex-lite, where appropriate (#1200)
bolinfest Jun 3, 2025
6fcc528
fix: provide tolerance for apply_patch tool (#993)
bolinfest Jun 3, 2025
c6fcec5
fix: always send full instructions when using the Responses API (#1207)
bolinfest Jun 3, 2025
a67a67f
codex-rs: make tool calls prettier (#1211)
rgwood-dd Jun 3, 2025
515b633
feat: add support for login with ChatGPT (#1212)
bolinfest Jun 4, 2025
9db53b3
fix: support arm64 build for Linux (#1225)
bolinfest Jun 6, 2025
c02d25f
fix: include codex-linux-sandbox-aarch64-unknown-linux-musl in the se…
bolinfest Jun 6, 2025
77b017f
fix: truncate auth.json file before rewriting it (#1231)
bolinfest Jun 6, 2025
2d52460
fix: use aarch64-unknown-linux-musl instead of aarch64-unknown-linux-…
bolinfest Jun 6, 2025
a80240c
chore: ensure next Node.js release includes musl binaries for arm64 L…
bolinfest Jun 6, 2025
029f39b
feat: port maybeRedeemCredits() from get-api-key.tsx to login_with_ch…
bolinfest Jun 6, 2025
345a385
codex-rs: Rename `/clear` to `/new`, make it start an entirely new ch…
rgwood-dd Jun 6, 2025
b73426c
docs: update codex-rs/README.md to list new features in the Rust CLI …
bolinfest Jun 7, 2025
6a16dff
feat: Check Nix package is working as part of the CI workflow
sestrella May 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
# enable 'universe' because musl-tools & clang live there
RUN apt-get update && \
apt-get install -y --no-install-recommends \
software-properties-common && \
add-apt-repository --yes universe

# now install build deps
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential curl git ca-certificates \
pkg-config clang musl-tools libssl-dev && \
rm -rf /var/lib/apt/lists/*

# non-root dev user
ARG USER=dev
ARG UID=1000
RUN useradd -m -u $UID $USER
USER $USER

# install Rust + musl target as dev user
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal && \
~/.cargo/bin/rustup target add aarch64-unknown-linux-musl

ENV PATH="/home/${USER}/.cargo/bin:${PATH}"

WORKDIR /workspace
30 changes: 30 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Containerized Development

We provide the following options to facilitate Codex development in a container. This is particularly useful for verifying the Linux build when working on a macOS host.

## Docker

To build the Docker image locally for x64 and then run it with the repo mounted under `/workspace`:

```shell
CODEX_DOCKER_IMAGE_NAME=codex-linux-dev
docker build --platform=linux/amd64 -t "$CODEX_DOCKER_IMAGE_NAME" ./.devcontainer
docker run --platform=linux/amd64 --rm -it -e CARGO_TARGET_DIR=/workspace/codex-rs/target-amd64 -v "$PWD":/workspace -w /workspace/codex-rs "$CODEX_DOCKER_IMAGE_NAME"
```

Note that `/workspace/target` will contain the binaries built for your host platform, so we include `-e CARGO_TARGET_DIR=/workspace/codex-rs/target-amd64` in the `docker run` command so that the binaries built inside your container are written to a separate directory.

For arm64, specify `--platform=linux/amd64` instead for both `docker build` and `docker run`.

Currently, the `Dockerfile` works for both x64 and arm64 Linux, though you need to run `rustup target add x86_64-unknown-linux-musl` yourself to install the musl toolchain for x64.

## VS Code

VS Code recognizes the `devcontainer.json` file and gives you the option to develop Codex in a container. Currently, `devcontainer.json` builds and runs the `arm64` flavor of the container.

From the integrated terminal in VS Code, you can build either flavor of the `arm64` build (GNU or musl):

```shell
cargo build --target aarch64-unknown-linux-musl
cargo build --target aarch64-unknown-linux-gnu
```
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "Codex",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"platform": "linux/arm64"
},

/* Force VS Code to run the container as arm64 in
case your host is x86 (or vice-versa). */
"runArgs": ["--platform=linux/arm64"],

"containerEnv": {
"RUST_BACKTRACE": "1",
"CARGO_TARGET_DIR": "${containerWorkspaceFolder}/codex-rs/target-arm64"
},

"remoteUser": "dev",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash"
},
"extensions": [
"rust-lang.rust-analyzer"
],
}
}
}
1 change: 1 addition & 0 deletions .github/actions/codex/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
8 changes: 8 additions & 0 deletions .github/actions/codex/.prettierrc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
printWidth = 80
quoteProps = "consistent"
semi = true
tabWidth = 2
trailingComma = "all"

# Preserve existing behavior for markdown/text wrapping.
proseWrap = "preserve"
140 changes: 140 additions & 0 deletions .github/actions/codex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# openai/codex-action

`openai/codex-action` is a GitHub Action that facilitates the use of [Codex](https://github.com/openai/codex) on GitHub issues and pull requests. Using the action, associate **labels** to run Codex with the appropriate prompt for the given context. Codex will respond by posting comments or creating PRs, whichever you specify!

Here is a sample workflow that uses `openai/codex-action`:

```yaml
name: Codex

on:
issues:
types: [opened, labeled]
pull_request:
branches: [main]
types: [labeled]

jobs:
codex:
if: ... # optional, but can be effective in conserving CI resources
runs-on: ubuntu-latest
# TODO(mbolin): Need to verify if/when `write` is necessary.
permissions:
contents: write
issues: write
pull-requests: write
steps:
# By default, Codex runs network disabled using --full-auto, so perform
# any setup that requires network (such as installing dependencies)
# before openai/codex-action.
- name: Checkout repository
uses: actions/checkout@v4

- name: Run Codex
uses: openai/codex-action@latest
with:
openai_api_key: ${{ secrets.CODEX_OPENAI_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
```

See sample usage in [`codex.yml`](../../workflows/codex.yml).

## Triggering the Action

Using the sample workflow above, we have:

```yaml
on:
issues:
types: [opened, labeled]
pull_request:
branches: [main]
types: [labeled]
```

which means our workflow will be triggered when any of the following events occur:

- a label is added to an issue
- a label is added to a pull request against the `main` branch

### Label-Based Triggers

To define a GitHub label that should trigger Codex, create a file named `.github/codex/labels/LABEL-NAME.md` in your repository where `LABEL-NAME` is the name of the label. The content of the file is the prompt template to use when the label is added (see more on [Prompt Template Variables](#prompt-template-variables) below).

For example, if the file `.github/codex/labels/codex-review.md` exists, then:

- Adding the `codex-review` label will trigger the workflow containing the `openai/codex-action` GitHub Action.
- When `openai/codex-action` starts, it will replace the `codex-review` label with `codex-review-in-progress`.
- When `openai/codex-action` is finished, it will replace the `codex-review-in-progress` label with `codex-review-completed`.

If Codex sees that either `codex-review-in-progress` or `codex-review-completed` is already present, it will not perform the action.

As determined by the [default config](./src/default-label-config.ts), Codex will act on the following labels by default:

- Adding the `codex-review` label to a pull request will have Codex review the PR and add it to the PR as a comment.
- Adding the `codex-triage` label to an issue will have Codex investigate the issue and report its findings as a comment.
- Adding the `codex-issue-fix` label to an issue will have Codex attempt to fix the issue and create a PR wit the fix, if any.

## Action Inputs

The `openai/codex-action` GitHub Action takes the following inputs

### `openai_api_key` (required)

Set your `OPENAI_API_KEY` as a [repository secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions). See **Secrets and varaibles** then **Actions** in the settings for your GitHub repo.

Note that the secret name does not have to be `OPENAI_API_KEY`. For example, you might want to name it `CODEX_OPENAI_API_KEY` and then configure it on `openai/codex-action` as follows:

```yaml
openai_api_key: ${{ secrets.CODEX_OPENAI_API_KEY }}
```

### `github_token` (required)

This is required so that Codex can post a comment or create a PR. Set this value on the action as follows:

```yaml
github_token: ${{ secrets.GITHUB_TOKEN }}
```

### `codex_args`

A whitespace-delimited list of arguments to pass to Codex. Defaults to `--full-auto`, but if you want to override the default model to use `o3`:

```yaml
codex_args: "--full-auto --model o3"
```

For more complex configurations, use the `codex_home` input.

### `codex_home`

If set, the value to use for the `$CODEX_HOME` environment variable when running Codex. As explained [in the docs](https://github.com/openai/codex/tree/main/codex-rs#readme), this folder can contain the `config.toml` to configure Codex, custom instructions, and log files.

This should be a relative path within your repo.

## Prompt Template Variables

As shown above, `"prompt"` and `"promptPath"` are used to define prompt templates that will be populated and passed to Codex in response to certain events. All template variables are of the form `{CODEX_ACTION_...}` and the supported values are defined below.

### `CODEX_ACTION_ISSUE_TITLE`

If the action was triggered on a GitHub issue, this is the issue title.

Specifically it is read as the `.issue.title` from the `$GITHUB_EVENT_PATH`.

### `CODEX_ACTION_ISSUE_BODY`

If the action was triggered on a GitHub issue, this is the issue body.

Specifically it is read as the `.issue.body` from the `$GITHUB_EVENT_PATH`.

### `CODEX_ACTION_GITHUB_EVENT_PATH`

The value of the `$GITHUB_EVENT_PATH` environment variable, which is the path to the file that contains the JSON payload for the event that triggered the workflow. Codex can use `jq` to read only the fields of interest from this file.

### `CODEX_ACTION_PR_DIFF`

If the action was triggered on a pull request, this is the diff between the base and head commits of the PR. It is the output from `git diff`.

Note that the content of the diff could be quite large, so is generally safer to point Codex at `CODEX_ACTION_GITHUB_EVENT_PATH` and let it decide how it wants to explore the change.
124 changes: 124 additions & 0 deletions .github/actions/codex/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: "Codex [reusable action]"
description: "A reusable action that runs a Codex model."

inputs:
openai_api_key:
description: "The value to use as the OPENAI_API_KEY environment variable when running Codex."
required: true
trigger_phrase:
description: "Text to trigger Codex from a PR/issue body or comment."
required: false
default: ""
github_token:
description: "Token so Codex can comment on the PR or issue."
required: true
codex_args:
description: "A whitespace-delimited list of arguments to pass to Codex. Due to limitations in YAML, arguments with spaces are not supported. For more complex configurations, use the `codex_home` input."
required: false
default: "--config hide_agent_reasoning=true --full-auto"
codex_home:
description: "Value to use as the CODEX_HOME environment variable when running Codex."
required: false
codex_release_tag:
description: "The release tag of the Codex model to run."
required: false
default: "codex-rs-ca8e97fcbcb991e542b8689f2d4eab9d30c399d6-1-rust-v0.0.2505302325"

runs:
using: "composite"
steps:
# Do this in Bash so we do not even bother to install Bun if the sender does
# not have write access to the repo.
- name: Verify user has write access to the repo.
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
PERMISSION=$(gh api \
"/repos/${GITHUB_REPOSITORY}/collaborators/${{ github.event.sender.login }}/permission" \
| jq -r '.permission')
if [[ "$PERMISSION" != "admin" && "$PERMISSION" != "write" ]]; then
exit 1
fi
- name: Download Codex
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
# Determine OS/arch and corresponding Codex artifact name.
uname_s=$(uname -s)
uname_m=$(uname -m)
case "$uname_s" in
Linux*) os="linux" ;;
Darwin*) os="apple-darwin" ;;
*) echo "Unsupported operating system: $uname_s"; exit 1 ;;
esac
case "$uname_m" in
x86_64*) arch="x86_64" ;;
arm64*|aarch64*) arch="aarch64" ;;
*) echo "Unsupported architecture: $uname_m"; exit 1 ;;
esac
# linux builds differentiate between musl and gnu.
if [[ "$os" == "linux" ]]; then
if [[ "$arch" == "x86_64" ]]; then
triple="${arch}-unknown-linux-musl"
else
# Only other supported linux build is aarch64 gnu.
triple="${arch}-unknown-linux-gnu"
fi
else
# macOS
triple="${arch}-apple-darwin"
fi
# Note that if we start baking version numbers into the artifact name,
# we will need to update this action.yml file to match.
artifact="codex-exec-${triple}.tar.gz"
gh release download ${{ inputs.codex_release_tag }} --repo openai/codex \
--pattern "$artifact" --output - \
| tar xzO > /usr/local/bin/codex-exec
chmod +x /usr/local/bin/codex-exec
# Display Codex version to confirm binary integrity; ensure we point it
# at the checked-out repository via --cd so that any subsequent commands
# use the correct working directory.
codex-exec --cd "$GITHUB_WORKSPACE" --version
- name: Install Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.2.11

- name: Install dependencies
shell: bash
run: |
cd ${{ github.action_path }}
bun install --production
- name: Run Codex
shell: bash
run: bun run ${{ github.action_path }}/src/main.ts
# Process args plus environment variables often have a max of 128 KiB,
# so we should fit within that limit?
env:
INPUT_CODEX_ARGS: ${{ inputs.codex_args || '' }}
INPUT_CODEX_HOME: ${{ inputs.codex_home || ''}}
INPUT_TRIGGER_PHRASE: ${{ inputs.trigger_phrase || '' }}
OPENAI_API_KEY: ${{ inputs.openai_api_key }}
GITHUB_TOKEN: ${{ inputs.github_token }}
GITHUB_EVENT_ACTION: ${{ github.event.action || '' }}
GITHUB_EVENT_LABEL_NAME: ${{ github.event.label.name || '' }}
GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number || '' }}
GITHUB_EVENT_ISSUE_BODY: ${{ github.event.issue.body || '' }}
GITHUB_EVENT_REVIEW_BODY: ${{ github.event.review.body || '' }}
GITHUB_EVENT_COMMENT_BODY: ${{ github.event.comment.body || '' }}
Loading
Loading