Skip to main content

life_cli/
cli.rs

1//! CLI argument definitions for `life`.
2
3use clap::{Parser, Subcommand};
4
5use crate::relay::RelayCommand;
6
7#[derive(Parser)]
8#[command(
9    name = "life",
10    about = "Agent Operating System — deploy, configure, and manage agents",
11    version,
12    propagate_version = true
13)]
14pub struct Cli {
15    #[command(subcommand)]
16    pub command: Option<Command>,
17}
18
19#[derive(Subcommand)]
20pub enum Command {
21    /// Initialize a .life/ directory in the current project.
22    Init,
23
24    /// Interactive setup wizard — configure providers, keys, and modules.
25    Setup,
26
27    /// Deploy an agent to a cloud target.
28    Deploy(DeployArgs),
29
30    /// Check the status of a deployed agent.
31    Status(StatusArgs),
32
33    /// List all deployed agents.
34    List(ListArgs),
35
36    /// Tear down a deployed agent and all its services.
37    Destroy(DestroyArgs),
38
39    /// Manage agent templates.
40    Templates(TemplateArgs),
41
42    /// Show cost tracking for a deployed agent.
43    Cost(CostArgs),
44
45    /// Stream logs from a deployed agent's services.
46    Logs(LogsArgs),
47
48    /// Scale agent services based on Autonomic economic modes.
49    Scale(ScaleArgs),
50
51    /// Manage the relay daemon for remote agent sessions.
52    Relay {
53        #[command(subcommand)]
54        command: RelayCommand,
55    },
56}
57
58#[derive(clap::Args)]
59pub struct DeployArgs {
60    /// Agent template name (e.g., coding-agent, data-agent, support-agent).
61    #[arg(long, short)]
62    pub agent: String,
63
64    /// Deployment target (railway, flyio, ecs).
65    #[arg(long, short, default_value = "railway")]
66    pub target: String,
67
68    /// LLM provider for the agent runtime (anthropic, openai, mock).
69    #[arg(long, default_value = "anthropic")]
70    pub provider: String,
71
72    /// Custom project name override (defaults to life-{agent}).
73    #[arg(long)]
74    pub project_name: Option<String>,
75
76    /// Path to custom template file (overrides built-in templates).
77    #[arg(long)]
78    pub template_path: Option<String>,
79
80    /// Skip health check polling after deployment.
81    #[arg(long)]
82    pub no_wait: bool,
83
84    /// Environment variables to pass to all services (KEY=VALUE).
85    #[arg(long, short = 'e')]
86    pub env: Vec<String>,
87}
88
89#[derive(clap::Args)]
90pub struct StatusArgs {
91    /// Agent name or Railway project ID.
92    #[arg(long, short)]
93    pub agent: String,
94
95    /// Deployment target.
96    #[arg(long, short, default_value = "railway")]
97    pub target: String,
98
99    /// Output format (table, json).
100    #[arg(long, default_value = "table")]
101    pub format: String,
102}
103
104#[derive(clap::Args)]
105pub struct ListArgs {
106    /// Output format (table, json).
107    #[arg(long, default_value = "table")]
108    pub format: String,
109}
110
111#[derive(clap::Args)]
112pub struct DestroyArgs {
113    /// Agent name or Railway project ID.
114    #[arg(long, short)]
115    pub agent: String,
116
117    /// Deployment target.
118    #[arg(long, short, default_value = "railway")]
119    pub target: String,
120
121    /// Skip confirmation prompt.
122    #[arg(long, short = 'y')]
123    pub yes: bool,
124}
125
126#[derive(clap::Args)]
127pub struct TemplateArgs {
128    #[command(subcommand)]
129    pub command: TemplateCommand,
130}
131
132#[derive(Subcommand)]
133pub enum TemplateCommand {
134    /// List available agent templates.
135    List,
136    /// Show details of a specific template.
137    Show {
138        /// Template name.
139        name: String,
140    },
141}
142
143#[derive(clap::Args)]
144pub struct CostArgs {
145    /// Agent name.
146    #[arg(long, short)]
147    pub agent: String,
148
149    /// Deployment target.
150    #[arg(long, short, default_value = "railway")]
151    pub target: String,
152
153    /// Time window for cost data (1h, 24h, 7d, 30d).
154    #[arg(long, default_value = "24h")]
155    pub window: String,
156
157    /// Output format (table, json).
158    #[arg(long, default_value = "table")]
159    pub format: String,
160}
161
162#[derive(clap::Args)]
163pub struct LogsArgs {
164    /// Agent name.
165    #[arg(long, short)]
166    pub agent: String,
167
168    /// Specific service to stream logs from (streams all if omitted).
169    #[arg(long, short)]
170    pub service: Option<String>,
171
172    /// Deployment target.
173    #[arg(long, short, default_value = "railway")]
174    pub target: String,
175
176    /// Number of recent log lines to show (0 = stream live only).
177    #[arg(long, short, default_value = "50")]
178    pub lines: u32,
179}
180
181#[derive(clap::Args)]
182pub struct ScaleArgs {
183    /// Agent name.
184    #[arg(long, short)]
185    pub agent: String,
186
187    /// Service to scale (scales arcan by default).
188    #[arg(long, short, default_value = "arcan")]
189    pub service: String,
190
191    /// Number of replicas (overrides auto-scaling).
192    #[arg(long, short)]
193    pub replicas: Option<u32>,
194
195    /// Use Autonomic economic mode to determine scale.
196    /// Queries the Autonomic service and scales based on its recommendation.
197    #[arg(long)]
198    pub auto: bool,
199
200    /// Deployment target.
201    #[arg(long, short, default_value = "railway")]
202    pub target: String,
203}