Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ jobs:
with:
tool: cargo-llvm-cov

# tests/tty_render.rs drives anyr in a pseudo-terminal under each shell.
- name: install shells for the terminal render tests
run: sudo apt-get update -q && sudo apt-get install -y -q zsh fish

- name: cargo llvm-cov (full suite)
env:
ANYR_PTY_REQUIRE_SHELLS: "1"
run: cargo llvm-cov --locked --all-targets --lcov --output-path lcov.info

# Repo secret CODECOV_TOKEN from https://app.codecov.io/gh/anyrouter-dev/cli
Expand Down Expand Up @@ -109,8 +115,19 @@ jobs:
with:
targets: ${{ matrix.target }}

# tests/tty_render.rs drives anyr in a pseudo-terminal under each shell.
- name: install shells for the terminal render tests (linux)
if: runner.os == 'Linux'
run: sudo apt-get update -q && sudo apt-get install -y -q zsh fish

- name: install shells for the terminal render tests (macos)
if: runner.os == 'macOS'
run: brew install fish

- name: cargo test
timeout-minutes: 20
env:
ANYR_PTY_REQUIRE_SHELLS: ${{ runner.os == 'Windows' && '0' || '1' }}
run: cargo test --locked --all-targets

- name: stamp beta version (main)
Expand Down
47 changes: 47 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ native = ["dep:ureq", "dep:ratatui", "dep:crossterm", "dep:tungstenite"]
serde_json = "1"
libc = "0.2"
sha2 = "0.10"
unicode-width = "0.2"
ureq = { version = "2.12", optional = true }
ratatui = { version = "=0.29.0", default-features = false, features = ["crossterm"], optional = true }
crossterm = { version = "=0.28.1", optional = true }
Expand All @@ -42,3 +43,6 @@ codegen-units = 1
strip = true
panic = "abort"
opt-level = "z"

[dev-dependencies]
vt100 = "0.15"
3 changes: 2 additions & 1 deletion src/cmd/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ pub(crate) fn allowed_flags(command: &str) -> Option<&'static [&'static str]> {
"base-url",
"config",
],
"whoami" => &["profile", "config", "json", "key", "base-url"],
"whoami" => &["profile", "config", "json", "key", "base-url", "verbose"],
"config" => &[
"config", "json", "key", "base-url", "profile", "dump-tui", "pick",
],
Expand Down Expand Up @@ -616,6 +616,7 @@ pub(crate) fn allowed_flags(command: &str) -> Option<&'static [&'static str]> {
"yes",
"json",
"masked",
"verbose",
],
"prompt" => &["base-url", "json"],
"menu" => &["dump-tui", "config", "profile", "key", "base-url"],
Expand Down
25 changes: 18 additions & 7 deletions src/cmd/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ use crate::cmd::models::{
};
use crate::cmd::usage::run_usage;

/// `…6789` from a masked key: enough to tell keys apart in a one-line row.
fn key_last4(masked: &str) -> String {
match masked.rsplit_once('…') {
Some((_, tail)) if !tail.is_empty() => format!("…{tail}"),
_ => masked.to_string(),
}
}

pub(crate) fn agent_binding_detail(
cfg: &crate::config::Config,
id: &str,
Expand All @@ -57,19 +65,22 @@ pub(crate) fn agent_binding_detail(
.filter(|s| !s.is_empty())
.unwrap_or(cfg.active_profile.as_str());
let key = if signed_in {
if let Some(k) = binding
let k = binding
.and_then(|b| b.api_key.as_deref())
.map(str::trim)
.filter(|s| !s.is_empty())
{
mask_api_key(Some(k))
} else {
mask_api_key(profile.and_then(|p| p.api_key.as_deref()))
}
.or_else(|| profile.and_then(|p| p.api_key.as_deref()));
key_last4(&mask_api_key(k))
} else {
"(not signed in)".into()
};
let mut parts = vec![model, account.to_string(), key];
// The account shows only when this agent uses another one than the
// active profile; the account row above already names that one.
let mut parts = vec![model];
if account != cfg.active_profile {
parts.push(account.to_string());
}
parts.push(key);
if let Some(r) = binding.map(|b| &b.routing) {
if r.wants_exacto() {
parts.push("exacto".into());
Expand Down
Loading
Loading