Skip to main content

vela_cli/cli/
surface.rs

1//! The released command surface: the deny/curation lists, the derived
2//! `is_science_subcommand` gate, and the curated `vela help advanced`
3//! text.
4
5use super::*;
6
7/// Names retired from the core binary in v0.900. They remain here so the
8/// dispatch gate cannot accidentally revive a stale alias.
9const RELEASE_DENY: &[&str] = &[
10    "atlas",
11    "credit",
12    "diff",
13    "foundry",
14    "hub",
15    "proposals",
16    "publication",
17    "reproduce-external",
18];
19
20/// Names omitted from the advanced menu. `completions` remains callable but
21/// hidden; the rest are retired names retained for concise migration guidance.
22#[cfg(test)]
23pub(crate) const HIDDEN_FROM_ADVANCED_HELP: &[&str] = &[
24    "atlas",
25    "completions",
26    "credit",
27    "diff",
28    "foundry",
29    "hub",
30    "proposals",
31    "publication",
32    "reproduce-external",
33];
34
35/// Whether `name` is a released top-level command the dispatcher will hand
36/// to clap. Derived from the clap command tree (`Cli::command()`), not a
37/// hand-maintained list, so a newly-added subcommand — or any of its
38/// aliases — is accepted the instant it exists. `surface.rs`'s unit tests
39/// pin this to the enum so the derivation can never silently drop a
40/// command. (Pre-clap intercepts like `claim state` / `proof verify` are
41/// matched in `run_from_args` before this gate, so they need no entry.)
42/// The released top-level command names + aliases, derived once from the
43/// clap tree and memoized. Building the full command tree is not free, so
44/// caching keeps `is_science_subcommand` O(1) per dispatch instead of
45/// rebuilding ~226 nodes every call.
46fn released_command_names() -> &'static std::collections::HashSet<String> {
47    use std::sync::OnceLock;
48    static NAMES: OnceLock<std::collections::HashSet<String>> = OnceLock::new();
49    NAMES.get_or_init(|| {
50        use clap::CommandFactory;
51        let mut set = std::collections::HashSet::new();
52        for c in Cli::command().get_subcommands() {
53            set.insert(c.get_name().to_string());
54            for a in c.get_all_aliases() {
55                set.insert(a.to_string());
56            }
57        }
58        set
59    })
60}
61
62pub fn is_science_subcommand(name: &str) -> bool {
63    if RELEASE_DENY.contains(&name) {
64        return false;
65    }
66    released_command_names().contains(name)
67}
68
69pub(crate) fn print_strict_help() {
70    print!("{}", strict_help_text());
71}
72
73/// The curated, grouped command reference (`vela help advanced`). Kept
74/// hand-curated for legibility — clap's flat alphabetical dump is worse UX —
75/// but `mod surface_tests` asserts every released subcommand appears here,
76/// so it can never silently omit a newly-added command (the drift the old
77/// hand-maintained allowlist suffered, now caught at the help layer too).
78pub(crate) fn strict_help_text() -> String {
79    let retired_line = RELEASE_DENY.join(", ");
80    format!(
81        r#"Vela {}
82Version control for scientific state.
83Agents land. Verifiers reproduce. Humans approve. Git publishes.
84
85Usage:
86  vela <COMMAND>
87
88Daily product:
89  init          Create a minimal Git-native frontier
90  status        Compact frontier identity, roots, counts, and next action
91  next          Ranked producer work only
92  work          Claim one target and open a private typed session
93  land          Land Receipt v1; policy admits, defers, or denies
94  review        Inspect, decide, or producer-withdraw one exact proposal
95  check         Replay, signatures, parity, and strict signals
96  reproduce     Re-run stored witnesses with frozen verifiers
97  verify        Retain non-authorizing proposal-scoped verifier evidence
98  log           Recent signed events or one finding's history
99  doctor        Blockers plus one safe next action
100  migrate       Preview or apply a root-preserving repository migration
101
102Nouns and setup:
103  finding       record, standing, evidence, and attribution views
104  artifact      content-addressed evidence lifecycle
105  frontier      materialize, compare, recover publication, release, audit
106  policy        standing authority rules and their human ceremonies
107  actor         governed frontier identities
108  id            local identity and key custody setup
109  agents        regenerate agent adapters from VELA.md
110  config        closed local/frontier configuration
111
112Advanced verification and integration:
113  gate          claim-level verification projections
114  proof         proof packet export, verify, and explain
115  ci            deterministic CI verdicts
116  serve         read-only or nonfinalizing draft MCP/HTTP surface
117  sign          historical batch and detached-file signing compatibility
118
119Hidden utility:
120  completions   generate shell completion scripts
121
122Retired from the core product: {}
123"#,
124        env!("CARGO_PKG_VERSION"),
125        retired_line,
126    )
127}