Commit Graph
1087 Commits
Author SHA1 Message Date
Michael Bolin 1f177a209b Merge 0e470f424b into sapling-pr-archive-bolinfest 2025-05-13 11:58:38 -07:00
Michael Bolin 0e470f424b fix: remember to set lastIndex = 0 on shared RegExp 2025-05-13 11:58:26 -07:00
Michael Bolin 2ae15cad9e merge commit for archive created by Sapling 2025-05-13 10:51:24 -07:00
Michael Bolin 1963882fe4 fix: patch in #366 and #367 for marked-terminal 2025-05-13 10:51:14 -07:00
Michael Bolin 1e12b2a511 Merge 70e9ff2fd7 into sapling-pr-archive-bolinfest 2025-05-13 10:27:54 -07:00
Michael Bolin 70e9ff2fd7 fix: patch in #366 and #367 for marked-terminal 2025-05-13 10:27:42 -07:00
Michael Bolin 557f608f25 fix: add support for fileOpener in config.json (#911)
This PR introduces the following type:

```typescript
export type FileOpenerScheme = "vscode" | "cursor" | "windsurf";
```

and uses it as the new type for a `fileOpener` option in `config.json`.
If set, this will be used to linkify file annotations in the output
using the URI-based file opener supported in VS Code-based IDEs.

Currently, this does not pass:

Updated `codex-cli/tests/markdown.test.tsx` to verify the new behavior.
Note it required mocking `supports-hyperlinks` and temporarily modifying
`chalk.level` to yield the desired output.
2025-05-13 09:45:46 -07:00
Michael Bolin f86a4749f4 Merge 86759c99ec into sapling-pr-archive-bolinfest 2025-05-13 09:34:37 -07:00
Michael Bolin 86759c99ec fix: add support for fileOpener in config.json 2025-05-13 09:34:31 -07:00
Michael Bolin 75fe7bb887 merge commit for archive created by Sapling 2025-05-13 09:32:43 -07:00
Michael Bolin 70daeb45ef fix: add support for fileOpener in config.json 2025-05-13 09:32:37 -07:00
Michael Bolin d079bce3eb merge commit for archive created by Sapling 2025-05-13 09:32:20 -07:00
Michael Bolin 15e6c36f74 fix: add support for fileOpener in config.json 2025-05-13 09:32:13 -07:00
Michael Bolin bfb522b493 merge commit for archive created by Sapling 2025-05-13 09:29:37 -07:00
Michael Bolin 1427b6df06 fix: add support for fileOpener in config.json 2025-05-13 09:29:32 -07:00
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