From 6949329a7fc66589b3355cf18c3cff4d94d21b1b Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Thu, 17 Jul 2025 11:40:00 -0700 Subject: [PATCH] chore: auto format code on save and add more details to AGENTS.md (#1582) Adds a default vscode config with generally applicable settings. Adds more entrypoints to justfile both for environment setup and to help agents better verify changes. --- .vscode/launch.json | 18 ++++++++++++++++++ .vscode/settings.json | 10 ++++++++++ AGENTS.md | 4 ++++ codex-rs/justfile | 6 ++++++ codex-rs/toolchain.toml | 3 +++ codex-rs/tui/src/app.rs | 2 +- .../src/bottom_pane/status_indicator_view.rs | 2 +- 7 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 codex-rs/toolchain.toml diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..618207f3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Cargo launch", + "cargo": { + "cwd": "${workspaceFolder}/codex-rs", + "args": [ + "build", + "--bin=codex-tui" + ] + }, + "args": [] + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..f66a1258 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "rust-analyzer.checkOnSave": true, + "rust-analyzer.check.command": "clippy", + "rust-analyzer.check.extraArgs": ["--all-features", "--tests"], + "rust-analyzer.rustfmt.extraArgs": ["--config", "imports_granularity=Item"], + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer", + "editor.formatOnSave": true, + } +} diff --git a/AGENTS.md b/AGENTS.md index 1348e578..4188cc98 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,3 +3,7 @@ In the codex-rs folder where the rust code lives: - Never add or modify any code related to `CODEX_SANDBOX_NETWORK_DISABLED_ENV_VAR`. You operate in a sandbox where `CODEX_SANDBOX_NETWORK_DISABLED=1` will be set whenever you use the `shell` tool. Any existing code that uses `CODEX_SANDBOX_NETWORK_DISABLED_ENV_VAR` was authored with this fact in mind. It is often used to early exit out of tests that the author knew you would not be able to run given your sandbox limitations. + +After making changes to the rust code run `just fmt` (in `codex-rs` directory) to format the code and `just fix` (in `codex-rs` directory) to fix any linter issues in the code. + +Ensure the test suite passes by running `cargo test --all-features` in the `codex-rs` directory. diff --git a/codex-rs/justfile b/codex-rs/justfile index 83a390ec..6c8e9f9e 100644 --- a/codex-rs/justfile +++ b/codex-rs/justfile @@ -23,3 +23,9 @@ file-search *args: # format code fmt: cargo fmt -- --config imports_granularity=Item + +fix: + cargo clippy --fix --all-features --tests --allow-dirty + +install: + cargo fetch diff --git a/codex-rs/toolchain.toml b/codex-rs/toolchain.toml new file mode 100644 index 00000000..72bafdf4 --- /dev/null +++ b/codex-rs/toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.88.0" +components = [ "clippy", "rustfmt", "rust-src"] diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index 88325040..ac69bef2 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -60,7 +60,7 @@ struct ChatWidgetArgs { initial_images: Vec, } -impl<'a> App<'a> { +impl App<'_> { pub(crate) fn new( config: Config, initial_prompt: Option, diff --git a/codex-rs/tui/src/bottom_pane/status_indicator_view.rs b/codex-rs/tui/src/bottom_pane/status_indicator_view.rs index d9ac57d7..de46ac27 100644 --- a/codex-rs/tui/src/bottom_pane/status_indicator_view.rs +++ b/codex-rs/tui/src/bottom_pane/status_indicator_view.rs @@ -24,7 +24,7 @@ impl StatusIndicatorView { } } -impl<'a> BottomPaneView<'a> for StatusIndicatorView { +impl BottomPaneView<'_> for StatusIndicatorView { fn update_status_text(&mut self, text: String) -> ConditionalUpdate { self.update_text(text); ConditionalUpdate::NeedsRedraw