838b5ae216
Update root + 43 directory-level AGENTS.md files to reflect current state: - Root AGENTS.md rewritten with accurate counts (1967 TS files, 1304 source + 663 test, 278k LOC, 120 barrel index.ts), 7-step init flow, 5-tier hook composition, and full Team Mode section (12 team_* tools, eligibility, storage layout, config gate) - src/AGENTS.md adds team-mode init step, current per-subdir file/LOC table - src/tools/AGENTS.md documents conditional gates (team-mode +12, task system +4, hashline +1, interactive_bash +1, look_at +1) with always-on baseline of 20 - src/hooks/AGENTS.md splits into 5 tiers + 4 conditional team-mode hooks - src/features/team-mode/AGENTS.md surfaces 12 tools, eligible agents, spawn-race-safe invariants, and integration points - src/features/builtin-skills/AGENTS.md tracks 10 skills incl. team-mode - src/agents/AGENTS.md, src/plugin/AGENTS.md, src/config/AGENTS.md updated for team-mode awareness, accurate counts, and current schema field list - All other AGENTS.md files refreshed to 2026-05-08 generation date
2.0 KiB
2.0 KiB
src/features/tmux-subagent/ — Tmux Pane Management
Generated: 2026-05-08
OVERVIEW
32 files. State-first tmux integration managing panes for background agent sessions. Handles split decisions, grid planning, polling, and lifecycle events.
CORE ARCHITECTURE
TmuxSessionManager (manager.ts)
├─→ DecisionEngine: Should we spawn/close panes?
├─→ ActionExecutor: Execute spawn/close/replace actions
├─→ PollingManager: Monitor pane health
└─→ EventHandlers: React to session create/delete
All tmux command execution is centralized through src/shared/tmux/runner.ts (runTmuxCommand). Do NOT add direct Bun.spawn([tmux,...]) calls in this module. They will drift from the retry/timeout/terminal-error discipline.
KEY FILES
| File | Purpose |
|---|---|
manager.ts |
TmuxSessionManager — main class, session tracking, event routing |
decision-engine.ts |
Evaluate window state → produce SpawnDecision with actions |
action-executor.ts |
Execute PaneAction[] (close, spawn, replace) |
grid-planning.ts |
Calculate pane layout given window dimensions |
spawn-action-decider.ts |
Decide spawn vs replace vs skip |
spawn-target-finder.ts |
Find best pane to split or replace |
polling-manager.ts |
Health polling for tracked sessions |
types.ts |
TrackedSession, WindowState, PaneAction, SpawnDecision |
PANE LIFECYCLE
session.created → spawn-action-decider → grid-planning → action-executor → track session
session.deleted → cleanup tracked session → close pane if empty
LAYOUT CONSTRAINTS
MIN_PANE_WIDTH: 52 charsMIN_PANE_HEIGHT: 11 lines- Main pane preserved (never split below minimum)
- Agent panes split from remaining space
EVENT HANDLERS
| File | Event |
|---|---|
session-created-handler.ts |
New background session → spawn pane |
session-deleted-handler.ts |
Session ended → close pane |
session-created-event.ts |
Event type definition |