Mirror of github.com/getsigit/si.
Mirrored from https://github.com/getsigit/si.git
Synced Nov 24, 08:15 UTC
Add account commands and si models
si auth signup creates an account with a confirmed password prompt, si auth resend sends the confirmation email again (the hint in the unverified-email message already pointed at it), si auth reset-password emails reset instructions, and si auth delete-account asks you to type your email before deleting, or takes --yes. si models lists the models a session can use. The client crate gets reset_password and models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seto Elkahfi committed
Oct 28, 2026 at 10:14 UTC
04c82c59cb18d990a2b6f5c50906bf5378abce37
10 files changed
+215
-2
crates/cli/src/cli.rs
+24
@@ -66,6 +66,9 @@ pub enum Command {
66
#[command(subcommand)]
67
Billing(BillingCommand),
68
69
+ /// List the models a session can use.
70
+ Models,
71
+
72
/// Open something on sigit.si in your browser.
73
Browse(BrowseArgs),
74
@@ -88,6 +91,27 @@ pub enum AuthCommand {
91
Logout,
92
/// Show who is currently signed in.
93
Status,
94
+ /// Create a sigit.si account. A confirmation email follows.
95
+ Signup {
96
+ #[arg(long)]
97
+ email: Option<String>,
98
+ },
99
+ /// Send the confirmation email again.
100
+ Resend {
101
+ #[arg(long)]
102
+ email: Option<String>,
103
+ },
104
+ /// Email instructions for choosing a new password.
105
+ ResetPassword {
106
+ #[arg(long)]
107
+ email: Option<String>,
108
+ },
109
+ /// Permanently delete your account.
110
+ DeleteAccount {
111
+ /// Skip the typed confirmation.
112
+ #[arg(short, long)]
113
+ yes: bool,
114
+ },
115
/// Let git use your sigit.si sign-in for clones and fetches, by adding a
116
/// credential helper to your global git config.
117
SetupGit,
crates/cli/src/commands/auth.rs
+67
@@ -15,6 +15,10 @@ pub async fn run(ctx: &Ctx, command: AuthCommand) -> Result<()> {
15
AuthCommand::Login { email } => login(ctx, email).await,
16
AuthCommand::Logout => logout(ctx).await,
17
AuthCommand::Status => status(ctx).await,
18
+ AuthCommand::Signup { email } => signup(ctx, email).await,
19
+ AuthCommand::Resend { email } => resend(ctx, email).await,
20
+ AuthCommand::ResetPassword { email } => reset_password(ctx, email).await,
21
+ AuthCommand::DeleteAccount { yes } => delete_account(ctx, yes).await,
22
AuthCommand::SetupGit => setup_git(ctx),
23
AuthCommand::GitCredential { operation } => git_credential(ctx, operation).await,
24
}
@@ -51,6 +55,69 @@ async fn git_credential(ctx: &Ctx, operation: GitCredentialOperation) -> Result<
55
Ok(())
56
}
57
58
+fn email_or_prompt(email: Option<String>) -> Result<String> {
59
+ match email {
60
+ Some(email) => Ok(email),
61
+ None => ui::prompt::text("Email"),
62
+ }
63
+}
64
+
65
+async fn signup(ctx: &Ctx, email: Option<String>) -> Result<()> {
66
+ let email = email_or_prompt(email)?;
67
+ let password = ui::prompt::new_password("Password")?;
68
+
69
+ let result = ctx.client.sign_up(&email, &password).await?;
70
+ ui::emit(ctx.json, &result, |result| {
71
+ let message = result["message"]
72
+ .as_str()
73
+ .unwrap_or("Signed up. Check your email to confirm your account.");
74
+ ui::success(message);
75
+ ui::note("Once it is confirmed, run `si auth login`.");
76
+ })
77
+}
78
+
79
+async fn resend(ctx: &Ctx, email: Option<String>) -> Result<()> {
80
+ let email = email_or_prompt(email)?;
81
+ ctx.client.resend_confirmation(&email).await?;
82
+ ui::success(format!(
83
+ "If {} has an account that is not confirmed yet, a new email is on its way.",
84
+ ui::highlight(&email)
85
+ ));
86
+ Ok(())
87
+}
88
+
89
+async fn reset_password(ctx: &Ctx, email: Option<String>) -> Result<()> {
90
+ let email = email_or_prompt(email)?;
91
+ ctx.client.reset_password(&email).await?;
92
+ ui::success(format!(
93
+ "If {} has an account, reset instructions are on their way.",
94
+ ui::highlight(&email)
95
+ ));
96
+ Ok(())
97
+}
98
+
99
+async fn delete_account(ctx: &Ctx, yes: bool) -> Result<()> {
100
+ ctx.require_token()?;
101
+
102
+ if !yes {
103
+ let user = ctx.client.user().await?;
104
+ ui::note(format!(
105
+ "This permanently deletes the account {} and everything in it.",
106
+ user.email
107
+ ));
108
+ let typed = ui::prompt::text(&format!("Type {} to confirm", user.email))?;
109
+ if !typed.trim().eq_ignore_ascii_case(&user.email) {
110
+ ui::note("Cancelled.");
111
+ return Ok(());
112
+ }
113
+ }
114
+
115
+ ctx.client.delete_account().await?;
116
+ config::clear_token(ctx.environment)?;
117
+ ui::success("Your account was deleted.");
118
+ Ok(())
119
+}
120
+
121
async fn login(ctx: &Ctx, email: Option<String>) -> Result<()> {
122
let email = match email {
123
Some(email) => email,
crates/cli/src/commands/mod.rs
+1
@@ -6,6 +6,7 @@ pub mod code;
6
pub mod hook;
7
pub mod issue;
8
pub mod me;
9
+pub mod models;
10
pub mod pr;
11
pub mod repo;
12
pub mod run;
crates/cli/src/commands/models.rs
new
+10
@@ -0,0 +1,10 @@
1
+use {
2
+ crate::{context::Ctx, ui},
3
+ anyhow::Result,
4
+};
5
+
6
+/// The model list is public, so this works without signing in.
7
+pub async fn run(ctx: &Ctx) -> Result<()> {
8
+ let models = ctx.client.models().await?;
9
+ ui::emit(ctx.json, &models, |models| ui::render::models(models))
10
+}
crates/cli/src/main.rs
+1
@@ -52,6 +52,7 @@ async fn run() -> Result<()> {
52
Command::Hook(command) => commands::hook::run(&ctx, command).await,
53
Command::Session(command) => commands::session::run(&ctx, command).await,
54
Command::Billing(command) => commands::billing::run(&ctx, command).await,
55
+ Command::Models => commands::models::run(&ctx).await,
56
Command::Browse(args) => commands::browse::run(&ctx, args).await,
57
Command::Api(args) => commands::api::run(&ctx, args).await,
58
// Takes `ctx` by value: the server outlives the dispatch, serving
crates/cli/src/ui/prompt.rs
+9
@@ -32,6 +32,15 @@ pub fn password(label: &str) -> Result<String> {
32
.interact()?)
33
}
34
35
+/// A new password, asked for twice.
36
+pub fn new_password(label: &str) -> Result<String> {
37
+ require_tty(label)?;
38
+ Ok(Password::with_theme(&ColorfulTheme::default())
39
+ .with_prompt(label)
40
+ .with_confirmation("Repeat the password", "The passwords do not match.")
41
+ .interact()?)
42
+}
43
+
44
/// A yes/no confirmation. Non-interactive callers should not reach this at
45
/// all for destructive actions — check `--yes` first — but reads default to
46
/// `default` here rather than erroring, since a TTY-less "confirm the details
crates/cli/src/ui/render.rs
+28
-1
@@ -6,7 +6,8 @@ use {
6
console::style,
7
sigit_si_api::models::{
8
AgentRun, Billing, CloudSession, CodeHit, CombinedStatus, Comment, Hook, Issue,
9
- IssueSummary, PullRequest, PullRequestSummary, Repository, RepositorySummary, Site, User,
9
+ IssueSummary, Model, PullRequest, PullRequestSummary, Repository, RepositorySummary, Site,
10
+ User,
11
},
12
tabled::{builder::Builder, settings::Style},
13
};
@@ -493,6 +494,32 @@ pub fn site(site: &Site) {
494
println!();
495
}
496
497
+// ── Models ──────────────────────────────────────────────────────────────────
498
+
499
+pub fn models(models: &[Model]) {
500
+ let rows = models
501
+ .iter()
502
+ .map(|model| {
503
+ vec![
504
+ model.id.clone(),
505
+ model
506
+ .display_name
507
+ .clone()
508
+ .unwrap_or_else(|| "—".to_string()),
509
+ model.capability.clone().unwrap_or_else(|| "—".to_string()),
510
+ if model.vision { "yes" } else { "no" }.to_string(),
511
+ if model.default { "default" } else { "" }.to_string(),
512
+ ]
513
+ })
514
+ .collect();
515
+
516
+ table(
517
+ &["Model", "Name", "Capability", "Vision", ""],
518
+ rows,
519
+ "No models are available right now.",
520
+ );
521
+}
522
+
523
// ── Billing ─────────────────────────────────────────────────────────────────
524
525
pub fn billing(billing: &Billing) {
crates/sigit-si-api/src/account.rs
+38
@@ -48,6 +48,18 @@ impl Client {
48
.await
49
}
50
51
+ /// `POST /api/v1/auth/password/reset` — emails reset instructions. The
52
+ /// server answers the same way whether or not the address has an account.
53
+ pub async fn reset_password(&self, email: &str) -> Result<()> {
54
+ self.send_empty(self.reset_password_request(email)).await
55
+ }
56
+
57
+ fn reset_password_request(&self, email: &str) -> reqwest::RequestBuilder {
58
+ let body = serde_json::json!({ "email": email.trim().to_ascii_lowercase() });
59
+ self.request(Method::POST, "auth/password/reset")
60
+ .json(&body)
61
+ }
62
+
63
/// `DELETE /api/v1/me` — permanently deletes the signed-in account.
64
pub async fn delete_account(&self) -> Result<()> {
65
self.delete("me").await
@@ -69,3 +81,29 @@ pub fn incomplete_reason(status: u32) -> &'static str {
81
_ => "Your account is not ready to sign in yet. Finish setting it up at https://sigit.si/auth.",
82
}
83
}
84
+
85
+#[cfg(test)]
86
+mod tests {
87
+ use {super::*, crate::Environment};
88
+
89
+ #[test]
90
+ fn a_reset_posts_the_normalized_email() {
91
+ let client = Client::builder(Environment::Production)
92
+ .base_url("https://sigit.si")
93
+ .build()
94
+ .unwrap();
95
+ let request = client
96
+ .reset_password_request(" Seto@Example.com ")
97
+ .build()
98
+ .unwrap();
99
+
100
+ assert_eq!(request.method(), Method::POST);
101
+ assert_eq!(
102
+ request.url().as_str(),
103
+ "https://sigit.si/api/v1/auth/password/reset"
104
+ );
105
+ let body = request.body().and_then(|b| b.as_bytes()).unwrap();
106
+ let body: serde_json::Value = serde_json::from_slice(body).unwrap();
107
+ assert_eq!(body["email"], "seto@example.com");
108
+ }
109
+}
crates/sigit-si-api/src/models.rs
+15
@@ -210,6 +210,21 @@ pub struct Site {
210
pub bytes: i64,
211
}
212
213
+// ── Models ──────────────────────────────────────────────────────────────────
214
+
215
+/// One entry of `GET /api/v1/models`, the models you can pick for a session.
216
+#[derive(Debug, Clone, Deserialize, Serialize)]
217
+pub struct Model {
218
+ pub id: String,
219
+ pub display_name: Option<String>,
220
+ pub capability: Option<String>,
221
+ #[serde(default)]
222
+ pub vision: bool,
223
+ /// Set on the model the calling client uses when none is named.
224
+ #[serde(default)]
225
+ pub default: bool,
226
+}
227
+
228
// ── MCP-backed resources ────────────────────────────────────────────────────
229
//
230
// Issues, pull requests, and code search have no REST surface; they are served
crates/sigit-si-api/src/sessions.rs
+22
-1
@@ -3,7 +3,7 @@
3
use crate::{
4
client::Client,
5
error::Result,
6
- models::{AppendedMessage, CloudSession},
6
+ models::{AppendedMessage, CloudSession, Model},
7
};
8
9
impl Client {
@@ -37,6 +37,17 @@ impl Client {
37
.await
38
}
39
40
+ /// `GET /api/v1/models` — the models a session can use. The server lists
41
+ /// them in the OpenAI shape, `{"data": [...]}`; this unwraps it.
42
+ pub async fn models(&self) -> Result<Vec<Model>> {
43
+ #[derive(serde::Deserialize)]
44
+ struct Models {
45
+ data: Vec<Model>,
46
+ }
47
+ let models: Models = self.get("models").await?;
48
+ Ok(models.data)
49
+ }
50
+
51
/// `DELETE /api/v1/sessions/:id`
52
pub async fn delete_session(&self, id: i64) -> Result<()> {
53
self.delete(&format!("sessions/{id}")).await
@@ -71,6 +82,16 @@ fn session_body(title: Option<&str>, model: Option<&str>) -> serde_json::Value {
82
mod tests {
83
use super::*;
84
85
+ #[test]
86
+ fn a_model_without_the_default_flag_is_not_the_default() {
87
+ let model: Model = serde_json::from_str(
88
+ r#"{"id":"m","object":"model","owned_by":"sigit","display_name":"M",
89
+ "capability":"fast","vision":false}"#,
90
+ )
91
+ .unwrap();
92
+ assert!(!model.default);
93
+ }
94
+
95
#[test]
96
fn omitted_fields_stay_out_of_the_update_body() {
97
let body = session_body(Some("Refactor auth"), None);