@claude-sync/cli 0.1.11 → 0.1.12

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.
@@ -5166,7 +5166,7 @@ __export(sync_exports, {
5166
5166
  });
5167
5167
  import { Command as Command4 } from "commander";
5168
5168
  import { select as select2, isCancel as isCancel3 } from "@clack/prompts";
5169
- import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, lstat as lstat2, symlink, unlink } from "fs/promises";
5169
+ import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, lstat as lstat2, symlink, unlink, rename } from "fs/promises";
5170
5170
  import { join as join3, dirname as dirname2 } from "path";
5171
5171
  import { homedir as homedir4 } from "os";
5172
5172
  async function runSync(options) {
@@ -5330,6 +5330,10 @@ async function handleFirstRun(client, config, cwd, ctx, manifest, projectDir, pr
5330
5330
  });
5331
5331
  if (isCancel3(projectChoice)) return "cancelled";
5332
5332
  const selectedProject = projects.find((p) => p.id === projectChoice);
5333
+ const existingCheck = await handleExistingSessionDir(projectsDir, ctx.encodedPath);
5334
+ if (existingCheck === "cancelled") {
5335
+ return "cancelled";
5336
+ }
5333
5337
  const downloaded = await crossMachinePull(
5334
5338
  client,
5335
5339
  config.deviceId,
@@ -5356,6 +5360,43 @@ async function handleFirstRun(client, config, cwd, ctx, manifest, projectDir, pr
5356
5360
  }
5357
5361
  return "pulled";
5358
5362
  }
5363
+ async function handleExistingSessionDir(projectsDir, localEncoded) {
5364
+ const symlinkPath = join3(projectsDir, localEncoded);
5365
+ try {
5366
+ const stats = await lstat2(symlinkPath);
5367
+ if (stats.isSymbolicLink()) {
5368
+ return "continue";
5369
+ }
5370
+ if (stats.isDirectory()) {
5371
+ printInfo(brand("Local session directory already exists"));
5372
+ printInfo(dim(symlinkPath));
5373
+ const choice = await select2({
5374
+ message: brand("What would you like to do?"),
5375
+ options: [
5376
+ {
5377
+ value: "backup",
5378
+ label: "Backup and continue",
5379
+ hint: dim("Move existing to .bak and sync from remote")
5380
+ },
5381
+ {
5382
+ value: "cancel",
5383
+ label: "Stop sync",
5384
+ hint: dim("Keep existing local sessions")
5385
+ }
5386
+ ]
5387
+ });
5388
+ if (isCancel3(choice) || choice === "cancel") {
5389
+ return "cancelled";
5390
+ }
5391
+ const backupPath = `${symlinkPath}.bak.${Date.now()}`;
5392
+ await rename(symlinkPath, backupPath);
5393
+ printSuccess(`Backed up to: ${dim(backupPath)}`);
5394
+ return "continue";
5395
+ }
5396
+ } catch {
5397
+ }
5398
+ return "continue";
5399
+ }
5359
5400
  async function createProjectSymlink(projectsDir, localEncoded, foreignEncoded) {
5360
5401
  const symlinkPath = join3(projectsDir, localEncoded);
5361
5402
  await mkdir2(projectsDir, { recursive: true });
@@ -5363,10 +5404,6 @@ async function createProjectSymlink(projectsDir, localEncoded, foreignEncoded) {
5363
5404
  const stats = await lstat2(symlinkPath);
5364
5405
  if (stats.isSymbolicLink()) {
5365
5406
  await unlink(symlinkPath);
5366
- } else if (stats.isDirectory()) {
5367
- printError(`Local session directory already exists. Back it up first:
5368
- mv "${symlinkPath}" "${symlinkPath}.bak"`);
5369
- return;
5370
5407
  }
5371
5408
  } catch {
5372
5409
  }