Skip to main content

blyte_cli/
cli.rs

1use clap::Parser;
2use serde::{Deserialize, Serialize};
3use std::path::PathBuf;
4
5#[derive(clap::Subcommand, Debug, PartialEq, Clone)]
6#[allow(clippy::large_enum_variant)]
7pub enum Command {
8    /// Detect this repository's checks and write blyte.toml
9    Init(InitArgs),
10    /// Serve a local dashboard of running and recent jobs
11    Dashboard(DashboardArgs),
12    /// Combine a request's passed runs on a work branch and run the repository's check
13    Combine(CombineArgs),
14    /// Run one task in its own git worktree (.wt/<id>, branch wip/<id>) and print a JSON summary
15    Dispatch(DispatchArgs),
16    /// Start a direct edit in its own git worktree (.wt/<id>, branch wip/<id>)
17    #[command(hide = true)]
18    EditStart(EditStartArgs),
19    /// Verify and record a direct edit started with `blyte edit-start`
20    #[command(hide = true)]
21    EditFinish(EditFinishArgs),
22    /// Show what a dispatched run did: commits, files, tree state, report, and optionally the diff
23    Review(ReviewArgs),
24    /// Remove finished worktrees and merged branches
25    Clean(CleanArgs),
26    /// Show what a dispatch is doing
27    Status {
28        id: String,
29        #[arg(long)]
30        json: bool,
31    },
32    /// Wait until dispatched runs finish (all of them, or the first with --any) and print one line per finished run
33    Wait {
34        /// Run ids, as given to `blyte dispatch`
35        #[arg(required = true, num_args = 1..)]
36        ids: Vec<String>,
37        /// Return as soon as at least one run has finished
38        #[arg(long)]
39        any: bool,
40        /// Give up after this many seconds (exit 2); stays under the 300 s shell-command limit
41        #[arg(long, default_value_t = 280)]
42        timeout: u64,
43    },
44    /// Install or print the Claude Code skill for the plan, delegate, review workflow
45    Skill(SkillArgs),
46    /// Replace this binary with the latest release (the old one is kept as blyte.prev)
47    Update {
48        /// Only show the installed and latest versions
49        #[arg(long, conflicts_with = "rollback")]
50        check: bool,
51        /// Swap back to the previous build (blyte.prev)
52        #[arg(long)]
53        rollback: bool,
54    },
55    /// Show conversation model and implementer costs
56    Cost(CostArgs),
57    /// Print Claude Code's status line with blyte costs
58    Statusline(StatuslineArgs),
59    /// List a plan's tasks with their state and the command to dispatch each ready one
60    Plan(PlanArgs),
61    /// List the surfaces running on this machine
62    Surfaces {
63        #[arg(long)]
64        json: bool,
65        /// List the stopped surfaces of the current folder
66        #[arg(long)]
67        stopped: bool,
68    },
69    /// Open a running surface's page by name
70    Open {
71        name: String,
72        /// Open the surface in an app window (`app`, default) or the default browser (`browser`)
73        #[arg(long = "open-in", value_name = "app|browser")]
74        open_in: Option<String>,
75    },
76    /// Reload a running surface onto the installed blyte binary
77    Reload(ReloadArgs),
78    /// Stop one or more running surfaces
79    Stop(StopArgs),
80    /// Send a message to a running surface
81    Tell {
82        name: String,
83        message: String,
84        #[arg(long, default_value = "terminal", value_name = "LABEL", value_parser = parse_from_label)]
85        from: String,
86    },
87    /// Fail when the working tree adds comments since a base commit
88    #[command(hide = true)]
89    Comments(CommentsArgs),
90    /// Print the instructions the conversation model is given
91    #[command(hide = true)]
92    Instructions(InstructionsArgs),
93    /// Restore a folder to its state before an in-place run
94    Undo(UndoArgs),
95}
96
97#[derive(clap::Args, Debug, PartialEq, Clone)]
98pub struct UndoArgs {
99    /// Run id to undo
100    pub id: String,
101}
102
103#[derive(clap::Args, Debug, PartialEq, Clone)]
104pub struct ReloadArgs {
105    /// Surface name or id (defaults to the current folder's running surface)
106    #[arg(value_name = "NAME", conflicts_with = "all")]
107    pub target: Option<String>,
108
109    /// Reload every running surface
110    #[arg(long)]
111    pub all: bool,
112}
113
114#[derive(clap::Args, Debug, PartialEq, Clone)]
115pub struct StopArgs {
116    /// Surface name or id (defaults to the current folder's running surface)
117    #[arg(value_name = "NAME", conflicts_with = "all")]
118    pub target: Option<String>,
119
120    /// Stop every running surface
121    #[arg(long)]
122    pub all: bool,
123
124    /// Stop even when a model turn is in progress
125    #[arg(long)]
126    pub force: bool,
127}
128
129#[derive(clap::Args, Debug, PartialEq, Clone)]
130pub struct InitArgs {
131    /// Overwrite an existing blyte.toml
132    #[arg(long)]
133    pub force: bool,
134
135    /// Print the file instead of writing it
136    #[arg(long)]
137    pub print: bool,
138
139    /// Skip gate verification on HEAD
140    #[arg(long)]
141    pub no_verify: bool,
142
143    /// Sandbox local command execution: 'on' or 'off' (default 'on')
144    #[arg(
145        long,
146        default_value = "on",
147        value_parser = ["on", "off"]
148    )]
149    pub sandbox: String,
150
151    /// Timeout in seconds for each verification step (default 600)
152    #[arg(long, default_value = "600", value_name = "SECONDS")]
153    pub step_timeout: u64,
154}
155
156#[derive(clap::Args, Debug, PartialEq, Clone)]
157pub struct DashboardArgs {
158    /// Port to listen on (0 for a free port)
159    #[arg(long, default_value = "7171", value_name = "N")]
160    pub port: u16,
161
162    /// Directory holding repositories or worktrees (repeatable)
163    #[arg(long = "root", value_name = "DIR")]
164    pub roots: Vec<PathBuf>,
165
166    /// Directory holding run logs and reports (repeatable)
167    #[arg(long = "runs-dir", value_name = "DIR")]
168    pub runs_dirs: Vec<PathBuf>,
169
170    /// How far back finished jobs are listed, in hours
171    #[arg(long, default_value = "24", value_name = "N")]
172    pub hours: u64,
173
174    /// Open the dashboard in the default browser
175    #[arg(long)]
176    pub open: bool,
177}
178
179#[derive(Debug, PartialEq, Clone)]
180pub struct SurfaceArgs {
181    pub port: u16,
182    pub no_open: bool,
183    pub open_in: crate::open_window::OpenIn,
184    pub days: u64,
185    pub name: Option<String>,
186    pub resume: Option<String>,
187}
188
189impl Default for SurfaceArgs {
190    fn default() -> Self {
191        Self {
192            port: 0,
193            no_open: false,
194            open_in: crate::open_window::OpenIn::App,
195            days: 14,
196            name: None,
197            resume: None,
198        }
199    }
200}
201
202#[derive(clap::Args, Debug, PartialEq, Clone)]
203pub struct CombineArgs {
204    /// Request identifier whose passed runs should be combined
205    pub request: String,
206}
207
208#[derive(clap::Args, Debug, PartialEq, Clone)]
209pub struct EditStartArgs {
210    /// Identifier for this direct edit (used for worktree and branch wip/<id>)
211    pub id: String,
212
213    /// Short description of the requested change
214    #[arg(long, value_name = "TEXT")]
215    pub task: String,
216
217    /// The commit the new worktree starts from
218    #[arg(long, default_value = "HEAD")]
219    pub base: String,
220}
221
222#[derive(clap::Args, Debug, PartialEq, Clone)]
223pub struct EditFinishArgs {
224    /// Identifier given to `blyte edit-start`
225    pub id: String,
226
227    /// Request identifier this edit belongs to
228    #[arg(long, value_name = "ID")]
229    pub request: Option<String>,
230
231    /// Surface identifier that started this edit
232    #[arg(long, value_name = "ID")]
233    pub surface: Option<String>,
234
235    #[arg(long, hide = true, value_name = "NAME")]
236    pub started_by: Option<String>,
237
238    /// Commit message used to commit uncommitted or untracked changes in the worktree
239    #[arg(long, value_name = "TEXT")]
240    pub message: Option<String>,
241}
242
243#[derive(clap::Args, Debug, PartialEq, Clone)]
244pub struct DispatchArgs {
245    /// Identifier for this dispatch (used for worktree and branch wip/<id>)
246    pub id: String,
247
248    /// Path to the task description markdown file; optional with --plan and --plan-task, which take the task from the plan
249    pub task_file: Option<PathBuf>,
250
251    /// The check command; several lines are several steps, all of which must pass
252    #[arg(short, long)]
253    pub gate: Option<String>,
254
255    /// Tag for this dispatch (repeatable)
256    #[arg(long = "tag", value_name = "TEXT")]
257    pub tags: Vec<String>,
258
259    /// Path to the plan file this dispatch belongs to
260    #[arg(long, value_name = "PATH")]
261    pub plan: Option<String>,
262
263    /// Plan task this dispatch implements
264    #[arg(long, value_name = "TEXT")]
265    pub plan_task: Option<String>,
266
267    /// Request identifier this dispatch belongs to
268    #[arg(long, value_name = "ID")]
269    pub request: Option<String>,
270
271    /// Surface identifier that started this dispatch
272    #[arg(long, value_name = "ID")]
273    pub surface: Option<String>,
274
275    #[arg(long, hide = true, value_name = "NAME")]
276    pub started_by: Option<String>,
277
278    /// The commit a new worktree starts from
279    #[arg(long, default_value = "HEAD")]
280    pub base: String,
281
282    /// Run read-only research: scratch repository, report gate, findings in report.md
283    #[arg(long, conflicts_with = "gate", conflicts_with = "base")]
284    pub research: bool,
285
286    /// Copy the finished research report to this path (only with --research)
287    #[arg(long = "report-to", requires = "research", value_name = "PATH")]
288    pub report_to: Option<PathBuf>,
289
290    /// Model identifier or provider selection
291    #[arg(short, long)]
292    pub model: Option<String>,
293
294    /// Wall-clock budget in seconds (default 3600)
295    #[arg(long)]
296    pub max_seconds: Option<u64>,
297
298    /// Maximum turn budget (default 300)
299    #[arg(long)]
300    pub max_turns: Option<u32>,
301
302    /// Maximum spend in USD (default 25)
303    #[arg(long = "max-cost")]
304    pub max_cost_usd: Option<f64>,
305
306    /// Approximate token budget for the verbatim tail before folding
307    #[arg(long)]
308    pub fold_budget: Option<usize>,
309
310    /// Sandbox local command execution: 'on' or 'off' (default 'on')
311    #[arg(
312        long,
313        default_value = "on",
314        value_parser = ["on", "off"]
315    )]
316    pub sandbox: String,
317
318    /// Outbound network mode: 'on' or 'off' (default 'on')
319    #[arg(
320        long,
321        value_parser = ["on", "off"]
322    )]
323    pub network: Option<String>,
324
325    /// Let sandboxed commands read this path despite credential deny-list (repeatable)
326    #[arg(long = "allow-read")]
327    pub allow_read: Vec<PathBuf>,
328
329    /// Start even if the task names paths outside the workspace and --allow-read
330    #[arg(long = "no-path-check")]
331    pub no_path_check: bool,
332
333    /// Research runs: no warning for missing brief sections, and allow a question that names an unverified report
334    #[arg(long = "no-brief-check")]
335    pub no_brief_check: bool,
336
337    /// Skip the model claim check on report.md for research runs
338    #[arg(long = "no-claim-check")]
339    pub no_claim_check: bool,
340
341    /// Skip the pre-run gate check on the untouched worktree
342    #[arg(long = "no-base-check")]
343    pub no_base_check: bool,
344
345    /// Pass this environment variable to commands (repeatable)
346    #[arg(long = "pass-env")]
347    pub pass_env: Vec<String>,
348}
349
350#[derive(clap::ValueEnum, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
351#[value(rename_all = "lowercase")]
352#[serde(rename_all = "lowercase")]
353pub enum ReviewVerdict {
354    Accepted,
355    Fixed,
356    Redone,
357}
358
359impl ReviewVerdict {
360    pub fn as_str(&self) -> &'static str {
361        match self {
362            Self::Accepted => "accepted",
363            Self::Fixed => "fixed",
364            Self::Redone => "redone",
365        }
366    }
367}
368
369impl std::fmt::Display for ReviewVerdict {
370    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
371        write!(f, "{}", self.as_str())
372    }
373}
374
375#[derive(clap::Args, Debug, PartialEq, Clone)]
376pub struct ReviewArgs {
377    pub id: String,
378
379    #[arg(long)]
380    pub diff: bool,
381
382    #[arg(long, value_enum)]
383    pub verdict: Option<ReviewVerdict>,
384
385    #[arg(long, value_name = "TEXT", requires = "verdict")]
386    pub notes: Option<String>,
387
388    /// Ask the implementer model for a first review of the diff against the task (trial)
389    #[arg(long, conflicts_with = "verdict")]
390    pub model_review: bool,
391}
392
393#[derive(clap::Args, Debug, PartialEq, Clone)]
394pub struct CleanArgs {
395    /// Show what would be removed without deleting anything
396    #[arg(long)]
397    pub dry_run: bool,
398
399    /// Worktrees older than this many days are removable without a verdict (default 14)
400    #[arg(long, default_value = "14", value_name = "DAYS")]
401    pub older_than: u64,
402
403    /// Clean every repository in the registry
404    #[arg(long)]
405    pub all: bool,
406
407    #[arg(long, hide = true, conflicts_with_all = ["all", "dry_run"])]
408    pub quiet: bool,
409
410    #[arg(long, hide = true, value_name = "ID", conflicts_with_all = ["all", "dry_run"])]
411    pub skip: Option<String>,
412}
413
414#[derive(clap::Args, Debug, PartialEq, Clone)]
415pub struct CostArgs {
416    /// Session identifier to filter by (an unknown session prints zero totals and exits 0)
417    #[arg(long, value_name = "ID")]
418    pub session: Option<String>,
419
420    /// Break down totals by session id
421    #[arg(long)]
422    pub by_session: bool,
423
424    /// Filter runs at or after this Unix timestamp in seconds
425    #[arg(long, value_name = "UNIX_SECS")]
426    pub since: Option<u64>,
427
428    /// Repository path to filter by
429    #[arg(long, value_name = "PATH")]
430    pub repo: Option<PathBuf>,
431
432    /// Output totals as JSON
433    #[arg(long)]
434    pub json: bool,
435}
436
437#[derive(clap::Args, Debug, PartialEq, Clone)]
438pub struct StatuslineArgs {
439    /// Command to generate the base line before appending blyte costs (5 s timeout; override in ms with BLYTE_STATUSLINE_AFTER_TIMEOUT_MS)
440    #[arg(long, value_name = "COMMAND")]
441    pub after: Option<String>,
442}
443
444#[derive(clap::Args, Debug, PartialEq, Clone)]
445pub struct PlanArgs {
446    /// Path to the plan markdown file
447    pub plan: PathBuf,
448
449    /// Output task statuses as JSON
450    #[arg(long)]
451    pub json: bool,
452}
453
454#[derive(clap::Args, Debug, PartialEq, Clone)]
455pub struct CommentsArgs {
456    /// Base commit or revision to compare the working tree against
457    #[arg(long, value_name = "REV")]
458    pub base: String,
459}
460
461#[derive(clap::Args, Debug, PartialEq, Clone)]
462pub struct InstructionsArgs {
463    /// Print the built-in default process and exit
464    #[arg(long, conflicts_with_all = ["one_shot", "dispatch_tool"])]
465    pub default_process: bool,
466
467    /// Show the instructions for a one-shot run
468    #[arg(long)]
469    pub one_shot: bool,
470
471    /// Show the instructions for `--dispatch-cmd` mode
472    #[arg(long)]
473    pub dispatch_tool: bool,
474
475    /// Show the instructions for sandbox 'on' or 'off'
476    #[arg(long, value_parser = ["on", "off"])]
477    pub sandbox: Option<String>,
478}
479
480#[derive(clap::Subcommand, Debug, PartialEq, Clone)]
481pub enum SkillAction {
482    /// Install the Claude Code skill
483    Install {
484        /// Install to repository instead of personal ~/.claude
485        #[arg(long)]
486        project: bool,
487
488        /// Overwrite even if existing skill was modified
489        #[arg(long)]
490        force: bool,
491
492        /// Also tell Claude Code to delegate implementation to blyte by default, in CLAUDE.md
493        #[arg(long, hide = true)]
494        default: bool,
495
496        /// Install the skill without making blyte the default in CLAUDE.md
497        #[arg(long)]
498        no_default: bool,
499
500        /// Do not set Claude Code's status line
501        #[arg(long)]
502        no_statusline: bool,
503
504        /// Do not set Claude Code's auto-compact window
505        #[arg(long)]
506        no_autocompact: bool,
507
508        /// Which conversation model to set up: claude (Claude Code), codex (Codex CLI) or all
509        #[arg(
510            long,
511            default_value = "claude",
512            value_parser = ["claude", "codex", "all"]
513        )]
514        harness: String,
515
516        /// Default implementer model to write to the env file
517        #[arg(long, value_name = "ID")]
518        model: Option<String>,
519    },
520
521    /// Remove the skill and the CLAUDE.md block
522    Uninstall {
523        /// Remove from repository instead of personal ~/.claude
524        #[arg(long)]
525        project: bool,
526
527        /// Which conversation model to set up: claude (Claude Code), codex (Codex CLI) or all
528        #[arg(
529            long,
530            default_value = "claude",
531            value_parser = ["claude", "codex", "all"]
532        )]
533        harness: String,
534    },
535
536    /// Print the skill markdown to stdout
537    Print,
538}
539
540#[derive(clap::Args, Debug, PartialEq, Clone)]
541pub struct SkillArgs {
542    #[command(subcommand)]
543    pub action: SkillAction,
544}
545
546#[derive(Parser, Debug, PartialEq)]
547#[command(
548    name = "blyte",
549    version = concat!(env!("CARGO_PKG_VERSION"), " (", env!("BLYTE_BUILD"), ")"),
550    about = "A lean coding-agent harness with a sealed verification gate\nBare `blyte` starts the live surface for the current repository.",
551    subcommand_precedence_over_arg = true
552)]
553pub struct Cli {
554    #[command(subcommand)]
555    pub command: Option<Command>,
556
557    /// Direct task prompt to run in single-shot / headless mode
558    #[arg(index = 1)]
559    pub prompt: Option<String>,
560
561    /// Verification gate command (e.g. 'pytest', 'cargo test'). Several steps may be given one per line: every step runs and all failures are reported together.
562    #[arg(short, long)]
563    pub gate: Option<String>,
564
565    /// Run blyte as the conversation model: plan, dispatch implementers with `blyte dispatch`, review and merge
566    #[arg(long, conflicts_with = "gate")]
567    pub converse: bool,
568
569    /// Command to run on the host when the conversation model delegates work via the `dispatch` tool
570    #[arg(long, requires = "converse")]
571    pub dispatch_cmd: Option<String>,
572
573    /// Context strategy: 'conversational' (append-all chat) or 'folded' (append-only chat, oldest half folded into digests past a budget)
574    #[arg(
575        long,
576        default_value = "folded",
577        value_parser = ["conversational", "folded"]
578    )]
579    pub context: String,
580
581    /// Model identifier or provider selection
582    #[arg(short, long)]
583    pub model: Option<String>,
584
585    /// Run inside an isolated container workspace instead of local host
586    #[arg(long)]
587    pub container: Option<String>,
588
589    /// Maximum turn budget
590    #[arg(long, default_value = "25")]
591    pub max_turns: usize,
592
593    /// Maximum verification gate attempts before failing
594    #[arg(long, default_value = "5")]
595    pub max_gates: usize,
596
597    /// Enable automatic rollback to baseline git commit if gate fails (disable with --rollback=false)
598    #[arg(
599        long,
600        default_value_t = true,
601        action = clap::ArgAction::Set,
602        num_args = 0..=1,
603        require_equals = true,
604        default_missing_value = "true",
605        value_parser = clap::builder::BoolishValueParser::new()
606    )]
607    pub rollback: bool,
608
609    /// Working directory inside the container when --container is set
610    #[arg(long, default_value = "/workspace")]
611    pub container_workdir: String,
612
613    /// Wall-clock budget in seconds; the run stops itself and reports when it is spent
614    #[arg(long)]
615    pub max_seconds: Option<u64>,
616
617    /// Maximum spend in USD; the run stops before a model call once reached
618    #[arg(long = "max-cost")]
619    pub max_cost_usd: Option<f64>,
620
621    /// Write a JSON run report to this path when the headless run exits
622    #[arg(long)]
623    pub report: Option<PathBuf>,
624
625    /// Approximate token budget for the verbatim tail before folding (folded context; default 48000)
626    #[arg(long)]
627    pub fold_budget: Option<usize>,
628
629    /// Sandbox the commands blyte runs on this machine (macOS Seatbelt, Linux Landlock): 'on' or 'off'
630    #[arg(
631        long,
632        default_value = "on",
633        value_parser = ["on", "off"]
634    )]
635    pub sandbox: String,
636
637    /// Let commands blyte runs connect out: 'on' or 'off' (default 'on', or 'off' under --converse). 'off' needs the sandbox
638    #[arg(
639        long,
640        value_parser = ["on", "off"]
641    )]
642    pub network: Option<String>,
643
644    /// Let sandboxed commands read this path despite the credential deny-list (repeatable)
645    #[arg(long = "allow-read")]
646    pub allow_read: Vec<PathBuf>,
647
648    /// Pass this environment variable to commands even though it looks like a credential (repeatable)
649    #[arg(long = "pass-env")]
650    pub pass_env: Vec<String>,
651
652    /// Directory allowed for reading with the read and grep tools (repeatable)
653    #[arg(long = "read-root", value_name = "DIR")]
654    pub read_roots: Vec<PathBuf>,
655
656    /// Gates in this run do not take a machine-wide slot
657    #[arg(long)]
658    pub no_gate_slot: bool,
659
660    #[arg(
661        long = "snapshot-dir",
662        hide = true,
663        value_name = "DIR",
664        requires = "snapshot_manifest",
665        conflicts_with_all = ["container", "converse"]
666    )]
667    pub snapshot_dir: Option<PathBuf>,
668
669    #[arg(
670        long = "snapshot-manifest",
671        hide = true,
672        value_name = "FILE",
673        requires = "snapshot_dir",
674        conflicts_with_all = ["container", "converse"]
675    )]
676    pub snapshot_manifest: Option<PathBuf>,
677
678    /// Whether this is a research run: periodically remind the model to keep report.md updated
679    #[arg(long)]
680    pub research: bool,
681
682    /// Research run: check report.md's claims against their cited lines
683    #[arg(long = "claim-check")]
684    pub claim_check: bool,
685
686    /// Run the verification gate once before the first model call and stop as blocked if it fails
687    #[arg(long = "base-check")]
688    pub base_check: bool,
689
690    /// Directory containing an untouched checkout of the base commit for running the base check beside the model's first turns
691    #[arg(long = "base-check-dir", value_name = "DIR")]
692    pub base_check_dir: Option<PathBuf>,
693
694    #[arg(
695        long,
696        help = "Run the surface in the terminal instead of opening the page"
697    )]
698    pub terminal: bool,
699
700    #[arg(
701        long,
702        value_name = "N",
703        help = "Port to listen on (default: a free port)"
704    )]
705    pub port: Option<u16>,
706
707    #[arg(long = "no-open", help = "Do not open the live surface in the browser")]
708    pub no_open: bool,
709
710    #[arg(
711        long = "open-in",
712        value_name = "app|browser",
713        help = "Open the live surface in an app window (`app`, default) or the default browser (`browser`)"
714    )]
715    pub open_in: Option<String>,
716
717    #[arg(
718        long,
719        value_name = "N",
720        value_parser = clap::value_parser!(u64).range(1..=31),
721        help = "How many days back to include finished runs in the live surface (1 to 31, default 14)"
722    )]
723    pub days: Option<u64>,
724
725    #[arg(
726        long,
727        value_name = "NAME",
728        help = "Name for this surface (default: the repository directory name)"
729    )]
730    pub name: Option<String>,
731
732    #[arg(
733        long,
734        value_name = "NAME",
735        conflicts_with = "name",
736        help = "Restart a stopped surface, by name or id, with its transcript"
737    )]
738    pub resume: Option<String>,
739
740    #[arg(
741        long,
742        help = "Keep the surface attached to the terminal instead of detaching"
743    )]
744    pub foreground: bool,
745
746    #[arg(
747        long,
748        conflicts_with = "resume",
749        help = "Start a fresh surface without prompting to open or resume"
750    )]
751    pub new: bool,
752}
753
754fn parse_from_label(raw: &str) -> Result<String, String> {
755    crate::surface_dir::validate_surface_name(raw)?;
756    Ok(raw.to_string())
757}
758
759/// Turn and context defaults for `--converse`. A flag the user gave explicitly wins.
760pub fn apply_converse_defaults(cli: &mut Cli, matches: &clap::ArgMatches) {
761    if !cli.converse {
762        return;
763    }
764    if matches.value_source("max_turns") == Some(clap::parser::ValueSource::DefaultValue) {
765        cli.max_turns = 1000;
766    }
767    if cli.fold_budget.is_none() {
768        cli.fold_budget = Some(100_000);
769    }
770}