feat: add status line with agent display + fix pa-mode keybind
Status line shows: [agent-name] Model | X% context - Added statusline.sh script that reads CLAUDE_AGENT env var - Configured settings.json to use the status line script Fixed pa-mode keybind issue (terminal closing immediately): - Changed from detached session + attach to exec tmux -A - Using exec replaces shell process, keeping terminal open - Added CLAUDE_AGENT env var export for status line 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ usage() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " (none) Attach to existing session or create new one"
|
echo " (none) Attach to existing session or create new one"
|
||||||
echo " new Force new session (detaches existing if any)"
|
echo " new Force new session (kills existing if any)"
|
||||||
echo " kill Terminate the PA session"
|
echo " kill Terminate the PA session"
|
||||||
echo " status Show session status"
|
echo " status Show session status"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -21,46 +21,41 @@ get_session_id() {
|
|||||||
date +"%Y-%m-%d_%H-%M-%S"
|
date +"%Y-%m-%d_%H-%M-%S"
|
||||||
}
|
}
|
||||||
|
|
||||||
create_session() {
|
record_session_start() {
|
||||||
local session_id
|
local session_id="$1"
|
||||||
session_id=$(get_session_id)
|
|
||||||
local history_file="$HISTORY_DIR/${session_id}.jsonl"
|
|
||||||
|
|
||||||
# Record session start in index
|
|
||||||
local tmp_file
|
local tmp_file
|
||||||
tmp_file=$(mktemp)
|
tmp_file=$(mktemp)
|
||||||
jq --arg id "$session_id" --arg started "$(date -Iseconds)" \
|
jq --arg id "$session_id" --arg started "$(date -Iseconds)" \
|
||||||
'.sessions += [{"id": $id, "started": $started, "ended": null, "summarized": false, "topics": []}]' \
|
'.sessions += [{"id": $id, "started": $started, "ended": null, "summarized": false, "topics": []}]' \
|
||||||
"$INDEX_FILE" > "$tmp_file" && mv "$tmp_file" "$INDEX_FILE"
|
"$INDEX_FILE" > "$tmp_file" && mv "$tmp_file" "$INDEX_FILE"
|
||||||
|
|
||||||
# Create tmux session with claude in PA mode
|
|
||||||
# Using HISTFILE-like approach: set env var for history location
|
|
||||||
tmux new-session -d -s "$SESSION_NAME" -c "$HOME" \
|
|
||||||
"PA_SESSION_ID='$session_id' PA_HISTORY_FILE='$history_file' claude --dangerously-skip-permissions --agent personal-assistant"
|
|
||||||
|
|
||||||
echo "Created new PA session: $session_id"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attach_session() {
|
create_or_attach_session() {
|
||||||
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
|
local session_id
|
||||||
tmux attach-session -t "$SESSION_NAME"
|
session_id=$(get_session_id)
|
||||||
else
|
local history_file="$HISTORY_DIR/${session_id}.jsonl"
|
||||||
create_session
|
|
||||||
tmux attach-session -t "$SESSION_NAME"
|
# If session doesn't exist, record it in index before creating
|
||||||
|
if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
|
||||||
|
record_session_start "$session_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Export for status line, then exec tmux (replaces this shell process)
|
||||||
|
# Using -A: attach if session exists, create if not
|
||||||
|
export CLAUDE_AGENT=personal-assistant
|
||||||
|
exec tmux new-session -A -s "$SESSION_NAME" -c "$HOME" \
|
||||||
|
"CLAUDE_AGENT=personal-assistant PA_SESSION_ID='$session_id' PA_HISTORY_FILE='$history_file' claude --dangerously-skip-permissions --agent personal-assistant"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
"")
|
"")
|
||||||
attach_session
|
create_or_attach_session
|
||||||
;;
|
;;
|
||||||
new)
|
new)
|
||||||
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
|
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
|
||||||
echo "Killing existing session..."
|
|
||||||
tmux kill-session -t "$SESSION_NAME"
|
tmux kill-session -t "$SESSION_NAME"
|
||||||
fi
|
fi
|
||||||
create_session
|
create_or_attach_session
|
||||||
tmux attach-session -t "$SESSION_NAME"
|
|
||||||
;;
|
;;
|
||||||
kill)
|
kill)
|
||||||
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
|
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
|
||||||
|
|||||||
23
automation/statusline.sh
Executable file
23
automation/statusline.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Claude Code Status Line - displays agent, model, and context usage
|
||||||
|
input=$(cat)
|
||||||
|
|
||||||
|
AGENT="${CLAUDE_AGENT:-}"
|
||||||
|
MODEL=$(echo "$input" | jq -r '.model.display_name // "?"')
|
||||||
|
|
||||||
|
# Calculate context percentage
|
||||||
|
CONTEXT_PCT="?"
|
||||||
|
usage=$(echo "$input" | jq '.context_window.current_usage // empty')
|
||||||
|
if [ -n "$usage" ]; then
|
||||||
|
current=$(echo "$usage" | jq '.input_tokens + .cache_creation_input_tokens + .cache_read_input_tokens')
|
||||||
|
size=$(echo "$input" | jq '.context_window.context_window_size')
|
||||||
|
if [ "$size" -gt 0 ] 2>/dev/null; then
|
||||||
|
CONTEXT_PCT=$((current * 100 / size))
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$AGENT" ]; then
|
||||||
|
echo "[$AGENT] $MODEL | ${CONTEXT_PCT}% context"
|
||||||
|
else
|
||||||
|
echo "$MODEL | ${CONTEXT_PCT}% context"
|
||||||
|
fi
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"model": "opus",
|
||||||
"enabledPlugins": {
|
"enabledPlugins": {
|
||||||
"frontend-design@claude-plugins-official": true,
|
"frontend-design@claude-plugins-official": true,
|
||||||
"typescript-lsp@claude-plugins-official": true,
|
"typescript-lsp@claude-plugins-official": true,
|
||||||
@@ -6,62 +7,9 @@
|
|||||||
"superpowers@superpowers-marketplace": true
|
"superpowers@superpowers-marketplace": true
|
||||||
},
|
},
|
||||||
"alwaysThinkingEnabled": true,
|
"alwaysThinkingEnabled": true,
|
||||||
"model": "opus",
|
"statusLine": {
|
||||||
"agents": {
|
"type": "command",
|
||||||
"k8s-orchestrator": {
|
"command": "~/.claude/automation/statusline.sh"
|
||||||
"model": "opus",
|
|
||||||
"promptFile": "agents/k8s-orchestrator.md",
|
|
||||||
"description": "Central orchestrator for K8s cluster management tasks"
|
|
||||||
},
|
|
||||||
"k8s-diagnostician": {
|
|
||||||
"model": "sonnet",
|
|
||||||
"promptFile": "agents/k8s-diagnostician.md",
|
|
||||||
"description": "Cluster health, pod/node status, log analysis"
|
|
||||||
},
|
|
||||||
"argocd-operator": {
|
|
||||||
"model": "sonnet",
|
|
||||||
"promptFile": "agents/argocd-operator.md",
|
|
||||||
"description": "ArgoCD app sync, deployments, rollbacks"
|
|
||||||
},
|
|
||||||
"prometheus-analyst": {
|
|
||||||
"model": "sonnet",
|
|
||||||
"promptFile": "agents/prometheus-analyst.md",
|
|
||||||
"description": "Metrics queries, alert analysis, trends"
|
|
||||||
},
|
|
||||||
"git-operator": {
|
|
||||||
"model": "sonnet",
|
|
||||||
"promptFile": "agents/git-operator.md",
|
|
||||||
"description": "Git commits, PRs, manifest management"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"autonomy": {
|
"_note": "Agent definitions moved to ~/.claude/agents/*.md with YAML frontmatter. Autonomy levels now in ~/.claude/state/autonomy-levels.json"
|
||||||
"safe_actions": [
|
|
||||||
"get",
|
|
||||||
"describe",
|
|
||||||
"logs",
|
|
||||||
"list",
|
|
||||||
"top",
|
|
||||||
"diff",
|
|
||||||
"refresh"
|
|
||||||
],
|
|
||||||
"confirm_actions": [
|
|
||||||
"delete",
|
|
||||||
"patch",
|
|
||||||
"edit",
|
|
||||||
"scale",
|
|
||||||
"rollout",
|
|
||||||
"apply",
|
|
||||||
"sync",
|
|
||||||
"commit",
|
|
||||||
"push",
|
|
||||||
"create-pr"
|
|
||||||
],
|
|
||||||
"forbidden_actions": [
|
|
||||||
"drain",
|
|
||||||
"cordon",
|
|
||||||
"delete node",
|
|
||||||
"reset",
|
|
||||||
"delete namespace"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user