mirror of
https://github.com/openai/codex.git
synced 2026-04-30 03:12:20 +03:00
`ParsedCommand::Read` has a `name` field that attempts to identify the
name of the file being read, but the file may not be in the `cwd` in
which the command is invoked as demonstrated by this existing unit test:
0139f6780c/codex-rs/core/src/parse_command.rs (L250-L260)
As you can see, `tui/Cargo.toml` is the relative path to the file being
read.
This PR introduces a new `path: PathBuf` field to `ParsedCommand::Read`
that attempts to capture this information. When possible, this is an
absolute path, though when relative, it should be resolved against the
`cwd` that will be used to run the command to derive the absolute path.
This should make it easier for clients to provide UI for a "read file"
event that corresponds to the command execution.
31 lines
808 B
Rust
31 lines
808 B
Rust
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use std::path::PathBuf;
|
|
use ts_rs::TS;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, TS)]
|
|
#[serde(tag = "type", rename_all = "snake_case")]
|
|
pub enum ParsedCommand {
|
|
Read {
|
|
cmd: String,
|
|
name: String,
|
|
/// (Best effort) Path to the file being read by the command. When
|
|
/// possible, this is an absolute path, though when relative, it should
|
|
/// be resolved against the `cwd`` that will be used to run the command
|
|
/// to derive the absolute path.
|
|
path: PathBuf,
|
|
},
|
|
ListFiles {
|
|
cmd: String,
|
|
path: Option<String>,
|
|
},
|
|
Search {
|
|
cmd: String,
|
|
query: Option<String>,
|
|
path: Option<String>,
|
|
},
|
|
Unknown {
|
|
cmd: String,
|
|
},
|
|
}
|