pub(super) const MUSE_SIGNED_OUT: &str = "muse usage: not logged in: run `muse login` first";
pub(super) const MUSE_TURN_SIGNED_OUT: &str =
"missing meta credentials: run `muse login` or set META_API_KEY";
const CURSOR_EXPIRED: &str = "Authentication failed: your Cursor credentials or API key are invalid or expired.\nIf you set CURSOR_API_KEY, check that it is correct, or run `cursor-agent login` to re-authenticate.";
pub(super) fn cursor_signed_out(stderr: &str) -> bool {
let said = stderr.trim();
let missing = said
.strip_prefix("Error: Authentication required. Run '")
.is_some_and(|rest| {
rest.ends_with(
" login', pass --api-key/--auth-token, or set CURSOR_API_KEY/CURSOR_AUTH_TOKEN.",
) && !rest.contains('\n')
});
missing || said == CURSOR_EXPIRED
}
pub(super) fn cursor_turn_signed_out(line: &str) -> bool {
line.strip_prefix("Error: Authentication required. Please run '")
.and_then(|rest| {
rest.strip_suffix(" login' first, or set CURSOR_API_KEY environment variable.")
})
.is_some_and(|name| !name.is_empty() && !name.contains(char::is_whitespace))
}
pub(super) fn vibe_turn_signed_out(line: &str) -> bool {
let named =
|word: &str, allowed: fn(char) -> bool| !word.is_empty() && word.chars().all(allowed);
line.strip_prefix("Error: Missing ")
.and_then(|rest| rest.strip_suffix(" provider"))
.and_then(|rest| rest.split_once(" environment variable for "))
.is_some_and(|(var, provider)| {
named(var, |c| {
c.is_ascii_uppercase() || c.is_ascii_digit() || c == '_'
}) && named(provider, |c| {
c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-'
})
})
}