@cestoliv/wt 0.5.0-pr21.ge97b6fa → 0.5.0-pr22.gbb5b3fa

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.
package/README.md CHANGED
@@ -38,6 +38,7 @@ wt # Browse worktrees (interactive TUI)
38
38
  wt create my-feat # New worktree, opens your IDE
39
39
  wt agent my-feat "Plan the feature" # New worktree + AI agent in Zed (macOS)
40
40
  wt agent fix-bug "Fix bug" --mode auto # Use auto mode instead of plan
41
+ wt prune # Remove merged worktrees (per-branch confirm)
41
42
  wt config # Edit config in $EDITOR
42
43
  wt skill # Print the skill file (for AI agents)
43
44
  ```
@@ -85,12 +86,12 @@ An interactive, fuzzy-searchable list of your worktrees:
85
86
 
86
87
  ```
87
88
  MY-PROJECT
88
- ▶ main ~/dev/my-project
89
+ ▶ main (main) ~/dev/my-project
89
90
  fix: resolve auth bug (2h ago)
90
91
  feat/dashboard ~/dev/my-project-feat-dashboard
91
92
  wip: add chart component (1d ago)
92
93
 
93
- ↕ navigate · Enter open · D delete · C create · A agent · Q quit
94
+ ↕ navigate · Enter open · D delete · P prune · C create · A agent · Q quit
94
95
  ```
95
96
 
96
97
  Type to fuzzy-filter branches instantly. Inside a repo it shows that repo's
@@ -104,8 +105,12 @@ and a permission mode — **worktree (repo → branch) → plan prompt → permi
104
105
  mode**. Pressing `Esc` steps back to the previous question (answers preserved),
105
106
  or back to the list from the first step. After creating, the list **refreshes
106
107
  and stays open** (preserving your search and cursor) instead of exiting — only
107
- `Enter` and `Q`/`Esc` leave the TUI. Note that `a`/`c`/`d` are command keys, so
108
- they can't be typed into the search box.
108
+ `Enter` and `Q`/`Esc` leave the TUI. `P` prunes every worktree whose branch has
109
+ already been merged (see [`wt prune`](#prune--wt-prune) below). Note that
110
+ `a`/`c`/`d`/`p` are command keys, so they can't be typed into the search box.
111
+
112
+ The main worktree is tagged `(main)` and is protected — `D` only removes linked
113
+ worktrees, never the main repository.
109
114
 
110
115
  ## Create — `wt create [branch]`
111
116
 
@@ -121,6 +126,26 @@ registered repos.
121
126
  If the path already exists, `wt create` offers to open it in your IDE instead of
122
127
  erroring (in a non-interactive shell it exits non-zero).
123
128
 
129
+ ## Prune — `wt prune`
130
+
131
+ ```bash
132
+ wt prune # remove every merged worktree, one confirmation per branch
133
+ ```
134
+
135
+ Cleans up the worktrees you're done with: it finds every worktree whose branch
136
+ has already been merged into the base branch (`base_branch`, default
137
+ `origin/main`) and removes it — **always confirming each branch individually**,
138
+ and force-confirming when git refuses (submodules or uncommitted changes), just
139
+ like a manual `D` delete. The branch itself stays; only the worktree is removed.
140
+ Your `teardown_commands` run before each removal.
141
+
142
+ Merge detection is patch-id based (via `git cherry`), so a single-commit branch
143
+ **squash-merged** through a PR is still detected. `wt prune` best-effort fetches
144
+ the remote first; if the base ref can't be resolved (offline, missing), it
145
+ removes nothing. The TUI exposes the same action under the `P` key. Works in
146
+ repo mode and across all registered repos in global mode (each against its own
147
+ `base_branch`).
148
+
124
149
  ## Configuration
125
150
 
126
151
  Edit with `wt config` (`wt config --path` prints the file location —
package/SKILL.md CHANGED
@@ -17,7 +17,8 @@ Launch the interactive TUI. Shows worktrees for the current repo (repo mode) or
17
17
 
18
18
  - Arrow keys — navigate
19
19
  - `Enter` — open worktree in IDE (exits the TUI)
20
- - `D` — delete worktree
20
+ - `D` — delete worktree (the main worktree is tagged `(main)` and cannot be deleted — only linked worktrees can)
21
+ - `P` — prune all merged worktrees (per-branch confirmation)
21
22
  - `C` — create a new worktree (works in both repo and global mode)
22
23
  - `A` — create a worktree and start an AI agent in it (works in both modes)
23
24
  - type to search · `Backspace` — edit search
@@ -38,8 +39,8 @@ After a create or agent action the TUI **refreshes and stays open** on the list
38
39
  (your search and cursor are preserved) rather than exiting — only `Enter` (open)
39
40
  and `Q`/`Esc` exit.
40
41
 
41
- Because `a`/`A`, `c`/`C`, and `d`/`D` are reserved as command keys, those
42
- letters can't be typed into the search box.
42
+ Because `a`/`A`, `c`/`C`, `d`/`D`, and `p`/`P` are reserved as command keys,
43
+ those letters can't be typed into the search box.
43
44
 
44
45
  ### `wt create [branch]`
45
46
 
@@ -97,6 +98,25 @@ If the worktree path already exists, `wt agent` prompts you to **open it in the
97
98
  IDE**, **open it and start the agent**, or **quit** — instead of erroring. (In a
98
99
  non-interactive shell it errors with a non-zero exit instead of prompting.)
99
100
 
101
+ ### `wt prune`
102
+
103
+ Remove every worktree whose branch has already been merged into the base
104
+ branch (`base_branch`, default `origin/main`). Each candidate is confirmed
105
+ individually — and force-confirmed when git refuses (submodules / uncommitted
106
+ changes), exactly like a manual `d` delete. The branch itself is left intact;
107
+ only the worktree is removed.
108
+
109
+ ```bash
110
+ wt prune # review and remove merged worktrees, one prompt per branch
111
+ ```
112
+
113
+ Merge detection is patch-id based (via `git cherry`), so a single-commit branch
114
+ that was **squash-merged** through a PR is still recognized as merged. It also
115
+ best-effort fetches the remote first so detection sees up-to-date refs; if the
116
+ base ref can't be resolved (e.g. offline), nothing is removed. Works in repo
117
+ mode (current repo) and global mode (all registered repos, each against its own
118
+ `base_branch`). The TUI exposes the same action under the `p` key.
119
+
100
120
  ### `wt config`
101
121
 
102
122
  Open the global config file in `$EDITOR` (defaults to `nano`).
@@ -3,8 +3,8 @@ import {
3
3
  openConfiguredIde,
4
4
  prepareWorktree,
5
5
  promptExistingWorktree
6
- } from "./chunk-2YENB5VN.js";
7
- import "./chunk-VZJ7HTCM.js";
6
+ } from "./chunk-Q6NNNYDJ.js";
7
+ import "./chunk-YXA6CZ2L.js";
8
8
  import "./chunk-QVYSEMSL.js";
9
9
 
10
10
  // src/commands/agent.ts
@@ -13,7 +13,7 @@ import {
13
13
  runCommands,
14
14
  runRepoPicker,
15
15
  setUpstreamTracking
16
- } from "./chunk-VZJ7HTCM.js";
16
+ } from "./chunk-YXA6CZ2L.js";
17
17
  import {
18
18
  createStore,
19
19
  getEffectiveConfig
@@ -0,0 +1,271 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ fetchRemote,
4
+ getRegisteredRepos,
5
+ getRepoRoot,
6
+ isBranchMerged,
7
+ listWorktreeDirtyFiles,
8
+ listWorktrees,
9
+ openIde,
10
+ registerRepo,
11
+ removeWorktree,
12
+ runBranchInput,
13
+ runCommands,
14
+ runInteractiveList,
15
+ runRepoPicker,
16
+ runWizard
17
+ } from "./chunk-YXA6CZ2L.js";
18
+ import {
19
+ createStore,
20
+ getEffectiveConfig,
21
+ getGlobalConfig
22
+ } from "./chunk-QVYSEMSL.js";
23
+
24
+ // src/commands/list.ts
25
+ import * as clack from "@clack/prompts";
26
+ import pc from "picocolors";
27
+ function buildWorktreeSteps(repoRoot, store, state) {
28
+ const steps = [];
29
+ if (!repoRoot) {
30
+ const repos = getRegisteredRepos(store);
31
+ steps.push(async () => {
32
+ const picked = await runRepoPicker(repos, state.pickedRepo);
33
+ if (!picked) return false;
34
+ state.pickedRepo = picked;
35
+ return true;
36
+ });
37
+ }
38
+ steps.push(async () => {
39
+ const entered = await runBranchInput(
40
+ state.pickedRepo,
41
+ state.branch ?? ""
42
+ );
43
+ if (!entered) return false;
44
+ state.branch = entered;
45
+ return true;
46
+ });
47
+ return steps;
48
+ }
49
+ async function prepareListItems(options = {}) {
50
+ const { cwd = process.cwd(), store = createStore() } = options;
51
+ let repoRoot = null;
52
+ try {
53
+ repoRoot = getRepoRoot(cwd);
54
+ } catch {
55
+ }
56
+ if (repoRoot) {
57
+ registerRepo(repoRoot, store);
58
+ const items2 = listWorktrees(repoRoot, cwd);
59
+ return { items: items2, mode: "repo", repoRoot };
60
+ }
61
+ const repos = getRegisteredRepos(store);
62
+ const items = repos.flatMap((repo) => {
63
+ try {
64
+ return listWorktrees(repo, cwd);
65
+ } catch {
66
+ return [];
67
+ }
68
+ });
69
+ return { items, mode: "global", repoRoot: null };
70
+ }
71
+ async function runList(options = {}) {
72
+ const { store = createStore(), cwd = process.cwd() } = options;
73
+ const { items, mode, repoRoot } = await prepareListItems({ cwd, store });
74
+ if (items.length === 0 && mode === "global") {
75
+ console.log(
76
+ pc.dim(
77
+ "No repos registered. Run `wt create` inside a repo to get started."
78
+ )
79
+ );
80
+ return;
81
+ }
82
+ const autoRefreshMinutes = mode === "repo" && repoRoot ? getEffectiveConfig(repoRoot, store).auto_refresh_minutes : getGlobalConfig(store).auto_refresh_minutes;
83
+ await runInteractiveList(
84
+ items,
85
+ mode,
86
+ {
87
+ onOpen: (item) => {
88
+ const config = getEffectiveConfig(item.repoRoot, store);
89
+ openIde(config.ide, config.ide_open_args, item.path);
90
+ },
91
+ onDelete: (item) => deleteWorktree(item, store),
92
+ onWipe: (items2) => wipeWorktrees(items2, store, { fetch: true }),
93
+ onCreate: async () => {
94
+ const state = { pickedRepo: repoRoot ?? void 0 };
95
+ const steps = buildWorktreeSteps(repoRoot, store, state);
96
+ if (!await runWizard(steps)) return;
97
+ if (state.pickedRepo === void 0 || state.branch === void 0)
98
+ return;
99
+ const { createWorktree } = await import("./create-DYM7QWI5.js");
100
+ await createWorktree(state.branch, { cwd: state.pickedRepo, store });
101
+ },
102
+ onAgent: async () => {
103
+ const { createAgentWorktree, VALID_MODES } = await import("./agent-575QKWIG.js");
104
+ const state = {
105
+ pickedRepo: repoRoot ?? void 0,
106
+ mode: "plan"
107
+ };
108
+ const steps = buildWorktreeSteps(repoRoot, store, state);
109
+ steps.push(async () => {
110
+ const entered = await clack.text({
111
+ message: "Plan prompt for the agent:",
112
+ initialValue: state.plan,
113
+ validate: (v) => !v || v.length === 0 ? "Required" : void 0
114
+ });
115
+ if (clack.isCancel(entered)) return false;
116
+ state.plan = entered;
117
+ return true;
118
+ });
119
+ steps.push(async () => {
120
+ const chosen = await clack.select({
121
+ message: "Permission mode:",
122
+ initialValue: state.mode,
123
+ options: VALID_MODES.map((m) => ({ value: String(m), label: m }))
124
+ });
125
+ if (clack.isCancel(chosen)) return false;
126
+ state.mode = chosen;
127
+ return true;
128
+ });
129
+ if (!await runWizard(steps)) return;
130
+ if (state.pickedRepo === void 0 || state.branch === void 0 || state.plan === void 0)
131
+ return;
132
+ await createAgentWorktree(state.branch, state.plan, {
133
+ cwd: state.pickedRepo,
134
+ store,
135
+ mode: state.mode
136
+ });
137
+ },
138
+ refreshItems: async () => {
139
+ const refreshed = await prepareListItems({ cwd, store });
140
+ return refreshed.items;
141
+ }
142
+ },
143
+ { autoRefreshMinutes }
144
+ );
145
+ }
146
+ async function deleteWorktree(item, store) {
147
+ const confirmed = await clack.confirm({
148
+ message: `Remove worktree ${pc.bold(item.branch)}? This cannot be undone.`
149
+ });
150
+ if (clack.isCancel(confirmed) || !confirmed) return false;
151
+ const config = getEffectiveConfig(item.repoRoot, store);
152
+ if (config.teardown_commands.length > 0) {
153
+ console.log(pc.dim("Running teardown commands..."));
154
+ const result = await runCommands(config.teardown_commands, item.path);
155
+ if (!result.success) {
156
+ clack.log.warn(
157
+ `Teardown command failed: ${result.failedCommand} (exit code ${result.exitCode})`
158
+ );
159
+ const proceed = await clack.confirm({
160
+ message: `Delete ${pc.bold(item.branch)} anyway?`
161
+ });
162
+ if (clack.isCancel(proceed) || !proceed) return false;
163
+ }
164
+ }
165
+ try {
166
+ removeWorktree(item.repoRoot, item.path);
167
+ console.log(pc.green(`\u2713 Removed ${item.branch}`));
168
+ return true;
169
+ } catch (err) {
170
+ const msg = String(err);
171
+ if (msg.includes("cannot be moved or removed")) {
172
+ clack.log.warn(
173
+ "Worktree contains git submodules, which prevent standard removal."
174
+ );
175
+ const force = await clack.confirm({
176
+ message: `Force delete ${pc.bold(item.branch)}? The worktree directory will be removed directly.`
177
+ });
178
+ if (clack.isCancel(force) || !force) return false;
179
+ try {
180
+ removeWorktree(item.repoRoot, item.path, true);
181
+ console.log(pc.green(`\u2713 Force-removed ${item.branch}`));
182
+ return true;
183
+ } catch (err2) {
184
+ console.error(pc.red(`\u2717 Failed to force-remove: ${String(err2)}`));
185
+ return false;
186
+ }
187
+ }
188
+ if (msg.includes("modified or untracked files")) {
189
+ const dirty = listWorktreeDirtyFiles(item.path);
190
+ if (dirty.length > 0) {
191
+ clack.log.warn(
192
+ `Worktree has uncommitted changes:
193
+ ${dirty.map((f) => ` ${f}`).join("\n")}`
194
+ );
195
+ }
196
+ const force = await clack.confirm({
197
+ message: `Force delete ${pc.bold(item.branch)}? All changes will be lost.`
198
+ });
199
+ if (clack.isCancel(force) || !force) return false;
200
+ try {
201
+ removeWorktree(item.repoRoot, item.path, true);
202
+ console.log(pc.green(`\u2713 Force-removed ${item.branch}`));
203
+ return true;
204
+ } catch (err2) {
205
+ console.error(pc.red(`\u2717 Failed to force-remove: ${String(err2)}`));
206
+ return false;
207
+ }
208
+ }
209
+ console.error(pc.red(`\u2717 Failed to remove: ${msg}`));
210
+ return false;
211
+ }
212
+ }
213
+ function selectWipeCandidates(items, isMerged) {
214
+ return items.filter(
215
+ (wt) => !wt.isCurrent && !wt.isMain && wt.branch !== "(detached)" && isMerged(wt)
216
+ );
217
+ }
218
+ function buildMergedPredicate(store) {
219
+ return (wt) => {
220
+ const config = getEffectiveConfig(wt.repoRoot, store);
221
+ const base = config.base_branch;
222
+ const baseLocal = base.split("/", 2).slice(1).join("/") || base;
223
+ if (wt.branch === base || wt.branch === baseLocal) return false;
224
+ return isBranchMerged(wt.repoRoot, wt.branch, base);
225
+ };
226
+ }
227
+ async function wipeWorktrees(items, store, options = {}) {
228
+ if (options.fetch) {
229
+ const seen = /* @__PURE__ */ new Set();
230
+ for (const wt of items) {
231
+ if (seen.has(wt.repoRoot)) continue;
232
+ seen.add(wt.repoRoot);
233
+ const parts = getEffectiveConfig(wt.repoRoot, store).base_branch.split(
234
+ "/",
235
+ 2
236
+ );
237
+ if (parts.length !== 2) continue;
238
+ const remote = parts[0] || "origin";
239
+ try {
240
+ fetchRemote(wt.repoRoot, remote);
241
+ } catch (err) {
242
+ console.warn(
243
+ pc.yellow(
244
+ `\u26A0 Could not fetch from ${remote} \u2014 using local state${err instanceof Error ? ` (${err.message})` : ""}`
245
+ )
246
+ );
247
+ }
248
+ }
249
+ }
250
+ const candidates = selectWipeCandidates(items, buildMergedPredicate(store));
251
+ if (candidates.length === 0) {
252
+ console.log(pc.dim("No merged worktrees to wipe."));
253
+ return [];
254
+ }
255
+ const removed = [];
256
+ for (const candidate of candidates) {
257
+ if (await deleteWorktree(candidate, store)) {
258
+ removed.push(candidate);
259
+ }
260
+ }
261
+ return removed;
262
+ }
263
+
264
+ export {
265
+ prepareListItems,
266
+ runList,
267
+ deleteWorktree,
268
+ selectWipeCandidates,
269
+ buildMergedPredicate,
270
+ wipeWorktrees
271
+ };
@@ -48,7 +48,7 @@ function listWorktrees(repoRoot, cwd = process.cwd()) {
48
48
  }));
49
49
  }
50
50
  function parseWorktreeList(output, repoRoot, cwd) {
51
- return output.trim().split("\n\n").map((block) => {
51
+ return output.trim().split("\n\n").map((block, index) => {
52
52
  const lines = block.trim().split("\n");
53
53
  const wtPath = lines[0].slice("worktree ".length);
54
54
  const branchLine = lines.find((l) => l.startsWith("branch "));
@@ -57,6 +57,8 @@ function parseWorktreeList(output, repoRoot, cwd) {
57
57
  path: wtPath,
58
58
  branch,
59
59
  isCurrent: cwd === wtPath || cwd.startsWith(wtPath + path.sep),
60
+ // The main worktree is always the first entry of `git worktree list`.
61
+ isMain: index === 0,
60
62
  repoRoot
61
63
  };
62
64
  });
@@ -77,6 +79,16 @@ function addWorktree(repoRoot, worktreePath, branch, baseBranch) {
77
79
  }
78
80
  }
79
81
  function removeWorktree(repoRoot, worktreePath, force = false) {
82
+ const resolve = (p) => {
83
+ try {
84
+ return realpathSync(p);
85
+ } catch {
86
+ return p;
87
+ }
88
+ };
89
+ if (resolve(worktreePath) === resolve(repoRoot)) {
90
+ throw new Error("Refusing to remove the main worktree");
91
+ }
80
92
  try {
81
93
  execFileSync(
82
94
  "git",
@@ -126,6 +138,19 @@ function branchExists(repoRoot, branch) {
126
138
  return false;
127
139
  }
128
140
  }
141
+ function isBranchMerged(repoRoot, branch, baseBranch) {
142
+ try {
143
+ const out = execFileSync("git", ["cherry", baseBranch, branch], {
144
+ cwd: repoRoot,
145
+ encoding: "utf8",
146
+ stdio: "pipe"
147
+ });
148
+ const lines = out.split("\n").filter((l) => l.trim().length > 0);
149
+ return lines.length > 0 && lines.every((l) => l.startsWith("-"));
150
+ } catch {
151
+ return false;
152
+ }
153
+ }
129
154
  function setUpstreamTracking(worktreePath, branch, remote = "origin") {
130
155
  try {
131
156
  execFileSync(
@@ -287,7 +312,7 @@ function buildListLayout(items, selectedIndex, query, mode, lastRefresh = null,
287
312
  for (const item of groupItems) {
288
313
  const start = body.length;
289
314
  const cursor = i === selectedIndex ? pc.cyan("\u25B6") : " ";
290
- const branchLabel = item.isCurrent ? pc.dim(`${item.branch} (current)`) : pc.white(item.branch);
315
+ const branchLabel = item.isCurrent ? pc.dim(`${item.branch} (current)`) : item.isMain ? pc.dim(`${item.branch} (main)`) : pc.white(item.branch);
291
316
  const pathLabel = pc.dim(shortenPath(item.path));
292
317
  body.push(` ${cursor} ${branchLabel} ${pathLabel}`);
293
318
  if (item.lastCommit) {
@@ -298,7 +323,9 @@ function buildListLayout(items, selectedIndex, query, mode, lastRefresh = null,
298
323
  }
299
324
  }
300
325
  const footer = [
301
- pc.dim("\u2195 navigate \xB7 Enter open \xB7 D delete \xB7 C create \xB7 A agent \xB7 Q quit")
326
+ pc.dim(
327
+ "\u2195 navigate \xB7 Enter open \xB7 D delete \xB7 P prune \xB7 C create \xB7 A agent \xB7 Q quit"
328
+ )
302
329
  ];
303
330
  return { header, body, footer, itemSpans };
304
331
  }
@@ -333,6 +360,17 @@ function cleanupRawMode() {
333
360
  process.stdin.pause();
334
361
  process.stdout.write("\x1B[2J\x1B[H");
335
362
  }
363
+ function waitForKeypress() {
364
+ return new Promise((resolve) => {
365
+ process.stdin.setRawMode(true);
366
+ process.stdin.resume();
367
+ process.stdin.once("data", () => {
368
+ process.stdin.setRawMode(false);
369
+ process.stdin.pause();
370
+ resolve();
371
+ });
372
+ });
373
+ }
336
374
  function renderRepoPicker(repos, selectedIndex, query) {
337
375
  const lines = [];
338
376
  lines.push(pc.dim("\u2139 Not in a git repository \u2014 select a repo to create in"));
@@ -579,6 +617,14 @@ async function runInteractiveList(allItems, mode, handlers, options = {}) {
579
617
  } else if (key === "d" || key === "D") {
580
618
  const item = filtered[selectedIndex];
581
619
  if (item) {
620
+ if (item.isMain) {
621
+ process.stdout.write(
622
+ pc.red(
623
+ "\nCannot delete the main repository \u2014 only worktrees can be removed.\n"
624
+ )
625
+ );
626
+ return;
627
+ }
582
628
  if (item.isCurrent) {
583
629
  process.stdout.write(
584
630
  pc.red("\nCannot delete the worktree you are currently in.\n")
@@ -602,6 +648,27 @@ async function runInteractiveList(allItems, mode, handlers, options = {}) {
602
648
  interacting = false;
603
649
  render();
604
650
  }
651
+ } else if (key === "p" || key === "P") {
652
+ interacting = true;
653
+ detachListener();
654
+ cleanupRawMode();
655
+ const removed = await handlers.onWipe(allItems);
656
+ if (removed.length > 0) {
657
+ const removedSet = new Set(removed);
658
+ allItems = allItems.filter((w) => !removedSet.has(w));
659
+ filtered = filtered.filter((w) => !removedSet.has(w));
660
+ } else {
661
+ process.stdout.write(pc.dim("\nPress any key to continue\u2026"));
662
+ await waitForKeypress();
663
+ }
664
+ selectedIndex = Math.min(
665
+ selectedIndex,
666
+ Math.max(0, filtered.length - 1)
667
+ );
668
+ setupRawMode();
669
+ attachListener();
670
+ interacting = false;
671
+ render();
605
672
  } else if (key === "c" || key === "C") {
606
673
  interacting = true;
607
674
  detachListener();
@@ -668,6 +735,7 @@ export {
668
735
  removeWorktree,
669
736
  listWorktreeDirtyFiles,
670
737
  branchExists,
738
+ isBranchMerged,
671
739
  setUpstreamTracking,
672
740
  fetchRemote,
673
741
  resolveWorktreePath,
package/dist/cli.js CHANGED
@@ -3,12 +3,12 @@
3
3
  // src/cli.ts
4
4
  import { Command } from "commander";
5
5
  var program = new Command();
6
- program.name("wt").description("Git worktree manager").version("0.5.0-pr21.ge97b6fa").action(async () => {
7
- const { runList } = await import("./list-JJ72GL3O.js");
6
+ program.name("wt").description("Git worktree manager").version("0.5.0-pr22.gbb5b3fa").action(async () => {
7
+ const { runList } = await import("./list-XRECVEUI.js");
8
8
  await runList();
9
9
  });
10
10
  program.command("create [branch]").description("Create a new worktree").action(async (branch) => {
11
- const { createWorktree } = await import("./create-JK2AGRNF.js");
11
+ const { createWorktree } = await import("./create-DYM7QWI5.js");
12
12
  await createWorktree(branch);
13
13
  });
14
14
  program.command("agent <branch> <plan_prompt>").description("Create a worktree and auto-start an AI agent in Zed (macOS)").option(
@@ -17,10 +17,16 @@ program.command("agent <branch> <plan_prompt>").description("Create a worktree a
17
17
  "plan"
18
18
  ).action(
19
19
  async (branch, planPrompt, options) => {
20
- const { createAgentWorktree } = await import("./agent-UJLUOPYM.js");
20
+ const { createAgentWorktree } = await import("./agent-575QKWIG.js");
21
21
  await createAgentWorktree(branch, planPrompt, { mode: options.mode });
22
22
  }
23
23
  );
24
+ program.command("prune").description(
25
+ "Remove worktrees whose branch has been merged into the base branch"
26
+ ).action(async () => {
27
+ const { runPrune } = await import("./prune-LOO5KMBU.js");
28
+ await runPrune();
29
+ });
24
30
  program.command("config").description("Open the config file in $EDITOR").option("--path", "Print the config file path and exit").action(async (options) => {
25
31
  if (options.path) {
26
32
  const { printConfigPath } = await import("./config-QLWPW2UZ.js");
@@ -31,7 +37,7 @@ program.command("config").description("Open the config file in $EDITOR").option(
31
37
  }
32
38
  });
33
39
  program.command("skill").description("Print the wt skill file to stdout").action(async () => {
34
- const { printSkill } = await import("./skill-HIPI5CFN.js");
40
+ const { printSkill } = await import("./skill-5JFC6Q33.js");
35
41
  printSkill();
36
42
  });
37
43
  await program.parseAsync(process.argv);
@@ -4,8 +4,8 @@ import {
4
4
  openConfiguredIde,
5
5
  prepareWorktree,
6
6
  promptExistingWorktree
7
- } from "./chunk-2YENB5VN.js";
8
- import "./chunk-VZJ7HTCM.js";
7
+ } from "./chunk-Q6NNNYDJ.js";
8
+ import "./chunk-YXA6CZ2L.js";
9
9
  import "./chunk-QVYSEMSL.js";
10
10
  export {
11
11
  createWorktree,
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ buildMergedPredicate,
4
+ deleteWorktree,
5
+ prepareListItems,
6
+ runList,
7
+ selectWipeCandidates,
8
+ wipeWorktrees
9
+ } from "./chunk-QHNOUX63.js";
10
+ import "./chunk-YXA6CZ2L.js";
11
+ import "./chunk-QVYSEMSL.js";
12
+ export {
13
+ buildMergedPredicate,
14
+ deleteWorktree,
15
+ prepareListItems,
16
+ runList,
17
+ selectWipeCandidates,
18
+ wipeWorktrees
19
+ };
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ prepareListItems,
4
+ wipeWorktrees
5
+ } from "./chunk-QHNOUX63.js";
6
+ import "./chunk-YXA6CZ2L.js";
7
+ import {
8
+ createStore
9
+ } from "./chunk-QVYSEMSL.js";
10
+
11
+ // src/commands/prune.ts
12
+ import pc from "picocolors";
13
+ async function runPrune(options = {}) {
14
+ const { cwd = process.cwd(), store = createStore() } = options;
15
+ const { items, mode } = await prepareListItems({ cwd, store });
16
+ if (items.length === 0) {
17
+ console.log(
18
+ pc.dim(
19
+ mode === "global" ? "No repos registered. Run `wt create` inside a repo to get started." : "No worktrees found."
20
+ )
21
+ );
22
+ return;
23
+ }
24
+ const removed = await wipeWorktrees(items, store, { fetch: true });
25
+ if (removed.length > 0) {
26
+ console.log(pc.green(`\u2713 Pruned ${removed.length} worktree(s).`));
27
+ }
28
+ }
29
+ export {
30
+ runPrune
31
+ };
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/commands/skill.ts
4
+ function printSkill() {
5
+ console.log('---\nname: wt-worktree-manager\ndescription: Use the wt CLI to create, browse, open, and delete git worktrees across repos. Use when the user asks to manage worktrees, create isolated branches, or configure worktree defaults.\n---\n\n# wt \u2014 Git Worktree Manager\n\n`wt` is a CLI for managing git worktrees. It provides an interactive TUI to browse, create, open in your IDE, and delete worktrees across multiple repos.\n\n## Commands\n\n### `wt` (no subcommand)\n\nLaunch the interactive TUI. Shows worktrees for the current repo (repo mode) or all registered repos (global mode, when run outside a repo).\n\n**Keybindings in the TUI:**\n\n- Arrow keys \u2014 navigate\n- `Enter` \u2014 open worktree in IDE (exits the TUI)\n- `D` \u2014 delete worktree (the main worktree is tagged `(main)` and cannot be deleted \u2014 only linked worktrees can)\n- `P` \u2014 prune all merged worktrees (per-branch confirmation)\n- `C` \u2014 create a new worktree (works in both repo and global mode)\n- `A` \u2014 create a worktree and start an AI agent in it (works in both modes)\n- type to search \xB7 `Backspace` \u2014 edit search\n- `Q` / `Esc` \u2014 quit\n\n`C` and `A` are step-by-step wizards. In global mode (run from outside a repo /\n"home") they start by prompting for the repo (picker), then the branch; in repo\nmode the repo is fixed so they start at the branch. `A` then adds two more\nsteps:\n\n- `C` \u2014 **worktree (repo \u2192 branch)**\n- `A` \u2014 **worktree (repo \u2192 branch) \u2192 plan prompt \u2192 permission mode**\n\nPressing `Esc` at any step goes back to the previous step (your earlier answers\nare preserved); pressing `Esc` on the first step returns to the list.\n\nAfter a create or agent action the TUI **refreshes and stays open** on the list\n(your search and cursor are preserved) rather than exiting \u2014 only `Enter` (open)\nand `Q`/`Esc` exit.\n\nBecause `a`/`A`, `c`/`C`, `d`/`D`, and `p`/`P` are reserved as command keys,\nthose letters can\'t be typed into the search box.\n\n### `wt create [branch]`\n\nCreate a new worktree. If `branch` is omitted, prompts interactively.\n\nThe worktree is created as a sibling directory to the repo: `<parent>/<repo-name>-<branch-name>`.\n\nAfter creation, `wt` runs any configured `setup_commands` and opens the worktree in your IDE.\n\nIf the worktree path already exists, `wt create` doesn\'t error \u2014 it prompts you\nto **open it in the IDE** or **quit**. (In a non-interactive shell it errors\nwith a non-zero exit instead of prompting.)\n\n### `wt agent <branch> <plan_prompt> [--mode <mode>]`\n\nCreate a worktree (same as `wt create`) **and** auto-start an AI agent in Zed\'s\nintegrated terminal, pre-filled with `<plan_prompt>` and left interactive for\nyou to take over.\n\n```bash\nwt agent feature/login \'Read the codebase, then propose a plan for login.\'\nwt agent feature/fix \'Fix the bug in payment processing\' --mode auto\nwt agent refactor/api \'Refactor the API layer\' --mode default\n```\n\nThe `--mode` flag sets Claude Code\'s permission mode (defaults to `plan`):\n\n- `default` \u2014 Standard interactive mode with approval for each action\n- `acceptEdits` \u2014 Allow file changes but keep command execution controlled\n- `plan` \u2014 Architecture-first mode with no surprise mutations (default)\n- `auto` \u2014 Claude\'s safety model makes decisions instead of prompting\n- `dontAsk` \u2014 Minimal interruptions in trusted environments\n- `bypassPermissions` \u2014 Skip all permission checks (dangerous, CI/sandbox only)\n\nIt writes a temporary `.zed/tasks.json` running\n`<agent_command> --permission-mode <mode> \'<plan_prompt>\'`, ensures a global Zed keymap chord\n(`agent_trigger_chord`) spawns that task, opens Zed, presses the chord via\n`osascript`, then removes the temporary task so the repo is left clean.\n\n**macOS + Zed only.** Requires Accessibility permission for the app that runs\n`wt` (Zed itself, when run from its integrated terminal). If it isn\'t granted,\n`wt agent` opens the _Privacy & Security \u2192 Accessibility_ settings pane and waits\nfor you to grant it and confirm, then retries automatically. On other platforms\n(or when `ide` is not `zed`) the worktree is still created and opened, but the\nagent is not auto-started.\n\nOver SSH it still works, provided the same user has an active graphical login on\nthe Mac: the keystroke is run inside the GUI session via Launch Services\n(`open -a Terminal` briefly flashes a Terminal window). Grant Accessibility to\nTerminal (not Zed) the first time. With no one logged in graphically there is\nnothing to drive, so it falls back to the manual "press the chord in Zed"\nmessage.\n\nIf the worktree path already exists, `wt agent` prompts you to **open it in the\nIDE**, **open it and start the agent**, or **quit** \u2014 instead of erroring. (In a\nnon-interactive shell it errors with a non-zero exit instead of prompting.)\n\n### `wt prune`\n\nRemove every worktree whose branch has already been merged into the base\nbranch (`base_branch`, default `origin/main`). Each candidate is confirmed\nindividually \u2014 and force-confirmed when git refuses (submodules / uncommitted\nchanges), exactly like a manual `d` delete. The branch itself is left intact;\nonly the worktree is removed.\n\n```bash\nwt prune # review and remove merged worktrees, one prompt per branch\n```\n\nMerge detection is patch-id based (via `git cherry`), so a single-commit branch\nthat was **squash-merged** through a PR is still recognized as merged. It also\nbest-effort fetches the remote first so detection sees up-to-date refs; if the\nbase ref can\'t be resolved (e.g. offline), nothing is removed. Works in repo\nmode (current repo) and global mode (all registered repos, each against its own\n`base_branch`). The TUI exposes the same action under the `p` key.\n\n### `wt config`\n\nOpen the global config file in `$EDITOR` (defaults to `nano`).\n\n```bash\nwt config # open in editor\nwt config --path # print config file path only\n```\n\n### `wt skill`\n\nPrint this skill file to stdout. Useful for piping to agents or copying to a project.\n\n## Configuration\n\nConfig is stored as JSON. Get the path with `wt config --path`.\n\n### Schema\n\n| Key | Type | Default | Description |\n| --------------------- | ---------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `worktree_path` | `string` | `"../"` | Where to place new worktrees, relative to the repo root |\n| `base_branch` | `string` | `"origin/main"` | Branch to base new worktrees on |\n| `setup_commands` | `string[]` | `[]` | Commands to run in a new worktree after creation (e.g. `["npm install"]`) |\n| `teardown_commands` | `string[]` | `[]` | Commands to run in a worktree just before it is deleted (e.g. `["docker compose down -v"]`); on failure you are prompted whether to delete anyway |\n| `ide` | `string` | `"zed"` | IDE command to open worktrees with |\n| `ide_open_args` | `string[]` | `["-n"]` | Arguments passed to the IDE command |\n| `agent_command` | `string` | `"claude --permission-mode plan"` | Base command `wt agent` runs in Zed; any `--permission-mode` flag is replaced by the `--mode` option (defaults to `plan`), then `<plan_prompt>` is appended single-quoted |\n| `agent_trigger_chord` | `string` | `"ctrl-shift-cmd-c"` | Zed keymap chord `wt agent` installs/presses to spawn the agent task |\n| `auto_refresh_minutes`| `number` | `5` | How often the interactive list (`wt`) re-fetches worktrees and updates the "last refreshed" header; `0` disables auto-refresh |\n| `repos` | `string[]` | `[]` | Registered repo paths (auto-populated on first use) |\n| `repo_overrides` | `object` | `{}` | Per-repo config overrides (see below) |\n\n### Per-repo overrides\n\nOverride any field (`worktree_path`, `base_branch`, `setup_commands`, `teardown_commands`, `ide`, `ide_open_args`, `agent_command`, `agent_trigger_chord`, `auto_refresh_minutes`) for a specific repo:\n\n```json\n{\n "base_branch": "origin/main",\n "ide": "zed",\n "repo_overrides": {\n "/path/to/my-repo": {\n "base_branch": "origin/develop",\n "setup_commands": ["npm install", "npm run build"]\n }\n }\n}\n```\n\n## Common workflows\n\n### Create a worktree for a new feature\n\n```bash\ncd /path/to/repo\nwt create feature/my-branch\n```\n\n### Configure setup commands for a repo\n\n```bash\nwt config\n# Then add to the JSON:\n# "repo_overrides": {\n# "/path/to/repo": {\n# "setup_commands": ["npm install"]\n# }\n# }\n```\n\n### Browse all worktrees across repos\n\nRun `wt` from any directory outside a git repo to see worktrees from all registered repos.\n');
6
+ }
7
+ export {
8
+ printSkill
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cestoliv/wt",
3
- "version": "0.5.0-pr21.ge97b6fa",
3
+ "version": "0.5.0-pr22.gbb5b3fa",
4
4
  "description": "Fast, interactive TUI to browse, create, open, and delete git worktrees across repos.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,216 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- getRegisteredRepos,
4
- getRepoRoot,
5
- listWorktreeDirtyFiles,
6
- listWorktrees,
7
- openIde,
8
- registerRepo,
9
- removeWorktree,
10
- runBranchInput,
11
- runCommands,
12
- runInteractiveList,
13
- runRepoPicker,
14
- runWizard
15
- } from "./chunk-VZJ7HTCM.js";
16
- import {
17
- createStore,
18
- getEffectiveConfig,
19
- getGlobalConfig
20
- } from "./chunk-QVYSEMSL.js";
21
-
22
- // src/commands/list.ts
23
- import * as clack from "@clack/prompts";
24
- import pc from "picocolors";
25
- function buildWorktreeSteps(repoRoot, store, state) {
26
- const steps = [];
27
- if (!repoRoot) {
28
- const repos = getRegisteredRepos(store);
29
- steps.push(async () => {
30
- const picked = await runRepoPicker(repos, state.pickedRepo);
31
- if (!picked) return false;
32
- state.pickedRepo = picked;
33
- return true;
34
- });
35
- }
36
- steps.push(async () => {
37
- const entered = await runBranchInput(
38
- state.pickedRepo,
39
- state.branch ?? ""
40
- );
41
- if (!entered) return false;
42
- state.branch = entered;
43
- return true;
44
- });
45
- return steps;
46
- }
47
- async function prepareListItems(options = {}) {
48
- const { cwd = process.cwd(), store = createStore() } = options;
49
- let repoRoot = null;
50
- try {
51
- repoRoot = getRepoRoot(cwd);
52
- } catch {
53
- }
54
- if (repoRoot) {
55
- registerRepo(repoRoot, store);
56
- const items2 = listWorktrees(repoRoot, cwd);
57
- return { items: items2, mode: "repo", repoRoot };
58
- }
59
- const repos = getRegisteredRepos(store);
60
- const items = repos.flatMap((repo) => {
61
- try {
62
- return listWorktrees(repo, cwd);
63
- } catch {
64
- return [];
65
- }
66
- });
67
- return { items, mode: "global", repoRoot: null };
68
- }
69
- async function runList(options = {}) {
70
- const { store = createStore(), cwd = process.cwd() } = options;
71
- const { items, mode, repoRoot } = await prepareListItems({ cwd, store });
72
- if (items.length === 0 && mode === "global") {
73
- console.log(
74
- pc.dim(
75
- "No repos registered. Run `wt create` inside a repo to get started."
76
- )
77
- );
78
- return;
79
- }
80
- const autoRefreshMinutes = mode === "repo" && repoRoot ? getEffectiveConfig(repoRoot, store).auto_refresh_minutes : getGlobalConfig(store).auto_refresh_minutes;
81
- await runInteractiveList(
82
- items,
83
- mode,
84
- {
85
- onOpen: (item) => {
86
- const config = getEffectiveConfig(item.repoRoot, store);
87
- openIde(config.ide, config.ide_open_args, item.path);
88
- },
89
- onDelete: async (item) => {
90
- const confirmed = await clack.confirm({
91
- message: `Remove worktree ${pc.bold(item.branch)}? This cannot be undone.`
92
- });
93
- if (clack.isCancel(confirmed) || !confirmed) return false;
94
- const config = getEffectiveConfig(item.repoRoot, store);
95
- if (config.teardown_commands.length > 0) {
96
- console.log(pc.dim("Running teardown commands..."));
97
- const result = await runCommands(config.teardown_commands, item.path);
98
- if (!result.success) {
99
- clack.log.warn(
100
- `Teardown command failed: ${result.failedCommand} (exit code ${result.exitCode})`
101
- );
102
- const proceed = await clack.confirm({
103
- message: `Delete ${pc.bold(item.branch)} anyway?`
104
- });
105
- if (clack.isCancel(proceed) || !proceed) return false;
106
- }
107
- }
108
- try {
109
- removeWorktree(item.repoRoot, item.path);
110
- console.log(pc.green(`\u2713 Removed ${item.branch}`));
111
- return true;
112
- } catch (err) {
113
- const msg = String(err);
114
- if (msg.includes("cannot be moved or removed")) {
115
- clack.log.warn(
116
- "Worktree contains git submodules, which prevent standard removal."
117
- );
118
- const force = await clack.confirm({
119
- message: `Force delete ${pc.bold(item.branch)}? The worktree directory will be removed directly.`
120
- });
121
- if (clack.isCancel(force) || !force) return false;
122
- try {
123
- removeWorktree(item.repoRoot, item.path, true);
124
- console.log(pc.green(`\u2713 Force-removed ${item.branch}`));
125
- return true;
126
- } catch (err2) {
127
- console.error(
128
- pc.red(`\u2717 Failed to force-remove: ${String(err2)}`)
129
- );
130
- return false;
131
- }
132
- }
133
- if (msg.includes("modified or untracked files")) {
134
- const dirty = listWorktreeDirtyFiles(item.path);
135
- if (dirty.length > 0) {
136
- clack.log.warn(
137
- `Worktree has uncommitted changes:
138
- ${dirty.map((f) => ` ${f}`).join("\n")}`
139
- );
140
- }
141
- const force = await clack.confirm({
142
- message: `Force delete ${pc.bold(item.branch)}? All changes will be lost.`
143
- });
144
- if (clack.isCancel(force) || !force) return false;
145
- try {
146
- removeWorktree(item.repoRoot, item.path, true);
147
- console.log(pc.green(`\u2713 Force-removed ${item.branch}`));
148
- return true;
149
- } catch (err2) {
150
- console.error(
151
- pc.red(`\u2717 Failed to force-remove: ${String(err2)}`)
152
- );
153
- return false;
154
- }
155
- }
156
- console.error(pc.red(`\u2717 Failed to remove: ${msg}`));
157
- return false;
158
- }
159
- },
160
- onCreate: async () => {
161
- const state = { pickedRepo: repoRoot ?? void 0 };
162
- const steps = buildWorktreeSteps(repoRoot, store, state);
163
- if (!await runWizard(steps)) return;
164
- if (state.pickedRepo === void 0 || state.branch === void 0)
165
- return;
166
- const { createWorktree } = await import("./create-JK2AGRNF.js");
167
- await createWorktree(state.branch, { cwd: state.pickedRepo, store });
168
- },
169
- onAgent: async () => {
170
- const { createAgentWorktree, VALID_MODES } = await import("./agent-UJLUOPYM.js");
171
- const state = {
172
- pickedRepo: repoRoot ?? void 0,
173
- mode: "plan"
174
- };
175
- const steps = buildWorktreeSteps(repoRoot, store, state);
176
- steps.push(async () => {
177
- const entered = await clack.text({
178
- message: "Plan prompt for the agent:",
179
- initialValue: state.plan,
180
- validate: (v) => !v || v.length === 0 ? "Required" : void 0
181
- });
182
- if (clack.isCancel(entered)) return false;
183
- state.plan = entered;
184
- return true;
185
- });
186
- steps.push(async () => {
187
- const chosen = await clack.select({
188
- message: "Permission mode:",
189
- initialValue: state.mode,
190
- options: VALID_MODES.map((m) => ({ value: String(m), label: m }))
191
- });
192
- if (clack.isCancel(chosen)) return false;
193
- state.mode = chosen;
194
- return true;
195
- });
196
- if (!await runWizard(steps)) return;
197
- if (state.pickedRepo === void 0 || state.branch === void 0 || state.plan === void 0)
198
- return;
199
- await createAgentWorktree(state.branch, state.plan, {
200
- cwd: state.pickedRepo,
201
- store,
202
- mode: state.mode
203
- });
204
- },
205
- refreshItems: async () => {
206
- const refreshed = await prepareListItems({ cwd, store });
207
- return refreshed.items;
208
- }
209
- },
210
- { autoRefreshMinutes }
211
- );
212
- }
213
- export {
214
- prepareListItems,
215
- runList
216
- };
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/commands/skill.ts
4
- function printSkill() {
5
- console.log('---\nname: wt-worktree-manager\ndescription: Use the wt CLI to create, browse, open, and delete git worktrees across repos. Use when the user asks to manage worktrees, create isolated branches, or configure worktree defaults.\n---\n\n# wt \u2014 Git Worktree Manager\n\n`wt` is a CLI for managing git worktrees. It provides an interactive TUI to browse, create, open in your IDE, and delete worktrees across multiple repos.\n\n## Commands\n\n### `wt` (no subcommand)\n\nLaunch the interactive TUI. Shows worktrees for the current repo (repo mode) or all registered repos (global mode, when run outside a repo).\n\n**Keybindings in the TUI:**\n\n- Arrow keys \u2014 navigate\n- `Enter` \u2014 open worktree in IDE (exits the TUI)\n- `D` \u2014 delete worktree\n- `C` \u2014 create a new worktree (works in both repo and global mode)\n- `A` \u2014 create a worktree and start an AI agent in it (works in both modes)\n- type to search \xB7 `Backspace` \u2014 edit search\n- `Q` / `Esc` \u2014 quit\n\n`C` and `A` are step-by-step wizards. In global mode (run from outside a repo /\n"home") they start by prompting for the repo (picker), then the branch; in repo\nmode the repo is fixed so they start at the branch. `A` then adds two more\nsteps:\n\n- `C` \u2014 **worktree (repo \u2192 branch)**\n- `A` \u2014 **worktree (repo \u2192 branch) \u2192 plan prompt \u2192 permission mode**\n\nPressing `Esc` at any step goes back to the previous step (your earlier answers\nare preserved); pressing `Esc` on the first step returns to the list.\n\nAfter a create or agent action the TUI **refreshes and stays open** on the list\n(your search and cursor are preserved) rather than exiting \u2014 only `Enter` (open)\nand `Q`/`Esc` exit.\n\nBecause `a`/`A`, `c`/`C`, and `d`/`D` are reserved as command keys, those\nletters can\'t be typed into the search box.\n\n### `wt create [branch]`\n\nCreate a new worktree. If `branch` is omitted, prompts interactively.\n\nThe worktree is created as a sibling directory to the repo: `<parent>/<repo-name>-<branch-name>`.\n\nAfter creation, `wt` runs any configured `setup_commands` and opens the worktree in your IDE.\n\nIf the worktree path already exists, `wt create` doesn\'t error \u2014 it prompts you\nto **open it in the IDE** or **quit**. (In a non-interactive shell it errors\nwith a non-zero exit instead of prompting.)\n\n### `wt agent <branch> <plan_prompt> [--mode <mode>]`\n\nCreate a worktree (same as `wt create`) **and** auto-start an AI agent in Zed\'s\nintegrated terminal, pre-filled with `<plan_prompt>` and left interactive for\nyou to take over.\n\n```bash\nwt agent feature/login \'Read the codebase, then propose a plan for login.\'\nwt agent feature/fix \'Fix the bug in payment processing\' --mode auto\nwt agent refactor/api \'Refactor the API layer\' --mode default\n```\n\nThe `--mode` flag sets Claude Code\'s permission mode (defaults to `plan`):\n\n- `default` \u2014 Standard interactive mode with approval for each action\n- `acceptEdits` \u2014 Allow file changes but keep command execution controlled\n- `plan` \u2014 Architecture-first mode with no surprise mutations (default)\n- `auto` \u2014 Claude\'s safety model makes decisions instead of prompting\n- `dontAsk` \u2014 Minimal interruptions in trusted environments\n- `bypassPermissions` \u2014 Skip all permission checks (dangerous, CI/sandbox only)\n\nIt writes a temporary `.zed/tasks.json` running\n`<agent_command> --permission-mode <mode> \'<plan_prompt>\'`, ensures a global Zed keymap chord\n(`agent_trigger_chord`) spawns that task, opens Zed, presses the chord via\n`osascript`, then removes the temporary task so the repo is left clean.\n\n**macOS + Zed only.** Requires Accessibility permission for the app that runs\n`wt` (Zed itself, when run from its integrated terminal). If it isn\'t granted,\n`wt agent` opens the _Privacy & Security \u2192 Accessibility_ settings pane and waits\nfor you to grant it and confirm, then retries automatically. On other platforms\n(or when `ide` is not `zed`) the worktree is still created and opened, but the\nagent is not auto-started.\n\nOver SSH it still works, provided the same user has an active graphical login on\nthe Mac: the keystroke is run inside the GUI session via Launch Services\n(`open -a Terminal` briefly flashes a Terminal window). Grant Accessibility to\nTerminal (not Zed) the first time. With no one logged in graphically there is\nnothing to drive, so it falls back to the manual "press the chord in Zed"\nmessage.\n\nIf the worktree path already exists, `wt agent` prompts you to **open it in the\nIDE**, **open it and start the agent**, or **quit** \u2014 instead of erroring. (In a\nnon-interactive shell it errors with a non-zero exit instead of prompting.)\n\n### `wt config`\n\nOpen the global config file in `$EDITOR` (defaults to `nano`).\n\n```bash\nwt config # open in editor\nwt config --path # print config file path only\n```\n\n### `wt skill`\n\nPrint this skill file to stdout. Useful for piping to agents or copying to a project.\n\n## Configuration\n\nConfig is stored as JSON. Get the path with `wt config --path`.\n\n### Schema\n\n| Key | Type | Default | Description |\n| --------------------- | ---------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `worktree_path` | `string` | `"../"` | Where to place new worktrees, relative to the repo root |\n| `base_branch` | `string` | `"origin/main"` | Branch to base new worktrees on |\n| `setup_commands` | `string[]` | `[]` | Commands to run in a new worktree after creation (e.g. `["npm install"]`) |\n| `teardown_commands` | `string[]` | `[]` | Commands to run in a worktree just before it is deleted (e.g. `["docker compose down -v"]`); on failure you are prompted whether to delete anyway |\n| `ide` | `string` | `"zed"` | IDE command to open worktrees with |\n| `ide_open_args` | `string[]` | `["-n"]` | Arguments passed to the IDE command |\n| `agent_command` | `string` | `"claude --permission-mode plan"` | Base command `wt agent` runs in Zed; any `--permission-mode` flag is replaced by the `--mode` option (defaults to `plan`), then `<plan_prompt>` is appended single-quoted |\n| `agent_trigger_chord` | `string` | `"ctrl-shift-cmd-c"` | Zed keymap chord `wt agent` installs/presses to spawn the agent task |\n| `auto_refresh_minutes`| `number` | `5` | How often the interactive list (`wt`) re-fetches worktrees and updates the "last refreshed" header; `0` disables auto-refresh |\n| `repos` | `string[]` | `[]` | Registered repo paths (auto-populated on first use) |\n| `repo_overrides` | `object` | `{}` | Per-repo config overrides (see below) |\n\n### Per-repo overrides\n\nOverride any field (`worktree_path`, `base_branch`, `setup_commands`, `teardown_commands`, `ide`, `ide_open_args`, `agent_command`, `agent_trigger_chord`, `auto_refresh_minutes`) for a specific repo:\n\n```json\n{\n "base_branch": "origin/main",\n "ide": "zed",\n "repo_overrides": {\n "/path/to/my-repo": {\n "base_branch": "origin/develop",\n "setup_commands": ["npm install", "npm run build"]\n }\n }\n}\n```\n\n## Common workflows\n\n### Create a worktree for a new feature\n\n```bash\ncd /path/to/repo\nwt create feature/my-branch\n```\n\n### Configure setup commands for a repo\n\n```bash\nwt config\n# Then add to the JSON:\n# "repo_overrides": {\n# "/path/to/repo": {\n# "setup_commands": ["npm install"]\n# }\n# }\n```\n\n### Browse all worktrees across repos\n\nRun `wt` from any directory outside a git repo to see worktrees from all registered repos.\n');
6
- }
7
- export {
8
- printSkill
9
- };