关于 tmux-status-debug
面向 tmux-opencode-integrated 维护者的状态检测调试技能,涵盖检查 tmux 窗格、测试状态匹配规则,以及更新测试和构建。
主要功能
- 01检查 Agent 窗格并捕获内容
- 02针对窗格输出测试匹配规则
- 03了解状态匹配优先级
- 04更新规则并运行测试
适用场景
- 01排查 Agent 状态图标错误
- 02诊断未匹配的终端模式
- 03添加并验证新的状态标记
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ edmundmiller/ dotfiles --skill tmux-status-debug安装后在 Claude Code 中输入/tmux-status-debug确认已加载。
详细介绍
调试 tmux-opencode-integrated 状态检测
适用场景
- 状态图标显示错误(例如,Agent 处于空闲状态,却显示错误)
- 为 Agent 检测添加新模式
- 使用真实窗格内容测试模式匹配
快捷命令
列出所有 Agent 窗格
tmux list-panes -a -F "#{session_name}:#{window_name}.#{pane_index} #{pane_current_command}" | grep -E "opencode|claude|amp"
捕获窗格内容(原始内容)
tmux capture-pane -t "main:1" -p -S -30 | tail -40
捕获窗格内容并显示控制字符
tmux capture-pane -t "main:1" -p -S -30 | cat -v | tail -40
检查窗格中是否存在某个模式
tmux capture-pane -t "main:1" -p -S -20 | grep -o "pattern"
调试脚本
创建 /tmp/debug_status.py,并使用包含 libtmux 的 Nix Python 运行:
import sys
sys.path.insert(0, "/Users/emiller/.config/dotfiles/packages/tmux-opencode-integrated/scripts")
import smart_name
import re
import libtmux
server = libtmux.Server()
for session in server.sessions:
for window in session.windows:
for pane in window.panes:
program = smart_name.get_pane_program(pane)
if program in smart_name.AGENT_PROGRAMS:
print(f"\n=== {program} in {session.name}:{window.name} ===")
try:
cmd_output = pane.cmd("capture-pane", "-p", "-S", "-20").stdout
if isinstance(cmd_output, list):
content = "\n".join(cmd_output)
else:
content = str(cmd_output)
cleaned = smart_name.strip_ansi_and_control(content)
print(f"Last 300 chars (cleaned):\n{cleaned[-300:]}")
print(f"\n--- Status: {smart_name.get_opencode_status(pane)} ---")
except Exception as e:
print(f"Error: {e}")
查找包含 libtmux 的 Nix Python
# Build the package and get the store path
nix build .#tmux-opencode-integrated --no-link --print-out-paths
# Check wrapper to find Python path
head -10 /nix/store/<hash>-tmux-opencode-integrated-*/share/tmux-plugins/tmux-opencode-integrated/scripts/smart-name.sh
# Run debug script with that Python
/nix/store/<python-hash>-python3-*-env/bin/python3 /tmp/debug_status.py
模式测试
使用示例内容测试模式:
import re
content = """ctrl+t variants tab agents ctrl+p commands • OpenCode 1.1.30"""
patterns = [
(r"OpenCode \d+\.\d+\.\d+", "IDLE - version"),
(r"ctrl\+p commands", "IDLE - status bar"),
(r"esc interrupt", "BUSY - can interrupt"),
(r"Esc to cancel", "BUSY - can cancel"),
(r"■■■", "BUSY - progress bar"),
]
for pattern, desc in patterns:
if re.search(pattern, content, re.IGNORECASE):
print(f"✓ {desc}: {pattern}")
状态优先级
顺序很重要——匹配到的第一个状态生效:
- ERROR - Traceback、panic、FATAL ERROR、API 错误
- WAITING - Allow once?、Permission required、yes/no/skip 提示
- BUSY - Thinking...、旋转指示器、Running tools、esc 中断
- IDLE - 输入提示、上下文显示、OpenCode 版本、ctrl+p 命令
- UNKNOWN - 未匹配到任何模式(回退状态)
添加新模式
- 使用上述调试脚本捕获真实窗格内容
- 找出能指示该状态的独特文本
- 将模式添加到
smart_name.py中对应的列表 - 在
tests/test_smart_name.py中添加测试用例 - 运行测试:
uvx pytest tests/test_smart_name.py -v - 重新构建:
nix build .#tmux-opencode-integrated
常见问题
“No module named 'libtmux'”
使用了错误的 Python。必须使用该软件包提供的 Nix 封装版 Python。
模式未匹配
终端控制字符可能造成干扰。strip_ansi_and_control() 函数应该能处理此问题,但请使用 cat -v 查看原始内容。
不应显示 ERROR,却显示了 ERROR
检查内容中是否包含先前输出遗留的错误样字符串。检测逻辑会查看窗格内容的最后 20 行。
评论
支持 Markdown