Commit Graph
8422 Commits
Author SHA1 Message Date
Michael Bolin 0a92c7228c merge commit for archive created by Sapling 2025-05-13 09:28:39 -07:00
Michael Bolin 3a8039886f fix: add support for fileOpener in config.json 2025-05-13 09:28:34 -07:00
Michael Bolin e9809cec05 Merge fa138db8fb into sapling-pr-archive-bolinfest 2025-05-12 23:41:15 -07:00
Michael Bolin fa138db8fb fix: add support for fileOpener in config.json 2025-05-12 23:41:06 -07:00
Michael Bolin 05bb5d7d46 fix: always load version from package.json at runtime (#909)
Note the high-level motivation behind this change is to avoid the need
to make temporary changes in the source tree in order to cut a release
build since that runs the risk of leaving things in an inconsistent
state in the event of a failure. The existing code:

```
import pkg from "../../package.json" assert { type: "json" };
```

did not work as intended because, as written, ESBuild would bake the
contents of the local `package.json` into the release build at build
time whereas we want it to read the contents at runtime so we can use
the `package.json` in the tree to build the code and later inject a
modified version into the release package with a timestamped build
version.

Changes:

* move `CLI_VERSION` out of `src/utils/session.ts` and into
`src/version.ts` so `../package.json` is a correct relative path both
from `src/version.ts` in the source tree and also in the final
`dist/cli.js` build output
* change `assert` to `with` in `import pkg` as apparently `with` became
standard in Node 22
* mark `"../package.json"` as external in `build.mjs` so the version is
not baked into the `.js` at build time

After using `pnpm stage-release` to build a release version, if I use
Node 22.0 to run Codex, I see the following printed to stderr at
startup:

```
(node:71308) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
```

Note it is a warning and does not prevent Codex from running.

In Node 22.12, the warning goes away, but the warning still appears in
Node 22.11. For Node 22, 22.15.0 is the current LTS version, so LTS
users will not see this.

Also, something about moving the definition of `CLI_VERSION` caused a
problem with the mocks in `check-updates.test.ts`. I asked Codex to fix
it, and it came up with the change to the test configs. I don't know
enough about vitest to understand what it did, but the tests seem
healthy again, so I'm going with it.
2025-05-12 21:27:15 -07:00
Michael Bolin 3287fa3a94 merge commit for archive created by Sapling 2025-05-12 21:11:38 -07:00
Michael Bolin 8e1450fd52 fix: always load version from package.json at runtime 2025-05-12 21:11:32 -07:00
Michael Bolin 0371b57292 Merge a741d32013 into sapling-pr-archive-bolinfest 2025-05-12 21:08:42 -07:00
Michael Bolin a741d32013 fix: always load version from package.json at runtime 2025-05-12 21:08:34 -07:00
Michael Bolin e6b5241d9c Merge f6f1df68f2 into sapling-pr-archive-bolinfest 2025-05-12 21:07:06 -07:00
Michael Bolin f6f1df68f2 fix: always load version from package.json at runtime 2025-05-12 21:06:58 -07:00
Michael Bolin 567c20df08 Merge d8d169a455 into sapling-pr-archive-bolinfest 2025-05-12 21:06:44 -07:00
Michael Bolin d8d169a455 fix: always load version from package.json at runtime 2025-05-12 21:06:32 -07:00
Michael Bolin 6472d1aa08 merge commit for archive created by Sapling 2025-05-12 21:04:36 -07:00
Michael Bolin 99e67d2e44 fix: always load version from package.json at runtime 2025-05-12 21:04:29 -07:00
Michael Bolin 2b599d59f0 Merge cfc87f9345 into sapling-pr-archive-bolinfest 2025-05-12 18:06:51 -07:00
Michael Bolin cfc87f9345 fix: always load version from package.json at runtime 2025-05-12 18:06:46 -07:00
Michael Bolin 48ba3e7ef8 Merge 33ddfabd1f into sapling-pr-archive-bolinfest 2025-05-12 18:04:38 -07:00
Michael Bolin 33ddfabd1f fix: always load version from package.json at runtime 2025-05-12 18:04:30 -07:00
Michael Bolin 61b881d4e5 fix: agent instructions were not being included when ~/.codex/instructions.md was empty (#908)
I had seen issues where `codex-rs` would not always write files without
me pressuring it to do so, and between that and the report of
https://github.com/openai/codex/issues/900, I decided to look into this
further. I found two serious issues with agent instructions:

(1) We were only sending agent instructions on the first turn, but
looking at the TypeScript code, we should be sending them on every turn.

(2) There was a serious issue where the agent instructions were
frequently lost:

* The TypeScript CLI appears to keep writing `~/.codex/instructions.md`:
https://github.com/openai/codex/blob/55142e3e6caddd1e613b71bcb89385ce5cc708bf/codex-cli/src/utils/config.ts#L586
* If `instructions.md` is present, the Rust CLI uses the contents of it
INSTEAD OF the default prompt, even if `instructions.md` is empty:
https://github.com/openai/codex/blob/55142e3e6caddd1e613b71bcb89385ce5cc708bf/codex-rs/core/src/config.rs#L202-L203

The combination of these two things means that I have been using
`codex-rs` without these key instructions:
https://github.com/openai/codex/blob/main/codex-rs/core/prompt.md

Looking at the TypeScript code, it appears we should be concatenating
these three items every time (if they exist):

* `prompt.md`
* `~/.codex/instructions.md`
* nearest `AGENTS.md`

This PR fixes things so that:

* `Config.instructions` is `None` if `instructions.md` is empty
* `Payload.instructions` is now `&'a str` instead of `Option<&'a
String>` because we should always have _something_ to send
* `Prompt` now has a `get_full_instructions()` helper that returns a
`Cow<str>` that will always include the agent instructions first.
codex-rs-94c47d69a3f92257e7f9717a2044bd55786eb999-1-rust-v0.0.2505121726
2025-05-12 17:24:44 -07:00
Michael Bolin 0882f3e003 Merge d1a917ce5f into sapling-pr-archive-bolinfest 2025-05-12 17:16:07 -07:00
Michael Bolin d1a917ce5f fix: agent instructions were not being included when ~/.codex/instructions.md was empty 2025-05-12 17:16:04 -07:00
Michael Bolin 8776ce2cc3 merge commit for archive created by Sapling 2025-05-12 17:15:26 -07:00
Michael Bolin cec83f5a1a fix: agent instructions were not being included when ~/.codex/instructions.md was empty 2025-05-12 17:15:14 -07:00
Michael Bolin 1744b21dea Merge 081f8eb7e8 into sapling-pr-archive-bolinfest 2025-05-12 17:10:42 -07:00
Michael Bolin 081f8eb7e8 fix: agent instructions were not being included when ~/.codex/instructions.md was empty 2025-05-12 17:10:35 -07:00
Michael Bolin 55142e3e6c fix: use "thinking" instead of "codex reasoning" as the label for reasoning events in the TUI (#905) codex-rs-9949f6404378db6f54a01bcadb1956e0535d4921-1-rust-v0.0.2505121520 2025-05-12 15:19:45 -07:00
Michael Bolin 115fb0b95d fix: navigate initialization phase before tools/list request in MCP client (#904)
Apparently the MCP server implemented in JavaScript did not require the
`initialize` handshake before responding to tool list/call, so I missed
this.
2025-05-12 15:15:26 -07:00
Michael Bolin 5c19e17fce Merge d64cbbf167 into sapling-pr-archive-bolinfest 2025-05-12 15:14:17 -07:00
Michael Bolin d64cbbf167 fix: use "thinking" instead of "codex reasoning" as the label for reasoning events in the TUI 2025-05-12 15:14:11 -07:00
Michael Bolin 8949fadf85 merge commit for archive created by Sapling 2025-05-12 15:10:35 -07:00
Michael Bolin 69edf359cb fix: navigate initialization phase before tools/list request in MCP client 2025-05-12 15:09:29 -07:00
Michael Bolin 89d96067e9 Merge 8a6cf1a8f0 into sapling-pr-archive-bolinfest 2025-05-12 14:43:10 -07:00
Michael Bolin 8a6cf1a8f0 fix: navigate initialization phase before tools/list request in MCP client 2025-05-12 14:43:01 -07:00
Avi Rosenberg ab4cb94227 fix: Normalize paths in resolvePathAgainstWorkdir to prevent path traversal vulnerability (#895)
This PR fixes a potential path traversal vulnerability by ensuring all
paths are properly normalized in the `resolvePathAgainstWorkdir`
function.

## Changes
- Added path normalization for both absolute and relative paths
- Ensures normalized paths are used in all subsequent operations
- Prevents potential path traversal attacks through non-normalized paths

This minimal change addresses the security concern without adding
unnecessary complexity, while maintaining compatibility with existing
code.
2025-05-12 13:44:00 -07:00
Michael Bolin 73fe1381aa chore: introduce new --native flag to Node module release process (#844)
This PR introduces an optional build flag, `--native`, that will build a
version of the Codex npm module that:

- Includes both the Node.js and native Rust versions (for Mac and Linux)
- Will run the native version if `CODEX_RUST=1` is set
- Runs the TypeScript version otherwise

Note this PR also updates the workflow URL to
https://github.com/openai/codex/actions/runs/14872557396, as that is a
build from today that includes everything up through
https://github.com/openai/codex/pull/843.

Test Plan:

In `~/code/codex/codex-cli`, I ran:

```
pnpm stage-release --native
```

The end of the output was:

```
Staged version 0.1.2505121317 for release in /var/folders/wm/f209bc1n2bd_r0jncn9s6j_00000gp/T/tmp.xd2p5ETYGN
Test Node:
    node /var/folders/wm/f209bc1n2bd_r0jncn9s6j_00000gp/T/tmp.xd2p5ETYGN/bin/codex.js --help
Test Rust:
    CODEX_RUST=1 node /var/folders/wm/f209bc1n2bd_r0jncn9s6j_00000gp/T/tmp.xd2p5ETYGN/bin/codex.js --help
Next:  cd "/var/folders/wm/f209bc1n2bd_r0jncn9s6j_00000gp/T/tmp.xd2p5ETYGN" && npm publish --tag native
```

I verified that running each of these commands ran the expected version
of Codex.

While here, I also added `bin` to the `files` list in `package.json`,
which should have been done as part of
https://github.com/openai/codex/pull/757, as that added new entries to
`bin` that were matched by `.gitignore` but should have been included in
a release.
2025-05-12 13:38:10 -07:00
Michael Bolin 2da72e5341 merge commit for archive created by Sapling 2025-05-12 13:35:55 -07:00
Michael Bolin 2893055403 chore: introduce new --native flag to Node module release process 2025-05-12 13:35:50 -07:00
Michael Bolin 9ca6ed2db6 Merge e656347993 into sapling-pr-archive-bolinfest 2025-05-12 13:32:49 -07:00
Michael Bolin e656347993 chore: introduce new --native flag to Node module release process 2025-05-12 13:32:45 -07:00
Michael Bolin 0f8b101898 merge commit for archive created by Sapling 2025-05-12 13:30:39 -07:00
Michael Bolin c428265b0f chore: introduce new --native flag to Node module release process 2025-05-12 13:30:34 -07:00
Michael Bolin 993eb938b5 Merge 7c8f0ffc89 into sapling-pr-archive-bolinfest 2025-05-12 13:18:06 -07:00
Michael Bolin 7c8f0ffc89 chore: introduce new --native flag to Node module release process 2025-05-12 13:18:02 -07:00
Michael Bolin ad60a59e84 Merge 99f1cc110b into sapling-pr-archive-bolinfest 2025-05-12 13:16:29 -07:00
Michael Bolin 99f1cc110b chore: introduce new --native flag to Node module release process 2025-05-12 13:16:25 -07:00
jcoens-openai f3bd143867 Disallow expect via lints (#865)
Adds `expect()` as a denied lint. Same deal applies with `unwrap()`
where we now need to put `#[expect(...` on ones that we legit want. Took
care to enable `expect()` in test contexts.

# Tests

```
cargo fmt
cargo clippy --all-features --all-targets --no-deps -- -D warnings
cargo test
```
2025-05-12 08:45:46 -07:00
Michael Bolin a1f51bf91b fix: fix border style for BottomPane (#893)
This PR fixes things so that:

* when the `BottomPane` is in the `StatusIndicator` state, the border
should be dim
* when the `BottomPane` does not have input focus, the border should be
dim

To make it easier to enforce this invariant, this PR introduces
`BottomPane::set_state()` that will:

* update `self.state`
* call `update_border_for_input_focus()`
* request a repaint

This should make it easier to enforce other updates for state changes
going forward.
2025-05-10 23:34:13 -07:00
Michael Bolin 50d87d346d Merge dea09c6f33 into sapling-pr-archive-bolinfest 2025-05-10 23:29:18 -07:00
Michael Bolin dea09c6f33 fix: fix border style for textarea 2025-05-10 23:28:21 -07:00