chore: introduce codex-common crate (#843)

I started this PR because I wanted to share the `format_duration()`
utility function in `codex-rs/exec/src/event_processor.rs` with the TUI.
The question was: where to put it?

`core` should have as few dependencies as possible, so moving it there
would introduce a dependency on `chrono`, which seemed undesirable.
`core` already had this `cli` feature to deal with a similar situation
around sharing common utility functions, so I decided to:

* make `core` feature-free
* introduce `common`
* `common` can have as many "special interest" features as it needs,
each of which can declare their own deps
* the first two features of common are `cli` and `elapsed`

In practice, this meant updating a number of `Cargo.toml` files,
replacing this line:

```toml
codex-core = { path = "../core", features = ["cli"] }
```

with these:

```toml
codex-core = { path = "../core" }
codex-common = { path = "../common", features = ["cli"] }
```

Moving `format_duration()` into its own file gave it some "breathing
room" to add a unit test, so I had Codex generate some tests and new
support for durations over 1 minute.
This commit is contained in:
Michael Bolin
2025-05-06 17:38:56 -07:00
committed by GitHub
parent 7d8b38b37b
commit c577e94b67
20 changed files with 143 additions and 42 deletions

12
codex-rs/Cargo.lock generated
View File

@@ -473,6 +473,7 @@ version = "0.0.0"
dependencies = [
"anyhow",
"clap",
"codex-common",
"codex-core",
"codex-exec",
"codex-tui",
@@ -482,6 +483,15 @@ dependencies = [
"tracing-subscriber",
]
[[package]]
name = "codex-common"
version = "0.1.0"
dependencies = [
"chrono",
"clap",
"codex-core",
]
[[package]]
name = "codex-core"
version = "0.1.0"
@@ -530,6 +540,7 @@ dependencies = [
"anyhow",
"chrono",
"clap",
"codex-common",
"codex-core",
"mcp-types",
"owo-colors 4.2.0",
@@ -596,6 +607,7 @@ dependencies = [
"anyhow",
"clap",
"codex-ansi-escape",
"codex-common",
"codex-core",
"color-eyre",
"crossterm",