Skip to content
Merged
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
11 changes: 11 additions & 0 deletions scripts/amp-statusline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# Agent resolution order:
# 1. AMP_AGENT_ID env var (explicit UUID)
# 2. CLAUDE_AGENT_NAME env var (AI Maestro sets this)
# 2.5 Claude Code native session_name (`claude --name`), if it maps to an agent
# 3. tmux session name
# 4. Working directory → AI Maestro API lookup
# 5. Working directory → walk up to .claude/settings.local.json for
Expand Down Expand Up @@ -101,6 +102,9 @@ MODEL=$(echo "$input" | jq -r '.model.display_name // "?"')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
CWD=$(echo "$input" | jq -r '.workspace.current_dir // empty')
# Claude Code's native session name (set by `claude --name` / `/rename`). Present
# only when a custom or AI-generated title exists; used below as an identity hint.
SESSION_NAME=$(echo "$input" | jq -r '.session_name // empty')

# --- Resolve AMP agent ---
AGENTS_BASE="${HOME}/.agent-messaging/agents"
Expand All @@ -119,6 +123,13 @@ if [ -n "${AMP_AGENT_ID:-}" ]; then
elif [ -n "${CLAUDE_AGENT_NAME:-}" ]; then
AGENT_NAME="$CLAUDE_AGENT_NAME"

# Priority 2.5: Claude Code's native session name (set by `claude --name`, as
# AI Maestro does when launching an agent). Trust it ONLY when it maps to a known
# agent — an AI-generated session title must not shadow the cwd/hint fallbacks.
elif [ -n "$SESSION_NAME" ] && [ -f "$INDEX_FILE" ] && \
[ -n "$(jq -r --arg n "$SESSION_NAME" '.[$n] // empty' "$INDEX_FILE" 2>/dev/null)" ]; then
AGENT_NAME="$SESSION_NAME"

# Priority 3: tmux session name
elif [ -n "${TMUX:-}" ]; then
AGENT_NAME=$(tmux display-message -p '#S' 2>/dev/null)
Expand Down
Loading