@claude-sync/cli 0.1.3 → 0.1.5

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/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -37,10 +38,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
37
38
  mod
38
39
  ));
39
40
 
41
+ // ../../node_modules/tsup/assets/esm_shims.js
42
+ import path from "path";
43
+ import { fileURLToPath } from "url";
44
+ var init_esm_shims = __esm({
45
+ "../../node_modules/tsup/assets/esm_shims.js"() {
46
+ "use strict";
47
+ }
48
+ });
49
+
40
50
  // ../../packages/utils/dist/path-encoding.js
41
51
  var require_path_encoding = __commonJS({
42
52
  "../../packages/utils/dist/path-encoding.js"(exports) {
43
53
  "use strict";
54
+ init_esm_shims();
44
55
  Object.defineProperty(exports, "__esModule", { value: true });
45
56
  exports.ROOT_PATTERN = void 0;
46
57
  exports.encodePath = encodePath3;
@@ -77,6 +88,7 @@ var require_path_encoding = __commonJS({
77
88
  var require_manifest = __commonJS({
78
89
  "../../packages/utils/dist/manifest.js"(exports) {
79
90
  "use strict";
91
+ init_esm_shims();
80
92
  Object.defineProperty(exports, "__esModule", { value: true });
81
93
  exports.hashFile = hashFile2;
82
94
  exports.hashManifest = hashManifest;
@@ -120,6 +132,7 @@ var require_manifest = __commonJS({
120
132
  var require_constants = __commonJS({
121
133
  "../../packages/utils/dist/constants.js"(exports) {
122
134
  "use strict";
135
+ init_esm_shims();
123
136
  Object.defineProperty(exports, "__esModule", { value: true });
124
137
  exports.PROJECTS_DIR = exports.CLAUDE_DIR = exports.MANIFEST_FILE = exports.CONFIG_FILE = exports.CONFIG_DIR = exports.API_VERSION = exports.BUCKET_MANIFESTS = exports.BUCKET_DATA = exports.SYNC_EXCLUDE_PATTERNS = void 0;
125
138
  exports.SYNC_EXCLUDE_PATTERNS = [
@@ -148,6 +161,7 @@ var require_constants = __commonJS({
148
161
  var require_util = __commonJS({
149
162
  "../../node_modules/zod/v3/helpers/util.cjs"(exports) {
150
163
  "use strict";
164
+ init_esm_shims();
151
165
  Object.defineProperty(exports, "__esModule", { value: true });
152
166
  exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0;
153
167
  var util;
@@ -290,6 +304,7 @@ var require_util = __commonJS({
290
304
  var require_ZodError = __commonJS({
291
305
  "../../node_modules/zod/v3/ZodError.cjs"(exports) {
292
306
  "use strict";
307
+ init_esm_shims();
293
308
  Object.defineProperty(exports, "__esModule", { value: true });
294
309
  exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
295
310
  var util_js_1 = require_util();
@@ -418,6 +433,7 @@ var require_ZodError = __commonJS({
418
433
  var require_en = __commonJS({
419
434
  "../../node_modules/zod/v3/locales/en.cjs"(exports) {
420
435
  "use strict";
436
+ init_esm_shims();
421
437
  Object.defineProperty(exports, "__esModule", { value: true });
422
438
  var ZodError_js_1 = require_ZodError();
423
439
  var util_js_1 = require_util();
@@ -529,6 +545,7 @@ var require_en = __commonJS({
529
545
  var require_errors = __commonJS({
530
546
  "../../node_modules/zod/v3/errors.cjs"(exports) {
531
547
  "use strict";
548
+ init_esm_shims();
532
549
  var __importDefault = exports && exports.__importDefault || function(mod) {
533
550
  return mod && mod.__esModule ? mod : { "default": mod };
534
551
  };
@@ -552,6 +569,7 @@ var require_errors = __commonJS({
552
569
  var require_parseUtil = __commonJS({
553
570
  "../../node_modules/zod/v3/helpers/parseUtil.cjs"(exports) {
554
571
  "use strict";
572
+ init_esm_shims();
555
573
  var __importDefault = exports && exports.__importDefault || function(mod) {
556
574
  return mod && mod.__esModule ? mod : { "default": mod };
557
575
  };
@@ -561,8 +579,8 @@ var require_parseUtil = __commonJS({
561
579
  var errors_js_1 = require_errors();
562
580
  var en_js_1 = __importDefault(require_en());
563
581
  var makeIssue = (params) => {
564
- const { data, path, errorMaps, issueData } = params;
565
- const fullPath = [...path, ...issueData.path || []];
582
+ const { data, path: path2, errorMaps, issueData } = params;
583
+ const fullPath = [...path2, ...issueData.path || []];
566
584
  const fullIssue = {
567
585
  ...issueData,
568
586
  path: fullPath
@@ -683,6 +701,7 @@ var require_parseUtil = __commonJS({
683
701
  var require_typeAliases = __commonJS({
684
702
  "../../node_modules/zod/v3/helpers/typeAliases.cjs"(exports) {
685
703
  "use strict";
704
+ init_esm_shims();
686
705
  Object.defineProperty(exports, "__esModule", { value: true });
687
706
  }
688
707
  });
@@ -691,6 +710,7 @@ var require_typeAliases = __commonJS({
691
710
  var require_errorUtil = __commonJS({
692
711
  "../../node_modules/zod/v3/helpers/errorUtil.cjs"(exports) {
693
712
  "use strict";
713
+ init_esm_shims();
694
714
  Object.defineProperty(exports, "__esModule", { value: true });
695
715
  exports.errorUtil = void 0;
696
716
  var errorUtil;
@@ -705,6 +725,7 @@ var require_errorUtil = __commonJS({
705
725
  var require_types = __commonJS({
706
726
  "../../node_modules/zod/v3/types.cjs"(exports) {
707
727
  "use strict";
728
+ init_esm_shims();
708
729
  Object.defineProperty(exports, "__esModule", { value: true });
709
730
  exports.discriminatedUnion = exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;
710
731
  exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = void 0;
@@ -716,11 +737,11 @@ var require_types = __commonJS({
716
737
  var parseUtil_js_1 = require_parseUtil();
717
738
  var util_js_1 = require_util();
718
739
  var ParseInputLazyPath = class {
719
- constructor(parent, value, path, key) {
740
+ constructor(parent, value, path2, key) {
720
741
  this._cachedPath = [];
721
742
  this.parent = parent;
722
743
  this.data = value;
723
- this._path = path;
744
+ this._path = path2;
724
745
  this._key = key;
725
746
  }
726
747
  get path() {
@@ -4247,6 +4268,7 @@ var require_types = __commonJS({
4247
4268
  var require_external = __commonJS({
4248
4269
  "../../node_modules/zod/v3/external.cjs"(exports) {
4249
4270
  "use strict";
4271
+ init_esm_shims();
4250
4272
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
4251
4273
  if (k2 === void 0) k2 = k;
4252
4274
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -4277,6 +4299,7 @@ var require_external = __commonJS({
4277
4299
  var require_zod = __commonJS({
4278
4300
  "../../node_modules/zod/index.cjs"(exports) {
4279
4301
  "use strict";
4302
+ init_esm_shims();
4280
4303
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
4281
4304
  if (k2 === void 0) k2 = k;
4282
4305
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -4320,6 +4343,7 @@ var require_zod = __commonJS({
4320
4343
  var require_validation = __commonJS({
4321
4344
  "../../packages/utils/dist/validation.js"(exports) {
4322
4345
  "use strict";
4346
+ init_esm_shims();
4323
4347
  Object.defineProperty(exports, "__esModule", { value: true });
4324
4348
  exports.updateProfileSchema = exports.refreshTokenSchema = exports.syncCompleteSchema = exports.downloadUrlSchema = exports.uploadUrlSchema = exports.pullRequestSchema = exports.pushManifestSchema = exports.updateDeviceSchema = exports.createDeviceSchema = exports.registerSchema = exports.loginSchema = void 0;
4325
4349
  var zod_1 = require_zod();
@@ -4394,6 +4418,7 @@ var require_validation = __commonJS({
4394
4418
  var require_dist = __commonJS({
4395
4419
  "../../packages/utils/dist/index.js"(exports) {
4396
4420
  "use strict";
4421
+ init_esm_shims();
4397
4422
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
4398
4423
  if (k2 === void 0) k2 = k;
4399
4424
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -4484,6 +4509,7 @@ var import_utils, DEFAULT_CONFIG;
4484
4509
  var init_config = __esm({
4485
4510
  "src/lib/config.ts"() {
4486
4511
  "use strict";
4512
+ init_esm_shims();
4487
4513
  import_utils = __toESM(require_dist(), 1);
4488
4514
  DEFAULT_CONFIG = {
4489
4515
  apiUrl: "https://api.claude-sync.com",
@@ -4502,18 +4528,19 @@ var ApiClient;
4502
4528
  var init_api_client = __esm({
4503
4529
  "src/lib/api-client.ts"() {
4504
4530
  "use strict";
4531
+ init_esm_shims();
4505
4532
  init_auth();
4506
4533
  ApiClient = class {
4507
4534
  baseUrl;
4508
4535
  constructor(baseUrl) {
4509
4536
  this.baseUrl = baseUrl.replace(/\/$/, "");
4510
4537
  }
4511
- async rawRequest(path, options = {}) {
4538
+ async rawRequest(path2, options = {}) {
4512
4539
  const controller = new AbortController();
4513
4540
  const timeout = setTimeout(() => controller.abort(), 15e3);
4514
4541
  let response;
4515
4542
  try {
4516
- response = await fetch(`${this.baseUrl}${path}`, {
4543
+ response = await fetch(`${this.baseUrl}${path2}`, {
4517
4544
  ...options,
4518
4545
  signal: controller.signal
4519
4546
  });
@@ -4539,7 +4566,7 @@ var init_api_client = __esm({
4539
4566
  const json = await response.json();
4540
4567
  return json.data !== void 0 ? json.data : json;
4541
4568
  }
4542
- async request(path, options = {}) {
4569
+ async request(path2, options = {}) {
4543
4570
  const token = await getValidToken();
4544
4571
  const headers = {
4545
4572
  "Content-Type": "application/json",
@@ -4548,32 +4575,32 @@ var init_api_client = __esm({
4548
4575
  if (token) {
4549
4576
  headers["Authorization"] = `Bearer ${token}`;
4550
4577
  }
4551
- return this.rawRequest(path, { ...options, headers });
4578
+ return this.rawRequest(path2, { ...options, headers });
4552
4579
  }
4553
- async requestNoAuth(path, options = {}) {
4580
+ async requestNoAuth(path2, options = {}) {
4554
4581
  const headers = {
4555
4582
  "Content-Type": "application/json",
4556
4583
  ...options.headers
4557
4584
  };
4558
- return this.rawRequest(path, { ...options, headers });
4585
+ return this.rawRequest(path2, { ...options, headers });
4559
4586
  }
4560
- async get(path) {
4561
- return this.request(path, { method: "GET" });
4587
+ async get(path2) {
4588
+ return this.request(path2, { method: "GET" });
4562
4589
  }
4563
- async post(path, body) {
4564
- return this.request(path, {
4590
+ async post(path2, body) {
4591
+ return this.request(path2, {
4565
4592
  method: "POST",
4566
4593
  body: body ? JSON.stringify(body) : void 0
4567
4594
  });
4568
4595
  }
4569
- async patch(path, body) {
4570
- return this.request(path, {
4596
+ async patch(path2, body) {
4597
+ return this.request(path2, {
4571
4598
  method: "PATCH",
4572
4599
  body: body ? JSON.stringify(body) : void 0
4573
4600
  });
4574
4601
  }
4575
- async delete(path) {
4576
- return this.request(path, { method: "DELETE" });
4602
+ async delete(path2) {
4603
+ return this.request(path2, { method: "DELETE" });
4577
4604
  }
4578
4605
  };
4579
4606
  }
@@ -4623,6 +4650,7 @@ async function getValidToken() {
4623
4650
  var init_auth = __esm({
4624
4651
  "src/lib/auth.ts"() {
4625
4652
  "use strict";
4653
+ init_esm_shims();
4626
4654
  init_config();
4627
4655
  init_api_client();
4628
4656
  }
@@ -4631,8 +4659,8 @@ var init_auth = __esm({
4631
4659
  // src/lib/progress.ts
4632
4660
  import ora from "ora";
4633
4661
  import chalk from "chalk";
4634
- function createSpinner(text3) {
4635
- return ora({ text: brandColor(text3), spinner: "dots", color: "magenta" });
4662
+ function createSpinner(text4) {
4663
+ return ora({ text: brandColor(text4), spinner: "dots", color: "magenta" });
4636
4664
  }
4637
4665
  function formatBytes(bytes) {
4638
4666
  if (bytes === 0) return "0 B";
@@ -4649,6 +4677,7 @@ var brandColor;
4649
4677
  var init_progress = __esm({
4650
4678
  "src/lib/progress.ts"() {
4651
4679
  "use strict";
4680
+ init_esm_shims();
4652
4681
  brandColor = chalk.hex("#8a8cdd");
4653
4682
  }
4654
4683
  });
@@ -4689,6 +4718,7 @@ var BRAND_HEX, BRAND_DIM_HEX, SUCCESS_HEX, WARN_HEX, ERROR_HEX, brand, brandBold
4689
4718
  var init_theme = __esm({
4690
4719
  "src/lib/theme.ts"() {
4691
4720
  "use strict";
4721
+ init_esm_shims();
4692
4722
  BRAND_HEX = "#8a8cdd";
4693
4723
  BRAND_DIM_HEX = "#6b6db8";
4694
4724
  SUCCESS_HEX = "#8adda0";
@@ -4806,6 +4836,7 @@ function loginCommand() {
4806
4836
  var init_login = __esm({
4807
4837
  "src/commands/login.ts"() {
4808
4838
  "use strict";
4839
+ init_esm_shims();
4809
4840
  init_config();
4810
4841
  init_auth();
4811
4842
  init_api_client();
@@ -4844,6 +4875,7 @@ function logoutCommand() {
4844
4875
  var init_logout = __esm({
4845
4876
  "src/commands/logout.ts"() {
4846
4877
  "use strict";
4878
+ init_esm_shims();
4847
4879
  init_config();
4848
4880
  init_api_client();
4849
4881
  init_theme();
@@ -4969,6 +5001,7 @@ function deviceCommand() {
4969
5001
  var init_device = __esm({
4970
5002
  "src/commands/device.ts"() {
4971
5003
  "use strict";
5004
+ init_esm_shims();
4972
5005
  init_config();
4973
5006
  init_api_client();
4974
5007
  init_progress();
@@ -5057,6 +5090,7 @@ var import_utils2;
5057
5090
  var init_sync_engine = __esm({
5058
5091
  "src/lib/sync-engine.ts"() {
5059
5092
  "use strict";
5093
+ init_esm_shims();
5060
5094
  import_utils2 = __toESM(require_dist(), 1);
5061
5095
  }
5062
5096
  });
@@ -5088,6 +5122,7 @@ function decompressBuffer(data) {
5088
5122
  var init_compress = __esm({
5089
5123
  "src/lib/compress.ts"() {
5090
5124
  "use strict";
5125
+ init_esm_shims();
5091
5126
  }
5092
5127
  });
5093
5128
 
@@ -5492,6 +5527,7 @@ var import_utils3;
5492
5527
  var init_sync = __esm({
5493
5528
  "src/commands/sync.ts"() {
5494
5529
  "use strict";
5530
+ init_esm_shims();
5495
5531
  init_config();
5496
5532
  init_api_client();
5497
5533
  init_sync_engine();
@@ -5537,6 +5573,7 @@ function statusCommand() {
5537
5573
  var init_status = __esm({
5538
5574
  "src/commands/status.ts"() {
5539
5575
  "use strict";
5576
+ init_esm_shims();
5540
5577
  init_config();
5541
5578
  init_sync_engine();
5542
5579
  init_progress();
@@ -5579,6 +5616,7 @@ function whoamiCommand() {
5579
5616
  var init_whoami = __esm({
5580
5617
  "src/commands/whoami.ts"() {
5581
5618
  "use strict";
5619
+ init_esm_shims();
5582
5620
  init_config();
5583
5621
  init_api_client();
5584
5622
  init_progress();
@@ -5587,6 +5625,7 @@ var init_whoami = __esm({
5587
5625
  });
5588
5626
 
5589
5627
  // src/index.ts
5628
+ init_esm_shims();
5590
5629
  init_login();
5591
5630
  init_logout();
5592
5631
  init_device();
@@ -5596,9 +5635,11 @@ init_whoami();
5596
5635
  import { Command as Command7 } from "commander";
5597
5636
 
5598
5637
  // src/commands/tui.ts
5638
+ init_esm_shims();
5599
5639
  init_theme();
5600
5640
  init_config();
5601
- import { select as select3, isCancel as isCancel4 } from "@clack/prompts";
5641
+ init_api_client();
5642
+ import { select as select3, text as text3, isCancel as isCancel4 } from "@clack/prompts";
5602
5643
  import chalk3 from "chalk";
5603
5644
  function buildMenu(loggedIn) {
5604
5645
  if (!loggedIn) {
@@ -5653,6 +5694,30 @@ async function runTui() {
5653
5694
  console.log();
5654
5695
  }
5655
5696
  }
5697
+ async function promptDeviceSelection(config) {
5698
+ const client = new ApiClient(config.apiUrl);
5699
+ let devices;
5700
+ try {
5701
+ devices = await client.get("/api/devices");
5702
+ } catch {
5703
+ printError("Failed to fetch devices.");
5704
+ return null;
5705
+ }
5706
+ if (devices.length === 0) {
5707
+ printError("No devices registered.");
5708
+ return null;
5709
+ }
5710
+ const choice = await select3({
5711
+ message: brand("Select device"),
5712
+ options: devices.map((d) => ({
5713
+ value: d.id,
5714
+ label: d.name,
5715
+ hint: d.id === config.deviceId ? dim("current") : void 0
5716
+ }))
5717
+ });
5718
+ if (isCancel4(choice)) return null;
5719
+ return choice;
5720
+ }
5656
5721
  async function executeCommand(command) {
5657
5722
  const { loginCommand: loginCommand2 } = await Promise.resolve().then(() => (init_login(), login_exports));
5658
5723
  const { logoutCommand: logoutCommand2 } = await Promise.resolve().then(() => (init_logout(), logout_exports));
@@ -5660,16 +5725,25 @@ async function executeCommand(command) {
5660
5725
  const { syncCommand: syncCommand2 } = await Promise.resolve().then(() => (init_sync(), sync_exports));
5661
5726
  const { statusCommand: statusCommand2 } = await Promise.resolve().then(() => (init_status(), status_exports));
5662
5727
  const { whoamiCommand: whoamiCommand2 } = await Promise.resolve().then(() => (init_whoami(), whoami_exports));
5728
+ const config = await loadConfig();
5663
5729
  const handlers = {
5664
- login: () => loginCommand2().parseAsync(["", "", "login"]),
5665
- logout: () => logoutCommand2().parseAsync(["", "", "logout"]),
5666
- sync: () => syncCommand2().parseAsync(["", "", "sync"]),
5667
- status: () => statusCommand2().parseAsync(["", "", "status"]),
5668
- whoami: () => whoamiCommand2().parseAsync(["", "", "whoami"]),
5669
- "device:add": () => deviceCommand2().parseAsync(["", "", "device", "add"]),
5670
- "device:list": () => deviceCommand2().parseAsync(["", "", "device", "list"]),
5671
- "device:remove": () => deviceCommand2().parseAsync(["", "", "device", "remove"]),
5672
- "device:rename": () => deviceCommand2().parseAsync(["", "", "device", "rename"])
5730
+ login: () => loginCommand2().parseAsync(["", ""]),
5731
+ logout: () => logoutCommand2().parseAsync(["", ""]),
5732
+ sync: () => syncCommand2().parseAsync(["", ""]),
5733
+ status: () => statusCommand2().parseAsync(["", ""]),
5734
+ whoami: () => whoamiCommand2().parseAsync(["", ""]),
5735
+ "device:add": () => deviceCommand2().parseAsync(["", "", "add"]),
5736
+ "device:list": () => deviceCommand2().parseAsync(["", "", "list"]),
5737
+ "device:remove": async () => {
5738
+ const deviceId = await promptDeviceSelection(config);
5739
+ if (!deviceId) return;
5740
+ await deviceCommand2().parseAsync(["", "", "remove", deviceId]);
5741
+ },
5742
+ "device:rename": async () => {
5743
+ const name = await text3({ message: `${brand("New device name")}:` });
5744
+ if (isCancel4(name)) return;
5745
+ await deviceCommand2().parseAsync(["", "", "rename", name]);
5746
+ }
5673
5747
  };
5674
5748
  const handler = handlers[command];
5675
5749
  if (handler) {