Skip to content

Commit 7f8dd7f

Browse files
authored
Merge branch 'main' into add-github-action-for-nix
2 parents c720581 + 7e3a272 commit 7f8dd7f

File tree

235 files changed

+13735
-3978
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+13735
-3978
lines changed

.github/ISSUE_TEMPLATE/4-feature-request.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: 🎁 Feature Request
22
description: Propose a new feature for Codex
33
labels:
44
- enhancement
5-
- needs triage
65
body:
76
- type: markdown
87
attributes:
@@ -19,11 +18,6 @@ body:
1918
label: What feature would you like to see?
2019
validations:
2120
required: true
22-
- type: textarea
23-
id: author
24-
attributes:
25-
label: Are you interested in implementing this feature?
26-
description: Please wait for acknowledgement before implementing or opening a PR.
2721
- type: textarea
2822
id: notes
2923
attributes:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
You are an assistant that triages new GitHub issues by identifying potential duplicates.
2+
3+
You will receive the following JSON files located in the current working directory:
4+
- `codex-current-issue.json`: JSON object describing the newly created issue (fields: number, title, body).
5+
- `codex-existing-issues.json`: JSON array of recent issues (each element includes number, title, body, createdAt).
6+
7+
Instructions:
8+
- Load both files as JSON and review their contents carefully. The codex-existing-issues.json file is large, ensure you explore all of it.
9+
- Compare the current issue against the existing issues to find up to five that appear to describe the same underlying problem or request.
10+
- Only consider an issue a potential duplicate if there is a clear overlap in symptoms, feature requests, reproduction steps, or error messages.
11+
- Prioritize newer issues when similarity is comparable.
12+
- Ignore pull requests and issues whose similarity is tenuous.
13+
- When unsure, prefer returning fewer matches.
14+
15+
Output requirements:
16+
- Respond with a JSON array of issue numbers (integers), ordered from most likely duplicate to least.
17+
- Include at most five numbers.
18+
- If you find no plausible duplicates, respond with `[]`.

.github/prompts/issue-labeler.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
You are an assistant that reviews GitHub issues for the repository.
2+
3+
Your job is to choose the most appropriate existing labels for the issue described later in this prompt.
4+
Follow these rules:
5+
- Only pick labels out of the list below.
6+
- Prefer a small set of precise labels over many broad ones.
7+
- If none of the labels fit, respond with an empty JSON array: []
8+
- Output must be a JSON array of label names (strings) with no additional commentary.
9+
10+
Labels to apply:
11+
1. bug — Reproducible defects in Codex products (CLI, VS Code extension, web, auth).
12+
2. enhancement — Feature requests or usability improvements that ask for new capabilities, better ergonomics, or quality-of-life tweaks.
13+
3. extension — VS Code (or other IDE) extension-specific issues.
14+
4. windows-os — Bugs or friction specific to Windows environments (PowerShell behavior, path handling, copy/paste, OS-specific auth or tooling failures).
15+
5. mcp — Topics involving Model Context Protocol servers/clients.
16+
6. codex-web — Issues targeting the Codex web UI/Cloud experience.
17+
8. azure — Problems or requests tied to Azure OpenAI deployments.
18+
9. documentation — Updates or corrections needed in docs/README/config references (broken links, missing examples, outdated keys, clarification requests).
19+
10. model-behavior — Undesirable LLM behavior: forgetting goals, refusing work, hallucinating environment details, quota misreports, or other reasoning/performance anomalies.
20+
21+
Issue information is available in environment variables:
22+
23+
ISSUE_NUMBER
24+
ISSUE_TITLE
25+
ISSUE_BODY
26+
REPO_FULL_NAME

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ jobs:
6060
run: ./scripts/asciicheck.py codex-cli/README.md
6161
- name: Check codex-cli/README ToC
6262
run: python3 scripts/readme_toc.py codex-cli/README.md
63+
64+
- name: Prettier (run `pnpm run format:fix` to fix)
65+
run: pnpm run format
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Issue Deduplicator
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
- labeled
8+
9+
jobs:
10+
gather-duplicates:
11+
name: Identify potential duplicates
12+
if: ${{ github.event.action == 'opened' || (github.event.action == 'labeled' && github.event.label.name == 'codex-deduplicate') }}
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
outputs:
17+
codex_output: ${{ steps.codex.outputs.final-message }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Prepare Codex inputs
22+
env:
23+
GH_TOKEN: ${{ github.token }}
24+
run: |
25+
set -eo pipefail
26+
27+
CURRENT_ISSUE_FILE=codex-current-issue.json
28+
EXISTING_ISSUES_FILE=codex-existing-issues.json
29+
30+
gh issue list --repo "${{ github.repository }}" \
31+
--json number,title,body,createdAt \
32+
--limit 1000 \
33+
--state all \
34+
--search "sort:created-desc" \
35+
| jq '.' \
36+
> "$EXISTING_ISSUES_FILE"
37+
38+
gh issue view "${{ github.event.issue.number }}" \
39+
--repo "${{ github.repository }}" \
40+
--json number,title,body \
41+
| jq '.' \
42+
> "$CURRENT_ISSUE_FILE"
43+
44+
- id: codex
45+
uses: openai/codex-action@main
46+
with:
47+
openai-api-key: ${{ secrets.CODEX_OPENAI_API_KEY }}
48+
allow-users: "*"
49+
model: gpt-5
50+
prompt: |
51+
You are an assistant that triages new GitHub issues by identifying potential duplicates.
52+
53+
You will receive the following JSON files located in the current working directory:
54+
- `codex-current-issue.json`: JSON object describing the newly created issue (fields: number, title, body).
55+
- `codex-existing-issues.json`: JSON array of recent issues (each element includes number, title, body, createdAt).
56+
57+
Instructions:
58+
- Compare the current issue against the existing issues to find up to five that appear to describe the same underlying problem or request.
59+
- Focus on the underlying intent and context of each issue—such as reported symptoms, feature requests, reproduction steps, or error messages—rather than relying solely on string similarity or synthetic metrics.
60+
- After your analysis, validate your results in 1-2 lines explaining your decision to return the selected matches.
61+
- When unsure, prefer returning fewer matches.
62+
- Include at most five numbers.
63+
64+
output-schema: |
65+
{
66+
"type": "object",
67+
"properties": {
68+
"issues": {
69+
"type": "array",
70+
"items": {
71+
"type": "string"
72+
}
73+
},
74+
"reason": { "type": "string" }
75+
},
76+
"required": ["issues", "reason"],
77+
"additionalProperties": false
78+
}
79+
80+
comment-on-issue:
81+
name: Comment with potential duplicates
82+
needs: gather-duplicates
83+
if: ${{ needs.gather-duplicates.result != 'skipped' }}
84+
runs-on: ubuntu-latest
85+
permissions:
86+
contents: read
87+
issues: write
88+
steps:
89+
- name: Comment on issue
90+
uses: actions/github-script@v7
91+
env:
92+
CODEX_OUTPUT: ${{ needs.gather-duplicates.outputs.codex_output }}
93+
with:
94+
github-token: ${{ github.token }}
95+
script: |
96+
const raw = process.env.CODEX_OUTPUT ?? '';
97+
let parsed;
98+
try {
99+
parsed = JSON.parse(raw);
100+
} catch (error) {
101+
core.info(`Codex output was not valid JSON. Raw output: ${raw}`);
102+
core.info(`Parse error: ${error.message}`);
103+
return;
104+
}
105+
106+
const issues = Array.isArray(parsed?.issues) ? parsed.issues : [];
107+
const currentIssueNumber = String(context.payload.issue.number);
108+
109+
console.log(`Current issue number: ${currentIssueNumber}`);
110+
console.log(issues);
111+
112+
const filteredIssues = issues.filter((value) => String(value) !== currentIssueNumber);
113+
114+
if (filteredIssues.length === 0) {
115+
core.info('Codex reported no potential duplicates.');
116+
return;
117+
}
118+
119+
const lines = [
120+
'Potential duplicates detected. Please review them and close your issue if it is a duplicate.',
121+
'',
122+
...filteredIssues.map((value) => `- #${String(value)}`),
123+
'',
124+
'*Powered by [Codex Action](https://github.com/openai/codex-action)*'];
125+
126+
await github.rest.issues.createComment({
127+
owner: context.repo.owner,
128+
repo: context.repo.repo,
129+
issue_number: context.payload.issue.number,
130+
body: lines.join("\n"),
131+
});
132+
133+
- name: Remove codex-deduplicate label
134+
if: ${{ always() && github.event.action == 'labeled' && github.event.label.name == 'codex-deduplicate' }}
135+
env:
136+
GH_TOKEN: ${{ github.token }}
137+
GH_REPO: ${{ github.repository }}
138+
run: |
139+
gh issue edit "${{ github.event.issue.number }}" --remove-label codex-deduplicate || true
140+
echo "Attempted to remove label: codex-deduplicate"
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Issue Labeler
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
- labeled
8+
9+
jobs:
10+
gather-labels:
11+
name: Generate label suggestions
12+
if: ${{ github.event.action == 'opened' || (github.event.action == 'labeled' && github.event.label.name == 'codex-label') }}
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
outputs:
17+
codex_output: ${{ steps.codex.outputs.final-message }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- id: codex
22+
uses: openai/codex-action@main
23+
with:
24+
openai-api-key: ${{ secrets.CODEX_OPENAI_API_KEY }}
25+
allow-users: "*"
26+
prompt: |
27+
You are an assistant that reviews GitHub issues for the repository.
28+
29+
Your job is to choose the most appropriate existing labels for the issue described later in this prompt.
30+
Follow these rules:
31+
- Only pick labels out of the list below.
32+
- Prefer a small set of precise labels over many broad ones.
33+
34+
Labels to apply:
35+
1. bug — Reproducible defects in Codex products (CLI, VS Code extension, web, auth).
36+
2. enhancement — Feature requests or usability improvements that ask for new capabilities, better ergonomics, or quality-of-life tweaks.
37+
3. extension — VS Code (or other IDE) extension-specific issues.
38+
4. windows-os — Bugs or friction specific to Windows environments (always when PowerShell is mentioned, path handling, copy/paste, OS-specific auth or tooling failures).
39+
5. mcp — Topics involving Model Context Protocol servers/clients.
40+
6. codex-web — Issues targeting the Codex web UI/Cloud experience.
41+
8. azure — Problems or requests tied to Azure OpenAI deployments.
42+
9. documentation — Updates or corrections needed in docs/README/config references (broken links, missing examples, outdated keys, clarification requests).
43+
10. model-behavior — Undesirable LLM behavior: forgetting goals, refusing work, hallucinating environment details, quota misreports, or other reasoning/performance anomalies.
44+
45+
Issue number: ${{ github.event.issue.number }}
46+
47+
Issue title:
48+
${{ github.event.issue.title }}
49+
50+
Issue body:
51+
${{ github.event.issue.body }}
52+
53+
Repository full name:
54+
${{ github.repository }}
55+
56+
output-schema: |
57+
{
58+
"type": "object",
59+
"properties": {
60+
"labels": {
61+
"type": "array",
62+
"items": {
63+
"type": "string"
64+
}
65+
}
66+
},
67+
"required": ["labels"],
68+
"additionalProperties": false
69+
}
70+
71+
apply-labels:
72+
name: Apply labels from Codex output
73+
needs: gather-labels
74+
if: ${{ needs.gather-labels.result != 'skipped' }}
75+
runs-on: ubuntu-latest
76+
permissions:
77+
contents: read
78+
issues: write
79+
env:
80+
GH_TOKEN: ${{ github.token }}
81+
GH_REPO: ${{ github.repository }}
82+
ISSUE_NUMBER: ${{ github.event.issue.number }}
83+
CODEX_OUTPUT: ${{ needs.gather-labels.outputs.codex_output }}
84+
steps:
85+
- name: Apply labels
86+
run: |
87+
json=${CODEX_OUTPUT//$'\r'/}
88+
if [ -z "$json" ]; then
89+
echo "Codex produced no output. Skipping label application."
90+
exit 0
91+
fi
92+
93+
if ! printf '%s' "$json" | jq -e 'type == "object" and (.labels | type == "array")' >/dev/null 2>&1; then
94+
echo "Codex output did not include a labels array. Raw output: $json"
95+
exit 0
96+
fi
97+
98+
labels=$(printf '%s' "$json" | jq -r '.labels[] | tostring')
99+
if [ -z "$labels" ]; then
100+
echo "Codex returned an empty array. Nothing to do."
101+
exit 0
102+
fi
103+
104+
cmd=(gh issue edit "$ISSUE_NUMBER")
105+
while IFS= read -r label; do
106+
cmd+=(--add-label "$label")
107+
done <<< "$labels"
108+
109+
"${cmd[@]}" || true
110+
111+
- name: Remove codex-label trigger
112+
if: ${{ always() && github.event.action == 'labeled' && github.event.label.name == 'codex-label' }}
113+
run: |
114+
gh issue edit "$ISSUE_NUMBER" --remove-label codex-label || true
115+
echo "Attempted to remove label: codex-label"

AGENTS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ In the codex-rs folder where the rust code lives:
88
- Never add or modify any code related to `CODEX_SANDBOX_NETWORK_DISABLED_ENV_VAR` or `CODEX_SANDBOX_ENV_VAR`.
99
- You operate in a sandbox where `CODEX_SANDBOX_NETWORK_DISABLED=1` will be set whenever you use the `shell` tool. Any existing code that uses `CODEX_SANDBOX_NETWORK_DISABLED_ENV_VAR` was authored with this fact in mind. It is often used to early exit out of tests that the author knew you would not be able to run given your sandbox limitations.
1010
- Similarly, when you spawn a process using Seatbelt (`/usr/bin/sandbox-exec`), `CODEX_SANDBOX=seatbelt` will be set on the child process. Integration tests that want to run Seatbelt themselves cannot be run under Seatbelt, so checks for `CODEX_SANDBOX=seatbelt` are also often used to early exit out of tests, as appropriate.
11+
- Always collapse if statements per https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
12+
- Always inline format! args when possible per https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
13+
- Use method references over closures when possible per https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_for_method_calls
14+
- When writing tests, prefer comparing the equality of entire objects over fields one by one.
1115

1216
Run `just fmt` (in `codex-rs` directory) automatically after making Rust code changes; do not ask for approval to run it. Before finalizing a change to `codex-rs`, run `just fix -p <project>` (in `codex-rs` directory) to fix any linter issues in the code. Prefer scoping with `-p` to avoid slow workspace‑wide Clippy builds; only run `just fix` without `-p` if you changed shared crates. Additionally, run the tests:
17+
1318
1. Run the test for the specific project that was changed. For example, if changes were made in `codex-rs/tui`, run `cargo test -p codex-tui`.
1419
2. Once those pass, if any changes were made in common, core, or protocol, run the complete test suite with `cargo test --all-features`.
15-
When running interactively, ask the user before running `just fix` to finalize. `just fmt` does not require approval. project-specific or individual tests can be run without asking the user, but do ask the user before running the complete test suite.
20+
When running interactively, ask the user before running `just fix` to finalize. `just fmt` does not require approval. project-specific or individual tests can be run without asking the user, but do ask the user before running the complete test suite.
1621

1722
## TUI style conventions
1823

@@ -28,6 +33,7 @@ See `codex-rs/tui/styles.md`.
2833
- Desired: vec![" └ ".into(), "M".red(), " ".dim(), "tui/src/app.rs".dim()]
2934

3035
### TUI Styling (ratatui)
36+
3137
- Prefer Stylize helpers: use "text".dim(), .bold(), .cyan(), .italic(), .underlined() instead of manual Style where possible.
3238
- Prefer simple conversions: use "text".into() for spans and vec![].into() for lines; when inference is ambiguous (e.g., Paragraph::new/Cell::from), use Line::from(spans) or Span::from(text).
3339
- Computed styles: if the Style is computed at runtime, using `Span::styled` is OK (`Span::from(text).set_style(style)` is also acceptable).
@@ -39,6 +45,7 @@ See `codex-rs/tui/styles.md`.
3945
- Compactness: prefer the form that stays on one line after rustfmt; if only one of Line::from(vec![]) or vec![].into() avoids wrapping, choose that. If both wrap, pick the one with fewer wrapped lines.
4046

4147
### Text wrapping
48+
4249
- Always use textwrap::wrap to wrap plain strings.
4350
- If you have a ratatui Line and you want to wrap it, use the helpers in tui/src/wrapping.rs, e.g. word_wrap_lines / word_wrap_line.
4451
- If you need to indent wrapped lines, use the initial_indent / subsequent_indent options from RtOptions if you can, rather than writing custom logic.
@@ -60,6 +67,7 @@ This repo uses snapshot tests (via `insta`), especially in `codex-rs/tui`, to va
6067
- `cargo insta accept -p codex-tui`
6168

6269
If you don’t have the tool:
70+
6371
- `cargo install cargo-insta`
6472

6573
### Test assertions

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<p align="center"><code>npm i -g @openai/codex</code><br />or <code>brew install codex</code></p>
32

43
<p align="center"><strong>Codex CLI</strong> is a coding agent from OpenAI that runs locally on your computer.
@@ -62,8 +61,7 @@ You can also use Codex with an API key, but this requires [additional setup](./d
6261

6362
### Model Context Protocol (MCP)
6463

65-
Codex CLI supports [MCP servers](./docs/advanced.md#model-context-protocol-mcp). Enable by adding an `mcp_servers` section to your `~/.codex/config.toml`.
66-
64+
Codex can access MCP servers. To configure them, refer to the [config docs](./docs/config.md#mcp_servers).
6765

6866
### Configuration
6967

@@ -83,8 +81,11 @@ Codex CLI supports a rich set of configuration options, with preferences stored
8381
- [**Authentication**](./docs/authentication.md)
8482
- [Auth methods](./docs/authentication.md#forcing-a-specific-auth-method-advanced)
8583
- [Login on a "Headless" machine](./docs/authentication.md#connecting-on-a-headless-machine)
84+
- **Automating Codex**
85+
- [GitHub Action](https://github.com/openai/codex-action)
86+
- [TypeScript SDK](./sdk/typescript/README.md)
87+
- [Non-interactive mode (`codex exec`)](./docs/exec.md)
8688
- [**Advanced**](./docs/advanced.md)
87-
- [Non-interactive / CI mode](./docs/advanced.md#non-interactive--ci-mode)
8889
- [Tracing / verbose logging](./docs/advanced.md#tracing--verbose-logging)
8990
- [Model Context Protocol (MCP)](./docs/advanced.md#model-context-protocol-mcp)
9091
- [**Zero data retention (ZDR)**](./docs/zdr.md)

0 commit comments

Comments
 (0)