@cestoliv/wt 0.2.0 → 0.3.0

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.
@@ -3,8 +3,8 @@ import {
3
3
  openConfiguredIde,
4
4
  prepareWorktree,
5
5
  promptExistingWorktree
6
- } from "./chunk-BYWCGKUP.js";
7
- import "./chunk-FSARWOCW.js";
6
+ } from "./chunk-B6EPGPXW.js";
7
+ import "./chunk-DKFHAASV.js";
8
8
  import "./chunk-IQWENLPW.js";
9
9
 
10
10
  // src/commands/agent.ts
@@ -10,8 +10,9 @@ import {
10
10
  registerRepo,
11
11
  resolveWorktreePath,
12
12
  runBranchInput,
13
- runRepoPicker
14
- } from "./chunk-FSARWOCW.js";
13
+ runRepoPicker,
14
+ setUpstreamTracking
15
+ } from "./chunk-DKFHAASV.js";
15
16
  import {
16
17
  createStore,
17
18
  getEffectiveConfig
@@ -118,8 +119,8 @@ async function prepareWorktree(branch, options = {}) {
118
119
  return { status: "exists", repoRoot, worktreePath, config };
119
120
  }
120
121
  const parts = config.base_branch.split("/", 2);
122
+ const remote = parts[0] || "origin";
121
123
  if (parts.length === 2) {
122
- const remote = parts[0];
123
124
  try {
124
125
  fetchRemote(repoRoot, remote);
125
126
  } catch (err) {
@@ -136,6 +137,7 @@ async function prepareWorktree(branch, options = {}) {
136
137
  } else {
137
138
  addWorktree(repoRoot, worktreePath, branch, config.base_branch);
138
139
  }
140
+ setUpstreamTracking(worktreePath, branch, remote);
139
141
  console.log(pc.green(`\u2713 Created worktree at ${worktreePath}`));
140
142
  if (config.setup_commands.length > 0) {
141
143
  console.log(pc.dim("Running setup commands..."));
@@ -124,6 +124,16 @@ function branchExists(repoRoot, branch) {
124
124
  return false;
125
125
  }
126
126
  }
127
+ function setUpstreamTracking(worktreePath, branch, remote = "origin") {
128
+ try {
129
+ execFileSync(
130
+ "git",
131
+ ["branch", "--set-upstream-to", `${remote}/${branch}`, branch],
132
+ { cwd: worktreePath, stdio: "pipe" }
133
+ );
134
+ } catch {
135
+ }
136
+ }
127
137
  function fetchRemote(repoRoot, remote = "origin") {
128
138
  execFileSync("git", ["fetch", remote], {
129
139
  cwd: repoRoot,
@@ -498,6 +508,7 @@ export {
498
508
  removeWorktree,
499
509
  listWorktreeDirtyFiles,
500
510
  branchExists,
511
+ setUpstreamTracking,
501
512
  fetchRemote,
502
513
  resolveWorktreePath,
503
514
  openIde,
package/dist/cli.js CHANGED
@@ -3,16 +3,16 @@
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.2.0").action(async () => {
7
- const { runList } = await import("./list-7UDMSJOS.js");
6
+ program.name("wt").description("Git worktree manager").version("0.3.0").action(async () => {
7
+ const { runList } = await import("./list-FOLV77ET.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-5J5NGGGM.js");
11
+ const { createWorktree } = await import("./create-5BZUA7QH.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)").action(async (branch, planPrompt) => {
15
- const { createAgentWorktree } = await import("./agent-PKCZHGN7.js");
15
+ const { createAgentWorktree } = await import("./agent-3N6CSK7A.js");
16
16
  await createAgentWorktree(branch, planPrompt);
17
17
  });
18
18
  program.command("config").description("Open the config file in $EDITOR").option("--path", "Print the config file path and exit").action(async (options) => {
@@ -4,8 +4,8 @@ import {
4
4
  openConfiguredIde,
5
5
  prepareWorktree,
6
6
  promptExistingWorktree
7
- } from "./chunk-BYWCGKUP.js";
8
- import "./chunk-FSARWOCW.js";
7
+ } from "./chunk-B6EPGPXW.js";
8
+ import "./chunk-DKFHAASV.js";
9
9
  import "./chunk-IQWENLPW.js";
10
10
  export {
11
11
  createWorktree,
@@ -8,7 +8,7 @@ import {
8
8
  registerRepo,
9
9
  removeWorktree,
10
10
  runInteractiveList
11
- } from "./chunk-FSARWOCW.js";
11
+ } from "./chunk-DKFHAASV.js";
12
12
  import {
13
13
  createStore,
14
14
  getEffectiveConfig
@@ -66,6 +66,23 @@ async function runList(options = {}) {
66
66
  return true;
67
67
  } catch (err) {
68
68
  const msg = String(err);
69
+ if (msg.includes("cannot be moved or removed")) {
70
+ clack.log.warn(
71
+ "Worktree contains git submodules, which prevent standard removal."
72
+ );
73
+ const force = await clack.confirm({
74
+ message: `Force delete ${pc.bold(item.branch)}? The worktree directory will be removed directly.`
75
+ });
76
+ if (clack.isCancel(force) || !force) return false;
77
+ try {
78
+ removeWorktree(item.repoRoot, item.path, true);
79
+ console.log(pc.green(`\u2713 Force-removed ${item.branch}`));
80
+ return true;
81
+ } catch (err2) {
82
+ console.error(pc.red(`\u2717 Failed to force-remove: ${String(err2)}`));
83
+ return false;
84
+ }
85
+ }
69
86
  if (msg.includes("modified or untracked files")) {
70
87
  const dirty = listWorktreeDirtyFiles(item.path);
71
88
  if (dirty.length > 0) {
@@ -93,7 +110,7 @@ ${dirty.map((f) => ` ${f}`).join("\n")}`
93
110
  },
94
111
  onCreate: async () => {
95
112
  if (repoRoot) {
96
- const { createWorktree } = await import("./create-5J5NGGGM.js");
113
+ const { createWorktree } = await import("./create-5BZUA7QH.js");
97
114
  await createWorktree(void 0, { cwd: repoRoot, store });
98
115
  }
99
116
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cestoliv/wt",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Fast, interactive TUI to browse, create, open, and delete git worktrees across repos.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -44,6 +44,6 @@
44
44
  "tsup": "^8.0.0",
45
45
  "tsx": "^4.19.0",
46
46
  "typescript": "^5.0.0",
47
- "vitest": "^3.0.0"
47
+ "vitest": "^4.1.0"
48
48
  }
49
49
  }