devmux 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
devmux/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """devmux - A tmux session manager for AI agent CLIs."""
2
+
3
+ __version__ = "0.2.0"
devmux/cli/main.py ADDED
@@ -0,0 +1,216 @@
1
+ #!/usr/bin/env python3
2
+ """devmux - A tmux session manager for AI agent CLIs."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from pathlib import Path
7
+ import sys
8
+
9
+ import click
10
+
11
+ from devmux import __version__
12
+ from devmux.core.manager import SessionManager, SessionManagerError
13
+ from devmux.utils.config import Config, ConfigError, VALID_ROLES, render_preset
14
+
15
+
16
+ def _load_config(config_path: str) -> Config:
17
+ path = Path(config_path)
18
+ if not path.exists():
19
+ raise ConfigError(f"Config file '{config_path}' not found.")
20
+ return Config.load(path)
21
+
22
+
23
+ def _fail(exc: Exception) -> None:
24
+ click.echo(f"Error: {exc}", err=True)
25
+ raise SystemExit(1) from exc
26
+
27
+
28
+ @click.group()
29
+ @click.version_option(version=__version__)
30
+ def cli() -> None:
31
+ """Launch reproducible tmux workspaces for AI-heavy CLI development."""
32
+
33
+
34
+ @cli.command()
35
+ @click.option(
36
+ "--preset",
37
+ type=click.Choice(["minimal", "backend", "full-stack"]),
38
+ default="backend",
39
+ show_default=True,
40
+ help="Starter workspace template to scaffold.",
41
+ )
42
+ @click.option(
43
+ "--config",
44
+ "-c",
45
+ default="devmux.yaml",
46
+ show_default=True,
47
+ help="Path to write the generated config file.",
48
+ )
49
+ @click.option(
50
+ "--force",
51
+ is_flag=True,
52
+ help="Overwrite the target config file if it already exists.",
53
+ )
54
+ def init(preset: str, config: str, force: bool) -> None:
55
+ """Create a starter devmux config."""
56
+ try:
57
+ config_path = Path(config)
58
+ if config_path.exists() and not force:
59
+ raise ConfigError(
60
+ f"Config file '{config}' already exists. Pass --force to overwrite it."
61
+ )
62
+
63
+ config_path.parent.mkdir(parents=True, exist_ok=True)
64
+ config_path.write_text(render_preset(preset), encoding="utf-8")
65
+ click.echo(f"Wrote {preset} preset to '{config}'.")
66
+ except Exception as exc:
67
+ _fail(exc)
68
+
69
+
70
+ @cli.command()
71
+ @click.argument("workspace_name")
72
+ @click.option(
73
+ "--config",
74
+ "-c",
75
+ default="devmux.yaml",
76
+ show_default=True,
77
+ help="Path to config file.",
78
+ )
79
+ @click.option(
80
+ "--detach",
81
+ is_flag=True,
82
+ help="Create or reuse the session without attaching to it.",
83
+ )
84
+ @click.option(
85
+ "--recreate",
86
+ is_flag=True,
87
+ help="Kill any existing session with the same name before creating it again.",
88
+ )
89
+ def start(workspace_name: str, config: str, detach: bool, recreate: bool) -> None:
90
+ """Create or resume a named workspace."""
91
+ try:
92
+ cfg = _load_config(config)
93
+ manager = SessionManager()
94
+ result = manager.start_workspace(workspace_name, cfg, recreate=recreate)
95
+
96
+ if detach:
97
+ verb = "Created" if result.created else "Reusing"
98
+ click.echo(f"{verb} detached session '{workspace_name}'.")
99
+ return
100
+
101
+ click.echo(f"Attaching to session '{workspace_name}'.")
102
+ manager.attach_session(workspace_name)
103
+ except Exception as exc:
104
+ _fail(exc)
105
+
106
+
107
+ @cli.command(name="attach")
108
+ @click.argument("workspace_name")
109
+ def attach(workspace_name: str) -> None:
110
+ """Attach to an existing session."""
111
+ try:
112
+ manager = SessionManager()
113
+ manager.attach_session(workspace_name)
114
+ except Exception as exc:
115
+ _fail(exc)
116
+
117
+
118
+ @cli.command(name="resume")
119
+ @click.argument("workspace_name")
120
+ def resume(workspace_name: str) -> None:
121
+ """Resume an existing session by name."""
122
+ try:
123
+ manager = SessionManager()
124
+ manager.attach_session(workspace_name)
125
+ except Exception as exc:
126
+ _fail(exc)
127
+
128
+
129
+ @cli.command(name="ls")
130
+ def list_sessions() -> None:
131
+ """List active tmux sessions."""
132
+ try:
133
+ manager = SessionManager()
134
+ sessions = manager.list_sessions()
135
+ if sessions:
136
+ click.echo("Active sessions:")
137
+ for session in sessions:
138
+ click.echo(f" - {session}")
139
+ else:
140
+ click.echo("No active sessions.")
141
+ except Exception as exc:
142
+ _fail(exc)
143
+
144
+
145
+ @cli.command()
146
+ @click.argument("workspace_name")
147
+ def kill(workspace_name: str) -> None:
148
+ """Kill a named session."""
149
+ try:
150
+ manager = SessionManager()
151
+ manager.kill_session(workspace_name)
152
+ click.echo(f"Killed session '{workspace_name}'.")
153
+ except Exception as exc:
154
+ _fail(exc)
155
+
156
+
157
+ @cli.command()
158
+ @click.argument("prompt")
159
+ @click.option(
160
+ "--session",
161
+ "-s",
162
+ help="Target session name. Defaults to the current tmux session.",
163
+ )
164
+ @click.option(
165
+ "--all",
166
+ "send_all",
167
+ is_flag=True,
168
+ help="Send to every pane in the target session.",
169
+ )
170
+ @click.option(
171
+ "--role",
172
+ type=click.Choice(sorted(VALID_ROLES)),
173
+ help="Send only to panes with the selected role.",
174
+ )
175
+ @click.option(
176
+ "--pane",
177
+ "pane_names",
178
+ multiple=True,
179
+ help="Send only to the named pane. Repeat to target multiple panes.",
180
+ )
181
+ def send(
182
+ prompt: str,
183
+ session: str | None,
184
+ send_all: bool,
185
+ role: str | None,
186
+ pane_names: tuple[str, ...],
187
+ ) -> None:
188
+ """Send a prompt to selected panes."""
189
+ try:
190
+ if send_all and (role or pane_names):
191
+ raise click.ClickException(
192
+ "--all cannot be combined with --role or --pane."
193
+ )
194
+ if role and pane_names:
195
+ raise click.ClickException("--role cannot be combined with --pane.")
196
+
197
+ manager = SessionManager()
198
+ delivered_to = manager.broadcast_prompt(
199
+ prompt,
200
+ session_name=session,
201
+ send_all=send_all,
202
+ role=role,
203
+ pane_names=pane_names,
204
+ )
205
+ click.echo(f"Delivered prompt to: {', '.join(delivered_to)}")
206
+ except Exception as exc:
207
+ _fail(exc)
208
+
209
+
210
+ def main() -> int:
211
+ cli()
212
+ return 0
213
+
214
+
215
+ if __name__ == "__main__":
216
+ sys.exit(main())
@@ -0,0 +1 @@
1
+
devmux/core/manager.py ADDED
@@ -0,0 +1,236 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ import os
5
+ import shutil
6
+ from typing import Iterable
7
+
8
+ import libtmux
9
+ from libtmux.constants import OptionScope, PaneDirection
10
+ from libtmux.pane import Pane
11
+ from libtmux.session import Session
12
+ from libtmux.window import Window
13
+
14
+ from devmux.utils.config import Config, ConfigError, PaneConfig, WorkspaceConfig
15
+
16
+
17
+ class SessionManagerError(RuntimeError):
18
+ """Raised when tmux session management fails."""
19
+
20
+
21
+ @dataclass(frozen=True)
22
+ class StartResult:
23
+ session_name: str
24
+ created: bool
25
+
26
+
27
+ class SessionManager:
28
+ def __init__(self, socket_name: str | None = None, tmux_bin: str | None = None):
29
+ self.tmux_bin = tmux_bin or shutil.which("tmux")
30
+ self.server = libtmux.Server(socket_name=socket_name, tmux_bin=self.tmux_bin)
31
+
32
+ def ensure_tmux_available(self) -> None:
33
+ if not self.tmux_bin:
34
+ raise SessionManagerError(
35
+ "tmux is not installed or not available on PATH. Install tmux first."
36
+ )
37
+ try:
38
+ self.server.cmd("list-sessions")
39
+ except Exception as exc: # pragma: no cover - libtmux exception surface varies
40
+ raise SessionManagerError(f"Unable to reach tmux: {exc}") from exc
41
+
42
+ def start_workspace(
43
+ self,
44
+ workspace_name: str,
45
+ config: Config,
46
+ *,
47
+ recreate: bool = False,
48
+ ) -> StartResult:
49
+ self.ensure_tmux_available()
50
+ workspace = self._get_workspace(config, workspace_name)
51
+
52
+ if recreate and self.server.has_session(workspace_name):
53
+ self.kill_session(workspace_name)
54
+
55
+ if self.server.has_session(workspace_name):
56
+ return StartResult(session_name=workspace_name, created=False)
57
+
58
+ session = self._create_session(workspace_name, workspace)
59
+ self._configure_session(session, workspace)
60
+ return StartResult(session_name=workspace_name, created=True)
61
+
62
+ def attach_session(self, workspace_name: str) -> None:
63
+ self.ensure_tmux_available()
64
+ session = self._find_session(workspace_name)
65
+ if session is None:
66
+ raise SessionManagerError(f"Session '{workspace_name}' does not exist.")
67
+ self.server.attach_session(target_session=workspace_name)
68
+
69
+ def list_sessions(self) -> list[str]:
70
+ self.ensure_tmux_available()
71
+ return [session.session_name for session in self.server.sessions]
72
+
73
+ def kill_session(self, workspace_name: str) -> None:
74
+ self.ensure_tmux_available()
75
+ session = self._find_session(workspace_name)
76
+ if session is None:
77
+ raise SessionManagerError(f"Session '{workspace_name}' does not exist.")
78
+ session.kill()
79
+
80
+ def broadcast_prompt(
81
+ self,
82
+ prompt: str,
83
+ *,
84
+ session_name: str | None = None,
85
+ send_all: bool = False,
86
+ role: str | None = None,
87
+ pane_names: Iterable[str] | None = None,
88
+ ) -> list[str]:
89
+ self.ensure_tmux_available()
90
+ session = self._resolve_session_for_send(session_name)
91
+ panes = self._resolve_target_panes(
92
+ session,
93
+ send_all=send_all,
94
+ role=role,
95
+ pane_names=list(pane_names or []),
96
+ )
97
+ if not panes:
98
+ raise SessionManagerError(
99
+ f"No panes matched in session '{session.session_name}'."
100
+ )
101
+
102
+ delivered_to: list[str] = []
103
+ for pane in panes:
104
+ pane.send_keys(prompt, enter=True)
105
+ delivered_to.append(self._pane_name(pane))
106
+ return delivered_to
107
+
108
+ def _create_session(self, workspace_name: str, workspace: WorkspaceConfig) -> Session:
109
+ start_directory = None
110
+ if workspace.cwd:
111
+ start_directory = str(
112
+ PaneConfig(
113
+ name="_workspace",
114
+ role="shell",
115
+ command="true",
116
+ cwd=workspace.cwd,
117
+ ).resolved_cwd(base_dir=workspace.base_dir)
118
+ )
119
+ return self.server.new_session(
120
+ session_name=workspace_name,
121
+ attach=False,
122
+ start_directory=start_directory,
123
+ )
124
+
125
+ def _configure_session(self, session: Session, workspace: WorkspaceConfig) -> None:
126
+ window = session.active_window
127
+ panes = self._build_layout(window, workspace)
128
+ for pane, pane_config in zip(panes, workspace.panes, strict=True):
129
+ self._configure_pane(pane, pane_config, workspace)
130
+
131
+ def _build_layout(self, window: Window, workspace: WorkspaceConfig) -> list[Pane]:
132
+ base_pane = window.active_pane
133
+ panes = [base_pane]
134
+
135
+ if workspace.layout == "duo":
136
+ panes.append(base_pane.split(direction=PaneDirection.Right, size="50%"))
137
+ return panes
138
+
139
+ if workspace.layout == "trio":
140
+ side_pane = base_pane.split(direction=PaneDirection.Right, size="50%")
141
+ panes.append(side_pane)
142
+ panes.append(side_pane.split(direction=PaneDirection.Below, size="50%"))
143
+ return panes
144
+
145
+ if workspace.layout == "quad":
146
+ right_pane = base_pane.split(direction=PaneDirection.Right, size="50%")
147
+ panes.append(right_pane)
148
+ panes.append(base_pane.split(direction=PaneDirection.Below, size="50%"))
149
+ panes.append(right_pane.split(direction=PaneDirection.Below, size="50%"))
150
+ return panes
151
+
152
+ if workspace.layout == "focus":
153
+ side_seed = base_pane.split(direction=PaneDirection.Right, size="30%")
154
+ panes.append(side_seed)
155
+ for _ in range(len(workspace.panes) - 2):
156
+ panes.append(side_seed.split(direction=PaneDirection.Below))
157
+ window.select_layout("main-vertical")
158
+ window.set_option("main-pane-width", "70%", scope=OptionScope.Window)
159
+ return panes
160
+
161
+ raise SessionManagerError(f"Unsupported layout '{workspace.layout}'.")
162
+
163
+ def _configure_pane(
164
+ self, pane: Pane, pane_config: PaneConfig, workspace: WorkspaceConfig
165
+ ) -> None:
166
+ pane_path = pane_config.resolved_cwd(workspace.cwd, workspace.base_dir)
167
+ pane.set_title(pane_config.name)
168
+ pane.set_option("@devmux_name", pane_config.name, scope=OptionScope.Pane)
169
+ pane.set_option("@devmux_role", pane_config.role, scope=OptionScope.Pane)
170
+ pane.send_keys(f"cd {self._shell_quote(str(pane_path))}", enter=True)
171
+ pane.send_keys(pane_config.command, enter=True)
172
+
173
+ def _resolve_session_for_send(self, session_name: str | None) -> Session:
174
+ target_session = session_name or self._current_session_name()
175
+ if not target_session:
176
+ raise SessionManagerError(
177
+ "Not inside a tmux session and no session specified. Pass --session NAME."
178
+ )
179
+ session = self._find_session(target_session)
180
+ if session is None:
181
+ raise SessionManagerError(f"Session '{target_session}' does not exist.")
182
+ return session
183
+
184
+ def _resolve_target_panes(
185
+ self,
186
+ session: Session,
187
+ *,
188
+ send_all: bool,
189
+ role: str | None,
190
+ pane_names: list[str],
191
+ ) -> list[Pane]:
192
+ panes = list(session.active_window.panes)
193
+ if send_all:
194
+ return panes
195
+
196
+ if pane_names:
197
+ matched = [pane for pane in panes if self._pane_name(pane) in set(pane_names)]
198
+ missing = sorted(set(pane_names) - {self._pane_name(pane) for pane in matched})
199
+ if missing:
200
+ raise SessionManagerError(
201
+ f"Unknown pane names for session '{session.session_name}': {', '.join(missing)}."
202
+ )
203
+ return matched
204
+
205
+ target_role = role or "agent"
206
+ return [pane for pane in panes if self._pane_role(pane) == target_role]
207
+
208
+ def _get_workspace(self, config: Config, workspace_name: str) -> WorkspaceConfig:
209
+ workspace = config.workspaces.get(workspace_name)
210
+ if workspace is None:
211
+ raise ConfigError(f"Workspace '{workspace_name}' not found in config.")
212
+ return workspace
213
+
214
+ def _find_session(self, workspace_name: str) -> Session | None:
215
+ return self.server.sessions.get(session_name=workspace_name)
216
+
217
+ def _current_session_name(self) -> str | None:
218
+ pane_id = os.environ.get("TMUX_PANE")
219
+ if not pane_id:
220
+ return None
221
+ output = self.server.cmd("display-message", "-p", "-t", pane_id, "#{session_name}")
222
+ if output.returncode != 0 or not output.stdout:
223
+ return None
224
+ return output.stdout[0].strip()
225
+
226
+ @staticmethod
227
+ def _pane_name(pane: Pane) -> str:
228
+ return str(pane.show_option("@devmux_name", scope=OptionScope.Pane) or pane.pane_title)
229
+
230
+ @staticmethod
231
+ def _pane_role(pane: Pane) -> str:
232
+ return str(pane.show_option("@devmux_role", scope=OptionScope.Pane) or "agent")
233
+
234
+ @staticmethod
235
+ def _shell_quote(value: str) -> str:
236
+ return "'" + value.replace("'", "'\"'\"'") + "'"
@@ -0,0 +1 @@
1
+
devmux/utils/config.py ADDED
@@ -0,0 +1,230 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass, field
4
+ from pathlib import Path
5
+ import os
6
+ from typing import Any
7
+
8
+ import yaml
9
+
10
+
11
+ VALID_LAYOUTS = {"duo", "trio", "quad", "focus"}
12
+ VALID_ROLES = {"agent", "logs", "tests", "shell"}
13
+
14
+
15
+ class ConfigError(ValueError):
16
+ """Raised when devmux configuration is invalid."""
17
+
18
+
19
+ @dataclass(frozen=True)
20
+ class PaneConfig:
21
+ name: str
22
+ role: str
23
+ command: str
24
+ cwd: str | None = None
25
+
26
+ def resolved_cwd(
27
+ self, workspace_cwd: str | None = None, base_dir: Path | None = None
28
+ ) -> Path:
29
+ cwd = Path(os.path.expanduser(self.cwd or workspace_cwd or "."))
30
+ if cwd.is_absolute():
31
+ return cwd.resolve()
32
+ anchor = base_dir or Path.cwd()
33
+ return (anchor / cwd).resolve()
34
+
35
+
36
+ @dataclass(frozen=True)
37
+ class WorkspaceConfig:
38
+ layout: str
39
+ cwd: str | None = None
40
+ panes: list[PaneConfig] = field(default_factory=list)
41
+ base_dir: Path = field(default_factory=Path.cwd)
42
+
43
+ def validate(self, name: str) -> None:
44
+ if self.layout not in VALID_LAYOUTS:
45
+ raise ConfigError(
46
+ f"Workspace '{name}' uses unsupported layout '{self.layout}'. "
47
+ f"Choose one of: {', '.join(sorted(VALID_LAYOUTS))}."
48
+ )
49
+
50
+ pane_count = len(self.panes)
51
+ if pane_count == 0:
52
+ raise ConfigError(f"Workspace '{name}' must define at least one pane.")
53
+
54
+ layout_bounds = {
55
+ "duo": {2},
56
+ "trio": {3},
57
+ "quad": {4},
58
+ "focus": {2, 3, 4, 5},
59
+ }
60
+ if pane_count not in layout_bounds[self.layout]:
61
+ allowed = ", ".join(str(count) for count in sorted(layout_bounds[self.layout]))
62
+ raise ConfigError(
63
+ f"Workspace '{name}' layout '{self.layout}' supports pane counts: {allowed}. "
64
+ f"Found {pane_count}."
65
+ )
66
+
67
+ seen_names: set[str] = set()
68
+ for pane in self.panes:
69
+ if not pane.name.strip():
70
+ raise ConfigError(f"Workspace '{name}' contains a pane with an empty name.")
71
+ if pane.name in seen_names:
72
+ raise ConfigError(
73
+ f"Workspace '{name}' defines duplicate pane name '{pane.name}'."
74
+ )
75
+ seen_names.add(pane.name)
76
+
77
+ if pane.role not in VALID_ROLES:
78
+ raise ConfigError(
79
+ f"Pane '{pane.name}' in workspace '{name}' uses unsupported role "
80
+ f"'{pane.role}'. Choose one of: {', '.join(sorted(VALID_ROLES))}."
81
+ )
82
+ if not pane.command.strip():
83
+ raise ConfigError(
84
+ f"Pane '{pane.name}' in workspace '{name}' must define a non-empty command."
85
+ )
86
+ resolved_cwd = pane.resolved_cwd(self.cwd, self.base_dir)
87
+ if not resolved_cwd.exists():
88
+ raise ConfigError(
89
+ f"Pane '{pane.name}' in workspace '{name}' references missing cwd "
90
+ f"'{resolved_cwd}'."
91
+ )
92
+
93
+
94
+ @dataclass(frozen=True)
95
+ class Config:
96
+ workspaces: dict[str, WorkspaceConfig] = field(default_factory=dict)
97
+
98
+ @classmethod
99
+ def load(cls, path: Path) -> "Config":
100
+ with path.open("r", encoding="utf-8") as handle:
101
+ data = yaml.safe_load(handle) or {}
102
+
103
+ if not isinstance(data, dict):
104
+ raise ConfigError("The config file must contain a top-level mapping.")
105
+
106
+ workspaces_data = data.get("workspaces", {})
107
+ if not isinstance(workspaces_data, dict):
108
+ raise ConfigError("'workspaces' must be a mapping.")
109
+
110
+ workspaces: dict[str, WorkspaceConfig] = {}
111
+ for workspace_name, raw_workspace in workspaces_data.items():
112
+ if not isinstance(raw_workspace, dict):
113
+ raise ConfigError(
114
+ f"Workspace '{workspace_name}' must be defined as a mapping."
115
+ )
116
+
117
+ layout = str(raw_workspace.get("layout", "")).strip()
118
+ workspace_cwd = raw_workspace.get("cwd")
119
+
120
+ panes = cls._parse_panes(raw_workspace)
121
+ workspace = WorkspaceConfig(
122
+ layout=layout,
123
+ cwd=workspace_cwd,
124
+ panes=panes,
125
+ base_dir=path.parent.resolve(),
126
+ )
127
+ workspace.validate(workspace_name)
128
+ workspaces[workspace_name] = workspace
129
+
130
+ return cls(workspaces=workspaces)
131
+
132
+ @staticmethod
133
+ def _parse_panes(raw_workspace: dict[str, Any]) -> list[PaneConfig]:
134
+ if "panes" in raw_workspace:
135
+ raw_panes = raw_workspace["panes"]
136
+ else:
137
+ raw_agents = raw_workspace.get("agents", [])
138
+ raw_panes = [
139
+ {
140
+ "name": agent.get("name", ""),
141
+ "role": "agent",
142
+ "command": Config._legacy_agent_command(agent),
143
+ "cwd": agent.get("cwd"),
144
+ }
145
+ for agent in raw_agents
146
+ ]
147
+
148
+ if not isinstance(raw_panes, list):
149
+ raise ConfigError("'panes' must be a list.")
150
+
151
+ panes: list[PaneConfig] = []
152
+ for raw_pane in raw_panes:
153
+ if not isinstance(raw_pane, dict):
154
+ raise ConfigError("Each pane definition must be a mapping.")
155
+
156
+ name = str(raw_pane.get("name", "")).strip()
157
+ role = str(raw_pane.get("role", "agent")).strip()
158
+ command = str(raw_pane.get("command", "")).strip()
159
+ cwd = raw_pane.get("cwd")
160
+
161
+ panes.append(PaneConfig(name=name, role=role, command=command, cwd=cwd))
162
+
163
+ return panes
164
+
165
+ @staticmethod
166
+ def _legacy_agent_command(agent: dict[str, Any]) -> str:
167
+ cmd = str(agent.get("cmd", "")).strip()
168
+ flags = str(agent.get("flags", "")).strip()
169
+ return " ".join(part for part in [cmd, flags] if part)
170
+
171
+
172
+ def render_preset(preset: str) -> str:
173
+ presets = {
174
+ "minimal": """# devmux v0.2 example config
175
+ # Replace the example commands below with the agent CLIs you use daily.
176
+ workspaces:
177
+ minimal:
178
+ layout: duo
179
+ cwd: .
180
+ panes:
181
+ - name: claude
182
+ role: agent
183
+ command: "claude"
184
+ - name: codex
185
+ role: agent
186
+ command: "codex --approval auto"
187
+ """,
188
+ "backend": """# devmux v0.2 example config
189
+ # The commands are generic examples. Swap in Claude, Codex, Gemini, Aider, tests, or logs as needed.
190
+ workspaces:
191
+ backend:
192
+ layout: trio
193
+ cwd: .
194
+ panes:
195
+ - name: planner
196
+ role: agent
197
+ command: "claude"
198
+ - name: builder
199
+ role: agent
200
+ command: "codex --approval auto"
201
+ - name: logs
202
+ role: logs
203
+ command: "docker compose logs -f"
204
+ """,
205
+ "full-stack": """# devmux v0.2 example config
206
+ # The layout is tuned for two agents plus live tests and logs.
207
+ workspaces:
208
+ full-stack:
209
+ layout: quad
210
+ cwd: .
211
+ panes:
212
+ - name: frontend
213
+ role: agent
214
+ command: "claude"
215
+ - name: backend
216
+ role: agent
217
+ command: "codex --approval auto"
218
+ - name: tests
219
+ role: tests
220
+ command: "npm test"
221
+ - name: logs
222
+ role: logs
223
+ command: "docker compose logs -f"
224
+ """,
225
+ }
226
+ if preset not in presets:
227
+ raise ConfigError(
228
+ f"Unknown preset '{preset}'. Choose one of: minimal, backend, full-stack."
229
+ )
230
+ return presets[preset]
@@ -0,0 +1,288 @@
1
+ Metadata-Version: 2.4
2
+ Name: devmux
3
+ Version: 0.2.0
4
+ Summary: A tmux session manager purpose-built for AI agent CLIs
5
+ Author-email: Ollayor <ollayor@example.com>
6
+ Project-URL: Homepage, https://github.com/olllayor/devmux
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: libtmux>=0.8.2
14
+ Requires-Dist: PyYAML>=5.4
15
+ Requires-Dist: click>=8.0
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest>=8.0; extra == "dev"
18
+ Dynamic: license-file
19
+
20
+ # devmux
21
+
22
+ `devmux` is a tmux launcher for developers who use multiple AI agents in the CLI.
23
+
24
+ It gives you one command to open a repeatable coding cockpit with agent panes, tests, logs, and shell helpers in the right layout and working directories.
25
+
26
+ ## Why it exists
27
+
28
+ If you already work with tools like Claude Code, Codex, Gemini CLI, Aider, test watchers, and logs, your terminal usually turns into a mess:
29
+
30
+ - too many panes to rebuild by hand
31
+ - prompts sent to the wrong place
32
+ - different repos and directories across panes
33
+ - no shared setup you can reuse every day
34
+
35
+ `devmux` fixes that by making your workflow reproducible.
36
+
37
+ ## What it does
38
+
39
+ - Launch named workspaces from `devmux.yaml`
40
+ - Create real tmux layouts: `duo`, `trio`, `quad`, `focus`
41
+ - Route prompts safely by pane role or pane name
42
+ - Reuse existing sessions with idempotent `start`
43
+ - Rebuild a workspace with `--recreate`
44
+ - Scaffold starter configs with `devmux init`
45
+ - Keep runtime behavior generic while still supporting AI-heavy workflows
46
+
47
+ ## Who it is for
48
+
49
+ `devmux` is best for developers who:
50
+
51
+ - already use tmux
52
+ - run 2 to 5 CLI agents or helper panes at once
53
+ - want one command to restore a known working setup
54
+ - want a simple, scriptable alternative to a full TUI dashboard
55
+
56
+ ## Requirements
57
+
58
+ - macOS or Linux
59
+ - `tmux` installed and available on `PATH`
60
+ - Python 3.8+
61
+
62
+ Check tmux:
63
+
64
+ ```bash
65
+ tmux -V
66
+ ```
67
+
68
+ ## Install
69
+
70
+ ### Option 1: Install from PyPI
71
+
72
+ Use this after you publish `devmux` to PyPI:
73
+
74
+ ```bash
75
+ python3 -m pip install devmux
76
+ ```
77
+
78
+ ### Option 2: Install from GitHub right now
79
+
80
+ If you want people to try it before a PyPI release:
81
+
82
+ ```bash
83
+ python3 -m pip install "git+https://github.com/olllayor/devmux.git"
84
+ ```
85
+
86
+ ### Option 3: Install locally for development
87
+
88
+ ```bash
89
+ git clone https://github.com/olllayor/devmux.git
90
+ cd devmux
91
+ python3 -m pip install -e ".[dev]"
92
+ ```
93
+
94
+ ## Quick start
95
+
96
+ Generate a starter config:
97
+
98
+ ```bash
99
+ devmux init --preset backend
100
+ ```
101
+
102
+ Start the workspace:
103
+
104
+ ```bash
105
+ devmux start backend
106
+ ```
107
+
108
+ Create or reuse a session without attaching:
109
+
110
+ ```bash
111
+ devmux start backend --detach
112
+ ```
113
+
114
+ Resume the same workspace later:
115
+
116
+ ```bash
117
+ devmux resume backend
118
+ ```
119
+
120
+ Send a prompt to all agent panes in the current session:
121
+
122
+ ```bash
123
+ devmux send "review the auth flow"
124
+ ```
125
+
126
+ Target a specific role or pane:
127
+
128
+ ```bash
129
+ devmux send "show me errors" --role logs
130
+ devmux send "run tests" --pane tests
131
+ devmux send "status" --all
132
+ ```
133
+
134
+ List or kill sessions:
135
+
136
+ ```bash
137
+ devmux ls
138
+ devmux kill backend
139
+ ```
140
+
141
+ ## Config
142
+
143
+ Example `devmux.yaml`:
144
+
145
+ ```yaml
146
+ workspaces:
147
+ backend:
148
+ layout: trio
149
+ cwd: ~/projects/tapi
150
+ panes:
151
+ - name: planner
152
+ role: agent
153
+ command: "claude"
154
+ - name: builder
155
+ role: agent
156
+ command: "codex --approval auto"
157
+ - name: logs
158
+ role: logs
159
+ command: "docker compose logs -f"
160
+ ```
161
+
162
+ Accepted layouts:
163
+
164
+ - `duo`
165
+ - `trio`
166
+ - `quad`
167
+ - `focus`
168
+
169
+ Accepted roles:
170
+
171
+ - `agent`
172
+ - `logs`
173
+ - `tests`
174
+ - `shell`
175
+
176
+ Legacy `agents` configs are still accepted and mapped to `role: agent`.
177
+
178
+ ## Commands
179
+
180
+ ```bash
181
+ devmux init [--preset minimal|backend|full-stack] [--config PATH] [--force]
182
+ devmux start <workspace> [--config PATH] [--detach] [--recreate]
183
+ devmux attach <workspace>
184
+ devmux resume <workspace>
185
+ devmux ls
186
+ devmux kill <workspace>
187
+ devmux send "<prompt>" [--session NAME] [--all | --role ROLE | --pane NAME ...]
188
+ ```
189
+
190
+ ## Typical workflows
191
+
192
+ ### Two-agent coding setup
193
+
194
+ ```yaml
195
+ workspaces:
196
+ minimal:
197
+ layout: duo
198
+ cwd: .
199
+ panes:
200
+ - name: claude
201
+ role: agent
202
+ command: "claude"
203
+ - name: codex
204
+ role: agent
205
+ command: "codex --approval auto"
206
+ ```
207
+
208
+ ### Backend setup with logs
209
+
210
+ ```yaml
211
+ workspaces:
212
+ backend:
213
+ layout: trio
214
+ cwd: .
215
+ panes:
216
+ - name: planner
217
+ role: agent
218
+ command: "claude"
219
+ - name: builder
220
+ role: agent
221
+ command: "codex --approval auto"
222
+ - name: logs
223
+ role: logs
224
+ command: "docker compose logs -f"
225
+ ```
226
+
227
+ ### Full-stack setup with tests and logs
228
+
229
+ ```yaml
230
+ workspaces:
231
+ full-stack:
232
+ layout: quad
233
+ cwd: .
234
+ panes:
235
+ - name: frontend
236
+ role: agent
237
+ command: "claude"
238
+ - name: backend
239
+ role: agent
240
+ command: "codex --approval auto"
241
+ - name: tests
242
+ role: tests
243
+ command: "npm test"
244
+ - name: logs
245
+ role: logs
246
+ command: "docker compose logs -f"
247
+ ```
248
+
249
+ ## How to release it to the world
250
+
251
+ Use two distribution paths:
252
+
253
+ 1. GitHub for discovery, source, issues, releases, and docs.
254
+ 2. PyPI for the simplest install command: `python3 -m pip install devmux`.
255
+
256
+ Recommended rollout order:
257
+
258
+ 1. Push this repo to GitHub with a clean README, license, and tagged release.
259
+ 2. Publish version `0.2.0` to PyPI.
260
+ 3. Share a short demo GIF/video showing `devmux init`, `devmux start`, and `devmux send`.
261
+ 4. Post it in places where AI-heavy CLI devs already are: X, Reddit, Hacker News, tmux/devtools communities, Discord/Slack groups, and your own network.
262
+
263
+ The detailed publishing checklist is in [RELEASING.md](/Users/ollayor/Code/Projects/agenix/RELEASING.md).
264
+
265
+ ## Development
266
+
267
+ Install dev dependencies:
268
+
269
+ ```bash
270
+ python3 -m pip install -e ".[dev]"
271
+ ```
272
+
273
+ Run tests:
274
+
275
+ ```bash
276
+ python3 -m pytest
277
+ ```
278
+
279
+ ## Scope
280
+
281
+ `devmux` v0.2 is intentionally focused:
282
+
283
+ - no TUI yet
284
+ - no status bar or health dashboard
285
+ - no deep agent-specific integrations
286
+ - no full pane history or recovery system
287
+
288
+ The goal is to be a reliable painkiller for launching and routing multi-agent CLI sessions.
@@ -0,0 +1,12 @@
1
+ devmux/__init__.py,sha256=Wy4CaBWIov4M_oNoBrzzzWN0Imijce7eQKfmNDAMDuo,80
2
+ devmux/cli/main.py,sha256=ROh1PyO8AV-FawspsYIPhqLZLi9NHNM6CijVdN6gKhk,5695
3
+ devmux/core/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ devmux/core/manager.py,sha256=BSUplGPyBaeLs-3d6hOQfUQq1zV21jHSFln4zv_O2h8,9015
5
+ devmux/utils/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
6
+ devmux/utils/config.py,sha256=QkWq3n05eaIdxF5p5fdzshETU6NyxRR8OmEBOcdLvz0,7416
7
+ devmux-0.2.0.dist-info/licenses/LICENSE,sha256=m4iEyn9xE5zQzQFhPHGjlmEqA-TjObpB_gVBbpDW56I,1064
8
+ devmux-0.2.0.dist-info/METADATA,sha256=09ScZAVV4k_P_RIsJ-GssUOJ5DYeZAg0WqtUdMm3uso,6084
9
+ devmux-0.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
10
+ devmux-0.2.0.dist-info/entry_points.txt,sha256=NHZ13BwV2-vDZSE_Ca50RWCNYq1AP2t1xOT6Nvh4X4w,48
11
+ devmux-0.2.0.dist-info/top_level.txt,sha256=bgCMo4cQWJs2H9MTXe-WJL9HMboStS61r10A5v11YMg,7
12
+ devmux-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ devmux = devmux.cli.main:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ollayor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ devmux