codex-wrapper 0.1.2

A type-safe Codex CLI wrapper for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
use crate::Codex;
use crate::command::CodexCommand;
#[cfg(feature = "json")]
use crate::error::Error;
use crate::error::Result;
use crate::exec::{self, CommandOutput};
#[cfg(feature = "json")]
use crate::types::JsonLineEvent;
use crate::types::{ApprovalPolicy, Color, SandboxMode};

/// Run Codex non-interactively (`codex exec <prompt>`).
///
/// This is the primary command for programmatic use. It supports the full
/// range of exec flags: model selection, sandbox policy, approval policy,
/// images, config overrides, feature flags, JSON output, and more.
///
/// # Example
///
/// ```no_run
/// use codex_wrapper::{Codex, CodexCommand, ExecCommand, SandboxMode};
///
/// # async fn example() -> codex_wrapper::Result<()> {
/// let codex = Codex::builder().build()?;
/// let output = ExecCommand::new("fix the failing test")
///     .model("o3")
///     .sandbox(SandboxMode::WorkspaceWrite)
///     .ephemeral()
///     .execute(&codex)
///     .await?;
/// println!("{}", output.stdout);
/// # Ok(())
/// # }
/// ```
#[derive(Debug, Clone)]
pub struct ExecCommand {
    prompt: Option<String>,
    config_overrides: Vec<String>,
    enabled_features: Vec<String>,
    disabled_features: Vec<String>,
    images: Vec<String>,
    model: Option<String>,
    oss: bool,
    local_provider: Option<String>,
    sandbox: Option<SandboxMode>,
    approval_policy: Option<ApprovalPolicy>,
    profile: Option<String>,
    full_auto: bool,
    dangerously_bypass_approvals_and_sandbox: bool,
    cd: Option<String>,
    skip_git_repo_check: bool,
    add_dirs: Vec<String>,
    search: bool,
    ephemeral: bool,
    output_schema: Option<String>,
    color: Option<Color>,
    progress_cursor: bool,
    json: bool,
    output_last_message: Option<String>,
    retry_policy: Option<crate::retry::RetryPolicy>,
}

impl ExecCommand {
    /// Create a new exec command with the given prompt.
    #[must_use]
    pub fn new(prompt: impl Into<String>) -> Self {
        Self {
            prompt: Some(prompt.into()),
            config_overrides: Vec::new(),
            enabled_features: Vec::new(),
            disabled_features: Vec::new(),
            images: Vec::new(),
            model: None,
            oss: false,
            local_provider: None,
            sandbox: None,
            approval_policy: None,
            profile: None,
            full_auto: false,
            dangerously_bypass_approvals_and_sandbox: false,
            cd: None,
            skip_git_repo_check: false,
            add_dirs: Vec::new(),
            search: false,
            ephemeral: false,
            output_schema: None,
            color: None,
            progress_cursor: false,
            json: false,
            output_last_message: None,
            retry_policy: None,
        }
    }

    /// Read the prompt from stdin (`-`).
    #[must_use]
    pub fn from_stdin() -> Self {
        Self::new("-")
    }

    /// Override a config key (`-c key=value`).
    ///
    /// May be called multiple times to set several keys.
    #[must_use]
    pub fn config(mut self, key_value: impl Into<String>) -> Self {
        self.config_overrides.push(key_value.into());
        self
    }

    /// Enable an optional feature flag (`--enable <feature>`).
    ///
    /// May be called multiple times.
    #[must_use]
    pub fn enable(mut self, feature: impl Into<String>) -> Self {
        self.enabled_features.push(feature.into());
        self
    }

    /// Disable an optional feature flag (`--disable <feature>`).
    ///
    /// May be called multiple times.
    #[must_use]
    pub fn disable(mut self, feature: impl Into<String>) -> Self {
        self.disabled_features.push(feature.into());
        self
    }

    /// Attach an image to the prompt (`--image <path>`).
    ///
    /// May be called multiple times to attach several images.
    #[must_use]
    pub fn image(mut self, path: impl Into<String>) -> Self {
        self.images.push(path.into());
        self
    }

    /// Set the model to use (`--model <model>`).
    ///
    /// Panics if `model` is an empty string.
    #[must_use]
    pub fn model(mut self, model: impl Into<String>) -> Self {
        let model = model.into();
        assert!(!model.is_empty(), "model name must not be empty");
        self.model = Some(model);
        self
    }

    /// Use the OSS model tier (`--oss`).
    #[must_use]
    pub fn oss(mut self) -> Self {
        self.oss = true;
        self
    }

    /// Use a local model provider (`--local-provider <provider>`).
    #[must_use]
    pub fn local_provider(mut self, provider: impl Into<String>) -> Self {
        self.local_provider = Some(provider.into());
        self
    }

    /// Set the sandbox policy (`--sandbox <mode>`).
    #[must_use]
    pub fn sandbox(mut self, sandbox: SandboxMode) -> Self {
        self.sandbox = Some(sandbox);
        self
    }

    /// Set the approval policy (`--ask-for-approval <policy>`).
    #[must_use]
    pub fn approval_policy(mut self, policy: ApprovalPolicy) -> Self {
        self.approval_policy = Some(policy);
        self
    }

    /// Select a named configuration profile (`--profile <name>`).
    #[must_use]
    pub fn profile(mut self, profile: impl Into<String>) -> Self {
        self.profile = Some(profile.into());
        self
    }

    /// Run in full-auto mode — no approval prompts (`--full-auto`).
    #[must_use]
    pub fn full_auto(mut self) -> Self {
        self.full_auto = true;
        self
    }

    /// Bypass all approval prompts and sandbox restrictions.
    ///
    /// Passes `--dangerously-bypass-approvals-and-sandbox`. Use with caution.
    #[must_use]
    pub fn dangerously_bypass_approvals_and_sandbox(mut self) -> Self {
        self.dangerously_bypass_approvals_and_sandbox = true;
        self
    }

    /// Change the working directory before running (`--cd <dir>`).
    #[must_use]
    pub fn cd(mut self, dir: impl Into<String>) -> Self {
        self.cd = Some(dir.into());
        self
    }

    /// Skip the git repository check (`--skip-git-repo-check`).
    #[must_use]
    pub fn skip_git_repo_check(mut self) -> Self {
        self.skip_git_repo_check = true;
        self
    }

    /// Add an extra directory to the context (`--add-dir <dir>`).
    ///
    /// May be called multiple times.
    #[must_use]
    pub fn add_dir(mut self, dir: impl Into<String>) -> Self {
        self.add_dirs.push(dir.into());
        self
    }

    /// Enable live web search (`--search`).
    #[must_use]
    pub fn search(mut self) -> Self {
        self.search = true;
        self
    }

    /// Run in ephemeral mode — no session is persisted (`--ephemeral`).
    #[must_use]
    pub fn ephemeral(mut self) -> Self {
        self.ephemeral = true;
        self
    }

    /// Require output to conform to a JSON schema (`--output-schema <path>`).
    #[must_use]
    pub fn output_schema(mut self, path: impl Into<String>) -> Self {
        self.output_schema = Some(path.into());
        self
    }

    /// Control terminal color output (`--color <mode>`).
    #[must_use]
    pub fn color(mut self, color: Color) -> Self {
        self.color = Some(color);
        self
    }

    /// Show a progress cursor while the command runs (`--progress-cursor`).
    #[must_use]
    pub fn progress_cursor(mut self) -> Self {
        self.progress_cursor = true;
        self
    }

    /// Emit JSON Lines output (`--json`).
    ///
    /// When set, stdout will contain one JSON object per line. Use
    /// [`execute_json_lines`](ExecCommand::execute_json_lines) to parse the
    /// events automatically (requires the `json` feature).
    #[must_use]
    pub fn json(mut self) -> Self {
        self.json = true;
        self
    }

    /// Write the last assistant message to a file (`--output-last-message <path>`).
    #[must_use]
    pub fn output_last_message(mut self, path: impl Into<String>) -> Self {
        self.output_last_message = Some(path.into());
        self
    }

    /// Override the retry policy for this command.
    ///
    /// Takes precedence over the client-level policy set on [`Codex`].
    #[must_use]
    pub fn retry(mut self, policy: crate::retry::RetryPolicy) -> Self {
        self.retry_policy = Some(policy);
        self
    }

    /// Stream JSONL events from the command, invoking `handler` for each
    /// parsed [`JsonLineEvent`] as it arrives.
    ///
    /// Automatically appends `--json` if not already set. Requires the `json`
    /// feature.
    ///
    /// # Example
    ///
    /// ```no_run
    /// use codex_wrapper::{Codex, ExecCommand, JsonLineEvent};
    ///
    /// # async fn example() -> codex_wrapper::Result<()> {
    /// let codex = Codex::builder().build()?;
    /// ExecCommand::new("what is 2+2?")
    ///     .ephemeral()
    ///     .stream(&codex, |event: JsonLineEvent| {
    ///         println!("{}: {:?}", event.event_type, event.extra);
    ///     })
    ///     .await?;
    /// # Ok(())
    /// # }
    /// ```
    #[cfg(feature = "json")]
    pub async fn stream<F>(&self, codex: &Codex, handler: F) -> Result<()>
    where
        F: FnMut(JsonLineEvent),
    {
        crate::streaming::stream_exec(codex, self, handler).await
    }

    /// Execute the command and parse the output as JSON Lines events.
    ///
    /// Automatically appends `--json` if not already set. Requires the `json`
    /// feature.
    #[cfg(feature = "json")]
    pub async fn execute_json_lines(&self, codex: &Codex) -> Result<Vec<JsonLineEvent>> {
        let mut args = self.args();
        if !self.json {
            args.push("--json".into());
        }

        let output = exec::run_codex_with_retry(codex, args, self.retry_policy.as_ref()).await?;
        parse_json_lines(&output.stdout)
    }
}

impl CodexCommand for ExecCommand {
    type Output = CommandOutput;

    fn args(&self) -> Vec<String> {
        let mut args = vec!["exec".to_string()];

        push_repeat(&mut args, "-c", &self.config_overrides);
        push_repeat(&mut args, "--enable", &self.enabled_features);
        push_repeat(&mut args, "--disable", &self.disabled_features);
        push_repeat(&mut args, "--image", &self.images);

        if let Some(model) = &self.model {
            args.push("--model".into());
            args.push(model.clone());
        }
        if self.oss {
            args.push("--oss".into());
        }
        if let Some(local_provider) = &self.local_provider {
            args.push("--local-provider".into());
            args.push(local_provider.clone());
        }
        if let Some(sandbox) = self.sandbox {
            args.push("--sandbox".into());
            args.push(sandbox.as_arg().into());
        }
        if let Some(policy) = self.approval_policy {
            args.push("--ask-for-approval".into());
            args.push(policy.as_arg().into());
        }
        if let Some(profile) = &self.profile {
            args.push("--profile".into());
            args.push(profile.clone());
        }
        if self.full_auto {
            args.push("--full-auto".into());
        }
        if self.dangerously_bypass_approvals_and_sandbox {
            args.push("--dangerously-bypass-approvals-and-sandbox".into());
        }
        if let Some(cd) = &self.cd {
            args.push("--cd".into());
            args.push(cd.clone());
        }
        if self.skip_git_repo_check {
            args.push("--skip-git-repo-check".into());
        }
        push_repeat(&mut args, "--add-dir", &self.add_dirs);
        if self.search {
            args.push("--search".into());
        }
        if self.ephemeral {
            args.push("--ephemeral".into());
        }
        if let Some(output_schema) = &self.output_schema {
            args.push("--output-schema".into());
            args.push(output_schema.clone());
        }
        if let Some(color) = self.color {
            args.push("--color".into());
            args.push(color.as_arg().into());
        }
        if self.progress_cursor {
            args.push("--progress-cursor".into());
        }
        if self.json {
            args.push("--json".into());
        }
        if let Some(path) = &self.output_last_message {
            args.push("--output-last-message".into());
            args.push(path.clone());
        }
        if let Some(prompt) = &self.prompt {
            args.push(prompt.clone());
        }

        args
    }

    async fn execute(&self, codex: &Codex) -> Result<CommandOutput> {
        exec::run_codex_with_retry(codex, self.args(), self.retry_policy.as_ref()).await
    }
}

/// Resume a previous non-interactive session (`codex exec resume`).
///
/// Use [`session_id`](ExecResumeCommand::session_id) to target a specific
/// session, or [`last`](ExecResumeCommand::last) to pick the most recent.
#[derive(Debug, Clone)]
pub struct ExecResumeCommand {
    session_id: Option<String>,
    prompt: Option<String>,
    last: bool,
    all: bool,
    config_overrides: Vec<String>,
    enabled_features: Vec<String>,
    disabled_features: Vec<String>,
    images: Vec<String>,
    model: Option<String>,
    full_auto: bool,
    dangerously_bypass_approvals_and_sandbox: bool,
    skip_git_repo_check: bool,
    ephemeral: bool,
    json: bool,
    output_last_message: Option<String>,
    retry_policy: Option<crate::retry::RetryPolicy>,
}

impl ExecResumeCommand {
    /// Create a new resume command with no options set.
    #[must_use]
    pub fn new() -> Self {
        Self {
            session_id: None,
            prompt: None,
            last: false,
            all: false,
            config_overrides: Vec::new(),
            enabled_features: Vec::new(),
            disabled_features: Vec::new(),
            images: Vec::new(),
            model: None,
            full_auto: false,
            dangerously_bypass_approvals_and_sandbox: false,
            skip_git_repo_check: false,
            ephemeral: false,
            json: false,
            output_last_message: None,
            retry_policy: None,
        }
    }

    /// Resume a specific session by its ID.
    #[must_use]
    pub fn session_id(mut self, session_id: impl Into<String>) -> Self {
        self.session_id = Some(session_id.into());
        self
    }

    /// Append an additional prompt to the resumed session.
    #[must_use]
    pub fn prompt(mut self, prompt: impl Into<String>) -> Self {
        self.prompt = Some(prompt.into());
        self
    }

    /// Resume the most recent session (`--last`).
    #[must_use]
    pub fn last(mut self) -> Self {
        self.last = true;
        self
    }

    /// Resume all sessions (`--all`).
    #[must_use]
    pub fn all(mut self) -> Self {
        self.all = true;
        self
    }

    /// Set the model to use (`--model <model>`).
    ///
    /// Panics if `model` is an empty string.
    #[must_use]
    pub fn model(mut self, model: impl Into<String>) -> Self {
        let model = model.into();
        assert!(!model.is_empty(), "model name must not be empty");
        self.model = Some(model);
        self
    }

    /// Attach an image to the prompt (`--image <path>`).
    ///
    /// May be called multiple times to attach several images.
    #[must_use]
    pub fn image(mut self, path: impl Into<String>) -> Self {
        self.images.push(path.into());
        self
    }

    /// Emit JSON Lines output (`--json`).
    #[must_use]
    pub fn json(mut self) -> Self {
        self.json = true;
        self
    }

    /// Write the last assistant message to a file (`--output-last-message <path>`).
    #[must_use]
    pub fn output_last_message(mut self, path: impl Into<String>) -> Self {
        self.output_last_message = Some(path.into());
        self
    }

    /// Override a config key (`-c key=value`).
    ///
    /// May be called multiple times to set several keys.
    #[must_use]
    pub fn config(mut self, key_value: impl Into<String>) -> Self {
        self.config_overrides.push(key_value.into());
        self
    }

    /// Enable an optional feature flag (`--enable <feature>`).
    ///
    /// May be called multiple times.
    #[must_use]
    pub fn enable(mut self, feature: impl Into<String>) -> Self {
        self.enabled_features.push(feature.into());
        self
    }

    /// Disable an optional feature flag (`--disable <feature>`).
    ///
    /// May be called multiple times.
    #[must_use]
    pub fn disable(mut self, feature: impl Into<String>) -> Self {
        self.disabled_features.push(feature.into());
        self
    }

    /// Run in full-auto mode — no approval prompts (`--full-auto`).
    #[must_use]
    pub fn full_auto(mut self) -> Self {
        self.full_auto = true;
        self
    }

    /// Bypass all approval prompts and sandbox restrictions.
    ///
    /// Passes `--dangerously-bypass-approvals-and-sandbox`. Use with caution.
    #[must_use]
    pub fn dangerously_bypass_approvals_and_sandbox(mut self) -> Self {
        self.dangerously_bypass_approvals_and_sandbox = true;
        self
    }

    /// Skip the git repository check (`--skip-git-repo-check`).
    #[must_use]
    pub fn skip_git_repo_check(mut self) -> Self {
        self.skip_git_repo_check = true;
        self
    }

    /// Run in ephemeral mode — no session is persisted (`--ephemeral`).
    #[must_use]
    pub fn ephemeral(mut self) -> Self {
        self.ephemeral = true;
        self
    }

    /// Override the retry policy for this command.
    ///
    /// Takes precedence over the client-level policy set on [`Codex`].
    #[must_use]
    pub fn retry(mut self, policy: crate::retry::RetryPolicy) -> Self {
        self.retry_policy = Some(policy);
        self
    }

    /// Execute the command and parse the output as JSON Lines events.
    ///
    /// Automatically appends `--json` if not already set. Requires the `json`
    /// feature.
    #[cfg(feature = "json")]
    pub async fn execute_json_lines(&self, codex: &Codex) -> Result<Vec<JsonLineEvent>> {
        let mut args = self.args();
        if !self.json {
            args.push("--json".into());
        }

        let output = exec::run_codex_with_retry(codex, args, self.retry_policy.as_ref()).await?;
        parse_json_lines(&output.stdout)
    }

    /// Stream JSONL events from the resume command, invoking `handler` for
    /// each parsed [`JsonLineEvent`] as it arrives.
    ///
    /// Automatically appends `--json` if not already set. Requires the `json`
    /// feature.
    #[cfg(feature = "json")]
    pub async fn stream<F>(&self, codex: &Codex, handler: F) -> Result<()>
    where
        F: FnMut(JsonLineEvent),
    {
        crate::streaming::stream_exec_resume(codex, self, handler).await
    }
}

impl Default for ExecResumeCommand {
    fn default() -> Self {
        Self::new()
    }
}

impl CodexCommand for ExecResumeCommand {
    type Output = CommandOutput;

    fn args(&self) -> Vec<String> {
        let mut args = vec!["exec".into(), "resume".into()];
        push_repeat(&mut args, "-c", &self.config_overrides);
        push_repeat(&mut args, "--enable", &self.enabled_features);
        push_repeat(&mut args, "--disable", &self.disabled_features);
        if self.last {
            args.push("--last".into());
        }
        if self.all {
            args.push("--all".into());
        }
        push_repeat(&mut args, "--image", &self.images);
        if let Some(model) = &self.model {
            args.push("--model".into());
            args.push(model.clone());
        }
        if self.full_auto {
            args.push("--full-auto".into());
        }
        if self.dangerously_bypass_approvals_and_sandbox {
            args.push("--dangerously-bypass-approvals-and-sandbox".into());
        }
        if self.skip_git_repo_check {
            args.push("--skip-git-repo-check".into());
        }
        if self.ephemeral {
            args.push("--ephemeral".into());
        }
        if self.json {
            args.push("--json".into());
        }
        if let Some(path) = &self.output_last_message {
            args.push("--output-last-message".into());
            args.push(path.clone());
        }
        if let Some(session_id) = &self.session_id {
            args.push(session_id.clone());
        }
        if let Some(prompt) = &self.prompt {
            args.push(prompt.clone());
        }
        args
    }

    async fn execute(&self, codex: &Codex) -> Result<CommandOutput> {
        exec::run_codex_with_retry(codex, self.args(), self.retry_policy.as_ref()).await
    }
}

fn push_repeat(args: &mut Vec<String>, flag: &str, values: &[String]) {
    for value in values {
        args.push(flag.into());
        args.push(value.clone());
    }
}

#[cfg(feature = "json")]
fn parse_json_lines(stdout: &str) -> Result<Vec<JsonLineEvent>> {
    stdout
        .lines()
        .filter(|line| line.trim_start().starts_with('{'))
        .map(|line| {
            serde_json::from_str(line).map_err(|source| Error::Json {
                message: format!("failed to parse JSONL event: {line}"),
                source,
            })
        })
        .collect()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn exec_args() {
        let args = ExecCommand::new("fix the test")
            .model("gpt-5")
            .sandbox(SandboxMode::WorkspaceWrite)
            .approval_policy(ApprovalPolicy::OnRequest)
            .skip_git_repo_check()
            .ephemeral()
            .json()
            .args();

        assert_eq!(
            args,
            vec![
                "exec",
                "--model",
                "gpt-5",
                "--sandbox",
                "workspace-write",
                "--ask-for-approval",
                "on-request",
                "--skip-git-repo-check",
                "--ephemeral",
                "--json",
                "fix the test",
            ]
        );
    }

    #[test]
    #[should_panic(expected = "model name must not be empty")]
    fn exec_model_empty_panics() {
        let _ = ExecCommand::new("prompt").model("");
    }

    #[test]
    #[should_panic(expected = "model name must not be empty")]
    fn exec_resume_model_empty_panics() {
        let _ = ExecResumeCommand::new().model("");
    }

    #[test]
    fn exec_resume_args() {
        let args = ExecResumeCommand::new()
            .last()
            .model("gpt-5")
            .json()
            .prompt("continue")
            .args();

        assert_eq!(
            args,
            vec![
                "exec", "resume", "--last", "--model", "gpt-5", "--json", "continue",
            ]
        );
    }
}