关于 ntm
ntm 是用于 tmux 的 Go 命令行工具,可在持久会话中并行管理和协调多种编码 Agent。它提供可视化监控、提示词分发和上下文轮换,面向需要组织多个 Agent 协作的开发者。
主要功能
- 01在 tmux 会话中创建和管理多个 Agent
- 02向指定或全部 Agent 分发提示词
- 03通过仪表板查看状态与上下文用量
- 04捕获、搜索和比较窗格输出
- 05监控活动并自动轮换上下文
适用场景
- 01并行运行 Claude Code、Codex 和 Gemini
- 02向多个 Agent 分配实现、测试与审查任务
- 03断开 SSH 后继续使用持久会话
- 04查看 Agent 输出并保存代码块
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ dicklesworthstone/ agent_flywheel_clawdbot_skills_and_integrations --skill ntm安装后在 Claude Code 中输入/ntm确认已加载。
详细介绍
NTM — 命名 Tmux 管理器
一个 Go 命令行工具,可将 tmux 打造成多 Agent 指挥中心,用于并行编排 Claude Code、Codex 和 Gemini Agent。通过精美的 TUI,在平铺窗格中启动、管理和协调 AI Agent;支持自动上下文轮换,并与 Agent Flywheel 生态系统深度集成。
为何开发此工具
管理多个 AI 编码 Agent 很麻烦:
- 窗口混乱:每个 Agent 都需要自己的终端
- 上下文切换:在窗口间跳转会打断工作流
- 无法编排:要向多个 Agent 发送相同提示词,需要手动复制粘贴
- 会话脆弱:SSH 断开后,所有 Agent 会话都会丢失
- 缺乏可见性:很难快速了解 Agent 状态
NTM 通过在一个会话中容纳多个 Agent 解决所有这些问题,并且即使 SSH 断开,会话也会持续存在。
快速开始
# Install
curl -fsSL https://raw.githubusercontent.com/Dicklesworthstone/ntm/main/install.sh | bash
# Add shell integration
echo 'eval "$(ntm init zsh)"' >> ~/.zshrc && source ~/.zshrc
# Interactive tutorial
ntm tutorial
# Check dependencies
ntm deps -v
# Create multi-agent session (agy = Antigravity CLI, NTM-pinned to "Gemini 3.1 Pro (High)")
ntm spawn myproject --cc=2 --cod=1 --agy=1
# Send prompt to all Claude agents
ntm send myproject --cc "Explore this codebase and summarize its architecture."
# Open command palette (or press F6 after `ntm bind`)
ntm palette myproject
创建会话
启动 Agent
ntm spawn myproject --cc=3 --cod=2 --agy=1 # 3 Claude + 2 Codex + 1 Gemini (via agy)
ntm quick myproject --template=go # Full project scaffold + agents
ntm create myproject --panes=10 # Empty panes only
ntm spawn myproject --profiles=architect,implementer,tester
Agent 标志
| 标志 | Agent | CLI 命令 |
|---|---|---|
--cc=N | Claude Code | claude |
--cod=N | Codex CLI | codex |
--agy=N | Antigravity CLI(固定使用 “Gemini 3.1 Pro (High)”) | agy |
--gmi=N | Gemini CLI(旧版,即将停止使用——建议使用 --agy=N) | gemini |
添加更多 Agent
ntm add myproject --cc=2 # Add 2 more Claude agents
ntm add myproject --cod=1 --agy=1 # Add mixed agents
发送提示词
ntm send myproject --cc "Implement user auth" # To all Claude
ntm send myproject --cod "Write unit tests" # To all Codex
ntm send myproject --agy "Review and document" # To all Antigravity (Gemini 3.1 Pro)
ntm send myproject --all "Review current state" # To ALL agents
ntm interrupt myproject # Ctrl+C to all
会话导航
| 命令 | 别名 | 描述 |
|---|---|---|
ntm list | lnt | 列出所有 tmux 会话 |
ntm attach | rnt | 连接到会话 |
ntm status | snt | 显示窗格详情和 Agent 数量 |
ntm view | vnt | 取消缩放、平铺布局并连接 |
ntm zoom | znt | 缩放到指定窗格 |
ntm dashboard | dash、d | 打开交互式可视化仪表板 |
ntm kill | knt | 终止会话(使用 -f 强制执行) |
命令面板
可模糊搜索的 TUI,内置预配置提示词:
ntm palette myproject # Open palette
ntm bind # Set up F6 keybinding
ntm bind --key=F5 # Use different key
面板功能
- 采用 Catppuccin 主题的渐变动画横幅
- 支持实时过滤的模糊搜索
- 固定/收藏命令(
Ctrl+P/Ctrl+F) - 带元数据的实时预览窗格
- 使用数字 1-9 快速选择
- 可视化目标选择器(全部/Claude/Codex/Gemini)
面板导航
| 按键 | 操作 |
|---|---|
↑/↓ 或 j/k | 导航 |
1-9 | 快速选择 |
Enter | 选择命令 |
Esc | 返回/退出 |
? | 帮助浮层 |
Ctrl+P | 固定/取消固定 |
Ctrl+F | 收藏 |
交互式仪表板
ntm dashboard myproject # Or: ntm dash myproject
仪表板功能
- 可视化窗格网格,Agent 卡片以颜色区分
- 实时 Agent 数量(Claude/Codex/Gemini/用户)
- Token 速度徽标(每分钟 Token 数)
- 上下文使用量指示器(绿/黄/橙/红)
- 按
r实时刷新
仪表板导航
| 按键 | 操作 |
|---|---|
↑/↓ 或 j/k | 导航窗格 |
1-9 | 快速选择 |
z 或 Enter | 缩放到窗格 |
r | 刷新 |
c | 查看上下文 |
m | 打开 Agent Mail |
q | 退出 |
输出捕获
ntm copy myproject:1 # Copy specific pane
ntm copy myproject --all # Copy all panes
ntm copy myproject --cc # Copy Claude panes only
ntm copy myproject --pattern 'ERROR' # Filter by regex
ntm copy myproject --code # Extract code blocks only
ntm copy myproject --output out.txt # Save to file
ntm save myproject -o ~/logs # Save all outputs
监控与分析
ntm activity myproject --watch # Real-time activity
ntm health myproject # Health status
ntm watch myproject --cc # Stream output
ntm extract myproject --lang=go # Extract code blocks
ntm diff myproject cc_1 cod_1 # Compare panes
ntm grep 'error' myproject -C 3 # Search with context
ntm analytics --days 7 # Session statistics
ntm locks myproject --all-agents # File reservations
活动状态
| 状态 | 图标 | 描述 |
|---|---|---|
| WAITING | ● | 空闲,已准备好工作 |
| GENERATING | ▶ | 正在生成输出 |
| THINKING | ◐ | 正在处理(尚无输出) |
| ERROR | ✗ | 遇到错误 |
| STALLED | ◯ | 意外停止 |
检查点
ntm checkpoint save myproject -m "Before refactor"
ntm checkpoint list myproject
ntm checkpoint show myproject 20251210-143052
ntm checkpoint delete myproject 20251210-143052 -f
上下文窗口轮换
NTM 会监控上下文使用量,并在上下文耗尽前自动轮换 Agent。
工作原理
- 监控:估算每个 Agent 的 Token 使用量
- 警告:使用量达到 80% 时发出提醒
- 压缩:先尝试
/compact或摘要 - 轮换:必要时启用全新 Agent,并附上交接摘要
上下文指示器
| 颜色 | 使用量 | 状态 |
|---|---|---|
| 绿色 | < 40% | 空间充足 |
| 黄色 | 40-60% | 状态良好 |
| 橙色 | 60-80% | 接近阈值 |
| 红色 | > 80% | 需要关注 |
自动压缩恢复
压缩上下文时,NTM 会发送恢复提示词:
[context_rotation.recovery]
enabled = true
prompt = "Reread AGENTS.md so it's still fresh in your mind. Use ultrathink."
include_bead_context = true # Include project state from bv
机器人模式(AI 自动化)
为 AI Agent 和自动化提供机器可读的 JSON 输出。
状态检查
ntm --robot-status # Sessions, panes, agent states
ntm --robot-context=SESSION # Context window usage
ntm --robot-snapshot # Unified state: sessions + beads + mail
ntm --robot-tail=SESSION # Recent pane output
ntm --robot-inspect-pane=SESS # Detailed pane inspection
ntm --robot-files=SESSION # File changes with attribution
ntm --robot-metrics=SESSION # Session metrics
ntm --robot-plan # bv execution plan
ntm --robot-dashboard # Dashboard summary
ntm --robot-health # Project health
Agent 控制
ntm --robot-send=SESSION --msg="Fix auth" --type=claude
ntm --robot-spawn=SESSION --spawn-cc=2 --spawn-wait
ntm --robot-interrupt=SESSION
ntm --robot-assign=SESSION --assign-beads=br-1,br-2
ntm --robot-replay=SESSION --replay-id=ID
Bead 管理
ntm --robot-bead-claim=BEAD_ID --bead-assignee=agent
ntm --robot-bead-create --bead-title="Fix bug" --bead-type=bug
ntm --robot-bead-show=BEAD_ID
ntm --robot-bead-close=BEAD_ID --bead-close-reason="Fixed"
CASS 集成
ntm --robot-cass-search="auth error" --cass-since=7d
ntm --robot-cass-context="how to implement auth"
ntm --robot-cass-status
退出代码
| 代码 | 含义 |
|---|---|
0 | 成功 |
1 | 错误 |
2 | 不可用/尚未实现 |
工作分配
与 BV 集成,实现智能任务分配:
ntm work triage # Full triage with recommendations
ntm work triage --by-label # Group by domain
ntm work triage --quick # Quick wins only
ntm work alerts # Stale issues, priority drift, cycles
ntm work search "JWT auth" # Semantic search
ntm work impact src/api/*.go # Impact analysis
ntm work next # Single best next action
智能分配
ntm --robot-assign=myproject --assign-strategy=balanced # Default
ntm --robot-assign=myproject --assign-strategy=speed # Maximize throughput
ntm --robot-assign=myproject --assign-strategy=quality # Best agent-task match
ntm --robot-assign=myproject --assign-strategy=dependency # Unblock downstream
Agent 能力矩阵
| Agent | 擅长领域 |
|---|---|
| Claude | 分析、重构、文档编写、架构设计 |
| Codex | 功能实现、错误修复、快速任务 |
| Gemini | 文档编写、分析、功能开发 |
配置档案与角色
ntm profiles list # List profiles
ntm profiles show architect # Show details
ntm spawn myproject --profiles=architect,implementer,tester
ntm spawn myproject --profile-set=backend-team
内置配置档案
architect、implementer、reviewer、tester、documenter
Agent Mail 集成
ntm mail send myproject --to GreenCastle "Review API changes"
ntm mail send myproject --all "Checkpoint: sync status"
ntm mail inbox myproject
ntm mail read myproject --agent BlueLake
ntm mail ack myproject 42
提交前防护
ntm hooks guard install # Prevent conflicting commits
ntm hooks guard uninstall
通知
为事件提供多渠道通知:
[notifications]
enabled = true
events = ["agent.error", "agent.crashed", "agent.rate_limit"]
[notifications.desktop]
enabled = true
[notifications.webhook]
enabled = true
url = "https://hooks.slack.com/..."
事件类型
agent.error、agent.crashed、agent.rate_limit、rotation.needed、session.created、session.killed、health.degraded
告警系统
告警类型
| 类型 | 严重程度 | 描述 |
|---|---|---|
unhealthy | 高 | Agent 进入不健康状态 |
degraded | 中 | Agent 性能下降 |
rate_limited | 中 | 检测到 API 速率限制 |
restart_failed | 高 | 重启尝试失败 |
max_restarts | 严重 | 超出重启次数上限 |
ntm --robot-alerts
ntm --robot-dismiss-alert=ALERT_ID
命令钩子
# ~/.config/ntm/hooks.toml
[[command_hooks]]
event = "post-spawn"
command = "notify-send 'NTM' 'Agents spawned'"
[[command_hooks]]
event = "pre-send"
command = "echo \"$(date): $NTM_MESSAGE\" >> ~/.ntm-send.log"
可用事件
pre-spawn、post-spawn、pre-send、post-send、pre-add、post-add、pre-shutdown、post-shutdown
安全系统
阻止 AI Agent 执行危险命令:
ntm safety status # Protection status
ntm safety check "git reset --hard"
ntm safety install # Install git wrapper + Claude hook
ntm safety uninstall
受保护的命令
| 模式 | 风险 | 操作 |
|---|---|---|
git reset --hard | 丢失未提交的更改 | 阻止 |
git push --force | 覆盖远程历史记录 | 阻止 |
rm -rf / | 灾难性删除 | 阻止 |
DROP TABLE | 数据库销毁 | 阻止 |
多 Agent 策略
分而治之
ntm send myproject --cc "design the database schema"
ntm send myproject --cod "implement the models"
ntm send myproject --agy "write tests"
竞争式比较
ntm send myproject --all "implement a rate limiter"
ntm view myproject # Compare side-by-side
审查工作流
ntm send myproject --cc "implement feature X"
ntm send myproject --cod "review Claude's code"
ntm send myproject --agy "write tests for edge cases"
配置
ntm config init # Create ~/.config/ntm/config.toml
ntm config show # Show current config
ntm config project init # Create .ntm/config.toml in project
配置示例
projects_base = "~/Developer"
[agents]
claude = 'claude --dangerously-skip-permissions'
codex = "codex --dangerously-bypass-approvals-and-sandbox"
gemini = "gemini --yolo"
[tmux]
default_panes = 10
palette_key = "F6"
[context_rotation]
enabled = true
warning_threshold = 0.80
rotate_threshold = 0.95
环境变量
| 变量 | 描述 |
|---|---|
NTM_PROJECTS_BASE | 项目的基础目录 |
NTM_THEME | 配色主题:auto、mocha、latte、nord、plain |
NTM_ICONS | 图标集:nerd、unicode、ascii |
NTM_REDUCE_MOTION | 禁用动画 |
NTM_PROFILE | 启用性能分析 |
主题与显示
配色主题
| 主题 | 描述 |
|---|---|
auto | 检测浅色/深色主题 |
mocha | 默认深色,暖色调 |
latte | 浅色变体 |
nord | 北极风格 |
plain | 无颜色 |
Agent 颜色
| Agent | 颜色 |
|---|---|
| Claude | 藕紫色(紫色) |
| Codex | 蓝色 |
| Gemini | 黄色 |
| User | 绿色 |
显示宽度级别
| 宽度 | 行为 |
|---|---|
| <120 cols | 堆叠布局 |
| 120-199 cols | 列表/详情分栏 |
| 200-239 cols | 加宽间距 |
| 240+ cols | 完整详情 |
窗格命名约定
格式:<project>__<agent>_<number>
myproject__cc_1- 第一个 Claudemyproject__cod_2- 第二个 Codexmyproject__gmi_1- 第一个 Gemini
状态指示符:C = Claude、X = Codex、G = Gemini、U = User
Shell 别名
执行 eval "$(ntm init zsh)" 后:
| 类别 | 别名 |
|---|---|
| Agent 启动 | cc、cod、agy(gmi 为旧版别名) |
| 会话 | cnt、sat、qps |
| Agent 管理 | ant、bp、int |
| 导航 | rnt、lnt、snt、vnt、znt |
| 仪表盘 | dash、d |
| 输出 | cpnt、svnt |
| 实用工具 | ncp、knt、cad |
安装
# One-liner (recommended)
curl -fsSL https://raw.githubusercontent.com/Dicklesworthstone/ntm/main/install.sh | bash
# Homebrew
brew install dicklesworthstone/tap/ntm
# Go install
go install github.com/Dicklesworthstone/ntm/cmd/ntm@latest
# Docker
docker pull ghcr.io/dicklesworthstone/ntm:latest
升级
ntm upgrade # Check and install updates
ntm upgrade --check # Check only
ntm upgrade --yes # Auto-confirm
Tmux 基础操作
| 按键 | 操作 |
|---|---|
Ctrl+B, D | 分离 |
Ctrl+B, [ | 滚动/复制模式 |
Ctrl+B, z | 切换缩放 |
Ctrl+B, Arrow | 在窗格间导航 |
F6 | 打开 NTM 调色板(执行 ntm bind 后) |
与 Flywheel 集成
| 工具 | 集成方式 |
|---|---|
| Agent Mail | 消息路由、文件预留、提交前防护 |
| BV | 工作分配、分类处理、分配策略 |
| CASS | 通过 robot mode 搜索过往会话 |
| CM | 用于 Agent 交接的程序性记忆 |
| DCG | 安全系统集成 |
| UBS | 文件变更时自动扫描 |