AGENT SKILL

tmux-observer

Attach a tmux window to an already-running fir session — observe its transcript and drive its input via tmux send-keys. Use when you need to watch or steer another fir agent.

License 许可
MIT
所属仓库
kfet/fir
最近更新
2026-11-15
Stars
★ 1
Forks
0

01 前言 Front Matter

name
tmux-observer
builtin
true
override
true
description
Attach a tmux window to an already-running fir session — observe its transcript and drive its input via tmux send-keys. Use when you need to watch or steer another fir agent.

02 资源文件 4

03 SKILL.md 正文

Attach a tmux window to an already-running fir session so you can both observe its transcript and drive its input. The fir session must already exist (started by someone else, or by you in a previous step) — this skill does not start sessions.

The whole skill is three tmux commands plus one fir command. There is no script.

First: you may not need a window at all

fir observe and fir send work one-shot, without a TTY, and over ssh. For an agent (rather than a human) that is strictly better than reading a pane:

fir observe <id> --status [--json]   # idle | running | error | no-model | observe-lost | ended | crashed,
                                     # model, current tool, last error, startup notice
fir observe <id> -n 40               # status + last 40 transcript entries; exits
fir observe <id> --wait --timeout 10m  # block until the current run ends, then snapshot
fir send <id> --wait --timeout 10m 'do X'  # send, block for the turn, print the final reply
fir send <id> '!stop, read foo.go'   # steer;  fir send <id> --abort  cancels the turn

Another host: run exactly the same commands there over ssh — e.g. rexec(host, "fir observe <id> --status"). The observe_session / send_session tools are local-only. Do not scrape the remote tmux pane to learn whether the agent works; --status shows things like no-model: No models available… or an auth error that the transcript alone does not.

Use the observer window below when a human wants a live view, or you want a persistent --interact pane.

When to use

  • You started or know about another fir session (ACP, interactive, or -p) and want to watch what it's doing.
  • You want to send prompts, steer mid-turn, or queue follow-ups into that session from your own process.
  • You want a persistent observation window the human (or you) can re-check anytime.

The model

One tmux window per fir session you want to drive. The window runs fir observe <id> --interact, which both tails the transcript and accepts stdin as messages back into the session. You read state with tmux capture-pane and send input with tmux send-keys.

Step 1 — discover the session id

fir observe        # table of running sessions: ID PID NAME CWD STATUS AGE

Pick the 8-char id prefix from the ID column. Or resolve by cwd:

fir observe --cwd /path/to/project   # errors if 0 or >1 matches

You can also read sidecars directly: ~/.local/state/fir/agents/<id>.json contains session_id, session_name, cwd, status, mode, etc.

Step 2 — spawn the observer window

tmux new-window -n fir-<short> "fir observe <id> --interact"
  • Formatted transcript with full message text — no truncation. Best for capture-pane reading.
  • --interact = stdin lines are sent as messages. Required if you want to use tmux send-keys to drive the session.
  • Use --json if you need raw JSONL events for programmatic parsing (more tokens, less readable).
  • Window name fir-<short> is just a convention — pick whatever helps you find it later. Use tmux list-windows to see your windows.

If you want the observer in a fresh tmux session instead of the current one, use tmux new-session -d -s <name> ... — that's your call. This skill does not prescribe layout, naming, or session strategy.

Step 3 — read the transcript

tmux capture-pane -p -t <window>           # currently visible content
tmux capture-pane -p -S - -t <window>      # full scrollback from the start
tmux capture-pane -p -S -200 -t <window>   # last 200 lines

-p prints to stdout. -t accepts window names (fir-<short>) or indices.

Step 4 — send input

Each tmux send-keys ... Enter sends one message because --interact is line-oriented (Enter sends immediately).

# Plain prompt — fresh turn (queues if mid-turn).
tmux send-keys -t <window> 'what is your current plan?' Enter

# Steer — interrupt the current turn.
tmux send-keys -t <window> '!stop, read foo.go first' Enter

# FollowUp — queue for after the current turn.
tmux send-keys -t <window> '+also update the changelog' Enter

# Literal leading ! or +  — escape with backslash.
tmux send-keys -t <window> '\!literal bang' Enter

Sigil rules (first char of the line):

  • ! → deliver_as=steer (interrupt)
  • + → deliver_as=followUp (queue)
  • \! / \+ → escape, send literal
  • anything else → fresh prompt

Empty / whitespace-only lines are silently skipped.

Step 5 — close the window

tmux kill-window -t <window>

The fir session itself keeps running; you only close your observer.

Caveats

  • --interact against a mode: interactive session races with the human's TTY input. Check the sidecar's mode field before driving an interactive session. ACP and print-mode sessions are the natural targets.
  • Quoting in tmux send-keys. Single-quote your message and the shell takes care of it. For messages containing single quotes, prefer a heredoc piped to fir send:
    fir send <id> <<'EOF'
    message with 'quotes' and special chars
    EOF
    
    (fir send is the alternative input path — same socket, no observer pane needed. Use it when send-keys quoting gets ugly.)
  • Multi-line messages via send-keys. Each Enter sends a separate message. For multi-line content, pipe via fir send instead — piped stdin is delivered as one message.
  • Post-mortem. If the session has ended, the sidecar still points at its transcript; fir observe <id> -n 100 prints it. The window will not accept input.

04 同仓库更多 Skills