Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
bc218b6
Plan multiple Claude and Codex accounts with manual or automatic swit…
dhh Sep 29, 2026
b6b9240
Keep several Claude and Codex accounts and start new sessions as the …
dhh Sep 29, 2026
f13074b
Report limits for every Claude and Codex account in the usage records
dhh Sep 29, 2026
c7054f4
Switch accounts automatically near a limit, or notify with a one-clic…
dhh Sep 29, 2026
ee56c93
Show every subscription account's limits in the agents panel
dhh Sep 29, 2026
0b23987
Add Setup > Agent Accounts to list, switch and add Claude and Codex a…
dhh Sep 29, 2026
048e2c6
Document switching between several Claude and Codex subscriptions
dhh Sep 29, 2026
962f4f2
Count a rested parked account as available, and pin Main to its own home
dhh Sep 29, 2026
2270ff0
Key limits caches by subscription and report when an account truly fr…
dhh Sep 29, 2026
886b0c3
Keep account ids clear of routing keywords and refresh the panel afte…
dhh Sep 29, 2026
fda5c94
Share Codex plugins and hooks across accounts, and key Claude caches …
dhh Sep 29, 2026
7e858fa
Drop the key hint from the Add account button
dhh Sep 29, 2026
8184b90
Sign new agent accounts in through a private browser window
dhh Sep 29, 2026
144fbec
Let agent account commands default to your default agent's provider
dhh Sep 29, 2026
3e4f6d9
Drop the primary alias, which shadowed an account named Primary
dhh Sep 29, 2026
59d0b57
Replace the auto switch button with a small Notify / Autoswitch toggle
dhh Sep 29, 2026
dc30174
Add accounts from a small + beside the switch toggle
dhh Sep 29, 2026
f9eaa3b
Fix the punctuation of the switch toggle's README line
dhh Sep 29, 2026
acf98d5
Drop the border around the add account +
dhh Sep 29, 2026
1045411
Rename Claude and Codex accounts without moving their homes
dhh Sep 29, 2026
1fdb330
Lay out agent accounts on accent rails instead of boxed cards
dhh Sep 29, 2026
05e8d43
Read Codex limits without waiting on account/read
dhh Sep 29, 2026
86c7f7d
Switch agent providers from their marks in the panel header
dhh Sep 29, 2026
de2a224
Keep the agents panel's scrollbar off its contents
dhh Sep 29, 2026
f79ac4f
Add Claude, Codex, or Grok subscriptions from one Add Account menu
dhh Sep 29, 2026
0269dd7
Reveal Autoswitch beside Use instead of a Notify / Autoswitch row
dhh Sep 29, 2026
e04655c
Split agent accounts with plain separators instead of rails
dhh Sep 29, 2026
14d63e4
Only call Claude limits stale once they're old, and poll near a limit…
dhh Sep 29, 2026
af6ff08
Show every agent's limits on one page under an Agents hero
dhh Sep 29, 2026
d97c16e
Report Codex's free rate-limit resets in its usage record
dhh Sep 29, 2026
a361417
Give the agents panel more room, and show Codex's free resets
dhh Sep 29, 2026
97e66f0
Mark Claude's Fable limit on the Weekly meter instead of its own row
dhh Sep 29, 2026
da96261
Let omarchy-default-agent set the default without launching it
dhh Sep 29, 2026
a2c45a9
Let the agents panel drive adding an account without a terminal
dhh Sep 29, 2026
b967330
Add subscriptions and pick the default agent right in the agents panel
dhh Sep 29, 2026
649e0d1
Draw the Fable tick in its meter's own color
dhh Sep 29, 2026
4cdfc47
Revert "Let omarchy-default-agent set the default without launching it"
dhh Sep 29, 2026
490bca1
Make the first agent signed in the default when none is picked
dhh Sep 29, 2026
9d42330
Keep the agents panel in the bar, with setup, starters, and adding in it
dhh Sep 29, 2026
387fd85
Offer the starter prompts as tiles, and adding as a row beneath them
dhh Sep 29, 2026
afd1ce7
Put the tinted add button in the agents panel's hero corner
dhh Sep 29, 2026
108d9de
Show when a limit resets in small type under its meter
dhh Sep 29, 2026
3c43182
Revert "Show when a limit resets in small type under its meter"
dhh Sep 29, 2026
7596226
Put each account's plan beside its name, and its email in a tooltip
dhh Sep 29, 2026
5d89c1b
Stack each limit's percentage over its time left, so the meter runs l…
dhh Sep 29, 2026
b4b2b90
Show only each limit's time left, with the exact percentage on hover
dhh Sep 29, 2026
260b2dc
Sign an existing account in again with omarchy-agent-account-add --re…
dhh Sep 29, 2026
9de936d
Offer Sign-in required in the agents panel instead of how old the num…
dhh Sep 29, 2026
808523c
Keep the separator dot out of the Sign-in required link
dhh Sep 29, 2026
3d89b5f
Drop the Setup > Agent Accounts menu and the stale plan
dhh Sep 29, 2026
c408bb2
Install the compiler and Qt pieces for building Omarchy-style apps
dhh Sep 29, 2026
7ef55b3
Add an omarchy-app agent skill for building apps the Omarchy way
dhh Sep 29, 2026
70a85c9
Link the omarchy-app skill on existing installs
dhh Sep 29, 2026
1644477
Let Cancel stop a waiting login, and list a lone account's limits
dhh Sep 29, 2026
07fcd4f
Re-read identity even when signed out, and count Grok as set up
dhh Sep 29, 2026
f2e468b
Save each account's current identity before collecting usage
dhh Sep 29, 2026
72e08be
Offer Claude's paste field from the start, and keep providers with ac…
dhh Sep 29, 2026
83abdba
Never autoswitch to a signed-out account, and report Codex's missing …
dhh Sep 29, 2026
b1d41e6
Link shared files before they exist, and only call every account over…
dhh Sep 29, 2026
38db762
Make the agent starter tiles compact and call the section Make someth…
dhh Sep 29, 2026
2ef626f
Hold the agents hero line until its next fade
dhh Oct 1, 2026
b871c8e
Start the default agent from the agents panel hero
dhh Oct 1, 2026
22295ac
Put the add button before the agent launcher in the hero corner
dhh Oct 1, 2026
174962c
Bring keyboard navigation back to the agents panel
dhh Oct 1, 2026
8505f24
Let adding an account take over the agents hero
dhh Oct 1, 2026
de97ddd
Show the agents to add as large marks, three across
dhh Oct 1, 2026
e4833aa
Move between Autoswitch and Use on an account with the arrows
dhh Oct 1, 2026
4d4df24
Land on Use when moving up or down onto an account
dhh Oct 1, 2026
c1b410b
Hide Use on an autoswitching account until you're on its line
dhh Oct 1, 2026
78f014a
Start adding an account with the first agent focused
dhh Oct 1, 2026
5559398
Drop the Sign in link under the account name field
dhh Oct 1, 2026
64e2c4a
Key the primary Claude account's limits cache by its subscription
dhh Oct 1, 2026
0786582
Leave Qt Multimedia out of the base packages again
dhh Oct 1, 2026
abfaa3a
Render the agents panel's dynamic text as plain text
dhh Oct 1, 2026
60d3bb7
Keep an account's plan and trouble clear of its Use and Autoswitch links
dhh Oct 1, 2026
bf3eb30
Let primary name the first account, as the manual says
dhh Oct 1, 2026
3d8a9fe
Install everything an Omarchy app needs by default
dhh Oct 1, 2026
a739e8d
Dim agent limits kept from an earlier check, with their age on hover
dhh Oct 1, 2026
3c27efa
Give the app skill templates for every file its build needs
dhh Oct 1, 2026
cba5275
Start the agents panel cursor over when the agent list comes or goes
dhh Oct 1, 2026
eb9c187
Drop dead hover and limit checks from the agents panel
dhh Oct 1, 2026
1f8046b
Merge quattro into agent-account-switching
dhh Oct 1, 2026
e996509
Drop the a hotkey for adding an agent subscription
dhh Oct 1, 2026
e060bac
List a command family that sits under a flags-only command
dhh Oct 1, 2026
6e12084
Refuse to remove an agent account a running session uses
dhh Oct 1, 2026
eaa3661
Prefer an account checked just now when switching near a limit
dhh Oct 1, 2026
a1a14a1
Leave a user's own omarchy-app skill in place when linking ours
dhh Oct 1, 2026
fc502fc
Reach Sign-in required with the keyboard in the agents panel
dhh Oct 1, 2026
db81a4e
Bring the manual's agent accounts paragraph up to date
dhh Oct 1, 2026
4b354a5
Keep the agents panel cursor on things you can act on
dhh Oct 1, 2026
6ae8e23
Never leave an added agent account's login outside the registry
dhh Oct 1, 2026
67ab7d5
Put room before freshness when picking an account to switch to
dhh Oct 1, 2026
65e7692
Check agent limits more often relative to the switch threshold
dhh Oct 1, 2026
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
27 changes: 26 additions & 1 deletion bin/omarchy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare -A ROUTE_IS_ALIAS
declare -A BINARY_TO_KEY
declare -A GROUP_DESCRIPTIONS

GROUP_DESCRIPTIONS[agent]="AI coding agent usage data"
GROUP_DESCRIPTIONS[agent]="AI coding agents, their usage, and subscription accounts"
GROUP_DESCRIPTIONS[ascii]="Text drawn as ASCII art"
GROUP_DESCRIPTIONS[audio]="Audio input and output controls"
GROUP_DESCRIPTIONS[bar]="Omarchy shell bar layout and settings"
Expand Down Expand Up @@ -371,6 +371,20 @@ command_requires_args() {
[[ -n $required ]]
}

# A command whose documented arguments are all flags can't take a word, so a
# word after it names something else: `omarchy agent account` is the account
# commands, not an argument to omarchy-agent.
command_takes_only_flags() {
local key="$1"
local args="${COMMAND_ARGS[$key]}"
local token=""

[[ -n $args ]] || return 1
for token in $args; do
[[ $token == -* || $token == "[-"* ]] || return 1
done
}

load_group_commands() {
local group="$1"
local file=""
Expand Down Expand Up @@ -956,6 +970,17 @@ dispatch_fast_or_help() {
remaining=("${args[@]:DIRECT_RESOLVED_COUNT}")
binary_path="$OMARCHY_BIN_DIR/$DIRECT_RESOLVED_BINARY"

if (( ${#remaining[@]} == 1 || ${#remaining[@]} == 2 )) && [[ ${remaining[0]} != -* ]] &&
{ (( ${#remaining[@]} == 1 )) || remaining_has_help_flag "${remaining[1]}"; } &&
group_has_child_commands "${DIRECT_RESOLVED_BINARY#omarchy-}-${remaining[0]}"; then
load_command_by_binary "$DIRECT_RESOLVED_BINARY"
key="${BINARY_TO_KEY[$DIRECT_RESOLVED_BINARY]}"
if [[ -n $key ]] && command_takes_only_flags "$key"; then
load_commands
show_prefix_help "$DIRECT_RESOLVED_ROUTE ${remaining[0]}" && return 0
fi
fi

if remaining_has_help_flag "${remaining[@]}"; then
if ! load_command_by_binary "$DIRECT_RESOLVED_BINARY"; then
echo "Binary is missing or not executable: $DIRECT_RESOLVED_BINARY" >&2
Expand Down
12 changes: 12 additions & 0 deletions bin/omarchy-agent
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ pi)
;;
esac

# Claude and Codex start as the active subscription account, the same as the
# shell functions in default/bash/fns/agent-accounts. The home travels in the
# command itself, since a terminal launched through uwsm doesn't inherit this
# process's environment.
if [[ $agent == "claude" && -z ${CLAUDE_CONFIG_DIR:-} ]]; then
home=$(omarchy-agent-account-home claude)
[[ -n $home ]] && command=(env "CLAUDE_CONFIG_DIR=$home" "${command[@]}")
elif [[ $agent == "codex" && -z ${CODEX_HOME:-} ]]; then
home=$(omarchy-agent-account-home codex)
[[ -n $home ]] && command=(env "CODEX_HOME=$home" "${command[@]}")
fi

if [[ $inline == "true" ]]; then
exec "${command[@]}"
else
Expand Down
240 changes: 240 additions & 0 deletions bin/omarchy-agent-account-add
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
#!/bin/bash

# omarchy:summary=Sign in to a Claude, Codex, or Grok subscription
# omarchy:args=[--check] [--events] [--reauth <account>] [claude|codex|grok] [label]
# omarchy:examples=omarchy agent account add claude | omarchy agent account add Work | omarchy agent account add codex Side

set -uo pipefail

# --check prints, per provider, whether adding one now would be its first
# sign-in, an additional account, or not possible yet. --events is for the
# agents panel: progress arrives as `@@omarchy <event> <detail>` lines mixed
# into the CLI's own output (which carries codes the panel shows), nothing
# waits on a terminal, and the result also lands as a notification in case
# the panel has closed.
# --reauth <account> signs an account that's already here in again, in its
# own home, for when its sign-in has lapsed.
check=false
events=false
reauth=""
while [[ ${1:-} == --* ]]; do
case "$1" in
--check) check=true ;;
--events) events=true ;;
--reauth)
reauth="${2:-}"
shift
;;
*) break ;;
esac
shift
done

# Whether a provider's own home (~/.claude, ~/.codex, ~/.grok) is signed in.
primary_signed_in() {
if [[ $1 == "grok" ]]; then
[[ -s $HOME/.grok/auth.json ]]
else
omarchy-agent-account-state list "$1" | jq -e '.[0].accounts | any(.primary and .signedIn)' >/dev/null
fi
}

if [[ $check == "true" ]]; then
for p in claude codex grok; do
if ! primary_signed_in "$p"; then
echo "$p first"
elif [[ $p == "grok" ]]; then
echo "$p unsupported"
else
echo "$p additional"
fi
done
exit 0
fi

# The provider can be left out when it's your default agent:
# `omarchy agent account add Work`.
if [[ ${1:-} != "claude" && ${1:-} != "codex" && ${1:-} != "grok" ]]; then
default=$(omarchy-default-agent)
[[ $default == "claude" || $default == "codex" || $default == "grok" ]] && set -- "$default" "$@"
fi

case "${1:-}" in
claude) provider="claude"; name="Claude"; site="claude.ai"; package="claude" ;;
codex) provider="codex"; name="Codex"; site="chatgpt.com"; package="codex" ;;
grok) provider="grok"; name="Grok"; site="x.ai"; package="npm:@xai-official/grok" ;;
*)
echo "Usage: omarchy-agent-account-add [--check] [--events] [--reauth <account>] [claude|codex|grok] [label]" >&2
exit 1
;;
esac
label="${2:-}"

say() {
if [[ $events == "true" ]]; then
printf '@@omarchy status %s\n' "$*"
else
echo "$*"
fi
}

finish() {
if [[ $events == "true" ]]; then
printf '@@omarchy done %s\n' "$1"
omarchy-notification-send -g 󰚩 "$1"
else
echo
echo "$1"
fi
}

fail() {
if [[ $events == "true" ]]; then
printf '@@omarchy error %s\n' "$1"
omarchy-notification-send -g 󰚩 -u critical "Couldn't add the $name account" "$1"
else
echo "$1" >&2
fi
exit 1
}

# Cancelling from the panel stops the CLI's login too, and leaves no
# half-made home behind.
home=""
browser=""
cleanup() {
[[ -n $browser ]] && rm -f "$browser"
[[ -n $home && -d $home && $home == */.pending/* ]] && rm -rf "$home"
}
trap cleanup EXIT
trap 'pkill -TERM -P $$; exit 130' TERM INT

# Bash holds a trap until a foreground command finishes, and a login waits on
# the browser for as long as it takes. Running it in the background behind a
# `wait` lets Cancel stop it at once. It keeps this script's stdin, where the
# panel sends a pasted code.
interruptible() {
"$@" <&0 &
wait $!
}

if omarchy-cmd-missing "$provider"; then
say "Installing the $name CLI…"
if [[ $events == "true" ]]; then
mise use -g "$package" >/dev/null 2>&1 || fail "Installing the $name CLI didn't finish."
else
mise use -g "$package" || exit 1
fi
fi

# Your main browser is almost certainly signed in to the account you already
# have, and a login would quietly reuse it. The CLIs open their login page
# through $BROWSER, so this points it at a private window instead.
private_browser() {
browser=$(mktemp "${XDG_RUNTIME_DIR:-/tmp}/omarchy-account-browser.XXXXXX")
printf '#!/bin/bash\nexec omarchy-launch-browser --private "$1"\n' >"$browser"
chmod +x "$browser"
}

case "$provider" in
claude) login_command=(claude auth login) ;;
codex) login_command=(codex login) ;;
grok) login_command=(grok login) ;;
esac

# The CLI's own home, whatever this shell has pointed it at.
login() {
interruptible env -u CLAUDE_CONFIG_DIR -u CODEX_HOME -u GROK_HOME "${login_command[@]}"
}

# Signing an account that's already here in again, where it lives: the
# primary home through the normal browser, an added one through a private
# window. Its home is never recreated or removed.
if [[ -n $reauth ]]; then
if [[ $provider == "grok" || $reauth == ":primary" ]]; then
account_home="$HOME/.$provider"
else
account_home=$(omarchy-agent-account-state homes "$provider" | awk -F'\t' -v id="$reauth" '$1 == id { print $2 }')
fi
[[ -n $account_home ]] || fail "No $name account named $reauth."

if [[ $account_home == "$HOME/.$provider" ]]; then
say "Sign in to $name again in the browser window that opens."
login || fail "The $name sign-in didn't finish."
else
say "Sign in again as this account in the private window that opens."
private_browser
if [[ $provider == "claude" ]]; then
interruptible env BROWSER="$browser" CLAUDE_CONFIG_DIR="$account_home" claude auth login || fail "The $name sign-in didn't finish."
else
interruptible env BROWSER="$browser" CODEX_HOME="$account_home" codex login || fail "The $name sign-in didn't finish."
fi
fi

omarchy-agent-usage-update --force "$provider" >/dev/null 2>&1 &
finish "Signed in to $name again."
exit 0
fi

# The first subscription signs in where the CLI always looks, through your
# normal browser: nothing is signed in there yet that it could be mistaken for.
if ! primary_signed_in "$provider"; then
say "Sign in to $name in the browser window that opens."
if login && primary_signed_in "$provider"; then
# The first agent signed in on a machine with none chosen becomes the
# default, so `omarchy agent` and the panel's starter prompts have one to
# run. A default someone already picked is never touched.
if [[ -z $(omarchy-default-agent) ]]; then
mkdir -p "$HOME/.config/omarchy/defaults"
printf '%s\n' "$provider" >"$HOME/.config/omarchy/defaults/agent"
fi
omarchy-agent-usage-update --force "$provider" >/dev/null 2>&1 &
finish "Signed in to $name."
else
fail "The $name sign-in didn't finish."
fi
elif [[ $provider == "grok" ]]; then
fail "Grok is already signed in, and a second Grok account isn't supported yet."
else
if [[ -z $label && $events == "false" && -t 0 ]]; then
label=$(gum input --placeholder "Work" --prompt "Name this $name account: ") || exit 130
fi

if [[ $events == "true" ]]; then
say "Sign in as the account you're adding in the private window that opens."
else
cat <<EOF

Sign in as the account you're adding in the private window that opens.
If a private window was already open, close it first, or $site may reuse whoever it has signed in.

Don't log out of the $name CLI to do this: logging out revokes the saved sign-in.

EOF
fi

home=$(omarchy-agent-account-state begin "$provider") || fail "Couldn't set up a home for the new account."

private_browser

if [[ $provider == "claude" ]]; then
interruptible env BROWSER="$browser" CLAUDE_CONFIG_DIR="$home" claude auth login
else
interruptible env BROWSER="$browser" CODEX_HOME="$home" codex login
fi

if account=$(omarchy-agent-account-state register "$provider" "$label" "$home" 2>&1); then
home=""
added=$(jq -r '.label + (if .email != "" then " (" + .email + ")" else "" end)' <<<"$account")
omarchy-agent-usage-update --force "$provider" >/dev/null 2>&1 &
if [[ $events == "true" ]]; then
finish "Added $added."
else
finish "Added $added."
echo "Switch to it with: omarchy agent account use $provider $(jq -r .id <<<"$account")"
fi
else
home=""
fail "$account"
fi
fi
18 changes: 18 additions & 0 deletions bin/omarchy-agent-account-home
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# omarchy:summary=Print the config home of the active Claude or Codex account
# omarchy:args=<claude|codex>
# omarchy:hidden=true

# Prints nothing while the primary account (~/.claude, ~/.codex) is active, so
# a launch only sets CLAUDE_CONFIG_DIR / CODEX_HOME when there's somewhere
# else to point it. Without a registry, no Python starts at all: this runs on
# every `claude` and `codex` typed at a prompt.
registry="${XDG_STATE_HOME:-$HOME/.local/state}/omarchy/agents/accounts/${1:-}.json"

if [[ ${1:-} != "claude" && ${1:-} != "codex" ]]; then
echo "Usage: omarchy-agent-account-home <claude|codex>" >&2
exit 1
elif [[ -f $registry ]]; then
exec omarchy-agent-account-state home "$1"
fi
58 changes: 58 additions & 0 deletions bin/omarchy-agent-account-list
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# omarchy:summary=List Claude and Codex subscription accounts and their limits
# omarchy:args=[claude|codex] [--json]
# omarchy:examples=omarchy agent account list | omarchy agent account list claude --json

set -uo pipefail

provider=""
json=false
for arg in "$@"; do
case "$arg" in
claude | codex) provider="$arg" ;;
--json) json=true ;;
*)
echo "Usage: omarchy-agent-account-list [claude|codex] [--json]" >&2
exit 1
;;
esac
done

usage_dir="${XDG_STATE_HOME:-$HOME/.local/state}/omarchy/agents/usage"
accounts=$(omarchy-agent-account-state list $provider) || exit 1

# Join each account with the limits its provider's usage record last saw. With
# a single account the collectors keep its limits at the record's top level.
accounts=$(jq -c --arg dir "$usage_dir" '
map(. as $p | .accounts |= map(. + {limits: []}))' <<<"$accounts")
for p in claude codex; do
record="$usage_dir/$p.json"
[[ -f $record ]] || continue
accounts=$(jq -c --arg p "$p" --slurpfile record "$record" '
map(if .provider == $p then
.accounts |= map(. as $a | . + {limits: (
if ($record[0].accounts // []) | length > 0 then
[$record[0].accounts[] | select(.id == $a.id) | .limits] | first // []
elif $a.primary then
$record[0].limits // []
else
[]
end)})
else . end)' <<<"$accounts")
done

if [[ $json == "true" ]]; then
echo "$accounts"
else
# A provider nobody has signed in to has nothing to list.
for (( i = 0; i < $(jq length <<<"$accounts"); i++ )); do
jq -e ".[$i].accounts | any(.signedIn)" <<<"$accounts" >/dev/null || continue
jq -r ".[$i] | \"\(.name) — \(.switch) switching at \(.threshold)%\"" <<<"$accounts"
jq -r ".[$i].accounts[] |
\"\(if .active then \"*\" else \" \" end)\t\(.id)\t\(.label)\t\(.plan)\t\(.email)\t\" +
([.limits[]? | select(.percent != null) | \"\(.label): \((.percent * 100) | round)%\"] | join(\", \"))" <<<"$accounts" |
column -t -s $'\t' | sed 's/^/ /'
echo
done
fi
Loading