Skip to content

Commit 3cc608d

Browse files
centdixclaude
andcommitted
feat: generate .workmux.yaml with env-aware pane setup in init
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3967301 commit 3cc608d

1 file changed

Lines changed: 29 additions & 11 deletions

File tree

bin/src/init.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ function wmdevTemplate(name: string): string {
4343
name: ${name}
4444
4545
# --- Service health monitoring (uncomment to enable) ---
46-
# Tracks port status for each worktree.
47-
# Each worktree gets its own port range: base + (slot × step)
46+
# Each service defines a port env var that wmdev injects into .env.local
47+
# when creating a worktree. Ports are auto-assigned: base + (slot × step).
48+
# Use \`source .env.local\` in your .workmux.yaml pane commands to pick them up.
4849
# services:
4950
# - name: app
5051
# portEnv: PORT
@@ -81,6 +82,30 @@ profiles:
8182
`;
8283
}
8384

85+
function workmuxTemplate(): string {
86+
return `main_branch: main
87+
88+
panes:
89+
# Agent pane — runs the AI coding assistant
90+
- command: >-
91+
claude --append-system-prompt
92+
"You are running inside a git worktree managed by workmux.\\n
93+
Pane layout (current window):\\n
94+
- Pane 0: this pane (claude agent)\\n
95+
- Pane 1: dev server\\n\\n
96+
To check dev server logs: tmux capture-pane -t .1 -p -S -50\\n
97+
To restart dev server: tmux send-keys -t .1 C-c 'source .env.local && PORT=\\$PORT npm run dev' Enter"
98+
focus: true
99+
100+
# Dev server — waits for .env.local (written by wmdev) then starts
101+
- command: >-
102+
until [ -f .env.local ]; do sleep 0.2; done;
103+
source .env.local;
104+
PORT=$PORT npm run dev
105+
split: horizontal
106+
`;
107+
}
108+
84109
// ── Main ─────────────────────────────────────────────────────────────────────
85110

86111
p.intro("wmdev init");
@@ -123,15 +148,8 @@ const workmuxYaml = join(gitRoot, ".workmux.yaml");
123148
if (existsSync(workmuxYaml)) {
124149
p.log.info(".workmux.yaml already exists, skipping");
125150
} else {
126-
const s = p.spinner();
127-
s.start("Running workmux init...");
128-
const result = run("workmux", ["init"], { cwd: gitRoot });
129-
if (result.success) {
130-
s.stop(".workmux.yaml created");
131-
} else {
132-
s.stop("workmux init failed");
133-
p.log.warning("Could not create .workmux.yaml. Run 'workmux init' manually.");
134-
}
151+
await Bun.write(workmuxYaml, workmuxTemplate());
152+
p.log.success(".workmux.yaml created");
135153
}
136154

137155
// Step 5 — .wmdev.yaml

0 commit comments

Comments
 (0)