-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinit-helpers.ts
More file actions
718 lines (623 loc) · 24.1 KB
/
Copy pathinit-helpers.ts
File metadata and controls
718 lines (623 loc) · 24.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
import { existsSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { detectProjectName, run } from "./shared.ts";
export type InitAuthoringChoice = "claude" | "codex" | "manual";
export type InitAgent = Exclude<InitAuthoringChoice, "manual">;
export type InitPackageManager = "bun" | "npm" | "pnpm" | "yarn";
export interface InitProjectContext {
gitRoot: string;
projectName: string;
mainBranch: string;
defaultAgent: InitAgent;
packageManager: InitPackageManager;
}
export interface InitPromptSpec {
systemPrompt: string;
userPrompt: string;
}
export interface InitAgentCommandSpec {
agent: InitAgent;
cmd: string;
args: string[];
summaryPath?: string;
}
export interface InitAgentStreamEvent {
kind: "assistant_delta" | "assistant_done" | "status" | "warning";
text: string;
}
export interface InitAgentRunResult {
exitCode: number;
stdout: string;
stderr: string;
summary: string;
}
export interface InitAgentRunHandlers {
onEvent?: (event: InitAgentStreamEvent) => void;
}
interface InitAgentStreamState {
assistantSnapshot: string;
lastStatus: string | null;
}
const FAST_CLAUDE_MODEL = "haiku";
const FAST_CLAUDE_EFFORT = "low";
const FAST_CODEX_MODEL = "gpt-5.1-codex";
const FAST_CODEX_REASONING = "low";
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
function readString(value: unknown): string | null {
return typeof value === "string" && value.trim().length > 0 ? value : null;
}
function detectPackageManager(gitRoot: string): InitPackageManager {
if (existsSync(join(gitRoot, "bun.lock")) || existsSync(join(gitRoot, "bun.lockb"))) return "bun";
if (existsSync(join(gitRoot, "pnpm-lock.yaml"))) return "pnpm";
if (existsSync(join(gitRoot, "yarn.lock"))) return "yarn";
return "npm";
}
function detectMainBranch(gitRoot: string): string {
const originHead = run("git", ["symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD"], { cwd: gitRoot });
if (originHead.success) {
const branch = originHead.stdout.toString().trim().split("/").pop();
if (branch) return branch;
}
const mainBranch = run("git", ["branch", "--list", "main"], { cwd: gitRoot });
if (mainBranch.success && mainBranch.stdout.toString().trim()) return "main";
const masterBranch = run("git", ["branch", "--list", "master"], { cwd: gitRoot });
if (masterBranch.success && masterBranch.stdout.toString().trim()) return "master";
const currentBranch = run("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd: gitRoot });
if (currentBranch.success) {
const branch = currentBranch.stdout.toString().trim();
if (branch && branch !== "HEAD") return branch;
}
return "main";
}
function buildRunScriptCommand(packageManager: InitPackageManager, scriptName: "dev" | "start"): string {
if (packageManager === "bun") return `bun run ${scriptName}`;
if (packageManager === "pnpm") return `pnpm ${scriptName}`;
if (packageManager === "yarn") return `yarn ${scriptName}`;
return `npm run ${scriptName}`;
}
export function detectInitProjectContext(gitRoot: string, defaultAgent: InitAgent): InitProjectContext {
return {
gitRoot,
projectName: detectProjectName(gitRoot),
mainBranch: detectMainBranch(gitRoot),
defaultAgent,
packageManager: detectPackageManager(gitRoot),
};
}
export function buildInitPromptSpec(context: InitProjectContext): InitPromptSpec {
const systemPrompt = [
"You are bootstrapping a local repository for webmux.",
"A starter `.webmux.yaml` already exists at the repo root.",
"Inspect the repository in the current working directory and edit that existing `.webmux.yaml` in place.",
"Do not modify any other file.",
"Do not ask the user questions. Infer the config from the repository contents.",
"Be efficient: inspect only the files needed to determine the project name, main branch, service layout, dev commands, and ports.",
"The active, uncommented YAML must be valid and minimal.",
"Do not remove other starter sections or their explanatory comments just because they are unused.",
"Keep optional examples and comments in place so the user can uncomment and use them later.",
`Set workspace.defaultAgent to ${context.defaultAgent}.`,
"Use this config shape:",
"name: infer from the repository",
"workspace.mainBranch: infer from git",
"workspace.worktreeRoot: keep ../worktrees unless there is clear evidence of an existing alternative",
"services: one entry per real dev service with name, portEnv, and portStart when a default port is clear",
"profiles.default.runtime: host",
"profiles.default.envPassthrough: []",
"profiles.default.panes: start with an agent pane focused true, then add command panes for real services",
"Command panes should use the repository's real dev command and pass the relevant port env var into the command when needed.",
"Use split: right for the first command pane and split: bottom for later command panes.",
"Include integrations.github.linkedRepos as an empty list, integrations.linear.enabled as true, and startupEnvs as an empty object.",
"Only include optional sections like auto_name, lifecycleHooks, sandbox/docker config, mounts, or systemPrompt if the repository gives clear evidence they are needed.",
"Prefer editing the existing keys over replacing the file with a completely different shape.",
"Preserve the existing template structure and comments unless a specific change requires updating them.",
"Before finishing, verify that `.webmux.yaml` exists and contains the final YAML.",
].join("\n");
return {
systemPrompt,
userPrompt: "Adapt the existing starter `.webmux.yaml` for this repository.",
};
}
export function buildInitAgentCommand(
agent: InitAgent,
prompt: InitPromptSpec,
outputPrefix = "webmux-init",
): InitAgentCommandSpec {
if (agent === "claude") {
return {
agent,
cmd: "claude",
args: [
"-p",
"--verbose",
"--permission-mode",
"bypassPermissions",
"--model",
FAST_CLAUDE_MODEL,
"--effort",
FAST_CLAUDE_EFFORT,
"--output-format",
"stream-json",
"--include-partial-messages",
"--append-system-prompt",
prompt.systemPrompt,
prompt.userPrompt,
],
};
}
const summaryPath = join(tmpdir(), `${outputPrefix}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.txt`);
return {
agent,
cmd: "codex",
args: [
"exec",
"--sandbox",
"workspace-write",
"--color",
"never",
"--json",
"-m",
FAST_CODEX_MODEL,
"-o",
summaryPath,
"-c",
`model_reasoning_effort="${FAST_CODEX_REASONING}"`,
"-c",
`developer_instructions=${prompt.systemPrompt}`,
prompt.userPrompt,
],
summaryPath,
};
}
function closeAssistant(state: InitAgentStreamState): InitAgentStreamEvent[] {
if (!state.assistantSnapshot) return [];
state.assistantSnapshot = "";
return [{ kind: "assistant_done", text: "" }];
}
function streamSnapshot(
state: InitAgentStreamState,
snapshot: string,
): InitAgentStreamEvent[] {
if (!snapshot) return [];
if (!state.assistantSnapshot) {
state.assistantSnapshot = snapshot;
return [{ kind: "assistant_delta", text: snapshot }];
}
if (snapshot === state.assistantSnapshot) return [];
if (snapshot.startsWith(state.assistantSnapshot)) {
const delta = snapshot.slice(state.assistantSnapshot.length);
state.assistantSnapshot = snapshot;
return delta ? [{ kind: "assistant_delta", text: delta }] : [];
}
state.assistantSnapshot = snapshot;
return [
{ kind: "assistant_done", text: "" },
{ kind: "assistant_delta", text: snapshot },
];
}
function emitStatus(state: InitAgentStreamState, text: string | null): InitAgentStreamEvent[] {
const status = text?.trim();
if (!status || status === state.lastStatus) return [];
state.lastStatus = status;
return [...closeAssistant(state), { kind: "status", text: status }];
}
function emitWarning(state: InitAgentStreamState, text: string | null): InitAgentStreamEvent[] {
const warning = text?.trim();
if (!warning) return [];
return [...closeAssistant(state), { kind: "warning", text: warning }];
}
function extractTextBlocks(value: unknown): string {
if (typeof value === "string") return value;
if (Array.isArray(value)) {
return value.map((entry) => extractTextBlocks(entry)).filter((entry) => entry.length > 0).join("");
}
if (!isRecord(value)) return "";
if (value.type === "text" && typeof value.text === "string") {
return value.text;
}
if (typeof value.output_text === "string") return value.output_text;
if (typeof value.text === "string") return value.text;
if (typeof value.delta === "string") return value.delta;
if (Array.isArray(value.content)) return extractTextBlocks(value.content);
if (Array.isArray(value.contents)) return extractTextBlocks(value.contents);
if (Array.isArray(value.parts)) return extractTextBlocks(value.parts);
if (Array.isArray(value.output)) return extractTextBlocks(value.output);
return "";
}
function extractCommandText(value: unknown): string | null {
if (typeof value === "string" && value.trim().length > 0) return value.trim();
if (Array.isArray(value) && value.every((entry) => typeof entry === "string")) {
return value.join(" ").trim() || null;
}
return null;
}
function truncateText(text: string, limit = 120): string {
return text.length > limit ? `${text.slice(0, limit - 3)}...` : text;
}
function extractStructuredMessage(raw: Record<string, unknown>): string | null {
const candidates: unknown[] = [
raw.message,
raw.result,
raw.item,
raw.output,
raw.content,
raw.text,
raw.response,
];
for (const candidate of candidates) {
const text = extractTextBlocks(candidate).trim();
if (text) return text;
}
return null;
}
function parseClaudeStreamLine(
raw: Record<string, unknown>,
state: InitAgentStreamState,
): InitAgentStreamEvent[] {
const type = readString(raw.type) ?? "unknown";
if (type === "content_block_delta" && isRecord(raw.delta)) {
if (raw.delta.type === "text_delta" && typeof raw.delta.text === "string") {
return [{ kind: "assistant_delta", text: raw.delta.text }];
}
if (typeof raw.delta.text === "string") {
return [{ kind: "assistant_delta", text: raw.delta.text }];
}
}
if (type === "content_block_start" && isRecord(raw.content_block)) {
if (raw.content_block.type === "tool_use") {
return emitStatus(state, `Using ${readString(raw.content_block.name) ?? "tool"}...`);
}
const snapshot = extractTextBlocks(raw.content_block).trim();
return streamSnapshot(state, snapshot);
}
if (type === "message_stop" || type === "result_stop" || type === "content_block_stop") {
return closeAssistant(state);
}
if (type === "error") {
const message = isRecord(raw.error) ? readString(raw.error.message) : readString(raw.message);
return emitWarning(state, message ?? "Claude returned an error.");
}
if (type.includes("tool")) {
const toolName = readString(raw.tool_name)
?? (isRecord(raw.tool) ? readString(raw.tool.name) : null)
?? readString(raw.name);
if (toolName) return emitStatus(state, `Using ${toolName}...`);
}
const snapshot = extractStructuredMessage(raw);
if (snapshot) return streamSnapshot(state, snapshot);
return [];
}
function parseCodexStatus(raw: Record<string, unknown>, type: string): string | null {
const command = extractCommandText(raw.command)
?? (isRecord(raw.item) ? extractCommandText(raw.item.command) : null);
if (command && (type.includes("command") || type.includes("exec") || type.includes("shell"))) {
return `Running ${truncateText(command)}`;
}
const toolName = readString(raw.tool_name)
?? readString(raw.name)
?? (isRecord(raw.item) ? readString(raw.item.name) : null);
if (toolName && (type.includes("tool") || type.includes("function"))) {
return `Using ${toolName}...`;
}
const status = readString(raw.status);
if (status && !["completed", "done", "finished"].includes(status)) {
return truncateText(status);
}
if (type.includes("turn")) return "Thinking...";
return null;
}
function parseCodexStreamLine(
raw: Record<string, unknown>,
state: InitAgentStreamState,
): InitAgentStreamEvent[] {
const type = readString(raw.type) ?? readString(raw.event) ?? "unknown";
if (type === "response.output_text.delta" && typeof raw.delta === "string") {
return [{ kind: "assistant_delta", text: raw.delta }];
}
if (type === "response.output_text.done") {
const text = readString(raw.text) ?? extractTextBlocks(raw.item).trim();
return [...(text ? streamSnapshot(state, text) : []), ...closeAssistant(state)];
}
if (type.includes("error")) {
const message = isRecord(raw.error) ? readString(raw.error.message) : readString(raw.message);
return emitWarning(state, message ?? "Codex returned an error.");
}
const status = parseCodexStatus(raw, type);
if (status) return emitStatus(state, status);
if (type.includes("delta") && typeof raw.delta === "string") {
return [{ kind: "assistant_delta", text: raw.delta }];
}
const snapshot = extractStructuredMessage(raw);
if (snapshot && (type.includes("assistant") || type.includes("message") || type.includes("output") || type.includes("response"))) {
const events = streamSnapshot(state, snapshot);
if (type.includes("done") || type.includes("completed") || type.includes("finished")) {
events.push(...closeAssistant(state));
}
return events;
}
if (type.includes("done") || type.includes("completed") || type.includes("finished")) {
return closeAssistant(state);
}
return [];
}
export function parseInitAgentStreamLine(
agent: InitAgent,
line: string,
state: InitAgentStreamState = { assistantSnapshot: "", lastStatus: null },
): InitAgentStreamEvent[] {
const trimmed = line.trim();
if (!trimmed) return [];
let parsed: unknown;
try {
parsed = JSON.parse(trimmed);
} catch {
return [];
}
if (!isRecord(parsed)) return [];
return agent === "claude" ? parseClaudeStreamLine(parsed, state) : parseCodexStreamLine(parsed, state);
}
async function consumeStructuredStream(
stream: ReadableStream<Uint8Array> | null,
agent: InitAgent,
onEvent?: (event: InitAgentStreamEvent) => void,
): Promise<{ raw: string; assistantText: string }> {
if (!stream) return { raw: "", assistantText: "" };
const reader = stream.getReader();
const decoder = new TextDecoder();
const state: InitAgentStreamState = { assistantSnapshot: "", lastStatus: null };
let buffer = "";
let raw = "";
let assistantText = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value, { stream: true });
raw += text;
buffer += text;
let newlineIndex = buffer.indexOf("\n");
while (newlineIndex !== -1) {
const line = buffer.slice(0, newlineIndex).replace(/\r$/, "");
buffer = buffer.slice(newlineIndex + 1);
for (const event of parseInitAgentStreamLine(agent, line, state)) {
if (event.kind === "assistant_delta") assistantText += event.text;
onEvent?.(event);
}
newlineIndex = buffer.indexOf("\n");
}
}
const tail = decoder.decode();
raw += tail;
buffer += tail;
const finalLine = buffer.replace(/\r$/, "");
if (finalLine) {
for (const event of parseInitAgentStreamLine(agent, finalLine, state)) {
if (event.kind === "assistant_delta") assistantText += event.text;
onEvent?.(event);
}
}
for (const event of closeAssistant(state)) {
onEvent?.(event);
}
return { raw, assistantText };
}
async function consumeRawStream(stream: ReadableStream<Uint8Array> | null): Promise<string> {
if (!stream) return "";
const reader = stream.getReader();
const decoder = new TextDecoder();
let raw = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
raw += decoder.decode(value, { stream: true });
}
return raw + decoder.decode();
}
export async function runInitAgentCommand(
spec: InitAgentCommandSpec,
cwd: string,
handlers: InitAgentRunHandlers = {},
): Promise<InitAgentRunResult> {
const proc = Bun.spawn([spec.cmd, ...spec.args], {
cwd,
stdout: "pipe",
stderr: "pipe",
});
const [exitCode, stdoutResult, stderr] = await Promise.all([
proc.exited,
consumeStructuredStream(proc.stdout, spec.agent, handlers.onEvent),
consumeRawStream(proc.stderr),
]);
let summary = stdoutResult.assistantText.trim();
if (spec.summaryPath && existsSync(spec.summaryPath)) {
try {
summary = readFileSync(spec.summaryPath, "utf8").trim() || summary;
} finally {
rmSync(spec.summaryPath, { force: true });
}
}
return { exitCode, stdout: stdoutResult.raw, stderr, summary };
}
export function buildStarterTemplate(input: {
projectName: string;
mainBranch: string;
defaultAgent?: InitAgent;
packageManager?: InitPackageManager;
}): string {
const defaultAgent = input.defaultAgent ?? "claude";
const packageManager = input.packageManager ?? "npm";
const devCommand = buildRunScriptCommand(packageManager, "dev");
return `# Starter config for webmux.
# Keep the active keys below as a minimal working setup, then uncomment
# the examples to enable more services, profiles, integrations, or hooks.
# Project display name shown in the dashboard and browser title.
name: ${input.projectName}
workspace:
# Git branch new worktrees start from.
mainBranch: ${input.mainBranch}
# Relative or absolute directory where managed worktrees are created.
worktreeRoot: ../worktrees
# Agent new worktrees use by default.
defaultAgent: ${defaultAgent}
# Example background pull settings for keeping the main branch fresh.
# autoPull:
# # Turn automatic pulls on or off.
# enabled: false
# # Seconds between pull attempts.
# intervalSeconds: 300
# Services define the ports webmux allocates and tracks per worktree.
services:
# Example app service with a predictable per-worktree port.
# - name: app
# # Env var name injected into panes and hooks.
# portEnv: PORT
# # Starting port for the first worktree slot.
# portStart: 3000
# # Port increment between worktree slots.
# portStep: 10
# # Link shown in the dashboard when the service is running.
# urlTemplate: http://localhost:\${PORT}
# Profiles define runtime, permissions, and tmux pane layout.
profiles:
default:
# Run panes directly on the host machine.
runtime: host
# Forward selected host env vars into the agent process.
envPassthrough:
# - ANTHROPIC_API_KEY
# - OPENAI_API_KEY
# Extra system instructions for the agent in this profile.
# systemPrompt: >
# You are working in \${WEBMUX_WORKTREE_PATH}
# Skip agent permission prompts in this profile.
# yolo: true
# Panes define the tmux layout created for each worktree session.
panes:
# Main AI coding pane.
- id: agent
# Pane type: agent, command, or shell.
kind: agent
# Focus this pane when the session opens.
focus: true
# Place this pane to the right of the existing layout.
# split: right
# Percent of the available space this pane should take.
# sizePct: 50
# Start this pane in the repo root or managed worktree.
# cwd: worktree
# Example dev server pane.
# - id: app
# # Pane type: agent, command, or shell.
# kind: command
# # Place this pane to the right of the existing layout.
# split: right
# # Percent of the available space this pane should take.
# sizePct: 50
# # Start this pane in the repo root or managed worktree.
# cwd: worktree
# # Change into a subdirectory before running the command.
# workingDir: frontend
# # Command run when the pane starts. webmux injects $PORT.
# command: PORT=$PORT ${devCommand}
# Example shell pane for manual commands.
# - id: shell
# # Pane type: agent, command, or shell.
# kind: shell
# # Place this pane below the existing layout.
# split: bottom
# # Percent of the available space this pane should take.
# sizePct: 30
# # Start this pane in the repo root or managed worktree.
# cwd: repo
# Example sandbox profile that runs panes inside Docker.
# sandbox:
# # Run panes inside a container instead of on the host.
# runtime: docker
# # Docker image used for the sandbox container.
# image: ghcr.io/your-org/your-image:latest
# # Forward selected host env vars into the container.
# envPassthrough:
# - ANTHROPIC_API_KEY
# - OPENAI_API_KEY
# # Extra system instructions for the agent in this profile.
# systemPrompt: >
# Extra instructions for the sandbox profile.
# # Skip agent permission prompts in this profile.
# yolo: true
# # Extra host paths to mount into the container.
# mounts:
# # Host path mounted into the sandbox.
# - hostPath: ~/.codex
# # Path inside the container.
# guestPath: /root/.codex
# # Allow writes through this mount.
# writable: true
# # Panes define the tmux layout created for sandbox sessions.
# panes:
# # Main AI coding pane.
# - id: agent
# # Pane type: agent, command, or shell.
# kind: agent
# # Focus this pane when the session opens.
# focus: true
# # Example shell pane for manual commands.
# - id: shell
# # Pane type: agent, command, or shell.
# kind: shell
# # Place this pane to the right of the existing layout.
# split: right
# # Start this pane in the repo root or managed worktree.
# cwd: repo
# Integrations connect webmux to external systems.
integrations:
github:
# Additional local repos webmux should consider alongside the main repo.
linkedRepos:
# GitHub slug for a related repo.
# - repo: your-org/your-repo
# # Short label shown in the UI.
# alias: repo
# # Relative or absolute path to that local checkout.
# dir: ../your-repo
# Remove managed worktrees automatically when their PR merges.
# autoRemoveOnMerge: true
linear:
# Enable Linear issue lookup and linking in the UI.
enabled: true
# Auto-create worktrees for assigned issues labeled "webmux" or "webmux_oneshot".
# autoCreateWorktrees: true
# Show a create-ticket action in the dashboard. The team to file into is
# picked in the dialog at creation time.
# createTicketOption: true
# Restrict the auto-create watcher to issues from these teams. Useful when
# the authenticated Linear user is in multiple teams or when running webmux
# in several projects on the same machine that share a Linear account.
# watchTeams: [ENG, OPS]
# Post a structured comment on the Linear issue when the auto-create
# watcher picks it up (prefix `**Webmux pickup — branch \`<branch>\`**`),
# so external automation can track when webmux starts working on it.
# postCommentOnPickup: true
# startupEnvs become runtime env vars for panes, agents, and hooks.
startupEnvs:
# Example feature flag available in every worktree session.
# FEATURE_FLAG: true
# Example service URL built from allocated ports.
# API_BASE_URL: http://localhost:\${PORT}
# lifecycleHooks run custom shell commands during worktree lifecycle events.
# lifecycleHooks:
# # Runs after env setup and before panes start.
# postCreate: bun install
# # Runs before the worktree directory is removed.
# preRemove: tmux kill-session -t "$WEBMUX_WORKTREE_ID" || true
# auto_name lets webmux generate a branch name when one is not provided.
# auto_name:
# # Provider used for automatic branch naming.
# provider: ${defaultAgent}
# # Model used for automatic branch naming.
# model: ${defaultAgent === "codex" ? "gpt-5.1-codex" : "claude-3-5-haiku-latest"}
# # Prompt that tells the model how to name branches.
# system_prompt: >
# Generate a short kebab-case git branch name.
`;
}