swain-stage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStage
Stage
Tmux workspace manager for swain. Creates pane layouts, manages an animated MOTD status panel, and gives the agent direct control over the visual workspace.
Prerequisite: Must be running inside a tmux session ( must be set). If not in tmux, inform the user and exit gracefully.
$TMUX面向Swain的Tmux工作区管理器。创建面板布局,管理动态MOTD状态面板,并让Agent能够直接控制可视化工作区。
前提条件: 必须在tmux会话中运行(必须设置环境变量)。如果不在tmux中,需告知用户并优雅退出。
$TMUXScript location
脚本位置
All scripts live in this skill's directory:
scripts/- — main tmux layout and pane manager
swain-stage.sh - — MOTD status panel (Textual TUI, runs via
swain-motd.py)uv run - — legacy bash MOTD (kept as fallback if uv/Textual unavailable)
swain-motd.sh
Resolve the script directory from this skill's install path.
所有脚本都位于该Skill的目录下:
scripts/- — 主tmux布局和面板管理器
swain-stage.sh - — MOTD状态面板(Textual TUI,通过
swain-motd.py运行)uv run - — 旧版bash实现的MOTD(当uv/Textual不可用时作为备用)
swain-motd.sh
从该Skill的安装路径解析脚本目录。
Commands
命令
Layout presets
布局预设
Apply a named layout. Available presets are in :
references/layouts/| Layout | Description |
|---|---|
| focus | Agent pane + MOTD top-right + file browser bottom-right |
| review | Agent + editor (changed files) + MOTD |
| browse | Agent + file browser + MOTD |
bash
bash scripts/swain-stage.sh layout review
bash scripts/swain-stage.sh layout browse
bash scripts/swain-stage.sh layout focusThe default layout is configured in under (default: ).
swain.settings.jsonstage.defaultLayoutfocusUsers can override layout definitions in under .
swain.settings.jsonstage.layouts.<name>应用命名布局。可用预设位于目录中:
references/layouts/| 布局 | 描述 |
|---|---|
| focus | Agent面板 + 右上角MOTD + 右下角文件浏览器 |
| review | Agent + 编辑器(已修改文件) + MOTD |
| browse | Agent + 文件浏览器 + MOTD |
bash
bash scripts/swain-stage.sh layout review
bash scripts/swain-stage.sh layout browse
bash scripts/swain-stage.sh layout focus默认布局在的中配置(默认值:)。
swain.settings.jsonstage.defaultLayoutfocus用户可在的中覆盖布局定义。
swain.settings.jsonstage.layouts.<name>Open individual panes
打开单个面板
Open a specific pane type without applying a full layout:
bash
bash scripts/swain-stage.sh pane editor file1.py file2.py # editor with specific files
bash scripts/swain-stage.sh pane browser # file browser at repo root
bash scripts/swain-stage.sh pane browser /some/path # file browser at specific path
bash scripts/swain-stage.sh pane motd # MOTD status panel
bash scripts/swain-stage.sh pane shell # plain shell无需应用完整布局,直接打开特定类型的面板:
bash
bash scripts/swain-stage.sh pane editor file1.py file2.py # 打开编辑器并加载指定文件
bash scripts/swain-stage.sh pane browser # 在仓库根目录打开文件浏览器
bash scripts/swain-stage.sh pane browser /some/path # 在指定路径打开文件浏览器
bash scripts/swain-stage.sh pane motd # 打开MOTD状态面板
bash scripts/swain-stage.sh pane shell # 打开普通Shell面板MOTD management
MOTD管理
The MOTD pane shows a dynamic status panel with:
- Project name, branch, and dirty state
- Animated spinner when the agent is working (braille, dots, or bar style)
- Current agent context (what it's doing)
- Active epic with progress ratio (from swain-status cache)
- Active bd task
- Ready (actionable) artifact count
- Last commit info
- Assigned GitHub issue count
- Count of touched files
The MOTD is a Textual TUI app () launched via . It reads project data from (written by swain-status) when available, falling back to direct git/bd queries when the cache is absent or stale (>5 min). Agent state (spinner, context) is always read from for real-time responsiveness. Textual handles Unicode width correctly, provides proper box drawing with rounded corners, and supports color theming.
swain-motd.pyuv runstatus-cache.jsonstage-status.jsonControl the MOTD:
bash
bash scripts/swain-stage.sh motd start # start MOTD in a new pane
bash scripts/swain-stage.sh motd stop # kill the MOTD pane
bash scripts/swain-stage.sh motd update "reviewing auth module" # update context
bash scripts/swain-stage.sh motd update "idle" # mark as idle
bash scripts/swain-stage.sh motd update "done" # mark as done/idleMOTD面板显示动态状态信息,包括:
- 项目名称、分支和脏状态
- Agent工作时的动态加载动画(盲文、点状或条状样式)
- 当前Agent的上下文(正在执行的任务)
- 进行中的Epic及进度占比(来自swain-status缓存)
- 活跃的bd任务
- 可操作的工件数量
- 最后一次提交信息
- 已分配的GitHub问题数量
- 已修改文件的数量
MOTD是一个Textual TUI应用(),通过启动。当(由swain-status生成)可用时,它会从中读取项目数据;如果缓存不存在或已过期(超过5分钟),则回退到直接查询git/bd。Agent状态(加载动画、上下文)始终从读取,以保证实时响应。Textual能够正确处理Unicode宽度,提供带圆角的标准边框绘制,并支持颜色主题定制。
swain-motd.pyuv runstatus-cache.jsonstage-status.json控制MOTD:
bash
bash scripts/swain-stage.sh motd start # 在新面板中启动MOTD
bash scripts/swain-stage.sh motd stop # 关闭MOTD面板
bash scripts/swain-stage.sh motd update "reviewing auth module" # 更新上下文信息
bash scripts/swain-stage.sh motd update "idle" # 标记为空闲状态
bash scripts/swain-stage.sh motd update "done" # 标记为完成/空闲状态Close panes
关闭面板
bash
bash scripts/swain-stage.sh close right # close the right pane
bash scripts/swain-stage.sh close bottom # close the bottom pane
bash scripts/swain-stage.sh close all # reset to single panebash
bash scripts/swain-stage.sh close right # 关闭右侧面板
bash scripts/swain-stage.sh close bottom # 关闭底部面板
bash scripts/swain-stage.sh close all # 重置为单个面板Status
状态查询
bash
bash scripts/swain-stage.sh status # show current layout infobash
bash scripts/swain-stage.sh status # 显示当前布局信息Reset
重置
bash
bash scripts/swain-stage.sh reset # kill all panes except currentbash
bash scripts/swain-stage.sh reset # 关闭当前面板以外的所有面板Agent-triggered pane operations
Agent触发的面板操作
The agent should use swain-stage directly during work. Recommended patterns:
Agent应在工作期间直接使用swain-stage。推荐使用模式:
After making changes — open review
修改完成后——打开审阅面板
When you've finished modifying files, open them for the user to review:
bash
bash scripts/swain-stage.sh motd update "changes ready for review"
bash scripts/swain-stage.sh pane editor file1.py file2.py当你完成文件修改后,打开文件供用户审阅:
bash
bash scripts/swain-stage.sh motd update "changes ready for review"
bash scripts/swain-stage.sh pane editor file1.py file2.pyDuring research — open file browser
研究期间——打开文件浏览器
When exploring the codebase:
bash
bash scripts/swain-stage.sh pane browser src/components/探索代码库时:
bash
bash scripts/swain-stage.sh pane browser src/components/Update context as you work
工作时更新上下文
Keep the MOTD informed of what you're doing:
bash
bash scripts/swain-stage.sh motd update "analyzing test failures"
bash scripts/swain-stage.sh motd update "writing migration script"
bash scripts/swain-stage.sh motd update "done"随时更新MOTD以告知用户当前工作内容:
bash
bash scripts/swain-stage.sh motd update "analyzing test failures"
bash scripts/swain-stage.sh motd update "writing migration script"
bash scripts/swain-stage.sh motd update "done"Clean up when done
完成工作后清理
bash
bash scripts/swain-stage.sh close right
bash scripts/swain-stage.sh motd update "idle"bash
bash scripts/swain-stage.sh close right
bash scripts/swain-stage.sh motd update "idle"Settings
设置
Read from (project) and (user override). User settings take precedence.
swain.settings.json~/.config/swain/settings.json| Key | Type | Default | Description |
|---|---|---|---|
| string | | Editor command. |
| string | | File browser command. |
| string | | Layout applied by default |
| number | | MOTD refresh interval in seconds (idle) |
| string | | Spinner animation: |
| object | | User-defined layout overrides (same schema as preset files) |
从项目级和用户级读取设置。用户级设置优先级更高。
swain.settings.json~/.config/swain/settings.json| 键 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| 字符串 | | 编辑器命令。 |
| 字符串 | | 文件浏览器命令。 |
| 字符串 | | 默认应用的布局 |
| 数字 | | MOTD空闲时的刷新间隔(秒) |
| 字符串 | | 加载动画样式: |
| 对象 | | 用户自定义的布局覆盖(与预设文件 schema 一致) |
Error handling
错误处理
- If not in tmux: report clearly and exit. Do not attempt tmux commands.
- If editor/file browser is not installed: warn the user and suggest alternatives or override.
swain.settings.json - If jq is not available: warn that settings cannot be read, use hardcoded defaults.
- Pane operations are best-effort — if a pane can't be created or found, warn but don't fail the session.
- 如果不在tmux中:清晰提示并退出,不执行任何tmux命令。
- 如果编辑器/文件浏览器未安装:警告用户并建议替代方案或通过覆盖设置。
swain.settings.json - 如果jq不可用:警告无法读取设置,使用硬编码默认值。
- 面板操作采用尽力而为原则——如果无法创建或找到面板,仅发出警告但不终止会话。