use clap::{ArgGroup, Subcommand};
use std::path::PathBuf;
pub(crate) const HELP_AS: &str = "Acting identity for this write (reviewer:<you> or agent:<name>). Optional: defaults to your `vela id`";
pub(crate) const HELP_REQUIRED_AS: &str =
"Exact acting identity for this write (reviewer:<you> or agent:<name>)";
pub(crate) const HELP_AS_OF: &str = "Answer as of this RFC3339 instant, e.g. 2026-07-02T16:00:00Z";
#[derive(Subcommand, Debug)]
pub enum ConfigAction {
Get {
key: String,
#[arg(long)]
frontier: Option<PathBuf>,
#[arg(long)]
json: bool,
},
Set {
key: String,
value: String,
#[arg(long)]
frontier: Option<PathBuf>,
#[arg(long)]
json: bool,
},
Unset {
key: String,
#[arg(long)]
frontier: Option<PathBuf>,
#[arg(long)]
json: bool,
},
List {
#[arg(long)]
frontier: Option<PathBuf>,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub(crate) enum Commands {
#[command(hide = true)]
Repository {
#[command(subcommand)]
action: RepositoryAction,
},
#[command(after_long_help = crate::cli::help_text::CHECK)]
Check {
source: Option<PathBuf>,
#[arg(long)]
strict: bool,
#[arg(long)]
json: bool,
},
#[command(after_long_help = crate::cli::help_text::DOCTOR)]
Doctor {
frontier: Option<PathBuf>,
#[arg(long)]
all: bool,
#[arg(long)]
json: bool,
},
#[command(after_long_help = crate::cli::help_text::STATUS)]
Status {
frontier: Option<PathBuf>,
#[arg(long)]
json: bool,
},
#[command(after_long_help = crate::cli::help_text::LOG)]
Log {
frontier: Option<PathBuf>,
object_id: Option<String>,
#[arg(long, default_value = "20")]
limit: usize,
#[arg(long)]
kind: Option<String>,
#[arg(long = "as-of", help = HELP_AS_OF)]
as_of: Option<String>,
#[arg(long)]
json: bool,
},
#[command(after_long_help = crate::cli::help_text::VERIFY)]
Verification {
#[command(subcommand)]
action: VerifyAction,
},
#[command(after_long_help = crate::cli::help_text::AGENTS)]
Agents {
#[command(subcommand)]
action: AgentsAction,
},
#[command(after_long_help = crate::cli::help_text::REPRODUCE)]
Reproduce {
#[arg(default_value = ".")]
path: PathBuf,
#[arg(long)]
proposal: Option<String>,
#[arg(long)]
json: bool,
},
#[command(after_long_help = crate::cli::help_text::ID)]
Id {
#[command(subcommand)]
action: IdAction,
},
#[command(hide = true)]
Authority {
#[command(subcommand)]
action: AuthorityAction,
},
#[command(after_long_help = crate::cli::help_text::INIT)]
Init {
#[arg(default_value = ".")]
path: PathBuf,
#[arg(long)]
name: Option<String>,
#[arg(long)]
scope: Option<String>,
#[arg(long)]
json: bool,
},
#[command(after_long_help = crate::cli::help_text::REVIEW)]
Review {
#[command(subcommand)]
action: ReviewAction,
},
#[command(hide = true)]
TargetIndex {
#[command(subcommand)]
action: TargetIndexAction,
},
#[command(after_long_help = crate::cli::help_text::CLAIM)]
Claim {
#[command(subcommand)]
command: ClaimCommands,
},
#[command(after_long_help = crate::cli::help_text::SHOW)]
Show {
frontier: PathBuf,
object_id: String,
#[arg(long)]
json: bool,
},
#[command(after_long_help = crate::cli::help_text::WHY)]
Why {
frontier: PathBuf,
claim_id: String,
#[arg(long)]
json: bool,
},
#[command(after_long_help = crate::cli::help_text::NEXT)]
Next {
frontier: Option<PathBuf>,
#[arg(long, default_value_t = 5)]
limit: usize,
#[arg(long)]
json: bool,
},
#[command(after_long_help = crate::cli::help_text::START)]
Start {
target: Option<String>,
#[arg(long)]
frontier: Option<PathBuf>,
#[arg(long)]
ttl: Option<u64>,
#[arg(long)]
drop: bool,
#[arg(long)]
reason: Option<String>,
#[arg(long, help = HELP_AS)]
r#as: Option<String>,
#[arg(long)]
json: bool,
},
#[command(group(
ArgGroup::new("submission_change")
.multiple(false)
.args(["corrects", "supersedes"])
))]
#[command(after_long_help = crate::cli::help_text::SUBMIT)]
Submit {
submission: Option<PathBuf>,
#[arg(long)]
frontier: Option<PathBuf>,
#[arg(long)]
claim: Option<String>,
#[arg(long = "type")]
claim_type: Option<String>,
#[arg(long)]
condition: Vec<String>,
#[arg(long)]
replayability: Option<String>,
#[arg(long)]
artifact: Vec<String>,
#[arg(long)]
caveat: Vec<String>,
#[arg(long = "check")]
producer_check: Vec<String>,
#[arg(long = "requires-verification")]
verification_requirement: Vec<String>,
#[arg(long, conflicts_with = "submission", requires = "target_root")]
corrects: Option<String>,
#[arg(long, conflicts_with = "submission", requires = "target_root")]
supersedes: Option<String>,
#[arg(long, conflicts_with = "submission", requires = "submission_change")]
target_root: Option<String>,
#[arg(long, conflicts_with = "submission", requires_all = ["profile_root", "verifier_capsule_root", "result_contract_root"])]
packet_root: Option<String>,
#[arg(long, conflicts_with = "submission", requires_all = ["packet_root", "verifier_capsule_root", "result_contract_root"])]
profile_root: Option<String>,
#[arg(long, conflicts_with = "submission", requires_all = ["packet_root", "profile_root", "result_contract_root"])]
verifier_capsule_root: Option<String>,
#[arg(long, conflicts_with = "submission", requires_all = ["packet_root", "profile_root", "verifier_capsule_root"])]
result_contract_root: Option<String>,
#[arg(long)]
attempt: Option<String>,
#[arg(long, help = HELP_AS)]
r#as: Option<String>,
#[arg(long)]
push: bool,
#[arg(long)]
json: bool,
},
#[command(after_long_help = crate::cli::help_text::CONFIG)]
Config {
#[command(subcommand)]
action: ConfigAction,
},
#[command(hide = true)]
Completions {
shell: String,
},
}
#[derive(Subcommand)]
pub(crate) enum TargetIndexAction {
#[command(group(ArgGroup::new("target_index_seal_mode").required(true).multiple(false).args(["check", "apply"])))]
Seal {
frontier: PathBuf,
#[arg(long)]
candidate: PathBuf,
#[arg(long)]
check: bool,
#[arg(long)]
apply: bool,
#[arg(long)]
json: bool,
},
Repair {
frontier: PathBuf,
#[arg(long)]
json: bool,
},
Inspect {
frontier: PathBuf,
target_id: Option<String>,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub(crate) enum IdAction {
Create {
#[arg(long)]
handle: Option<String>,
#[arg(long)]
agent: bool,
#[arg(long)]
force: bool,
#[arg(long)]
json: bool,
},
Show {
#[arg(long)]
json: bool,
},
#[command(hide = true)]
Import {
#[arg(long)]
key: PathBuf,
#[arg(long)]
handle: Option<String>,
#[arg(long, required = true)]
agent: bool,
#[arg(long)]
force: bool,
#[arg(long)]
json: bool,
},
#[command(hide = true)]
Keygen {
#[arg(long, default_value = ".vela/keys")]
out: PathBuf,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub(crate) enum AgentsAction {
Sync {
#[arg(default_value = ".")]
root: PathBuf,
#[arg(long)]
json: bool,
},
Doctor {
#[arg(default_value = ".")]
root: PathBuf,
#[arg(long)]
json: bool,
},
Diff {
#[arg(default_value = ".")]
root: PathBuf,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub(crate) enum VerifyAction {
Import {
frontier: PathBuf,
record: PathBuf,
#[arg(long = "as", help = HELP_REQUIRED_AS)]
actor: String,
#[arg(long)]
push: bool,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub(crate) enum AuthorityAction {
Init {
#[arg(default_value = ".")]
frontier: PathBuf,
#[arg(long)]
key: Option<String>,
#[arg(long)]
reason: String,
#[arg(long)]
json: bool,
},
Trust {
#[command(subcommand)]
action: AuthorityTrustAction,
},
}
#[derive(Subcommand)]
pub(crate) enum AuthorityTrustAction {
Pin {
#[arg(default_value = ".")]
frontier: PathBuf,
#[arg(long)]
record_root: String,
#[arg(long)]
previous_record_root: Option<String>,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub(crate) enum RepositoryAction {
Verify {
#[arg(default_value = ".")]
frontier: PathBuf,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub(crate) enum ClaimCommands {
Show {
frontier: PathBuf,
claim_id: String,
#[arg(long, default_value = "record")]
view: String,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub(crate) enum ReviewAction {
List {
frontier: PathBuf,
#[arg(long)]
status: Option<String>,
#[arg(long, default_value_t = 50)]
limit: usize,
#[arg(long)]
cursor: Option<String>,
#[arg(long)]
json: bool,
},
Show {
frontier: PathBuf,
proposal_id: String,
#[arg(long)]
json: bool,
},
Accept {
frontier: PathBuf,
proposal_id: String,
#[arg(long)]
reason: String,
#[arg(long)]
json: bool,
},
Reject {
frontier: PathBuf,
proposal_id: String,
#[arg(long)]
reason: String,
#[arg(long)]
json: bool,
},
}