Commit Graph

1288 Commits

Author SHA1 Message Date
Michael Bolin
bdc2c97a50 merge commit for archive created by Sapling 2025-05-16 10:15:29 -07:00
Michael Bolin
90c068412d feat: add support for file_opener option in Rust, similiar to #911 2025-05-16 10:14:17 -07:00
Michael Bolin
2519f91566 merge commit for archive created by Sapling 2025-05-16 10:01:10 -07:00
Michael Bolin
0d197916a5 feat: add support for file_opener option in Rust, similiar to #911 2025-05-16 10:01:05 -07:00
Michael Bolin
85848f6cb1 merge commit for archive created by Sapling 2025-05-16 09:57:11 -07:00
Michael Bolin
2e6fadc7ec feat: add support for file_opener option in Rust, similiar to #911 2025-05-16 09:57:06 -07:00
Michael Bolin
55148939c4 Merge baa92fc9c3 into sapling-pr-archive-bolinfest 2025-05-16 09:52:19 -07:00
Michael Bolin
baa92fc9c3 feat: add support for file_opener option in Rust, similiar to #911 2025-05-16 09:52:13 -07:00
Michael Bolin
3d9f4fcd8a fix: introduce ExtractHeredocError that implements PartialEq (#958) 2025-05-16 09:42:27 -07:00
Michael Bolin
a62437601b Merge 649ac117f0 into sapling-pr-archive-bolinfest 2025-05-16 09:36:29 -07:00
Michael Bolin
649ac117f0 fix: introduce ExtractHeredocError that implements PartialEq 2025-05-16 09:36:22 -07:00
Michael Bolin
ce225b13de merge commit for archive created by Sapling 2025-05-16 09:23:37 -07:00
Michael Bolin
678fd19340 feat: add support for file_opener option in Rust, similiar to #911 2025-05-16 09:23:32 -07:00
Michael Bolin
404c304aff Merge 02a569ac31 into sapling-pr-archive-bolinfest 2025-05-16 09:22:47 -07:00
Michael Bolin
02a569ac31 feat: add support for file_opener option in Rust, similiar to #911 2025-05-16 09:22:31 -07:00
Sebastian Lund
84e01f4b62 fix: apply patch issue when using different cwd (#942)
If you run a codex instance outside of the current working directory
from where you launched the codex binary it won't be able to apply
patches correctly, even if the sandbox policy allows it. This manifests
weird behaviours, such as

* Reading the same filename in the binary working directory, and
overwriting it in the session working directory. e.g. if you have a
`readme` in both folders it will overwrite the readme in the session
working directory with the readme in the binary working directory
*applied with the suggested patch*.
* The LLM ends up in weird loops trying to verify and debug why the
apply_patch won't work, and it can result in it applying patches by
manually writing python or javascript if it figures out that either is
supported by the system instead.

I added a test-case to ensure that the patch contents are based on the
cwd.

## Issue: mixing relative & absolute paths in apply_patch

1. The apply_patch tool use relative paths based on the session working
directory.
2. `unified_diff_from_chunks` eventually ends up [reading the source
file](https://github.com/reflectionai/codex/blob/main/codex-rs/apply-patch/src/lib.rs#L410)
to figure out what the diff is, by using the relative path.
3. The changes are targeted using an absolute path derived from the
current working directory.

The end-result in case session working directory differs from the binary
working directory: we get the diff for a file relative to the binary
working directory, and apply it on a file in the session working
directory.
2025-05-16 09:12:16 -07:00
hanson-openai
7edfbae062 fix: diff command for filenames with special characters (#954)
## Summary
- fix quoting issues in `/diff` to correctly handle files with special
characters
- add regression test for `getGitDiff` when filenames contain `$`
- relax timeout in raw-exec-process-group test

Fixes https://github.com/openai/codex/issues/943

## Testing
- `pnpm test`
2025-05-16 09:10:44 -07:00
Fouad Matin
316289d01d bump(version): 0.1.2505160811 codex-mini-latest (#953)
## `0.1.2505160811`

- `codex-mini-latest` (#951)
2025-05-16 08:18:20 -07:00
Michael Bolin
30cbfdfa87 chore: update exec crate to use std::time instead of chrono (#952)
When I originally wrote `elapsed.rs`, I realized we were using both
`std::time` and `chrono` with no real benefit of having both. We should
try to keep the `exec` subcommand trim (as it also buildable as a
standalone executable), so this helps tighten things up.
2025-05-16 08:14:50 -07:00
Fouad Matin
070499f534 add: codex-mini-latest (#951)
💽

---------

Co-authored-by: Trevor Creech <tcreech@openai.com>
2025-05-16 08:04:00 -07:00
Michael Bolin
ab7ccfbfd6 Merge 8a327a7283 into sapling-pr-archive-bolinfest 2025-05-16 08:00:06 -07:00
Michael Bolin
8a327a7283 chore: update exec crate to use std::time instead of chrono 2025-05-16 07:55:33 -07:00
Michael Bolin
ce2ecbe72f feat: record messages from user in ~/.codex/history.jsonl (#939)
This is a large change to support a "history" feature like you would
expect in a shell like Bash.

History events are recorded in `$CODEX_HOME/history.jsonl`. Because it
is a JSONL file, it is straightforward to append new entries (as opposed
to the TypeScript file that uses `$CODEX_HOME/history.json`, so to be
valid JSON, each new entry entails rewriting the entire file). Because
it is possible for there to be multiple instances of Codex CLI writing
to `history.jsonl` at once, we use advisory file locking when working
with `history.jsonl` in `codex-rs/core/src/message_history.rs`.

Because we believe history is a sufficiently useful feature, we enable
it by default. Though to provide some safety, we set the file
permissions of `history.jsonl` to be `o600` so that other users on the
system cannot read the user's history. We do not yet support a default
list of `SENSITIVE_PATTERNS` as the TypeScript CLI does:


3fdf9df133/codex-cli/src/utils/storage/command-history.ts (L10-L17)

We are going to take a more conservative approach to this list in the
Rust CLI. For example, while `/\b[A-Za-z0-9-_]{20,}\b/` might exclude
sensitive information like API tokens, it would also exclude valuable
information such as references to Git commits.

As noted in the updated documentation, users can opt-out of history by
adding the following to `config.toml`:

```toml
[history]
persistence = "none" 
```

Because `history.jsonl` could, in theory, be quite large, we take a[n
arguably overly pedantic] approach in reading history entries into
memory. Specifically, we start by telling the client the current number
of entries in the history file (`history_entry_count`) as well as the
inode (`history_log_id`) of `history.jsonl` (see the new fields on
`SessionConfiguredEvent`).

The client is responsible for keeping new entries in memory to create a
"local history," but if the user hits up enough times to go "past" the
end of local history, then the client should use the new
`GetHistoryEntryRequest` in the protocol to fetch older entries.
Specifically, it should pass the `history_log_id` it was given
originally and work backwards from `history_entry_count`. (It should
really fetch history in batches rather than one-at-a-time, but that is
something we can improve upon in subsequent PRs.)

The motivation behind this crazy scheme is that it is designed to defend
against:

* The `history.jsonl` being truncated during the session such that the
index into the history is no longer consistent with what had been read
up to that point. We do not yet have logic to enforce a `max_bytes` for
`history.jsonl`, but once we do, we will aspire to implement it in a way
that should result in a new inode for the file on most systems.
* New items from concurrent Codex CLI sessions amending to the history.
Because, in absence of truncation, `history.jsonl` is an append-only
log, so long as the client reads backwards from `history_entry_count`,
it should always get a consistent view of history. (That said, it will
not be able to read _new_ commands from concurrent sessions, but perhaps
we will introduce a `/` command to reload latest history or something
down the road.)

Admittedly, my testing of this feature thus far has been fairly light. I
expect we will find bugs and introduce enhancements/fixes going forward.
codex-rs-8d6a8b308e7457d432564083bb2f577cd39e132b-1-rust-v0.0.2505151627
2025-05-15 16:26:23 -07:00
Michael Bolin
11c3ce7a72 merge commit for archive created by Sapling 2025-05-15 16:18:40 -07:00
Michael Bolin
7b8f239dc1 feat: record messages from user in ~/.codex/history.jsonl 2025-05-15 16:18:34 -07:00
Michael Bolin
38ed1bd2c9 merge commit for archive created by Sapling 2025-05-15 16:02:25 -07:00
Michael Bolin
e67ff236a4 feat: record messages from user in ~/.codex/history.jsonl 2025-05-15 16:01:13 -07:00
Michael Bolin
f298f5fd3b merge commit for archive created by Sapling 2025-05-15 15:41:54 -07:00
Michael Bolin
4b6d0a627b feat: record messages from user in ~/.codex/history.jsonl 2025-05-15 15:41:48 -07:00
Michael Bolin
cfde8d25f8 Merge ffc1432f8a into sapling-pr-archive-bolinfest 2025-05-15 15:24:12 -07:00
Michael Bolin
ffc1432f8a feat: record messages from user in ~/.codex/history.jsonl 2025-05-15 15:24:09 -07:00
Michael Bolin
4ebe3a21d0 merge commit for archive created by Sapling 2025-05-15 15:19:28 -07:00
Michael Bolin
19fa6a552b feat: record messages from user in ~/.codex/history.jsonl 2025-05-15 15:19:18 -07:00
Michael Bolin
d10106d9cc merge commit for archive created by Sapling 2025-05-15 14:54:48 -07:00
Michael Bolin
aca377958a feat: record messages from user in ~/.codex/history.jsonl 2025-05-15 14:54:15 -07:00
Michael Bolin
3fdf9df133 chore: introduce AppEventSender to help fix clippy warnings and update to Rust 1.87 (#948)
Moving to Rust 1.87 introduced a clippy warning that
`SendError<AppEvent>` was too large.

In practice, the only thing we ever did when we got this error was log
it (if the mspc channel is closed, then the app is likely shutting down
or something, so there's not much to do...), so this finally motivated
me to introduce `AppEventSender`, which wraps
`std::sync::mpsc::Sender<AppEvent>` with a `send()` method that invokes
`send()` on the underlying `Sender` and logs an `Err` if it gets one.

This greatly simplifies the code, as many functions that previously
returned `Result<(), SendError<AppEvent>>` now return `()`, so we don't
have to propagate an `Err` all over the place that we don't really
handle, anyway.

This also makes it so we can upgrade to Rust 1.87 in CI.
2025-05-15 14:50:30 -07:00
Michael Bolin
2f26a4541b merge commit for archive created by Sapling 2025-05-15 14:41:03 -07:00
Michael Bolin
ffb04a92c9 chore: introduce AppEventSender to help fix clippy warnings and update to Rust 1.87 2025-05-15 14:40:39 -07:00
Michael Bolin
8d4fa1cd45 Merge 910e8a5d85 into sapling-pr-archive-bolinfest 2025-05-15 14:07:42 -07:00
Michael Bolin
910e8a5d85 feat: record messages from user in ~/.codex/history.jsonl 2025-05-15 14:07:30 -07:00
Michael Bolin
ec5e82b77c chore: pin Rust version to 1.86 and use io::Error::other to prepare for 1.87 (#947)
Previously, our GitHub actions specified the Rust toolchain as
`dtolnay/rust-toolchain@stable`, which meant the version could change
out from under us. In this case, the move from 1.86 to 1.87 introduced
new clippy warnings, causing build failures.

Because it will take a little time to fix all the new clippy warnings,
this PR pins things to 1.86 for now to unbreak the build.

It also replaces `io::Error::new(io::ErrorKind::Other)` with
`io::Error::other()` in preparation for 1.87.
2025-05-15 14:07:16 -07:00
Michael Bolin
a7ce2e06ef Merge 581c5bfcb3 into sapling-pr-archive-bolinfest 2025-05-15 14:03:56 -07:00
Michael Bolin
581c5bfcb3 chore: pin Rust version to 1.86 and use io::Error::other to prepare for 1.87 2025-05-15 14:03:52 -07:00
Michael Bolin
77d0ab8357 merge commit for archive created by Sapling 2025-05-15 14:00:42 -07:00
Michael Bolin
fab2b94323 chore: pin Rust version to 1.86 and use io::Error::other to prepare for 1.87 2025-05-15 14:00:35 -07:00
Michael Bolin
c993940ec0 Merge fc4434a92d into sapling-pr-archive-bolinfest 2025-05-15 13:56:41 -07:00
Michael Bolin
fc4434a92d chore: pin Rust version to 1.86 and use io::Error::other to prepare for 1.87 2025-05-15 13:56:37 -07:00
Michael Bolin
37f89ba5cf Merge 22037acecd into sapling-pr-archive-bolinfest 2025-05-15 13:56:32 -07:00
Michael Bolin
22037acecd chore: pin Rust version to 1.86 and use io::Error::other to prepare for 1.87 2025-05-15 13:56:21 -07:00
Michael Bolin
19879c0f5f merge commit for archive created by Sapling 2025-05-15 13:37:33 -07:00