mcpField
T
tmux-status-debug

tmux-status-debug

github.com/edmundmillerAgent 工作流8051 次安装今天更新
代码仓库

关于 tmux-status-debug

面向 tmux-opencode-integrated 维护者的状态检测调试技能,涵盖检查 tmux 窗格、测试状态匹配规则,以及更新测试和构建。

主要功能

  1. 01检查 Agent 窗格并捕获内容
  2. 02针对窗格输出测试匹配规则
  3. 03了解状态匹配优先级
  4. 04更新规则并运行测试

适用场景

  1. 01排查 Agent 状态图标错误
  2. 02诊断未匹配的终端模式
  3. 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}")

状态优先级

顺序很重要——匹配到的第一个状态生效:

  1. ERROR - Traceback、panic、FATAL ERROR、API 错误
  2. WAITING - Allow once?、Permission required、yes/no/skip 提示
  3. BUSY - Thinking...、旋转指示器、Running tools、esc 中断
  4. IDLE - 输入提示、上下文显示、OpenCode 版本、ctrl+p 命令
  5. UNKNOWN - 未匹配到任何模式(回退状态)

添加新模式

  1. 使用上述调试脚本捕获真实窗格内容
  2. 找出能指示该状态的独特文本
  3. 将模式添加到 smart_name.py 中对应的列表
  4. 在 tests/test_smart_name.py 中添加测试用例
  5. 运行测试:uvx pytest tests/test_smart_name.py -v
  6. 重新构建:nix build .#tmux-opencode-integrated

常见问题

“No module named 'libtmux'”

使用了错误的 Python。必须使用该软件包提供的 Nix 封装版 Python。

模式未匹配

终端控制字符可能造成干扰。strip_ansi_and_control() 函数应该能处理此问题,但请使用 cat -v 查看原始内容。

不应显示 ERROR,却显示了 ERROR

检查内容中是否包含先前输出遗留的错误样字符串。检测逻辑会查看窗格内容的最后 20 行。

评论

支持 Markdown