diff --git a/dotfiles/agents/AGENTS.md b/dotfiles/agents/AGENTS.md new file mode 100644 index 00000000..8bb2bade --- /dev/null +++ b/dotfiles/agents/AGENTS.md @@ -0,0 +1,21 @@ +# Agentic Session Preferences + +## Tmux session titling +- If the TMUX environment variable is set, treat this chat as the controller for the current tmux session. +- Maintain a session/window/pane title that updates when the task focus changes substantially. +- Prefer automatic titling: infer a concise from the current user request and context without asking. +- Title format: " - ". + - is the basename of the current project directory. + - Prefer git repo root basename if available; otherwise use basename of the current working directory. + - is a short, user-friendly description of what we are doing. +- Ask for a short descriptive only when the task is ambiguous or you are not confident in an inferred title. +- When the task changes substantially, update the automatically if clear; otherwise ask for an updated . +- When a title is provided or updated, immediately run this one-liner: + + tmux rename-session ' - ' \; rename-window ' - ' \; select-pane -T ' - ' + +- Assume you are inside tmux, so do not use -t unless the user asks to target a specific session. +- For Claude Code sessions, a UserPromptSubmit hook will also update titles automatically based on the latest prompt. + +## Pane usage +- Do not create extra panes or windows unless the user asks. diff --git a/dotfiles/agents/hooks/tmux-title.sh b/dotfiles/agents/hooks/tmux-title.sh new file mode 100755 index 00000000..707b0e17 --- /dev/null +++ b/dotfiles/agents/hooks/tmux-title.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ -z "${TMUX:-}" ]]; then + exit 0 +fi + +input=$(cat) + +read -r cwd prompt <<'PY' < <(python3 - <<'PY' +import json, os, sys +try: + data = json.load(sys.stdin) +except Exception: + data = {} + +cwd = data.get("cwd") or os.getcwd() +prompt = (data.get("prompt") or "").strip() +print(cwd) +print(prompt) +PY +) + +if [[ -z "${cwd}" ]]; then + cwd="$PWD" +fi + +project_root=$(git -C "$cwd" rev-parse --show-toplevel 2>/dev/null || true) +if [[ -n "$project_root" ]]; then + project=$(basename "$project_root") +else + project=$(basename "$cwd") +fi + +prompt_first_line=$(printf '%s' "$prompt" | head -n 1 | tr '\n' ' ' | sed -e 's/[[:space:]]\+/ /g' -e 's/^ *//; s/ *$//') + +lower=$(printf '%s' "$prompt_first_line" | tr '[:upper:]' '[:lower:]') +case "$lower" in + ""|"ok"|"okay"|"thanks"|"thx"|"cool"|"yep"|"yes"|"no"|"sure"|"done"|"k") + exit 0 + ;; +esac + +task="$prompt_first_line" +if [[ -z "$task" ]]; then + task="work" +fi + +# Trim to a reasonable length for tmux status bars. +if [[ ${#task} -gt 60 ]]; then + task="${task:0:57}..." +fi + +title="$project - $task" + +state_dir="${HOME}/.agents/state" +state_file="$state_dir/tmux-title" +mkdir -p "$state_dir" + +if [[ -f "$state_file" ]]; then + last_title=$(cat "$state_file" 2>/dev/null || true) + if [[ "$last_title" == "$title" ]]; then + exit 0 + fi +fi + +printf '%s' "$title" > "$state_file" + +# Update session, window, and pane titles. +tmux rename-session "$title" \; rename-window "$title" \; select-pane -T "$title" diff --git a/dotfiles/claude/CLAUDE.md b/dotfiles/claude/CLAUDE.md new file mode 120000 index 00000000..837ac03b --- /dev/null +++ b/dotfiles/claude/CLAUDE.md @@ -0,0 +1 @@ +../agents/AGENTS.md \ No newline at end of file diff --git a/dotfiles/claude/settings.json b/dotfiles/claude/settings.json new file mode 100644 index 00000000..2bd4ea1e --- /dev/null +++ b/dotfiles/claude/settings.json @@ -0,0 +1,18 @@ +{ + "enabledPlugins": { + "superpowers@superpowers-marketplace": true, + "agent-browser@agent-browser": true + }, + "hooks": { + "UserPromptSubmit": [ + { + "hooks": [ + { + "type": "command", + "command": "~/.agents/hooks/tmux-title.sh" + } + ] + } + ] + } +} diff --git a/dotfiles/codex/AGENTS.md b/dotfiles/codex/AGENTS.md new file mode 120000 index 00000000..837ac03b --- /dev/null +++ b/dotfiles/codex/AGENTS.md @@ -0,0 +1 @@ +../agents/AGENTS.md \ No newline at end of file