-
-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathlib.rs
More file actions
249 lines (236 loc) · 6.83 KB
/
Copy pathlib.rs
File metadata and controls
249 lines (236 loc) · 6.83 KB
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
use clap::{Subcommand, ValueEnum};
pub mod commands;
pub mod config;
pub mod enterprise_cloud;
pub mod errors;
pub mod local_runtime;
pub mod metrics_sender;
pub mod output;
pub mod port;
pub mod project;
pub mod prompts;
pub mod setup;
pub mod sse_client;
pub mod ts_query;
pub mod update;
pub mod utils;
#[derive(Subcommand)]
pub enum AuthAction {
/// Login to Helix Cloud
Login,
/// Logout from Helix Cloud
Logout,
/// Rotate an Enterprise cluster API key
CreateKey {
/// Cluster ID
cluster: String,
},
}
#[derive(Subcommand)]
pub enum InitTarget {
/// Initialize a local v2 development project
Local {
/// Local instance name
#[arg(short, long, default_value = "dev")]
name: String,
/// Local gateway port
#[arg(long, default_value_t = crate::config::DEFAULT_LOCAL_PORT)]
port: u16,
/// Use on-disk storage backed by a local MinIO container
#[arg(long)]
disk: bool,
/// Install the Helix agent skills + docs MCP (prompted when interactive)
#[arg(long, conflicts_with = "no_skills")]
skills: bool,
/// Skip installing the Helix agent skills + docs MCP
#[arg(long = "no-skills", conflicts_with = "skills")]
no_skills: bool,
},
/// Initialize a Helix Cloud project
#[command(name = "cloud", alias = "enterprise")]
Enterprise {
/// Cloud instance name
#[arg(short, long, default_value = "production")]
name: String,
/// Cloud cluster ID; omit to pick one from the cluster list interactively
#[arg(long)]
cluster_id: Option<String>,
/// Runtime gateway URL for dynamic queries
#[arg(long)]
gateway_url: Option<String>,
/// Install the Helix agent skills + docs MCP (prompted when interactive)
#[arg(long, conflicts_with = "no_skills")]
skills: bool,
/// Skip installing the Helix agent skills + docs MCP
#[arg(long = "no-skills", conflicts_with = "skills")]
no_skills: bool,
},
}
impl InitTarget {
/// Resolve the `--skills`/`--no-skills` flags supplied *after* the
/// subcommand (e.g. `helix init local --no-skills`) into the same
/// `Option<bool>` shape used for the top-level flags. Returns `None` when
/// neither was set, so the caller can fall back to the parent-level flag.
pub fn skills_override(&self) -> Option<bool> {
let (skills, no_skills) = match self {
InitTarget::Local {
skills, no_skills, ..
}
| InitTarget::Enterprise {
skills, no_skills, ..
} => (*skills, *no_skills),
};
if skills {
Some(true)
} else if no_skills {
Some(false)
} else {
None
}
}
}
#[derive(Subcommand)]
pub enum AddTarget {
/// Add a local v2 development instance
Local {
/// Local instance name
#[arg(short, long)]
name: String,
/// Local gateway port
#[arg(long, default_value_t = crate::config::DEFAULT_LOCAL_PORT)]
port: u16,
/// Use on-disk storage backed by a local MinIO container
#[arg(long)]
disk: bool,
},
/// Add a Helix Cloud instance
#[command(name = "cloud", alias = "enterprise")]
Enterprise {
/// Cloud instance name
#[arg(short, long)]
name: String,
/// Cloud cluster ID; omit to pick one from the cluster list interactively
#[arg(long)]
cluster_id: Option<String>,
/// Runtime gateway URL for dynamic queries
#[arg(long)]
gateway_url: Option<String>,
},
}
#[derive(Subcommand)]
pub enum SkillsAction {
/// Install the Helix agent skills (npx skills add HelixDB/skills)
Install {
/// Install into the current project (.<agent>/skills) instead of globally
#[arg(long)]
project: bool,
},
/// Refresh installed Helix agent skills to the latest version
Update {
/// Operate on the current project instead of globally
#[arg(long)]
project: bool,
},
/// List installed agent skills
List {
/// List project skills instead of global skills
#[arg(long)]
project: bool,
},
}
#[derive(Subcommand)]
pub enum MetricsAction {
/// Enable full metrics collection
Full,
/// Enable basic metrics collection
Basic,
/// Disable metrics collection
Off,
/// Show metrics status
Status,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum, Default)]
pub enum ConfigOutputFormat {
#[default]
Human,
Json,
}
#[derive(Subcommand)]
pub enum ConfigAction {
/// Manage active workspace selection
Workspace {
#[command(subcommand)]
action: WorkspaceConfigAction,
},
/// Manage linked project selection
Project {
#[command(subcommand)]
action: ProjectConfigAction,
},
/// List Enterprise clusters
Cluster {
#[command(subcommand)]
action: ClusterConfigAction,
},
}
#[derive(Subcommand)]
pub enum WorkspaceConfigAction {
/// List accessible workspaces
List {
#[arg(long, value_enum, default_value_t = ConfigOutputFormat::Human)]
format: ConfigOutputFormat,
},
/// Show selected workspace
Show {
#[arg(long, value_enum, default_value_t = ConfigOutputFormat::Human)]
format: ConfigOutputFormat,
},
/// Select workspace by slug or ID
Switch {
workspace: String,
#[arg(long)]
id: bool,
},
}
#[derive(Subcommand)]
pub enum ProjectConfigAction {
/// List projects in the selected workspace
List {
#[arg(long)]
workspace_id: Option<String>,
#[arg(long, value_enum, default_value_t = ConfigOutputFormat::Human)]
format: ConfigOutputFormat,
},
/// Show linked project
Show {
#[arg(long, value_enum, default_value_t = ConfigOutputFormat::Human)]
format: ConfigOutputFormat,
},
/// Link this project to a cloud project by name or ID
Switch {
project: String,
#[arg(long)]
id: bool,
},
}
#[derive(Subcommand)]
pub enum ClusterConfigAction {
/// List Enterprise clusters
List {
#[arg(long)]
workspace_id: Option<String>,
#[arg(long)]
project_id: Option<String>,
#[arg(long, value_enum, default_value_t = ConfigOutputFormat::Human)]
format: ConfigOutputFormat,
},
/// List indexes in an Enterprise cluster
#[command(alias = "indices")]
Indexes {
/// Enterprise cluster ID; defaults to the current project's Enterprise instance
#[arg(long, value_name = "CLUSTER_ID")]
cluster_id: Option<String>,
#[arg(long, value_enum, default_value_t = ConfigOutputFormat::Human)]
format: ConfigOutputFormat,
},
}