core-agent-ide/codex-cli/src/utils
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
..
agent fix: always load version from package.json at runtime (#909) 2025-05-12 21:27:15 -07:00
logger chore: improve storage/ implementation; use log(...) consistently (#473) 2025-04-21 09:51:34 -04:00
singlepass refactor: improve performance of renderFilesToXml using Array.join (#127) 2025-04-16 16:14:57 -07:00
storage chore: improve storage/ implementation; use log(...) consistently (#473) 2025-04-21 09:51:34 -04:00
approximate-tokens-used.ts fix(cli): ensure /clear resets context and exclude system messages from approximateTokenUsed count (#443) 2025-04-20 08:52:14 -07:00
auto-approval-mode.js Initial commit 2025-04-16 12:56:08 -04:00
auto-approval-mode.ts Initial commit 2025-04-16 12:56:08 -04:00
bug-report.ts fix: /bug report command, thinking indicator (#381) 2025-04-18 18:13:34 -07:00
check-in-git.ts Initial commit 2025-04-16 12:56:08 -04:00
check-updates.ts fix: always load version from package.json at runtime (#909) 2025-05-12 21:27:15 -07:00
compact-summary.ts Adds Azure OpenAI support (#769) 2025-05-09 18:11:32 -07:00
config.ts fix: flex-mode via config/flag (#813) 2025-05-10 16:18:20 -07:00
extract-applied-patches.ts feat: /diff command to view git diff (#426) 2025-04-19 16:23:27 -07:00
file-system-suggestions.ts feat: @mention files in codex (#701) 2025-04-30 16:19:55 -07:00
file-tag-utils.ts feat: @mention files in codex (#701) 2025-04-30 16:19:55 -07:00
get-diff.ts fix: /diff should include untracked files (#686) 2025-04-26 12:43:51 -07:00
input-utils.ts Add fallback text for missing images (#397) 2025-04-18 22:55:24 -07:00
model-info.ts feat: add openai model info configuration (#551) 2025-04-22 17:31:25 -04:00
model-utils.ts Adds Azure OpenAI support (#769) 2025-05-09 18:11:32 -07:00
openai-client.ts Adds Azure OpenAI support (#769) 2025-05-09 18:11:32 -07:00
package-manager-detector.ts refactor(updates): fetch version from registry instead of npm CLI to support multiple managers (#446) 2025-04-21 00:00:20 -07:00
parsers.ts fix: agent loop for disable response storage (#543) 2025-04-22 13:49:10 -07:00
providers.ts feat: added arceeai as a provider (#818) 2025-05-10 16:16:28 -07:00
responses.ts fix: guard against missing choices (#817) 2025-05-10 16:16:19 -07:00
session.ts fix: always load version from package.json at runtime (#909) 2025-05-12 21:27:15 -07:00
short-path.ts Initial commit 2025-04-16 12:56:08 -04:00
slash-commands.ts feat(bug-report): print bug report URL in terminal instead of opening browser (#510) (#528) 2025-04-24 17:00:14 -07:00
terminal-chat-utils.ts chore: consolidate model utils and drive-by cleanups (#476) 2025-04-21 12:33:57 -04:00
terminal.ts fix: /clear now clears terminal screen and resets context left indicator (#425) 2025-04-21 12:39:46 -04:00