workon 3.5.1 → 3.5.2

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/dist/cli.js CHANGED
@@ -1569,11 +1569,12 @@ var init_worktree = __esm({
1569
1569
  if (worktree.isMain) {
1570
1570
  throw new Error("Cannot remove the main worktree");
1571
1571
  }
1572
- if (!force && await this.hasUncommittedChanges(name)) {
1572
+ const pathMissing = !existsSync2(worktree.path);
1573
+ if (!pathMissing && !force && await this.hasUncommittedChanges(name)) {
1573
1574
  throw new Error(`Worktree '${name}' has uncommitted changes. Use --force to remove anyway.`);
1574
1575
  }
1575
1576
  const args = ["worktree", "remove"];
1576
- if (force) {
1577
+ if (force || pathMissing) {
1577
1578
  args.push("--force");
1578
1579
  }
1579
1580
  args.push(worktree.path);
@@ -1592,6 +1593,9 @@ var init_worktree = __esm({
1592
1593
  if (!worktree) {
1593
1594
  throw new Error(`Worktree '${nameOrPath}' not found`);
1594
1595
  }
1596
+ if (!existsSync2(worktree.path)) {
1597
+ return false;
1598
+ }
1595
1599
  const worktreeGit = simpleGit2(worktree.path);
1596
1600
  const status = await worktreeGit.status();
1597
1601
  return !status.isClean();
@@ -1933,6 +1937,7 @@ var init_utils = __esm({
1933
1937
  import { Command } from "commander";
1934
1938
  import chalk from "chalk";
1935
1939
  import path2 from "path";
1940
+ import { existsSync as existsSync3 } from "fs";
1936
1941
  function createListCommand(ctx) {
1937
1942
  const { config, log } = ctx;
1938
1943
  return new Command("list").description("List worktrees for the current project").option("-a, --all", "Show all worktrees (including main)").action(async (options) => {
@@ -1966,9 +1971,10 @@ Worktrees for ${displayName}:`));
1966
1971
  for (const wt of worktrees) {
1967
1972
  const isManaged = managedPaths.has(wt.path);
1968
1973
  const mainLabel = wt.isMain ? chalk.gray(" (main)") : "";
1969
- const externalLabel = !wt.isMain && !isManaged ? chalk.yellow(" (external)") : "";
1974
+ const missingLabel = !wt.isMain && !existsSync3(wt.path) ? chalk.red(" (missing)") : "";
1975
+ const externalLabel = !wt.isMain && !isManaged && !missingLabel ? chalk.yellow(" (external)") : "";
1970
1976
  const branchDisplay = wt.branch === "(detached)" ? chalk.yellow(wt.branch) : chalk.green(wt.branch);
1971
- console.log(` ${chalk.cyan(wt.name)}${mainLabel}${externalLabel}`);
1977
+ console.log(` ${chalk.cyan(wt.name)}${mainLabel}${missingLabel}${externalLabel}`);
1972
1978
  console.log(` Branch: ${branchDisplay}`);
1973
1979
  console.log(` Path: ${chalk.gray(wt.path)}`);
1974
1980
  console.log(` HEAD: ${chalk.gray(wt.head.substring(0, 8))}`);
@@ -2105,6 +2111,7 @@ import { Command as Command3 } from "commander";
2105
2111
  import chalk3 from "chalk";
2106
2112
  import ora2 from "ora";
2107
2113
  import path3 from "path";
2114
+ import { existsSync as existsSync4 } from "fs";
2108
2115
  import { confirm as confirm5 } from "@inquirer/prompts";
2109
2116
  function createRemoveCommand(ctx) {
2110
2117
  const { config, log } = ctx;
@@ -2134,22 +2141,29 @@ function createRemoveCommand(ctx) {
2134
2141
  log.error("Cannot remove the main worktree");
2135
2142
  process.exit(1);
2136
2143
  }
2137
- const hasChanges = await manager.hasUncommittedChanges(name);
2138
- if (hasChanges && !options.force) {
2139
- log.warn(`Worktree '${name}' has uncommitted changes.`);
2140
- if (!options.yes) {
2141
- const shouldForce = await confirm5({
2142
- message: "Do you want to force removal and lose these changes?",
2143
- default: false
2144
- });
2145
- if (!shouldForce) {
2146
- log.info("Removal cancelled.");
2147
- return;
2144
+ const pathMissing = !existsSync4(worktree.path);
2145
+ if (pathMissing) {
2146
+ log.warn(`Worktree directory is missing from disk: ${worktree.path}`);
2147
+ options.force = true;
2148
+ }
2149
+ if (!pathMissing) {
2150
+ const hasChanges = await manager.hasUncommittedChanges(name);
2151
+ if (hasChanges && !options.force) {
2152
+ log.warn(`Worktree '${name}' has uncommitted changes.`);
2153
+ if (!options.yes) {
2154
+ const shouldForce = await confirm5({
2155
+ message: "Do you want to force removal and lose these changes?",
2156
+ default: false
2157
+ });
2158
+ if (!shouldForce) {
2159
+ log.info("Removal cancelled.");
2160
+ return;
2161
+ }
2162
+ options.force = true;
2163
+ } else {
2164
+ log.error("Use --force to remove worktrees with uncommitted changes.");
2165
+ process.exit(1);
2148
2166
  }
2149
- options.force = true;
2150
- } else {
2151
- log.error("Use --force to remove worktrees with uncommitted changes.");
2152
- process.exit(1);
2153
2167
  }
2154
2168
  }
2155
2169
  if (!options.yes) {
@@ -4105,7 +4119,7 @@ init_environment();
4105
4119
  init_registry();
4106
4120
  init_open2();
4107
4121
  import { Command as Command16 } from "commander";
4108
- import { readFileSync as readFileSync2, existsSync as existsSync4 } from "fs";
4122
+ import { readFileSync as readFileSync2, existsSync as existsSync6 } from "fs";
4109
4123
  import { join as join2, dirname as dirname2 } from "path";
4110
4124
  import { fileURLToPath } from "url";
4111
4125
  import loog from "loog";
@@ -4478,7 +4492,7 @@ async function listProjects(ctx) {
4478
4492
 
4479
4493
  // src/commands/add.ts
4480
4494
  import { Command as Command14 } from "commander";
4481
- import { existsSync as existsSync3, readFileSync } from "fs";
4495
+ import { existsSync as existsSync5, readFileSync } from "fs";
4482
4496
  import { basename as basename2, resolve } from "path";
4483
4497
  import File8 from "phylo";
4484
4498
  import { confirm as confirm10 } from "@inquirer/prompts";
@@ -4500,7 +4514,7 @@ async function addProject(pathArg, options, ctx) {
4500
4514
  const projects = config.getProjects();
4501
4515
  const targetPath = resolve(pathArg);
4502
4516
  log.debug(`Resolved path: ${targetPath}`);
4503
- if (!existsSync3(targetPath)) {
4517
+ if (!existsSync5(targetPath)) {
4504
4518
  log.error(`Path does not exist: ${targetPath}`);
4505
4519
  process.exit(1);
4506
4520
  }
@@ -4584,7 +4598,7 @@ function discoverProject(targetPath, log) {
4584
4598
  packageJson: null
4585
4599
  };
4586
4600
  const packageJsonPath = resolve(targetPath, "package.json");
4587
- if (existsSync3(packageJsonPath)) {
4601
+ if (existsSync5(packageJsonPath)) {
4588
4602
  discovery.isNode = true;
4589
4603
  log.debug("Detected Node project (package.json found)");
4590
4604
  try {
@@ -4600,25 +4614,25 @@ function discoverProject(targetPath, log) {
4600
4614
  }
4601
4615
  }
4602
4616
  const bunLockPath = resolve(targetPath, "bun.lockb");
4603
- if (existsSync3(bunLockPath)) {
4617
+ if (existsSync5(bunLockPath)) {
4604
4618
  discovery.isBun = true;
4605
4619
  log.debug("Detected Bun project (bun.lockb found)");
4606
4620
  }
4607
4621
  const vscodeDir = resolve(targetPath, ".vscode");
4608
4622
  const cursorDir = resolve(targetPath, ".cursor");
4609
4623
  const ideaDir = resolve(targetPath, ".idea");
4610
- if (existsSync3(cursorDir)) {
4624
+ if (existsSync5(cursorDir)) {
4611
4625
  discovery.detectedIde = "cursor";
4612
4626
  log.debug("Detected Cursor (.cursor directory found)");
4613
- } else if (existsSync3(vscodeDir)) {
4627
+ } else if (existsSync5(vscodeDir)) {
4614
4628
  discovery.detectedIde = "code";
4615
4629
  log.debug("Detected VS Code (.vscode directory found)");
4616
- } else if (existsSync3(ideaDir)) {
4630
+ } else if (existsSync5(ideaDir)) {
4617
4631
  discovery.detectedIde = "idea";
4618
4632
  log.debug("Detected IntelliJ IDEA (.idea directory found)");
4619
4633
  }
4620
4634
  const claudeMdPath = resolve(targetPath, "CLAUDE.md");
4621
- if (existsSync3(claudeMdPath)) {
4635
+ if (existsSync5(claudeMdPath)) {
4622
4636
  discovery.hasClaude = true;
4623
4637
  log.debug("Detected Claude Code project (CLAUDE.md found)");
4624
4638
  }
@@ -4914,7 +4928,7 @@ function findPackageJson() {
4914
4928
  join2(process.cwd(), "package.json")
4915
4929
  ];
4916
4930
  for (const p of paths) {
4917
- if (existsSync4(p)) {
4931
+ if (existsSync6(p)) {
4918
4932
  return p;
4919
4933
  }
4920
4934
  }